Merge "audio: add the property audio.offload.min.duration.secs"
diff --git a/configs/atoll/atoll.mk b/configs/atoll/atoll.mk
index 3432cdc..5acb773 100644
--- a/configs/atoll/atoll.mk
+++ b/configs/atoll/atoll.mk
@@ -69,6 +69,8 @@
 AUDIO_FEATURE_ENABLED_BATTERY_LISTENER := true
 ##AUDIO_FEATURE_FLAGS
 
+BOARD_SUPPORTS_OPENSOURCE_STHAL := true
+
 AUDIO_HARDWARE := audio.a2dp.default
 AUDIO_HARDWARE += audio.usb.default
 AUDIO_HARDWARE += audio.r_submix.default
@@ -167,6 +169,8 @@
     vendor/qcom/opensource/audio-hal/primary-hal/configs/atoll/mixer_paths_wcd9375.xml:$(TARGET_COPY_OUT_VENDOR)/etc/mixer_paths_wcd9375.xml \
     vendor/qcom/opensource/audio-hal/primary-hal/configs/atoll/mixer_paths_qrd.xml:$(TARGET_COPY_OUT_VENDOR)/etc/mixer_paths_qrd.xml \
     vendor/qcom/opensource/audio-hal/primary-hal/configs/atoll/mixer_paths_wcd9375qrd.xml:$(TARGET_COPY_OUT_VENDOR)/etc/mixer_paths_wcd9375qrd.xml \
+    frameworks/native/data/etc/android.hardware.audio.pro.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/android.hardware.audio.pro.xml \
+    frameworks/native/data/etc/android.hardware.audio.low_latency.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/android.hardware.audio.low_latency.xml
 
 #XML Audio configuration files
 ifneq ($(TARGET_USES_AOSP_FOR_AUDIO), true)
diff --git a/configs/atoll/audio_policy_configuration.xml b/configs/atoll/audio_policy_configuration.xml
index 5a251c2..a6d7eef 100644
--- a/configs/atoll/audio_policy_configuration.xml
+++ b/configs/atoll/audio_policy_configuration.xml
@@ -266,17 +266,20 @@
                              samplingRates="48000" channelMasks="AUDIO_CHANNEL_OUT_MONO,AUDIO_CHANNEL_OUT_STEREO"/>
                 </devicePort>
                 <devicePort tagName="BT A2DP Out" type="AUDIO_DEVICE_OUT_BLUETOOTH_A2DP" role="sink"
-                            encodedFormats="AUDIO_FORMAT_SBC AUDIO_FORMAT_AAC AUDIO_FORMAT_APTX AUDIO_FORMAT_APTX_HD AUDIO_FORMAT_LDAC">
+                            encodedFormats="AUDIO_FORMAT_SBC AUDIO_FORMAT_AAC AUDIO_FORMAT_APTX AUDIO_FORMAT_APTX_HD AUDIO_FORMAT_LDAC AUDIO_FORMAT_CELT AUDIO_FORMAT_APTX_ADAPTIVE AUDIO_FORMAT_APTX_TW
+SP">
                     <profile name="" format="AUDIO_FORMAT_PCM_16_BIT"
                              samplingRates="48000" channelMasks="AUDIO_CHANNEL_OUT_STEREO"/>
                 </devicePort>
                 <devicePort tagName="BT A2DP Headphones" type="AUDIO_DEVICE_OUT_BLUETOOTH_A2DP_HEADPHONES" role="sink"
-                            encodedFormats="AUDIO_FORMAT_SBC AUDIO_FORMAT_AAC AUDIO_FORMAT_APTX AUDIO_FORMAT_APTX_HD AUDIO_FORMAT_LDAC">
+                            encodedFormats="AUDIO_FORMAT_SBC AUDIO_FORMAT_AAC AUDIO_FORMAT_APTX AUDIO_FORMAT_APTX_HD AUDIO_FORMAT_LDAC AUDIO_FORMAT_CELT AUDIO_FORMAT_APTX_ADAPTIVE AUDIO_FORMAT_APTX_TW
+SP">
                     <profile name="" format="AUDIO_FORMAT_PCM_16_BIT"
                              samplingRates="48000" channelMasks="AUDIO_CHANNEL_OUT_STEREO"/>
                 </devicePort>
                 <devicePort tagName="BT A2DP Speaker" type="AUDIO_DEVICE_OUT_BLUETOOTH_A2DP_SPEAKER" role="sink"
-                            encodedFormats="AUDIO_FORMAT_SBC AUDIO_FORMAT_AAC AUDIO_FORMAT_APTX AUDIO_FORMAT_APTX_HD AUDIO_FORMAT_LDAC">
+                            encodedFormats="AUDIO_FORMAT_SBC AUDIO_FORMAT_AAC AUDIO_FORMAT_APTX AUDIO_FORMAT_APTX_HD AUDIO_FORMAT_LDAC AUDIO_FORMAT_CELT AUDIO_FORMAT_APTX_ADAPTIVE AUDIO_FORMAT_APTX_TW
+SP">
                     <profile name="" format="AUDIO_FORMAT_PCM_16_BIT"
                              samplingRates="48000" channelMasks="AUDIO_CHANNEL_OUT_STEREO"/>
                 </devicePort>
@@ -319,27 +322,8 @@
                              samplingRates="8000,16000,48000" channelMasks="AUDIO_CHANNEL_IN_MONO"/>
                 </devicePort>
                 <devicePort tagName="USB Device In" type="AUDIO_DEVICE_IN_USB_DEVICE" role="source">
-                    <profile name="" format="AUDIO_FORMAT_PCM_16_BIT"
-                             samplingRates="44100,48000,64000,88200,96000,128000,176400,192000" channelMasks="AUDIO_CHANNEL_IN_MONO,AUDIO_CHANNEL_IN_STEREO,AUDIO_CHANNEL_INDEX_MASK_6,AUDIO_CHANNEL_IN_7POINT1,AUDIO_CHANNEL_INDEX_MASK_8"/>
-                    <profile name="" format="AUDIO_FORMAT_PCM_8_24_BIT"
-                             samplingRates="44100,48000,64000,88200,96000,128000,176400,192000"
-                             channelMasks="AUDIO_CHANNEL_IN_MONO,AUDIO_CHANNEL_IN_STEREO,AUDIO_CHANNEL_INDEX_MASK_6,AUDIO_CHANNEL_IN_7POINT1,AUDIO_CHANNEL_INDEX_MASK_8"/>
-                    <!-- edit as needed -->
-                    <profile name="" format="AUDIO_FORMAT_PCM_32_BIT"
-                             samplingRates="44100,48000,64000,88200,96000,128000,176400,192000"
-                             channelMasks="AUDIO_CHANNEL_IN_MONO,AUDIO_CHANNEL_IN_STEREO,AUDIO_CHANNEL_INDEX_MASK_6,AUDIO_CHANNEL_IN_7POINT1,AUDIO_CHANNEL_INDEX_MASK_8"/>
                 </devicePort>
                 <devicePort tagName="USB Headset In" type="AUDIO_DEVICE_IN_USB_HEADSET" role="source">
-                    <profile name="" format="AUDIO_FORMAT_PCM_16_BIT"
-                             samplingRates="44100,48000,64000,88200,96000,128000,176400,192000"
-                             channelMasks="AUDIO_CHANNEL_IN_MONO,AUDIO_CHANNEL_IN_STEREO,AUDIO_CHANNEL_INDEX_MASK_6,AUDIO_CHANNEL_IN_7POINT1,AUDIO_CHANNEL_INDEX_MASK_8"/>
-                    <profile name="" format="AUDIO_FORMAT_PCM_8_24_BIT"
-                             samplingRates="44100,48000,64000,88200,96000,128000,176400,192000"
-                             channelMasks="AUDIO_CHANNEL_IN_MONO,AUDIO_CHANNEL_IN_STEREO,AUDIO_CHANNEL_INDEX_MASK_6,AUDIO_CHANNEL_IN_7POINT1,AUDIO_CHANNEL_INDEX_MASK_8"/>
-                    <!-- edit as needed -->
-                    <profile name="" format="AUDIO_FORMAT_PCM_32_BIT"
-                             samplingRates="44100,48000,64000,88200,96000,128000,176400,192000"
-                             channelMasks="AUDIO_CHANNEL_IN_MONO,AUDIO_CHANNEL_IN_STEREO,AUDIO_CHANNEL_INDEX_MASK_6,AUDIO_CHANNEL_IN_7POINT1,AUDIO_CHANNEL_INDEX_MASK_8"/>
                 </devicePort>
 
             </devicePorts>
diff --git a/configs/atoll/mixer_paths_idp.xml b/configs/atoll/mixer_paths_idp.xml
index 860a253..433e1a8 100644
--- a/configs/atoll/mixer_paths_idp.xml
+++ b/configs/atoll/mixer_paths_idp.xml
@@ -2130,6 +2130,10 @@
         <path name="handset" />
     </path>
 
+    <path name="voice-handset-tmus">
+        <path name="handset" />
+    </path>
+
     <path name="voice-speaker">
         <path name="speaker-mono" />
     </path>
diff --git a/configs/atoll/mixer_paths_qrd.xml b/configs/atoll/mixer_paths_qrd.xml
index 5efd1aa..8719bf1 100644
--- a/configs/atoll/mixer_paths_qrd.xml
+++ b/configs/atoll/mixer_paths_qrd.xml
@@ -2151,6 +2151,10 @@
         <path name="handset" />
     </path>
 
+    <path name="voice-handset-tmus">
+        <path name="handset" />
+    </path>
+
     <path name="voice-speaker">
         <path name="speaker-mono" />
     </path>
diff --git a/configs/atoll/mixer_paths_wcd9375.xml b/configs/atoll/mixer_paths_wcd9375.xml
index 680f445..c4d2af7 100644
--- a/configs/atoll/mixer_paths_wcd9375.xml
+++ b/configs/atoll/mixer_paths_wcd9375.xml
@@ -2155,6 +2155,10 @@
         <path name="handset" />
     </path>
 
+    <path name="voice-handset-tmus">
+        <path name="handset" />
+    </path>
+
     <path name="voice-speaker">
         <path name="speaker-mono" />
     </path>
diff --git a/configs/atoll/mixer_paths_wcd9375qrd.xml b/configs/atoll/mixer_paths_wcd9375qrd.xml
index 758a1d3..aee360c 100644
--- a/configs/atoll/mixer_paths_wcd9375qrd.xml
+++ b/configs/atoll/mixer_paths_wcd9375qrd.xml
@@ -2237,6 +2237,10 @@
         <path name="handset" />
     </path>
 
+    <path name="voice-handset-tmus">
+        <path name="handset" />
+    </path>
+
     <path name="voice-speaker">
         <path name="speaker-mono" />
     </path>
diff --git a/configs/kona/audio_platform_info.xml b/configs/kona/audio_platform_info.xml
index 5b12029..346041f 100644
--- a/configs/kona/audio_platform_info.xml
+++ b/configs/kona/audio_platform_info.xml
@@ -110,6 +110,7 @@
         <usecase name="USECASE_AUDIO_A2DP_ABR_FEEDBACK" type="in" id="36" />
         <usecase name="USECASE_AUDIO_A2DP_ABR_FEEDBACK" type="out" id="36" />
         <usecase name="USECASE_INCALL_MUSIC_UPLINK" type="out" id="23" />
+        <usecase name="USECASE_AUDIO_RECORD_COMPRESS2" type="in" id="37" />
     </pcm_ids>
     <config_params>
         <param key="spkr_1_tz_name" value="wsatz.13"/>
@@ -145,6 +146,7 @@
         <device name="SND_DEVICE_OUT_SPEAKER_AND_LINE" backend="speaker-and-headphones" interface="WSA_CDC_DMA_RX_0-and-RX_CDC_DMA_RX_0"/>
         <device name="SND_DEVICE_OUT_SPEAKER_AND_ANC_HEADSET" backend="speaker-and-headphones" interface="WSA_CDC_DMA_RX_0-and-RX_CDC_DMA_RX_0"/>
         <device name="SND_DEVICE_OUT_VOICE_HEADPHONES" backend="headphones" interface="RX_CDC_DMA_RX_0"/>
+        <device name="SND_DEVICE_OUT_VOICE_HEADSET" backend="headset" interface="RX_CDC_DMA_RX_0"/>
         <device name="SND_DEVICE_OUT_VOICE_ANC_HEADSET" backend="headphones" interface="RX_CDC_DMA_RX_0"/>
         <device name="SND_DEVICE_OUT_VOICE_LINE" backend="headphones" interface="RX_CDC_DMA_RX_0"/>
         <device name="SND_DEVICE_OUT_VOICE_TTY_FULL_HEADPHONES" backend="headphones" interface="RX_CDC_DMA_RX_0"/>
@@ -160,6 +162,7 @@
         <device name="SND_DEVICE_OUT_VOICE_HANDSET" interface="WSA_CDC_DMA_RX_0"/>
         <device name="SND_DEVICE_IN_HANDSET_GENERIC_QMIC" interface="TX_CDC_DMA_TX_3"/>
         <device name="SND_DEVICE_OUT_VOICE_SPEAKER" interface="WSA_CDC_DMA_RX_0"/>
+        <device name="SND_DEVICE_OUT_VOICE_SPEAKER_STEREO" interface="WSA_CDC_DMA_RX_0"/>
         <device name="SND_DEVICE_OUT_VOICE_SPEAKER_VBAT" interface="WSA_CDC_DMA_RX_0"/>
         <device name="SND_DEVICE_OUT_VOICE_SPEAKER_2" interface="WSA_CDC_DMA_RX_0"/>
         <device name="SND_DEVICE_OUT_VOICE_SPEAKER_2_VBAT" interface="WSA_CDC_DMA_RX_0"/>
@@ -196,10 +199,16 @@
         <device name="SND_DEVICE_IN_SPEAKER_DMIC_AEC" interface="TX_CDC_DMA_TX_3"/>
         <device name="SND_DEVICE_IN_SPEAKER_DMIC_NS" interface="TX_CDC_DMA_TX_3"/>
         <device name="SND_DEVICE_IN_SPEAKER_DMIC_AEC_NS" interface="TX_CDC_DMA_TX_3"/>
-        <device name="SND_DEVICE_IN_HEADSET_MIC" interface="TX_CDC_DMA_TX_3"/>
-        <device name="SND_DEVICE_IN_HEADSET_MIC_FLUENCE" interface="TX_CDC_DMA_TX_3"/>
+        <device name="SND_DEVICE_IN_HEADSET_MIC" backend="headset-mic" interface="TX_CDC_DMA_TX_4"/>
+        <device name="SND_DEVICE_IN_HEADSET_MIC_FLUENCE" backend="headset-mic" interface="TX_CDC_DMA_TX_4"/>
+        <device name="SND_DEVICE_IN_VOICE_HEADSET_MIC" backend="headset-mic" interface="TX_CDC_DMA_TX_4"/>
+        <device name="SND_DEVICE_IN_VOICE_TTY_FULL_HEADSET_MIC" backend="headset-mic" interface="TX_CDC_DMA_TX_4"/>
+        <device name="SND_DEVICE_IN_VOICE_TTY_HCO_HEADSET_MIC" backend="headset-mic" interface="TX_CDC_DMA_TX_4"/>
+        <device name="SND_DEVICE_IN_UNPROCESSED_HEADSET_MIC" backend="headset-mic" interface="TX_CDC_DMA_TX_4"/>
+        <device name="SND_DEVICE_IN_VOICE_REC_HEADSET_MIC" backend="headset-mic" interface="TX_CDC_DMA_TX_4"/>
+        <device name="SND_DEVICE_IN_HEADSET_MIC_AEC" backend="headset-mic" interface="TX_CDC_DMA_TX_4"/>
+        <device name="SND_DEVICE_IN_HEADSET_MIC_FLUENCE" backend="headset-mic" interface="TX_CDC_DMA_TX_4"/>
         <device name="SND_DEVICE_IN_VOICE_SPEAKER_MIC" interface="TX_CDC_DMA_TX_3"/>
-        <device name="SND_DEVICE_IN_VOICE_HEADSET_MIC" interface="TX_CDC_DMA_TX_3"/>
         <device name="SND_DEVICE_IN_HDMI_MIC" interface="HDMI"/>
         <device name="SND_DEVICE_IN_BT_SCO_MIC" interface="SLIMBUS_7_TX"/>
         <device name="SND_DEVICE_IN_BT_SCO_MIC_NREC" interface="SLIMBUS_7_TX"/>
diff --git a/configs/kona/audio_platform_info_intcodec.xml b/configs/kona/audio_platform_info_intcodec.xml
index 2aa4b27..2d22400 100644
--- a/configs/kona/audio_platform_info_intcodec.xml
+++ b/configs/kona/audio_platform_info_intcodec.xml
@@ -94,6 +94,7 @@
         <usecase name="USECASE_AUDIO_A2DP_ABR_FEEDBACK" type="in" id="36" />
         <usecase name="USECASE_AUDIO_A2DP_ABR_FEEDBACK" type="out" id="36" />
         <usecase name="USECASE_INCALL_MUSIC_UPLINK" type="out" id="23" />
+        <usecase name="USECASE_AUDIO_RECORD_COMPRESS2" type="in" id="37" />
     </pcm_ids>
     <config_params>
         <!-- In the below value string, the value indicates default mono -->
@@ -149,6 +150,7 @@
         <device name="SND_DEVICE_OUT_SPEAKER_AND_LINE" backend="speaker-and-headphones" interface="WSA_CDC_DMA_RX_0-and-RX_CDC_DMA_RX_0"/>
         <device name="SND_DEVICE_OUT_SPEAKER_AND_ANC_HEADSET" backend="speaker-and-headphones" interface="WSA_CDC_DMA_RX_0-and-RX_CDC_DMA_RX_0"/>
         <device name="SND_DEVICE_OUT_VOICE_HEADPHONES" backend="headphones" interface="RX_CDC_DMA_RX_0"/>
+        <device name="SND_DEVICE_OUT_VOICE_HEADSET" backend="headset" interface="RX_CDC_DMA_RX_0"/>
         <device name="SND_DEVICE_OUT_VOICE_ANC_HEADSET" backend="headphones" interface="RX_CDC_DMA_RX_0"/>
         <device name="SND_DEVICE_OUT_VOICE_LINE" backend="headphones" interface="RX_CDC_DMA_RX_0"/>
         <device name="SND_DEVICE_OUT_VOICE_TTY_FULL_HEADPHONES" backend="headphones" interface="RX_CDC_DMA_RX_0"/>
@@ -164,6 +166,7 @@
         <device name="SND_DEVICE_OUT_VOICE_HANDSET" interface="WSA_CDC_DMA_RX_0"/>
         <device name="SND_DEVICE_IN_HANDSET_GENERIC_QMIC" interface="TX_CDC_DMA_TX_3"/>
         <device name="SND_DEVICE_OUT_VOICE_SPEAKER" interface="WSA_CDC_DMA_RX_0"/>
+        <device name="SND_DEVICE_OUT_VOICE_SPEAKER_STEREO" interface="WSA_CDC_DMA_RX_0"/>
         <device name="SND_DEVICE_OUT_VOICE_SPEAKER_VBAT" interface="WSA_CDC_DMA_RX_0"/>
         <device name="SND_DEVICE_OUT_VOICE_SPEAKER_2" interface="WSA_CDC_DMA_RX_0"/>
         <device name="SND_DEVICE_OUT_VOICE_SPEAKER_2_VBAT" interface="WSA_CDC_DMA_RX_0"/>
@@ -214,11 +217,17 @@
         <device name="SND_DEVICE_IN_SPEAKER_DMIC_NS_SB" interface="TX_CDC_DMA_TX_3"/>
         <device name="SND_DEVICE_IN_SPEAKER_DMIC_AEC_NS" interface="TX_CDC_DMA_TX_3"/>
         <device name="SND_DEVICE_IN_SPEAKER_DMIC_AEC_NS_SB" interface="TX_CDC_DMA_TX_3"/>
-        <device name="SND_DEVICE_IN_HEADSET_MIC" interface="TX_CDC_DMA_TX_3"/>
-        <device name="SND_DEVICE_IN_HEADSET_MIC_FLUENCE" interface="TX_CDC_DMA_TX_3"/>
+        <device name="SND_DEVICE_IN_HEADSET_MIC" backend="headset-mic" interface="TX_CDC_DMA_TX_4"/>
+        <device name="SND_DEVICE_IN_HEADSET_MIC_FLUENCE" backend="headset-mic" interface="TX_CDC_DMA_TX_4"/>
+        <device name="SND_DEVICE_IN_VOICE_HEADSET_MIC" backend="headset-mic" interface="TX_CDC_DMA_TX_4"/>
+        <device name="SND_DEVICE_IN_VOICE_TTY_FULL_HEADSET_MIC" backend="headset-mic" interface="TX_CDC_DMA_TX_4"/>
+        <device name="SND_DEVICE_IN_VOICE_TTY_HCO_HEADSET_MIC" backend="headset-mic" interface="TX_CDC_DMA_TX_4"/>
+        <device name="SND_DEVICE_IN_UNPROCESSED_HEADSET_MIC" backend="headset-mic" interface="TX_CDC_DMA_TX_4"/>
+        <device name="SND_DEVICE_IN_VOICE_REC_HEADSET_MIC" backend="headset-mic" interface="TX_CDC_DMA_TX_4"/>
+        <device name="SND_DEVICE_IN_HEADSET_MIC_AEC" backend="headset-mic" interface="TX_CDC_DMA_TX_4"/>
+        <device name="SND_DEVICE_IN_HEADSET_MIC_FLUENCE" backend="headset-mic" interface="TX_CDC_DMA_TX_4"/>
         <device name="SND_DEVICE_IN_VOICE_SPEAKER_MIC" interface="TX_CDC_DMA_TX_3"/>
         <device name="SND_DEVICE_IN_VOICE_SPEAKER_MIC_SB" interface="TX_CDC_DMA_TX_3"/>
-        <device name="SND_DEVICE_IN_VOICE_HEADSET_MIC" interface="TX_CDC_DMA_TX_3"/>
         <device name="SND_DEVICE_IN_HDMI_MIC" interface="HDMI"/>
         <device name="SND_DEVICE_IN_BT_SCO_MIC" interface="SLIMBUS_7_TX"/>
         <device name="SND_DEVICE_IN_BT_SCO_MIC_NREC" interface="SLIMBUS_7_TX"/>
diff --git a/configs/kona/audio_platform_info_qrd.xml b/configs/kona/audio_platform_info_qrd.xml
index 7ff0f17..bcf63aa 100644
--- a/configs/kona/audio_platform_info_qrd.xml
+++ b/configs/kona/audio_platform_info_qrd.xml
@@ -92,6 +92,7 @@
         <usecase name="USECASE_AUDIO_A2DP_ABR_FEEDBACK" type="in" id="36" />
         <usecase name="USECASE_AUDIO_A2DP_ABR_FEEDBACK" type="out" id="36" />
         <usecase name="USECASE_INCALL_MUSIC_UPLINK" type="out" id="23" />
+        <usecase name="USECASE_AUDIO_RECORD_COMPRESS2" type="in" id="37" />
     </pcm_ids>
     <config_params>
         <!-- In the below value string, the value indicates default mono -->
@@ -160,6 +161,7 @@
         <device name="SND_DEVICE_OUT_SPEAKER_AND_LINE" backend="speaker-and-headphones" interface="WSA_CDC_DMA_RX_0-and-RX_CDC_DMA_RX_0"/>
         <device name="SND_DEVICE_OUT_SPEAKER_AND_ANC_HEADSET" backend="speaker-and-headphones" interface="WSA_CDC_DMA_RX_0-and-RX_CDC_DMA_RX_0"/>
         <device name="SND_DEVICE_OUT_VOICE_HEADPHONES" backend="headphones" interface="RX_CDC_DMA_RX_0"/>
+        <device name="SND_DEVICE_OUT_VOICE_HEADSET" backend="headset" interface="RX_CDC_DMA_RX_0"/>
         <device name="SND_DEVICE_OUT_VOICE_ANC_HEADSET" backend="headphones" interface="RX_CDC_DMA_RX_0"/>
         <device name="SND_DEVICE_OUT_VOICE_LINE" backend="headphones" interface="RX_CDC_DMA_RX_0"/>
         <device name="SND_DEVICE_OUT_VOICE_TTY_FULL_HEADPHONES" backend="headphones" interface="RX_CDC_DMA_RX_0"/>
@@ -175,6 +177,7 @@
         <device name="SND_DEVICE_OUT_VOICE_HANDSET" backend="handset" interface="RX_CDC_DMA_RX_0"/>
         <device name="SND_DEVICE_IN_HANDSET_GENERIC_QMIC" interface="TX_CDC_DMA_TX_3"/>
         <device name="SND_DEVICE_OUT_VOICE_SPEAKER" interface="WSA_CDC_DMA_RX_0"/>
+        <device name="SND_DEVICE_OUT_VOICE_SPEAKER_STEREO" interface="WSA_CDC_DMA_RX_0"/>
         <device name="SND_DEVICE_OUT_VOICE_SPEAKER_VBAT" interface="WSA_CDC_DMA_RX_0"/>
         <device name="SND_DEVICE_OUT_VOICE_SPEAKER_2" interface="WSA_CDC_DMA_RX_0"/>
         <device name="SND_DEVICE_OUT_VOICE_SPEAKER_2_VBAT" interface="WSA_CDC_DMA_RX_0"/>
@@ -225,11 +228,17 @@
         <device name="SND_DEVICE_IN_SPEAKER_DMIC_NS_SB" interface="TX_CDC_DMA_TX_3"/>
         <device name="SND_DEVICE_IN_SPEAKER_DMIC_AEC_NS" interface="TX_CDC_DMA_TX_3"/>
         <device name="SND_DEVICE_IN_SPEAKER_DMIC_AEC_NS_SB" interface="TX_CDC_DMA_TX_3"/>
-        <device name="SND_DEVICE_IN_HEADSET_MIC" interface="TX_CDC_DMA_TX_3"/>
-        <device name="SND_DEVICE_IN_HEADSET_MIC_FLUENCE" interface="TX_CDC_DMA_TX_3"/>
+        <device name="SND_DEVICE_IN_HEADSET_MIC" backend="headset-mic" interface="TX_CDC_DMA_TX_4"/>
+        <device name="SND_DEVICE_IN_HEADSET_MIC_FLUENCE" backend="headset-mic" interface="TX_CDC_DMA_TX_4"/>
+        <device name="SND_DEVICE_IN_VOICE_HEADSET_MIC" backend="headset-mic" interface="TX_CDC_DMA_TX_4"/>
+        <device name="SND_DEVICE_IN_VOICE_TTY_FULL_HEADSET_MIC" backend="headset-mic" interface="TX_CDC_DMA_TX_4"/>
+        <device name="SND_DEVICE_IN_VOICE_TTY_HCO_HEADSET_MIC" backend="headset-mic" interface="TX_CDC_DMA_TX_4"/>
+        <device name="SND_DEVICE_IN_UNPROCESSED_HEADSET_MIC" backend="headset-mic" interface="TX_CDC_DMA_TX_4"/>
+        <device name="SND_DEVICE_IN_VOICE_REC_HEADSET_MIC" backend="headset-mic" interface="TX_CDC_DMA_TX_4"/>
+        <device name="SND_DEVICE_IN_HEADSET_MIC_AEC" backend="headset-mic" interface="TX_CDC_DMA_TX_4"/>
+        <device name="SND_DEVICE_IN_HEADSET_MIC_FLUENCE" backend="headset-mic" interface="TX_CDC_DMA_TX_4"/>
         <device name="SND_DEVICE_IN_VOICE_SPEAKER_MIC" interface="TX_CDC_DMA_TX_3"/>
         <device name="SND_DEVICE_IN_VOICE_SPEAKER_MIC_SB" interface="TX_CDC_DMA_TX_3"/>
-        <device name="SND_DEVICE_IN_VOICE_HEADSET_MIC" interface="TX_CDC_DMA_TX_3"/>
         <device name="SND_DEVICE_IN_HDMI_MIC" interface="HDMI"/>
         <device name="SND_DEVICE_IN_BT_SCO_MIC" interface="SLIMBUS_7_TX"/>
         <device name="SND_DEVICE_IN_BT_SCO_MIC_NREC" interface="SLIMBUS_7_TX"/>
diff --git a/configs/kona/audio_policy_configuration.xml b/configs/kona/audio_policy_configuration.xml
index 657b5d1..8bb3328 100644
--- a/configs/kona/audio_policy_configuration.xml
+++ b/configs/kona/audio_policy_configuration.xml
@@ -184,7 +184,7 @@
                              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="record_24" role="sink">
+                <mixPort name="record_24" role="sink" maxOpenCount="2" maxActiveCount="2">
                     <profile name="" format="AUDIO_FORMAT_PCM_24_BIT_PACKED"
                              samplingRates="8000,11025,12000,16000,22050,24000,32000,44100,48000,96000,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"/>
@@ -311,27 +311,8 @@
                              samplingRates="8000,16000,48000" channelMasks="AUDIO_CHANNEL_IN_MONO"/>
                 </devicePort>
                 <devicePort tagName="USB Device In" type="AUDIO_DEVICE_IN_USB_DEVICE" role="source">
-                    <profile name="" format="AUDIO_FORMAT_PCM_16_BIT"
-                             samplingRates="44100,48000,64000,88200,96000,128000,176400,192000" channelMasks="AUDIO_CHANNEL_IN_MONO,AUDIO_CHANNEL_IN_STEREO,AUDIO_CHANNEL_INDEX_MASK_6,AUDIO_CHANNEL_IN_7POINT1,AUDIO_CHANNEL_INDEX_MASK_8"/>
-                    <profile name="" format="AUDIO_FORMAT_PCM_8_24_BIT"
-                             samplingRates="44100,48000,64000,88200,96000,128000,176400,192000"
-                             channelMasks="AUDIO_CHANNEL_IN_MONO,AUDIO_CHANNEL_IN_STEREO,AUDIO_CHANNEL_INDEX_MASK_6,AUDIO_CHANNEL_IN_7POINT1,AUDIO_CHANNEL_INDEX_MASK_8"/>
-                    <!-- edit as needed -->
-                    <profile name="" format="AUDIO_FORMAT_PCM_32_BIT"
-                             samplingRates="44100,48000,64000,88200,96000,128000,176400,192000"
-                             channelMasks="AUDIO_CHANNEL_IN_MONO,AUDIO_CHANNEL_IN_STEREO,AUDIO_CHANNEL_INDEX_MASK_6,AUDIO_CHANNEL_IN_7POINT1,AUDIO_CHANNEL_INDEX_MASK_8"/>
                 </devicePort>
                 <devicePort tagName="USB Headset In" type="AUDIO_DEVICE_IN_USB_HEADSET" role="source">
-                    <profile name="" format="AUDIO_FORMAT_PCM_16_BIT"
-                             samplingRates="44100,48000,64000,88200,96000,128000,176400,192000"
-                             channelMasks="AUDIO_CHANNEL_IN_MONO,AUDIO_CHANNEL_IN_STEREO,AUDIO_CHANNEL_INDEX_MASK_6,AUDIO_CHANNEL_IN_7POINT1,AUDIO_CHANNEL_INDEX_MASK_8"/>
-                    <profile name="" format="AUDIO_FORMAT_PCM_8_24_BIT"
-                             samplingRates="44100,48000,64000,88200,96000,128000,176400,192000"
-                             channelMasks="AUDIO_CHANNEL_IN_MONO,AUDIO_CHANNEL_IN_STEREO,AUDIO_CHANNEL_INDEX_MASK_6,AUDIO_CHANNEL_IN_7POINT1,AUDIO_CHANNEL_INDEX_MASK_8"/>
-                    <!-- edit as needed -->
-                    <profile name="" format="AUDIO_FORMAT_PCM_32_BIT"
-                             samplingRates="44100,48000,64000,88200,96000,128000,176400,192000"
-                             channelMasks="AUDIO_CHANNEL_IN_MONO,AUDIO_CHANNEL_IN_STEREO,AUDIO_CHANNEL_INDEX_MASK_6,AUDIO_CHANNEL_IN_7POINT1,AUDIO_CHANNEL_INDEX_MASK_8"/>
                 </devicePort>
 
             </devicePorts>
diff --git a/configs/kona/kona.mk b/configs/kona/kona.mk
index 2de2f3b..33a678f 100644
--- a/configs/kona/kona.mk
+++ b/configs/kona/kona.mk
@@ -32,6 +32,7 @@
 AUDIO_FEATURE_ENABLED_ALAC_OFFLOAD := true
 AUDIO_FEATURE_ENABLED_APE_OFFLOAD := true
 AUDIO_FEATURE_ENABLED_AAC_ADTS_OFFLOAD := true
+AUDIO_FEATURE_ENABLED_MPEGH_SW_DECODER := true
 AUDIO_FEATURE_ENABLED_PROXY_DEVICE := true
 AUDIO_FEATURE_ENABLED_SSR := true
 AUDIO_FEATURE_ENABLED_DTS_EAGLE := false
@@ -179,12 +180,15 @@
     vendor/qcom/opensource/audio-hal/primary-hal/configs/kona/audio_platform_info_intcodec.xml:$(TARGET_COPY_OUT_VENDOR)/etc/audio_platform_info_intcodec.xml \
     vendor/qcom/opensource/audio-hal/primary-hal/configs/kona/sound_trigger_mixer_paths.xml:$(TARGET_COPY_OUT_VENDOR)/etc/sound_trigger_mixer_paths.xml \
     vendor/qcom/opensource/audio-hal/primary-hal/configs/kona/sound_trigger_mixer_paths_qrd.xml:$(TARGET_COPY_OUT_VENDOR)/etc/sound_trigger_mixer_paths_qrd.xml \
+    vendor/qcom/opensource/audio-hal/primary-hal/configs/kona/sound_trigger_mixer_paths_qrd.xml:$(TARGET_COPY_OUT_VENDOR)/etc/sound_trigger_mixer_paths_cdp.xml \
     vendor/qcom/opensource/audio-hal/primary-hal/configs/kona/mixer_paths.xml:$(TARGET_COPY_OUT_VENDOR)/etc/mixer_paths.xml \
     vendor/qcom/opensource/audio-hal/primary-hal/configs/kona/mixer_paths_qrd.xml:$(TARGET_COPY_OUT_VENDOR)/etc/mixer_paths_qrd.xml \
+    vendor/qcom/opensource/audio-hal/primary-hal/configs/kona/mixer_paths_qrd.xml:$(TARGET_COPY_OUT_VENDOR)/etc/mixer_paths_cdp.xml \
     vendor/qcom/opensource/audio-hal/primary-hal/configs/kona/audio_configs.xml:$(TARGET_COPY_OUT_VENDOR)/etc/audio_configs.xml \
     vendor/qcom/opensource/audio-hal/primary-hal/configs/kona/audio_configs_stock.xml:$(TARGET_COPY_OUT_VENDOR)/etc/audio_configs_stock.xml \
     vendor/qcom/opensource/audio-hal/primary-hal/configs/kona/audio_tuning_mixer.txt:$(TARGET_COPY_OUT_VENDOR)/etc/audio_tuning_mixer.txt \
-    frameworks/native/data/etc/android.hardware.audio.pro.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/android.hardware.audio.pro.xml
+    frameworks/native/data/etc/android.hardware.audio.pro.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/android.hardware.audio.pro.xml \
+    frameworks/native/data/etc/android.hardware.audio.low_latency.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/android.hardware.audio.low_latency.xml
 
 #XML Audio configuration files
 ifneq ($(TARGET_USES_AOSP_FOR_AUDIO), true)
@@ -208,6 +212,14 @@
 PRODUCT_PROPERTY_OVERRIDES += \
     vendor.audio_hal.period_size=192
 
+##Ambisonic Capture
+PRODUCT_PROPERTY_OVERRIDES += \
+vendor.audio.ambisonic.capture=true \
+vendor.audio.ambisonic.auto.profile=true
+
+PRODUCT_PROPERTY_OVERRIDES += \
+vendor.audio.apptype.multirec.enabled=true
+
 ##fluencetype can be "fluence" or "fluencepro" or "none"
 PRODUCT_PROPERTY_OVERRIDES += \
 ro.vendor.audio.sdk.fluencetype=none\
@@ -289,7 +301,7 @@
 
 #enable pbe effects
 PRODUCT_PROPERTY_OVERRIDES += \
-vendor.audio.safx.pbe.enabled=true
+vendor.audio.safx.pbe.enabled=false
 
 #parser input buffer size(256kb) in byte stream mode
 PRODUCT_PROPERTY_OVERRIDES += \
@@ -389,18 +401,17 @@
 vendor.audio.feature.a2dp_offload.enable=true \
 vendor.audio.feature.afe_proxy.enable=true \
 vendor.audio.feature.anc_headset.enable=true \
-vendor.audio.feature.audio_sphere.enable=true \
 vendor.audio.feature.battery_listener.enable=true \
 vendor.audio.feature.compr_cap.enable=false \
 vendor.audio.feature.compress_in.enable=true \
 vendor.audio.feature.compress_meta_data.enable=true \
 vendor.audio.feature.compr_voip.enable=false \
-vendor.audio.feature.concurrent_capture.enable=false \
+vendor.audio.feature.concurrent_capture.enable=true \
 vendor.audio.feature.custom_stereo.enable=true \
 vendor.audio.feature.display_port.enable=true \
 vendor.audio.feature.dsm_feedback.enable=false \
 vendor.audio.feature.dynamic_ecns.enable=true \
-vendor.audio.feature.ext_hw_plugin.enable=true \
+vendor.audio.feature.ext_hw_plugin.enable=false \
 vendor.audio.feature.external_dsp.enable=false \
 vendor.audio.feature.external_speaker.enable=false \
 vendor.audio.feature.external_speaker_tfa.enable=false \
@@ -445,6 +456,15 @@
     vendor.qti.hardware.audiohalext@1.0-impl \
     vendor.qti.hardware.audiohalext-utils
 
+# enable audio hidl hal 5.0
+PRODUCT_PACKAGES += \
+    android.hardware.audio@5.0 \
+    android.hardware.audio.common@5.0 \
+    android.hardware.audio.common@5.0-util \
+    android.hardware.audio@5.0-impl \
+    android.hardware.audio.effect@5.0 \
+    android.hardware.audio.effect@5.0-impl
+
 PRODUCT_PACKAGES_ENG += \
     VoicePrintTest \
     VoicePrintDemo
diff --git a/configs/kona/mixer_paths.xml b/configs/kona/mixer_paths.xml
index 3e40870..3949c7c 100644
--- a/configs/kona/mixer_paths.xml
+++ b/configs/kona/mixer_paths.xml
@@ -61,11 +61,16 @@
     <ctl name="MultiMedia5 Mixer AFE_PCM_TX" value="0" />
     <ctl name="MultiMedia5 Mixer TX_CDC_DMA_TX_3" value="0" />
     <ctl name="MultiMedia1 Mixer TX_CDC_DMA_TX_3" value="0" />
+    <ctl name="MultiMedia1 Mixer TX_CDC_DMA_TX_4" value="0" />
     <ctl name="MultiMedia1 Mixer SLIM_7_TX" value="0" />
     <ctl name="MultiMedia8 Mixer SLIM_7_TX" value="0" />
     <ctl name="MultiMedia10 Mixer TX_CDC_DMA_TX_3" value="0" />
+    <ctl name="MultiMedia10 Mixer TX_CDC_DMA_TX_4" value="0" />
     <ctl name="MultiMedia10 Mixer SLIM_7_TX" value="0" />
     <ctl name="MultiMedia10 Mixer AFE_PCM_TX" value="0" />
+    <ctl name="MultiMedia17 Mixer TX_CDC_DMA_TX_3" value="0" />
+    <ctl name="MultiMedia17 Mixer TX_CDC_DMA_TX_4" value="0" />
+    <ctl name="MultiMedia17 Mixer SLIM_7_TX" value="0" />
     <ctl name="DISPLAY_PORT Mixer MultiMedia1" value="0" />
     <ctl name="DISPLAY_PORT Mixer MultiMedia2" value="0" />
     <ctl name="DISPLAY_PORT Mixer MultiMedia3" value="0" />
@@ -129,6 +134,7 @@
     <ctl name="MultiMedia5 Mixer USB_AUDIO_TX" value="0" />
     <ctl name="MultiMedia8 Mixer USB_AUDIO_TX" value="0" />
     <ctl name="MultiMedia10 Mixer USB_AUDIO_TX" value="0" />
+    <ctl name="MultiMedia17 Mixer USB_AUDIO_TX" value="0" />
     <ctl name="TX_CDC_DMA_TX_3 Channels" value="One" />
     <ctl name="WSA_CDC_DMA_RX_0 Channels" value="One" />
     <ctl name="RX_CDC_DMA_RX_0 Channels" value="One" />
@@ -175,6 +181,7 @@
     <ctl name="WSA_CDC_DMA_RX_0_Voice Mixer VoiceMMode1" value="0" />
     <ctl name="RX_CDC_DMA_RX_0_Voice Mixer VoiceMMode1" value="0" />
     <ctl name="VoiceMMode1_Tx Mixer TX_CDC_DMA_TX_3_MMode1" value="0" />
+    <ctl name="VoiceMMode1_Tx Mixer TX_CDC_DMA_TX_4_MMode1" value="0" />
     <!-- Multimode Voice1 BTSCO -->
     <ctl name="SLIM_7_RX_Voice Mixer VoiceMMode1" value="0" />
     <ctl name="VoiceMMode1_Tx Mixer SLIM_7_TX_MMode1" value="0" />
@@ -191,6 +198,7 @@
     <ctl name="WSA_CDC_DMA_RX_0_Voice Mixer VoiceMMode2" value="0" />
     <ctl name="RX_CDC_DMA_RX_0_Voice Mixer VoiceMMode2" value="0" />
     <ctl name="VoiceMMode1_Tx Mixer TX_CDC_DMA_TX_3_MMode2" value="0" />
+    <ctl name="VoiceMMode1_Tx Mixer TX_CDC_DMA_TX_4_MMode2" value="0" />
     <!-- Multimode Voice2 BTSCO -->
     <ctl name="SLIM_7_RX_Voice Mixer VoiceMMode2" value="0" />
     <ctl name="VoiceMMode2_Tx Mixer SLIM_7_TX_MMode2" value="0" />
@@ -423,6 +431,7 @@
 
     <!-- defaults for mmap record -->
     <ctl name="MultiMedia16 Mixer TX_CDC_DMA_TX_3" value="0" />
+    <ctl name="MultiMedia16 Mixer TX_CDC_DMA_TX_4" value="0" />
     <ctl name="MultiMedia16 Mixer SLIM_7_TX" value="0" />
     <ctl name="MultiMedia16 Mixer TERT_MI2S_TX" value="0" />
     <ctl name="MultiMedia16 Mixer USB_AUDIO_TX" value="0" />
@@ -440,6 +449,10 @@
         <ctl name="AUDIO_REF_EC_UL1 MUX" value="RX_CDC_DMA_RX_0" />
     </path>
 
+    <path name="echo-reference headset">
+        <path name="echo-reference headphones" />
+    </path>
+
     <path name="echo-reference display-port">
         <ctl name="AUDIO_REF_EC_UL1 MUX" value="DISPLAY_PORT" />
     </path>
@@ -507,6 +520,10 @@
         <ctl name="RX_CDC_DMA_RX_0 Audio Mixer MultiMedia1" value="1" />
     </path>
 
+    <path name="deep-buffer-playback headset">
+        <path name="deep-buffer-playback headphones" />
+    </path>
+
     <path name="deep-buffer-playback speaker-and-headphones">
         <path name="deep-buffer-playback headphones" />
         <path name="deep-buffer-playback" />
@@ -578,6 +595,10 @@
         <ctl name="RX_CDC_DMA_RX_0 Audio Mixer MultiMedia5" value="1" />
     </path>
 
+    <path name="low-latency-playback headset">
+        <path name="low-latency-playback headphones" />
+    </path>
+
     <path name="low-latency-playback speaker-and-headphones">
         <path name="low-latency-playback headphones" />
         <path name="low-latency-playback" />
@@ -613,6 +634,10 @@
         <ctl name="RX_CDC_DMA_RX_0 Audio Mixer MultiMedia8" value="1" />
     </path>
 
+    <path name="audio-ull-playback headset">
+        <path name="audio-ull-playback headphones" />
+    </path>
+
     <path name="audio-ull-playback speaker-and-headphones">
         <path name="audio-ull-playback" />
         <path name="audio-ull-playback headphones" />
@@ -730,6 +755,10 @@
         <ctl name="RX_CDC_DMA_RX_0 Audio Mixer MultiMedia4" value="1" />
     </path>
 
+    <path name="compress-offload-playback headset">
+        <path name="compress-offload-playback headphones" />
+    </path>
+
     <path name="compress-offload-playback headphones-44.1">
         <ctl name="RX_CDC_DMA_RX_0 Audio Mixer MultiMedia4" value="1" />
     </path>
@@ -805,6 +834,10 @@
         <ctl name="RX_CDC_DMA_RX_0 Audio Mixer MultiMedia7" value="1" />
     </path>
 
+    <path name="compress-offload-playback2 headset">
+        <path name="compress-offload-playback2 headphones" />
+    </path>
+
     <path name="compress-offload-playback2 headphones-44.1">
         <ctl name="RX_CDC_DMA_RX_0 Audio Mixer MultiMedia7" value="1" />
 
@@ -881,6 +914,10 @@
         <ctl name="RX_CDC_DMA_RX_0 Audio Mixer MultiMedia10" value="1" />
     </path>
 
+    <path name="compress-offload-playback3 headset">
+        <path name="compress-offload-playback3 headphones" />
+    </path>
+
     <path name="compress-offload-playback3 headphones-44.1">
         <ctl name="RX_CDC_DMA_RX_0 Audio Mixer MultiMedia10" value="1" />
     </path>
@@ -957,6 +994,10 @@
         <ctl name="RX_CDC_DMA_RX_0 Audio Mixer MultiMedia11" value="1" />
     </path>
 
+    <path name="compress-offload-playback4 headset">
+        <path name="compress-offload-playback4 headphones" />
+    </path>
+
     <path name="compress-offload-playback4 headphones-44.1">
         <ctl name="RX_CDC_DMA_RX_0 Audio Mixer MultiMedia11" value="1" />
     </path>
@@ -1032,6 +1073,10 @@
         <ctl name="RX_CDC_DMA_RX_0 Audio Mixer MultiMedia12" value="1" />
     </path>
 
+    <path name="compress-offload-playback5 headset">
+        <path name="compress-offload-playback5 headphones" />
+    </path>
+
     <path name="compress-offload-playback5 headphones-44.1">
         <ctl name="RX_CDC_DMA_RX_0 Audio Mixer MultiMedia12" value="1" />
     </path>
@@ -1107,6 +1152,10 @@
         <ctl name="RX_CDC_DMA_RX_0 Audio Mixer MultiMedia13" value="1" />
     </path>
 
+    <path name="compress-offload-playback6 headset">
+        <path name="compress-offload-playback6 headphones" />
+    </path>
+
     <path name="compress-offload-playback6 headphones-44.1">
         <ctl name="RX_CDC_DMA_RX_0 Audio Mixer MultiMedia13" value="1" />
     </path>
@@ -1182,6 +1231,10 @@
         <ctl name="RX_CDC_DMA_RX_0 Audio Mixer MultiMedia14" value="1" />
     </path>
 
+    <path name="compress-offload-playback7 headset">
+        <path name="compress-offload-playback7 headphones" />
+    </path>
+
     <path name="compress-offload-playback7 headphones-44.1">
         <ctl name="RX_CDC_DMA_RX_0 Audio Mixer MultiMedia14" value="1" />
     </path>
@@ -1257,6 +1310,10 @@
         <ctl name="RX_CDC_DMA_RX_0 Audio Mixer MultiMedia15" value="1" />
     </path>
 
+    <path name="compress-offload-playback8 headset">
+        <path name="compress-offload-playback8 headphones" />
+    </path>
+
     <path name="compress-offload-playback8 headphones-44.1">
         <ctl name="RX_CDC_DMA_RX_0 Audio Mixer MultiMedia15" value="1" />
     </path>
@@ -1332,6 +1389,10 @@
         <ctl name="RX_CDC_DMA_RX_0 Audio Mixer MultiMedia16" value="1" />
     </path>
 
+    <path name="compress-offload-playback9 headset">
+        <path name="compress-offload-playback9 headphones" />
+    </path>
+
     <path name="compress-offload-playback9 headphones-44.1">
         <ctl name="RX_CDC_DMA_RX_0 Audio Mixer MultiMedia16" value="1" />
     </path>
@@ -1381,6 +1442,10 @@
         <path name="audio-record bt-sco" />
     </path>
 
+    <path name="audio-record headset-mic">
+        <ctl name="MultiMedia1 Mixer TX_CDC_DMA_TX_4" value="1" />
+    </path>
+
     <path name="audio-record capture-fm">
         <ctl name="MultiMedia1 Mixer TERT_MI2S_TX" value="1" />
     </path>
@@ -1406,6 +1471,31 @@
         <ctl name="MultiMedia8 Mixer USB_AUDIO_TX" value="1" />
     </path>
 
+    <path name="audio-record-compress2">
+        <ctl name="MultiMedia17 Mixer TX_CDC_DMA_TX_3" value="1" />
+    </path>
+
+    <path name="audio-record-compress2 bt-sco">
+        <ctl name="MultiMedia17 Mixer SLIM_7_TX" value="1" />
+    </path>
+
+    <path name="audio-record-compress bt-sco-wb">
+        <ctl name="BT SampleRate" value="KHZ_16" />
+        <path name="audio-record-compress2 bt-sco" />
+    </path>
+
+    <path name="audio-record-compress2 bt-sco-swb">
+        <path name="audio-record-compress2 bt-sco" />
+    </path>
+
+    <path name="audio-record-compress2 usb-headset-mic">
+        <ctl name="MultiMedia17 Mixer USB_AUDIO_TX" value="1" />
+    </path>
+
+    <path name="audio-record-compress2 headset-mic">
+        <ctl name="MultiMedia17 Mixer TX_CDC_DMA_TX_4" value="1" />
+    </path>
+
     <path name="low-latency-record">
       <ctl name="MultiMedia8 Mixer TX_CDC_DMA_TX_3" value="1" />
     </path>
@@ -1447,6 +1537,10 @@
         <ctl name="RX_CDC_DMA_RX_0_DL_HL Switch" value="1" />
     </path>
 
+    <path name="play-fm headset">
+        <path name="play-fm headphones" />
+    </path>
+
     <path name="incall-rec-uplink">
         <ctl name="MultiMedia1 Mixer VOC_REC_UL" value="1" />
     </path>
@@ -1471,6 +1565,10 @@
         <path name="incall-rec-uplink" />
     </path>
 
+    <path name="incall-rec-uplink headset-mic">
+        <path name="incall-rec-uplink" />
+    </path>
+
     <path name="incall-rec-uplink-compress">
         <ctl name="MultiMedia8 Mixer VOC_REC_UL" value="1" />
     </path>
@@ -1495,6 +1593,10 @@
         <path name="incall-rec-uplink-compress" />
     </path>
 
+    <path name="incall-rec-uplink-compress headset-mic">
+        <path name="incall-rec-uplink-compress" />
+    </path>
+
     <path name="incall-rec-downlink">
         <ctl name="MultiMedia1 Mixer VOC_REC_DL"  value="1" />
     </path>
@@ -1519,6 +1621,10 @@
         <path name="incall-rec-downlink" />
     </path>
 
+    <path name="incall-rec-downlink headset-mic">
+        <path name="incall-rec-downlink" />
+    </path>
+
     <path name="incall-rec-downlink-compress">
         <ctl name="MultiMedia8 Mixer VOC_REC_DL" value="1" />
     </path>
@@ -1543,6 +1649,10 @@
         <path name="incall-rec-downlink-compress" />
     </path>
 
+    <path name="incall-rec-downlink-compress headset-mic">
+        <path name="incall-rec-downlink-compress" />
+    </path>
+
     <path name="incall-rec-uplink-and-downlink">
         <path name="incall-rec-uplink" />
         <path name="incall-rec-downlink" />
@@ -1568,6 +1678,10 @@
         <path name="incall-rec-uplink-and-downlink" />
     </path>
 
+    <path name="incall-rec-uplink-and-downlink headset-mic">
+        <path name="incall-rec-uplink-and-downlink" />
+    </path>
+
     <path name="incall-rec-uplink-and-downlink-compress">
         <path name="incall-rec-uplink-compress" />
         <path name="incall-rec-downlink-compress" />
@@ -1593,6 +1707,10 @@
         <path name="incall-rec-uplink-and-downlink-compress" />
     </path>
 
+    <path name="incall-rec-uplink-and-downlink-compress headset-mic">
+        <path name="incall-rec-uplink-and-downlink-compress" />
+    </path>
+
     <path name="hfp-sco">
     </path>
 
@@ -1662,6 +1780,11 @@
         <ctl name="VoiceMMode1_Tx Mixer TX_CDC_DMA_TX_3_MMode1" value="1" />
     </path>
 
+    <path name="voicemmode1-call headset">
+        <ctl name="RX_CDC_DMA_RX_0_Voice Mixer VoiceMMode1" value="1" />
+        <ctl name="VoiceMMode1_Tx Mixer TX_CDC_DMA_TX_4_MMode1" value="1" />
+    </path>
+
     <path name="voicemmode1-call bt-sco">
         <ctl name="SLIM_7_RX_Voice Mixer VoiceMMode1" value="1" />
         <ctl name="VoiceMMode1_Tx Mixer SLIM_7_TX_MMode1" value="1" />
@@ -1711,6 +1834,11 @@
         <ctl name="VoiceMMode2_Tx Mixer TX_CDC_DMA_TX_3_MMode2" value="1" />
     </path>
 
+    <path name="voicemmode2-call headset">
+        <ctl name="RX_CDC_DMA_RX_0_Voice Mixer VoiceMMode2" value="1" />
+        <ctl name="VoiceMMode2_Tx Mixer TX_CDC_DMA_TX_4_MMode2" value="1" />
+    </path>
+
     <path name="voicemmode2-call bt-sco">
         <ctl name="SLIM_7_RX_Voice Mixer VoiceMMode2" value="1" />
         <ctl name="VoiceMMode2_Tx Mixer SLIM_7_TX_MMode2" value="1" />
@@ -1819,6 +1947,10 @@
         <path name="audio-record-voip bt-sco" />
     </path>
 
+    <path name="audio-record-voip headset-mic">
+        <ctl name="MultiMedia10 Mixer TX_CDC_DMA_TX_4" value="1" />
+    </path>
+
     <path name="spkr-rx-calib">
         <ctl name="WSA_CDC_DMA_RX_0_DL_HL Switch"  value="1" />
     </path>
@@ -1828,10 +1960,10 @@
 
     <!-- These are actual sound device specific mixer settings -->
     <path name="amic2">
-        <ctl name="TX DEC0 MUX" value="SWR_MIC" />
-        <ctl name="TX SMIC MUX0" value="ADC1" />
-        <ctl name="TX_CDC_DMA_TX_3 Channels" value="One" />
-        <ctl name="TX_AIF1_CAP Mixer DEC0" value="1" />
+        <ctl name="TX DEC5 MUX" value="SWR_MIC" />
+        <ctl name="TX SMIC MUX5" value="ADC1" />
+        <ctl name="TX_CDC_DMA_TX_4 Channels" value="One" />
+        <ctl name="TX_AIF2_CAP Mixer DEC5" value="1" />
         <ctl name="ADC2_MIXER Switch" value="1" />
         <ctl name="ADC2 MUX" value="INP2" />
     </path>
@@ -2027,8 +2159,6 @@
         <ctl name="RX INT1_1 MIX1 INP0" value="RX1" />
         <ctl name="RX INT0 DEM MUX" value="CLSH_DSM_OUT" />
         <ctl name="RX INT1 DEM MUX" value="CLSH_DSM_OUT" />
-        <ctl name="RX_HPH_PWR_MODE" value="LOHIFI" />
-        <ctl name="RX HPH Mode" value="CLS_H_LOHIFI" />
         <ctl name="RX_COMP1 Switch" value="1" />
         <ctl name="RX_COMP2 Switch" value="1" />
         <ctl name="HPHL_COMP Switch" value="1" />
@@ -2056,7 +2186,6 @@
 
     <path name="headset-mic">
         <path name="amic2" />
-        <ctl name="TX_DEC0 Volume" value="84" />
     </path>
 
     <path name="headset-mic-liquid">
@@ -2113,6 +2242,10 @@
         <path name="headphones" />
     </path>
 
+    <path name="voice-headset">
+        <path name="headphones" />
+    </path>
+
     <path name="voice-line">
         <path name="voice-headphones" />
     </path>
@@ -2648,6 +2781,10 @@
        <ctl name="MultiMedia16 Mixer USB_AUDIO_TX" value="1" />
     </path>
 
+    <path name="mmap-record headset-mic">
+        <ctl name="MultiMedia16 Mixer TX_CDC_DMA_TX_4" value="1" />
+    </path>
+
     <path name="hifi-playback display-port">
         <ctl name="DISPLAY_PORT Mixer MultiMedia2" value="1" />
     </path>
@@ -2728,6 +2865,10 @@
         <path name="incall_music_uplink" />
     </path>
 
+    <path name="incall_music_uplink headset">
+        <path name="incall_music_uplink" />
+    </path>
+
     <path name="incall_music_uplink speaker-and-headphones">
         <path name="incall_music_uplink" />
     </path>
diff --git a/configs/kona/mixer_paths_cdp.xml b/configs/kona/mixer_paths_cdp.xml
new file mode 100644
index 0000000..67041e6
--- /dev/null
+++ b/configs/kona/mixer_paths_cdp.xml
@@ -0,0 +1,2916 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!-- Copyright (c) 2015-2019, 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 -->
+<!-- met:                                                                   -->
+<!--     * Redistributions of source code must retain the above copyright   -->
+<!--       notice, this list of conditions and the following disclaimer.    -->
+<!--     * Redistributions in binary form must reproduce the above          -->
+<!--       copyright notice, this list of conditions and the following      -->
+<!--       disclaimer in the documentation and/or other materials provided  -->
+<!--       with the distribution.                                           -->
+<!--     * Neither the name of The Linux Foundation nor the names of its    -->
+<!--       contributors may be used to endorse or promote products derived  -->
+<!--       from this software without specific prior written permission.    -->
+<!--                                                                        -->
+<!-- THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED           -->
+<!-- WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF   -->
+<!-- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT -->
+<!-- ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS -->
+<!-- BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -->
+<!-- CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF   -->
+<!-- SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR        -->
+<!-- BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,  -->
+<!-- WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE   -->
+<!-- OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -->
+<!-- IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.                          -->
+<mixer>
+    <!-- These are the initial mixer settings -->
+    <ctl name="Voice Rx Device Mute" id="0" value="0" />
+    <ctl name="Voice Rx Device Mute" id="1" value="-1" />
+    <ctl name="Voice Rx Device Mute" id="2" value="20" />
+    <ctl name="Voice Tx Mute" id="0" value="0" />
+    <ctl name="Voice Tx Mute" id="1" value="-1" />
+    <ctl name="Voice Tx Mute" id="2" value="500" />
+    <ctl name="Voice Rx Gain" id="0" value="0" />
+    <ctl name="Voice Rx Gain" id="1" value="-1" />
+    <ctl name="Voice Rx Gain" id="2" value="20" />
+    <ctl name="Voice Sidetone Enable" value="0" />
+    <ctl name="Voip Tx Mute" id="0" value="0" />
+    <ctl name="Voip Tx Mute" id="1" value="500" />
+    <ctl name="Voip Rx Gain" id="0" value="0" />
+    <ctl name="Voip Rx Gain" id="1" value="20" />
+    <ctl name="Voip Mode Config" value="12" />
+    <ctl name="Voip Rate Config" value="0" />
+    <ctl name="Voip Evrc Min Max Rate Config" id="0" value="1" />
+    <ctl name="Voip Evrc Min Max Rate Config" id="1" value="4" />
+    <ctl name="Voip Dtx Mode" value="0" />
+    <ctl name="TTY Mode" value="OFF" />
+    <ctl name="SLIMBUS_7_RX Audio Mixer MultiMedia1" value="0" />
+    <ctl name="SLIMBUS_7_RX Audio Mixer MultiMedia4" value="0" />
+    <ctl name="SLIMBUS_7_RX Audio Mixer MultiMedia5" value="0" />
+    <ctl name="SLIMBUS_7_RX Audio Mixer MultiMedia7" value="0" />
+    <ctl name="SLIMBUS_7_RX Audio Mixer MultiMedia8" value="0" />
+    <ctl name="SLIMBUS_7_RX Audio Mixer MultiMedia10" value="0" />
+    <ctl name="SLIMBUS_7_RX Audio Mixer MultiMedia11" value="0" />
+    <ctl name="SLIMBUS_7_RX Audio Mixer MultiMedia12" value="0" />
+    <ctl name="SLIMBUS_7_RX Audio Mixer MultiMedia13" value="0" />
+    <ctl name="SLIMBUS_7_RX Audio Mixer MultiMedia14" value="0" />
+    <ctl name="SLIMBUS_7_RX Audio Mixer MultiMedia15" value="0" />
+    <ctl name="SLIMBUS_7_RX Audio Mixer MultiMedia16" value="0" />
+    <ctl name="MultiMedia5 Mixer AFE_PCM_TX" value="0" />
+    <ctl name="MultiMedia5 Mixer TX_CDC_DMA_TX_3" value="0" />
+    <ctl name="MultiMedia1 Mixer TX_CDC_DMA_TX_3" value="0" />
+    <ctl name="MultiMedia1 Mixer TX_CDC_DMA_TX_4" value="0" />
+    <ctl name="MultiMedia1 Mixer SLIM_7_TX" value="0" />
+    <ctl name="MultiMedia8 Mixer SLIM_7_TX" value="0" />
+    <ctl name="MultiMedia10 Mixer TX_CDC_DMA_TX_3" value="0" />
+    <ctl name="MultiMedia10 Mixer TX_CDC_DMA_TX_4" value="0" />
+    <ctl name="MultiMedia10 Mixer SLIM_7_TX" value="0" />
+    <ctl name="MultiMedia10 Mixer AFE_PCM_TX" value="0" />
+    <ctl name="MultiMedia17 Mixer TX_CDC_DMA_TX_3" value="0" />
+    <ctl name="MultiMedia17 Mixer TX_CDC_DMA_TX_4" value="0" />
+    <ctl name="MultiMedia17 Mixer SLIM_7_TX" value="0" />
+    <ctl name="DISPLAY_PORT Mixer MultiMedia1" value="0" />
+    <ctl name="DISPLAY_PORT Mixer MultiMedia2" value="0" />
+    <ctl name="DISPLAY_PORT Mixer MultiMedia3" value="0" />
+    <ctl name="DISPLAY_PORT Mixer MultiMedia4" value="0" />
+    <ctl name="DISPLAY_PORT Mixer MultiMedia5" value="0" />
+    <ctl name="DISPLAY_PORT Mixer MultiMedia6" value="0" />
+    <ctl name="DISPLAY_PORT Mixer MultiMedia7" value="0" />
+    <ctl name="DISPLAY_PORT Mixer MultiMedia8" value="0" />
+    <ctl name="DISPLAY_PORT Mixer MultiMedia9" value="0" />
+    <ctl name="DISPLAY_PORT Mixer MultiMedia10" value="0" />
+    <ctl name="DISPLAY_PORT Mixer MultiMedia11" value="0" />
+    <ctl name="DISPLAY_PORT Mixer MultiMedia12" value="0" />
+    <ctl name="DISPLAY_PORT Mixer MultiMedia13" value="0" />
+    <ctl name="DISPLAY_PORT Mixer MultiMedia14" value="0" />
+    <ctl name="DISPLAY_PORT Mixer MultiMedia15" value="0" />
+    <ctl name="DISPLAY_PORT Mixer MultiMedia16" value="0" />
+    <ctl name="WSA_CDC_DMA_RX_0 Audio Mixer MultiMedia1" value="0" />
+    <ctl name="WSA_CDC_DMA_RX_0 Audio Mixer MultiMedia2" value="0" />
+    <ctl name="WSA_CDC_DMA_RX_0 Audio Mixer MultiMedia3" value="0" />
+    <ctl name="WSA_CDC_DMA_RX_0 Audio Mixer MultiMedia4" value="0" />
+    <ctl name="WSA_CDC_DMA_RX_0 Audio Mixer MultiMedia5" value="0" />
+    <ctl name="WSA_CDC_DMA_RX_0 Audio Mixer MultiMedia7" value="0" />
+    <ctl name="WSA_CDC_DMA_RX_0 Audio Mixer MultiMedia8" value="0" />
+    <ctl name="WSA_CDC_DMA_RX_0 Audio Mixer MultiMedia10" value="0" />
+    <ctl name="WSA_CDC_DMA_RX_0 Audio Mixer MultiMedia11" value="0" />
+    <ctl name="WSA_CDC_DMA_RX_0 Audio Mixer MultiMedia12" value="0" />
+    <ctl name="WSA_CDC_DMA_RX_0 Audio Mixer MultiMedia13" value="0" />
+    <ctl name="WSA_CDC_DMA_RX_0 Audio Mixer MultiMedia14" value="0" />
+    <ctl name="WSA_CDC_DMA_RX_0 Audio Mixer MultiMedia15" value="0" />
+    <ctl name="RX_CDC_DMA_RX_0 Audio Mixer MultiMedia16" value="0" />
+    <ctl name="RX_CDC_DMA_RX_0 Audio Mixer MultiMedia1" value="0" />
+    <ctl name="RX_CDC_DMA_RX_0 Audio Mixer MultiMedia2" value="0" />
+    <ctl name="RX_CDC_DMA_RX_0 Audio Mixer MultiMedia3" value="0" />
+    <ctl name="RX_CDC_DMA_RX_0 Audio Mixer MultiMedia4" value="0" />
+    <ctl name="RX_CDC_DMA_RX_0 Audio Mixer MultiMedia5" value="0" />
+    <ctl name="RX_CDC_DMA_RX_0 Audio Mixer MultiMedia7" value="0" />
+    <ctl name="RX_CDC_DMA_RX_0 Audio Mixer MultiMedia8" value="0" />
+    <ctl name="RX_CDC_DMA_RX_0 Audio Mixer MultiMedia10" value="0" />
+    <ctl name="RX_CDC_DMA_RX_0 Audio Mixer MultiMedia11" value="0" />
+    <ctl name="RX_CDC_DMA_RX_0 Audio Mixer MultiMedia12" value="0" />
+    <ctl name="RX_CDC_DMA_RX_0 Audio Mixer MultiMedia13" value="0" />
+    <ctl name="RX_CDC_DMA_RX_0 Audio Mixer MultiMedia14" value="0" />
+    <ctl name="RX_CDC_DMA_RX_0 Audio Mixer MultiMedia15" value="0" />
+    <ctl name="RX_CDC_DMA_RX_0 Audio Mixer MultiMedia16" value="0" />
+    <ctl name="USB_AUDIO_RX Audio Mixer MultiMedia1" value="0" />
+    <ctl name="USB_AUDIO_RX Audio Mixer MultiMedia2" value="0" />
+    <ctl name="USB_AUDIO_RX Audio Mixer MultiMedia3" value="0" />
+    <ctl name="USB_AUDIO_RX Audio Mixer MultiMedia4" value="0" />
+    <ctl name="USB_AUDIO_RX Audio Mixer MultiMedia5" value="0" />
+    <ctl name="USB_AUDIO_RX Audio Mixer MultiMedia7" value="0" />
+    <ctl name="USB_AUDIO_RX Audio Mixer MultiMedia8" value="0" />
+    <ctl name="USB_AUDIO_RX Audio Mixer MultiMedia10" value="0" />
+    <ctl name="USB_AUDIO_RX Audio Mixer MultiMedia11" value="0" />
+    <ctl name="USB_AUDIO_RX Audio Mixer MultiMedia12" value="0" />
+    <ctl name="USB_AUDIO_RX Audio Mixer MultiMedia13" value="0" />
+    <ctl name="USB_AUDIO_RX Audio Mixer MultiMedia14" value="0" />
+    <ctl name="USB_AUDIO_RX Audio Mixer MultiMedia15" value="0" />
+    <ctl name="USB_AUDIO_RX Audio Mixer MultiMedia16" value="0" />
+    <ctl name="MultiMedia1 Mixer USB_AUDIO_TX" value="0" />
+    <ctl name="MultiMedia2 Mixer USB_AUDIO_TX" value="0" />
+    <ctl name="MultiMedia5 Mixer USB_AUDIO_TX" value="0" />
+    <ctl name="MultiMedia8 Mixer USB_AUDIO_TX" value="0" />
+    <ctl name="MultiMedia10 Mixer USB_AUDIO_TX" value="0" />
+    <ctl name="MultiMedia17 Mixer USB_AUDIO_TX" value="0" />
+    <ctl name="TX_CDC_DMA_TX_3 Channels" value="One" />
+    <ctl name="WSA_CDC_DMA_RX_0 Channels" value="One" />
+    <ctl name="RX_CDC_DMA_RX_0 Channels" value="One" />
+    <ctl name="VI_FEED_TX Channels" value="Two" />
+    <ctl name="WSA_AIF_VI Mixer WSA_SPKR_VI_1" value="0" />
+    <ctl name="WSA_AIF_VI Mixer WSA_SPKR_VI_2" value="0" />
+    <ctl name="WSA_CDC_DMA_RX_0 Format" value="UNPACKED" />
+    <ctl name="WSA_CDC_DMA_TX_0 Format" value="UNPACKED" />
+    <ctl name="RX_CDC_DMA_RX_0 Format" value="UNPACKED" />
+    <ctl name="TX_CDC_DMA_TX_3 Format" value="UNPACKED" />
+    <!-- HFP start -->
+    <ctl name="HFP_SLIM7_UL_HL Switch" value="0" />
+    <ctl name="WSA_CDC_DMA_RX_0 Port Mixer SLIM_7_TX" value="0" />
+    <ctl name="RX_CDC_DMA_RX_0 Port Mixer SLIM_7_TX" value="0" />
+    <!-- HFP end -->
+    <!-- echo reference -->
+    <ctl name="AUDIO_REF_EC_UL1 MUX" value="None" />
+    <!-- usb headset -->
+    <ctl name="AFE_PCM_RX Audio Mixer MultiMedia1" value="0" />
+    <ctl name="AFE_PCM_RX Audio Mixer MultiMedia2" value="0" />
+    <ctl name="AFE_PCM_RX Audio Mixer MultiMedia4" value="0" />
+    <ctl name="AFE_PCM_RX Audio Mixer MultiMedia7" value="0" />
+    <ctl name="AFE_PCM_RX Audio Mixer MultiMedia10" value="0" />
+    <ctl name="AFE_PCM_RX Audio Mixer MultiMedia11" value="0" />
+    <ctl name="AFE_PCM_RX Audio Mixer MultiMedia12" value="0" />
+    <ctl name="AFE_PCM_RX Audio Mixer MultiMedia13" value="0" />
+    <ctl name="AFE_PCM_RX Audio Mixer MultiMedia14" value="0" />
+    <ctl name="AFE_PCM_RX Audio Mixer MultiMedia15" value="0" />
+    <ctl name="AFE_PCM_RX Audio Mixer MultiMedia16" value="0" />
+    <ctl name="MultiMedia1 Mixer AFE_PCM_TX" value="0" />
+    <ctl name="AFE_PCM_RX Audio Mixer MultiMedia5" value="0" />
+    <!-- usb headset end -->
+    <!-- fm -->
+    <ctl name="Tert MI2S LOOPBACK Volume" value="0" />
+    <ctl name="WSA_CDC_DMA_RX_0 Port Mixer TERT_MI2S_TX" value="0" />
+    <ctl name="WSA_CDC_DMA_RX_0_DL_HL Switch" value="0" />
+    <ctl name="RX_CDC_DMA_RX_0 Port Mixer TERT_MI2S_TX" value="0" />
+    <ctl name="RX_CDC_DMA_RX_0_DL_HL Switch" value="0" />
+    <ctl name="MultiMedia1 Mixer TERT_MI2S_TX" value="0" />
+    <ctl name="MultiMedia2 Mixer TERT_MI2S_TX" value="0" />
+    <!-- fm end -->
+
+    <!-- Multimode Voice1 -->
+    <ctl name="WSA_CDC_DMA_RX_0_Voice Mixer VoiceMMode1" value="0" />
+    <ctl name="RX_CDC_DMA_RX_0_Voice Mixer VoiceMMode1" value="0" />
+    <ctl name="VoiceMMode1_Tx Mixer TX_CDC_DMA_TX_3_MMode1" value="0" />
+    <ctl name="VoiceMMode1_Tx Mixer TX_CDC_DMA_TX_4_MMode1" value="0" />
+    <!-- Multimode Voice1 BTSCO -->
+    <ctl name="SLIM_7_RX_Voice Mixer VoiceMMode1" value="0" />
+    <ctl name="VoiceMMode1_Tx Mixer SLIM_7_TX_MMode1" value="0" />
+    <!-- Multimode Voice1 USB headset -->
+    <ctl name="AFE_PCM_RX_Voice Mixer VoiceMMode1" value="0" />
+    <ctl name="VoiceMMode1_Tx Mixer AFE_PCM_TX_MMode1" value="0" />
+    <ctl name="USB_AUDIO_RX_Voice Mixer VoiceMMode1" value="0" />
+    <ctl name="VoiceMMode1_Tx Mixer USB_AUDIO_TX_MMode1" value="0" />
+    <!-- Multimode Voice1 Display-Port -->
+    <ctl name="DISPLAY_PORT_RX_Voice Mixer VoiceMMode1" value="0" />
+    <!-- Miltimode Voice1 end-->
+
+    <!-- Multimode Voice2 -->
+    <ctl name="WSA_CDC_DMA_RX_0_Voice Mixer VoiceMMode2" value="0" />
+    <ctl name="RX_CDC_DMA_RX_0_Voice Mixer VoiceMMode2" value="0" />
+    <ctl name="VoiceMMode1_Tx Mixer TX_CDC_DMA_TX_3_MMode2" value="0" />
+    <ctl name="VoiceMMode1_Tx Mixer TX_CDC_DMA_TX_4_MMode2" value="0" />
+    <!-- Multimode Voice2 BTSCO -->
+    <ctl name="SLIM_7_RX_Voice Mixer VoiceMMode2" value="0" />
+    <ctl name="VoiceMMode2_Tx Mixer SLIM_7_TX_MMode2" value="0" />
+    <!-- Multimode Voice2 USB headset -->
+    <ctl name="AFE_PCM_RX_Voice Mixer VoiceMMode2" value="0" />
+    <ctl name="VoiceMMode2_Tx Mixer AFE_PCM_TX_MMode2" value="0" />
+    <ctl name="USB_AUDIO_RX_Voice Mixer VoiceMMode2" value="0" />
+    <ctl name="VoiceMMode2_Tx Mixer USB_AUDIO_TX_MMode2" value="0" />
+    <!-- Multimode Voice2 Display-Port -->
+    <ctl name="DISPLAY_PORT_RX_Voice Mixer VoiceMMode2" value="0" />
+    <!-- Multimode Voice2 end-->
+
+    <!-- Voice external ec. reference -->
+    <ctl name="VOC_EXT_EC MUX" value="NONE" />
+    <!-- Voice external ec. reference end -->
+
+    <!-- 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" />
+    <!-- RT Proxy Cal end -->
+
+    <!-- Incall Recording -->
+    <ctl name="MultiMedia1 Mixer VOC_REC_UL" value="0" />
+    <ctl name="MultiMedia1 Mixer VOC_REC_DL" value="0" />
+    <ctl name="MultiMedia8 Mixer VOC_REC_UL" value="0" />
+    <ctl name="MultiMedia8 Mixer VOC_REC_DL" value="0" />
+    <!-- Incall Recording End -->
+
+    <!-- Incall Music -->
+    <ctl name="Incall_Music Audio Mixer MultiMedia2" value="0" />
+    <ctl name="Incall_Music Audio Mixer MultiMedia9" value="0" />
+    <!-- Incall Music End -->
+
+    <!-- compress-voip-call start -->
+    <ctl name="WSA_CDC_DMA_RX_0_Voice Mixer Voip" value="0" />
+    <ctl name="RX_CDC_DMA_RX_0_Voice Mixer Voip" value="0" />
+    <ctl name="Voip_Tx Mixer TX_CDC_DMA_TX_3_Voip" value="0" />
+    <ctl name="SLIM_7_RX_Voice Mixer Voip" value="0" />
+    <ctl name="Voip_Tx Mixer SLIM_7_TX_Voip" value="0" />
+    <ctl name="AFE_PCM_RX_Voice Mixer Voip" value="0" />
+    <ctl name="Voip_Tx Mixer AFE_PCM_TX_Voip" value="0" />
+    <ctl name="USB_AUDIO_RX_Voice Mixer Voip" value="0" />
+    <ctl name="Voip_Tx Mixer USB_AUDIO_TX_Voip" value="0" />
+    <!-- compress-voip-call end-->
+
+    <!-- Audio BTSCO -->
+    <ctl name="SLIMBUS_7_RX Audio Mixer MultiMedia1" value="0" />
+    <ctl name="SLIMBUS_7_RX Audio Mixer MultiMedia4" value="0" />
+    <ctl name="SLIMBUS_7_RX Audio Mixer MultiMedia5" value="0" />
+    <ctl name="SLIMBUS_7_RX Audio Mixer MultiMedia6" value="0" />
+    <ctl name="MultiMedia1 Mixer SLIM_7_TX" value="0" />
+    <!-- audio record compress-->
+    <ctl name="MultiMedia8 Mixer TX_CDC_DMA_TX_3" value="0" />
+    <ctl name="MultiMedia8 Mixer SLIM_7_TX" value="0" />
+    <ctl name="MultiMedia8 Mixer AFE_PCM_TX" value="0" />
+    <!-- audio record compress end-->
+
+    <!-- split a2dp -->
+    <ctl name="BT SampleRate" value="KHZ_8" />
+    <ctl name="AFE Input Channels" value="Zero" />
+    <ctl name="SLIM7_RX ADM Channels" value="Zero" />
+    <!-- split a2dp end-->
+
+    <!-- ADSP testfwk -->
+    <ctl name="WSA_CDC_DMA_RX_0_DL_HL Switch" value="0" />
+    <ctl name="RX_CDC_DMA_RX_0_DL_HL Switch" value="0" />
+    <!-- ADSP testfwk end-->
+
+    <ctl name="AFE_PCM_RX Audio Mixer MultiMedia3" value="0" />
+
+    <!-- Codec controls -->
+    <!-- WSA controls -->
+    <ctl name="WSA RX0 MUX" value="ZERO" />
+    <ctl name="WSA RX1 MUX" value="ZERO" />
+    <ctl name="WSA_RX0 INP0" value="ZERO" />
+    <ctl name="WSA_RX1 INP0" value="ZERO" />
+    <ctl name="WSA_AIF_VI Mixer WSA_SPKR_VI_1" value="0" />
+    <ctl name="WSA_AIF_VI Mixer WSA_SPKR_VI_2" value="0" />
+    <ctl name="WSA_RX_0_VI_FB_LCH_MUX" value="ZERO" />
+    <ctl name="WSA_RX_0_VI_FB_RCH_MUX" value="ZERO" />
+    <ctl name="SpkrLeft COMP Switch" value="0" />
+    <ctl name="SpkrRight COMP Switch" value="0" />
+    <ctl name="SpkrLeft BOOST Switch" value="0" />
+    <ctl name="SpkrRight BOOST Switch" value="0" />
+    <ctl name="SpkrLeft VISENSE Switch" value="0" />
+    <ctl name="SpkrRight VISENSE Switch" value="0" />
+    <ctl name="SpkrLeft SWR DAC_Port Switch" value="0" />
+    <ctl name="SpkrRight SWR DAC_Port Switch" value="0" />
+
+    <!-- RX Controls -->
+    <ctl name="RX_MACRO RX0 MUX" value="ZERO" />
+    <ctl name="RX_MACRO RX1 MUX" value="ZERO" />
+    <ctl name="RX_CDC_DMA_RX_0 Channels" value="One" />
+    <ctl name="RX INT0_1 MIX1 INP0" value="ZERO" />
+    <ctl name="RX INT0_1 MIX1 INP1" value="ZERO" />
+    <ctl name="RX INT0_1 MIX1 INP2" value="ZERO" />
+    <ctl name="RX INT1_1 MIX1 INP0" value="ZERO" />
+    <ctl name="RX INT1_1 MIX1 INP1" value="ZERO" />
+    <ctl name="RX INT1_1 MIX1 INP2" value="ZERO" />
+    <ctl name="RX_CDC_DMA_RX_0 Audio Mixer MultiMedia1" value="0" />
+    <ctl name="RX INT0 DEM MUX" value="NORMAL_DSM_OUT" />
+    <ctl name="RX INT1 DEM MUX" value="NORMAL_DSM_OUT" />
+    <ctl name="RX_COMP1 Switch" value="0" />
+    <ctl name="RX_COMP2 Switch" value="0" />
+    <ctl name="HPHL_COMP Switch" value="0" />
+    <ctl name="HPHR_COMP Switch" value="0" />
+    <ctl name="EAR_RDAC Switch" value="0" />
+    <ctl name="HPHL_RDAC Switch" value="0" />
+    <ctl name="HPHR_RDAC Switch" value="0" />
+    <ctl name="AUX_RDAC Switch" value="0" />
+    <ctl name="RDAC3_MUX" value="ZERO" />
+    <ctl name="RX_EAR Mode" value="OFF" />
+
+    <!-- TX Controls -->
+    <ctl name="TX_CDC_DMA_TX_3 Channels" value="One" />
+    <ctl name="MultiMedia1 Mixer TX_CDC_DMA_TX_3" value="0" />
+    <ctl name="ADC1_MIXER Switch" value="0" />
+    <ctl name="ADC2_MIXER Switch" value="0" />
+    <ctl name="ADC2 MUX" value="ZERO" />
+    <ctl name="ADC3_MIXER Switch" value="0" />
+    <ctl name="ADC3 MUX" value="ZERO" />
+    <ctl name="ADC4_MIXER Switch" value="0" />
+    <ctl name="ADC4 MUX" value="ZERO" />
+    <ctl name="TX_AIF1_CAP Mixer DEC0" value="0" />
+    <ctl name="TX_AIF1_CAP Mixer DEC1" value="0" />
+    <ctl name="TX_AIF1_CAP Mixer DEC2" value="0" />
+    <ctl name="TX_AIF1_CAP Mixer DEC3" value="0" />
+    <ctl name="TX_AIF1_CAP Mixer DEC4" value="0" />
+    <ctl name="TX_AIF1_CAP Mixer DEC5" value="0" />
+    <ctl name="TX_AIF1_CAP Mixer DEC6" value="0" />
+    <ctl name="TX_AIF1_CAP Mixer DEC7" value="0" />
+    <ctl name="TX DEC0 MUX" value="MSM_DMIC" />
+    <ctl name="TX DMIC MUX0" value="ZERO" />
+    <ctl name="TX SMIC MUX0" value="ZERO" />
+    <ctl name="TX DEC1 MUX" value="MSM_DMIC" />
+    <ctl name="TX DMIC MUX1" value="ZERO" />
+    <ctl name="TX SMIC MUX1" value="ZERO" />
+    <ctl name="TX DEC2 MUX" value="MSM_DMIC" />
+    <ctl name="TX DMIC MUX2" value="ZERO" />
+    <ctl name="TX SMIC MUX2" value="ZERO" />
+    <ctl name="TX DEC3 MUX" value="MSM_DMIC" />
+    <ctl name="TX DMIC MUX3" value="ZERO" />
+    <ctl name="TX SMIC MUX3" value="ZERO" />
+    <ctl name="TX DEC4 MUX" value="MSM_DMIC" />
+    <ctl name="TX DMIC MUX4" value="ZERO" />
+    <ctl name="TX SMIC MUX4" value="ZERO" />
+    <ctl name="TX DEC5 MUX" value="MSM_DMIC" />
+    <ctl name="TX DMIC MUX5" value="ZERO" />
+    <ctl name="TX SMIC MUX5" value="ZERO" />
+    <ctl name="TX DEC6 MUX" value="MSM_DMIC" />
+    <ctl name="TX DMIC MUX6" value="ZERO" />
+    <ctl name="TX SMIC MUX6" value="ZERO" />
+    <ctl name="TX DEC7 MUX" value="MSM_DMIC" />
+    <ctl name="TX DMIC MUX7" value="ZERO" />
+    <ctl name="TX SMIC MUX7" value="ZERO" />
+
+    <!-- Volume controls -->
+    <ctl name="WSA_RX0 Digital Volume" value="84" />
+    <ctl name="WSA_RX1 Digital Volume" value="84" />
+    <ctl name="RX_RX0 Digital Volume" value="84" />
+    <ctl name="RX_RX1 Digital Volume" value="84" />
+    <ctl name="RX_RX2 Digital Volume" value="84" />
+    <ctl name="HPHL Volume" value="20" />
+    <ctl name="HPHR Volume" value="20" />
+    <ctl name="EAR SPKR PA Gain" value="G_DEFAULT" />
+
+    <ctl name="TX_DEC0 Volume" value="102" />
+    <ctl name="TX_DEC1 Volume" value="102" />
+    <ctl name="TX_DEC2 Volume" value="102" />
+    <ctl name="TX_DEC3 Volume" value="102" />
+    <ctl name="TX_DEC4 Volume" value="84" />
+    <ctl name="TX_DEC5 Volume" value="84" />
+    <ctl name="TX_DEC6 Volume" value="84" />
+    <ctl name="TX_DEC7 Volume" value="84" />
+
+    <ctl name="ADC1 Volume" value="12" />
+    <ctl name="ADC2 Volume" value="12" />
+    <ctl name="ADC3 Volume" value="12" />
+
+    <!-- Compander controls -->
+    <ctl name="WSA_COMP1 Switch" value="0" />
+    <ctl name="WSA_COMP2 Switch" value="0" />
+    <ctl name="COMP7 Switch" value="0" />
+    <ctl name="COMP8 Switch" value="0" />
+
+    <!-- Headphone class-H mode -->
+    <ctl name="RX_HPH_PWR_MODE" value="ULP" />
+    <ctl name="RX HPH Mode" value="CLS_H_ULP" />
+
+    <!-- IIR/voice anc -->
+    <ctl name="IIR0 Band1" id ="0" value="268435456" />
+    <ctl name="IIR0 Band1" id ="1" value="0" />
+    <ctl name="IIR0 Band1" id ="2" value="0" />
+    <ctl name="IIR0 Band1" id ="3" value="0" />
+    <ctl name="IIR0 Band1" id ="4" value="0" />
+    <ctl name="IIR0 Band2" id ="0" value="268435456" />
+    <ctl name="IIR0 Band2" id ="1" value="0" />
+    <ctl name="IIR0 Band2" id ="2" value="0" />
+    <ctl name="IIR0 Band2" id ="3" value="0" />
+    <ctl name="IIR0 Band2" id ="4" value="0" />
+    <ctl name="IIR0 Band3" id ="0" value="268435456" />
+    <ctl name="IIR0 Band3" id ="1" value="0" />
+    <ctl name="IIR0 Band3" id ="2" value="0" />
+    <ctl name="IIR0 Band3" id ="3" value="0" />
+    <ctl name="IIR0 Band3" id ="4" value="0" />
+    <ctl name="IIR0 Band4" id ="0" value="268435456" />
+    <ctl name="IIR0 Band4" id ="1" value="0" />
+    <ctl name="IIR0 Band4" id ="2" value="0" />
+    <ctl name="IIR0 Band4" id ="3" value="0" />
+    <ctl name="IIR0 Band4" id ="4" value="0" />
+    <ctl name="IIR0 Band5" id ="0" value="268435456" />
+    <ctl name="IIR0 Band5" id ="1" value="0" />
+    <ctl name="IIR0 Band5" id ="2" value="0" />
+    <ctl name="IIR0 Band5" id ="3" value="0" />
+    <ctl name="IIR0 Band5" id ="4" value="0" />
+    <ctl name="IIR0 Enable Band1" value="0" />
+    <ctl name="IIR0 Enable Band2" value="0" />
+    <ctl name="IIR0 Enable Band3" value="0" />
+    <ctl name="IIR0 Enable Band4" value="0" />
+    <ctl name="IIR0 Enable Band5" value="0" />
+    <ctl name="IIR0 INP0 Volume" value="54" />
+    <ctl name="IIR0 INP0 MUX" value="ZERO" />
+    <ctl name="IIR0 INP1 MUX" value="ZERO" />
+    <ctl name="IIR0 INP2 MUX" value="ZERO" />
+    <ctl name="IIR0 INP3 MUX" value="ZERO" />
+
+    <!-- vbat related data -->
+    <ctl name="GSM mode Enable" value="OFF" />
+    <ctl name="WSA_Softclip0 Enable" value="0" />
+    <ctl name="WSA_Softclip1 Enable" value="0" />
+    <ctl name="WSA_RX INT0 VBAT WSA RX0 VBAT Enable" value="0" />
+    <ctl name="WSA_RX INT1 VBAT WSA RX1 VBAT Enable" value="0" />
+
+    <!-- Codec controls end -->
+
+    <!-- defaults for mmap record -->
+    <ctl name="MultiMedia16 Mixer TX_CDC_DMA_TX_3" value="0" />
+    <ctl name="MultiMedia16 Mixer TX_CDC_DMA_TX_4" value="0" />
+    <ctl name="MultiMedia16 Mixer SLIM_7_TX" value="0" />
+    <ctl name="MultiMedia16 Mixer TERT_MI2S_TX" value="0" />
+    <ctl name="MultiMedia16 Mixer USB_AUDIO_TX" value="0" />
+
+    <!-- These are audio route (FE to BE) specific mixer settings -->
+    <path name="gsm-mode">
+        <ctl name="GSM mode Enable" value="ON" />
+    </path>
+
+    <path name="echo-reference">
+        <ctl name="AUDIO_REF_EC_UL1 MUX" value="WSA_CDC_DMA_RX_0" />
+    </path>
+
+    <path name="echo-reference headphones">
+        <ctl name="AUDIO_REF_EC_UL1 MUX" value="RX_CDC_DMA_RX_0" />
+    </path>
+
+    <path name="echo-reference headset">
+        <path name="echo-reference headphones" />
+    </path>
+
+    <path name="echo-reference display-port">
+        <ctl name="AUDIO_REF_EC_UL1 MUX" value="DISPLAY_PORT" />
+    </path>
+
+    <path name="echo-reference headphones-44.1">
+        <ctl name="AUDIO_REF_EC_UL1 MUX" value="RX_CDC_DMA_RX_0" />
+    </path>
+
+    <path name="echo-reference-voip">
+        <ctl name="AUDIO_REF_EC_UL10 MUX" value="WSA_CDC_DMA_RX_0" />
+    </path>
+
+    <path name="echo-reference-voip headphones">
+        <ctl name="AUDIO_REF_EC_UL10 MUX" value="RX_CDC_DMA_RX_0" />
+    </path>
+
+    <path name="deep-buffer-playback">
+        <ctl name="WSA_CDC_DMA_RX_0 Audio Mixer MultiMedia1" value="1" />
+    </path>
+
+    <path name="deep-buffer-playback speaker-protected">
+        <path name="deep-buffer-playback" />
+    </path>
+
+    <path name="deep-buffer-playback display-port">
+        <ctl name="DISPLAY_PORT Mixer MultiMedia1" value="1" />
+    </path>
+
+    <path name="deep-buffer-playback speaker-and-display-port">
+        <path name="deep-buffer-playback display-port" />
+        <path name="deep-buffer-playback" />
+    </path>
+
+    <path name="deep-buffer-playback bt-sco">
+        <ctl name="SLIMBUS_7_RX Audio Mixer MultiMedia1" value="1" />
+    </path>
+
+    <path name="deep-buffer-playback bt-sco-wb">
+        <ctl name="BT SampleRate" value="KHZ_16" />
+        <path name="deep-buffer-playback bt-sco" />
+    </path>
+
+    <path name="deep-buffer-playback bt-sco-swb">
+        <path name="deep-buffer-playback bt-sco" />
+    </path>
+
+    <path name="deep-buffer-playback afe-proxy">
+        <ctl name="AFE_PCM_RX Audio Mixer MultiMedia1" value="1" />
+    </path>
+
+    <path name="deep-buffer-playback usb-headphones">
+        <ctl name="USB_AUDIO_RX Audio Mixer MultiMedia1" value="1" />
+    </path>
+
+    <path name="deep-buffer-playback usb-headset">
+        <ctl name="USB_AUDIO_RX Audio Mixer MultiMedia1" value="1" />
+    </path>
+
+    <path name="deep-buffer-playback speaker-and-usb-headphones">
+        <path name="deep-buffer-playback usb-headphones" />
+        <path name="deep-buffer-playback" />
+    </path>
+
+    <path name="deep-buffer-playback headphones">
+        <ctl name="RX_CDC_DMA_RX_0 Audio Mixer MultiMedia1" value="1" />
+    </path>
+
+    <path name="deep-buffer-playback headset">
+        <path name="deep-buffer-playback headphones" />
+    </path>
+
+    <path name="deep-buffer-playback speaker-and-headphones">
+        <path name="deep-buffer-playback headphones" />
+        <path name="deep-buffer-playback" />
+    </path>
+
+    <path name="deep-buffer-playback speaker-and-bt-sco">
+        <path name="deep-buffer-playback bt-sco" />
+        <path name="deep-buffer-playback" />
+    </path>
+
+    <path name="deep-buffer-playback speaker-and-bt-sco-wb">
+        <path name="deep-buffer-playback bt-sco-wb" />
+        <path name="deep-buffer-playback" />
+    </path>
+
+    <path name="deep-buffer-playback speaker-and-bt-sco-swb">
+        <path name="deep-buffer-playback bt-sco-swb" />
+        <path name="deep-buffer-playback" />
+    </path>
+
+    <path name="low-latency-playback">
+        <ctl name="WSA_CDC_DMA_RX_0 Audio Mixer MultiMedia5" value="1" />
+    </path>
+
+    <path name="low-latency-playback speaker-protected">
+        <path name="low-latency-playback" />
+    </path>
+
+    <path name="low-latency-playback display-port">
+        <ctl name="DISPLAY_PORT Mixer MultiMedia5" value="1" />
+    </path>
+
+    <path name="low-latency-playback bt-sco">
+        <ctl name="SLIMBUS_7_RX Audio Mixer MultiMedia5" value="1" />
+    </path>
+
+    <path name="low-latency-playback bt-sco-wb">
+        <ctl name="BT SampleRate" value="KHZ_16" />
+        <path name="low-latency-playback bt-sco" />
+    </path>
+
+    <path name="low-latency-playback bt-sco-swb">
+        <path name="low-latency-playback bt-sco" />
+    </path>
+
+    <path name="low-latency-playback speaker-and-display-port">
+        <path name="low-latency-playback display-port" />
+        <path name="low-latency-playback" />
+    </path>
+
+    <path name="low-latency-playback afe-proxy">
+        <ctl name="AFE_PCM_RX Audio Mixer MultiMedia5" value="1" />
+    </path>
+
+    <path name="low-latency-playback usb-headphones">
+        <ctl name="USB_AUDIO_RX Audio Mixer MultiMedia5" value="1" />
+    </path>
+
+    <path name="low-latency-playback usb-headset">
+        <ctl name="USB_AUDIO_RX Audio Mixer MultiMedia5" value="1" />
+    </path>
+
+    <path name="low-latency-playback speaker-and-usb-headphones">
+        <path name="low-latency-playback usb-headphones" />
+        <path name="low-latency-playback" />
+    </path>
+
+    <path name="low-latency-playback headphones">
+        <ctl name="RX_CDC_DMA_RX_0 Audio Mixer MultiMedia5" value="1" />
+    </path>
+
+    <path name="low-latency-playback headset">
+        <path name="low-latency-playback headphones" />
+    </path>
+
+    <path name="low-latency-playback speaker-and-headphones">
+        <path name="low-latency-playback headphones" />
+        <path name="low-latency-playback" />
+    </path>
+    <path name="low-latency-playback resume">
+        <ctl name="MultiMedia5_RX QOS Vote" value="Enable" />
+    </path>
+
+    <path name="low-latency-playback speaker-and-bt-sco">
+        <path name="low-latency-playback bt-sco" />
+        <path name="low-latency-playback" />
+    </path>
+
+    <path name="low-latency-playback speaker-and-bt-sco-wb">
+        <path name="low-latency-playback bt-sco-wb" />
+        <path name="low-latency-playback" />
+    </path>
+
+    <path name="low-latency-playback speaker-and-bt-sco-swb">
+        <path name="low-latency-playback bt-sco-swb" />
+        <path name="low-latency-playback" />
+    </path>
+
+    <path name="audio-ull-playback">
+        <ctl name="WSA_CDC_DMA_RX_0 Audio Mixer MultiMedia8" value="1" />
+    </path>
+
+    <path name="audio-ull-playback speaker-protected">
+        <path name="audio-ull-playback" />
+    </path>
+
+    <path name="audio-ull-playback headphones">
+        <ctl name="RX_CDC_DMA_RX_0 Audio Mixer MultiMedia8" value="1" />
+    </path>
+
+    <path name="audio-ull-playback headset">
+        <path name="audio-ull-playback headphones" />
+    </path>
+
+    <path name="audio-ull-playback speaker-and-headphones">
+        <path name="audio-ull-playback" />
+        <path name="audio-ull-playback headphones" />
+    </path>
+
+    <path name="audio-ull-playback display-port">
+        <ctl name="DISPLAY_PORT Mixer MultiMedia8" value="1" />
+    </path>
+
+    <path name="audio-ull-playback bt-sco">
+        <ctl name="SLIMBUS_7_RX Audio Mixer MultiMedia8" value="1" />
+    </path>
+
+    <path name="audio-ull-playback bt-sco-wb">
+        <ctl name="BT SampleRate" value="KHZ_16" />
+        <path name="audio-ull-playback bt-sco" />
+    </path>
+
+    <path name="audio-ull-playback bt-sco-swb">
+        <path name="audio-ull-playback bt-sco" />
+    </path>
+
+    <path name="audio-ull-playback speaker-and-display-port">
+        <path name="audio-ull-playback display-port" />
+        <path name="audio-ull-playback" />
+    </path>
+
+    <path name="audio-ull-playback afe-proxy">
+        <ctl name="AFE_PCM_RX Audio Mixer MultiMedia8" value="1" />
+    </path>
+
+    <path name="audio-ull-playback usb-headphones">
+        <ctl name="USB_AUDIO_RX Audio Mixer MultiMedia8" value="1" />
+    </path>
+
+    <path name="audio-ull-playback usb-headset">
+        <ctl name="USB_AUDIO_RX Audio Mixer MultiMedia8" value="1" />
+    </path>
+
+    <path name="audio-ull-playback speaker-and-bt-sco">
+        <path name="audio-ull-playback bt-sco" />
+        <path name="audio-ull-playback" />
+    </path>
+
+    <path name="audio-ull-playback speaker-and-bt-sco-wb">
+        <path name="audio-ull-playback bt-sco-wb" />
+        <path name="audio-ull-playback" />
+    </path>
+
+    <path name="audio-ull-playback speaker-and-bt-sco-swb">
+        <path name="audio-ull-playback bt-sco-swb" />
+        <path name="audio-ull-playback" />
+    </path>
+
+    <path name="multi-channel-playback display-port">
+        <ctl name="DISPLAY_PORT Mixer MultiMedia2" value="1" />
+    </path>
+
+    <path name="multi-channel-playback afe-proxy">
+        <ctl name="AFE_PCM_RX Audio Mixer MultiMedia2" value="1" />
+    </path>
+
+    <path name="compress-offload-playback">
+        <ctl name="WSA_CDC_DMA_RX_0 Audio Mixer MultiMedia4" value="1" />
+    </path>
+
+    <path name="compress-offload-playback speaker-protected">
+        <path name="compress-offload-playback" />
+    </path>
+
+    <path name="compress-offload-playback display-port">
+        <ctl name="DISPLAY_PORT Mixer MultiMedia4" value="1" />
+    </path>
+
+    <path name="silence-playback display-port">
+        <ctl name="DISPLAY_PORT Mixer MultiMedia9" value="1" />
+    </path>
+
+    <path name="compress-offload-playback bt-sco">
+        <ctl name="SLIMBUS_7_RX Audio Mixer MultiMedia4" value="1" />
+    </path>
+
+    <path name="compress-offload-playback bt-sco-wb">
+        <ctl name="BT SampleRate" value="KHZ_16" />
+        <path name="compress-offload-playback bt-sco" />
+    </path>
+
+    <path name="compress-offload-playback bt-sco-swb">
+        <path name="compress-offload-playback bt-sco" />
+    </path>
+
+    <path name="compress-offload-playback speaker-and-display-port">
+        <path name="compress-offload-playback display-port" />
+        <path name="compress-offload-playback" />
+    </path>
+
+    <path name="compress-offload-playback afe-proxy">
+        <ctl name="AFE_PCM_RX Audio Mixer MultiMedia4" value="1" />
+    </path>
+
+    <path name="compress-offload-playback usb-headphones">
+        <ctl name="USB_AUDIO_RX Audio Mixer MultiMedia4" value="1" />
+    </path>
+
+    <path name="compress-offload-playback usb-headset">
+        <ctl name="USB_AUDIO_RX Audio Mixer MultiMedia4" value="1" />
+    </path>
+
+    <path name="compress-offload-playback speaker-and-usb-headphones">
+        <path name="compress-offload-playback usb-headphones" />
+        <path name="compress-offload-playback" />
+    </path>
+
+    <path name="compress-offload-playback headphones">
+        <ctl name="RX_CDC_DMA_RX_0 Audio Mixer MultiMedia4" value="1" />
+    </path>
+
+    <path name="compress-offload-playback headset">
+        <path name="compress-offload-playback headphones" />
+    </path>
+
+    <path name="compress-offload-playback headphones-44.1">
+        <ctl name="RX_CDC_DMA_RX_0 Audio Mixer MultiMedia4" value="1" />
+    </path>
+
+    <path name="compress-offload-playback headphones-dsd">
+        <ctl name="RX_CDC_DMA_RX_0 Audio Mixer MultiMedia4" value="1" />
+    </path>
+
+    <path name="compress-offload-playback speaker-and-headphones">
+        <path name="compress-offload-playback headphones" />
+        <path name="compress-offload-playback" />
+    </path>
+
+    <path name="compress-offload-playback speaker-and-bt-sco">
+        <path name="compress-offload-playback bt-sco" />
+        <path name="compress-offload-playback" />
+    </path>
+
+    <path name="compress-offload-playback speaker-and-bt-sco-wb">
+        <path name="compress-offload-playback bt-sco-wb" />
+        <path name="compress-offload-playback" />
+    </path>
+
+    <path name="compress-offload-playback speaker-and-bt-sco-swb">
+        <path name="compress-offload-playback bt-sco-swb" />
+        <path name="compress-offload-playback" />
+    </path>
+
+    <path name="compress-offload-playback2">
+        <ctl name="WSA_CDC_DMA_RX_0 Audio Mixer MultiMedia7" value="1" />
+    </path>
+
+    <path name="compress-offload-playback2 display-port">
+        <ctl name="DISPLAY_PORT Mixer MultiMedia7" value="1" />
+    </path>
+
+    <path name="compress-offload-playback2 bt-sco">
+        <ctl name="SLIMBUS_7_RX Audio Mixer MultiMedia7" value="1" />
+    </path>
+
+    <path name="compress-offload-playback2 bt-sco-wb">
+        <ctl name="BT SampleRate" value="KHZ_16" />
+        <path name="compress-offload-playback2 bt-sco" />
+    </path>
+
+    <path name="compress-offload-playback2 bt-sco-swb">
+        <path name="compress-offload-playback2 bt-sco" />
+    </path>
+
+    <path name="compress-offload-playback2 speaker-and-display-port">
+        <path name="compress-offload-playback2 display-port" />
+        <path name="compress-offload-playback2" />
+    </path>
+
+    <path name="compress-offload-playback2 afe-proxy">
+        <ctl name="AFE_PCM_RX Audio Mixer MultiMedia7" value="1" />
+    </path>
+
+    <path name="compress-offload-playback2 usb-headphones">
+        <ctl name="USB_AUDIO_RX Audio Mixer MultiMedia7" value="1" />
+    </path>
+
+    <path name="compress-offload-playback2 usb-headset">
+        <ctl name="USB_AUDIO_RX Audio Mixer MultiMedia7" value="1" />
+    </path>
+
+    <path name="compress-offload-playback2 speaker-and-usb-headphones">
+        <path name="compress-offload-playback2 usb-headphones" />
+        <path name="compress-offload-playback2" />
+    </path>
+
+    <path name="compress-offload-playback2 headphones">
+        <ctl name="RX_CDC_DMA_RX_0 Audio Mixer MultiMedia7" value="1" />
+    </path>
+
+    <path name="compress-offload-playback2 headset">
+        <path name="compress-offload-playback2 headphones" />
+    </path>
+
+    <path name="compress-offload-playback2 headphones-44.1">
+        <ctl name="RX_CDC_DMA_RX_0 Audio Mixer MultiMedia7" value="1" />
+
+    </path>
+
+    <path name="compress-offload-playback2 headphones-dsd">
+        <ctl name="RX_CDC_DMA_RX_0 Audio Mixer MultiMedia7" value="1" />
+    </path>
+
+    <path name="compress-offload-playback2 speaker-and-headphones">
+        <path name="compress-offload-playback2 headphones" />
+        <path name="compress-offload-playback2" />
+    </path>
+
+    <path name="compress-offload-playback2 speaker-and-bt-sco">
+        <path name="compress-offload-playback2 bt-sco" />
+        <path name="compress-offload-playback2" />
+    </path>
+
+    <path name="compress-offload-playback2 speaker-and-bt-sco-wb">
+        <path name="compress-offload-playback2 bt-sco-wb" />
+        <path name="compress-offload-playback2" />
+    </path>
+
+    <path name="compress-offload-playback2 speaker-and-bt-sco-swb">
+        <path name="compress-offload-playback2 bt-sco-swb" />
+        <path name="compress-offload-playback2" />
+    </path>
+
+    <path name="compress-offload-playback3">
+        <ctl name="WSA_CDC_DMA_RX_0 Audio Mixer MultiMedia10" value="1" />
+    </path>
+
+    <path name="compress-offload-playback3 display-port">
+        <ctl name="DISPLAY_PORT Mixer MultiMedia10" value="1" />
+    </path>
+
+    <path name="compress-offload-playback3 bt-sco">
+        <ctl name="SLIMBUS_7_RX Audio Mixer MultiMedia10" value="1" />
+    </path>
+
+    <path name="compress-offload-playback3 bt-sco-wb">
+        <ctl name="BT SampleRate" value="KHZ_16" />
+        <path name="compress-offload-playback3 bt-sco" />
+    </path>
+
+    <path name="compress-offload-playback3 bt-sco-swb">
+        <path name="compress-offload-playback3 bt-sco" />
+    </path>
+
+    <path name="compress-offload-playback3 speaker-and-display-port">
+        <path name="compress-offload-playback3 display-port" />
+        <path name="compress-offload-playback3" />
+    </path>
+
+    <path name="compress-offload-playback3 afe-proxy">
+        <ctl name="AFE_PCM_RX Audio Mixer MultiMedia10" value="1" />
+    </path>
+
+    <path name="compress-offload-playback3 usb-headphones">
+        <ctl name="USB_AUDIO_RX Audio Mixer MultiMedia10" value="1" />
+    </path>
+
+    <path name="compress-offload-playback3 usb-headset">
+        <ctl name="USB_AUDIO_RX Audio Mixer MultiMedia10" value="1" />
+    </path>
+
+    <path name="compress-offload-playback3 speaker-and-usb-headphones">
+        <path name="compress-offload-playback3 usb-headphones" />
+        <path name="compress-offload-playback3" />
+    </path>
+
+    <path name="compress-offload-playback3 headphones">
+        <ctl name="RX_CDC_DMA_RX_0 Audio Mixer MultiMedia10" value="1" />
+    </path>
+
+    <path name="compress-offload-playback3 headset">
+        <path name="compress-offload-playback3 headphones" />
+    </path>
+
+    <path name="compress-offload-playback3 headphones-44.1">
+        <ctl name="RX_CDC_DMA_RX_0 Audio Mixer MultiMedia10" value="1" />
+    </path>
+
+    <path name="compress-offload-playback3 headphones-dsd">
+        <ctl name="RX_CDC_DMA_RX_0 Audio Mixer MultiMedia10" value="1" />
+    </path>
+
+    <path name="compress-offload-playback3 speaker-and-headphones">
+        <path name="compress-offload-playback3 headphones" />
+        <path name="compress-offload-playback3" />
+    </path>
+
+    <path name="compress-offload-playback3 speaker-and-bt-sco">
+        <path name="compress-offload-playback3 bt-sco" />
+        <path name="compress-offload-playback3" />
+    </path>
+
+    <path name="compress-offload-playback3 speaker-and-bt-sco-wb">
+        <path name="compress-offload-playback3 bt-sco-wb" />
+        <path name="compress-offload-playback3" />
+    </path>
+
+    <path name="compress-offload-playback3 speaker-and-bt-sco-swb">
+        <path name="compress-offload-playback3 bt-sco-swb" />
+        <path name="compress-offload-playback3" />
+    </path>
+
+    <path name="compress-offload-playback4">
+        <ctl name="WSA_CDC_DMA_RX_0 Audio Mixer MultiMedia11" value="1" />
+    </path>
+
+    <path name="compress-offload-playback4 display-port">
+        <ctl name="DISPLAY_PORT Mixer MultiMedia11" value="1" />
+    </path>
+
+    <path name="compress-offload-playback4 bt-sco">
+        <ctl name="SLIMBUS_7_RX Audio Mixer MultiMedia11" value="1" />
+    </path>
+
+    <path name="compress-offload-playback4 bt-sco-wb">
+        <ctl name="BT SampleRate" value="KHZ_16" />
+        <path name="compress-offload-playback4 bt-sco" />
+    </path>
+
+    <path name="compress-offload-playback4 bt-sco-swb">
+        <path name="compress-offload-playback4 bt-sco" />
+    </path>
+
+    <path name="compress-offload-playback4 speaker-and-display-port">
+        <path name="compress-offload-playback4 display-port" />
+        <path name="compress-offload-playback4" />
+    </path>
+
+
+    <path name="compress-offload-playback4 afe-proxy">
+        <ctl name="AFE_PCM_RX Audio Mixer MultiMedia11" value="1" />
+    </path>
+
+    <path name="compress-offload-playback4 usb-headphones">
+        <ctl name="USB_AUDIO_RX Audio Mixer MultiMedia11" value="1" />
+    </path>
+
+    <path name="compress-offload-playback4 usb-headset">
+        <ctl name="USB_AUDIO_RX Audio Mixer MultiMedia11" value="1" />
+    </path>
+
+    <path name="compress-offload-playback4 speaker-and-usb-headphones">
+        <path name="compress-offload-playback4 usb-headphones" />
+        <path name="compress-offload-playback4" />
+    </path>
+
+    <path name="compress-offload-playback4 headphones">
+        <ctl name="RX_CDC_DMA_RX_0 Audio Mixer MultiMedia11" value="1" />
+    </path>
+
+    <path name="compress-offload-playback4 headset">
+        <path name="compress-offload-playback4 headphones" />
+    </path>
+
+    <path name="compress-offload-playback4 headphones-44.1">
+        <ctl name="RX_CDC_DMA_RX_0 Audio Mixer MultiMedia11" value="1" />
+    </path>
+
+    <path name="compress-offload-playback4 headphones-dsd">
+        <ctl name="RX_CDC_DMA_RX_0 Audio Mixer MultiMedia11" value="1" />
+    </path>
+
+    <path name="compress-offload-playback4 speaker-and-headphones">
+        <path name="compress-offload-playback4 headphones" />
+        <path name="compress-offload-playback4" />
+    </path>
+
+    <path name="compress-offload-playback4 speaker-and-bt-sco">
+        <path name="compress-offload-playback4 bt-sco" />
+        <path name="compress-offload-playback4" />
+    </path>
+
+    <path name="compress-offload-playback4 speaker-and-bt-sco-wb">
+        <path name="compress-offload-playback4 bt-sco-wb" />
+        <path name="compress-offload-playback4" />
+    </path>
+
+    <path name="compress-offload-playback4 speaker-and-bt-sco-swb">
+        <path name="compress-offload-playback4 bt-sco-swb" />
+        <path name="compress-offload-playback4" />
+    </path>
+
+    <path name="compress-offload-playback5">
+        <ctl name="WSA_CDC_DMA_RX_0 Audio Mixer MultiMedia12" value="1" />
+    </path>
+
+    <path name="compress-offload-playback5 display-port">
+        <ctl name="DISPLAY_PORT Mixer MultiMedia12" value="1" />
+    </path>
+
+    <path name="compress-offload-playback5 bt-sco">
+        <ctl name="SLIMBUS_7_RX Audio Mixer MultiMedia12" value="1" />
+    </path>
+
+    <path name="compress-offload-playback5 bt-sco-wb">
+        <ctl name="BT SampleRate" value="KHZ_16" />
+        <path name="compress-offload-playback5 bt-sco" />
+    </path>
+
+    <path name="compress-offload-playback5 bt-sco-swb">
+        <path name="compress-offload-playback5 bt-sco" />
+    </path>
+
+    <path name="compress-offload-playback5 speaker-and-display-port">
+        <path name="compress-offload-playback5 display-port" />
+        <path name="compress-offload-playback5" />
+    </path>
+
+    <path name="compress-offload-playback5 afe-proxy">
+        <ctl name="AFE_PCM_RX Audio Mixer MultiMedia12" value="1" />
+    </path>
+
+    <path name="compress-offload-playback5 usb-headphones">
+        <ctl name="USB_AUDIO_RX Audio Mixer MultiMedia12" value="1" />
+    </path>
+
+    <path name="compress-offload-playback5 usb-headset">
+        <ctl name="USB_AUDIO_RX Audio Mixer MultiMedia12" value="1" />
+    </path>
+
+    <path name="compress-offload-playback5 speaker-and-usb-headphones">
+        <path name="compress-offload-playback5 usb-headphones" />
+        <path name="compress-offload-playback5" />
+    </path>
+
+    <path name="compress-offload-playback5 headphones">
+        <ctl name="RX_CDC_DMA_RX_0 Audio Mixer MultiMedia12" value="1" />
+    </path>
+
+    <path name="compress-offload-playback5 headset">
+        <path name="compress-offload-playback5 headphones" />
+    </path>
+
+    <path name="compress-offload-playback5 headphones-44.1">
+        <ctl name="RX_CDC_DMA_RX_0 Audio Mixer MultiMedia12" value="1" />
+    </path>
+
+    <path name="compress-offload-playback5 headphones-dsd">
+        <ctl name="RX_CDC_DMA_RX_0 Audio Mixer MultiMedia12" value="1" />
+    </path>
+
+    <path name="compress-offload-playback5 speaker-and-headphones">
+        <path name="compress-offload-playback5 headphones" />
+        <path name="compress-offload-playback5" />
+    </path>
+
+    <path name="compress-offload-playback5 speaker-and-bt-sco">
+        <path name="compress-offload-playback5 bt-sco" />
+        <path name="compress-offload-playback5" />
+    </path>
+
+    <path name="compress-offload-playback5 speaker-and-bt-sco-wb">
+        <path name="compress-offload-playback5 bt-sco-wb" />
+        <path name="compress-offload-playback5" />
+    </path>
+
+    <path name="compress-offload-playback5 speaker-and-bt-sco-swb">
+        <path name="compress-offload-playback5 bt-sco-swb" />
+        <path name="compress-offload-playback5" />
+    </path>
+
+    <path name="compress-offload-playback6">
+        <ctl name="WSA_CDC_DMA_RX_0 Audio Mixer MultiMedia13" value="1" />
+    </path>
+
+    <path name="compress-offload-playback6 display-port">
+        <ctl name="DISPLAY_PORT Mixer MultiMedia13" value="1" />
+    </path>
+
+    <path name="compress-offload-playback6 bt-sco">
+        <ctl name="SLIMBUS_7_RX Audio Mixer MultiMedia13" value="1" />
+    </path>
+
+    <path name="compress-offload-playback6 bt-sco-wb">
+        <ctl name="BT SampleRate" value="KHZ_16" />
+        <path name="compress-offload-playback6 bt-sco" />
+    </path>
+
+    <path name="compress-offload-playback6 bt-sco-swb">
+        <path name="compress-offload-playback6 bt-sco" />
+    </path>
+
+    <path name="compress-offload-playback6 speaker-and-display-port">
+        <path name="compress-offload-playback6 display-port" />
+        <path name="compress-offload-playback6" />
+    </path>
+
+    <path name="compress-offload-playback6 afe-proxy">
+        <ctl name="AFE_PCM_RX Audio Mixer MultiMedia13" value="1" />
+    </path>
+
+    <path name="compress-offload-playback6 usb-headphones">
+        <ctl name="USB_AUDIO_RX Audio Mixer MultiMedia13" value="1" />
+    </path>
+
+    <path name="compress-offload-playback6 usb-headset">
+        <ctl name="USB_AUDIO_RX Audio Mixer MultiMedia13" value="1" />
+    </path>
+
+    <path name="compress-offload-playback6 speaker-and-usb-headphones">
+        <path name="compress-offload-playback6 usb-headphones" />
+        <path name="compress-offload-playback6" />
+    </path>
+
+    <path name="compress-offload-playback6 headphones">
+        <ctl name="RX_CDC_DMA_RX_0 Audio Mixer MultiMedia13" value="1" />
+    </path>
+
+    <path name="compress-offload-playback6 headset">
+        <path name="compress-offload-playback6 headphones" />
+    </path>
+
+    <path name="compress-offload-playback6 headphones-44.1">
+        <ctl name="RX_CDC_DMA_RX_0 Audio Mixer MultiMedia13" value="1" />
+    </path>
+
+    <path name="compress-offload-playback6 headphones-dsd">
+        <ctl name="RX_CDC_DMA_RX_0 Audio Mixer MultiMedia13" value="1" />
+    </path>
+
+    <path name="compress-offload-playback6 speaker-and-headphones">
+        <path name="compress-offload-playback6 headphones" />
+        <path name="compress-offload-playback6" />
+    </path>
+
+    <path name="compress-offload-playback6 speaker-and-bt-sco">
+        <path name="compress-offload-playback6 bt-sco" />
+        <path name="compress-offload-playback6" />
+    </path>
+
+    <path name="compress-offload-playback6 speaker-and-bt-sco-wb">
+        <path name="compress-offload-playback6 bt-sco-wb" />
+        <path name="compress-offload-playback6" />
+    </path>
+
+    <path name="compress-offload-playback6 speaker-and-bt-sco-swb">
+        <path name="compress-offload-playback6 bt-sco-swb" />
+        <path name="compress-offload-playback6" />
+    </path>
+
+    <path name="compress-offload-playback7">
+        <ctl name="WSA_CDC_DMA_RX_0 Audio Mixer MultiMedia14" value="1" />
+    </path>
+
+    <path name="compress-offload-playback7 display-port">
+        <ctl name="DISPLAY_PORT Mixer MultiMedia14" value="1" />
+    </path>
+
+    <path name="compress-offload-playback7 bt-sco">
+        <ctl name="SLIMBUS_7_RX Audio Mixer MultiMedia14" value="1" />
+    </path>
+
+    <path name="compress-offload-playback7 bt-sco-wb">
+        <ctl name="BT SampleRate" value="KHZ_16" />
+        <path name="compress-offload-playback7 bt-sco" />
+    </path>
+
+    <path name="compress-offload-playback7 bt-sco-swb">
+        <path name="compress-offload-playback7 bt-sco" />
+    </path>
+
+    <path name="compress-offload-playback7 speaker-and-display-port">
+        <path name="compress-offload-playback7 display-port" />
+        <path name="compress-offload-playback7" />
+    </path>
+
+    <path name="compress-offload-playback7 afe-proxy">
+        <ctl name="AFE_PCM_RX Audio Mixer MultiMedia14" value="1" />
+    </path>
+
+    <path name="compress-offload-playback7 usb-headphones">
+        <ctl name="USB_AUDIO_RX Audio Mixer MultiMedia14" value="1" />
+    </path>
+
+    <path name="compress-offload-playback7 usb-headset">
+        <ctl name="USB_AUDIO_RX Audio Mixer MultiMedia14" value="1" />
+    </path>
+
+    <path name="compress-offload-playback7 speaker-and-usb-headphones">
+        <path name="compress-offload-playback7 usb-headphones" />
+        <path name="compress-offload-playback7" />
+    </path>
+
+    <path name="compress-offload-playback7 headphones">
+        <ctl name="RX_CDC_DMA_RX_0 Audio Mixer MultiMedia14" value="1" />
+    </path>
+
+    <path name="compress-offload-playback7 headset">
+        <path name="compress-offload-playback7 headphones" />
+    </path>
+
+    <path name="compress-offload-playback7 headphones-44.1">
+        <ctl name="RX_CDC_DMA_RX_0 Audio Mixer MultiMedia14" value="1" />
+    </path>
+
+    <path name="compress-offload-playback7 headphones-dsd">
+        <ctl name="RX_CDC_DMA_RX_0 Audio Mixer MultiMedia14" value="1" />
+    </path>
+
+    <path name="compress-offload-playback7 speaker-and-headphones">
+        <path name="compress-offload-playback7 headphones" />
+        <path name="compress-offload-playback7" />
+    </path>
+
+    <path name="compress-offload-playback7 speaker-and-bt-sco">
+        <path name="compress-offload-playback7 bt-sco" />
+        <path name="compress-offload-playback7" />
+    </path>
+
+    <path name="compress-offload-playback7 speaker-and-bt-sco-wb">
+        <path name="compress-offload-playback7 bt-sco-wb" />
+        <path name="compress-offload-playback7" />
+    </path>
+
+    <path name="compress-offload-playback7 speaker-and-bt-sco-swb">
+        <path name="compress-offload-playback7 bt-sco-swb" />
+        <path name="compress-offload-playback7" />
+    </path>
+
+    <path name="compress-offload-playback8">
+        <ctl name="WSA_CDC_DMA_RX_0 Audio Mixer MultiMedia15" value="1" />
+    </path>
+
+    <path name="compress-offload-playback8 display-port">
+        <ctl name="DISPLAY_PORT Mixer MultiMedia15" value="1" />
+    </path>
+
+    <path name="compress-offload-playback8 bt-sco">
+        <ctl name="SLIMBUS_7_RX Audio Mixer MultiMedia15" value="1" />
+    </path>
+
+    <path name="compress-offload-playback8 bt-sco-wb">
+        <ctl name="BT SampleRate" value="KHZ_16" />
+        <path name="compress-offload-playback8 bt-sco" />
+    </path>
+
+    <path name="compress-offload-playback8 bt-sco-swb">
+        <path name="compress-offload-playback8 bt-sco" />
+    </path>
+
+    <path name="compress-offload-playback8 speaker-and-display-port">
+        <path name="compress-offload-playback8 display-port" />
+        <path name="compress-offload-playback8" />
+    </path>
+
+    <path name="compress-offload-playback8 afe-proxy">
+        <ctl name="AFE_PCM_RX Audio Mixer MultiMedia15" value="1" />
+    </path>
+
+    <path name="compress-offload-playback8 usb-headphones">
+        <ctl name="USB_AUDIO_RX Audio Mixer MultiMedia15" value="1" />
+    </path>
+
+    <path name="compress-offload-playback8 usb-headset">
+        <ctl name="USB_AUDIO_RX Audio Mixer MultiMedia15" value="1" />
+    </path>
+
+    <path name="compress-offload-playback8 speaker-and-usb-headphones">
+        <path name="compress-offload-playback8 usb-headphones" />
+        <path name="compress-offload-playback8" />
+    </path>
+
+    <path name="compress-offload-playback8 headphones">
+        <ctl name="RX_CDC_DMA_RX_0 Audio Mixer MultiMedia15" value="1" />
+    </path>
+
+    <path name="compress-offload-playback8 headset">
+        <path name="compress-offload-playback8 headphones" />
+    </path>
+
+    <path name="compress-offload-playback8 headphones-44.1">
+        <ctl name="RX_CDC_DMA_RX_0 Audio Mixer MultiMedia15" value="1" />
+    </path>
+
+    <path name="compress-offload-playback8 headphones-dsd">
+        <ctl name="RX_CDC_DMA_RX_0 Audio Mixer MultiMedia15" value="1" />
+    </path>
+
+    <path name="compress-offload-playback8 speaker-and-headphones">
+        <path name="compress-offload-playback8 headphones" />
+        <path name="compress-offload-playback8" />
+    </path>
+
+    <path name="compress-offload-playback8 speaker-and-bt-sco">
+        <path name="compress-offload-playback8 bt-sco" />
+        <path name="compress-offload-playback8" />
+    </path>
+
+    <path name="compress-offload-playback8 speaker-and-bt-sco-wb">
+        <path name="compress-offload-playback8 bt-sco-wb" />
+        <path name="compress-offload-playback8" />
+    </path>
+
+    <path name="compress-offload-playback8 speaker-and-bt-sco-swb">
+        <path name="compress-offload-playback8 bt-sco-swb" />
+        <path name="compress-offload-playback8" />
+    </path>
+
+    <path name="compress-offload-playback9">
+        <ctl name="WSA_CDC_DMA_RX_0 Audio Mixer MultiMedia16" value="1" />
+    </path>
+
+    <path name="compress-offload-playback9 display-port">
+        <ctl name="DISPLAY_PORT Mixer MultiMedia16" value="1" />
+    </path>
+
+    <path name="compress-offload-playback9 bt-sco">
+        <ctl name="SLIMBUS_7_RX Audio Mixer MultiMedia16" value="1" />
+    </path>
+
+    <path name="compress-offload-playback9 bt-sco-wb">
+        <ctl name="BT SampleRate" value="KHZ_16" />
+        <path name="compress-offload-playback9 bt-sco" />
+    </path>
+
+    <path name="compress-offload-playback9 bt-sco-swb">
+        <path name="compress-offload-playback9 bt-sco" />
+    </path>
+
+    <path name="compress-offload-playback9 speaker-and-display-port">
+        <path name="compress-offload-playback9 display-port" />
+        <path name="compress-offload-playback9" />
+    </path>
+
+    <path name="compress-offload-playback9 afe-proxy">
+        <ctl name="AFE_PCM_RX Audio Mixer MultiMedia16" value="1" />
+    </path>
+
+    <path name="compress-offload-playback9 usb-headphones">
+        <ctl name="USB_AUDIO_RX Audio Mixer MultiMedia16" value="1" />
+    </path>
+
+    <path name="compress-offload-playback9 usb-headset">
+        <ctl name="USB_AUDIO_RX Audio Mixer MultiMedia16" value="1" />
+    </path>
+
+    <path name="compress-offload-playback9 speaker-and-usb-headphones">
+        <path name="compress-offload-playback9 usb-headphones" />
+        <path name="compress-offload-playback9" />
+    </path>
+
+    <path name="compress-offload-playback9 headphones">
+        <ctl name="RX_CDC_DMA_RX_0 Audio Mixer MultiMedia16" value="1" />
+    </path>
+
+    <path name="compress-offload-playback9 headset">
+        <path name="compress-offload-playback9 headphones" />
+    </path>
+
+    <path name="compress-offload-playback9 headphones-44.1">
+        <ctl name="RX_CDC_DMA_RX_0 Audio Mixer MultiMedia16" value="1" />
+    </path>
+
+    <path name="compress-offload-playback9 headphones-dsd">
+        <ctl name="RX_CDC_DMA_RX_0 Audio Mixer MultiMedia16" value="1" />
+    </path>
+
+    <path name="compress-offload-playback9 speaker-and-headphones">
+        <path name="compress-offload-playback9 headphones" />
+        <path name="compress-offload-playback9" />
+    </path>
+
+    <path name="compress-offload-playback9 speaker-and-bt-sco">
+        <path name="compress-offload-playback9 bt-sco" />
+        <path name="compress-offload-playback9" />
+    </path>
+
+    <path name="compress-offload-playback9 speaker-and-bt-sco-wb">
+        <path name="compress-offload-playback9 bt-sco-wb" />
+        <path name="compress-offload-playback9" />
+    </path>
+
+    <path name="compress-offload-playback9 speaker-and-bt-sco-swb">
+        <path name="compress-offload-playback9 bt-sco-swb" />
+        <path name="compress-offload-playback9" />
+    </path>
+
+    <path name="audio-record">
+        <ctl name="MultiMedia1 Mixer TX_CDC_DMA_TX_3" value="1" />
+    </path>
+
+    <path name="audio-record usb-headset-mic">
+        <ctl name="MultiMedia1 Mixer USB_AUDIO_TX" value="1" />
+    </path>
+
+    <path name="audio-record bt-sco">
+        <ctl name="MultiMedia1 Mixer SLIM_7_TX" value="1" />
+    </path>
+
+    <path name="audio-record bt-sco-wb">
+        <ctl name="BT SampleRate" value="KHZ_16" />
+        <path name="audio-record bt-sco" />
+    </path>
+
+    <path name="audio-record bt-sco-swb">
+        <path name="audio-record bt-sco" />
+    </path>
+
+    <path name="audio-record headset-mic">
+        <ctl name="MultiMedia1 Mixer TX_CDC_DMA_TX_4" value="1" />
+    </path>
+
+    <path name="audio-record capture-fm">
+        <ctl name="MultiMedia1 Mixer TERT_MI2S_TX" value="1" />
+    </path>
+
+    <path name="audio-record-compress">
+        <ctl name="MultiMedia8 Mixer TX_CDC_DMA_TX_3" value="1" />
+    </path>
+
+    <path name="audio-record-compress bt-sco">
+        <ctl name="MultiMedia8 Mixer SLIM_7_TX" value="1" />
+    </path>
+
+    <path name="audio-record-compress bt-sco-wb">
+        <ctl name="BT SampleRate" value="KHZ_16" />
+        <path name="audio-record-compress bt-sco" />
+    </path>
+
+    <path name="audio-record-compress bt-sco-swb">
+        <path name="audio-record-compress bt-sco" />
+    </path>
+
+    <path name="audio-record-compress usb-headset-mic">
+        <ctl name="MultiMedia8 Mixer USB_AUDIO_TX" value="1" />
+    </path>
+
+    <path name="audio-record-compress2">
+        <ctl name="MultiMedia17 Mixer TX_CDC_DMA_TX_3" value="1" />
+    </path>
+
+    <path name="audio-record-compress2 bt-sco">
+        <ctl name="MultiMedia17 Mixer SLIM_7_TX" value="1" />
+    </path>
+
+    <path name="audio-record-compress bt-sco-wb">
+        <ctl name="BT SampleRate" value="KHZ_16" />
+        <path name="audio-record-compress2 bt-sco" />
+    </path>
+
+    <path name="audio-record-compress2 bt-sco-swb">
+        <path name="audio-record-compress2 bt-sco" />
+    </path>
+
+    <path name="audio-record-compress2 usb-headset-mic">
+        <ctl name="MultiMedia17 Mixer USB_AUDIO_TX" value="1" />
+    </path>
+
+    <path name="audio-record-compress2 headset-mic">
+        <ctl name="MultiMedia17 Mixer TX_CDC_DMA_TX_4" value="1" />
+    </path>
+
+    <path name="low-latency-record">
+      <ctl name="MultiMedia8 Mixer TX_CDC_DMA_TX_3" value="1" />
+    </path>
+
+    <path name="low-latency-record bt-sco">
+      <ctl name="MultiMedia8 Mixer SLIM_7_TX" value="1" />
+    </path>
+
+    <path name="low-latency-record bt-sco-wb">
+        <ctl name="BT SampleRate" value="KHZ_16" />
+        <path name="low-latency-record bt-sco" />
+    </path>
+
+    <path name="low-latency-record bt-sco-swb">
+        <path name="low-latency-record bt-sco" />
+    </path>
+
+    <path name="low-latency-record usb-headset-mic">
+        <ctl name="MultiMedia8 Mixer USB_AUDIO_TX" value="1" />
+    </path>
+
+    <path name="low-latency-record capture-fm">
+      <ctl name="MultiMedia8 Mixer TERT_MI2S_TX" value="1" />
+    </path>
+
+    <path name="fm-virtual-record capture-fm">
+        <ctl name="MultiMedia2 Mixer TERT_MI2S_TX" value="1" />
+    </path>
+
+    <path name="play-fm">
+        <ctl name="Tert MI2S LOOPBACK Volume" value="1" />
+        <ctl name="WSA_CDC_DMA_RX_0 Port Mixer TERT_MI2S_TX" value="1" />
+        <ctl name="WSA_CDC_DMA_RX_0_DL_HL Switch" value="1" />
+    </path>
+
+    <path name="play-fm headphones">
+        <ctl name="Tert MI2S LOOPBACK Volume" value="1" />
+        <ctl name="RX_CDC_DMA_RX_0 Port Mixer TERT_MI2S_TX" value="1" />
+        <ctl name="RX_CDC_DMA_RX_0_DL_HL Switch" value="1" />
+    </path>
+
+    <path name="play-fm headset">
+        <path name="play-fm headphones" />
+    </path>
+
+    <path name="incall-rec-uplink">
+        <ctl name="MultiMedia1 Mixer VOC_REC_UL" value="1" />
+    </path>
+
+    <path name="incall-rec-uplink bt-sco">
+        <path name="incall-rec-uplink" />
+    </path>
+
+    <path name="incall-rec-uplink bt-sco-wb">
+        <path name="incall-rec-uplink" />
+    </path>
+
+    <path name="incall-rec-uplink bt-sco-swb">
+        <path name="incall-rec-uplink" />
+    </path>
+
+    <path name="incall-rec-uplink usb-headset-mic">
+        <path name="incall-rec-uplink" />
+    </path>
+
+    <path name="incall-rec-uplink afe-proxy">
+        <path name="incall-rec-uplink" />
+    </path>
+
+    <path name="incall-rec-uplink headset-mic">
+        <path name="incall-rec-uplink" />
+    </path>
+
+    <path name="incall-rec-uplink-compress">
+        <ctl name="MultiMedia8 Mixer VOC_REC_UL" value="1" />
+    </path>
+
+    <path name="incall-rec-uplink-compress bt-sco">
+        <path name="incall-rec-uplink-compress" />
+    </path>
+
+    <path name="incall-rec-uplink-compress bt-sco-wb">
+        <path name="incall-rec-uplink-compress" />
+    </path>
+
+    <path name="incall-rec-uplink-compress bt-sco-swb">
+        <path name="incall-rec-uplink-compress" />
+    </path>
+
+    <path name="incall-rec-uplink-compress usb-headset-mic">
+        <path name="incall-rec-uplink-compress" />
+    </path>
+
+    <path name="incall-rec-uplink-compress afe-proxy">
+        <path name="incall-rec-uplink-compress" />
+    </path>
+
+    <path name="incall-rec-uplink-compress headset-mic">
+        <path name="incall-rec-uplink-compress" />
+    </path>
+
+    <path name="incall-rec-downlink">
+        <ctl name="MultiMedia1 Mixer VOC_REC_DL"  value="1" />
+    </path>
+
+    <path name="incall-rec-downlink bt-sco">
+        <path name="incall-rec-downlink" />
+    </path>
+
+    <path name="incall-rec-downlink bt-sco-wb">
+        <path name="incall-rec-downlink" />
+    </path>
+
+    <path name="incall-rec-downlink bt-sco-swb">
+        <path name="incall-rec-downlink" />
+    </path>
+
+    <path name="incall-rec-downlink usb-headset-mic">
+        <path name="incall-rec-downlink" />
+    </path>
+
+    <path name="incall-rec-downlink afe-proxy">
+        <path name="incall-rec-downlink" />
+    </path>
+
+    <path name="incall-rec-downlink headset-mic">
+        <path name="incall-rec-downlink" />
+    </path>
+
+    <path name="incall-rec-downlink-compress">
+        <ctl name="MultiMedia8 Mixer VOC_REC_DL" value="1" />
+    </path>
+
+    <path name="incall-rec-downlink-compress bt-sco">
+        <path name="incall-rec-downlink-compress" />
+    </path>
+
+    <path name="incall-rec-downlink-compress bt-sco-wb">
+        <path name="incall-rec-downlink-compress" />
+    </path>
+
+    <path name="incall-rec-downlink-compress bt-sco-swb">
+        <path name="incall-rec-downlink-compress" />
+    </path>
+
+    <path name="incall-rec-downlink-compress usb-headset-mic">
+        <path name="incall-rec-downlink-compress" />
+    </path>
+
+    <path name="incall-rec-downlink-compress afe-proxy">
+        <path name="incall-rec-downlink-compress" />
+    </path>
+
+    <path name="incall-rec-downlink-compress headset-mic">
+        <path name="incall-rec-downlink-compress" />
+    </path>
+
+    <path name="incall-rec-uplink-and-downlink">
+        <path name="incall-rec-uplink" />
+        <path name="incall-rec-downlink" />
+    </path>
+
+    <path name="incall-rec-uplink-and-downlink bt-sco">
+        <path name="incall-rec-uplink-and-downlink" />
+    </path>
+
+    <path name="incall-rec-uplink-and-downlink bt-sco-wb">
+        <path name="incall-rec-uplink-and-downlink" />
+    </path>
+
+    <path name="incall-rec-uplink-and-downlink bt-sco-swb">
+        <path name="incall-rec-uplink-and-downlink" />
+    </path>
+
+    <path name="incall-rec-uplink-and-downlink usb-headset-mic">
+        <path name="incall-rec-uplink-and-downlink" />
+    </path>
+
+    <path name="incall-rec-uplink-and-downlink afe-proxy">
+        <path name="incall-rec-uplink-and-downlink" />
+    </path>
+
+    <path name="incall-rec-uplink-and-downlink headset-mic">
+        <path name="incall-rec-uplink-and-downlink" />
+    </path>
+
+    <path name="incall-rec-uplink-and-downlink-compress">
+        <path name="incall-rec-uplink-compress" />
+        <path name="incall-rec-downlink-compress" />
+    </path>
+
+    <path name="incall-rec-uplink-and-downlink-compress bt-sco">
+        <path name="incall-rec-uplink-and-downlink-compress" />
+    </path>
+
+    <path name="incall-rec-uplink-and-downlink-compress bt-sco-wb">
+        <path name="incall-rec-uplink-and-downlink-compress" />
+    </path>
+
+    <path name="incall-rec-uplink-and-downlink-compress bt-sco-swb">
+        <path name="incall-rec-uplink-and-downlink-compress" />
+    </path>
+
+    <path name="incall-rec-uplink-and-downlink-compress usb-headset-mic">
+        <path name="incall-rec-uplink-and-downlink-compress" />
+    </path>
+
+    <path name="incall-rec-uplink-and-downlink-compress afe-proxy">
+        <path name="incall-rec-uplink-and-downlink-compress" />
+    </path>
+
+    <path name="incall-rec-uplink-and-downlink-compress headset-mic">
+        <path name="incall-rec-uplink-and-downlink-compress" />
+    </path>
+
+    <path name="hfp-sco">
+    </path>
+
+    <path name="hfp-sco headphones">
+    </path>
+
+   <path name="hfp-sco-wb">
+        <path name="hfp-sco" />
+   </path>
+
+    <path name="hfp-sco-wb headphones">
+        <path name="hfp-sco headphones" />
+    </path>
+
+    <path name="compress-voip-call">
+        <ctl name="WSA_CDC_DMA_RX_0_Voice Mixer Voip" value="1" />
+        <ctl name="Voip_Tx Mixer TX_CDC_DMA_TX_3_Voip" value="1" />
+    </path>
+
+    <path name="compress-voip-call bt-a2dp">
+        <ctl name="SLIM_7_RX_Voice Mixer Voip" value="1" />
+        <ctl name="Voip_Tx Mixer TX_CDC_DMA_TX_3_Voip" value="1" />
+    </path>
+
+    <path name="compress-voip-call headphones">
+        <ctl name="RX_CDC_DMA_RX_0_Voice Mixer Voip" value="1" />
+        <ctl name="Voip_Tx Mixer TX_CDC_DMA_TX_3_Voip" value="1" />
+    </path>
+
+
+    <path name="compress-voip-call bt-sco">
+        <ctl name="SLIM_7_RX_Voice Mixer Voip" value="1" />
+        <ctl name="Voip_Tx Mixer SLIM_7_TX_Voip" value="1" />
+    </path>
+
+    <path name="compress-voip-call bt-sco-wb">
+        <ctl name="BT SampleRate" value="KHZ_16" />
+        <path name="compress-voip-call bt-sco" />
+    </path>
+
+    <path name="compress-voip-call bt-sco-swb">
+        <path name="compress-voip-call bt-sco" />
+    </path>
+
+    <path name="compress-voip-call afe-proxy">
+        <ctl name="AFE_PCM_RX_Voice Mixer Voip" value="1" />
+        <ctl name="Voip_Tx Mixer AFE_PCM_TX_Voip" value="1" />
+    </path>
+
+    <path name="compress-voip-call usb-headphones">
+        <ctl name="USB_AUDIO_RX_Voice Mixer Voip" value="1" />
+        <ctl name="Voip_Tx Mixer TX_CDC_DMA_TX_3_Voip" value="1" />
+    </path>
+
+    <path name="compress-voip-call usb-headset">
+        <ctl name="USB_AUDIO_RX_Voice Mixer Voip" value="1" />
+        <ctl name="Voip_Tx Mixer USB_AUDIO_TX_Voip" value="1" />
+    </path>
+
+    <path name="voicemmode1-call">
+        <ctl name="WSA_CDC_DMA_RX_0_Voice Mixer VoiceMMode1" value="1" />
+        <ctl name="VoiceMMode1_Tx Mixer TX_CDC_DMA_TX_3_MMode1" value="1" />
+    </path>
+
+    <path name="voicemmode1-call headphones">
+        <ctl name="RX_CDC_DMA_RX_0_Voice Mixer VoiceMMode1" value="1" />
+        <ctl name="VoiceMMode1_Tx Mixer TX_CDC_DMA_TX_3_MMode1" value="1" />
+    </path>
+
+    <path name="voicemmode1-call headset">
+        <ctl name="RX_CDC_DMA_RX_0_Voice Mixer VoiceMMode1" value="1" />
+        <ctl name="VoiceMMode1_Tx Mixer TX_CDC_DMA_TX_4_MMode1" value="1" />
+    </path>
+
+    <path name="voicemmode1-call bt-sco">
+        <ctl name="SLIM_7_RX_Voice Mixer VoiceMMode1" value="1" />
+        <ctl name="VoiceMMode1_Tx Mixer SLIM_7_TX_MMode1" value="1" />
+    </path>
+
+    <path name="voicemmode1-call bt-sco-wb">
+        <ctl name="BT SampleRate" value="KHZ_16" />
+        <path name="voicemmode1-call bt-sco" />
+    </path>
+
+    <path name="voicemmode1-call bt-sco-swb">
+        <path name="voicemmode1-call bt-sco" />
+    </path>
+
+    <path name="voicemmode1-call afe-proxy">
+        <ctl name="AFE_PCM_RX_Voice Mixer VoiceMMode1" value="1" />
+        <ctl name="VoiceMMode1_Tx Mixer AFE_PCM_TX_MMode1" value="1" />
+    </path>
+
+    <path name="voicemmode1-call usb-headphones">
+        <ctl name="USB_AUDIO_RX_Voice Mixer VoiceMMode1" value="1" />
+        <ctl name="VoiceMMode1_Tx Mixer TX_CDC_DMA_TX_3_MMode1" value="1" />
+    </path>
+
+    <path name="voicemmode1-call usb-headset">
+        <ctl name="USB_AUDIO_RX_Voice Mixer VoiceMMode1" value="1" />
+        <ctl name="VoiceMMode1_Tx Mixer USB_AUDIO_TX_MMode1" value="1" />
+    </path>
+
+    <path name="voicemmode1-call display-port-and-usb-headset-mic">
+        <ctl name="DISPLAY_PORT_RX_Voice Mixer VoiceMMode1" value="1" />
+        <ctl name="VoiceMMode1_Tx Mixer USB_AUDIO_TX_MMode1" value="1" />
+    </path>
+
+    <path name="voicemmode1-call display-port">
+        <ctl name="DISPLAY_PORT_RX_Voice Mixer VoiceMMode1" value="1" />
+        <ctl name="VoiceMMode1_Tx Mixer TX_CDC_DMA_TX_3_MMode1" value="1" />
+    </path>
+
+    <path name="voicemmode2-call">
+        <ctl name="WSA_CDC_DMA_RX_0_Voice Mixer VoiceMMode2" value="1" />
+        <ctl name="VoiceMMode2_Tx Mixer TX_CDC_DMA_TX_3_MMode2" value="1" />
+    </path>
+
+    <path name="voicemmode2-call headphones">
+        <ctl name="RX_CDC_DMA_RX_0_Voice Mixer VoiceMMode2" value="1" />
+        <ctl name="VoiceMMode2_Tx Mixer TX_CDC_DMA_TX_3_MMode2" value="1" />
+    </path>
+
+    <path name="voicemmode2-call headset">
+        <ctl name="RX_CDC_DMA_RX_0_Voice Mixer VoiceMMode2" value="1" />
+        <ctl name="VoiceMMode2_Tx Mixer TX_CDC_DMA_TX_4_MMode2" value="1" />
+    </path>
+
+    <path name="voicemmode2-call bt-sco">
+        <ctl name="SLIM_7_RX_Voice Mixer VoiceMMode2" value="1" />
+        <ctl name="VoiceMMode2_Tx Mixer SLIM_7_TX_MMode2" value="1" />
+    </path>
+
+    <path name="voicemmode2-call bt-sco-wb">
+        <ctl name="BT SampleRate" value="KHZ_16" />
+        <path name="voicemmode2-call bt-sco" />
+    </path>
+
+    <path name="voicemmode2-call bt-sco-swb">
+        <path name="voicemmode2-call bt-sco" />
+    </path>
+
+    <path name="voicemmode2-call afe-proxy">
+        <ctl name="AFE_PCM_RX_Voice Mixer VoiceMMode2" value="1" />
+        <ctl name="VoiceMMode2_Tx Mixer AFE_PCM_TX_MMode2" value="1" />
+    </path>
+
+    <path name="voicemmode2-call usb-headphones">
+        <ctl name="USB_AUDIO_RX_Voice Mixer VoiceMMode2" value="1" />
+        <ctl name="VoiceMMode2_Tx Mixer TX_CDC_DMA_TX_3_MMode2" value="1" />
+    </path>
+
+    <path name="voicemmode2-call usb-headset">
+        <ctl name="USB_AUDIO_RX_Voice Mixer VoiceMMode2" value="1" />
+        <ctl name="VoiceMMode2_Tx Mixer USB_AUDIO_TX_MMode2" value="1" />
+    </path>
+
+    <path name="voicemmode2-call display-port-and-usb-headset-mic">
+        <ctl name="DISPLAY_PORT_RX_Voice Mixer VoiceMMode2" value="1" />
+        <ctl name="VoiceMMode2_Tx Mixer USB_AUDIO_TX_MMode2" value="1" />
+    </path>
+
+    <path name="voicemmode2-call display-port">
+        <ctl name="DISPLAY_PORT_RX_Voice Mixer VoiceMMode2" value="1" />
+        <ctl name="VoiceMMode2_Tx Mixer TX_CDC_DMA_TX_3_MMode2" value="1" />
+    </path>
+
+    <!-- VoIP Rx settings -->
+    <path name="audio-playback-voip">
+        <ctl name="WSA_CDC_DMA_RX_0 Audio Mixer MultiMedia10" value="1" />
+    </path>
+
+    <path name="audio-playback-voip headphones">
+        <ctl name="RX_CDC_DMA_RX_0 Audio Mixer MultiMedia10" value="1" />
+    </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">
+        <ctl name="BT SampleRate" value="KHZ_16" />
+        <path name="audio-playback-voip bt-sco" />
+    </path>
+
+    <path name="audio-playback-voip bt-sco-swb">
+        <path name="audio-playback-voip bt-sco" />
+    </path>
+
+    <path name="audio-playback-voip bt-a2dp">
+        <ctl name="SLIMBUS_7_RX Audio Mixer MultiMedia10" value="1" />
+    </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">
+        <ctl name="USB_AUDIO_RX Audio Mixer MultiMedia10" value="1" />
+    </path>
+
+    <path name="audio-playback-voip usb-headset">
+        <ctl name="USB_AUDIO_RX Audio Mixer MultiMedia10" value="1" />
+    </path>
+
+    <path name="audio-playback-voip display-port">
+        <ctl name="DISPLAY_PORT Mixer MultiMedia10" value="1" />
+    </path>
+
+    <path name="audio-playback-voip speaker-and-display-port">
+        <path name="audio-playback-voip display-port" />
+        <path name="audio-playback-voip" />
+    </path>
+
+    <!-- VoIP Tx settings -->
+    <path name="audio-record-voip">
+        <ctl name="MultiMedia10 Mixer TX_CDC_DMA_TX_3" value="1" />
+    </path>
+
+    <path name="audio-record-voip usb-headset-mic">
+        <ctl name="MultiMedia10 Mixer USB_AUDIO_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">
+        <ctl name="BT SampleRate" value="KHZ_16" />
+        <path name="audio-record-voip bt-sco" />
+    </path>
+
+    <path name="audio-record-voip bt-sco-swb">
+        <path name="audio-record-voip bt-sco" />
+    </path>
+
+    <path name="audio-record-voip headset-mic">
+        <ctl name="MultiMedia10 Mixer TX_CDC_DMA_TX_4" value="1" />
+    </path>
+
+    <path name="spkr-rx-calib">
+        <ctl name="WSA_CDC_DMA_RX_0_DL_HL Switch"  value="1" />
+    </path>
+
+    <path name="spkr-vi-record">
+    </path>
+
+    <!-- These are actual sound device specific mixer settings -->
+    <path name="amic1">
+        <ctl name="TX DEC1 MUX" value="SWR_MIC" />
+        <ctl name="TX SMIC MUX1" value="ADC0" />
+        <ctl name="TX_AIF1_CAP Mixer DEC1" value="1" />
+        <ctl name="ADC1_MIXER Switch" value="1" />
+    </path>
+
+    <path name="amic2">
+        <ctl name="TX DEC5 MUX" value="SWR_MIC" />
+        <ctl name="TX SMIC MUX5" value="ADC1" />
+        <ctl name="TX_CDC_DMA_TX_4 Channels" value="One" />
+        <ctl name="TX_AIF2_CAP Mixer DEC5" value="1" />
+        <ctl name="ADC2_MIXER Switch" value="1" />
+        <ctl name="ADC2 MUX" value="INP2" />
+    </path>
+
+    <path name="amic3">
+        <ctl name="TX DEC0 MUX" value="SWR_MIC" />
+        <ctl name="TX SMIC MUX0" value="ADC1" />
+        <ctl name="TX_AIF1_CAP Mixer DEC0" value="1" />
+        <ctl name="ADC2_MIXER Switch" value="1" />
+        <ctl name="ADC2 MUX" value="INP3" />
+    </path>
+
+    <path name="amic4">
+        <ctl name="TX DEC2 MUX" value="SWR_MIC" />
+        <ctl name="TX SMIC MUX2" value="ADC2" />
+        <ctl name="TX_AIF1_CAP Mixer DEC2" value="1" />
+        <ctl name="ADC3_MIXER Switch" value="1" />
+        <ctl name="ADC3 MUX" value="INP4" />
+    </path>
+
+    <path name="amic5">
+        <ctl name="TX DEC3 MUX" value="SWR_MIC" />
+        <ctl name="TX SMIC MUX3" value="ADC3" />
+        <ctl name="TX_AIF1_CAP Mixer DEC3" value="1" />
+        <ctl name="ADC4_MIXER Switch" value="1" />
+        <ctl name="ADC4 MUX" value="INP5" />
+    </path>
+
+    <path name="dmic1">
+        <ctl name="TX_CDC_DMA_TX_3 Channels" value="One" />
+        <ctl name="TX_AIF1_CAP Mixer DEC0" value="1" />
+        <ctl name="TX DMIC MUX0" value="DMIC0" />
+    </path>
+
+    <path name="dmic2">
+        <ctl name="TX_CDC_DMA_TX_3 Channels" value="One" />
+        <ctl name="TX_AIF1_CAP Mixer DEC0" value="1" />
+        <ctl name="TX DMIC MUX0" value="DMIC1" />
+    </path>
+
+    <path name="dmic3">
+        <ctl name="TX_CDC_DMA_TX_3 Channels" value="One" />
+        <ctl name="TX_AIF1_CAP Mixer DEC0" value="1" />
+        <ctl name="TX DMIC MUX0" value="DMIC2" />
+    </path>
+
+    <path name="dmic4">
+        <ctl name="TX_CDC_DMA_TX_3 Channels" value="One" />
+        <ctl name="TX_AIF1_CAP Mixer DEC0" value="1" />
+        <ctl name="TX DMIC MUX0" value="DMIC3" />
+    </path>
+
+    <path name="dmic5">
+        <ctl name="TX_CDC_DMA_TX_3 Channels" value="One" />
+        <ctl name="TX_AIF1_CAP Mixer DEC0" value="1" />
+        <ctl name="TX DMIC MUX0" value="DMIC4" />
+    </path>
+
+    <path name="dmic6">
+        <ctl name="TX_CDC_DMA_TX_3 Channels" value="One" />
+        <ctl name="TX_AIF1_CAP Mixer DEC0" value="1" />
+        <ctl name="TX DMIC MUX0" value="DMIC5" />
+    </path>
+
+    <path name="speaker">
+        <ctl name="WSA_CDC_DMA_RX_0 Channels" value="Two" />
+        <ctl name="WSA RX0 MUX" value="AIF1_PB" />
+        <ctl name="WSA RX1 MUX" value="AIF1_PB" />
+        <ctl name="WSA_RX0 INP0" value="RX0" />
+        <ctl name="WSA_RX1 INP0" value="RX1" />
+        <ctl name="WSA_COMP1 Switch" value="1" />
+        <ctl name="WSA_COMP2 Switch" value="1" />
+        <ctl name="SpkrLeft COMP Switch" value="1" />
+        <ctl name="SpkrLeft BOOST Switch" value="1" />
+        <ctl name="SpkrLeft VISENSE Switch" value="1" />
+        <ctl name="SpkrLeft SWR DAC_Port Switch" value="1" />
+        <ctl name="SpkrRight COMP Switch" value="1" />
+        <ctl name="SpkrRight BOOST Switch" value="1" />
+        <ctl name="SpkrRight VISENSE Switch" value="1" />
+        <ctl name="SpkrRight SWR DAC_Port Switch" value="1" />
+    </path>
+
+    <path name="speaker-mono">
+        <ctl name="WSA_CDC_DMA_RX_0 Channels" value="One" />
+        <ctl name="WSA RX0 MUX" value="AIF1_PB" />
+        <ctl name="WSA_RX0 INP0" value="RX0" />
+        <ctl name="WSA_COMP1 Switch" value="1" />
+        <ctl name="SpkrLeft COMP Switch" value="1" />
+        <ctl name="SpkrLeft BOOST Switch" value="1" />
+        <ctl name="SpkrLeft VISENSE Switch" value="1" />
+        <ctl name="SpkrLeft SWR DAC_Port Switch" value="1" />
+    </path>
+
+    <path name="speaker-mono-2">
+        <ctl name="WSA_CDC_DMA_RX_0 Channels" value="One" />
+        <ctl name="WSA RX1 MUX" value="AIF1_PB" />
+        <ctl name="WSA_RX1 INP0" value="RX1" />
+        <ctl name="WSA_COMP2 Switch" value="1" />
+        <ctl name="SpkrRight COMP Switch" value="1" />
+        <ctl name="SpkrRight BOOST Switch" value="1" />
+        <ctl name="SpkrRight VISENSE Switch" value="1" />
+        <ctl name="SpkrRight SWR DAC_Port Switch" value="1" />
+    </path>
+
+
+    <path name="speaker-hdk">
+        <path name="speaker-mono" />
+    </path>
+
+    <path name="speaker-fluid">
+        <path name="speaker-mono" />
+    </path>
+
+    <path name="speaker-liquid">
+        <path name="speaker" />
+    </path>
+
+   <path name="sidetone-iir">
+        <ctl name="IIR0 Enable Band1" value="1" />
+        <ctl name="IIR0 Enable Band2" value="1" />
+        <ctl name="IIR0 Enable Band3" value="1" />
+        <ctl name="IIR0 Enable Band4" value="1" />
+        <ctl name="IIR0 Enable Band5" value="1" />
+    </path>
+
+    <path name="sidetone-headphones">
+        <path name="sidetone-iir" />
+        <ctl name="IIR0 INP0 Volume" value="54" />
+        <ctl name="IIR0 INP0 MUX" value="DEC0" />
+        <ctl name="RX INT0 MIX2 INP" value="SRC0" />
+        <ctl name="RX INT1 MIX2 INP" value="SRC0" />
+    </path>
+
+    <path name="sidetone-handset">
+        <path name="sidetone-iir" />
+        <ctl name="IIR0 INP0 Volume" value="54" />
+        <ctl name="IIR0 INP0 MUX" value="DEC0" />
+        <ctl name="RX INT2 MIX2 INP" value="SRC0" />
+        <ctl name="WSA_RX0 INT0 SIDETONE MIX" value="SRC0" />
+    </path>
+
+    <path name="afe-sidetone">
+        <ctl name="Voice Sidetone Enable" value="1" />
+    </path>
+
+    <path name="speaker-mic">
+        <path name="dmic5" />
+    </path>
+
+    <path name="speaker-mic-liquid">
+        <path name="dmic5" />
+    </path>
+
+    <path name="speaker-mic-sbc">
+    </path>
+
+    <path name="speaker-protected">
+        <ctl name="WSA_AIF_VI Mixer WSA_SPKR_VI_1" value="1" />
+        <ctl name="WSA_AIF_VI Mixer WSA_SPKR_VI_2" value="1" />
+        <ctl name="WSA_CDC_DMA_0 TX Format" value="PACKED_16B" />
+        <path name="speaker" />
+        <ctl name="VI_FEED_TX Channels" value="Two" />
+        <ctl name="WSA_RX_0_VI_FB_LCH_MUX" value="WSA_CDC_DMA_TX_0" />
+        <ctl name="WSA_RX_0_VI_FB_RCH_MUX" value="WSA_CDC_DMA_TX_0" />
+    </path>
+
+    <path name="voice-speaker-protected">
+        <ctl name="WSA_AIF_VI Mixer WSA_SPKR_VI_1" value="1" />
+        <ctl name="WSA_CDC_DMA_0 TX Format" value="PACKED_16B" />
+        <path name="speaker-mono" />
+        <ctl name="VI_FEED_TX Channels" value="One" />
+        <ctl name="WSA_RX_0_VI_FB_LCH_MUX" value="WSA_CDC_DMA_TX_0" />
+    </path>
+
+    <path name="voice-speaker-2-protected">
+        <ctl name="WSA_AIF_VI Mixer WSA_SPKR_VI_2" value="1" />
+        <ctl name="WSA_CDC_DMA_0 TX Format" value="PACKED_16B" />
+        <path name="speaker-mono-2" />
+        <ctl name="VI_FEED_TX Channels" value="One" />
+        <ctl name="WSA_RX_0_VI_FB_RCH_MUX" value="WSA_CDC_DMA_TX_0" />
+    </path>
+
+    <path name="voice-speaker-stereo-protected">
+        <path name="speaker-protected" />
+    </path>
+
+    <path name="vi-feedback">
+    </path>
+
+    <path name="vi-feedback-mono-1">
+    </path>
+
+    <path name="vi-feedback-mono-2">
+    </path>
+
+    <path name="handset">
+        <ctl name="WSA_CDC_DMA_RX_0 Channels" value="One" />
+        <ctl name="WSA RX0 MUX" value="AIF1_PB" />
+        <ctl name="WSA_RX0 INP0" value="RX0" />
+        <ctl name="WSA_COMP1 Switch" value="1" />
+        <ctl name="SpkrLeft COMP Switch" value="1" />
+        <ctl name="SpkrLeft BOOST Switch" value="1" />
+        <ctl name="SpkrLeft VISENSE Switch" value="1" />
+        <ctl name="SpkrLeft SWR DAC_Port Switch" value="1" />
+        <ctl name="EAR SPKR PA Gain" value="G_6_DB" />
+    </path>
+
+    <path name="handset-mic">
+        <ctl name="TX_CDC_DMA_TX_3 Channels" value="One" />
+        <path name="amic5" />
+    </path>
+
+    <path name="headphones">
+        <ctl name="RX_MACRO RX0 MUX" value="AIF1_PB" />
+        <ctl name="RX_MACRO RX1 MUX" value="AIF1_PB" />
+        <ctl name="RX_CDC_DMA_RX_0 Channels" value="Two" />
+        <ctl name="RX INT0_1 MIX1 INP0" value="RX0" />
+        <ctl name="RX INT1_1 MIX1 INP0" value="RX1" />
+        <ctl name="RX INT0 DEM MUX" value="CLSH_DSM_OUT" />
+        <ctl name="RX INT1 DEM MUX" value="CLSH_DSM_OUT" />
+        <ctl name="RX_HPH_PWR_MODE" value="LOHIFI" />
+        <ctl name="RX HPH Mode" value="CLS_H_LOHIFI" />
+        <ctl name="RX_COMP1 Switch" value="1" />
+        <ctl name="RX_COMP2 Switch" value="1" />
+        <ctl name="HPHL_COMP Switch" value="1" />
+        <ctl name="HPHR_COMP Switch" value="1" />
+        <ctl name="HPHL_RDAC Switch" value="1" />
+        <ctl name="HPHR_RDAC Switch" value="1" />
+    </path>
+
+    <path name="headphones-44.1">
+        <path name="headphones" />
+    </path>
+
+    <path name="hph-highquality-mode">
+    </path>
+
+    <path name="hph-lowpower-mode">
+    </path>
+
+    <path name="true-native-mode">
+    </path>
+
+    <path name="line">
+        <path name="headphones" />
+    </path>
+
+    <path name="headset-mic">
+        <path name="amic2" />
+        <ctl name="TX_DEC0 Volume" value="84" />
+    </path>
+
+    <path name="headset-mic-liquid">
+        <path name="amic2" />
+    </path>
+    <path name="voice-handset">
+        <path name="handset" />
+    </path>
+
+    <path name="voice-handset-tmus">
+        <path name="handset" />
+    </path>
+
+    <path name="voice-handset-hdk">
+        <path name="handset" />
+    </path>
+
+    <path name="voice-handset-tmus-hdk">
+        <path name="handset" />
+    </path>
+    <path name="voice-speaker">
+        <path name="speaker-mono" />
+    </path>
+
+    <path name="voice-speaker-stereo">
+        <path name="speaker" />
+    </path>
+
+    <path name="voice-speaker-2">
+        <path name="speaker-mono-2" />
+    </path>
+
+    <path name="voice-speaker-hdk">
+        <path name="speaker-mono" />
+    </path>
+
+    <path name="voice-speaker-fluid">
+        <path name="speaker-fluid" />
+    </path>
+
+    <path name="voice-speaker-vbat">
+        <path name="speaker-vbat-mono" />
+    </path>
+
+    <path name="voice-speaker-2-vbat">
+        <path name="speaker-vbat-mono-2" />
+    </path>
+
+    <path name="voice-speaker-mic">
+        <path name="speaker-mic" />
+    </path>
+
+    <path name="voice-headphones">
+        <path name="headphones" />
+    </path>
+
+    <path name="voice-headset">
+        <path name="headphones" />
+    </path>
+
+    <path name="voice-line">
+        <path name="voice-headphones" />
+    </path>
+
+    <path name="voice-headset-mic">
+        <path name="headset-mic" />
+    </path>
+
+    <path name="speaker-and-headphones">
+        <path name="headphones" />
+        <path name="speaker" />
+    </path>
+
+    <path name="speaker-and-line">
+        <path name="speaker-and-headphones" />
+    </path>
+
+    <path name="speaker-and-headphones-liquid">
+        <path name="headphones" />
+        <path name="speaker" />
+    </path>
+
+    <path name="speaker-and-line-liquid">
+        <path name="speaker-and-headphones-liquid" />
+    </path>
+
+    <path name="usb-headphones">
+    </path>
+
+    <path name="usb-headset">
+    </path>
+
+    <path name="afe-proxy">
+    </path>
+
+    <path name="display-port">
+    </path>
+
+    <path name="speaker-and-usb-headphones">
+        <path name="speaker" />
+        <path name="usb-headphones" />
+    </path>
+
+    <path name="speaker-and-display-port">
+        <path name="speaker" />
+        <path name="display-port" />
+    </path>
+
+    <path name="voice-rec-mic">
+        <path name="handset-mic" />
+    </path>
+
+    <path name="camcorder-mic">
+        <path name="handset-mic" />
+    </path>
+
+    <path name="bt-sco-headset">
+    </path>
+
+    <path name="bt-sco-mic">
+    </path>
+
+    <path name="bt-sco-headset-wb">
+    </path>
+
+    <path name="bt-sco-mic-wb">
+    </path>
+
+    <path name="bt-sco-headset-swb">
+    </path>
+
+    <path name="bt-sco-mic-swb">
+    </path>
+
+    <path name="usb-headset-mic">
+    </path>
+
+    <path name="capture-fm">
+    </path>
+
+    <!-- Dual MIC devices -->
+    <path name="handset-dmic-endfire">
+        <ctl name="TX_CDC_DMA_TX_3 Channels" value="Two" />
+        <path name="amic1" />
+        <path name="amic3" />
+    </path>
+
+    <path name="speaker-dmic-endfire">
+        <ctl name="TX_CDC_DMA_TX_3 Channels" value="Two" />
+        <path name="amic1" />
+        <path name="amic3" />
+    </path>
+
+    <path name="dmic-endfire">
+        <path name="handset-dmic-endfire" />
+        <ctl name="IIR0 INP0 MUX" value="DEC0" />
+    </path>
+
+    <path name="dmic-endfire-liquid">
+        <path name="handset-dmic-endfire" />
+        <ctl name="IIR0 INP0 MUX" value="DEC7" />
+    </path>
+
+    <path name="handset-stereo-dmic-ef">
+        <path name="handset-dmic-endfire" />
+    </path>
+
+    <path name="speaker-stereo-dmic-ef">
+        <path name="speaker-dmic-endfire" />
+    </path>
+
+    <path name="voice-dmic-ef-tmus">
+        <path name="dmic-endfire" />
+    </path>
+
+    <path name="voice-dmic-ef">
+        <path name="dmic-endfire" />
+    </path>
+
+    <path name="voice-speaker-dmic-ef">
+        <path name="speaker-dmic-endfire" />
+    </path>
+
+    <path name="voice-rec-dmic-ef">
+        <path name="dmic-endfire" />
+    </path>
+
+    <path name="voice-rec-dmic-ef-fluence">
+        <path name="dmic-endfire" />
+    </path>
+
+    <path name="handset-stereo-dmic-ef-liquid">
+        <path name="handset-dmic-endfire" />
+    </path>
+
+    <path name="speaker-stereo-dmic-ef-liquid">
+        <path name="speaker-dmic-endfire" />
+    </path>
+
+    <path name="voice-dmic-ef-liquid-liquid">
+        <path name="dmic-endfire-liquid" />
+    </path>
+
+    <path name="voice-speaker-dmic-ef-liquid">
+        <path name="dmic-endfire-liquid" />
+    </path>
+
+    <path name="voice-rec-dmic-ef-liquid">
+        <path name="dmic-endfire-liquid" />
+    </path>
+
+    <path name="voice-rec-dmic-ef-fluence-liquid">
+        <path name="dmic-endfire-liquid" />
+    </path>
+    <path name="speaker-dmic-broadside">
+        <ctl name="TX_CDC_DMA_TX_3 Channels" value="Two" />
+        <path name="amic1" />
+        <path name="amic3" />
+    </path>
+
+    <path name="dmic-broadside">
+        <path name="speaker-dmic-broadside" />
+        <ctl name="IIR0 INP0 MUX" value="DEC0" />
+    </path>
+
+    <path name="voice-speaker-dmic-broadside">
+        <path name="dmic-broadside" />
+    </path>
+
+    <!-- Tri MIC devices -->
+    <path name="three-mic">
+        <ctl name="TX_CDC_DMA_TX_3 Channels" value="Three" />
+        <path name="amic1" />
+        <path name="amic3" />
+        <path name="amic4" />
+    </path>
+
+    <path name="speaker-tmic">
+        <path name="three-mic" />
+    </path>
+
+    <path name="voice-speaker-tmic">
+        <path name="speaker-tmic" />
+    </path>
+
+    <!-- Quad MIC devices -->
+    <path name="speaker-qmic">
+        <ctl name="TX_CDC_DMA_TX_3 Channels" value="Four" />
+        <path name="amic1" />
+        <path name="amic3" />
+        <path name="amic4" />
+        <path name="amic5" />
+    </path>
+
+    <path name="speaker-qmic-liquid">
+    </path>
+
+    <path name="voice-speaker-qmic">
+        <path name="speaker-qmic" />
+    </path>
+
+    <path name="quad-mic">
+        <path name="speaker-qmic" />
+    </path>
+
+    <path name="voice-speaker-qmic-liquid">
+        <path name="speaker-qmic-liquid" />
+    </path>
+
+    <path name="quad-mic-liquid">
+        <path name="speaker-qmic-liquid" />
+    </path>
+
+    <!-- TTY devices -->
+
+    <path name="tty-headphones">
+        <ctl name="RX_MACRO RX0 MUX" value="AIF1_PB" />
+        <ctl name="RX INT0_1 MIX1 INP0" value="RX0" />
+        <ctl name="RX INT0 DEM MUX" value="CLSH_DSM_OUT" />
+        <ctl name="RX_COMP1 Switch" value="1" />
+        <ctl name="HPHL_COMP Switch" value="1" />
+        <ctl name="HPHL_RDAC Switch" value="1" />
+    </path>
+
+    <path name="voice-tty-full-headphones">
+        <ctl name="TTY Mode" value="FULL" />
+        <path name="tty-headphones" />
+    </path>
+
+    <path name="voice-tty-vco-headphones">
+        <ctl name="TTY Mode" value="VCO" />
+        <path name="tty-headphones" />
+    </path>
+
+    <path name="voice-tty-hco-handset">
+        <ctl name="TTY Mode" value="HCO" />
+        <path name="handset" />
+    </path>
+
+
+    <path name="voice-tty-hco-handset-hdk">
+        <ctl name="TTY Mode" value="HCO" />
+        <path name="handset" />
+    </path>
+
+    <path name="voice-tty-full-headset-mic">
+        <path name="amic2" />
+        <ctl name="ADC2 Volume" value="0" />
+        <ctl name="TX_DEC0 Volume" value="84" />
+    </path>
+
+    <path name="voice-tty-hco-headset-mic">
+        <path name="voice-tty-full-headset-mic" />
+    </path>
+
+    <path name="voice-tty-vco-handset-mic">
+        <path name="dmic3" />
+    </path>
+
+    <path name="unprocessed-handset-mic">
+        <path name="handset-mic" />
+    </path>
+
+    <path name="unprocessed-mic">
+        <path name="unprocessed-handset-mic" />
+    </path>
+
+    <path name="unprocessed-stereo-mic">
+        <path name="voice-rec-dmic-ef" />
+    </path>
+
+    <path name="unprocessed-three-mic">
+        <path name="three-mic" />
+    </path>
+
+    <path name="unprocessed-quad-mic">
+        <path name="quad-mic" />
+    </path>
+
+    <path name="unprocessed-headset-mic">
+        <path name="headset-mic" />
+    </path>
+
+    <!-- USB TTY start -->
+
+    <!-- full: both end tty -->
+    <path name="voice-tty-full-usb">
+        <ctl name="TTY Mode" value="FULL" />
+        <path name="usb-headphones" />
+    </path>
+
+    <path name="voice-tty-full-usb-mic">
+        <path name="usb-headset-mic" />
+    </path>
+
+    <!-- vco, in: handset mic use existing, out: tty -->
+    <path name="voice-tty-vco-usb">
+        <ctl name="TTY Mode" value="VCO" />
+        <path name="usb-headphones" />
+    </path>
+
+    <!-- hco, in: tty, out: speaker, use existing handset -->
+    <path name="voice-tty-hco-usb-mic">
+        <path name="voice-tty-full-usb-mic" />
+    </path>
+
+    <!-- USB TTY end   -->
+
+    <!-- Added for ADSP testfwk -->
+    <path name="ADSP testfwk">
+        <ctl name="WSA_CDC_DMA_RX_0_DL_HL Switch" value="1" />
+    </path>
+
+    <path name="bt-a2dp">
+        <ctl name="SLIM7_RX ADM Channels" value="Two" />
+    </path>
+
+    <path name="speaker-and-bt-a2dp">
+        <path name="speaker" />
+        <path name="bt-a2dp" />
+    </path>
+
+    <path name="deep-buffer-playback bt-a2dp">
+        <ctl name="SLIMBUS_7_RX Audio Mixer MultiMedia1" value="1" />
+    </path>
+
+    <path name="low-latency-playback bt-a2dp">
+        <ctl name="SLIMBUS_7_RX Audio Mixer MultiMedia5" value="1" />
+    </path>
+
+    <path name="compress-offload-playback bt-a2dp">
+        <ctl name="SLIMBUS_7_RX Audio Mixer MultiMedia4" value="1" />
+    </path>
+
+    <path name="compress-offload-playback2 bt-a2dp">
+        <ctl name="SLIMBUS_7_RX Audio Mixer MultiMedia7" value="1" />
+    </path>
+
+    <path name="compress-offload-playback3 bt-a2dp">
+        <ctl name="SLIMBUS_7_RX Audio Mixer MultiMedia10" value="1" />
+    </path>
+
+    <path name="compress-offload-playback4 bt-a2dp">
+        <ctl name="SLIMBUS_7_RX Audio Mixer MultiMedia11" value="1" />
+    </path>
+
+    <path name="compress-offload-playback5 bt-a2dp">
+        <ctl name="SLIMBUS_7_RX Audio Mixer MultiMedia12" value="1" />
+    </path>
+
+    <path name="compress-offload-playback6 bt-a2dp">
+        <ctl name="SLIMBUS_7_RX Audio Mixer MultiMedia13" value="1" />
+    </path>
+
+    <path name="compress-offload-playback7 bt-a2dp">
+        <ctl name="SLIMBUS_7_RX Audio Mixer MultiMedia14" value="1" />
+    </path>
+
+    <path name="compress-offload-playback8 bt-a2dp">
+        <ctl name="SLIMBUS_7_RX Audio Mixer MultiMedia15" value="1" />
+    </path>
+
+    <path name="compress-offload-playback9 bt-a2dp">
+        <ctl name="SLIMBUS_7_RX Audio Mixer MultiMedia16" value="1" />
+    </path>
+
+    <path name="audio-ull-playback bt-a2dp">
+        <ctl name="SLIMBUS_7_RX Audio Mixer MultiMedia8" value="1" />
+    </path>
+
+    <path name="deep-buffer-playback speaker-and-bt-a2dp">
+        <path name="deep-buffer-playback bt-a2dp" />
+        <path name="deep-buffer-playback" />
+    </path>
+
+    <path name="compress-offload-playback speaker-and-bt-a2dp">
+        <path name="compress-offload-playback bt-a2dp" />
+        <path name="compress-offload-playback" />
+    </path>
+
+    <path name="low-latency-playback speaker-and-bt-a2dp">
+        <path name="low-latency-playback bt-a2dp" />
+        <path name="low-latency-playback" />
+    </path>
+
+    <path name="compress-offload-playback2 speaker-and-bt-a2dp">
+        <path name="compress-offload-playback2 bt-a2dp" />
+        <path name="compress-offload-playback2" />
+    </path>
+
+    <path name="compress-offload-playback3 speaker-and-bt-a2dp">
+        <path name="compress-offload-playback3 bt-a2dp" />
+        <path name="compress-offload-playback3" />
+    </path>
+
+    <path name="compress-offload-playback4 speaker-and-bt-a2dp">
+        <path name="compress-offload-playback4 bt-a2dp" />
+        <path name="compress-offload-playback4" />
+    </path>
+
+    <path name="compress-offload-playback5 speaker-and-bt-a2dp">
+        <path name="compress-offload-playback5 bt-a2dp" />
+        <path name="compress-offload-playback5" />
+    </path>
+
+    <path name="compress-offload-playback6 speaker-and-bt-a2dp">
+        <path name="compress-offload-playback6 bt-a2dp" />
+        <path name="compress-offload-playback6" />
+    </path>
+
+    <path name="compress-offload-playback7 speaker-and-bt-a2dp">
+        <path name="compress-offload-playback7 bt-a2dp" />
+        <path name="compress-offload-playback7" />
+    </path>
+
+    <path name="compress-offload-playback8 speaker-and-bt-a2dp">
+        <path name="compress-offload-playback8 bt-a2dp" />
+        <path name="compress-offload-playback8" />
+    </path>
+
+    <path name="compress-offload-playback9 speaker-and-bt-a2dp">
+        <path name="compress-offload-playback9 bt-a2dp" />
+        <path name="compress-offload-playback9" />
+    </path>
+
+    <path name="audio-ull-playback speaker-and-bt-a2dp">
+        <path name="audio-ull-playback bt-a2dp" />
+        <path name="audio-ull-playback" />
+    </path>
+
+    <path name="mmap-playback">
+        <ctl name="WSA_CDC_DMA_RX_0 Audio Mixer MultiMedia16" value="1" />
+    </path>
+
+    <path name="mmap-playback headphones">
+        <ctl name="RX_CDC_DMA_RX_0 Audio Mixer MultiMedia16" value="1" />
+    </path>
+
+    <path name="mmap-playback speaker-and-headphones">
+        <path name="mmap-playback" />
+        <path name="mmap-playback headphones" />
+    </path>
+
+    <path name="mmap-playback bt-sco">
+        <ctl name="SLIMBUS_7_RX Audio Mixer MultiMedia16" value="1" />
+    </path>
+
+    <path name="mmap-playback bt-sco-wb">
+        <ctl name="BT SampleRate" value="KHZ_16" />
+        <path name="mmap-playback bt-sco" />
+    </path>
+
+    <path name="mmap-playback bt-sco-swb">
+        <path name="mmap-playback bt-sco" />
+    </path>
+
+    <path name="mmap-playback afe-proxy">
+        <ctl name="AFE_PCM_RX Audio Mixer MultiMedia16" value="1" />
+    </path>
+
+    <path name="mmap-playback usb-headphones">
+        <ctl name="USB_AUDIO_RX Audio Mixer MultiMedia16" value="1" />
+    </path>
+
+    <path name="mmap-playback usb-headset">
+        <ctl name="USB_AUDIO_RX Audio Mixer MultiMedia16" value="1" />
+    </path>
+
+    <path name="mmap-playback display-port">
+        <ctl name="DISPLAY_PORT Mixer MultiMedia16" value="1" />
+    </path>
+
+    <path name="mmap-playback hdmi">
+        <ctl name="HDMI Mixer MultiMedia16" value="1" />
+    </path>
+
+    <path name="mmap-playback speaker-and-hdmi">
+        <path name="mmap-playback hdmi" />
+        <path name="mmap-playback" />
+    </path>
+
+    <path name="mmap-playback speaker-and-display-port">
+        <path name="mmap-playback display-port" />
+        <path name="mmap-playback" />
+    </path>
+
+    <path name="mmap-playback speaker-and-usb-headphones">
+        <path name="mmap-playback usb-headphones" />
+        <path name="mmap-playback" />
+    </path>
+
+    <path name="mmap-record">
+      <ctl name="MultiMedia16 Mixer TX_CDC_DMA_TX_3" value="1" />
+    </path>
+
+    <path name="mmap-record bt-sco">
+      <ctl name="MultiMedia16 Mixer SLIM_7_TX" value="1" />
+    </path>
+
+    <path name="mmap-record bt-sco-wb">
+        <ctl name="BT SampleRate" value="KHZ_16" />
+        <path name="mmap-record bt-sco" />
+    </path>
+
+    <path name="mmap-record bt-sco-swb">
+        <path name="mmap-record bt-sco" />
+    </path>
+
+    <path name="mmap-record capture-fm">
+      <ctl name="MultiMedia16 Mixer TERT_MI2S_TX" value="1" />
+    </path>
+
+    <path name="mmap-record usb-headset-mic">
+       <ctl name="MultiMedia16 Mixer USB_AUDIO_TX" value="1" />
+    </path>
+
+    <path name="mmap-record headset-mic">
+        <ctl name="MultiMedia16 Mixer TX_CDC_DMA_TX_4" value="1" />
+    </path>
+
+    <path name="hifi-playback display-port">
+        <ctl name="DISPLAY_PORT Mixer MultiMedia2" value="1" />
+    </path>
+
+    <path name="hifi-playback afe-proxy">
+        <ctl name="AFE_PCM_RX Audio Mixer MultiMedia2" value="1" />
+    </path>
+
+    <path name="hifi-playback usb-headset">
+        <ctl name="USB_AUDIO_RX Audio Mixer MultiMedia2" value="1" />
+    </path>
+
+    <path name="hifi-playback usb-headphones">
+        <ctl name="USB_AUDIO_RX Audio Mixer MultiMedia2" value="1" />
+    </path>
+
+    <path name="hifi-record">
+        <ctl name="MultiMedia2 Mixer TX_CDC_DMA_TX_3" value="1" />
+    </path>
+
+    <path name="hifi-record usb-headset-mic">
+        <ctl name="MultiMedia2 Mixer USB_AUDIO_TX" value="1" />
+    </path>
+
+    <path name="incall_music_uplink">
+        <ctl name="Incall_Music Audio Mixer MultiMedia9" value="1" />
+    </path>
+
+    <path name="incall_music_uplink speaker">
+        <path name="incall_music_uplink" />
+    </path>
+
+    <path name="incall_music_uplink handset">
+        <path name="incall_music_uplink" />
+    </path>
+
+    <path name="incall_music_uplink handset-hac">
+        <path name="incall_music_uplink" />
+    </path>
+
+    <path name="incall_music_uplink display-port">
+        <path name="incall_music_uplink" />
+    </path>
+
+    <path name="incall_music_uplink bt-sco">
+        <path name="incall_music_uplink" />
+    </path>
+
+    <path name="incall_music_uplink bt-sco-wb">
+        <path name="incall_music_uplink" />
+    </path>
+
+    <path name="incall_music_uplink bt-sco-swb">
+        <path name="incall_music_uplink" />
+    </path>
+
+    <path name="incall_music_uplink speaker-and-display-port">
+        <path name="incall_music_uplink" />
+    </path>
+
+    <path name="incall_music_uplink afe-proxy">
+        <path name="incall_music_uplink" />
+    </path>
+
+    <path name="incall_music_uplink usb-headphones">
+        <path name="incall_music_uplink" />
+    </path>
+
+    <path name="incall_music_uplink usb-headset">
+        <path name="incall_music_uplink" />
+    </path>
+
+    <path name="incall_music_uplink speaker-and-usb-headphones">
+        <path name="incall_music_uplink" />
+    </path>
+
+    <path name="incall_music_uplink headphones">
+        <path name="incall_music_uplink" />
+    </path>
+
+    <path name="incall_music_uplink headset">
+        <path name="incall_music_uplink" />
+    </path>
+
+    <path name="incall_music_uplink speaker-and-headphones">
+        <path name="incall_music_uplink" />
+    </path>
+
+    <path name="incall_music_uplink speaker-and-bt-sco">
+        <path name="incall_music_uplink" />
+    </path>
+
+    <path name="incall_music_uplink voice-tty-hco-handset">
+        <path name="incall_music_uplink" />
+    </path>
+
+    <path name="incall_music_uplink speaker-and-bt-a2dp">
+        <path name="incall_music_uplink" />
+    </path>
+
+    <path name="incall_music_uplink bt-a2dp">
+        <path name="incall_music_uplink" />
+    </path>
+    <path name="incall_music_uplink afe-proxy">
+        <path name="incall_music_uplink" />
+    </path>
+</mixer>
diff --git a/configs/kona/mixer_paths_qrd.xml b/configs/kona/mixer_paths_qrd.xml
index 4a305ca..08176d5 100644
--- a/configs/kona/mixer_paths_qrd.xml
+++ b/configs/kona/mixer_paths_qrd.xml
@@ -61,11 +61,16 @@
     <ctl name="MultiMedia5 Mixer AFE_PCM_TX" value="0" />
     <ctl name="MultiMedia5 Mixer TX_CDC_DMA_TX_3" value="0" />
     <ctl name="MultiMedia1 Mixer TX_CDC_DMA_TX_3" value="0" />
+    <ctl name="MultiMedia1 Mixer TX_CDC_DMA_TX_4" value="0" />
     <ctl name="MultiMedia1 Mixer SLIM_7_TX" value="0" />
     <ctl name="MultiMedia8 Mixer SLIM_7_TX" value="0" />
     <ctl name="MultiMedia10 Mixer TX_CDC_DMA_TX_3" value="0" />
+    <ctl name="MultiMedia10 Mixer TX_CDC_DMA_TX_4" value="0" />
     <ctl name="MultiMedia10 Mixer SLIM_7_TX" value="0" />
     <ctl name="MultiMedia10 Mixer AFE_PCM_TX" value="0" />
+    <ctl name="MultiMedia17 Mixer TX_CDC_DMA_TX_3" value="0" />
+    <ctl name="MultiMedia17 Mixer TX_CDC_DMA_TX_4" value="0" />
+    <ctl name="MultiMedia17 Mixer SLIM_7_TX" value="0" />
     <ctl name="DISPLAY_PORT Mixer MultiMedia1" value="0" />
     <ctl name="DISPLAY_PORT Mixer MultiMedia2" value="0" />
     <ctl name="DISPLAY_PORT Mixer MultiMedia3" value="0" />
@@ -129,6 +134,7 @@
     <ctl name="MultiMedia5 Mixer USB_AUDIO_TX" value="0" />
     <ctl name="MultiMedia8 Mixer USB_AUDIO_TX" value="0" />
     <ctl name="MultiMedia10 Mixer USB_AUDIO_TX" value="0" />
+    <ctl name="MultiMedia17 Mixer USB_AUDIO_TX" value="0" />
     <ctl name="TX_CDC_DMA_TX_3 Channels" value="One" />
     <ctl name="WSA_CDC_DMA_RX_0 Channels" value="One" />
     <ctl name="RX_CDC_DMA_RX_0 Channels" value="One" />
@@ -175,6 +181,7 @@
     <ctl name="WSA_CDC_DMA_RX_0_Voice Mixer VoiceMMode1" value="0" />
     <ctl name="RX_CDC_DMA_RX_0_Voice Mixer VoiceMMode1" value="0" />
     <ctl name="VoiceMMode1_Tx Mixer TX_CDC_DMA_TX_3_MMode1" value="0" />
+    <ctl name="VoiceMMode1_Tx Mixer TX_CDC_DMA_TX_4_MMode1" value="0" />
     <!-- Multimode Voice1 BTSCO -->
     <ctl name="SLIM_7_RX_Voice Mixer VoiceMMode1" value="0" />
     <ctl name="VoiceMMode1_Tx Mixer SLIM_7_TX_MMode1" value="0" />
@@ -191,6 +198,7 @@
     <ctl name="WSA_CDC_DMA_RX_0_Voice Mixer VoiceMMode2" value="0" />
     <ctl name="RX_CDC_DMA_RX_0_Voice Mixer VoiceMMode2" value="0" />
     <ctl name="VoiceMMode1_Tx Mixer TX_CDC_DMA_TX_3_MMode2" value="0" />
+    <ctl name="VoiceMMode1_Tx Mixer TX_CDC_DMA_TX_4_MMode2" value="0" />
     <!-- Multimode Voice2 BTSCO -->
     <ctl name="SLIM_7_RX_Voice Mixer VoiceMMode2" value="0" />
     <ctl name="VoiceMMode2_Tx Mixer SLIM_7_TX_MMode2" value="0" />
@@ -352,10 +360,10 @@
     <ctl name="HPHR Volume" value="20" />
     <ctl name="EAR SPKR PA Gain" value="G_DEFAULT" />
 
-    <ctl name="TX_DEC0 Volume" value="102" />
-    <ctl name="TX_DEC1 Volume" value="102" />
-    <ctl name="TX_DEC2 Volume" value="102" />
-    <ctl name="TX_DEC3 Volume" value="102" />
+    <ctl name="TX_DEC0 Volume" value="96" />
+    <ctl name="TX_DEC1 Volume" value="96" />
+    <ctl name="TX_DEC2 Volume" value="96" />
+    <ctl name="TX_DEC3 Volume" value="96" />
     <ctl name="TX_DEC4 Volume" value="84" />
     <ctl name="TX_DEC5 Volume" value="84" />
     <ctl name="TX_DEC6 Volume" value="84" />
@@ -423,6 +431,7 @@
 
     <!-- defaults for mmap record -->
     <ctl name="MultiMedia16 Mixer TX_CDC_DMA_TX_3" value="0" />
+    <ctl name="MultiMedia16 Mixer TX_CDC_DMA_TX_4" value="0" />
     <ctl name="MultiMedia16 Mixer SLIM_7_TX" value="0" />
     <ctl name="MultiMedia16 Mixer TERT_MI2S_TX" value="0" />
     <ctl name="MultiMedia16 Mixer USB_AUDIO_TX" value="0" />
@@ -440,6 +449,10 @@
         <ctl name="AUDIO_REF_EC_UL1 MUX" value="RX_CDC_DMA_RX_0" />
     </path>
 
+    <path name="echo-reference headset">
+        <path name="echo-reference headphones" />
+    </path>
+
     <path name="echo-reference display-port">
         <ctl name="AUDIO_REF_EC_UL1 MUX" value="DISPLAY_PORT" />
     </path>
@@ -515,6 +528,10 @@
         <ctl name="RX_CDC_DMA_RX_0 Audio Mixer MultiMedia1" value="1" />
     </path>
 
+    <path name="deep-buffer-playback headset">
+        <path name="deep-buffer-playback headphones" />
+    </path>
+
     <path name="deep-buffer-playback speaker-and-headphones">
         <path name="deep-buffer-playback headphones" />
         <path name="deep-buffer-playback" />
@@ -590,6 +607,10 @@
         <ctl name="RX_CDC_DMA_RX_0 Audio Mixer MultiMedia5" value="1" />
     </path>
 
+    <path name="low-latency-playback headset">
+        <path name="low-latency-playback headphones" />
+    </path>
+
     <path name="low-latency-playback speaker-and-headphones">
         <path name="low-latency-playback headphones" />
         <path name="low-latency-playback" />
@@ -626,6 +647,10 @@
         <ctl name="RX_CDC_DMA_RX_0 Audio Mixer MultiMedia8" value="1" />
     </path>
 
+    <path name="audio-ull-playback headset">
+        <path name="audio-ull-playback headphones" />
+    </path>
+
     <path name="audio-ull-playback speaker-and-headphones">
         <path name="audio-ull-playback" />
         <path name="audio-ull-playback headphones" />
@@ -747,6 +772,10 @@
         <ctl name="RX_CDC_DMA_RX_0 Audio Mixer MultiMedia4" value="1" />
     </path>
 
+    <path name="compress-offload-playback headset">
+        <path name="compress-offload-playback headphones" />
+    </path>
+
     <path name="compress-offload-playback headphones-44.1">
         <ctl name="RX_CDC_DMA_RX_0 Audio Mixer MultiMedia4" value="1" />
     </path>
@@ -822,6 +851,10 @@
         <ctl name="RX_CDC_DMA_RX_0 Audio Mixer MultiMedia7" value="1" />
     </path>
 
+    <path name="compress-offload-playback2 headset">
+        <path name="compress-offload-playback2 headphones" />
+    </path>
+
     <path name="compress-offload-playback2 headphones-44.1">
         <ctl name="RX_CDC_DMA_RX_0 Audio Mixer MultiMedia7" value="1" />
     </path>
@@ -897,6 +930,10 @@
         <ctl name="RX_CDC_DMA_RX_0 Audio Mixer MultiMedia10" value="1" />
     </path>
 
+    <path name="compress-offload-playback3 headset">
+        <path name="compress-offload-playback3 headphones" />
+    </path>
+
     <path name="compress-offload-playback3 headphones-44.1">
         <ctl name="RX_CDC_DMA_RX_0 Audio Mixer MultiMedia10" value="1" />
     </path>
@@ -973,6 +1010,10 @@
         <ctl name="RX_CDC_DMA_RX_0 Audio Mixer MultiMedia11" value="1" />
     </path>
 
+    <path name="compress-offload-playback4 headset">
+        <path name="compress-offload-playback4 headphones" />
+    </path>
+
     <path name="compress-offload-playback4 headphones-44.1">
         <ctl name="RX_CDC_DMA_RX_0 Audio Mixer MultiMedia11" value="1" />
     </path>
@@ -1048,6 +1089,10 @@
         <ctl name="RX_CDC_DMA_RX_0 Audio Mixer MultiMedia12" value="1" />
     </path>
 
+    <path name="compress-offload-playback5 headset">
+        <path name="compress-offload-playback5 headphones" />
+    </path>
+
     <path name="compress-offload-playback5 headphones-44.1">
         <ctl name="RX_CDC_DMA_RX_0 Audio Mixer MultiMedia12" value="1" />
     </path>
@@ -1123,6 +1168,10 @@
         <ctl name="RX_CDC_DMA_RX_0 Audio Mixer MultiMedia13" value="1" />
     </path>
 
+    <path name="compress-offload-playback6 headset">
+        <path name="compress-offload-playback6 headphones" />
+    </path>
+
     <path name="compress-offload-playback6 headphones-44.1">
         <ctl name="RX_CDC_DMA_RX_0 Audio Mixer MultiMedia13" value="1" />
     </path>
@@ -1198,6 +1247,10 @@
         <ctl name="RX_CDC_DMA_RX_0 Audio Mixer MultiMedia14" value="1" />
     </path>
 
+    <path name="compress-offload-playback7 headset">
+        <path name="compress-offload-playback7 headphones" />
+    </path>
+
     <path name="compress-offload-playback7 headphones-44.1">
         <ctl name="RX_CDC_DMA_RX_0 Audio Mixer MultiMedia14" value="1" />
     </path>
@@ -1273,6 +1326,10 @@
         <ctl name="RX_CDC_DMA_RX_0 Audio Mixer MultiMedia15" value="1" />
     </path>
 
+    <path name="compress-offload-playback8 headset">
+        <path name="compress-offload-playback8 headphones" />
+    </path>
+
     <path name="compress-offload-playback8 headphones-44.1">
         <ctl name="RX_CDC_DMA_RX_0 Audio Mixer MultiMedia15" value="1" />
     </path>
@@ -1348,6 +1405,10 @@
         <ctl name="RX_CDC_DMA_RX_0 Audio Mixer MultiMedia16" value="1" />
     </path>
 
+    <path name="compress-offload-playback9 headset">
+        <path name="compress-offload-playback9 headphones" />
+    </path>
+
     <path name="compress-offload-playback9 headphones-44.1">
         <ctl name="RX_CDC_DMA_RX_0 Audio Mixer MultiMedia16" value="1" />
     </path>
@@ -1393,6 +1454,10 @@
         <path name="audio-record bt-sco" />
     </path>
 
+    <path name="audio-record headset-mic">
+        <ctl name="MultiMedia1 Mixer TX_CDC_DMA_TX_4" value="1" />
+    </path>
+
     <path name="audio-record capture-fm">
         <ctl name="MultiMedia1 Mixer TERT_MI2S_TX" value="1" />
     </path>
@@ -1418,6 +1483,31 @@
         <ctl name="MultiMedia8 Mixer USB_AUDIO_TX" value="1" />
     </path>
 
+    <path name="audio-record-compress2">
+        <ctl name="MultiMedia17 Mixer TX_CDC_DMA_TX_3" value="1" />
+    </path>
+
+    <path name="audio-record-compress2 bt-sco">
+        <ctl name="MultiMedia17 Mixer SLIM_7_TX" value="1" />
+    </path>
+
+    <path name="audio-record-compress bt-sco-wb">
+        <ctl name="BT SampleRate" value="KHZ_16" />
+        <path name="audio-record-compress2 bt-sco" />
+    </path>
+
+    <path name="audio-record-compress2 bt-sco-swb">
+        <path name="audio-record-compress2 bt-sco" />
+    </path>
+
+    <path name="audio-record-compress2 usb-headset-mic">
+        <ctl name="MultiMedia17 Mixer USB_AUDIO_TX" value="1" />
+    </path>
+
+    <path name="audio-record-compress2 headset-mic">
+        <ctl name="MultiMedia17 Mixer TX_CDC_DMA_TX_4" value="1" />
+    </path>
+
     <path name="low-latency-record">
       <ctl name="MultiMedia8 Mixer TX_CDC_DMA_TX_3" value="1" />
     </path>
@@ -1459,6 +1549,10 @@
         <ctl name="RX_CDC_DMA_RX_0_DL_HL Switch" value="1" />
     </path>
 
+    <path name="play-fm headset">
+        <path name="play-fm headphones" />
+    </path>
+
     <path name="incall-rec-uplink">
         <ctl name="MultiMedia1 Mixer VOC_REC_UL" value="1" />
     </path>
@@ -1483,6 +1577,10 @@
         <path name="incall-rec-uplink" />
     </path>
 
+    <path name="incall-rec-uplink headset-mic">
+        <path name="incall-rec-uplink" />
+    </path>
+
     <path name="incall-rec-uplink-compress">
         <ctl name="MultiMedia8 Mixer VOC_REC_UL" value="1" />
     </path>
@@ -1507,6 +1605,10 @@
         <path name="incall-rec-uplink-compress" />
     </path>
 
+    <path name="incall-rec-uplink-compress headset-mic">
+        <path name="incall-rec-uplink-compress" />
+    </path>
+
     <path name="incall-rec-downlink">
         <ctl name="MultiMedia1 Mixer VOC_REC_DL"  value="1" />
     </path>
@@ -1531,6 +1633,10 @@
         <path name="incall-rec-downlink" />
     </path>
 
+    <path name="incall-rec-downlink headset-mic">
+        <path name="incall-rec-downlink" />
+    </path>
+
     <path name="incall-rec-downlink-compress">
         <ctl name="MultiMedia8 Mixer VOC_REC_DL" value="1" />
     </path>
@@ -1555,6 +1661,10 @@
         <path name="incall-rec-downlink-compress" />
     </path>
 
+    <path name="incall-rec-downlink-compress headset-mic">
+        <path name="incall-rec-downlink-compress" />
+    </path>
+
     <path name="incall-rec-uplink-and-downlink">
         <path name="incall-rec-uplink" />
         <path name="incall-rec-downlink" />
@@ -1580,6 +1690,10 @@
         <path name="incall-rec-uplink-and-downlink" />
     </path>
 
+    <path name="incall-rec-uplink-and-downlink headset-mic">
+        <path name="incall-rec-uplink-and-downlink" />
+    </path>
+
     <path name="incall-rec-uplink-and-downlink-compress">
         <path name="incall-rec-uplink-compress" />
         <path name="incall-rec-downlink-compress" />
@@ -1605,6 +1719,10 @@
         <path name="incall-rec-uplink-and-downlink-compress" />
     </path>
 
+    <path name="incall-rec-uplink-and-downlink-compress headset-mic">
+        <path name="incall-rec-uplink-and-downlink-compress" />
+    </path>
+
     <path name="hfp-sco">
     </path>
 
@@ -1683,6 +1801,11 @@
         <ctl name="VoiceMMode1_Tx Mixer TX_CDC_DMA_TX_3_MMode1" value="1" />
     </path>
 
+    <path name="voicemmode1-call headset">
+        <ctl name="RX_CDC_DMA_RX_0_Voice Mixer VoiceMMode1" value="1" />
+        <ctl name="VoiceMMode1_Tx Mixer TX_CDC_DMA_TX_4_MMode1" value="1" />
+    </path>
+
     <path name="voicemmode1-call bt-sco">
         <ctl name="SLIM_7_RX_Voice Mixer VoiceMMode1" value="1" />
         <ctl name="VoiceMMode1_Tx Mixer SLIM_7_TX_MMode1" value="1" />
@@ -1737,6 +1860,11 @@
         <ctl name="VoiceMMode2_Tx Mixer TX_CDC_DMA_TX_3_MMode2" value="1" />
     </path>
 
+    <path name="voicemmode2-call headset">
+        <ctl name="RX_CDC_DMA_RX_0_Voice Mixer VoiceMMode2" value="1" />
+        <ctl name="VoiceMMode2_Tx Mixer TX_CDC_DMA_TX_4_MMode2" value="1" />
+    </path>
+
     <path name="voicemmode2-call bt-sco">
         <ctl name="SLIM_7_RX_Voice Mixer VoiceMMode2" value="1" />
         <ctl name="VoiceMMode2_Tx Mixer SLIM_7_TX_MMode2" value="1" />
@@ -1849,6 +1977,10 @@
         <path name="audio-record-voip bt-sco" />
     </path>
 
+    <path name="audio-record-voip headset-mic">
+        <ctl name="MultiMedia10 Mixer TX_CDC_DMA_TX_4" value="1" />
+    </path>
+
     <path name="bt-a2dp">
         <ctl name="SLIM7_RX ADM Channels" value="Two" />
     </path>
@@ -2056,6 +2188,10 @@
        <ctl name="MultiMedia16 Mixer USB_AUDIO_TX" value="1" />
     </path>
 
+    <path name="mmap-record headset-mic">
+        <ctl name="MultiMedia16 Mixer TX_CDC_DMA_TX_4" value="1" />
+    </path>
+
     <path name="hifi-playback display-port">
         <ctl name="DISPLAY_PORT Mixer MultiMedia2" value="1" />
     </path>
@@ -2136,6 +2272,10 @@
         <path name="incall_music_uplink" />
     </path>
 
+    <path name="incall_music_uplink headset">
+        <path name="incall_music_uplink" />
+    </path>
+
     <path name="incall_music_uplink speaker-and-headphones">
         <path name="incall_music_uplink" />
     </path>
@@ -2176,10 +2316,10 @@
     </path>
 
     <path name="amic2">
-        <ctl name="TX DEC0 MUX" value="SWR_MIC" />
-        <ctl name="TX SMIC MUX0" value="ADC1" />
-        <ctl name="TX_CDC_DMA_TX_3 Channels" value="One" />
-        <ctl name="TX_AIF1_CAP Mixer DEC0" value="1" />
+        <ctl name="TX DEC5 MUX" value="SWR_MIC" />
+        <ctl name="TX SMIC MUX5" value="ADC1" />
+        <ctl name="TX_CDC_DMA_TX_4 Channels" value="One" />
+        <ctl name="TX_AIF2_CAP Mixer DEC5" value="1" />
         <ctl name="ADC2_MIXER Switch" value="1" />
         <ctl name="ADC2 MUX" value="INP2" />
     </path>
@@ -2346,8 +2486,6 @@
         <ctl name="RX INT1_1 MIX1 INP0" value="RX1" />
         <ctl name="RX INT0 DEM MUX" value="CLSH_DSM_OUT" />
         <ctl name="RX INT1 DEM MUX" value="CLSH_DSM_OUT" />
-        <ctl name="RX_HPH_PWR_MODE" value="LOHIFI" />
-        <ctl name="RX HPH Mode" value="CLS_H_LOHIFI" />
         <ctl name="RX_COMP1 Switch" value="1" />
         <ctl name="RX_COMP2 Switch" value="1" />
         <ctl name="HPHL_COMP Switch" value="1" />
@@ -2379,13 +2517,16 @@
 
     <path name="headset-mic">
         <path name="amic2" />
-        <ctl name="TX_DEC0 Volume" value="84" />
     </path>
 
     <path name="voice-handset">
         <path name="handset" />
     </path>
 
+    <path name="voice-handset-tmus">
+        <path name="handset" />
+    </path>
+
     <path name="voice-speaker">
         <path name="speaker-mono" />
     </path>
@@ -2406,6 +2547,10 @@
         <path name="headphones" />
     </path>
 
+    <path name="voice-headset">
+        <path name="headphones" />
+    </path>
+
     <path name="voice-line">
         <path name="voice-headphones" />
     </path>
diff --git a/configs/kona/sound_trigger_mixer_paths_cdp.xml b/configs/kona/sound_trigger_mixer_paths_cdp.xml
new file mode 100644
index 0000000..2f75edc
--- /dev/null
+++ b/configs/kona/sound_trigger_mixer_paths_cdp.xml
@@ -0,0 +1,329 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!--- Copyright (c) 2014-2019, 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    -->
+<!--- met:                                                                      -->
+<!---     * Redistributions of source code must retain the above copyright      -->
+<!---       notice, this list of conditions and the following disclaimer.       -->
+<!---     * Redistributions in binary form must reproduce the above             -->
+<!---       copyright notice, this list of conditions and the following         -->
+<!---       disclaimer in the documentation and/or other materials provided     -->
+<!---       with the distribution.                                              -->
+<!---     * Neither the name of The Linux Foundation nor the names of its       -->
+<!---       contributors may be used to endorse or promote products derived     -->
+<!---       from this software without specific prior written permission.       -->
+<!---                                                                           -->
+<!--- THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED              -->
+<!--- WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF      -->
+<!--- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT    -->
+<!--- ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS    -->
+<!--- BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR    -->
+<!--- CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF      -->
+<!--- SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR           -->
+<!--- BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,     -->
+<!--- WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE      -->
+<!--- OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN    -->
+<!--- IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.                             -->
+
+<mixer>
+    <!-- These are the initial mixer settings -->
+    <ctl name="LSM1 Mixer VA_CDC_DMA_TX_0" value="0" />
+    <ctl name="LSM2 Mixer VA_CDC_DMA_TX_0" value="0" />
+    <ctl name="LSM3 Mixer VA_CDC_DMA_TX_0" value="0" />
+    <ctl name="LSM4 Mixer VA_CDC_DMA_TX_0" value="0" />
+    <ctl name="LSM5 Mixer VA_CDC_DMA_TX_0" value="0" />
+    <ctl name="LSM6 Mixer VA_CDC_DMA_TX_0" value="0" />
+    <ctl name="LSM7 Mixer VA_CDC_DMA_TX_0" value="0" />
+    <ctl name="LSM8 Mixer VA_CDC_DMA_TX_0" value="0" />
+    <ctl name="LSM1 Port" value="None" />
+    <ctl name="LSM2 Port" value="None" />
+    <ctl name="LSM3 Port" value="None" />
+    <ctl name="LSM4 Port" value="None" />
+    <ctl name="LSM5 Port" value="None" />
+    <ctl name="LSM6 Port" value="None" />
+    <ctl name="LSM7 Port" value="None" />
+    <ctl name="LSM8 Port" value="None" />
+    <ctl name="VA_CDC_DMA_TX_0 Channels" value="One" />
+    <ctl name="VA_AIF1_CAP Mixer DEC0" value="0" />
+    <ctl name="VA_AIF1_CAP Mixer DEC1" value="0" />
+    <ctl name="VA_AIF1_CAP Mixer DEC2" value="0" />
+    <ctl name="VA_AIF1_CAP Mixer DEC3" value="0" />
+    <ctl name="VA_AIF1_CAP Mixer DEC4" value="0" />
+    <ctl name="VA_AIF1_CAP Mixer DEC5" value="0" />
+    <ctl name="VA_AIF1_CAP Mixer DEC6" value="0" />
+    <ctl name="VA_AIF1_CAP Mixer DEC7" value="0" />
+    <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 DEC3 MUX" value="MSM_DMIC" />
+    <ctl name="VA DEC4 MUX" value="MSM_DMIC" />
+    <ctl name="VA DEC5 MUX" value="MSM_DMIC" />
+    <ctl name="VA DEC6 MUX" value="MSM_DMIC" />
+    <ctl name="VA DEC7 MUX" value="MSM_DMIC" />
+    <ctl name="VA DMIC MUX0" value="ZERO" />
+    <ctl name="VA DMIC MUX1" value="ZERO" />
+    <ctl name="VA DMIC MUX2" value="ZERO" />
+    <ctl name="VA DMIC MUX3" value="ZERO" />
+    <ctl name="VA DMIC MUX4" value="ZERO" />
+    <ctl name="VA DMIC MUX5" value="ZERO" />
+    <ctl name="VA DMIC MUX6" value="ZERO" />
+    <ctl name="VA DMIC MUX7" value="ZERO" />
+    <ctl name="VA SMIC MUX0" value="ZERO" />
+    <ctl name="VA SMIC MUX1" value="ZERO" />
+    <ctl name="VA SMIC MUX2" value="ZERO" />
+    <ctl name="VA SMIC MUX3" value="ZERO" />
+    <ctl name="VA SMIC MUX4" value="ZERO" />
+    <ctl name="VA SMIC MUX5" value="ZERO" />
+    <ctl name="VA SMIC MUX6" value="ZERO" />
+    <ctl name="VA SMIC MUX7" value="ZERO" />
+    <ctl name="ADC1_MIXER Switch" value="0" />
+    <ctl name="ADC2_MIXER Switch" value="0" />
+    <ctl name="ADC2 MUX" value="ZERO" />
+    <ctl name="ADC3_MIXER Switch" value="0" />
+    <ctl name="ADC3 MUX" value="ZERO" />
+    <ctl name="ADC4_MIXER Switch" value="0" />
+    <ctl name="ADC4 MUX" value="ZERO" />
+    <ctl name="ADC1 Volume" value="0" />
+    <ctl name="ADC2 Volume" value="0" />
+    <ctl name="ADC3 Volume" value="0" />
+    <ctl name="ADC4 Volume" value="0" />
+    <ctl name="AUDIO_REF_EC_UL1 MUX" value="None"/>
+    <ctl name="EC Reference Channels" value="Zero"/>
+    <ctl name="EC Reference Bit Format" value="0"/>
+    <ctl name="EC Reference SampleRate" value="0"/>
+
+    <path name="listen-voice-wakeup-1">
+        <ctl name="LSM1 Mixer VA_CDC_DMA_TX_0" value="1" />
+    </path>
+
+    <path name="listen-voice-wakeup-2">
+        <ctl name="LSM2 Mixer VA_CDC_DMA_TX_0" value="1" />
+    </path>
+
+    <path name="listen-voice-wakeup-3">
+        <ctl name="LSM3 Mixer VA_CDC_DMA_TX_0" value="1" />
+    </path>
+
+    <path name="listen-voice-wakeup-4">
+        <ctl name="LSM4 Mixer VA_CDC_DMA_TX_0" value="1" />
+    </path>
+
+    <path name="listen-voice-wakeup-5">
+        <ctl name="LSM5 Mixer VA_CDC_DMA_TX_0" value="1" />
+    </path>
+
+    <path name="listen-voice-wakeup-6">
+        <ctl name="LSM6 Mixer VA_CDC_DMA_TX_0" value="1" />
+    </path>
+
+    <path name="listen-voice-wakeup-7">
+        <ctl name="LSM7 Mixer VA_CDC_DMA_TX_0" value="1" />
+    </path>
+
+    <path name="listen-voice-wakeup-8">
+        <ctl name="LSM8 Mixer VA_CDC_DMA_TX_0" value="1" />
+    </path>
+
+    <path name="listen-voice-wakeup-1 preproc">
+        <path name="listen-voice-wakeup-1" />
+    </path>
+
+    <path name="listen-voice-wakeup-2 preproc">
+        <path name="listen-voice-wakeup-2" />
+    </path>
+
+    <path name="listen-voice-wakeup-3 preproc">
+        <path name="listen-voice-wakeup-3" />
+    </path>
+
+    <path name="listen-voice-wakeup-4 preproc">
+        <path name="listen-voice-wakeup-4" />
+    </path>
+
+    <path name="listen-voice-wakeup-5 preproc">
+        <path name="listen-voice-wakeup-5" />
+    </path>
+
+    <path name="listen-voice-wakeup-6 preproc">
+        <path name="listen-voice-wakeup-6" />
+    </path>
+
+    <path name="listen-voice-wakeup-7 preproc">
+        <path name="listen-voice-wakeup-7" />
+    </path>
+
+    <path name="listen-voice-wakeup-8 preproc">
+        <path name="listen-voice-wakeup-8" />
+    </path>
+
+    <path name="listen-voice-wakeup-1 port">
+        <ctl name="LSM1 Port" value="VA_CDC_DMA_TX_0" />
+    </path>
+
+    <path name="listen-voice-wakeup-2 port">
+        <ctl name="LSM2 Port" value="VA_CDC_DMA_TX_0" />
+    </path>
+
+    <path name="listen-voice-wakeup-3 port">
+        <ctl name="LSM3 Port" value="VA_CDC_DMA_TX_0" />
+    </path>
+
+    <path name="listen-voice-wakeup-4 port">
+        <ctl name="LSM4 Port" value="VA_CDC_DMA_TX_0" />
+    </path>
+
+    <path name="listen-voice-wakeup-5 port">
+        <ctl name="LSM5 Port" value="VA_CDC_DMA_TX_0" />
+    </path>
+
+    <path name="listen-voice-wakeup-6 port">
+        <ctl name="LSM6 Port" value="VA_CDC_DMA_TX_0" />
+    </path>
+
+    <path name="listen-voice-wakeup-7 port">
+        <ctl name="LSM7 Port" value="VA_CDC_DMA_TX_0" />
+    </path>
+
+    <path name="listen-voice-wakeup-8 port">
+        <ctl name="LSM8 Port" value="VA_CDC_DMA_TX_0" />
+    </path>
+
+    <path name="listen-voice-wakeup-1 preproc port">
+        <ctl name="LSM1 Port" value="ADM_LSM_TX" />
+    </path>
+
+    <path name="listen-voice-wakeup-2 preproc port">
+        <ctl name="LSM2 Port" value="ADM_LSM_TX" />
+    </path>
+
+    <path name="listen-voice-wakeup-3 preproc port">
+        <ctl name="LSM3 Port" value="ADM_LSM_TX" />
+    </path>
+
+    <path name="listen-voice-wakeup-4 preproc port">
+        <ctl name="LSM4 Port" value="ADM_LSM_TX" />
+    </path>
+
+    <path name="listen-voice-wakeup-5 preproc port">
+        <ctl name="LSM5 Port" value="ADM_LSM_TX" />
+    </path>
+
+    <path name="listen-voice-wakeup-6 preproc port">
+        <ctl name="LSM6 Port" value="ADM_LSM_TX" />
+    </path>
+
+    <path name="listen-voice-wakeup-7 preproc port">
+        <ctl name="LSM7 Port" value="ADM_LSM_TX" />
+    </path>
+
+    <path name="listen-voice-wakeup-8 preproc port">
+        <ctl name="LSM8 Port" value="ADM_LSM_TX" />
+    </path>
+
+    <path name="listen-ape-handset-mic">
+        <ctl name="VA_AIF1_CAP Mixer DEC0" value="1" />
+        <ctl name="VA DEC0 MUX" value="SWR_MIC" />
+        <ctl name="VA SMIC MUX0" value="ADC0" />
+        <ctl name="ADC1 Volume" value="62" />
+        <ctl name="ADC1_MIXER Switch" value="1" />
+    </path>
+
+    <path name="listen-ape-handset-mic-preproc">
+        <path name="listen-ape-handset-mic" />
+    </path>
+
+    <path name="listen-ape-handset-dmic">
+        <ctl name="VA_CDC_DMA_TX_0 Channels" value="Two" />
+        <ctl name="VA_AIF1_CAP Mixer DEC0" value="1" />
+        <ctl name="VA_AIF1_CAP Mixer DEC1" value="1" />
+        <ctl name="VA DEC0 MUX" value="SWR_MIC" />
+        <ctl name="VA SMIC MUX0" value="ADC0" />
+        <ctl name="ADC1 Volume" value="62" />
+        <ctl name="ADC1_MIXER Switch" value="1" />
+        <ctl name="VA DEC1 MUX" value="SWR_MIC" />
+        <ctl name="VA SMIC MUX1" value="ADC1" />
+        <ctl name="ADC2 Volume" value="62" />
+        <ctl name="ADC2_MIXER Switch" value="1" />
+        <ctl name="ADC2 MUX" value="INP3" />
+    </path>
+
+    <path name="listen-ape-handset-tmic">
+        <ctl name="VA_CDC_DMA_TX_0 Channels" value="Three" />
+        <ctl name="VA_AIF1_CAP Mixer DEC0" value="1" />
+        <ctl name="VA_AIF1_CAP Mixer DEC1" value="1" />
+        <ctl name="VA_AIF1_CAP Mixer DEC2" value="1" />
+        <ctl name="VA DEC0 MUX" value="SWR_MIC" />
+        <ctl name="VA SMIC MUX0" value="ADC0" />
+        <ctl name="ADC1 Volume" value="62" />
+        <ctl name="ADC1_MIXER Switch" value="1" />
+        <ctl name="VA DEC1 MUX" value="SWR_MIC" />
+        <ctl name="VA SMIC MUX1" value="ADC1" />
+        <ctl name="ADC2 Volume" value="62" />
+        <ctl name="ADC2_MIXER Switch" value="1" />
+        <ctl name="ADC2 MUX" value="INP3" />
+        <ctl name="VA DEC2 MUX" value="SWR_MIC" />
+        <ctl name="VA SMIC MUX2" value="ADC2" />
+        <ctl name="ADC3 Volume" value="62" />
+        <ctl name="ADC3_MIXER Switch" value="1" />
+        <ctl name="ADC3 MUX" value="INP4" />
+    </path>
+
+    <path name="listen-ape-handset-qmic">
+        <ctl name="VA_CDC_DMA_TX_0 Channels" value="Four" />
+        <ctl name="VA_AIF1_CAP Mixer DEC0" value="1" />
+        <ctl name="VA_AIF1_CAP Mixer DEC1" value="1" />
+        <ctl name="VA_AIF1_CAP Mixer DEC2" value="1" />
+        <ctl name="VA_AIF1_CAP Mixer DEC3" value="1" />
+        <ctl name="VA DEC0 MUX" value="SWR_MIC" />
+        <ctl name="VA SMIC MUX0" value="ADC0" />
+        <ctl name="ADC1 Volume" value="62" />
+        <ctl name="ADC1_MIXER Switch" value="1" />
+        <ctl name="VA DEC1 MUX" value="SWR_MIC" />
+        <ctl name="VA SMIC MUX1" value="ADC1" />
+        <ctl name="ADC2 Volume" value="62" />
+        <ctl name="ADC2_MIXER Switch" value="1" />
+        <ctl name="ADC2 MUX" value="INP3" />
+        <ctl name="VA DEC3 MUX" value="SWR_MIC" />
+        <ctl name="VA SMIC MUX3" value="ADC2" />
+        <ctl name="ADC3 Volume" value="62" />
+        <ctl name="ADC3_MIXER Switch" value="1" />
+        <ctl name="ADC3 MUX" value="INP4" />
+        <ctl name="VA DEC2 MUX" value="SWR_MIC" />
+        <ctl name="VA SMIC MUX2" value="ADC3" />
+        <ctl name="ADC4 Volume" value="62" />
+        <ctl name="ADC4_MIXER Switch" value="1" />
+        <ctl name="ADC4 MUX" value="INP5" />
+    </path>
+
+    <path name="listen-ape-headset-mic">
+        <ctl name="VA_AIF1_CAP Mixer DEC0" value="1" />
+        <ctl name="VA DEC0 MUX" value="SWR_MIC" />
+        <ctl name="VA SMIC MUX0" value="ADC1" />
+        <ctl name="ADC2 Volume" value="62" />
+        <ctl name="ADC2_MIXER Switch" value="1" />
+        <ctl name="ADC2 MUX" value="INP2" />
+    </path>
+
+    <path name="echo-reference">
+        <ctl name="AUDIO_REF_EC_UL1 MUX" value="WSA_CDC_DMA_RX_0"/>
+        <ctl name="EC Reference Channels" value="Two"/>
+        <ctl name="EC Reference Bit Format" value="S16_LE"/>
+        <ctl name="EC Reference SampleRate" value="48000"/>
+    </path>
+
+    <path name="echo-reference headset">
+        <ctl name="AUDIO_REF_EC_UL1 MUX" value="WSA_CDC_DMA_RX_0"/>
+        <ctl name="EC Reference Channels" value="One"/>
+        <ctl name="EC Reference Bit Format" value="S16_LE"/>
+        <ctl name="EC Reference SampleRate" value="48000"/>
+    </path>
+
+    <path name="echo-reference a2dp">
+        <ctl name="AUDIO_REF_EC_UL1 MUX" value="SLIM_7_RX"/>
+        <ctl name="EC Reference Channels" value="Two"/>
+        <ctl name="EC Reference Bit Format" value="S16_LE"/>
+        <ctl name="EC Reference SampleRate" value="48000"/>
+    </path>
+
+</mixer>
diff --git a/configs/kona/sound_trigger_platform_info.xml b/configs/kona/sound_trigger_platform_info.xml
index c5b9676..7c8c25f 100644
--- a/configs/kona/sound_trigger_platform_info.xml
+++ b/configs/kona/sound_trigger_platform_info.xml
@@ -48,6 +48,7 @@
         <param backend_dai_name="VA_CDC_DMA_TX_0" />
         <!-- Param used to indicate if SVA has dedicated SLIM ports -->
         <param dedicated_sva_path="true" />
+        <param dedicated_headset_path="false" />
         <param platform_lpi_enable="true" />
     </common_config>
     <acdb_ids>
@@ -71,7 +72,7 @@
     <sound_model_config>
         <param vendor_uuid="68ab2d40-e860-11e3-95ef-0002a5d5c51b" />
         <param execution_type="ADSP" />
-        <param library="libsmwrapper.so" />
+        <param merge_first_stage_sound_models="false"/>
         <param max_ape_phrases="20" />
         <param max_ape_users="10" />
         <!-- Profile specific data which the algorithm can support -->
@@ -152,7 +153,6 @@
     <sound_model_config>
         <param vendor_uuid="876c1b46-9d4d-40cc-a4fd-4d5ec7a80e47" />
         <param execution_type="ADSP" />
-        <param library="libsmwrapper.so" />
         <param max_ape_phrases="1" />
         <param max_ape_users="1" />
         <!-- Profile specific data which the algorithm can support -->
@@ -207,7 +207,6 @@
     <sound_model_config>
         <param vendor_uuid="7038ddc8-30f2-11e6-b0ac-40a8f03d3f15" />
         <param execution_type="ADSP" />
-        <param library="none" />
         <param max_ape_phrases="1" />
         <param max_ape_users="1" />
         <!-- Profile specific data which the algorithm can support -->
@@ -260,7 +259,6 @@
     <sound_model_config>
         <param vendor_uuid="9f6ad62a-1f0b-11e7-87c5-40a8f03d3f15" />
         <param execution_type="ADSP" />
-        <param library="none" />
         <param max_ape_phrases="1" />
         <param max_ape_users="1" />
         <!-- Profile specific data which the algorithm can support -->
diff --git a/configs/lito/audio_effects.xml b/configs/lito/audio_effects.xml
index b6e318e..add0925 100644
--- a/configs/lito/audio_effects.xml
+++ b/configs/lito/audio_effects.xml
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<!--- Copyright (c) 2018-2019, The Linux Foundation. All rights reserved.            -->
+<!--- Copyright (c) 2018-2019, 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    -->
@@ -30,9 +30,6 @@
     <libraries>
         <library name="bundle" path="libbundlewrapper.so"/>
         <library name="reverb" path="libreverbwrapper.so"/>
-        <library name="qcbassboost" path="libqcbassboost.so"/>
-        <library name="qcvirt" path="libqcvirt.so"/>
-        <library name="qcreverb" path="libqcreverb.so"/>
         <library name="visualizer_sw" path="libvisualizer.so"/>
         <library name="visualizer_hw" path="libqcomvisualizer.so"/>
         <library name="downmix" path="libdownmix.so"/>
@@ -47,11 +44,11 @@
     </libraries>
     <effects>
         <effectProxy name="bassboost" library="proxy" uuid="14804144-a5ee-4d24-aa88-0002a5d5c51b">
-            <libsw library="qcbassboost" uuid="23aca180-44bd-11e2-bcfd-0800200c9a66"/>
+            <libsw library="bundle" uuid="8631f300-72e2-11df-b57e-0002a5d5c51b"/>
             <libhw library="offload_bundle" uuid="2c4a8c24-1581-487f-94f6-0002a5d5c51b"/>
         </effectProxy>
         <effectProxy name="virtualizer" library="proxy" uuid="d3467faa-acc7-4d34-acaf-0002a5d5c51b">
-            <libsw library="qcvirt" uuid="e6c98a16-22a3-11e2-b87b-f23c91aec05e"/>
+            <libsw library="bundle" uuid="1d4033c0-8557-11df-9f2d-0002a5d5c51b"/>
             <libhw library="offload_bundle" uuid="509a4498-561a-4bea-b3b1-0002a5d5c51b"/>
         </effectProxy>
         <effectProxy name="equalizer" library="proxy" uuid="c8e70ecd-48ca-456e-8a4f-0002a5d5c51b">
@@ -60,19 +57,19 @@
         </effectProxy>
         <effect name="volume" library="bundle" uuid="119341a0-8469-11df-81f9-0002a5d5c51b"/>
         <effectProxy name="reverb_env_aux" library="proxy" uuid="48404ac9-d202-4ccc-bf84-0002a5d5c51b">
-            <libsw library="qcreverb" uuid="a8c1e5f3-293d-43cd-95ec-d5e26c02e217"/>
+            <libsw library="reverb" uuid="4a387fc0-8ab3-11df-8bad-0002a5d5c51b"/>
             <libhw library="offload_bundle" uuid="79a18026-18fd-4185-8233-0002a5d5c51b"/>
         </effectProxy>
         <effectProxy name="reverb_env_ins" library="proxy" uuid="b707403a-a1c1-4291-9573-0002a5d5c51b">
-            <libsw library="qcreverb" uuid="791fff8b-8129-4655-83a4-59bc61034c3a"/>
+            <libsw library="reverb" uuid="c7a511a0-a3bb-11df-860e-0002a5d5c51b"/>
             <libhw library="offload_bundle" uuid="eb64ea04-973b-43d2-8f5e-0002a5d5c51b"/>
         </effectProxy>
         <effectProxy name="reverb_pre_aux" library="proxy" uuid="1b78f587-6d1c-422e-8b84-0002a5d5c51b">
-            <libsw library="qcreverb" uuid="53ef1db5-c0c0-445b-b060-e34d20ebb70a"/>
+            <libsw library="reverb" uuid="f29a1400-a3bb-11df-8ddc-0002a5d5c51b"/>
             <libhw library="offload_bundle" uuid="6987be09-b142-4b41-9056-0002a5d5c51b"/>
         </effectProxy>
         <effectProxy name="reverb_pre_ins" library="proxy" uuid="f3e178d2-ebcb-408e-8357-0002a5d5c51b">
-            <libsw library="qcreverb" uuid="b08a0e38-22a5-11e2-b87b-f23c91aec05e"/>
+            <libsw library="reverb" uuid="172cdf00-a3bc-11df-a72f-0002a5d5c51b"/>
             <libhw library="offload_bundle" uuid="aa2bebf6-47cf-4613-9bca-0002a5d5c51b"/>
         </effectProxy>
         <effectProxy name="visualizer" library="proxy" uuid="1d0a1a53-7d5d-48f2-8e71-27fbd10d842c">
diff --git a/configs/lito/audio_platform_info.xml b/configs/lito/audio_platform_info.xml
index 21714f4..6d14b50 100644
--- a/configs/lito/audio_platform_info.xml
+++ b/configs/lito/audio_platform_info.xml
@@ -152,6 +152,7 @@
         <device name="SND_DEVICE_OUT_VOICE_HANDSET" interface="WSA_CDC_DMA_RX_0"/>
         <device name="SND_DEVICE_IN_HANDSET_GENERIC_QMIC" interface="TX_CDC_DMA_TX_3"/>
         <device name="SND_DEVICE_OUT_VOICE_SPEAKER" interface="WSA_CDC_DMA_RX_0"/>
+        <device name="SND_DEVICE_OUT_VOICE_SPEAKER_STEREO" interface="WSA_CDC_DMA_RX_0"/>
         <device name="SND_DEVICE_OUT_VOICE_SPEAKER_VBAT" interface="WSA_CDC_DMA_RX_0"/>
         <device name="SND_DEVICE_OUT_VOICE_SPEAKER_2" interface="WSA_CDC_DMA_RX_0"/>
         <device name="SND_DEVICE_OUT_VOICE_SPEAKER_2_VBAT" interface="WSA_CDC_DMA_RX_0"/>
diff --git a/configs/lito/audio_platform_info_intcodec.xml b/configs/lito/audio_platform_info_intcodec.xml
index 7c57bf4..7f2a4a0 100644
--- a/configs/lito/audio_platform_info_intcodec.xml
+++ b/configs/lito/audio_platform_info_intcodec.xml
@@ -129,6 +129,7 @@
         <device name="SND_DEVICE_OUT_VOICE_HANDSET" interface="WSA_CDC_DMA_RX_0"/>
         <device name="SND_DEVICE_IN_HANDSET_GENERIC_QMIC" interface="TX_CDC_DMA_TX_3"/>
         <device name="SND_DEVICE_OUT_VOICE_SPEAKER" interface="WSA_CDC_DMA_RX_0"/>
+        <device name="SND_DEVICE_OUT_VOICE_SPEAKER_STEREO" interface="WSA_CDC_DMA_RX_0"/>
         <device name="SND_DEVICE_OUT_VOICE_SPEAKER_VBAT" interface="WSA_CDC_DMA_RX_0"/>
         <device name="SND_DEVICE_OUT_VOICE_SPEAKER_2" interface="WSA_CDC_DMA_RX_0"/>
         <device name="SND_DEVICE_OUT_VOICE_SPEAKER_2_VBAT" interface="WSA_CDC_DMA_RX_0"/>
diff --git a/configs/lito/audio_platform_info_qrd.xml b/configs/lito/audio_platform_info_qrd.xml
index e7d2662..635f321 100644
--- a/configs/lito/audio_platform_info_qrd.xml
+++ b/configs/lito/audio_platform_info_qrd.xml
@@ -128,6 +128,7 @@
         <device name="SND_DEVICE_OUT_VOICE_HANDSET" backend="handset" interface="RX_CDC_DMA_RX_0"/>
         <device name="SND_DEVICE_IN_HANDSET_GENERIC_QMIC" interface="TX_CDC_DMA_TX_3"/>
         <device name="SND_DEVICE_OUT_VOICE_SPEAKER" interface="WSA_CDC_DMA_RX_0"/>
+        <device name="SND_DEVICE_OUT_VOICE_SPEAKER_STEREO" interface="WSA_CDC_DMA_RX_0"/>
         <device name="SND_DEVICE_OUT_VOICE_SPEAKER_VBAT" interface="WSA_CDC_DMA_RX_0"/>
         <device name="SND_DEVICE_OUT_VOICE_SPEAKER_2" interface="WSA_CDC_DMA_RX_0"/>
         <device name="SND_DEVICE_OUT_VOICE_SPEAKER_2_VBAT" interface="WSA_CDC_DMA_RX_0"/>
diff --git a/configs/lito/audio_policy_configuration.xml b/configs/lito/audio_policy_configuration.xml
index 50920b3..a33356b 100644
--- a/configs/lito/audio_policy_configuration.xml
+++ b/configs/lito/audio_policy_configuration.xml
@@ -263,17 +263,20 @@
                              samplingRates="48000" channelMasks="AUDIO_CHANNEL_OUT_MONO,AUDIO_CHANNEL_OUT_STEREO"/>
                 </devicePort>
                 <devicePort tagName="BT A2DP Out" type="AUDIO_DEVICE_OUT_BLUETOOTH_A2DP" role="sink"
-                            encodedFormats="AUDIO_FORMAT_SBC AUDIO_FORMAT_AAC AUDIO_FORMAT_APTX AUDIO_FORMAT_APTX_HD AUDIO_FORMAT_LDAC AUDIO_FORMAT_CELT AUDIO_FORMAT_APTX_ADAPTIVE">
+                            encodedFormats="AUDIO_FORMAT_SBC AUDIO_FORMAT_AAC AUDIO_FORMAT_APTX AUDIO_FORMAT_APTX_HD AUDIO_FORMAT_LDAC AUDIO_FORMAT_CELT AUDIO_FORMAT_APTX_ADAPTIVE AUDIO_FORMAT_APTX_TW
+SP">
                     <profile name="" format="AUDIO_FORMAT_PCM_16_BIT"
                              samplingRates="48000" channelMasks="AUDIO_CHANNEL_OUT_STEREO"/>
                 </devicePort>
                 <devicePort tagName="BT A2DP Headphones" type="AUDIO_DEVICE_OUT_BLUETOOTH_A2DP_HEADPHONES" role="sink"
-                            encodedFormats="AUDIO_FORMAT_SBC AUDIO_FORMAT_AAC AUDIO_FORMAT_APTX AUDIO_FORMAT_APTX_HD AUDIO_FORMAT_LDAC AUDIO_FORMAT_CELT AUDIO_FORMAT_APTX_ADAPTIVE">
+                            encodedFormats="AUDIO_FORMAT_SBC AUDIO_FORMAT_AAC AUDIO_FORMAT_APTX AUDIO_FORMAT_APTX_HD AUDIO_FORMAT_LDAC AUDIO_FORMAT_CELT AUDIO_FORMAT_APTX_ADAPTIVE AUDIO_FORMAT_APTX_TW
+SP">
                     <profile name="" format="AUDIO_FORMAT_PCM_16_BIT"
                              samplingRates="48000" channelMasks="AUDIO_CHANNEL_OUT_STEREO"/>
                 </devicePort>
                 <devicePort tagName="BT A2DP Speaker" type="AUDIO_DEVICE_OUT_BLUETOOTH_A2DP_SPEAKER" role="sink"
-                            encodedFormats="AUDIO_FORMAT_SBC AUDIO_FORMAT_AAC AUDIO_FORMAT_APTX AUDIO_FORMAT_APTX_HD AUDIO_FORMAT_LDAC AUDIO_FORMAT_CELT AUDIO_FORMAT_APTX_ADAPTIVE">
+                            encodedFormats="AUDIO_FORMAT_SBC AUDIO_FORMAT_AAC AUDIO_FORMAT_APTX AUDIO_FORMAT_APTX_HD AUDIO_FORMAT_LDAC AUDIO_FORMAT_CELT AUDIO_FORMAT_APTX_ADAPTIVE AUDIO_FORMAT_APTX_TW
+SP">
                     <profile name="" format="AUDIO_FORMAT_PCM_16_BIT"
                              samplingRates="48000" channelMasks="AUDIO_CHANNEL_OUT_STEREO"/>
                 </devicePort>
@@ -316,27 +319,8 @@
                              samplingRates="8000,16000,48000" channelMasks="AUDIO_CHANNEL_IN_MONO"/>
                 </devicePort>
                 <devicePort tagName="USB Device In" type="AUDIO_DEVICE_IN_USB_DEVICE" role="source">
-                    <profile name="" format="AUDIO_FORMAT_PCM_16_BIT"
-                             samplingRates="44100,48000,64000,88200,96000,128000,176400,192000" channelMasks="AUDIO_CHANNEL_IN_MONO,AUDIO_CHANNEL_IN_STEREO,AUDIO_CHANNEL_INDEX_MASK_6,AUDIO_CHANNEL_IN_7POINT1,AUDIO_CHANNEL_INDEX_MASK_8"/>
-                    <profile name="" format="AUDIO_FORMAT_PCM_8_24_BIT"
-                             samplingRates="44100,48000,64000,88200,96000,128000,176400,192000"
-                             channelMasks="AUDIO_CHANNEL_IN_MONO,AUDIO_CHANNEL_IN_STEREO,AUDIO_CHANNEL_INDEX_MASK_6,AUDIO_CHANNEL_IN_7POINT1,AUDIO_CHANNEL_INDEX_MASK_8"/>
-                    <!-- edit as needed -->
-                    <profile name="" format="AUDIO_FORMAT_PCM_32_BIT"
-                             samplingRates="44100,48000,64000,88200,96000,128000,176400,192000"
-                             channelMasks="AUDIO_CHANNEL_IN_MONO,AUDIO_CHANNEL_IN_STEREO,AUDIO_CHANNEL_INDEX_MASK_6,AUDIO_CHANNEL_IN_7POINT1,AUDIO_CHANNEL_INDEX_MASK_8"/>
                 </devicePort>
                 <devicePort tagName="USB Headset In" type="AUDIO_DEVICE_IN_USB_HEADSET" role="source">
-                    <profile name="" format="AUDIO_FORMAT_PCM_16_BIT"
-                             samplingRates="44100,48000,64000,88200,96000,128000,176400,192000"
-                             channelMasks="AUDIO_CHANNEL_IN_MONO,AUDIO_CHANNEL_IN_STEREO,AUDIO_CHANNEL_INDEX_MASK_6,AUDIO_CHANNEL_IN_7POINT1,AUDIO_CHANNEL_INDEX_MASK_8"/>
-                    <profile name="" format="AUDIO_FORMAT_PCM_8_24_BIT"
-                             samplingRates="44100,48000,64000,88200,96000,128000,176400,192000"
-                             channelMasks="AUDIO_CHANNEL_IN_MONO,AUDIO_CHANNEL_IN_STEREO,AUDIO_CHANNEL_INDEX_MASK_6,AUDIO_CHANNEL_IN_7POINT1,AUDIO_CHANNEL_INDEX_MASK_8"/>
-                    <!-- edit as needed -->
-                    <profile name="" format="AUDIO_FORMAT_PCM_32_BIT"
-                             samplingRates="44100,48000,64000,88200,96000,128000,176400,192000"
-                             channelMasks="AUDIO_CHANNEL_IN_MONO,AUDIO_CHANNEL_IN_STEREO,AUDIO_CHANNEL_INDEX_MASK_6,AUDIO_CHANNEL_IN_7POINT1,AUDIO_CHANNEL_INDEX_MASK_8"/>
                 </devicePort>
 
             </devicePorts>
diff --git a/configs/lito/lito.mk b/configs/lito/lito.mk
index 45258f0..00876db 100644
--- a/configs/lito/lito.mk
+++ b/configs/lito/lito.mk
@@ -81,6 +81,8 @@
 AUDIO_FEATURE_ENABLED_BATTERY_LISTENER := true
 ##AUDIO_FEATURE_FLAGS
 
+BOARD_SUPPORTS_OPENSOURCE_STHAL := true
+
 AUDIO_HARDWARE := audio.a2dp.default
 AUDIO_HARDWARE += audio.usb.default
 AUDIO_HARDWARE += audio.r_submix.default
@@ -177,7 +179,8 @@
     vendor/qcom/opensource/audio-hal/primary-hal/configs/lito/mixer_paths_qrd.xml:$(TARGET_COPY_OUT_VENDOR)/etc/mixer_paths_qrd.xml \
     vendor/qcom/opensource/audio-hal/primary-hal/configs/lito/audio_configs.xml:$(TARGET_COPY_OUT_VENDOR)/etc/audio_configs.xml \
     vendor/qcom/opensource/audio-hal/primary-hal/configs/lito/audio_configs_stock.xml:$(TARGET_COPY_OUT_VENDOR)/etc/audio_configs_stock.xml \
-    frameworks/native/data/etc/android.hardware.audio.pro.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/android.hardware.audio.pro.xml
+    frameworks/native/data/etc/android.hardware.audio.pro.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/android.hardware.audio.pro.xml \
+    frameworks/native/data/etc/android.hardware.audio.low_latency.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/android.hardware.audio.low_latency.xml
 
 #XML Audio configuration files
 ifneq ($(TARGET_USES_AOSP_FOR_AUDIO), true)
@@ -282,7 +285,7 @@
 
 #enable pbe effects
 PRODUCT_PROPERTY_OVERRIDES += \
-vendor.audio.safx.pbe.enabled=true
+vendor.audio.safx.pbe.enabled=false
 
 #parser input buffer size(256kb) in byte stream mode
 PRODUCT_PROPERTY_OVERRIDES += \
@@ -382,7 +385,6 @@
 vendor.audio.feature.a2dp_offload.enable=true \
 vendor.audio.feature.afe_proxy.enable=true \
 vendor.audio.feature.anc_headset.enable=true \
-vendor.audio.feature.audio_sphere.enable=true \
 vendor.audio.feature.battery_listener.enable=true \
 vendor.audio.feature.compr_cap.enable=false \
 vendor.audio.feature.compress_in.enable=true \
@@ -393,7 +395,7 @@
 vendor.audio.feature.display_port.enable=true \
 vendor.audio.feature.dsm_feedback.enable=false \
 vendor.audio.feature.dynamic_ecns.enable=true \
-vendor.audio.feature.ext_hw_plugin.enable=true \
+vendor.audio.feature.ext_hw_plugin.enable=false \
 vendor.audio.feature.external_dsp.enable=false \
 vendor.audio.feature.external_speaker.enable=false \
 vendor.audio.feature.external_speaker_tfa.enable=false \
diff --git a/configs/lito/mixer_paths.xml b/configs/lito/mixer_paths.xml
index 8688745..ec6be2e 100644
--- a/configs/lito/mixer_paths.xml
+++ b/configs/lito/mixer_paths.xml
@@ -2027,8 +2027,6 @@
         <ctl name="RX INT1_1 MIX1 INP0" value="RX1" />
         <ctl name="RX INT0 DEM MUX" value="CLSH_DSM_OUT" />
         <ctl name="RX INT1 DEM MUX" value="CLSH_DSM_OUT" />
-        <ctl name="RX_HPH_PWR_MODE" value="LOHIFI" />
-        <ctl name="RX HPH Mode" value="CLS_H_LOHIFI" />
         <ctl name="RX_COMP1 Switch" value="1" />
         <ctl name="RX_COMP2 Switch" value="1" />
         <ctl name="HPHL_COMP Switch" value="1" />
diff --git a/configs/lito/mixer_paths_qrd.xml b/configs/lito/mixer_paths_qrd.xml
index a6bdeae..b246c5a 100644
--- a/configs/lito/mixer_paths_qrd.xml
+++ b/configs/lito/mixer_paths_qrd.xml
@@ -2284,7 +2284,7 @@
     </path>
 
     <path name="speaker-protected">
-        <ctl name="WSA_AIF_VI Mixer WSA_SPKR_VI_1" value="1" />
+        <ctl name="WSA_AIF_VI Mixer WSA_SPKR_VI_2" value="1" />
         <ctl name="WSA_CDC_DMA_0 TX Format" value="PACKED_16B" />
         <path name="speaker" />
         <ctl name="VI_FEED_TX Channels" value="One" />
@@ -2292,7 +2292,7 @@
     </path>
 
     <path name="voice-speaker-protected">
-        <ctl name="WSA_AIF_VI Mixer WSA_SPKR_VI_1" value="1" />
+        <ctl name="WSA_AIF_VI Mixer WSA_SPKR_VI_2" value="1" />
         <ctl name="WSA_CDC_DMA_0 TX Format" value="PACKED_16B" />
         <path name="speaker-mono" />
         <ctl name="VI_FEED_TX Channels" value="One" />
@@ -2342,8 +2342,6 @@
         <ctl name="RX INT1_1 MIX1 INP0" value="RX1" />
         <ctl name="RX INT0 DEM MUX" value="CLSH_DSM_OUT" />
         <ctl name="RX INT1 DEM MUX" value="CLSH_DSM_OUT" />
-        <ctl name="RX_HPH_PWR_MODE" value="LOHIFI" />
-        <ctl name="RX HPH Mode" value="CLS_H_LOHIFI" />
         <ctl name="RX_COMP1 Switch" value="1" />
         <ctl name="RX_COMP2 Switch" value="1" />
         <ctl name="HPHL_COMP Switch" value="1" />
@@ -2381,6 +2379,10 @@
         <path name="handset" />
     </path>
 
+    <path name="voice-handset-tmus">
+        <path name="handset" />
+    </path>
+
     <path name="voice-speaker">
         <path name="speaker-mono" />
     </path>
@@ -2607,8 +2609,8 @@
          <ctl name="TX DMIC MUX1" value="DMIC1" />
          <ctl name="TX_AIF1_CAP Mixer DEC2" value="1" />
          <ctl name="TX DMIC MUX2" value="DMIC3" />
-         <ctl name="TX_AIF1_CAP Mixer DEC4" value="1" />
-         <ctl name="TX DMIC MUX2" value="DMIC3" />
+         <ctl name="TX_AIF1_CAP Mixer DEC3" value="1" />
+         <ctl name="TX DMIC MUX3" value="DMIC4" />
     </path>
 
     <path name="voice-speaker-qmic">
diff --git a/configs/lito/sound_trigger_mixer_paths_qrd.xml b/configs/lito/sound_trigger_mixer_paths_qrd.xml
index ccbdd94..8e6513c 100644
--- a/configs/lito/sound_trigger_mixer_paths_qrd.xml
+++ b/configs/lito/sound_trigger_mixer_paths_qrd.xml
@@ -234,13 +234,13 @@
         <ctl name="VA_CDC_DMA_TX_0 Channels" value="Three" />
         <ctl name="VA_AIF1_CAP Mixer DEC0" value="1" />
         <ctl name="VA_AIF1_CAP Mixer DEC1" value="1" />
-        <ctl name="VA_AIF1_CAP Mixer DEC5" value="1" />
+        <ctl name="VA_AIF1_CAP Mixer DEC2" value="1" />
         <ctl name="VA DEC0 MUX" value="MSM_DMIC" />
         <ctl name="VA DEC1 MUX" value="MSM_DMIC" />
-        <ctl name="VA DEC5 MUX" value="MSM_DMIC" />
+        <ctl name="VA DEC2 MUX" value="MSM_DMIC" />
         <ctl name="VA DMIC MUX0" value="DMIC1" />
         <ctl name="VA DMIC MUX1" value="DMIC2" />
-        <ctl name="VA DMIC MUX5" value="DMIC5" />
+        <ctl name="VA DMIC MUX2" value="DMIC4" />
     </path>
 
     <path name="listen-ape-handset-qmic">
@@ -248,15 +248,15 @@
         <ctl name="VA_AIF1_CAP Mixer DEC0" value="1" />
         <ctl name="VA_AIF1_CAP Mixer DEC1" value="1" />
         <ctl name="VA_AIF1_CAP Mixer DEC2" value="1" />
-        <ctl name="VA_AIF1_CAP Mixer DEC5" value="1" />
+        <ctl name="VA_AIF1_CAP Mixer DEC3" value="1" />
         <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 DEC5 MUX" value="MSM_DMIC" />
+        <ctl name="VA DEC3 MUX" value="MSM_DMIC" />
         <ctl name="VA DMIC MUX0" value="DMIC1" />
         <ctl name="VA DMIC MUX1" value="DMIC2" />
         <ctl name="VA DMIC MUX2" value="DMIC3" />
-        <ctl name="VA DMIC MUX5" value="DMIC5" />
+        <ctl name="VA DMIC MUX3" value="DMIC4" />
     </path>
 
     <path name="listen-ape-headset-mic">
diff --git a/configs/msm8937/msm8937.mk b/configs/msm8937/msm8937.mk
index 72fa6f3..a41740f 100644
--- a/configs/msm8937/msm8937.mk
+++ b/configs/msm8937/msm8937.mk
@@ -199,10 +199,6 @@
 vendor.audio.use.sw.alac.decoder=true\
 vendor.audio.use.sw.ape.decoder=true
 
-#property for AudioSphere Post processing
-PRODUCT_PROPERTY_OVERRIDES += \
-vendor.audio.pp.asphere.enabled=false
-
 #Audio voice concurrency related flags
 PRODUCT_PROPERTY_OVERRIDES += \
 vendor.voice.playback.conc.disabled=true\
@@ -245,7 +241,6 @@
 vendor.audio.feature.a2dp_offload.enable=false \
 vendor.audio.feature.afe_proxy.enable=true \
 vendor.audio.feature.anc_headset.enable=true \
-vendor.audio.feature.audio_sphere.enable=true \
 vendor.audio.feature.battery_listener.enable=false \
 vendor.audio.feature.compr_cap.enable=false \
 vendor.audio.feature.compress_in.enable=false \
diff --git a/configs/msm8953/msm8953.mk b/configs/msm8953/msm8953.mk
index 25d42cf..0b0e6be 100644
--- a/configs/msm8953/msm8953.mk
+++ b/configs/msm8953/msm8953.mk
@@ -212,10 +212,6 @@
 vendor.audio.use.sw.alac.decoder=true\
 vendor.audio.use.sw.ape.decoder=true
 
-#property for AudioSphere Post processing
-PRODUCT_PROPERTY_OVERRIDES += \
-vendor.audio.pp.asphere.enabled=false
-
 #Audio voice concurrency related flags
 PRODUCT_PROPERTY_OVERRIDES += \
 vendor.voice.playback.conc.disabled=true\
diff --git a/configs/msm8998/msm8998.mk b/configs/msm8998/msm8998.mk
index bee32c8..6b77f69 100644
--- a/configs/msm8998/msm8998.mk
+++ b/configs/msm8998/msm8998.mk
@@ -191,7 +191,7 @@
 
 #enable pbe effects
 PRODUCT_PROPERTY_OVERRIDES += \
-vendor.audio.safx.pbe.enabled=true
+vendor.audio.safx.pbe.enabled=false
 
 #parser input buffer size(256kb) in byte stream mode
 PRODUCT_PROPERTY_OVERRIDES += \
@@ -255,7 +255,6 @@
 vendor.audio.feature.a2dp_offload.enable=true \
 vendor.audio.feature.afe_proxy.enable=true \
 vendor.audio.feature.anc_headset.enable=true \
-vendor.audio.feature.audio_sphere.enable=true \
 vendor.audio.feature.battery_listener.enable=false \
 vendor.audio.feature.compr_cap.enable=false \
 vendor.audio.feature.compress_in.enable=false \
diff --git a/configs/msmnile/audio_platform_info.xml b/configs/msmnile/audio_platform_info.xml
index 6bfadc8..80924e2 100644
--- a/configs/msmnile/audio_platform_info.xml
+++ b/configs/msmnile/audio_platform_info.xml
@@ -143,7 +143,9 @@
         <device name="SND_DEVICE_OUT_VOICE_ANC_FB_HEADSET" backend="headphones" interface="SLIMBUS_6_RX"/>
         <device name="SND_DEVICE_OUT_VOICE_LINE" backend="headphones" interface="SLIMBUS_6_RX"/>
         <device name="SND_DEVICE_OUT_VOICE_TTY_FULL_HEADPHONES" backend="headphones" interface="SLIMBUS_6_RX"/>
+        <device name="SND_DEVICE_OUT_VOICE_TTY_FULL_HEADSET" backend="headset" interface="SLIMBUS_6_RX"/>
         <device name="SND_DEVICE_OUT_VOICE_TTY_VCO_HEADPHONES" backend="headphones" interface="SLIMBUS_6_RX"/>
+        <device name="SND_DEVICE_OUT_VOICE_TTY_VCO_HEADSET" backend="headset" interface="SLIMBUS_6_RX"/>
         <device name="SND_DEVICE_OUT_SPEAKER_AND_BT_SCO" backend="speaker-and-bt-sco" interface="SLIMBUS_0_RX-and-SLIMBUS_7_RX"/>
         <device name="SND_DEVICE_OUT_SPEAKER_AND_BT_SCO_WB" backend="speaker-and-bt-sco-wb" interface="SLIMBUS_0_RX-and-SLIMBUS_7_RX"/>
         <device name="SND_DEVICE_IN_HEADSET_MIC" backend="headset-mic" interface="SLIMBUS_1_TX"/>
diff --git a/configs/msmnile/audio_policy_configuration.xml b/configs/msmnile/audio_policy_configuration.xml
index 657b5d1..5c05206 100644
--- a/configs/msmnile/audio_policy_configuration.xml
+++ b/configs/msmnile/audio_policy_configuration.xml
@@ -311,27 +311,8 @@
                              samplingRates="8000,16000,48000" channelMasks="AUDIO_CHANNEL_IN_MONO"/>
                 </devicePort>
                 <devicePort tagName="USB Device In" type="AUDIO_DEVICE_IN_USB_DEVICE" role="source">
-                    <profile name="" format="AUDIO_FORMAT_PCM_16_BIT"
-                             samplingRates="44100,48000,64000,88200,96000,128000,176400,192000" channelMasks="AUDIO_CHANNEL_IN_MONO,AUDIO_CHANNEL_IN_STEREO,AUDIO_CHANNEL_INDEX_MASK_6,AUDIO_CHANNEL_IN_7POINT1,AUDIO_CHANNEL_INDEX_MASK_8"/>
-                    <profile name="" format="AUDIO_FORMAT_PCM_8_24_BIT"
-                             samplingRates="44100,48000,64000,88200,96000,128000,176400,192000"
-                             channelMasks="AUDIO_CHANNEL_IN_MONO,AUDIO_CHANNEL_IN_STEREO,AUDIO_CHANNEL_INDEX_MASK_6,AUDIO_CHANNEL_IN_7POINT1,AUDIO_CHANNEL_INDEX_MASK_8"/>
-                    <!-- edit as needed -->
-                    <profile name="" format="AUDIO_FORMAT_PCM_32_BIT"
-                             samplingRates="44100,48000,64000,88200,96000,128000,176400,192000"
-                             channelMasks="AUDIO_CHANNEL_IN_MONO,AUDIO_CHANNEL_IN_STEREO,AUDIO_CHANNEL_INDEX_MASK_6,AUDIO_CHANNEL_IN_7POINT1,AUDIO_CHANNEL_INDEX_MASK_8"/>
                 </devicePort>
                 <devicePort tagName="USB Headset In" type="AUDIO_DEVICE_IN_USB_HEADSET" role="source">
-                    <profile name="" format="AUDIO_FORMAT_PCM_16_BIT"
-                             samplingRates="44100,48000,64000,88200,96000,128000,176400,192000"
-                             channelMasks="AUDIO_CHANNEL_IN_MONO,AUDIO_CHANNEL_IN_STEREO,AUDIO_CHANNEL_INDEX_MASK_6,AUDIO_CHANNEL_IN_7POINT1,AUDIO_CHANNEL_INDEX_MASK_8"/>
-                    <profile name="" format="AUDIO_FORMAT_PCM_8_24_BIT"
-                             samplingRates="44100,48000,64000,88200,96000,128000,176400,192000"
-                             channelMasks="AUDIO_CHANNEL_IN_MONO,AUDIO_CHANNEL_IN_STEREO,AUDIO_CHANNEL_INDEX_MASK_6,AUDIO_CHANNEL_IN_7POINT1,AUDIO_CHANNEL_INDEX_MASK_8"/>
-                    <!-- edit as needed -->
-                    <profile name="" format="AUDIO_FORMAT_PCM_32_BIT"
-                             samplingRates="44100,48000,64000,88200,96000,128000,176400,192000"
-                             channelMasks="AUDIO_CHANNEL_IN_MONO,AUDIO_CHANNEL_IN_STEREO,AUDIO_CHANNEL_INDEX_MASK_6,AUDIO_CHANNEL_IN_7POINT1,AUDIO_CHANNEL_INDEX_MASK_8"/>
                 </devicePort>
 
             </devicePorts>
diff --git a/configs/msmnile/mixer_paths_tavil.xml b/configs/msmnile/mixer_paths_tavil.xml
index f2e4842..fb315bf 100644
--- a/configs/msmnile/mixer_paths_tavil.xml
+++ b/configs/msmnile/mixer_paths_tavil.xml
@@ -2988,11 +2988,21 @@
         <path name="tty-headphones" />
     </path>
 
+    <path name="voice-tty-full-headset">
+        <ctl name="TTY Mode" value="FULL" />
+        <path name="tty-headphones" />
+    </path>
+
     <path name="voice-tty-vco-headphones">
         <ctl name="TTY Mode" value="VCO" />
         <path name="tty-headphones" />
     </path>
 
+    <path name="voice-tty-vco-headset">
+        <ctl name="TTY Mode" value="VCO" />
+        <path name="tty-headphones" />
+    </path>
+
     <path name="voice-tty-hco-handset">
         <ctl name="TTY Mode" value="HCO" />
         <path name="handset" />
@@ -3011,7 +3021,7 @@
     <path name="voice-tty-full-headset-mic">
         <path name="amic2" />
         <ctl name="ADC2 Volume" value="0" />
-        <ctl name="DEC0 Volume" value="84" />
+        <ctl name="DEC1 Volume" value="84" />
     </path>
 
     <path name="voice-tty-hco-headset-mic">
diff --git a/configs/msmnile/msmnile.mk b/configs/msmnile/msmnile.mk
index 1764204..3315b11 100644
--- a/configs/msmnile/msmnile.mk
+++ b/configs/msmnile/msmnile.mk
@@ -176,7 +176,8 @@
     vendor/qcom/opensource/audio-hal/primary-hal/configs/msmnile/sound_trigger_mixer_paths.xml:$(TARGET_COPY_OUT_VENDOR)/etc/sound_trigger_mixer_paths.xml \
     vendor/qcom/opensource/audio-hal/primary-hal/configs/msmnile/audio_configs.xml:$(TARGET_COPY_OUT_VENDOR)/etc/audio_configs.xml \
     vendor/qcom/opensource/audio-hal/primary-hal/configs/msmnile/audio_configs_stock.xml:$(TARGET_COPY_OUT_VENDOR)/etc/audio_configs_stock.xml \
-    frameworks/native/data/etc/android.hardware.audio.pro.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/android.hardware.audio.pro.xml
+    frameworks/native/data/etc/android.hardware.audio.pro.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/android.hardware.audio.pro.xml \
+    frameworks/native/data/etc/android.hardware.audio.low_latency.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/android.hardware.audio.low_latency.xml
 
 #XML Audio configuration files
 ifneq ($(TARGET_USES_AOSP_FOR_AUDIO), true)
@@ -280,7 +281,7 @@
 
 #enable pbe effects
 PRODUCT_PROPERTY_OVERRIDES += \
-vendor.audio.safx.pbe.enabled=true
+vendor.audio.safx.pbe.enabled=false
 
 #parser input buffer size(256kb) in byte stream mode
 PRODUCT_PROPERTY_OVERRIDES += \
@@ -379,7 +380,6 @@
 vendor.audio.feature.a2dp_offload.enable=true \
 vendor.audio.feature.afe_proxy.enable=false \
 vendor.audio.feature.anc_headset.enable=false \
-vendor.audio.feature.audio_sphere.enable=false \
 vendor.audio.feature.battery_listener.enable=false \
 vendor.audio.feature.compr_cap.enable=false \
 vendor.audio.feature.compress_in.enable=false \
@@ -424,7 +424,6 @@
 vendor.audio.feature.a2dp_offload.enable=true \
 vendor.audio.feature.afe_proxy.enable=true \
 vendor.audio.feature.anc_headset.enable=true \
-vendor.audio.feature.audio_sphere.enable=true \
 vendor.audio.feature.battery_listener.enable=true \
 vendor.audio.feature.compr_cap.enable=false \
 vendor.audio.feature.compress_in.enable=true \
@@ -481,6 +480,15 @@
     vendor.qti.hardware.audiohalext@1.0-impl \
     vendor.qti.hardware.audiohalext-utils
 
+# enable audio hidl hal 5.0
+PRODUCT_PACKAGES += \
+    android.hardware.audio@5.0 \
+    android.hardware.audio.common@5.0 \
+    android.hardware.audio.common@5.0-util \
+    android.hardware.audio@5.0-impl \
+    android.hardware.audio.effect@5.0 \
+    android.hardware.audio.effect@5.0-impl
+
 PRODUCT_PACKAGES_ENG += \
     VoicePrintTest \
     VoicePrintDemo
diff --git a/configs/msmnile/sound_trigger_platform_info.xml b/configs/msmnile/sound_trigger_platform_info.xml
index 8468452..7d5e81f 100644
--- a/configs/msmnile/sound_trigger_platform_info.xml
+++ b/configs/msmnile/sound_trigger_platform_info.xml
@@ -35,6 +35,7 @@
 <!--- added to <adm_config>                                                     -->
 
     <common_config>
+        <param implementer_version="0x0100" />
         <param max_cpe_sessions="1" />
         <param max_wdsp_sessions="2" />
         <param max_ape_sessions="8" />
diff --git a/configs/msmnile_au/audio_platform_info.xml b/configs/msmnile_au/audio_platform_info.xml
index 1dbaac1..e02397c 100644
--- a/configs/msmnile_au/audio_platform_info.xml
+++ b/configs/msmnile_au/audio_platform_info.xml
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="ISO-8859-1"?>
-<!-- Copyright (c) 2014, 2016-2018, The Linux Foundation. All rights reserved. -->
+<!-- Copyright (c) 2014, 2016-2019, 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 -->
@@ -29,6 +29,10 @@
         <device name="SND_DEVICE_OUT_HANDSET" acdb_id="78"/>
         <device name="SND_DEVICE_OUT_SPEAKER" acdb_id="78"/>
         <device name="SND_DEVICE_OUT_HEADPHONES" acdb_id="78"/>
+        <device name="SND_DEVICE_OUT_BUS_MEDIA" acdb_id="78"/>
+        <device name="SND_DEVICE_OUT_BUS_SYS" acdb_id="78"/>
+        <device name="SND_DEVICE_OUT_BUS_NAV" acdb_id="14"/>
+        <device name="SND_DEVICE_OUT_BUS_PHN" acdb_id="94"/>
         <device name="SND_DEVICE_OUT_BT_SCO" acdb_id="94"/>
         <device name="SND_DEVICE_OUT_BT_SCO_WB" acdb_id="94"/>
         <device name="SND_DEVICE_OUT_BT_A2DP" acdb_id="78"/>
@@ -36,6 +40,7 @@
         <device name="SND_DEVICE_OUT_VOICE_SPEAKER" acdb_id="94"/>
         <device name="SND_DEVICE_IN_HANDSET_MIC" acdb_id="11"/>
         <device name="SND_DEVICE_IN_SPEAKER_MIC" acdb_id="11"/>
+        <device name="SND_DEVICE_IN_BUS" acdb_id="11"/>
         <device name="SND_DEVICE_IN_HEADSET_MIC" acdb_id="11"/>
         <device name="SND_DEVICE_IN_VOICE_SPEAKER_MIC" acdb_id="95"/>
         <device name="SND_DEVICE_IN_VOICE_HEADSET_MIC" acdb_id="95"/>
diff --git a/configs/msmnile_au/audio_policy_configuration.xml b/configs/msmnile_au/audio_policy_configuration.xml
index e4aec16..b00e62f 100644
--- a/configs/msmnile_au/audio_policy_configuration.xml
+++ b/configs/msmnile_au/audio_policy_configuration.xml
@@ -23,7 +23,6 @@
     <!-- Global configuration Decalaration -->
     <globalConfiguration speaker_drc_enabled="true"/>
 
-
     <!-- Modules section:
         There is one section per audio HW module present on the platform.
         Each module section will contains two mandatory tags for audio HAL “halVersion” and “name”.
@@ -33,6 +32,11 @@
         “devicePorts”: a list of device descriptors for all input and output devices accessible via this
         module.
         This contains both permanently attached devices and removable devices.
+            "gain": constraints applied to the millibel values:
+                - maxValueMB >= minValueMB
+                - defaultValueMB >= minValueMB && defaultValueMB <= maxValueMB
+                - (maxValueMB - minValueMB) % stepValueMB == 0
+                - (defaultValueMB - minValueMB) % stepValueMB == 0
         “mixPorts”: listing all output and input streams exposed by the audio HAL
         “routes”: list of possible connections between input and output devices or between stream and
         devices.
@@ -47,18 +51,37 @@
     -->
     <modules>
         <!-- Primary Audio HAL -->
-        <module name="primary" halVersion="2.0">
+        <module name="primary" halVersion="3.0">
             <attachedDevices>
-                <item>Earpiece</item>
-                <item>Speaker</item>
+                <item>Media Bus</item>
+                <item>Sys Notification Bus</item>
+                <item>Nav Guidance Bus</item>
+                <item>Phone Bus</item>
                 <item>Telephony Tx</item>
                 <item>Built-In Mic</item>
                 <item>Built-In Back Mic</item>
                 <item>FM Tuner</item>
                 <item>Telephony Rx</item>
             </attachedDevices>
-            <defaultOutputDevice>Speaker</defaultOutputDevice>
+            <defaultOutputDevice>Media Bus</defaultOutputDevice>
             <mixPorts>
+                <mixPort name="media" role="source"
+                         flags="AUDIO_OUTPUT_FLAG_PRIMARY">
+                    <profile name="" format="AUDIO_FORMAT_PCM_16_BIT"
+                             samplingRates="48000" channelMasks="AUDIO_CHANNEL_OUT_STEREO"/>
+                </mixPort>
+                <mixPort name="sys_notification" role="source">
+                    <profile name="" format="AUDIO_FORMAT_PCM_16_BIT"
+                             samplingRates="48000" channelMasks="AUDIO_CHANNEL_OUT_STEREO"/>
+                </mixPort>
+                <mixPort name="nav_guidance" role="source">
+                    <profile name="" format="AUDIO_FORMAT_PCM_16_BIT"
+                             samplingRates="48000" channelMasks="AUDIO_CHANNEL_OUT_STEREO"/>
+                </mixPort>
+                <mixPort name="phone" role="source">
+                    <profile name="" format="AUDIO_FORMAT_PCM_16_BIT"
+                             samplingRates="48000" channelMasks="AUDIO_CHANNEL_OUT_STEREO"/>
+                </mixPort>
                 <mixPort name="primary output" role="source" flags="AUDIO_OUTPUT_FLAG_FAST|AUDIO_OUTPUT_FLAG_PRIMARY">
                     <profile name="" format="AUDIO_FORMAT_PCM_16_BIT"
                              samplingRates="48000" channelMasks="AUDIO_CHANNEL_OUT_STEREO"/>
@@ -145,6 +168,12 @@
                     <profile name="" format="AUDIO_FORMAT_AAC_ADTS_HE_V2"
                              samplingRates="8000,11025,12000,16000,22050,24000,32000,44100,48000,64000,88200,96000"
                              channelMasks="AUDIO_CHANNEL_OUT_STEREO,AUDIO_CHANNEL_OUT_MONO"/>
+                    <profile name="" format="AUDIO_FORMAT_PCM_16_BIT"
+                             samplingRates="8000,11025,12000,16000,22050,24000,32000,44100,48000,64000,88200,96000,128000,176400,192000"
+                            channelMasks="AUDIO_CHANNEL_OUT_MONO,AUDIO_CHANNEL_OUT_STEREO,AUDIO_CHANNEL_OUT_2POINT1,AUDIO_CHANNEL_OUT_QUAD,AUDIO_CHANNEL_OUT_PENTA,AUDIO_CHANNEL_OUT_5POINT1,AUDIO_CHANNEL_OUT_6POINT1,AUDIO_CHANNEL_OUT_7POINT1"/>
+                    <profile name="" format="AUDIO_FORMAT_PCM_24_BIT_PACKED"
+                            samplingRates="8000,11025,12000,16000,22050,24000,32000,44100,48000,64000,88200,96000,128000,176400,192000"
+                            channelMasks="AUDIO_CHANNEL_OUT_MONO,AUDIO_CHANNEL_OUT_STEREO,AUDIO_CHANNEL_OUT_2POINT1,AUDIO_CHANNEL_OUT_QUAD,AUDIO_CHANNEL_OUT_PENTA,AUDIO_CHANNEL_OUT_5POINT1,AUDIO_CHANNEL_OUT_6POINT1,AUDIO_CHANNEL_OUT_7POINT1"/>
                 </mixPort>
                 <mixPort name="dsd_compress_passthrough" role="source"
                          flags="AUDIO_OUTPUT_FLAG_DIRECT|AUDIO_OUTPUT_FLAG_COMPRESS_OFFLOAD|AUDIO_OUTPUT_FLAG_NON_BLOCKING">
@@ -197,6 +226,42 @@
 
             <devicePorts>
                 <!-- Output devices declaration, i.e. Sink DEVICE PORT -->
+                <devicePort tagName="Media Bus" role="sink" type="AUDIO_DEVICE_OUT_BUS"
+                        address="BUS00_MEDIA">
+                    <profile name="" format="AUDIO_FORMAT_PCM_16_BIT"
+                             samplingRates="48000" channelMasks="AUDIO_CHANNEL_OUT_STEREO"/>
+                    <gains>
+                        <gain name="" mode="AUDIO_GAIN_MODE_JOINT"
+                                minValueMB="-6000" maxValueMB="600" defaultValueMB="0" stepValueMB="100"/>
+                    </gains>
+                </devicePort>
+                <devicePort tagName="Sys Notification Bus" role="sink" type="AUDIO_DEVICE_OUT_BUS"
+                        address="BUS01_SYS_NOTIFICATION">
+                    <profile name="" format="AUDIO_FORMAT_PCM_16_BIT"
+                             samplingRates="48000" channelMasks="AUDIO_CHANNEL_OUT_STEREO"/>
+                    <gains>
+                        <gain name="" mode="AUDIO_GAIN_MODE_JOINT"
+                                minValueMB="-6000" maxValueMB="600" defaultValueMB="0" stepValueMB="100"/>
+                    </gains>
+                </devicePort>
+                <devicePort tagName="Nav Guidance Bus" role="sink" type="AUDIO_DEVICE_OUT_BUS"
+                        address="BUS02_NAV_GUIDANCE">
+                    <profile name="" format="AUDIO_FORMAT_PCM_16_BIT"
+                             samplingRates="48000" channelMasks="AUDIO_CHANNEL_OUT_STEREO"/>
+                    <gains>
+                        <gain name="" mode="AUDIO_GAIN_MODE_JOINT"
+                                minValueMB="-6000" maxValueMB="600" defaultValueMB="0" stepValueMB="100"/>
+                    </gains>
+                </devicePort>
+                <devicePort tagName="Phone Bus" role="sink" type="AUDIO_DEVICE_OUT_BUS"
+                        address="BUS03_PHONE">
+                    <profile name="" format="AUDIO_FORMAT_PCM_16_BIT"
+                             samplingRates="48000" channelMasks="AUDIO_CHANNEL_OUT_STEREO"/>
+                    <gains>
+                        <gain name="" mode="AUDIO_GAIN_MODE_JOINT"
+                                minValueMB="-6000" maxValueMB="600" defaultValueMB="0" stepValueMB="100"/>
+                    </gains>
+                </devicePort>
                 <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"/>
@@ -295,6 +360,14 @@
             </devicePorts>
             <!-- route declaration, i.e. list all available sources for a given sink -->
             <routes>
+                <route type="mix" sink="Media Bus"
+                       sources="media,direct_pcm,compressed_offload,voip_rx,mmap_no_irq_out"/>
+                <route type="mix" sink="Sys Notification Bus"
+                       sources="sys_notification"/>
+                <route type="mix" sink="Nav Guidance Bus"
+                       sources="nav_guidance"/>
+                <route type="mix" sink="Phone Bus"
+                       sources="phone"/>
                 <route type="mix" sink="Earpiece"
                        sources="primary output,raw,deep_buffer,direct_pcm,compressed_offload,voip_rx,mmap_no_irq_out"/>
                 <route type="mix" sink="Speaker"
diff --git a/configs/msmnile_au/mixer_paths_adp.xml b/configs/msmnile_au/mixer_paths_adp.xml
index b07e235..63012be 100644
--- a/configs/msmnile_au/mixer_paths_adp.xml
+++ b/configs/msmnile_au/mixer_paths_adp.xml
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="ISO-8859-1"?>
-<!-- Copyright (c) 2016-2018, The Linux Foundation. All rights reserved.    -->
+<!-- Copyright (c) 2016-2019, 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 -->
@@ -329,6 +329,8 @@
     <path name="deep-buffer-playback">
         <ctl name="TERT_TDM_RX_0 Channels" value="Six" />
         <ctl name="TERT_TDM_RX_0 Audio Mixer MultiMedia1" value="1" />
+        <ctl name="QUAT_TDM_RX_0 Channels" value="Six" />
+        <ctl name="QUAT_TDM_RX_0 Audio Mixer MultiMedia1" value="1" />
     </path>
 
     <path name="deep-buffer-playback speaker-protected">
@@ -525,6 +527,8 @@
     <path name="compress-offload-playback">
         <ctl name="TERT_TDM_RX_0 Channels" value="Six" />
         <ctl name="TERT_TDM_RX_0 Audio Mixer MultiMedia4" value="1" />
+        <ctl name="QUAT_TDM_RX_0 Channels" value="Six" />
+        <ctl name="QUAT_TDM_RX_0 Audio Mixer MultiMedia4" value="1" />
     </path>
 
     <path name="compress-offload-playback speaker-protected">
@@ -600,6 +604,8 @@
     <path name="compress-offload-playback2">
         <ctl name="TERT_TDM_RX_0 Channels" value="Six" />
         <ctl name="TERT_TDM_RX_0 Audio Mixer MultiMedia7" value="1" />
+        <ctl name="QUAT_TDM_RX_0 Channels" value="Six" />
+        <ctl name="QUAT_TDM_RX_0 Audio Mixer MultiMedia7" value="1" />
     </path>
 
     <path name="compress-offload-playback2 display-port">
@@ -1134,6 +1140,27 @@
         <path name="compress-offload-playback9" />
     </path>
 
+    <!-- The following use cases are used for car streams  -->
+    <path name="media-playback">
+        <ctl name="TERT_TDM_RX_0 Channels" value="Six" />
+        <ctl name="TERT_TDM_RX_0 Audio Mixer MultiMedia1" value="1" />
+    </path>
+
+    <path name="sys-notification-playback">
+        <ctl name="TERT_TDM_RX_0 Channels" value="Six" />
+        <ctl name="TERT_TDM_RX_0 Audio Mixer MultiMedia5" value="1" />
+    </path>
+
+    <path name="nav-guidance-playback">
+        <ctl name="TERT_TDM_RX_1 Channels" value="One" />
+        <ctl name="TERT_TDM_RX_1 Audio Mixer MultiMedia2" value="1" />
+    </path>
+
+    <path name="phone-playback">
+        <ctl name="TERT_TDM_RX_2 Channels" value="One" />
+        <ctl name="TERT_TDM_RX_2 Audio Mixer MultiMedia10" value="1" />
+    </path>
+
     <path name="audio-record">
         <ctl name="TERT_TDM_TX_0 Channels" value="One" />
         <ctl name="MultiMedia1 Mixer TERT_TDM_TX_0" value="1" />
@@ -1621,9 +1648,15 @@
     </path>
 
     <path name="speaker-adp">
+        <!--ctl name="TERT_TDM_RX_0 Channels" value="Six" /-->
     </path>
 
     <path name="speaker-custom">
+        <!--ctl name="TERT_TDM_RX_0 Channels" value="Six" /-->
+    </path>
+
+    <path name="bus-speaker">
+        <!--ctl name="TERT_TDM_RX_0 Channels" value="Six" /-->
     </path>
 
    <path name="sidetone-iir">
diff --git a/configs/msmnile_au/mixer_paths_custom.xml b/configs/msmnile_au/mixer_paths_custom.xml
index d8e45cd..9d8507a 100644
--- a/configs/msmnile_au/mixer_paths_custom.xml
+++ b/configs/msmnile_au/mixer_paths_custom.xml
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="ISO-8859-1"?>
-<!-- Copyright (c) 2016-2018, The Linux Foundation. All rights reserved.    -->
+<!-- Copyright (c) 2016-2019, 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 -->
@@ -1130,6 +1130,27 @@
         <path name="compress-offload-playback9" />
     </path>
 
+    <!-- The following use cases are used for car streams  -->
+    <path name="media-playback">
+        <ctl name="TERT_TDM_RX_0 Channels" value="Six" />
+        <ctl name="TERT_TDM_RX_0 Audio Mixer MultiMedia1" value="1" />
+    </path>
+
+    <path name="sys-notification-playback">
+        <ctl name="TERT_TDM_RX_0 Channels" value="Six" />
+        <ctl name="TERT_TDM_RX_0 Audio Mixer MultiMedia5" value="1" />
+    </path>
+
+    <path name="nav-guidance-playback">
+        <ctl name="TERT_TDM_RX_1 Channels" value="One" />
+        <ctl name="TERT_TDM_RX_1 Audio Mixer MultiMedia2" value="1" />
+    </path>
+
+    <path name="phone-playback">
+        <ctl name="TERT_TDM_RX_2 Channels" value="One" />
+        <ctl name="TERT_TDM_RX_2 Audio Mixer MultiMedia10" value="1" />
+    </path>
+
     <path name="audio-record">
         <ctl name="TERT_TDM_TX_0 Channels" value="One" />
         <ctl name="MultiMedia1 Mixer TERT_TDM_TX_0" value="1" />
@@ -1617,9 +1638,15 @@
     </path>
 
     <path name="speaker-adp">
+        <!--ctl name="TERT_TDM_RX_0 Channels" value="Six" /-->
     </path>
 
     <path name="speaker-custom">
+        <!--ctl name="TERT_TDM_RX_0 Channels" value="Six" /-->
+    </path>
+
+    <path name="bus-speaker">
+        <!--ctl name="TERT_TDM_RX_0 Channels" value="Six" /-->
     </path>
 
    <path name="sidetone-iir">
diff --git a/configs/msmnile_au/msmnile_au.mk b/configs/msmnile_au/msmnile_au.mk
index c1b8630..394dfea 100644
--- a/configs/msmnile_au/msmnile_au.mk
+++ b/configs/msmnile_au/msmnile_au.mk
@@ -69,8 +69,8 @@
 AUDIO_FEATURE_ENABLED_BATTERY_LISTENER := false
 ##AUDIO_FEATURE_FLAGS
 
+AUDIO_FEATURE_ENABLED_AUTO_HAL := true
 AUDIO_FEATURE_ENABLED_EXT_HW_PLUGIN := true
-AUDIO_FEATURE_ENABLED_BUS_ADDRESS := true
 AUDIO_FEATURE_ENABLED_AUDIO_CONTROL_HAL := true
 ##AUTOMOTIVE_AUDIO_FEATURE_FLAGS
 
@@ -79,6 +79,9 @@
 DEVICE_PACKAGE_OVERLAYS += vendor/qcom/opensource/audio-hal/primary-hal/configs/common/overlay
 endif
 
+#Automotive audio specific device overlays
+DEVICE_PACKAGE_OVERLAYS += hardware/qcom/audio/configs/msmnile_au/overlay
+
 PRODUCT_COPY_FILES += \
     vendor/qcom/opensource/audio-hal/primary-hal/configs/msmnile_au/audio_output_policy.conf:$(TARGET_COPY_OUT_VENDOR)/etc/audio_output_policy.conf \
     vendor/qcom/opensource/audio-hal/primary-hal/configs/msmnile_au/audio_effects.conf:$(TARGET_COPY_OUT_VENDOR)/etc/audio_effects.conf \
@@ -111,6 +114,10 @@
 PRODUCT_COPY_FILES += \
     vendor/qcom/opensource/audio-hal/primary-hal/configs/msmnile_au/listen_platform_info.xml:$(TARGET_COPY_OUT_VENDOR)/etc/listen_platform_info.xml
 
+#Audio HAL version
+PRODUCT_PROPERTY_OVERRIDES += \
+vendor.audio.hal.maj.version=3
+
 # Reduce client buffer size for fast audio output tracks
 PRODUCT_PROPERTY_OVERRIDES += \
     af.fast_track_multiplier=1
@@ -188,6 +195,14 @@
 PRODUCT_PROPERTY_OVERRIDES += \
 vendor.audio.parser.ip.buffer.size=262144
 
+#Enable 16 bit PCM offload by default
+PRODUCT_PROPERTY_OVERRIDES += \
+audio.offload.pcm.16bit.enable=true
+
+#Enable 24 bit PCM offload by default
+PRODUCT_PROPERTY_OVERRIDES += \
+audio.offload.pcm.24bit.enable=true
+
 #flac sw decoder 24 bit decode capability
 PRODUCT_PROPERTY_OVERRIDES += \
 vendor.audio.flac.sw.decoder.24bit=true
@@ -274,3 +289,21 @@
     android.hardware.audio@4.0-impl \
     android.hardware.audio.effect@4.0 \
     android.hardware.audio.effect@4.0-impl
+
+# for HIDL related audiocontrol packages
+PRODUCT_PACKAGES += \
+    vendor.qti.hardware.automotive.audiocontrol@1.0-service \
+    android.hardware.automotive.audiocontrol@1.0
+
+ifeq ($(ENABLE_HYP),true)
+PRODUCT_PROPERTY_OVERRIDES += \
+persist.vendor.audio.calfile0=/vendor/etc/acdbdata/adsp_avs_config.acdb\
+persist.vendor.audio.calfile1=/vendor/etc/acdbdata/ADP/Bluetooth_cal.acdb\
+persist.vendor.audio.calfile2=/vendor/etc/acdbdata/ADP/Codec_cal.acdb\
+persist.vendor.audio.calfile3=/vendor/etc/acdbdata/ADP/General_cal.acdb\
+persist.vendor.audio.calfile4=/vendor/etc/acdbdata/ADP/Global_cal.acdb\
+persist.vendor.audio.calfile5=/vendor/etc/acdbdata/ADP/Handset_cal.acdb\
+persist.vendor.audio.calfile6=/vendor/etc/acdbdata/ADP/Hdmi_cal.acdb\
+persist.vendor.audio.calfile7=/vendor/etc/acdbdata/ADP/Headset_cal.acdb\
+persist.vendor.audio.calfile8=/vendor/etc/acdbdata/ADP/Speaker_cal.acdb
+endif
diff --git a/configs/msmnile_au/overlay/frameworks/base/core/res/res/values/config.xml b/configs/msmnile_au/overlay/frameworks/base/core/res/res/values/config.xml
new file mode 100644
index 0000000..0274f9e
--- /dev/null
+++ b/configs/msmnile_au/overlay/frameworks/base/core/res/res/values/config.xml
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+/*
+** Copyright (c) 2018-2019, The Linux Foundation. All rights reserved.
+** Not a Contribution.
+*/
+/*
+** Copyright 2009, The Android Open Source Project
+**
+** Licensed under the Apache License, Version 2.0 (the "License");
+** you may not use this file except in compliance with the License.
+** You may obtain a copy of the License at
+**
+**     http://www.apache.org/licenses/LICENSE-2.0
+**
+** Unless required by applicable law or agreed to in writing, software
+** distributed under the License is distributed on an "AS IS" BASIS,
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+** See the License for the specific language governing permissions and
+** limitations under the License.
+*/
+-->
+
+<resources>
+     <!-- Car uses hardware amplifier for volume. -->
+    <bool name="config_useFixedVolume">false</bool>
+    <!--
+      Handle volume keys directly in CarAudioService without passing them to the foreground app
+    -->
+    <bool name="config_handleVolumeKeysInWindowManager">true</bool>
+</resources>
diff --git a/configs/msmnile_au/overlay/packages/services/Car/service/res/values/config.xml b/configs/msmnile_au/overlay/packages/services/Car/service/res/values/config.xml
new file mode 100644
index 0000000..ac5f818
--- /dev/null
+++ b/configs/msmnile_au/overlay/packages/services/Car/service/res/values/config.xml
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+/*
+** Copyright (c) 2018-2019, The Linux Foundation. All rights reserved.
+** Not a Contribution.
+*/
+/*
+** Copyright 2015, The Android Open Source Project
+**
+** Licensed under the Apache License, Version 2.0 (the "License");
+** you may not use this file except in compliance with the License.
+** You may obtain a copy of the License at
+**
+**     http://www.apache.org/licenses/LICENSE-2.0
+**
+** Unless required by applicable law or agreed to in writing, software
+** distributed under the License is distributed on an "AS IS" BASIS,
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+** See the License for the specific language governing permissions and
+** limitations under the License.
+*/
+-->
+
+<!--
+  Overlay resources to configure car service based on each OEM's preference.
+  See also packages/services/Car/service/res/values/config.xml
+-->
+<resources>
+    <!--  Configuration to enable usage of dynamic audio routing. If this is set to false,
+          dynamic audio routing is disabled and audio works in legacy mode. It may be useful
+          during initial development where audio hal does not support bus based addressing yet. -->
+    <bool name="audioUseDynamicRouting">true</bool>
+</resources>
diff --git a/configs/msmnile_au/overlay/packages/services/Car/service/res/xml/car_volume_groups.xml b/configs/msmnile_au/overlay/packages/services/Car/service/res/xml/car_volume_groups.xml
new file mode 100644
index 0000000..850d4d4
--- /dev/null
+++ b/configs/msmnile_au/overlay/packages/services/Car/service/res/xml/car_volume_groups.xml
@@ -0,0 +1,57 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+     Copyright (c) 2018-2019, The Linux Foundation. All rights reserved.
+     Not a Contribution.
+
+     Copyright (C) 2018 The Android Open Source Project
+
+     Licensed under the Apache License, Version 2.0 (the "License");
+     you may not use this file except in compliance with the License.
+     You may obtain a copy of the License at
+
+          http://www.apache.org/licenses/LICENSE-2.0
+
+     Unless required by applicable law or agreed to in writing, software
+     distributed under the License is distributed on an "AS IS" BASIS,
+     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+     See the License for the specific language governing permissions and
+     limitations under the License.
+-->
+
+<!--
+  Defines the all available volume groups for volume control in a car.
+  One can overlay this configuration to customize the groups.
+
+  This configuration will be populated by CarAudioService and
+  surfaced to Car Settings App and/or other volume control interfaces.
+
+  Certain constraints applied to this configuration
+    - One context should not appear in two groups
+    - All contexts are assigned
+    - One bus should not appear in two groups
+    - All gain controllers (set on each bus) in one group have same step value
+
+  It is fine that there are buses that do not appear in any group, those buses
+  may be reserved for other usages.
+
+  Important note: when overlaying this configuration,
+  make sure the resources are in the same package as CarAudioService.
+-->
+<volumeGroups xmlns:car="http://schemas.android.com/apk/res-auto">
+    <group>
+        <context car:context="music"/>
+    </group>
+    <group>
+        <context car:context="call"/>
+        <context car:context="call_ring"/>
+    </group>
+    <group>
+        <context car:context="alarm"/>
+        <context car:context="notification"/>
+        <context car:context="system_sound"/>
+    </group>
+    <group>
+        <context car:context="navigation"/>
+        <context car:context="voice_command"/>
+    </group>
+</volumeGroups>
diff --git a/configs/msmsteppe/audio_effects.xml b/configs/msmsteppe/audio_effects.xml
index 7c0cd22..add0925 100644
--- a/configs/msmsteppe/audio_effects.xml
+++ b/configs/msmsteppe/audio_effects.xml
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<!--- Copyright (c) 2018, The Linux Foundation. All rights reserved.            -->
+<!--- Copyright (c) 2018-2019, 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    -->
@@ -30,9 +30,6 @@
     <libraries>
         <library name="bundle" path="libbundlewrapper.so"/>
         <library name="reverb" path="libreverbwrapper.so"/>
-        <library name="qcbassboost" path="libqcbassboost.so"/>
-        <library name="qcvirt" path="libqcvirt.so"/>
-        <library name="qcreverb" path="libqcreverb.so"/>
         <library name="visualizer_sw" path="libvisualizer.so"/>
         <library name="visualizer_hw" path="libqcomvisualizer.so"/>
         <library name="downmix" path="libdownmix.so"/>
@@ -47,11 +44,11 @@
     </libraries>
     <effects>
         <effectProxy name="bassboost" library="proxy" uuid="14804144-a5ee-4d24-aa88-0002a5d5c51b">
-            <libsw library="qcbassboost" uuid="23aca180-44bd-11e2-bcfd-0800200c9a66"/>
+            <libsw library="bundle" uuid="8631f300-72e2-11df-b57e-0002a5d5c51b"/>
             <libhw library="offload_bundle" uuid="2c4a8c24-1581-487f-94f6-0002a5d5c51b"/>
         </effectProxy>
         <effectProxy name="virtualizer" library="proxy" uuid="d3467faa-acc7-4d34-acaf-0002a5d5c51b">
-            <libsw library="qcvirt" uuid="e6c98a16-22a3-11e2-b87b-f23c91aec05e"/>
+            <libsw library="bundle" uuid="1d4033c0-8557-11df-9f2d-0002a5d5c51b"/>
             <libhw library="offload_bundle" uuid="509a4498-561a-4bea-b3b1-0002a5d5c51b"/>
         </effectProxy>
         <effectProxy name="equalizer" library="proxy" uuid="c8e70ecd-48ca-456e-8a4f-0002a5d5c51b">
@@ -60,19 +57,19 @@
         </effectProxy>
         <effect name="volume" library="bundle" uuid="119341a0-8469-11df-81f9-0002a5d5c51b"/>
         <effectProxy name="reverb_env_aux" library="proxy" uuid="48404ac9-d202-4ccc-bf84-0002a5d5c51b">
-            <libsw library="qcreverb" uuid="a8c1e5f3-293d-43cd-95ec-d5e26c02e217"/>
+            <libsw library="reverb" uuid="4a387fc0-8ab3-11df-8bad-0002a5d5c51b"/>
             <libhw library="offload_bundle" uuid="79a18026-18fd-4185-8233-0002a5d5c51b"/>
         </effectProxy>
         <effectProxy name="reverb_env_ins" library="proxy" uuid="b707403a-a1c1-4291-9573-0002a5d5c51b">
-            <libsw library="qcreverb" uuid="791fff8b-8129-4655-83a4-59bc61034c3a"/>
+            <libsw library="reverb" uuid="c7a511a0-a3bb-11df-860e-0002a5d5c51b"/>
             <libhw library="offload_bundle" uuid="eb64ea04-973b-43d2-8f5e-0002a5d5c51b"/>
         </effectProxy>
         <effectProxy name="reverb_pre_aux" library="proxy" uuid="1b78f587-6d1c-422e-8b84-0002a5d5c51b">
-            <libsw library="qcreverb" uuid="53ef1db5-c0c0-445b-b060-e34d20ebb70a"/>
+            <libsw library="reverb" uuid="f29a1400-a3bb-11df-8ddc-0002a5d5c51b"/>
             <libhw library="offload_bundle" uuid="6987be09-b142-4b41-9056-0002a5d5c51b"/>
         </effectProxy>
         <effectProxy name="reverb_pre_ins" library="proxy" uuid="f3e178d2-ebcb-408e-8357-0002a5d5c51b">
-            <libsw library="qcreverb" uuid="b08a0e38-22a5-11e2-b87b-f23c91aec05e"/>
+            <libsw library="reverb" uuid="172cdf00-a3bc-11df-a72f-0002a5d5c51b"/>
             <libhw library="offload_bundle" uuid="aa2bebf6-47cf-4613-9bca-0002a5d5c51b"/>
         </effectProxy>
         <effectProxy name="visualizer" library="proxy" uuid="1d0a1a53-7d5d-48f2-8e71-27fbd10d842c">
diff --git a/configs/msmsteppe/audio_platform_info.xml b/configs/msmsteppe/audio_platform_info.xml
index 09b2d9b..30fbf1e 100644
--- a/configs/msmsteppe/audio_platform_info.xml
+++ b/configs/msmsteppe/audio_platform_info.xml
@@ -102,6 +102,7 @@
         <usecase name="USECASE_AUDIO_PLAYBACK_MMAP" type="out" id="33" />
         <usecase name="USECASE_AUDIO_RECORD_MMAP" type="in" id="33" />
         <usecase name="USECASE_AUDIO_A2DP_ABR_FEEDBACK" type="in" id="12" />
+        <usecase name="USECASE_INCALL_MUSIC_UPLINK" type="out" id="27" />
     </pcm_ids>
     <config_params>
         <param key="spkr_1_tz_name" value="wsatz.13"/>
diff --git a/configs/msmsteppe/audio_platform_info_intcodec.xml b/configs/msmsteppe/audio_platform_info_intcodec.xml
index ac6c4cc..6273fb8 100644
--- a/configs/msmsteppe/audio_platform_info_intcodec.xml
+++ b/configs/msmsteppe/audio_platform_info_intcodec.xml
@@ -64,6 +64,7 @@
         <usecase name="USECASE_AUDIO_PLAYBACK_VOIP" type="out" id="16" />
         <usecase name="USECASE_AUDIO_RECORD_VOIP" type="in" id="16" />
         <usecase name="USECASE_AUDIO_A2DP_ABR_FEEDBACK" type="in" id="12" />
+        <usecase name="USECASE_INCALL_MUSIC_UPLINK" type="out" id="27" />
     </pcm_ids>
     <config_params>
         <!-- In the below value string, the value indicates default mono -->
diff --git a/configs/msmsteppe/audio_platform_info_qrd.xml b/configs/msmsteppe/audio_platform_info_qrd.xml
index bcda82f..c49fcb5 100644
--- a/configs/msmsteppe/audio_platform_info_qrd.xml
+++ b/configs/msmsteppe/audio_platform_info_qrd.xml
@@ -64,6 +64,7 @@
         <usecase name="USECASE_AUDIO_PLAYBACK_VOIP" type="out" id="16" />
         <usecase name="USECASE_AUDIO_RECORD_VOIP" type="in" id="16" />
         <usecase name="USECASE_AUDIO_A2DP_ABR_FEEDBACK" type="in" id="12" />
+        <usecase name="USECASE_INCALL_MUSIC_UPLINK" type="out" id="27" />
     </pcm_ids>
     <config_params>
         <!-- In the below value string, the value indicates default mono -->
diff --git a/configs/msmsteppe/audio_policy_configuration.xml b/configs/msmsteppe/audio_policy_configuration.xml
index f86a518..b092687 100644
--- a/configs/msmsteppe/audio_policy_configuration.xml
+++ b/configs/msmsteppe/audio_policy_configuration.xml
@@ -167,6 +167,12 @@
                              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="incall_music_uplink" role="source"
+                        flags="AUDIO_OUTPUT_FLAG_INCALL_MUSIC">
+                    <profile name="" format="AUDIO_FORMAT_PCM_16_BIT"
+                             samplingRates="8000,16000,48000"
+                             channelMasks="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"
@@ -305,27 +311,8 @@
                              samplingRates="8000,16000,48000" channelMasks="AUDIO_CHANNEL_IN_MONO"/>
                 </devicePort>
                 <devicePort tagName="USB Device In" type="AUDIO_DEVICE_IN_USB_DEVICE" role="source">
-                    <profile name="" format="AUDIO_FORMAT_PCM_16_BIT"
-                             samplingRates="44100,48000,64000,88200,96000,128000,176400,192000" channelMasks="AUDIO_CHANNEL_IN_MONO,AUDIO_CHANNEL_IN_STEREO,AUDIO_CHANNEL_INDEX_MASK_6,AUDIO_CHANNEL_IN_7POINT1,AUDIO_CHANNEL_INDEX_MASK_8"/>
-                    <profile name="" format="AUDIO_FORMAT_PCM_8_24_BIT"
-                             samplingRates="44100,48000,64000,88200,96000,128000,176400,192000"
-                             channelMasks="AUDIO_CHANNEL_IN_MONO,AUDIO_CHANNEL_IN_STEREO,AUDIO_CHANNEL_INDEX_MASK_6,AUDIO_CHANNEL_IN_7POINT1,AUDIO_CHANNEL_INDEX_MASK_8"/>
-                    <!-- edit as needed -->
-                    <profile name="" format="AUDIO_FORMAT_PCM_32_BIT"
-                             samplingRates="44100,48000,64000,88200,96000,128000,176400,192000"
-                             channelMasks="AUDIO_CHANNEL_IN_MONO,AUDIO_CHANNEL_IN_STEREO,AUDIO_CHANNEL_INDEX_MASK_6,AUDIO_CHANNEL_IN_7POINT1,AUDIO_CHANNEL_INDEX_MASK_8"/>
                 </devicePort>
                 <devicePort tagName="USB Headset In" type="AUDIO_DEVICE_IN_USB_HEADSET" role="source">
-                    <profile name="" format="AUDIO_FORMAT_PCM_16_BIT"
-                             samplingRates="44100,48000,64000,88200,96000,128000,176400,192000"
-                             channelMasks="AUDIO_CHANNEL_IN_MONO,AUDIO_CHANNEL_IN_STEREO,AUDIO_CHANNEL_INDEX_MASK_6,AUDIO_CHANNEL_IN_7POINT1,AUDIO_CHANNEL_INDEX_MASK_8"/>
-                    <profile name="" format="AUDIO_FORMAT_PCM_8_24_BIT"
-                             samplingRates="44100,48000,64000,88200,96000,128000,176400,192000"
-                             channelMasks="AUDIO_CHANNEL_IN_MONO,AUDIO_CHANNEL_IN_STEREO,AUDIO_CHANNEL_INDEX_MASK_6,AUDIO_CHANNEL_IN_7POINT1,AUDIO_CHANNEL_INDEX_MASK_8"/>
-                    <!-- edit as needed -->
-                    <profile name="" format="AUDIO_FORMAT_PCM_32_BIT"
-                             samplingRates="44100,48000,64000,88200,96000,128000,176400,192000"
-                             channelMasks="AUDIO_CHANNEL_IN_MONO,AUDIO_CHANNEL_IN_STEREO,AUDIO_CHANNEL_INDEX_MASK_6,AUDIO_CHANNEL_IN_7POINT1,AUDIO_CHANNEL_INDEX_MASK_8"/>
                 </devicePort>
 
             </devicePorts>
@@ -358,7 +345,7 @@
                 <route type="mix" sink="USB Headset Out"
                        sources="primary output,raw,deep_buffer,direct_pcm,compressed_offload,voip_rx,mmap_no_irq_out,hifi_playback"/>
                 <route type="mix" sink="Telephony Tx"
-                       sources="voice_tx"/>
+                       sources="voice_tx,incall_music_uplink"/>
                 <route type="mix" sink="voice_rx"
                        sources="Telephony Rx"/>
                 <route type="mix" sink="primary input"
diff --git a/configs/msmsteppe/mixer_paths_idp.xml b/configs/msmsteppe/mixer_paths_idp.xml
index a48defd..2ce8d12 100644
--- a/configs/msmsteppe/mixer_paths_idp.xml
+++ b/configs/msmsteppe/mixer_paths_idp.xml
@@ -1833,76 +1833,79 @@
         <ctl name="MultiMedia2 Mixer USB_AUDIO_TX" value="1" />
     </path>
 
-    <path name="incall-music-uplink">
+    <path name="incall_music_uplink">
         <ctl name="Incall_Music Audio Mixer MultiMedia9" value="1" />
     </path>
 
-    <path name="incall-music-uplink speaker">
-        <path name="incall-music-uplink" />
+    <path name="incall_music_uplink speaker">
+        <path name="incall_music_uplink" />
     </path>
 
-    <path name="incall-music-uplink handset">
-        <path name="incall-music-uplink" />
+    <path name="incall_music_uplink handset">
+        <path name="incall_music_uplink" />
     </path>
 
-    <path name="incall-music-uplink handset-hac">
-        <path name="incall-music-uplink" />
+    <path name="incall_music_uplink handset-hac">
+        <path name="incall_music_uplink" />
     </path>
 
-    <path name="incall-music-uplink display-port">
-        <path name="incall-music-uplink" />
+    <path name="incall_music_uplink display-port">
+        <path name="incall_music_uplink" />
     </path>
 
-    <path name="incall-music-uplink bt-sco">
-        <path name="incall-music-uplink" />
+    <path name="incall_music_uplink bt-sco">
+        <path name="incall_music_uplink" />
     </path>
 
-    <path name="incall-music-uplink bt-sco-wb">
-        <path name="incall-music-uplink" />
+    <path name="incall_music_uplink bt-sco-wb">
+        <path name="incall_music_uplink" />
     </path>
 
-    <path name="incall-music-uplink speaker-and-display-port">
-        <path name="incall-music-uplink" />
+    <path name="incall_music_uplink speaker-and-display-port">
+        <path name="incall_music_uplink" />
     </path>
 
-    <path name="incall-music-uplink afe-proxy">
-        <path name="incall-music-uplink" />
+    <path name="incall_music_uplink afe-proxy">
+        <path name="incall_music_uplink" />
     </path>
 
-    <path name="incall-music-uplink usb-headphones">
-        <path name="incall-music-uplink" />
+    <path name="incall_music_uplink usb-headphones">
+        <path name="incall_music_uplink" />
     </path>
 
-    <path name="incall-music-uplink usb-headset">
-        <path name="incall-music-uplink" />
+    <path name="incall_music_uplink usb-headset">
+        <path name="incall_music_uplink" />
     </path>
 
-    <path name="incall-music-uplink speaker-and-usb-headphones">
-        <path name="incall-music-uplink" />
+    <path name="incall_music_uplink speaker-and-usb-headphones">
+        <path name="incall_music_uplink" />
     </path>
 
-    <path name="incall-music-uplink headphones">
-        <path name="incall-music-uplink" />
+    <path name="incall_music_uplink headphones">
+        <path name="incall_music_uplink" />
     </path>
 
-    <path name="incall-music-uplink speaker-and-headphones">
-        <path name="incall-music-uplink" />
+    <path name="incall_music_uplink speaker-and-headphones">
+        <path name="incall_music_uplink" />
     </path>
 
-    <path name="incall-music-uplink speaker-and-bt-sco">
-        <path name="incall-music-uplink" />
+    <path name="incall_music_uplink speaker-and-bt-sco">
+        <path name="incall_music_uplink" />
     </path>
 
-    <path name="incall-music-uplink voice-tty-hco-handset">
-        <path name="incall-music-uplink" />
+    <path name="incall_music_uplink voice-tty-hco-handset">
+        <path name="incall_music_uplink" />
     </path>
 
-    <path name="incall-music-uplink speaker-and-bt-a2dp">
-        <path name="incall-music-uplink" />
+    <path name="incall_music_uplink speaker-and-bt-a2dp">
+        <path name="incall_music_uplink" />
     </path>
 
-    <path name="incall-music-uplink bt-a2dp">
-        <path name="incall-music-uplink" />
+    <path name="incall_music_uplink bt-a2dp">
+        <path name="incall_music_uplink" />
+    </path>
+    <path name="incall_music_uplink afe-proxy">
+        <path name="incall_music_uplink" />
     </path>
 
    <path name="spkr-rx-calib">
@@ -2147,6 +2150,10 @@
         <path name="handset" />
     </path>
 
+    <path name="voice-handset-tmus">
+        <path name="handset" />
+    </path>
+
     <path name="voice-speaker">
         <path name="speaker-mono" />
     </path>
diff --git a/configs/msmsteppe/mixer_paths_qrd.xml b/configs/msmsteppe/mixer_paths_qrd.xml
index 53c91c3..5665322 100644
--- a/configs/msmsteppe/mixer_paths_qrd.xml
+++ b/configs/msmsteppe/mixer_paths_qrd.xml
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="ISO-8859-1"?>
-<!-- Copyright (c) 2015-2018, The Linux Foundation. All rights reserved.    -->
+<!-- Copyright (c) 2015-2019, 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 -->
@@ -1895,76 +1895,79 @@
         <ctl name="MultiMedia2 Mixer USB_AUDIO_TX" value="1" />
     </path>
 
-    <path name="incall-music-uplink">
+    <path name="incall_music_uplink">
         <ctl name="Incall_Music Audio Mixer MultiMedia9" value="1" />
     </path>
 
-    <path name="incall-music-uplink speaker">
-        <path name="incall-music-uplink" />
+    <path name="incall_music_uplink speaker">
+        <path name="incall_music_uplink" />
     </path>
 
-    <path name="incall-music-uplink handset">
-        <path name="incall-music-uplink" />
+    <path name="incall_music_uplink handset">
+        <path name="incall_music_uplink" />
     </path>
 
-    <path name="incall-music-uplink handset-hac">
-        <path name="incall-music-uplink" />
+    <path name="incall_music_uplink handset-hac">
+        <path name="incall_music_uplink" />
     </path>
 
-    <path name="incall-music-uplink display-port">
-        <path name="incall-music-uplink" />
+    <path name="incall_music_uplink display-port">
+        <path name="incall_music_uplink" />
     </path>
 
-    <path name="incall-music-uplink bt-sco">
-        <path name="incall-music-uplink" />
+    <path name="incall_music_uplink bt-sco">
+        <path name="incall_music_uplink" />
     </path>
 
-    <path name="incall-music-uplink bt-sco-wb">
-        <path name="incall-music-uplink" />
+    <path name="incall_music_uplink bt-sco-wb">
+        <path name="incall_music_uplink" />
     </path>
 
-    <path name="incall-music-uplink speaker-and-display-port">
-        <path name="incall-music-uplink" />
+    <path name="incall_music_uplink speaker-and-display-port">
+        <path name="incall_music_uplink" />
     </path>
 
-    <path name="incall-music-uplink afe-proxy">
-        <path name="incall-music-uplink" />
+    <path name="incall_music_uplink afe-proxy">
+        <path name="incall_music_uplink" />
     </path>
 
-    <path name="incall-music-uplink usb-headphones">
-        <path name="incall-music-uplink" />
+    <path name="incall_music_uplink usb-headphones">
+        <path name="incall_music_uplink" />
     </path>
 
-    <path name="incall-music-uplink usb-headset">
-        <path name="incall-music-uplink" />
+    <path name="incall_music_uplink usb-headset">
+        <path name="incall_music_uplink" />
     </path>
 
-    <path name="incall-music-uplink speaker-and-usb-headphones">
-        <path name="incall-music-uplink" />
+    <path name="incall_music_uplink speaker-and-usb-headphones">
+        <path name="incall_music_uplink" />
     </path>
 
-    <path name="incall-music-uplink headphones">
-        <path name="incall-music-uplink" />
+    <path name="incall_music_uplink headphones">
+        <path name="incall_music_uplink" />
     </path>
 
-    <path name="incall-music-uplink speaker-and-headphones">
-        <path name="incall-music-uplink" />
+    <path name="incall_music_uplink speaker-and-headphones">
+        <path name="incall_music_uplink" />
     </path>
 
-    <path name="incall-music-uplink speaker-and-bt-sco">
-        <path name="incall-music-uplink" />
+    <path name="incall_music_uplink speaker-and-bt-sco">
+        <path name="incall_music_uplink" />
     </path>
 
-    <path name="incall-music-uplink voice-tty-hco-handset">
-        <path name="incall-music-uplink" />
+    <path name="incall_music_uplink voice-tty-hco-handset">
+        <path name="incall_music_uplink" />
     </path>
 
-    <path name="incall-music-uplink speaker-and-bt-a2dp">
-        <path name="incall-music-uplink" />
+    <path name="incall_music_uplink speaker-and-bt-a2dp">
+        <path name="incall_music_uplink" />
     </path>
 
-    <path name="incall-music-uplink bt-a2dp">
-        <path name="incall-music-uplink" />
+    <path name="incall_music_uplink bt-a2dp">
+        <path name="incall_music_uplink" />
+    </path>
+    <path name="incall_music_uplink afe-proxy">
+        <path name="incall_music_uplink" />
     </path>
 
    <path name="spkr-rx-calib">
@@ -2172,6 +2175,10 @@
         <path name="handset" />
     </path>
 
+    <path name="voice-handset-tmus">
+        <path name="handset" />
+    </path>
+
     <path name="voice-speaker">
         <path name="speaker-mono" />
     </path>
@@ -2189,7 +2196,15 @@
     </path>
 
     <path name="voice-headphones">
-        <path name="headphones" />
+        <ctl name="RX_MACRO RX0 MUX" value="AIF1_PB" />
+        <ctl name="RX_MACRO RX1 MUX" value="AIF1_PB" />
+        <ctl name="RX_CDC_DMA_RX_0 Channels" value="Two" />
+        <ctl name="RX INT0_1 MIX1 INP0" value="RX0" />
+        <ctl name="RX INT1_1 MIX1 INP0" value="RX1" />
+        <ctl name="RX INT0 DEM MUX" value="CLSH_DSM_OUT" />
+        <ctl name="RX INT1 DEM MUX" value="CLSH_DSM_OUT" />
+        <ctl name="HPHL_RDAC Switch" value="1" />
+        <ctl name="HPHR_RDAC Switch" value="1" />
     </path>
 
     <path name="voice-line">
diff --git a/configs/msmsteppe/mixer_paths_tavil.xml b/configs/msmsteppe/mixer_paths_tavil.xml
index 1a2bf55..d0db2fb 100644
--- a/configs/msmsteppe/mixer_paths_tavil.xml
+++ b/configs/msmsteppe/mixer_paths_tavil.xml
@@ -2938,76 +2938,79 @@
         <ctl name="MultiMedia2 Mixer USB_AUDIO_TX" value="1" />
     </path>
 
-    <path name="incall-music-uplink">
+    <path name="incall_music_uplink">
         <ctl name="Incall_Music Audio Mixer MultiMedia9" value="1" />
     </path>
 
-    <path name="incall-music-uplink speaker">
-        <path name="incall-music-uplink" />
+    <path name="incall_music_uplink speaker">
+        <path name="incall_music_uplink" />
     </path>
 
-    <path name="incall-music-uplink handset">
-        <path name="incall-music-uplink" />
+    <path name="incall_music_uplink handset">
+        <path name="incall_music_uplink" />
     </path>
 
-    <path name="incall-music-uplink handset-hac">
-        <path name="incall-music-uplink" />
+    <path name="incall_music_uplink handset-hac">
+        <path name="incall_music_uplink" />
     </path>
 
-    <path name="incall-music-uplink display-port">
-        <path name="incall-music-uplink" />
+    <path name="incall_music_uplink display-port">
+        <path name="incall_music_uplink" />
     </path>
 
-    <path name="incall-music-uplink bt-sco">
-        <path name="incall-music-uplink" />
+    <path name="incall_music_uplink bt-sco">
+        <path name="incall_music_uplink" />
     </path>
 
-    <path name="incall-music-uplink bt-sco-wb">
-        <path name="incall-music-uplink" />
+    <path name="incall_music_uplink bt-sco-wb">
+        <path name="incall_music_uplink" />
     </path>
 
-    <path name="incall-music-uplink speaker-and-display-port">
-        <path name="incall-music-uplink" />
+    <path name="incall_music_uplink speaker-and-display-port">
+        <path name="incall_music_uplink" />
     </path>
 
-    <path name="incall-music-uplink afe-proxy">
-        <path name="incall-music-uplink" />
+    <path name="incall_music_uplink afe-proxy">
+        <path name="incall_music_uplink" />
     </path>
 
-    <path name="incall-music-uplink usb-headphones">
-        <path name="incall-music-uplink" />
+    <path name="incall_music_uplink usb-headphones">
+        <path name="incall_music_uplink" />
     </path>
 
-    <path name="incall-music-uplink usb-headset">
-        <path name="incall-music-uplink" />
+    <path name="incall_music_uplink usb-headset">
+        <path name="incall_music_uplink" />
     </path>
 
-    <path name="incall-music-uplink speaker-and-usb-headphones">
-        <path name="incall-music-uplink" />
+    <path name="incall_music_uplink speaker-and-usb-headphones">
+        <path name="incall_music_uplink" />
     </path>
 
-    <path name="incall-music-uplink headphones">
-        <path name="incall-music-uplink" />
+    <path name="incall_music_uplink headphones">
+        <path name="incall_music_uplink" />
     </path>
 
-    <path name="incall-music-uplink speaker-and-headphones">
-        <path name="incall-music-uplink" />
+    <path name="incall_music_uplink speaker-and-headphones">
+        <path name="incall_music_uplink" />
     </path>
 
-    <path name="incall-music-uplink speaker-and-bt-sco">
-        <path name="incall-music-uplink" />
+    <path name="incall_music_uplink speaker-and-bt-sco">
+        <path name="incall_music_uplink" />
     </path>
 
-    <path name="incall-music-uplink voice-tty-hco-handset">
-        <path name="incall-music-uplink" />
+    <path name="incall_music_uplink voice-tty-hco-handset">
+        <path name="incall_music_uplink" />
     </path>
 
-    <path name="incall-music-uplink speaker-and-bt-a2dp">
-        <path name="incall-music-uplink" />
+    <path name="incall_music_uplink speaker-and-bt-a2dp">
+        <path name="incall_music_uplink" />
     </path>
 
-    <path name="incall-music-uplink bt-a2dp">
-        <path name="incall-music-uplink" />
+    <path name="incall_music_uplink bt-a2dp">
+        <path name="incall_music_uplink" />
+    </path>
+    <path name="incall_music_uplink afe-proxy">
+        <path name="incall_music_uplink" />
     </path>
 
 </mixer>
diff --git a/configs/msmsteppe/mixer_paths_wcd9375.xml b/configs/msmsteppe/mixer_paths_wcd9375.xml
index 680f445..c4d2af7 100644
--- a/configs/msmsteppe/mixer_paths_wcd9375.xml
+++ b/configs/msmsteppe/mixer_paths_wcd9375.xml
@@ -2155,6 +2155,10 @@
         <path name="handset" />
     </path>
 
+    <path name="voice-handset-tmus">
+        <path name="handset" />
+    </path>
+
     <path name="voice-speaker">
         <path name="speaker-mono" />
     </path>
diff --git a/configs/msmsteppe/mixer_paths_wcd9375qrd.xml b/configs/msmsteppe/mixer_paths_wcd9375qrd.xml
index 758a1d3..aee360c 100644
--- a/configs/msmsteppe/mixer_paths_wcd9375qrd.xml
+++ b/configs/msmsteppe/mixer_paths_wcd9375qrd.xml
@@ -2237,6 +2237,10 @@
         <path name="handset" />
     </path>
 
+    <path name="voice-handset-tmus">
+        <path name="handset" />
+    </path>
+
     <path name="voice-speaker">
         <path name="speaker-mono" />
     </path>
diff --git a/configs/msmsteppe/msmsteppe.mk b/configs/msmsteppe/msmsteppe.mk
index 753a674..ec546ac 100644
--- a/configs/msmsteppe/msmsteppe.mk
+++ b/configs/msmsteppe/msmsteppe.mk
@@ -176,6 +176,8 @@
     vendor/qcom/opensource/audio-hal/primary-hal/configs/msmsteppe/mixer_paths_qrd.xml:$(TARGET_COPY_OUT_VENDOR)/etc/mixer_paths_qrd.xml \
     vendor/qcom/opensource/audio-hal/primary-hal/configs/msmsteppe/mixer_paths_wcd9375qrd.xml:$(TARGET_COPY_OUT_VENDOR)/etc/mixer_paths_wcd9375qrd.xml \
     vendor/qcom/opensource/audio-hal/primary-hal/configs/msmsteppe/mixer_paths_tavil.xml:$(TARGET_COPY_OUT_VENDOR)/etc/mixer_paths_tavil.xml \
+    frameworks/native/data/etc/android.hardware.audio.pro.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/android.hardware.audio.pro.xml \
+    frameworks/native/data/etc/android.hardware.audio.low_latency.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/android.hardware.audio.low_latency.xml
 
 #XML Audio configuration files
 ifneq ($(TARGET_USES_AOSP_FOR_AUDIO), true)
@@ -240,6 +242,10 @@
 PRODUCT_PROPERTY_OVERRIDES += \
 vendor.audio.offload.buffer.size.kb=32
 
+#Minimum duration for offload playback in secs
+PRODUCT_PROPERTY_OVERRIDES += \
+audio.offload.min.duration.secs=30
+
 #Enable offload audio video playback by default
 PRODUCT_PROPERTY_OVERRIDES += \
 audio.offload.video=true
@@ -283,7 +289,7 @@
 
 #enable pbe effects
 PRODUCT_PROPERTY_OVERRIDES += \
-vendor.audio.safx.pbe.enabled=true
+vendor.audio.safx.pbe.enabled=false
 
 #parser input buffer size(256kb) in byte stream mode
 PRODUCT_PROPERTY_OVERRIDES += \
@@ -356,7 +362,6 @@
 vendor.audio.feature.a2dp_offload.enable=true \
 vendor.audio.feature.afe_proxy.enable=true \
 vendor.audio.feature.anc_headset.enable=true \
-vendor.audio.feature.audio_sphere.enable=true \
 vendor.audio.feature.battery_listener.enable=false \
 vendor.audio.feature.compr_cap.enable=false \
 vendor.audio.feature.compress_in.enable=false \
@@ -378,7 +383,7 @@
 vendor.audio.feature.hfp.enable=true \
 vendor.audio.feature.hifi_audio.enable=false \
 vendor.audio.feature.hwdep_cal.enable=false \
-vendor.audio.feature.incall_music.enable=false \
+vendor.audio.feature.incall_music.enable=true \
 vendor.audio.feature.keep_alive.enable=false \
 vendor.audio.feature.kpi_optimize.enable=true \
 vendor.audio.feature.maxx_audio.enable=false \
@@ -388,7 +393,7 @@
 vendor.audio.feature.spkr_prot.enable=true \
 vendor.audio.feature.ssrec.enable=true \
 vendor.audio.feature.usb_offload.enable=true \
-vendor.audio.feature.usb_offload_burst_mode.enable=false \
+vendor.audio.feature.usb_offload_burst_mode.enable=true \
 vendor.audio.feature.usb_offload_sidetone_volume.enable=false \
 vendor.audio.feature.deepbuffer_as_primary.enable=false \
 vendor.audio.feature.vbat.enable=true \
@@ -396,6 +401,10 @@
 vendor.audio.feature.audiozoom.enable=false \
 vendor.audio.feature.snd_mon.enable=true
 
+#enable AAC frame ctl for A2DP sinks
+PRODUCT_PROPERTY_OVERRIDES += \
+persist.vendor.bt.aac_frm_ctl.enabled=true
+
 # for HIDL related packages
 PRODUCT_PACKAGES += \
     android.hardware.audio@2.0-service \
@@ -409,6 +418,15 @@
     android.hardware.audio.effect@4.0 \
     android.hardware.audio.effect@4.0-impl
 
+# enable audio hidl hal 5.0
+PRODUCT_PACKAGES += \
+    android.hardware.audio@5.0 \
+    android.hardware.audio.common@5.0 \
+    android.hardware.audio.common@5.0-util \
+    android.hardware.audio@5.0-impl \
+    android.hardware.audio.effect@5.0 \
+    android.hardware.audio.effect@5.0-impl
+
 PRODUCT_PACKAGES_ENG += \
     VoicePrintTest \
     VoicePrintDemo
diff --git a/configs/msmsteppe/sound_trigger_mixer_paths.xml b/configs/msmsteppe/sound_trigger_mixer_paths.xml
index a489e7f..90de0d3 100644
--- a/configs/msmsteppe/sound_trigger_mixer_paths.xml
+++ b/configs/msmsteppe/sound_trigger_mixer_paths.xml
@@ -206,11 +206,11 @@
         <ctl name="TX_DEC3 Volume" value="102" />
         <ctl name="TX DMIC MUX0" value="DMIC2" />
         <ctl name="TX_AIF1_CAP Mixer DEC1" value="1" />
-        <ctl name="TX DMIC MUX1" value="DMIC1" />
+        <ctl name="TX DMIC MUX1" value="DMIC0" />
         <ctl name="TX_AIF1_CAP Mixer DEC2" value="1" />
         <ctl name="TX DMIC MUX2" value="DMIC3" />
         <ctl name="TX_AIF1_CAP Mixer DEC3" value="1" />
-        <ctl name="TX DMIC MUX3" value="DMIC0" />
+        <ctl name="TX DMIC MUX3" value="DMIC1" />
     </path>
 
     <path name="echo-reference">
diff --git a/configs/msmsteppe/sound_trigger_mixer_paths_wcd9340.xml b/configs/msmsteppe/sound_trigger_mixer_paths_wcd9340.xml
index 55dd42f..f74c4fe 100644
--- a/configs/msmsteppe/sound_trigger_mixer_paths_wcd9340.xml
+++ b/configs/msmsteppe/sound_trigger_mixer_paths_wcd9340.xml
@@ -199,7 +199,7 @@
         <ctl name= "DMIC MUX0" value="DMIC2" />
         <ctl name= "DEC0 Volume" value="84" />
         <ctl name= "ADC MUX1" value="DMIC" />
-        <ctl name= "DMIC MUX1" value="DMIC0" />
+        <ctl name= "DMIC MUX1" value="DMIC5" />
         <ctl name= "DEC1 Volume" value="84" />
         <ctl name= "WDMA3 PORT0 MUX" value="DEC0" />
         <ctl name= "WDMA3 PORT1 MUX" value="DEC1" />
@@ -217,7 +217,7 @@
         <ctl name= "DMIC MUX1" value="DMIC0" />
         <ctl name= "DEC1 Volume" value="84" />
         <ctl name= "ADC MUX2" value="DMIC" />
-        <ctl name= "DMIC MUX2" value="DMIC1" />
+        <ctl name= "DMIC MUX2" value="DMIC5" />
         <ctl name= "DEC2 Volume" value="84" />
         <ctl name= "WDMA3 PORT0 MUX" value="DEC0" />
         <ctl name= "WDMA3 PORT1 MUX" value="DEC1" />
@@ -237,10 +237,10 @@
         <ctl name= "DMIC MUX1" value="DMIC0" />
         <ctl name= "DEC1 Volume" value="84" />
         <ctl name= "ADC MUX2" value="DMIC" />
-        <ctl name= "DMIC MUX2" value="DMIC1" />
+        <ctl name= "DMIC MUX2" value="DMIC5" />
         <ctl name= "DEC2 Volume" value="84" />
         <ctl name= "ADC MUX3" value="DMIC" />
-        <ctl name= "DMIC MUX3" value="DMIC3" />
+        <ctl name= "DMIC MUX3" value="DMIC1" />
         <ctl name= "DEC3 Volume" value="84" />
         <ctl name= "WDMA3 PORT0 MUX" value="DEC0" />
         <ctl name= "WDMA3 PORT1 MUX" value="DEC1" />
@@ -298,7 +298,7 @@
         <ctl name="AIF1_CAP Mixer SLIM TX8" value="1" />
         <ctl name="CDC_IF TX7 MUX" value="DEC7" />
         <ctl name="ADC MUX7" value="DMIC" />
-        <ctl name="DMIC MUX7" value="DMIC1" />
+        <ctl name="DMIC MUX7" value="DMIC2" />
         <ctl name="CDC_IF TX8 MUX" value="DEC8" />
         <ctl name="ADC MUX8" value="DMIC" />
         <ctl name="DMIC MUX8" value="DMIC5" />
@@ -312,13 +312,13 @@
         <ctl name="SLIM_0_TX Channels" value="Three" />
         <ctl name="CDC_IF TX5 MUX" value="DEC5" />
         <ctl name="ADC MUX5" value="DMIC" />
-        <ctl name="DMIC MUX5" value="DMIC1" />
+        <ctl name="DMIC MUX5" value="DMIC2" />
         <ctl name="CDC_IF TX6 MUX" value="DEC6" />
         <ctl name="ADC MUX6" value="DMIC" />
-        <ctl name="DMIC MUX6" value="DMIC5" />
+        <ctl name="DMIC MUX6" value="DMIC0" />
         <ctl name="CDC_IF TX7 MUX" value="DEC7" />
         <ctl name="ADC MUX7" value="DMIC" />
-        <ctl name="DMIC MUX7" value="DMIC2" />
+        <ctl name="DMIC MUX7" value="DMIC5" />
     </path>
 
     <path name="listen-ape-handset-qmic">
@@ -329,16 +329,16 @@
         <ctl name="SLIM_0_TX Channels" value="Four" />
         <ctl name="CDC_IF TX5 MUX" value="DEC5" />
         <ctl name="ADC MUX5" value="DMIC" />
-        <ctl name="DMIC MUX5" value="DMIC1" />
+        <ctl name="DMIC MUX5" value="DMIC2" />
         <ctl name="CDC_IF TX6 MUX" value="DEC6" />
         <ctl name="ADC MUX6" value="DMIC" />
-        <ctl name="DMIC MUX6" value="DMIC5" />
+        <ctl name="DMIC MUX6" value="DMIC0" />
         <ctl name="CDC_IF TX7 MUX" value="DEC7" />
         <ctl name="ADC MUX7" value="DMIC" />
-        <ctl name="DMIC MUX7" value="DMIC2" />
+        <ctl name="DMIC MUX7" value="DMIC5" />
         <ctl name="CDC_IF TX8 MUX" value="DEC8" />
         <ctl name="ADC MUX8" value="DMIC" />
-        <ctl name="DMIC MUX8" value="DMIC0" />
+        <ctl name="DMIC MUX8" value="DMIC1" />
     </path>
 
     <path name="echo-reference">
diff --git a/configs/msmsteppe/sound_trigger_platform_info.xml b/configs/msmsteppe/sound_trigger_platform_info.xml
index 413f4c6..a85a180 100644
--- a/configs/msmsteppe/sound_trigger_platform_info.xml
+++ b/configs/msmsteppe/sound_trigger_platform_info.xml
@@ -54,6 +54,8 @@
 
     </common_config>
     <acdb_ids>
+        <!--For internal codec please enable below device-->
+        <!--param DEVICE_HANDSET_MIC_APE="130" /-->
         <param DEVICE_HANDSET_MIC_APE="100" />
         <param DEVICE_HANDSET_MIC_CPE="128" />
         <param DEVICE_HANDSET_MIC_ECPP_CPE="128" />
@@ -127,6 +129,28 @@
             <param read_rsp_ids="0x00020013, 0x3, 0x00020016" />
             <param custom_config_ids="0x00012C0D, 0x3, 0x00012C20" />
         </gcs_usecase>
+        <gcs_usecase>
+            <param uid="0x7" />
+            <param acdb_devices="DEVICE_HANDSET_DMIC_CPE" />
+            <param load_sound_model_ids="0x00012C0D, 0x7, 0x00012C14" />
+            <param confidence_levels_ids="0x00012C0D, 0x7, 0x00012C28" />
+            <param detection_event_ids="0x00012C0D, 0x7, 0x00012B05" />
+            <param read_cmd_ids="0x00020013, 0x7, 0x00020015" />
+            <param read_rsp_ids="0x00020013, 0x7, 0x00020016" />
+            <param custom_config_ids="0x00012C0D, 0x7, 0x00012C20" />
+            <param det_event_type_ids="0x00012C0D, 0x7, 0x00012C2A" />
+        </gcs_usecase>
+        <gcs_usecase>
+            <param uid="0x8" />
+            <param acdb_devices="DEVICE_HANDSET_DMIC_CPE" />
+            <param load_sound_model_ids="0x00012C0D, 0x8, 0x00012C14" />
+            <param confidence_levels_ids="0x00012C0D, 0x8, 0x00012C28" />
+            <param detection_event_ids="0x00012C0D, 0x8, 0x00012B05" />
+            <param read_cmd_ids="0x00020013, 0x8, 0x00020015" />
+            <param read_rsp_ids="0x00020013, 0x8, 0x00020016" />
+            <param custom_config_ids="0x00012C0D, 0x8, 0x00012C20" />
+            <param det_event_type_ids="0x00012C0D, 0x8, 0x00012C2A" />
+        </gcs_usecase>
         <!-- Module and param ids with which the algorithm is integrated
             in non-graphite firmware (note these must come after gcs params)
             Extends flexibility to have different ids based on execution type.
diff --git a/configs/msmsteppe_au/audio_platform_info.xml b/configs/msmsteppe_au/audio_platform_info.xml
index 1b49031..a33ae3f 100644
--- a/configs/msmsteppe_au/audio_platform_info.xml
+++ b/configs/msmsteppe_au/audio_platform_info.xml
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="ISO-8859-1"?>
-<!-- Copyright (c) 2014, 2016-2018, The Linux Foundation. All rights reserved. -->
+<!-- Copyright (c) 2014, 2016-2019, 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 -->
@@ -97,10 +97,10 @@
         <usecase name="USECASE_AUDIO_PLAYBACK_MMAP" type="out" id="28" />
         <usecase name="USECASE_AUDIO_RECORD_MMAP" type="in" id="28" />
         <usecase name="USECASE_AUDIO_RECORD" type="in" id="0" />
-        <usecase name="USECASE_AUDIO_HFP_SCO" type="in" id="29" />
-        <usecase name="USECASE_AUDIO_HFP_SCO" type="out" id="29" />
-        <usecase name="USECASE_AUDIO_HFP_SCO_WB" type="in" id="29" />
-        <usecase name="USECASE_AUDIO_HFP_SCO_WB" type="out" id="29" />
+        <usecase name="USECASE_AUDIO_HFP_SCO" type="in" id="36" />
+        <usecase name="USECASE_AUDIO_HFP_SCO" type="out" id="36" />
+        <usecase name="USECASE_AUDIO_HFP_SCO_WB" type="in" id="36" />
+        <usecase name="USECASE_AUDIO_HFP_SCO_WB" type="out" id="36" />
     </pcm_ids>
 
     <config_params>
diff --git a/configs/msmsteppe_au/audio_policy_configuration.xml b/configs/msmsteppe_au/audio_policy_configuration.xml
index e4aec16..4d9340d 100644
--- a/configs/msmsteppe_au/audio_policy_configuration.xml
+++ b/configs/msmsteppe_au/audio_policy_configuration.xml
@@ -145,6 +145,12 @@
                     <profile name="" format="AUDIO_FORMAT_AAC_ADTS_HE_V2"
                              samplingRates="8000,11025,12000,16000,22050,24000,32000,44100,48000,64000,88200,96000"
                              channelMasks="AUDIO_CHANNEL_OUT_STEREO,AUDIO_CHANNEL_OUT_MONO"/>
+                    <profile name="" format="AUDIO_FORMAT_PCM_16_BIT"
+                             samplingRates="8000,11025,12000,16000,22050,24000,32000,44100,48000,64000,88200,96000,128000,176400,192000"
+                            channelMasks="AUDIO_CHANNEL_OUT_MONO,AUDIO_CHANNEL_OUT_STEREO,AUDIO_CHANNEL_OUT_2POINT1,AUDIO_CHANNEL_OUT_QUAD,AUDIO_CHANNEL_OUT_PENTA,AUDIO_CHANNEL_OUT_5POINT1,AUDIO_CHANNEL_OUT_6POINT1,AUDIO_CHANNEL_OUT_7POINT1"/>
+                    <profile name="" format="AUDIO_FORMAT_PCM_24_BIT_PACKED"
+                            samplingRates="8000,11025,12000,16000,22050,24000,32000,44100,48000,64000,88200,96000,128000,176400,192000"
+                            channelMasks="AUDIO_CHANNEL_OUT_MONO,AUDIO_CHANNEL_OUT_STEREO,AUDIO_CHANNEL_OUT_2POINT1,AUDIO_CHANNEL_OUT_QUAD,AUDIO_CHANNEL_OUT_PENTA,AUDIO_CHANNEL_OUT_5POINT1,AUDIO_CHANNEL_OUT_6POINT1,AUDIO_CHANNEL_OUT_7POINT1"/>
                 </mixPort>
                 <mixPort name="dsd_compress_passthrough" role="source"
                          flags="AUDIO_OUTPUT_FLAG_DIRECT|AUDIO_OUTPUT_FLAG_COMPRESS_OFFLOAD|AUDIO_OUTPUT_FLAG_NON_BLOCKING">
diff --git a/configs/msmsteppe_au/msmsteppe_au.mk b/configs/msmsteppe_au/msmsteppe_au.mk
index 87893a5..51829bd 100644
--- a/configs/msmsteppe_au/msmsteppe_au.mk
+++ b/configs/msmsteppe_au/msmsteppe_au.mk
@@ -2,7 +2,6 @@
 #
 #AUDIO_FEATURE_FLAGS
 BOARD_USES_ALSA_AUDIO := true
-TARGET_USES_AOSP_FOR_AUDIO := false
 
 ifneq ($(TARGET_USES_AOSP_FOR_AUDIO), true)
 USE_CUSTOM_AUDIO_POLICY := 1
@@ -75,6 +74,9 @@
 DEVICE_PACKAGE_OVERLAYS += vendor/qcom/opensource/audio-hal/primary-hal/configs/common/overlay
 endif
 
+#Automotive audio specific device overlays
+DEVICE_PACKAGE_OVERLAYS += hardware/qcom/audio/configs/msmsteppe_au/overlay
+
 PRODUCT_COPY_FILES += \
     vendor/qcom/opensource/audio-hal/primary-hal/configs/msmsteppe_au/audio_output_policy.conf:$(TARGET_COPY_OUT_VENDOR)/etc/audio_output_policy.conf \
     vendor/qcom/opensource/audio-hal/primary-hal/configs/msmsteppe_au/audio_effects.conf:$(TARGET_COPY_OUT_VENDOR)/etc/audio_effects.conf \
@@ -184,6 +186,14 @@
 PRODUCT_PROPERTY_OVERRIDES += \
 vendor.audio.parser.ip.buffer.size=262144
 
+#Enable 16 bit PCM offload by default
+PRODUCT_PROPERTY_OVERRIDES += \
+audio.offload.pcm.16bit.enable=true
+
+#Enable 24 bit PCM offload by default
+PRODUCT_PROPERTY_OVERRIDES += \
+audio.offload.pcm.24bit.enable=true
+
 #flac sw decoder 24 bit decode capability
 PRODUCT_PROPERTY_OVERRIDES += \
 vendor.audio.flac.sw.decoder.24bit=true
diff --git a/configs/msmsteppe_au/overlay/frameworks/base/core/res/res/values/config.xml b/configs/msmsteppe_au/overlay/frameworks/base/core/res/res/values/config.xml
new file mode 100644
index 0000000..0274f9e
--- /dev/null
+++ b/configs/msmsteppe_au/overlay/frameworks/base/core/res/res/values/config.xml
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+/*
+** Copyright (c) 2018-2019, The Linux Foundation. All rights reserved.
+** Not a Contribution.
+*/
+/*
+** Copyright 2009, The Android Open Source Project
+**
+** Licensed under the Apache License, Version 2.0 (the "License");
+** you may not use this file except in compliance with the License.
+** You may obtain a copy of the License at
+**
+**     http://www.apache.org/licenses/LICENSE-2.0
+**
+** Unless required by applicable law or agreed to in writing, software
+** distributed under the License is distributed on an "AS IS" BASIS,
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+** See the License for the specific language governing permissions and
+** limitations under the License.
+*/
+-->
+
+<resources>
+     <!-- Car uses hardware amplifier for volume. -->
+    <bool name="config_useFixedVolume">false</bool>
+    <!--
+      Handle volume keys directly in CarAudioService without passing them to the foreground app
+    -->
+    <bool name="config_handleVolumeKeysInWindowManager">true</bool>
+</resources>
diff --git a/configs/msmsteppe_au/overlay/packages/services/Car/service/res/values/config.xml b/configs/msmsteppe_au/overlay/packages/services/Car/service/res/values/config.xml
new file mode 100644
index 0000000..ac5f818
--- /dev/null
+++ b/configs/msmsteppe_au/overlay/packages/services/Car/service/res/values/config.xml
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+/*
+** Copyright (c) 2018-2019, The Linux Foundation. All rights reserved.
+** Not a Contribution.
+*/
+/*
+** Copyright 2015, The Android Open Source Project
+**
+** Licensed under the Apache License, Version 2.0 (the "License");
+** you may not use this file except in compliance with the License.
+** You may obtain a copy of the License at
+**
+**     http://www.apache.org/licenses/LICENSE-2.0
+**
+** Unless required by applicable law or agreed to in writing, software
+** distributed under the License is distributed on an "AS IS" BASIS,
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+** See the License for the specific language governing permissions and
+** limitations under the License.
+*/
+-->
+
+<!--
+  Overlay resources to configure car service based on each OEM's preference.
+  See also packages/services/Car/service/res/values/config.xml
+-->
+<resources>
+    <!--  Configuration to enable usage of dynamic audio routing. If this is set to false,
+          dynamic audio routing is disabled and audio works in legacy mode. It may be useful
+          during initial development where audio hal does not support bus based addressing yet. -->
+    <bool name="audioUseDynamicRouting">true</bool>
+</resources>
diff --git a/configs/msmsteppe_au/overlay/packages/services/Car/service/res/xml/car_volume_groups.xml b/configs/msmsteppe_au/overlay/packages/services/Car/service/res/xml/car_volume_groups.xml
new file mode 100644
index 0000000..850d4d4
--- /dev/null
+++ b/configs/msmsteppe_au/overlay/packages/services/Car/service/res/xml/car_volume_groups.xml
@@ -0,0 +1,57 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+     Copyright (c) 2018-2019, The Linux Foundation. All rights reserved.
+     Not a Contribution.
+
+     Copyright (C) 2018 The Android Open Source Project
+
+     Licensed under the Apache License, Version 2.0 (the "License");
+     you may not use this file except in compliance with the License.
+     You may obtain a copy of the License at
+
+          http://www.apache.org/licenses/LICENSE-2.0
+
+     Unless required by applicable law or agreed to in writing, software
+     distributed under the License is distributed on an "AS IS" BASIS,
+     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+     See the License for the specific language governing permissions and
+     limitations under the License.
+-->
+
+<!--
+  Defines the all available volume groups for volume control in a car.
+  One can overlay this configuration to customize the groups.
+
+  This configuration will be populated by CarAudioService and
+  surfaced to Car Settings App and/or other volume control interfaces.
+
+  Certain constraints applied to this configuration
+    - One context should not appear in two groups
+    - All contexts are assigned
+    - One bus should not appear in two groups
+    - All gain controllers (set on each bus) in one group have same step value
+
+  It is fine that there are buses that do not appear in any group, those buses
+  may be reserved for other usages.
+
+  Important note: when overlaying this configuration,
+  make sure the resources are in the same package as CarAudioService.
+-->
+<volumeGroups xmlns:car="http://schemas.android.com/apk/res-auto">
+    <group>
+        <context car:context="music"/>
+    </group>
+    <group>
+        <context car:context="call"/>
+        <context car:context="call_ring"/>
+    </group>
+    <group>
+        <context car:context="alarm"/>
+        <context car:context="notification"/>
+        <context car:context="system_sound"/>
+    </group>
+    <group>
+        <context car:context="navigation"/>
+        <context car:context="voice_command"/>
+    </group>
+</volumeGroups>
diff --git a/configs/sdm660/sdm660.mk b/configs/sdm660/sdm660.mk
index 84f0f1e..5695851 100644
--- a/configs/sdm660/sdm660.mk
+++ b/configs/sdm660/sdm660.mk
@@ -202,7 +202,7 @@
 
 #enable pbe effects
 PRODUCT_PROPERTY_OVERRIDES += \
-vendor.audio.safx.pbe.enabled=true
+vendor.audio.safx.pbe.enabled=false
 
 #parser input buffer size(256kb) in byte stream mode
 PRODUCT_PROPERTY_OVERRIDES += \
@@ -266,7 +266,6 @@
 vendor.audio.feature.a2dp_offload.enable=true \
 vendor.audio.feature.afe_proxy.enable=true \
 vendor.audio.feature.anc_headset.enable=true \
-vendor.audio.feature.audio_sphere.enable=true \
 vendor.audio.feature.battery_listener.enable=false \
 vendor.audio.feature.compr_cap.enable=false \
 vendor.audio.feature.compress_in.enable=false \
diff --git a/configs/sdm710/sdm710.mk b/configs/sdm710/sdm710.mk
index c47a146..fb01728 100644
--- a/configs/sdm710/sdm710.mk
+++ b/configs/sdm710/sdm710.mk
@@ -296,7 +296,7 @@
 
 #enable pbe effects
 PRODUCT_PROPERTY_OVERRIDES += \
-vendor.audio.safx.pbe.enabled=true
+vendor.audio.safx.pbe.enabled=false
 
 #parser input buffer size(256kb) in byte stream mode
 PRODUCT_PROPERTY_OVERRIDES += \
@@ -365,7 +365,6 @@
 vendor.audio.feature.a2dp_offload.enable=true \
 vendor.audio.feature.afe_proxy.enable=true \
 vendor.audio.feature.anc_headset.enable=true \
-vendor.audio.feature.audio_sphere.enable=true \
 vendor.audio.feature.battery_listener.enable=false \
 vendor.audio.feature.compr_cap.enable=false \
 vendor.audio.feature.compress_in.enable=false \
@@ -418,6 +417,15 @@
     android.hardware.audio.effect@4.0 \
     android.hardware.audio.effect@4.0-impl
 
+# enable audio hidl hal 5.0
+PRODUCT_PACKAGES += \
+    android.hardware.audio@5.0 \
+    android.hardware.audio.common@5.0 \
+    android.hardware.audio.common@5.0-util \
+    android.hardware.audio@5.0-impl \
+    android.hardware.audio.effect@5.0 \
+    android.hardware.audio.effect@5.0-impl
+
 PRODUCT_PACKAGES_ENG += \
     VoicePrintTest \
     VoicePrintDemo
diff --git a/configs/sdm845/sdm845.mk b/configs/sdm845/sdm845.mk
index 4fb1485..c3c3578 100644
--- a/configs/sdm845/sdm845.mk
+++ b/configs/sdm845/sdm845.mk
@@ -186,6 +186,10 @@
 PRODUCT_PROPERTY_OVERRIDES += \
 vendor.audio.offload.buffer.size.kb=32
 
+#Minimum duration for offload playback in secs
+PRODUCT_PROPERTY_OVERRIDES += \
+audio.offload.min.duration.secs=30
+
 #Enable offload audio video playback by default
 PRODUCT_PROPERTY_OVERRIDES += \
 audio.offload.video=true
@@ -229,7 +233,7 @@
 
 #enable pbe effects
 PRODUCT_PROPERTY_OVERRIDES += \
-vendor.audio.safx.pbe.enabled=true
+vendor.audio.safx.pbe.enabled=false
 
 #parser input buffer size(256kb) in byte stream mode
 PRODUCT_PROPERTY_OVERRIDES += \
@@ -310,7 +314,6 @@
 vendor.audio.feature.a2dp_offload.enable=true \
 vendor.audio.feature.afe_proxy.enable=true \
 vendor.audio.feature.anc_headset.enable=true \
-vendor.audio.feature.audio_sphere.enable=true \
 vendor.audio.feature.battery_listener.enable=false \
 vendor.audio.feature.compr_cap.enable=false \
 vendor.audio.feature.compress_in.enable=false \
@@ -363,6 +366,15 @@
     android.hardware.audio.effect@4.0 \
     android.hardware.audio.effect@4.0-impl
 
+# enable audio hidl hal 5.0
+PRODUCT_PACKAGES += \
+    android.hardware.audio@5.0 \
+    android.hardware.audio.common@5.0 \
+    android.hardware.audio.common@5.0-util \
+    android.hardware.audio@5.0-impl \
+    android.hardware.audio.effect@5.0 \
+    android.hardware.audio.effect@5.0-impl
+
 PRODUCT_PACKAGES_ENG += \
     VoicePrintTest \
     VoicePrintDemo
diff --git a/configs/sdm845/sound_trigger_platform_info.xml b/configs/sdm845/sound_trigger_platform_info.xml
index 0942fab..a80765b 100644
--- a/configs/sdm845/sound_trigger_platform_info.xml
+++ b/configs/sdm845/sound_trigger_platform_info.xml
@@ -32,6 +32,7 @@
 <!--- 0x0102: Includes acdb_ids param with the gcs_usecase tag. This matches    -->
 <!--- the gcs_usecase with the acdb device that uses it.                        -->
     <common_config>
+        <param implementer_version="0x0100" />
         <param max_cpe_sessions="1" />
         <param max_wdsp_sessions="2" />
         <param max_ape_sessions="8" />
diff --git a/configs/trinket/audio_effects.xml b/configs/trinket/audio_effects.xml
index a1cc069..add0925 100644
--- a/configs/trinket/audio_effects.xml
+++ b/configs/trinket/audio_effects.xml
@@ -30,9 +30,6 @@
     <libraries>
         <library name="bundle" path="libbundlewrapper.so"/>
         <library name="reverb" path="libreverbwrapper.so"/>
-        <library name="qcbassboost" path="libqcbassboost.so"/>
-        <library name="qcvirt" path="libqcvirt.so"/>
-        <library name="qcreverb" path="libqcreverb.so"/>
         <library name="visualizer_sw" path="libvisualizer.so"/>
         <library name="visualizer_hw" path="libqcomvisualizer.so"/>
         <library name="downmix" path="libdownmix.so"/>
@@ -47,11 +44,11 @@
     </libraries>
     <effects>
         <effectProxy name="bassboost" library="proxy" uuid="14804144-a5ee-4d24-aa88-0002a5d5c51b">
-            <libsw library="qcbassboost" uuid="23aca180-44bd-11e2-bcfd-0800200c9a66"/>
+            <libsw library="bundle" uuid="8631f300-72e2-11df-b57e-0002a5d5c51b"/>
             <libhw library="offload_bundle" uuid="2c4a8c24-1581-487f-94f6-0002a5d5c51b"/>
         </effectProxy>
         <effectProxy name="virtualizer" library="proxy" uuid="d3467faa-acc7-4d34-acaf-0002a5d5c51b">
-            <libsw library="qcvirt" uuid="e6c98a16-22a3-11e2-b87b-f23c91aec05e"/>
+            <libsw library="bundle" uuid="1d4033c0-8557-11df-9f2d-0002a5d5c51b"/>
             <libhw library="offload_bundle" uuid="509a4498-561a-4bea-b3b1-0002a5d5c51b"/>
         </effectProxy>
         <effectProxy name="equalizer" library="proxy" uuid="c8e70ecd-48ca-456e-8a4f-0002a5d5c51b">
@@ -60,19 +57,19 @@
         </effectProxy>
         <effect name="volume" library="bundle" uuid="119341a0-8469-11df-81f9-0002a5d5c51b"/>
         <effectProxy name="reverb_env_aux" library="proxy" uuid="48404ac9-d202-4ccc-bf84-0002a5d5c51b">
-            <libsw library="qcreverb" uuid="a8c1e5f3-293d-43cd-95ec-d5e26c02e217"/>
+            <libsw library="reverb" uuid="4a387fc0-8ab3-11df-8bad-0002a5d5c51b"/>
             <libhw library="offload_bundle" uuid="79a18026-18fd-4185-8233-0002a5d5c51b"/>
         </effectProxy>
         <effectProxy name="reverb_env_ins" library="proxy" uuid="b707403a-a1c1-4291-9573-0002a5d5c51b">
-            <libsw library="qcreverb" uuid="791fff8b-8129-4655-83a4-59bc61034c3a"/>
+            <libsw library="reverb" uuid="c7a511a0-a3bb-11df-860e-0002a5d5c51b"/>
             <libhw library="offload_bundle" uuid="eb64ea04-973b-43d2-8f5e-0002a5d5c51b"/>
         </effectProxy>
         <effectProxy name="reverb_pre_aux" library="proxy" uuid="1b78f587-6d1c-422e-8b84-0002a5d5c51b">
-            <libsw library="qcreverb" uuid="53ef1db5-c0c0-445b-b060-e34d20ebb70a"/>
+            <libsw library="reverb" uuid="f29a1400-a3bb-11df-8ddc-0002a5d5c51b"/>
             <libhw library="offload_bundle" uuid="6987be09-b142-4b41-9056-0002a5d5c51b"/>
         </effectProxy>
         <effectProxy name="reverb_pre_ins" library="proxy" uuid="f3e178d2-ebcb-408e-8357-0002a5d5c51b">
-            <libsw library="qcreverb" uuid="b08a0e38-22a5-11e2-b87b-f23c91aec05e"/>
+            <libsw library="reverb" uuid="172cdf00-a3bc-11df-a72f-0002a5d5c51b"/>
             <libhw library="offload_bundle" uuid="aa2bebf6-47cf-4613-9bca-0002a5d5c51b"/>
         </effectProxy>
         <effectProxy name="visualizer" library="proxy" uuid="1d0a1a53-7d5d-48f2-8e71-27fbd10d842c">
diff --git a/configs/trinket/audio_policy_configuration.xml b/configs/trinket/audio_policy_configuration.xml
index 0939e3b..8015afa 100644
--- a/configs/trinket/audio_policy_configuration.xml
+++ b/configs/trinket/audio_policy_configuration.xml
@@ -263,17 +263,20 @@
                              samplingRates="48000" channelMasks="AUDIO_CHANNEL_OUT_MONO,AUDIO_CHANNEL_OUT_STEREO"/>
                 </devicePort>
                 <devicePort tagName="BT A2DP Out" type="AUDIO_DEVICE_OUT_BLUETOOTH_A2DP" role="sink"
-                            encodedFormats="AUDIO_FORMAT_SBC AUDIO_FORMAT_AAC AUDIO_FORMAT_APTX AUDIO_FORMAT_APTX_HD AUDIO_FORMAT_LDAC">
+                            encodedFormats="AUDIO_FORMAT_SBC AUDIO_FORMAT_AAC AUDIO_FORMAT_APTX AUDIO_FORMAT_APTX_HD AUDIO_FORMAT_LDAC AUDIO_FORMAT_CELT AUDIO_FORMAT_APTX_ADAPTIVE AUDIO_FORMAT_APTX_TW
+SP">
                     <profile name="" format="AUDIO_FORMAT_PCM_16_BIT"
                              samplingRates="48000" channelMasks="AUDIO_CHANNEL_OUT_STEREO"/>
                 </devicePort>
                 <devicePort tagName="BT A2DP Headphones" type="AUDIO_DEVICE_OUT_BLUETOOTH_A2DP_HEADPHONES" role="sink"
-                            encodedFormats="AUDIO_FORMAT_SBC AUDIO_FORMAT_AAC AUDIO_FORMAT_APTX AUDIO_FORMAT_APTX_HD AUDIO_FORMAT_LDAC">
+                            encodedFormats="AUDIO_FORMAT_SBC AUDIO_FORMAT_AAC AUDIO_FORMAT_APTX AUDIO_FORMAT_APTX_HD AUDIO_FORMAT_LDAC AUDIO_FORMAT_CELT AUDIO_FORMAT_APTX_ADAPTIVE AUDIO_FORMAT_APTX_TW
+SP">
                     <profile name="" format="AUDIO_FORMAT_PCM_16_BIT"
                              samplingRates="48000" channelMasks="AUDIO_CHANNEL_OUT_STEREO"/>
                 </devicePort>
                 <devicePort tagName="BT A2DP Speaker" type="AUDIO_DEVICE_OUT_BLUETOOTH_A2DP_SPEAKER" role="sink"
-                            encodedFormats="AUDIO_FORMAT_SBC AUDIO_FORMAT_AAC AUDIO_FORMAT_APTX AUDIO_FORMAT_APTX_HD AUDIO_FORMAT_LDAC">
+                            encodedFormats="AUDIO_FORMAT_SBC AUDIO_FORMAT_AAC AUDIO_FORMAT_APTX AUDIO_FORMAT_APTX_HD AUDIO_FORMAT_LDAC AUDIO_FORMAT_CELT AUDIO_FORMAT_APTX_ADAPTIVE AUDIO_FORMAT_APTX_TW
+SP">
                     <profile name="" format="AUDIO_FORMAT_PCM_16_BIT"
                              samplingRates="48000" channelMasks="AUDIO_CHANNEL_OUT_STEREO"/>
                 </devicePort>
@@ -316,27 +319,8 @@
                              samplingRates="8000,16000,48000" channelMasks="AUDIO_CHANNEL_IN_MONO"/>
                 </devicePort>
                 <devicePort tagName="USB Device In" type="AUDIO_DEVICE_IN_USB_DEVICE" role="source">
-                    <profile name="" format="AUDIO_FORMAT_PCM_16_BIT"
-                             samplingRates="44100,48000,64000,88200,96000,128000,176400,192000" channelMasks="AUDIO_CHANNEL_IN_MONO,AUDIO_CHANNEL_IN_STEREO,AUDIO_CHANNEL_INDEX_MASK_6,AUDIO_CHANNEL_IN_7POINT1,AUDIO_CHANNEL_INDEX_MASK_8"/>
-                    <profile name="" format="AUDIO_FORMAT_PCM_8_24_BIT"
-                             samplingRates="44100,48000,64000,88200,96000,128000,176400,192000"
-                             channelMasks="AUDIO_CHANNEL_IN_MONO,AUDIO_CHANNEL_IN_STEREO,AUDIO_CHANNEL_INDEX_MASK_6,AUDIO_CHANNEL_IN_7POINT1,AUDIO_CHANNEL_INDEX_MASK_8"/>
-                    <!-- edit as needed -->
-                    <profile name="" format="AUDIO_FORMAT_PCM_32_BIT"
-                             samplingRates="44100,48000,64000,88200,96000,128000,176400,192000"
-                             channelMasks="AUDIO_CHANNEL_IN_MONO,AUDIO_CHANNEL_IN_STEREO,AUDIO_CHANNEL_INDEX_MASK_6,AUDIO_CHANNEL_IN_7POINT1,AUDIO_CHANNEL_INDEX_MASK_8"/>
                 </devicePort>
                 <devicePort tagName="USB Headset In" type="AUDIO_DEVICE_IN_USB_HEADSET" role="source">
-                    <profile name="" format="AUDIO_FORMAT_PCM_16_BIT"
-                             samplingRates="44100,48000,64000,88200,96000,128000,176400,192000"
-                             channelMasks="AUDIO_CHANNEL_IN_MONO,AUDIO_CHANNEL_IN_STEREO,AUDIO_CHANNEL_INDEX_MASK_6,AUDIO_CHANNEL_IN_7POINT1,AUDIO_CHANNEL_INDEX_MASK_8"/>
-                    <profile name="" format="AUDIO_FORMAT_PCM_8_24_BIT"
-                             samplingRates="44100,48000,64000,88200,96000,128000,176400,192000"
-                             channelMasks="AUDIO_CHANNEL_IN_MONO,AUDIO_CHANNEL_IN_STEREO,AUDIO_CHANNEL_INDEX_MASK_6,AUDIO_CHANNEL_IN_7POINT1,AUDIO_CHANNEL_INDEX_MASK_8"/>
-                    <!-- edit as needed -->
-                    <profile name="" format="AUDIO_FORMAT_PCM_32_BIT"
-                             samplingRates="44100,48000,64000,88200,96000,128000,176400,192000"
-                             channelMasks="AUDIO_CHANNEL_IN_MONO,AUDIO_CHANNEL_IN_STEREO,AUDIO_CHANNEL_INDEX_MASK_6,AUDIO_CHANNEL_IN_7POINT1,AUDIO_CHANNEL_INDEX_MASK_8"/>
                 </devicePort>
 
             </devicePorts>
diff --git a/configs/trinket/mixer_paths_idp.xml b/configs/trinket/mixer_paths_idp.xml
index b341a3c..5e769db 100644
--- a/configs/trinket/mixer_paths_idp.xml
+++ b/configs/trinket/mixer_paths_idp.xml
@@ -2185,6 +2185,10 @@
         <path name="handset" />
     </path>
 
+    <path name="voice-handset-tmus">
+        <path name="handset" />
+    </path>
+
     <path name="voice-speaker">
         <path name="speaker-mono" />
     </path>
diff --git a/configs/trinket/mixer_paths_qrd.xml b/configs/trinket/mixer_paths_qrd.xml
index 7039dbb..9fbc525 100644
--- a/configs/trinket/mixer_paths_qrd.xml
+++ b/configs/trinket/mixer_paths_qrd.xml
@@ -2180,6 +2180,10 @@
         <path name="handset" />
     </path>
 
+    <path name="voice-handset-tmus">
+        <path name="handset" />
+    </path>
+
     <path name="voice-speaker">
         <path name="speaker-mono" />
     </path>
diff --git a/configs/trinket/trinket.mk b/configs/trinket/trinket.mk
index 44babfa..5176889 100644
--- a/configs/trinket/trinket.mk
+++ b/configs/trinket/trinket.mk
@@ -92,6 +92,8 @@
     vendor/qcom/opensource/audio-hal/primary-hal/configs/trinket/mixer_paths_tavil.xml:$(TARGET_COPY_OUT_VENDOR)/etc/mixer_paths_tavil.xml \
     vendor/qcom/opensource/audio-hal/primary-hal/configs/trinket/mixer_paths_tasha.xml:$(TARGET_COPY_OUT_VENDOR)/etc/mixer_paths_tasha.xml \
     vendor/qcom/opensource/audio-hal/primary-hal/configs/trinket/mixer_paths_tashalite.xml:$(TARGET_COPY_OUT_VENDOR)/etc/mixer_paths_tashalite.xml \
+    frameworks/native/data/etc/android.hardware.audio.pro.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/android.hardware.audio.pro.xml \
+    frameworks/native/data/etc/android.hardware.audio.low_latency.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/android.hardware.audio.low_latency.xml
 
 #XML Audio configuration files
 ifneq ($(TARGET_USES_AOSP_FOR_AUDIO), true)
@@ -185,7 +187,7 @@
 
 #enable pbe effects
 PRODUCT_PROPERTY_OVERRIDES += \
-vendor.audio.safx.pbe.enabled=true
+vendor.audio.safx.pbe.enabled=false
 
 #parser input buffer size(256kb) in byte stream mode
 PRODUCT_PROPERTY_OVERRIDES += \
@@ -233,12 +235,15 @@
 PRODUCT_PROPERTY_OVERRIDES += \
 vendor.audio.adm.buffering.ms=2
 
+#enable AAC frame ctl for A2DP sinks
+PRODUCT_PROPERTY_OVERRIDES += \
+persist.vendor.bt.aac_frm_ctl.enabled=true
+
 #add dynamic feature flags here
 PRODUCT_PROPERTY_OVERRIDES += \
 vendor.audio.feature.a2dp_offload.enable=true \
 vendor.audio.feature.afe_proxy.enable=true \
 vendor.audio.feature.anc_headset.enable=true \
-vendor.audio.feature.audio_sphere.enable=true \
 vendor.audio.feature.battery_listener.enable=false \
 vendor.audio.feature.compr_cap.enable=false \
 vendor.audio.feature.compress_in.enable=false \
diff --git a/hal/Android.mk b/hal/Android.mk
index 0ce2d6e..a671373 100644
--- a/hal/Android.mk
+++ b/hal/Android.mk
@@ -210,12 +210,14 @@
 endif
 
 # Hardware specific feature
-ifeq ($(strip $(BOARD_SUPPORTS_QAHW)),true)
-    LOCAL_CFLAGS += -DAUDIO_HW_EXTN_API_ENABLED
-    LOCAL_SRC_FILES += audio_hw_extn_api.c
+ifeq ($(strip $(AUDIO_FEATURE_ENABLED_QAP)),true)
+LOCAL_CFLAGS += -DQAP_EXTN_ENABLED -Wno-tautological-pointer-compare
+LOCAL_SRC_FILES += audio_extn/qap.c
+LOCAL_C_INCLUDES += $(TARGET_OUT_HEADERS)/mm-audio/qap_wrapper/
+LOCAL_HEADER_LIBRARIES += audio_qaf_headers
+LOCAL_SHARED_LIBRARIES += libqap_wrapper liblog
 endif
 
-# Hardware specific feature
 ifeq ($(strip $(AUDIO_FEATURE_ENABLED_LISTEN)),true)
     LOCAL_CFLAGS += -DAUDIO_LISTEN_ENABLED
     LOCAL_C_INCLUDES += $(TARGET_OUT_HEADERS)/mm-audio/audio-listen
diff --git a/hal/audio_extn/audio_extn.c b/hal/audio_extn/audio_extn.c
index f00f74d..f9f33d1 100644
--- a/hal/audio_extn/audio_extn.c
+++ b/hal/audio_extn/audio_extn.c
@@ -98,12 +98,13 @@
 bool cin_attached_usecase(audio_usecase_t uc_id);
 bool cin_format_supported(audio_format_t format);
 size_t cin_get_buffer_size(struct stream_in *in);
-int cin_start_input_stream(struct stream_in *in);
+int cin_open_input_stream(struct stream_in *in);
 void cin_stop_input_stream(struct stream_in *in);
 void cin_close_input_stream(struct stream_in *in);
+void cin_free_input_stream_resources(struct stream_in *in);
 int cin_read(struct stream_in *in, void *buffer,
                         size_t bytes, size_t *bytes_read);
-int cin_configure_input_stream(struct stream_in *in);
+int cin_configure_input_stream(struct stream_in *in, struct audio_config *in_config);
 
 void audio_extn_set_snd_card_split(const char* in_snd_card_name)
 {
@@ -366,9 +367,9 @@
     }
 }
 
-static int update_custom_mtmx_coefficients(struct audio_device *adev,
-                                           struct audio_custom_mtmx_params *params,
-                                           int pcm_device_id)
+static int update_custom_mtmx_coefficients_v2(struct audio_device *adev,
+                                              struct audio_custom_mtmx_params *params,
+                                              int pcm_device_id)
 {
     struct mixer_ctl *ctl = NULL;
     char *mixer_name_prefix = "AudStr";
@@ -430,9 +431,9 @@
     return 0;
 }
 
-static void set_custom_mtmx_params(struct audio_device *adev,
-                                   struct audio_custom_mtmx_params_info *pinfo,
-                                   int pcm_device_id, bool enable)
+static void set_custom_mtmx_params_v2(struct audio_device *adev,
+                                      struct audio_custom_mtmx_params_info *pinfo,
+                                      int pcm_device_id, bool enable)
 {
     struct mixer_ctl *ctl = NULL;
     char *mixer_name_prefix = "AudStr";
@@ -465,7 +466,7 @@
         ALOGE("%s: ERROR. Mixer ctl set failed", __func__);
 }
 
-void audio_extn_set_custom_mtmx_params(struct audio_device *adev,
+void audio_extn_set_custom_mtmx_params_v2(struct audio_device *adev,
                                         struct audio_usecase *usecase,
                                         bool enable)
 {
@@ -535,16 +536,402 @@
         params = platform_get_custom_mtmx_params(adev->platform, &info);
         if (params) {
             if (enable)
-                ret = update_custom_mtmx_coefficients(adev, params,
+                ret = update_custom_mtmx_coefficients_v2(adev, params,
                                                       pcm_device_id);
             if (ret < 0)
                 ALOGE("%s: error updating mtmx coeffs err:%d", __func__, ret);
             else
-                set_custom_mtmx_params(adev, &info, pcm_device_id, enable);
+                set_custom_mtmx_params_v2(adev, &info, pcm_device_id, enable);
         }
     }
 }
 
+static int set_custom_mtmx_output_channel_map(struct audio_device *adev,
+                                              char *mixer_name_prefix,
+                                              uint32_t ch_count,
+                                              bool enable)
+{
+    struct mixer_ctl *ctl = NULL;
+    char mixer_ctl_name[128] = {0};
+    int ret = 0;
+    int channel_map[AUDIO_MAX_DSP_CHANNELS] = {0};
+
+    ALOGV("%s channel_count %d", __func__, ch_count);
+
+    if (!enable) {
+        ALOGV("%s: reset output channel map", __func__);
+        goto exit;
+    }
+
+    switch (ch_count) {
+    case 2:
+        channel_map[0] = PCM_CHANNEL_FL;
+        channel_map[1] = PCM_CHANNEL_FR;
+        break;
+    case 4:
+        channel_map[0] = PCM_CHANNEL_FL;
+        channel_map[1] = PCM_CHANNEL_FR;
+        channel_map[2] = PCM_CHANNEL_LS;
+        channel_map[3] = PCM_CHANNEL_RS;
+        break;
+    case 6:
+        channel_map[0] = PCM_CHANNEL_FL;
+        channel_map[1] = PCM_CHANNEL_FR;
+        channel_map[2] = PCM_CHANNEL_FC;
+        channel_map[3] = PCM_CHANNEL_LFE;
+        channel_map[4] = PCM_CHANNEL_LS;
+        channel_map[5] = PCM_CHANNEL_RS;
+        break;
+    case 8:
+        channel_map[0] = PCM_CHANNEL_FL;
+        channel_map[1] = PCM_CHANNEL_FR;
+        channel_map[2] = PCM_CHANNEL_FC;
+        channel_map[3] = PCM_CHANNEL_LFE;
+        channel_map[4] = PCM_CHANNEL_LB;
+        channel_map[5] = PCM_CHANNEL_RB;
+        channel_map[6] = PCM_CHANNEL_LS;
+        channel_map[7] = PCM_CHANNEL_RS;
+        break;
+    case 10:
+        channel_map[0] = PCM_CHANNEL_FL;
+        channel_map[1] = PCM_CHANNEL_FR;
+        channel_map[2] = PCM_CHANNEL_LFE;
+        channel_map[3] = PCM_CHANNEL_FC;
+        channel_map[4] = PCM_CHANNEL_LB;
+        channel_map[5] = PCM_CHANNEL_RB;
+        channel_map[6] = PCM_CHANNEL_LS;
+        channel_map[7] = PCM_CHANNEL_RS;
+        channel_map[8] = PCM_CHANNEL_TFL;
+        channel_map[9] = PCM_CHANNEL_TFR;
+        break;
+    case 12:
+        channel_map[0] = PCM_CHANNEL_FL;
+        channel_map[1] = PCM_CHANNEL_FR;
+        channel_map[2] = PCM_CHANNEL_FC;
+        channel_map[3] = PCM_CHANNEL_LFE;
+        channel_map[4] = PCM_CHANNEL_LB;
+        channel_map[5] = PCM_CHANNEL_RB;
+        channel_map[6] = PCM_CHANNEL_LS;
+        channel_map[7] = PCM_CHANNEL_RS;
+        channel_map[8] = PCM_CHANNEL_TFL;
+        channel_map[9] = PCM_CHANNEL_TFR;
+        channel_map[10] = PCM_CHANNEL_TSL;
+        channel_map[11] = PCM_CHANNEL_TSR;
+        break;
+    case 14:
+        channel_map[0] = PCM_CHANNEL_FL;
+        channel_map[1] = PCM_CHANNEL_FR;
+        channel_map[2] = PCM_CHANNEL_LFE;
+        channel_map[3] = PCM_CHANNEL_FC;
+        channel_map[4] = PCM_CHANNEL_LB;
+        channel_map[5] = PCM_CHANNEL_RB;
+        channel_map[6] = PCM_CHANNEL_LS;
+        channel_map[7] = PCM_CHANNEL_RS;
+        channel_map[8] = PCM_CHANNEL_TFL;
+        channel_map[9] = PCM_CHANNEL_TFR;
+        channel_map[10] = PCM_CHANNEL_TSL;
+        channel_map[11] = PCM_CHANNEL_TSR;
+        channel_map[12] = PCM_CHANNEL_FLC;
+        channel_map[13] = PCM_CHANNEL_FRC;
+        break;
+    case 16:
+        channel_map[0] = PCM_CHANNEL_FL;
+        channel_map[1] = PCM_CHANNEL_FR;
+        channel_map[2] = PCM_CHANNEL_FC;
+        channel_map[3] = PCM_CHANNEL_LFE;
+        channel_map[4] = PCM_CHANNEL_LB;
+        channel_map[5] = PCM_CHANNEL_RB;
+        channel_map[6] = PCM_CHANNEL_LS;
+        channel_map[7] = PCM_CHANNEL_RS;
+        channel_map[8] = PCM_CHANNEL_TFL;
+        channel_map[9] = PCM_CHANNEL_TFR;
+        channel_map[10] = PCM_CHANNEL_TSL;
+        channel_map[11] = PCM_CHANNEL_TSR;
+        channel_map[12] = PCM_CHANNEL_FLC;
+        channel_map[13] = PCM_CHANNEL_FRC;
+        channel_map[14] = PCM_CHANNEL_RLC;
+        channel_map[15] = PCM_CHANNEL_RRC;
+        break;
+    default:
+        ALOGE("%s: unsupported channels(%d) for setting channel map",
+               __func__, ch_count);
+        return -EINVAL;
+    }
+
+exit:
+    snprintf(mixer_ctl_name, sizeof(mixer_ctl_name), "%s %s",
+             mixer_name_prefix, "Output Channel Map");
+
+    ctl = mixer_get_ctl_by_name(adev->mixer, mixer_ctl_name);
+    if (!ctl) {
+        ALOGE("%s: ERROR. Could not get ctl for mixer cmd - %s",
+               __func__, mixer_ctl_name);
+        return -EINVAL;
+    }
+
+    ret = mixer_ctl_set_array(ctl, channel_map, ch_count);
+    return ret;
+}
+
+static int update_custom_mtmx_coefficients_v1(struct audio_device *adev,
+                                           struct audio_custom_mtmx_params *params,
+                                           struct audio_custom_mtmx_in_params *in_params,
+                                           int pcm_device_id,
+                                           usecase_type_t type,
+                                           bool enable)
+{
+    struct mixer_ctl *ctl = NULL;
+    char mixer_ctl_name[128] = {0};
+    struct audio_custom_mtmx_params_info *pinfo = &params->info;
+    char mixer_name_prefix[100];
+    int i = 0, err = 0, rule = 0;
+    uint32_t mtrx_row_cnt = 0, mtrx_column_cnt = 0;
+    int reset_coeffs[AUDIO_MAX_DSP_CHANNELS] = {0};
+
+    ALOGI("%s: ip_channels %d, op_channels %d, pcm_device_id %d, usecase type %d, enable %d",
+          __func__, pinfo->ip_channels, pinfo->op_channels, pcm_device_id,
+          type, enable);
+
+    if (!strcmp(pinfo->fe_name, "")) {
+        ALOGE("%s: Error. no front end defined", __func__);
+        return -EINVAL;
+    }
+
+    strlcpy(mixer_name_prefix, pinfo->fe_name, sizeof(mixer_name_prefix));
+
+    /*
+     * Enable/Disable channel mixer.
+     * If enable, use params and in_params to configure mixer.
+     * If disable, reset previously configured mixer.
+    */
+    snprintf(mixer_ctl_name, sizeof(mixer_ctl_name), "%s %s",
+             mixer_name_prefix, "Channel Mixer");
+
+    ctl = mixer_get_ctl_by_name(adev->mixer, mixer_ctl_name);
+    if (!ctl) {
+        ALOGE("%s: ERROR. Could not get ctl for mixer cmd - %s",
+               __func__, mixer_ctl_name);
+        return -EINVAL;
+    }
+
+    if (enable)
+        err = mixer_ctl_set_enum_by_string(ctl, "Enable");
+    else
+        err = mixer_ctl_set_enum_by_string(ctl, "Disable");
+
+    if (err) {
+        ALOGE("%s: ERROR. %s channel mixer failed", __func__,
+              enable ? "Enable" : "Disable");
+        return -EINVAL;
+    }
+
+    /* Configure output channels of channel mixer */
+    snprintf(mixer_ctl_name, sizeof(mixer_ctl_name), "%s %s",
+             mixer_name_prefix, "Channels");
+
+    ctl = mixer_get_ctl_by_name(adev->mixer, mixer_ctl_name);
+    if (!ctl) {
+        ALOGE("%s: ERROR. Could not get ctl for mixer cmd - %s",
+               __func__, mixer_ctl_name);
+        return -EINVAL;
+    }
+
+    mtrx_row_cnt = pinfo->op_channels;
+    mtrx_column_cnt = pinfo->ip_channels;
+
+    if (enable)
+        err = mixer_ctl_set_value(ctl, 0, mtrx_row_cnt);
+    else
+        err = mixer_ctl_set_value(ctl, 0, 0);
+
+    if (err) {
+        ALOGE("%s: ERROR. %s mixer output channels failed", __func__,
+              enable ? "Set" : "Reset");
+        return -EINVAL;
+    }
+
+
+    /* To keep output channel map in sync with asm driver channel mapping */
+    err = set_custom_mtmx_output_channel_map(adev, mixer_name_prefix, mtrx_row_cnt,
+                                       enable);
+    if (err) {
+        ALOGE("%s: ERROR. %s mtmx output channel map failed", __func__,
+              enable ? "Set" : "Reset");
+        return -EINVAL;
+    }
+
+    /* Send channel mixer rule */
+    snprintf(mixer_ctl_name, sizeof(mixer_ctl_name), "%s %s",
+             mixer_name_prefix, "Channel Rule");
+
+    ctl = mixer_get_ctl_by_name(adev->mixer, mixer_ctl_name);
+    if (!ctl) {
+        ALOGE("%s: ERROR. Could not get ctl for mixer cmd - %s",
+               __func__, mixer_ctl_name);
+        return -EINVAL;
+    }
+
+    mixer_ctl_set_value(ctl, 0, rule);
+
+    /* Send channel coefficients for each output channel */
+    for (i = 0; i < mtrx_row_cnt; i++) {
+        snprintf(mixer_ctl_name, sizeof(mixer_ctl_name), "%s %s%d",
+                 mixer_name_prefix, "Output Channel", i+1);
+        ctl = mixer_get_ctl_by_name(adev->mixer, mixer_ctl_name);
+        if (!ctl) {
+            ALOGE("%s: ERROR. Could not get ctl for mixer cmd - %s",
+                  __func__, mixer_ctl_name);
+            return -EINVAL;
+        }
+
+        if (enable)
+            err = mixer_ctl_set_array(ctl,
+                                  &params->coeffs[mtrx_column_cnt * i],
+                                  mtrx_column_cnt);
+        else
+            err = mixer_ctl_set_array(ctl,
+                                  reset_coeffs,
+                                  mtrx_column_cnt);
+        if (err) {
+            ALOGE("%s: ERROR. %s coefficients failed for output channel %d",
+                   __func__, enable ? "Set" : "Reset", i);
+            return -EINVAL;
+        }
+    }
+
+    /* Configure backend interfaces with information provided in xml */
+    i = 0;
+    while (in_params->in_ch_info[i].ch_count != 0) {
+        snprintf(mixer_ctl_name, sizeof(mixer_ctl_name), "%s %s%d",
+                 mixer_name_prefix, "Channel", i+1);
+        ctl = mixer_get_ctl_by_name(adev->mixer, mixer_ctl_name);
+        if (!ctl) {
+            ALOGE("%s: ERROR. Could not get ctl for mixer cmd - %s",
+                  __func__, mixer_ctl_name);
+            return -EINVAL;
+        }
+        if (enable) {
+            ALOGD("%s: mixer %s, interface %s", __func__, mixer_ctl_name,
+                   in_params->in_ch_info[i].hw_interface);
+            err = mixer_ctl_set_enum_by_string(ctl,
+                      in_params->in_ch_info[i].hw_interface);
+        } else {
+            err = mixer_ctl_set_enum_by_string(ctl, "ZERO");
+        }
+
+        if (err) {
+            ALOGE("%s: ERROR. %s channel backend interface failed", __func__,
+                   enable ? "Set" : "Reset");
+            return -EINVAL;
+        }
+        i++;
+    }
+
+    return 0;
+}
+
+
+void audio_extn_set_custom_mtmx_params_v1(struct audio_device *adev,
+                                       struct audio_usecase *usecase,
+                                       bool enable)
+{
+    struct audio_custom_mtmx_params_info info = {0};
+    struct audio_custom_mtmx_params *params = NULL;
+    struct audio_custom_mtmx_in_params_info in_info = {0};
+    struct audio_custom_mtmx_in_params *in_params = NULL;
+    int pcm_device_id = -1, ret = 0;
+    uint32_t feature_id = 0;
+
+    switch(usecase->type) {
+    case PCM_CAPTURE:
+        if (usecase->stream.in) {
+            pcm_device_id =
+                platform_get_pcm_device_id(usecase->id, PCM_CAPTURE);
+            info.snd_device = usecase->in_snd_device;
+        } else {
+            ALOGE("%s: invalid input stream for capture usecase id:%d",
+                  __func__, usecase->id);
+            return;
+        }
+        break;
+    case PCM_PLAYBACK:
+    default:
+        ALOGV("%s: unsupported usecase id:%d", __func__, usecase->id);
+        return;
+    }
+
+    ALOGD("%s: snd device %d", __func__, info.snd_device);
+    info.id = feature_id;
+    info.usecase_id = usecase->id;
+    info.op_channels = audio_channel_count_from_in_mask(
+                                usecase->stream.in->channel_mask);
+
+    in_info.usecase_id = info.usecase_id;
+    in_info.op_channels = info.op_channels;
+    in_params = platform_get_custom_mtmx_in_params(adev->platform, &in_info);
+    if (!in_params) {
+        ALOGE("%s: Could not get in params for usecase %d, channels %d",
+               __func__, in_info.usecase_id, in_info.op_channels);
+        return;
+    }
+
+    info.ip_channels = in_params->ip_channels;
+    ALOGD("%s: ip channels %d, op channels %d", __func__, info.ip_channels, info.op_channels);
+
+    params = platform_get_custom_mtmx_params(adev->platform, &info);
+    if (params) {
+        ret = update_custom_mtmx_coefficients_v1(adev, params, in_params,
+                             pcm_device_id, usecase->type, enable);
+        if (ret < 0)
+            ALOGE("%s: error updating mtmx coeffs err:%d", __func__, ret);
+    }
+}
+
+snd_device_t audio_extn_get_loopback_snd_device(struct audio_device *adev,
+                                                struct audio_usecase *usecase,
+                                                int channel_count)
+{
+    snd_device_t snd_device = SND_DEVICE_NONE;
+    struct audio_custom_mtmx_in_params_info in_info = {0};
+    struct audio_custom_mtmx_in_params *in_params = NULL;
+
+    if (!adev || !usecase) {
+        ALOGE("%s: Invalid params", __func__);
+        return snd_device;
+    }
+
+    in_info.usecase_id = usecase->id;
+    in_info.op_channels = channel_count;
+    in_params = platform_get_custom_mtmx_in_params(adev->platform, &in_info);
+    if (!in_params) {
+        ALOGE("%s: Could not get in params for usecase %d, channels %d",
+               __func__, in_info.usecase_id, in_info.op_channels);
+        return snd_device;
+    }
+
+    switch(in_params->mic_ch) {
+    case 2:
+        snd_device = SND_DEVICE_IN_HANDSET_DMIC_AND_EC_REF_LOOPBACK;
+        break;
+    case 4:
+        snd_device = SND_DEVICE_IN_HANDSET_QMIC_AND_EC_REF_LOOPBACK;
+        break;
+    case 6:
+        snd_device = SND_DEVICE_IN_HANDSET_6MIC_AND_EC_REF_LOOPBACK;
+        break;
+    case 8:
+        snd_device = SND_DEVICE_IN_HANDSET_8MIC_AND_EC_REF_LOOPBACK;
+        break;
+    default:
+        ALOGE("%s: Unsupported mic channels %d",
+               __func__, in_params->mic_ch);
+        break;
+    }
+
+    ALOGD("%s: return snd device %d", __func__, snd_device);
+    return snd_device;
+}
+
 #ifndef DTS_EAGLE
 #define audio_extn_hpx_set_parameters(adev, parms)         (0)
 #define audio_extn_hpx_get_parameters(query, reply)  (0)
@@ -2893,10 +3280,10 @@
     *channel_mask_updated = false;
 
     int max_mic_count = platform_get_max_mic_count(adev->platform);
-    /* validate input params*/
+    /* validate input params. Avoid updated channel mask if loopback device */
     if ((channel_count == 6) &&
-        (in->format == AUDIO_FORMAT_PCM_16_BIT)) {
-
+        (in->format == AUDIO_FORMAT_PCM_16_BIT) &&
+        (!is_loopback_input_device(in->device))) {
         switch (max_mic_count) {
             case 4:
                 config->channel_mask = AUDIO_CHANNEL_INDEX_MASK_4;
@@ -4262,52 +4649,52 @@
 int audio_extn_ext_hw_plugin_deinit(void *plugin)
 {
     return ((ext_hw_plugin_deinit) ?
-                            ext_hw_plugin_deinit(plugin): -1);
+                            ext_hw_plugin_deinit(plugin): 0);
 }
 
 int audio_extn_ext_hw_plugin_usecase_start(void *plugin, struct audio_usecase *usecase)
 {
     return ((ext_hw_plugin_usecase_start) ?
-                            ext_hw_plugin_usecase_start(plugin, usecase): -1);
+                            ext_hw_plugin_usecase_start(plugin, usecase): 0);
 }
 
 int audio_extn_ext_hw_plugin_usecase_stop(void *plugin, struct audio_usecase *usecase)
 {
     return ((ext_hw_plugin_usecase_stop) ?
-                            ext_hw_plugin_usecase_stop(plugin, usecase): -1);
+                            ext_hw_plugin_usecase_stop(plugin, usecase): 0);
 }
 
 int audio_extn_ext_hw_plugin_set_parameters(void *plugin,
                                            struct str_parms *parms)
 {
     return ((ext_hw_plugin_set_parameters) ?
-                            ext_hw_plugin_set_parameters(plugin, parms): -1);
+                            ext_hw_plugin_set_parameters(plugin, parms): 0);
 }
 
 int audio_extn_ext_hw_plugin_get_parameters(void *plugin,
                   struct str_parms *query, struct str_parms *reply)
 {
     return ((ext_hw_plugin_get_parameters) ?
-                        ext_hw_plugin_get_parameters(plugin, query, reply): -1);
+                        ext_hw_plugin_get_parameters(plugin, query, reply): 0);
 }
 
 int audio_extn_ext_hw_plugin_set_mic_mute(void *plugin, bool mute)
 {
     return ((ext_hw_plugin_set_mic_mute) ?
-                        ext_hw_plugin_set_mic_mute(plugin, mute): -1);
+                        ext_hw_plugin_set_mic_mute(plugin, mute): 0);
 }
 
 int audio_extn_ext_hw_plugin_get_mic_mute(void *plugin, bool *mute)
 {
     return ((ext_hw_plugin_get_mic_mute) ?
-                        ext_hw_plugin_get_mic_mute(plugin, mute): -1);
+                        ext_hw_plugin_get_mic_mute(plugin, mute): 0);
 }
 
 int audio_extn_ext_hw_plugin_set_audio_gain(void *plugin,
             struct audio_usecase *usecase, uint32_t gain)
 {
     return ((ext_hw_plugin_set_audio_gain) ?
-                        ext_hw_plugin_set_audio_gain(plugin, usecase, gain): -1);
+                        ext_hw_plugin_set_audio_gain(plugin, usecase, gain): 0);
 }
 // END: EXT_HW_PLUGIN ===================================================================
 
@@ -4608,6 +4995,7 @@
                                                     audio_extn_utils_is_dolby_format;
         passthru_init(init_config);
         ALOGD("%s:: ---- Feature HDMI_PASSTHROUGH is Enabled ----", __func__);
+        return;
     }
 
 feature_disabled:
@@ -4676,9 +5064,9 @@
 {
     return (audio_extn_compress_in_enabled? cin_get_buffer_size(in): 0);
 }
-int audio_extn_cin_start_input_stream(struct stream_in *in)
+int audio_extn_cin_open_input_stream(struct stream_in *in)
 {
-    return (audio_extn_compress_in_enabled? cin_start_input_stream(in): -1);
+    return (audio_extn_compress_in_enabled? cin_open_input_stream(in): -1);
 }
 void audio_extn_cin_stop_input_stream(struct stream_in *in)
 {
@@ -4688,15 +5076,19 @@
 {
     (audio_extn_compress_in_enabled? cin_close_input_stream(in): NULL);
 }
+void audio_extn_cin_free_input_stream_resources(struct stream_in *in)
+{
+    return (audio_extn_compress_in_enabled? cin_free_input_stream_resources(in): NULL);
+}
 int audio_extn_cin_read(struct stream_in *in, void *buffer,
                         size_t bytes, size_t *bytes_read)
 {
     return (audio_extn_compress_in_enabled?
                             cin_read(in, buffer, bytes, bytes_read): -1);
 }
-int audio_extn_cin_configure_input_stream(struct stream_in *in)
+int audio_extn_cin_configure_input_stream(struct stream_in *in, struct audio_config *in_config)
 {
-    return (audio_extn_compress_in_enabled? cin_configure_input_stream(in): -1);
+    return (audio_extn_compress_in_enabled? cin_configure_input_stream(in, in_config): -1);
 }
 // END: COMPRESS_IN ====================================================
 
@@ -4721,7 +5113,6 @@
 void battery_listener_feature_init(bool is_feature_enabled)
 {
     audio_extn_battery_listener_enabled = is_feature_enabled;
-    ALOGD("%s: ---- Feature BATTERY_LISTENER is %s----", __func__, is_feature_enabled? "ENABLED": "NOT ENABLED");
     if (is_feature_enabled) {
         // dlopen lib
         batt_listener_lib_handle = dlopen(BATTERY_LISTENER_LIB_PATH, RTLD_NOW);
@@ -4741,6 +5132,8 @@
              ALOGE("%s: dlsym failed", __func__);
                 goto feature_disabled;
         }
+        ALOGD("%s: ---- Feature BATTERY_LISTENER is enabled ----", __func__);
+        return;
     }
 
     feature_disabled:
@@ -5141,6 +5534,8 @@
    audio_extn_passthru_set_parameters(adev, parms);
    audio_extn_ext_disp_set_parameters(adev, parms);
    audio_extn_qaf_set_parameters(adev, parms);
+   if (audio_extn_qap_is_enabled())
+       audio_extn_qap_set_parameters(adev, parms);
    if (adev->offload_effects_set_parameters != NULL)
        adev->offload_effects_set_parameters(parms);
    audio_extn_set_aptx_dec_bt_addr(adev, parms);
diff --git a/hal/audio_extn/audio_extn.h b/hal/audio_extn/audio_extn.h
index 5e2e643..7364d76 100644
--- a/hal/audio_extn/audio_extn.h
+++ b/hal/audio_extn/audio_extn.h
@@ -216,6 +216,9 @@
 
 //END: EXTN_QDSP_PLUGIN      ===========================================
 
+#define MIN_OFFLOAD_BUFFER_DURATION_MS 5 /* 5ms */
+#define MAX_OFFLOAD_BUFFER_DURATION_MS (100 * 1000) /* 100s */
+
 void audio_extn_set_parameters(struct audio_device *adev,
                                struct str_parms *parms);
 
@@ -434,6 +437,7 @@
 #define audio_extn_sound_trigger_update_device_status(snd_dev, event)  (0)
 #define audio_extn_sound_trigger_update_stream_status(uc_info, event)  (0)
 #define audio_extn_sound_trigger_update_battery_status(charging)       (0)
+#define audio_extn_sound_trigger_update_screen_status(screen_off)      (0)
 #define audio_extn_sound_trigger_set_parameters(adev, parms)           (0)
 #define audio_extn_sound_trigger_get_parameters(adev, query, reply)    (0)
 #define audio_extn_sound_trigger_check_and_get_session(in)             (0)
@@ -458,6 +462,7 @@
 void audio_extn_sound_trigger_update_stream_status(struct audio_usecase *uc_info,
                                      st_event_type_t event);
 void audio_extn_sound_trigger_update_battery_status(bool charging);
+void audio_extn_sound_trigger_update_screen_status(bool screen_off);
 void audio_extn_sound_trigger_set_parameters(struct audio_device *adev,
                                              struct str_parms *parms);
 void audio_extn_sound_trigger_check_and_get_session(struct stream_in *in);
@@ -910,6 +915,59 @@
 #define audio_extn_is_qaf_stream(out)                                   (0)
 #endif
 
+
+#ifdef QAP_EXTN_ENABLED
+/*
+ * Helper funtion to know if HAL QAP extention is enabled or not.
+ */
+bool audio_extn_qap_is_enabled();
+/*
+ * QAP HAL extention init, called during bootup/HAL device open.
+ * QAP library will be loaded in this funtion.
+ */
+int audio_extn_qap_init(struct audio_device *adev);
+void audio_extn_qap_deinit();
+/*
+ * if HAL QAP is enabled and inited succesfully then all then this funtion
+ * gets called for all the open_output_stream requests, in other words
+ * the core audio_hw->open_output_stream is overridden by this funtion
+ */
+int audio_extn_qap_open_output_stream(struct audio_hw_device *dev,
+                                   audio_io_handle_t handle,
+                                   audio_devices_t devices,
+                                   audio_output_flags_t flags,
+                                   struct audio_config *config,
+                                   struct audio_stream_out **stream_out,
+                                   const char *address __unused);
+void audio_extn_qap_close_output_stream(struct audio_hw_device *dev __unused,
+                                        struct audio_stream_out *stream);
+/*
+ * this funtion is how HAL QAP extention gets to know the device connection/disconnection
+ */
+int audio_extn_qap_set_parameters(struct audio_device *adev, struct str_parms *parms);
+int audio_extn_qap_out_set_param_data(struct stream_out *out,
+                           audio_extn_param_id param_id,
+                           audio_extn_param_payload *payload);
+int audio_extn_qap_out_get_param_data(struct stream_out *out,
+                             audio_extn_param_id param_id,
+                             audio_extn_param_payload *payload);
+/*
+ * helper funtion.
+ */
+bool audio_extn_is_qap_stream(struct stream_out *out);
+#else
+#define audio_extn_qap_is_enabled()                                     (0)
+#define audio_extn_qap_deinit()                                         (0)
+#define audio_extn_qap_close_output_stream         adev_close_output_stream
+#define audio_extn_qap_open_output_stream           adev_open_output_stream
+#define audio_extn_qap_init(adev)                                       (0)
+#define audio_extn_qap_set_parameters(adev, parms)                      (0)
+#define audio_extn_qap_out_set_param_data(out, param_id, payload)       (0)
+#define audio_extn_qap_out_get_param_data(out, param_id, payload)       (0)
+#define audio_extn_is_qap_stream(out)                                   (0)
+#endif
+
+
 #ifdef AUDIO_EXTN_BT_HAL_ENABLED
 int audio_extn_bt_hal_load(void **handle);
 int audio_extn_bt_hal_open_output_stream(void *handle, int in_rate, audio_channel_mask_t channel_mask, int bit_width);
@@ -1011,12 +1069,13 @@
 bool audio_extn_cin_attached_usecase(audio_usecase_t uc_id);
 bool audio_extn_cin_format_supported(audio_format_t format);
 size_t audio_extn_cin_get_buffer_size(struct stream_in *in);
-int audio_extn_cin_start_input_stream(struct stream_in *in);
+int audio_extn_cin_open_input_stream(struct stream_in *in);
 void audio_extn_cin_stop_input_stream(struct stream_in *in);
 void audio_extn_cin_close_input_stream(struct stream_in *in);
+void audio_extn_cin_free_input_stream_resources(struct stream_in *in);
 int audio_extn_cin_read(struct stream_in *in, void *buffer,
                         size_t bytes, size_t *bytes_read);
-int audio_extn_cin_configure_input_stream(struct stream_in *in);
+int audio_extn_cin_configure_input_stream(struct stream_in *in, struct audio_config *in_config);
 // END: COMPRESS_INPUT_ENABLED ===============================
 
 //START: SOURCE_TRACKING_FEATURE ==============================================
@@ -1091,6 +1150,8 @@
             uint64_t *frames, struct timespec *timestamp, int32_t clock_id);
 int audio_extn_utils_pcm_get_dsp_presentation_pos(struct stream_out *out,
             uint64_t *frames, struct timespec *timestamp, int32_t clock_id);
+size_t audio_extn_utils_get_input_buffer_size(uint32_t, audio_format_t, int, int64_t, bool);
+int audio_extn_utils_get_perf_mode_flag(void);
 #ifdef AUDIO_HW_LOOPBACK_ENABLED
 /* API to create audio patch */
 int audio_extn_hw_loopback_create_audio_patch(struct audio_hw_device *dev,
@@ -1218,6 +1279,13 @@
 #define audio_extn_auto_hal_create_audio_patch(dev, num_sources,\
     sources, num_sinks, sinks, handle) (0)
 #define audio_extn_auto_hal_release_audio_patch(dev, handle) (0)
+#define audio_extn_auto_hal_get_car_audio_stream_from_address(address) (-1)
+#define audio_extn_auto_hal_open_output_stream(out) (0)
+#define audio_extn_auto_hal_is_bus_device_usecase(uc_id) (0)
+#define audio_extn_auto_hal_get_snd_device_for_car_audio_stream(out) (0)
+#define audio_extn_auto_hal_get_audio_port(dev, config) (0)
+#define audio_extn_auto_hal_set_audio_port_config(dev, config) (0)
+#define audio_extn_auto_hal_set_parameters(adev, parms) (0)
 #else
 int32_t audio_extn_auto_hal_init(struct audio_device *adev);
 void audio_extn_auto_hal_deinit(void);
@@ -1231,6 +1299,16 @@
                                 audio_patch_handle_t *handle);
 int audio_extn_auto_hal_release_audio_patch(struct audio_hw_device *dev,
                                 audio_patch_handle_t handle);
+int32_t audio_extn_auto_hal_get_car_audio_stream_from_address(const char *address);
+int32_t audio_extn_auto_hal_open_output_stream(struct stream_out *out);
+bool audio_extn_auto_hal_is_bus_device_usecase(audio_usecase_t uc_id);
+snd_device_t audio_extn_auto_hal_get_snd_device_for_car_audio_stream(struct stream_out *out);
+int audio_extn_auto_hal_get_audio_port(struct audio_hw_device *dev,
+                                struct audio_port *config);
+int audio_extn_auto_hal_set_audio_port_config(struct audio_hw_device *dev,
+                                const struct audio_port_config *config);
+void audio_extn_auto_hal_set_parameters(struct audio_device *adev,
+                                        struct str_parms *parms);
 #endif
 
 bool audio_extn_edid_is_supported_sr(edid_audio_info* info, int sr);
@@ -1252,7 +1330,13 @@
 void audio_extn_set_cpu_affinity();
 bool audio_extn_is_record_play_concurrency_enabled();
 bool audio_extn_is_concurrent_capture_enabled();
-void audio_extn_set_custom_mtmx_params(struct audio_device *adev,
+void audio_extn_set_custom_mtmx_params_v2(struct audio_device *adev,
                                         struct audio_usecase *usecase,
                                         bool enable);
+void audio_extn_set_custom_mtmx_params_v1(struct audio_device *adev,
+                                        struct audio_usecase *usecase,
+                                        bool enable);
+snd_device_t audio_extn_get_loopback_snd_device(struct audio_device *adev,
+                                                struct audio_usecase *usecase,
+                                                int channel_count);
 #endif /* AUDIO_EXTN_H */
diff --git a/hal/audio_extn/auto_hal.c b/hal/audio_extn/auto_hal.c
index c70dc17..ad5e331 100644
--- a/hal/audio_extn/auto_hal.c
+++ b/hal/audio_extn/auto_hal.c
@@ -54,12 +54,23 @@
 
 typedef struct auto_hal_module {
     struct audio_device *adev;
+    card_status_t card_status;
     struct hostless_config hostless;
 } auto_hal_module_t;
 
 /* Auto hal module struct */
 static struct auto_hal_module *auto_hal = NULL;
 
+extern struct pcm_config pcm_config_deep_buffer;
+extern struct pcm_config pcm_config_low_latency;
+
+static const audio_usecase_t bus_device_usecases[] = {
+    USECASE_AUDIO_PLAYBACK_MEDIA,
+    USECASE_AUDIO_PLAYBACK_SYS_NOTIFICATION,
+    USECASE_AUDIO_PLAYBACK_NAV_GUIDANCE,
+    USECASE_AUDIO_PLAYBACK_PHONE,
+};
+
 /* Note: Due to ADP H/W design, SoC TERT/SEC TDM CLK and FSYNC lines are
  * both connected with CODEC and a single master is needed to provide
  * consistent CLK and FSYNC to slaves, hence configuring SoC TERT TDM as
@@ -310,6 +321,274 @@
     return ret;
 }
 
+int32_t audio_extn_auto_hal_get_car_audio_stream_from_address(const char *address)
+{
+    int32_t bus_num = -1;
+    char *str = NULL;
+    char *last_r = NULL;
+    char local_address[AUDIO_DEVICE_MAX_ADDRESS_LEN];
+
+    /* bus device with null address error out */
+    if (address == NULL) {
+        ALOGE("%s: null address for car stream", __func__);
+        return -1;
+    }
+
+    /* strtok will modify the original string. make a copy first */
+    strlcpy(local_address, address, AUDIO_DEVICE_MAX_ADDRESS_LEN);
+
+    /* extract bus number from address */
+    str = strtok_r(local_address, "BUS_",&last_r);
+    if (str != NULL)
+        bus_num = (int32_t)strtol(str, (char **)NULL, 10);
+
+    /* validate bus number */
+    if ((bus_num < 0) || (bus_num >= MAX_CAR_AUDIO_STREAMS)) {
+        ALOGE("%s: invalid bus number %d", __func__, bus_num);
+        return -1;
+    }
+
+    return (0x1 << bus_num);
+}
+
+int32_t audio_extn_auto_hal_open_output_stream(struct stream_out *out)
+{
+    int ret = 0;
+    unsigned int channels = audio_channel_count_from_out_mask(out->channel_mask);
+
+    switch(out->car_audio_stream) {
+    case CAR_AUDIO_STREAM_MEDIA:
+        /* media bus stream shares pcm device with deep-buffer */
+        out->usecase = USECASE_AUDIO_PLAYBACK_MEDIA;
+        out->config = pcm_config_deep_buffer;
+        out->config.period_size = get_output_period_size(out->sample_rate, out->format,
+                                        channels, DEEP_BUFFER_OUTPUT_PERIOD_DURATION);
+        if (out->config.period_size <= 0) {
+            ALOGE("Invalid configuration period size is not valid");
+            ret = -EINVAL;
+            goto error;
+        }
+        break;
+    case CAR_AUDIO_STREAM_SYS_NOTIFICATION:
+        /* sys notification bus stream shares pcm device with low-latency */
+        out->usecase = USECASE_AUDIO_PLAYBACK_SYS_NOTIFICATION;
+        out->config = pcm_config_low_latency;
+        break;
+    case CAR_AUDIO_STREAM_NAV_GUIDANCE:
+        out->usecase = USECASE_AUDIO_PLAYBACK_NAV_GUIDANCE;
+        out->config = pcm_config_deep_buffer;
+        out->config.period_size = get_output_period_size(out->sample_rate, out->format,
+                                        channels, DEEP_BUFFER_OUTPUT_PERIOD_DURATION);
+        if (out->config.period_size <= 0) {
+            ALOGE("Invalid configuration period size is not valid");
+            ret = -EINVAL;
+            goto error;
+        }
+        break;
+    case CAR_AUDIO_STREAM_PHONE:
+        out->usecase = USECASE_AUDIO_PLAYBACK_PHONE;
+        out->config = pcm_config_low_latency;
+        break;
+    default:
+        ALOGE("%s: Car audio stream %x not supported", __func__,
+            out->car_audio_stream);
+        ret = -EINVAL;
+        goto error;
+    }
+
+error:
+    return ret;
+}
+
+bool audio_extn_auto_hal_is_bus_device_usecase(audio_usecase_t uc_id)
+{
+    unsigned int i;
+    for (i = 0; i < sizeof(bus_device_usecases)/sizeof(bus_device_usecases[0]); i++) {
+        if (uc_id == bus_device_usecases[i])
+            return true;
+    }
+    return false;
+}
+
+snd_device_t audio_extn_auto_hal_get_snd_device_for_car_audio_stream(struct stream_out *out)
+{
+    snd_device_t snd_device = SND_DEVICE_NONE;
+
+    switch(out->car_audio_stream) {
+    case CAR_AUDIO_STREAM_MEDIA:
+        snd_device = SND_DEVICE_OUT_BUS_MEDIA;
+        break;
+    case CAR_AUDIO_STREAM_SYS_NOTIFICATION:
+        snd_device = SND_DEVICE_OUT_BUS_SYS;
+        break;
+    case CAR_AUDIO_STREAM_NAV_GUIDANCE:
+        snd_device = SND_DEVICE_OUT_BUS_NAV;
+        break;
+    case CAR_AUDIO_STREAM_PHONE:
+        snd_device = SND_DEVICE_OUT_BUS_PHN;
+        break;
+    default:
+        ALOGE("%s: Unknown car audio stream (%x)",
+            __func__, out->car_audio_stream);
+    }
+    return snd_device;
+}
+
+int audio_extn_auto_hal_get_audio_port(struct audio_hw_device *dev __unused,
+                        struct audio_port *config __unused)
+{
+    return -ENOSYS;
+}
+
+/* Volume min/max defined by audio policy configuration in millibel.
+ * Support a range of -60dB to 6dB.
+ */
+#define MIN_VOLUME_VALUE_MB -6000
+#define MAX_VOLUME_VALUE_MB 600
+#define STEP_VALUE_MB 100
+int audio_extn_auto_hal_set_audio_port_config(struct audio_hw_device *dev,
+                        const struct audio_port_config *config)
+{
+    struct audio_device *adev = (struct audio_device *)dev;
+    int ret = 0;
+    struct listnode *node = NULL;
+    float volume = 0.0;
+
+    ALOGV("%s: enter", __func__);
+
+    if (!config) {
+        ALOGE("%s: invalid input parameters", __func__);
+        return -EINVAL;
+    }
+
+    /* For Android automotive, audio port config from car framework
+     * allows volume gain to be set to device at audio HAL level, where
+     * the gain can be applied in DSP mixer or CODEC amplifier.
+     *
+     * Following routing should be considered:
+     *     MIX -> DEVICE
+     *     DEVICE -> MIX
+     *     DEVICE -> DEVICE
+     *
+     * For BUS devices routed to/from mixer, gain will be applied to DSP
+     * mixer via kernel control which audio HAL stream is associated with.
+     *
+     * For external (source) device (FM TUNER/AUX), routing is typically
+     * done with AudioPatch to (sink) device (SPKR), thus gain should be
+     * applied to CODEC amplifier via codec plugin extention as audio HAL
+     * stream may not be available for external audio routing.
+     */
+    if (config->type == AUDIO_PORT_TYPE_DEVICE) {
+        ALOGI("%s: device port: type %x, address %s, gain %d mB", __func__,
+            config->ext.device.type,
+            config->ext.device.address,
+            config->gain.values[0]);
+        if (config->role == AUDIO_PORT_ROLE_SINK) {
+            /* handle output devices */
+            pthread_mutex_lock(&adev->lock);
+            list_for_each(node, &adev->active_outputs_list) {
+                streams_output_ctxt_t *out_ctxt = node_to_item(node,
+                                                    streams_output_ctxt_t,
+                                                    list);
+                /* limit audio gain support for bus device only */
+                if (out_ctxt->output->devices == AUDIO_DEVICE_OUT_BUS &&
+                    out_ctxt->output->devices == config->ext.device.type &&
+                    strcmp(out_ctxt->output->address,
+                        config->ext.device.address) == 0) {
+                    /* millibel = 1/100 dB = 1/1000 bel
+                     * q13 = (10^(mdb/100/20))*(2^13)
+                     */
+                    if(config->gain.values[0] <= (MIN_VOLUME_VALUE_MB + STEP_VALUE_MB))
+                        volume = 0.0 ;
+                    else
+                        volume = powf(10.0, ((float)config->gain.values[0] / 2000));
+                    ALOGV("%s: set volume to stream: %p", __func__,
+                        &out_ctxt->output->stream);
+                    /* set gain if output stream is active */
+                    out_ctxt->output->stream.set_volume(
+                                                &out_ctxt->output->stream,
+                                                volume, volume);
+                }
+            }
+            /* NOTE: Ideally audio patch list is a superset of output stream list above.
+             *       However, audio HAL does not maintain patches for mix -> device or
+             *       device -> mix currently. Thus doing separate lookups for device ->
+             *       device in audio patch list.
+             * FIXME: Cannot cache the gain if audio patch is not created. Expected gain
+             *        to be part of port config upon audio patch creation. If not, need
+             *        to create a list of audio port configs in adev context.
+             */
+#if 0
+            list_for_each(node, &adev->audio_patch_record_list) {
+                struct audio_patch_record *patch_record = node_to_item(node,
+                                                    struct audio_patch_record,
+                                                    list);
+                /* limit audio gain support for bus device only */
+                if (patch_record->sink.type == AUDIO_PORT_TYPE_DEVICE &&
+                    patch_record->sink.role == AUDIO_PORT_ROLE_SINK &&
+                    patch_record->sink.ext.device.type == AUDIO_DEVICE_OUT_BUS &&
+                    patch_record->sink.ext.device.type == config->ext.device.type &&
+                    strcmp(patch_record->sink.ext.device.address,
+                        config->ext.device.address) == 0) {
+                    /* cache / update gain per audio patch sink */
+                    patch_record->sink.gain = config->gain;
+
+                    struct audio_usecase *uc_info = get_usecase_from_list(adev,
+                                                        patch_record->usecase);
+                    if (!uc_info) {
+                        ALOGE("%s: failed to find the usecase %d",
+                            __func__, patch_record->usecase);
+                        ret = -EINVAL;
+                    } else {
+                        volume = config->gain->values[0];
+                        /* linear interpolation from millibel to level */
+                        int vol_level = lrint(((volume + (0 - MIN_VOLUME_VALUE_MB)) /
+                                               (MAX_VOLUME_VALUE_MB - MIN_VOLUME_VALUE_MB)) * 40);
+                        ALOGV("%s: set volume to patch: %p", __func__,
+                            patch_record->handle);
+                        ret = audio_extn_ext_hw_plugin_set_audio_gain(adev,
+                                uc_info, vol_level);
+                    }
+                }
+            }
+#endif
+            pthread_mutex_unlock(&adev->lock);
+        } else if (config->role == AUDIO_PORT_ROLE_SOURCE) {
+            // FIXME: handle input devices.
+        }
+    }
+
+    /* Only handle device port currently. */
+
+    ALOGV("%s: exit", __func__);
+    return ret;
+}
+
+void audio_extn_auto_hal_set_parameters(struct audio_device *adev __unused,
+                                        struct str_parms *parms)
+{
+    int ret = 0;
+    char value[32]={0};
+
+    ALOGV("%s: enter", __func__);
+
+    ret = str_parms_get_str(parms, "SND_CARD_STATUS", value, sizeof(value));
+    if (ret >= 0) {
+        char *snd_card_status = value+2;
+        ALOGV("%s: snd card status %s", __func__, snd_card_status);
+        if (strstr(snd_card_status, "OFFLINE")) {
+            auto_hal->card_status = CARD_STATUS_OFFLINE;
+            audio_extn_auto_hal_disable_hostless();
+        }
+        else if (strstr(snd_card_status, "ONLINE")) {
+            auto_hal->card_status = CARD_STATUS_ONLINE;
+            audio_extn_auto_hal_enable_hostless();
+        }
+    }
+
+    ALOGV("%s: exit", __func__);
+}
+
 int32_t audio_extn_auto_hal_init(struct audio_device *adev)
 {
     int32_t ret = 0;
diff --git a/hal/audio_extn/compress_in.c b/hal/audio_extn/compress_in.c
index 6cf6b81..6b525b0 100644
--- a/hal/audio_extn/compress_in.c
+++ b/hal/audio_extn/compress_in.c
@@ -100,7 +100,7 @@
  * only after validating that input against cin_attached_usecase
  * except below calls
  * 1. cin_applicable_stream(in)
- * 2. cin_configure_input_stream(in)
+ * 2. cin_configure_input_stream(in, in_config)
  */
 
 bool cin_attached_usecase(audio_usecase_t uc_id)
@@ -179,7 +179,7 @@
     return sz;
 }
 
-int cin_start_input_stream(struct stream_in *in)
+int cin_open_input_stream(struct stream_in *in)
 {
     int ret = -EINVAL;
     struct audio_device *adev = in->dev;
@@ -208,12 +208,23 @@
 
     ALOGV("%s: in %p, cin_data %p", __func__, in, cin_data);
     if (cin_data->compr) {
+        compress_stop(cin_data->compr);
+    }
+}
+
+
+void cin_close_input_stream(struct stream_in *in)
+{
+    cin_private_data_t *cin_data = (cin_private_data_t *) in->cin_extn;
+
+    ALOGV("%s: in %p, cin_data %p", __func__, in, cin_data);
+    if (cin_data->compr) {
         compress_close(cin_data->compr);
         cin_data->compr = NULL;
     }
 }
 
-void cin_close_input_stream(struct stream_in *in)
+void cin_free_input_stream_resources(struct stream_in *in)
 {
     cin_private_data_t *cin_data = (cin_private_data_t *) in->cin_extn;
 
@@ -265,9 +276,8 @@
     return ret;
 }
 
-int cin_configure_input_stream(struct stream_in *in)
+int cin_configure_input_stream(struct stream_in *in, struct audio_config *in_config)
 {
-    struct audio_device *adev = in->dev;
     struct audio_config config = {.format = 0};
     int ret = 0, buffer_size = 0, meta_size = sizeof(struct snd_codec_metadata);
     cin_private_data_t *cin_data = NULL;
@@ -304,7 +314,8 @@
     config.channel_mask = in->channel_mask;
     config.format = in->format;
     in->config.channels = audio_channel_count_from_in_mask(in->channel_mask);
-    buffer_size = adev->device.get_input_buffer_size(&adev->device, &config);
+    buffer_size = audio_extn_utils_get_input_buffer_size(config.sample_rate, config.format,
+                    in->config.channels, in_config->offload_info.duration_us / 1000, false);
 
     cin_data->compr_config.fragment_size = buffer_size;
     cin_data->compr_config.codec->id = get_snd_codec_id(in->format);
@@ -321,6 +332,11 @@
     else
         cin_data->compr_config.codec->compr_passthr = PASSTHROUGH_GEN;
 
+    if (in->flags & AUDIO_INPUT_FLAG_FAST) {
+        ALOGD("%s: Setting latency mode to true", __func__);
+        cin_data->compr_config.codec->flags |= audio_extn_utils_get_perf_mode_flag();
+    }
+
     if ((in->flags & AUDIO_INPUT_FLAG_TIMESTAMP) ||
         (in->flags & AUDIO_INPUT_FLAG_PASSTHROUGH)) {
         compress_config_set_timstamp_flag(&cin_data->compr_config);
@@ -332,6 +348,6 @@
     return ret;
 
 err_config:
-    cin_close_input_stream(in);
+    cin_free_input_stream_resources(in);
     return ret;
 }
diff --git a/hal/audio_extn/ext_hw_plugin.c b/hal/audio_extn/ext_hw_plugin.c
index 45ba1d7..6b4a718 100644
--- a/hal/audio_extn/ext_hw_plugin.c
+++ b/hal/audio_extn/ext_hw_plugin.c
@@ -265,6 +265,8 @@
     case USECASE_AUDIO_PLAYBACK_OFFLOAD8:
     case USECASE_AUDIO_PLAYBACK_OFFLOAD9:
     case USECASE_AUDIO_PLAYBACK_ULL:
+    case USECASE_AUDIO_PLAYBACK_MEDIA:
+    case USECASE_AUDIO_PLAYBACK_SYS_NOTIFICATION:
         *plugin_usecase = AUDIO_HAL_PLUGIN_USECASE_DEFAULT_PLAYBACK;
         break;
     case USECASE_AUDIO_RECORD:
@@ -281,6 +283,12 @@
     case USECASE_VOICEMMODE1_CALL:
         *plugin_usecase = AUDIO_HAL_PLUGIN_USECASE_CS_VOICE_CALL;
         break;
+    case USECASE_AUDIO_PLAYBACK_NAV_GUIDANCE:
+        *plugin_usecase = AUDIO_HAL_PLUGIN_USECASE_DRIVER_SIDE_PLAYBACK;
+        break;
+    case USECASE_AUDIO_PLAYBACK_PHONE:
+        *plugin_usecase = AUDIO_HAL_PLUGIN_USECASE_PHONE_PLAYBACK;
+        break;
     default:
         ret = -EINVAL;
     }
diff --git a/hal/audio_extn/hw_loopback.c b/hal/audio_extn/hw_loopback.c
index 76c8873..afc029b 100644
--- a/hal/audio_extn/hw_loopback.c
+++ b/hal/audio_extn/hw_loopback.c
@@ -329,8 +329,6 @@
     list_remove(&uc_info_rx->list);
     free(uc_info_rx);
 
-    adev->active_input = get_next_active_input(adev);
-
     if (inout->ip_hdlr_handle) {
         ret = audio_extn_ip_hdlr_intf_close(inout->ip_hdlr_handle, true, inout);
         if (ret < 0)
@@ -522,7 +520,6 @@
 
     memcpy(&loopback_source_stream.usecase, uc_info_rx,
            sizeof(struct audio_usecase));
-    adev->active_input = &loopback_source_stream;
     select_devices(adev, uc_info_rx->id);
     select_devices(adev, uc_info_tx->id);
 
diff --git a/hal/audio_extn/maxxaudio.c b/hal/audio_extn/maxxaudio.c
index 31feb02..a8f09fc 100644
--- a/hal/audio_extn/maxxaudio.c
+++ b/hal/audio_extn/maxxaudio.c
@@ -352,7 +352,7 @@
 
 static bool find_sup_dev(char *name)
 {
-    char *token;
+    char *token, *saveptr = NULL;
     const char s[2] = ",";
     bool ret = false;
     char sup_devs[128];
@@ -362,7 +362,7 @@
     // 2. Both string content are equal
 
     strncpy(sup_devs, SUPPORT_DEV, sizeof(sup_devs));
-    token = strtok(sup_devs, s);
+    token = strtok_r(sup_devs, s, &saveptr);
     while (token != NULL) {
         if (strncmp(token, name, strlen(token)) == 0 &&
             strlen(token) == strlen(name)) {
@@ -370,7 +370,7 @@
             ret = true;
             break;
         }
-        token = strtok(NULL, s);
+        token = strtok_r(NULL, s, &saveptr);
     }
 
     return ret;
@@ -399,6 +399,7 @@
     int ret = 0;
     int32_t fd = -1;
     char *idd;
+    char *saveptr = NULL;
 
     if (enable) {
         ret = snprintf(path, sizeof(path), "/proc/asound/card%u/usbid", card);
@@ -418,7 +419,7 @@
             goto done;
         }
         //replace '\n' to '\0'
-        idd = strtok(id, "\n");
+        idd = strtok_r(id, "\n", &saveptr);
 
         if (find_sup_dev(idd)) {
             ALOGV("%s: support usbid is %s", __func__, id);
diff --git a/hal/audio_extn/qap.c b/hal/audio_extn/qap.c
new file mode 100644
index 0000000..0625737
--- /dev/null
+++ b/hal/audio_extn/qap.c
@@ -0,0 +1,3137 @@
+/*
+ * Copyright (c) 2016-2019, 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
+ * met:
+ *     * Redistributions of source code must retain the above copyright
+ *       notice, this list of conditions and the following disclaimer.
+ *     * Redistributions in binary form must reproduce the above
+ *       copyright notice, this list of conditions and the following
+ *       disclaimer in the documentation and/or other materials provided
+ *       with the distribution.
+ *     * Neither the name of The Linux Foundation nor the names of its
+ *       contributors may be used to endorse or promote products derived
+ *       from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#define LOG_TAG "audio_hw_qap"
+#define LOG_NDEBUG 0
+#define VERY_VERY_VERBOSE_LOGGING
+#ifdef VERY_VERY_VERBOSE_LOGGING
+#define DEBUG_MSG_VV DEBUG_MSG
+#else
+#define DEBUG_MSG_VV(a...) do { } while(0)
+#endif
+
+#define DEBUG_MSG(arg,...) ALOGE("%s: %d:  " arg, __func__, __LINE__, ##__VA_ARGS__)
+#define ERROR_MSG(arg,...) ALOGE("%s: %d:  " arg, __func__, __LINE__, ##__VA_ARGS__)
+
+#define COMPRESS_OFFLOAD_NUM_FRAGMENTS 2
+#define COMPRESS_PASSTHROUGH_DDP_FRAGMENT_SIZE 4608
+
+#define QAP_DEFAULT_COMPR_AUDIO_HANDLE 1001
+#define QAP_DEFAULT_COMPR_PASSTHROUGH_HANDLE 1002
+#define QAP_DEFAULT_PASSTHROUGH_HANDLE 1003
+
+#define COMPRESS_OFFLOAD_PLAYBACK_LATENCY 300
+
+#define MIN_PCM_OFFLOAD_FRAGMENT_SIZE 512
+#define MAX_PCM_OFFLOAD_FRAGMENT_SIZE (240 * 1024)
+
+#define DIV_ROUND_UP(x, y) (((x) + (y) - 1)/(y))
+#define ALIGN(x, y) ((y) * DIV_ROUND_UP((x), (y)))
+
+/* Pcm input node buffer size is 6144 bytes, i.e, 32msec for 48000 samplerate */
+#define QAP_MODULE_PCM_INPUT_BUFFER_LATENCY 32
+
+#define MS12_PCM_OUT_FRAGMENT_SIZE 1536 //samples
+#define MS12_PCM_IN_FRAGMENT_SIZE 1536 //samples
+
+#define DD_FRAME_SIZE 1536
+#define DDP_FRAME_SIZE DD_FRAME_SIZE
+/*
+ * DD encoder output size for one frame.
+ */
+#define DD_ENCODER_OUTPUT_SIZE 2560
+/*
+ * DDP encoder output size for one frame.
+ */
+#define DDP_ENCODER_OUTPUT_SIZE 4608
+
+/*********TODO Need to get correct values.*************************/
+
+#define DTS_PCM_OUT_FRAGMENT_SIZE 1024 //samples
+
+#define DTS_FRAME_SIZE 1536
+#define DTSHD_FRAME_SIZE DTS_FRAME_SIZE
+/*
+ * DTS encoder output size for one frame.
+ */
+#define DTS_ENCODER_OUTPUT_SIZE 2560
+/*
+ * DTSHD encoder output size for one frame.
+ */
+#define DTSHD_ENCODER_OUTPUT_SIZE 4608
+/******************************************************************/
+
+/*
+ * QAP Latency to process buffers since out_write from primary HAL
+ */
+#define QAP_COMPRESS_OFFLOAD_PROCESSING_LATENCY 18
+#define QAP_PCM_OFFLOAD_PROCESSING_LATENCY 48
+
+//TODO: Need to handle for DTS
+#define QAP_DEEP_BUFFER_OUTPUT_PERIOD_SIZE 1536
+
+#include <stdlib.h>
+#include <pthread.h>
+#include <errno.h>
+#include <dlfcn.h>
+#include <unistd.h>
+#include <sys/resource.h>
+#include <sys/prctl.h>
+#include <cutils/properties.h>
+#include <cutils/str_parms.h>
+#include <cutils/log.h>
+#include <cutils/atomic.h>
+#include "audio_utils/primitives.h"
+#include "audio_hw.h"
+#include "platform_api.h"
+#include <platform.h>
+#include <system/thread_defs.h>
+#include <cutils/sched_policy.h>
+#include "audio_extn.h"
+#include <qti_audio.h>
+#include <qap_api.h>
+#include "sound/compress_params.h"
+#include "ip_hdlr_intf.h"
+#include "dolby_ms12.h"
+
+#ifdef DYNAMIC_LOG_ENABLED
+#include <log_xml_parser.h>
+#define LOG_MASK HAL_MOD_FILE_QAF
+#include <log_utils.h>
+#endif
+
+//TODO: Need to remove this.
+#define QAP_OUTPUT_SAMPLING_RATE 48000
+
+#ifdef QAP_DUMP_ENABLED
+FILE *fp_output_writer_hdmi = NULL;
+#endif
+
+//Types of MM module, currently supported by QAP.
+typedef enum {
+    MS12,
+    DTS_M8,
+    MAX_MM_MODULE_TYPE,
+    INVALID_MM_MODULE
+} mm_module_type;
+
+typedef enum {
+    QAP_OUT_TRANSCODE_PASSTHROUGH = 0, /* Transcode passthrough via MM module*/
+    QAP_OUT_OFFLOAD_MCH, /* Multi-channel PCM offload*/
+    QAP_OUT_OFFLOAD, /* PCM offload */
+
+    MAX_QAP_MODULE_OUT
+} mm_module_output_type;
+
+typedef enum {
+    QAP_IN_MAIN = 0, /* Single PID Main/Primary or Dual-PID stream */
+    QAP_IN_ASSOC,    /* Associated/Secondary stream */
+    QAP_IN_PCM,      /* PCM stream. */
+    QAP_IN_MAIN_2,   /* Single PID Main2 stream */
+    MAX_QAP_MODULE_IN
+} mm_module_input_type;
+
+typedef enum {
+    STOPPED,    /*Stream is in stop state. */
+    STOPPING,   /*Stream is stopping, waiting for EOS. */
+    RUN,        /*Stream is in run state. */
+    MAX_STATES
+} qap_stream_state;
+
+struct qap_module {
+    audio_session_handle_t session_handle;
+    void *qap_lib;
+    void *qap_handle;
+
+    /*Input stream of MM module */
+    struct stream_out *stream_in[MAX_QAP_MODULE_IN];
+    /*Output Stream from MM module */
+    struct stream_out *stream_out[MAX_QAP_MODULE_OUT];
+
+    /*Media format associated with each output id raised by mm module. */
+    qap_session_outputs_config_t session_outputs_config;
+    /*Flag is set if media format is changed for an mm module output. */
+    bool is_media_fmt_changed[MAX_QAP_MODULE_OUT];
+    /*Index to be updated in session_outputs_config array for a new mm module output. */
+    int new_out_format_index;
+
+    //BT session handle.
+    void *bt_hdl;
+
+    float vol_left;
+    float vol_right;
+    bool is_vol_set;
+    qap_stream_state stream_state[MAX_QAP_MODULE_IN];
+    bool is_session_closing;
+    bool is_session_output_active;
+    pthread_cond_t session_output_cond;
+    pthread_mutex_t session_output_lock;
+
+};
+
+struct qap {
+    struct audio_device *adev;
+
+    pthread_mutex_t lock;
+
+    bool bt_connect;
+    bool hdmi_connect;
+    int hdmi_sink_channels;
+
+    //Flag to indicate if QAP transcode output stream is enabled from any mm module.
+    bool passthrough_enabled;
+    //Flag to indicate if QAP mch pcm output stream is enabled from any mm module.
+    bool mch_pcm_hdmi_enabled;
+
+    //Flag to indicate if msmd is supported.
+    bool qap_msmd_enabled;
+
+    bool qap_output_block_handling;
+    //Handle of QAP input stream, which is routed as QAP passthrough.
+    struct stream_out *passthrough_in;
+    //Handle of QAP passthrough stream.
+    struct stream_out *passthrough_out;
+
+    struct qap_module qap_mod[MAX_MM_MODULE_TYPE];
+};
+
+//Global handle of QAP. Access to this should be protected by mutex lock.
+static struct qap *p_qap = NULL;
+
+/* Gets the pointer to qap module for the qap input stream. */
+static struct qap_module* get_qap_module_for_input_stream_l(struct stream_out *out)
+{
+    struct qap_module *qap_mod = NULL;
+    int i, j;
+    if (!p_qap) return NULL;
+
+    for (i = 0; i < MAX_MM_MODULE_TYPE; i++) {
+        for (j = 0; j < MAX_QAP_MODULE_IN; j++) {
+            if (p_qap->qap_mod[i].stream_in[j] == out) {
+                qap_mod = &(p_qap->qap_mod[i]);
+                break;
+            }
+        }
+    }
+
+    return qap_mod;
+}
+
+/* Finds the mm module input stream index for the QAP input stream. */
+static int get_input_stream_index_l(struct stream_out *out)
+{
+    int index = -1, j;
+    struct qap_module* qap_mod = NULL;
+
+    qap_mod = get_qap_module_for_input_stream_l(out);
+    if (!qap_mod) return index;
+
+    for (j = 0; j < MAX_QAP_MODULE_IN; j++) {
+        if (qap_mod->stream_in[j] == out) {
+            index = j;
+            break;
+        }
+    }
+
+    return index;
+}
+
+static void set_stream_state_l(struct stream_out *out, int state)
+{
+    struct qap_module *qap_mod = get_qap_module_for_input_stream_l(out);
+    int index = get_input_stream_index_l(out);
+    if (qap_mod && index >= 0) qap_mod->stream_state[index] = state;
+}
+
+static bool check_stream_state_l(struct stream_out *out, int state)
+{
+    struct qap_module *qap_mod = get_qap_module_for_input_stream_l(out);
+    int index = get_input_stream_index_l(out);
+    if (qap_mod && index >= 0) return ((int)qap_mod->stream_state[index] == state);
+    return false;
+}
+
+/* Finds the right mm module for the QAP input stream format. */
+static mm_module_type get_mm_module_for_format_l(audio_format_t format)
+{
+    int j;
+
+    DEBUG_MSG("Format 0x%x", format);
+
+    if (format == AUDIO_FORMAT_PCM_16_BIT) {
+        //If dts is not supported then alway support pcm with MS12
+        if (!property_get_bool("vendor.audio.qap.dts_m8", false)) { //TODO: Need to add this property for DTS.
+            return MS12;
+        }
+
+        //If QAP passthrough is active then send the PCM stream to primary HAL.
+        if (!p_qap->passthrough_out) {
+            /* Iff any stream is active in MS12 module then route PCM stream to it. */
+            for (j = 0; j < MAX_QAP_MODULE_IN; j++) {
+                if (p_qap->qap_mod[MS12].stream_in[j]) {
+                    return MS12;
+                }
+            }
+        }
+        return INVALID_MM_MODULE;
+    }
+
+    switch (format & AUDIO_FORMAT_MAIN_MASK) {
+        case AUDIO_FORMAT_AC3:
+        case AUDIO_FORMAT_E_AC3:
+        case AUDIO_FORMAT_AAC:
+        case AUDIO_FORMAT_AAC_ADTS:
+        case AUDIO_FORMAT_AC4:
+            return MS12;
+        case AUDIO_FORMAT_DTS:
+        case AUDIO_FORMAT_DTS_HD:
+            return DTS_M8;
+        default:
+            return INVALID_MM_MODULE;
+    }
+}
+
+static bool is_main_active_l(struct qap_module* qap_mod)
+{
+   return (qap_mod->stream_in[QAP_IN_MAIN] || qap_mod->stream_in[QAP_IN_MAIN_2]);
+}
+
+static bool is_dual_main_active_l(struct qap_module* qap_mod)
+{
+   return (qap_mod->stream_in[QAP_IN_MAIN] && qap_mod->stream_in[QAP_IN_MAIN_2]);
+}
+
+//Checks if any main or pcm stream is running in the session.
+static bool is_any_stream_running_l(struct qap_module* qap_mod)
+{
+    //Not checking associated stream.
+    struct stream_out *out = qap_mod->stream_in[QAP_IN_MAIN];
+    struct stream_out *out_pcm = qap_mod->stream_in[QAP_IN_PCM];
+    struct stream_out *out_main2 = qap_mod->stream_in[QAP_IN_MAIN_2];
+
+    if ((out == NULL || (out != NULL && check_stream_state_l(out, STOPPED)))
+        && (out_main2 == NULL || (out_main2 != NULL && check_stream_state_l(out_main2, STOPPED)))
+        && (out_pcm == NULL || (out_pcm != NULL && check_stream_state_l(out_pcm, STOPPED)))) {
+        return false;
+    }
+    return true;
+}
+
+/* Gets the pcm output buffer size(in samples) for the mm module. */
+static uint32_t get_pcm_output_buffer_size_samples_l(struct qap_module *qap_mod)
+{
+    uint32_t pcm_output_buffer_size = 0;
+
+    if (qap_mod == &p_qap->qap_mod[MS12]) {
+        pcm_output_buffer_size = MS12_PCM_OUT_FRAGMENT_SIZE;
+    } else if (qap_mod == &p_qap->qap_mod[DTS_M8]) {
+        pcm_output_buffer_size = DTS_PCM_OUT_FRAGMENT_SIZE;
+    }
+
+    return pcm_output_buffer_size;
+}
+
+static int get_media_fmt_array_index_for_output_id_l(
+        struct qap_module* qap_mod,
+        uint32_t output_id)
+{
+    int i;
+    for (i = 0; i < MAX_SUPPORTED_OUTPUTS; i++) {
+        if (qap_mod->session_outputs_config.output_config[i].id == output_id) {
+            return i;
+        }
+    }
+    return -1;
+}
+
+/* Acquire Mutex lock on output stream */
+static void lock_output_stream_l(struct stream_out *out)
+{
+    pthread_mutex_lock(&out->pre_lock);
+    pthread_mutex_lock(&out->lock);
+    pthread_mutex_unlock(&out->pre_lock);
+}
+
+/* Release Mutex lock on output stream */
+static void unlock_output_stream_l(struct stream_out *out)
+{
+    pthread_mutex_unlock(&out->lock);
+}
+
+/* Checks if stream can be routed as QAP passthrough or not. */
+static bool audio_extn_qap_passthrough_enabled(struct stream_out *out)
+{
+    DEBUG_MSG("Format 0x%x", out->format);
+    bool is_enabled = false;
+
+    if (!p_qap) return false;
+
+    if ((!property_get_bool("vendor.audio.qap.reencode", false))
+        && property_get_bool("vendor.audio.qap.passthrough", false)) {
+
+        if ((out->format == AUDIO_FORMAT_PCM_16_BIT) && (popcount(out->channel_mask) > 2)) {
+            is_enabled = true;
+        } else if (property_get_bool("vendor.audio.offload.passthrough", false)) {
+            switch (out->format) {
+                case AUDIO_FORMAT_AC3:
+                case AUDIO_FORMAT_E_AC3:
+                case AUDIO_FORMAT_DTS:
+                case AUDIO_FORMAT_DTS_HD:
+                case AUDIO_FORMAT_DOLBY_TRUEHD:
+                case AUDIO_FORMAT_IEC61937: {
+                    is_enabled = true;
+                    break;
+                }
+                default:
+                    is_enabled = false;
+                break;
+            }
+        }
+    }
+
+    return is_enabled;
+}
+
+/*Closes all pcm hdmi output from QAP. */
+static void close_all_pcm_hdmi_output_l()
+{
+    int i;
+    //Closing all the PCM HDMI output stream from QAP.
+    for (i = 0; i < MAX_MM_MODULE_TYPE; i++) {
+        if (p_qap->qap_mod[i].stream_out[QAP_OUT_OFFLOAD_MCH]) {
+            adev_close_output_stream((struct audio_hw_device *)p_qap->adev,
+                                     (struct audio_stream_out *)(p_qap->qap_mod[i].stream_out[QAP_OUT_OFFLOAD_MCH]));
+            p_qap->qap_mod[i].stream_out[QAP_OUT_OFFLOAD_MCH] = NULL;
+        }
+
+        if ((p_qap->qap_mod[i].stream_out[QAP_OUT_OFFLOAD])
+            && (p_qap->qap_mod[i].stream_out[QAP_OUT_OFFLOAD]->devices & AUDIO_DEVICE_OUT_AUX_DIGITAL)) {
+            adev_close_output_stream((struct audio_hw_device *)p_qap->adev,
+                                     (struct audio_stream_out *)(p_qap->qap_mod[i].stream_out[QAP_OUT_OFFLOAD]));
+            p_qap->qap_mod[i].stream_out[QAP_OUT_OFFLOAD] = NULL;
+        }
+    }
+
+    p_qap->mch_pcm_hdmi_enabled = 0;
+}
+
+static void close_all_hdmi_output_l()
+{
+    int k;
+    for (k = 0; k < MAX_MM_MODULE_TYPE; k++) {
+        if (p_qap->qap_mod[k].stream_out[QAP_OUT_TRANSCODE_PASSTHROUGH]) {
+            adev_close_output_stream((struct audio_hw_device *)p_qap->adev,
+                                     (struct audio_stream_out *)(p_qap->qap_mod[k].stream_out[QAP_OUT_TRANSCODE_PASSTHROUGH]));
+            p_qap->qap_mod[k].stream_out[QAP_OUT_TRANSCODE_PASSTHROUGH] = NULL;
+        }
+    }
+    p_qap->passthrough_enabled = 0;
+
+    close_all_pcm_hdmi_output_l();
+}
+
+static int qap_out_callback(stream_callback_event_t event, void *param __unused, void *cookie)
+{
+    struct stream_out *out = (struct stream_out *)cookie;
+
+    out->client_callback(event, NULL, out->client_cookie);
+    return 0;
+}
+
+/* Creates the QAP passthrough output stream. */
+static int create_qap_passthrough_stream_l()
+{
+    DEBUG_MSG("Entry");
+
+    int ret = 0;
+    struct stream_out *out = p_qap->passthrough_in;
+
+    if (!out) return -EINVAL;
+
+    pthread_mutex_lock(&p_qap->lock);
+    lock_output_stream_l(out);
+
+    //Creating QAP passthrough output stream.
+    if (NULL == p_qap->passthrough_out) {
+        audio_output_flags_t flags;
+        struct audio_config config;
+        audio_devices_t devices;
+
+        config.sample_rate = config.offload_info.sample_rate = out->sample_rate;
+        config.offload_info.version = AUDIO_INFO_INITIALIZER.version;
+        config.offload_info.size = AUDIO_INFO_INITIALIZER.size;
+        config.offload_info.format = out->format;
+        config.offload_info.bit_width = out->bit_width;
+        config.format = out->format;
+        config.offload_info.channel_mask = config.channel_mask = out->channel_mask;
+
+        //Device is copied from the QAP passthrough input stream.
+        devices = out->devices;
+        flags = out->flags;
+
+        ret = adev_open_output_stream((struct audio_hw_device *)p_qap->adev,
+                                      QAP_DEFAULT_PASSTHROUGH_HANDLE,
+                                      devices,
+                                      flags,
+                                      &config,
+                                      (struct audio_stream_out **)&(p_qap->passthrough_out),
+                                      NULL);
+        if (ret < 0) {
+            ERROR_MSG("adev_open_output_stream failed with ret = %d!", ret);
+            unlock_output_stream_l(out);
+            return ret;
+        }
+        p_qap->passthrough_in = out;
+        p_qap->passthrough_out->stream.set_callback((struct audio_stream_out *)p_qap->passthrough_out,
+                                                    (stream_callback_t) qap_out_callback, out);
+    }
+
+    unlock_output_stream_l(out);
+
+    //Since QAP-Passthrough is created, close other HDMI outputs.
+    close_all_hdmi_output_l();
+
+    pthread_mutex_unlock(&p_qap->lock);
+    return ret;
+}
+
+
+/* Stops a QAP module stream.*/
+static int audio_extn_qap_stream_stop(struct stream_out *out)
+{
+    int ret = 0;
+    DEBUG_MSG("Output Stream 0x%x", (int)out);
+
+    if (!check_stream_state_l(out, RUN)) return ret;
+
+    struct qap_module *qap_mod = get_qap_module_for_input_stream_l(out);
+
+    if (!qap_mod || !qap_mod->session_handle|| !out->qap_stream_handle) {
+        ERROR_MSG("Wrong state to process qap_mod(%p) sess_hadl(%p) strm hndl(%p)",
+                                qap_mod, qap_mod->session_handle, out->qap_stream_handle);
+        return -EINVAL;
+    }
+
+    ret = qap_module_cmd(out->qap_stream_handle,
+                            QAP_MODULE_CMD_STOP,
+                            sizeof(QAP_MODULE_CMD_STOP),
+                            NULL,
+                            NULL,
+                            NULL);
+    if (QAP_STATUS_OK != ret) {
+        ERROR_MSG("stop failed %d", ret);
+        return -EINVAL;
+    }
+
+    return ret;
+}
+
+static int qap_out_drain(struct audio_stream_out* stream, audio_drain_type_t type)
+{
+    struct stream_out *out = (struct stream_out *)stream;
+    int status = 0;
+    struct qap_module *qap_mod = NULL;
+
+    qap_mod = get_qap_module_for_input_stream_l(out);
+    DEBUG_MSG("Output Stream %p", out);
+
+    lock_output_stream_l(out);
+
+    //If QAP passthrough is enabled then block the drain on module stream.
+    if (p_qap->passthrough_out) {
+        pthread_mutex_lock(&p_qap->lock);
+        //If drain is received for QAP passthorugh stream then call the primary HAL api.
+        if (p_qap->passthrough_in == out) {
+            status = p_qap->passthrough_out->stream.drain(
+                    (struct audio_stream_out *)p_qap->passthrough_out, type);
+        }
+        pthread_mutex_unlock(&p_qap->lock);
+    } else if (!is_any_stream_running_l(qap_mod)) {
+        //If stream is already stopped then send the drain ready.
+        out->client_callback(STREAM_CBK_EVENT_DRAIN_READY, NULL, out->client_cookie);
+        set_stream_state_l(out, STOPPED);
+    } else {
+        qap_audio_buffer_t *buffer;
+        buffer = (qap_audio_buffer_t *) calloc(1, sizeof(qap_audio_buffer_t));
+        buffer->common_params.offset = 0;
+        buffer->common_params.data = buffer;
+        buffer->common_params.size = 0;
+        buffer->buffer_parms.input_buf_params.flags = QAP_BUFFER_EOS;
+        DEBUG_MSG("Queing EOS buffer %p flags %d size %d", buffer, buffer->buffer_parms.input_buf_params.flags, buffer->common_params.size);
+        status = qap_module_process(out->qap_stream_handle, buffer);
+        if (QAP_STATUS_OK != status) {
+            ERROR_MSG("EOS buffer queing failed%d", status);
+            return -EINVAL;
+        }
+
+        //Drain the module input stream.
+        /* Stream stop will trigger EOS and on EOS_EVENT received
+         from callback DRAIN_READY command is sent */
+        status = audio_extn_qap_stream_stop(out);
+
+        if (status == 0) {
+            //Setting state to stopping as client is expecting drain_ready event.
+            set_stream_state_l(out, STOPPING);
+        }
+    }
+
+    unlock_output_stream_l(out);
+    return status;
+}
+
+
+/* Flush the QAP module input stream. */
+static int audio_extn_qap_stream_flush(struct stream_out *out)
+{
+    DEBUG_MSG("Output Stream %p", out);
+    int ret = -EINVAL;
+    struct qap_module *qap_mod = NULL;
+
+    qap_mod = get_qap_module_for_input_stream_l(out);
+    if (!qap_mod || !qap_mod->session_handle|| !out->qap_stream_handle) {
+        ERROR_MSG("Wrong state to process qap_mod(%p) sess_hadl(%p) strm hndl(%p)",
+                                qap_mod, qap_mod->session_handle, out->qap_stream_handle);
+        return -EINVAL;
+    }
+
+    ret = qap_module_cmd(out->qap_stream_handle,
+                            QAP_MODULE_CMD_FLUSH,
+                            sizeof(QAP_MODULE_CMD_FLUSH),
+                            NULL,
+                            NULL,
+                            NULL);
+    if (QAP_STATUS_OK != ret) {
+        ERROR_MSG("flush failed %d", ret);
+        return -EINVAL;
+    }
+
+    return ret;
+}
+
+
+/* Pause the QAP module input stream. */
+static int qap_stream_pause_l(struct stream_out *out)
+{
+    struct qap_module *qap_mod = NULL;
+    int ret = -EINVAL;
+
+    qap_mod = get_qap_module_for_input_stream_l(out);
+    if (!qap_mod || !qap_mod->session_handle|| !out->qap_stream_handle) {
+        ERROR_MSG("Wrong state to process qap_mod(%p) sess_hadl(%p) strm hndl(%p)",
+            qap_mod, qap_mod->session_handle, out->qap_stream_handle);
+        return -EINVAL;
+    }
+
+    ret = qap_module_cmd(out->qap_stream_handle,
+                            QAP_MODULE_CMD_PAUSE,
+                            sizeof(QAP_MODULE_CMD_PAUSE),
+                            NULL,
+                            NULL,
+                            NULL);
+    if (QAP_STATUS_OK != ret) {
+        ERROR_MSG("pause failed %d", ret);
+        return -EINVAL;
+    }
+
+    return ret;
+}
+
+
+/* Flush the QAP input stream. */
+static int qap_out_flush(struct audio_stream_out* stream)
+{
+    struct stream_out *out = (struct stream_out *)stream;
+    int status = 0;
+
+    DEBUG_MSG("Output Stream %p", out);
+    lock_output_stream_l(out);
+
+    if (!out->standby) {
+        //If QAP passthrough is active then block the flush on module input streams.
+        if (p_qap->passthrough_out) {
+            pthread_mutex_lock(&p_qap->lock);
+            //If flush is received for the QAP passthrough stream then call the primary HAL api.
+            if (p_qap->passthrough_in == out) {
+                status = p_qap->passthrough_out->stream.flush(
+                        (struct audio_stream_out *)p_qap->passthrough_out);
+                out->offload_state = OFFLOAD_STATE_IDLE;
+            }
+            pthread_mutex_unlock(&p_qap->lock);
+        } else {
+            //Flush the module input stream.
+            status = audio_extn_qap_stream_flush(out);
+        }
+    }
+    unlock_output_stream_l(out);
+    DEBUG_MSG("Exit");
+    return status;
+}
+
+
+/* Pause a QAP input stream. */
+static int qap_out_pause(struct audio_stream_out* stream)
+{
+    struct stream_out *out = (struct stream_out *)stream;
+    int status = 0;
+    DEBUG_MSG("Output Stream %p", out);
+
+    lock_output_stream_l(out);
+
+    //If QAP passthrough is enabled then block the pause on module stream.
+    if (p_qap->passthrough_out) {
+        pthread_mutex_lock(&p_qap->lock);
+        //If pause is received for QAP passthorugh stream then call the primary HAL api.
+        if (p_qap->passthrough_in == out) {
+            status = p_qap->passthrough_out->stream.pause(
+                    (struct audio_stream_out *)p_qap->passthrough_out);
+            out->offload_state = OFFLOAD_STATE_PAUSED;
+        }
+        pthread_mutex_unlock(&p_qap->lock);
+    } else {
+        //Pause the module input stream.
+        status = qap_stream_pause_l(out);
+    }
+
+    unlock_output_stream_l(out);
+    return status;
+}
+
+static void close_qap_passthrough_stream_l()
+{
+    if (p_qap->passthrough_out != NULL) { //QAP pasthroug is enabled. Close it.
+        pthread_mutex_lock(&p_qap->lock);
+        adev_close_output_stream((struct audio_hw_device *)p_qap->adev,
+                                 (struct audio_stream_out *)(p_qap->passthrough_out));
+        p_qap->passthrough_out = NULL;
+        pthread_mutex_unlock(&p_qap->lock);
+
+        if (p_qap->passthrough_in->qap_stream_handle) {
+            qap_out_pause((struct audio_stream_out*)p_qap->passthrough_in);
+            qap_out_flush((struct audio_stream_out*)p_qap->passthrough_in);
+            qap_out_drain((struct audio_stream_out*)p_qap->passthrough_in,
+                          (audio_drain_type_t)STREAM_CBK_EVENT_DRAIN_READY);
+        }
+    }
+}
+
+static int qap_out_standby(struct audio_stream *stream)
+{
+    struct stream_out *out = (struct stream_out *)stream;
+    struct qap_module *qap_mod = NULL;
+    int status = 0;
+    int i;
+
+    ALOGD("%s: enter: stream (%p) usecase(%d: %s)", __func__,
+          stream, out->usecase, use_case_table[out->usecase]);
+
+    lock_output_stream_l(out);
+
+    //If QAP passthrough is active then block standby on all the input streams of QAP mm modules.
+    if (p_qap->passthrough_out) {
+        //If standby is received on QAP passthrough stream then forward it to primary HAL.
+        if (p_qap->passthrough_in == out) {
+            status = p_qap->passthrough_out->stream.common.standby(
+                    (struct audio_stream *)p_qap->passthrough_out);
+        }
+    } else if (check_stream_state_l(out, RUN)) {
+        //If QAP passthrough stream is not active then stop the QAP module stream.
+        status = audio_extn_qap_stream_stop(out);
+
+        if (status == 0) {
+            //Setting state to stopped as client not expecting drain_ready event.
+            set_stream_state_l(out, STOPPED);
+        }
+        if(p_qap->qap_output_block_handling) {
+            qap_mod = get_qap_module_for_input_stream_l(out);
+            for (i = 0; i < MAX_QAP_MODULE_IN; i++) {
+                if (qap_mod->stream_in[i] != NULL &&
+                    check_stream_state_l(qap_mod->stream_in[i], RUN)) {
+                    break;
+                }
+            }
+
+            if (i != MAX_QAP_MODULE_IN) {
+                DEBUG_MSG("[%s] stream is still active.", use_case_table[qap_mod->stream_in[i]->usecase]);
+            } else {
+                pthread_mutex_lock(&qap_mod->session_output_lock);
+                qap_mod->is_session_output_active = false;
+                pthread_mutex_unlock(&qap_mod->session_output_lock);
+                DEBUG_MSG(" all the input streams are either closed or stopped(standby) block the MM module output");
+            }
+        }
+    }
+
+    if (!out->standby) {
+        out->standby = true;
+    }
+
+    unlock_output_stream_l(out);
+    return status;
+}
+
+/* Sets the volume to PCM output stream. */
+static int qap_out_set_volume(struct audio_stream_out *stream, float left, float right)
+{
+    int ret = 0;
+    struct stream_out *out = (struct stream_out *)stream;
+    struct qap_module *qap_mod = NULL;
+
+    DEBUG_MSG("Left %f, Right %f", left, right);
+
+    qap_mod = get_qap_module_for_input_stream_l(out);
+    if (!qap_mod) {
+        return -EINVAL;
+    }
+
+    pthread_mutex_lock(&p_qap->lock);
+    qap_mod->vol_left = left;
+    qap_mod->vol_right = right;
+    qap_mod->is_vol_set = true;
+    pthread_mutex_unlock(&p_qap->lock);
+
+    if (qap_mod->stream_out[QAP_OUT_OFFLOAD] != NULL) {
+        ret = qap_mod->stream_out[QAP_OUT_OFFLOAD]->stream.set_volume(
+                (struct audio_stream_out *)qap_mod->stream_out[QAP_OUT_OFFLOAD], left, right);
+    }
+
+    return ret;
+}
+
+/* Starts a QAP module stream. */
+static int qap_stream_start_l(struct stream_out *out)
+{
+    int ret = 0;
+    struct qap_module *qap_mod = NULL;
+
+    DEBUG_MSG("Output Stream = %p", out);
+
+    qap_mod = get_qap_module_for_input_stream_l(out);
+    if ((!qap_mod) || (!qap_mod->session_handle)) {
+        ERROR_MSG("QAP mod is not inited (%p) or session is not yet opened (%p) ",
+            qap_mod, qap_mod->session_handle);
+        return -EINVAL;
+    }
+    if (out->qap_stream_handle) {
+        ret = qap_module_cmd(out->qap_stream_handle,
+                             QAP_MODULE_CMD_START,
+                             sizeof(QAP_MODULE_CMD_START),
+                             NULL,
+                             NULL,
+                             NULL);
+        if (ret != QAP_STATUS_OK) {
+            ERROR_MSG("start failed");
+            ret = -EINVAL;
+        }
+    } else
+        ERROR_MSG("QAP stream not yet opened, drop this cmd");
+
+    DEBUG_MSG("exit");
+    return ret;
+
+}
+
+static int qap_start_output_stream(struct stream_out *out)
+{
+    int ret = 0;
+    struct audio_device *adev = out->dev;
+
+    if ((out->usecase < 0) || (out->usecase >= AUDIO_USECASE_MAX)) {
+        ret = -EINVAL;
+        DEBUG_MSG("Use case out of bounds sleeping for 500ms");
+        usleep(50000);
+        return ret;
+    }
+
+    ALOGD("%s: enter: stream(%p)usecase(%d: %s) devices(%#x)",
+          __func__, &out->stream, out->usecase, use_case_table[out->usecase],
+          out->devices);
+
+    if (CARD_STATUS_OFFLINE == out->card_status ||
+        CARD_STATUS_OFFLINE == adev->card_status) {
+        ALOGE("%s: sound card is not active/SSR returning error", __func__);
+        ret = -EIO;
+        usleep(50000);
+        return ret;
+    }
+
+    return qap_stream_start_l(out);
+}
+
+/* Sends input buffer to the QAP MM module. */
+static int qap_module_write_input_buffer(struct stream_out *out, const void *buffer, int bytes)
+{
+    int ret = -EINVAL;
+    struct qap_module *qap_mod = NULL;
+    qap_audio_buffer_t buff;
+
+    qap_mod = get_qap_module_for_input_stream_l(out);
+    if ((!qap_mod) || (!qap_mod->session_handle) || (!out->qap_stream_handle)) {
+        return ret;
+    }
+
+    //If data received on associated stream when all other stream are stopped then drop the data.
+    if (out == qap_mod->stream_in[QAP_IN_ASSOC] && !is_any_stream_running_l(qap_mod))
+        return bytes;
+
+    memset(&buff, 0, sizeof(buff));
+    buff.common_params.offset = 0;
+    buff.common_params.size = bytes;
+    buff.common_params.data = (void *) buffer;
+    buff.common_params.timestamp = QAP_BUFFER_NO_TSTAMP;
+    buff.buffer_parms.input_buf_params.flags = QAP_BUFFER_NO_TSTAMP;
+    DEBUG_MSG("calling module process with bytes %d %p", bytes, buffer);
+    ret  = qap_module_process(out->qap_stream_handle, &buff);
+
+    if(ret > 0) set_stream_state_l(out, RUN);
+
+    return ret;
+}
+
+static ssize_t qap_out_write(struct audio_stream_out *stream, const void *buffer, size_t bytes)
+{
+    struct stream_out *out = (struct stream_out *)stream;
+    struct audio_device *adev = out->dev;
+    ssize_t ret = 0;
+    struct qap_module *qap_mod = NULL;
+
+    DEBUG_MSG_VV("bytes = %d, usecase[%s] and flags[%x] for handle[%p]",
+          (int)bytes, use_case_table[out->usecase], out->flags, out);
+
+    lock_output_stream_l(out);
+
+    // If QAP passthrough is active then block writing data to QAP mm module.
+    if (p_qap->passthrough_out) {
+        //If write is received for the QAP passthrough stream then send the buffer to primary HAL.
+        if (p_qap->passthrough_in == out) {
+            ret = p_qap->passthrough_out->stream.write(
+                    (struct audio_stream_out *)(p_qap->passthrough_out),
+                    buffer,
+                    bytes);
+            if (ret > 0) out->standby = false;
+        }
+        unlock_output_stream_l(out);
+        return ret;
+    } else if (out->standby) {
+        pthread_mutex_lock(&adev->lock);
+        ret = qap_start_output_stream(out);
+        pthread_mutex_unlock(&adev->lock);
+        if (ret == 0) {
+            out->standby = false;
+            if(p_qap->qap_output_block_handling) {
+                qap_mod = get_qap_module_for_input_stream_l(out);
+
+                pthread_mutex_lock(&qap_mod->session_output_lock);
+                if (qap_mod->is_session_output_active == false) {
+                    qap_mod->is_session_output_active = true;
+                    pthread_cond_signal(&qap_mod->session_output_cond);
+                    DEBUG_MSG("Wake up MM module output thread");
+                }
+                pthread_mutex_unlock(&qap_mod->session_output_lock);
+            }
+        } else {
+            goto exit;
+        }
+    }
+
+    if ((adev->is_channel_status_set == false) && (out->devices & AUDIO_DEVICE_OUT_AUX_DIGITAL)) {
+        audio_utils_set_hdmi_channel_status(out, (char *)buffer, bytes);
+        adev->is_channel_status_set = true;
+    }
+
+    ret = qap_module_write_input_buffer(out, buffer, bytes);
+    DEBUG_MSG_VV("Bytes consumed [%d] by MM Module", (int)ret);
+
+    if (ret >= 0) {
+        out->written += ret / ((popcount(out->channel_mask) * sizeof(short)));
+    }
+
+
+exit:
+    unlock_output_stream_l(out);
+
+    if (ret < 0) {
+        if (ret == -EAGAIN) {
+            DEBUG_MSG_VV("No space available to consume bytes, post msg to cb thread");
+            bytes = 0;
+        } else if (ret == -ENOMEM || ret == -EPERM) {
+            if (out->pcm)
+                ERROR_MSG("error %d, %s", (int)ret, pcm_get_error(out->pcm));
+            qap_out_standby(&out->stream.common);
+            DEBUG_MSG("SLEEP for 100sec");
+            usleep(bytes * 1000000
+                   / audio_stream_out_frame_size(stream)
+                   / out->stream.common.get_sample_rate(&out->stream.common));
+        }
+    } else if (ret < (ssize_t)bytes) {
+        //partial buffer copied to the module.
+        DEBUG_MSG_VV("Not enough space available to consume all the bytes");
+        bytes = ret;
+    }
+    return bytes;
+}
+
+/* Gets PCM offload buffer size for a given config. */
+static uint32_t qap_get_pcm_offload_buffer_size(audio_offload_info_t* info,
+                                                uint32_t samples_per_frame)
+{
+    uint32_t fragment_size = 0;
+
+    fragment_size = (samples_per_frame * (info->bit_width >> 3) * popcount(info->channel_mask));
+
+    if (fragment_size < MIN_PCM_OFFLOAD_FRAGMENT_SIZE)
+        fragment_size = MIN_PCM_OFFLOAD_FRAGMENT_SIZE;
+    else if (fragment_size > MAX_PCM_OFFLOAD_FRAGMENT_SIZE)
+        fragment_size = MAX_PCM_OFFLOAD_FRAGMENT_SIZE;
+
+    // To have same PCM samples for all channels, the buffer size requires to
+    // be multiple of (number of channels * bytes per sample)
+    // For writes to succeed, the buffer must be written at address which is multiple of 32
+    fragment_size = ALIGN(fragment_size,
+                          ((info->bit_width >> 3) * popcount(info->channel_mask) * 32));
+
+    ALOGI("Qap PCM offload Fragment size is %d bytes", fragment_size);
+
+    return fragment_size;
+}
+
+static uint32_t qap_get_pcm_offload_input_buffer_size(audio_offload_info_t* info)
+{
+    return qap_get_pcm_offload_buffer_size(info, MS12_PCM_IN_FRAGMENT_SIZE);
+}
+
+static uint32_t qap_get_pcm_offload_output_buffer_size(struct qap_module *qap_mod,
+                                                audio_offload_info_t* info)
+{
+    return qap_get_pcm_offload_buffer_size(info, get_pcm_output_buffer_size_samples_l(qap_mod));
+}
+
+/* Gets buffer latency in samples. */
+static int get_buffer_latency(struct stream_out *out, uint32_t buffer_size, uint32_t *latency)
+{
+    unsigned long int samples_in_one_encoded_frame;
+    unsigned long int size_of_one_encoded_frame;
+
+    switch (out->format) {
+        case AUDIO_FORMAT_AC3:
+            samples_in_one_encoded_frame = DD_FRAME_SIZE;
+            size_of_one_encoded_frame = DD_ENCODER_OUTPUT_SIZE;
+        break;
+        case AUDIO_FORMAT_E_AC3:
+            samples_in_one_encoded_frame = DDP_FRAME_SIZE;
+            size_of_one_encoded_frame = DDP_ENCODER_OUTPUT_SIZE;
+        break;
+        case AUDIO_FORMAT_DTS:
+            samples_in_one_encoded_frame = DTS_FRAME_SIZE;
+            size_of_one_encoded_frame = DTS_ENCODER_OUTPUT_SIZE;
+        break;
+        case AUDIO_FORMAT_DTS_HD:
+            samples_in_one_encoded_frame = DTSHD_FRAME_SIZE;
+            size_of_one_encoded_frame = DTSHD_ENCODER_OUTPUT_SIZE;
+        break;
+        case AUDIO_FORMAT_PCM_16_BIT:
+            samples_in_one_encoded_frame = 1;
+            size_of_one_encoded_frame = ((out->bit_width) >> 3) * popcount(out->channel_mask);
+        break;
+        default:
+            *latency = 0;
+            return (-EINVAL);
+    }
+
+    *latency = ((buffer_size * samples_in_one_encoded_frame) / size_of_one_encoded_frame);
+    return 0;
+}
+
+/* Returns the number of frames rendered to outside observer. */
+static int qap_get_rendered_frames(struct stream_out *out, uint64_t *frames)
+{
+    int ret = 0, i;
+    struct str_parms *parms;
+//    int value = 0;
+    int module_latency = 0;
+    uint32_t kernel_latency = 0;
+    uint32_t dsp_latency = 0;
+    int signed_frames = 0;
+    char* kvpairs = NULL;
+    struct qap_module *qap_mod = NULL;
+
+    DEBUG_MSG("Output Format %d", out->format);
+
+    qap_mod = get_qap_module_for_input_stream_l(out);
+    if (!qap_mod || !qap_mod->session_handle|| !out->qap_stream_handle) {
+        ERROR_MSG("Wrong state to process qap_mod(%p) sess_hadl(%p) strm hndl(%p)",
+            qap_mod, qap_mod->session_handle, out->qap_stream_handle);
+        return -EINVAL;
+    }
+
+    //Get MM module latency.
+/* Tobeported
+    kvpairs = qap_mod->qap_audio_stream_get_param(out->qap_stream_handle, "get_latency");
+*/
+    if (kvpairs) {
+        parms = str_parms_create_str(kvpairs);
+        ret = str_parms_get_int(parms, "get_latency", &module_latency);
+        if (ret >= 0) {
+            str_parms_destroy(parms);
+            parms = NULL;
+        }
+        free(kvpairs);
+        kvpairs = NULL;
+    }
+
+    //Get kernel Latency
+    for (i = MAX_QAP_MODULE_OUT - 1; i >= 0; i--) {
+        if (qap_mod->stream_out[i] == NULL) {
+            continue;
+        } else {
+            unsigned int num_fragments = qap_mod->stream_out[i]->compr_config.fragments;
+            uint32_t fragment_size = qap_mod->stream_out[i]->compr_config.fragment_size;
+            uint32_t kernel_buffer_size = num_fragments * fragment_size;
+            get_buffer_latency(qap_mod->stream_out[i], kernel_buffer_size, &kernel_latency);
+            break;
+        }
+    }
+
+    //Get DSP latency
+    if ((qap_mod->stream_out[QAP_OUT_OFFLOAD] != NULL)
+        || (qap_mod->stream_out[QAP_OUT_OFFLOAD_MCH] != NULL)) {
+        unsigned int sample_rate = 0;
+        audio_usecase_t platform_latency = 0;
+
+        if (qap_mod->stream_out[QAP_OUT_OFFLOAD])
+            sample_rate = qap_mod->stream_out[QAP_OUT_OFFLOAD]->sample_rate;
+        else if (qap_mod->stream_out[QAP_OUT_OFFLOAD_MCH])
+            sample_rate = qap_mod->stream_out[QAP_OUT_OFFLOAD_MCH]->sample_rate;
+
+        if (qap_mod->stream_out[QAP_OUT_OFFLOAD])
+            platform_latency =
+                platform_render_latency(qap_mod->stream_out[QAP_OUT_OFFLOAD]->usecase);
+        else
+            platform_latency =
+                platform_render_latency(qap_mod->stream_out[QAP_OUT_OFFLOAD_MCH]->usecase);
+
+        dsp_latency = (platform_latency * sample_rate) / 1000000LL;
+    } else if (qap_mod->stream_out[QAP_OUT_TRANSCODE_PASSTHROUGH] != NULL) {
+        unsigned int sample_rate = 0;
+
+        sample_rate = qap_mod->stream_out[QAP_OUT_TRANSCODE_PASSTHROUGH]->sample_rate; //TODO: How this sample rate can be used?
+        dsp_latency = (COMPRESS_OFFLOAD_PLAYBACK_LATENCY * sample_rate) / 1000;
+    }
+
+    // MM Module Latency + Kernel Latency + DSP Latency
+    if ( audio_extn_bt_hal_get_output_stream(qap_mod->bt_hdl) != NULL) {
+        out->platform_latency = module_latency + audio_extn_bt_hal_get_latency(qap_mod->bt_hdl);
+    } else {
+        out->platform_latency = (uint32_t)module_latency + kernel_latency + dsp_latency;
+    }
+
+    if (out->format & AUDIO_FORMAT_PCM_16_BIT) {
+        *frames = 0;
+        signed_frames = out->written - out->platform_latency;
+        // It would be unusual for this value to be negative, but check just in case ...
+        if (signed_frames >= 0) {
+            *frames = signed_frames;
+        }
+/* Tobeported
+        }
+        else {
+
+        kvpairs = qap_mod->qap_audio_stream_get_param(out->qap_stream_handle, "position");
+    if (kvpairs) {
+        parms = str_parms_create_str(kvpairs);
+        ret = str_parms_get_int(parms, "position", &value);
+        if (ret >= 0) {
+            *frames = value;
+            signed_frames = value - out->platform_latency;
+            // It would be unusual for this value to be negative, but check just in case ...
+            if (signed_frames >= 0) {
+                *frames = signed_frames;
+            }
+        }
+        str_parms_destroy(parms);
+    }
+*/
+    } else {
+        ret = -EINVAL;
+    }
+
+    return ret;
+}
+
+static int qap_out_get_render_position(const struct audio_stream_out *stream,
+                                   uint32_t *dsp_frames)
+{
+    struct stream_out *out = (struct stream_out *)stream;
+    int ret = 0;
+    uint64_t frames=0;
+    struct qap_module* qap_mod = NULL;
+    ALOGV("%s, Output Stream %p,dsp frames %d",__func__, stream, (int)dsp_frames);
+
+    qap_mod = get_qap_module_for_input_stream_l(out);
+    if (!qap_mod) {
+        ret = out->stream.get_render_position(stream, dsp_frames);
+        ALOGV("%s, non qap_MOD DSP FRAMES %d",__func__, (int)dsp_frames);
+        return ret;
+    }
+
+    if (p_qap->passthrough_out) {
+        pthread_mutex_lock(&p_qap->lock);
+        ret = p_qap->passthrough_out->stream.get_render_position((struct audio_stream_out *)p_qap->passthrough_out, dsp_frames);
+        pthread_mutex_unlock(&p_qap->lock);
+        ALOGV("%s, PASS THROUGH DSP FRAMES %p",__func__, dsp_frames);
+        return ret;
+        }
+    frames=*dsp_frames;
+    ret = qap_get_rendered_frames(out, &frames);
+    *dsp_frames = (uint32_t)frames;
+    ALOGV("%s, DSP FRAMES %d",__func__, (int)dsp_frames);
+    return ret;
+}
+
+static int qap_out_get_presentation_position(const struct audio_stream_out *stream,
+                                             uint64_t *frames,
+                                             struct timespec *timestamp)
+{
+    struct stream_out *out = (struct stream_out *)stream;
+    int ret = 0;
+
+//    DEBUG_MSG_VV("Output Stream %p", stream);
+
+    //If QAP passthorugh output stream is active.
+    if (p_qap->passthrough_out) {
+        if (p_qap->passthrough_in == out) {
+            //If api is called for QAP passthorugh stream then call the primary HAL api to get the position.
+            pthread_mutex_lock(&p_qap->lock);
+            ret = p_qap->passthrough_out->stream.get_presentation_position(
+                    (struct audio_stream_out *)p_qap->passthrough_out,
+                    frames,
+                    timestamp);
+            pthread_mutex_unlock(&p_qap->lock);
+        } else {
+            //If api is called for other stream then return zero frames.
+            *frames = 0;
+            clock_gettime(CLOCK_MONOTONIC, timestamp);
+        }
+        return ret;
+    }
+
+    ret = qap_get_rendered_frames(out, frames);
+    clock_gettime(CLOCK_MONOTONIC, timestamp);
+
+    return ret;
+}
+
+static uint32_t qap_out_get_latency(const struct audio_stream_out *stream)
+{
+    struct stream_out *out = (struct stream_out *)stream;
+    uint32_t latency = 0;
+    struct qap_module *qap_mod = NULL;
+    DEBUG_MSG_VV("Output Stream %p", out);
+
+    qap_mod = get_qap_module_for_input_stream_l(out);
+    if (!qap_mod) {
+        return 0;
+    }
+
+    //If QAP passthrough is active then block the get latency on module input streams.
+    if (p_qap->passthrough_out) {
+        pthread_mutex_lock(&p_qap->lock);
+        //If get latency is called for the QAP passthrough stream then call the primary HAL api.
+        if (p_qap->passthrough_in == out) {
+            latency = p_qap->passthrough_out->stream.get_latency(
+                    (struct audio_stream_out *)p_qap->passthrough_out);
+        }
+        pthread_mutex_unlock(&p_qap->lock);
+    } else {
+        if (is_offload_usecase(out->usecase)) {
+            latency = COMPRESS_OFFLOAD_PLAYBACK_LATENCY;
+        } else {
+            uint32_t sample_rate = 0;
+            latency = QAP_MODULE_PCM_INPUT_BUFFER_LATENCY; //Input latency
+
+            if (qap_mod->stream_out[QAP_OUT_OFFLOAD])
+                sample_rate = qap_mod->stream_out[QAP_OUT_OFFLOAD]->sample_rate;
+            else if (qap_mod->stream_out[QAP_OUT_OFFLOAD_MCH])
+                sample_rate = qap_mod->stream_out[QAP_OUT_OFFLOAD_MCH]->sample_rate;
+
+            if (sample_rate) {
+                latency += (get_pcm_output_buffer_size_samples_l(qap_mod) * 1000) / out->sample_rate;
+            }
+        }
+
+        if ( audio_extn_bt_hal_get_output_stream(qap_mod->bt_hdl) != NULL) {
+            if (is_offload_usecase(out->usecase)) {
+                latency = audio_extn_bt_hal_get_latency(qap_mod->bt_hdl) +
+                QAP_COMPRESS_OFFLOAD_PROCESSING_LATENCY;
+            } else {
+                latency = audio_extn_bt_hal_get_latency(qap_mod->bt_hdl) +
+                QAP_PCM_OFFLOAD_PROCESSING_LATENCY;
+            }
+        }
+    }
+
+    DEBUG_MSG_VV("Latency %d", latency);
+    return latency;
+}
+
+static bool qap_check_and_get_compressed_device_format(int device, int *format)
+{
+    switch (device) {
+        case (AUDIO_DEVICE_OUT_AUX_DIGITAL | QAP_AUDIO_FORMAT_AC3):
+            *format = AUDIO_FORMAT_AC3;
+            return true;
+        case (AUDIO_DEVICE_OUT_AUX_DIGITAL | QAP_AUDIO_FORMAT_EAC3):
+            *format = AUDIO_FORMAT_E_AC3;
+            return true;
+        case (AUDIO_DEVICE_OUT_AUX_DIGITAL | QAP_AUDIO_FORMAT_DTS):
+            *format = AUDIO_FORMAT_DTS;
+            return true;
+        default:
+            return false;
+    }
+}
+
+static void set_out_stream_channel_map(struct stream_out *out, qap_output_config_t * media_fmt)
+{
+    if (media_fmt == NULL || out == NULL) {
+        return;
+    }
+    struct audio_out_channel_map_param chmap = {0,{0}};
+    int i = 0;
+    chmap.channels = media_fmt->channels;
+    for (i = 0; i < chmap.channels && i < AUDIO_CHANNEL_COUNT_MAX && i < AUDIO_QAF_MAX_CHANNELS;
+            i++) {
+        chmap.channel_map[i] = media_fmt->ch_map[i];
+    }
+    audio_extn_utils_set_channel_map(out, &chmap);
+}
+
+bool audio_extn_is_qap_enabled()
+{
+    bool prop_enabled = false;
+    char value[PROPERTY_VALUE_MAX] = {0};
+    property_get("vendor.audio.qap.enabled", value, NULL);
+    prop_enabled = atoi(value) || !strncmp("true", value, 4);
+    DEBUG_MSG("%d", prop_enabled);
+    return (prop_enabled);
+}
+
+void static qap_close_all_output_streams(struct qap_module *qap_mod)
+{
+    int i =0;
+    struct stream_out *stream_out = NULL;
+    DEBUG_MSG("Entry");
+
+    for (i = 0; i < MAX_QAP_MODULE_OUT; i++) {
+        stream_out = qap_mod->stream_out[i];
+        if (stream_out != NULL) {
+            adev_close_output_stream((struct audio_hw_device *)p_qap->adev, (struct audio_stream_out *)stream_out);
+            DEBUG_MSG("Closed outputenum=%d session 0x%x %s",
+                    i, (int)stream_out, use_case_table[stream_out->usecase]);
+            qap_mod->stream_out[i] = NULL;
+        }
+        memset(&qap_mod->session_outputs_config.output_config[i], 0, sizeof(qap_session_outputs_config_t));
+        qap_mod->is_media_fmt_changed[i] = false;
+    }
+    DEBUG_MSG("exit");
+}
+
+/* Call back function for mm module. */
+static void qap_session_callback(qap_session_handle_t session_handle __unused,
+                                  void *prv_data,
+                                 qap_callback_event_t event_id,
+                                  int size,
+                                  void *data)
+{
+
+    /*
+     For SPKR:
+     1. Open pcm device if device_id passed to it SPKR and write the data to
+     pcm device
+
+     For HDMI
+     1.Open compress device for HDMI(PCM or AC3) based on current hdmi o/p format and write
+     data to the HDMI device.
+     */
+    int ret;
+    audio_output_flags_t flags;
+    struct qap_module* qap_mod = (struct qap_module*)prv_data;
+    struct audio_stream_out *bt_stream = NULL;
+    int format;
+    int8_t *data_buffer_p = NULL;
+    uint32_t buffer_size = 0;
+    bool need_to_recreate_stream = false;
+    struct audio_config config;
+    qap_output_config_t *new_conf = NULL;
+    qap_audio_buffer_t *buffer = (qap_audio_buffer_t *) data;
+    uint32_t device = 0;
+
+    if (qap_mod->is_session_closing) {
+        DEBUG_MSG("Dropping event as session is closing."
+                "Event = 0x%X, Bytes to write %d", event_id, size);
+        return;
+    }
+
+    if(p_qap->qap_output_block_handling) {
+        pthread_mutex_lock(&qap_mod->session_output_lock);
+        if (!qap_mod->is_session_output_active) {
+            qap_close_all_output_streams(qap_mod);
+            DEBUG_MSG("disabling MM module output by blocking the output thread");
+            pthread_cond_wait(&qap_mod->session_output_cond, &qap_mod->session_output_lock);
+            DEBUG_MSG("MM module output Enabled, output thread active");
+        }
+        pthread_mutex_unlock(&qap_mod->session_output_lock);
+    }
+
+    /* Default config initialization. */
+    config.sample_rate = config.offload_info.sample_rate = QAP_OUTPUT_SAMPLING_RATE;
+    config.offload_info.version = AUDIO_INFO_INITIALIZER.version;
+    config.offload_info.size = AUDIO_INFO_INITIALIZER.size;
+    config.format = config.offload_info.format = AUDIO_FORMAT_PCM_16_BIT;
+    config.offload_info.bit_width = CODEC_BACKEND_DEFAULT_BIT_WIDTH;
+    config.offload_info.channel_mask = config.channel_mask = AUDIO_CHANNEL_OUT_STEREO;
+
+    pthread_mutex_lock(&p_qap->lock);
+
+    if (event_id == QAP_CALLBACK_EVENT_OUTPUT_CFG_CHANGE) {
+        new_conf = &buffer->buffer_parms.output_buf_params.output_config;
+        qap_output_config_t *cached_conf = NULL;
+        int index = -1;
+
+        DEBUG_MSG("Received QAP_CALLBACK_EVENT_OUTPUT_CFG_CHANGE event for output id=0x%x",
+                buffer->buffer_parms.output_buf_params.output_id);
+
+        DEBUG_MSG("sample rate=%d bitwidth=%d format = %d channels =0x%x",
+            new_conf->sample_rate,
+            new_conf->bit_width,
+            new_conf->format,
+            new_conf->channels);
+
+        if ( (uint32_t)size < sizeof(qap_output_config_t)) {
+            ERROR_MSG("Size is not proper for the event AUDIO_OUTPUT_MEDIA_FORMAT_EVENT.");
+            return ;
+        }
+
+        index = get_media_fmt_array_index_for_output_id_l(qap_mod, buffer->buffer_parms.output_buf_params.output_id);
+
+        DEBUG_MSG("index = %d", index);
+
+        if (index >= 0) {
+            cached_conf = &qap_mod->session_outputs_config.output_config[index];
+        } else if (index < 0 && qap_mod->new_out_format_index < MAX_QAP_MODULE_OUT) {
+            index = qap_mod->new_out_format_index;
+            cached_conf = &qap_mod->session_outputs_config.output_config[index];
+            qap_mod->new_out_format_index++;
+        }
+
+        if (cached_conf == NULL) {
+            ERROR_MSG("Maximum output from a QAP module is reached. Can not process new output.");
+            return ;
+        }
+
+        if (memcmp(cached_conf, new_conf, sizeof(qap_output_config_t)) != 0) {
+            memcpy(cached_conf, new_conf, sizeof(qap_output_config_t));
+            qap_mod->is_media_fmt_changed[index] = true;
+        }
+    } else if (event_id == QAP_CALLBACK_EVENT_DATA) {
+        data_buffer_p = (int8_t*)buffer->common_params.data+buffer->common_params.offset;
+        buffer_size = buffer->common_params.size;
+        device = buffer->buffer_parms.output_buf_params.output_id;
+
+        DEBUG_MSG_VV("Received QAP_CALLBACK_EVENT_DATA event buff size(%d) for outputid=0x%x",
+            buffer_size, buffer->buffer_parms.output_buf_params.output_id);
+
+        if (buffer && buffer->common_params.data) {
+            int index = -1;
+
+            index = get_media_fmt_array_index_for_output_id_l(qap_mod, buffer->buffer_parms.output_buf_params.output_id);
+            DEBUG_MSG("index = %d", index);
+            if (index > -1 && qap_mod->is_media_fmt_changed[index]) {
+                DEBUG_MSG("FORMAT changed, recreate stream");
+                need_to_recreate_stream = true;
+                qap_mod->is_media_fmt_changed[index] = false;
+
+                qap_output_config_t *new_config = &qap_mod->session_outputs_config.output_config[index];
+
+                config.sample_rate = config.offload_info.sample_rate = new_config->sample_rate;
+                config.offload_info.version = AUDIO_INFO_INITIALIZER.version;
+                config.offload_info.size = AUDIO_INFO_INITIALIZER.size;
+                config.offload_info.bit_width = new_config->bit_width;
+
+                if (new_config->format == QAP_AUDIO_FORMAT_PCM_16_BIT) {
+                    if (new_config->bit_width == 16)
+                        config.format = config.offload_info.format = AUDIO_FORMAT_PCM_16_BIT;
+                    else if (new_config->bit_width == 24)
+                        config.format = config.offload_info.format = AUDIO_FORMAT_PCM_24_BIT_PACKED;
+                    else
+                        config.format = config.offload_info.format = AUDIO_FORMAT_PCM_32_BIT;
+                } else if (new_config->format  == QAP_AUDIO_FORMAT_AC3)
+                    config.format = config.offload_info.format = AUDIO_FORMAT_AC3;
+                else if (new_config->format  == QAP_AUDIO_FORMAT_EAC3)
+                    config.format = config.offload_info.format = AUDIO_FORMAT_E_AC3;
+                else if (new_config->format  == QAP_AUDIO_FORMAT_DTS)
+                    config.format = config.offload_info.format = AUDIO_FORMAT_DTS;
+
+                device |= (new_config->format & AUDIO_FORMAT_MAIN_MASK);
+
+                config.channel_mask = audio_channel_out_mask_from_count(new_config->channels);
+                config.offload_info.channel_mask = config.channel_mask;
+                DEBUG_MSG("sample rate=%d bitwidth=%d format = %d channels=%d channel_mask=%d device =0x%x",
+                    config.sample_rate,
+                    config.offload_info.bit_width,
+                    config.offload_info.format,
+                    new_config->channels,
+                    config.channel_mask,
+                    device);
+            }
+        }
+
+        if (p_qap->passthrough_out != NULL) {
+            //If QAP passthrough is active then all the module output will be dropped.
+            pthread_mutex_unlock(&p_qap->lock);
+            DEBUG_MSG("QAP-PSTH is active, DROPPING DATA!");
+            return;
+        }
+
+        if (qap_check_and_get_compressed_device_format(device, &format)) {
+            /*
+             * CASE 1: Transcoded output of mm module.
+             * If HDMI is not connected then drop the data.
+             * Only one HDMI output can be supported from all the mm modules of QAP.
+             * Multi-Channel PCM HDMI output streams will be closed from all the mm modules.
+             * If transcoded output of other module is already enabled then this data will be dropped.
+             */
+
+            if (!p_qap->hdmi_connect) {
+                DEBUG_MSG("HDMI not connected, DROPPING DATA!");
+                pthread_mutex_unlock(&p_qap->lock);
+                return;
+            }
+
+            //Closing all the PCM HDMI output stream from QAP.
+            close_all_pcm_hdmi_output_l();
+
+            /* If Media format was changed for this stream then need to re-create the stream. */
+            if (need_to_recreate_stream && qap_mod->stream_out[QAP_OUT_TRANSCODE_PASSTHROUGH]) {
+                DEBUG_MSG("closing Transcode Passthrough session ox%x",
+                    (int)qap_mod->stream_out[QAP_OUT_TRANSCODE_PASSTHROUGH]);
+                adev_close_output_stream((struct audio_hw_device *)p_qap->adev,
+                                         (struct audio_stream_out *)(qap_mod->stream_out[QAP_OUT_TRANSCODE_PASSTHROUGH]));
+                qap_mod->stream_out[QAP_OUT_TRANSCODE_PASSTHROUGH] = NULL;
+                p_qap->passthrough_enabled = false;
+            }
+
+            if (!p_qap->passthrough_enabled
+                && !(qap_mod->stream_out[QAP_OUT_TRANSCODE_PASSTHROUGH])) {
+
+                audio_devices_t devices;
+
+                config.format = config.offload_info.format = format;
+                config.offload_info.channel_mask = config.channel_mask = AUDIO_CHANNEL_OUT_5POINT1;
+
+                flags = (AUDIO_OUTPUT_FLAG_NON_BLOCKING
+                         | AUDIO_OUTPUT_FLAG_COMPRESS_OFFLOAD
+                         | AUDIO_OUTPUT_FLAG_DIRECT
+                         | AUDIO_OUTPUT_FLAG_COMPRESS_PASSTHROUGH);
+                devices = AUDIO_DEVICE_OUT_AUX_DIGITAL;
+
+                DEBUG_MSG("Opening Transcode Passthrough out(outputenum=%d) session 0x%x with below params",
+                        QAP_OUT_TRANSCODE_PASSTHROUGH,
+                        (int)qap_mod->stream_out[QAP_OUT_TRANSCODE_PASSTHROUGH]);
+
+                DEBUG_MSG("sample rate=%d bitwidth=%d format = 0x%x channel mask=0x%x flags=0x%x device =0x%x",
+                    config.sample_rate,
+                    config.offload_info.bit_width,
+                    config.offload_info.format,
+                    config.offload_info.channel_mask,
+                    flags,
+                    devices);
+
+                ret = adev_open_output_stream((struct audio_hw_device *)p_qap->adev,
+                                              QAP_DEFAULT_COMPR_PASSTHROUGH_HANDLE,
+                                              devices,
+                                              flags,
+                                              &config,
+                                              (struct audio_stream_out **)&(qap_mod->stream_out[QAP_OUT_TRANSCODE_PASSTHROUGH]),
+                                              NULL);
+                if (ret < 0) {
+                    ERROR_MSG("Failed opening Transcode Passthrough out(outputenum=%d) session 0x%x",
+                            QAP_OUT_TRANSCODE_PASSTHROUGH,
+                            (int)qap_mod->stream_out[QAP_OUT_TRANSCODE_PASSTHROUGH]);
+                    pthread_mutex_unlock(&p_qap->lock);
+                    return;
+                } else
+                    DEBUG_MSG("Opened Transcode Passthrough out(outputenum=%d) session 0x%x",
+                            QAP_OUT_TRANSCODE_PASSTHROUGH,
+                            (int)qap_mod->stream_out[QAP_OUT_TRANSCODE_PASSTHROUGH]);
+
+
+                if (format == AUDIO_FORMAT_E_AC3) {
+                    qap_mod->stream_out[QAP_OUT_TRANSCODE_PASSTHROUGH]->compr_config.fragment_size =
+                            COMPRESS_PASSTHROUGH_DDP_FRAGMENT_SIZE;
+                }
+                qap_mod->stream_out[QAP_OUT_TRANSCODE_PASSTHROUGH]->compr_config.fragments =
+                        COMPRESS_OFFLOAD_NUM_FRAGMENTS;
+
+                p_qap->passthrough_enabled = true;
+            }
+
+            if (qap_mod->stream_out[QAP_OUT_TRANSCODE_PASSTHROUGH]) {
+                DEBUG_MSG_VV("Writing Bytes(%d) to QAP_OUT_TRANSCODE_PASSTHROUGH output(%p) buff ptr(%p)",
+                    buffer_size, qap_mod->stream_out[QAP_OUT_TRANSCODE_PASSTHROUGH],
+                    data_buffer_p);
+                ret = qap_mod->stream_out[QAP_OUT_TRANSCODE_PASSTHROUGH]->stream.write(
+                        (struct audio_stream_out *)qap_mod->stream_out[QAP_OUT_TRANSCODE_PASSTHROUGH],
+                        data_buffer_p,
+                        buffer_size);
+            }
+        }
+        else if ((device & AUDIO_DEVICE_OUT_AUX_DIGITAL)
+                   && (p_qap->hdmi_connect)
+                   && (p_qap->hdmi_sink_channels > 2)) {
+
+            /* CASE 2: Multi-Channel PCM output to HDMI.
+             * If any other HDMI output is already enabled then this has to be dropped.
+             */
+
+            if (p_qap->passthrough_enabled) {
+                //Closing all the multi-Channel PCM HDMI output stream from QAP.
+                close_all_pcm_hdmi_output_l();
+
+                //If passthrough is active then pcm hdmi output has to be dropped.
+                pthread_mutex_unlock(&p_qap->lock);
+                DEBUG_MSG("Compressed passthrough enabled, DROPPING DATA!");
+                return;
+            }
+
+            /* If Media format was changed for this stream then need to re-create the stream. */
+            if (need_to_recreate_stream && qap_mod->stream_out[QAP_OUT_OFFLOAD_MCH]) {
+                DEBUG_MSG("closing MCH PCM session ox%x", (int)qap_mod->stream_out[QAP_OUT_OFFLOAD_MCH]);
+                adev_close_output_stream((struct audio_hw_device *)p_qap->adev,
+                                         (struct audio_stream_out *)(qap_mod->stream_out[QAP_OUT_OFFLOAD_MCH]));
+                qap_mod->stream_out[QAP_OUT_OFFLOAD_MCH] = NULL;
+                p_qap->mch_pcm_hdmi_enabled = false;
+            }
+
+            if (!p_qap->mch_pcm_hdmi_enabled && !(qap_mod->stream_out[QAP_OUT_OFFLOAD_MCH])) {
+                audio_devices_t devices;
+
+                if (event_id == AUDIO_DATA_EVENT) {
+                    config.offload_info.format = config.format = AUDIO_FORMAT_PCM_16_BIT;
+
+                    if (p_qap->hdmi_sink_channels == 8) {
+                        config.offload_info.channel_mask = config.channel_mask =
+                                AUDIO_CHANNEL_OUT_7POINT1;
+                    } else if (p_qap->hdmi_sink_channels == 6) {
+                        config.offload_info.channel_mask = config.channel_mask =
+                                AUDIO_CHANNEL_OUT_5POINT1;
+                    } else {
+                        config.offload_info.channel_mask = config.channel_mask =
+                                AUDIO_CHANNEL_OUT_STEREO;
+                    }
+                }
+
+                devices = AUDIO_DEVICE_OUT_AUX_DIGITAL;
+                flags = AUDIO_OUTPUT_FLAG_DIRECT;
+
+                DEBUG_MSG("Opening MCH PCM out(outputenum=%d) session ox%x with below params",
+                    QAP_OUT_OFFLOAD_MCH,
+                    (int)qap_mod->stream_out[QAP_OUT_OFFLOAD_MCH]);
+
+                DEBUG_MSG("sample rate=%d bitwidth=%d format = 0x%x channel mask=0x%x flags=0x%x device =0x%x",
+                    config.sample_rate,
+                    config.offload_info.bit_width,
+                    config.offload_info.format,
+                    config.offload_info.channel_mask,
+                    flags,
+                    devices);
+
+                ret = adev_open_output_stream((struct audio_hw_device *)p_qap->adev,
+                                              QAP_DEFAULT_COMPR_AUDIO_HANDLE,
+                                              devices,
+                                              flags,
+                                              &config,
+                                              (struct audio_stream_out **)&(qap_mod->stream_out[QAP_OUT_OFFLOAD_MCH]),
+                                              NULL);
+                if (ret < 0) {
+                    ERROR_MSG("Failed opening MCH PCM out(outputenum=%d) session ox%x",
+                        QAP_OUT_OFFLOAD_MCH,
+                        (int)qap_mod->stream_out[QAP_OUT_OFFLOAD_MCH]);
+                    pthread_mutex_unlock(&p_qap->lock);
+                    return;
+                    } else
+                        DEBUG_MSG("Opened MCH PCM out(outputenum=%d) session ox%x",
+                            QAP_OUT_OFFLOAD_MCH,
+                            (int)qap_mod->stream_out[QAP_OUT_OFFLOAD_MCH]);
+
+                set_out_stream_channel_map(qap_mod->stream_out[QAP_OUT_OFFLOAD_MCH], new_conf);
+
+                qap_mod->stream_out[QAP_OUT_OFFLOAD_MCH]->compr_config.fragments =
+                        COMPRESS_OFFLOAD_NUM_FRAGMENTS;
+                qap_mod->stream_out[QAP_OUT_OFFLOAD_MCH]->compr_config.fragment_size =
+                        qap_get_pcm_offload_output_buffer_size(qap_mod, &config.offload_info);
+
+                p_qap->mch_pcm_hdmi_enabled = true;
+
+                if ((qap_mod->stream_in[QAP_IN_MAIN]
+                    && qap_mod->stream_in[QAP_IN_MAIN]->client_callback != NULL) ||
+                    (qap_mod->stream_in[QAP_IN_MAIN_2]
+                    && qap_mod->stream_in[QAP_IN_MAIN_2]->client_callback != NULL)) {
+
+                    if (qap_mod->stream_in[QAP_IN_MAIN]) {
+                        qap_mod->stream_out[QAP_OUT_OFFLOAD_MCH]->stream.set_callback(
+                            (struct audio_stream_out *)qap_mod->stream_out[QAP_OUT_OFFLOAD_MCH],
+                            qap_mod->stream_in[QAP_IN_MAIN]->client_callback,
+                            qap_mod->stream_in[QAP_IN_MAIN]->client_cookie);
+                    }
+                    if (qap_mod->stream_in[QAP_IN_MAIN_2]) {
+                        qap_mod->stream_out[QAP_OUT_OFFLOAD_MCH]->stream.set_callback(
+                            (struct audio_stream_out *)qap_mod->stream_out[QAP_OUT_OFFLOAD_MCH],
+                            qap_mod->stream_in[QAP_IN_MAIN_2]->client_callback,
+                            qap_mod->stream_in[QAP_IN_MAIN_2]->client_cookie);
+                    }
+                } else if (qap_mod->stream_in[QAP_IN_PCM]
+                           && qap_mod->stream_in[QAP_IN_PCM]->client_callback != NULL) {
+
+                    qap_mod->stream_out[QAP_OUT_OFFLOAD_MCH]->stream.set_callback(
+                            (struct audio_stream_out *)qap_mod->stream_out[QAP_OUT_OFFLOAD_MCH],
+                            qap_mod->stream_in[QAP_IN_PCM]->client_callback,
+                            qap_mod->stream_in[QAP_IN_PCM]->client_cookie);
+                }
+            }
+            if (qap_mod->stream_out[QAP_OUT_OFFLOAD_MCH]) {
+                DEBUG_MSG_VV("Writing Bytes(%d) to QAP_OUT_OFFLOAD_MCH output(%p) buff ptr(%p)",
+                    buffer_size, qap_mod->stream_out[QAP_OUT_OFFLOAD_MCH],
+                    data_buffer_p);
+                ret = qap_mod->stream_out[QAP_OUT_OFFLOAD_MCH]->stream.write(
+                        (struct audio_stream_out *)qap_mod->stream_out[QAP_OUT_OFFLOAD_MCH],
+                        data_buffer_p,
+                        buffer_size);
+            }
+        }
+        else {
+            /* CASE 3: PCM output.
+             */
+
+            /* If Media format was changed for this stream then need to re-create the stream. */
+            if (need_to_recreate_stream && qap_mod->stream_out[QAP_OUT_OFFLOAD]) {
+                DEBUG_MSG("closing PCM session ox%x", (int)qap_mod->stream_out[QAP_OUT_OFFLOAD]);
+                adev_close_output_stream((struct audio_hw_device *)p_qap->adev,
+                                         (struct audio_stream_out *)(qap_mod->stream_out[QAP_OUT_OFFLOAD]));
+                qap_mod->stream_out[QAP_OUT_OFFLOAD] = NULL;
+            }
+
+            bt_stream = audio_extn_bt_hal_get_output_stream(qap_mod->bt_hdl);
+            if (bt_stream != NULL) {
+                if (qap_mod->stream_out[QAP_OUT_OFFLOAD]) {
+                    adev_close_output_stream((struct audio_hw_device *)p_qap->adev,
+                                             (struct audio_stream_out *)(qap_mod->stream_out[QAP_OUT_OFFLOAD]));
+                    qap_mod->stream_out[QAP_OUT_OFFLOAD] = NULL;
+                }
+
+                audio_extn_bt_hal_out_write(p_qap->bt_hdl, data_buffer_p, buffer_size);
+            } else if (NULL == qap_mod->stream_out[QAP_OUT_OFFLOAD]) {
+                audio_devices_t devices;
+
+                if (qap_mod->stream_in[QAP_IN_MAIN])
+                    devices = qap_mod->stream_in[QAP_IN_MAIN]->devices;
+                else
+                    devices = qap_mod->stream_in[QAP_IN_PCM]->devices;
+
+                //If multi channel pcm or passthrough is already enabled then remove the hdmi flag from device.
+                if (p_qap->mch_pcm_hdmi_enabled || p_qap->passthrough_enabled) {
+                    if (devices & AUDIO_DEVICE_OUT_AUX_DIGITAL)
+                        devices ^= AUDIO_DEVICE_OUT_AUX_DIGITAL;
+                }
+                if (devices == 0) {
+                    devices = device;
+                }
+
+                flags = AUDIO_OUTPUT_FLAG_DIRECT;
+
+
+                DEBUG_MSG("Opening Stereo PCM out(outputenum=%d) session ox%x with below params",
+                    QAP_OUT_OFFLOAD,
+                    (int)qap_mod->stream_out[QAP_OUT_OFFLOAD]);
+
+
+                DEBUG_MSG("sample rate=%d bitwidth=%d format = 0x%x channel mask=0x%x flags=0x%x device =0x%x",
+                    config.sample_rate,
+                    config.offload_info.bit_width,
+                    config.offload_info.format,
+                    config.offload_info.channel_mask,
+                    flags,
+                    devices);
+
+
+                /* TODO:: Need to Propagate errors to framework */
+                ret = adev_open_output_stream((struct audio_hw_device *)p_qap->adev,
+                                              QAP_DEFAULT_COMPR_AUDIO_HANDLE,
+                                              devices,
+                                              flags,
+                                              &config,
+                                              (struct audio_stream_out **)&(qap_mod->stream_out[QAP_OUT_OFFLOAD]),
+                                              NULL);
+                if (ret < 0) {
+                    ERROR_MSG("Failed opening Stereo PCM out(outputenum=%d) session ox%x",
+                        QAP_OUT_OFFLOAD,
+                        (int)qap_mod->stream_out[QAP_OUT_OFFLOAD]);
+                    pthread_mutex_unlock(&p_qap->lock);
+                    return;
+                } else
+                    DEBUG_MSG("Opened Stereo PCM out(outputenum=%d) session ox%x",
+                        QAP_OUT_OFFLOAD,
+                        (int)qap_mod->stream_out[QAP_OUT_OFFLOAD]);
+
+                set_out_stream_channel_map(qap_mod->stream_out[QAP_OUT_OFFLOAD], new_conf);
+
+                if ((qap_mod->stream_in[QAP_IN_MAIN]
+                    && qap_mod->stream_in[QAP_IN_MAIN]->client_callback != NULL) ||
+                    (qap_mod->stream_in[QAP_IN_MAIN_2]
+                    && qap_mod->stream_in[QAP_IN_MAIN_2]->client_callback != NULL)) {
+
+                    if (qap_mod->stream_in[QAP_IN_MAIN]) {
+                        qap_mod->stream_out[QAP_OUT_OFFLOAD]->stream.set_callback(
+                            (struct audio_stream_out *)qap_mod->stream_out[QAP_OUT_OFFLOAD],
+                            qap_mod->stream_in[QAP_IN_MAIN]->client_callback,
+                            qap_mod->stream_in[QAP_IN_MAIN]->client_cookie);
+                    }
+                    if (qap_mod->stream_in[QAP_IN_MAIN_2]) {
+                        qap_mod->stream_out[QAP_OUT_OFFLOAD]->stream.set_callback(
+                            (struct audio_stream_out *)qap_mod->stream_out[QAP_OUT_OFFLOAD],
+                            qap_mod->stream_in[QAP_IN_MAIN_2]->client_callback,
+                            qap_mod->stream_in[QAP_IN_MAIN_2]->client_cookie);
+                    }
+                } else if (qap_mod->stream_in[QAP_IN_PCM]
+                           && qap_mod->stream_in[QAP_IN_PCM]->client_callback != NULL) {
+
+                    qap_mod->stream_out[QAP_OUT_OFFLOAD]->stream.set_callback(
+                                                (struct audio_stream_out *)qap_mod->stream_out[QAP_OUT_OFFLOAD],
+                                                qap_mod->stream_in[QAP_IN_PCM]->client_callback,
+                                                qap_mod->stream_in[QAP_IN_PCM]->client_cookie);
+                }
+
+                qap_mod->stream_out[QAP_OUT_OFFLOAD]->compr_config.fragments =
+                        COMPRESS_OFFLOAD_NUM_FRAGMENTS;
+                qap_mod->stream_out[QAP_OUT_OFFLOAD]->compr_config.fragment_size =
+                        qap_get_pcm_offload_output_buffer_size(qap_mod, &config.offload_info);
+
+                if (qap_mod->is_vol_set) {
+                    DEBUG_MSG("Setting Volume Left[%f], Right[%f]", qap_mod->vol_left, qap_mod->vol_right);
+                    qap_mod->stream_out[QAP_OUT_OFFLOAD]->stream.set_volume(
+                            (struct audio_stream_out *)qap_mod->stream_out[QAP_OUT_OFFLOAD],
+                            qap_mod->vol_left,
+                            qap_mod->vol_right);
+                }
+            }
+
+            if (qap_mod->stream_out[QAP_OUT_OFFLOAD]) {
+                DEBUG_MSG_VV("Writing Bytes(%d) to QAP_OUT_OFFLOAD output(%p) buff ptr(%p)",
+                    buffer_size, qap_mod->stream_out[QAP_OUT_OFFLOAD],
+                    data_buffer_p);
+                ret = qap_mod->stream_out[QAP_OUT_OFFLOAD]->stream.write(
+                        (struct audio_stream_out *)qap_mod->stream_out[QAP_OUT_OFFLOAD],
+                        data_buffer_p,
+                        buffer_size);
+            }
+        }
+        DEBUG_MSG_VV("Bytes consumed [%d] by Audio HAL", ret);
+    }
+    else if (event_id == QAP_CALLBACK_EVENT_EOS
+               || event_id == QAP_CALLBACK_EVENT_MAIN_2_EOS
+               || event_id == QAP_CALLBACK_EVENT_EOS_ASSOC) {
+        struct stream_out *out = qap_mod->stream_in[QAP_IN_MAIN];
+        struct stream_out *out_pcm = qap_mod->stream_in[QAP_IN_PCM];
+        struct stream_out *out_main2 = qap_mod->stream_in[QAP_IN_MAIN_2];
+        struct stream_out *out_assoc = qap_mod->stream_in[QAP_IN_ASSOC];
+
+        /**
+         * TODO:: Only DD/DDP Associate Eos is handled, need to add support
+         * for other formats.
+         */
+        if (event_id == QAP_CALLBACK_EVENT_EOS
+                && (out_pcm != NULL)
+                && (check_stream_state_l(out_pcm, STOPPING))) {
+
+            lock_output_stream_l(out_pcm);
+            out_pcm->client_callback(STREAM_CBK_EVENT_DRAIN_READY, NULL, out_pcm->client_cookie);
+            set_stream_state_l(out_pcm, STOPPED);
+            unlock_output_stream_l(out_pcm);
+            DEBUG_MSG("sent pcm DRAIN_READY");
+        } else if ( event_id == QAP_CALLBACK_EVENT_EOS_ASSOC
+                && (out_assoc != NULL)
+                && (check_stream_state_l(out_assoc, STOPPING))) {
+
+            lock_output_stream_l(out_assoc);
+            out_assoc->client_callback(STREAM_CBK_EVENT_DRAIN_READY, NULL, out_assoc->client_cookie);
+            set_stream_state_l(out_assoc, STOPPED);
+            unlock_output_stream_l(out_assoc);
+            DEBUG_MSG("sent associated DRAIN_READY");
+        } else if (event_id == QAP_CALLBACK_EVENT_MAIN_2_EOS
+                && (out_main2 != NULL)
+                && (check_stream_state_l(out_main2, STOPPING))) {
+
+            lock_output_stream_l(out_main2);
+            out_main2->client_callback(STREAM_CBK_EVENT_DRAIN_READY, NULL, out_main2->client_cookie);
+            set_stream_state_l(out_main2, STOPPED);
+            unlock_output_stream_l(out_main2);
+            DEBUG_MSG("sent main2 DRAIN_READY");
+        } else if ((out != NULL) && (check_stream_state_l(out, STOPPING))) {
+            lock_output_stream_l(out);
+            out->client_callback(STREAM_CBK_EVENT_DRAIN_READY, NULL, out->client_cookie);
+            set_stream_state_l(out, STOPPED);
+            unlock_output_stream_l(out);
+            DEBUG_MSG("sent main DRAIN_READY");
+        }
+    }
+    else if (event_id == QAP_CALLBACK_EVENT_EOS || event_id == QAP_CALLBACK_EVENT_EOS_ASSOC) {
+        struct stream_out *out = NULL;
+
+        if (event_id == QAP_CALLBACK_EVENT_EOS) {
+            out = qap_mod->stream_in[QAP_IN_MAIN];
+        } else {
+            out = qap_mod->stream_in[QAP_IN_ASSOC];
+        }
+
+        if ((out != NULL) && (check_stream_state_l(out, STOPPING))) {
+            lock_output_stream_l(out);
+            out->client_callback(STREAM_CBK_EVENT_DRAIN_READY, NULL, out->client_cookie);
+            set_stream_state_l(out, STOPPED);
+            unlock_output_stream_l(out);
+            DEBUG_MSG("sent DRAIN_READY");
+        }
+    }
+
+    pthread_mutex_unlock(&p_qap->lock);
+    return;
+}
+
+static int qap_sess_close(struct qap_module* qap_mod)
+{
+    int j;
+    int ret = -EINVAL;
+
+    DEBUG_MSG("Closing Session.");
+
+    //Check if all streams are closed or not.
+    for (j = 0; j < MAX_QAP_MODULE_IN; j++) {
+        if (qap_mod->stream_in[j] != NULL) {
+            break;
+        }
+    }
+    if (j != MAX_QAP_MODULE_IN) {
+        DEBUG_MSG("Some stream is still active, Can not close session.");
+        return 0;
+    }
+
+    qap_mod->is_session_closing = true;
+    if(p_qap->qap_output_block_handling) {
+        pthread_mutex_lock(&qap_mod->session_output_lock);
+        if (qap_mod->is_session_output_active == false) {
+            pthread_cond_signal(&qap_mod->session_output_cond);
+            DEBUG_MSG("Wake up MM module output thread");
+        }
+        pthread_mutex_unlock(&qap_mod->session_output_lock);
+    }
+    pthread_mutex_lock(&p_qap->lock);
+
+    if (!qap_mod || !qap_mod->session_handle) {
+        ERROR_MSG("Wrong state to process qap_mod(%p) sess_hadl(%p)",
+            qap_mod, qap_mod->session_handle);
+        return -EINVAL;
+    }
+
+    ret = qap_session_close(qap_mod->session_handle);
+    if (QAP_STATUS_OK != ret) {
+        ERROR_MSG("close session failed %d", ret);
+        return -EINVAL;
+    } else
+        DEBUG_MSG("Closed QAP session 0x%x", (int)qap_mod->session_handle);
+
+    qap_mod->session_handle = NULL;
+    qap_mod->is_vol_set = false;
+    memset(qap_mod->stream_state, 0, sizeof(qap_mod->stream_state));
+
+    qap_close_all_output_streams(qap_mod);
+
+    qap_mod->new_out_format_index = 0;
+
+    pthread_mutex_unlock(&p_qap->lock);
+    qap_mod->is_session_closing = false;
+    DEBUG_MSG("Exit.");
+
+    return 0;
+}
+
+static int qap_stream_close(struct stream_out *out)
+{
+    int ret = -EINVAL;
+    struct qap_module *qap_mod = NULL;
+    int index = -1;
+    DEBUG_MSG("Flag [0x%x], Stream handle [%p]", out->flags, out->qap_stream_handle);
+
+    qap_mod = get_qap_module_for_input_stream_l(out);
+    index = get_input_stream_index_l(out);
+
+    if (!qap_mod || !qap_mod->session_handle || (index < 0) || !out->qap_stream_handle) {
+        ERROR_MSG("Wrong state to process qap_mod(%p) sess_hadl(%p) strm hndl(%p), index %d",
+            qap_mod, qap_mod->session_handle, out->qap_stream_handle, index);
+        return -EINVAL;
+    }
+
+    pthread_mutex_lock(&p_qap->lock);
+
+    set_stream_state_l(out,STOPPED);
+    qap_mod->stream_in[index] = NULL;
+
+    lock_output_stream_l(out);
+
+    ret = qap_module_deinit(out->qap_stream_handle);
+    if (QAP_STATUS_OK != ret) {
+        ERROR_MSG("deinit failed %d", ret);
+        return -EINVAL;
+    } else
+        DEBUG_MSG("module(ox%x) closed successfully", (int)out->qap_stream_handle);
+
+
+    out->qap_stream_handle = NULL;
+    unlock_output_stream_l(out);
+
+    pthread_mutex_unlock(&p_qap->lock);
+
+    //If all streams are closed then close the session.
+    qap_sess_close(qap_mod);
+
+    DEBUG_MSG("Exit");
+    return ret;
+}
+
+#define MAX_INIT_PARAMS 6
+
+static void update_qap_session_init_params(audio_session_handle_t session_handle) {
+    DEBUG_MSG("Entry");
+    qap_status_t ret = QAP_STATUS_OK;
+    uint32_t cmd_data[MAX_INIT_PARAMS] = {0};
+
+    /* all init params should be sent
+     * together so gang them up.
+     */
+    cmd_data[0] = MS12_SESSION_CFG_MAX_CHS;
+    cmd_data[1] = 6;/*5.1 channels*/
+
+    cmd_data[2] = MS12_SESSION_CFG_BS_OUTPUT_MODE;
+    cmd_data[3] = 3;/*DDP Re-encoding and DDP to DD Transcoding*/
+
+    cmd_data[4] = MS12_SESSION_CFG_CHMOD_LOCKING;
+    cmd_data[MAX_INIT_PARAMS - 1] = 1;/*Lock to 6 channel*/
+
+    ret = qap_session_cmd(session_handle,
+            QAP_SESSION_CMD_SET_PARAM,
+            MAX_INIT_PARAMS * sizeof(uint32_t),
+            &cmd_data[0],
+            NULL,
+            NULL);
+    if (ret != QAP_STATUS_OK) {
+        ERROR_MSG("session init params config failed");
+    }
+    DEBUG_MSG("Exit");
+    return;
+}
+
+/* Query HDMI EDID and sets module output accordingly.*/
+static void qap_set_hdmi_configuration_to_module()
+{
+    int ret = 0;
+    int channels = 0;
+    char prop_value[PROPERTY_VALUE_MAX] = {0};
+    bool passth_support = false;
+    qap_session_outputs_config_t *session_outputs_config = NULL;
+
+
+    DEBUG_MSG("Entry");
+
+    if (!p_qap) {
+        return;
+    }
+
+    if (!p_qap->hdmi_connect) {
+        return;
+    }
+
+    p_qap->hdmi_sink_channels = 0;
+
+    if (p_qap->qap_mod[MS12].session_handle)
+        session_outputs_config = &p_qap->qap_mod[MS12].session_outputs_config;
+    else if (p_qap->qap_mod[DTS_M8].session_handle)
+        session_outputs_config = &p_qap->qap_mod[DTS_M8].session_outputs_config;
+    else {
+        DEBUG_MSG("HDMI connection comes even before session is setup");
+        return;
+    }
+
+    session_outputs_config->num_output = 1;
+    //QAP re-encoding and DSP offload passthrough is supported.
+    if (property_get_bool("vendor.audio.offload.passthrough", false)
+            && property_get_bool("vendor.audio.qap.reencode", false)) {
+
+        if (p_qap->qap_mod[MS12].session_handle) {
+
+            bool do_setparam = false;
+            property_get("vendor.audio.qap.hdmi.out", prop_value, NULL);
+
+            if (platform_is_edid_supported_format(p_qap->adev->platform, AUDIO_FORMAT_E_AC3)
+                    && (strncmp(prop_value, "ddp", 3) == 0)) {
+                do_setparam = true;
+                session_outputs_config->output_config[0].format = QAP_AUDIO_FORMAT_EAC3;
+                session_outputs_config->output_config[0].id = AUDIO_DEVICE_OUT_HDMI|QAP_AUDIO_FORMAT_EAC3;
+            } else if (platform_is_edid_supported_format(p_qap->adev->platform, AUDIO_FORMAT_AC3)) {
+                do_setparam = true;
+                session_outputs_config->output_config[0].format = QAP_AUDIO_FORMAT_AC3;
+                session_outputs_config->output_config[0].id = AUDIO_DEVICE_OUT_HDMI|QAP_AUDIO_FORMAT_AC3;
+            }
+            if (do_setparam) {
+                DEBUG_MSG(" Enabling HDMI(Passthrough out) from MS12 wrapper outputid=0x%x",
+                    session_outputs_config->output_config[0].id);
+                ret = qap_session_cmd(p_qap->qap_mod[MS12].session_handle,
+                                    QAP_SESSION_CMD_SET_OUTPUTS,
+                                    sizeof(qap_session_outputs_config_t),
+                                    session_outputs_config,
+                                    NULL,
+                                    NULL);
+                if (QAP_STATUS_OK != ret) {
+                    ERROR_MSG("Unable to register AUDIO_DEVICE_OUT_HDMI device with QAP %d", ret);
+                    return;
+                }
+                passth_support = true;
+            }
+        }
+
+        if (p_qap->qap_mod[DTS_M8].session_handle) {
+
+            bool do_setparam = false;
+            if (platform_is_edid_supported_format(p_qap->adev->platform, AUDIO_FORMAT_DTS)) {
+                do_setparam = true;
+                session_outputs_config->output_config[0].format = QAP_AUDIO_FORMAT_DTS;
+                session_outputs_config->output_config[0].id = AUDIO_DEVICE_OUT_HDMI|QAP_AUDIO_FORMAT_DTS;
+            }
+
+            if (do_setparam) {
+                ret = qap_session_cmd(p_qap->qap_mod[DTS_M8].session_handle,
+                                    QAP_SESSION_CMD_SET_OUTPUTS,
+                                    sizeof(qap_session_outputs_config_t),
+                                    session_outputs_config,
+                                    NULL,
+                                    NULL);
+                if (QAP_STATUS_OK != ret) {
+                    ERROR_MSG("Unable to register AUDIO_DEVICE_OUT_HDMI device with QAP %d", ret);
+                    return;
+                }
+                passth_support = true;
+            }
+        }
+    }
+    //Compressed passthrough is not enabled.
+    if (!passth_support) {
+
+        channels = platform_edid_get_max_channels(p_qap->adev->platform);
+        session_outputs_config->output_config[0].format = QAP_AUDIO_FORMAT_PCM_16_BIT;
+
+        switch (channels) {
+            case 8:
+                DEBUG_MSG("Switching Qap output to 7.1 channels");
+                session_outputs_config->output_config[0].channels = 8;
+                if (!p_qap->qap_msmd_enabled)
+                    session_outputs_config->output_config[0].id = AUDIO_DEVICE_OUT_HDMI|QAP_AUDIO_FORMAT_PCM_16_BIT;
+                p_qap->hdmi_sink_channels = channels;
+                break;
+            case 6:
+                DEBUG_MSG("Switching Qap output to 5.1 channels");
+                session_outputs_config->output_config[0].channels = 6;
+                if (!p_qap->qap_msmd_enabled)
+                    session_outputs_config->output_config[0].id = AUDIO_DEVICE_OUT_HDMI|QAP_AUDIO_FORMAT_PCM_16_BIT;
+                p_qap->hdmi_sink_channels = channels;
+                break;
+            default:
+                DEBUG_MSG("Switching Qap output to default channels");
+                session_outputs_config->output_config[0].channels = 2;
+                if (!p_qap->qap_msmd_enabled)
+                    session_outputs_config->output_config[0].id = AUDIO_DEVICE_OUT_HDMI|QAP_AUDIO_FORMAT_PCM_16_BIT;
+                p_qap->hdmi_sink_channels = 2;
+                break;
+        }
+
+        if (p_qap->qap_mod[MS12].session_handle) {
+            DEBUG_MSG(" Enabling HDMI(MCH PCM out) from MS12 wrapper outputid = %x", session_outputs_config->output_config[0].id);
+            ret = qap_session_cmd(p_qap->qap_mod[MS12].session_handle,
+                                QAP_SESSION_CMD_SET_OUTPUTS,
+                                sizeof(qap_session_outputs_config_t),
+                                session_outputs_config,
+                                NULL,
+                                NULL);
+            if (QAP_STATUS_OK != ret) {
+                ERROR_MSG("Unable to register AUDIO_DEVICE_OUT_HDMI device with QAP %d", ret);
+                return;
+            }
+        }
+        if (p_qap->qap_mod[DTS_M8].session_handle) {
+                ret = qap_session_cmd(p_qap->qap_mod[MS12].session_handle,
+                                    QAP_SESSION_CMD_SET_OUTPUTS,
+                                    sizeof(qap_session_outputs_config_t),
+                                    session_outputs_config,
+                                    NULL,
+                                    NULL);
+                if (QAP_STATUS_OK != ret) {
+                    ERROR_MSG("Unable to register AUDIO_DEVICE_OUT_HDMI device with QAP %d", ret);
+                    return;
+                }
+            }
+
+    }
+    DEBUG_MSG("Exit");
+}
+
+
+static void qap_set_default_configuration_to_module()
+{
+    qap_session_outputs_config_t *session_outputs_config = NULL;
+    int ret = 0;
+
+    DEBUG_MSG("Entry");
+
+    if (!p_qap) {
+        return;
+    }
+
+    if (!p_qap->bt_connect) {
+        DEBUG_MSG("BT is not connected.");
+    }
+
+    //ms12 wrapper don't support bt, treat this as speaker and routign to bt
+    //will take care as a part of data callback notifier
+
+
+    if (p_qap->qap_mod[MS12].session_handle)
+        session_outputs_config = &p_qap->qap_mod[MS12].session_outputs_config;
+    else if (p_qap->qap_mod[DTS_M8].session_handle)
+        session_outputs_config = &p_qap->qap_mod[DTS_M8].session_outputs_config;
+
+    session_outputs_config->num_output = 1;
+    session_outputs_config->output_config[0].id = AUDIO_DEVICE_OUT_SPEAKER;
+    session_outputs_config->output_config[0].format = QAP_AUDIO_FORMAT_PCM_16_BIT;
+
+
+    if (p_qap->qap_mod[MS12].session_handle) {
+        DEBUG_MSG(" Enabling speaker(PCM out) from MS12 wrapper outputid = %x", session_outputs_config->output_config[0].id);
+        ret = qap_session_cmd(p_qap->qap_mod[MS12].session_handle,
+                            QAP_SESSION_CMD_SET_OUTPUTS,
+                            sizeof(qap_session_outputs_config_t),
+                            session_outputs_config,
+                            NULL,
+                            NULL);
+        if (QAP_STATUS_OK != ret) {
+            ERROR_MSG("Unable to register AUDIO_DEVICE_OUT_SPEAKER device with QAP %d", ret);
+            return;
+        }
+    }
+    if (p_qap->qap_mod[DTS_M8].session_handle) {
+        ret = qap_session_cmd(p_qap->qap_mod[DTS_M8].session_handle,
+                            QAP_SESSION_CMD_SET_OUTPUTS,
+                            sizeof(qap_session_outputs_config_t),
+                            session_outputs_config,
+                            NULL,
+                            NULL);
+        if (QAP_STATUS_OK != ret) {
+            ERROR_MSG("Unable to register AUDIO_DEVICE_OUT_SPEAKER device with QAP %d", ret);
+            return;
+        }
+    }
+}
+
+
+/* Open a MM module session with QAP. */
+static int audio_extn_qap_session_open(mm_module_type mod_type, __unused struct stream_out *out)
+{
+    DEBUG_MSG("%s %d", __func__, __LINE__);
+    int ret = 0;
+
+    struct qap_module *qap_mod = NULL;
+
+    if (mod_type >= MAX_MM_MODULE_TYPE)
+        return -ENOTSUP; //Not supported by QAP module.
+
+    pthread_mutex_lock(&p_qap->lock);
+
+    qap_mod = &(p_qap->qap_mod[mod_type]);
+
+    //If session is already opened then return.
+    if (qap_mod->session_handle) {
+        DEBUG_MSG("QAP Session is already opened.");
+        pthread_mutex_unlock(&p_qap->lock);
+        return 0;
+    }
+
+    if (MS12 == mod_type) {
+        if (NULL == (qap_mod->session_handle = (void *)qap_session_open(QAP_SESSION_MS12_OTT, qap_mod->qap_lib))) {
+            ERROR_MSG("Failed to open QAP session, lib_handle 0x%x", (int)qap_mod->qap_lib);
+            ret = -EINVAL;
+            goto exit;
+        } else
+            DEBUG_MSG("Opened QAP session 0x%x", (int)qap_mod->session_handle);
+
+        update_qap_session_init_params(qap_mod->session_handle);
+    }
+
+    if (QAP_STATUS_OK != (qap_session_set_callback (qap_mod->session_handle, &qap_session_callback, (void *)qap_mod))) {
+        ERROR_MSG("Failed to register QAP session callback");
+        ret = -EINVAL;
+        goto exit;
+    }
+
+    qap_mod->is_session_output_active = true;
+
+    if(p_qap->hdmi_connect)
+        qap_set_hdmi_configuration_to_module();
+    else
+        qap_set_default_configuration_to_module();
+
+exit:
+    pthread_mutex_unlock(&p_qap->lock);
+    return ret;
+}
+
+
+
+static int qap_map_input_format(audio_format_t audio_format, qap_audio_format_t *format)
+{
+    if (audio_format == AUDIO_FORMAT_AC3) {
+        *format = QAP_AUDIO_FORMAT_AC3;
+        DEBUG_MSG( "File Format is AC3!");
+    } else if (audio_format == AUDIO_FORMAT_E_AC3) {
+        *format = QAP_AUDIO_FORMAT_EAC3;
+        DEBUG_MSG( "File Format is E_AC3!");
+    } else if ((audio_format == AUDIO_FORMAT_AAC_ADTS_LC) ||
+               (audio_format == AUDIO_FORMAT_AAC_ADTS_HE_V1) ||
+               (audio_format == AUDIO_FORMAT_AAC_ADTS_HE_V2) ||
+               (audio_format == AUDIO_FORMAT_AAC_LC) ||
+               (audio_format == AUDIO_FORMAT_AAC_HE_V1) ||
+               (audio_format == AUDIO_FORMAT_AAC_HE_V2) ||
+               (audio_format == AUDIO_FORMAT_AAC_LATM_LC) ||
+               (audio_format == AUDIO_FORMAT_AAC_LATM_HE_V1) ||
+               (audio_format == AUDIO_FORMAT_AAC_LATM_HE_V2)) {
+        *format = QAP_AUDIO_FORMAT_AAC_ADTS;
+        DEBUG_MSG( "File Format is AAC!");
+    } else if (audio_format == AUDIO_FORMAT_DTS) {
+        *format = QAP_AUDIO_FORMAT_DTS;
+        DEBUG_MSG( "File Format is DTS!");
+    } else if (audio_format == AUDIO_FORMAT_DTS_HD) {
+        *format = QAP_AUDIO_FORMAT_DTS_HD;
+        DEBUG_MSG( "File Format is DTS_HD!");
+    } else if (audio_format == AUDIO_FORMAT_PCM_16_BIT) {
+        *format = QAP_AUDIO_FORMAT_PCM_16_BIT;
+        DEBUG_MSG( "File Format is PCM_16!");
+    } else if (audio_format == AUDIO_FORMAT_PCM_32_BIT) {
+        *format = QAP_AUDIO_FORMAT_PCM_32_BIT;
+        DEBUG_MSG( "File Format is PCM_32!");
+    } else if (audio_format == AUDIO_FORMAT_PCM_24_BIT_PACKED) {
+        *format = QAP_AUDIO_FORMAT_PCM_24_BIT_PACKED;
+        DEBUG_MSG( "File Format is PCM_24!");
+    } else if ((audio_format == AUDIO_FORMAT_PCM_8_BIT) ||
+               (audio_format == AUDIO_FORMAT_PCM_8_24_BIT)) {
+        *format = QAP_AUDIO_FORMAT_PCM_8_24_BIT;
+        DEBUG_MSG( "File Format is PCM_8_24!");
+    } else {
+        ERROR_MSG( "File Format not supported!");
+        return -EINVAL;
+    }
+    return 0;
+}
+
+
+void qap_module_callback(__unused qap_module_handle_t module_handle,
+                         void* priv_data,
+                         qap_module_callback_event_t event_id,
+                         __unused int size,
+                         __unused void *data)
+{
+    struct stream_out *out=(struct stream_out *)priv_data;
+
+    DEBUG_MSG("Entry");
+    if (QAP_MODULE_CALLBACK_EVENT_SEND_INPUT_BUFFER == event_id) {
+        DEBUG_MSG("QAP_MODULE_CALLBACK_EVENT_SEND_INPUT_BUFFER for (%p)", out);
+        if (out->client_callback) {
+            out->client_callback(STREAM_CBK_EVENT_WRITE_READY, NULL, out->client_cookie);
+        }
+        else
+            DEBUG_MSG("client has no callback registered, no action needed for this event %d",
+                event_id);
+    }
+    else
+        DEBUG_MSG("Un Recognized event %d", event_id);
+
+    DEBUG_MSG("exit");
+    return;
+}
+
+
+/* opens a stream in QAP module. */
+static int qap_stream_open(struct stream_out *out,
+                           struct audio_config *config,
+                           audio_output_flags_t flags,
+                           audio_devices_t devices)
+{
+    int status = -EINVAL;
+    mm_module_type mmtype = get_mm_module_for_format_l(config->format);
+    struct qap_module* qap_mod = NULL;
+    qap_module_config_t input_config = {0};
+
+    DEBUG_MSG("Flags 0x%x, Device 0x%x for use case %s out 0x%x", flags, devices, use_case_table[out->usecase], (int)out);
+
+    if (mmtype >= MAX_MM_MODULE_TYPE) {
+        ERROR_MSG("Unsupported Stream");
+        return -ENOTSUP;
+    }
+
+    //Open the module session, if not opened already.
+    status = audio_extn_qap_session_open(mmtype, out);
+    qap_mod = &(p_qap->qap_mod[mmtype]);
+
+    if ((status != 0) || (!qap_mod->session_handle ))
+        return status;
+
+    input_config.sample_rate = config->sample_rate;
+    input_config.channels = popcount(config->channel_mask);
+    if (input_config.format != AUDIO_FORMAT_PCM_16_BIT) {
+        input_config.format &= AUDIO_FORMAT_MAIN_MASK;
+    }
+    input_config.module_type = QAP_MODULE_DECODER;
+    status = qap_map_input_format(config->format, &input_config.format);
+    if (status == -EINVAL)
+        return -EINVAL;
+
+    DEBUG_MSG("qap_stream_open sample_rate(%d) channels(%d) devices(%#x) flags(%#x) format(%#x)",
+              input_config.sample_rate, input_config.channels, devices, flags, input_config.format);
+
+    if (input_config.format == QAP_AUDIO_FORMAT_PCM_16_BIT) {
+        //If PCM stream is already opened then fail this stream open.
+        if (qap_mod->stream_in[QAP_IN_PCM]) {
+            ERROR_MSG("PCM input is already active.");
+            return -ENOTSUP;
+        }
+        input_config.flags = QAP_MODULE_FLAG_SYSTEM_SOUND;
+        status = qap_module_init(qap_mod->session_handle, &input_config, &out->qap_stream_handle);
+        if (QAP_STATUS_OK != status) {
+            ERROR_MSG("Unable to open PCM(QAP_MODULE_FLAG_SYSTEM_SOUND) QAP module %d", status);
+            return -EINVAL;
+        } else
+            DEBUG_MSG("QAP_MODULE_FLAG_SYSTEM_SOUND, module(ox%x) opened successfully", (int)out->qap_stream_handle);
+
+        qap_mod->stream_in[QAP_IN_PCM] = out;
+    } else if ((flags & AUDIO_OUTPUT_FLAG_MAIN) && (flags & AUDIO_OUTPUT_FLAG_ASSOCIATED)) {
+        if (is_main_active_l(qap_mod) || is_dual_main_active_l(qap_mod)) {
+            ERROR_MSG("Dual Main or Main already active. So, Cannot open main and associated stream");
+            return -EINVAL;
+        } else {
+            input_config.flags = QAP_MODULE_FLAG_PRIMARY;
+            status = qap_module_init(qap_mod->session_handle, &input_config, &out->qap_stream_handle);
+            if (QAP_STATUS_OK != status) {
+                ERROR_MSG("Unable to open QAP stream/module with QAP_MODULE_FLAG_PRIMARY flag %d", status);
+                return -EINVAL;
+                } else
+                    DEBUG_MSG("QAP_MODULE_FLAG_PRIMARY, module opened successfully 0x%x", (int)out->qap_stream_handle);;
+
+            qap_mod->stream_in[QAP_IN_MAIN] = out;
+        }
+    } else if ((flags & AUDIO_OUTPUT_FLAG_MAIN) || ((!(flags & AUDIO_OUTPUT_FLAG_MAIN)) && (!(flags & AUDIO_OUTPUT_FLAG_ASSOCIATED)))) {
+        /* Assume Main if no flag is set */
+        if (is_dual_main_active_l(qap_mod)) {
+            ERROR_MSG("Dual Main already active. So, Cannot open main stream");
+            return -EINVAL;
+        } else if (is_main_active_l(qap_mod) && qap_mod->stream_in[QAP_IN_ASSOC]) {
+            ERROR_MSG("Main and Associated already active. So, Cannot open main stream");
+            return -EINVAL;
+        } else if (is_main_active_l(qap_mod) && (mmtype != MS12)) {
+            ERROR_MSG("Main already active and Not an MS12 format. So, Cannot open another main stream");
+            return -EINVAL;
+        } else {
+            input_config.flags = QAP_MODULE_FLAG_PRIMARY;
+            status = qap_module_init(qap_mod->session_handle, &input_config, &out->qap_stream_handle);
+            if (QAP_STATUS_OK != status) {
+                ERROR_MSG("Unable to open QAP stream/module with QAP_MODULE_FLAG_PRIMARY flag %d", status);
+                return -EINVAL;
+            } else
+                DEBUG_MSG("QAP_MODULE_FLAG_PRIMARY, module opened successfully 0x%x", (int)out->qap_stream_handle);
+
+            if(qap_mod->stream_in[QAP_IN_MAIN]) {
+                qap_mod->stream_in[QAP_IN_MAIN_2] = out;
+            } else {
+                qap_mod->stream_in[QAP_IN_MAIN] = out;
+            }
+        }
+    } else if ((flags & AUDIO_OUTPUT_FLAG_ASSOCIATED)) {
+        if (is_dual_main_active_l(qap_mod)) {
+            ERROR_MSG("Dual Main already active. So, Cannot open associated stream");
+            return -EINVAL;
+        } else if (!is_main_active_l(qap_mod)) {
+            ERROR_MSG("Main not active. So, Cannot open associated stream");
+            return -EINVAL;
+        } else if (qap_mod->stream_in[QAP_IN_ASSOC]) {
+            ERROR_MSG("Associated already active. So, Cannot open associated stream");
+            return -EINVAL;
+        }
+        input_config.flags = QAP_MODULE_FLAG_SECONDARY;
+        status = qap_module_init(qap_mod->session_handle, &input_config, &out->qap_stream_handle);
+        if (QAP_STATUS_OK != status) {
+            ERROR_MSG("Unable to open QAP stream/module with QAP_MODULE_FLAG_SECONDARY flag %d", status);
+            return -EINVAL;
+        } else
+            DEBUG_MSG("QAP_MODULE_FLAG_SECONDARY, module opened successfully 0x%x", (int)out->qap_stream_handle);
+
+        qap_mod->stream_in[QAP_IN_ASSOC] = out;
+    }
+
+    if (out->qap_stream_handle) {
+        status = qap_module_set_callback(out->qap_stream_handle, &qap_module_callback, out);
+        if (QAP_STATUS_OK != status) {
+            ERROR_MSG("Unable to register module callback %d", status);
+            return -EINVAL;
+        } else
+            DEBUG_MSG("Module call back registered 0x%x cookie 0x%x", (int)out->qap_stream_handle, (int)out);
+    }
+
+    if (status != 0) {
+        //If no stream is active then close the session.
+        qap_sess_close(qap_mod);
+        return 0;
+    }
+
+    //If Device is HDMI, QAP passthrough is enabled and there is no previous QAP passthrough input stream.
+    if ((!p_qap->passthrough_in)
+        && (devices & AUDIO_DEVICE_OUT_AUX_DIGITAL)
+        && audio_extn_qap_passthrough_enabled(out)) {
+        //Assign the QAP passthrough input stream.
+        p_qap->passthrough_in = out;
+
+        //If HDMI is connected and format is supported by HDMI then create QAP passthrough output stream.
+        if (p_qap->hdmi_connect
+            && platform_is_edid_supported_format(p_qap->adev->platform, out->format)) {
+            status = create_qap_passthrough_stream_l();
+            if (status < 0) {
+                qap_stream_close(out);
+                ERROR_MSG("QAP passthrough stream creation failed with error %d", status);
+                return status;
+            }
+        }
+        /*Else: since QAP passthrough input stream is already initialized,
+         * when hdmi is connected
+         * then qap passthrough output stream will be created.
+         */
+    }
+
+    DEBUG_MSG();
+    return status;
+}
+
+static int qap_out_resume(struct audio_stream_out* stream)
+{
+    struct stream_out *out = (struct stream_out *)stream;
+    int status = 0;
+    DEBUG_MSG("Output Stream %p", out);
+
+
+    lock_output_stream_l(out);
+
+    //If QAP passthrough is active then block the resume on module input streams.
+    if (p_qap->passthrough_out) {
+        //If resume is received for the QAP passthrough stream then call the primary HAL api.
+        pthread_mutex_lock(&p_qap->lock);
+        if (p_qap->passthrough_in == out) {
+            status = p_qap->passthrough_out->stream.resume(
+                    (struct audio_stream_out*)p_qap->passthrough_out);
+            if (!status) out->offload_state = OFFLOAD_STATE_PLAYING;
+        }
+        pthread_mutex_unlock(&p_qap->lock);
+    } else {
+        //Flush the module input stream.
+        status = qap_stream_start_l(out);
+    }
+
+    unlock_output_stream_l(out);
+
+    DEBUG_MSG();
+    return status;
+}
+
+static int qap_out_set_parameters(struct audio_stream *stream, const char *kvpairs)
+{
+    struct str_parms *parms;
+    char value[32];
+    int val = 0;
+    struct stream_out *out = (struct stream_out *)stream;
+    int ret = 0;
+    int err = 0;
+    struct qap_module *qap_mod = NULL;
+
+    DEBUG_MSG("usecase(%d: %s) kvpairs: %s", out->usecase, use_case_table[out->usecase], kvpairs);
+
+    parms = str_parms_create_str(kvpairs);
+    err = str_parms_get_str(parms, AUDIO_PARAMETER_STREAM_ROUTING, value, sizeof(value));
+    if (err < 0)
+        return err;
+    val = atoi(value);
+
+    qap_mod = get_qap_module_for_input_stream_l(out);
+    if (!qap_mod) return (-EINVAL);
+
+    //TODO: HDMI is connected but user doesn't want HDMI output, close both HDMI outputs.
+
+    /* Setting new device information to the mm module input streams.
+     * This is needed if QAP module output streams are not created yet.
+     */
+    out->devices = val;
+
+#ifndef SPLIT_A2DP_ENABLED
+    if (val == AUDIO_DEVICE_OUT_BLUETOOTH_A2DP) {
+        //If device is BT then open the BT stream if not already opened.
+        if ( audio_extn_bt_hal_get_output_stream(qap_mod->bt_hdl) == NULL
+             && audio_extn_bt_hal_get_device(qap_mod->bt_hdl) != NULL) {
+            ret = audio_extn_bt_hal_open_output_stream(qap_mod->bt_hdl,
+                                                       QAP_OUTPUT_SAMPLING_RATE,
+                                                       AUDIO_CHANNEL_OUT_STEREO,
+                                                       CODEC_BACKEND_DEFAULT_BIT_WIDTH);
+            if (ret != 0) {
+                ERROR_MSG("BT Output stream open failure!");
+            }
+        }
+    } else if (val != 0) {
+        //If device is not BT then close the BT stream if already opened.
+        if ( audio_extn_bt_hal_get_output_stream(qap_mod->bt_hdl) != NULL) {
+            audio_extn_bt_hal_close_output_stream(qap_mod->bt_hdl);
+        }
+    }
+#endif
+
+    if (p_qap->passthrough_in == out) { //Device routing is received for QAP passthrough stream.
+
+        if (!(val & AUDIO_DEVICE_OUT_AUX_DIGITAL)) { //HDMI route is disabled.
+
+            //If QAP pasthrough output is enabled. Close it.
+            close_qap_passthrough_stream_l();
+
+            //Send the routing information to mm module pcm output.
+            if (qap_mod->stream_out[QAP_OUT_OFFLOAD]) {
+                ret = qap_mod->stream_out[QAP_OUT_OFFLOAD]->stream.common.set_parameters(
+                        (struct audio_stream *)qap_mod->stream_out[QAP_OUT_OFFLOAD], kvpairs);
+            }
+            //else: device info is updated in the input streams.
+        } else { //HDMI route is enabled.
+
+            //create the QAf passthrough stream, if not created already.
+            ret = create_qap_passthrough_stream_l();
+
+            if (p_qap->passthrough_out != NULL) { //If QAP passthrough out is enabled then send routing information.
+                ret = p_qap->passthrough_out->stream.common.set_parameters(
+                        (struct audio_stream *)p_qap->passthrough_out, kvpairs);
+            }
+        }
+    } else {
+        //Send the routing information to mm module pcm output.
+        if (qap_mod->stream_out[QAP_OUT_OFFLOAD]) {
+            ret = qap_mod->stream_out[QAP_OUT_OFFLOAD]->stream.common.set_parameters(
+                    (struct audio_stream *)qap_mod->stream_out[QAP_OUT_OFFLOAD], kvpairs);
+        }
+        //else: device info is updated in the input streams.
+    }
+    str_parms_destroy(parms);
+
+    return ret;
+}
+
+/* Checks if a stream is QAP stream or not. */
+bool audio_extn_is_qap_stream(struct stream_out *out)
+{
+    struct qap_module *qap_mod = get_qap_module_for_input_stream_l(out);
+
+    if (qap_mod) {
+        return true;
+    }
+    return false;
+}
+
+#if 0
+/* API to send playback stream specific config parameters */
+int audio_extn_qap_out_set_param_data(struct stream_out *out,
+                                       audio_extn_param_id param_id,
+                                       audio_extn_param_payload *payload)
+{
+    int ret = -EINVAL;
+    int index;
+    struct stream_out *new_out = NULL;
+    struct audio_adsp_event *adsp_event;
+    struct qap_module *qap_mod = get_qap_module_for_input_stream_l(out);
+
+    if (!out || !qap_mod || !payload) {
+        ERROR_MSG("Invalid Param");
+        return ret;
+    }
+
+    /* apply param for all active out sessions */
+    for (index = 0; index < MAX_QAP_MODULE_OUT; index++) {
+        new_out = qap_mod->stream_out[index];
+        if (!new_out) continue;
+
+        /*ADSP event is not supported for passthrough*/
+        if ((param_id == AUDIO_EXTN_PARAM_ADSP_STREAM_CMD)
+            && !(new_out->flags == AUDIO_OUTPUT_FLAG_DIRECT)) continue;
+        if (new_out->standby)
+            new_out->stream.write((struct audio_stream_out *)new_out, NULL, 0);
+        lock_output_stream_l(new_out);
+        ret = audio_extn_out_set_param_data(new_out, param_id, payload);
+        if (ret)
+            ERROR_MSG("audio_extn_out_set_param_data error %d", ret);
+        unlock_output_stream_l(new_out);
+    }
+    return ret;
+}
+
+int audio_extn_qap_out_get_param_data(struct stream_out *out,
+                             audio_extn_param_id param_id,
+                             audio_extn_param_payload *payload)
+{
+    int ret = -EINVAL, i;
+    struct stream_out *new_out = NULL;
+    struct qap_module *qap_mod = get_qap_module_for_input_stream_l(out);
+
+    if (!out || !qap_mod || !payload) {
+        ERROR_MSG("Invalid Param");
+        return ret;
+    }
+
+    if (!p_qap->hdmi_connect) {
+        ERROR_MSG("hdmi not connected");
+        return ret;
+    }
+
+    /* get session which is routed to hdmi*/
+    if (p_qap->passthrough_out)
+        new_out = p_qap->passthrough_out;
+    else {
+        for (i = 0; i < MAX_QAP_MODULE_OUT; i++) {
+            if (qap_mod->stream_out[i]) {
+                new_out = qap_mod->stream_out[i];
+                break;
+            }
+        }
+    }
+
+    if (!new_out) {
+        ERROR_MSG("No stream active.");
+        return ret;
+    }
+
+    if (new_out->standby)
+        new_out->stream.write((struct audio_stream_out *)new_out, NULL, 0);
+
+    lock_output_stream_l(new_out);
+    ret = audio_extn_out_get_param_data(new_out, param_id, payload);
+    if (ret)
+        ERROR_MSG("audio_extn_out_get_param_data error %d", ret);
+    unlock_output_stream_l(new_out);
+
+    return ret;
+}
+#endif
+
+int audio_extn_qap_open_output_stream(struct audio_hw_device *dev,
+                                      audio_io_handle_t handle,
+                                      audio_devices_t devices,
+                                      audio_output_flags_t flags,
+                                      struct audio_config *config,
+                                      struct audio_stream_out **stream_out,
+                                      const char *address)
+{
+    int ret = 0;
+    struct stream_out *out;
+
+    DEBUG_MSG("Entry");
+    ret = adev_open_output_stream(dev, handle, devices, flags, config, stream_out, address);
+    if (*stream_out == NULL) {
+        ERROR_MSG("Stream open failed %d", ret);
+        return ret;
+    }
+
+#ifndef LINUX_ENABLED
+//Bypass QAP for dummy PCM session opened by APM during boot time
+    if(flags == 0) {
+        ALOGD("bypassing QAP for flags is equal to none");
+        return ret;
+    }
+#endif
+
+    out = (struct stream_out *)*stream_out;
+
+    DEBUG_MSG("%s 0x%x", use_case_table[out->usecase], (int)out);
+
+    ret = qap_stream_open(out, config, flags, devices);
+    if (ret < 0) {
+        ERROR_MSG("Error opening QAP stream err[%d]", ret);
+        //Stream not supported by QAP, Bypass QAP.
+        return 0;
+    }
+
+    /* Override function pointers based on qap definitions */
+    out->stream.set_volume = qap_out_set_volume;
+    out->stream.pause = qap_out_pause;
+    out->stream.resume = qap_out_resume;
+    out->stream.drain = qap_out_drain;
+    out->stream.flush = qap_out_flush;
+
+    out->stream.common.standby = qap_out_standby;
+    out->stream.common.set_parameters = qap_out_set_parameters;
+    out->stream.get_latency = qap_out_get_latency;
+    out->stream.get_render_position = qap_out_get_render_position;
+    out->stream.write = qap_out_write;
+    out->stream.get_presentation_position = qap_out_get_presentation_position;
+    out->platform_latency = 0;
+
+    /*TODO: Need to handle this for DTS*/
+    if (out->usecase == USECASE_AUDIO_PLAYBACK_LOW_LATENCY) {
+        out->usecase = USECASE_AUDIO_PLAYBACK_DEEP_BUFFER;
+        out->config.period_size = QAP_DEEP_BUFFER_OUTPUT_PERIOD_SIZE;
+        out->config.period_count = DEEP_BUFFER_OUTPUT_PERIOD_COUNT;
+        out->config.start_threshold = QAP_DEEP_BUFFER_OUTPUT_PERIOD_SIZE / 4;
+        out->config.avail_min = QAP_DEEP_BUFFER_OUTPUT_PERIOD_SIZE / 4;
+    } else if(out->flags == AUDIO_OUTPUT_FLAG_DIRECT) {
+        out->compr_config.fragment_size = qap_get_pcm_offload_input_buffer_size(&(config->offload_info));
+    }
+
+    *stream_out = &out->stream;
+
+    DEBUG_MSG("Exit");
+    return 0;
+}
+
+void audio_extn_qap_close_output_stream(struct audio_hw_device *dev,
+                                        struct audio_stream_out *stream)
+{
+    struct stream_out *out = (struct stream_out *)stream;
+    struct qap_module* qap_mod = get_qap_module_for_input_stream_l(out);
+
+    DEBUG_MSG("%s 0x%x", use_case_table[out->usecase], (int)out);
+
+    if (!qap_mod) {
+        DEBUG_MSG("qap module is NULL, nothing to close");
+        /*closing non-MS12/default output stream opened with qap */
+        adev_close_output_stream(dev, stream);
+        return;
+    }
+
+    DEBUG_MSG("stream_handle(%p) format = %x", out, out->format);
+
+    //If close is received for QAP passthrough stream then close the QAP passthrough output.
+    if (p_qap->passthrough_in == out) {
+        if (p_qap->passthrough_out) {
+            ALOGD("%s %d closing stream handle %p", __func__, __LINE__, p_qap->passthrough_out);
+            pthread_mutex_lock(&p_qap->lock);
+            adev_close_output_stream((struct audio_hw_device *)p_qap->adev,
+                                     (struct audio_stream_out *)(p_qap->passthrough_out));
+            pthread_mutex_unlock(&p_qap->lock);
+            p_qap->passthrough_out = NULL;
+        }
+
+        p_qap->passthrough_in = NULL;
+    }
+
+    qap_stream_close(out);
+
+    adev_close_output_stream(dev, stream);
+
+    DEBUG_MSG("Exit");
+}
+
+/* Check if QAP is supported or not. */
+bool audio_extn_qap_is_enabled()
+{
+    bool prop_enabled = false;
+    char value[PROPERTY_VALUE_MAX] = {0};
+    property_get("vendor.audio.qap.enabled", value, NULL);
+    prop_enabled = atoi(value) || !strncmp("true", value, 4);
+    return (prop_enabled);
+}
+
+/* QAP set parameter function. For Device connect and disconnect. */
+int audio_extn_qap_set_parameters(struct audio_device *adev, struct str_parms *parms)
+{
+    int status = 0, val = 0;
+    qap_session_outputs_config_t *session_outputs_config = NULL;
+
+    if (!p_qap) {
+        return -EINVAL;
+    }
+
+    DEBUG_MSG("Entry");
+
+    status = str_parms_get_int(parms, AUDIO_PARAMETER_DEVICE_CONNECT, &val);
+
+    if ((status >= 0) && audio_is_output_device(val)) {
+        if (val & AUDIO_DEVICE_OUT_AUX_DIGITAL) { //HDMI is connected.
+            DEBUG_MSG("AUDIO_DEVICE_OUT_AUX_DIGITAL connected");
+            p_qap->hdmi_connect = 1;
+            p_qap->hdmi_sink_channels = 0;
+
+            if (p_qap->passthrough_in) { //If QAP passthrough is already initialized.
+                lock_output_stream_l(p_qap->passthrough_in);
+                if (platform_is_edid_supported_format(adev->platform,
+                                                      p_qap->passthrough_in->format)) {
+                    //If passthrough format is supported by HDMI then create the QAP passthrough output if not created already.
+                    create_qap_passthrough_stream_l();
+                    //Ignoring the returned error, If error then QAP passthrough is disabled.
+                } else {
+                    //If passthrough format is not supported by HDMI then close the QAP passthrough output if already created.
+                    close_qap_passthrough_stream_l();
+                }
+                unlock_output_stream_l(p_qap->passthrough_in);
+            }
+
+            qap_set_hdmi_configuration_to_module();
+
+        } else if (val & AUDIO_DEVICE_OUT_BLUETOOTH_A2DP) {
+            DEBUG_MSG("AUDIO_DEVICE_OUT_BLUETOOTH_A2DP connected");
+            p_qap->bt_connect = 1;
+            qap_set_default_configuration_to_module();
+#ifndef SPLIT_A2DP_ENABLED
+            for (k = 0; k < MAX_MM_MODULE_TYPE; k++) {
+                if (!p_qap->qap_mod[k].bt_hdl) {
+                    DEBUG_MSG("Opening a2dp output...");
+                    status = audio_extn_bt_hal_load(&p_qap->qap_mod[k].bt_hdl);
+                    if (status != 0) {
+                        ERROR_MSG("Error opening BT module");
+                        return status;
+                    }
+                }
+            }
+#endif
+        }
+        //TODO else if: Need to consider other devices.
+    }
+
+    status = str_parms_get_int(parms, AUDIO_PARAMETER_DEVICE_DISCONNECT, &val);
+    if ((status >= 0) && audio_is_output_device(val)) {
+        DEBUG_MSG("AUDIO_DEVICE_OUT_AUX_DIGITAL disconnected");
+        if (val & AUDIO_DEVICE_OUT_AUX_DIGITAL) {
+
+            p_qap->hdmi_sink_channels = 0;
+
+            p_qap->passthrough_enabled = 0;
+            p_qap->mch_pcm_hdmi_enabled = 0;
+            p_qap->hdmi_connect = 0;
+
+            if (p_qap->qap_mod[MS12].session_handle)
+                session_outputs_config = &p_qap->qap_mod[MS12].session_outputs_config;
+            else if (p_qap->qap_mod[DTS_M8].session_handle)
+                session_outputs_config = &p_qap->qap_mod[DTS_M8].session_outputs_config;
+            else {
+                DEBUG_MSG("HDMI disconnection comes even before session is setup");
+                return 0;
+            }
+
+            session_outputs_config->num_output = 1;
+
+            session_outputs_config->output_config[0].id = AUDIO_DEVICE_OUT_SPEAKER;
+            session_outputs_config->output_config[0].format = QAP_AUDIO_FORMAT_PCM_16_BIT;
+
+
+            if (p_qap->qap_mod[MS12].session_handle) {
+                DEBUG_MSG(" Enabling speaker(PCM out) from MS12 wrapper outputid = %x", session_outputs_config->output_config[0].id);
+                status = qap_session_cmd(p_qap->qap_mod[MS12].session_handle,
+                                    QAP_SESSION_CMD_SET_OUTPUTS,
+                                    sizeof(qap_session_outputs_config_t),
+                                    session_outputs_config,
+                                    NULL,
+                                    NULL);
+                if (QAP_STATUS_OK != status) {
+                    ERROR_MSG("Unable to register AUDIO_DEVICE_OUT_SPEAKER device with QAP %d",status);
+                    return -EINVAL;
+                }
+            }
+            if (p_qap->qap_mod[DTS_M8].session_handle) {
+                status = qap_session_cmd(p_qap->qap_mod[MS12].session_handle,
+                                    QAP_SESSION_CMD_SET_OUTPUTS,
+                                    sizeof(qap_session_outputs_config_t),
+                                    session_outputs_config,
+                                    NULL,
+                                    NULL);
+                if (QAP_STATUS_OK != status) {
+                    ERROR_MSG("Unable to register AUDIO_DEVICE_OUT_SPEAKER device with QAP %d", status);
+                    return -EINVAL;
+                }
+            }
+
+            close_all_hdmi_output_l();
+            close_qap_passthrough_stream_l();
+        } else if (val & AUDIO_DEVICE_OUT_BLUETOOTH_A2DP) {
+            DEBUG_MSG("AUDIO_DEVICE_OUT_BLUETOOTH_A2DP disconnected");
+            p_qap->bt_connect = 0;
+            //reconfig HDMI as end device (if connected)
+            if(p_qap->hdmi_connect)
+                qap_set_hdmi_configuration_to_module();
+#ifndef SPLIT_A2DP_ENABLED
+            DEBUG_MSG("Closing a2dp output...");
+            for (k = 0; k < MAX_MM_MODULE_TYPE; k++) {
+                if (p_qap->qap_mod[k].bt_hdl) {
+                    audio_extn_bt_hal_unload(p_qap->qap_mod[k].bt_hdl);
+                    p_qap->qap_mod[k].bt_hdl = NULL;
+                }
+            }
+#endif
+        }
+        //TODO else if: Need to consider other devices.
+    }
+
+#if 0
+    /* does this need to be ported to QAP?*/
+    for (k = 0; k < MAX_MM_MODULE_TYPE; k++) {
+        kv_parirs = str_parms_to_str(parms);
+        if (p_qap->qap_mod[k].session_handle) {
+            p_qap->qap_mod[k].qap_audio_session_set_param(
+                    p_qap->qap_mod[k].session_handle, kv_parirs);
+        }
+    }
+#endif
+
+    DEBUG_MSG("Exit");
+    return status;
+}
+
+/* Create the QAP. */
+int audio_extn_qap_init(struct audio_device *adev)
+{
+    DEBUG_MSG("Entry");
+
+    p_qap = calloc(1, sizeof(struct qap));
+    if (p_qap == NULL) {
+        ERROR_MSG("Out of memory");
+        return -ENOMEM;
+    }
+
+    p_qap->adev = adev;
+
+    if (property_get_bool("vendor.audio.qap.msmd", false)) {
+        DEBUG_MSG("MSMD enabled.");
+        p_qap->qap_msmd_enabled = 1;
+    }
+
+    if (property_get_bool("vendor.audio.qap.output.block.handling", false)) {
+        DEBUG_MSG("out put thread blocking handling enabled.");
+        p_qap->qap_output_block_handling = 1;
+    }
+    pthread_mutex_init(&p_qap->lock, (const pthread_mutexattr_t *) NULL);
+
+    int i = 0;
+
+    for (i = 0; i < MAX_MM_MODULE_TYPE; i++) {
+        char value[PROPERTY_VALUE_MAX] = {0};
+        char lib_name[PROPERTY_VALUE_MAX] = {0};
+        struct qap_module *qap_mod = &(p_qap->qap_mod[i]);
+
+        if (i == MS12) {
+            property_get("vendor.audio.qap.library", value, NULL);
+            snprintf(lib_name, PROPERTY_VALUE_MAX, "%s", value);
+
+            DEBUG_MSG("Opening Ms12 library at %s", lib_name);
+           qap_mod->qap_lib = ( void *) qap_load_library(lib_name);
+            if (qap_mod->qap_lib == NULL) {
+                ERROR_MSG("qap load lib failed for MS12 %s", lib_name);
+                continue;
+            }
+            DEBUG_MSG("Loaded QAP lib at %s", lib_name);
+            pthread_mutex_init(&qap_mod->session_output_lock, (const pthread_mutexattr_t *) NULL);
+            pthread_cond_init(&qap_mod->session_output_cond, (const pthread_condattr_t *)NULL);
+        } else if (i == DTS_M8) {
+            property_get("vendor.audio.qap.m8.library", value, NULL);
+            snprintf(lib_name, PROPERTY_VALUE_MAX, "%s", value);
+            qap_mod->qap_lib = dlopen(lib_name, RTLD_NOW);
+            if (qap_mod->qap_lib == NULL) {
+                ERROR_MSG("DLOPEN failed for DTS M8 %s", lib_name);
+                continue;
+            }
+            DEBUG_MSG("DLOPEN successful for %s", lib_name);
+            pthread_mutex_init(&qap_mod->session_output_lock, (const pthread_mutexattr_t *) NULL);
+            pthread_cond_init(&qap_mod->session_output_cond, (const pthread_condattr_t *)NULL);
+        } else {
+            continue;
+        }
+    }
+
+    DEBUG_MSG("Exit");
+    return 0;
+}
+
+/* Tear down the qap extension. */
+void audio_extn_qap_deinit()
+{
+    int i;
+    DEBUG_MSG("Entry");
+    char value[PROPERTY_VALUE_MAX] = {0};
+    char lib_name[PROPERTY_VALUE_MAX] = {0};
+
+    if (p_qap != NULL) {
+        for (i = 0; i < MAX_MM_MODULE_TYPE; i++) {
+            if (p_qap->qap_mod[i].session_handle != NULL)
+                qap_sess_close(&p_qap->qap_mod[i]);
+
+            if (p_qap->qap_mod[i].qap_lib != NULL) {
+                if (i == MS12) {
+                    property_get("vendor.audio.qap.library", value, NULL);
+                    snprintf(lib_name, PROPERTY_VALUE_MAX, "%s", value);
+                    DEBUG_MSG("lib_name %s", lib_name);
+                    if (QAP_STATUS_OK != qap_unload_library(p_qap->qap_mod[i].qap_lib))
+                        ERROR_MSG("Failed to unload MS12 library lib name %s", lib_name);
+                    else
+                        DEBUG_MSG("closed/unloaded QAP lib at %s", lib_name);
+                    p_qap->qap_mod[i].qap_lib = NULL;
+                } else {
+                    dlclose(p_qap->qap_mod[i].qap_lib);
+                    p_qap->qap_mod[i].qap_lib = NULL;
+                }
+                pthread_mutex_destroy(&p_qap->qap_mod[i].session_output_lock);
+                pthread_cond_destroy(&p_qap->qap_mod[i].session_output_cond);
+            }
+        }
+
+        if (p_qap->passthrough_out) {
+            adev_close_output_stream((struct audio_hw_device *)p_qap->adev,
+                                     (struct audio_stream_out *)(p_qap->passthrough_out));
+            p_qap->passthrough_out = NULL;
+        }
+
+        pthread_mutex_destroy(&p_qap->lock);
+        free(p_qap);
+        p_qap = NULL;
+    }
+    DEBUG_MSG("Exit");
+}
diff --git a/hal/audio_extn/soundtrigger.c b/hal/audio_extn/soundtrigger.c
index a07796a..aa13c2b 100644
--- a/hal/audio_extn/soundtrigger.c
+++ b/hal/audio_extn/soundtrigger.c
@@ -84,6 +84,7 @@
     AUDIO_EVENT_CAPTURE_STREAM_INACTIVE,
     AUDIO_EVENT_CAPTURE_STREAM_ACTIVE,
     AUDIO_EVENT_BATTERY_STATUS_CHANGED,
+    AUDIO_EVENT_SCREEN_STATUS_CHANGED,
     AUDIO_EVENT_GET_PARAM,
     AUDIO_EVENT_UPDATE_ECHO_REF
 } audio_event_type_t;
@@ -605,6 +606,17 @@
     st_dev->st_callback(AUDIO_EVENT_BATTERY_STATUS_CHANGED, &ev_info);
 }
 
+void audio_extn_sound_trigger_update_screen_status(bool screen_off)
+{
+    struct audio_event_info ev_info = {{0}, {0}};
+
+    if (!st_dev)
+        return;
+
+    ev_info.u.value = screen_off;
+    st_dev->st_callback(AUDIO_EVENT_SCREEN_STATUS_CHANGED, &ev_info);
+}
+
 
 void audio_extn_sound_trigger_set_parameters(struct audio_device *adev __unused,
                                struct str_parms *params)
diff --git a/hal/audio_extn/usb.c b/hal/audio_extn/usb.c
index e6859fe..c1ee008 100644
--- a/hal/audio_extn/usb.c
+++ b/hal/audio_extn/usb.c
@@ -395,6 +395,7 @@
         return -1;
     }
     memcpy(tmp, interval_str_start, eol-interval_str_start);
+    tmp[eol-interval_str_start] = '\0';
     sscanf(tmp, "%lu %2s", &interval, &time_unit[0]);
     if (!strcmp(time_unit, "us")) {
         multiplier = 1;
@@ -628,6 +629,7 @@
     int32_t fd=-1;
     char path[128];
     int ret = 0;
+    char *saveptr = NULL;
 
     memset(usb_card_info->usbid, 0, sizeof(usb_card_info->usbid));
 
@@ -655,7 +657,7 @@
         goto done;
     }
 
-    strtok(usb_card_info->usbid, "\n");
+    strtok_r(usb_card_info->usbid, "\n", &saveptr);
 
 done:
     if (fd >= 0)
diff --git a/hal/audio_extn/utils.c b/hal/audio_extn/utils.c
index ea0d324..30bc10d 100644
--- a/hal/audio_extn/utils.c
+++ b/hal/audio_extn/utils.c
@@ -37,6 +37,7 @@
 #include "platform.h"
 #include "platform_api.h"
 #include "audio_extn.h"
+#include "voice_extn.h"
 #include "voice.h"
 #include <sound/compress_params.h>
 #include <sound/compress_offload.h>
@@ -1140,7 +1141,8 @@
         (usecase->id != USECASE_AUDIO_TRANSCODE_LOOPBACK_RX) &&
         (!is_interactive_usecase(usecase->id)) &&
         (!is_offload_usecase(usecase->id)) &&
-        (usecase->type != PCM_CAPTURE)) {
+        (usecase->type != PCM_CAPTURE) &&
+        (!audio_extn_auto_hal_is_bus_device_usecase(usecase->id))) {
         ALOGV("%s: a rx/tx/loopback path where app type cfg is not required %d", __func__, usecase->id);
         rc = 0;
         goto exit_send_app_type_cfg;
@@ -1248,6 +1250,88 @@
     return rc;
 }
 
+static int audio_extn_utils_check_input_parameters(uint32_t sample_rate,
+                                  audio_format_t format,
+                                  int channel_count)
+{
+    int ret = 0;
+
+    if (((format != AUDIO_FORMAT_PCM_16_BIT) && (format != AUDIO_FORMAT_PCM_8_24_BIT) &&
+        (format != AUDIO_FORMAT_PCM_24_BIT_PACKED) && (format != AUDIO_FORMAT_PCM_32_BIT) &&
+        (format != AUDIO_FORMAT_PCM_FLOAT)) &&
+        !voice_extn_compress_voip_is_format_supported(format) &&
+        !audio_extn_compr_cap_format_supported(format) &&
+        !audio_extn_cin_format_supported(format))
+            ret = -EINVAL;
+
+    switch (channel_count) {
+    case 1:
+    case 2:
+    case 3:
+    case 4:
+    case 6:
+    case 8:
+        break;
+    default:
+        ret = -EINVAL;
+    }
+
+    switch (sample_rate) {
+    case 8000:
+    case 11025:
+    case 12000:
+    case 16000:
+    case 22050:
+    case 24000:
+    case 32000:
+    case 44100:
+    case 48000:
+    case 88200:
+    case 96000:
+    case 176400:
+    case 192000:
+        break;
+    default:
+        ret = -EINVAL;
+    }
+
+    return ret;
+}
+
+static inline uint32_t audio_extn_utils_nearest_multiple(uint32_t num, uint32_t multiplier)
+{
+    uint32_t remainder = 0;
+
+    if (!multiplier)
+        return num;
+
+    remainder = num % multiplier;
+    if (remainder)
+        num += (multiplier - remainder);
+
+    return num;
+}
+
+static inline uint32_t audio_extn_utils_lcm(uint32_t num1, uint32_t num2)
+{
+    uint32_t high = num1, low = num2, temp = 0;
+
+    if (!num1 || !num2)
+        return 0;
+
+    if (num1 < num2) {
+         high = num2;
+         low = num1;
+    }
+
+    while (low != 0) {
+        temp = low;
+        low = high % low;
+        high = temp;
+    }
+    return (num1 * num2)/high;
+}
+
 int audio_extn_utils_send_app_type_cfg(struct audio_device *adev,
                                        struct audio_usecase *usecase)
 {
@@ -1441,11 +1525,15 @@
 
 uint32_t get_alsa_fragment_size(uint32_t bytes_per_sample,
                                   uint32_t sample_rate,
-                                  uint32_t noOfChannels)
+                                  uint32_t noOfChannels,
+                                  int64_t duration_ms)
 {
     uint32_t fragment_size = 0;
     uint32_t pcm_offload_time = PCM_OFFLOAD_BUFFER_DURATION;
 
+    if (duration_ms >= MIN_OFFLOAD_BUFFER_DURATION_MS && duration_ms <= MAX_OFFLOAD_BUFFER_DURATION_MS)
+        pcm_offload_time = duration_ms;
+
     fragment_size = (pcm_offload_time
                      * sample_rate
                      * bytes_per_sample
@@ -1480,7 +1568,8 @@
     out->compr_config.fragment_size =
              get_alsa_fragment_size(hal_op_bytes_per_sample,
                                       out->sample_rate,
-                                      popcount(out->channel_mask));
+                                      popcount(out->channel_mask),
+                                      out->info.duration_us / 1000);
 
     if ((src_format != dst_format) &&
          hal_op_bytes_per_sample != hal_ip_bytes_per_sample) {
@@ -2859,3 +2948,51 @@
 
     return is_running_with_enhanced_fwk;
 }
+
+int audio_extn_utils_get_perf_mode_flag(void)
+{
+#ifdef COMPRESSED_PERF_MODE_FLAG
+    return COMPRESSED_PERF_MODE_FLAG;
+#else
+    return 0;
+#endif
+}
+
+size_t audio_extn_utils_get_input_buffer_size(uint32_t sample_rate,
+                                            audio_format_t format,
+                                            int channel_count,
+                                            int64_t duration_ms,
+                                            bool is_low_latency)
+{
+    size_t size = 0;
+    size_t capture_duration = AUDIO_CAPTURE_PERIOD_DURATION_MSEC;
+    uint32_t bytes_per_period_sample = 0;
+
+
+    if (audio_extn_utils_check_input_parameters(sample_rate, format, channel_count) != 0)
+        return 0;
+
+    if (duration_ms >= MIN_OFFLOAD_BUFFER_DURATION_MS && duration_ms <= MAX_OFFLOAD_BUFFER_DURATION_MS)
+        capture_duration = duration_ms;
+
+    size = (sample_rate * capture_duration) / 1000;
+    if (is_low_latency)
+        size = LOW_LATENCY_CAPTURE_PERIOD_SIZE;
+
+
+    bytes_per_period_sample = audio_bytes_per_sample(format) * channel_count;
+    size *= bytes_per_period_sample;
+
+    /* make sure the size is multiple of 32 bytes and additionally multiple of
+     * the frame_size (required for 24bit samples and non-power-of-2 channel counts)
+     * At 48 kHz mono 16-bit PCM:
+     *  5.000 ms = 240 frames = 15*16*1*2 = 480, a whole multiple of 32 (15)
+     *  3.333 ms = 160 frames = 10*16*1*2 = 320, a whole multiple of 32 (10)
+     *
+     *  The loop reaches result within 32 iterations, as initial size is
+     *  already a multiple of frame_size
+     */
+    size = audio_extn_utils_nearest_multiple(size, audio_extn_utils_lcm(32, bytes_per_period_sample));
+
+    return size;
+}
diff --git a/hal/audio_hw.c b/hal/audio_hw.c
index a5df951..71f62a7 100644
--- a/hal/audio_hw.c
+++ b/hal/audio_hw.c
@@ -400,7 +400,12 @@
 
     [USECASE_AUDIO_EC_REF_LOOPBACK] = "ec-ref-audio-capture",
 
-    [USECASE_AUDIO_A2DP_ABR_FEEDBACK] = "a2dp-abr-feedback"
+    [USECASE_AUDIO_A2DP_ABR_FEEDBACK] = "a2dp-abr-feedback",
+
+    [USECASE_AUDIO_PLAYBACK_MEDIA] = "media-playback",
+    [USECASE_AUDIO_PLAYBACK_SYS_NOTIFICATION] = "sys-notification-playback",
+    [USECASE_AUDIO_PLAYBACK_NAV_GUIDANCE] = "nav-guidance-playback",
+    [USECASE_AUDIO_PLAYBACK_PHONE] = "phone-playback",
 };
 
 static const audio_usecase_t offload_usecases[] = {
@@ -483,6 +488,11 @@
     STRING_TO_ENUM(192000),
 };
 
+struct in_effect_list {
+    struct listnode list;
+    effect_handle_t handle;
+};
+
 static struct audio_device *adev = NULL;
 static pthread_mutex_t adev_init_lock = PTHREAD_MUTEX_INITIALIZER;
 static unsigned int audio_device_ref_count;
@@ -511,7 +521,6 @@
                                            audio_microphone_direction_t dir);
 static int in_set_microphone_field_dimension(const struct audio_stream_in *stream, float zoom);
 
-
 static bool may_use_noirq_mode(struct audio_device *adev, audio_usecase_t uc_id,
                                int flags __unused)
 {
@@ -923,7 +932,12 @@
     char mixer_ctl_name[] = "Audio Effect";
     struct mixer_ctl *ctl;
     long set_values[6];
-    struct stream_in *in = adev->active_input;
+    struct stream_in *in = adev_get_active_input(adev);
+
+    if (in == NULL) {
+        ALOGE("%s: active input stream is NULL", __func__);
+        return -EINVAL;
+    }
 
     ctl = mixer_get_ctl_by_name(adev->mixer, mixer_ctl_name);
     if (!ctl) {
@@ -951,7 +965,12 @@
     int ret = 0;
     struct audio_effect_config other_effect_config;
     struct audio_usecase *usecase = NULL;
-    struct stream_in *in = adev->active_input;
+    struct stream_in *in = adev_get_active_input(adev);
+
+    if (in == NULL) {
+        ALOGE("%s: active input stream is NULL", __func__);
+        return -EINVAL;
+    }
 
     usecase = get_usecase_from_list(adev, in->usecase);
     if (!usecase)
@@ -981,7 +1000,7 @@
     struct audio_usecase *usecase = NULL;
     int ret = 0;
     unsigned int param_value = 0;
-    struct stream_in *in = adev->active_input;
+    struct stream_in *in = adev_get_active_input(adev);
 
     if(!voice_extn_is_dynamic_ecns_enabled())
         return ENOSYS;
@@ -1030,13 +1049,16 @@
     if(!voice_extn_is_dynamic_ecns_enabled())
         return;
 
-    if (adev->active_input->enable_aec) {
-        enable_disable_effect(adev, EFFECT_AEC, true);
-    }
+    struct stream_in *in = adev_get_active_input(adev);
 
-    if (adev->active_input->enable_ns &&
-        adev->active_input->source == AUDIO_SOURCE_VOICE_COMMUNICATION) {
-        enable_disable_effect(adev, EFFECT_NS, true);
+    if (in != NULL && !in->standby) {
+        if (in->enable_aec)
+            enable_disable_effect(adev, EFFECT_AEC, true);
+
+        if (in->enable_ns &&
+            in->source == AUDIO_SOURCE_VOICE_COMMUNICATION) {
+            enable_disable_effect(adev, EFFECT_NS, true);
+        }
     }
 }
 
@@ -1059,6 +1081,7 @@
     snd_device_t snd_device;
     char mixer_path[MIXER_PATH_MAX_LENGTH];
     struct stream_out *out = NULL;
+    struct stream_in *in = NULL;
     int ret = 0;
 
     if (usecase == NULL)
@@ -1066,10 +1089,40 @@
 
     ALOGV("%s: enter: usecase(%d)", __func__, usecase->id);
 
-    if (usecase->type == PCM_CAPTURE || usecase->type == TRANSCODE_LOOPBACK_TX)
+    if (usecase->type == PCM_CAPTURE) {
+        struct stream_in *in = usecase->stream.in;
+        struct audio_usecase *uinfo;
         snd_device = usecase->in_snd_device;
-    else
+
+        if (in) {
+            if (in->enable_aec || in->enable_ec_port) {
+                audio_devices_t out_device = AUDIO_DEVICE_OUT_SPEAKER;
+                struct listnode *node;
+                struct audio_usecase *voip_usecase = get_usecase_from_list(adev,
+                                                           USECASE_AUDIO_PLAYBACK_VOIP);
+                if (voip_usecase) {
+                    out_device = voip_usecase->stream.out->devices;
+                } else if (adev->primary_output &&
+                              !adev->primary_output->standby) {
+                    out_device = adev->primary_output->devices;
+                } else {
+                    list_for_each(node, &adev->usecase_list) {
+                        uinfo = node_to_item(node, struct audio_usecase, list);
+                        if (uinfo->type != PCM_CAPTURE) {
+                            out_device = uinfo->stream.out->devices;
+                            break;
+                        }
+                    }
+                }
+                platform_set_echo_reference(adev, true, out_device);
+                in->ec_opened = true;
+            }
+        }
+    } else if (usecase->type == TRANSCODE_LOOPBACK_TX) {
+        snd_device = usecase->in_snd_device;
+    } else {
         snd_device = usecase->out_snd_device;
+    }
 
 #ifdef DS1_DOLBY_DAP_ENABLED
     audio_extn_dolby_set_dmid(adev);
@@ -1087,7 +1140,16 @@
         if (out && out->compr)
             audio_extn_utils_compress_set_clk_rec_mode(usecase);
     }
-    audio_extn_set_custom_mtmx_params(adev, usecase, true);
+
+    if (usecase->type == PCM_CAPTURE) {
+        in = usecase->stream.in;
+        if (in && is_loopback_input_device(in->device)) {
+            ALOGD("%s: set custom mtmx params v1", __func__);
+            audio_extn_set_custom_mtmx_params_v1(adev, usecase, true);
+        }
+    } else {
+        audio_extn_set_custom_mtmx_params_v2(adev, usecase, true);
+    }
 
     // we shouldn't truncate mixer_path
     ALOGW_IF(strlcpy(mixer_path, use_case_table[usecase->id], sizeof(mixer_path))
@@ -1112,6 +1174,7 @@
 {
     snd_device_t snd_device;
     char mixer_path[MIXER_PATH_MAX_LENGTH];
+    struct stream_in *in = NULL;
 
     if (usecase == NULL || usecase->id == USECASE_INVALID)
         return -EINVAL;
@@ -1128,12 +1191,30 @@
     platform_add_backend_name(mixer_path, snd_device, usecase);
     ALOGD("%s: reset and update mixer path: %s", __func__, mixer_path);
     audio_route_reset_and_update_path(adev->audio_route, mixer_path);
+    if (usecase->type == PCM_CAPTURE) {
+        struct stream_in *in = usecase->stream.in;
+        if (in && in->ec_opened) {
+            platform_set_echo_reference(in->dev, false, AUDIO_DEVICE_NONE);
+            in->ec_opened = false;
+        }
+    }
     audio_extn_sound_trigger_update_stream_status(usecase, ST_EVENT_STREAM_FREE);
     audio_extn_listen_update_stream_status(usecase, LISTEN_EVENT_STREAM_FREE);
-    audio_extn_set_custom_mtmx_params(adev, usecase, false);
+
+    if (usecase->type == PCM_CAPTURE) {
+        in = usecase->stream.in;
+        if (in && is_loopback_input_device(in->device)) {
+            ALOGD("%s: reset custom mtmx params v1", __func__);
+            audio_extn_set_custom_mtmx_params_v1(adev, usecase, false);
+        }
+    } else {
+        audio_extn_set_custom_mtmx_params_v2(adev, usecase, false);
+    }
+
     if ((usecase->type == PCM_PLAYBACK) &&
             (usecase->stream.out != NULL))
         usecase->stream.out->pspd_coeff_sent = false;
+
     ALOGV("%s: exit", __func__);
     return 0;
 }
@@ -1243,7 +1324,7 @@
         }
         if (((snd_device == SND_DEVICE_IN_HANDSET_6MIC) ||
             (snd_device == SND_DEVICE_IN_HANDSET_QMIC)) &&
-            (audio_extn_ffv_get_stream() == adev->active_input)) {
+            (audio_extn_ffv_get_stream() == adev_get_active_input(adev))) {
             ALOGD("%s: init ec ref loopback", __func__);
             audio_extn_ffv_init_ec_ref_loopback(adev, snd_device);
         }
@@ -1325,7 +1406,7 @@
             audio_route_apply_and_update_path(adev->audio_route, "hph-lowpower-mode");
         } else if (((snd_device == SND_DEVICE_IN_HANDSET_6MIC) ||
             (snd_device == SND_DEVICE_IN_HANDSET_QMIC)) &&
-            (audio_extn_ffv_get_stream() == adev->active_input)) {
+            (audio_extn_ffv_get_stream() == adev_get_active_input(adev))) {
             ALOGD("%s: deinit ec ref loopback", __func__);
             audio_extn_ffv_deinit_ec_ref_loopback(adev, snd_device);
         }
@@ -1618,8 +1699,10 @@
                     /* Update voc calibration before enabling VoIP route */
                     if (usecase->type == VOIP_CALL)
                         status = platform_switch_voice_call_device_post(adev->platform,
-                                                                        usecase->out_snd_device,
-                                                                        platform_get_input_snd_device(adev->platform, uc_info->devices));
+                                                           usecase->out_snd_device,
+                                                           platform_get_input_snd_device(
+                                                               adev->platform, NULL,
+                                                               uc_info->devices));
                     enable_audio_route(adev, usecase);
                     if (usecase->stream.out && usecase->id == USECASE_AUDIO_PLAYBACK_VOIP) {
                         out_set_voip_volume(&usecase->stream.out->stream,
@@ -1974,19 +2057,6 @@
     return NULL;
 }
 
-struct stream_in *get_next_active_input(const struct audio_device *adev)
-{
-    struct audio_usecase *usecase;
-    struct listnode *node;
-
-    list_for_each_reverse(node, &adev->usecase_list) {
-        usecase = node_to_item(node, struct audio_usecase, list);
-        if (usecase->type == PCM_CAPTURE)
-            return usecase->stream.in;
-    }
-    return NULL;
-}
-
 /*
  * is a true native playback active
  */
@@ -2220,6 +2290,97 @@
 
 int out_standby_l(struct audio_stream *stream);
 
+struct stream_in *adev_get_active_input(const struct audio_device *adev)
+{
+    struct listnode *node;
+    struct stream_in *last_active_in = NULL;
+
+    /* Get last added active input.
+     * TODO: We may use a priority mechanism to pick highest priority active source */
+    list_for_each(node, &adev->usecase_list)
+    {
+        struct audio_usecase *usecase = node_to_item(node, struct audio_usecase, list);
+        if (usecase->type == PCM_CAPTURE && usecase->stream.in != NULL)
+            last_active_in =  usecase->stream.in;
+    }
+
+    return last_active_in;
+}
+
+struct stream_in *get_voice_communication_input(const struct audio_device *adev)
+{
+    struct listnode *node;
+
+    /* First check active inputs with voice communication source and then
+     * any input if audio mode is in communication */
+    list_for_each(node, &adev->usecase_list)
+    {
+        struct audio_usecase *usecase = node_to_item(node, struct audio_usecase, list);
+        if (usecase->type == PCM_CAPTURE && usecase->stream.in != NULL &&
+            usecase->stream.in->source == AUDIO_SOURCE_VOICE_COMMUNICATION)
+            return usecase->stream.in;
+    }
+    if (adev->mode == AUDIO_MODE_IN_COMMUNICATION)
+        return adev_get_active_input(adev);
+
+    return NULL;
+}
+
+/*
+ * Aligned with policy.h
+ */
+static inline int source_priority(int inputSource)
+{
+    switch (inputSource) {
+    case AUDIO_SOURCE_VOICE_COMMUNICATION:
+        return 9;
+    case AUDIO_SOURCE_CAMCORDER:
+        return 8;
+    case AUDIO_SOURCE_VOICE_PERFORMANCE:
+        return 7;
+    case AUDIO_SOURCE_UNPROCESSED:
+        return 6;
+    case AUDIO_SOURCE_MIC:
+        return 5;
+    case AUDIO_SOURCE_ECHO_REFERENCE:
+        return 4;
+    case AUDIO_SOURCE_FM_TUNER:
+        return 3;
+    case AUDIO_SOURCE_VOICE_RECOGNITION:
+        return 2;
+    case AUDIO_SOURCE_HOTWORD:
+        return 1;
+    default:
+        break;
+    }
+    return 0;
+}
+
+static struct stream_in *get_priority_input(struct audio_device *adev)
+{
+    struct listnode *node;
+    struct audio_usecase *usecase;
+    int last_priority = 0, priority;
+    struct stream_in *priority_in = NULL;
+    struct stream_in *in;
+
+    list_for_each(node, &adev->usecase_list) {
+        usecase = node_to_item(node, struct audio_usecase, list);
+        if (usecase->type == PCM_CAPTURE) {
+            in = usecase->stream.in;
+            if (!in)
+                continue;
+            priority = source_priority(in->source);
+
+            if (priority > last_priority) {
+                last_priority = priority;
+                priority_in = in;
+            }
+        }
+    }
+    return priority_in;
+}
+
 int select_devices(struct audio_device *adev, audio_usecase_t uc_id)
 {
     snd_device_t out_snd_device = SND_DEVICE_NONE;
@@ -2249,7 +2410,9 @@
         }
         out_snd_device = platform_get_output_snd_device(adev->platform,
                                                         usecase->stream.out);
-        in_snd_device = platform_get_input_snd_device(adev->platform, usecase->stream.out->devices);
+        in_snd_device = platform_get_input_snd_device(adev->platform,
+                                                      NULL,
+                                                      usecase->stream.out->devices);
         usecase->devices = usecase->stream.out->devices;
     } else if (usecase->type == TRANSCODE_LOOPBACK_RX) {
         if (usecase->stream.inout == NULL) {
@@ -2268,7 +2431,7 @@
             ALOGE("%s: stream.inout is NULL", __func__);
             return -EINVAL;
         }
-        in_snd_device = platform_get_input_snd_device(adev->platform, AUDIO_DEVICE_NONE);
+        in_snd_device = platform_get_input_snd_device(adev->platform, NULL, AUDIO_DEVICE_NONE);
         usecase->devices = in_snd_device;
     } else {
         /*
@@ -2328,21 +2491,17 @@
             usecase->devices = usecase->stream.out->devices;
             in_snd_device = SND_DEVICE_NONE;
             if (out_snd_device == SND_DEVICE_NONE) {
+                struct stream_out *voip_out = adev->primary_output;
+                struct stream_in *voip_in = get_voice_communication_input(adev);
                 out_snd_device = platform_get_output_snd_device(adev->platform,
-                                            usecase->stream.out);
+                                                                usecase->stream.out);
                 voip_usecase = get_usecase_from_list(adev, USECASE_AUDIO_PLAYBACK_VOIP);
-                if (voip_usecase == NULL && adev->primary_output && !adev->primary_output->standby)
-                    voip_usecase = get_usecase_from_list(adev, adev->primary_output->usecase);
 
-                if ((usecase->stream.out != NULL &&
-                     voip_usecase != NULL &&
-                     usecase->stream.out->usecase == voip_usecase->id) &&
-                    adev->active_input &&
-                    (adev->active_input->source == AUDIO_SOURCE_VOICE_COMMUNICATION ||
-                     adev->mode == AUDIO_MODE_IN_COMMUNICATION) &&
-                    out_snd_device != usecase->out_snd_device) {
-                    select_devices(adev, adev->active_input->usecase);
-                }
+                if (voip_usecase)
+                    voip_out = voip_usecase->stream.out;
+
+                if (usecase->stream.out == voip_out && voip_in != NULL)
+                    select_devices(adev, voip_in->usecase);
             }
         } else if (usecase->type == PCM_CAPTURE) {
             if (usecase->stream.in == NULL) {
@@ -2353,24 +2512,39 @@
             out_snd_device = SND_DEVICE_NONE;
             if (in_snd_device == SND_DEVICE_NONE) {
                 audio_devices_t out_device = AUDIO_DEVICE_NONE;
-                if (adev->active_input &&
-                    (adev->active_input->source == AUDIO_SOURCE_VOICE_COMMUNICATION ||
-                    (adev->mode == AUDIO_MODE_IN_COMMUNICATION &&
-                     adev->active_input->source == AUDIO_SOURCE_MIC))) {
-                    voip_usecase = get_usecase_from_list(adev, USECASE_AUDIO_PLAYBACK_VOIP);
-                    if (voip_usecase != NULL && voip_usecase->stream.out != NULL)
+                struct stream_in *voip_in = get_voice_communication_input(adev);
+                struct stream_in *priority_in = NULL;
+
+                if (voip_in != NULL) {
+                    struct audio_usecase *voip_usecase = get_usecase_from_list(adev,
+                                                             USECASE_AUDIO_PLAYBACK_VOIP);
+
+                    usecase->stream.in->enable_ec_port = false;
+
+                    if (usecase->id == USECASE_AUDIO_RECORD_AFE_PROXY) {
+                        out_device = AUDIO_DEVICE_OUT_TELEPHONY_TX;
+                    } else if (voip_usecase) {
                         out_device = voip_usecase->stream.out->devices;
-                    else if (adev->primary_output && !adev->primary_output->standby)
+                    } else if (adev->primary_output &&
+                                  !adev->primary_output->standby) {
                         out_device = adev->primary_output->devices;
-                    platform_set_echo_reference(adev, false, AUDIO_DEVICE_NONE);
-                } else if (usecase->id == USECASE_AUDIO_RECORD_AFE_PROXY) {
-                    out_device = AUDIO_DEVICE_OUT_TELEPHONY_TX;
+                    } else {
+                        /* forcing speaker o/p device to get matching i/p pair
+                           in case o/p is not routed from same primary HAL */
+                        out_device = AUDIO_DEVICE_OUT_SPEAKER;
+                    }
+                    priority_in = voip_in;
                 } else {
-                    /* forcing speaker o/p device to get matching i/p pair
-                       in case o/p is not routed from same primary HAL */
-                    out_device = AUDIO_DEVICE_OUT_SPEAKER;
+                    /* get the input with the highest priority source*/
+                    priority_in = get_priority_input(adev);
+
+                    if (!priority_in)
+                        priority_in = usecase->stream.in;
                 }
-                in_snd_device = platform_get_input_snd_device(adev->platform, out_device);
+
+                in_snd_device = platform_get_input_snd_device(adev->platform,
+                                                              priority_in,
+                                                              out_device);
             }
         }
     }
@@ -2524,22 +2698,23 @@
                     (usecase->stream.out->sample_rate < OUTPUT_SAMPLING_RATE_44100)) {
             usecase->stream.out->app_type_cfg.sample_rate = DEFAULT_OUTPUT_SAMPLING_RATE;
         }
+    }
+    enable_audio_route(adev, usecase);
 
-        /* Notify device change info to effect clients registered */
+    /* Notify device change info to effect clients registered */
+    if (usecase->type == PCM_PLAYBACK) {
         audio_extn_gef_notify_device_config(
                 usecase->stream.out->devices,
                 usecase->stream.out->channel_mask,
                 usecase->stream.out->app_type_cfg.sample_rate,
                 platform_get_snd_device_acdb_id(usecase->out_snd_device));
     }
-    enable_audio_route(adev, usecase);
 
     audio_extn_qdsp_set_device(usecase);
 
     /* If input stream is already running then effect needs to be
        applied on the new input device that's being enabled here.  */
-    if ((in_snd_device != SND_DEVICE_NONE) && (adev->active_input != NULL) &&
-        (!adev->active_input->standby))
+    if (in_snd_device != SND_DEVICE_NONE)
         check_and_enable_effect(adev);
 
     if (usecase->type == VOICE_CALL || usecase->type == VOIP_CALL) {
@@ -2563,14 +2738,13 @@
                                                                in_snd_device);
 
     if (is_btsco_device(out_snd_device, in_snd_device) || is_a2dp_device(out_snd_device)) {
-
+         struct stream_in *in = adev_get_active_input(adev);
          if (usecase->type == VOIP_CALL) {
-             if (adev->active_input != NULL &&
-                 !adev->active_input->standby) {
+             if (in != NULL && !in->standby) {
                  if (is_bt_soc_on(adev) == false){
                       ALOGD("BT SCO MIC disconnected while in connection");
-                      if (adev->active_input->pcm != NULL)
-                          pcm_stop(adev->active_input->pcm);
+                      if (in->pcm != NULL)
+                          pcm_stop(in->pcm);
                  }
              }
              if ((usecase->stream.out != NULL) && (usecase->stream.out != adev->primary_output)
@@ -2615,6 +2789,7 @@
     }
 
     struct audio_device *adev = in->dev;
+    struct stream_in *priority_in = NULL;
 
     ALOGV("%s: enter: usecase(%d: %s)", __func__,
           in->usecase, use_case_table[in->usecase]);
@@ -2625,6 +2800,8 @@
         return -EINVAL;
     }
 
+    priority_in = get_priority_input(adev);
+
     if (audio_extn_ext_hw_plugin_usecase_stop(adev->ext_hw_plugin, uc_info))
         ALOGE("%s: failed to stop ext hw plugin", __func__);
 
@@ -2637,10 +2814,18 @@
     /* 2. Disable the tx device */
     disable_snd_device(adev, uc_info->in_snd_device);
 
+    if (is_loopback_input_device(in->device))
+        audio_extn_keep_alive_stop(KEEP_ALIVE_OUT_PRIMARY);
+
     list_remove(&uc_info->list);
     free(uc_info);
 
-    adev->active_input = get_next_active_input(adev);
+    if (priority_in == in) {
+        priority_in = get_priority_input(adev);
+        if (priority_in)
+            select_devices(adev, priority_in->usecase);
+    }
+
     enable_gcov();
     ALOGV("%s: exit: status(%d)", __func__, ret);
     return ret;
@@ -2702,7 +2887,6 @@
         goto error_config;
     }
 
-    adev->active_input = in;
     uc_info = (struct audio_usecase *)calloc(1, sizeof(struct audio_usecase));
 
     if (!uc_info) {
@@ -2727,8 +2911,10 @@
     if (audio_extn_ext_hw_plugin_usecase_start(adev->ext_hw_plugin, uc_info))
         ALOGE("%s: failed to start ext hw plugin", __func__);
 
+    android_atomic_acquire_cas(true, false, &(in->capture_stopped));
+
     if (audio_extn_cin_attached_usecase(in->usecase)) {
-       ret = audio_extn_cin_start_input_stream(in);
+       ret = audio_extn_cin_open_input_stream(in);
        if (ret)
            goto error_open;
        else
@@ -2820,6 +3006,9 @@
     audio_extn_audiozoom_set_microphone_direction(in, in->zoom);
     audio_extn_audiozoom_set_microphone_field_dimension(in, in->direction);
 
+    if (is_loopback_input_device(in->device))
+        audio_extn_keep_alive_start(KEEP_ALIVE_OUT_PRIMARY);
+
 done_open:
     audio_streaming_hint_end();
     audio_extn_perf_lock_release(&adev->perf_lock_handle);
@@ -2833,7 +3022,6 @@
     stop_input_stream(in);
 
 error_config:
-    adev->active_input = get_next_active_input(adev);
     /*
      * sleep 50ms to allow sufficient time for kernel
      * drivers to recover incases like SSR.
@@ -3509,6 +3697,8 @@
                   out->usecase == USECASE_AUDIO_PLAYBACK_ULL) && (out->apply_volume)) {
                  out_set_pcm_volume(&out->stream, out->volume_l, out->volume_r);
                  out->apply_volume = false;
+        } else if (audio_extn_auto_hal_is_bus_device_usecase(out->usecase)) {
+            out_set_pcm_volume(&out->stream, out->volume_l, out->volume_r);
         }
     } else {
         platform_set_stream_channel_map(adev->platform, out->channel_mask,
@@ -3571,6 +3761,22 @@
                 adev->offload_effects_start_output(out->handle, out->pcm_device_id, adev->mixer);
             audio_extn_check_and_set_dts_hpx_state(adev);
         }
+
+        if (out->devices & AUDIO_DEVICE_OUT_BUS) {
+            /* Update cached volume from media to offload/direct stream */
+            struct listnode *node = NULL;
+            list_for_each(node, &adev->active_outputs_list) {
+                streams_output_ctxt_t *out_ctxt = node_to_item(node,
+                                                    streams_output_ctxt_t,
+                                                    list);
+                if (out_ctxt->output->usecase == USECASE_AUDIO_PLAYBACK_MEDIA) {
+                    out->volume_l = out_ctxt->output->volume_l;
+                    out->volume_r = out_ctxt->output->volume_r;
+                }
+            }
+            out_set_compr_volume(&out->stream,
+                                 out->volume_l, out->volume_r);
+        }
     }
 
     if (ret == 0) {
@@ -3660,6 +3866,9 @@
     case 4:
     case 6:
     case 8:
+    case 10:
+    case 12:
+    case 14:
         break;
     default:
         ret = -EINVAL;
@@ -3811,10 +4020,10 @@
                                   is_low_latency);
 }
 
-static size_t get_output_period_size(uint32_t sample_rate,
-                                    audio_format_t format,
-                                    int channel_count,
-                                    int duration /*in millisecs*/)
+size_t get_output_period_size(uint32_t sample_rate,
+                            audio_format_t format,
+                            int channel_count,
+                            int duration /*in millisecs*/)
 {
     size_t size = 0;
     uint32_t bytes_per_sample = audio_bytes_per_sample(format);
@@ -3904,8 +4113,6 @@
             return out->compr_config.fragment_size;
     } else if(out->usecase == USECASE_COMPRESS_VOIP_CALL)
         return voice_extn_compress_voip_out_get_buffer_size(out);
-    else if(out->usecase == USECASE_AUDIO_PLAYBACK_VOIP)
-        return VOIP_IO_BUF_SIZE(out->config.rate, DEFAULT_VOIP_BUF_DURATION_MS, DEFAULT_VOIP_BIT_DEPTH_BYTE);
     else if (is_offload_usecase(out->usecase) &&
              out->flags == AUDIO_OUTPUT_FLAG_DIRECT)
         return out->hal_fragment_size;
@@ -4955,6 +5162,13 @@
         out->volume_l = left;
         out->volume_r = right;
         return ret;
+    } else if (audio_extn_auto_hal_is_bus_device_usecase(out->usecase)) {
+        ALOGV("%s: bus device set volume called", __func__);
+        if (!out->standby)
+            ret = out_set_pcm_volume(stream, left, right);
+        out->volume_l = left;
+        out->volume_r = right;
+        return ret;
     }
 
     return -ENOSYS;
@@ -5216,7 +5430,7 @@
          */
         usecase = get_usecase_from_list(adev, out->usecase);
         if (usecase != NULL) {
-            audio_extn_set_custom_mtmx_params(adev, usecase, true);
+            audio_extn_set_custom_mtmx_params_v2(adev, usecase, true);
             out->pspd_coeff_sent = true;
         }
     }
@@ -5957,8 +6171,6 @@
 
     if(in->usecase == USECASE_COMPRESS_VOIP_CALL)
         return voice_extn_compress_voip_in_get_buffer_size(in);
-    else if(in->usecase == USECASE_AUDIO_RECORD_VOIP)
-        return VOIP_IO_BUF_SIZE(in->config.rate, DEFAULT_VOIP_BUF_DURATION_MS, DEFAULT_VOIP_BIT_DEPTH_BYTE);
     else if(audio_extn_compr_cap_usecase_supported(in->usecase))
         return audio_extn_compr_cap_get_buffer_size(in->config.format);
     else if(audio_extn_cin_attached_usecase(in->usecase))
@@ -6020,7 +6232,7 @@
             in->capture_started = false;
         } else {
             if (audio_extn_cin_attached_usecase(in->usecase))
-                audio_extn_cin_stop_input_stream(in);
+                audio_extn_cin_close_input_stream(in);
         }
 
         if (in->pcm) {
@@ -6030,11 +6242,11 @@
             in->pcm = NULL;
         }
 
-        if(do_stop) {
+        if (in->source == AUDIO_SOURCE_VOICE_COMMUNICATION)
             adev->enable_voicerx = false;
-            platform_set_echo_reference(adev, false, AUDIO_DEVICE_NONE);
+
+        if (do_stop)
             status = stop_input_stream(in);
-        }
 
         if (in->source == AUDIO_SOURCE_VOICE_RECOGNITION)
             adev->num_va_sessions--;
@@ -6324,6 +6536,13 @@
         in->standby = 0;
     }
 
+    /* Avoid read if capture_stopped is set */
+    if (android_atomic_acquire_load(&(in->capture_stopped)) > 0) {
+        ALOGD("%s: force stopped catpure session, ignoring read request", __func__);
+        ret = -EINVAL;
+        goto exit;
+    }
+
     // what's the duration requested by the client?
     long ns = 0;
 
@@ -6448,6 +6667,51 @@
     return ret;
 }
 
+static int in_update_effect_list(bool add, effect_handle_t effect,
+                            struct listnode *head)
+{
+    struct listnode *node;
+    struct in_effect_list *elist = NULL;
+    struct in_effect_list *target = NULL;
+    int ret = 0;
+
+    if (!head)
+        return ret;
+
+    list_for_each(node, head) {
+        elist = node_to_item(node, struct in_effect_list, list);
+        if (elist->handle == effect) {
+            target = elist;
+            break;
+        }
+    }
+
+    if (add) {
+        if (target) {
+            ALOGD("effect %p already exist", effect);
+            return ret;
+        }
+
+        target = (struct in_effect_list *)
+                     calloc(1, sizeof(struct in_effect_list));
+
+        if (!target) {
+            ALOGE("%s:fail to allocate memory", __func__);
+            return -ENOMEM;
+        }
+
+        target->handle = effect;
+        list_add_tail(head, &target->list);
+    } else {
+        if (target) {
+            list_remove(&target->list);
+            free(target);
+        }
+    }
+
+    return ret;
+}
+
 static int add_remove_audio_effect(const struct audio_stream *stream,
                                    effect_handle_t effect,
                                    bool enable)
@@ -6465,13 +6729,18 @@
     lock_input_stream(in);
     pthread_mutex_lock(&in->dev->lock);
     if ((in->source == AUDIO_SOURCE_VOICE_COMMUNICATION ||
-         in->source == AUDIO_SOURCE_VOICE_RECOGNITION ||
-         in->dev->mode == AUDIO_MODE_IN_COMMUNICATION) &&
-            in->enable_aec != enable &&
+            in->source == AUDIO_SOURCE_VOICE_RECOGNITION ||
+            adev->mode == AUDIO_MODE_IN_COMMUNICATION) &&
             (memcmp(&desc.type, FX_IID_AEC, sizeof(effect_uuid_t)) == 0)) {
+
+        in_update_effect_list(enable, effect, &in->aec_list);
+        enable = !list_empty(&in->aec_list);
+        if (enable == in->enable_aec)
+            goto exit;
+
         in->enable_aec = enable;
-        if (!enable)
-            platform_set_echo_reference(in->dev, enable, AUDIO_DEVICE_NONE);
+        ALOGD("AEC enable %d", enable);
+
         if (in->source == AUDIO_SOURCE_VOICE_COMMUNICATION ||
             in->dev->mode == AUDIO_MODE_IN_COMMUNICATION) {
             in->dev->enable_voicerx = enable;
@@ -6489,9 +6758,15 @@
         }
 
     }
-    if (in->enable_ns != enable &&
-            (memcmp(&desc.type, FX_IID_NS, sizeof(effect_uuid_t)) == 0)) {
+    if (memcmp(&desc.type, FX_IID_NS, sizeof(effect_uuid_t)) == 0) {
+
+        in_update_effect_list(enable, effect, &in->ns_list);
+        enable = !list_empty(&in->ns_list);
+        if (enable == in->enable_ns)
+            goto exit;
+
         in->enable_ns = enable;
+        ALOGD("NS enable %d", enable);
         if (!in->standby) {
             if (in->source == AUDIO_SOURCE_VOICE_COMMUNICATION ||
                 in->dev->mode == AUDIO_MODE_IN_COMMUNICATION) {
@@ -6501,6 +6776,7 @@
                 select_devices(in->dev, in->usecase);
         }
     }
+exit:
     pthread_mutex_unlock(&in->dev->lock);
     pthread_mutex_unlock(&in->lock);
 
@@ -6828,7 +7104,7 @@
                             audio_output_flags_t flags,
                             struct audio_config *config,
                             struct audio_stream_out **stream_out,
-                            const char *address __unused)
+                            const char *address)
 {
     struct audio_device *adev = (struct audio_device *)dev;
     struct stream_out *out;
@@ -6859,8 +7135,8 @@
     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)\
-        stream_handle(%p)", __func__, config->format, config->sample_rate, config->channel_mask,
-        devices, flags, &out->stream);
+        stream_handle(%p) address(%s)", __func__, config->format, config->sample_rate, config->channel_mask,
+        devices, flags, &out->stream, address);
 
 
     if (!out) {
@@ -6983,6 +7259,23 @@
         out->config.format = pcm_format_from_audio_format(out->format);
     }
 
+    /* validate bus device address */
+    if (out->devices & AUDIO_DEVICE_OUT_BUS) {
+        /* extract car audio stream index */
+        out->car_audio_stream =
+            audio_extn_auto_hal_get_car_audio_stream_from_address(address);
+        if (out->car_audio_stream < 0) {
+            ALOGE("%s: invalid car audio stream %x",
+                __func__, out->car_audio_stream);
+            ret = -EINVAL;
+            goto error_open;
+        }
+        /* save car audio stream and address for bus device */
+        strlcpy(out->address, address, AUDIO_DEVICE_MAX_ADDRESS_LEN);
+        ALOGV("%s: address %s, car_audio_stream %x",
+            __func__, out->address, out->car_audio_stream);
+    }
+
     /* Check for VOIP usecase */
     if (is_voip_rx) {
         if (!voice_extn_is_compress_voip_supported()) {
@@ -6996,8 +7289,17 @@
                 out->volume_r = INVALID_OUT_VOLUME;
 
                 out->config = default_pcm_config_voip_copp;
-                out->config.period_size = VOIP_IO_BUF_SIZE(out->sample_rate, DEFAULT_VOIP_BUF_DURATION_MS, DEFAULT_VOIP_BIT_DEPTH_BYTE)/2;
                 out->config.rate = out->sample_rate;
+                uint32_t channel_count =
+                        audio_channel_count_from_out_mask(out->channel_mask);
+                uint32_t buffer_size = get_stream_buffer_size(DEFAULT_VOIP_BUF_DURATION_MS,
+                                                              out->sample_rate, out->format,
+                                                              channel_count, false);
+                uint32_t frame_size = audio_bytes_per_sample(out->format) * channel_count;
+                if (frame_size != 0)
+                    out->config.period_size = buffer_size / frame_size;
+                else
+                    ALOGW("%s: frame size is 0 for format %#x", __func__, out->format);
             }
         } else {
                 if ((out->dev->mode == AUDIO_MODE_IN_COMMUNICATION ||
@@ -7089,6 +7391,11 @@
             ALOGV("non-offload DIRECT_usecase ... usecase selected %d ", out->usecase);
         }
 
+        if (out->flags & AUDIO_OUTPUT_FLAG_FAST) {
+            ALOGD("%s: Setting latency mode to true", __func__);
+            out->compr_config.codec->flags |= audio_extn_utils_get_perf_mode_flag();
+        }
+
         if (out->usecase == USECASE_INVALID) {
             if (out->devices & AUDIO_DEVICE_OUT_AUX_DIGITAL &&
                     config->format == 0 && config->sample_rate == 0 &&
@@ -7172,6 +7479,10 @@
 
             out->compr_config.fragments = DIRECT_PCM_NUM_FRAGMENTS;
 
+            if ((config->offload_info.duration_us >= MIN_OFFLOAD_BUFFER_DURATION_MS * 1000) &&
+                   (config->offload_info.duration_us <= MAX_OFFLOAD_BUFFER_DURATION_MS * 1000))
+                out->info.duration_us = (int64_t)config->offload_info.duration_us;
+
             /* Check if alsa session is configured with the same format as HAL input format,
              * if not then derive correct fragment size needed to accomodate the
              * conversion of HAL input format to alsa format.
@@ -7456,6 +7767,13 @@
                 adev->haptics_config.channels = 1;
             } else
                 adev->haptics_config.channels = audio_channel_count_from_out_mask(out->channel_mask & AUDIO_CHANNEL_HAPTIC_ALL);
+        } else if (out->devices & AUDIO_DEVICE_OUT_BUS) {
+            ret = audio_extn_auto_hal_open_output_stream(out);
+            if (ret) {
+                ALOGE("%s: Failed to open output stream for bus device", __func__);
+                ret = -EINVAL;
+                goto error_open;
+            }
         } else {
             /* primary path is the default path selected if no other outputs are available/suitable */
             out->usecase = GET_USECASE_AUDIO_PLAYBACK_PRIMARY(use_db_as_primary);
@@ -7781,6 +8099,7 @@
             adev->screen_off = false;
         else
             adev->screen_off = true;
+        audio_extn_sound_trigger_update_screen_status(adev->screen_off);
     }
 
     ret = str_parms_get_int(parms, "rotation", &val);
@@ -7883,6 +8202,21 @@
                 adev->allow_afe_proxy_usage = true;
             }
         }
+        if (audio_is_a2dp_out_device(device)) {
+           struct audio_usecase *usecase;
+           struct listnode *node;
+           list_for_each(node, &adev->usecase_list) {
+               usecase = node_to_item(node, struct audio_usecase, list);
+               if (PCM_PLAYBACK == usecase->type && usecase->stream.out &&
+                  (usecase->stream.out->flags & AUDIO_OUTPUT_FLAG_COMPRESS_OFFLOAD) &&
+                   usecase->stream.out->a2dp_compress_mute) {
+                   struct stream_out *out = usecase->stream.out;
+                   ALOGD("Unmuting the stream when Bt-A2dp disconnected and stream is mute");
+                   out->a2dp_compress_mute = false;
+                   out_set_compr_volume(&out->stream, out->volume_l, out->volume_r);
+               }
+           }
+        }
     }
 
     audio_extn_hfp_set_parameters(adev, parms);
@@ -7897,13 +8231,17 @@
             if (usecase->stream.out && (usecase->type == PCM_PLAYBACK) &&
                 (usecase->devices & AUDIO_DEVICE_OUT_ALL_A2DP)){
                 ALOGD("reconfigure a2dp... forcing device switch");
-
                 pthread_mutex_unlock(&adev->lock);
                 lock_output_stream(usecase->stream.out);
                 pthread_mutex_lock(&adev->lock);
                 audio_extn_a2dp_set_handoff_mode(true);
+                ALOGD("Switching to speaker and muting the stream before select_devices");
+                check_a2dp_restore_l(adev, usecase->stream.out, false);
                 //force device switch to re configure encoder
                 select_devices(adev, usecase->id);
+                ALOGD("Unmuting the stream after select_devices");
+                usecase->stream.out->a2dp_compress_mute = false;
+                out_set_compr_volume(&usecase->stream.out->stream, usecase->stream.out->volume_l, usecase->stream.out->volume_r);
                 audio_extn_a2dp_set_handoff_mode(false);
                 pthread_mutex_unlock(&usecase->stream.out->lock);
                 break;
@@ -8324,6 +8662,8 @@
     in->af_period_multiplier = 1;
     in->direction = MIC_DIRECTION_UNSPECIFIED;
     in->zoom = 0;
+    list_init(&in->aec_list);
+    list_init(&in->ns_list);
 
     ALOGV("%s: source %d, config->channel_mask %#x", __func__, source, config->channel_mask);
     if (source == AUDIO_SOURCE_VOICE_UPLINK ||
@@ -8409,6 +8749,8 @@
     }
 
     if (config->sample_rate == LOW_LATENCY_CAPTURE_SAMPLE_RATE &&
+            (flags & AUDIO_INPUT_FLAG_TIMESTAMP) == 0 &&
+            (flags & AUDIO_INPUT_FLAG_COMPRESS) == 0 &&
             (flags & AUDIO_INPUT_FLAG_FAST) != 0) {
         is_low_latency = true;
 #if LOW_LATENCY_CAPTURE_USE_CASE
@@ -8529,7 +8871,7 @@
                    (in->dev->mode != AUDIO_MODE_IN_COMMUNICATION)) {
             audio_extn_compr_cap_init(in);
         } else if (audio_extn_cin_applicable_stream(in)) {
-            ret = audio_extn_cin_configure_input_stream(in);
+            ret = audio_extn_cin_configure_input_stream(in, config);
             if (ret)
                 goto err_open;
         } else {
@@ -8580,7 +8922,7 @@
                     ALOGV("%s: overriding usecase with USECASE_AUDIO_RECORD_COMPRESS2 and appending compress flag", __func__);
                     if (audio_extn_cin_applicable_stream(in)) {
                         in->sample_rate = config->sample_rate;
-                        ret = audio_extn_cin_configure_input_stream(in);
+                        ret = audio_extn_cin_configure_input_stream(in, config);
                         if (ret)
                             goto err_open;
                     }
@@ -8664,7 +9006,7 @@
     /* Disable echo reference if there are no active input, hfp call
      * and sound trigger while closing input stream
      */
-    if (!adev->active_input &&
+    if (adev_get_active_input(adev) == NULL &&
         !audio_extn_hfp_is_active(adev) &&
         !audio_extn_sound_trigger_check_ec_ref_enable())
         platform_set_echo_reference(adev, false, AUDIO_DEVICE_NONE);
@@ -8707,7 +9049,7 @@
         audio_extn_compr_cap_deinit();
 
     if (audio_extn_cin_attached_usecase(in->usecase))
-        audio_extn_cin_close_input_stream(in);
+        audio_extn_cin_free_input_stream_resources(in);
 
     if (in->is_st_session) {
         ALOGV("%s: sound trigger pcm stop lab", __func__);
@@ -8812,13 +9154,10 @@
             uc_info.id = audio_usecase;
             uc_info.type = usecase_type;
             if (dir) {
-                adev->active_input = &in;
                 memset(&in, 0, sizeof(in));
                 in.device = audio_device;
                 in.source = AUDIO_SOURCE_VOICE_COMMUNICATION;
                 uc_info.stream.in = &in;
-            }  else {
-                adev->active_input = NULL;
             }
             memset(&out, 0, sizeof(out));
             out.devices = audio_device; /* only field needed in select_devices */
@@ -8853,7 +9192,6 @@
             list_remove(&uc_info.list);
         }
     }
-    adev->active_input = NULL; /* restore adev state */
     return 0;
 }
 
@@ -8893,13 +9231,21 @@
 
 int adev_get_audio_port(struct audio_hw_device *dev, struct audio_port *config)
 {
-    return audio_extn_hw_loopback_get_audio_port(dev, config);
+    int ret = 0;
+
+    ret = audio_extn_hw_loopback_get_audio_port(dev, config);
+    ret |= audio_extn_auto_hal_get_audio_port(dev, config);
+    return ret;
 }
 
 int adev_set_audio_port_config(struct audio_hw_device *dev,
                         const struct audio_port_config *config)
 {
-    return audio_extn_hw_loopback_set_audio_port_config(dev, config);
+    int ret = 0;
+
+    ret = audio_extn_hw_loopback_set_audio_port_config(dev, config);
+    ret |= audio_extn_auto_hal_set_audio_port_config(dev, config);
+    return ret;
 }
 
 static int adev_dump(const audio_hw_device_t *device __unused,
@@ -8911,9 +9257,9 @@
 static int adev_close(hw_device_t *device)
 {
     size_t i;
-    struct audio_device *adev = (struct audio_device *)device;
+    struct audio_device *adev_temp = (struct audio_device *)device;
 
-    if (!adev)
+    if (!adev_temp)
         return 0;
 
     pthread_mutex_lock(&adev_init_lock);
@@ -8929,6 +9275,8 @@
         audio_extn_utils_release_streams_cfg_lists(
                       &adev->streams_output_cfg_list,
                       &adev->streams_input_cfg_list);
+        if (audio_extn_qap_is_enabled())
+            audio_extn_qap_deinit();
         if (audio_extn_qaf_is_enabled())
             audio_extn_qaf_deinit();
         audio_route_free(adev->audio_route);
@@ -9004,6 +9352,7 @@
             adev->card_status = status;
             platform_snd_card_update(adev->platform, status);
             audio_extn_fm_set_parameters(adev, parms);
+            audio_extn_auto_hal_set_parameters(adev, parms);
         } else if (is_ext_device_status) {
             platform_set_parameters(adev->platform, parms);
         }
@@ -9038,7 +9387,7 @@
             select_devices(adev, uc_info->id);
             pthread_mutex_lock(&out->compr_mute_lock);
             if ((out->flags & AUDIO_OUTPUT_FLAG_COMPRESS_OFFLOAD) &&
-                (out->a2dp_compress_mute)) {
+                (out->a2dp_compress_mute) && (uc_info->out_snd_device == SND_DEVICE_OUT_BT_A2DP)) {
                 out->a2dp_compress_mute = false;
                 out_set_compr_volume(&out->stream, out->volume_l, out->volume_r);
             }
@@ -9167,7 +9516,6 @@
 
     /* Set the default route before the PCM stream is opened */
     adev->mode = AUDIO_MODE_NORMAL;
-    adev->active_input = NULL;
     adev->primary_output = NULL;
     adev->out_device = AUDIO_DEVICE_NONE;
     adev->bluetooth_nrec = true;
@@ -9209,6 +9557,20 @@
     }
 
     adev->extspk = audio_extn_extspk_init(adev);
+    if (audio_extn_qap_is_enabled()) {
+        ret = audio_extn_qap_init(adev);
+        if (ret < 0) {
+            pthread_mutex_destroy(&adev->lock);
+            free(adev);
+            adev = NULL;
+            ALOGE("%s: Failed to init platform data, aborting.", __func__);
+            *device = NULL;
+            pthread_mutex_unlock(&adev_init_lock);
+            return ret;
+        }
+        adev->device.open_output_stream = audio_extn_qap_open_output_stream;
+        adev->device.close_output_stream = audio_extn_qap_close_output_stream;
+    }
 
     if (audio_extn_qaf_is_enabled()) {
         ret = audio_extn_qaf_init(adev);
diff --git a/hal/audio_hw.h b/hal/audio_hw.h
index 9a93ed7..4810896 100644
--- a/hal/audio_hw.h
+++ b/hal/audio_hw.h
@@ -222,6 +222,12 @@
 
     USECASE_AUDIO_A2DP_ABR_FEEDBACK,
 
+    /* car streams usecases */
+    USECASE_AUDIO_PLAYBACK_MEDIA,
+    USECASE_AUDIO_PLAYBACK_SYS_NOTIFICATION,
+    USECASE_AUDIO_PLAYBACK_NAV_GUIDANCE,
+    USECASE_AUDIO_PLAYBACK_PHONE,
+
     AUDIO_USECASE_MAX
 };
 
@@ -290,6 +296,21 @@
     RENDER_MODE_AUDIO_STC_MASTER,
 } render_mode_t;
 
+#ifdef AUDIO_EXTN_AUTO_HAL_ENABLED
+/* This defines the physical car streams supported in audio HAL,
+ * limited by the available frontend PCM driver.
+ * Max number of physical streams supported is currently 8 and is
+ * represented by stream bit flag as indicated in vehicle HAL interface.
+ */
+#define MAX_CAR_AUDIO_STREAMS    8
+enum {
+    CAR_AUDIO_STREAM_MEDIA            = 0x1,
+    CAR_AUDIO_STREAM_SYS_NOTIFICATION = 0x2,
+    CAR_AUDIO_STREAM_NAV_GUIDANCE     = 0x4,
+    CAR_AUDIO_STREAM_PHONE            = 0x8,
+};
+#endif
+
 struct stream_app_type_cfg {
     int sample_rate;
     uint32_t bit_width;
@@ -378,6 +399,7 @@
     card_status_t card_status;
 
     void* qaf_stream_handle;
+    void* qap_stream_handle;
     pthread_cond_t qaf_offload_cond;
     pthread_t qaf_offload_thread;
     struct listnode qaf_offload_cmd_list;
@@ -407,6 +429,9 @@
 
     error_log_t *error_log;
     bool pspd_coeff_sent;
+
+    char address[AUDIO_DEVICE_MAX_ADDRESS_LEN];
+    int car_audio_stream;
 };
 
 struct stream_in {
@@ -424,6 +449,10 @@
     bool enable_aec;
     bool enable_ns;
     audio_format_t format;
+    bool enable_ec_port;
+    bool ec_opened;
+    struct listnode aec_list;
+    struct listnode ns_list;
     int64_t mmap_time_offset_nanos; /* fudge factor to correct inaccuracies in DSP */
     audio_io_handle_t capture_handle;
     audio_input_flags_t flags;
@@ -444,6 +473,8 @@
     float zoom;
     audio_microphone_direction_t direction;
 
+    volatile int32_t capture_stopped;
+
     /* Array of supported channel mask configurations. +1 so that the last entry is always 0 */
     audio_channel_mask_t supported_channel_masks[MAX_SUPPORTED_CHANNEL_MASKS + 1];
     audio_format_t supported_formats[MAX_SUPPORTED_FORMATS + 1];
@@ -541,7 +572,6 @@
     struct mixer *mixer;
     audio_mode_t mode;
     audio_devices_t out_device;
-    struct stream_in *active_input;
     struct stream_out *primary_output;
     struct stream_out *voice_tx_output;
     struct stream_out *current_call_output;
@@ -660,8 +690,6 @@
 struct audio_usecase *get_usecase_from_list(const struct audio_device *adev,
                                                    audio_usecase_t uc_id);
 
-struct stream_in *get_next_active_input(const struct audio_device *adev);
-
 bool is_offload_usecase(audio_usecase_t uc_id);
 
 bool audio_is_true_native_stream_active(struct audio_device *adev);
@@ -694,11 +722,24 @@
 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,
+                            int duration /*in millisecs*/);
+
 #define LITERAL_TO_STRING(x) #x
 #define CHECK(condition) LOG_ALWAYS_FATAL_IF(!(condition), "%s",\
             __FILE__ ":" LITERAL_TO_STRING(__LINE__)\
             " ASSERT_FATAL(" #condition ") failed.")
 
+static inline bool is_loopback_input_device(audio_devices_t device) {
+    if (!audio_is_output_device(device) &&
+         ((device & AUDIO_DEVICE_IN_LOOPBACK) == AUDIO_DEVICE_IN_LOOPBACK))
+        return true;
+    else
+        return false;
+}
+
 /*
  * NOTE: when multiple mutexes have to be acquired, always take the
  * stream_in or stream_out mutex first, followed by the audio_device mutex.
diff --git a/hal/audio_hw_extn_api.c b/hal/audio_hw_extn_api.c
index af73375..22c8685 100644
--- a/hal/audio_hw_extn_api.c
+++ b/hal/audio_hw_extn_api.c
@@ -34,6 +34,7 @@
 #include <inttypes.h>
 #include <errno.h>
 #include <log/log.h>
+#include <cutils/atomic.h>
 
 #include <hardware/audio.h>
 #include "sound/compress_params.h"
@@ -190,6 +191,31 @@
     return ret;
 }
 
+int qahwi_in_stop(struct audio_stream_in* stream) {
+    struct stream_in *in = (struct stream_in *)stream;
+    struct audio_device *adev = in->dev;
+
+    ALOGD("%s processing, in %p", __func__, in);
+
+    pthread_mutex_lock(&adev->lock);
+
+    if (!in->standby) {
+        if (in->pcm != NULL ) {
+            pcm_stop(in->pcm);
+        } else if (audio_extn_cin_attached_usecase(in->usecase)) {
+            audio_extn_cin_stop_input_stream(in);
+        }
+
+        /* Set the atomic variable when the session is stopped */
+        if (android_atomic_acquire_cas(false, true, &(in->capture_stopped)) == 0)
+            ALOGI("%s: capture_stopped bit set", __func__);
+    }
+
+    pthread_mutex_unlock(&adev->lock);
+
+    return 0;
+}
+
 ssize_t qahwi_in_read_v2(struct audio_stream_in *stream, void* buffer,
                           size_t bytes, uint64_t *timestamp)
 {
diff --git a/hal/msm8916/platform.c b/hal/msm8916/platform.c
index bdd10b0..8b9b53d 100644
--- a/hal/msm8916/platform.c
+++ b/hal/msm8916/platform.c
@@ -2845,6 +2845,20 @@
     }
 }
 
+struct audio_custom_mtmx_in_params *platform_get_custom_mtmx_in_params(void *platform,
+                                   struct audio_custom_mtmx_in_params_info *info)
+{
+    ALOGW("%s: not implemented!", __func__);
+    return -ENOSYS;
+}
+
+int platform_add_custom_mtmx_in_params(void *platform,
+                                    struct audio_custom_mtmx_in_params_info *info)
+{
+    ALOGW("%s: not implemented!", __func__);
+    return -ENOSYS;
+}
+
 void platform_release_acdb_metainfo_key(void *platform)
 {
     struct platform_data *my_data = (struct platform_data *)platform;
@@ -4163,6 +4177,7 @@
     bool use_voip_out_devices = false;
     bool prop_rec_play_enabled = false;
     char recConcPropValue[PROPERTY_VALUE_MAX];
+    struct stream_in *in = adev_get_active_input(adev);
 
     if (property_get("vendor.audio.rec.playback.conc.disabled", recConcPropValue, NULL)) {
         prop_rec_play_enabled = atoi(recConcPropValue) || !strncmp("true", recConcPropValue, 4);
@@ -4171,8 +4186,8 @@
                         (my_data->rec_play_conc_set || adev->mode == AUDIO_MODE_IN_COMMUNICATION);
     ALOGV("platform_get_output_snd_device use_voip_out_devices : %d",use_voip_out_devices);
 
-    audio_channel_mask_t channel_mask = (adev->active_input == NULL) ?
-                                AUDIO_CHANNEL_IN_MONO : adev->active_input->channel_mask;
+    audio_channel_mask_t channel_mask = (in == NULL) ?
+                                            AUDIO_CHANNEL_IN_MONO : in->channel_mask;
     int channel_count = popcount(channel_mask);
 
     ALOGV("%s: enter: output devices(%#x)", __func__, devices);
@@ -4191,7 +4206,7 @@
         * enforced audible (e.g. Camera shutter sound).
         */
         if ((mode == AUDIO_MODE_IN_CALL) ||
-            voice_is_in_call(adev) ||
+            voice_check_voicecall_usecases_active(adev) ||
             voice_extn_compress_voip_is_active(adev))
                 is_active_voice_call = true;
 
@@ -4274,7 +4289,7 @@
     }
 
     if ((mode == AUDIO_MODE_IN_CALL) ||
-        voice_is_in_call(adev) ||
+        voice_check_voicecall_usecases_active(adev) ||
         voice_extn_compress_voip_is_active(adev)) {
         if (devices & AUDIO_DEVICE_OUT_WIRED_HEADPHONE ||
             devices & AUDIO_DEVICE_OUT_WIRED_HEADSET ||
@@ -4513,9 +4528,9 @@
 {
     struct audio_device *adev = my_data->adev;
     snd_device_t snd_device = SND_DEVICE_NONE;
+    struct stream_in *in = adev_get_active_input(adev);
 
-    if (adev->active_input->enable_aec &&
-        adev->active_input->enable_ns) {
+    if (in != NULL && in->enable_aec && in->enable_ns) {
         if (in_device & AUDIO_DEVICE_IN_BACK_MIC) {
             if (my_data->fluence_in_spkr_mode) {
                 if ((my_data->fluence_type & FLUENCE_QUAD_MIC) &&
@@ -4547,7 +4562,7 @@
             snd_device = SND_DEVICE_IN_USB_HEADSET_MIC_AEC;
         }
         platform_set_echo_reference(adev, true, out_device);
-    } else if (adev->active_input->enable_aec) {
+    } else if (in != NULL && in->enable_aec) {
         if (in_device & AUDIO_DEVICE_IN_BACK_MIC) {
             if (my_data->fluence_in_spkr_mode) {
                 if ((my_data->fluence_type & FLUENCE_QUAD_MIC) &&
@@ -4579,7 +4594,7 @@
             snd_device = SND_DEVICE_IN_USB_HEADSET_MIC_AEC;
         }
         platform_set_echo_reference(adev, true, out_device);
-    } else if (adev->active_input->enable_ns) {
+    } else if (in != NULL && in->enable_ns) {
         if (in_device & AUDIO_DEVICE_IN_BACK_MIC) {
             if (my_data->fluence_in_spkr_mode) {
                 if ((my_data->fluence_type & FLUENCE_QUAD_MIC) &&
@@ -4625,33 +4640,35 @@
         return get_snd_device_for_voice_comm_ecns_disabled(my_data, out_device, in_device);
 }
 
-snd_device_t platform_get_input_snd_device(void *platform, audio_devices_t out_device)
+snd_device_t platform_get_input_snd_device(void *platform,
+                                           struct stream_in *in,
+                                           audio_devices_t out_device)
 {
     struct platform_data *my_data = (struct platform_data *)platform;
     struct audio_device *adev = my_data->adev;
-    /*
-     * TODO: active_input always points to last opened input. Source returned will
-     * be wrong if more than one active inputs are present.
-     */
-    audio_source_t  source = (adev->active_input == NULL) ?
-                                AUDIO_SOURCE_DEFAULT : adev->active_input->source;
-
-    audio_mode_t    mode   = adev->mode;
-    audio_devices_t in_device = ((adev->active_input == NULL) ?
-                                    AUDIO_DEVICE_NONE : adev->active_input->device)
-                                & ~AUDIO_DEVICE_BIT_IN;
-    audio_channel_mask_t channel_mask = (adev->active_input == NULL) ?
-                                AUDIO_CHANNEL_IN_MONO : adev->active_input->channel_mask;
+    audio_mode_t mode = adev->mode;
     snd_device_t snd_device = SND_DEVICE_NONE;
-    int channel_count = popcount(channel_mask);
-    int str_bitwidth = (adev->active_input == NULL) ?
-                    CODEC_BACKEND_DEFAULT_BIT_WIDTH : adev->active_input->bit_width;
+
+    if (in == NULL) {
+        in = adev_get_active_input(adev);
+    }
+
+    audio_source_t source = (in == NULL) ? AUDIO_SOURCE_DEFAULT : in->source;
+    audio_devices_t in_device =
+        ((in == NULL) ? AUDIO_DEVICE_NONE : in->device) & ~AUDIO_DEVICE_BIT_IN;
+    audio_channel_mask_t channel_mask = (in == NULL) ? AUDIO_CHANNEL_IN_MONO : in->channel_mask;
+    int channel_count = audio_channel_count_from_in_mask(channel_mask);
+
+    int str_bitwidth = (in == NULL) ?
+                    CODEC_BACKEND_DEFAULT_BIT_WIDTH : in->bit_width;
 
     ALOGV("%s: enter: out_device(%#x) in_device(%#x) channel_count (%d) channel_mask (0x%x)",
           __func__, out_device, in_device, channel_count, channel_mask);
     if (my_data->external_mic) {
-        if ((out_device != AUDIO_DEVICE_NONE) && ((mode == AUDIO_MODE_IN_CALL) || voice_is_in_call(adev) ||
-            voice_extn_compress_voip_is_active(adev) || audio_extn_hfp_is_active(adev))) {
+        if ((out_device != AUDIO_DEVICE_NONE) && ((mode == AUDIO_MODE_IN_CALL) ||
+            voice_check_voicecall_usecases_active(adev) ||
+            voice_extn_compress_voip_is_active(adev) ||
+            audio_extn_hfp_is_active(adev))) {
             if (out_device & AUDIO_DEVICE_OUT_WIRED_HEADPHONE ||
                out_device & AUDIO_DEVICE_OUT_EARPIECE ||
                out_device & AUDIO_DEVICE_OUT_SPEAKER )
@@ -4665,8 +4682,10 @@
     if (snd_device != AUDIO_DEVICE_NONE)
         goto exit;
 
-    if ((out_device != AUDIO_DEVICE_NONE) && ((mode == AUDIO_MODE_IN_CALL) || voice_is_in_call(adev) ||
-        voice_extn_compress_voip_is_active(adev) || audio_extn_hfp_is_active(adev))) {
+    if ((out_device != AUDIO_DEVICE_NONE) && ((mode == AUDIO_MODE_IN_CALL) ||
+        voice_check_voicecall_usecases_active(adev) ||
+        voice_extn_compress_voip_is_active(adev) ||
+        audio_extn_hfp_is_active(adev))) {
         if ((adev->voice.tty_mode != TTY_MODE_OFF) &&
             !voice_extn_compress_voip_is_active(adev)) {
             if (out_device & AUDIO_DEVICE_OUT_WIRED_HEADPHONE ||
@@ -4834,7 +4853,7 @@
                 snd_device = SND_DEVICE_IN_QUAD_MIC;
             }
             if (snd_device == SND_DEVICE_NONE) {
-                if (adev->active_input->enable_ns)
+                if (in != NULL && in->enable_ns)
                     snd_device = SND_DEVICE_IN_VOICE_REC_MIC_NS;
                 else
                     snd_device = SND_DEVICE_IN_VOICE_REC_MIC;
@@ -4876,16 +4895,15 @@
         in_device = ((out_device == AUDIO_DEVICE_NONE) ?
                       AUDIO_DEVICE_IN_BUILTIN_MIC : in_device) & ~AUDIO_DEVICE_BIT_IN;
 
-        if (adev->active_input) {
+        if (in)
             snd_device = get_snd_device_for_voice_comm(my_data, out_device, in_device);
-        }
     } else if (source == AUDIO_SOURCE_MIC) {
         if (in_device & AUDIO_DEVICE_IN_BUILTIN_MIC &&
                 channel_count == 1) {
             if(my_data->fluence_in_audio_rec) {
                 if ((my_data->fluence_type & FLUENCE_HEX_MIC) &&
                     (my_data->source_mic_type & SOURCE_HEX_MIC) &&
-                    (audio_extn_ffv_get_stream() == adev->active_input)) {
+                    (audio_extn_ffv_get_stream() == in)) {
                     snd_device = audio_extn_ffv_get_capture_snd_device();
                 } else if ((my_data->fluence_type & FLUENCE_QUAD_MIC) &&
                     (my_data->source_mic_type & SOURCE_QUAD_MIC)) {
@@ -4907,7 +4925,7 @@
         goto exit;
     }
 
-    if (adev->active_input && (audio_extn_ssr_get_stream() == adev->active_input))
+    if (in && (audio_extn_ssr_get_stream() == in))
         snd_device = SND_DEVICE_IN_THREE_MIC;
 
     if (snd_device != SND_DEVICE_NONE) {
@@ -4918,7 +4936,7 @@
             !(in_device & AUDIO_DEVICE_IN_VOICE_CALL) &&
             !(in_device & AUDIO_DEVICE_IN_COMMUNICATION)) {
         if (in_device & AUDIO_DEVICE_IN_BUILTIN_MIC) {
-            if (adev->active_input && (audio_extn_ssr_get_stream() == adev->active_input))
+            if (in && (audio_extn_ssr_get_stream() == in))
                 snd_device = SND_DEVICE_IN_QUAD_MIC;
             else if ((my_data->fluence_type & (FLUENCE_DUAL_MIC | FLUENCE_TRI_MIC | FLUENCE_QUAD_MIC)) &&
                     (channel_count == 2) && (my_data->source_mic_type & SOURCE_DUAL_MIC))
@@ -5243,9 +5261,9 @@
             goto done_key_audcal;
         }
 
-        if(cal.dev_id) {
-          if(audio_is_input_device(cal.dev_id)) {
-              cal.snd_dev_id = platform_get_input_snd_device(platform, cal.dev_id);
+        if (cal.dev_id) {
+          if (audio_is_input_device(cal.dev_id)) {
+              cal.snd_dev_id = platform_get_input_snd_device(platform, NULL, cal.dev_id);
           } else {
               out.devices = cal.dev_id;
               out.sample_rate = cal.sampling_rate;
@@ -5569,7 +5587,7 @@
     }
 
     if(cal.dev_id & AUDIO_DEVICE_BIT_IN) {
-        cal.snd_dev_id = platform_get_input_snd_device(platform, cal.dev_id);
+        cal.snd_dev_id = platform_get_input_snd_device(platform, NULL, cal.dev_id);
     } else if(cal.dev_id) {
         out.devices = cal.dev_id;
         out.sample_rate = cal.sampling_rate;
@@ -8530,7 +8548,7 @@
     size_t actual_mic_count = 0;
 
     snd_device_t active_input_snd_device =
-            platform_get_input_snd_device(platform, usecase->stream.in->device);
+            platform_get_input_snd_device(platform, usecase->stream.in, AUDIO_DEVICE_NONE);
     if (active_input_snd_device == SND_DEVICE_NONE) {
         ALOGI("%s: No active microphones found", __func__);
         goto end;
diff --git a/hal/msm8916/platform.h b/hal/msm8916/platform.h
index e337870..3c94532 100644
--- a/hal/msm8916/platform.h
+++ b/hal/msm8916/platform.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013-2018, The Linux Foundation. All rights reserved.
+ * Copyright (c) 2013-2019, The Linux Foundation. All rights reserved.
  * Not a Contribution.
  *
  * Copyright (C) 2013 The Android Open Source Project
@@ -246,6 +246,11 @@
     SND_DEVICE_IN_INCALL_REC_TX,
     SND_DEVICE_IN_INCALL_REC_RX_TX,
     SND_DEVICE_IN_LINE,
+    SND_DEVICE_IN_EC_REF_LOOPBACK,
+    SND_DEVICE_IN_HANDSET_DMIC_AND_EC_REF_LOOPBACK,
+    SND_DEVICE_IN_HANDSET_QMIC_AND_EC_REF_LOOPBACK,
+    SND_DEVICE_IN_HANDSET_6MIC_AND_EC_REF_LOOPBACK,
+    SND_DEVICE_IN_HANDSET_8MIC_AND_EC_REF_LOOPBACK,
     SND_DEVICE_IN_END,
 
     SND_DEVICE_MAX = SND_DEVICE_IN_END,
diff --git a/hal/msm8960/platform.c b/hal/msm8960/platform.c
index 0a81969..137e700 100644
--- a/hal/msm8960/platform.c
+++ b/hal/msm8960/platform.c
@@ -374,6 +374,20 @@
     return -ENOSYS;
 }
 
+struct audio_custom_mtmx_in_params *platform_get_custom_mtmx_in_params(void *platform,
+                                   struct audio_custom_mtmx_in_params_info *info)
+{
+    ALOGW("%s: not implemented!", __func__);
+    return -ENOSYS;
+}
+
+int platform_add_custom_mtmx_in_params(void *platform,
+                                    struct audio_custom_mtmx_in_params_info *info)
+{
+    ALOGW("%s: not implemented!", __func__);
+    return -ENOSYS;
+}
+
 void platform_deinit(void *platform)
 {
     struct platform_data *my_data = (struct platform_data *)platform;
@@ -536,7 +550,7 @@
                    voice_is_in_call_rec_stream(usecase->stream.in))
         snd_device = voice_get_incall_rec_snd_device(usecase->in_snd_device);
     else if ((usecase->type == PCM_HFP_CALL) || (usecase->type == PCM_CAPTURE))
-        snd_device = platform_get_input_snd_device(adev->platform,
+        snd_device = platform_get_input_snd_device(adev->platform, NULL,
                                             adev->primary_output->devices);
     acdb_dev_id = acdb_device_table[snd_device];
     if (acdb_dev_id < 0) {
@@ -794,21 +808,23 @@
     return snd_device;
 }
 
-snd_device_t platform_get_input_snd_device(void *platform, audio_devices_t out_device)
+snd_device_t platform_get_input_snd_device(void *platform,
+                                           struct stream_in *in,
+                                           audio_devices_t out_device)
 {
     struct platform_data *my_data = (struct platform_data *)platform;
     struct audio_device *adev = my_data->adev;
-    audio_source_t  source = (adev->active_input == NULL) ?
-                                AUDIO_SOURCE_DEFAULT : adev->active_input->source;
-
-    audio_mode_t    mode   = adev->mode;
-    audio_devices_t in_device = ((adev->active_input == NULL) ?
-                                    AUDIO_DEVICE_NONE : adev->active_input->device)
-                                & ~AUDIO_DEVICE_BIT_IN;
-    audio_channel_mask_t channel_mask = (adev->active_input == NULL) ?
-                                AUDIO_CHANNEL_IN_MONO : adev->active_input->channel_mask;
+    audio_mode_t mode = adev->mode;
     snd_device_t snd_device = SND_DEVICE_NONE;
 
+    if (in == NULL)
+        in = adev_get_active_input(adev);
+
+    audio_source_t source = (in == NULL) ? AUDIO_SOURCE_DEFAULT : in->source;
+    audio_devices_t in_device =
+        ((in == NULL) ? AUDIO_DEVICE_NONE : in->device) & ~AUDIO_DEVICE_BIT_IN;
+    audio_channel_mask_t channel_mask = (in == NULL) ? AUDIO_CHANNEL_IN_MONO : in->channel_mask;
+
     ALOGV("%s: enter: out_device(%#x) in_device(%#x)",
           __func__, out_device, in_device);
     if ((out_device != AUDIO_DEVICE_NONE) && (mode == AUDIO_MODE_IN_CALL)) {
@@ -882,8 +898,8 @@
     } else if (source == AUDIO_SOURCE_VOICE_COMMUNICATION) {
         if (out_device & AUDIO_DEVICE_OUT_SPEAKER)
             in_device = AUDIO_DEVICE_IN_BACK_MIC;
-        if (adev->active_input) {
-            if (adev->active_input->enable_aec) {
+        if (in) {
+            if (in->enable_aec) {
                 if (in_device & AUDIO_DEVICE_IN_BACK_MIC) {
                     snd_device = SND_DEVICE_IN_SPEAKER_MIC_AEC;
                 } else if (in_device & AUDIO_DEVICE_IN_BUILTIN_MIC) {
diff --git a/hal/msm8960/platform.h b/hal/msm8960/platform.h
index 727f906..2c66208 100644
--- a/hal/msm8960/platform.h
+++ b/hal/msm8960/platform.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013 - 2018 The Linux Foundation. All rights reserved.
+ * Copyright (c) 2013 - 2019 The Linux Foundation. All rights reserved.
  * Not a contribution.
  *
  * Copyright (C) 2013 The Android Open Source Project
@@ -104,6 +104,11 @@
     SND_DEVICE_IN_VOICE_REC_DMIC,
     SND_DEVICE_IN_VOICE_REC_DMIC_FLUENCE,
     SND_DEVICE_IN_USB_HEADSET_MIC,
+    SND_DEVICE_IN_EC_REF_LOOPBACK,
+    SND_DEVICE_IN_HANDSET_DMIC_AND_EC_REF_LOOPBACK,
+    SND_DEVICE_IN_HANDSET_QMIC_AND_EC_REF_LOOPBACK,
+    SND_DEVICE_IN_HANDSET_6MIC_AND_EC_REF_LOOPBACK,
+    SND_DEVICE_IN_HANDSET_8MIC_AND_EC_REF_LOOPBACK,
     SND_DEVICE_IN_END,
 
     SND_DEVICE_MAX = SND_DEVICE_IN_END,
diff --git a/hal/msm8974/hw_info.c b/hal/msm8974/hw_info.c
index e77ab83..7dfa819 100755
--- a/hal/msm8974/hw_info.c
+++ b/hal/msm8974/hw_info.c
@@ -688,6 +688,9 @@
     } else if (!strncmp(snd_card_name, "sm6150-idp-snd-card",
                  sizeof("sm6150-idp-snd-card"))) {
         strlcpy(hw_info->name, "sm6150", sizeof(hw_info->name));
+    } else if (!strncmp(snd_card_name, "sm6150-wcd9375-snd-card",
+                 sizeof("sm6150-wcd9375-snd-card"))) {
+        strlcpy(hw_info->name, "sm6150", sizeof(hw_info->name));
     } else if (!strncmp(snd_card_name, "sm6150-qrd-snd-card",
                  sizeof("sm6150-qrd-snd-card"))) {
         hw_info->is_stereo_spkr = false;
diff --git a/hal/msm8974/platform.c b/hal/msm8974/platform.c
index 9ee58cb..1b14d63 100644
--- a/hal/msm8974/platform.c
+++ b/hal/msm8974/platform.c
@@ -350,6 +350,7 @@
     struct  spkr_device_chmap *spkr_ch_map;
     bool use_sprk_default_sample_rate;
     struct listnode custom_mtmx_params_list;
+    struct listnode custom_mtmx_in_params_list;
 };
 
 struct  spkr_device_chmap {
@@ -469,6 +470,15 @@
     [USECASE_AUDIO_PLAYBACK_INTERACTIVE_STREAM8] =
                      {PLAYBACK_INTERACTIVE_STRM_DEVICE8, PLAYBACK_INTERACTIVE_STRM_DEVICE8},
     [USECASE_AUDIO_EC_REF_LOOPBACK] = {-1, -1}, /* pcm id updated from platform info file */
+    [USECASE_AUDIO_PLAYBACK_MEDIA] = {MEDIA_PCM_DEVICE,
+                                      MEDIA_PCM_DEVICE},
+    [USECASE_AUDIO_PLAYBACK_SYS_NOTIFICATION] = {SYS_NOTIFICATION_PCM_DEVICE,
+                                                 SYS_NOTIFICATION_PCM_DEVICE},
+    [USECASE_AUDIO_PLAYBACK_NAV_GUIDANCE] = {NAV_GUIDANCE_PCM_DEVICE,
+                                             NAV_GUIDANCE_PCM_DEVICE},
+    [USECASE_AUDIO_PLAYBACK_PHONE] = {PHONE_PCM_DEVICE,
+                                      PHONE_PCM_DEVICE},
+
 };
 
 /* Array to store sound devices */
@@ -517,7 +527,9 @@
     [SND_DEVICE_OUT_SPEAKER_SAFE_AND_BT_A2DP] = "speaker-safe-and-bt-a2dp",
     [SND_DEVICE_OUT_VOICE_HANDSET_TMUS] = "voice-handset-tmus",
     [SND_DEVICE_OUT_VOICE_TTY_FULL_HEADPHONES] = "voice-tty-full-headphones",
+    [SND_DEVICE_OUT_VOICE_TTY_FULL_HEADSET] = "voice-tty-full-headset",
     [SND_DEVICE_OUT_VOICE_TTY_VCO_HEADPHONES] = "voice-tty-vco-headphones",
+    [SND_DEVICE_OUT_VOICE_TTY_VCO_HEADSET] = "voice-tty-vco-headset",
     [SND_DEVICE_OUT_VOICE_TTY_HCO_HANDSET] = "voice-tty-hco-handset",
     [SND_DEVICE_OUT_VOICE_TTY_FULL_USB] = "voice-tty-full-usb",
     [SND_DEVICE_OUT_VOICE_TTY_VCO_USB] = "voice-tty-vco-usb",
@@ -565,6 +577,10 @@
     [SND_DEVICE_OUT_SPEAKER_WSA_AND_BT_SCO_WB] = "wsa-speaker-and-bt-sco-wb",
     [SND_DEVICE_OUT_SPEAKER_WSA_AND_BT_SCO_SWB] = "wsa-speaker-and-bt-sco-wb",
     [SND_DEVICE_OUT_VOICE_HEARING_AID] = "hearing-aid",
+    [SND_DEVICE_OUT_BUS_MEDIA] = "bus-speaker",
+    [SND_DEVICE_OUT_BUS_SYS] = "bus-speaker",
+    [SND_DEVICE_OUT_BUS_NAV] = "bus-speaker",
+    [SND_DEVICE_OUT_BUS_PHN] = "bus-speaker",
 
     /* Capture sound devices */
     [SND_DEVICE_IN_HANDSET_MIC] = "handset-mic",
@@ -697,6 +713,12 @@
     [SND_DEVICE_OUT_VOIP_SPEAKER] = "voip-speaker",
     [SND_DEVICE_OUT_VOIP_HEADPHONES] = "voip-headphones",
     [SND_DEVICE_IN_VOICE_HEARING_AID] = "hearing-aid-mic",
+    [SND_DEVICE_IN_BUS] = "bus-mic",
+    [SND_DEVICE_IN_EC_REF_LOOPBACK] = "ec-ref-loopback",
+    [SND_DEVICE_IN_HANDSET_DMIC_AND_EC_REF_LOOPBACK] = "handset-dmic-and-ec-ref-loopback",
+    [SND_DEVICE_IN_HANDSET_QMIC_AND_EC_REF_LOOPBACK] = "handset-qmic-and-ec-ref-loopback",
+    [SND_DEVICE_IN_HANDSET_6MIC_AND_EC_REF_LOOPBACK] = "handset-6mic-and-ec-ref-loopback",
+    [SND_DEVICE_IN_HANDSET_8MIC_AND_EC_REF_LOOPBACK] = "handset-8mic-and-ec-ref-loopback",
 };
 
 // Platform specific backend bit width table
@@ -786,7 +808,9 @@
     [SND_DEVICE_OUT_SPEAKER_SAFE_AND_BT_A2DP] = 14,
     [SND_DEVICE_OUT_VOICE_HANDSET_TMUS] = 88,
     [SND_DEVICE_OUT_VOICE_TTY_FULL_HEADPHONES] = 17,
+    [SND_DEVICE_OUT_VOICE_TTY_FULL_HEADSET] = 17,
     [SND_DEVICE_OUT_VOICE_TTY_VCO_HEADPHONES] = 17,
+    [SND_DEVICE_OUT_VOICE_TTY_VCO_HEADSET] = 17,
     [SND_DEVICE_OUT_VOICE_TTY_HCO_HANDSET] = 37,
     [SND_DEVICE_OUT_VOICE_TTY_FULL_USB] = 17,
     [SND_DEVICE_OUT_VOICE_TTY_VCO_USB] = 17,
@@ -819,6 +843,10 @@
     [SND_DEVICE_OUT_SPEAKER_PROTECTED_RAS] = 134,
     [SND_DEVICE_OUT_SPEAKER_PROTECTED_VBAT_RAS] = 134,
     [SND_DEVICE_OUT_VOICE_HEARING_AID] = 45,
+    [SND_DEVICE_OUT_BUS_MEDIA] = 78,
+    [SND_DEVICE_OUT_BUS_SYS] = 78,
+    [SND_DEVICE_OUT_BUS_NAV] = 14,
+    [SND_DEVICE_OUT_BUS_PHN] = 94,
     [SND_DEVICE_IN_HANDSET_MIC] = 4,
     [SND_DEVICE_IN_HANDSET_MIC_SB] = 163,
     [SND_DEVICE_IN_HANDSET_MIC_EXTERNAL] = 4,
@@ -946,6 +974,7 @@
     [SND_DEVICE_IN_CAMCORDER_SELFIE_INVERT_LANDSCAPE] = 4,
     [SND_DEVICE_IN_CAMCORDER_SELFIE_PORTRAIT] = 4,
     [SND_DEVICE_IN_VOICE_HEARING_AID] = 44,
+    [SND_DEVICE_IN_BUS] = 11,
 };
 
 struct name_to_index {
@@ -977,6 +1006,7 @@
     {TO_NAME_INDEX(SND_DEVICE_OUT_SPEAKER_AND_HEADPHONES_EXTERNAL_2)},
     {TO_NAME_INDEX(SND_DEVICE_OUT_VOICE_HANDSET)},
     {TO_NAME_INDEX(SND_DEVICE_OUT_VOICE_SPEAKER)},
+    {TO_NAME_INDEX(SND_DEVICE_OUT_VOICE_SPEAKER_STEREO)},
     {TO_NAME_INDEX(SND_DEVICE_OUT_VOICE_SPEAKER_WSA)},
     {TO_NAME_INDEX(SND_DEVICE_OUT_VOICE_SPEAKER_HFP)},
     {TO_NAME_INDEX(SND_DEVICE_OUT_VOICE_SPEAKER_VBAT)},
@@ -1002,7 +1032,9 @@
     {TO_NAME_INDEX(SND_DEVICE_OUT_VOICE_HANDSET_TMUS)},
     {TO_NAME_INDEX(SND_DEVICE_OUT_VOICE_HAC_HANDSET)},
     {TO_NAME_INDEX(SND_DEVICE_OUT_VOICE_TTY_FULL_HEADPHONES)},
+    {TO_NAME_INDEX(SND_DEVICE_OUT_VOICE_TTY_FULL_HEADSET)},
     {TO_NAME_INDEX(SND_DEVICE_OUT_VOICE_TTY_VCO_HEADPHONES)},
+    {TO_NAME_INDEX(SND_DEVICE_OUT_VOICE_TTY_VCO_HEADSET)},
     {TO_NAME_INDEX(SND_DEVICE_OUT_VOICE_TTY_HCO_HANDSET)},
     {TO_NAME_INDEX(SND_DEVICE_OUT_SPEAKER_AND_BT_SCO)},
     {TO_NAME_INDEX(SND_DEVICE_OUT_SPEAKER_AND_BT_SCO_WB)},
@@ -1042,6 +1074,10 @@
     {TO_NAME_INDEX(SND_DEVICE_OUT_VOIP_SPEAKER)},
     {TO_NAME_INDEX(SND_DEVICE_OUT_VOIP_HEADPHONES)},
     {TO_NAME_INDEX(SND_DEVICE_OUT_VOICE_HEARING_AID)},
+    {TO_NAME_INDEX(SND_DEVICE_OUT_BUS_MEDIA)},
+    {TO_NAME_INDEX(SND_DEVICE_OUT_BUS_SYS)},
+    {TO_NAME_INDEX(SND_DEVICE_OUT_BUS_NAV)},
+    {TO_NAME_INDEX(SND_DEVICE_OUT_BUS_PHN)},
     {TO_NAME_INDEX(SND_DEVICE_IN_HANDSET_MIC)},
     {TO_NAME_INDEX(SND_DEVICE_IN_HANDSET_MIC_SB)},
     {TO_NAME_INDEX(SND_DEVICE_IN_HANDSET_MIC_EXTERNAL)},
@@ -1171,6 +1207,12 @@
     {TO_NAME_INDEX(SND_DEVICE_IN_CAMCORDER_SELFIE_PORTRAIT)},
     /* For legacy xml file parsing */
     {TO_NAME_INDEX(SND_DEVICE_IN_CAMCORDER_MIC)},
+    {TO_NAME_INDEX(SND_DEVICE_IN_BUS)},
+    {TO_NAME_INDEX(SND_DEVICE_IN_EC_REF_LOOPBACK)},
+    {TO_NAME_INDEX(SND_DEVICE_IN_HANDSET_DMIC_AND_EC_REF_LOOPBACK)},
+    {TO_NAME_INDEX(SND_DEVICE_IN_HANDSET_QMIC_AND_EC_REF_LOOPBACK)},
+    {TO_NAME_INDEX(SND_DEVICE_IN_HANDSET_6MIC_AND_EC_REF_LOOPBACK)},
+    {TO_NAME_INDEX(SND_DEVICE_IN_HANDSET_8MIC_AND_EC_REF_LOOPBACK)},
 };
 
 static char * backend_tag_table[SND_DEVICE_MAX] = {0};
@@ -1232,7 +1274,10 @@
     {TO_NAME_INDEX(USECASE_AUDIO_RECORD_VOIP)},
     {TO_NAME_INDEX(USECASE_AUDIO_TRANSCODE_LOOPBACK_RX)},
     {TO_NAME_INDEX(USECASE_AUDIO_TRANSCODE_LOOPBACK_TX)},
-
+    {TO_NAME_INDEX(USECASE_AUDIO_PLAYBACK_MEDIA)},
+    {TO_NAME_INDEX(USECASE_AUDIO_PLAYBACK_SYS_NOTIFICATION)},
+    {TO_NAME_INDEX(USECASE_AUDIO_PLAYBACK_NAV_GUIDANCE)},
+    {TO_NAME_INDEX(USECASE_AUDIO_PLAYBACK_PHONE)},
 };
 
 static const struct name_to_index usecase_type_index[USECASE_TYPE_MAX] = {
@@ -1620,8 +1665,10 @@
          !strncmp(snd_card_name, "sdm439-snd-card-mtp",
                    sizeof("sdm439-snd-card-mtp")) ||
          !strncmp(snd_card_name, "sm6150-wcd9375qrd-snd-card",
-                   sizeof("sm6150-wcd9375qrd-snd-card"))) {
-         ALOGI("%s: snd_card_name: %s", __func__, snd_card_name);
+                   sizeof("sm6150-wcd9375qrd-snd-card")) ||
+         !strncmp(snd_card_name, "sm6150-wcd9375-snd-card",
+                   sizeof("sm6150-wcd9375-snd-card"))) {
+         ALOGI("%s: snd_card_name: %s",__func__,snd_card_name);
          my_data->is_internal_codec = true;
          my_data->is_slimbus_interface = false;
      }
@@ -1652,12 +1699,12 @@
 {
     struct platform_data *my_data = (struct platform_data *)platform;
     struct audio_device *adev = my_data->adev;
-    if (adev->active_input == NULL) {
+    struct stream_in *in = adev_get_active_input(adev);
+    if (in == NULL)
         return base;
-    }
-    unsigned int sr = adev->active_input->sample_rate;
-    unsigned int ch = popcount(adev->active_input->channel_mask);
-    unsigned int bit_width = adev->active_input->bit_width;
+    unsigned int sr = in->sample_rate;
+    unsigned int ch = popcount(in->channel_mask);
+    unsigned int bit_width = in->bit_width;
     if (audio_extn_usb_is_config_supported(&bit_width, &sr, &ch, false)
                                            && ((ch == 6) || (ch == 8))) {
         return other;
@@ -2088,6 +2135,7 @@
     hw_interface_table[SND_DEVICE_OUT_VOICE_HANDSET] = strdup("SLIMBUS_0_RX");
     hw_interface_table[SND_DEVICE_OUT_VOICE_HAC_HANDSET] = strdup("SLIMBUS_0_RX");
     hw_interface_table[SND_DEVICE_OUT_VOICE_SPEAKER] = strdup("SLIMBUS_0_RX");
+    hw_interface_table[SND_DEVICE_OUT_VOICE_SPEAKER_STEREO] = strdup("SLIMBUS_0_RX");
     hw_interface_table[SND_DEVICE_OUT_VOICE_SPEAKER_VBAT] = strdup("SLIMBUS_0_RX");
     hw_interface_table[SND_DEVICE_OUT_VOICE_SPEAKER_2] = strdup("SLIMBUS_0_RX");
     hw_interface_table[SND_DEVICE_OUT_VOICE_SPEAKER_2_VBAT] = strdup("SLIMBUS_0_RX");
@@ -2108,7 +2156,9 @@
         strdup("SLIMBUS_0_RX-and-SLIMBUS_7_RX");
     hw_interface_table[SND_DEVICE_OUT_VOICE_HANDSET_TMUS] = strdup("SLIMBUS_0_RX");
     hw_interface_table[SND_DEVICE_OUT_VOICE_TTY_FULL_HEADPHONES] = strdup("SLIMBUS_6_RX");
+    hw_interface_table[SND_DEVICE_OUT_VOICE_TTY_FULL_HEADSET] = strdup("SLIMBUS_6_RX");
     hw_interface_table[SND_DEVICE_OUT_VOICE_TTY_VCO_HEADPHONES] = strdup("SLIMBUS_6_RX");
+    hw_interface_table[SND_DEVICE_OUT_VOICE_TTY_VCO_HEADSET] = strdup("SLIMBUS_6_RX");
     hw_interface_table[SND_DEVICE_OUT_VOICE_TTY_HCO_HANDSET] = strdup("SLIMBUS_0_RX");
     hw_interface_table[SND_DEVICE_OUT_VOICE_TTY_FULL_USB] = strdup("USB_AUDIO_RX");
     hw_interface_table[SND_DEVICE_OUT_VOICE_TTY_VCO_USB] = strdup("USB_AUDIO_RX");
@@ -2151,6 +2201,10 @@
        Need snd_device to route voice call and use specific acdb tuning.
        Also, BT_RX is a virtual port to indicate bluetooth hearing aid. */
     hw_interface_table[SND_DEVICE_OUT_VOICE_HEARING_AID] = strdup("BT_RX"),
+    hw_interface_table[SND_DEVICE_OUT_BUS_MEDIA] = strdup("TERT_TDM_RX_0");
+    hw_interface_table[SND_DEVICE_OUT_BUS_SYS] = strdup("TERT_TDM_RX_0");
+    hw_interface_table[SND_DEVICE_OUT_BUS_NAV] = strdup("TERT_TDM_RX_1");
+    hw_interface_table[SND_DEVICE_OUT_BUS_PHN] = strdup("TERT_TDM_RX_2");
     hw_interface_table[SND_DEVICE_IN_HANDSET_MIC] = strdup("SLIMBUS_0_TX");
     hw_interface_table[SND_DEVICE_IN_HANDSET_MIC_SB] = strdup("SLIMBUS_0_TX");
     hw_interface_table[SND_DEVICE_IN_HANDSET_MIC_EXTERNAL] = strdup("SLIMBUS_0_TX");
@@ -2277,6 +2331,7 @@
     hw_interface_table[SND_DEVICE_IN_CAMCORDER_SELFIE_INVERT_LANDSCAPE] = strdup("SLIMBUS_0_TX");
     hw_interface_table[SND_DEVICE_IN_CAMCORDER_SELFIE_PORTRAIT] = strdup("SLIMBUS_0_TX");
     hw_interface_table[SND_DEVICE_IN_VOICE_HEARING_AID] = strdup("SLIMBUS_0_TX");
+    hw_interface_table[SND_DEVICE_IN_BUS] = strdup("TERT_TDM_TX_0");
     my_data->max_mic_count = PLATFORM_DEFAULT_MIC_COUNT;
 
      /*remove ALAC & APE from DSP decoder list based on software decoder availability*/
@@ -3051,11 +3106,11 @@
         }
     }
     /* Check for Ambisonic Capture Enablement */
-    if (property_get_bool("persist.vendor.audio.ambisonic.capture",false))
+    if (property_get_bool("vendor.audio.ambisonic.capture",false))
         my_data->ambisonic_capture = true;
 
     /* Check for Ambisonic Profile Assignment*/
-    if (property_get_bool("persist.vendor.audio.ambisonic.auto.profile",false))
+    if (property_get_bool("vendor.audio.ambisonic.auto.profile",false))
         my_data->ambisonic_profile = true;
 
     if (check_and_get_wsa_info((char *)snd_card_name, &wsaCount, &is_wsa_combo_supported)
@@ -3097,6 +3152,7 @@
 
     list_init(&my_data->acdb_meta_key_list);
     list_init(&my_data->custom_mtmx_params_list);
+    list_init(&my_data->custom_mtmx_in_params_list);
 
     ret = audio_extn_is_hifi_audio_supported();
     if (ret || !my_data->is_internal_codec)
@@ -3691,6 +3747,66 @@
     }
 }
 
+struct audio_custom_mtmx_in_params *platform_get_custom_mtmx_in_params(void *platform,
+                                    struct audio_custom_mtmx_in_params_info *info)
+{
+    struct platform_data *my_data = (struct platform_data *)platform;
+    struct listnode *node = NULL;
+    struct audio_custom_mtmx_in_params *params = NULL;
+
+    list_for_each(node, &my_data->custom_mtmx_in_params_list) {
+        params = node_to_item(node, struct audio_custom_mtmx_in_params, list);
+        if (params &&
+            params->in_info.op_channels == info->op_channels &&
+            params->in_info.usecase_id == info->usecase_id) {
+            ALOGV("%s: found params with op_ch %d uc_id %d",
+                  __func__, info->op_channels, info->usecase_id);
+            return params;
+        }
+    }
+
+    ALOGI("%s: no matching param with op_ch %d uc_id %d",
+           __func__, info->op_channels, info->usecase_id);
+    return NULL;
+}
+
+int platform_add_custom_mtmx_in_params(void *platform,
+                                    struct audio_custom_mtmx_in_params_info *info)
+{
+    struct platform_data *my_data = (struct platform_data *)platform;
+    struct audio_custom_mtmx_in_params *params = NULL;
+    uint32_t size = sizeof(*params);
+
+    if (info->op_channels > AUDIO_CHANNEL_COUNT_MAX) {
+        ALOGE("%s: unusupported channels in %d", __func__, info->op_channels);
+        return -EINVAL;
+    }
+
+    params = (struct audio_custom_mtmx_in_params *)calloc(1, size);
+    if (!params) {
+        ALOGE("%s: failed to add custom mtmx in params", __func__);
+        return -ENOMEM;
+    }
+
+    ALOGI("%s: adding mtmx in params with op_ch %d uc_id %d",
+          __func__, info->op_channels, info->usecase_id);
+
+    params->in_info = *info;
+    list_add_tail(&my_data->custom_mtmx_in_params_list, &params->list);
+    return 0;
+}
+
+static void platform_release_custom_mtmx_in_params(void *platform)
+{
+    struct platform_data *my_data = (struct platform_data *)platform;
+    struct listnode *node = NULL, *tempnode = NULL;
+
+    list_for_each_safe(node, tempnode, &my_data->custom_mtmx_in_params_list) {
+        list_remove(node);
+        free(node_to_item(node, struct audio_custom_mtmx_in_params, list));
+    }
+}
+
 void platform_release_acdb_metainfo_key(void *platform)
 {
     struct platform_data *my_data = (struct platform_data *)platform;
@@ -3840,6 +3956,7 @@
     /* free acdb_meta_key_list */
     platform_release_acdb_metainfo_key(platform);
     platform_release_custom_mtmx_params(platform);
+    platform_release_custom_mtmx_in_params(platform);
 
     if (my_data->acdb_deallocate)
         my_data->acdb_deallocate();
@@ -4697,6 +4814,9 @@
                 else if (strncmp(backend_tag_table[snd_device], "headphones",
                             sizeof("headphones")) == 0)
                         port = HEADPHONE_BACKEND;
+                else if (strncmp(backend_tag_table[snd_device], "headset",
+                            sizeof("headset")) == 0)
+                        port = HEADPHONE_BACKEND;
                 else if (strcmp(backend_tag_table[snd_device], "hdmi") == 0)
                         port = HDMI_RX_BACKEND;
                 else if (strcmp(backend_tag_table[snd_device], "display-port") == 0)
@@ -4845,6 +4965,7 @@
         return ret;
 
     if ((out_snd_device == SND_DEVICE_OUT_VOICE_SPEAKER ||
+         out_snd_device == SND_DEVICE_OUT_VOICE_SPEAKER_STEREO ||
          out_snd_device == SND_DEVICE_OUT_VOICE_SPEAKER_2 ||
          out_snd_device == SND_DEVICE_OUT_VOICE_SPEAKER_VBAT ||
          out_snd_device == SND_DEVICE_OUT_VOICE_SPEAKER_2_VBAT) &&
@@ -5377,8 +5498,29 @@
         new_snd_devices[0] = SND_DEVICE_IN_INCALL_REC_RX;
         new_snd_devices[1] = SND_DEVICE_IN_INCALL_REC_TX;
         ret = 0;
+    } else if (SND_DEVICE_IN_HANDSET_DMIC_AND_EC_REF_LOOPBACK == snd_device) {
+        *num_devices = 2;
+        new_snd_devices[0] = SND_DEVICE_IN_HANDSET_DMIC;
+        new_snd_devices[1] = SND_DEVICE_IN_EC_REF_LOOPBACK;
+        ret = 0;
+    } else if (SND_DEVICE_IN_HANDSET_QMIC_AND_EC_REF_LOOPBACK == snd_device) {
+        *num_devices = 2;
+        new_snd_devices[0] = SND_DEVICE_IN_UNPROCESSED_QUAD_MIC;
+        new_snd_devices[1] = SND_DEVICE_IN_EC_REF_LOOPBACK;
+        ret = 0;
+    } else if (SND_DEVICE_IN_HANDSET_6MIC_AND_EC_REF_LOOPBACK == snd_device) {
+        *num_devices = 2;
+        new_snd_devices[0] = SND_DEVICE_IN_HANDSET_6MIC;
+        new_snd_devices[1] = SND_DEVICE_IN_EC_REF_LOOPBACK;
+        ret = 0;
+    } else if (SND_DEVICE_IN_HANDSET_8MIC_AND_EC_REF_LOOPBACK == snd_device) {
+        *num_devices = 2;
+        new_snd_devices[0] = SND_DEVICE_IN_HANDSET_8MIC;
+        new_snd_devices[1] = SND_DEVICE_IN_EC_REF_LOOPBACK;
+        ret = 0;
     }
 
+
     ALOGD("%s: snd_device(%d) num devices(%d) new_snd_devices(%d)", __func__,
         snd_device, *num_devices, *new_snd_devices);
 
@@ -5430,9 +5572,10 @@
     audio_devices_t devices = out->devices;
     unsigned int sample_rate = out->sample_rate;
     int na_mode = platform_get_native_support();
+    struct stream_in *in = adev_get_active_input(adev);
 
-    audio_channel_mask_t channel_mask = (adev->active_input == NULL) ?
-                                AUDIO_CHANNEL_IN_MONO : adev->active_input->channel_mask;
+    audio_channel_mask_t channel_mask = (in == NULL) ?
+                                AUDIO_CHANNEL_IN_MONO : in->channel_mask;
     int channel_count = popcount(channel_mask);
 
     ALOGV("%s: enter: output devices(%#x)", __func__, devices);
@@ -5451,7 +5594,7 @@
         * enforced audible (e.g. Camera shutter sound).
         */
         if ((mode == AUDIO_MODE_IN_CALL) ||
-            voice_is_in_call(adev) ||
+            voice_check_voicecall_usecases_active(adev) ||
             voice_extn_compress_voip_is_active(adev))
                 is_active_voice_call = true;
 
@@ -5575,7 +5718,7 @@
     }
 
     if ((mode == AUDIO_MODE_IN_CALL) ||
-        voice_is_in_call(adev) ||
+        voice_check_voicecall_usecases_active(adev) ||
         voice_extn_compress_voip_is_active(adev) ||
         adev->enable_voicerx ||
         audio_extn_hfp_is_active(adev)) {
@@ -5586,10 +5729,22 @@
                 !voice_extn_compress_voip_is_active(adev)) {
                 switch (adev->voice.tty_mode) {
                 case TTY_MODE_FULL:
-                    snd_device = SND_DEVICE_OUT_VOICE_TTY_FULL_HEADPHONES;
+                    if (audio_extn_is_concurrent_capture_enabled() &&
+                         (devices & AUDIO_DEVICE_OUT_WIRED_HEADSET)) {
+                        //Separate backend is added for headset-mic as part of concurrent capture
+                        snd_device = SND_DEVICE_OUT_VOICE_TTY_FULL_HEADSET;
+                    } else {
+                        snd_device = SND_DEVICE_OUT_VOICE_TTY_FULL_HEADPHONES;
+                    }
                     break;
                 case TTY_MODE_VCO:
-                    snd_device = SND_DEVICE_OUT_VOICE_TTY_VCO_HEADPHONES;
+                    if (audio_extn_is_concurrent_capture_enabled() &&
+                         (devices & AUDIO_DEVICE_OUT_WIRED_HEADSET)) {
+                        //Separate backend is added for headset-mic as part of concurrent capture
+                        snd_device = SND_DEVICE_OUT_VOICE_TTY_VCO_HEADSET;
+                    } else {
+                        snd_device = SND_DEVICE_OUT_VOICE_TTY_VCO_HEADPHONES;
+                    }
                     break;
                 case TTY_MODE_HCO:
                     snd_device = SND_DEVICE_OUT_VOICE_TTY_HCO_HANDSET;
@@ -5818,6 +5973,8 @@
         ALOGD("%s: setting sink capability(%d) for Proxy", __func__, channel_count);
         snd_device = SND_DEVICE_OUT_AFE_PROXY;
         audio_extn_set_afe_proxy_channel_mixer(adev, channel_count, snd_device);
+    } else if (devices & AUDIO_DEVICE_OUT_BUS) {
+        snd_device = audio_extn_auto_hal_get_snd_device_for_car_audio_stream(out);
     } else {
         ALOGE("%s: Unknown device(s) %#x", __func__, devices);
     }
@@ -5827,7 +5984,8 @@
 }
 
 static snd_device_t get_snd_device_for_voice_comm_ecns_enabled(struct platform_data *my_data,
-                                                  audio_devices_t out_device,
+                                                  struct stream_in *in,
+                                                  audio_devices_t out_device __unused,
                                                   audio_devices_t in_device)
 {
     struct audio_device *adev = my_data->adev;
@@ -5873,20 +6031,20 @@
     } else if (in_device & AUDIO_DEVICE_IN_WIRED_HEADSET) {
         snd_device = SND_DEVICE_IN_HEADSET_MIC;
     }
-    platform_set_echo_reference(adev, true, out_device);
+    in->enable_ec_port = true;
 
     return snd_device;
 }
 
 static snd_device_t get_snd_device_for_voice_comm_ecns_disabled(struct platform_data *my_data,
+                                                  struct stream_in *in,
                                                   audio_devices_t out_device,
                                                   audio_devices_t in_device)
 {
     struct audio_device *adev = my_data->adev;
     snd_device_t snd_device = SND_DEVICE_NONE;
 
-    if (adev->active_input->enable_aec &&
-        adev->active_input->enable_ns) {
+    if (in != NULL && in->enable_aec && in->enable_ns) {
         if (in_device & AUDIO_DEVICE_IN_BACK_MIC) {
             if (my_data->fluence_in_spkr_mode) {
                 if ((my_data->fluence_type & FLUENCE_QUAD_MIC) &&
@@ -5931,8 +6089,7 @@
         } else if (audio_extn_usb_connected(NULL) && audio_is_usb_in_device(in_device | AUDIO_DEVICE_BIT_IN)) {
             snd_device = SND_DEVICE_IN_USB_HEADSET_MIC_AEC;
         }
-        platform_set_echo_reference(adev, true, out_device);
-    } else if (adev->active_input->enable_aec) {
+    } else if (in != NULL && in->enable_aec) {
         if (in_device & AUDIO_DEVICE_IN_BACK_MIC) {
             if (my_data->fluence_in_spkr_mode) {
                 if ((my_data->fluence_type & FLUENCE_QUAD_MIC) &&
@@ -5975,8 +6132,7 @@
         } else if (audio_extn_usb_connected(NULL) && audio_is_usb_in_device(in_device | AUDIO_DEVICE_BIT_IN)) {
             snd_device = SND_DEVICE_IN_USB_HEADSET_MIC_AEC;
         }
-        platform_set_echo_reference(adev, true, out_device);
-    } else if (adev->active_input->enable_ns) {
+    } else if (in != NULL && in->enable_ns) {
         if (in_device & AUDIO_DEVICE_IN_BACK_MIC) {
             if (my_data->fluence_in_spkr_mode) {
                 if ((my_data->fluence_type & FLUENCE_QUAD_MIC) &&
@@ -6025,42 +6181,44 @@
 }
 
 static snd_device_t get_snd_device_for_voice_comm(struct platform_data *my_data,
+                                                  struct stream_in *in,
                                                   audio_devices_t out_device,
                                                   audio_devices_t in_device)
 {
     if(voice_extn_is_dynamic_ecns_enabled())
-        return get_snd_device_for_voice_comm_ecns_enabled(my_data, out_device, in_device);
+        return get_snd_device_for_voice_comm_ecns_enabled(my_data, in, out_device, in_device);
     else
-        return get_snd_device_for_voice_comm_ecns_disabled(my_data, out_device, in_device);
+        return get_snd_device_for_voice_comm_ecns_disabled(my_data, in, out_device, in_device);
 }
 
-snd_device_t platform_get_input_snd_device(void *platform, audio_devices_t out_device)
+snd_device_t platform_get_input_snd_device(void *platform,
+                                           struct stream_in *in,
+                                           audio_devices_t out_device)
 {
     struct platform_data *my_data = (struct platform_data *)platform;
     struct audio_device *adev = my_data->adev;
-    /*
-     * TODO: active_input always points to last opened input. Source returned will
-     * be wrong if more than one active inputs are present.
-     */
-    audio_source_t  source = (adev->active_input == NULL) ?
-                                AUDIO_SOURCE_DEFAULT : adev->active_input->source;
-
-    audio_mode_t    mode   = adev->mode;
-    audio_devices_t in_device = ((adev->active_input == NULL) ?
-                                    AUDIO_DEVICE_NONE : adev->active_input->device)
-                                & ~AUDIO_DEVICE_BIT_IN;
-    audio_channel_mask_t channel_mask = (adev->active_input == NULL) ?
-                                AUDIO_CHANNEL_IN_MONO : adev->active_input->channel_mask;
+    audio_mode_t mode = adev->mode;
     snd_device_t snd_device = SND_DEVICE_NONE;
-    int channel_count = popcount(channel_mask);
-    int str_bitwidth = (adev->active_input == NULL) ?
-                 CODEC_BACKEND_DEFAULT_BIT_WIDTH : adev->active_input->bit_width;
+
+    if (in == NULL)
+        in = adev_get_active_input(adev);
+
+    audio_source_t source = (in == NULL) ? AUDIO_SOURCE_DEFAULT : in->source;
+    audio_devices_t in_device =
+        ((in == NULL) ? AUDIO_DEVICE_NONE : in->device) & ~AUDIO_DEVICE_BIT_IN;
+    audio_channel_mask_t channel_mask = (in == NULL) ? AUDIO_CHANNEL_IN_MONO : in->channel_mask;
+    int channel_count = audio_channel_count_from_in_mask(channel_mask);
+    int str_bitwidth = (in == NULL) ? CODEC_BACKEND_DEFAULT_BIT_WIDTH : in->bit_width;
+    int sample_rate = (in == NULL) ? 8000 : in->sample_rate;
+    struct audio_usecase *usecase = NULL;
 
     ALOGV("%s: enter: out_device(%#x) in_device(%#x) channel_count (%d) channel_mask (0x%x)",
           __func__, out_device, in_device, channel_count, channel_mask);
     if (my_data->external_mic) {
-        if ((out_device != AUDIO_DEVICE_NONE) && ((mode == AUDIO_MODE_IN_CALL) || voice_is_in_call(adev) ||
-            voice_extn_compress_voip_is_active(adev) || audio_extn_hfp_is_active(adev))) {
+        if ((out_device != AUDIO_DEVICE_NONE) && ((mode == AUDIO_MODE_IN_CALL) ||
+            voice_check_voicecall_usecases_active(adev) ||
+            voice_extn_compress_voip_is_active(adev) ||
+            audio_extn_hfp_is_active(adev))) {
             if (out_device & AUDIO_DEVICE_OUT_WIRED_HEADPHONE ||
                out_device & AUDIO_DEVICE_OUT_EARPIECE ||
                out_device & AUDIO_DEVICE_OUT_SPEAKER )
@@ -6074,8 +6232,10 @@
     if (snd_device != AUDIO_DEVICE_NONE)
         goto exit;
 
-    if ((out_device != AUDIO_DEVICE_NONE) && ((mode == AUDIO_MODE_IN_CALL) || voice_is_in_call(adev) ||
-        voice_extn_compress_voip_is_active(adev) || audio_extn_hfp_is_active(adev))) {
+    if ((out_device != AUDIO_DEVICE_NONE) && ((mode == AUDIO_MODE_IN_CALL) ||
+        voice_check_voicecall_usecases_active(adev) ||
+        voice_extn_compress_voip_is_active(adev) ||
+        audio_extn_hfp_is_active(adev))) {
         if ((adev->voice.tty_mode != TTY_MODE_OFF) &&
             !voice_extn_compress_voip_is_active(adev)) {
             if (out_device & AUDIO_DEVICE_OUT_WIRED_HEADPHONE ||
@@ -6265,23 +6425,25 @@
                (in_device & AUDIO_DEVICE_IN_BACK_MIC)) &&       // OR Back-mic
                (source == AUDIO_SOURCE_MIC ||                   // AND source is MIC for 16bit
                 source == AUDIO_SOURCE_UNPROCESSED ||           // OR unprocessed for 24bit
-                source == AUDIO_SOURCE_CAMCORDER)) {            // OR camera usecase
+                source == AUDIO_SOURCE_CAMCORDER) &&            // OR camera usecase
+                ((int)channel_mask == (int)AUDIO_CHANNEL_INDEX_MASK_4) && // AND 4mic channel mask
+                (sample_rate == 48000)) {             // AND sample rate is 48Khz
                 snd_device = SND_DEVICE_IN_HANDSET_GENERIC_QMIC;
                 /* Below check is true only in LA build to set
                    ambisonic profile. In LE hal client will set profile
                  */
-                if (my_data->ambisonic_profile == true) {
-                    strlcpy(adev->active_input->profile, "record_ambisonic",
-                            sizeof(adev->active_input->profile));
-                }
+                if (my_data->ambisonic_profile == true &&
+                    in != NULL)
+                    strlcpy(in->profile, "record_ambisonic",
+                            sizeof(in->profile));
 
-                if (!strncmp(adev->active_input->profile, "record_ambisonic",
-                            strlen("record_ambisonic"))) {
+                if (in != NULL && !strncmp(in->profile, "record_ambisonic",
+                                           strlen("record_ambisonic"))) {
                     /* Validate input stream configuration for
                        Ambisonic capture.
                      */
                     if (((int)channel_mask != (int)AUDIO_CHANNEL_INDEX_MASK_4) ||
-                         (adev->active_input->sample_rate != 48000)) {
+                         (sample_rate != 48000)) {
                           snd_device = SND_DEVICE_NONE;
                           ALOGW("Unsupported Input configuration for ambisonic capture");
                           goto exit;
@@ -6347,24 +6509,24 @@
             if (my_data->fluence_in_voice_rec && channel_count == 1) {
                 if ((my_data->fluence_type & FLUENCE_QUAD_MIC) &&
                     (my_data->source_mic_type & SOURCE_QUAD_MIC)) {
-                    if (adev->active_input->enable_aec)
+                    if (in != NULL && in->enable_aec)
                         snd_device = SND_DEVICE_IN_HANDSET_QMIC_AEC;
                     else
                         snd_device = SND_DEVICE_IN_VOICE_REC_QMIC_FLUENCE;
                 } else if ((my_data->fluence_type & FLUENCE_QUAD_MIC) &&
                     (my_data->source_mic_type & SOURCE_THREE_MIC)) {
-                    if (adev->active_input->enable_aec)
+                    if (in != NULL && in->enable_aec)
                         snd_device = SND_DEVICE_IN_HANDSET_TMIC_AEC;
                     else
                         snd_device = SND_DEVICE_IN_VOICE_REC_TMIC;
                 } else if ((my_data->fluence_type & FLUENCE_DUAL_MIC) &&
                     (my_data->source_mic_type & SOURCE_DUAL_MIC)) {
-                    if (adev->active_input->enable_aec)
+                    if (in != NULL && in->enable_aec)
                         snd_device = SND_DEVICE_IN_HANDSET_DMIC_AEC;
                     else
                         snd_device = SND_DEVICE_IN_VOICE_REC_DMIC_FLUENCE;
                 }
-                platform_set_echo_reference(adev, true, out_device);
+                in->enable_ec_port = true;
             } else if (((channel_mask == AUDIO_CHANNEL_IN_FRONT_BACK) ||
                        (channel_mask == AUDIO_CHANNEL_IN_STEREO)) &&
                        (my_data->source_mic_type & SOURCE_DUAL_MIC)) {
@@ -6377,14 +6539,13 @@
                 snd_device = SND_DEVICE_IN_QUAD_MIC;
             }
             if (snd_device == SND_DEVICE_NONE) {
-                if (adev->active_input->enable_aec) {
-                    if (adev->active_input->enable_ns) {
+                if (in != NULL && in->enable_aec) {
+                    if (in->enable_ns) {
                         snd_device = SND_DEVICE_IN_VOICE_REC_MIC_AEC_NS;
                     } else {
                         snd_device = SND_DEVICE_IN_VOICE_REC_MIC_AEC;
                     }
-                    platform_set_echo_reference(adev, true, out_device);
-                } else if (adev->active_input->enable_ns)
+                } else if (in != NULL && in->enable_ns)
                     snd_device = SND_DEVICE_IN_VOICE_REC_MIC_NS;
                 else
                     snd_device = SND_DEVICE_IN_VOICE_REC_MIC;
@@ -6435,9 +6596,8 @@
         in_device = ((out_device == AUDIO_DEVICE_NONE) ?
                       AUDIO_DEVICE_IN_BUILTIN_MIC : in_device) & ~AUDIO_DEVICE_BIT_IN;
 
-        if (adev->active_input) {
-            snd_device = get_snd_device_for_voice_comm(my_data, out_device, in_device);
-        }
+        if (in)
+            snd_device = get_snd_device_for_voice_comm(my_data, in, out_device, in_device);
     } else if (source == AUDIO_SOURCE_MIC) {
         if (in_device & AUDIO_DEVICE_IN_BUILTIN_MIC &&
                 channel_count == 1 ) {
@@ -6458,6 +6618,20 @@
                     platform_set_echo_reference(adev, true, out_device);
                 }
             }
+        } else if (in_device & AUDIO_DEVICE_IN_LOOPBACK) {
+            if (in_device & AUDIO_DEVICE_IN_BUILTIN_MIC) {
+                usecase = get_usecase_from_list(adev, USECASE_AUDIO_RECORD);
+                if (usecase == NULL) {
+                    ALOGE("%s: Could not find the record usecase", __func__);
+                    snd_device = SND_DEVICE_NONE;
+                    goto exit;
+                }
+
+                int ch_count = audio_channel_count_from_in_mask(channel_mask);
+                snd_device = audio_extn_get_loopback_snd_device(adev, usecase,
+                                  ch_count);
+                ALOGD("%s: snd device %d", __func__, snd_device);
+            }
         }
     } else if (source == AUDIO_SOURCE_FM_TUNER) {
         snd_device = SND_DEVICE_IN_CAPTURE_FM;
@@ -6465,7 +6639,7 @@
         goto exit;
     }
 
-    if (adev->active_input && (audio_extn_ssr_get_stream() == adev->active_input))
+    if (in && (audio_extn_ssr_get_stream() == in))
         snd_device = SND_DEVICE_IN_THREE_MIC;
 
     if (snd_device != SND_DEVICE_NONE) {
@@ -6476,7 +6650,7 @@
             !(in_device & AUDIO_DEVICE_IN_VOICE_CALL) &&
             !(in_device & AUDIO_DEVICE_IN_COMMUNICATION)) {
         if (in_device & AUDIO_DEVICE_IN_BUILTIN_MIC) {
-            if ((adev->active_input && (audio_extn_ssr_get_stream() == adev->active_input)) ||
+            if ((in && (audio_extn_ssr_get_stream() == in)) ||
                 ((my_data->source_mic_type & SOURCE_QUAD_MIC) &&
                  channel_mask == AUDIO_CHANNEL_INDEX_MASK_4))
                 snd_device = SND_DEVICE_IN_QUAD_MIC;
@@ -6879,9 +7053,11 @@
             goto done_key_audcal;
         }
 
-        if(cal.dev_id) {
-          if(audio_is_input_device(cal.dev_id)) {
-              cal.snd_dev_id = platform_get_input_snd_device(platform, cal.dev_id);
+        if (cal.dev_id) {
+          if (audio_is_input_device(cal.dev_id)) {
+              // FIXME: why pass an input device whereas
+              // platform_get_input_snd_device() expects as an output device?
+              cal.snd_dev_id = platform_get_input_snd_device(platform, NULL, cal.dev_id);
           } else {
               out.devices = cal.dev_id;
               out.sample_rate = cal.sampling_rate;
@@ -7436,8 +7612,8 @@
         goto done;
     }
 
-    if(cal.dev_id & AUDIO_DEVICE_BIT_IN) {
-        cal.snd_dev_id = platform_get_input_snd_device(platform, cal.dev_id);
+    if (cal.dev_id & AUDIO_DEVICE_BIT_IN) {
+        cal.snd_dev_id = platform_get_input_snd_device(platform, NULL, cal.dev_id);
     } else if(cal.dev_id) {
         out.devices = cal.dev_id;
         out.sample_rate = cal.sampling_rate;
@@ -7654,9 +7830,13 @@
 {
     switch (usecase) {
         case USECASE_AUDIO_PLAYBACK_DEEP_BUFFER:
+        case USECASE_AUDIO_PLAYBACK_MEDIA:
+        case USECASE_AUDIO_PLAYBACK_NAV_GUIDANCE:
             return DEEP_BUFFER_PLATFORM_DELAY;
         case USECASE_AUDIO_PLAYBACK_LOW_LATENCY:
         case USECASE_AUDIO_PLAYBACK_WITH_HAPTICS:
+        case USECASE_AUDIO_PLAYBACK_SYS_NOTIFICATION:
+        case USECASE_AUDIO_PLAYBACK_PHONE:
             return LOW_LATENCY_PLATFORM_DELAY;
         case USECASE_AUDIO_PLAYBACK_OFFLOAD:
         case USECASE_AUDIO_PLAYBACK_OFFLOAD2:
@@ -7723,15 +7903,20 @@
     case USECASE_AUDIO_PLAYBACK_MULTI_CH:
     case USECASE_AUDIO_PLAYBACK_OFFLOAD:
     case USECASE_AUDIO_PLAYBACK_OFFLOAD2:
-        needs_event = true;
-        break;
-    /* concurrent playback in low latency allowed */
-    case USECASE_AUDIO_PLAYBACK_LOW_LATENCY:
-        break;
-    /* concurrent playback FM needs event */
     case USECASE_AUDIO_PLAYBACK_FM:
         needs_event = true;
         break;
+    case USECASE_AUDIO_PLAYBACK_ULL:
+    case USECASE_AUDIO_PLAYBACK_MMAP:
+        if (property_get_bool("persist.vendor.audio.ull_playback_bargein",
+            false))
+            needs_event = true;
+        break;
+    case USECASE_AUDIO_PLAYBACK_LOW_LATENCY:
+        if (property_get_bool("persist.vendor.audio.ll_playback_bargein",
+            false))
+            needs_event = true;
+        break;
 
     /* concurrent capture usecases which needs event */
     case USECASE_AUDIO_RECORD:
@@ -7775,6 +7960,9 @@
 {
     char value[PROPERTY_VALUE_MAX] = {0};
     uint32_t fragment_size = COMPRESS_OFFLOAD_FRAGMENT_SIZE;
+    uint32_t new_fragment_size = 0;
+    int32_t duration_ms = 0;
+    int channel_count = 0;
     if((property_get("vendor.audio.offload.buffer.size.kb", value, "")) &&
             atoi(value)) {
         fragment_size =  atoi(value) * 1024;
@@ -7788,6 +7976,17 @@
         fragment_size = info->offload_buffer_size;
     }
 
+    /* Use client specified buffer size if mentioned */
+    if ((info != NULL) && (info->duration_us > 0)) {
+        duration_ms = info->duration_us / 1000;
+        channel_count = audio_channel_count_from_in_mask(info->channel_mask);
+
+        new_fragment_size = (duration_ms * info->sample_rate * channel_count * audio_bytes_per_sample(info->format)) / 1000;
+        ALOGI("%s:: Overwriting offload buffer size with client requested size old:%d new:%d", __func__, fragment_size, new_fragment_size);
+
+        fragment_size = new_fragment_size;
+    }
+
     if (info != NULL) {
         if (info->is_streaming && info->has_video) {
             fragment_size = COMPRESS_OFFLOAD_FRAGMENT_SIZE_FOR_AV_STREAMING;
@@ -8615,6 +8814,7 @@
     unsigned int channels;
     unsigned int format;
     struct platform_data *my_data = (struct platform_data *)adev->platform;
+    struct stream_in *in = adev_get_active_input(adev);
 
     bit_width = backend_cfg->bit_width;
     sample_rate = backend_cfg->sample_rate;
@@ -8638,7 +8838,7 @@
     } else if (my_data->is_internal_codec && !audio_is_usb_in_device(snd_device)) {
         sample_rate =  CODEC_BACKEND_DEFAULT_SAMPLE_RATE;
         channels = CODEC_BACKEND_DEFAULT_TX_CHANNELS;
-        if (adev->active_input && adev->active_input->bit_width == 24)
+        if (in && in->bit_width == 24)
             bit_width = platform_get_snd_device_bit_width(snd_device);
     } else {
         struct listnode *node;
@@ -8722,6 +8922,14 @@
         backend_cfg.bit_width= usecase->stream.in->bit_width;
         backend_cfg.format= usecase->stream.in->format;
         backend_cfg.channels = audio_channel_count_from_in_mask(usecase->stream.in->channel_mask);
+        if (is_loopback_input_device(usecase->stream.in->device)) {
+            int bw = platform_get_snd_device_bit_width(snd_device);
+            if ((-ENOSYS != bw) && (backend_cfg.bit_width > (uint32_t)bw)) {
+                backend_cfg.bit_width = bw;
+                ALOGD("%s:txbecf: set bitwidth to %d from platform info",
+                       __func__, bw);
+            }
+        }
     } else {
         backend_cfg.bit_width = CODEC_BACKEND_DEFAULT_BIT_WIDTH;
         backend_cfg.sample_rate =  CODEC_BACKEND_DEFAULT_SAMPLE_RATE;
@@ -10533,7 +10741,7 @@
     size_t actual_mic_count = 0;
 
     snd_device_t active_input_snd_device =
-            platform_get_input_snd_device(platform, usecase->stream.in->device);
+            platform_get_input_snd_device(platform, usecase->stream.in, AUDIO_DEVICE_NONE);
     if (active_input_snd_device == SND_DEVICE_NONE) {
         ALOGI("%s: No active microphones found", __func__);
         goto end;
diff --git a/hal/msm8974/platform.h b/hal/msm8974/platform.h
index 5160959..1d56a7e 100644
--- a/hal/msm8974/platform.h
+++ b/hal/msm8974/platform.h
@@ -129,7 +129,9 @@
     SND_DEVICE_OUT_SPEAKER_WSA_AND_BT_SCO_WB,
     SND_DEVICE_OUT_SPEAKER_WSA_AND_BT_SCO_SWB,
     SND_DEVICE_OUT_VOICE_TTY_FULL_HEADPHONES,
+    SND_DEVICE_OUT_VOICE_TTY_FULL_HEADSET,
     SND_DEVICE_OUT_VOICE_TTY_VCO_HEADPHONES,
+    SND_DEVICE_OUT_VOICE_TTY_VCO_HEADSET,
     SND_DEVICE_OUT_VOICE_TTY_HCO_HANDSET,
     SND_DEVICE_OUT_VOICE_TTY_FULL_USB,
     SND_DEVICE_OUT_VOICE_TTY_VCO_USB,
@@ -175,6 +177,10 @@
     SND_DEVICE_OUT_VOICE_SPEAKER_STEREO_AND_VOICE_ANC_HEADSET,
     SND_DEVICE_OUT_VOICE_SPEAKER_STEREO_AND_VOICE_ANC_FB_HEADSET,
     SND_DEVICE_OUT_VOICE_HEARING_AID,
+    SND_DEVICE_OUT_BUS_MEDIA,
+    SND_DEVICE_OUT_BUS_SYS,
+    SND_DEVICE_OUT_BUS_NAV,
+    SND_DEVICE_OUT_BUS_PHN,
     SND_DEVICE_OUT_END,
 
     /*
@@ -311,6 +317,12 @@
     SND_DEVICE_IN_CAMCORDER_SELFIE_INVERT_LANDSCAPE,
     SND_DEVICE_IN_CAMCORDER_SELFIE_PORTRAIT,
     SND_DEVICE_IN_VOICE_HEARING_AID,
+    SND_DEVICE_IN_BUS,
+    SND_DEVICE_IN_EC_REF_LOOPBACK,
+    SND_DEVICE_IN_HANDSET_DMIC_AND_EC_REF_LOOPBACK,
+    SND_DEVICE_IN_HANDSET_QMIC_AND_EC_REF_LOOPBACK,
+    SND_DEVICE_IN_HANDSET_6MIC_AND_EC_REF_LOOPBACK,
+    SND_DEVICE_IN_HANDSET_8MIC_AND_EC_REF_LOOPBACK,
     SND_DEVICE_IN_END,
 
     SND_DEVICE_MAX = SND_DEVICE_IN_END,
@@ -625,6 +637,11 @@
 #define PLAYBACK_INTERACTIVE_STRM_DEVICE7 48
 #define PLAYBACK_INTERACTIVE_STRM_DEVICE8 49
 
+#define MEDIA_PCM_DEVICE DEEP_BUFFER_PCM_DEVICE
+#define SYS_NOTIFICATION_PCM_DEVICE 9
+#define NAV_GUIDANCE_PCM_DEVICE MULTIMEDIA2_PCM_DEVICE
+#define PHONE_PCM_DEVICE 12
+
 #ifdef PLATFORM_APQ8084
 #define FM_RX_VOLUME "Quat MI2S FM RX Volume"
 #elif PLATFORM_MSM8994
diff --git a/hal/platform_api.h b/hal/platform_api.h
index fd85aab..394310a 100644
--- a/hal/platform_api.h
+++ b/hal/platform_api.h
@@ -34,6 +34,7 @@
 #define LICENSE_STR_MAX_LEN  (64)
 #define PRODUCT_FFV      "ffv"
 #define PRODUCT_ALLPLAY  "allplay"
+#define MAX_IN_CHANNELS 32
 
 typedef enum {
     PLATFORM,
@@ -104,6 +105,7 @@
     uint32_t op_channels;
     uint32_t usecase_id;
     uint32_t snd_device;
+    char fe_name[128];
 };
 
 struct audio_custom_mtmx_params {
@@ -112,6 +114,26 @@
     uint32_t coeffs[0];
 };
 
+struct audio_custom_mtmx_in_params_info {
+    uint32_t op_channels;
+    uint32_t usecase_id;
+};
+
+struct audio_custom_mtmx_params_in_ch_info {
+    uint32_t ch_count;
+    char device[128];
+    char hw_interface[128];
+};
+
+struct audio_custom_mtmx_in_params {
+    struct listnode list;
+    struct audio_custom_mtmx_in_params_info in_info;
+    uint32_t ip_channels;
+    uint32_t mic_ch;
+    uint32_t ec_ref_ch;
+    struct audio_custom_mtmx_params_in_ch_info in_ch_info[MAX_IN_CHANNELS];
+};
+
 enum card_status_t;
 
 void *platform_init(struct audio_device *adev);
@@ -179,7 +201,9 @@
 int platform_get_sample_rate(void *platform, uint32_t *rate);
 int platform_set_device_mute(void *platform, bool state, char *dir);
 snd_device_t platform_get_output_snd_device(void *platform, struct stream_out *out);
-snd_device_t platform_get_input_snd_device(void *platform, audio_devices_t out_device);
+snd_device_t platform_get_input_snd_device(void *platform,
+                                           struct stream_in *in,
+                                           audio_devices_t out_device);
 int platform_set_hdmi_channels(void *platform, int channel_count);
 int platform_edid_get_max_channels(void *platform);
 void platform_add_operator_specific_device(snd_device_t snd_device,
@@ -356,4 +380,11 @@
                                     struct audio_custom_mtmx_params_info *info);
 int platform_add_custom_mtmx_params(void *platform,
                                     struct audio_custom_mtmx_params_info *info);
+/* callback functions from platform to common audio HAL */
+struct stream_in *adev_get_active_input(const struct audio_device *adev);
+
+struct audio_custom_mtmx_in_params * platform_get_custom_mtmx_in_params(void *platform,
+                                    struct audio_custom_mtmx_in_params_info *info);
+int platform_add_custom_mtmx_in_params(void *platform,
+                                    struct audio_custom_mtmx_in_params_info *info);
 #endif // AUDIO_PLATFORM_API_H
diff --git a/hal/platform_info.c b/hal/platform_info.c
index 05ee9cd..8ee8b07 100644
--- a/hal/platform_info.c
+++ b/hal/platform_info.c
@@ -73,6 +73,8 @@
     CUSTOM_MTMX_PARAMS,
     CUSTOM_MTMX_PARAM_COEFFS,
     EXTERNAL_DEVICE_SPECIFIC,
+    CUSTOM_MTMX_IN_PARAMS,
+    CUSTOM_MTMX_PARAM_IN_CH_INFO,
 } section_t;
 
 typedef void (* section_process_fn)(const XML_Char **attr);
@@ -97,6 +99,8 @@
 static void process_custom_mtmx_params(const XML_Char **attr);
 static void process_custom_mtmx_param_coeffs(const XML_Char **attr);
 static void process_external_dev(const XML_Char **attr);
+static void process_custom_mtmx_in_params(const XML_Char **attr);
+static void process_custom_mtmx_param_in_ch_info(const XML_Char **attr);
 
 static section_process_fn section_table[] = {
     [ROOT] = process_root,
@@ -118,6 +122,8 @@
     [CUSTOM_MTMX_PARAMS] = process_custom_mtmx_params,
     [CUSTOM_MTMX_PARAM_COEFFS] = process_custom_mtmx_param_coeffs,
     [EXTERNAL_DEVICE_SPECIFIC] = process_external_dev,
+    [CUSTOM_MTMX_IN_PARAMS] = process_custom_mtmx_in_params,
+    [CUSTOM_MTMX_PARAM_IN_CH_INFO] = process_custom_mtmx_param_in_ch_info,
 };
 
 static section_t section;
@@ -224,6 +230,7 @@
 }
 
 static struct audio_custom_mtmx_params_info mtmx_params_info;
+static struct audio_custom_mtmx_in_params_info mtmx_in_params_info;
 
 /*
  * <audio_platform_info>
@@ -1003,6 +1010,82 @@
     return;
 }
 
+static void process_custom_mtmx_param_in_ch_info(const XML_Char **attr)
+{
+    uint32_t attr_idx = 0;
+    int32_t in_ch_idx = -1;
+    struct audio_custom_mtmx_in_params *mtmx_in_params = NULL;
+
+    mtmx_in_params = platform_get_custom_mtmx_in_params((void *)my_data.platform,
+                                                  &mtmx_in_params_info);
+    if (mtmx_in_params == NULL) {
+        ALOGE("%s: mtmx in params with given param info, not found", __func__);
+        return;
+    }
+
+    if (strcmp(attr[attr_idx++], "in_channel_index") != 0) {
+        ALOGE("%s: 'in_channel_index' not found", __func__);
+        return;
+    }
+
+    in_ch_idx = atoi((char *)attr[attr_idx++]);
+    if (in_ch_idx < 0 || in_ch_idx >= MAX_IN_CHANNELS) {
+        ALOGE("%s: invalid input channel index(%d)", __func__, in_ch_idx);
+        return;
+    }
+
+    if (strcmp(attr[attr_idx++], "channel_count") != 0) {
+        ALOGE("%s: 'channel_count' not found", __func__);
+        return;
+    }
+    mtmx_in_params->in_ch_info[in_ch_idx].ch_count = atoi((char *)attr[attr_idx++]);
+
+    if (strcmp(attr[attr_idx++], "device") != 0) {
+        ALOGE("%s: 'device' not found", __func__);
+        return;
+    }
+    strlcpy(mtmx_in_params->in_ch_info[in_ch_idx].device, attr[attr_idx++],
+            sizeof(mtmx_in_params->in_ch_info[in_ch_idx].device));
+
+    if (strcmp(attr[attr_idx++], "interface") != 0) {
+        ALOGE("%s: 'interface' not found", __func__);
+        return;
+    }
+    strlcpy(mtmx_in_params->in_ch_info[in_ch_idx].hw_interface, attr[attr_idx++],
+            sizeof(mtmx_in_params->in_ch_info[in_ch_idx].hw_interface));
+
+    if (!strncmp(mtmx_in_params->in_ch_info[in_ch_idx].device,
+                 ENUM_TO_STRING(AUDIO_DEVICE_IN_BUILTIN_MIC),
+                 sizeof(mtmx_in_params->in_ch_info[in_ch_idx].device)))
+        mtmx_in_params->mic_ch = mtmx_in_params->in_ch_info[in_ch_idx].ch_count;
+    else if (!strncmp(mtmx_in_params->in_ch_info[in_ch_idx].device,
+              ENUM_TO_STRING(AUDIO_DEVICE_IN_LOOPBACK),
+              sizeof(mtmx_in_params->in_ch_info[in_ch_idx].device)))
+        mtmx_in_params->ec_ref_ch = mtmx_in_params->in_ch_info[in_ch_idx].ch_count;
+
+    mtmx_in_params->ip_channels += mtmx_in_params->in_ch_info[in_ch_idx].ch_count;
+}
+
+static void process_custom_mtmx_in_params(const XML_Char **attr)
+{
+    int attr_idx = 0;
+
+    if (strcmp(attr[attr_idx++], "usecase") != 0) {
+        ALOGE("%s: 'usecase' not found", __func__);
+        return;
+    }
+    mtmx_in_params_info.usecase_id = platform_get_usecase_index((char *)attr[attr_idx++]);
+
+    if (strcmp(attr[attr_idx++], "out_channel_count") != 0) {
+        ALOGE("%s: 'out_channel_count' not found", __func__);
+        return;
+    }
+    mtmx_in_params_info.op_channels = atoi((char *)attr[attr_idx++]);
+
+    platform_add_custom_mtmx_in_params((void *)my_data.platform, &mtmx_in_params_info);
+
+}
+
 static void process_custom_mtmx_param_coeffs(const XML_Char **attr)
 {
     uint32_t attr_idx = 0, out_ch_idx = -1, ch_coeff_count = 0;
@@ -1034,7 +1117,7 @@
     ch_coeff_value = strtok_r((char *)attr[attr_idx++], " ", &context);
     ip_channels = mtmx_params->info.ip_channels;
     op_channels = mtmx_params->info.op_channels;
-    while(ch_coeff_value && ch_coeff_count < op_channels) {
+    while(ch_coeff_value && ch_coeff_count < ip_channels) {
         mtmx_params->coeffs[ip_channels * out_ch_idx + ch_coeff_count++]
                            = atoi(ch_coeff_value);
         ch_coeff_value = strtok_r(NULL, " ", &context);
@@ -1077,6 +1160,15 @@
         return;
     }
     mtmx_params_info.snd_device = platform_get_snd_device_index((char *)attr[attr_idx++]);
+
+    if ((attr[attr_idx] != NULL) && (strcmp(attr[attr_idx++], "fe_name") == 0)) {
+        strlcpy(mtmx_params_info.fe_name, (char *)attr[attr_idx++],
+                sizeof(mtmx_params_info.fe_name));
+    } else {
+        ALOGD("%s: 'fe_name' not found", __func__);
+        mtmx_params_info.fe_name[0] = '\0';
+    }
+
     platform_add_custom_mtmx_params((void *)my_data.platform, &mtmx_params_info);
 
 }
@@ -1244,6 +1336,22 @@
         } else if (strcmp(tag_name, "ext_device") == 0) {
             section_process_fn fn = section_table[section];
             fn(attr);
+        } else if (strcmp(tag_name, "custom_mtmx_in_params") == 0) {
+            if (section != ROOT) {
+                ALOGE("custom_mtmx_in_params tag supported only in ROOT section");
+                return;
+            }
+            section = CUSTOM_MTMX_IN_PARAMS;
+            section_process_fn fn = section_table[section];
+            fn(attr);
+        } else if (strcmp(tag_name, "custom_mtmx_param_in_chs") == 0) {
+            if (section != CUSTOM_MTMX_IN_PARAMS) {
+                ALOGE("custom_mtmx_param_in_chs tag supported only with CUSTOM_MTMX_IN_PARAMS section");
+                return;
+            }
+            section = CUSTOM_MTMX_PARAM_IN_CH_INFO;
+            section_process_fn fn = section_table[section];
+            fn(attr);
         }
     } else {
         if(strcmp(tag_name, "config_params") == 0) {
@@ -1306,6 +1414,10 @@
         section = ROOT;
     } else if (strcmp(tag_name, "custom_mtmx_param_coeffs") == 0) {
         section = CUSTOM_MTMX_PARAMS;
+    } else if (strcmp(tag_name, "custom_mtmx_in_params") == 0) {
+        section = ROOT;
+    } else if (strcmp(tag_name, "custom_mtmx_param_in_chs") == 0) {
+        section = CUSTOM_MTMX_IN_PARAMS;
     }
 }
 
diff --git a/hal/voice.c b/hal/voice.c
index 729ab27..006dd08 100644
--- a/hal/voice.c
+++ b/hal/voice.c
@@ -377,6 +377,22 @@
     return session_id;
 }
 
+bool voice_check_voicecall_usecases_active(struct audio_device *adev)
+{
+    struct listnode *node;
+    struct audio_usecase *usecase = NULL;
+
+    list_for_each(node, &adev->usecase_list) {
+        usecase = node_to_item(node, struct audio_usecase, list);
+        if (usecase->type == VOICE_CALL) {
+            ALOGV("%s: voice usecase:%s is active", __func__,
+                   use_case_table[usecase->id]);
+            return true;
+        }
+    }
+    return false;
+}
+
 int voice_check_and_set_incall_rec_usecase(struct audio_device *adev,
                                            struct stream_in *in)
 {
diff --git a/hal/voice.h b/hal/voice.h
index 9612edd..188345d 100644
--- a/hal/voice.h
+++ b/hal/voice.h
@@ -101,4 +101,5 @@
 bool voice_is_call_state_active(struct audio_device *adev);
 void voice_set_device_mute_flag (struct audio_device *adev, bool state);
 snd_device_t voice_get_incall_rec_backend_device(struct stream_in *in);
+bool voice_check_voicecall_usecases_active(struct audio_device *adev);
 #endif //VOICE_H
diff --git a/hal/voice_extn/compress_voip.c b/hal/voice_extn/compress_voip.c
index e4bc210..fbd6d6f 100644
--- a/hal/voice_extn/compress_voip.c
+++ b/hal/voice_extn/compress_voip.c
@@ -501,7 +501,6 @@
     if (!voip_data.in_stream_count)
         ret = compress_voip_open_input_stream(in);
 
-    adev->active_input = in;
     ret = voip_start_call(adev, &in->config);
     in->pcm = voip_data.pcm_tx;
 
@@ -539,7 +538,6 @@
     if(voip_data.in_stream_count > 0) {
        voip_data.in_stream_count--;
        status = voip_stop_call(adev);
-       adev->active_input = get_next_active_input(adev);
        in->pcm = NULL;
     }
 
diff --git a/post_proc/Android.mk b/post_proc/Android.mk
index 6b1afd3..fb42514 100644
--- a/post_proc/Android.mk
+++ b/post_proc/Android.mk
@@ -30,8 +30,7 @@
         virtualizer.c \
         reverb.c \
         effect_api.c \
-        effect_util.c \
-        asphere.c
+        effect_util.c
 
 # HW_ACCELERATED has been disabled by default since msm8996. File doesn't
 # compile cleanly on tip so don't want to include it, but keeping this
diff --git a/post_proc/Makefile.am b/post_proc/Makefile.am
index bd29473..8bd41ae 100644
--- a/post_proc/Makefile.am
+++ b/post_proc/Makefile.am
@@ -19,10 +19,6 @@
 c_sources += hw_accelerator.c
 endif
 
-if AUDIOSPHERE
-c_sources += asphere.c
-endif
-
 library_include_HEADERS = $(h_sources)
 library_includedir = $(includedir)
 
diff --git a/post_proc/asphere.c b/post_proc/asphere.c
deleted file mode 100644
index efe07c6..0000000
--- a/post_proc/asphere.c
+++ /dev/null
@@ -1,323 +0,0 @@
-/* Copyright (c) 2015, 2017, 2019 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
- * met:
- *     * Redistributions of source code must retain the above copyright
- *       notice, this list of conditions and the following disclaimer.
- *     * Redistributions in binary form must reproduce the above
- *       copyright notice, this list of conditions and the following
- *       disclaimer in the documentation and/or other materials provided
- *       with the distribution.
- *     * Neither the name of The Linux Foundation nor the names of its
- *       contributors may be used to endorse or promote products derived
- *       from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- */
-#define LOG_TAG "audio_pp_asphere"
-/*#define LOG_NDEBUG 0*/
-
-#include <errno.h>
-#include <fcntl.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <stdbool.h>
-#include <sys/stat.h>
-#include <log/log.h>
-#include <cutils/list.h>
-#include <cutils/str_parms.h>
-#include <cutils/properties.h>
-#include <hardware/audio_effect.h>
-#include <pthread.h>
-#include "bundle.h"
-#include "equalizer.h"
-#include "bass_boost.h"
-#include "virtualizer.h"
-#include "reverb.h"
-#include "asphere.h"
-
-#define ASPHERE_MIXER_NAME  "MSM ASphere Set Param"
-
-#define AUDIO_PARAMETER_KEY_ASPHERE_STATUS  "asphere_status"
-#define AUDIO_PARAMETER_KEY_ASPHERE_ENABLE   "asphere_enable"
-#define AUDIO_PARAMETER_KEY_ASPHERE_STRENGTH "asphere_strength"
-
-#define AUDIO_ASPHERE_EVENT_NODE "/data/misc/audio_pp/event_node"
-
-enum {
-    ASPHERE_ACTIVE = 0,
-    ASPHERE_SUSPENDED,
-    ASPHERE_ERROR
-};
-
-#ifdef AUDIO_FEATURE_ENABLED_GCOV
-extern void  __gcov_flush();
-static void enable_gcov()
-{
-    __gcov_flush();
-}
-#else
-static void enable_gcov()
-{
-}
-#endif
-
-struct asphere_module {
-    bool enabled;
-    int status;
-    int strength;
-    pthread_mutex_t lock;
-    int init_status;
-};
-
-static struct asphere_module asphere;
-pthread_once_t asphere_once = PTHREAD_ONCE_INIT;
-
-static int asphere_create_app_notification_node(void)
-{
-    int fd;
-    if ((fd = open(AUDIO_ASPHERE_EVENT_NODE, O_CREAT|O_TRUNC|O_WRONLY,
-                            S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH)) < 0) {
-        ALOGE("creating notification node failed %d", errno);
-        return -EINVAL;
-    }
-    chmod(AUDIO_ASPHERE_EVENT_NODE, S_IRWXU|S_IRGRP|S_IXGRP|S_IROTH);
-    close(fd);
-    ALOGD("%s: successfully created notification node %s",
-                               __func__, AUDIO_ASPHERE_EVENT_NODE);
-    return 0;
-}
-
-static int asphere_notify_app(void)
-{
-    int fd;
-    if ((fd = open(AUDIO_ASPHERE_EVENT_NODE, O_TRUNC|O_WRONLY)) < 0) {
-        ALOGE("opening notification node failed %d", errno);
-        return -EINVAL;
-    }
-    close(fd);
-    ALOGD("%s: successfully opened notification node", __func__);
-    return 0;
-}
-
-static int asphere_get_values_from_mixer(void)
-{
-    int ret = 0;
-    long val[2] = {-1, -1};
-    struct mixer_ctl *ctl = NULL;
-    struct mixer *mixer = mixer_open(MIXER_CARD);
-    if (mixer)
-        ctl = mixer_get_ctl_by_name(mixer, ASPHERE_MIXER_NAME);
-    if (!ctl) {
-        ALOGE("%s: could not get ctl for mixer cmd - %s",
-              __func__, ASPHERE_MIXER_NAME);
-        return -EINVAL;
-    }
-    ret = mixer_ctl_get_array(ctl, val, sizeof(val)/sizeof(val[0]));
-    if (!ret) {
-        asphere.enabled = (val[0] == 0) ? false : true;
-        asphere.strength = val[1];
-    }
-    ALOGD("%s: returned %d, enabled:%ld, strength:%ld",
-          __func__, ret, val[0], val[1]);
-
-    return ret;
-}
-
-static int asphere_set_values_to_mixer(void)
-{
-    int ret = 0;
-    long val[2] = {-1, -1};
-    struct mixer_ctl *ctl = NULL;
-    struct mixer *mixer = mixer_open(MIXER_CARD);
-    if (mixer)
-        ctl = mixer_get_ctl_by_name(mixer, ASPHERE_MIXER_NAME);
-    if (!ctl) {
-        ALOGE("%s: could not get ctl for mixer cmd - %s",
-              __func__, ASPHERE_MIXER_NAME);
-        return -EINVAL;
-    }
-    val[0] = ((asphere.status == ASPHERE_ACTIVE) && asphere.enabled) ? 1 : 0;
-    val[1] = asphere.strength;
-
-    ret = mixer_ctl_set_array(ctl, val, sizeof(val)/sizeof(val[0]));
-    ALOGD("%s: returned %d, enabled:%ld, strength:%ld",
-          __func__, ret, val[0], val[1]);
-
-    return ret;
-}
-
-static void asphere_init_once() {
-    ALOGD("%s", __func__);
-    pthread_mutex_init(&asphere.lock, NULL);
-
-    if (property_get_bool("vendor.audio.feature.audio_sphere.enable", false)) {
-        asphere.init_status = 1;
-        asphere_get_values_from_mixer();
-        asphere_create_app_notification_node();
-        return;
-    } else {
-        ALOGW("%s: asphere feature not enabled", __func__);
-    }
-
-    asphere.init_status = 0;
-}
-
-static int asphere_init() {
-    pthread_once(&asphere_once, asphere_init_once);
-    enable_gcov();
-    return asphere.init_status;
-}
-
-static bool asphere_parms_allowed(struct str_parms *parms)
-{
-    if (str_parms_has_key(parms, AUDIO_PARAMETER_KEY_ASPHERE_ENABLE))
-        return true;
-    if (str_parms_has_key(parms, AUDIO_PARAMETER_KEY_ASPHERE_STRENGTH))
-        return true;
-    if (str_parms_has_key(parms, AUDIO_PARAMETER_KEY_ASPHERE_STATUS))
-        return true;
-
-    return false;
-}
-
-void asphere_set_parameters(struct str_parms *parms)
-{
-    int ret = 0;
-    bool enable = false;
-    int strength = -1;
-    char value[32] = {0};
-    bool set_enable = false, set_strength = false;
-
-    if (!asphere_parms_allowed(parms)) {
-        return;
-    }
-
-    if (asphere_init() != 1) {
-        ALOGW("%s: init check failed!!!", __func__);
-        return;
-    }
-
-    ret = str_parms_get_str(parms, AUDIO_PARAMETER_KEY_ASPHERE_ENABLE,
-                                                  value, sizeof(value));
-    if (ret > 0) {
-        enable = (atoi(value) == 1) ? true : false;
-        set_enable = true;
-    }
-
-    ret = str_parms_get_str(parms, AUDIO_PARAMETER_KEY_ASPHERE_STRENGTH,
-                                                   value, sizeof(value));
-    if (ret > 0) {
-        strength = atoi(value);
-        if (strength >= 0 && strength <= 1000)
-            set_strength = true;
-    }
-
-    if (set_enable || set_strength) {
-        pthread_mutex_lock(&asphere.lock);
-        asphere.enabled = set_enable ? enable : asphere.enabled;
-        asphere.strength = set_strength ? strength : asphere.strength;
-        ret = asphere_set_values_to_mixer();
-        pthread_mutex_unlock(&asphere.lock);
-        ALOGV("%s: exit ret %d", __func__, ret);
-    }
-}
-
-void asphere_get_parameters(struct str_parms *query,
-                                      struct str_parms *reply)
-{
-    char value[32] = {0};
-    int ret;
-
-    if (asphere_init() != 1) {
-        ALOGW("%s: init check failed!!!", __func__);
-        return;
-    }
-
-    ret = str_parms_get_str(query, AUDIO_PARAMETER_KEY_ASPHERE_STATUS,
-                                                 value, sizeof(value));
-    if (ret >= 0) {
-        str_parms_add_int(reply, AUDIO_PARAMETER_KEY_ASPHERE_STATUS,
-                                                     asphere.status);
-    }
-
-    ret = str_parms_get_str(query, AUDIO_PARAMETER_KEY_ASPHERE_ENABLE,
-                                                 value, sizeof(value));
-    if (ret >= 0) {
-        str_parms_add_int(reply, AUDIO_PARAMETER_KEY_ASPHERE_ENABLE,
-                                              asphere.enabled ? 1 : 0);
-    }
-
-    ret = str_parms_get_str(query, AUDIO_PARAMETER_KEY_ASPHERE_STRENGTH,
-                                                  value, sizeof(value));
-    if (ret >= 0) {
-        str_parms_add_int(reply, AUDIO_PARAMETER_KEY_ASPHERE_STRENGTH,
-                                                     asphere.strength);
-    }
-}
-
-static bool effect_needs_asphere_concurrency_handling(effect_context_t *context)
-{
-    if (memcmp(&context->desc->type,
-                &equalizer_descriptor.type, sizeof(effect_uuid_t)) == 0 ||
-        memcmp(&context->desc->type,
-                &bassboost_descriptor.type, sizeof(effect_uuid_t)) == 0 ||
-        memcmp(&context->desc->type,
-                &virtualizer_descriptor.type, sizeof(effect_uuid_t)) == 0 ||
-        memcmp(&context->desc->type,
-                &ins_preset_reverb_descriptor.type, sizeof(effect_uuid_t)) == 0 ||
-        memcmp(&context->desc->type,
-                &ins_env_reverb_descriptor.type, sizeof(effect_uuid_t)) == 0)
-        return true;
-
-    return false;
-}
-
-void handle_asphere_on_effect_enabled(bool enable,
-                                      effect_context_t *context,
-                                      struct listnode *created_effects)
-{
-    struct listnode *node;
-
-    ALOGV("%s: effect %0x", __func__, context->desc->type.timeLow);
-    if (asphere_init() != 1) {
-        ALOGW("%s: init check failed!!!", __func__);
-        return;
-    }
-
-    if (!effect_needs_asphere_concurrency_handling(context)) {
-        ALOGV("%s: effect %0x, do not need concurrency handling",
-                                 __func__, context->desc->type.timeLow);
-        return;
-    }
-
-    list_for_each(node, created_effects) {
-        effect_context_t *fx_ctxt = node_to_item(node,
-                                                 effect_context_t,
-                                                 effects_list_node);
-        if (fx_ctxt != NULL &&
-            effect_needs_asphere_concurrency_handling(fx_ctxt) == true &&
-            fx_ctxt != context && effect_is_active(fx_ctxt) == true) {
-            ALOGV("%s: found another effect %0x, skip processing %0x", __func__,
-                      fx_ctxt->desc->type.timeLow, context->desc->type.timeLow);
-            return;
-        }
-    }
-    pthread_mutex_lock(&asphere.lock);
-    asphere.status = enable ? ASPHERE_SUSPENDED : ASPHERE_ACTIVE;
-    asphere_set_values_to_mixer();
-    asphere_notify_app();
-    pthread_mutex_unlock(&asphere.lock);
-}
diff --git a/post_proc/asphere.h b/post_proc/asphere.h
deleted file mode 100644
index 3babd1d..0000000
--- a/post_proc/asphere.h
+++ /dev/null
@@ -1,44 +0,0 @@
-/* Copyright (c) 2015, 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
- * met:
- *     * Redistributions of source code must retain the above copyright
- *       notice, this list of conditions and the following disclaimer.
- *     * Redistributions in binary form must reproduce the above
- *       copyright notice, this list of conditions and the following
- *       disclaimer in the documentation and/or other materials provided
- *       with the distribution.
- *     * Neither the name of The Linux Foundation nor the names of its
- *       contributors may be used to endorse or promote products derived
- *       from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- */
-
-#ifndef OFFLOAD_ASPHERE_H_
-#define OFFLOAD_ASPHERE_H_
-
-#include <cutils/str_parms.h>
-#include <cutils/list.h>
-#include "bundle.h"
-
-void asphere_get_parameters(struct str_parms *query,
-                            struct str_parms *reply);
-void asphere_set_parameters(struct str_parms *reply);
-void handle_asphere_on_effect_enabled(bool enable,
-                                      effect_context_t *context,
-                                      struct listnode *created_effects);
-
-#endif /* OFFLOAD_ASPHERE_H_ */
diff --git a/post_proc/bundle.c b/post_proc/bundle.c
index 1e6b91d..0dbf27b 100644
--- a/post_proc/bundle.c
+++ b/post_proc/bundle.c
@@ -40,6 +40,7 @@
 
 #include <stdlib.h>
 #include <cutils/list.h>
+#include <cutils/str_parms.h>
 #include <log/log.h>
 #include <system/thread_defs.h>
 #include <tinyalsa/asoundlib.h>
@@ -53,7 +54,6 @@
 #include "bass_boost.h"
 #include "virtualizer.h"
 #include "reverb.h"
-#include "asphere.h"
 
 #ifdef DTS_EAGLE
 #include "effect_util.h"
@@ -455,20 +455,16 @@
 
 /*
  * Effect Bundle Set and get param operations.
- * currently only handles audio sphere scenario,
- * but the interface itself can be utilized for any effect.
  */
 __attribute__ ((visibility ("default")))
-void offload_effects_bundle_get_parameters(struct str_parms *query,
-                                           struct str_parms *reply)
+void offload_effects_bundle_get_parameters(struct str_parms *query __unused,
+                                           struct str_parms *reply __unused)
 {
-    asphere_get_parameters(query, reply);
 }
 
 __attribute__ ((visibility ("default")))
-void offload_effects_bundle_set_parameters(struct str_parms *parms)
+void offload_effects_bundle_set_parameters(struct str_parms *parms __unused)
 {
-    asphere_set_parameters(parms);
 }
 
 /*
@@ -826,7 +822,6 @@
             status = -ENOSYS;
             goto exit;
         }
-        handle_asphere_on_effect_enabled(true, context, &created_effects_list);
         context->state = EFFECT_STATE_ACTIVE;
         if (context->ops.enable)
             context->ops.enable(context);
@@ -841,7 +836,6 @@
             status = -ENOSYS;
             goto exit;
         }
-        handle_asphere_on_effect_enabled(false, context, &created_effects_list);
         context->state = EFFECT_STATE_INITIALIZED;
         if (context->ops.disable)
             context->ops.disable(context);
diff --git a/qahw/inc/qahw.h b/qahw/inc/qahw.h
index dd5b403..5020c8f 100644
--- a/qahw/inc/qahw.h
+++ b/qahw/inc/qahw.h
@@ -358,6 +358,10 @@
 ssize_t qahw_in_read_l(qahw_stream_handle_t *in_handle,
                      qahw_in_buffer_t *in_buf);
 /*
+ * Stop input stream. Returns zero on success.
+ */
+int qahw_in_stop_l(qahw_stream_handle_t *in_handle);
+/*
  * Return the amount of input frames lost in the audio driver since the
  * last call of this function.
  * Audio driver is expected to reset the value to 0 and restart counting
diff --git a/qahw/src/qahw.c b/qahw/src/qahw.c
index 3390c26..545152c 100644
--- a/qahw/src/qahw.c
+++ b/qahw/src/qahw.c
@@ -61,6 +61,8 @@
 typedef uint64_t (*qahwi_in_read_v2_t)(audio_stream_in_t *in, void* buffer,
                                        size_t bytes, int64_t *timestamp);
 
+typedef int (*qahwi_in_stop_t)(audio_stream_in_t *in);
+
 typedef int (*qahwi_out_set_param_data_t)(struct audio_stream_out *out,
                                       qahw_param_id param_id,
                                       qahw_param_payload *payload);
@@ -109,6 +111,7 @@
     struct listnode list;
     pthread_mutex_t lock;
     qahwi_in_read_v2_t qahwi_in_read_v2;
+    qahwi_in_stop_t qahwi_in_stop;
 } qahw_stream_in_t;
 
 typedef enum {
@@ -1035,6 +1038,31 @@
 }
 
 /*
+ * Stop input stream. Returns zero on success.
+ */
+int qahw_in_stop_l(qahw_stream_handle_t *in_handle)
+{
+    int rc = -EINVAL;
+    qahw_stream_in_t *qahw_stream_in = (qahw_stream_in_t *)in_handle;
+    audio_stream_in_t *in = NULL;
+
+    if (!is_valid_qahw_stream_l((void *)qahw_stream_in, STREAM_DIR_IN)) {
+        ALOGV("%s::Invalid in handle %p", __func__, in_handle);
+        goto exit;
+    }
+    ALOGD("%s", __func__);
+
+    in = qahw_stream_in->stream;
+
+    if (qahw_stream_in->qahwi_in_stop)
+        rc = qahw_stream_in->qahwi_in_stop(in);
+    ALOGD("%s: exit", __func__);
+
+exit:
+    return rc;
+}
+
+/*
  * Return the amount of input frames lost in the audio driver since the
  * last call of this function.
  * Audio driver is expected to reset the value to 0 and restart counting
@@ -1718,6 +1746,7 @@
     qahw_module_t *qahw_module_temp = NULL;
     audio_hw_device_t *audio_device = NULL;
     qahw_stream_in_t *qahw_stream_in = NULL;
+    const char *error;
 
     pthread_mutex_lock(&qahw_module_init_lock);
     qahw_module_temp = get_qahw_module_by_ptr_l(qahw_module);
@@ -1747,6 +1776,7 @@
     if (rc) {
         ALOGE("%s::open input stream failed %d",__func__, rc);
         free(qahw_stream_in);
+        goto exit;
     } else {
         qahw_stream_in->module = hw_module;
         *in_handle = (void *)qahw_stream_in;
@@ -1757,7 +1787,6 @@
     /* dlsym qahwi_in_read_v2 if timestamp flag is used */
     if (!rc && ((flags & QAHW_INPUT_FLAG_TIMESTAMP) ||
                 (flags & QAHW_INPUT_FLAG_PASSTHROUGH))) {
-        const char *error;
 
         /* clear any existing errors */
         dlerror();
@@ -1769,7 +1798,16 @@
         }
     }
 
-exit:
+    /* clear any existing errors */
+    dlerror();
+    qahw_stream_in->qahwi_in_stop = (qahwi_in_stop_t)
+        dlsym(qahw_module->module->dso, "qahwi_in_stop");
+    if ((error = dlerror()) != NULL) {
+        ALOGI("%s: dlsym error %s for qahwi_in_stop", __func__, error);
+        qahw_stream_in->qahwi_in_stop = NULL;
+    }
+
+ exit:
     pthread_mutex_unlock(&qahw_module->lock);
     return rc;
 }
diff --git a/qahw_api/inc/qahw_api.h b/qahw_api/inc/qahw_api.h
index 823c6bb..b37757d 100644
--- a/qahw_api/inc/qahw_api.h
+++ b/qahw_api/inc/qahw_api.h
@@ -354,6 +354,10 @@
 ssize_t qahw_in_read(qahw_stream_handle_t *in_handle,
                      qahw_in_buffer_t *in_buf);
 /*
+ * Stop input stream. Returns zero on success.
+ */
+int qahw_in_stop(qahw_stream_handle_t *in_handle);
+/*
  * Return the amount of input frames lost in the audio driver since the
  * last call of this function.
  * Audio driver is expected to reset the value to 0 and restart counting
diff --git a/qahw_api/src/qahw_api.cpp b/qahw_api/src/qahw_api.cpp
index f1c75f4..0810ede 100644
--- a/qahw_api/src/qahw_api.cpp
+++ b/qahw_api/src/qahw_api.cpp
@@ -678,6 +678,22 @@
     }
 }
 
+int qahw_in_stop(qahw_stream_handle_t *in_handle)
+{
+    if (g_binder_enabled) {
+        if (!g_qas_died) {
+            sp<Iqti_audio_server> qas = get_qti_audio_server();
+            if (qas_status(qas) == -1)
+                return -ENODEV;
+            return qas->qahw_in_stop(in_handle);
+        } else {
+            return -ENODEV;
+        }
+    } else {
+        return qahw_in_stop_l(in_handle);
+    }
+}
+
 uint32_t qahw_in_get_input_frames_lost(qahw_stream_handle_t *in_handle)
 {
     ALOGV("%d:%s",__LINE__, __func__);
@@ -1544,6 +1560,11 @@
     return qahw_in_read_l(in_handle, in_buf);
 }
 
+int qahw_in_stop(qahw_stream_handle_t *in_handle)
+{
+    return qahw_in_stop_l(in_handle);
+}
+
 uint32_t qahw_in_get_input_frames_lost(qahw_stream_handle_t *in_handle)
 {
     ALOGV("%d:%s",__LINE__, __func__);
diff --git a/qahw_api/test/qahw_multi_record_test.c b/qahw_api/test/qahw_multi_record_test.c
index eccfe76..e033921 100644
--- a/qahw_api/test/qahw_multi_record_test.c
+++ b/qahw_api/test/qahw_multi_record_test.c
@@ -283,6 +283,15 @@
   case 8:
       params->config.channel_mask = AUDIO_CHANNEL_INDEX_MASK_8;
       break;
+  case 10:
+      params->config.channel_mask = AUDIO_CHANNEL_INDEX_MASK_10;
+      break;
+  case 12:
+      params->config.channel_mask = AUDIO_CHANNEL_INDEX_MASK_12;
+      break;
+  case 14:
+      params->config.channel_mask = AUDIO_CHANNEL_INDEX_MASK_14;
+      break;
   default:
       fprintf(log_file, "ERROR :::: channle count %d not supported, handle(%d)", params->channels, params->handle);
       if (log_file != stdout)
diff --git a/qahw_api/test/qahw_playback_test.c b/qahw_api/test/qahw_playback_test.c
index 9f1489c..12be83d 100644
--- a/qahw_api/test/qahw_playback_test.c
+++ b/qahw_api/test/qahw_playback_test.c
@@ -353,9 +353,11 @@
     switch (event) {
     case QAHW_STREAM_CBK_EVENT_WRITE_READY:
         fprintf(log_file, "stream %d: received event - QAHW_STREAM_CBK_EVENT_WRITE_READY\n", params->stream_index);
+
         pthread_mutex_lock(&params->write_lock);
         pthread_cond_signal(&params->write_cond);
         pthread_mutex_unlock(&params->write_lock);
+
         break;
     case QAHW_STREAM_CBK_EVENT_DRAIN_READY:
         fprintf(log_file, "stream %d: received event - QAHW_STREAM_CBK_EVENT_DRAIN_READY\n", params->stream_index);
@@ -534,7 +536,7 @@
     stream_config *stream_params = (stream_config*) params_ptr;
 
     ssize_t ret;
-    pthread_mutex_lock(&stream_params->write_lock);
+
     qahw_out_buffer_t out_buf;
 
     memset(&out_buf,0, sizeof(qahw_out_buffer_t));
@@ -545,13 +547,14 @@
     if (ret < 0) {
         fprintf(log_file, "stream %d: writing data to hal failed (ret = %zd)\n", stream_params->stream_index, ret);
     } else if ((ret != bytes) && (!stop_playback)) {
+        pthread_mutex_lock(&stream_params->write_lock);
         fprintf(log_file, "stream %d: provided bytes %zd, written bytes %d\n",stream_params->stream_index, bytes, ret);
         fprintf(log_file, "stream %d: waiting for event write ready\n", stream_params->stream_index);
         pthread_cond_wait(&stream_params->write_cond, &stream_params->write_lock);
         fprintf(log_file, "stream %d: out of wait for event write ready\n", stream_params->stream_index);
+        pthread_mutex_unlock(&stream_params->write_lock);
     }
 
-    pthread_mutex_unlock(&stream_params->write_lock);
     return ret;
 }
 
@@ -2111,6 +2114,7 @@
         {"intr-strm",    required_argument,    0, 'i'},
         {"device-config", required_argument,    0, 'C'},
         {"play-list",    required_argument,    0, 'g'},
+        {"ec-ref",        no_argument,         0, 'L'},
         {"help",          no_argument,          0, 'h'},
         {"bt-wbs",        no_argument,    0, 'z'},
         {0, 0, 0, 0}
@@ -2135,7 +2139,7 @@
 
     while ((opt = getopt_long(argc,
                               argv,
-                              "-f:r:c:b:d:s:v:V:l:t:a:w:k:PD:KF:Ee:A:u:m:S:C:p::x:y:qQzh:i:h:g:O:",
+                              "-f:r:c:b:d:s:v:V:l:t:a:w:k:PD:KF:Ee:A:u:m:S:C:p::x:y:qQzLh:i:h:g:O:",
                               long_options,
                               &option_index)) != -1) {
 
@@ -2335,6 +2339,9 @@
         case 'x':
             render_format = atoi(optarg);
             break;
+        case 'L':
+            ec_ref = true;
+            break;
         case 'y':
             stream_param[i].timestamp_filename = optarg;
             break;
diff --git a/qahw_api/test/qahw_playback_test.h b/qahw_api/test/qahw_playback_test.h
index 6f33338..4c78813 100644
--- a/qahw_api/test/qahw_playback_test.h
+++ b/qahw_api/test/qahw_playback_test.h
@@ -41,6 +41,7 @@
 bool enable_dump;
 float vol_level;
 uint8_t render_format;
+bool ec_ref;
 
 
 enum {
diff --git a/qahw_api/test/qap_wrapper_extn.c b/qahw_api/test/qap_wrapper_extn.c
index de954bf..b3da21a 100644
--- a/qahw_api/test/qap_wrapper_extn.c
+++ b/qahw_api/test/qap_wrapper_extn.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016-2017, The Linux Foundation. All rights reserved.
+ * Copyright (c) 2016-2017,2019 The Linux Foundation. All rights reserved.
  * Not a Contribution.
  *
  * Copyright (C) 2015 The Android Open Source Project *
@@ -88,6 +88,7 @@
 FILE *fp_output_writer_hp = NULL;
 FILE *fp_output_writer_hdmi = NULL;
 FILE *fp_output_timestamp_file = NULL;
+FILE *fp_ecref = NULL;
 unsigned char data_buf[MAX_BUFFER_SIZE];
 uint32_t output_device_id = 0;
 uint16_t input_streams_count = 0;
@@ -207,6 +208,7 @@
     bool enable_hdmi = false;
     bool combo_enabled = false;
     char dev_kv_pair[16] = {0};
+    bool enable_ecref = false;
 
     ALOGV("%s:%d output device id %d render format = %d", __func__, __LINE__, output_device_id, hdmi_render_format);
 
@@ -217,6 +219,8 @@
         enable_hp = true;
     if (output_device_id & AUDIO_DEVICE_OUT_SPEAKER)
         enable_spk = true;
+    if (ec_ref)
+        enable_ecref = true;
 
     if (enable_hdmi) {
         session_output_config.output_config[session_output_config.num_output].id = AUDIO_DEVICE_OUT_HDMI;
@@ -270,6 +274,20 @@
         session_output_config.num_output++;
     }
 
+    if (enable_ecref) {
+        session_output_config.output_config[session_output_config.num_output].channels = popcount(AUDIO_CHANNEL_OUT_STEREO);
+        session_output_config.output_config[session_output_config.num_output].id = AUDIO_DEVICE_OUT_PROXY;
+        session_output_config.output_config[session_output_config.num_output].sample_rate = smpl_rate;
+        if (bitwidth == PCM_24_BITWIDTH) {
+            session_output_config.output_config[session_output_config.num_output].format = QAP_AUDIO_FORMAT_PCM_24_BIT_PACKED;
+            session_output_config.output_config[session_output_config.num_output].bit_width = PCM_24_BITWIDTH;
+        } else {
+            session_output_config.output_config[session_output_config.num_output].format = QAP_AUDIO_FORMAT_PCM_16_BIT;
+            session_output_config.output_config[session_output_config.num_output].bit_width = PCM_16_BITWIDTH;
+        }
+        session_output_config.num_output++;
+    }
+
     ALOGV("%s:%d num_output = %d", __func__, __LINE__, session_output_config.num_output);
     return;
 }
@@ -1235,6 +1253,20 @@
                              ALOGD("%s::%d Measuring Kpi cold stop %lf", __func__, __LINE__, cold_stop);
                         }
                     }
+                    if (buffer->buffer_parms.output_buf_params.output_id == AUDIO_DEVICE_OUT_PROXY) {
+
+                        if (fp_ecref == NULL) {
+                            fp_ecref = fopen("/data/vendor/misc/audio/ecref", "w+");
+                        }
+
+                        if (fp_ecref) {
+                            ALOGD("%s: write %d bytes to ecref dump",__func__,buffer->common_params.size);
+                            fwrite((unsigned char *)buffer->common_params.data, 1, buffer->common_params.size, fp_ecref);
+                        } else {
+                            ALOGE("%s: failed to open ecref dump file",__func__);
+                        }
+
+                    }
                 }
             }
             break;