[PATCH i-g-t] RFC: tests/kms_plane_lowres: Refactor test to handle tiling formats dynamically

Jeevan B jeevan.b at intel.com
Thu Nov 14 10:03:32 UTC 2024


Refactored the test to dynamically handle different tiling formats.
Removed the hardcoded list of subtests and instead automatically checks
which tiling formats are supported for each plane.

Signed-off-by: Jeevan B <jeevan.b at intel.com>
---
 tests/kms_plane_lowres.c | 105 ++++++++++++++-------------------------
 1 file changed, 36 insertions(+), 69 deletions(-)

diff --git a/tests/kms_plane_lowres.c b/tests/kms_plane_lowres.c
index ef85e8fb9..a2b81a129 100644
--- a/tests/kms_plane_lowres.c
+++ b/tests/kms_plane_lowres.c
@@ -42,21 +42,10 @@
 #include <time.h>
 
 /**
- * SUBTEST: tiling-none
+ * SUBTEST: tiling
  * Description: Tests the visibility of the planes when switching between high
- *              and low resolution with Linear buffer (no tiling)
+ *              and low resolution with Supported Tiling Formats
  * Functionality: plane
- *
- * SUBTEST: tiling-%s
- * Description: Tests the visibility of the planes when switching between high
- *              and low resolution with %arg[1]
- *
- * arg[1]:
- *
- * @4:           4-tiling
- * @x:           x-tiling
- * @y:           y-tiling
- * @yf:          yf-tiling
  */
 
 IGT_TEST_DESCRIPTION("Test atomic mode setting with a plane by switching between high and low resolutions");
@@ -290,57 +279,6 @@ static void test_cleanup(data_t *data)
 	igt_display_commit2(&data->display, COMMIT_ATOMIC);
 }
 
-static void run_test(data_t *data, uint64_t modifier)
-{
-	enum pipe pipe;
-	igt_output_t *output;
-
-	if(!igt_display_has_format_mod(&data->display, DRM_FORMAT_XRGB8888, modifier))
-		return;
-
-	for_each_pipe(&data->display, pipe) {
-		for_each_valid_output_on_pipe(&data->display, pipe, output) {
-			data->pipe = pipe;
-			data->output = output;
-
-			igt_display_reset(&data->display);
-			igt_output_set_pipe(data->output, data->pipe);
-
-			if (!intel_pipe_output_combo_valid(&data->display))
-				continue;
-
-			data->pipe_crc = igt_pipe_crc_new(data->drm_fd, data->pipe,
-							  IGT_PIPE_CRC_SOURCE_AUTO);
-
-			igt_dynamic_f("pipe-%s-%s", kmstest_pipe_name(pipe), data->output->name)
-				test_planes_on_pipe(data, modifier);
-
-			test_cleanup(data);
-		}
-	}
-}
-
-static const struct {
-	const char *name;
-	uint64_t modifier;
-} subtests[] = {
-	{ .name = "tiling-none",
-	  .modifier = DRM_FORMAT_MOD_LINEAR,
-	},
-	{ .name = "tiling-x",
-	  .modifier = I915_FORMAT_MOD_X_TILED,
-	},
-	{ .name = "tiling-y",
-	  .modifier = I915_FORMAT_MOD_Y_TILED,
-	},
-	{ .name = "tiling-yf",
-	  .modifier = I915_FORMAT_MOD_Yf_TILED,
-	},
-	{ .name = "tiling-4",
-	  .modifier = I915_FORMAT_MOD_4_TILED,
-	},
-};
-
 igt_main
 {
 	data_t data = {};
@@ -358,12 +296,41 @@ igt_main
 		igt_require(data.display.is_atomic);
 	}
 
-	for (int i = 0; i < ARRAY_SIZE(subtests); i++) {
-		igt_describe_f("Tests the visibility of the planes when switching between "
-			       "high and low resolution with %s\n", subtests[i].name);
+	igt_describe("Tests the visibility of the planes when switching between "
+		     "high and low resolution\n");
+	igt_subtest_with_dynamic("tiling") {
+		enum pipe pipe;
+		igt_output_t *output;
+
+		for_each_pipe(&data.display, pipe) {
+			for_each_valid_output_on_pipe(&data.display, pipe, output) {
+				igt_plane_t *plane;
+				data.pipe = pipe;
+				data.output = output;
+
+				igt_display_reset(&data.display);
+				igt_output_set_pipe(data.output, data.pipe);
 
-		igt_subtest_with_dynamic(subtests[i].name)
-			run_test(&data, subtests[i].modifier);
+				if (!intel_pipe_output_combo_valid(&data.display))
+					continue;
+
+				data.pipe_crc = igt_pipe_crc_new(data.drm_fd, data.pipe,
+								  IGT_PIPE_CRC_SOURCE_AUTO);
+
+				plane = igt_output_get_plane_type(output, DRM_PLANE_TYPE_PRIMARY);
+
+				for (int i = 0; i < plane->format_mod_count; i++) {
+					if (plane->formats[i] != DRM_FORMAT_XRGB8888)
+						continue;
+
+		                        igt_dynamic_f("%s-pipe-%s-%s", igt_fb_modifier_name(plane->modifiers[i]),
+						      kmstest_pipe_name(pipe), data.output->name);
+					test_planes_on_pipe(&data, plane->modifiers[i]);
+
+					test_cleanup(&data);
+				}
+			}
+		}
 	}
 
 	igt_fixture {
-- 
2.25.1



More information about the igt-dev mailing list