[PATCH i-g-t v3 19/29] lib/unigraf: Allows sst/mst configuration

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


Unigraf devices can emulate both SST and MST display port. In order to
write tests using both, add fews helper to manipulate them.

The define TSI_DPRX_NOT_DOCUMENTED_SIDEBAND_MSG_SUPPORT is taken from the
python SDK, as it was not defined by the C sdk nor documented.

Signed-off-by: Louis Chauvet <louis.chauvet at bootlin.com>
---
 lib/unigraf/unigraf.c | 72 +++++++++++++++++++++++++++++++++++++++++++++++++++
 lib/unigraf/unigraf.h | 38 +++++++++++++++++++++++++++
 2 files changed, 110 insertions(+)

diff --git a/lib/unigraf/unigraf.c b/lib/unigraf/unigraf.c
index b0b6af97acc563d7af163c175bb4a73bd25abdb9..6166a6d7e9bb8e348c8f6e6f42ad30b6487bbdd6 100644
--- a/lib/unigraf/unigraf.c
+++ b/lib/unigraf/unigraf.c
@@ -341,3 +341,75 @@ void unigraf_plug(void)
 	igt_assert(unigraf_device);
 	unigraf_write(TSI_DPRX_HPD_FORCE, &d, sizeof(d));
 }
+
+void unigraf_set_sst(void)
+{
+	int link_flags = 0xFFFFFFFF;
+
+	igt_assert(unigraf_device);
+	unigraf_unplug();
+	unigraf_assert(TSIX_TS_GetConfigItem(unigraf_device, TSI_DPRX_LINK_FLAGS,
+					     &link_flags, sizeof(link_flags)));
+	link_flags &= ~(TSI_DPRX_LINK_FLAGS_MST | TSI_DPRX_NOT_DOCUMENTED_SIDEBAND_MSG_SUPPORT);
+	unigraf_write(TSI_DPRX_LINK_FLAGS, &link_flags, sizeof(link_flags));
+	unigraf_plug();
+	unigraf_hpd_pulse(500000);
+}
+
+void unigraf_set_mst(void)
+{
+	int link_flags = 0xFFFFFFFF;
+
+	igt_assert(unigraf_device);
+	unigraf_assert(TSIX_TS_GetConfigItem(unigraf_device, TSI_DPRX_LINK_FLAGS,
+					     &link_flags, sizeof(link_flags)));
+	link_flags |= TSI_DPRX_LINK_FLAGS_MST | TSI_DPRX_NOT_DOCUMENTED_SIDEBAND_MSG_SUPPORT;
+	unigraf_write(TSI_DPRX_LINK_FLAGS, &link_flags, sizeof(link_flags));
+}
+
+int unigraf_get_mst_stream_max_count(void)
+{
+	int previous_count;
+	int max_count = -1;
+
+	// You can write any value to the register, but the actual
+	// value will not be more than the supported sink count.
+	previous_count = unigraf_get_mst_stream_count();
+	unigraf_write(TSI_DPRX_MST_SINK_COUNT, &max_count, sizeof(max_count));
+	max_count = unigraf_get_mst_stream_count();
+
+	unigraf_write(TSI_DPRX_MST_SINK_COUNT, &previous_count, sizeof(previous_count));
+	return max_count;
+}
+
+int unigraf_get_mst_stream_count(void)
+{
+	int count;
+
+	igt_assert(unigraf_device);
+
+	unigraf_assert(TSIX_TS_GetConfigItem(unigraf_device, TSI_DPRX_MST_SINK_COUNT,
+					     &count, sizeof(count)));
+
+	return count;
+}
+
+bool unigraf_set_mst_stream_count(int count)
+{
+	int new_count;
+
+	unigraf_write(TSI_DPRX_MST_SINK_COUNT, &count, sizeof(count));
+	new_count = unigraf_get_mst_stream_count();
+
+	igt_warn_on_f(count != new_count,
+		      "IGT:%p: Requested MST stream count (%d) differ from what was applied by the device (%d)\n",
+		      unigraf_device, count, new_count);
+
+	return count == new_count;
+}
+
+void unigraf_select_stream(int stream)
+{
+	igt_assert(unigraf_device);
+	unigraf_write(TSI_DPRX_STREAM_SELECT, &stream, sizeof(stream));
+}
diff --git a/lib/unigraf/unigraf.h b/lib/unigraf/unigraf.h
index 4f32a3632c8dcd6bd9900d821a93dba3cb77d62a..4d9eb1b926dfe9ad531e58243f4edf1623a24473 100644
--- a/lib/unigraf/unigraf.h
+++ b/lib/unigraf/unigraf.h
@@ -83,4 +83,42 @@ void unigraf_plug(void);
  */
 void unigraf_unplug(void);
 
+/**
+ * unigraf_set_sst() - Configure the device for Single Stream Transport mode
+ *
+ * This function sets the device to operate in Single Stream Transport (SST) mode.
+ */
+void unigraf_set_sst(void);
+
+/**
+ * unigraf_set_mst() - Configure the device for Multi Stream Transport mode
+ *
+ * This function sets the device to operate in Multi Stream Transport (MST) mode.
+ */
+void unigraf_set_mst(void);
+
+/**
+ * unigraf_get_mst_stream_count() - Get the current number of MST streams
+ *
+ * Returns: The current number of MST streams configured on the device.
+ */
+int unigraf_get_mst_stream_count(void);
+
+/**
+ * unigraf_set_mst_stream_count() - Set the number of accepted stream count
+ *
+ * Returns true when the stream count was properly applied, false if the final stream count
+ * is not the one requested
+ */
+bool unigraf_set_mst_stream_count(int count);
+
+/**
+ * unigraf_get_mst_stream_max_count() - Get the maximum number of stream count accepted by the
+ * device
+ * Caution: This function can be destructive to some configuration: the only way to get the
+ * information is to try and read the new value.
+ */
+int unigraf_get_mst_stream_max_count(void);
+void unigraf_select_stream(int stream);
+
 #endif // UNIGRAF_H

-- 
2.50.1



More information about the igt-dev mailing list