Merge "hal: typecasting variable to avoid multiplication overflow error"
diff --git a/configs/msm8937/mixer_paths_mtp.xml b/configs/msm8937/mixer_paths_mtp.xml
index 8ded630..c92fb58 100644
--- a/configs/msm8937/mixer_paths_mtp.xml
+++ b/configs/msm8937/mixer_paths_mtp.xml
@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="ISO-8859-1"?>
 <!--
-   Copyright (c) 2015-2016, 2018-2020, The Linux Foundation. All rights reserved.
+   Copyright (c) 2015-2016, 2018-2021, The Linux Foundation. All rights reserved.
 
     Redistribution and use in source and binary forms, with or without
     modification, are permitted provided that the following conditions are
@@ -1420,6 +1420,11 @@
         <path name="headphones" />
     </path>
 
+    <path name="wsa-speaker-and-headphones">
+        <path name="wsa-speaker" />
+        <path name="headphones" />
+    </path>
+
     <path name="usb-headphones">
     </path>
 
diff --git a/configs/msm8937/mixer_paths_tasha.xml b/configs/msm8937/mixer_paths_tasha.xml
index 24b5c1e..4944f9d 100644
--- a/configs/msm8937/mixer_paths_tasha.xml
+++ b/configs/msm8937/mixer_paths_tasha.xml
@@ -1,5 +1,6 @@
 <?xml version="1.0" encoding="ISO-8859-1"?>
-<!-- Copyright (c) 2015-2016, 2018, 2020, The Linux Foundation. All rights reserved.      -->
+<!-- Copyright (c) 2015-2016, 2018, 2020-2021, The Linux Foundation.        -->
+<!-- All rights reserved.                                                   -->
 <!--                                                                        -->
 <!-- Redistribution and use in source and binary forms, with or without     -->
 <!-- modification, are permitted provided that the following conditions are -->
@@ -2359,6 +2360,10 @@
         <path name="wsa-speaker" />
     </path>
 
+    <path name="wsa-speaker-and-headphones">
+        <path name="wsa-speaker" />
+        <path name="headphones" />
+    </path>
 
     <path name="usb-headphones">
     </path>
diff --git a/configs/msm8937/mixer_paths_tashalite.xml b/configs/msm8937/mixer_paths_tashalite.xml
index 00b2d74..4f20a0a 100644
--- a/configs/msm8937/mixer_paths_tashalite.xml
+++ b/configs/msm8937/mixer_paths_tashalite.xml
@@ -1,5 +1,6 @@
 <?xml version="1.0" encoding="ISO-8859-1"?>
-<!-- Copyright (c) 2015-2016, 2018, 2020, The Linux Foundation. All rights reserved.      -->
+<!-- Copyright (c) 2015-2016, 2018, 2020-2021,                              -->
+<!-- The Linux Foundation. All rights reserved.                             -->
 <!--                                                                        -->
 <!-- Redistribution and use in source and binary forms, with or without     -->
 <!-- modification, are permitted provided that the following conditions are -->
@@ -2326,6 +2327,10 @@
         <path name="wsa-speaker" />
     </path>
 
+    <path name="wsa-speaker-and-headphones">
+        <path name="wsa-speaker" />
+        <path name="headphones" />
+    </path>
 
     <path name="usb-headphones">
     </path>
diff --git a/configs/msm8937/msm8937.mk b/configs/msm8937/msm8937.mk
index 5db9969..9e9c36c 100644
--- a/configs/msm8937/msm8937.mk
+++ b/configs/msm8937/msm8937.mk
@@ -199,8 +199,10 @@
 audio.offload.min.duration.secs=30
 
 #Enable offload audio video playback by default
+ifneq ($(TARGET_PRODUCT),sdm429w)
 PRODUCT_PROPERTY_OVERRIDES += \
 audio.offload.video=true
+endif
 
 #Enable audio track offload by default
 PRODUCT_PROPERTY_OVERRIDES += \
diff --git a/configs/msmnile_au/msmnile_au.mk b/configs/msmnile_au/msmnile_au.mk
index 5886918..22a08f9 100644
--- a/configs/msmnile_au/msmnile_au.mk
+++ b/configs/msmnile_au/msmnile_au.mk
@@ -97,7 +97,7 @@
 ifneq ($(ENABLE_HYP),true)
 AUDIO_FEATURE_ENABLED_AUTO_AUDIOD := true
 
-ifeq ($(TARGET_PRODUCT),msmnile_au)
+ifneq ( ,$(filter msmnile_au msmnile_tb, $(TARGET_PRODUCT)))
 AUDIO_FEATURE_ENABLED_DAEMON_SUPPORT := true
 AUDIO_FEATURE_ENABLED_SILENT_BOOT := true
 else
diff --git a/configs/sdm660/audio_platform_info_tasha_skus.xml b/configs/sdm660/audio_platform_info_tasha_skus.xml
index a4ae7c1..ed35b4b 100644
--- a/configs/sdm660/audio_platform_info_tasha_skus.xml
+++ b/configs/sdm660/audio_platform_info_tasha_skus.xml
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="ISO-8859-1"?>
-<!-- Copyright (c) 2014, 2016-2018, 2020 The Linux Foundation. All rights reserved.-->
+<!-- Copyright (c) 2014, 2016-2018, 2020-2021 The Linux Foundation. All rights reserved.-->
 <!--                                                                        -->
 <!-- Redistribution and use in source and binary forms, with or without     -->
 <!-- modification, are permitted provided that the following conditions are -->
@@ -95,7 +95,7 @@
         <param key="spkr_2_tz_name" value="wsatz.14"/>
         <!-- In the below value string, the value indicates default mono -->
         <!-- speaker. It can be set to either left or right              -->
-        <param key="mono_speaker" value="right"/>
+        <param key="mono_speaker" value="left"/>
         <!-- In the below value string, first parameter indicates size -->
         <!-- followed by perf lock options                             -->
         <param key="perf_lock_opts" value="4, 0x101, 0x704, 0x20F, 0x1E01"/>
diff --git a/configs/sdm660/sound_trigger_platform_info.xml b/configs/sdm660/sound_trigger_platform_info.xml
index 271f99d..13d1adc 100644
--- a/configs/sdm660/sound_trigger_platform_info.xml
+++ b/configs/sdm660/sound_trigger_platform_info.xml
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="ISO-8859-1"?>
-<!--- Copyright (c) 2013-2017, The Linux Foundation. All rights reserved.       -->
+<!--- Copyright (c) 2013-2017, 2021 The Linux Foundation. All rights reserved.       -->
 <!---                                                                           -->
 <!--- Redistribution and use in source and binary forms, with or without        -->
 <!--- modification, are permitted provided that the following conditions are    -->
@@ -51,6 +51,7 @@
     <sound_model_config>
         <param vendor_uuid="68ab2d40-e860-11e3-95ef-0002a5d5c51b" />
         <param execution_type="WDSP" /> <!-- value: "WDSP" "ADSP" "DYNAMIC" -->
+        <param second_stage_supported="false" />
         <param app_type="2" /> <!-- app type used in ACDB -->
         <param library="libsmwrapper.so" />
         <param max_cpe_phrases="6" />
diff --git a/hal/audio_extn/utils.c b/hal/audio_extn/utils.c
index 1f61d6d..f71f2b2 100755
--- a/hal/audio_extn/utils.c
+++ b/hal/audio_extn/utils.c
@@ -1329,12 +1329,6 @@
               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 &&
-                     !audio_is_this_native_usecase(usecase)) &&
-            usecase->stream.out->sample_rate == OUTPUT_SAMPLING_RATE_44100) ||
-            (usecase->stream.out->sample_rate < OUTPUT_SAMPLING_RATE_44100)) {
-            /* Reset to default if no native stream is active*/
-            usecase->stream.out->app_type_cfg.sample_rate = DEFAULT_OUTPUT_SAMPLING_RATE;
         } else if (snd_device == SND_DEVICE_OUT_BT_A2DP) {
                  /*
                   * For a2dp playback get encoder sampling rate and set copp sampling rate,
@@ -1343,8 +1337,12 @@
                    audio_extn_a2dp_get_enc_sample_rate(&usecase->stream.out->app_type_cfg.sample_rate);
                    ALOGI("%s using %d sample rate rate for A2DP CoPP",
                         __func__, usecase->stream.out->app_type_cfg.sample_rate);
-        } else if (compare_device_type(&usecase->stream.out->device_list,
-                                       AUDIO_DEVICE_OUT_SPEAKER)) {
+        } else if ((((snd_device != SND_DEVICE_OUT_HEADPHONES_44_1 &&
+                     !audio_is_this_native_usecase(usecase)) &&
+            usecase->stream.out->sample_rate == OUTPUT_SAMPLING_RATE_44100) ||
+            (usecase->stream.out->sample_rate < OUTPUT_SAMPLING_RATE_44100)) ||
+            (compare_device_type(&usecase->stream.out->device_list,AUDIO_DEVICE_OUT_SPEAKER))) {
+            /* Reset to default if no native stream is active or default device is speaker*/
             usecase->stream.out->app_type_cfg.sample_rate = DEFAULT_OUTPUT_SAMPLING_RATE;
         }
         audio_extn_btsco_get_sample_rate(snd_device, &usecase->stream.out->app_type_cfg.sample_rate);
diff --git a/hal/audio_hw.c b/hal/audio_hw.c
index 0855185..9ed29ed 100644
--- a/hal/audio_hw.c
+++ b/hal/audio_hw.c
@@ -2810,7 +2810,10 @@
                                  (is_single_device_type_equal(&usecase->device_list,
                                                      AUDIO_DEVICE_IN_USB_HEADSET) &&
                                  is_single_device_type_equal(&vc_usecase->device_list,
-                                                        AUDIO_DEVICE_OUT_USB_HEADSET)))) {
+                                                        AUDIO_DEVICE_OUT_USB_HEADSET))||
+                                 (is_single_device_type_equal(&usecase->device_list,
+                                                     AUDIO_DEVICE_IN_BLUETOOTH_SCO_HEADSET) &&
+                                 is_codec_backend_out_device_type(&vc_usecase->device_list)))) {
                 in_snd_device = vc_usecase->in_snd_device;
                 out_snd_device = vc_usecase->out_snd_device;
             }
@@ -4116,9 +4119,8 @@
             }
         }
 
-        if (out->realtime)
-            platform_set_stream_channel_map(adev->platform, out->channel_mask,
-                   out->pcm_device_id, -1, &out->channel_map_param.channel_map[0]);
+        platform_set_stream_channel_map(adev->platform, out->channel_mask,
+               out->pcm_device_id, -1, &out->channel_map_param.channel_map[0]);
 
         out->pcm = pcm_open_prepare_helper(adev->snd_card, out->pcm_device_id,
                                        flags, pcm_open_retry_count,
@@ -4142,10 +4144,6 @@
             }
         }
 
-        if (!out->realtime)
-            platform_set_stream_channel_map(adev->platform, out->channel_mask,
-                   out->pcm_device_id, -1, &out->channel_map_param.channel_map[0]);
-
         // apply volume for voip playback after path is set up
         if (out->usecase == USECASE_AUDIO_PLAYBACK_VOIP)
             out_set_voip_volume(&out->stream, out->volume_l, out->volume_r);