diff options
author | Simon Ser <simon.ser@intel.com> | 2019-07-03 10:43:38 +0300 |
---|---|---|
committer | Simon Ser <simon.ser@intel.com> | 2019-07-17 17:41:35 +0300 |
commit | d9fde0f6213c9c79dbcd85caa84b81d7aff4dd68 (patch) | |
tree | 4213418dbaaf21a0754e7bf53d77ca08adfc18d3 /lib/igt_chamelium.c | |
parent | ce3cf9b933eeb361a58e3d850320c6119f07217f (diff) |
lib/igt_chamelium: add chamelium_supports_get_video_params
This allows to skip video params tests on Chamelium boards which aren't recent
enough.
Signed-off-by: Simon Ser <simon.ser@intel.com>
Reviewed-by: Martin Peres <martin.peres@linux.intel.com>
Diffstat (limited to 'lib/igt_chamelium.c')
-rw-r--r-- | lib/igt_chamelium.c | 48 |
1 files changed, 28 insertions, 20 deletions
diff --git a/lib/igt_chamelium.c b/lib/igt_chamelium.c index c332291e..3803a90e 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; } |