drivers/staging/media/atomisp/pci/sh_css_param_shading.c
Source file repositories/reference/linux-study-clean/drivers/staging/media/atomisp/pci/sh_css_param_shading.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/staging/media/atomisp/pci/sh_css_param_shading.c- Extension
.c- Size
- 11044 bytes
- Lines
- 392
- 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.
- 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.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/overflow.hlinux/math.hlinux/slab.hmath_support.hsh_css_param_shading.hia_css_shading.hassert_support.hsh_css_defs.hsh_css_internal.hia_css_debug.hia_css_pipe_binarydesc.hsh_css_hrt.hplatform_support.h
Detected Declarations
function Copyrightfunction sh_css_params_shading_id_table_generatefunction prepare_shading_tablefunction ia_css_shading_table_allocfunction ia_css_shading_table_free
Annotated Snippet
if (divy == 0) {
dy0 = 1;
divy = 1;
}
for (j = 0; j < out_table->width; j++, out_ptr++) {
int tx, src_x0, src_x1;
unsigned int sx0, sx1, dx0, dx1, divx;
unsigned short s_ul, s_ur, s_ll, s_lr;
/* calculate target point */
tx = out_start_col + j * out_cell_size;
/* calculate closest source points. */
src_x0 = tx / (int)in_cell_size;
if (in_cell_size < out_cell_size) {
src_x1 = (tx + out_cell_size) /
(int)in_cell_size;
} else {
src_x1 = src_x0 + 1;
}
/* if src points fall in padding, select closest ones.*/
src_x0 = clamp(src_x0, 0, (int)table_width - 1);
src_x1 = clamp(src_x1, 0, (int)table_width - 1);
tx = min(clamp(tx, 0, (int)sensor_width - 1),
(int)table_cell_w);
/*
* calculate closest source points for distance
* computation
*/
sx0 = min(src_x0 * in_cell_size, sensor_width - 1);
sx1 = min(src_x1 * in_cell_size, sensor_width - 1);
/*
* calculate distances between source and target
* pixels
*/
dx0 = tx - sx0;
dx1 = sx1 - tx;
divx = sx1 - sx0;
/*
* if we're at the edge, we just use the closest
* point still in the grid. We make up for the divider
* in this case by setting the distance to
* out_cell_size, since it's actually 0.
*/
if (divx == 0) {
dx0 = 1;
divx = 1;
}
/* get source pixel values */
s_ul = in_ptr[(table_width * src_y0) + src_x0];
s_ur = in_ptr[(table_width * src_y0) + src_x1];
s_ll = in_ptr[(table_width * src_y1) + src_x0];
s_lr = in_ptr[(table_width * src_y1) + src_x1];
*out_ptr = (unsigned short)((dx0 * dy0 * s_lr + dx0 * dy1 * s_ur + dx1 * dy0 *
s_ll + dx1 * dy1 * s_ul) /
(divx * divy));
}
}
}
void
sh_css_params_shading_id_table_generate(
struct ia_css_shading_table **target_table,
unsigned int table_width,
unsigned int table_height)
{
/* initialize table with ones, shift becomes zero */
unsigned int i, j;
struct ia_css_shading_table *result;
assert(target_table);
result = ia_css_shading_table_alloc(table_width, table_height);
if (!result) {
*target_table = NULL;
return;
}
for (i = 0; i < IA_CSS_SC_NUM_COLORS; i++) {
for (j = 0; j < table_height * table_width; j++)
result->data[i][j] = 1;
}
result->fraction_bits = 0;
*target_table = result;
}
void
prepare_shading_table(const struct ia_css_shading_table *in_table,
Annotation
- Immediate include surface: `linux/overflow.h`, `linux/math.h`, `linux/slab.h`, `math_support.h`, `sh_css_param_shading.h`, `ia_css_shading.h`, `assert_support.h`, `sh_css_defs.h`.
- Detected declarations: `function Copyright`, `function sh_css_params_shading_id_table_generate`, `function prepare_shading_table`, `function ia_css_shading_table_alloc`, `function ia_css_shading_table_free`.
- Atlas domain: Driver Families / drivers/staging.
- Implementation status: source implementation candidate.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.