[PATCH i-g-t v7 31/48] lib/unigraf: Add unigraf CRC capture

Louis Chauvet
2026-02-23T12:09:21Z

As unigraf devices are able to grab a CRC for the current video stream,
add an helper to read the CRC.

Reviewed-by: Kory Maincent <kory.maincent@bootlin.com>
Signed-off-by: Louis Chauvet <louis.chauvet@bootlin.com>
---
lib/unigraf/unigraf.c | 22 ++++++++++++++++++++++
lib/unigraf/unigraf.h | 3 +++
2 files changed, 25 insertions(+)

diff --git a/lib/unigraf/unigraf.c b/lib/unigraf/unigraf.c
index 549196bb90bd..927eee3d184d 100644
--- a/lib/unigraf/unigraf.c
+++ b/lib/unigraf/unigraf.c
@@ -15,6 +15,7 @@
#include "TSI.h"
#include "igt_edid.h"
#include "igt_kms.h"
+#include "igt_pipe_crc.h"
#include "igt_rc.h"
#include "monitor_edids/monitor_edids_helper.h"

@@ -658,3 +659,24 @@ void unigraf_select_stream(int stream)
{
unigraf_write_u32(TSI_DPRX_STREAM_SELECT, stream);
}
+
+/**
+ * unigraf_read_crc() - Read the CRC values from the Unigraf device
+ * @stream: Stream to grab the CRC from
+ * @out: Pointer to an igt_crc_t structure where the CRC values will be stored
+ *
+ * This function reads the CRC values from the Unigraf device and stores them in the
+ * provided igt_crc_t structure.
+ */
+void unigraf_read_crc(int stream, igt_crc_t *out)
+{
+ unigraf_select_stream(stream);
+ unigraf_assert(TSIX_TS_GetConfigItem(unigraf_device, TSI_DPRX_CRC_R_R,
+ &out->crc[0], sizeof(out->crc[0])));
+ unigraf_assert(TSIX_TS_GetConfigItem(unigraf_device, TSI_DPRX_CRC_G_R,
+ &out->crc[1], sizeof(out->crc[1])));
+ unigraf_assert(TSIX_TS_GetConfigItem(unigraf_device, TSI_DPRX_CRC_B_R,
+ &out->crc[2], sizeof(out->crc[2])));
+ out->n_words = 3;
+ out->has_valid_frame = false;
+}
diff --git a/lib/unigraf/unigraf.h b/lib/unigraf/unigraf.h
index fdc4441740fa..8b38261dca09 100644
--- a/lib/unigraf/unigraf.h
+++ b/lib/unigraf/unigraf.h
@@ -9,6 +9,7 @@
#ifndef UNIGRAF_H
#define UNIGRAF_H

+#include "igt_fb.h"
#include <stdbool.h>
#include <stdint.h>
#include <xf86drmMode.h>
@@ -71,4 +72,6 @@ int unigraf_get_mst_stream_max_count(void);

void unigraf_select_stream(int stream);

+void unigraf_read_crc(int stream, igt_crc_t *out);
+
#endif // UNIGRAF_H

--
2.52.0