drm/amd/display: Add atomic transfer-function tests

[WHY]
The atomic regamma, shaper, and blend helpers were only exercised on
their linear bypass paths, leaving the generated transfer-function
cases untested.

[HOW]
Add sRGB success-path tests that verify the generated transfer
functions and the corresponding plane color-management enable flags.

Assisted-by: Copilot:GPT-5.6-Sol
Reviewed-by: Bhawanpreet Lakha <bhawanpreet.lakha@amd.com>
Signed-off-by: Alex Hung <alex.hung@amd.com>
Signed-off-by: Fangzhi Zuo <jerry.zuo@amd.com>
Tested-by: Dan Wheeler <daniel.wheeler@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
This commit is contained in:
Alex Hung
2026-07-14 15:09:29 -06:00
committed by Alex Deucher
parent bfab0b0efd
commit 52d0db4dfc

View File

@@ -1535,6 +1535,23 @@ static void dm_test_set_atomic_regamma_bypass(struct kunit *test)
KUNIT_EXPECT_EQ(test, (int)out_tf->tf, (int)TRANSFER_FUNCTION_LINEAR);
}
/**
* dm_test_set_atomic_regamma_srgb - Non-linear TF enables generated regamma
* @test: KUnit test context
*/
static void dm_test_set_atomic_regamma_srgb(struct kunit *test)
{
struct dc_transfer_func *out_tf;
out_tf = kunit_kzalloc(test, sizeof(*out_tf), GFP_KERNEL);
KUNIT_ASSERT_NOT_NULL(test, out_tf);
KUNIT_EXPECT_EQ(test,
amdgpu_dm_set_atomic_regamma(out_tf, NULL, 0, true, TRANSFER_FUNCTION_SRGB),
0);
KUNIT_EXPECT_EQ(test, (int)out_tf->type, (int)TF_TYPE_DISTRIBUTED_POINTS);
}
/**
* dm_test_atomic_shaper_lut_bypass - No LUT and linear TF: must take bypass path
* @test: KUnit test context
@@ -1577,6 +1594,28 @@ static void dm_test_atomic_blend_lut_bypass(struct kunit *test)
KUNIT_EXPECT_EQ(test, (int)cm->blend_func.tf, (int)TRANSFER_FUNCTION_LINEAR);
}
/**
* dm_test_atomic_shaper_blend_srgb - Non-linear TFs enable shaper and blend
* @test: KUnit test context
*/
static void dm_test_atomic_shaper_blend_srgb(struct kunit *test)
{
struct dc_plane_cm *cm;
cm = kunit_kzalloc(test, sizeof(*cm), GFP_KERNEL);
KUNIT_ASSERT_NOT_NULL(test, cm);
KUNIT_EXPECT_EQ(test,
amdgpu_dm_atomic_shaper_lut(NULL, true, TRANSFER_FUNCTION_SRGB, 0, cm),
0);
KUNIT_EXPECT_TRUE(test, cm->flags.bits.shaper_enable);
KUNIT_EXPECT_EQ(test,
amdgpu_dm_atomic_blend_lut(NULL, false, TRANSFER_FUNCTION_SRGB, 0, cm),
0);
KUNIT_EXPECT_TRUE(test, cm->flags.bits.blend_enable);
}
/* ---- Tests for __set_colorop_in_tf_1d_curve ---- */
/**
@@ -2533,10 +2572,12 @@ static struct kunit_case dm_color_test_cases[] = {
KUNIT_CASE(dm_test_set_transfer_funcs_with_luts),
/* amdgpu_dm_set_atomic_regamma */
KUNIT_CASE(dm_test_set_atomic_regamma_bypass),
KUNIT_CASE(dm_test_set_atomic_regamma_srgb),
/* amdgpu_dm_atomic_shaper_lut */
KUNIT_CASE(dm_test_atomic_shaper_lut_bypass),
/* amdgpu_dm_atomic_blend_lut */
KUNIT_CASE(dm_test_atomic_blend_lut_bypass),
KUNIT_CASE(dm_test_atomic_shaper_blend_srgb),
/* __set_colorop_in_tf_1d_curve */
KUNIT_CASE(dm_test_set_colorop_in_tf_1d_curve_invalid_type),
KUNIT_CASE(dm_test_set_colorop_in_tf_1d_curve_unsupported_curve),