Igt-dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: simon.zeni@collabora.com
To: igt-dev@lists.freedesktop.org
Cc: kamil.konieczny@linux.intel.com, karthik.b.s@intel.com,
	swati2.sharma@intel.com, adrinael@adrinael.net,
	juhapekka.heikkila@gmail.com,
	Simon Zeni <simon.zeni@collabora.com>
Subject: [PATCH i-g-t 3/3] tests/kms_plane: compare DRM_FORMAT_Y8 plane with greyscale reference CRC
Date: Wed,  2 Dec 2026 11:51:07 -0500	[thread overview]
Message-ID: <20261202165111.33166-4-simon.zeni@collabora.com> (raw)
In-Reply-To: <20261202165111.33166-1-simon.zeni@collabora.com>

From: Simon Zeni <simon.zeni@collabora.com>

The format DRM_FORMAT_Y8 is a specific YUV format that can't properly represent colours, so
comparing the tested plane against the existing reference CRC would yield a mismatch warning.

This introduced a new capture format CRC consisting of a solid grey colour aimed specifically at
greyscale colours which can't represent the full colour spectrum.

Signed-off-by: Simon Zeni <simon.zeni@collabora.com>
---
 tests/kms_plane.c | 58 +++++++++++++++++++++++++++++++++++++++++++++--
 1 file changed, 56 insertions(+), 2 deletions(-)

diff --git a/tests/kms_plane.c b/tests/kms_plane.c
index 388b869ea..0c6b98321 100644
--- a/tests/kms_plane.c
+++ b/tests/kms_plane.c
@@ -789,6 +789,36 @@ static void capture_format_crcs_single(data_t *data, igt_crtc_t *crtc,
 	igt_pipe_crc_get_current(data->drm_fd, data->pipe_crc, &crc[0]);
 }
 
+static void capture_format_crcs_greyscale(data_t *data, igt_crtc_t *crtc,
+					  igt_plane_t *plane,
+					  uint32_t format, uint64_t modifier,
+					  int width, int height,
+					  enum igt_color_encoding encoding,
+					  enum igt_color_range range,
+					  igt_crc_t crc[], struct igt_fb *fb)
+{
+	struct igt_fb old_fb = *fb;
+	const color_t grey = { 0.5f, 0.5f, 0.5f };
+
+	prepare_format_color(data, plane, format, modifier,
+			     width, height, encoding, range, &grey, fb, false);
+
+	igt_display_commit2(&data->display, data->display.is_atomic ?
+			    COMMIT_ATOMIC : COMMIT_UNIVERSAL);
+
+	igt_remove_fb(data->drm_fd, &old_fb);
+
+	/*
+	 * On MediaTek hardware, CRC generation needs time to stabilize after
+	 * a pixel format change. Wait for at least one vblank to ensure the
+	 * CRC hardware has updated for the new format.
+	 */
+	if (is_mtk_device(data->drm_fd))
+		igt_wait_for_vblank(crtc);
+
+	igt_pipe_crc_get_current(data->drm_fd, data->pipe_crc, &crc[0]);
+}
+
 static void capture_format_crcs_multiple(data_t *data, igt_crtc_t *crtc,
 					 igt_plane_t *plane,
 					 uint32_t format, uint64_t modifier,
@@ -939,6 +969,13 @@ static bool test_format_plane_colors(data_t *data, igt_crtc_t *crtc,
 					     width, height, encoding, range, crc,
 					     fb);
 		total_crcs = data->num_colors;
+	} else if (format == DRM_FORMAT_Y8) {
+		capture_format_crcs_greyscale(data,
+					   crtc,
+					   plane, format,
+					   modifier,
+					   width, height, encoding, range, crc,
+					   fb);
 	} else {
 		capture_format_crcs_single(data,
 					   crtc,
@@ -1049,6 +1086,7 @@ static bool test_format_plane_yuv(data_t *data, igt_crtc_t *crtc,
 
 enum crc_set {
 	SINGLE_CRC_SET,
+	GREYSCALE_CRC_SET,
 	MULTIPLE_CRC_SET,
 	MAX_CRC_SET,
 };
@@ -1133,6 +1171,7 @@ static void test_format_plane(data_t *data, igt_crtc_t *crtc,
 	struct igt_vec tested_formats;
 	struct format_mod ref = {};
 	struct format_mod f = {};
+	enum crc_set set;
 	igt_crc_t* crcset;
 	bool result = true;
 
@@ -1178,6 +1217,14 @@ static void test_format_plane(data_t *data, igt_crtc_t *crtc,
 				   IGT_COLOR_YCBCR_LIMITED_RANGE,
 				   ref_crc[SINGLE_CRC_SET], &fb);
 
+	capture_format_crcs_greyscale(data,
+				   crtc,
+				   plane, ref.format,
+				   ref.modifier,
+				   width, height, IGT_COLOR_YCBCR_BT709,
+				   IGT_COLOR_YCBCR_LIMITED_RANGE,
+				   ref_crc[GREYSCALE_CRC_SET], &fb);
+
 	capture_format_crcs_multiple(data,
 				     crtc,
 				     plane, ref.format,
@@ -1219,8 +1266,15 @@ static void test_format_plane(data_t *data, igt_crtc_t *crtc,
 				continue;
 		}
 
-		crcset = ref_crc[use_multiple_colors(data, f.format) ?
-				 MULTIPLE_CRC_SET : SINGLE_CRC_SET];
+		if (use_multiple_colors(data, f.format)) {
+			set = MULTIPLE_CRC_SET;
+		} else if (f.format == DRM_FORMAT_Y8) {
+			set = GREYSCALE_CRC_SET;
+		} else {
+			set = SINGLE_CRC_SET;
+		}
+
+		crcset = ref_crc[set];
 
 		if (igt_format_is_yuv(f.format))
 			result &= test_format_plane_yuv(data,
-- 
2.53.0


  parent reply	other threads:[~2026-12-02 16:54 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-02 16:51 [PATCH i-g-t 0/3] Add support for DRM_FORMAT_Y8 in tests/kms_plane simon.zeni
2026-12-02 16:51 ` [PATCH i-g-t 1/3] drm-uapi/fourcc: sync with drm-next 601c30449 simon.zeni
2026-12-02 16:51 ` [PATCH i-g-t 2/3] lib/igt_fb: add support for DRM_FORMAT_Y8 simon.zeni
2026-12-02 16:51 ` simon.zeni [this message]
2026-12-02 21:08 ` ✓ Xe.CI.BAT: success for Add support for DRM_FORMAT_Y8 in tests/kms_plane Patchwork
2026-12-02 21:57 ` ✓ i915.CI.BAT: " Patchwork
  -- strict thread matches above, loose matches on Subject: below --
2026-11-25 19:37 [PATCH i-g-t 1/3] drm_uapi/fourcc: sync with drm-next Simon Zeni
2026-11-25 19:37 ` [PATCH i-g-t 3/3] tests/kms_plane: compare DRM_FORMAT_Y8 plane with greyscale reference CRC Simon Zeni

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261202165111.33166-4-simon.zeni@collabora.com \
    --to=simon.zeni@collabora.com \
    --cc=adrinael@adrinael.net \
    --cc=igt-dev@lists.freedesktop.org \
    --cc=juhapekka.heikkila@gmail.com \
    --cc=kamil.konieczny@linux.intel.com \
    --cc=karthik.b.s@intel.com \
    --cc=swati2.sharma@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox