[PATCH i-g-t v7 34/48] lib/unigraf: Add helper to check timings received by unigraf

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

Unigraf device can check that some input video parameters.
Add a function to compare a mode with the actual signal
received by the unigraf.

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

diff --git a/lib/unigraf/unigraf.c b/lib/unigraf/unigraf.c
index 5d9edb8cd069..f30205bbed0b 100644
--- a/lib/unigraf/unigraf.c
+++ b/lib/unigraf/unigraf.c
@@ -746,3 +746,38 @@ bool unigraf_use_crc(void)
{
return unigraf_crc;
}
+
+static void unigraf_read_msa(void)
+{
+ uint32_t data = 1;
+
+ unigraf_write_u32(TSI_DPRX_MSA_COMMAND_W, data);
+}
+
+/**
+ * unigraf_assert_stream_timings() - Assert that the received stream on unigraf
+ * matches the mode_info
+ * @stream: Stream id on the unigraf
+ * @mode_info: Mode to compare with
+ */
+void unigraf_assert_stream_timings(int stream, drmModeModeInfoPtr mode_info)
+{
+ uint32_t stream_count;
+
+ igt_assert(mode_info);
+
+ unigraf_read_msa();
+ stream_count = unigraf_read_u32(TSI_DPRX_MSA_STREAM_COUNT_R);
+ igt_assert_lt(stream, stream_count);
+ unigraf_write_u32(TSI_DPRX_MSA_STREAM_SELECT, stream);
+ igt_assert_eq(mode_info->htotal, unigraf_read_u32(TSI_DPRX_MSA_HTOTAL_R));
+ igt_assert_eq(mode_info->vtotal, unigraf_read_u32(TSI_DPRX_MSA_VTOTAL_R));
+ igt_assert_eq(mode_info->hdisplay, unigraf_read_u32(TSI_DPRX_MSA_HACTIVE_R));
+ igt_assert_eq(mode_info->vdisplay, unigraf_read_u32(TSI_DPRX_MSA_VACTIVE_R));
+ igt_assert_eq(mode_info->hsync_end - mode_info->hsync_start,
+ unigraf_read_u32(TSI_DPRX_MSA_HSYNC_WIDTH_R));
+ igt_assert_eq(mode_info->vsync_end - mode_info->vsync_start,
+ unigraf_read_u32(TSI_DPRX_MSA_VSYNC_WIDTH_R));
+ igt_assert_eq(mode_info->vsync_start, unigraf_read_u32(TSI_DPRX_MSA_VSTART_R));
+ igt_assert_eq(mode_info->hsync_start, unigraf_read_u32(TSI_DPRX_MSA_HSTART_R));
+}
diff --git a/lib/unigraf/unigraf.h b/lib/unigraf/unigraf.h
index 0ed6d1eb2713..65f00c8d4948 100644
--- a/lib/unigraf/unigraf.h
+++ b/lib/unigraf/unigraf.h
@@ -78,4 +78,6 @@ bool unigraf_use_crc(void);

int unigraf_get_connector_id_by_stream(int drm_fd, int stream_id);

+void unigraf_assert_stream_timings(int stream, drmModeModeInfoPtr mode_info);
+
#endif // UNIGRAF_H

--
2.52.0