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 2/5] lib/igt_alsa: add format argument to alsa_test_output_configuration
Date: Fri, 17 May 2019 19:02:39 +0300 [thread overview]
Message-ID: <20190517160242.28247-2-simon.ser@intel.com> (raw)
In-Reply-To: <20190517160242.28247-1-simon.ser@intel.com>
This allows us to test whether HW supports a PCM format, and only run the test
if it's the case.
Signed-off-by: Simon Ser <simon.ser@intel.com>
---
lib/igt_alsa.c | 18 +++++++++++++-----
lib/igt_alsa.h | 4 ++--
tests/kms_chamelium.c | 31 ++++++++++++++++++++-----------
3 files changed, 35 insertions(+), 18 deletions(-)
diff --git a/lib/igt_alsa.c b/lib/igt_alsa.c
index 2dfb8ccd3ad9..5b5980a94888 100644
--- a/lib/igt_alsa.c
+++ b/lib/igt_alsa.c
@@ -266,8 +266,8 @@ void alsa_close_output(struct alsa *alsa)
alsa->output_callback = NULL;
}
-static bool alsa_test_configuration(snd_pcm_t *handle, int channels,
- int sampling_rate)
+static bool alsa_test_configuration(snd_pcm_t *handle, snd_pcm_format_t fmt,
+ int channels, int sampling_rate)
{
snd_pcm_hw_params_t *params;
int ret;
@@ -281,6 +281,13 @@ static bool alsa_test_configuration(snd_pcm_t *handle, int channels,
if (ret < 0)
return false;
+ ret = snd_pcm_hw_params_test_format(handle, params, fmt);
+ if (ret < 0) {
+ igt_debug("Output device doesn't support the format %s\n",
+ snd_pcm_format_name(fmt));
+ return false;
+ }
+
ret = snd_pcm_hw_params_test_rate(handle, params, sampling_rate, 0);
if (ret < 0) {
snd_pcm_hw_params_get_rate_min(params, &min_rate, &min_rate_dir);
@@ -307,6 +314,7 @@ static bool alsa_test_configuration(snd_pcm_t *handle, int channels,
/**
* alsa_test_output_configuration:
* @alsa: The target alsa structure
+ * @fmt: The format to test
* @channels: The number of channels to test
* @sampling_rate: The sampling rate to test
*
@@ -315,8 +323,8 @@ static bool alsa_test_configuration(snd_pcm_t *handle, int channels,
*
* Returns: A boolean indicating whether the test succeeded
*/
-bool alsa_test_output_configuration(struct alsa *alsa, int channels,
- int sampling_rate)
+bool alsa_test_output_configuration(struct alsa *alsa, snd_pcm_format_t fmt,
+ int channels, int sampling_rate)
{
snd_pcm_t *handle;
bool ret;
@@ -325,7 +333,7 @@ bool alsa_test_output_configuration(struct alsa *alsa, int channels,
for (i = 0; i < alsa->output_handles_count; i++) {
handle = alsa->output_handles[i];
- ret = alsa_test_configuration(handle, channels, sampling_rate);
+ ret = alsa_test_configuration(handle, fmt, channels, sampling_rate);
if (!ret)
return false;
}
diff --git a/lib/igt_alsa.h b/lib/igt_alsa.h
index 46b3568d26fd..1ece9f5255d8 100644
--- a/lib/igt_alsa.h
+++ b/lib/igt_alsa.h
@@ -38,8 +38,8 @@ bool alsa_has_exclusive_access(void);
struct alsa *alsa_init(void);
int alsa_open_output(struct alsa *alsa, const char *device_name);
void alsa_close_output(struct alsa *alsa);
-bool alsa_test_output_configuration(struct alsa *alsa, int channels,
- int sampling_rate);
+bool alsa_test_output_configuration(struct alsa *alsa, snd_pcm_format_t dmt,
+ int channels, int sampling_rate);
void alsa_configure_output(struct alsa *alsa, snd_pcm_format_t fmt,
int channels, int sampling_rate);
void alsa_register_output_callback(struct alsa *alsa,
diff --git a/tests/kms_chamelium.c b/tests/kms_chamelium.c
index 2b465565418d..af9f54d1f4c7 100644
--- a/tests/kms_chamelium.c
+++ b/tests/kms_chamelium.c
@@ -821,8 +821,8 @@ run_audio_thread(void *data)
static bool
do_test_display_audio(data_t *data, struct chamelium_port *port,
- struct alsa *alsa, int playback_channels,
- int playback_rate)
+ struct alsa *alsa, snd_pcm_format_t playback_format,
+ int playback_channels, int playback_rate)
{
int ret, capture_rate, capture_channels, msec, freq, step;
struct chamelium_audio_file *audio_file;
@@ -841,9 +841,11 @@ do_test_display_audio(data_t *data, struct chamelium_port *port,
struct audio_state state = {};
int channel_mapping[8], capture_chan;
- igt_debug("Testing with playback sampling rate %d Hz and %d channels\n",
+ igt_debug("Testing with playback format %s, sampling rate %d Hz and "
+ "%d channels\n",
+ snd_pcm_format_name(playback_format),
playback_rate, playback_channels);
- alsa_configure_output(alsa, SND_PCM_FORMAT_S16_LE,
+ alsa_configure_output(alsa, playback_format,
playback_channels, playback_rate);
chamelium_start_capturing_audio(data->chamelium, port, false);
@@ -913,7 +915,9 @@ do_test_display_audio(data_t *data, struct chamelium_port *port,
}
if (igt_frame_dump_is_enabled()) {
- snprintf(dump_suffix, sizeof(dump_suffix), "capture-%dch-%d",
+ snprintf(dump_suffix, sizeof(dump_suffix),
+ "capture-%s-%dch-%dHz",
+ snd_pcm_format_name(playback_format),
playback_channels, playback_rate);
dump_fd = audio_create_wav_file_s32_le(dump_suffix,
@@ -1037,6 +1041,7 @@ test_display_audio(data_t *data, struct chamelium_port *port,
drmModeConnector *connector;
int fb_id, i;
int channels, sampling_rate;
+ snd_pcm_format_t format;
igt_require(alsa_has_exclusive_access());
@@ -1074,23 +1079,27 @@ test_display_audio(data_t *data, struct chamelium_port *port,
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, channels,
+ if (!alsa_test_output_configuration(alsa, format, channels,
sampling_rate)) {
- igt_debug("Skipping test with sample rate %d Hz and %d channels "
- "because at least one of the selected output devices "
- "doesn't support this configuration\n",
+ 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;
}
run = true;
- success &= do_test_display_audio(data, port, alsa, channels,
- sampling_rate);
+ success &= do_test_display_audio(data, port, alsa, format,
+ channels, sampling_rate);
alsa_close_output(alsa);
}
--
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 ` Simon Ser [this message]
2019-05-20 12:08 ` [igt-dev] [PATCH i-g-t 2/5] lib/igt_alsa: add format argument to alsa_test_output_configuration 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 ` [igt-dev] [PATCH i-g-t 4/5] tests/kms_chamelium: add S24_LE and S32_LE audio tests Simon Ser
2019-05-20 12:20 ` 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-2-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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.