[PATCH i-g-t 9/9] tests/kms_plane: Add black and white test

Louis Chauvet louis.chauvet at bootlin.com
Wed Mar 6 17:28:43 UTC 2024


The black and white formats can't use the same list of colors as the
standard colors test. This new subtest uses only black and white to check
if the conversion is correct.

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

diff --git a/tests/kms_plane.c b/tests/kms_plane.c
index 8e92d2e13993..1d47ccc73f75 100644
--- a/tests/kms_plane.c
+++ b/tests/kms_plane.c
@@ -521,6 +521,11 @@ static const color_t colors_reduced[] = {
 	{ 0.0f, 1.0f, 1.0f, },
 };
 
+static const color_t color_black_white[] = {
+	{ 1.0f, 1.0f, 1.0f },
+	{ 0.0f, 0.0f, 0.0f },
+};
+
 static void set_legacy_lut(data_t *data, enum pipe pipe,
 			   uint16_t mask)
 {
@@ -1159,6 +1164,118 @@ static bool test_format_plane(data_t *data, enum pipe pipe,
 	return result;
 }
 
+static bool test_format_black_and_white_plane(data_t *data, enum pipe pipe,
+					      igt_output_t *output, igt_plane_t *plane, igt_fb_t *primary_fb)
+{
+	struct igt_fb fb = {};
+	struct igt_fb *clear_fb = plane->type == DRM_PLANE_TYPE_PRIMARY ? primary_fb : NULL;
+	drmModeModeInfo *mode;
+	int width, height;
+	igt_crc_t ref_crc[ARRAY_SIZE(color_black_white) + 1];
+	igt_crc_t crc[ARRAY_SIZE(color_black_white) + 1];
+	struct format_mod ref = {};
+	bool result = true;
+
+	/*
+	 * No clamping test for cursor plane
+	 */
+	if (data->crop != 0 && plane->type == DRM_PLANE_TYPE_CURSOR)
+		return true;
+
+
+	mode = igt_output_get_mode(output);
+	if (plane->type != DRM_PLANE_TYPE_CURSOR) {
+		width = mode->hdisplay;
+		height = mode->vdisplay;
+		ref.format = DRM_FORMAT_XRGB8888;
+		ref.modifier = DRM_FORMAT_MOD_LINEAR;
+	} else {
+		if (!plane->drm_plane) {
+			igt_debug("Only legacy cursor ioctl supported, skipping cursor plane\n");
+			return true;
+		}
+		do_or_die(drmGetCap(data->drm_fd, DRM_CAP_CURSOR_WIDTH, &width));
+		do_or_die(drmGetCap(data->drm_fd, DRM_CAP_CURSOR_HEIGHT, &height));
+		ref.format = DRM_FORMAT_ARGB8888;
+		ref.modifier = DRM_FORMAT_MOD_LINEAR;
+	}
+
+	igt_debug("Testing connector %s on %s plane %s.%u with black and white colors\n",
+		  igt_output_name(output), kmstest_plane_type_name(plane->type),
+		  kmstest_pipe_name(pipe), plane->index);
+
+	igt_pipe_crc_start(data->pipe_crc);
+
+	igt_info("Testing format " IGT_FORMAT_FMT " / modifier " IGT_MODIFIER_FMT " on %s.%u for reference CRC\n",
+		 IGT_FORMAT_ARGS(ref.format), IGT_MODIFIER_ARGS(ref.modifier),
+		 kmstest_pipe_name(pipe), plane->index);
+
+	check_allowed_plane_size_64x64(data, plane, &width, &height, ref.format);
+
+	/* Capture the reference CRCs */
+	capture_format_crcs_single(data, pipe, plane, ref.format, ref.modifier,
+				   width, height, IGT_COLOR_YCBCR_BT709,
+				   IGT_COLOR_YCBCR_LIMITED_RANGE,
+				   &ref_crc[0], &fb, color_black_white, ARRAY_SIZE(color_black_white));
+
+	for (int i = 0; i < ARRAY_SIZE(color_black_white); i++) {
+		capture_format_crcs_single(data, pipe, plane, ref.format, ref.modifier, width, height,
+					   IGT_COLOR_YCBCR_BT709, IGT_COLOR_YCBCR_LIMITED_RANGE, &ref_crc[i + 1], &fb,
+					   &color_black_white[i], 1);
+	}
+
+	for (int i = 0; i < plane->format_mod_count; i++) {
+		uint32_t format = plane->formats[i];
+		uint64_t modifier = plane->modifiers[i];
+
+		if (!igt_fb_supported_format(format)
+		    || !igt_format_is_black_white(format))
+			continue;
+
+		igt_info("Testing format " IGT_FORMAT_FMT " / modifier " IGT_MODIFIER_FMT " on %s.%u\n",
+			 IGT_FORMAT_ARGS(format), IGT_MODIFIER_ARGS(modifier),
+			 kmstest_pipe_name(pipe), plane->index);
+
+		capture_format_crcs_single(data, pipe, plane, format, modifier,
+					   width, height, IGT_COLOR_YCBCR_BT709,
+					   IGT_COLOR_YCBCR_LIMITED_RANGE,
+					   &crc[0], &fb, color_black_white, ARRAY_SIZE(color_black_white));
+
+		for (int i = 0; i < ARRAY_SIZE(color_black_white); i++) {
+			capture_format_crcs_single(data, pipe, plane, format, modifier, width, height,
+						   IGT_COLOR_YCBCR_BT709, IGT_COLOR_YCBCR_LIMITED_RANGE, &crc[i + 1],
+						   &fb,
+						   &color_black_white[i], 1);
+		}
+
+		bool tmp_result = igt_check_crc_equal(&crc[0], &ref_crc[0]);
+		if (!tmp_result)
+			igt_warn(
+				"Format " IGT_FORMAT_FMT " / modifier " IGT_MODIFIER_FMT " failed on %s.%u with the array pattern\n",
+				IGT_FORMAT_ARGS(format), IGT_MODIFIER_ARGS(modifier), kmstest_pipe_name(pipe),
+				plane->index);
+		result &= tmp_result;
+
+		for (int i = 1; i < ARRAY_SIZE(crc); i++) {
+			tmp_result = igt_check_crc_equal(&crc[i], &ref_crc[i]);
+			if (!tmp_result)
+				igt_warn(
+					"Format " IGT_FORMAT_FMT " / modifier " IGT_MODIFIER_FMT " failed on %s.%u for the color (r=%f,g=%f,b=%f)\n",
+					IGT_FORMAT_ARGS(format), IGT_MODIFIER_ARGS(modifier), kmstest_pipe_name(pipe),
+					plane->index, color_black_white[i - 1].red, color_black_white[i - 1].green,
+					color_black_white[i - 1].blue);
+			result &= tmp_result;
+		}
+	}
+
+	igt_pipe_crc_stop(data->pipe_crc);
+
+	igt_plane_set_fb(plane, clear_fb);
+	igt_remove_fb(data->drm_fd, &fb);
+
+	return result;
+}
+
 static bool skip_plane(data_t *data, igt_plane_t *plane)
 {
 	int index = plane->index;
@@ -1251,6 +1368,55 @@ test_pixel_formats(data_t *data, enum pipe pipe)
 
 	igt_assert_f(result, "At least one CRC mismatch happened\n");
 }
+
+
+static void
+test_pixel_black_and_white_formats(data_t *data, enum pipe pipe)
+{
+	struct igt_fb primary_fb;
+	igt_plane_t *primary;
+	drmModeModeInfo *mode;
+	bool result;
+	igt_output_t *output = data->output;
+	igt_plane_t *plane;
+
+	igt_info("Using (pipe %s + %s) to run the subtest.\n",
+		 kmstest_pipe_name(pipe), igt_output_name(output));
+
+	test_init(data, pipe);
+
+	mode = igt_output_get_mode(output);
+
+	igt_create_fb(data->drm_fd, mode->hdisplay, mode->vdisplay,
+		      DRM_FORMAT_XRGB8888, DRM_FORMAT_MOD_LINEAR, &primary_fb);
+
+	igt_output_set_pipe(output, pipe);
+	primary = igt_output_get_plane_type(output, DRM_PLANE_TYPE_PRIMARY);
+	igt_plane_set_fb(primary, &primary_fb);
+
+	igt_display_commit2(&data->display, data->display.is_atomic ? COMMIT_ATOMIC : COMMIT_LEGACY);
+
+	set_legacy_lut(data, pipe, LUT_MASK);
+
+	result = true;
+	for_each_plane_on_pipe(&data->display, pipe, plane) {
+		if (skip_plane(data, plane))
+			continue;
+		result &= test_format_black_and_white_plane(data, pipe, output, plane, &primary_fb);
+	}
+
+	test_fini(data);
+
+	set_legacy_lut(data, pipe, 0xffff);
+
+	igt_plane_set_fb(primary, NULL);
+	igt_output_set_pipe(output, PIPE_NONE);
+	igt_display_commit2(&data->display, data->display.is_atomic ? COMMIT_ATOMIC : COMMIT_LEGACY);
+
+	igt_remove_fb(data->drm_fd, &primary_fb);
+
+	igt_assert_f(result, "At least one CRC mismatch happened\n");
+}
 static void test_odd_size_with_yuv(data_t *data)
 {
 	enum pipe pipe = PIPE_A;
@@ -1350,9 +1516,13 @@ static void
 run_tests_for_pipe_plane(data_t *data)
 {
 	igt_describe("verify the pixel formats for given plane and pipe");
-	igt_subtest_with_dynamic_f("pixel-format")
+	igt_subtest_with_dynamic_f("pixel-format-colors")
 		run_test(data, test_pixel_formats);
 
+	igt_describe("verify the black and white pixel formats for given plane and pipe");
+	igt_subtest_with_dynamic_f("pixel-format-black-white")
+		run_test(data, test_pixel_black_and_white_formats);
+
 	igt_describe("verify the pixel formats for given plane and pipe with source clamping");
 	igt_subtest_with_dynamic_f("pixel-format-source-clamping") {
 		data->crop = 4;

-- 
2.43.0



More information about the igt-dev mailing list