[PATCH i-g-t v7 26/48] lib/unigraf: Add plug/unplug helpers

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

The unigraf can emulate a full cable plug/unplug, so add helper to emulate
this.

Reviewed-by: Kory Maincent <kory.maincent@bootlin.com>
Reviewed-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
Signed-off-by: Louis Chauvet <louis.chauvet@bootlin.com>
---
lib/unigraf/unigraf.c | 28 +++++++++++++++++++++++++++-
lib/unigraf/unigraf.h | 4 ++++
2 files changed, 31 insertions(+), 1 deletion(-)

diff --git a/lib/unigraf/unigraf.c b/lib/unigraf/unigraf.c
index 5812f46fe6ae..f148d4fc099f 100644
--- a/lib/unigraf/unigraf.c
+++ b/lib/unigraf/unigraf.c
@@ -307,7 +307,9 @@ void unigraf_require_device(int drm_fd)
* and link parameters to default values.
*/
void unigraf_reset(void)
-{}
+{
+ unigraf_plug();
+}

/**
* unigraf_hpd_assert() - Assert Hot Plug Detect signal
@@ -345,3 +347,27 @@ void unigraf_hpd_deassert(void)
{
unigraf_write_u32(TSI_FORCE_HOT_PLUG_STATE_W, 0);
}
+
+/**
+ * unigraf_plug() - Emulate a cable unplug
+ *
+ * This function will emulate a full cable unplug (not a simple HPD line change)
+ */
+void unigraf_unplug(void)
+{
+ int d = 2 << 2;
+
+ unigraf_write_u32(TSI_DPRX_HPD_FORCE, d);
+}
+
+/**
+ * unigraf_plug() - Emulate a cable plug
+ *
+ * This function will emulate a full cable plug (not a simple HPD line change)
+ */
+void unigraf_plug(void)
+{
+ int d = 3 << 2;
+
+ unigraf_write_u32(TSI_DPRX_HPD_FORCE, d);
+}
diff --git a/lib/unigraf/unigraf.h b/lib/unigraf/unigraf.h
index 77fba4e53912..ae1f0d8955ab 100644
--- a/lib/unigraf/unigraf.h
+++ b/lib/unigraf/unigraf.h
@@ -48,4 +48,8 @@ void unigraf_hpd_pulse(int duration);

void unigraf_hpd_assert(void);

+void unigraf_plug(void);
+
+void unigraf_unplug(void);
+
#endif // UNIGRAF_H

--
2.52.0