[igt-dev] [PATCH i-g-t v3 01/10] lib/igt_chamelium: introduce CHAMELIUM_MAX_AUDIO_CHANNELS

Simon Ser simon.ser at intel.com
Mon May 27 14:34:09 UTC 2019


This allows us not to hardcode 8 everywhere.

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

diff --git a/lib/igt_chamelium.c b/lib/igt_chamelium.c
index cfdf7617a65a..75f03d8469aa 100644
--- a/lib/igt_chamelium.c
+++ b/lib/igt_chamelium.c
@@ -1020,7 +1020,7 @@ bool chamelium_has_audio_support(struct chamelium *chamelium,
  */
 void chamelium_get_audio_channel_mapping(struct chamelium *chamelium,
 					 struct chamelium_port *port,
-					 int mapping[static 8])
+					 int mapping[static CHAMELIUM_MAX_AUDIO_CHANNELS])
 {
 	xmlrpc_value *res, *res_channel;
 	int res_len, i;
@@ -1028,7 +1028,7 @@ void chamelium_get_audio_channel_mapping(struct chamelium *chamelium,
 	res = chamelium_rpc(chamelium, port, "GetAudioChannelMapping", "(i)",
 			    port->id);
 	res_len = xmlrpc_array_size(&chamelium->env, res);
-	igt_assert(res_len == 8);
+	igt_assert(res_len == CHAMELIUM_MAX_AUDIO_CHANNELS);
 	for (i = 0; i < res_len; i++) {
 		xmlrpc_array_read_item(&chamelium->env, res, i, &res_channel);
 		xmlrpc_read_int(&chamelium->env, res_channel, &mapping[i]);
@@ -1058,8 +1058,10 @@ static void audio_format_from_xml(struct chamelium *chamelium,
 
 	if (rate)
 		xmlrpc_read_int(&chamelium->env, res_rate, rate);
-	if (channels)
+	if (channels) {
 		xmlrpc_read_int(&chamelium->env, res_channel, channels);
+		igt_assert(*channels <= CHAMELIUM_MAX_AUDIO_CHANNELS);
+	}
 
 	xmlrpc_DECREF(res_channel);
 	xmlrpc_DECREF(res_sample_format);
diff --git a/lib/igt_chamelium.h b/lib/igt_chamelium.h
index 33362b266ce4..28f726c91e83 100644
--- a/lib/igt_chamelium.h
+++ b/lib/igt_chamelium.h
@@ -65,6 +65,12 @@ struct chamelium_audio_file {
  */
 #define CHAMELIUM_DEFAULT_EDID 0
 
+/**
+ * CHAMELIUM_MAX_AUDIO_CHANNELS: the maximum number of audio capture channels
+ * supported by Chamelium.
+ */
+#define CHAMELIUM_MAX_AUDIO_CHANNELS 8
+
 struct chamelium *chamelium_init(int drm_fd);
 void chamelium_deinit(struct chamelium *chamelium);
 void chamelium_reset(struct chamelium *chamelium);
@@ -116,7 +122,7 @@ bool chamelium_has_audio_support(struct chamelium *chamelium,
 				 struct chamelium_port *port);
 void chamelium_get_audio_channel_mapping(struct chamelium *chamelium,
 					 struct chamelium_port *port,
-					 int mapping[static 8]);
+					 int mapping[static CHAMELIUM_MAX_AUDIO_CHANNELS]);
 void chamelium_get_audio_format(struct chamelium *chamelium,
 				struct chamelium_port *port,
 				int *rate, int *channels);
-- 
2.21.0



More information about the igt-dev mailing list