summaryrefslogtreecommitdiff
path: root/drivers/gpu/drm/amd/display/amdgpu_dm
diff options
context:
space:
mode:
authorAlex Hung <alex.hung@amd.com>2026-04-22 11:37:19 -0600
committerAlex Deucher <alexander.deucher@amd.com>2026-05-19 11:54:36 -0400
commit77f3ed873c5985bb326ab8a4fd8d243e957e962a (patch)
treed5c83a46823c711579fafe312a3303ec79cfcf19 /drivers/gpu/drm/amd/display/amdgpu_dm
parent7a5371e20884cd2b8d583f2879da7679648ff440 (diff)
drm/amd/display: Add KUnit test for colorop TF bitmasks
Add KUnit tests that verify the three supported transfer function bitmask constants exported by amdgpu_dm_colorop.c: amdgpu_dm_supported_degam_tfs, amdgpu_dm_supported_shaper_tfs, and amdgpu_dm_supported_blnd_tfs. Each bitmask is tested for presence of each expected curve flag and absence of any unexpected bits. A cross-check confirms that degam and blnd bitmasks are identical. amdgpu_dm_initialize_default_pipeline() is not tested because it needs a fully initialised drm_plane backed by an amdgpu_device with DC color caps. Assisted-by: Copilot:Claude-Opus-4.6 Reviewed-by: Harry Wentland <harry.wentland@amd.com> Signed-off-by: Alex Hung <alex.hung@amd.com> Signed-off-by: Ivan Lipski <ivan.lipski@amd.com> Tested-by: Dan Wheeler <daniel.wheeler@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Diffstat (limited to 'drivers/gpu/drm/amd/display/amdgpu_dm')
-rw-r--r--drivers/gpu/drm/amd/display/amdgpu_dm/tests/Makefile1
-rw-r--r--drivers/gpu/drm/amd/display/amdgpu_dm/tests/amdgpu_dm_colorop_test.c161
2 files changed, 162 insertions, 0 deletions
diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/tests/Makefile b/drivers/gpu/drm/amd/display/amdgpu_dm/tests/Makefile
index 9669ea79a666..e300bcf39835 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/tests/Makefile
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/tests/Makefile
@@ -10,3 +10,4 @@ ccflags-y += -I$(src)/../../dc
obj-$(CONFIG_DRM_AMD_DC_KUNIT_TEST) += amdgpu_dm_crc_test.o
obj-$(CONFIG_DRM_AMD_DC_KUNIT_TEST) += amdgpu_dm_hdcp_test.o
+obj-$(CONFIG_DRM_AMD_DC_KUNIT_TEST) += amdgpu_dm_colorop_test.o
diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/tests/amdgpu_dm_colorop_test.c b/drivers/gpu/drm/amd/display/amdgpu_dm/tests/amdgpu_dm_colorop_test.c
new file mode 100644
index 000000000000..8bdebcaf42b2
--- /dev/null
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/tests/amdgpu_dm_colorop_test.c
@@ -0,0 +1,161 @@
+// SPDX-License-Identifier: GPL-2.0 OR MIT
+/*
+ * KUnit tests for amdgpu_dm_colorop.c
+ *
+ * Copyright 2026 Advanced Micro Devices, Inc.
+ */
+
+#include <kunit/test.h>
+#include <drm/drm_colorop.h>
+
+#include "amdgpu_dm_colorop.h"
+
+/* Tests for amdgpu_dm_supported_degam_tfs */
+
+static void dm_test_supported_degam_tfs_has_srgb_eotf(struct kunit *test)
+{
+ KUNIT_EXPECT_TRUE(test, amdgpu_dm_supported_degam_tfs &
+ BIT(DRM_COLOROP_1D_CURVE_SRGB_EOTF));
+}
+
+static void dm_test_supported_degam_tfs_has_pq125_eotf(struct kunit *test)
+{
+ KUNIT_EXPECT_TRUE(test, amdgpu_dm_supported_degam_tfs &
+ BIT(DRM_COLOROP_1D_CURVE_PQ_125_EOTF));
+}
+
+static void dm_test_supported_degam_tfs_has_bt2020_inv_oetf(struct kunit *test)
+{
+ KUNIT_EXPECT_TRUE(test, amdgpu_dm_supported_degam_tfs &
+ BIT(DRM_COLOROP_1D_CURVE_BT2020_INV_OETF));
+}
+
+static void dm_test_supported_degam_tfs_has_gamma22_inv(struct kunit *test)
+{
+ KUNIT_EXPECT_TRUE(test, amdgpu_dm_supported_degam_tfs &
+ BIT(DRM_COLOROP_1D_CURVE_GAMMA22_INV));
+}
+
+static void dm_test_supported_degam_tfs_no_extra_bits(struct kunit *test)
+{
+ u64 expected = BIT(DRM_COLOROP_1D_CURVE_SRGB_EOTF) |
+ BIT(DRM_COLOROP_1D_CURVE_PQ_125_EOTF) |
+ BIT(DRM_COLOROP_1D_CURVE_BT2020_INV_OETF) |
+ BIT(DRM_COLOROP_1D_CURVE_GAMMA22_INV);
+
+ KUNIT_EXPECT_EQ(test, amdgpu_dm_supported_degam_tfs, expected);
+}
+
+/* Tests for amdgpu_dm_supported_shaper_tfs */
+
+static void dm_test_supported_shaper_tfs_has_srgb_inv_eotf(struct kunit *test)
+{
+ KUNIT_EXPECT_TRUE(test, amdgpu_dm_supported_shaper_tfs &
+ BIT(DRM_COLOROP_1D_CURVE_SRGB_INV_EOTF));
+}
+
+static void dm_test_supported_shaper_tfs_has_pq125_inv_eotf(struct kunit *test)
+{
+ KUNIT_EXPECT_TRUE(test, amdgpu_dm_supported_shaper_tfs &
+ BIT(DRM_COLOROP_1D_CURVE_PQ_125_INV_EOTF));
+}
+
+static void dm_test_supported_shaper_tfs_has_bt2020_oetf(struct kunit *test)
+{
+ KUNIT_EXPECT_TRUE(test, amdgpu_dm_supported_shaper_tfs &
+ BIT(DRM_COLOROP_1D_CURVE_BT2020_OETF));
+}
+
+static void dm_test_supported_shaper_tfs_has_gamma22(struct kunit *test)
+{
+ KUNIT_EXPECT_TRUE(test, amdgpu_dm_supported_shaper_tfs &
+ BIT(DRM_COLOROP_1D_CURVE_GAMMA22));
+}
+
+static void dm_test_supported_degam_tfs_no_extra_bits(struct kunit *test)
+{
+ u64 expected = BIT(DRM_COLOROP_1D_CURVE_SRGB_EOTF) |
+ BIT(DRM_COLOROP_1D_CURVE_PQ_125_EOTF) |
+ BIT(DRM_COLOROP_1D_CURVE_BT2020_INV_OETF) |
+ BIT(DRM_COLOROP_1D_CURVE_GAMMA22_INV);
+
+ KUNIT_EXPECT_EQ(test, amdgpu_dm_supported_shaper_tfs, expected);
+}
+
+/* Tests for amdgpu_dm_supported_blnd_tfs */
+
+static void dm_test_supported_blnd_tfs_has_srgb_eotf(struct kunit *test)
+{
+ KUNIT_EXPECT_TRUE(test, amdgpu_dm_supported_blnd_tfs &
+ BIT(DRM_COLOROP_1D_CURVE_SRGB_EOTF));
+}
+
+static void dm_test_supported_blnd_tfs_has_pq125_eotf(struct kunit *test)
+{
+ KUNIT_EXPECT_TRUE(test, amdgpu_dm_supported_blnd_tfs &
+ BIT(DRM_COLOROP_1D_CURVE_PQ_125_EOTF));
+}
+
+static void dm_test_supported_blnd_tfs_has_bt2020_inv_oetf(struct kunit *test)
+{
+ KUNIT_EXPECT_TRUE(test, amdgpu_dm_supported_blnd_tfs &
+ BIT(DRM_COLOROP_1D_CURVE_BT2020_INV_OETF));
+}
+
+static void dm_test_supported_blnd_tfs_has_gamma22_inv(struct kunit *test)
+{
+ KUNIT_EXPECT_TRUE(test, amdgpu_dm_supported_blnd_tfs &
+ BIT(DRM_COLOROP_1D_CURVE_GAMMA22_INV));
+}
+
+static void dm_test_supported_blnd_tfs_no_extra_bits(struct kunit *test)
+{
+ u64 expected = BIT(DRM_COLOROP_1D_CURVE_SRGB_EOTF) |
+ BIT(DRM_COLOROP_1D_CURVE_PQ_125_EOTF) |
+ BIT(DRM_COLOROP_1D_CURVE_BT2020_INV_OETF) |
+ BIT(DRM_COLOROP_1D_CURVE_GAMMA22_INV);
+
+ KUNIT_EXPECT_EQ(test, amdgpu_dm_supported_blnd_tfs, expected);
+}
+
+/* degam and blnd should support the same set of EOTF curves */
+static void dm_test_degam_and_blnd_tfs_match(struct kunit *test)
+{
+ KUNIT_EXPECT_EQ(test, amdgpu_dm_supported_degam_tfs,
+ amdgpu_dm_supported_blnd_tfs);
+}
+
+static struct kunit_case dm_colorop_test_cases[] = {
+ /* degam TFs */
+ KUNIT_CASE(dm_test_supported_degam_tfs_has_srgb_eotf),
+ KUNIT_CASE(dm_test_supported_degam_tfs_has_pq125_eotf),
+ KUNIT_CASE(dm_test_supported_degam_tfs_has_bt2020_inv_oetf),
+ KUNIT_CASE(dm_test_supported_degam_tfs_has_gamma22_inv),
+ KUNIT_CASE(dm_test_supported_degam_tfs_no_extra_bits),
+ /* shaper TFs */
+ KUNIT_CASE(dm_test_supported_shaper_tfs_has_srgb_inv_eotf),
+ KUNIT_CASE(dm_test_supported_shaper_tfs_has_pq125_inv_eotf),
+ KUNIT_CASE(dm_test_supported_shaper_tfs_has_bt2020_oetf),
+ KUNIT_CASE(dm_test_supported_shaper_tfs_has_gamma22),
+ KUNIT_CASE(dm_test_supported_shaper_tfs_no_extra_bits),
+ /* blnd TFs */
+ KUNIT_CASE(dm_test_supported_blnd_tfs_has_srgb_eotf),
+ KUNIT_CASE(dm_test_supported_blnd_tfs_has_pq125_eotf),
+ KUNIT_CASE(dm_test_supported_blnd_tfs_has_bt2020_inv_oetf),
+ KUNIT_CASE(dm_test_supported_blnd_tfs_has_gamma22_inv),
+ KUNIT_CASE(dm_test_supported_blnd_tfs_no_extra_bits),
+ /* cross-check */
+ KUNIT_CASE(dm_test_degam_and_blnd_tfs_match),
+ {}
+};
+
+static struct kunit_suite dm_colorop_test_suite = {
+ .name = "amdgpu_dm_colorop",
+ .test_cases = dm_colorop_test_cases,
+};
+
+kunit_test_suite(dm_colorop_test_suite);
+
+MODULE_LICENSE("Dual MIT/GPL");
+MODULE_DESCRIPTION("KUnit tests for amdgpu_dm_colorop");
+MODULE_AUTHOR("AMD");