hal: Avoid setting wrong sample rate for headset device
On internal codec, headset is shared same backend with
speaker or handset. platform_check_codec_backend_cfg is
wrongly setting backend sample rate to 48 KHz for headset
when using native playback or hifi audio.
Avoid setting sample rate to default sample rate for headset.
CRs-Fixed: 2398845
Change-Id: Ia8e1831292370f8648e145e0aa715ab9471d3a71
diff --git a/hal/msm8974/platform.c b/hal/msm8974/platform.c
index 613d7ba..0b625d5 100644
--- a/hal/msm8974/platform.c
+++ b/hal/msm8974/platform.c
@@ -7353,7 +7353,9 @@
* Handset and speaker may have diffrent backend. Check if the device is speaker or handset,
* and these devices are restricited to 48kHz.
*/
- if (platform_check_backends_match(SND_DEVICE_OUT_SPEAKER, snd_device)) {
+ if (!codec_device_supports_native_playback(usecase->devices) &&
+ (platform_check_backends_match(SND_DEVICE_OUT_SPEAKER, snd_device) ||
+ platform_check_backends_match(SND_DEVICE_OUT_HANDSET, snd_device))) {
int bw = platform_get_snd_device_bit_width(SND_DEVICE_OUT_SPEAKER);
if ((-ENOSYS != bw) && (bit_width > (uint32_t)bw)) {
bit_width = (uint32_t)bw;