drm/amd/display: add CRC source list KUnit coverage

[WHAT]
Expose amdgpu_dm_crtc_get_crc_sources() for KUnit and add a test that
verifies the returned static source-name list and its count. This is the
accessor used by the debugfs CRC control interface.

Assisted-by: Copilot:Claude-Opus-4.8 GPT-5.5
Reviewed-by: Bhawanpreet Lakha <bhawanpreet.lakha@amd.com>
Signed-off-by: Alex Hung <alex.hung@amd.com>
Signed-off-by: Wayne Lin <wayne.lin@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-06 20:54:22 -06:00 committed by Alex Deucher
parent d79f3c7fe1
commit e3a1ebae26
2 changed files with 27 additions and 0 deletions

View File

@ -152,6 +152,7 @@ const char *const *amdgpu_dm_crtc_get_crc_sources(struct drm_crtc *crtc,
*count = ARRAY_SIZE(pipe_crc_sources);
return pipe_crc_sources;
}
EXPORT_IF_KUNIT(amdgpu_dm_crtc_get_crc_sources);
#ifdef CONFIG_DRM_AMD_SECURE_DISPLAY
static void update_phy_id_mapping(struct amdgpu_device *adev)

View File

@ -95,6 +95,30 @@ static void dm_test_is_valid_crc_source(struct kunit *test)
KUNIT_EXPECT_FALSE(test, amdgpu_dm_is_valid_crc_source(AMDGPU_DM_PIPE_CRC_SOURCE_INVALID));
}
/**
* dm_test_crtc_get_crc_sources() - Test available CRC source strings.
* @test: KUnit test context.
*
* Verifies that amdgpu_dm_crtc_get_crc_sources() returns the static source
* list and reports all debugfs source names.
*/
static void dm_test_crtc_get_crc_sources(struct kunit *test)
{
const char *const *sources;
size_t count = 0;
sources = amdgpu_dm_crtc_get_crc_sources(NULL, &count);
KUNIT_ASSERT_NOT_NULL(test, sources);
KUNIT_EXPECT_EQ(test, count, 6);
KUNIT_EXPECT_STREQ(test, sources[0], "none");
KUNIT_EXPECT_STREQ(test, sources[1], "crtc");
KUNIT_EXPECT_STREQ(test, sources[2], "crtc dither");
KUNIT_EXPECT_STREQ(test, sources[3], "dprx");
KUNIT_EXPECT_STREQ(test, sources[4], "dprx dither");
KUNIT_EXPECT_STREQ(test, sources[5], "auto");
}
/**
* dm_test_need_dp_aux() - Test dm_need_dp_aux().
* @test: KUnit test context.
@ -222,6 +246,8 @@ static struct kunit_case dm_crc_test_cases[] = {
KUNIT_CASE(dm_test_need_crc_dither),
/* amdgpu_dm_is_valid_crc_source() */
KUNIT_CASE(dm_test_is_valid_crc_source),
/* amdgpu_dm_crtc_get_crc_sources() */
KUNIT_CASE(dm_test_crtc_get_crc_sources),
/* dm_need_dp_aux() */
KUNIT_CASE(dm_test_need_dp_aux),
/* dm_crc_source_should_start_dprx() */