[PATCH V8 36/36] tests/kms_colorop: Add a colorop uniqueness subtest
Alex Hung
alex.hung at amd.com
Wed Apr 30 01:34:54 UTC 2025
A colorop should have unique ID.
Signed-off-by: Alex Hung <alex.hung at amd.com>
---
tests/kms_colorop.c | 50 +++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 50 insertions(+)
diff --git a/tests/kms_colorop.c b/tests/kms_colorop.c
index c4ac3799c..acdebf8b3 100644
--- a/tests/kms_colorop.c
+++ b/tests/kms_colorop.c
@@ -25,11 +25,16 @@
#include "sw_sync.h"
#include "kms_colorop.h"
+#include <glib.h>
+
/**
* TEST: kms colorop
* Category: Display
* Description: Test to validate the retrieving and setting of DRM colorops
*
+ * SUBTEST: check_plane_colorop_ids
+ * Description: Verify that all igt_colorop_t IDs are unique across planes
+ *
* SUBTEST: plane-%s-%s
* Description: Tests DRM colorop properties on a plane
* Driver requirement: amdgpu
@@ -555,6 +560,47 @@ static void colorop_plane_test(igt_display_t *display,
}
+static void check_plane_colorop_ids(igt_display_t *display)
+{
+ igt_plane_t *plane;
+ int colorop_idx;
+ igt_colorop_t *next;
+ int prop_val = 0, pipe = 0;
+
+ /* Use hash tables to track drm_planes and unique IDs */
+ GHashTable *plane_set = g_hash_table_new(g_direct_hash, g_direct_equal);
+ GHashTable *id_set = g_hash_table_new(g_direct_hash, g_direct_equal);
+
+ for_each_pipe(display, pipe) {
+ for_each_plane_on_pipe(display, pipe, plane) {
+ /* Skip when a drm_plane is already scanned */
+ if (g_hash_table_contains(plane_set, GINT_TO_POINTER(plane->drm_plane->plane_id)))
+ continue;
+
+ g_hash_table_add(plane_set, GINT_TO_POINTER(plane->drm_plane->plane_id));
+
+ for (colorop_idx = 0; colorop_idx < plane->num_color_pipelines; colorop_idx++) {
+ next = plane->color_pipelines[colorop_idx];
+ while (next) {
+ /* Check if the ID already exists in the set */
+ if (g_hash_table_contains(id_set, GINT_TO_POINTER(next->id))) {
+ igt_fail_on_f(true, "Duplicate colorop ID %u found on plane %d\n",
+ next->id, plane->drm_plane->plane_id);
+ }
+
+ g_hash_table_add(id_set, GINT_TO_POINTER(next->id));
+ prop_val = igt_colorop_get_prop(display, next, IGT_COLOROP_NEXT);
+ next = igt_find_colorop(display, prop_val);
+ }
+ }
+ }
+ }
+
+ g_hash_table_destroy(id_set);
+ g_hash_table_destroy(plane_set);
+ igt_info("All igt_colorop_t IDs are unique across planes\n");
+}
+
igt_main
{
@@ -622,6 +668,10 @@ igt_main
igt_require(display.is_atomic);
}
+ igt_subtest_f("check_plane_colorop_ids") {
+ check_plane_colorop_ids(&display);
+ }
+
for (j = 0; j < ARRAY_SIZE(formats); j++) {
igt_output_t *output;
igt_plane_t *plane;
--
2.43.0
More information about the igt-dev
mailing list