[PATCH i-g-t v2 16/26] lib/unigraf: Add unigraf assert and deassert helpers
Louis Chauvet
louis.chauvet at bootlin.com
Thu Jul 17 18:46:36 UTC 2025
Unigraf is able to manipulate the HPD line of the connector, add few
helpers to manipulate them.
---
lib/unigraf/unigraf.c | 38 ++++++++++++++++++++++++++++++++++++++
lib/unigraf/unigraf.h | 22 ++++++++++++++++++++++
2 files changed, 60 insertions(+)
diff --git a/lib/unigraf/unigraf.c b/lib/unigraf/unigraf.c
index d9e9d80a4cf19c6be67977050ef2a17f2cb489d7..3998a3af1bef4490bf9d3c796876d268957e87e2 100644
--- a/lib/unigraf/unigraf.c
+++ b/lib/unigraf/unigraf.c
@@ -88,6 +88,25 @@ 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
*
@@ -261,3 +280,22 @@ void unigraf_require_device(void)
{
igt_require(unigraf_open_device());
}
+
+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 8e0137ce30ed1bc0b334540561f93c7ade38e386..0a872b6e5859347be371b6a28db5516f4c854d2f 100644
--- a/lib/unigraf/unigraf.h
+++ b/lib/unigraf/unigraf.h
@@ -45,4 +45,26 @@ bool unigraf_open_device(void);
*/
void unigraf_require_device(void);
+/**
+ * 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.0
More information about the igt-dev
mailing list