hal: Configure correct COPP sample rate for USB and HDMI devices.
-In case of playback over HDMI/USB, the device might not support the same sample rate as of the stream, though it is preferred that resampling happens after post processing, but if device sample rate is not even a multiple of stream sample rate, ensure that resampling happens in the COPP. Change-Id: Ia8cdff5294433ec099b703001d11da905bf82c9b
This commit is contained in:
parent
44995bad21
commit
a052e57d42
|
@ -666,6 +666,18 @@ int audio_extn_utils_send_app_type_cfg(struct audio_device *adev,
|
|||
if ((24 == usecase->stream.out->bit_width) &&
|
||||
(usecase->stream.out->devices & AUDIO_DEVICE_OUT_SPEAKER)) {
|
||||
usecase->stream.out->app_type_cfg.sample_rate = DEFAULT_OUTPUT_SAMPLING_RATE;
|
||||
} else if ((snd_device == SND_DEVICE_OUT_HDMI ||
|
||||
snd_device == SND_DEVICE_OUT_USB_HEADSET ||
|
||||
snd_device == SND_DEVICE_OUT_DISPLAY_PORT) &&
|
||||
(usecase->stream.out->sample_rate >= OUTPUT_SAMPLING_RATE_44100)) {
|
||||
/*
|
||||
* To best utlize DSP, check if the stream sample rate is supported/multiple of
|
||||
* configured device sample rate, if not update the COPP rate to be equal to the
|
||||
* device sample rate, else open COPP at stream sample rate
|
||||
*/
|
||||
platform_check_and_update_copp_sample_rate(adev->platform, snd_device,
|
||||
usecase->stream.out->sample_rate,
|
||||
&usecase->stream.out->app_type_cfg.sample_rate);
|
||||
} else if ((snd_device != SND_DEVICE_OUT_HEADPHONES_44_1 &&
|
||||
usecase->stream.out->sample_rate == OUTPUT_SAMPLING_RATE_44100) ||
|
||||
(usecase->stream.out->sample_rate < OUTPUT_SAMPLING_RATE_44100)) {
|
||||
|
|
|
@ -5016,6 +5016,29 @@ int platform_set_stream_channel_map(void *platform, audio_channel_mask_t channel
|
|||
return ret;
|
||||
}
|
||||
|
||||
void platform_check_and_update_copp_sample_rate(void* platform, snd_device_t snd_device,
|
||||
unsigned int stream_sr, int* sample_rate)
|
||||
{
|
||||
struct platform_data* my_data = (struct platform_data *)platform;
|
||||
int backend_idx = platform_get_backend_index(snd_device);
|
||||
int device_sr = my_data->current_backend_cfg[backend_idx].sample_rate;
|
||||
/*Check if device SR is multiple of 8K or 11.025 Khz
|
||||
*check if the stream SR is multiple of same base, if not set
|
||||
*copp sample rate equal to device sample rate.
|
||||
*/
|
||||
if (!(((sample_rate_multiple(device_sr, SAMPLE_RATE_8000)) &&
|
||||
(sample_rate_multiple(stream_sr, SAMPLE_RATE_8000))) ||
|
||||
((sample_rate_multiple(device_sr, SAMPLE_RATE_11025)) &&
|
||||
(sample_rate_multiple(stream_sr, SAMPLE_RATE_11025))))) {
|
||||
*sample_rate = device_sr;
|
||||
} else
|
||||
*sample_rate = stream_sr;
|
||||
|
||||
ALOGI("sn_device %d device sr %d stream sr %d copp sr %d", snd_device, device_sr, stream_sr
|
||||
, *sample_rate);
|
||||
|
||||
}
|
||||
|
||||
int platform_get_edid_info(void *platform)
|
||||
{
|
||||
struct platform_data *my_data = (struct platform_data *)platform;
|
||||
|
|
|
@ -5299,6 +5299,32 @@ uint32_t platform_get_compress_passthrough_buffer_size(
|
|||
return fragment_size;
|
||||
}
|
||||
|
||||
void platform_check_and_update_copp_sample_rate(void* platform, snd_device_t snd_device,
|
||||
unsigned int stream_sr, int* sample_rate)
|
||||
{
|
||||
struct platform_data* my_data = (struct platform_data *)platform;
|
||||
int backend_idx = platform_get_backend_index(snd_device);
|
||||
int device_sr = my_data->current_backend_cfg[backend_idx].sample_rate;
|
||||
/*
|
||||
*Check if device SR is multiple of 8K or 11.025 Khz
|
||||
*check if the stream SR is multiple of same base, if yes
|
||||
*then have copp SR equal to stream SR, this ensures that
|
||||
*post processing happens at stream SR, else have
|
||||
*copp SR equal to device SR.
|
||||
*/
|
||||
if (!(((sample_rate_multiple(device_sr, SAMPLE_RATE_8000)) &&
|
||||
(sample_rate_multiple(stream_sr, SAMPLE_RATE_8000))) ||
|
||||
((sample_rate_multiple(device_sr, SAMPLE_RATE_11025)) &&
|
||||
(sample_rate_multiple(stream_sr, SAMPLE_RATE_11025))))) {
|
||||
*sample_rate = device_sr;
|
||||
} else
|
||||
*sample_rate = stream_sr;
|
||||
|
||||
ALOGI("sn_device %d device sr %d stream sr %d copp sr %d", snd_device, device_sr, stream_sr
|
||||
, *sample_rate);
|
||||
|
||||
}
|
||||
|
||||
void platform_reset_edid_info(void *platform) {
|
||||
|
||||
ALOGV("%s:", __func__);
|
||||
|
|
|
@ -25,7 +25,9 @@
|
|||
#define CODEC_BACKEND_DEFAULT_SAMPLE_RATE 48000
|
||||
#define CODEC_BACKEND_DEFAULT_CHANNELS 2
|
||||
#define CODEC_BACKEND_DEFAULT_TX_CHANNELS 1
|
||||
|
||||
#define SAMPLE_RATE_8000 8000
|
||||
#define SAMPLE_RATE_11025 11025
|
||||
#define sample_rate_multiple(sr, base) ((sr % base)== 0?true:false)
|
||||
|
||||
enum {
|
||||
NATIVE_AUDIO_MODE_SRC = 1,
|
||||
|
@ -187,4 +189,6 @@ int platform_retrieve_audio_cal(void* platform, int acdb_dev_id, int acdb_device
|
|||
|
||||
unsigned char* platform_get_license(void* platform, int* size);
|
||||
int platform_get_max_mic_count(void *platform);
|
||||
void platform_check_and_update_copp_sample_rate(void *platform, snd_device_t snd_device,
|
||||
unsigned int stream_sr,int *sample_rate);
|
||||
#endif // AUDIO_PLATFORM_API_H
|
||||
|
|
Loading…
Reference in New Issue