[PATCH i-g-t v2 26/39] lib/chamelium/v3: Implement helper function to get port mapping from Chameleon port id
Louis Chauvet
louis.chauvet at bootlin.com
Tue Jul 9 15:34:42 UTC 2024
Introduces a new helper function in the Chameleon V3 wrapper to retrieve
the port mapping from a Chameleon port id. This function is useful for
certain tests, such as when listing MST children, as it simplifies the
process of obtaining the port mapping based on the Chameleon port id.
Signed-off-by: Louis Chauvet <louis.chauvet at bootlin.com>
---
lib/chamelium/v3/igt_chamelium.c | 23 +++++++++++++++++++++++
lib/chamelium/v3/igt_chamelium.h | 4 +++-
2 files changed, 26 insertions(+), 1 deletion(-)
diff --git a/lib/chamelium/v3/igt_chamelium.c b/lib/chamelium/v3/igt_chamelium.c
index fb559f29a72e..fc9520466de5 100644
--- a/lib/chamelium/v3/igt_chamelium.c
+++ b/lib/chamelium/v3/igt_chamelium.c
@@ -341,6 +341,29 @@ void chamelium_v3_fill_port_mapping(struct igt_chamelium_v3 *chamelium)
chamelium_v3_port_mapping_info_list(&chamelium->port_mapping);
}
+/**
+ * chamelium_v3_get_port_mapping_for_chamelium_port_id() - Get a port mapping from a chamelium port
+ * id
+ *
+ * @chamelium: Chamelium to search the port ID
+ * @port_id: Port ID to search for
+ *
+ * Returns the pointer to a port mapping
+ */
+struct chamelium_v3_port_mapping *
+chamelium_v3_get_port_mapping_for_chamelium_port_id(struct igt_chamelium_v3 *chamelium,
+ chamelium_v3_port_id port_id)
+{
+ struct chamelium_v3_port_mapping *port_mapping, *tmp;
+
+ igt_list_for_each_entry_safe(port_mapping, tmp, &chamelium->port_mapping, link) {
+ if (port_mapping->port_id == port_id)
+ return port_mapping;
+ }
+
+ return NULL;
+}
+
/**
* chamelium_v3_uninit() - Free the resources used by a chamelium
*
diff --git a/lib/chamelium/v3/igt_chamelium.h b/lib/chamelium/v3/igt_chamelium.h
index b29221c460f0..5e035bdd10bf 100644
--- a/lib/chamelium/v3/igt_chamelium.h
+++ b/lib/chamelium/v3/igt_chamelium.h
@@ -46,7 +46,9 @@ struct igt_chamelium_v3 *chamelium_v3_init_from_config(void);
void chamelium_v3_fill_port_mapping(struct igt_chamelium_v3 *chamelium);
struct igt_list_head *chamelium_v3_get_port_mapping(struct igt_chamelium_v3 *chamelium);
-
+struct chamelium_v3_port_mapping *
+chamelium_v3_get_port_mapping_for_chamelium_port_id(struct igt_chamelium_v3 *chamelium,
+ chamelium_v3_port_id port_id);
void chamelium_v3_uninit(struct igt_chamelium_v3 *chamelium);
void chamelium_v3_reset(struct igt_chamelium_v3 *chamelium);
--
2.44.2
More information about the igt-dev
mailing list