drivers/staging/media/atomisp/pci/isp/kernels/ctc/ctc2/ia_css_ctc2.host.c
Source file repositories/reference/linux-study-clean/drivers/staging/media/atomisp/pci/isp/kernels/ctc/ctc2/ia_css_ctc2.host.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/staging/media/atomisp/pci/isp/kernels/ctc/ctc2/ia_css_ctc2.host.c- Extension
.c- Size
- 4504 bytes
- Lines
- 149
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
ia_css_types.hsh_css_defs.hassert_support.hia_css_ctc2.host.h
Detected Declarations
function ctc2_slopefunction ia_css_ctc2_vmem_encodefunction ia_css_ctc2_encode
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0
/*
* Support for Intel Camera Imaging ISP subsystem.
* Copyright (c) 2015, Intel Corporation.
*/
#include "ia_css_types.h"
#include "sh_css_defs.h"
#include "assert_support.h"
#include "ia_css_ctc2.host.h"
#define INEFFECTIVE_VAL 4096
#define BASIC_VAL 819
/*Default configuration of parameters for Ctc2*/
const struct ia_css_ctc2_config default_ctc2_config = {
INEFFECTIVE_VAL, INEFFECTIVE_VAL, INEFFECTIVE_VAL,
INEFFECTIVE_VAL, INEFFECTIVE_VAL, INEFFECTIVE_VAL,
BASIC_VAL * 2, BASIC_VAL * 4, BASIC_VAL * 6,
BASIC_VAL * 8, INEFFECTIVE_VAL, INEFFECTIVE_VAL,
BASIC_VAL >> 1, BASIC_VAL
};
/* (dydx) = ctc2_slope(y1, y0, x1, x0)
* -----------------------------------------------
* Calculation of the Slope of a Line = ((y1 - y0) >> 8)/(x1 - x0)
*
* Note: y1, y0 , x1 & x0 must lie within the range 0 <-> 8191
*/
static int ctc2_slope(int y1, int y0, int x1, int x0)
{
const int shift_val = 8;
const int max_slope = (1 << IA_CSS_CTC_COEF_SHIFT) - 1;
int dy = y1 - y0;
int dx = x1 - x0;
int rounding = (dx + 1) >> 1;
int dy_shift = dy << shift_val;
int slope, dydx;
/*Protection for parameter values, & avoiding zero divisions*/
assert(y0 >= 0 && y0 <= max_slope);
assert(y1 >= 0 && y1 <= max_slope);
assert(x0 >= 0 && x0 <= max_slope);
assert(x1 > 0 && x1 <= max_slope);
assert(dx > 0);
if (dy < 0)
rounding = -rounding;
slope = (int)(dy_shift + rounding) / dx;
/*the slope must lie within the range
(-max_slope-1) >= (dydx) >= (max_slope)
*/
if (slope <= -max_slope - 1)
dydx = -max_slope - 1;
else if (slope >= max_slope)
dydx = max_slope;
else
dydx = slope;
return dydx;
}
/* (void) = ia_css_ctc2_vmem_encode(*to, *from)
* -----------------------------------------------
* VMEM Encode Function to translate Y parameters from userspace into ISP space
*/
void ia_css_ctc2_vmem_encode(struct ia_css_isp_ctc2_vmem_params *to,
const struct ia_css_ctc2_config *from,
size_t size)
{
unsigned int i, j;
const unsigned int shffl_blck = 4;
const unsigned int length_zeros = 11;
short dydx0, dydx1, dydx2, dydx3, dydx4;
(void)size;
/*
* Calculation of slopes of lines interconnecting
* 0.0 -> y_x1 -> y_x2 -> y _x3 -> y_x4 -> 1.0
*/
dydx0 = ctc2_slope(from->y_y1, from->y_y0,
from->y_x1, 0);
dydx1 = ctc2_slope(from->y_y2, from->y_y1,
from->y_x2, from->y_x1);
dydx2 = ctc2_slope(from->y_y3, from->y_y2,
from->y_x3, from->y_x2);
dydx3 = ctc2_slope(from->y_y4, from->y_y3,
from->y_x4, from->y_x3);
Annotation
- Immediate include surface: `ia_css_types.h`, `sh_css_defs.h`, `assert_support.h`, `ia_css_ctc2.host.h`.
- Detected declarations: `function ctc2_slope`, `function ia_css_ctc2_vmem_encode`, `function ia_css_ctc2_encode`.
- 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.