From: Martin Peres <martin.peres@linux.intel.com>
To: Simon Ser <simon.ser@intel.com>, igt-dev@lists.freedesktop.org
Subject: Re: [igt-dev] [PATCH i-g-t v6 4/7] tests/kms_chamelium: test audio channels are not mixed up
Date: Tue, 23 Apr 2019 10:51:03 +0300 [thread overview]
Message-ID: <ed081511-311f-f661-c1a8-1d877f4a4403@linux.intel.com> (raw)
In-Reply-To: <20190417124359.12293-5-simon.ser@intel.com>
On 17/04/2019 15:43, Simon Ser wrote:
> Send a different signal to each channel and make sure captured audio channels
> are not swapped or mixed up.
>
> The Chamelium device has a bug and already swaps the left and right channels.
> For this reason, clients need to retrieve the Chamelium channel mapping and
> accomodate for this. See https://crbug.com/950922 for a discussion about this.
>
> Signed-off-by: Simon Ser <simon.ser@intel.com>
> ---
> lib/igt_chamelium.c | 34 ++++++++++++++++++++++++++++++++++
> lib/igt_chamelium.h | 3 +++
> tests/kms_chamelium.c | 37 +++++++++++++++++++++++++++++++------
> 3 files changed, 68 insertions(+), 6 deletions(-)
>
> diff --git a/lib/igt_chamelium.c b/lib/igt_chamelium.c
> index 7c9030d1..6ac7b722 100644
> --- a/lib/igt_chamelium.c
> +++ b/lib/igt_chamelium.c
> @@ -930,6 +930,40 @@ int chamelium_get_captured_frame_count(struct chamelium *chamelium)
> return ret;
> }
>
> +/**
> + * chamelium_get_audio_channel_mapping:
> + * @chamelium: the Chamelium instance
> + * @port: the audio port
> + * @mapping: will be filled with the channel mapping
> + *
> + * Obtains the channel mapping for an audio port.
> + *
> + * Audio channels are not guaranteed not to be swapped. Users can use the
> + * channel mapping to match an input channel to a capture channel.
> + *
> + * The mapping contains one element per capture channel. Each element indicates
> + * which input channel the capture channel is mapped to. As a special case, -1
> + * means that the channel isn't mapped.
> + */
> +void chamelium_get_audio_channel_mapping(struct chamelium *chamelium,
> + struct chamelium_port *port,
> + int mapping[static 8])
> +{
> + xmlrpc_value *res, *res_channel;
> + int res_len, i;
> +
> + res = chamelium_rpc(chamelium, port, "GetAudioChannelMapping", "(i)",
> + port->id);
> + res_len = xmlrpc_array_size(&chamelium->env, res);
> + igt_assert(res_len == 8);
> + 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]);
> + xmlrpc_DECREF(res_channel);
> + }
> + xmlrpc_DECREF(res);
> +}
> +
> /**
> * chamelium_start_capturing_audio:
> * @chamelium: the Chamelium instance
> diff --git a/lib/igt_chamelium.h b/lib/igt_chamelium.h
> index 047f8c5d..728d16ea 100644
> --- a/lib/igt_chamelium.h
> +++ b/lib/igt_chamelium.h
> @@ -106,6 +106,9 @@ void chamelium_start_capture(struct chamelium *chamelium,
> void chamelium_stop_capture(struct chamelium *chamelium, int frame_count);
> void chamelium_capture(struct chamelium *chamelium, struct chamelium_port *port,
> int x, int y, int w, int h, int frame_count);
> +void chamelium_get_audio_channel_mapping(struct chamelium *chamelium,
> + struct chamelium_port *port,
> + int mapping[static 8]);
> void chamelium_start_capturing_audio(struct chamelium *chamelium,
> struct chamelium_port *port, bool save_to_file);
> struct chamelium_audio_file *chamelium_stop_capturing_audio(struct chamelium *chamelium,
> diff --git a/tests/kms_chamelium.c b/tests/kms_chamelium.c
> index d336612f..8d6cc092 100644
> --- a/tests/kms_chamelium.c
> +++ b/tests/kms_chamelium.c
> @@ -777,7 +777,7 @@ do_test_display_audio(data_t *data, struct chamelium_port *port,
> struct alsa *alsa, int playback_channels,
> int playback_rate)
> {
> - int ret, capture_rate, capture_channels, msec, freq;
> + int ret, capture_rate, capture_channels, msec, freq, step;
> struct chamelium_audio_file *audio_file;
> struct chamelium_stream *stream;
> enum chamelium_stream_realtime_mode stream_mode;
> @@ -792,16 +792,17 @@ do_test_display_audio(data_t *data, struct chamelium_port *port,
> int dump_fd = -1;
> pthread_t thread;
> struct audio_state state = {};
> + int channel_mapping[8], capture_chan;
>
> if (!alsa_test_output_configuration(alsa, playback_channels,
> playback_rate)) {
> - igt_debug("Skipping test with sample rate %d and %d channels "
> + igt_debug("Skipping test with sample rate %d Hz and %d channels "
> "because selected output devices don't support this "
How about "because at least some output devices do not support this"?
> "configuration\n", playback_rate, playback_channels);
> return false;
> }
>
> - igt_debug("Testing with playback sampling rate %d and %d channels\n",
> + igt_debug("Testing with playback sampling rate %d Hz and %d channels\n",
> playback_rate, playback_channels);
> alsa_configure_output(alsa, playback_channels, playback_rate);
>
> @@ -830,9 +831,15 @@ do_test_display_audio(data_t *data, struct chamelium_port *port,
> signal = audio_signal_init(playback_channels, playback_rate);
> igt_assert(signal);
>
> + /* We'll choose different frequencies per channel to make sure they are
> + * independent from each other. To do so, we'll add a different offset
> + * to the base frequencies for each channel. We need to choose a big
> + * enough offset so that we're sure to detect mixed up channels.
> + */
> + step = 2 * capture_rate / CAPTURE_SAMPLES;
Please say that this formula adds an offset of 2 bins in the final FFT,
thus enforcing a clear difference (please make sure of that).
> for (i = 0; i < test_frequencies_count; i++) {
> for (j = 0; j < playback_channels; j++) {
> - freq = test_frequencies[i];
> + freq = test_frequencies[i] + j * step;
> audio_signal_add_frequency(signal, freq, j);
> }
> }
> @@ -847,6 +854,20 @@ do_test_display_audio(data_t *data, struct chamelium_port *port,
> ret = pthread_create(&thread, NULL, run_audio_thread, alsa);
> igt_assert(ret == 0);
>
> + chamelium_get_audio_channel_mapping(data->chamelium, port,
> + channel_mapping);
> + /* Make sure we can capture all channels we send. */
> + for (i = 0; i < playback_channels; i++) {
> + ok = false;
> + for (j = 0; j < capture_channels; j++) {
> + if (channel_mapping[j] == i) {
> + ok = true;
> + break;
> + }
> + }
> + igt_assert(ok);
> + }
> +
> /* Needs to be a multiple of 128, because that's the number of samples
> * we get per channel each time we receive an audio page from the
> * Chamelium device. */
> @@ -886,11 +907,15 @@ do_test_display_audio(data_t *data, struct chamelium_port *port,
> igt_debug("Detecting audio signal, t=%d msec\n", msec);
>
> for (j = 0; j < playback_channels; j++) {
> - igt_debug("Processing channel %zu\n", j);
> + capture_chan = channel_mapping[j];
> + igt_assert(capture_chan >= 0);
> + igt_debug("Processing channel %zu (captured as "
> + "channel %d)\n", j, capture_chan);
>
> audio_extract_channel_s32_le(channel, channel_len,
> buf, buf_len,
> - capture_channels, j);
> + capture_channels,
> + capture_chan);
>
> if (audio_signal_detect(signal, capture_rate, j,
> channel, channel_len))
>
Looks great!
Reviewed-by: Martin Peres <martin.peres@linux.intel.com>
_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev
next prev parent reply other threads:[~2019-04-23 7:51 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-04-17 12:43 [igt-dev] [PATCH i-g-t v6 0/7] tests/kms_chamelium: add dp-audio test Simon Ser
2019-04-17 12:43 ` [igt-dev] [PATCH i-g-t v6 1/7] " Simon Ser
2019-04-17 12:43 ` [igt-dev] [PATCH i-g-t v6 2/7] tests/kms_chamelium: capture audio data in real-time Simon Ser
2019-04-17 12:57 ` Martin Peres
2019-04-17 12:43 ` [igt-dev] [PATCH i-g-t v6 3/7] tests/kms_chamelium: test we receive a signal from both audio channels Simon Ser
2019-04-23 7:41 ` Martin Peres
2019-04-23 12:23 ` Ser, Simon
2019-04-17 12:43 ` [igt-dev] [PATCH i-g-t v6 4/7] tests/kms_chamelium: test audio channels are not mixed up Simon Ser
2019-04-23 7:51 ` Martin Peres [this message]
2019-04-23 12:57 ` Ser, Simon
2019-04-17 12:43 ` [igt-dev] [PATCH i-g-t v6 5/7] tests/kms_chamelium: run audio test with multiple sampling rates Simon Ser
2019-04-23 7:58 ` Martin Peres
2019-04-23 12:59 ` Ser, Simon
2019-04-25 9:58 ` Martin Peres
2019-04-17 12:43 ` [igt-dev] [PATCH i-g-t v6 6/7] lib/igt_edid: add support for Short Audio Descriptors Simon Ser
2019-04-17 12:43 ` [igt-dev] [PATCH i-g-t v6 7/7] HAX: add dp-audio test to fast-feedback Simon Ser
2019-04-23 8:04 ` Martin Peres
2019-04-17 13:25 ` [igt-dev] ✗ Fi.CI.BAT: failure for tests/kms_chamelium: add dp-audio test (rev6) Patchwork
2019-04-17 16:27 ` Ser, Simon
2019-04-17 17:23 ` [igt-dev] ✓ Fi.CI.BAT: success for tests/kms_chamelium: add dp-audio test (rev7) Patchwork
2019-04-23 8:05 ` Martin Peres
2019-04-18 1:25 ` [igt-dev] ✓ Fi.CI.IGT: " Patchwork
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ed081511-311f-f661-c1a8-1d877f4a4403@linux.intel.com \
--to=martin.peres@linux.intel.com \
--cc=igt-dev@lists.freedesktop.org \
--cc=simon.ser@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox