[igt-dev] [PATCH i-g-t v4 09/10] lib/igt_chamelium: add chamelium_get_video_ports
Simon Ser
simon.ser at intel.com
Tue Jun 25 13:14:30 UTC 2019
This function queries the video port IDs supported by the Chamelium device.
It'll be used to know on which ports we can perform auto-detection.
An alternative would be to hardcode a list of port IDs. However port IDs are
specific to each Chamelium board, and will change for a different
implementation. Also it would be nice to have simulators implement the
Chamelium APIā¦
Signed-off-by: Simon Ser <simon.ser at intel.com>
---
lib/igt_chamelium.c | 44 ++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 44 insertions(+)
diff --git a/lib/igt_chamelium.c b/lib/igt_chamelium.c
index 959a14333ed9..3cd2acafd385 100644
--- a/lib/igt_chamelium.c
+++ b/lib/igt_chamelium.c
@@ -1758,6 +1758,50 @@ static unsigned int chamelium_get_port_type(struct chamelium *chamelium,
return port_type;
}
+static bool chamelium_has_video_support(struct chamelium *chamelium,
+ int port_id)
+{
+ xmlrpc_value *res;
+ int has_video_support;
+
+ res = chamelium_rpc(chamelium, NULL, "HasVideoSupport", "(i)", port_id);
+ xmlrpc_read_bool(&chamelium->env, res, &has_video_support);
+ xmlrpc_DECREF(res);
+
+ return has_video_support;
+}
+
+/**
+ * chamelium_get_video_ports: retrieve a list of video port IDs
+ *
+ * Returns: the number of video port IDs
+ */
+static size_t chamelium_get_video_ports(struct chamelium *chamelium,
+ int port_ids[static CHAMELIUM_MAX_PORTS])
+{
+ xmlrpc_value *res, *res_port;
+ int res_len, i, port_id;
+ size_t port_ids_len = 0;
+
+ res = chamelium_rpc(chamelium, NULL, "GetSupportedInputs", "()");
+ res_len = xmlrpc_array_size(&chamelium->env, res);
+ for (i = 0; i < res_len; i++) {
+ xmlrpc_array_read_item(&chamelium->env, res, i, &res_port);
+ xmlrpc_read_int(&chamelium->env, res_port, &port_id);
+ xmlrpc_DECREF(res_port);
+
+ if (!chamelium_has_video_support(chamelium, port_id))
+ continue;
+
+ igt_assert(port_ids_len < CHAMELIUM_MAX_PORTS);
+ port_ids[port_ids_len] = port_id;
+ port_ids_len++;
+ }
+ xmlrpc_DECREF(res);
+
+ return port_ids_len;
+}
+
static bool chamelium_read_port_mappings(struct chamelium *chamelium,
int drm_fd)
{
--
2.22.0
More information about the igt-dev
mailing list