[igt-dev] [PATCH i-g-t 2/3] lib/igt_chamelium: add chamelium_supports_get_video_params

Simon Ser simon.ser at intel.com
Wed Jul 3 07:57:30 UTC 2019


This allows to skip video params tests on Chamelium boards which aren't recent
enough.

Signed-off-by: Simon Ser <simon.ser at intel.com>
---
 lib/igt_chamelium.c | 48 ++++++++++++++++++++++++++-------------------
 lib/igt_chamelium.h |  1 +
 2 files changed, 29 insertions(+), 20 deletions(-)

diff --git a/lib/igt_chamelium.c b/lib/igt_chamelium.c
index c332291ef305..3803a90e4250 100644
--- a/lib/igt_chamelium.c
+++ b/lib/igt_chamelium.c
@@ -658,6 +658,33 @@ void chamelium_port_get_resolution(struct chamelium *chamelium,
 	xmlrpc_DECREF(res);
 }
 
+/** chamelium_supports_method: checks if the Chamelium board supports a method.
+ *
+ * Note: this actually tries to call the method.
+ *
+ * See https://crbug.com/977995 for a discussion about a better solution.
+ */
+static bool chamelium_supports_method(struct chamelium *chamelium,
+				      const char *name)
+{
+	xmlrpc_value *res;
+
+	res = __chamelium_rpc(chamelium, NULL, name, "()");
+	if (res)
+		xmlrpc_DECREF(res);
+
+	/* XML-RPC has a special code for unsupported methods
+	 * (XMLRPC_NO_SUCH_METHOD_ERROR) however the Chamelium implementation
+	 * doesn't return it. */
+	return (!chamelium->env.fault_occurred ||
+		strstr(chamelium->env.fault_string, "not supported") == NULL);
+}
+
+bool chamelium_supports_get_video_params(struct chamelium *chamelium)
+{
+	return chamelium_supports_method(chamelium, "GetVideoParams");
+}
+
 static void read_int_from_xml_struct(struct chamelium *chamelium,
 				     xmlrpc_value *struct_val, const char *key,
 				     int *dst)
@@ -1018,32 +1045,13 @@ int chamelium_get_captured_frame_count(struct chamelium *chamelium)
 	return ret;
 }
 
-/**
- * chamelium_supports_get_audio_format: check the Chamelium device supports
- * retrieving the capture audio format.
- */
-static bool chamelium_supports_get_audio_format(struct chamelium *chamelium)
-{
-	xmlrpc_value *res;
-
-	res = __chamelium_rpc(chamelium, NULL, "GetAudioFormat", "(i)", 3);
-	if (res)
-		xmlrpc_DECREF(res);
-
-	/* XML-RPC has a special code for unsupported methods
-	 * (XMLRPC_NO_SUCH_METHOD_ERROR) however the Chamelium implementation
-	 * doesn't return it. */
-	return (!chamelium->env.fault_occurred ||
-		strstr(chamelium->env.fault_string, "not supported") == NULL);
-}
-
 bool chamelium_has_audio_support(struct chamelium *chamelium,
 				 struct chamelium_port *port)
 {
 	xmlrpc_value *res;
 	xmlrpc_bool has_support;
 
-	if (!chamelium_supports_get_audio_format(chamelium)) {
+	if (!chamelium_supports_method(chamelium, "GetAudioFormat")) {
 		igt_debug("The Chamelium device doesn't support GetAudioFormat\n");
 		return false;
 	}
diff --git a/lib/igt_chamelium.h b/lib/igt_chamelium.h
index cd5813821fb4..8b4fc3344c64 100644
--- a/lib/igt_chamelium.h
+++ b/lib/igt_chamelium.h
@@ -119,6 +119,7 @@ void chamelium_port_set_ddc_state(struct chamelium *chamelium,
 void chamelium_port_get_resolution(struct chamelium *chamelium,
 				   struct chamelium_port *port,
 				   int *x, int *y);
+bool chamelium_supports_get_video_params(struct chamelium *chamelium);
 void chamelium_port_get_video_params(struct chamelium *chamelium,
 				     struct chamelium_port *port,
 				     struct chamelium_video_params *params);
-- 
2.22.0



More information about the igt-dev mailing list