[PATCH i-g-t v2 17/39] lib/chamelium/v3: Implement method to retrieve Chamelium port names

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


Chamelium ports have descriptive names associated with them. This commit
introduces an RPC call to fetch these names, facilitating easier debugging
and better understanding of the port configuration.

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

diff --git a/lib/chamelium/v3/igt_chamelium.c b/lib/chamelium/v3/igt_chamelium.c
index c4c75c57fa64..5a7e42334e81 100644
--- a/lib/chamelium/v3/igt_chamelium.c
+++ b/lib/chamelium/v3/igt_chamelium.c
@@ -282,3 +282,28 @@ bool chamelium_v3_is_mst(struct igt_chamelium_v3 *chamelium, chamelium_v3_port_i
 
 	return is_mst;
 }
+
+/**
+ * chamelium_v3_get_port_name - Get the port name from its id
+ *
+ * @chamelium: Chamelium to get the ports from
+ * @port_id: Port to get the name
+ *
+ * Returns a string containing the port name for @port_id. The caller must free this pointer when
+ * not used anymore.
+ */
+char *chamelium_v3_get_port_name(struct igt_chamelium_v3 *chamelium,
+				 chamelium_v3_port_id port_id)
+{
+	xmlrpc_value *res;
+	char *port_name;
+
+	igt_debug("RPC GetPortName(%d)\n", port_id);
+	res = __chamelium_rpc(chamelium, "GetPortName", "(i)", port_id);
+
+	xmlrpc_read_string(&chamelium->env, res, (const char **)&port_name);
+
+	xmlrpc_DECREF(res);
+
+	return port_name;
+}
diff --git a/lib/chamelium/v3/igt_chamelium.h b/lib/chamelium/v3/igt_chamelium.h
index 763ab4bc0304..ae3225873bfb 100644
--- a/lib/chamelium/v3/igt_chamelium.h
+++ b/lib/chamelium/v3/igt_chamelium.h
@@ -47,5 +47,6 @@ int chamelium_v3_get_supported_ports(struct igt_chamelium_v3 *chamelium,
 int chamelium_v3_get_children(struct igt_chamelium_v3 *chamelium, chamelium_v3_port_id port_id,
 			      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);
 
 #endif //V3_IGT_CHAMELIUM_H

-- 
2.44.2



More information about the igt-dev mailing list