drivers/gpu/drm/amd/display/modules/color/color_gamma.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/amd/display/modules/color/color_gamma.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/amd/display/modules/color/color_gamma.c- Extension
.c- Size
- 56699 bytes
- Lines
- 2009
- Domain
- Driver Families
- Bucket
- drivers/gpu
- 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
dc.hopp.hcolor_gamma.h
Detected Declarations
struct dividersfunction setup_x_points_distributionfunction log_x_points_distributionfunction compute_pqfunction compute_de_pqfunction compute_hlg_eotffunction compute_hlg_oetffunction precompute_pqfunction precompute_de_pqfunction build_coefficientsfunction translate_from_linear_spacefunction translate_from_linear_space_longfunction calculate_gamma22function translate_to_linear_spacefunction translate_from_linear_space_exfunction translate_to_linear_space_exfunction find_software_pointsfunction dc_fixpt_lefunction dc_fixpt_lefunction build_custom_gamma_mapping_coefficients_workerfunction calculate_mapped_valuefunction build_pqfunction build_de_pqfunction build_regammafunction hermite_spline_eetffunction build_freesync_hdrfunction build_degammafunction build_hlg_degammafunction build_hlg_regammafunction scale_gammafunction scale_gamma_dxfunction apply_lut_1dfunction build_evenly_distributed_pointsfunction copy_rgb_regamma_to_coordinates_xfunction calculate_interpolated_hardware_curvefunction build_new_custom_resulted_curvefunction map_regamma_hw_to_x_userfunction mod_color_calculate_degamma_paramsfunction calculate_curvefunction mod_color_calculate_regamma_params
Annotated Snippet
struct dividers {
struct fixed31_32 divider1;
struct fixed31_32 divider2;
struct fixed31_32 divider3;
};
static bool build_coefficients(struct gamma_coefficients *coefficients,
enum dc_transfer_func_predefined type)
{
uint32_t i = 0;
uint32_t index = 0;
bool ret = true;
if (type == TRANSFER_FUNCTION_SRGB)
index = 0;
else if (type == TRANSFER_FUNCTION_BT709)
index = 1;
else if (type == TRANSFER_FUNCTION_GAMMA22)
index = 2;
else if (type == TRANSFER_FUNCTION_GAMMA24)
index = 3;
else if (type == TRANSFER_FUNCTION_GAMMA26)
index = 4;
else {
ret = false;
goto release;
}
do {
coefficients->a0[i] = dc_fixpt_from_fraction(
numerator01[index], 10000000);
coefficients->a1[i] = dc_fixpt_from_fraction(
numerator02[index], 1000);
coefficients->a2[i] = dc_fixpt_from_fraction(
numerator03[index], 1000);
coefficients->a3[i] = dc_fixpt_from_fraction(
numerator04[index], 1000);
coefficients->user_gamma[i] = dc_fixpt_from_fraction(
numerator05[index], 1000);
++i;
} while (i != ARRAY_SIZE(coefficients->a0));
release:
return ret;
}
static struct fixed31_32 translate_from_linear_space(
struct translate_from_linear_space_args *args)
{
const struct fixed31_32 one = dc_fixpt_from_int(1);
struct fixed31_32 scratch_1, scratch_2;
struct calculate_buffer *cal_buffer = args->cal_buffer;
if (dc_fixpt_le(one, args->arg))
return one;
if (dc_fixpt_le(args->arg, dc_fixpt_neg(args->a0))) {
scratch_1 = dc_fixpt_add(one, args->a3);
scratch_2 = dc_fixpt_pow(
dc_fixpt_neg(args->arg),
dc_fixpt_recip(args->gamma));
scratch_1 = dc_fixpt_mul(scratch_1, scratch_2);
scratch_1 = dc_fixpt_sub(args->a2, scratch_1);
return scratch_1;
} else if (dc_fixpt_le(args->a0, args->arg)) {
if (cal_buffer->buffer_index == 0) {
cal_buffer->gamma_of_2 = dc_fixpt_pow(dc_fixpt_from_int(2),
dc_fixpt_recip(args->gamma));
}
scratch_1 = dc_fixpt_add(one, args->a3);
/* In the first region (first 16 points) and in the
* region delimited by START/END we calculate with
* full precision to avoid error accumulation.
*/
if ((cal_buffer->buffer_index >= PRECISE_LUT_REGION_START &&
cal_buffer->buffer_index <= PRECISE_LUT_REGION_END) ||
(cal_buffer->buffer_index < 16))
scratch_2 = dc_fixpt_pow(args->arg,
dc_fixpt_recip(args->gamma));
else
scratch_2 = dc_fixpt_mul(cal_buffer->gamma_of_2,
cal_buffer->buffer[cal_buffer->buffer_index%16]);
if (cal_buffer->buffer_index != -1) {
cal_buffer->buffer[cal_buffer->buffer_index%16] = scratch_2;
cal_buffer->buffer_index++;
Annotation
- Immediate include surface: `dc.h`, `opp.h`, `color_gamma.h`.
- Detected declarations: `struct dividers`, `function setup_x_points_distribution`, `function log_x_points_distribution`, `function compute_pq`, `function compute_de_pq`, `function compute_hlg_eotf`, `function compute_hlg_oetf`, `function precompute_pq`, `function precompute_de_pq`, `function build_coefficients`.
- Atlas domain: Driver Families / drivers/gpu.
- 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.