drivers/gpu/drm/vkms/tests/vkms_color_test.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/vkms/tests/vkms_color_test.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/vkms/tests/vkms_color_test.c- Extension
.c- Size
- 10567 bytes
- Lines
- 415
- 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
kunit/test.hdrm/drm_fixed.hdrm/drm_mode.h../vkms_composer.h../vkms_drv.h../vkms_luts.h
Detected Declarations
struct vkms_color_test_lerp_paramsfunction vkms_color_test_get_lut_indexfunction vkms_color_test_lerpfunction vkms_color_test_linearfunction vkms_color_srgb_inv_srgbfunction vkms_color_ctm_3x4_50_desatfunction vkms_color_ctm_3x4_bt709
Annotated Snippet
struct vkms_color_test_lerp_params {
s64 t;
__u16 a;
__u16 b;
__u16 expected;
};
/* lerp test cases */
static const struct vkms_color_test_lerp_params color_test_lerp_cases[] = {
/* Half-way round down */
{ 0x80000000 - 1, 0x0, 0x10, 0x8 },
{ 0x80000000 - 1, 0x1, 0x10, 0x8 }, /* Odd a */
{ 0x80000000 - 1, 0x1, 0xf, 0x8 }, /* Odd b */
{ 0x80000000 - 1, 0x10, 0x10, 0x10 }, /* b = a */
{ 0x80000000 - 1, 0x10, 0x11, 0x10 }, /* b = a + 1*/
/* Half-way round up */
{ 0x80000000, 0x0, 0x10, 0x8 },
{ 0x80000000, 0x1, 0x10, 0x9 }, /* Odd a */
{ 0x80000000, 0x1, 0xf, 0x8 }, /* Odd b */
{ 0x80000000, 0x10, 0x10, 0x10 }, /* b = a */
{ 0x80000000, 0x10, 0x11, 0x11 }, /* b = a + 1*/
/* t = 0.0 */
{ 0x0, 0x0, 0x10, 0x0 },
{ 0x0, 0x1, 0x10, 0x1 }, /* Odd a */
{ 0x0, 0x1, 0xf, 0x1 }, /* Odd b */
{ 0x0, 0x10, 0x10, 0x10 }, /* b = a */
{ 0x0, 0x10, 0x11, 0x10 }, /* b = a + 1*/
/* t = 1.0 */
{ 0x100000000, 0x0, 0x10, 0x10 },
{ 0x100000000, 0x1, 0x10, 0x10 }, /* Odd a */
{ 0x100000000, 0x1, 0xf, 0xf }, /* Odd b */
{ 0x100000000, 0x10, 0x10, 0x10 }, /* b = a */
{ 0x100000000, 0x10, 0x11, 0x11 }, /* b = a + 1*/
/* t = 0.0 + 1 */
{ 0x0 + 1, 0x0, 0x10, 0x0 },
{ 0x0 + 1, 0x1, 0x10, 0x1 }, /* Odd a */
{ 0x0 + 1, 0x1, 0xf, 0x1 }, /* Odd b */
{ 0x0 + 1, 0x10, 0x10, 0x10 }, /* b = a */
{ 0x0 + 1, 0x10, 0x11, 0x10 }, /* b = a + 1*/
/* t = 1.0 - 1 */
{ 0x100000000 - 1, 0x0, 0x10, 0x10 },
{ 0x100000000 - 1, 0x1, 0x10, 0x10 }, /* Odd a */
{ 0x100000000 - 1, 0x1, 0xf, 0xf }, /* Odd b */
{ 0x100000000 - 1, 0x10, 0x10, 0x10 }, /* b = a */
{ 0x100000000 - 1, 0x10, 0x11, 0x11 }, /* b = a + 1*/
/* t chosen to verify the flipping point of result a (or b) to a+1 (or b-1) */
{ 0x80000000 - 1, 0x0, 0x1, 0x0 },
{ 0x80000000, 0x0, 0x1, 0x1 },
};
static const struct vkms_color_lut test_linear_lut = {
.base = test_linear_array,
.lut_length = TEST_LUT_SIZE,
.channel_value2index_ratio = 0xf000fll
};
static void vkms_color_test_get_lut_index(struct kunit *test)
{
s64 lut_index;
int i;
lut_index = get_lut_index(&test_linear_lut, test_linear_array[0].red);
KUNIT_EXPECT_EQ(test, drm_fixp2int(lut_index), 0);
for (i = 0; i < TEST_LUT_SIZE; i++) {
lut_index = get_lut_index(&test_linear_lut, test_linear_array[i].red);
KUNIT_EXPECT_EQ(test, drm_fixp2int_ceil(lut_index), i);
}
KUNIT_EXPECT_EQ(test, drm_fixp2int(get_lut_index(&srgb_eotf, 0x0)), 0x0);
KUNIT_EXPECT_EQ(test, drm_fixp2int_ceil(get_lut_index(&srgb_eotf, 0x0)), 0x0);
KUNIT_EXPECT_EQ(test, drm_fixp2int_ceil(get_lut_index(&srgb_eotf, 0x101)), 0x1);
KUNIT_EXPECT_EQ(test, drm_fixp2int_ceil(get_lut_index(&srgb_eotf, 0x202)), 0x2);
KUNIT_EXPECT_EQ(test, drm_fixp2int(get_lut_index(&srgb_inv_eotf, 0x0)), 0x0);
KUNIT_EXPECT_EQ(test, drm_fixp2int_ceil(get_lut_index(&srgb_inv_eotf, 0x0)), 0x0);
KUNIT_EXPECT_EQ(test, drm_fixp2int_ceil(get_lut_index(&srgb_inv_eotf, 0x101)), 0x1);
KUNIT_EXPECT_EQ(test, drm_fixp2int_ceil(get_lut_index(&srgb_inv_eotf, 0x202)), 0x2);
KUNIT_EXPECT_EQ(test, drm_fixp2int_ceil(get_lut_index(&srgb_eotf, 0xfefe)), 0xfe);
KUNIT_EXPECT_EQ(test, drm_fixp2int_ceil(get_lut_index(&srgb_eotf, 0xffff)), 0xff);
}
static void vkms_color_test_lerp(struct kunit *test)
{
int i;
for (i = 0; i < ARRAY_SIZE(color_test_lerp_cases); i++) {
const struct vkms_color_test_lerp_params *params = &color_test_lerp_cases[i];
Annotation
- Immediate include surface: `kunit/test.h`, `drm/drm_fixed.h`, `drm/drm_mode.h`, `../vkms_composer.h`, `../vkms_drv.h`, `../vkms_luts.h`.
- Detected declarations: `struct vkms_color_test_lerp_params`, `function vkms_color_test_get_lut_index`, `function vkms_color_test_lerp`, `function vkms_color_test_linear`, `function vkms_color_srgb_inv_srgb`, `function vkms_color_ctm_3x4_50_desat`, `function vkms_color_ctm_3x4_bt709`.
- 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.