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

Peres, Martin
2019-05-27T14:41:25Z

On 27/05/2019 17:35, Ser, Simon wrote:
> This allows us not to hardcode 8 everywhere.
>
> Signed-off-by: Simon Ser <simon.ser@intel.com>

The series is:
Reviewed-by: Martin Peres <martin.peres@linux.intel.com>

Please land the patches as soon as you get the CI results!

> ---
> 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);
>

---------------------------------------------------------------------
Intel Finland Oy
Registered Address: PL 281, 00181 Helsinki
Business Identity Code: 0357606 - 4
Domiciled in Helsinki

This e-mail and any attachments may contain confidential material for
the sole use of the intended recipient(s). Any review or distribution
by others is strictly prohibited. If you are not the intended
recipient, please contact the sender and delete all copies.