diff options
author | Simon Ser <simon.ser@intel.com> | 2019-04-23 16:04:58 +0300 |
---|---|---|
committer | Arkadiusz Hiler <arkadiusz.hiler@intel.com> | 2019-04-25 13:07:53 +0300 |
commit | ffe44144a2285788ae07768a9240b27ea8182d5c (patch) | |
tree | d506cf0c7a24eea420403b6399b2a4b746caf646 /lib/igt_chamelium.c | |
parent | 7775f1562ca348f0c1a21388053172368055c5f1 (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 'lib/igt_chamelium.c')
-rw-r--r-- | lib/igt_chamelium.c | 80 |
1 files changed, 53 insertions, 27 deletions
diff --git a/lib/igt_chamelium.c b/lib/igt_chamelium.c index 6ac7b722..ffc68f35 100644 --- a/lib/igt_chamelium.c +++ b/lib/igt_chamelium.c @@ -964,31 +964,6 @@ void chamelium_get_audio_channel_mapping(struct chamelium *chamelium, xmlrpc_DECREF(res); } -/** - * chamelium_start_capturing_audio: - * @chamelium: the Chamelium instance - * @port: the port to capture audio from (it must support audio) - * @save_to_file: whether the captured audio data should be saved to a file on - * the Chamelium device - * - * Starts capturing audio from a Chamelium port. To stop the capture, use - * #chamelium_stop_capturing_audio. To retrieve the audio data, either use the - * stream server or enable @save_to_file (the latter is mainly useful for - * debugging purposes). - * - * It isn't possible to capture audio from multiple ports at the same time. - */ -void chamelium_start_capturing_audio(struct chamelium *chamelium, - struct chamelium_port *port, - bool save_to_file) -{ - xmlrpc_value *res; - - res = chamelium_rpc(chamelium, port, "StartCapturingAudio", "(ib)", - port->id, save_to_file); - xmlrpc_DECREF(res); -} - static void audio_format_from_xml(struct chamelium *chamelium, xmlrpc_value *res, int *rate, int *channels) { @@ -1008,8 +983,10 @@ static void audio_format_from_xml(struct chamelium *chamelium, igt_assert(strcmp(sample_format, "S32_LE") == 0); free(sample_format); - xmlrpc_read_int(&chamelium->env, res_rate, rate); - xmlrpc_read_int(&chamelium->env, res_channel, channels); + if (rate) + xmlrpc_read_int(&chamelium->env, res_rate, rate); + if (channels) + xmlrpc_read_int(&chamelium->env, res_channel, channels); xmlrpc_DECREF(res_channel); xmlrpc_DECREF(res_sample_format); @@ -1018,6 +995,55 @@ static void audio_format_from_xml(struct chamelium *chamelium, } /** + * chamelium_get_audio_format: + * @chamelium: the Chamelium instance + * @port: the audio port + * @rate: if non-NULL, will be set to the sample rate in Hz + * @channels: if non-NULL, will be set to the number of channels + * + * Obtains the audio format of the captured data. Users should start sending an + * audio signal to the Chamelium device prior to calling this function. + * + * The captured data is guaranteed to be in the S32_LE format. + */ +void chamelium_get_audio_format(struct chamelium *chamelium, + struct chamelium_port *port, + int *rate, int *channels) +{ + xmlrpc_value *res; + + res = chamelium_rpc(chamelium, port, "GetAudioFormat", "(i)", + port->id); + audio_format_from_xml(chamelium, res, rate, channels); + xmlrpc_DECREF(res); +} + +/** + * chamelium_start_capturing_audio: + * @chamelium: the Chamelium instance + * @port: the port to capture audio from (it must support audio) + * @save_to_file: whether the captured audio data should be saved to a file on + * the Chamelium device + * + * Starts capturing audio from a Chamelium port. To stop the capture, use + * #chamelium_stop_capturing_audio. To retrieve the audio data, either use the + * stream server or enable @save_to_file (the latter is mainly useful for + * debugging purposes). + * + * It isn't possible to capture audio from multiple ports at the same time. + */ +void chamelium_start_capturing_audio(struct chamelium *chamelium, + struct chamelium_port *port, + bool save_to_file) +{ + xmlrpc_value *res; + + res = chamelium_rpc(chamelium, port, "StartCapturingAudio", "(ib)", + port->id, save_to_file); + xmlrpc_DECREF(res); +} + +/** * chamelium_stop_capturing_audio: * @chamelium: the Chamelium instance * @port: the port from which audio is being captured |