drivers/staging/media/atomisp/pci/isp/kernels/s3a/s3a_1.0/ia_css_s3a.host.c

Source file repositories/reference/linux-study-clean/drivers/staging/media/atomisp/pci/isp/kernels/s3a/s3a_1.0/ia_css_s3a.host.c

File Facts

System
Linux kernel
Corpus path
drivers/staging/media/atomisp/pci/isp/kernels/s3a/s3a_1.0/ia_css_s3a.host.c
Extension
.c
Size
9865 bytes
Lines
373
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

if (sum_g != sum_r || sum_b != sum_r || sum_y != sum_r) {
			/* histogram is invalid */
			return;
		}
	}
#endif

	/*
	 * Limit the histogram area only to 3A area.
	 * In DSP, the histogram of 0 is incremented for pixels
	 * which are outside of 3A area. That amount should be subtracted here.
	 *   hist[0] = hist[0] - ((sum of all hist[]) - (pixel count for 3A area))
	 */
	diff = sum_r - count_for_3a;
	out_ptr[0].r -= diff;
	out_ptr[0].g -= diff;
	out_ptr[0].b -= diff;
	out_ptr[0].y -= diff;
}

void
ia_css_s3a_dmem_decode(
    struct ia_css_3a_statistics *host_stats,
    const struct ia_css_3a_output *isp_stats)
{
	int isp_width, host_width, height, i;
	struct ia_css_3a_output *host_ptr;

	assert(host_stats);
	assert(host_stats->data);
	assert(isp_stats);

	isp_width  = host_stats->grid.aligned_width;
	host_width = host_stats->grid.width;
	height     = host_stats->grid.height;
	host_ptr   = host_stats->data;

	/* Getting 3A statistics from DMEM does not involve any
	 * transformation (like the VMEM version), we just copy the data
	 * using a different output width. */
	for (i = 0; i < height; i++) {
		memcpy(host_ptr, isp_stats, host_width * sizeof(*host_ptr));
		isp_stats += isp_width;
		host_ptr += host_width;
	}
}

/* MW: this is an ISP function */
static inline int
merge_hi_lo_14(unsigned short hi, unsigned short lo)
{
	int val = (int)((((unsigned int)hi << 14) & 0xfffc000) |
			((unsigned int)lo & 0x3fff));
	return val;
}

void
ia_css_s3a_vmem_decode(
    struct ia_css_3a_statistics *host_stats,
    const u16 *isp_stats_hi,
    const uint16_t *isp_stats_lo)
{
	int out_width, out_height, chunk, rest, kmax, y, x, k, elm_start, elm, ofs;
	const u16 *hi, *lo;
	struct ia_css_3a_output *output;

	assert(host_stats);
	assert(host_stats->data);
	assert(isp_stats_hi);
	assert(isp_stats_lo);

	output = host_stats->data;
	out_width  = host_stats->grid.width;
	out_height = host_stats->grid.height;
	hi = isp_stats_hi;
	lo = isp_stats_lo;

	chunk = ISP_VEC_NELEMS >> host_stats->grid.deci_factor_log2;
	chunk = max(chunk, 1);

	for (y = 0; y < out_height; y++) {
		elm_start = y * ISP_S3ATBL_HI_LO_STRIDE;
		rest = out_width;
		x = 0;
		while (x < out_width) {
			kmax = (rest > chunk) ? chunk : rest;
			ofs = y * out_width + x;
			elm = elm_start + x * sizeof(*output) / sizeof(int32_t);
			for (k = 0; k < kmax; k++, elm++) {
				output[ofs + k].ae_y    = merge_hi_lo_14(

Annotation

Implementation Notes