[PATCH i-g-t v3 23/29] lib/unigraf: Add edid configuration

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


As unigraf could be used as a simple screen for all tests, add a default
EDID configuration to connect the unigraf by default on every tests using
this EDID.

Signed-off-by: Louis Chauvet <louis.chauvet at bootlin.com>
---
 lib/unigraf/unigraf.c | 34 ++++++++++++++++++++++++++++++++++
 1 file changed, 34 insertions(+)

diff --git a/lib/unigraf/unigraf.c b/lib/unigraf/unigraf.c
index b90025425d232bd5269adfe9f17f2813eac7754d..5aa5d94660255d9740db7b74c3e1eea0575fa5f2 100644
--- a/lib/unigraf/unigraf.c
+++ b/lib/unigraf/unigraf.c
@@ -10,8 +10,10 @@
 #include "unigraf.h"
 #include "TSI_types.h"
 #include "TSI.h"
+#include "igt_edid.h"
 #include "igt_kms.h"
 #include "igt_rc.h"
+#include "monitor_edids/monitor_edids_helper.h"
 
 #define unigraf_debug(fmt, ...)	igt_debug("TSI:%p: " fmt, unigraf_device, ##__VA_ARGS__)
 
@@ -50,6 +52,11 @@ static char *unigraf_connector_name;
  */
 #define UNIGRAF_CONFIG_CONNECTOR_NAME "Connector"
 
+/**
+ * UNIGRAF_CONFIG_EDID_NAME - Key of the EDID name in the configuration file
+ */
+#define UNIGRAF_CONFIG_EDID_NAME "EDID"
+
 /**
  * UNIGRAF_DEFAULT_ROLE_NAME - Default role name to search on the unigraf device
  */
@@ -176,6 +183,18 @@ static int unigraf_find_input(const char *request)
 	return chosen_input;
 }
 
+static void unigraf_load_default_edid(void)
+{
+	struct edid *edid = get_edid_by_name(unigraf_default_edid);
+
+	if (edid) {
+		unigraf_write_edid(0, edid, edid_get_size(edid));
+	} else {
+		igt_warn("Impossible to find an edid named \"%s\"", unigraf_default_edid);
+		list_edid_names(IGT_LOG_WARN);
+	}
+}
+
 static void unigraf_autodetect_connector(int drm_fd)
 {
 	int newly_connected_count, already_connected_count, diff_len;
@@ -239,6 +258,7 @@ bool unigraf_open_device(int drm_fd)
 	char *cfg_device = NULL;
 	char *cfg_role = NULL;
 	char *cfg_input = NULL;
+	char *cfg_edid_name = NULL;
 	int device_count;
 	int chosen_device;
 	int chosen_role;
@@ -267,6 +287,7 @@ bool unigraf_open_device(int drm_fd)
 		cfg_device = NULL;
 		cfg_role = NULL;
 		cfg_input = NULL;
+		cfg_edid_name = NULL;
 		unigraf_connector_name = NULL;
 	} else {
 		cfg_device = g_key_file_get_string(igt_key_file, cfg_group,
@@ -300,6 +321,14 @@ bool unigraf_open_device(int drm_fd)
 			unigraf_debug("No connector name configured, will autodetect.\n");
 			unigraf_connector_name = NULL;
 		}
+
+		cfg_error = NULL;
+		cfg_edid_name = g_key_file_get_string(igt_key_file, cfg_group,
+						      UNIGRAF_CONFIG_EDID_NAME, &cfg_error);
+		if (cfg_error) {
+			unigraf_debug("No default EDID set, use IGT default.\n");
+			cfg_edid_name = NULL;
+		}
 	}
 
 	unigraf_assert(TSIX_DEV_RescanDevices(0, TSI_DEVCAP_VIDEO_CAPTURE, 0));
@@ -376,6 +405,11 @@ bool unigraf_open_device(int drm_fd)
 
 	unigraf_hpd_deassert();
 	unigraf_set_sst();
+	if (!cfg_edid_name)
+		cfg_edid_name = strdup("DEL_16543_DELL_P2314T_DP");
+
+	unigraf_default_edid = cfg_edid_name;
+	unigraf_load_default_edid();
 	unigraf_hpd_assert();
 	sleep(1);
 	return unigraf_connector_name != NULL;

-- 
2.50.1



More information about the igt-dev mailing list