mirror of
https://github.com/torvalds/linux.git
synced 2026-07-28 10:09:10 +02:00
drm/amd/display: Add KUnit tests for amdgpu_dm_colorop
[Why & How] Add a KUnit pipeline test for amdgpu_dm_build_default_pipeline(). The pipeline test uses a mock drm_device (via DRM KUnit helpers), calls amdgpu_dm_build_default_pipeline() with hw_3d_lut=true, then walks the returned colorop chain asserting the correct type sequence (degam_tf, mult, ctm, shaper_tf, shaper_lut, 3dlut, blnd_tf, blnd_lut), that every op carries bypass_property, and that the chain length is exactly eight. A kunit cleanup action calls drm_colorop_pipeline_destroy() before the device is torn down. Assisted-by: Copilot:Claude-Sonnet-4.6 Reviewed-by: Harry Wentland <harry.wentland@amd.com> Signed-off-by: Alex Hung <alex.hung@amd.com> Signed-off-by: Ray Wu <ray.wu@amd.com> Tested-by: Daniel Wheeler <daniel.wheeler@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
This commit is contained in:
parent
533de2d4d5
commit
2da6b0b28f
|
|
@ -58,7 +58,7 @@ config DRM_AMD_SECURE_DISPLAY
|
|||
|
||||
config DRM_AMD_DC_KUNIT_TEST
|
||||
tristate "KUnit tests for the AMD DC display driver" if !KUNIT_ALL_TESTS
|
||||
depends on DRM_AMD_DC && KUNIT && DEBUG_FS
|
||||
depends on DRM_AMD_DC && KUNIT && DEBUG_FS && DRM_KUNIT_TEST_HELPERS
|
||||
default KUNIT_ALL_TESTS
|
||||
help
|
||||
This option enables KUnit tests for the AMD Display Core driver.
|
||||
|
|
|
|||
|
|
@ -6,6 +6,8 @@ CONFIG_DRM_AMD_DC=y
|
|||
CONFIG_DEBUG_FS=y
|
||||
CONFIG_DRM_AMD_DC_KUNIT_TEST=y
|
||||
CONFIG_FW_LOADER=y
|
||||
CONFIG_DRM_KUNIT_TEST=y
|
||||
CONFIG_DRM_KUNIT_TEST_HELPERS=y
|
||||
CONFIG_DRM_KMS_HELPER=y
|
||||
CONFIG_DRM_TTM=y
|
||||
CONFIG_HWMON=y
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@
|
|||
|
||||
#include <kunit/test.h>
|
||||
#include <drm/drm_colorop.h>
|
||||
#include <drm/drm_kunit_helpers.h>
|
||||
|
||||
#include "amdgpu_dm_colorop.h"
|
||||
|
||||
|
|
@ -125,6 +126,81 @@ static void dm_test_degam_and_blnd_tfs_match(struct kunit *test)
|
|||
amdgpu_dm_supported_blnd_tfs);
|
||||
}
|
||||
|
||||
/* Tests for amdgpu_dm_initialize_default_pipeline */
|
||||
|
||||
static void kunit_colorop_pipeline_destroy(void *drm)
|
||||
{
|
||||
drm_colorop_pipeline_destroy((struct drm_device *)drm);
|
||||
}
|
||||
|
||||
/**
|
||||
* dm_test_initialize_default_pipeline() - Verify amdgpu_dm_build_default_pipeline()
|
||||
* produces the expected colorop chain with all ops bypassable.
|
||||
* @test: KUnit test context.
|
||||
*/
|
||||
static void dm_test_initialize_default_pipeline(struct kunit *test)
|
||||
{
|
||||
static const enum drm_colorop_type expected[] = {
|
||||
DRM_COLOROP_1D_CURVE, /* degam TF */
|
||||
DRM_COLOROP_MULTIPLIER,
|
||||
DRM_COLOROP_CTM_3X4,
|
||||
DRM_COLOROP_1D_CURVE, /* shaper TF */
|
||||
DRM_COLOROP_1D_LUT, /* shaper LUT */
|
||||
DRM_COLOROP_3D_LUT,
|
||||
DRM_COLOROP_1D_CURVE, /* blnd TF */
|
||||
DRM_COLOROP_1D_LUT, /* blnd LUT */
|
||||
};
|
||||
struct device *dev;
|
||||
struct drm_device *drm;
|
||||
struct drm_plane *plane;
|
||||
struct drm_prop_enum_list list = {};
|
||||
struct drm_colorop *op, *first = NULL;
|
||||
int i = 0;
|
||||
int ret;
|
||||
|
||||
dev = drm_kunit_helper_alloc_device(test);
|
||||
KUNIT_ASSERT_NOT_ERR_OR_NULL(test, dev);
|
||||
|
||||
/*
|
||||
* Allocate a plain drm_device (not an amdgpu_device) — sufficient
|
||||
* because amdgpu_dm_build_default_pipeline() only needs the DRM
|
||||
* mode-config infrastructure, not the amdgpu device wrapper.
|
||||
*/
|
||||
drm = __drm_kunit_helper_alloc_drm_device(test, dev,
|
||||
sizeof(*drm), 0, 0);
|
||||
KUNIT_ASSERT_NOT_ERR_OR_NULL(test, drm);
|
||||
|
||||
plane = drm_kunit_helper_create_primary_plane(test, drm,
|
||||
NULL, NULL, NULL, 0, NULL);
|
||||
KUNIT_ASSERT_NOT_ERR_OR_NULL(test, plane);
|
||||
|
||||
/*
|
||||
* Destroy the pipeline before the DRM device is cleaned up so
|
||||
* that the colorop objects (kzalloc'd inside the function) are
|
||||
* freed while the device is still valid.
|
||||
*/
|
||||
kunit_add_action(test, kunit_colorop_pipeline_destroy, drm);
|
||||
|
||||
ret = amdgpu_dm_build_default_pipeline(drm, plane, true, &list);
|
||||
KUNIT_ASSERT_EQ(test, ret, 0);
|
||||
kfree(list.name);
|
||||
|
||||
drm_for_each_colorop(op, drm) {
|
||||
if (op->base.id == (uint32_t)list.type) {
|
||||
first = op;
|
||||
break;
|
||||
}
|
||||
}
|
||||
KUNIT_ASSERT_NOT_ERR_OR_NULL(test, first);
|
||||
|
||||
for (op = first; op; op = op->next, i++) {
|
||||
KUNIT_ASSERT_LT(test, i, (int)ARRAY_SIZE(expected));
|
||||
KUNIT_EXPECT_EQ(test, op->type, expected[i]);
|
||||
KUNIT_EXPECT_NOT_NULL(test, op->bypass_property);
|
||||
}
|
||||
KUNIT_EXPECT_EQ(test, i, (int)ARRAY_SIZE(expected));
|
||||
}
|
||||
|
||||
static struct kunit_case dm_colorop_test_cases[] = {
|
||||
/* degam TFs */
|
||||
KUNIT_CASE(dm_test_supported_degam_tfs_has_srgb_eotf),
|
||||
|
|
@ -146,6 +222,8 @@ static struct kunit_case dm_colorop_test_cases[] = {
|
|||
KUNIT_CASE(dm_test_supported_blnd_tfs_no_extra_bits),
|
||||
/* cross-check */
|
||||
KUNIT_CASE(dm_test_degam_and_blnd_tfs_match),
|
||||
/* amdgpu_dm_initialize_default_pipeline */
|
||||
KUNIT_CASE(dm_test_initialize_default_pipeline),
|
||||
{}
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user