Merge "Configs: yupik: update decimator gain to 84 for yupik qrd"
diff --git a/configs/common/base/mixer_paths_base.xml b/configs/common/base/mixer_paths_base.xml
index 7930865..78c3077 100755
--- a/configs/common/base/mixer_paths_base.xml
+++ b/configs/common/base/mixer_paths_base.xml
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="ISO-8859-1"?>
-<!--- Copyright (c) 2020, The Linux Foundation. All rights reserved.       -->
+<!--- Copyright (c) 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    -->
@@ -1544,7 +1544,7 @@
         <path name="play-fm headphones"/>
     </path>
     <path name="incall-rec-uplink">
-        <ctl name="MultiMedia1 Mixer VOC_REC_UL" value="1"/>
+        <ctl name="MultiMedia9 Mixer VOC_REC_UL" value="1"/>
     </path>
     <path name="incall-rec-uplink bt-sco">
         <path name="incall-rec-uplink"/>
@@ -1589,7 +1589,7 @@
         <path name="incall-rec-uplink-compress"/>
     </path>
     <path name="incall-rec-downlink">
-        <ctl name="MultiMedia1 Mixer VOC_REC_DL" value="1"/>
+        <ctl name="MultiMedia9 Mixer VOC_REC_DL" value="1"/>
     </path>
     <path name="incall-rec-downlink bt-sco">
         <path name="incall-rec-downlink"/>
diff --git a/configs/common/base/sound_trigger_mixer_paths_base.xml b/configs/common/base/sound_trigger_mixer_paths_base.xml
index 4aae071..258a7ac 100644
--- a/configs/common/base/sound_trigger_mixer_paths_base.xml
+++ b/configs/common/base/sound_trigger_mixer_paths_base.xml
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="ISO-8859-1"?>
-<!--- Copyright (c) 2020, The Linux Foundation. All rights reserved.       -->
+<!--- Copyright (c) 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    -->
@@ -244,9 +244,9 @@
         <ctl name="VA_DEC1 MODE" value="ADC_LOW_PWR"/>
         <ctl name="VA SMIC MUX1" value="SWR_MIC1"/>
         <ctl name="ADC2 ChMap" value="SWRM_TX1_CH2"/>
-        <ctl name="ADC2_MIXER Switch" value="1"/>
         <ctl name="ADC2 MUX" value="INP3"/>
         <ctl name="HDR12 MUX" value="NO_HDR12"/>
+        <ctl name="ADC2_MIXER Switch" value="1"/>
     </path>
     <path name="listen-ape-handset-tmic">
         <ctl name="VA_CDC_DMA_TX_0 Channels" value="Three"/>
@@ -312,10 +312,10 @@
         <ctl name="VA SMIC MUX0" value="SWR_MIC1"/>
         <ctl name="VA_CDC_DMA_TX_0 Channels" value="One"/>
         <ctl name="ADC2 ChMap" value="SWRM_TX1_CH2"/>
-        <ctl name="ADC2_MIXER Switch" value="1"/>
         <ctl name="VA_DEC0 MODE" value="ADC_LOW_PWR"/>
         <ctl name="ADC2 MUX" value="INP2"/>
         <ctl name="HDR12 MUX" value="NO_HDR12"/>
+        <ctl name="ADC2_MIXER Switch" value="1"/>
         <ctl name="ADC2_BCS Disable" value="1"/>
     </path>
     <path name="echo-reference">
diff --git a/configs/lahaina/audio_io_policy.conf b/configs/lahaina/audio_io_policy.conf
index 3e3fdec..0932e44 100644
--- a/configs/lahaina/audio_io_policy.conf
+++ b/configs/lahaina/audio_io_policy.conf
@@ -76,7 +76,7 @@
   }
   compress_offload_24 {
     flags AUDIO_OUTPUT_FLAG_DIRECT|AUDIO_OUTPUT_FLAG_COMPRESS_OFFLOAD|AUDIO_OUTPUT_FLAG_NON_BLOCKING
-    formats AUDIO_FORMAT_MP3|AUDIO_FORMAT_PCM_24_BIT_OFFLOAD|AUDIO_FORMAT_FLAC|AUDIO_FORMAT_ALAC|AUDIO_FORMAT_APE|AUDIO_FORMAT_AAC_LC|AUDIO_FORMAT_AAC_HE_V1|AUDIO_FORMAT_AAC_HE_V2|AUDIO_FORMAT_WMA_PRO|AUDIO_FORMAT_AAC_ADTS_LC|AUDIO_FORMAT_AAC_ADTS_HE_V1|AUDIO_FORMAT_AAC_ADTS_HE_V2|AUDIO_FORMAT_AAC_LATM_LC|AUDIO_FORMAT_AAC_LATM_HE_V1|AUDIO_FORMAT_AAC_LATM_HE_V2
+    formats AUDIO_FORMAT_MP3|AUDIO_FORMAT_PCM_24_BIT_OFFLOAD|AUDIO_FORMAT_FLAC|AUDIO_FORMAT_ALAC|AUDIO_FORMAT_APE|AUDIO_FORMAT_AAC_LC|AUDIO_FORMAT_AAC_HE_V1|AUDIO_FORMAT_AAC_HE_V2|AUDIO_FORMAT_WMA_PRO|AUDIO_FORMAT_VORBIS|AUDIO_FORMAT_AAC_ADTS_LC|AUDIO_FORMAT_AAC_ADTS_HE_V1|AUDIO_FORMAT_AAC_ADTS_HE_V2|AUDIO_FORMAT_AAC_LATM_LC|AUDIO_FORMAT_AAC_LATM_HE_V1|AUDIO_FORMAT_AAC_LATM_HE_V2
     sampling_rates 44100|48000|88200|96000|176400|192000
     bit_width 24
     app_type 69940
diff --git a/configs/lahaina/audio_platform_info_shimaidp.xml b/configs/lahaina/audio_platform_info_shimaidp.xml
index 0ec8164..bb77ab4 100644
--- a/configs/lahaina/audio_platform_info_shimaidp.xml
+++ b/configs/lahaina/audio_platform_info_shimaidp.xml
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="ISO-8859-1"?>
-<!--- Copyright (c) 2020, The Linux Foundation. All rights reserved.       -->
+<!--- Copyright (c) 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    -->
@@ -120,6 +120,9 @@
         <usecase name="USECASE_AUDIO_RECORD_COMPRESS2" type="in" id="37" />
         <usecase name="USECASE_AUDIO_PLAYBACK_WITH_HAPTICS" type="out" id="40" />
         <usecase name="USECASE_AUDIO_PLAYBACK_HAPTICS" type="out" id="41" />
+        <usecase name="USECASE_INCALL_REC_UPLINK" type="in" id="23" />
+        <usecase name="USECASE_INCALL_REC_DOWNLINK" type="in" id="23" />
+        <usecase name="USECASE_INCALL_REC_UPLINK_AND_DOWNLINK" type="in" id="23" />
     </pcm_ids>
     <config_params>
         <param key="spkr_1_tz_name" value="wsatz.13"/>
diff --git a/configs/lahaina/audio_platform_info_shimaqrd.xml b/configs/lahaina/audio_platform_info_shimaqrd.xml
index 750b83e..0353a77 100644
--- a/configs/lahaina/audio_platform_info_shimaqrd.xml
+++ b/configs/lahaina/audio_platform_info_shimaqrd.xml
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="ISO-8859-1"?>
-<!--- Copyright (c) 2018-2020, The Linux Foundation. All rights reserved.       -->
+<!--- Copyright (c) 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    -->
@@ -122,6 +122,9 @@
         <usecase name="USECASE_AUDIO_RECORD_COMPRESS2" type="in" id="37" />
         <usecase name="USECASE_AUDIO_PLAYBACK_WITH_HAPTICS" type="out" id="40" />
         <usecase name="USECASE_AUDIO_PLAYBACK_HAPTICS" type="out" id="41" />
+        <usecase name="USECASE_INCALL_REC_UPLINK" type="in" id="23" />
+        <usecase name="USECASE_INCALL_REC_DOWNLINK" type="in" id="23" />
+        <usecase name="USECASE_INCALL_REC_UPLINK_AND_DOWNLINK" type="in" id="23" />
     </pcm_ids>
     <config_params>
         <param key="spkr_2_tz_name" value="wsatz.14"/>
diff --git a/configs/lahaina/audio_platform_info_yupikqrd.xml b/configs/lahaina/audio_platform_info_yupikqrd.xml
index 3fd44de..c6b6075 100644
--- a/configs/lahaina/audio_platform_info_yupikqrd.xml
+++ b/configs/lahaina/audio_platform_info_yupikqrd.xml
@@ -122,6 +122,9 @@
         <usecase name="USECASE_AUDIO_RECORD_COMPRESS2" type="in" id="37" />
         <usecase name="USECASE_AUDIO_PLAYBACK_WITH_HAPTICS" type="out" id="40" />
         <usecase name="USECASE_AUDIO_PLAYBACK_HAPTICS" type="out" id="41" />
+        <usecase name="USECASE_INCALL_REC_UPLINK" type="in" id="23" />
+        <usecase name="USECASE_INCALL_REC_DOWNLINK" type="in" id="23" />
+        <usecase name="USECASE_INCALL_REC_UPLINK_AND_DOWNLINK" type="in" id="23" />
     </pcm_ids>
     <config_params>
         <param key="spkr_2_tz_name" value="wsatz.14"/>
diff --git a/configs/lahaina/yupik_overlay/sound_trigger_mixer_paths_yupikidp_overlay.xml b/configs/lahaina/yupik_overlay/sound_trigger_mixer_paths_yupikidp_overlay.xml
index 5c8abb8..7a6e6cb 100644
--- a/configs/lahaina/yupik_overlay/sound_trigger_mixer_paths_yupikidp_overlay.xml
+++ b/configs/lahaina/yupik_overlay/sound_trigger_mixer_paths_yupikidp_overlay.xml
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="ISO-8859-1"?>
-<!--- Copyright (c) 2020, The Linux Foundation. All rights reserved.       -->
+<!--- Copyright (c) 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    -->
@@ -38,7 +38,7 @@
         <ctl name="VA_CDC_DMA_TX_0 Channels" value="One"/>
         <ctl name="VA_AIF1_CAP Mixer DEC0" value="1"/>
         <ctl name="VA DEC0 MUX" value="MSM_DMIC"/>
-        <ctl name="VA DMIC MUX0" value="DMIC0"/>
+        <ctl name="VA DMIC MUX0" value="DMIC3"/>
     </path>
     <path name="listen-ape-handset-dmic">
         <ctl name="VA_CDC_DMA_TX_0 Channels" value="Two"/>
@@ -46,8 +46,8 @@
         <ctl name="VA_AIF1_CAP Mixer DEC1" value="1"/>
         <ctl name="VA DEC0 MUX" value="MSM_DMIC"/>
         <ctl name="VA DEC1 MUX" value="MSM_DMIC"/>
-        <ctl name="VA DMIC MUX0" value="DMIC0"/>
-        <ctl name="VA DMIC MUX1" value="DMIC1"/>
+        <ctl name="VA DMIC MUX0" value="DMIC3"/>
+        <ctl name="VA DMIC MUX1" value="DMIC0"/>
     </path>
     <path name="listen-ape-handset-tmic">
         <ctl name="VA_CDC_DMA_TX_0 Channels" value="Three"/>
@@ -57,9 +57,9 @@
         <ctl name="VA DEC0 MUX" value="MSM_DMIC"/>
         <ctl name="VA DEC1 MUX" value="MSM_DMIC"/>
         <ctl name="VA DEC2 MUX" value="MSM_DMIC"/>
-        <ctl name="VA DMIC MUX0" value="DMIC0"/>
-        <ctl name="VA DMIC MUX1" value="DMIC2"/>
-        <ctl name="VA DMIC MUX2" value="DMIC3"/>
+        <ctl name="VA DMIC MUX0" value="DMIC3"/>
+        <ctl name="VA DMIC MUX1" value="DMIC0"/>
+        <ctl name="VA DMIC MUX2" value="DMIC2"/>
     </path>
     <path name="listen-ape-handset-qmic">
         <ctl name="VA_CDC_DMA_TX_0 Channels" value="Four"/>
@@ -71,9 +71,9 @@
         <ctl name="VA DEC1 MUX" value="MSM_DMIC"/>
         <ctl name="VA DEC2 MUX" value="MSM_DMIC"/>
         <ctl name="VA DEC3 MUX" value="MSM_DMIC"/>
-        <ctl name="VA DMIC MUX0" value="DMIC0"/>
-        <ctl name="VA DMIC MUX1" value="DMIC1"/>
+        <ctl name="VA DMIC MUX0" value="DMIC3"/>
+        <ctl name="VA DMIC MUX1" value="DMIC0"/>
         <ctl name="VA DMIC MUX2" value="DMIC2"/>
-        <ctl name="VA DMIC MUX3" value="DMIC3"/>
+        <ctl name="VA DMIC MUX3" value="DMIC1"/>
     </path>
 </mixer>
diff --git a/configs/lahaina/yupik_overlay/sound_trigger_mixer_paths_yupikqrd_overlay.xml b/configs/lahaina/yupik_overlay/sound_trigger_mixer_paths_yupikqrd_overlay.xml
index 34cc1e6..9e94102 100644
--- a/configs/lahaina/yupik_overlay/sound_trigger_mixer_paths_yupikqrd_overlay.xml
+++ b/configs/lahaina/yupik_overlay/sound_trigger_mixer_paths_yupikqrd_overlay.xml
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="ISO-8859-1"?>
-<!--- Copyright (c) 2020, The Linux Foundation. All rights reserved.       -->
+<!--- Copyright (c) 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    -->
@@ -41,9 +41,9 @@
         <ctl name="VA_DEC0 MODE" value="ADC_LOW_PWR" />
         <ctl name="VA SMIC MUX0" value="SWR_MIC1" />
         <ctl name="ADC2 ChMap" value="SWRM_TX1_CH2" />
-        <ctl name="ADC2_MIXER Switch" value="1" />
         <ctl name="ADC2 MUX" value="INP3" />
         <ctl name="HDR12 MUX" value="NO_HDR12" />
+        <ctl name="ADC2_MIXER Switch" value="1" />
     </path>
     <path name="listen-ape-handset-mic-preproc">
         <path name="listen-ape-handset-mic" />
@@ -55,17 +55,17 @@
         <ctl name="VA_DEC0 MODE" value="ADC_LOW_PWR" />
         <ctl name="VA SMIC MUX0" value="SWR_MIC1" />
         <ctl name="ADC2 ChMap" value="SWRM_TX1_CH2" />
-        <ctl name="ADC2_MIXER Switch" value="1" />
         <ctl name="ADC2 MUX" value="INP3" />
         <ctl name="HDR12 MUX" value="NO_HDR12" />
+        <ctl name="ADC2_MIXER Switch" value="1" />
         <ctl name="VA_AIF1_CAP Mixer DEC1" value="1" />
-        <ctl name="VA DEC1 MUX" value="SWR_MIC0" />
+        <ctl name="VA DEC1 MUX" value="SWR_MIC" />
         <ctl name="VA_DEC1 MODE" value="ADC_LOW_PWR" />
         <ctl name="VA SMIC MUX1" value="SWR_MIC4" />
         <ctl name="ADC3 ChMap" value="SWRM_TX2_CH1" />
-        <ctl name="ADC3_MIXER Switch" value="1" />
         <ctl name="ADC3 MUX" value="INP4" />
         <ctl name="HDR34 MUX" value="NO_HDR34" />
+        <ctl name="ADC3_MIXER Switch" value="1" />
     </path>
     <path name="listen-ape-handset-tmic">
         <ctl name="VA_CDC_DMA_TX_0 Channels" value="Three" />
@@ -74,9 +74,9 @@
         <ctl name="VA_DEC0 MODE" value="ADC_LOW_PWR" />
         <ctl name="VA SMIC MUX0" value="SWR_MIC1" />
         <ctl name="ADC2 ChMap" value="SWRM_TX1_CH2" />
-        <ctl name="ADC2_MIXER Switch" value="1" />
         <ctl name="ADC2 MUX" value="INP3" />
         <ctl name="HDR12 MUX" value="NO_HDR12" />
+        <ctl name="ADC2_MIXER Switch" value="1" />
         <ctl name="VA_AIF1_CAP Mixer DEC1" value="1" />
         <ctl name="VA DEC1 MUX" value="SWR_MIC" />
         <ctl name="VA_DEC1 MODE" value="ADC_LOW_PWR" />
@@ -88,9 +88,9 @@
         <ctl name="VA_DEC2 MODE" value="ADC_LOW_PWR" />
         <ctl name="VA SMIC MUX2" value="SWR_MIC4" />
         <ctl name="ADC3 ChMap" value="SWRM_TX2_CH1" />
-        <ctl name="ADC3_MIXER Switch" value="1" />
         <ctl name="ADC3 MUX" value="INP4" />
         <ctl name="HDR34 MUX" value="NO_HDR34" />
+        <ctl name="ADC3_MIXER Switch" value="1" />
     </path>
     <path name="echo-reference">
         <ctl name="AUDIO_REF_EC_UL1 MUX" value="WSA_CDC_DMA_RX_0"/>
diff --git a/configs/msm8937/audio_platform_info_sdm429w.xml b/configs/msm8937/audio_platform_info_sdm429w.xml
index 13f0fe8..91a7a20 100644
--- a/configs/msm8937/audio_platform_info_sdm429w.xml
+++ b/configs/msm8937/audio_platform_info_sdm429w.xml
@@ -1,5 +1,5 @@
 <?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 -->
@@ -49,10 +49,13 @@
         <usecase name="USECASE_VOICEMMODE2_CALL" type="out" id="35"/>
         <usecase name="USECASE_AUDIO_HFP_SCO" type="out" id="25" />
         <usecase name="USECASE_AUDIO_HFP_SCO_WB" type="out" id="25" />
+        <usecase name="USECASE_AUDIO_PLAYBACK_VOIP" type="out" id="27" />
+        <usecase name="USECASE_AUDIO_RECORD_VOIP" type="in" id="27" />
     </pcm_ids>
     <config_params>
         <param key="spkr_1_tz_name" value="wsa881x.0f"/>
         <param key="spkr_2_tz_name" value=""/>
+        <param key="hfp_pcm_dev_id" value="18"/>
     </config_params>
     <acdb_ids>
         <device name="SND_DEVICE_OUT_SPEAKER_PROTECTED" acdb_id="136"/>
diff --git a/configs/msm8937/audio_platform_info_sdm429w_dvt2.xml b/configs/msm8937/audio_platform_info_sdm429w_dvt2.xml
index 3a5c477..8dacccf 100644
--- a/configs/msm8937/audio_platform_info_sdm429w_dvt2.xml
+++ b/configs/msm8937/audio_platform_info_sdm429w_dvt2.xml
@@ -51,6 +51,8 @@
         <usecase name="USECASE_AUDIO_HFP_SCO_WB" type="in" id="56" />
         <usecase name="USECASE_AUDIO_HFP_SCO" type="out" id="25" />
         <usecase name="USECASE_AUDIO_HFP_SCO_WB" type="out" id="25" />
+        <usecase name="USECASE_AUDIO_PLAYBACK_VOIP" type="out" id="27" />
+        <usecase name="USECASE_AUDIO_RECORD_VOIP" type="in" id="27" />
     </pcm_ids>
     <config_params>
         <param key="spkr_1_tz_name" value="wsa881x.0f"/>
diff --git a/configs/msm8937/audio_policy_configuration_sdm429w_law.xml b/configs/msm8937/audio_policy_configuration_sdm429w_law.xml
index 7f90a55..0630c09 100755
--- a/configs/msm8937/audio_policy_configuration_sdm429w_law.xml
+++ b/configs/msm8937/audio_policy_configuration_sdm429w_law.xml
@@ -49,7 +49,6 @@
         <!-- Primary Audio HAL -->
         <module name="primary" halVersion="2.0">
             <attachedDevices>
-                <item>Earpiece</item>
                 <item>Speaker</item>
                 <item>Telephony Tx</item>
                 <item>Built-In Mic</item>
@@ -161,10 +160,6 @@
 
             <devicePorts>
                 <!-- Output devices declaration, i.e. Sink DEVICE PORT -->
-                <devicePort tagName="Earpiece" type="AUDIO_DEVICE_OUT_EARPIECE" role="sink">
-                   <profile name="" format="AUDIO_FORMAT_PCM_16_BIT"
-                            samplingRates="48000" channelMasks="AUDIO_CHANNEL_IN_MONO"/>
-                </devicePort>
                 <devicePort tagName="Speaker" role="sink" type="AUDIO_DEVICE_OUT_SPEAKER" address="">
                     <profile name="" format="AUDIO_FORMAT_PCM_16_BIT"
                              samplingRates="48000" channelMasks="AUDIO_CHANNEL_OUT_STEREO"/>
@@ -199,11 +194,11 @@
                 </devicePort>
                 <devicePort tagName="HDMI" type="AUDIO_DEVICE_OUT_AUX_DIGITAL" role="sink">
                     <profile name="" format="AUDIO_FORMAT_PCM_16_BIT"
-                             samplingRates="8000,11025,16000,22050,32000,44100,48000,64000,88200,96000,128000,176400,192000" channelMasks="dynamic"/>
+                             samplingRates="8000,11025,16000,22050,32000,44100,48000,64000,88200,96000,128000,176400,192000"/>
                 </devicePort>
                 <devicePort tagName="Proxy" type="AUDIO_DEVICE_OUT_PROXY" role="sink">
                     <profile name="" format="AUDIO_FORMAT_PCM_16_BIT"
-                             samplingRates="8000,11025,16000,22050,32000,44100,48000,64000,88200,96000,128000,176400,192000" channelMasks="dynamic"/>
+                             samplingRates="8000,11025,16000,22050,32000,44100,48000,64000,88200,96000,128000,176400,192000"/>
                 </devicePort>
                 <devicePort tagName="FM" type="AUDIO_DEVICE_OUT_FM" role="sink">
                     <profile name="" format="AUDIO_FORMAT_PCM_16_BIT"
@@ -256,8 +251,6 @@
             </devicePorts>
             <!-- route declaration, i.e. list all available sources for a given sink -->
             <routes>
-                <route type="mix" sink="Earpiece"
-                       sources="primary output,raw,deep_buffer,direct_pcm,compressed_offload,voip_rx"/>
                 <route type="mix" sink="Speaker"
                        sources="primary output,raw,deep_buffer,direct_pcm,compressed_offload,voip_rx"/>
                 <route type="mix" sink="Wired Headset"
@@ -280,8 +273,6 @@
                        sources="primary output,raw,deep_buffer,direct_pcm,compressed_offload,voip_rx"/>
                 <route type="mix" sink="BT SCO Car Kit"
                        sources="primary output,raw,deep_buffer,direct_pcm,compressed_offload,voip_rx"/>
-                <route type="mix" sink="Telephony Tx"
-                       sources="voice_tx"/>
                 <route type="mix" sink="primary input"
                        sources="Built-In Mic,Built-In Back Mic,Wired Headset Mic,BT SCO Headset Mic,FM Tuner"/>
                 <route type="mix" sink="surround_sound"
diff --git a/configs/msm8937/mixer_paths_sdm429w.xml b/configs/msm8937/mixer_paths_sdm429w.xml
index cc2c73c..2c19094 100644
--- a/configs/msm8937/mixer_paths_sdm429w.xml
+++ b/configs/msm8937/mixer_paths_sdm429w.xml
@@ -199,6 +199,15 @@
     <ctl name="Voip_Tx Mixer INTERNAL_BT_SCO_TX_Voip" value="0" />
     <!-- Voip end -->
 
+    <!-- VoIP over audio -->
+    <ctl name="MultiMedia10 Mixer TERT_MI2S_TX" value="0" />
+    <ctl name="MultiMedia10 Mixer INTERNAL_BT_SCO_TX" value="0" />
+    <ctl name="MultiMedia10 Mixer AFE_PCM_TX" value="0" />
+    <ctl name="QUAT_MI2S_RX Audio Mixer MultiMedia10" value="0" />
+    <ctl name="INTERNAL_BT_SCO_RX Audio Mixer MultiMedia10" value="0" />
+    <ctl name="AFE_PCM_RX Audio Mixer MultiMedia10" value="0" />
+    <!-- VoIP over audio -->
+
     <!-- fm -->
     <ctl name="Internal FM RX Volume" value="0" />
     <ctl name="PRI_MI2S_RX Port Mixer INTERNAL_FM_TX" value="0" />
@@ -1588,4 +1597,51 @@
         <path name="speaker" />
     </path>
 
+    <!-- VoIP Rx settings -->
+    <path name="audio-playback-voip">
+        <ctl name="QUAT_MI2S_RX Audio Mixer MultiMedia10" value="1" />
+    </path>
+
+    <path name="audio-playback-voip headphones">
+        <path name="audio-playback-voip" />
+    </path>
+
+    <path name="audio-playback-voip bt-sco">
+        <ctl name="INTERNAL_BT_SCO_RX Audio Mixer MultiMedia10" value="1" />
+    </path>
+
+    <path name="audio-playback-voip bt-sco-wb">
+        <path name="audio-playback-voip bt-sco" />
+    </path>
+
+    <path name="audio-playback-voip afe-proxy">
+        <ctl name="AFE_PCM_RX Audio Mixer MultiMedia10" value="1" />
+    </path>
+
+    <path name="audio-playback-voip usb-headphones">
+        <path name="audio-playback-voip afe-proxy" />
+    </path>
+
+    <path name="audio-playback-voip speaker-and-usb-headphones">
+        <path name="audio-playback-voip usb-headphones" />
+        <path name="audio-playback-voip" />
+    </path>
+
+    <!-- VoIP Tx settings -->
+    <path name="audio-record-voip">
+        <ctl name="MultiMedia10 Mixer TERT_MI2S_TX" value="1" />
+    </path>
+
+    <path name="audio-record-voip bt-sco">
+        <ctl name="MultiMedia10 Mixer INTERNAL_BT_SCO_TX" value="1" />
+    </path>
+
+    <path name="audio-record-voip bt-sco-wb">
+        <path name="audio-record-voip bt-sco" />
+    </path>
+
+    <path name="audio-record-voip usb-headset-mic">
+        <ctl name="MultiMedia10 Mixer AFE_PCM_TX" value="1" />
+    </path>
+
 </mixer>
diff --git a/configs/msm8937/mixer_paths_sdm429w_dvt2.xml b/configs/msm8937/mixer_paths_sdm429w_dvt2.xml
index bea8f02..4a6d124 100644
--- a/configs/msm8937/mixer_paths_sdm429w_dvt2.xml
+++ b/configs/msm8937/mixer_paths_sdm429w_dvt2.xml
@@ -119,7 +119,7 @@
     <ctl name="MultiMedia1 Mixer TERT_MI2S_TX" value="0" />
     <ctl name="MultiMedia5 Mixer TERT_MI2S_TX" value="0" />
     <ctl name="MultiMedia1 Mixer SLIM_7_TX" value="0" />
-    <ctl name="MultiMedia5 Mixer SLIM_7_TX" value="1" />
+    <ctl name="MultiMedia5 Mixer SLIM_7_TX" value="0" />
     <ctl name="MultiMedia8 Mixer SLIM_7_TX" value="0" />
     <ctl name="PRI_MI2S_RX_Voice Mixer CSVoice" value="0" />
     <ctl name="Voice_Tx Mixer TERT_MI2S_TX_Voice" value="0" />
@@ -191,6 +191,15 @@
     <ctl name="Voip_Tx Mixer SLIM_7_TX_Voip" value="0" />
     <!-- Voip end -->
 
+    <!-- VoIP over audio -->
+    <ctl name="MultiMedia10 Mixer TERT_MI2S_TX" value="0" />
+    <ctl name="MultiMedia10 Mixer SLIM_7_TX" value="0" />
+    <ctl name="MultiMedia10 Mixer AFE_PCM_TX" value="0" />
+    <ctl name="QUAT_MI2S_RX Audio Mixer MultiMedia10" value="0" />
+    <ctl name="SLIMBUS_7_RX Audio Mixer MultiMedia10" value="0" />
+    <ctl name="AFE_PCM_RX Audio Mixer MultiMedia10" value="0" />
+    <!-- VoIP over audio -->
+
     <!-- RT Proxy Cal -->
     <ctl name="RT_PROXY_1_RX SetCalMode" value="CAL_MODE_NONE" />
     <ctl name="RT_PROXY_1_TX SetCalMode" value="CAL_MODE_NONE" />
@@ -1051,4 +1060,51 @@
         <path name="speaker" />
     </path>
 
+    <!-- VoIP Rx settings -->
+    <path name="audio-playback-voip">
+        <ctl name="QUAT_MI2S_RX Audio Mixer MultiMedia10" value="1" />
+    </path>
+
+    <path name="audio-playback-voip headphones">
+        <path name="audio-playback-voip" />
+    </path>
+
+    <path name="audio-playback-voip bt-sco">
+        <ctl name="SLIMBUS_7_RX Audio Mixer MultiMedia10" value="1" />
+    </path>
+
+    <path name="audio-playback-voip bt-sco-wb">
+        <path name="audio-playback-voip bt-sco" />
+    </path>
+
+    <path name="audio-playback-voip afe-proxy">
+        <ctl name="AFE_PCM_RX Audio Mixer MultiMedia10" value="1" />
+    </path>
+
+    <path name="audio-playback-voip usb-headphones">
+        <path name="audio-playback-voip afe-proxy" />
+    </path>
+
+    <path name="audio-playback-voip speaker-and-usb-headphones">
+        <path name="audio-playback-voip usb-headphones" />
+        <path name="audio-playback-voip" />
+    </path>
+
+    <!-- VoIP Tx settings -->
+    <path name="audio-record-voip">
+        <ctl name="MultiMedia10 Mixer TERT_MI2S_TX" value="1" />
+    </path>
+
+    <path name="audio-record-voip bt-sco">
+        <ctl name="MultiMedia10 Mixer SLIM_7_TX" value="1" />
+    </path>
+
+    <path name="audio-record-voip bt-sco-wb">
+        <path name="audio-record-voip bt-sco" />
+    </path>
+
+    <path name="audio-record-voip usb-headset-mic">
+        <ctl name="MultiMedia10 Mixer AFE_PCM_TX" value="1" />
+    </path>
+
 </mixer>
diff --git a/configs/msm8937/msm8937.mk b/configs/msm8937/msm8937.mk
index c55bd6a..23364e2 100644
--- a/configs/msm8937/msm8937.mk
+++ b/configs/msm8937/msm8937.mk
@@ -66,6 +66,9 @@
 else
     AUDIO_FEATURE_ENABLED_DLKM := true
 endif
+ifeq ($(TARGET_SUPPORTS_WEARABLES),true)
+AUDIO_FEATURE_ENABLED_SPLIT_A2DP := true
+endif
 ##AUDIO_FEATURE_FLAGS
 
 #Audio Specific device overlays
diff --git a/configs/msmnile_au/audio_effects.conf b/configs/msmnile_au/audio_effects.conf
old mode 100644
new mode 100755
index 8d1251a..edb9814
--- a/configs/msmnile_au/audio_effects.conf
+++ b/configs/msmnile_au/audio_effects.conf
@@ -45,9 +45,6 @@
   audio_pre_processing {
     path /vendor/lib/soundfx/libqcomvoiceprocessing.so
   }
-  volume_listener {
-    path /vendor/lib/soundfx/libvolumelistener.so
-  }
   audiosphere {
     path /vendor/lib/soundfx/libasphere.so
   }
@@ -262,27 +259,6 @@
     library audio_pre_processing
     uuid 1d97bb0b-9e2f-4403-9ae3-58c2554306f8
   }
-  music_helper {
-    library volume_listener
-    uuid 08b8b058-0590-11e5-ac71-0025b32654a0
-  }
-  ring_helper {
-    library volume_listener
-    uuid 0956df94-0590-11e5-bdbe-0025b32654a0
-  }
-  alarm_helper {
-    library volume_listener
-    uuid 09f303e2-0590-11e5-8fdb-0025b32654a0
-  }
-  # voice_helper is called when stream type is voice_call in VoIP usecase
-  voice_helper {
-    library volume_listener
-    uuid 0ace5c08-0590-11e5-ae9e-0025b32654a0
-  }
-  notification_helper {
-    library volume_listener
-    uuid 0b776dde-0590-11e5-81ba-0025b32654a0
-  }
   audiosphere {
     library audiosphere
     uuid 184e62ab-2d19-4364-9d1b-c0a40733866c
diff --git a/configs/msmnile_au/msmnile_au.mk b/configs/msmnile_au/msmnile_au.mk
index 9e963ac..7d9aa3c 100644
--- a/configs/msmnile_au/msmnile_au.mk
+++ b/configs/msmnile_au/msmnile_au.mk
@@ -482,6 +482,15 @@
     android.hardware.automotive.audiocontrol@2.0-service \
     android.hardware.automotive.audiocontrol@2.0
 
+# enable sound trigger hidl hal 2.2
+PRODUCT_PACKAGES += \
+    android.hardware.soundtrigger@2.2-impl \
+
+# enable sound trigger hidl hal 2.3
+PRODUCT_PACKAGES += \
+    android.hardware.soundtrigger@2.3-impl \
+
+
 ifeq ($(ENABLE_HYP),true)
 PRODUCT_PROPERTY_OVERRIDES += \
 persist.vendor.audio.calfile0=/vendor/etc/acdbdata/adsp_avs_config.acdb\
diff --git a/configs/msmsteppe_au/audio_effects.conf b/configs/msmsteppe_au/audio_effects.conf
old mode 100644
new mode 100755
index 1f29086..2e850c6
--- a/configs/msmsteppe_au/audio_effects.conf
+++ b/configs/msmsteppe_au/audio_effects.conf
@@ -42,9 +42,6 @@
   audio_pre_processing {
     path /vendor/lib/soundfx/libqcomvoiceprocessing.so
   }
-  volume_listener {
-    path /vendor/lib/soundfx/libvolumelistener.so
-  }
   audiosphere {
     path /vendor/lib/soundfx/libasphere.so
   }
@@ -255,27 +252,6 @@
     library audio_pre_processing
     uuid 1d97bb0b-9e2f-4403-9ae3-58c2554306f8
   }
-  music_helper {
-    library volume_listener
-    uuid 08b8b058-0590-11e5-ac71-0025b32654a0
-  }
-  ring_helper {
-    library volume_listener
-    uuid 0956df94-0590-11e5-bdbe-0025b32654a0
-  }
-  alarm_helper {
-    library volume_listener
-    uuid 09f303e2-0590-11e5-8fdb-0025b32654a0
-  }
-  # voice_helper is called when stream type is voice_call in VoIP usecase
-  voice_helper {
-    library volume_listener
-    uuid 0ace5c08-0590-11e5-ae9e-0025b32654a0
-  }
-  notification_helper {
-    library volume_listener
-    uuid 0b776dde-0590-11e5-81ba-0025b32654a0
-  }
   audiosphere {
     library audiosphere
     uuid 184e62ab-2d19-4364-9d1b-c0a40733866c
diff --git a/configs/sdm660/audio_policy_configuration.xml b/configs/sdm660/audio_policy_configuration.xml
index 884aca8..1d70af6 100644
--- a/configs/sdm660/audio_policy_configuration.xml
+++ b/configs/sdm660/audio_policy_configuration.xml
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
-<!-- Copyright (c) 2016-2020 The Linux Foundation. All rights reserved
+<!-- Copyright (c) 2016-2021 The Linux Foundation. All rights reserved
      Not a Contribution.
 -->
 <!-- Copyright (C) 2015 The Android Open Source Project
@@ -163,6 +163,17 @@
                              samplingRates="8000,11025,12000,16000,22050,24000,32000,44100,48000"
                              channelMasks="AUDIO_CHANNEL_IN_MONO,AUDIO_CHANNEL_IN_STEREO,AUDIO_CHANNEL_IN_FRONT_BACK"/>
                 </mixPort>
+                <mixPort name="usb_surround_sound" role="sink">
+                     <profile name="" format="AUDIO_FORMAT_PCM_16_BIT"
+                              samplingRates="8000,11025,12000,16000,22050,24000,32000,44100,48000,88200,96000,176400,192000"
+                              channelMasks="AUDIO_CHANNEL_IN_MONO,AUDIO_CHANNEL_IN_STEREO,AUDIO_CHANNEL_IN_FRONT_BACK,AUDIO_CHANNEL_INDEX_MASK_3,AUDIO_CHANNEL_INDEX_MASK_4,AUDIO_CHANNEL_IN_5POINT1,AUDIO_CHANNEL_INDEX_MASK_6,AUDIO_CHANNEL_IN_7POINT1,AUDIO_CHANNEL_INDEX_MASK_8"/>
+                     <profile name="" format="AUDIO_FORMAT_PCM_32_BIT"
+                              samplingRates="8000,11025,12000,16000,22050,24000,32000,44100,48000,88200,96000,176400,192000"
+                              channelMasks="AUDIO_CHANNEL_IN_5POINT1,AUDIO_CHANNEL_INDEX_MASK_6,AUDIO_CHANNEL_IN_7POINT1,AUDIO_CHANNEL_INDEX_MASK_8"/>
+                     <profile name="" format="AUDIO_FORMAT_PCM_FLOAT"
+                              samplingRates="8000,11025,12000,16000,22050,24000,32000,44100,48000,88200,96000,176400,192000"
+                              channelMasks="AUDIO_CHANNEL_IN_5POINT1,AUDIO_CHANNEL_INDEX_MASK_6,AUDIO_CHANNEL_IN_7POINT1,AUDIO_CHANNEL_INDEX_MASK_8"/>
+                </mixPort>
                 <mixPort name="voip_tx" role="sink"
                          flags="AUDIO_INPUT_FLAG_VOIP_TX">
                     <profile name="" format="AUDIO_FORMAT_PCM_16_BIT"
@@ -341,7 +352,9 @@
                 <route type="mix" sink="voice_rx"
                        sources="Telephony Rx"/>
                 <route type="mix" sink="primary input"
-                       sources="Built-In Mic,Built-In Back Mic,Wired Headset Mic,BT SCO Headset Mic,FM Tuner,USB Device In,USB Headset In"/>
+                       sources="Built-In Mic,Built-In Back Mic,Wired Headset Mic,BT SCO Headset Mic,FM Tuner"/>
+                 <route type="mix" sink="usb_surround_sound"
+                        sources="USB Device In,USB Headset In"/>
                 <route type="mix" sink="voip_tx"
                        sources="Built-In Mic,Built-In Back Mic,BT SCO Headset Mic,USB Device In,USB Headset In"/>
                 <route type="mix" sink="surround_sound"
diff --git a/configs/sdm660/mixer_paths_mtp.xml b/configs/sdm660/mixer_paths_mtp.xml
index fba65eb..ccab771 100644
--- a/configs/sdm660/mixer_paths_mtp.xml
+++ b/configs/sdm660/mixer_paths_mtp.xml
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="ISO-8859-1"?>
-<!-- Copyright (c) 2015-2017, 2020 The Linux Foundation. All rights reserved.    -->
+<!-- Copyright (c) 2015-2017, 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 -->
@@ -3020,6 +3020,10 @@
         <ctl name="USB_AUDIO_RX Audio Mixer MultiMedia2" value="1" />
     </path>
 
+    <path name="hifi-record">
+        <ctl name="MultiMedia2 Mixer INT3_MI2S_TX" value="1" />
+    </path>
+
     <path name="hifi-record usb-headset-mic">
         <ctl name="MultiMedia2 Mixer USB_AUDIO_TX" value="1" />
     </path>
diff --git a/configs/sdm710/audio_policy_configuration.xml b/configs/sdm710/audio_policy_configuration.xml
index d3bada4..57a3d7e 100644
--- a/configs/sdm710/audio_policy_configuration.xml
+++ b/configs/sdm710/audio_policy_configuration.xml
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
-<!-- Copyright (c) 2016-2020, The Linux Foundation. All rights reserved
+<!-- Copyright (c) 2016-2021, The Linux Foundation. All rights reserved
      Not a Contribution.
 -->
 <!-- Copyright (C) 2015 The Android Open Source Project
@@ -172,6 +172,17 @@
                              samplingRates="8000,11025,12000,16000,22050,24000,32000,44100,48000"
                              channelMasks="AUDIO_CHANNEL_IN_MONO,AUDIO_CHANNEL_IN_STEREO,AUDIO_CHANNEL_IN_FRONT_BACK"/>
                 </mixPort>
+                <mixPort name="usb_surround_sound" role="sink">
+                     <profile name="" format="AUDIO_FORMAT_PCM_16_BIT"
+                              samplingRates="8000,11025,12000,16000,22050,24000,32000,44100,48000,88200,96000,176400,192000"
+                              channelMasks="AUDIO_CHANNEL_IN_MONO,AUDIO_CHANNEL_IN_STEREO,AUDIO_CHANNEL_IN_FRONT_BACK,AUDIO_CHANNEL_INDEX_MASK_3,AUDIO_CHANNEL_INDEX_MASK_4,AUDIO_CHANNEL_IN_5POINT1,AUDIO_CHANNEL_INDEX_MASK_6,AUDIO_CHANNEL_IN_7POINT1,AUDIO_CHANNEL_INDEX_MASK_8"/>
+                     <profile name="" format="AUDIO_FORMAT_PCM_32_BIT"
+                              samplingRates="8000,11025,12000,16000,22050,24000,32000,44100,48000,88200,96000,176400,192000"
+                              channelMasks="AUDIO_CHANNEL_IN_5POINT1,AUDIO_CHANNEL_INDEX_MASK_6,AUDIO_CHANNEL_IN_7POINT1,AUDIO_CHANNEL_INDEX_MASK_8"/>
+                     <profile name="" format="AUDIO_FORMAT_PCM_FLOAT"
+                              samplingRates="8000,11025,12000,16000,22050,24000,32000,44100,48000,88200,96000,176400,192000"
+                              channelMasks="AUDIO_CHANNEL_IN_5POINT1,AUDIO_CHANNEL_INDEX_MASK_6,AUDIO_CHANNEL_IN_7POINT1,AUDIO_CHANNEL_INDEX_MASK_8"/>
+                </mixPort>
                 <mixPort name="voip_tx" role="sink"
                          flags="AUDIO_INPUT_FLAG_VOIP_TX">
                     <profile name="" format="AUDIO_FORMAT_PCM_16_BIT"
@@ -349,7 +360,9 @@
                 <route type="mix" sink="voice_rx"
                        sources="Telephony Rx"/>
                 <route type="mix" sink="primary input"
-                       sources="Built-In Mic,Built-In Back Mic,Wired Headset Mic,BT SCO Headset Mic,FM Tuner,USB Device In,USB Headset In"/>
+                       sources="Built-In Mic,Built-In Back Mic,Wired Headset Mic,BT SCO Headset Mic,FM Tuner"/>
+                 <route type="mix" sink="usb_surround_sound"
+                        sources="USB Device In,USB Headset In"/>
                 <route type="mix" sink="voip_tx"
                        sources="Built-In Mic,Built-In Back Mic,BT SCO Headset Mic,USB Device In,USB Headset In"/>
                 <route type="mix" sink="surround_sound"
diff --git a/configs/sdm845/audio_policy_configuration.xml b/configs/sdm845/audio_policy_configuration.xml
index 130e9f8..d1e77a7 100644
--- a/configs/sdm845/audio_policy_configuration.xml
+++ b/configs/sdm845/audio_policy_configuration.xml
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
-<!-- Copyright (c) 2016-2020, The Linux Foundation. All rights reserved
+<!-- Copyright (c) 2016-2021, The Linux Foundation. All rights reserved
      Not a Contribution.
 -->
 <!-- Copyright (C) 2015 The Android Open Source Project
@@ -161,6 +161,17 @@
                     <profile name="" format="AUDIO_FORMAT_PCM_16_BIT"
                              samplingRates="8000,16000,32000,48000" channelMasks="AUDIO_CHANNEL_OUT_MONO,AUDIO_CHANNEL_OUT_STEREO"/>
                 </mixPort>
+                <mixPort name="usb_surround_sound" role="sink">
+                     <profile name="" format="AUDIO_FORMAT_PCM_16_BIT"
+                              samplingRates="8000,11025,12000,16000,22050,24000,32000,44100,48000,88200,96000,176400,192000"
+                              channelMasks="AUDIO_CHANNEL_IN_MONO,AUDIO_CHANNEL_IN_STEREO,AUDIO_CHANNEL_IN_FRONT_BACK,AUDIO_CHANNEL_INDEX_MASK_3,AUDIO_CHANNEL_INDEX_MASK_4,AUDIO_CHANNEL_IN_5POINT1,AUDIO_CHANNEL_INDEX_MASK_6,AUDIO_CHANNEL_IN_7POINT1,AUDIO_CHANNEL_INDEX_MASK_8"/>
+                     <profile name="" format="AUDIO_FORMAT_PCM_32_BIT"
+                              samplingRates="8000,11025,12000,16000,22050,24000,32000,44100,48000,88200,96000,176400,192000"
+                              channelMasks="AUDIO_CHANNEL_IN_5POINT1,AUDIO_CHANNEL_INDEX_MASK_6,AUDIO_CHANNEL_IN_7POINT1,AUDIO_CHANNEL_INDEX_MASK_8"/>
+                     <profile name="" format="AUDIO_FORMAT_PCM_FLOAT"
+                              samplingRates="8000,11025,12000,16000,22050,24000,32000,44100,48000,88200,96000,176400,192000"
+                              channelMasks="AUDIO_CHANNEL_IN_5POINT1,AUDIO_CHANNEL_INDEX_MASK_6,AUDIO_CHANNEL_IN_7POINT1,AUDIO_CHANNEL_INDEX_MASK_8"/>
+                </mixPort>
                 <mixPort name="primary input" role="sink">
                     <profile name="" format="AUDIO_FORMAT_PCM_16_BIT"
                              samplingRates="8000,11025,12000,16000,22050,24000,32000,44100,48000"
@@ -336,7 +347,9 @@
                 <route type="mix" sink="voice_rx"
                        sources="Telephony Rx"/>
                 <route type="mix" sink="primary input"
-                       sources="Built-In Mic,Built-In Back Mic,Wired Headset Mic,BT SCO Headset Mic,FM Tuner,USB Device In,USB Headset In"/>
+                       sources="Built-In Mic,Built-In Back Mic,Wired Headset Mic,BT SCO Headset Mic,FM Tuner"/>
+                 <route type="mix" sink="usb_surround_sound"
+                        sources="USB Device In,USB Headset In"/>
                 <route type="mix" sink="voip_tx"
                        sources="Built-In Mic,Built-In Back Mic,BT SCO Headset Mic,USB Device In,USB Headset In"/>
                 <route type="mix" sink="record_24"
diff --git a/hal/audio_extn/Android.mk b/hal/audio_extn/Android.mk
index 597b6bd..aba6592 100755
--- a/hal/audio_extn/Android.mk
+++ b/hal/audio_extn/Android.mk
@@ -1080,6 +1080,7 @@
 
 #            Build AUTO_HAL LIB
 #-------------------------------------------
+ifeq ($(strip $(AUDIO_FEATURE_ENABLED_AUTO_HAL)), true)
 include $(CLEAR_VARS)
 
 LOCAL_MODULE := libautohal
@@ -1137,3 +1138,4 @@
 LOCAL_SANITIZE := integer_overflow
 endif
 include $(BUILD_SHARED_LIBRARY)
+endif
diff --git a/hal/audio_extn/a2dp.c b/hal/audio_extn/a2dp.c
index d8bbdfe..148f53d 100644
--- a/hal/audio_extn/a2dp.c
+++ b/hal/audio_extn/a2dp.c
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2015-2020, The Linux Foundation. All rights reserved.
+* Copyright (c) 2015-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
@@ -1168,16 +1168,32 @@
                   dlsym(a2dp.bt_lib_source_handle, "audio_stream_open");
     a2dp.audio_source_start = (audio_source_start_t)
                   dlsym(a2dp.bt_lib_source_handle, "audio_start_stream");
+    if (a2dp.audio_source_start == NULL) {
+        a2dp.audio_source_start = (audio_source_start_t)
+                  dlsym(a2dp.bt_lib_source_handle, "audio_stream_start");
+    }
     a2dp.audio_get_enc_config = (audio_get_enc_config_t)
                   dlsym(a2dp.bt_lib_source_handle, "audio_get_codec_config");
     a2dp.audio_source_suspend = (audio_source_suspend_t)
                   dlsym(a2dp.bt_lib_source_handle, "audio_suspend_stream");
+    if (a2dp.audio_source_suspend == NULL) {
+        a2dp.audio_source_suspend = (audio_source_suspend_t)
+                  dlsym(a2dp.bt_lib_source_handle, "audio_stream_suspend");
+    }
     a2dp.audio_source_handoff_triggered = (audio_source_handoff_triggered_t)
                   dlsym(a2dp.bt_lib_source_handle, "audio_handoff_triggered");
     a2dp.clear_source_a2dpsuspend_flag = (clear_source_a2dpsuspend_flag_t)
                   dlsym(a2dp.bt_lib_source_handle, "clear_a2dpsuspend_flag");
+    if (a2dp.clear_source_a2dpsuspend_flag == NULL) {
+        a2dp.clear_source_a2dpsuspend_flag = (clear_source_a2dpsuspend_flag_t)
+                  dlsym(a2dp.bt_lib_source_handle, "clear_a2dp_suspend_flag");
+    }
     a2dp.audio_source_stop = (audio_source_stop_t)
                    dlsym(a2dp.bt_lib_source_handle, "audio_stop_stream");
+    if (a2dp.audio_source_stop == NULL) {
+        a2dp.audio_source_stop = (audio_source_stop_t)
+                  dlsym(a2dp.bt_lib_source_handle, "audio_stream_stop");
+    }
     a2dp.audio_source_close = (audio_source_close_t)
                   dlsym(a2dp.bt_lib_source_handle, "audio_stream_close");
     a2dp.audio_source_check_a2dp_ready = (audio_source_check_a2dp_ready_t)
diff --git a/hal/audio_extn/audio_extn.c b/hal/audio_extn/audio_extn.c
index ca06e59..d3b2935 100755
--- a/hal/audio_extn/audio_extn.c
+++ b/hal/audio_extn/audio_extn.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013-2020, The Linux Foundation. All rights reserved.
+ * Copyright (c) 2013-2021, The Linux Foundation. All rights reserved.
  * Not a Contribution.
  *
  * Copyright (C) 2013 The Android Open Source Project
@@ -6228,8 +6228,6 @@
 {
     if(auto_hal_init) {
         auto_hal_init_config_t auto_hal_init_config;
-        auto_hal_init_config.fp_in_get_stream = in_get_stream;
-        auto_hal_init_config.fp_out_get_stream = out_get_stream;
         auto_hal_init_config.fp_audio_extn_ext_hw_plugin_usecase_start = audio_extn_ext_hw_plugin_usecase_start;
         auto_hal_init_config.fp_audio_extn_ext_hw_plugin_usecase_stop = audio_extn_ext_hw_plugin_usecase_stop;
         auto_hal_init_config.fp_get_usecase_from_list = get_usecase_from_list;
diff --git a/hal/audio_extn/audio_extn.h b/hal/audio_extn/audio_extn.h
index 2c7711d..64b77e8 100755
--- a/hal/audio_extn/audio_extn.h
+++ b/hal/audio_extn/audio_extn.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013-2020, The Linux Foundation. All rights reserved.
+ * Copyright (c) 2013-2021, The Linux Foundation. All rights reserved.
  * Not a Contribution.
  *
  * Copyright (C) 2013 The Android Open Source Project
@@ -1390,16 +1390,12 @@
                                 audio_usecase_t uc_id);
 snd_device_t audio_extn_auto_hal_get_snd_device_for_car_audio_stream(int car_audio_stream);
 
-typedef streams_input_ctxt_t* (*fp_in_get_stream_t)(struct audio_device*, audio_io_handle_t);
-typedef streams_output_ctxt_t* (*fp_out_get_stream_t)(struct audio_device*, audio_io_handle_t);
 typedef size_t (*fp_get_output_period_size_t)(uint32_t, audio_format_t, int, int);
 typedef int (*fp_audio_extn_ext_hw_plugin_set_audio_gain_t)(void*, struct audio_usecase*, uint32_t);
 typedef struct stream_in* (*fp_adev_get_active_input_t)(const struct audio_device*);
 typedef audio_patch_handle_t (*fp_generate_patch_handle_t)(void);
 
 typedef struct auto_hal_init_config {
-    fp_in_get_stream_t                           fp_in_get_stream;
-    fp_out_get_stream_t                          fp_out_get_stream;
     fp_audio_extn_ext_hw_plugin_usecase_start_t  fp_audio_extn_ext_hw_plugin_usecase_start;
     fp_audio_extn_ext_hw_plugin_usecase_stop_t   fp_audio_extn_ext_hw_plugin_usecase_stop;
     fp_get_usecase_from_list_t                   fp_get_usecase_from_list;
diff --git a/hal/audio_extn/auto_hal.c b/hal/audio_extn/auto_hal.c
index 9276c9c..39f2838 100755
--- a/hal/audio_extn/auto_hal.c
+++ b/hal/audio_extn/auto_hal.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2019-2020, The Linux Foundation. All rights reserved.
+ * Copyright (c) 2019-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
@@ -47,8 +47,6 @@
 #endif
 
 //external feature dependency
-static fp_in_get_stream_t                           fp_in_get_stream;
-static fp_out_get_stream_t                          fp_out_get_stream;
 static fp_audio_extn_ext_hw_plugin_usecase_start_t  fp_audio_extn_ext_hw_plugin_usecase_start;
 static fp_audio_extn_ext_hw_plugin_usecase_stop_t   fp_audio_extn_ext_hw_plugin_usecase_stop;
 static fp_get_usecase_from_list_t                   fp_get_usecase_from_list;
@@ -937,8 +935,6 @@
 
     auto_hal->adev = adev;
 
-    fp_in_get_stream = init_config.fp_in_get_stream;
-    fp_out_get_stream = init_config.fp_out_get_stream;
     fp_audio_extn_ext_hw_plugin_usecase_start = init_config.fp_audio_extn_ext_hw_plugin_usecase_start;
     fp_audio_extn_ext_hw_plugin_usecase_stop = init_config.fp_audio_extn_ext_hw_plugin_usecase_stop;
     fp_get_usecase_from_list = init_config.fp_get_usecase_from_list;
diff --git a/hal/audio_extn/hfp.c b/hal/audio_extn/hfp.c
index ca5d3bb..697a507 100644
--- a/hal/audio_extn/hfp.c
+++ b/hal/audio_extn/hfp.c
@@ -52,6 +52,7 @@
 #define AUDIO_PARAMETER_HFP_PCM_DEV_ID "hfp_pcm_dev_id"
 #define AUDIO_PARAMETER_HFP_VOL_MIXER_CTL "hfp_vol_mixer_ctl"
 #define AUDIO_PARAMETER_HFP_VALUE_MAX   128
+#define AUDIO_PARAMETER_HFP_FORCE_ROUTE_SPEAKER "hfp_route_spkr"
 
 #define AUDIO_PARAMETER_KEY_HFP_MIC_VOLUME "hfp_mic_volume"
 #define PLAYBACK_VOLUME_MAX 0x2000
@@ -118,6 +119,7 @@
     .stop_threshold = INT_MAX,
     .avail_min = 0,
 };
+static bool route_spkr = false;
 
 //external feature dependency
 static fp_platform_set_mic_mute_t                   fp_platform_set_mic_mute;
@@ -320,6 +322,11 @@
     uc_info->in_snd_device = SND_DEVICE_NONE;
     uc_info->out_snd_device = SND_DEVICE_NONE;
 
+    if (route_spkr) {
+        reassign_device_list(&uc_info->device_list, AUDIO_DEVICE_OUT_SPEAKER, "");
+        reassign_device_list(&uc_info->stream.out->device_list, AUDIO_DEVICE_OUT_SPEAKER, "");
+    }
+
     list_add_tail(&adev->usecase_list, &uc_info->list);
 
     fp_select_devices(adev, hfpmod.ucid);
@@ -431,6 +438,7 @@
 
     ALOGD("%s: enter", __func__);
     hfpmod.is_hfp_running = false;
+    route_spkr = false;
 
     /* 1. Close the PCM devices */
     if (hfpmod.hfp_sco_rx) {
@@ -553,6 +561,7 @@
     int val;
     float vol;
     char value[32]={0};
+    struct audio_usecase *uc_info = NULL;
 
     ALOGV("%s: enter", __func__);
 
@@ -581,14 +590,36 @@
                ALOGE("Unsupported rate..");
     }
 
-    if (hfpmod.is_hfp_running) {
-        memset(value, 0, sizeof(value));
-        ret = str_parms_get_str(parms, AUDIO_PARAMETER_STREAM_ROUTING,
+    memset(value, 0, sizeof(value));
+    ret = str_parms_get_str(parms, AUDIO_PARAMETER_HFP_FORCE_ROUTE_SPEAKER, value,
+                            sizeof(value));
+    if(ret >= 0){
+        route_spkr = true;
+        ALOGD("%s: Set force route to speaker", __func__);
+    }
+
+    memset(value, 0, sizeof(value));
+    ret = str_parms_get_str(parms, AUDIO_PARAMETER_STREAM_ROUTING,
                                 value, sizeof(value));
-        if (ret >= 0) {
-            val = atoi(value);
-            if (val > 0)
-                fp_select_devices(adev, hfpmod.ucid);
+    if (ret >= 0) {
+        val = atoi(value);
+        if (val > 0) {
+            if (hfpmod.is_hfp_running) {
+                if (route_spkr) {
+                    if (val != AUDIO_DEVICE_OUT_SPEAKER)
+                        ALOGI("%s: HFP call in progress, cannot route to device %d", __func__, val);
+                } else {
+                    uc_info = fp_get_usecase_from_list(adev, hfpmod.ucid);
+
+                    if (uc_info != NULL) {
+                        reassign_device_list(&uc_info->device_list, val, "");
+                        reassign_device_list(&uc_info->stream.out->device_list, val, "");
+                        fp_select_devices(adev, hfpmod.ucid);
+                    }
+                }
+
+                str_parms_del(parms, AUDIO_PARAMETER_STREAM_ROUTING);
+            }
         }
     }
 
diff --git a/hal/audio_hw.c b/hal/audio_hw.c
index 062386c..83c35c7 100644
--- a/hal/audio_hw.c
+++ b/hal/audio_hw.c
@@ -3206,7 +3206,7 @@
     }
 
     if (is_sco_in_device_type(&in->device_list)) {
-        if (!adev->bt_sco_on) {
+        if (!adev->bt_sco_on || audio_extn_a2dp_source_is_ready()) {
             ALOGE("%s: SCO profile is not ready, return error", __func__);
             ret = -EIO;
             goto error_config;
@@ -7440,38 +7440,6 @@
     return add_remove_audio_effect(stream, effect, false);
 }
 
-streams_input_ctxt_t *in_get_stream(struct audio_device *dev,
-                                  audio_io_handle_t input)
-{
-    struct listnode *node;
-
-    list_for_each(node, &dev->active_inputs_list) {
-        streams_input_ctxt_t *in_ctxt = node_to_item(node,
-                                                     streams_input_ctxt_t,
-                                                     list);
-        if (in_ctxt->input->capture_handle == input) {
-            return in_ctxt;
-        }
-    }
-    return NULL;
-}
-
-streams_output_ctxt_t *out_get_stream(struct audio_device *dev,
-                                  audio_io_handle_t output)
-{
-    struct listnode *node;
-
-    list_for_each(node, &dev->active_outputs_list) {
-        streams_output_ctxt_t *out_ctxt = node_to_item(node,
-                                                     streams_output_ctxt_t,
-                                                     list);
-        if (out_ctxt->output->handle == output) {
-            return out_ctxt;
-        }
-    }
-    return NULL;
-}
-
 static int in_stop(const struct audio_stream_in* stream)
 {
     struct stream_in *in = (struct stream_in *)stream;
@@ -7797,15 +7765,6 @@
 
     *stream_out = NULL;
 
-    pthread_mutex_lock(&adev->lock);
-    if (out_get_stream(adev, handle) != NULL) {
-        ALOGW("%s, output stream already opened", __func__);
-        ret = -EEXIST;
-    }
-    pthread_mutex_unlock(&adev->lock);
-    if (ret)
-        return ret;
-
     out = (struct stream_out *)calloc(1, sizeof(struct stream_out));
 
     ALOGD("%s: enter: format(%#x) sample_rate(%d) channel_mask(%#x) devices(%#x) flags(%#x)\
@@ -8643,17 +8602,10 @@
     if (ret != 0)
         goto error_open;
 
-    streams_output_ctxt_t *out_ctxt = (streams_output_ctxt_t *)
-        calloc(1, sizeof(streams_output_ctxt_t));
-    if (out_ctxt == NULL) {
-        ALOGE("%s fail to allocate output ctxt", __func__);
-        ret = -ENOMEM;
-        goto error_open;
-    }
-    out_ctxt->output = out;
+    out->out_ctxt.output = out;
 
     pthread_mutex_lock(&adev->lock);
-    list_add_tail(&adev->active_outputs_list, &out_ctxt->list);
+    list_add_tail(&adev->active_outputs_list, &out->out_ctxt.list);
     pthread_mutex_unlock(&adev->lock);
 
     ALOGV("%s: exit", __func__);
@@ -8679,6 +8631,12 @@
 
     io_streams_map_remove(adev, out->handle);
 
+    // remove out_ctxt early to prevent the stream
+    // being opened in a race condition
+    pthread_mutex_lock(&adev->lock);
+    list_remove(&out->out_ctxt.list);
+    pthread_mutex_unlock(&adev->lock);
+
     // must deregister from sndmonitor first to prevent races
     // between the callback and close_stream
     audio_extn_snd_mon_unregister_listener(out);
@@ -8741,13 +8699,6 @@
     pthread_mutex_destroy(&out->position_query_lock);
 
     pthread_mutex_lock(&adev->lock);
-    streams_output_ctxt_t *out_ctxt = out_get_stream(adev, out->handle);
-    if (out_ctxt != NULL) {
-        list_remove(&out_ctxt->list);
-        free(out_ctxt);
-    } else {
-        ALOGW("%s, output stream already closed", __func__);
-    }
     free(stream);
     pthread_mutex_unlock(&adev->lock);
     ALOGV("%s: exit", __func__);
@@ -9386,15 +9337,6 @@
             return -EINVAL;
     }
 
-    pthread_mutex_lock(&adev->lock);
-    if (in_get_stream(adev, handle) != NULL) {
-        ALOGW("%s, input stream already opened", __func__);
-        ret = -EEXIST;
-    }
-    pthread_mutex_unlock(&adev->lock);
-    if (ret)
-        return ret;
-
     in = (struct stream_in *)calloc(1, sizeof(struct stream_in));
 
     if (!in) {
@@ -9781,17 +9723,10 @@
     if (ret != 0)
         goto err_open;
 
-    streams_input_ctxt_t *in_ctxt = (streams_input_ctxt_t *)
-        calloc(1, sizeof(streams_input_ctxt_t));
-    if (in_ctxt == NULL) {
-        ALOGE("%s fail to allocate input ctxt", __func__);
-        ret = -ENOMEM;
-        goto err_open;
-    }
-    in_ctxt->input = in;
+    in->in_ctxt.input = in;
 
     pthread_mutex_lock(&adev->lock);
-    list_add_tail(&adev->active_inputs_list, &in_ctxt->list);
+    list_add_tail(&adev->active_inputs_list, &in->in_ctxt.list);
     pthread_mutex_unlock(&adev->lock);
 
     ALOGV("%s: exit", __func__);
@@ -9823,6 +9758,12 @@
     }
     io_streams_map_remove(adev, in->capture_handle);
 
+    // remove out_ctxt early to prevent the stream
+    // being opened in a race condition
+    pthread_mutex_lock(&adev->lock);
+    list_remove(&in->in_ctxt.list);
+    pthread_mutex_unlock(&adev->lock);
+
     /* must deregister from sndmonitor first to prevent races
      * between the callback and close_stream
      */
@@ -9885,13 +9826,6 @@
         ALOGV("%s: sound trigger pcm stop lab", __func__);
         audio_extn_sound_trigger_stop_lab(in);
     }
-    streams_input_ctxt_t *in_ctxt = in_get_stream(adev, in->capture_handle);
-    if (in_ctxt != NULL) {
-        list_remove(&in_ctxt->list);
-        free(in_ctxt);
-    } else {
-        ALOGW("%s, input stream already closed", __func__);
-    }
     free(stream);
     pthread_mutex_unlock(&adev->lock);
     return;
diff --git a/hal/audio_hw.h b/hal/audio_hw.h
index 05382e4..8caefe8 100755
--- a/hal/audio_hw.h
+++ b/hal/audio_hw.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013-2020, The Linux Foundation. All rights reserved.
+ * Copyright (c) 2013-2021, The Linux Foundation. All rights reserved.
  * Not a contribution.
  *
  * Copyright (C) 2013 The Android Open Source Project
@@ -361,6 +361,16 @@
     unsigned int bit_width;
 };
 
+typedef struct streams_input_ctxt {
+    struct listnode list;
+    struct stream_in *input;
+} streams_input_ctxt_t;
+
+typedef struct streams_output_ctxt {
+    struct listnode list;
+    struct stream_out *output;
+} streams_output_ctxt_t;
+
 struct stream_inout {
     pthread_mutex_t lock; /* see note below on mutex acquisition order */
     pthread_mutex_t pre_lock; /* acquire before lock to avoid DOS by playback thread */
@@ -409,6 +419,7 @@
     int64_t mmap_time_offset_nanos; /* fudge factor to correct inaccuracies in DSP */
     int     mmap_shared_memory_fd; /* file descriptor associated with MMAP NOIRQ shared memory */
     audio_io_handle_t handle;
+    streams_output_ctxt_t out_ctxt;
     struct stream_app_type_cfg app_type_cfg;
 
     int non_blocking;
@@ -515,6 +526,7 @@
     int64_t mmap_time_offset_nanos; /* fudge factor to correct inaccuracies in DSP */
     int     mmap_shared_memory_fd; /* file descriptor associated with MMAP NOIRQ shared memory */
     audio_io_handle_t capture_handle;
+    streams_input_ctxt_t in_ctxt;
     audio_input_flags_t flags;
     char profile[MAX_STREAM_PROFILE_STR_LEN];
     bool is_st_session;
@@ -623,16 +635,6 @@
     struct stream_app_type_cfg app_type_cfg;
 };
 
-typedef struct streams_input_ctxt {
-    struct listnode list;
-    struct stream_in *input;
-} streams_input_ctxt_t;
-
-typedef struct streams_output_ctxt {
-    struct listnode list;
-    struct stream_out *output;
-} streams_output_ctxt_t;
-
 typedef void* (*adm_init_t)();
 typedef void (*adm_deinit_t)(void *);
 typedef void (*adm_register_output_stream_t)(void *, audio_io_handle_t, audio_output_flags_t);
@@ -814,11 +816,6 @@
 
 bool is_interactive_usecase(audio_usecase_t uc_id);
 
-streams_input_ctxt_t *in_get_stream(struct audio_device *dev,
-                                  audio_io_handle_t input);
-streams_output_ctxt_t *out_get_stream(struct audio_device *dev,
-                                  audio_io_handle_t output);
-
 size_t get_output_period_size(uint32_t sample_rate,
                             audio_format_t format,
                             int channel_count,