diff options
author | Simon Ser <simon.ser@intel.com> | 2019-04-23 16:04:52 +0300 |
---|---|---|
committer | Arkadiusz Hiler <arkadiusz.hiler@intel.com> | 2019-04-25 13:07:15 +0300 |
commit | 311baff151f90c1db6f57ee9515216b4f9da5db7 (patch) | |
tree | cff58efbdacda05b06e7d88a2ab3d68816687eb4 /lib/igt_alsa.c | |
parent | 11e10bc575516c56978640fcc697c27f277c660a (diff) |
tests/kms_chamelium: add dp-audio test
This new test ensures DisplayPort audio works by using the Chamelium.
It enables the DisplayPort output and sends an audio signal containing a set of
frequencies we choose to all HDMI/DisplayPort audio devices. It starts
recording audio on the Chamelium device and uses the stream server to retrieve
captured audio pages. It then checks that the capture audio signal contains the
frequencies we sent, and only those, by computing a FFT.
A new library has been added to libigt to communicate with the stream server.
It implements a simple custom TCP protocol.
In case the test fails, a WAV file with the captured data is saved on disk.
Right now the test has a few limitations:
- Only the first channel is checked
- IGT only generates audio with a single sampling rate (48 KHz)
- Audio data is not captured in real-time
These limitations will be lifted in future patches.
PulseAudio must not run during the tests since ALSA is used directly. To ensure
this, edit /etc/pulse/client.conf and add `autospawn=no`. Then run
`pulseaudio --kill`.
This commit deletes the existing audio tests. They weren't run and required an
exotic configuration (HDMI audio splitter, dummy HDMI sink and a line-in port
on the DUT).
This patch also changes lib/igt_audio to use uint16_t instead of short. The
rationale is:
- The standard says a short is at least 16 bit wide, but a short can be
larger (in practice it won't happen, but better use types correctly)
- It makes it clearer that the audio format is S16_LE, since "16" is
in the type name.
This patch depends on the following Chameleon bugs:
- https://crbug.com/948060
- https://crbug.com/950857
Signed-off-by: Simon Ser <simon.ser@intel.com>
Reviewed-by: Martin Peres <martin.peres@linux.intel.com>
Diffstat (limited to 'lib/igt_alsa.c')
-rw-r--r-- | lib/igt_alsa.c | 42 |
1 files changed, 38 insertions, 4 deletions
diff --git a/lib/igt_alsa.c b/lib/igt_alsa.c index bb6682cc..22089881 100644 --- a/lib/igt_alsa.c +++ b/lib/igt_alsa.c @@ -26,9 +26,11 @@ #include "config.h" +#include <limits.h> #include <alsa/asoundlib.h> #include "igt_alsa.h" +#include "igt_aux.h" #include "igt_core.h" #define HANDLES_MAX 8 @@ -61,6 +63,26 @@ struct alsa { int input_samples_trigger; }; +/** + * alsa_has_exclusive_access: + * Check whether ALSA has exclusive access to audio devices. Fails if + * PulseAudio is running. + */ +bool alsa_has_exclusive_access(void) +{ + if (igt_is_process_running("pulseaudio")) { + igt_warn("alsa doesn't have exclusive access to audio devices\n"); + igt_warn("It seems that PulseAudio is running. Audio tests " + "need direct access to audio devices, so PulseAudio " + "needs to be stopped. You can do so by running " + "`pulseaudio --kill`. Also make sure to add " + "autospawn=no to /etc/pulse/client.conf\n"); + return false; + } + + return true; +} + static void alsa_error_handler(const char *file, int line, const char *function, int err, const char *fmt, ...) { @@ -78,6 +100,10 @@ struct alsa *alsa_init(void) { struct alsa *alsa; + if (!alsa_has_exclusive_access()) { + return NULL; + } + alsa = malloc(sizeof(struct alsa)); memset(alsa, 0, sizeof(struct alsa)); @@ -553,16 +579,20 @@ int alsa_run(struct alsa *alsa, int duration_ms) if (ret < 0) { ret = snd_pcm_recover(handle, ret, 0); - if (ret < 0) + if (ret < 0) { + igt_debug("snd_pcm_recover after snd_pcm_writei failed"); goto complete; + } } output_counts[i] += ret; } else if (output_counts[i] < output_trigger && ret < 0) { ret = snd_pcm_recover(handle, ret, 0); - if (ret < 0) + if (ret < 0) { + igt_debug("snd_pcm_recover failed"); goto complete; + } } } @@ -609,16 +639,20 @@ int alsa_run(struct alsa *alsa, int duration_ms) ret = 0; } else if (ret < 0) { ret = snd_pcm_recover(handle, ret, 0); - if (ret < 0) + if (ret < 0) { + igt_debug("snd_pcm_recover after snd_pcm_readi failed"); goto complete; + } } input_count += ret; input_total += ret; } else if (input_count < input_trigger && ret < 0) { ret = snd_pcm_recover(handle, ret, 0); - if (ret < 0) + if (ret < 0) { + igt_debug("snd_pcm_recover failed"); goto complete; + } } } } while (!reached); |