[PATCH i-g-t v2 20/26] lib/unigraf: Add connector configuration

Louis Chauvet louis.chauvet at bootlin.com
Thu Jul 17 18:46:40 UTC 2025


As multiple connectors can be present on the DUT, add a configuration to
tell which connector is used by the Unigraf.

The configuration will look like:

[Unigraf]
Device=UCD-500 [2434C620]
Role=DisplayPort Source and Sink
Input=DP RX
Connector=DP-4
---
 lib/unigraf/unigraf.c | 18 ++++++++++++++++++
 lib/unigraf/unigraf.h | 11 +++++++++++
 2 files changed, 29 insertions(+)

diff --git a/lib/unigraf/unigraf.c b/lib/unigraf/unigraf.c
index 6df48da4672c1774bd85125076fcc63e9891b6cc..b59a3627af30642899fcf3e4c9e5b53fb4e54eeb 100644
--- a/lib/unigraf/unigraf.c
+++ b/lib/unigraf/unigraf.c
@@ -10,6 +10,7 @@
 #include "unigraf.h"
 #include "TSI_types.h"
 #include "TSI.h"
+#include "igt_kms.h"
 #include "igt_rc.h"
 
 #define unigraf_debug(fmt, ...)	igt_debug("TSI:%p: " fmt, unigraf_device,##__VA_ARGS__)
@@ -44,6 +45,11 @@ static char *unigraf_connector_name;
  */
 #define UNIGRAF_CONFIG_INPUT_NAME "Input"
 
+/**
+ * UNIGRAF_CONFIG_CONNECTOR_NAME - Key of the connector name in the configuration file
+ */
+#define UNIGRAF_CONFIG_CONNECTOR_NAME "Connector"
+
 /**
  * UNIGRAF_DEFAULT_ROLE_NAME - Default role name to search on the unigraf device
  */
@@ -159,6 +165,11 @@ static int unigraf_find_input(char *request) {
 	return chosen_input;
 }
 
+drmModeConnectorPtr unigraf_get_connector(int drm_fd)
+{
+	return igt_get_connector_from_name(drm_fd, unigraf_connector_name);
+}
+
 bool unigraf_open_device(void)
 {
 	TSI_RESULT r;
@@ -215,6 +226,13 @@ bool unigraf_open_device(void)
 			unigraf_debug("No input name configured.\n");
 			cfg_input = NULL;
 		}
+
+		cfg_error = NULL;
+		unigraf_connector_name = g_key_file_get_string(igt_key_file, cfg_group, UNIGRAF_CONFIG_CONNECTOR_NAME, &cfg_error);
+		if (cfg_error) {
+			unigraf_debug("No connector name configured, will autodetect.\n");
+			unigraf_connector_name = NULL;
+		}
 	}
 
 	unigraf_assert(TSIX_DEV_RescanDevices(0, TSI_DEVCAP_VIDEO_CAPTURE, 0));
diff --git a/lib/unigraf/unigraf.h b/lib/unigraf/unigraf.h
index e843aa8f2badddcfaeceb8773d5ad19e572e37d9..e014ead67b57e860907bd0cd3521fb5842240594 100644
--- a/lib/unigraf/unigraf.h
+++ b/lib/unigraf/unigraf.h
@@ -5,6 +5,7 @@
 
 #include <stdbool.h>
 #include <stdint.h>
+#include <xf86drmMode.h>
 
 /**
  * unigraf_assert: Helper macro to assert a TSI return value and retrieve a detailed error message.
@@ -45,6 +46,16 @@ bool unigraf_open_device(void);
  */
 void unigraf_require_device(void);
 
+/**
+ * unigraf_get_connector() - Get a DRM connector for the Unigraf device
+ * @drm_fd: DRM file descriptor
+ *
+ * Returns: A pointer to the drmModeConnector connected to the unigraf device,
+ * or NULL if the operation failed. The caller is responsible for freeing this
+ * pointer with drmModeFreeConnector().
+ */
+drmModeConnectorPtr unigraf_get_connector(int drm_fd);
+
 /**
  * unigraf_read_edid() - Read the EDID from the specified input
  * @dev: The device handle

-- 
2.50.0



More information about the igt-dev mailing list