[PATCH i-g-t v7 44/48] lib/unigraf: Add lane count configuration

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

As unigraf can emulate 1, 2 or 4 lanes display port connections, add
helpers to configure the number of lanes.

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

diff --git a/lib/unigraf/unigraf.c b/lib/unigraf/unigraf.c
index 17b96aa3ac89..038188182bc5 100644
--- a/lib/unigraf/unigraf.c
+++ b/lib/unigraf/unigraf.c
@@ -543,6 +543,7 @@ void unigraf_reset(void)
unigraf_set_sst();
unigraf_load_default_edid();
unigraf_hpd_assert();
+ unigraf_set_max_lane_count(4);
}

/**
@@ -803,3 +804,31 @@ void unigraf_assert_stream_timings(int stream, drmModeModeInfoPtr mode_info)
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));
}
+
+/**
+ * unigraf_set_max_lane_count() - Set the maximum number of lanes advertised to the DUT
+ * @count: The maximum number of lanes to configure on the device
+ *
+ * This function sets the maximum number of lanes that the device will advertise on the DP link.
+ * The actual number of lanes used may be less than the requested count if the
+ * DUT does not support/use it.
+ */
+void unigraf_set_max_lane_count(uint32_t count)
+{
+ unigraf_write_u32(TSI_DPRX_MAX_LANES, count);
+}
+
+/**
+ * unigraf_get_max_lane_count() - Get the maximum number of lanes supported by the device
+ *
+ * Returns: The maximum number of lanes supported by the device.
+ */
+int unigraf_get_max_lane_count(void)
+{
+ int max_lanes;
+
+ igt_assert(unigraf_device);
+ unigraf_assert(TSIX_TS_GetConfigItem(unigraf_device, TSI_DPRX_MAX_LANES,
+ &max_lanes, sizeof(max_lanes)));
+ return max_lanes;
+}
diff --git a/lib/unigraf/unigraf.h b/lib/unigraf/unigraf.h
index 65f00c8d4948..e926855dd059 100644
--- a/lib/unigraf/unigraf.h
+++ b/lib/unigraf/unigraf.h
@@ -80,4 +80,8 @@ int unigraf_get_connector_id_by_stream(int drm_fd, int stream_id);

void unigraf_assert_stream_timings(int stream, drmModeModeInfoPtr mode_info);

+int unigraf_get_max_lane_count(void);
+
+void unigraf_set_max_lane_count(uint32_t count);
+
#endif // UNIGRAF_H

--
2.52.0