From: Simon Ser <simon.ser@intel.com>
To: igt-dev@lists.freedesktop.org
Cc: martin.peres@intel.com
Subject: [igt-dev] [PATCH i-g-t 4/5] tests/kms_chamelium: add S24_LE and S32_LE audio tests
Date: Fri, 17 May 2019 19:02:41 +0300 [thread overview]
Message-ID: <20190517160242.28247-4-simon.ser@intel.com> (raw)
In-Reply-To: <20190517160242.28247-1-simon.ser@intel.com>
This adds a new test_formats array, which is a list of PCM formats we want to
run the tests with. We try to run tests for all combinations of sampling rates
and formats.
The ALSA callback now needs to fill the playback buffer differently depending
on the format.
Signed-off-by: Simon Ser <simon.ser@intel.com>
---
tests/kms_chamelium.c | 86 ++++++++++++++++++++++++++++++-------------
1 file changed, 60 insertions(+), 26 deletions(-)
diff --git a/tests/kms_chamelium.c b/tests/kms_chamelium.c
index af9f54d1f4c7..88356dd232b6 100644
--- a/tests/kms_chamelium.c
+++ b/tests/kms_chamelium.c
@@ -795,8 +795,17 @@ static int test_frequencies[] = {
static int test_frequencies_count = sizeof(test_frequencies) / sizeof(int);
+static const snd_pcm_format_t test_formats[] = {
+ SND_PCM_FORMAT_S16_LE,
+ SND_PCM_FORMAT_S24_LE,
+ SND_PCM_FORMAT_S32_LE,
+};
+
+static const size_t test_formats_count = sizeof(test_formats) / sizeof(test_formats[0]);
+
struct audio_state {
struct audio_signal *signal;
+ snd_pcm_format_t format;
atomic_bool run;
};
@@ -805,7 +814,19 @@ audio_output_callback(void *data, void *buffer, int samples)
{
struct audio_state *state = data;
- audio_signal_fill_s16_le(state->signal, buffer, samples);
+ switch (state->format) {
+ case SND_PCM_FORMAT_S16_LE:
+ audio_signal_fill_s16_le(state->signal, buffer, samples);
+ break;
+ case SND_PCM_FORMAT_S24_LE:
+ audio_signal_fill_s24_le(state->signal, buffer, samples);
+ break;
+ case SND_PCM_FORMAT_S32_LE:
+ audio_signal_fill_s32_le(state->signal, buffer, samples);
+ break;
+ default:
+ assert(false); /* unreachable */
+ }
return state->run ? 0 : -1;
}
@@ -881,6 +902,7 @@ do_test_display_audio(data_t *data, struct chamelium_port *port,
audio_signal_synthesize(signal);
state.signal = signal;
+ state.format = playback_format;
state.run = true;
alsa_register_output_callback(alsa, audio_output_callback, &state,
PLAYBACK_SAMPLES);
@@ -1027,6 +1049,22 @@ do_test_display_audio(data_t *data, struct chamelium_port *port,
return success;
}
+static bool test_audio_configuration(struct alsa *alsa, snd_pcm_format_t format,
+ int channels, int sampling_rate)
+{
+ if (!alsa_test_output_configuration(alsa, format, channels,
+ sampling_rate)) {
+ igt_debug("Skipping test with format %s, sampling rate %d Hz "
+ "and %d channels because at least one of the "
+ "selected output devices doesn't support this "
+ "configuration\n",
+ snd_pcm_format_name(format),
+ sampling_rate, channels);
+ return false;
+ }
+ return true;
+}
+
static void
test_display_audio(data_t *data, struct chamelium_port *port,
const char *audio_device, enum test_edid edid)
@@ -1039,7 +1077,7 @@ test_display_audio(data_t *data, struct chamelium_port *port,
struct igt_fb fb;
drmModeModeInfo *mode;
drmModeConnector *connector;
- int fb_id, i;
+ int fb_id, i, j;
int channels, sampling_rate;
snd_pcm_format_t format;
@@ -1076,35 +1114,31 @@ test_display_audio(data_t *data, struct chamelium_port *port,
run = false;
success = true;
for (i = 0; i < test_sampling_rates_count; i++) {
- ret = alsa_open_output(alsa, audio_device);
- igt_assert(ret >= 0);
-
- /* TODO: playback with different formats */
- /* TODO: playback on all 8 available channels */
- format = SND_PCM_FORMAT_S16_LE;
- channels = PLAYBACK_CHANNELS;
- sampling_rate = test_sampling_rates[i];
-
- if (!alsa_test_output_configuration(alsa, format, channels,
- sampling_rate)) {
- igt_debug("Skipping test with format %s, sample rate "
- "%d Hz and %d channels because at least one "
- "of the selected output devices doesn't "
- "support this configuration\n",
- snd_pcm_format_name(format),
- channels, sampling_rate);
- continue;
- }
+ for (j = 0; j < test_formats_count; j++) {
+ ret = alsa_open_output(alsa, audio_device);
+ igt_assert(ret >= 0);
+
+ /* TODO: playback with different formats */
+ /* TODO: playback on all 8 available channels */
+ format = test_formats[j];
+ channels = PLAYBACK_CHANNELS;
+ sampling_rate = test_sampling_rates[i];
- run = true;
+ if (!test_audio_configuration(alsa, format, channels,
+ sampling_rate))
+ continue;
- success &= do_test_display_audio(data, port, alsa, format,
- channels, sampling_rate);
+ run = true;
- alsa_close_output(alsa);
+ success &= do_test_display_audio(data, port, alsa,
+ format, channels,
+ sampling_rate);
+
+ alsa_close_output(alsa);
+ }
}
- /* Make sure we tested at least one frequency. */
+ /* Make sure we tested at least one frequency and format. */
igt_assert(run);
/* Make sure all runs were successful. */
igt_assert(success);
--
2.21.0
_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev
next prev parent reply other threads:[~2019-05-17 16:02 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-05-17 16:02 [igt-dev] [PATCH i-g-t 1/5] lib/igt_alsa: support all alsa formats Simon Ser
2019-05-17 16:02 ` [igt-dev] [PATCH i-g-t 2/5] lib/igt_alsa: add format argument to alsa_test_output_configuration Simon Ser
2019-05-20 12:08 ` Martin Peres
2019-05-17 16:02 ` [igt-dev] [PATCH i-g-t 3/5] lib/igt_audio: add support for S24_LE and S32_LE signal generation Simon Ser
2019-05-20 12:14 ` Martin Peres
2019-05-20 13:08 ` Ser, Simon
2019-05-17 16:02 ` Simon Ser [this message]
2019-05-20 12:20 ` [igt-dev] [PATCH i-g-t 4/5] tests/kms_chamelium: add S24_LE and S32_LE audio tests Peres, Martin
2019-05-20 13:10 ` Ser, Simon
2019-05-20 13:43 ` Martin Peres
2019-05-17 16:02 ` [igt-dev] [PATCH i-g-t 5/5] tests/kms_chamelium: skip audio tests Chamelium doesn't support Simon Ser
2019-05-20 12:21 ` Peres, Martin
2019-05-20 13:12 ` Ser, Simon
2019-05-17 16:44 ` [igt-dev] ✓ Fi.CI.BAT: success for series starting with [i-g-t,1/5] lib/igt_alsa: support all alsa formats Patchwork
2019-05-18 4:26 ` [igt-dev] ✓ Fi.CI.IGT: " Patchwork
2019-05-20 10:11 ` [igt-dev] [PATCH i-g-t 1/5] " Martin Peres
2019-05-20 10:38 ` Ser, Simon
2019-05-20 10:46 ` Martin Peres
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=20190517160242.28247-4-simon.ser@intel.com \
--to=simon.ser@intel.com \
--cc=igt-dev@lists.freedesktop.org \
--cc=martin.peres@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