[PATCH i-g-t v7 32/48] lib/unigraf: Add configuration for CRC usage

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

As Unigraf devices are able to compute a CRC for the input image, add a
configuration file option to use them.

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

diff --git a/lib/unigraf/unigraf.c b/lib/unigraf/unigraf.c
index 927eee3d184d..e9c9beb80c44 100644
--- a/lib/unigraf/unigraf.c
+++ b/lib/unigraf/unigraf.c
@@ -24,6 +24,7 @@
static TSI_HANDLE unigraf_device;
static char *unigraf_default_edid;
static char *unigraf_connector_name;
+static bool unigraf_crc;

/**
* UNIGRAF_NAME_MAX - Maximum name length to be used for TSI functions
@@ -60,6 +61,11 @@ static char *unigraf_connector_name;
*/
#define UNIGRAF_CONFIG_EDID_NAME "EDID"

+/**
+ * UNIGRAF_CONFIG_USE_CRC_NAME - Key of the CRC selection in the configuration file
+ */
+#define UNIGRAF_CONFIG_USE_CRC_NAME "UseCRC"
+
/**
* UNIGRAF_DEFAULT_ROLE_NAME - Default role name to search on the unigraf device
*/
@@ -358,6 +364,14 @@ bool unigraf_open_device(int drm_fd)
unigraf_debug("No default EDID set, use IGT default.\n");
cfg_edid_name = NULL;
}
+
+ cfg_error = NULL;
+ unigraf_crc = g_key_file_get_boolean(igt_key_file, UNIGRAF_CONFIG_GROUP,
+ UNIGRAF_CONFIG_USE_CRC_NAME, &cfg_error);
+ if (cfg_error) {
+ unigraf_debug("CRC usage not configured, using unigraf CRC.\n");
+ unigraf_crc = true;
+ }
}

unigraf_assert(TSIX_DEV_RescanDevices(0, TSI_DEVCAP_VIDEO_CAPTURE, 0));
@@ -680,3 +694,14 @@ void unigraf_read_crc(int stream, igt_crc_t *out)
out->n_words = 3;
out->has_valid_frame = false;
}
+
+/**
+ * unigraf_use_crc() - Check if Unigraf device should be used for CRC computation
+ *
+ * Returns: true if the Unigraf device should be used for CRC computation,
+ * false otherwise.
+ */
+bool unigraf_use_crc(void)
+{
+ return unigraf_crc;
+}
diff --git a/lib/unigraf/unigraf.h b/lib/unigraf/unigraf.h
index 8b38261dca09..f22f4c993622 100644
--- a/lib/unigraf/unigraf.h
+++ b/lib/unigraf/unigraf.h
@@ -74,4 +74,6 @@ void unigraf_select_stream(int stream);

void unigraf_read_crc(int stream, igt_crc_t *out);

+bool unigraf_use_crc(void);
+
#endif // UNIGRAF_H

--
2.52.0