drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_color.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_color.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_color.c- Extension
.c- Size
- 66714 bytes
- Lines
- 2099
- 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.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
drm/drm_colorop.hamdgpu.hamdgpu_mode.hamdgpu_dm.hamdgpu_dm_color.hamdgpu_dm_colorop.hdc.hmodules/color/color_gamma.hamdgpu_dm_kunit_helpers.h
Detected Declarations
function filesfunction amdgpu_dm_fixpt_from_s3132function amdgpu_create_tf_propertyfunction amdgpu_dm_create_color_propertiesfunction __extract_blob_lutfunction __extract_blob_lut32function __is_lut_linearfunction __drm_lut_to_dc_gammafunction __drm_lut32_to_dc_gammafunction __drm_ctm_to_dc_matrixfunction __drm_ctm_3x4_to_dc_matrixfunction __set_legacy_tffunction __set_output_tffunction __set_output_tf_32function __set_tf_bypassfunction __set_tf_distributed_pointsfunction amdgpu_dm_set_atomic_regammafunction __set_input_tffunction __set_input_tf_32function amdgpu_tf_to_dc_tffunction amdgpu_colorop_tf_to_dc_tffunction __to_dc_lut3d_colorfunction __drm_3dlut_to_dc_3dlutfunction __to_dc_lut3d_32_colorfunction __drm_3dlut32_to_dc_3dlutfunction amdgpu_dm_atomic_lut3dfunction amdgpu_dm_atomic_shaper_lutfunction amdgpu_dm_atomic_blend_lutfunction amdgpu_dm_verify_lut3d_sizefunction amdgpu_dm_verify_lut_sizesfunction amdgpu_dm_check_crtc_color_mgmtfunction amdgpu_dm_update_crtc_color_mgmtfunction map_crtc_degamma_to_dc_planefunction __set_dm_plane_degammafunction __set_colorop_in_tf_1d_curvefunction __set_dm_plane_colorop_degammafunction __set_dm_plane_colorop_3x4_matrixfunction __set_dm_plane_colorop_multiplierfunction __set_dm_plane_colorop_shaperfunction __set_colorop_3dlutfunction __set_dm_plane_colorop_3dlutfunction __set_dm_plane_colorop_blendfunction amdgpu_dm_plane_set_color_propertiesfunction amdgpu_dm_plane_set_colorop_propertiesfunction amdgpu_dm_update_plane_color_mgmt
Annotated Snippet
if (i % 4 == 3) {
matrix[i] = dc_fixpt_zero;
continue;
}
/* gamut_remap_matrix[i] = ctm[i - floor(i/4)] */
matrix[i] = amdgpu_dm_fixpt_from_s3132(ctm->matrix[i - (i / 4)]);
}
}
EXPORT_IF_KUNIT(__drm_ctm_to_dc_matrix);
/**
* __drm_ctm_3x4_to_dc_matrix - converts a DRM CTM 3x4 to a DC CSC float matrix
* @ctm: DRM color transformation matrix with 3x4 dimensions
* @matrix: DC CSC float matrix
*
* The matrix needs to be a 3x4 (12 entry) matrix.
*/
STATIC_IFN_KUNIT
void __drm_ctm_3x4_to_dc_matrix(const struct drm_color_ctm_3x4 *ctm,
struct fixed31_32 *matrix)
{
int i;
/* The format provided is S31.32, using signed-magnitude representation.
* Our fixed31_32 is also S31.32, but is using 2's complement. We have
* to convert from signed-magnitude to 2's complement.
*/
for (i = 0; i < 12; i++) {
/* gamut_remap_matrix[i] = ctm[i - floor(i/4)] */
matrix[i] = amdgpu_dm_fixpt_from_s3132(ctm->matrix[i]);
}
}
EXPORT_IF_KUNIT(__drm_ctm_3x4_to_dc_matrix);
/**
* __set_legacy_tf - Calculates the legacy transfer function
* @func: transfer function
* @lut: lookup table that defines the color space
* @lut_size: size of respective lut
* @has_rom: if ROM can be used for hardcoded curve
*
* Only for sRGB input space
*
* Returns:
* 0 in case of success, -ENOMEM if fails
*/
static int __set_legacy_tf(struct dc_transfer_func *func,
const struct drm_color_lut *lut, uint32_t lut_size,
bool has_rom)
{
struct dc_gamma *gamma = NULL;
struct calculate_buffer cal_buffer = {0};
bool res;
ASSERT(lut && lut_size == MAX_COLOR_LEGACY_LUT_ENTRIES);
cal_buffer.buffer_index = -1;
gamma = dc_create_gamma();
if (!gamma)
return -ENOMEM;
gamma->type = GAMMA_RGB_256;
gamma->num_entries = lut_size;
__drm_lut_to_dc_gamma(lut, gamma, true);
res = mod_color_calculate_regamma_params(func, gamma, true, has_rom,
NULL, &cal_buffer);
dc_gamma_release(&gamma);
return res ? 0 : -ENOMEM;
}
/**
* __set_output_tf - calculates the output transfer function based on expected input space.
* @func: transfer function
* @lut: lookup table that defines the color space
* @lut_size: size of respective lut
* @has_rom: if ROM can be used for hardcoded curve
*
* Returns:
* 0 in case of success. -ENOMEM if fails.
*/
static int __set_output_tf(struct dc_transfer_func *func,
const struct drm_color_lut *lut, uint32_t lut_size,
bool has_rom)
{
struct dc_gamma *gamma = NULL;
Annotation
- Immediate include surface: `drm/drm_colorop.h`, `amdgpu.h`, `amdgpu_mode.h`, `amdgpu_dm.h`, `amdgpu_dm_color.h`, `amdgpu_dm_colorop.h`, `dc.h`, `modules/color/color_gamma.h`.
- Detected declarations: `function files`, `function amdgpu_dm_fixpt_from_s3132`, `function amdgpu_create_tf_property`, `function amdgpu_dm_create_color_properties`, `function __extract_blob_lut`, `function __extract_blob_lut32`, `function __is_lut_linear`, `function __drm_lut_to_dc_gamma`, `function __drm_lut32_to_dc_gamma`, `function __drm_ctm_to_dc_matrix`.
- Atlas domain: Driver Families / drivers/gpu.
- Implementation status: source implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
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.