drivers/staging/media/atomisp/pci/isp/kernels/bnlm/ia_css_bnlm.host.c

Source file repositories/reference/linux-study-clean/drivers/staging/media/atomisp/pci/isp/kernels/bnlm/ia_css_bnlm.host.c

File Facts

System
Linux kernel
Corpus path
drivers/staging/media/atomisp/pci/isp/kernels/bnlm/ia_css_bnlm.host.c
Extension
.c
Size
6145 bytes
Lines
187
Domain
Driver Families
Bucket
drivers/staging
Inferred role
Driver Families: implementation source
Status
source implementation candidate

Why This File Exists

Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.

Dependency Surface

Detected Declarations

Annotated Snippet

// SPDX-License-Identifier: GPL-2.0
/*
 * Support for Intel Camera Imaging ISP subsystem.
 * Copyright (c) 2015, Intel Corporation.
 */

#include "type_support.h"
#include "ia_css_bnlm.host.h"

#ifndef IA_CSS_NO_DEBUG
#include "ia_css_debug.h" /* ia_css_debug_dtrace() */
#endif
#include <assert_support.h>

#define BNLM_DIV_LUT_SIZE	(12)
static const s32 div_lut_nearests[BNLM_DIV_LUT_SIZE] = {
	0, 454, 948, 1484, 2070, 2710, 3412, 4184, 5035, 5978, 7025, 8191
};

static const s32 div_lut_slopes[BNLM_DIV_LUT_SIZE] = {
	-7760, -6960, -6216, -5536, -4912, -4344, -3832, -3360, -2936, -2552, -2208, -2208
    };

static const s32 div_lut_intercepts[BNLM_DIV_LUT_SIZE] = {
	8184, 7752, 7336, 6928, 6536, 6152, 5776, 5416, 5064, 4728, 4408, 4408
};

/* Encodes a look-up table from BNLM public parameters to vmem parameters.
 * Input:
 *	lut	:	bnlm_lut struct containing encoded vmem parameters look-up table
 *	lut_thr	:	array containing threshold values for lut
 *	lut_val	:	array containing output values related to lut_thr
 *	lut_size:	Size of lut_val array
 */
static inline void
bnlm_lut_encode(struct bnlm_lut *lut, const int32_t *lut_thr,
		const s32 *lut_val, const uint32_t lut_size)
{
	u32 blk, i;
	const u32 block_size = 16;
	const u32 total_blocks = ISP_VEC_NELEMS / block_size;

	/* Create VMEM LUTs from the threshold and value arrays.
	 *
	 * Min size of the LUT is 2 entries.
	 *
	 * Max size of the LUT is 16 entries, so that the LUT can fit into a
	 * single group of 16 elements inside a vector.
	 * Then these elements are copied into other groups inside the same
	 * vector. If the LUT size is less than 16, then remaining elements are
	 * set to 0.
	 */
	assert((lut_size >= 2) && (lut_size <= block_size));
	/* array lut_thr has (lut_size-1) entries */
	for (i = 0; i < lut_size - 2; i++) {
		/* Check if the lut_thr is monotonically increasing */
		assert(lut_thr[i] <= lut_thr[i + 1]);
	}

	/* Initialize */
	for (i = 0; i < total_blocks * block_size; i++) {
		lut->thr[0][i] = 0;
		lut->val[0][i] = 0;
	}

	/* Copy all data */
	for (i = 0; i < lut_size - 1; i++) {
		lut->thr[0][i] = lut_thr[i];
		lut->val[0][i] = lut_val[i];
	}
	lut->val[0][i] = lut_val[i]; /* val has one more element than thr */

	/* Copy data from first block to all blocks */
	for (blk = 1; blk < total_blocks; blk++) {
		u32 blk_offset = blk * block_size;

		for (i = 1; i < lut_size; i++) {
			lut->thr[0][blk_offset + i] = lut->thr[0][i];
			lut->val[0][blk_offset + i] = lut->val[0][i];
		}
	}
}

/*
 * - Encodes BNLM public parameters into VMEM parameters
 * - Generates VMEM parameters which will needed internally ISP
 */
void
ia_css_bnlm_vmem_encode(
    struct bnlm_vmem_params *to,

Annotation

Implementation Notes