[PATCH i-g-t v3 28/29] lib/igt_pipe_crc: Add ungiraf crc calculation

Louis Chauvet louis.chauvet at bootlin.com
Sat Aug 23 02:11:48 UTC 2025


Unigraf can read crc from the physical output, use this CRC instead of
internal CRC when configured. This allows to also test the hardware signal
generation.

This small addition allows to use the unigraf device for most of the
kms_* tests.

Signed-off-by: Louis Chauvet <louis.chauvet at bootlin.com>
---
 lib/igt_pipe_crc.c    | 27 +++++++++++++++++++++++++++
 lib/unigraf/unigraf.c |  1 +
 2 files changed, 28 insertions(+)

diff --git a/lib/igt_pipe_crc.c b/lib/igt_pipe_crc.c
index 866bf2881cbd04df0ae0cc8fe91fe0626367144f..64ef1fe47ea5735b56cf56b007831d404dd5cf5d 100644
--- a/lib/igt_pipe_crc.c
+++ b/lib/igt_pipe_crc.c
@@ -3,9 +3,12 @@
  * Copyright © 2013 Intel Corporation
  */
 
+#include "igt_core.h"
+#include "unigraf/unigraf.h"
 #include <inttypes.h>
 #include <sys/stat.h>
 #include <sys/mount.h>
+#include <xf86drmMode.h>
 #ifdef __linux__
 #include <sys/sysmacros.h>
 #endif
@@ -359,6 +362,30 @@ static void read_one_crc(igt_pipe_crc_t *pipe_crc, igt_crc_t *out)
 	} while (ret == -EINTR);
 
 	fcntl(pipe_crc->crc_fd, F_SETFL, pipe_crc->flags);
+
+#if HAVE_UNIGRAF
+	if (unigraf_open_device(pipe_crc->fd) && unigraf_use_crc()) {
+		int pipe_id;
+		int stream_id;
+		drmModeConnectorPtr connector = unigraf_get_connector(pipe_crc->fd);
+		if (!connector)
+			return;
+
+		pipe_id = igt_get_pipe_from_connector(pipe_crc->fd, connector->connector_id);
+		if (pipe_id != PIPE_NONE && pipe_id == pipe_crc->pipe) {
+			unigraf_read_crc(0, out);
+			return;
+		}
+
+		for (stream_id = 0; stream_id < unigraf_get_mst_stream_count(); stream_id++) {
+			pipe_id = unigraf_get_connector_by_stream(pipe_crc->fd, stream_id);
+			if (pipe_id != PIPE_NONE && pipe_id == pipe_crc->pipe) {
+				unigraf_read_crc(stream_id, out);
+				return;
+			}
+		}
+	}
+#endif
 }
 
 /**
diff --git a/lib/unigraf/unigraf.c b/lib/unigraf/unigraf.c
index 8de2c74affdda741b11933a1a55f1c2d2b1bb61b..d4403a6d42eabc748a841b307f76856454360279 100644
--- a/lib/unigraf/unigraf.c
+++ b/lib/unigraf/unigraf.c
@@ -1,6 +1,7 @@
 // SPDX-License-Identifier: MIT
 
 #include "glib.h"
+#include "igt_aux.h"
 #include "igt_core.h"
 #include <stdint.h>
 #include <stdio.h>

-- 
2.50.1



More information about the igt-dev mailing list