[PATCH i-g-t v2 20/39] lib/chamelium/v3: Implement methods for plugging Chamelium ports
Louis Chauvet
louis.chauvet at bootlin.com
Tue Jul 9 15:34:36 UTC 2024
Introduce two new RPC calls, Plug and PlugWithChildren, to manage
Chamelium port connections. The Plug method enables plugging physical
ports (HDMI1/2, DP1/2), while the PlugWithChildren method allows plugging
MST connectors (DP1 and its MST children).
Signed-off-by: Louis Chauvet <louis.chauvet at bootlin.com>
---
lib/chamelium/v3/igt_chamelium.c | 51 ++++++++++++++++++++++++++++++++++++++++
lib/chamelium/v3/igt_chamelium.h | 4 ++++
2 files changed, 55 insertions(+)
diff --git a/lib/chamelium/v3/igt_chamelium.c b/lib/chamelium/v3/igt_chamelium.c
index af6ab5c6c9b7..334098d4dea6 100644
--- a/lib/chamelium/v3/igt_chamelium.c
+++ b/lib/chamelium/v3/igt_chamelium.c
@@ -323,3 +323,54 @@ char *chamelium_v3_get_port_name(struct igt_chamelium_v3 *chamelium,
return port_name;
}
+
+/**
+ * chamelium_v3_plug - Emulate a plug action on a specific port id
+ *
+ * @chamelium: Chamelium to get the ports from
+ * @port_id: Port to plug
+ *
+ * Emulate a connection action on the chamelium. It should have the same effect as physically
+ * plugging a connector.
+ *
+ * Note: The current chamelium have some issue with port 1: the plug/unplug action does not seems to
+ * works reliably. However, it works fine with port 5 (same physical connector, but use a different
+ * component to emulate MST).
+ */
+void chamelium_v3_plug(struct igt_chamelium_v3 *chamelium, chamelium_v3_port_id port_id)
+{
+ igt_debug("RPC Plug(%d)\n", port_id);
+ xmlrpc_DECREF(__chamelium_rpc(chamelium, "Plug", "(i)", port_id));
+}
+
+/**
+ * chamelium_v3_plug_with_children - Emulate a plug action on a specific port with MST children
+ *
+ * @chamelium: Chamelium to get the ports from
+ * @port_id: Parent port for MST
+ * @children: List of children port to plug. It must not include the parent port id.
+ * @children_port_count: Number of ports in @children
+ *
+ * Emulate a connection action on the chamelium using a MST device. The parent connector will always
+ * be plugged.
+ *
+ * The children pointer is not freed by this function and must be managed by the caller.
+ */
+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)
+{
+ xmlrpc_value *tmp;
+ 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]);
+ xmlrpc_array_append_item(&chamelium->env, children_array, tmp);
+ xmlrpc_DECREF(tmp);
+ }
+
+ igt_debug("RPC PlugWithChildren(%d, ...)\n", port_id);
+ xmlrpc_DECREF(__chamelium_rpc(chamelium, "PlugWithChildren", "(iA)", port_id,
+ children_array));
+ xmlrpc_DECREF(children_array);
+}
diff --git a/lib/chamelium/v3/igt_chamelium.h b/lib/chamelium/v3/igt_chamelium.h
index 88b407dfd1ae..9bad733b717b 100644
--- a/lib/chamelium/v3/igt_chamelium.h
+++ b/lib/chamelium/v3/igt_chamelium.h
@@ -49,5 +49,9 @@ int chamelium_v3_get_children(struct igt_chamelium_v3 *chamelium, chamelium_v3_p
chamelium_v3_port_id **port_ids);
bool chamelium_v3_is_mst(struct igt_chamelium_v3 *chamelium, chamelium_v3_port_id port_id);
char *chamelium_v3_get_port_name(struct igt_chamelium_v3 *chamelium, chamelium_v3_port_id port_id);
+void chamelium_v3_plug(struct igt_chamelium_v3 *chamelium, chamelium_v3_port_id 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);
#endif //V3_IGT_CHAMELIUM_H
--
2.44.2
More information about the igt-dev
mailing list