[PATCH i-g-t 3/3] tests: kms_crtc_background_color: add CRC based test

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Add an additional test using the CRC unit on the pipe to verify
setting the background color on the pipe produces the same CRCs as
setting a plane with cairo colored pixels.

Also only requires the CRC support for that test.

Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin@xxxxxxxxx>
---
 tests/kms_crtc_background_color.c | 99 ++++++++++++++++++++++++++++++++++-----
 1 file changed, 86 insertions(+), 13 deletions(-)

diff --git a/tests/kms_crtc_background_color.c b/tests/kms_crtc_background_color.c
index dbf9609..cab849d 100644
--- a/tests/kms_crtc_background_color.c
+++ b/tests/kms_crtc_background_color.c
@@ -37,7 +37,12 @@ typedef struct {
 } data_t;
 
 /* 8bpc values software rendered by Cairo */
+#define CAIRO_BLACK      0x000000
+#define CAIRO_CYAN       0xFFFF00
 #define CAIRO_PURPLE     0xFF00FF
+#define CAIRO_RED        0x0000FF
+#define CAIRO_WHITE      0xFFFFFF
+#define CAIRO_YELLOW     0x00FFFF
 
 /* 16bpc values (alpha is ignored) */
 #define BLACK64    DRM_RGBA16161616(0x0000, 0x0000, 0x0000, 0x0000)
@@ -49,6 +54,15 @@ typedef struct {
 #define GREEN64    DRM_RGBA16161616(0x0000, 0xFFFF, 0x0000, 0x0000)
 #define BLUE64     DRM_RGBA16161616(0x0000, 0x0000, 0xFFFF, 0x0000)
 
+/* 8bpc values (alpha is ignored) */
+#define CYAN8      DRM_RGBA8888(0x00, 0xFF, 0xFF, 0x00)
+#define PURPLE8    DRM_RGBA8888(0xFF, 0x00, 0xFF, 0x00)
+#define YELLOW8    DRM_RGBA8888(0xFF, 0xFF, 0x00, 0x00)
+#define WHITE8     DRM_RGBA8888(0xFF, 0xFF, 0xFF, 0x00)
+#define RED8       DRM_RGBA8888(0xFF, 0x00, 0x00, 0x00)
+#define GREEN8     DRM_RGBA8888(0x00, 0xFF, 0x00, 0x00)
+#define BLUE8      DRM_RGBA8888(0x00, 0x00, 0xFF, 0x00)
+
 static void
 paint_background(data_t *data, struct igt_fb *fb, drmModeModeInfo *mode,
 		uint32_t background, double alpha)
@@ -82,10 +96,6 @@ static void prepare_crtc(data_t *data, igt_output_t *output, enum pipe pipe,
 
 	igt_output_set_pipe(output, pipe);
 
-	/* create the pipe_crc object for this pipe */
-	igt_pipe_crc_free(data->pipe_crc);
-	data->pipe_crc = igt_pipe_crc_new(pipe, INTEL_PIPE_CRC_SOURCE_AUTO);
-
 	mode = igt_output_get_mode(output);
 
 	fb_id = igt_create_fb(data->gfx_fd,
@@ -111,9 +121,6 @@ static void cleanup_crtc(data_t *data, igt_output_t *output, igt_plane_t *plane)
 {
 	igt_display_t *display = &data->display;
 
-	igt_pipe_crc_free(data->pipe_crc);
-	data->pipe_crc = NULL;
-
 	igt_remove_fb(data->gfx_fd, &data->fb);
 
 	igt_crtc_set_background(plane->pipe, BLACK64);
@@ -174,17 +181,83 @@ static void test_crtc_background(data_t *data)
 	igt_require_f(valid_tests, "no valid crtc/connector combinations found\n");
 }
 
-igt_simple_main
+static void verify_color_match(data_t *data,
+			       igt_output_t *output,
+			       uint64_t background_color,
+			       uint32_t plane_color)
+{
+	igt_plane_t *plane = igt_output_get_plane(output, IGT_PLANE_PRIMARY);
+	enum pipe pipe = output->config.pipe;
+	igt_crc_t crc_plane, crc_background;
+
+	prepare_crtc(data, output, pipe, plane, 1, plane_color, RED64);
+	igt_wait_for_vblank(data->gfx_fd, pipe);
+	igt_pipe_crc_collect_crc(data->pipe_crc, &crc_plane);
+
+	igt_plane_set_fb(plane, NULL);
+	igt_crtc_set_background(&data->display.pipes[pipe], background_color);
+	igt_wait_for_vblank(data->gfx_fd, pipe);
+	igt_pipe_crc_collect_crc(data->pipe_crc, &crc_background);
+	cleanup_crtc(data, output, plane);
+
+	igt_assert_crc_equal(&crc_plane, &crc_background);
+}
+
+/*
+ * Verify colors set on a plane covering the entire the screen yield
+ * the same CRC as the same colors set on the background.
+ */
+static void test_crtc_background_crc(data_t *data)
+{
+
+	igt_display_t *display = &data->display;
+	igt_output_t *output;
+
+	igt_require_pipe_crc();
+	igt_require(data->display.has_universal_planes);
+
+	for_each_connected_output(display, output) {
+		enum pipe p = output->config.pipe;
+		igt_pipe_t *pipe = &display->pipes[p];
+
+		igt_output_set_pipe(output, p);
+
+		igt_require(pipe->background_property);
+
+		/* create the pipe_crc object for this pipe */
+		igt_pipe_crc_free(data->pipe_crc);
+		data->pipe_crc = igt_pipe_crc_new(p,
+						  INTEL_PIPE_CRC_SOURCE_AUTO);
+
+		verify_color_match(data, output, BLACK64, CAIRO_BLACK);
+		verify_color_match(data, output, CYAN8, CAIRO_CYAN);
+		verify_color_match(data, output, PURPLE8, CAIRO_PURPLE);
+		verify_color_match(data, output, YELLOW8, CAIRO_YELLOW);
+		verify_color_match(data, output, RED8, CAIRO_RED);
+
+		igt_pipe_crc_free(data->pipe_crc);
+		data->pipe_crc = NULL;
+	}
+}
+
+igt_main
 {
 	data_t data = {};
 
 	igt_skip_on_simulation();
 
-	data.gfx_fd = drm_open_driver(DRIVER_INTEL);
-	igt_require_pipe_crc();
-	igt_display_init(&data.display, data.gfx_fd);
+	igt_fixture {
+		data.gfx_fd = drm_open_driver(DRIVER_INTEL);
+		igt_display_init(&data.display, data.gfx_fd);
+	}
 
-	test_crtc_background(&data);
+	igt_subtest_f("crtc-background")
+		test_crtc_background(&data);
 
-	igt_display_fini(&data.display);
+	igt_subtest_f("crtc-background-crc")
+		test_crtc_background_crc(&data);
+
+	igt_fixture {
+		igt_display_fini(&data.display);
+	}
 }
-- 
2.7.0

_______________________________________________
Intel-gfx mailing list
Intel-gfx@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/intel-gfx




[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]
  Powered by Linux