[PATCH i-g-t v2 22/26] lib/unigraf: Add edid configuration

Louis Chauvet louis.chauvet at bootlin.com
Thu Jul 17 18:46:42 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.
---
 lib/unigraf/unigraf.c | 34 ++++++++++++++++++++++++++++++++++
 1 file changed, 34 insertions(+)

diff --git a/lib/unigraf/unigraf.c b/lib/unigraf/unigraf.c
index 10f8c5ab671d0e8ccf27d333f6ea66c8219b0892..add5d5b2b1379bb34ff73505ee917e51398f4b66 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
  */
@@ -165,6 +172,17 @@ static int unigraf_find_input(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;
@@ -228,6 +246,7 @@ bool unigraf_open_device(void)
 	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;
@@ -283,6 +302,13 @@ bool unigraf_open_device(void)
 			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");
+			unigraf_connector_name = NULL;
+		}
 	}
 
 	unigraf_assert(TSIX_DEV_RescanDevices(0, TSI_DEVCAP_VIDEO_CAPTURE, 0));
@@ -341,6 +367,14 @@ bool unigraf_open_device(void)
 	unigraf_assert(TSIX_VIN_Select(unigraf_device, chosen_input));
 	unigraf_assert(TSIX_VIN_Enable(unigraf_device, chosen_input));
 
+	if (cfg_edid_name == NULL) {
+		cfg_edid_name = strdup("DEL_16543_DELL_P2314T_DP");
+	}
+	unigraf_default_edid = cfg_edid_name;
+
+	unigraf_set_sst();
+	unigraf_load_default_edid();
+
 	return true;
 }
 

-- 
2.50.0



More information about the igt-dev mailing list