summaryrefslogtreecommitdiff
path: root/tests/kms_chamelium.c
diff options
context:
space:
mode:
authorSimon Ser <simon.ser@intel.com>2019-04-23 16:04:58 +0300
committerArkadiusz Hiler <arkadiusz.hiler@intel.com>2019-04-25 13:07:53 +0300
commitffe44144a2285788ae07768a9240b27ea8182d5c (patch)
treed506cf0c7a24eea420403b6399b2a4b746caf646 /tests/kms_chamelium.c
parent7775f1562ca348f0c1a21388053172368055c5f1 (diff)
tests/kms_chamelium: run audio test with multiple sampling rates
The audio test is now run multiple times with a variety of playback sampling rates. We now query the capture audio format from the Chamelium XML-RPC API instead of hardcoding it. One limitation is that we need to start sending an audio signal before being able to query the capture audio format. However we need the capture sample rate to decide which frequencies we generate. For now we use the playback rate and check that it's the same as the capture rate. Another limitation is that the DP receiver reports an unknown sampling rate during the 44.1KHz test. In this case we assume the capture rate is the same as the playback rate. We'll fail later anyway if this assumption is incorrect since we check the signal we receive. Chameleon bug: https://crbug.com/950913 Signed-off-by: Simon Ser <simon.ser@intel.com> Reviewed-by: Martin Peres <martin.peres@linux.intel.com>
Diffstat (limited to 'tests/kms_chamelium.c')
-rw-r--r--tests/kms_chamelium.c54
1 files changed, 33 insertions, 21 deletions
diff --git a/tests/kms_chamelium.c b/tests/kms_chamelium.c
index 1118da86..714e5e06 100644
--- a/tests/kms_chamelium.c
+++ b/tests/kms_chamelium.c
@@ -725,15 +725,14 @@ test_display_frame_dump(data_t *data, struct chamelium_port *port)
/* A streak of 3 gives confidence that the signal is good. */
#define MIN_STREAK 3
-/* TODO: Chamelium only supports 48KHz for now */
static int sampling_rates[] = {
-/* 32000, */
-/* 44100, */
+ 32000,
+ 44100,
48000,
-/* 88200, */
-/* 96000, */
-/* 176400, */
-/* 192000, */
+ 88200,
+ 96000,
+ 176400,
+ 192000,
};
static int sampling_rates_count = sizeof(sampling_rates) / sizeof(int);
@@ -816,19 +815,6 @@ do_test_display_audio(data_t *data, struct chamelium_port *port,
ok = chamelium_stream_dump_realtime_audio(stream, stream_mode);
igt_assert(ok);
- chamelium_stream_audio_format(stream, &capture_rate, &capture_channels);
-
- if (igt_frame_dump_is_enabled()) {
- snprintf(dump_suffix, sizeof(dump_suffix), "capture-%dch-%d",
- playback_channels, playback_rate);
-
- dump_fd = audio_create_wav_file_s32_le(dump_suffix,
- capture_rate,
- capture_channels,
- &dump_path);
- igt_assert(dump_fd >= 0);
- }
-
signal = audio_signal_init(playback_channels, playback_rate);
igt_assert(signal);
@@ -838,8 +824,12 @@ do_test_display_audio(data_t *data, struct chamelium_port *port,
* enough offset so that we're sure to detect mixed up channels. We
* choose an offset of two 2 bins in the final FFT to enforce a clear
* difference.
+ *
+ * Note that we assume capture_rate == playback_rate. We'll assert this
+ * later on. We cannot retrieve the capture rate before starting
+ * playing audio, so we don't really have the choice.
*/
- step = 2 * capture_rate / CAPTURE_SAMPLES;
+ step = 2 * playback_rate / CAPTURE_SAMPLES;
for (i = 0; i < test_frequencies_count; i++) {
for (j = 0; j < playback_channels; j++) {
freq = test_frequencies[i] + j * step;
@@ -857,6 +847,17 @@ do_test_display_audio(data_t *data, struct chamelium_port *port,
ret = pthread_create(&thread, NULL, run_audio_thread, alsa);
igt_assert(ret == 0);
+ /* Only after we've started playing audio, we can retrieve the capture
+ * format used by the Chamelium device. */
+ chamelium_get_audio_format(data->chamelium, port,
+ &capture_rate, &capture_channels);
+ if (capture_rate == 0) {
+ igt_debug("Audio receiver doesn't indicate the capture "
+ "sampling rate, assuming it's %d Hz\n", playback_rate);
+ capture_rate = playback_rate;
+ } else
+ igt_assert(capture_rate == playback_rate);
+
chamelium_get_audio_channel_mapping(data->chamelium, port,
channel_mapping);
/* Make sure we can capture all channels we send. */
@@ -871,6 +872,17 @@ do_test_display_audio(data_t *data, struct chamelium_port *port,
igt_assert(ok);
}
+ if (igt_frame_dump_is_enabled()) {
+ snprintf(dump_suffix, sizeof(dump_suffix), "capture-%dch-%d",
+ playback_channels, playback_rate);
+
+ dump_fd = audio_create_wav_file_s32_le(dump_suffix,
+ capture_rate,
+ capture_channels,
+ &dump_path);
+ igt_assert(dump_fd >= 0);
+ }
+
/* 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. */