[PATCH i-g-t] tests/kms_flip_scaled_crc: throw away lsbs to match scaled to nonscaled

Juha-Pekka Heikkila juhapekka.heikkila at gmail.com
Wed Dec 30 19:17:47 UTC 2020


Try to mask lowest bits away from fb to get match with crcs on scaled and
non scaled image on gen9. This is basically cut'n'paste from what Ville
wrote on kms_plane some time ago.

Signed-off-by: Juha-Pekka Heikkila <juhapekka.heikkila at gmail.com>
---
 tests/kms_flip_scaled_crc.c | 31 +++++++++++++++++++++++++++++++
 1 file changed, 31 insertions(+)

diff --git a/tests/kms_flip_scaled_crc.c b/tests/kms_flip_scaled_crc.c
index 93d8031f7..8de96cfa0 100644
--- a/tests/kms_flip_scaled_crc.c
+++ b/tests/kms_flip_scaled_crc.c
@@ -26,6 +26,12 @@
 
 IGT_TEST_DESCRIPTION("Test flipping between scaled/nonscaled framebuffers");
 
+/*
+ * Throw away enough lsbs to get a match despite some differences between
+ * scaled/nonscaled image.
+ */
+#define LUT_MASK 0xf800
+
 typedef struct {
 	int drm_fd;
 	igt_display_t display;
@@ -89,6 +95,29 @@ const struct {
 	},
 };
 
+static void set_legacy_lut(data_t *data, enum pipe pipe,
+			   uint16_t mask)
+{
+	igt_pipe_t *pipe_obj = &data->display.pipes[pipe];
+	drmModeCrtc *crtc;
+	uint16_t *lut;
+	int i, lut_size;
+
+	crtc = drmModeGetCrtc(data->drm_fd, pipe_obj->crtc_id);
+	lut_size = crtc->gamma_size;
+	drmModeFreeCrtc(crtc);
+
+	lut = malloc(sizeof(uint16_t) * lut_size);
+
+	for (i = 0; i < lut_size; i++)
+		lut[i] = (i * 0xffff / (lut_size - 1)) & mask;
+
+	igt_assert_eq(drmModeCrtcSetGamma(data->drm_fd, pipe_obj->crtc_id,
+					  lut_size, lut, lut, lut), 0);
+
+	free(lut);
+}
+
 static void setup_fb(data_t *data, struct igt_fb *newfb, uint32_t width,
 		     uint32_t height, uint64_t format, uint64_t modifier)
 {
@@ -182,6 +211,7 @@ static void test_flip_to_scaled(data_t *data, uint32_t index, enum pipe pipe,
 	igt_output_set_pipe(output, pipe);
 
 	primary = igt_output_get_plane_type(output, DRM_PLANE_TYPE_PRIMARY);
+	set_legacy_lut(data, pipe, LUT_MASK);
 	igt_display_commit_atomic(&data->display, DRM_MODE_ATOMIC_ALLOW_MODESET,
 				  NULL);
 	data->pipe_crc = igt_pipe_crc_new(data->drm_fd, pipe,
@@ -209,6 +239,7 @@ static void test_flip_to_scaled(data_t *data, uint32_t index, enum pipe pipe,
 	igt_assert(read(data->drm_fd, &ev, sizeof(ev)) == sizeof(ev));
 
 	igt_pipe_crc_get_current(data->drm_fd, data->pipe_crc, &big_crc);
+	set_legacy_lut(data, pipe, 0xffff);
 	igt_assert(igt_check_crc_equal(&small_crc, &big_crc));
 
 	igt_pipe_crc_stop(data->pipe_crc);
-- 
2.28.0



More information about the Intel-gfx-trybot mailing list