[PATCH i-g-t v2 21/39] lib/chamelium/v3: Implement methods for managing Chamelium EDID

Louis Chauvet louis.chauvet at bootlin.com
Tue Jul 9 15:34:37 UTC 2024


Introduce functionality to apply different EDIDs to each Chamelium port.
This includes uploading EDIDs and assigning identifiers for applying them
to specific connectors. This feature allows for greater flexibility in
configuring and testing display setups.

Signed-off-by: Louis Chauvet <louis.chauvet at bootlin.com>
---
 lib/chamelium/v3/igt_chamelium.c | 47 +++++++++++++++++++++++++++++++++++++++-
 lib/chamelium/v3/igt_chamelium.h |  8 +++++++
 2 files changed, 54 insertions(+), 1 deletion(-)

diff --git a/lib/chamelium/v3/igt_chamelium.c b/lib/chamelium/v3/igt_chamelium.c
index 334098d4dea6..767dfcfcb182 100644
--- a/lib/chamelium/v3/igt_chamelium.c
+++ b/lib/chamelium/v3/igt_chamelium.c
@@ -364,7 +364,7 @@ void chamelium_v3_plug_with_children(struct igt_chamelium_v3 *chamelium,
 	xmlrpc_value *children_array = xmlrpc_array_new(&chamelium->env);
 
 	for (int i = 0; i < children_port_count; i++) {
-		tmp = xmlrpc_int_new(&chamelium->env, (int) children[i]);
+		tmp = xmlrpc_int_new(&chamelium->env, (int)children[i]);
 		xmlrpc_array_append_item(&chamelium->env, children_array, tmp);
 		xmlrpc_DECREF(tmp);
 	}
@@ -374,3 +374,48 @@ void chamelium_v3_plug_with_children(struct igt_chamelium_v3 *chamelium,
 				      children_array));
 	xmlrpc_DECREF(children_array);
 }
+
+/**
+ * chamelium_v3_create_edid - Upload an EDID to the chamelium
+ *
+ * @chamelium: Chamelium to get the ports from
+ * @edid: EDID to upload
+ *
+ * Upload an EDID to the chamelium. The returned value must then be used with
+ * chamelium_v3_apply_edid to associate this EDID with a port.
+ *
+ * If you prefer to not upload, the chamelium already has a default EDID that you can apply by using
+ * the value CHAMELIUM_V3_EDID_DEFAULT.
+ */
+chamelium_edid_id chamelium_v3_create_edid(struct igt_chamelium_v3 *chamelium,
+					   const struct edid *edid)
+{
+	xmlrpc_value *res;
+	chamelium_edid_id edid_id;
+
+	igt_debug("RPC CreateEdid(...)\n");
+	res = __chamelium_rpc(chamelium, "CreateEdid", "(6)",
+			      edid, edid_get_size(edid));
+	xmlrpc_read_int(&chamelium->env, res, &edid_id);
+	xmlrpc_DECREF(res);
+
+	return edid_id;
+}
+
+/**
+ * chamelium_v3_apply_edid - Set an EDID to a specific port
+ *
+ * @chamelium: Chamelium to get the ports from
+ * @port_id: Port to apply the EDID
+ * @edid_id: EDID to apply
+ *
+ * Apply a specific EDID to a port. The @edid_id is the value returned by a call to
+ * chamelium_v3_create_edid. For simplicity you can also use CHAMELIUM_V3_EDID_DEFAULT to use the
+ * default EDID.
+ */
+void chamelium_v3_apply_edid(struct igt_chamelium_v3 *chamelium,
+			     chamelium_v3_port_id port_id, chamelium_edid_id edid_id)
+{
+	igt_debug("RPC ApplyEdid(%d, %d)\n", port_id, edid_id);
+	xmlrpc_DECREF(__chamelium_rpc(chamelium, "ApplyEdid", "(ii)", port_id, edid_id));
+}
diff --git a/lib/chamelium/v3/igt_chamelium.h b/lib/chamelium/v3/igt_chamelium.h
index 9bad733b717b..cab33e43aadd 100644
--- a/lib/chamelium/v3/igt_chamelium.h
+++ b/lib/chamelium/v3/igt_chamelium.h
@@ -5,10 +5,14 @@
 
 #include <stdint.h>
 
+#include "igt_edid.h"
 #include "igt_list.h"
 
 struct igt_chamelium_v3;
 typedef uint32_t chamelium_v3_port_id;
+typedef int chamelium_edid_id;
+
+#define CHAMELIUM_V3_EDID_DEFAULT 0
 
 /** struct chamelium_v3_port_mapping - Represent a mapping between a DRM connector and a port on
  * the chamelium
@@ -53,5 +57,9 @@ void chamelium_v3_plug(struct igt_chamelium_v3 *chamelium, chamelium_v3_port_id
 void chamelium_v3_plug_with_children(struct igt_chamelium_v3 *chamelium,
 				     chamelium_v3_port_id port_id, chamelium_v3_port_id *children,
 				     size_t children_port_count);
+chamelium_edid_id chamelium_v3_create_edid(struct igt_chamelium_v3 *chamelium,
+					   const struct edid *edid);
+void chamelium_v3_apply_edid(struct igt_chamelium_v3 *chamelium, chamelium_v3_port_id port_id,
+			     chamelium_edid_id edid_id);
 
 #endif //V3_IGT_CHAMELIUM_H

-- 
2.44.2



More information about the igt-dev mailing list