Merge "hal: Fix backend for 24 bit playback on speaker"
diff --git a/hal/audio_extn/utils.c b/hal/audio_extn/utils.c
index aa22193..5287ae8 100644
--- a/hal/audio_extn/utils.c
+++ b/hal/audio_extn/utils.c
@@ -472,6 +472,7 @@
struct audio_device *adev;
struct mixer_ctl *ctl;
int pcm_device_id, acdb_dev_id, snd_device = usecase->out_snd_device;
+ int32_t sample_rate = DEFAULT_OUTPUT_SAMPLING_RATE;
ALOGV("%s", __func__);
@@ -513,13 +514,21 @@
rc = -EINVAL;
goto exit_send_app_type_cfg;
}
+
+ if ((24 == usecase->stream.out->bit_width) &&
+ (AUDIO_DEVICE_OUT_SPEAKER == snd_device)) {
+ sample_rate = DEFAULT_OUTPUT_SAMPLING_RATE;
+ } else {
+ sample_rate = out->app_type_cfg.sample_rate;
+ }
+
app_type_cfg[len++] = out->app_type_cfg.app_type;
app_type_cfg[len++] = acdb_dev_id;
- app_type_cfg[len++] = out->app_type_cfg.sample_rate;
+ app_type_cfg[len++] = sample_rate;
mixer_ctl_set_array(ctl, app_type_cfg, len);
ALOGI("%s app_type %d, acdb_dev_id %d, sample_rate %d",
- __func__, out->app_type_cfg.app_type, acdb_dev_id, out->app_type_cfg.sample_rate);
+ __func__, out->app_type_cfg.app_type, acdb_dev_id, sample_rate);
rc = 0;
exit_send_app_type_cfg:
return rc;
diff --git a/hal/audio_hw.c b/hal/audio_hw.c
index 57a1a1b..c5736fc 100644
--- a/hal/audio_hw.c
+++ b/hal/audio_hw.c
@@ -797,6 +797,27 @@
usecase->in_snd_device = in_snd_device;
usecase->out_snd_device = out_snd_device;
+ if (usecase->type == PCM_PLAYBACK) {
+ if ((24 == usecase->stream.out->bit_width) &&
+ (AUDIO_DEVICE_OUT_SPEAKER == usecase->stream.out->devices)) {
+ audio_extn_utils_update_stream_app_type_cfg(adev->platform,
+ &adev->streams_output_cfg_list,
+ usecase->stream.out->flags,
+ usecase->stream.out->format,
+ DEFAULT_OUTPUT_SAMPLING_RATE,
+ usecase->stream.out->bit_width,
+ &usecase->stream.out->app_type_cfg);
+ } else {
+ audio_extn_utils_update_stream_app_type_cfg(adev->platform,
+ &adev->streams_output_cfg_list,
+ usecase->stream.out->flags,
+ usecase->stream.out->format,
+ usecase->stream.out->sample_rate,
+ usecase->stream.out->bit_width,
+ &usecase->stream.out->app_type_cfg);
+ }
+ ALOGI("%s Selected apptype: %d", __func__, usecase->stream.out->app_type_cfg.app_type);
+ }
enable_audio_route(adev, usecase);
/* Applicable only on the targets that has external modem.
@@ -2382,6 +2403,7 @@
struct stream_out *out;
int i, ret = 0;
audio_format_t format;
+ int32_t sample_rate = DEFAULT_OUTPUT_SAMPLING_RATE;
*stream_out = NULL;
@@ -2567,11 +2589,20 @@
out->sample_rate = out->config.rate;
}
- ALOGV("%s flags %x, format %x, out->sample_rate %d, out->bit_width %d",
- __func__, flags, format, out->sample_rate, out->bit_width);
+ if ((24 == out->bit_width) &&
+ (devices == AUDIO_DEVICE_OUT_SPEAKER)) {
+ sample_rate = DEFAULT_OUTPUT_SAMPLING_RATE;
+ ALOGI("%s 24-bit playback on Speaker is allowed ONLY at 48khz. Hence changing sample rate to: %d",
+ __func__, sample_rate);
+ } else {
+ sample_rate = out->sample_rate;
+ }
+
+ ALOGV("%s flags %x, format %x, sample_rate %d, out->bit_width %d",
+ __func__, flags, format, sample_rate, out->bit_width);
audio_extn_utils_update_stream_app_type_cfg(adev->platform,
&adev->streams_output_cfg_list,
- flags, format, out->sample_rate,
+ flags, format, sample_rate,
out->bit_width, &out->app_type_cfg);
if ((out->usecase == USECASE_AUDIO_PLAYBACK_PRIMARY) ||
(flags & AUDIO_OUTPUT_FLAG_PRIMARY)) {
diff --git a/hal/msm8974/platform.c b/hal/msm8974/platform.c
index 9a2f87d..ff9076e 100644
--- a/hal/msm8974/platform.c
+++ b/hal/msm8974/platform.c
@@ -2560,8 +2560,10 @@
}
// 16 bit playbacks is allowed through 16 bit/48 khz backend only
- if (16 == bit_width)
+ if ((16 == bit_width) ||
+ ((24 == bit_width) && (SND_DEVICE_OUT_SPEAKER == usecase->devices))) {
sample_rate = CODEC_BACKEND_DEFAULT_SAMPLE_RATE;
+ }
// Force routing if the expected bitwdith or samplerate
// is not same as current backend comfiguration
if ((bit_width != adev->cur_codec_backend_bit_width) ||