drivers/gpu/drm/amd/display/amdgpu_dm/tests/amdgpu_dm_color_test.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/amd/display/amdgpu_dm/tests/amdgpu_dm_color_test.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/amd/display/amdgpu_dm/tests/amdgpu_dm_color_test.c- Extension
.c- Size
- 51706 bytes
- Lines
- 1640
- 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.
- 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
kunit/test.hlinux/types.hdrm/drm_colorop.hdrm/drm_property.huapi/drm/drm_mode.hdc.hamdgpu_mode.hamdgpu_dm.hamdgpu_dm_color.h
Detected Declarations
function dm_test_fixpt_from_s3132_zerofunction dm_test_fixpt_from_s3132_onefunction dm_test_fixpt_from_s3132_negative_onefunction dm_test_fixpt_from_s3132_halffunction dm_test_fixpt_from_s3132_neg_halffunction dm_test_is_lut_linear_with_linear_lutfunction dm_test_is_lut_linear_with_nonlinear_lutfunction dm_test_is_lut_linear_rgb_mismatchfunction dm_test_drm_ctm_to_dc_matrix_identityfunction dm_test_drm_ctm_to_dc_matrix_negativefunction dm_test_drm_ctm_to_dc_matrix_4th_col_zerofunction dm_test_drm_ctm_3x4_to_dc_matrix_identityfunction dm_test_drm_ctm_3x4_to_dc_matrix_offsetfunction dm_test_tf_to_dc_tf_defaultfunction dm_test_tf_to_dc_tf_identityfunction dm_test_tf_to_dc_tf_srgbfunction dm_test_tf_to_dc_tf_bt709function dm_test_tf_to_dc_tf_pqfunction dm_test_tf_to_dc_tf_gamma22function dm_test_tf_to_dc_tf_gamma24function dm_test_tf_to_dc_tf_gamma26function dm_test_colorop_tf_to_dc_tf_srgbfunction dm_test_colorop_tf_to_dc_tf_pqfunction dm_test_colorop_tf_to_dc_tf_bt2020function dm_test_colorop_tf_to_dc_tf_gamma22function dm_test_colorop_tf_to_dc_tf_defaultfunction dm_test_drm_lut_to_dc_gamma_legacy_zerofunction dm_test_drm_lut_to_dc_gamma_legacy_maxfunction dm_test_drm_lut_to_dc_gamma_legacy_channelsfunction dm_test_drm_lut_to_dc_gamma_nonlegacy_zerofunction dm_test_drm_lut_to_dc_gamma_nonlegacy_maxfunction dm_test_drm_lut32_to_dc_gamma_zerofunction dm_test_drm_lut32_to_dc_gamma_maxfunction dm_test_drm_lut32_to_dc_gamma_channelsfunction dm_test_extract_blob_lut_nullfunction dm_test_extract_blob_lut_validfunction dm_test_extract_blob_lut32_nullfunction dm_test_extract_blob_lut32_validfunction dm_test_to_dc_lut3d_color_zerofunction dm_test_to_dc_lut3d_color_maxfunction dm_test_to_dc_lut3d_color_channelsfunction dm_test_3dlut_to_dc_3dlut_distributionfunction dm_test_3dlut_to_dc_3dlut_tetrahedral_17function dm_test_3dlut_to_dc_3dlut_green_bluefunction dm_test_to_dc_lut3d_32_color_zerofunction dm_test_to_dc_lut3d_32_color_maxfunction dm_test_to_dc_lut3d_32_color_channelsfunction dm_test_3dlut32_to_dc_3dlut_distribution
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0 OR MIT
/*
* KUnit tests for amdgpu_dm_color.c
*
* Copyright 2026 Advanced Micro Devices, Inc.
*/
#include <kunit/test.h>
#include <linux/types.h>
#include <drm/drm_colorop.h>
#include <drm/drm_property.h>
#include <uapi/drm/drm_mode.h>
#include "dc.h"
#include "amdgpu_mode.h"
#include "amdgpu_dm.h"
#include "amdgpu_dm_color.h"
/* ---- Tests for amdgpu_dm_fixpt_from_s3132 ---- */
static void dm_test_fixpt_from_s3132_zero(struct kunit *test)
{
struct fixed31_32 val = amdgpu_dm_fixpt_from_s3132(0ULL);
KUNIT_EXPECT_EQ(test, val.value, 0LL);
}
static void dm_test_fixpt_from_s3132_one(struct kunit *test)
{
/* 1.0 in S31.32 signed-magnitude = 1ULL << 32 */
struct fixed31_32 val = amdgpu_dm_fixpt_from_s3132(1ULL << 32);
KUNIT_EXPECT_EQ(test, val.value, (long long)(1ULL << 32));
}
static void dm_test_fixpt_from_s3132_negative_one(struct kunit *test)
{
/* -1.0 in S31.32 signed-magnitude: sign bit set | magnitude 1<<32 */
__u64 neg_one = (1ULL << 63) | (1ULL << 32);
struct fixed31_32 val = amdgpu_dm_fixpt_from_s3132(neg_one);
/* 2's complement of 1.0 is -(1<<32) */
KUNIT_EXPECT_EQ(test, val.value, -(long long)(1ULL << 32));
}
static void dm_test_fixpt_from_s3132_half(struct kunit *test)
{
/* 0.5 in S31.32 = 1ULL << 31 */
struct fixed31_32 val = amdgpu_dm_fixpt_from_s3132(1ULL << 31);
KUNIT_EXPECT_EQ(test, val.value, (long long)(1ULL << 31));
}
static void dm_test_fixpt_from_s3132_neg_half(struct kunit *test)
{
__u64 neg_half = (1ULL << 63) | (1ULL << 31);
struct fixed31_32 val = amdgpu_dm_fixpt_from_s3132(neg_half);
KUNIT_EXPECT_EQ(test, val.value, -(long long)(1ULL << 31));
}
/* ---- Tests for __is_lut_linear ---- */
static void dm_test_is_lut_linear_with_linear_lut(struct kunit *test)
{
const uint32_t size = 256;
struct drm_color_lut *lut;
int i;
lut = kunit_kcalloc(test, size, sizeof(*lut), GFP_KERNEL);
KUNIT_ASSERT_NOT_ERR_OR_NULL(test, lut);
for (i = 0; i < size; i++) {
uint16_t val = (uint16_t)(i * MAX_DRM_LUT_VALUE / (size - 1));
lut[i].red = val;
lut[i].green = val;
lut[i].blue = val;
}
KUNIT_EXPECT_TRUE(test, __is_lut_linear(lut, size));
}
static void dm_test_is_lut_linear_with_nonlinear_lut(struct kunit *test)
{
const uint32_t size = 256;
struct drm_color_lut *lut;
int i;
lut = kunit_kcalloc(test, size, sizeof(*lut), GFP_KERNEL);
Annotation
- Immediate include surface: `kunit/test.h`, `linux/types.h`, `drm/drm_colorop.h`, `drm/drm_property.h`, `uapi/drm/drm_mode.h`, `dc.h`, `amdgpu_mode.h`, `amdgpu_dm.h`.
- Detected declarations: `function dm_test_fixpt_from_s3132_zero`, `function dm_test_fixpt_from_s3132_one`, `function dm_test_fixpt_from_s3132_negative_one`, `function dm_test_fixpt_from_s3132_half`, `function dm_test_fixpt_from_s3132_neg_half`, `function dm_test_is_lut_linear_with_linear_lut`, `function dm_test_is_lut_linear_with_nonlinear_lut`, `function dm_test_is_lut_linear_rgb_mismatch`, `function dm_test_drm_ctm_to_dc_matrix_identity`, `function dm_test_drm_ctm_to_dc_matrix_negative`.
- 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.