[PATCH i-g-t 2/3] tests/kms/plane: Use a complex pattern to test plane color conversion.

Louis Chauvet louis.chauvet at bootlin.com
Thu Feb 1 16:35:54 UTC 2024


Replace the simple "lines pattern" by a "square pattern" to detect if the
drm device correctly render the picture.

It's useful for example for the series [1] where the tests are "SUCCESS",
but in fact it works only because the content of a line is the same. The
"square pattern" will detect this kind of issues on the x axis.

It also allows this "square pattern" to be tested in the
"capture_format_crcs_multiple" tests, otherwise it is not executed for yuv
formats.

[1]: https://lore.kernel.org/dri-devel/20240110-vkms-yuv-v2-0-952fcaa5a193@riseup.net/

Signed-off-by: Louis Chauvet <louis.chauvet at bootlin.com>
---
 tests/kms_plane.c | 42 +++++++++++++++++++++++++++++-------------
 1 file changed, 29 insertions(+), 13 deletions(-)

diff --git a/tests/kms_plane.c b/tests/kms_plane.c
index 0bca96692b14..296d5af3eb91 100644
--- a/tests/kms_plane.c
+++ b/tests/kms_plane.c
@@ -587,7 +587,10 @@ static void draw_entire_color_array(data_t *data, cairo_t *cr, uint32_t format,
 				    struct igt_fb *fb)
 {
 	const int color_amount = ARRAY_SIZE(colors_extended);
-	const int x = format == DRM_FORMAT_XRGB8888 ? 0 : data->crop;
+	const int margin = format == DRM_FORMAT_XRGB8888 ? 0 : data->crop;
+	const int step_x = (fb->width - margin * 2) / color_amount;
+	const int step_y = (fb->height - margin * 2) / color_amount;
+	int color_index;
 
 	if (format != DRM_FORMAT_XRGB8888) {
 		cairo_rectangle(cr, data->crop, data->crop,
@@ -595,16 +598,18 @@ static void draw_entire_color_array(data_t *data, cairo_t *cr, uint32_t format,
 				fb->height - data->crop * 2);
 	}
 
-
 	for (int n = 0; n < color_amount; n++) {
-		int y = (fb->height - x * 2) * n / color_amount + x;
-
-		igt_paint_color(cr, x, y,
-				fb->width - x * 2,
-				(fb->height - x * 2) / color_amount + 1,
-				colors_extended[n].red,
-				colors_extended[n].green,
-				colors_extended[n].blue);
+		for (int m = 0; m < color_amount; m++) {
+			color_index = (n + m) % color_amount;
+			igt_paint_color(cr,
+					margin + n * step_x,
+					margin + m * step_y,
+					step_x,
+					step_y,
+					colors_extended[color_index].red,
+					colors_extended[color_index].green,
+					colors_extended[color_index].blue);
+		}
 	}
 }
 
@@ -712,6 +717,11 @@ static void capture_format_crcs_single(data_t *data, enum pipe pipe,
 	igt_pipe_crc_get_current(data->drm_fd, data->pipe_crc, &crc[0]);
 }
 
+/*
+ * capture_format_crcs_multiple() - Capture CRC for multiples colors
+ *
+ * @crc: list to store generated CRC. It must be at least data.num_colors + 1
+ */
 static void capture_format_crcs_multiple(data_t *data, enum pipe pipe,
 					 igt_plane_t *plane,
 					 uint32_t format, uint64_t modifier,
@@ -724,6 +734,12 @@ static void capture_format_crcs_multiple(data_t *data, enum pipe pipe,
 	struct drm_event_vblank ev;
 	int i;
 
+	/* Also run single colors to capture more failures */
+	capture_format_crcs_single(data, pipe, plane, format, modifier, width, height, encoding, range, crc, fb);
+
+	/* Skip the first crc as it's taken by "capture_format_crcs_single" */
+	crc = crc + 1;
+
 restart_round:
 	for (i = 0; i < data->num_colors; i++) {
 		const color_t *c = &data->colors[i];
@@ -849,7 +865,7 @@ static bool test_format_plane_colors(data_t *data, enum pipe pipe,
 				     igt_crc_t ref_crc[],
 				     struct igt_fb *fb)
 {
-	igt_crc_t crc[ARRAY_SIZE(colors_extended)];
+	igt_crc_t crc[ARRAY_SIZE(colors_extended) + 1];
 	unsigned int crc_mismatch_mask = 0;
 	int crc_mismatch_count = 0;
 	bool result = true;
@@ -859,7 +875,7 @@ static bool test_format_plane_colors(data_t *data, enum pipe pipe,
 		capture_format_crcs_multiple(data, pipe, plane, format, modifier,
 					     width, height, encoding, range, crc,
 					     fb);
-		total_crcs = data->num_colors;
+		total_crcs = data->num_colors + 1;
 	} else {
 		capture_format_crcs_single(data, pipe, plane, format, modifier,
 					   width, height, encoding, range, crc,
@@ -1006,7 +1022,7 @@ static bool test_format_plane(data_t *data, enum pipe pipe,
 	struct igt_fb *clear_fb = plane->type == DRM_PLANE_TYPE_PRIMARY ? primary_fb : NULL;
 	drmModeModeInfo *mode;
 	uint64_t width, height;
-	igt_crc_t ref_crc[MAX_CRC_SET][ARRAY_SIZE(colors_extended)];
+	igt_crc_t ref_crc[MAX_CRC_SET][ARRAY_SIZE(colors_extended) + 1];
 	struct igt_vec tested_formats;
 	struct format_mod ref = {};
 	igt_crc_t* crcset;

-- 
2.43.0



More information about the igt-dev mailing list