[PATCH i-g-t v3 17/29] lib/unigraf: Add unigraf assert and deassert helpers

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


Unigraf is able to manipulate the HPD line of the connector, add few
helpers to manipulate them.

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

diff --git a/lib/unigraf/unigraf.c b/lib/unigraf/unigraf.c
index 59a85e1b84c9df47a56f0273dac37d2dcba175c3..0682f383aaa0f5eb8d4b40bb88c2ea88975f311f 100644
--- a/lib/unigraf/unigraf.c
+++ b/lib/unigraf/unigraf.c
@@ -88,6 +88,24 @@ static void unigraf_init(void)
 	igt_install_exit_handler(unigraf_exit_handler);
 }
 
+/**
+ * unigraf_write() - Helper to write a value to unigraf
+ * @dev: device handle, can be null for some config id
+ * @config: config id to write
+ * @data: data to write
+ * @data_len: length of the data
+ * Returns
+ */
+static void unigraf_write(TSI_CONFIG_ID config, const void *data, size_t data_len)
+{
+	unigraf_debug("Writing %zu bytes to 0x%x\n", data_len, config);
+
+	if (data_len == 4)
+		unigraf_debug("Value = 0x%x\n", *(int *)data);
+
+	unigraf_assert(TSIX_TS_SetConfigItem(unigraf_device, config, data, data_len));
+}
+
 /**
  * unigraf_device_count() - Return the number of scanned devices
  *
@@ -285,3 +303,25 @@ void unigraf_require_device(int drm_fd)
 {
 	igt_require(unigraf_open_device(drm_fd));
 }
+
+void unigraf_hpd_assert(void)
+{
+	int d = 1;
+
+	igt_assert(unigraf_device);
+	unigraf_write(TSI_FORCE_HOT_PLUG_STATE_W, &d, sizeof(d));
+}
+
+void unigraf_hpd_pulse(int duration)
+{
+	igt_assert(unigraf_device);
+	unigraf_write(TSI_DPRX_HPD_PULSE_W, &duration, sizeof(duration));
+}
+
+void unigraf_hpd_deassert(void)
+{
+	int d = 0;
+
+	igt_assert(unigraf_device);
+	unigraf_write(TSI_FORCE_HOT_PLUG_STATE_W, &d, sizeof(d));
+}
diff --git a/lib/unigraf/unigraf.h b/lib/unigraf/unigraf.h
index 8cdbf00201b2a0467ec15259cf4bc0a2d8f9b61e..c5ae949c54729bf293a4629ec3bf5d995de9fb6b 100644
--- a/lib/unigraf/unigraf.h
+++ b/lib/unigraf/unigraf.h
@@ -47,4 +47,26 @@ bool unigraf_open_device(int drm_fd);
  */
 void unigraf_require_device(int drm_fd);
 
+/**
+ * unigraf_hpd_deassert() - Deassert Hot Plug Detect signal
+ *
+ * This function deasserts the HPD signal, simulating a device disconnection.
+ */
+void unigraf_hpd_deassert(void);
+
+/**
+ * unigraf_hpd_pulse() - Pulse the Hot Plug Detect signal
+ * @duration: The duration in milliseconds for which the HPD signal should be pulsed
+ *
+ * This function pulses the HPD signal for the specified duration.
+ */
+void unigraf_hpd_pulse(int duration);
+
+/**
+ * unigraf_hpd_assert() - Assert Hot Plug Detect signal
+ *
+ * This function asserts the HPD signal, simulating a device connection.
+ */
+void unigraf_hpd_assert(void);
+
 #endif // UNIGRAF_H

-- 
2.50.1



More information about the igt-dev mailing list