Merge "configs: Declare midi feature support"
diff --git a/configs/atoll/sound_trigger_platform_info.xml b/configs/atoll/sound_trigger_platform_info.xml
index 07a59d0..00ba7ec 100644
--- a/configs/atoll/sound_trigger_platform_info.xml
+++ b/configs/atoll/sound_trigger_platform_info.xml
@@ -50,6 +50,8 @@
         <param dedicated_sva_path="true" />
         <param dedicated_headset_path="false" />
         <param platform_lpi_enable="true" />
+        <param enable_debug_dumps="false" />
+        <param support_non_lpi_without_ec="false" />
     </common_config>
     <acdb_ids>
         <param DEVICE_HANDSET_MIC_APE="100" />
@@ -105,27 +107,6 @@
             <param bit_wdith="16"/>
             <param channel_count="1"/>
         </arm_ss_usecase>
-        <gcs_usecase>
-            <param uid="0x1" />
-            <param acdb_devices="DEVICE_HANDSET_MIC_CPE, DEVICE_HANDSET_TMIC_CPE, DEVICE_HEADSET_MIC_CPE" />
-            <!-- module_id, instance_id, param_id -->
-            <param load_sound_model_ids="0x00012C0D, 0x2, 0x00012C14" />
-            <param confidence_levels_ids="0x00012C0D, 0x2, 0x00012C28" />
-            <param detection_event_ids="0x00012C0D, 0x2, 0x00012C29" />
-            <param read_cmd_ids="0x00020013, 0x2, 0x00020015" />
-            <param read_rsp_ids="0x00020013, 0x2, 0x00020016" />
-            <param custom_config_ids="0x00012C0D, 0x2, 0x00012C20" />
-        </gcs_usecase>
-        <gcs_usecase>
-            <param uid="0x2" />
-            <param acdb_devices="DEVICE_HANDSET_MIC_CPE, DEVICE_HANDSET_TMIC_CPE, DEVICE_HEADSET_MIC_CPE" />
-            <param load_sound_model_ids="0x00012C0D, 0x3, 0x00012C14" />
-            <param confidence_levels_ids="0x00012C0D, 0x3, 0x00012C28" />
-            <param detection_event_ids="0x00012C0D, 0x3, 0x00012C29" />
-            <param read_cmd_ids="0x00020013, 0x3, 0x00020015" />
-            <param read_rsp_ids="0x00020013, 0x3, 0x00020016" />
-            <param custom_config_ids="0x00012C0D, 0x3, 0x00012C20" />
-        </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.
@@ -138,11 +119,47 @@
             <!-- fluence_type: "FLUENCE_MIC", "FLUENCE_DMIC", "FLUENCE_TMIC"   -->
             <!-- "FLUENCE_QMIC". Param value is valid when adm_cfg_profile -->
             <!-- is FFECNS -->
-            <param fluence_type="FLUENCE_TMIC" />
+            <param fluence_type="FLUENCE_DMIC" />
             <param execution_mode="ADSP" />
+            <!-- lpi_mode: "NON_LPI_BARGE_IN", "NON_LPI", "LPI" -->
+            <!-- NON_LPI_BARGE_IN: Default non-LPI mode type. lsm_usecase -->
+            <!-- must be present with this mode type to handle barge-in. -->
+            <!-- NON_LPI: If another lsm_usecase is present with this mode -->
+            <!-- type, it will be used for non-LPI non-barge-in usecases. -->
+            <!-- If not present, NON_LPI_BARGE_IN mode type will be used. -->
+            <!-- LPI: This mode type will be used for LPI usecases. -->
+            <param lpi_mode="NON_LPI_BARGE_IN" />
             <param app_type="2" /> <!-- app type used in ACDB -->
             <param in_channels="5"/> <!-- Module input channels -->
-            <param in_channels_lpi="1"/>
+            <param load_sound_model_ids="0x00012C1C, 0x0, 0x00012C14" />
+            <param unload_sound_model_ids="0x00012C1C, 0x0, 0x00012C15" />
+            <param confidence_levels_ids="0x00012C1C, 0x0, 0x00012C07" />
+            <param operation_mode_ids="0x00012C1C, 0x0, 0x00012C02" />
+            <param polling_enable_ids="0x00012C1C, 0x0, 0x00012C1B" />
+            <param custom_config_ids="0x00012C1C, 0x0, 0x00012C20" />
+            <param det_event_type_ids="0x00012C1C, 0x0, 0x00012C2C" />
+            <param lab_dam_cfg_ids="0x00012C08, 0x0, 0x000102C4" />
+        </lsm_usecase>
+        <lsm_usecase>
+            <param capture_device="HANDSET" />
+            <!-- adm_cfg_profile should match with the one defined under adm_config -->
+            <!-- Set it to NONE if LSM directly connects to AFE -->
+            <param adm_cfg_profile="FFECNS" />
+            <!-- fluence_type: "FLUENCE_MIC", "FLUENCE_DMIC", "FLUENCE_TMIC"   -->
+            <!-- "FLUENCE_QMIC". Param value is valid when adm_cfg_profile -->
+            <!-- is FFECNS -->
+            <param fluence_type="FLUENCE_DMIC" />
+            <param execution_mode="ADSP" />
+            <!-- lpi_mode: "NON_LPI_BARGE_IN", "NON_LPI", "LPI" -->
+            <!-- NON_LPI_BARGE_IN: Default non-LPI mode type. lsm_usecase -->
+            <!-- must be present with this mode type to handle barge-in. -->
+            <!-- NON_LPI: If another lsm_usecase is present with this mode -->
+            <!-- type, it will be used for non-LPI non-barge-in usecases. -->
+            <!-- If not present, NON_LPI_BARGE_IN mode type will be used. -->
+            <!-- LPI: This mode type will be used for LPI usecases. -->
+            <param lpi_mode="LPI" />
+            <param app_type="2" /> <!-- app type used in ACDB -->
+            <param in_channels="1"/> <!-- Module input channels -->
             <param load_sound_model_ids="0x00012C1C, 0x0, 0x00012C14" />
             <param unload_sound_model_ids="0x00012C1C, 0x0, 0x00012C15" />
             <param confidence_levels_ids="0x00012C1C, 0x0, 0x00012C07" />
diff --git a/configs/kona/kona.mk b/configs/kona/kona.mk
index 16ef488..6b73f5d 100644
--- a/configs/kona/kona.mk
+++ b/configs/kona/kona.mk
@@ -216,11 +216,11 @@
 
 ##Ambisonic Capture
 PRODUCT_PROPERTY_OVERRIDES += \
-vendor.audio.ambisonic.capture=true \
-vendor.audio.ambisonic.auto.profile=true
+persist.vendor.audio.ambisonic.capture=false \
+persist.vendor.audio.ambisonic.auto.profile=false
 
 PRODUCT_PROPERTY_OVERRIDES += \
-vendor.audio.apptype.multirec.enabled=true
+persist.vendor.audio.apptype.multirec.enabled=false
 
 ##fluencetype can be "fluence" or "fluencepro" or "none"
 PRODUCT_PROPERTY_OVERRIDES += \
diff --git a/configs/lito/sound_trigger_platform_info.xml b/configs/lito/sound_trigger_platform_info.xml
index 3cbcd67..00ba7ec 100644
--- a/configs/lito/sound_trigger_platform_info.xml
+++ b/configs/lito/sound_trigger_platform_info.xml
@@ -50,6 +50,8 @@
         <param dedicated_sva_path="true" />
         <param dedicated_headset_path="false" />
         <param platform_lpi_enable="true" />
+        <param enable_debug_dumps="false" />
+        <param support_non_lpi_without_ec="false" />
     </common_config>
     <acdb_ids>
         <param DEVICE_HANDSET_MIC_APE="100" />
@@ -119,9 +121,45 @@
             <!-- is FFECNS -->
             <param fluence_type="FLUENCE_DMIC" />
             <param execution_mode="ADSP" />
+            <!-- lpi_mode: "NON_LPI_BARGE_IN", "NON_LPI", "LPI" -->
+            <!-- NON_LPI_BARGE_IN: Default non-LPI mode type. lsm_usecase -->
+            <!-- must be present with this mode type to handle barge-in. -->
+            <!-- NON_LPI: If another lsm_usecase is present with this mode -->
+            <!-- type, it will be used for non-LPI non-barge-in usecases. -->
+            <!-- If not present, NON_LPI_BARGE_IN mode type will be used. -->
+            <!-- LPI: This mode type will be used for LPI usecases. -->
+            <param lpi_mode="NON_LPI_BARGE_IN" />
             <param app_type="2" /> <!-- app type used in ACDB -->
             <param in_channels="5"/> <!-- Module input channels -->
-            <param in_channels_lpi="1"/>
+            <param load_sound_model_ids="0x00012C1C, 0x0, 0x00012C14" />
+            <param unload_sound_model_ids="0x00012C1C, 0x0, 0x00012C15" />
+            <param confidence_levels_ids="0x00012C1C, 0x0, 0x00012C07" />
+            <param operation_mode_ids="0x00012C1C, 0x0, 0x00012C02" />
+            <param polling_enable_ids="0x00012C1C, 0x0, 0x00012C1B" />
+            <param custom_config_ids="0x00012C1C, 0x0, 0x00012C20" />
+            <param det_event_type_ids="0x00012C1C, 0x0, 0x00012C2C" />
+            <param lab_dam_cfg_ids="0x00012C08, 0x0, 0x000102C4" />
+        </lsm_usecase>
+        <lsm_usecase>
+            <param capture_device="HANDSET" />
+            <!-- adm_cfg_profile should match with the one defined under adm_config -->
+            <!-- Set it to NONE if LSM directly connects to AFE -->
+            <param adm_cfg_profile="FFECNS" />
+            <!-- fluence_type: "FLUENCE_MIC", "FLUENCE_DMIC", "FLUENCE_TMIC"   -->
+            <!-- "FLUENCE_QMIC". Param value is valid when adm_cfg_profile -->
+            <!-- is FFECNS -->
+            <param fluence_type="FLUENCE_DMIC" />
+            <param execution_mode="ADSP" />
+            <!-- lpi_mode: "NON_LPI_BARGE_IN", "NON_LPI", "LPI" -->
+            <!-- NON_LPI_BARGE_IN: Default non-LPI mode type. lsm_usecase -->
+            <!-- must be present with this mode type to handle barge-in. -->
+            <!-- NON_LPI: If another lsm_usecase is present with this mode -->
+            <!-- type, it will be used for non-LPI non-barge-in usecases. -->
+            <!-- If not present, NON_LPI_BARGE_IN mode type will be used. -->
+            <!-- LPI: This mode type will be used for LPI usecases. -->
+            <param lpi_mode="LPI" />
+            <param app_type="2" /> <!-- app type used in ACDB -->
+            <param in_channels="1"/> <!-- Module input channels -->
             <param load_sound_model_ids="0x00012C1C, 0x0, 0x00012C14" />
             <param unload_sound_model_ids="0x00012C1C, 0x0, 0x00012C15" />
             <param confidence_levels_ids="0x00012C1C, 0x0, 0x00012C07" />
diff --git a/configs/msmnile_au/audio_policy_configuration.xml b/configs/msmnile_au/audio_policy_configuration.xml
index 65f5e8a..5a54b6d 100644
--- a/configs/msmnile_au/audio_policy_configuration.xml
+++ b/configs/msmnile_au/audio_policy_configuration.xml
@@ -218,9 +218,6 @@
                     <profile name="" format="AUDIO_FORMAT_PCM_8_24_BIT"
                              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"/>
-                    <profile name="" format="AUDIO_FORMAT_PCM_FLOAT"
-                             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"/>
                 </mixPort>
                 <mixPort name="voice_rx" role="sink">
                     <profile name="" format="AUDIO_FORMAT_PCM_16_BIT"
diff --git a/configs/msmsteppe_au/audio_policy_configuration.xml b/configs/msmsteppe_au/audio_policy_configuration.xml
index 2d45ec3..7355e3f 100644
--- a/configs/msmsteppe_au/audio_policy_configuration.xml
+++ b/configs/msmsteppe_au/audio_policy_configuration.xml
@@ -218,9 +218,6 @@
                     <profile name="" format="AUDIO_FORMAT_PCM_8_24_BIT"
                              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"/>
-                    <profile name="" format="AUDIO_FORMAT_PCM_FLOAT"
-                             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"/>
                 </mixPort>
                 <mixPort name="voice_rx" role="sink">
                     <profile name="" format="AUDIO_FORMAT_PCM_16_BIT"
diff --git a/hal/audio_extn/battery_listener.cpp b/hal/audio_extn/battery_listener.cpp
index 55db095..604f81c 100644
--- a/hal/audio_extn/battery_listener.cpp
+++ b/hal/audio_extn/battery_listener.cpp
@@ -65,6 +65,7 @@
         std::lock_guard<std::mutex> _l(mLock);
         return statusToBool(mStatus);
     }
+    void reset();
   private:
     sp<hardware::health::V2_0::IHealth> mHealth;
     status_t init();
@@ -164,15 +165,19 @@
 
 BatteryListenerImpl::~BatteryListenerImpl()
 {
-    {
-        std::lock_guard<std::mutex> _l(mLock);
-        if (mHealth != NULL)
-            mHealth->unlinkToDeath(this);
-    }
-    mDone = true;
     mThread->join();
 }
 
+void BatteryListenerImpl::reset(){
+    std::lock_guard<std::mutex> _l(mLock);
+    if (mHealth != nullptr) {
+        mHealth->unregisterCallback(this);
+        mHealth->unlinkToDeath(this);
+    }
+    mStatus = BatteryStatus::UNKNOWN;
+    mDone = true;
+    mCond.notify_one();
+}
 void BatteryListenerImpl::serviceDied(uint64_t cookie __unused,
                                      const wp<hidl::base::V1_0::IBase>& who)
 {
@@ -216,6 +221,7 @@
 
 status_t batteryPropertiesListenerDeinit()
 {
+    batteryListener->reset();
     batteryListener.clear();
     return OK;
 }
diff --git a/hal/audio_hw.c b/hal/audio_hw.c
index 8366f24..e31e1ad 100644
--- a/hal/audio_hw.c
+++ b/hal/audio_hw.c
@@ -7476,6 +7476,9 @@
                               __func__, ret);
                         goto error_open;
                     }
+                } else {
+                    out->usecase = GET_USECASE_AUDIO_PLAYBACK_PRIMARY(use_db_as_primary);
+                    out->config = GET_PCM_CONFIG_AUDIO_PLAYBACK_PRIMARY(use_db_as_primary);
                 }
         }
     } else if (audio_is_linear_pcm(out->format) &&
@@ -9469,6 +9472,7 @@
     if ((--audio_device_ref_count) == 0) {
          if (audio_extn_spkr_prot_is_enabled())
              audio_extn_spkr_prot_deinit();
+        audio_extn_battery_properties_listener_deinit();
         audio_extn_snd_mon_unregister_listener(adev);
         audio_extn_sound_trigger_deinit(adev);
         audio_extn_listen_deinit(adev);
diff --git a/hal/msm8974/platform.c b/hal/msm8974/platform.c
index 61eca9b..8d6e7bc 100644
--- a/hal/msm8974/platform.c
+++ b/hal/msm8974/platform.c
@@ -3185,11 +3185,11 @@
         }
     }
     /* Check for Ambisonic Capture Enablement */
-    if (property_get_bool("vendor.audio.ambisonic.capture",false))
+    if (property_get_bool("persist.vendor.audio.ambisonic.capture",false))
         my_data->ambisonic_capture = true;
 
     /* Check for Ambisonic Profile Assignment*/
-    if (property_get_bool("vendor.audio.ambisonic.auto.profile",false))
+    if (property_get_bool("persist.vendor.audio.ambisonic.auto.profile",false))
         my_data->ambisonic_profile = true;
 
     if (audio_extn_is_wsa_enabled()
@@ -3642,10 +3642,6 @@
         strdup("USB_AUDIO_TX SampleRate");
     my_data->current_backend_cfg[USB_AUDIO_TX_BACKEND].channels_mixer_ctl =
         strdup("USB_AUDIO_TX Channels");
-    my_data->current_backend_cfg[SLIMBUS_0_TX].bitwidth_mixer_ctl =
-        strdup("SLIM_0_TX Format");
-    my_data->current_backend_cfg[SLIMBUS_0_TX].samplerate_mixer_ctl =
-        strdup("SLIM_0_TX SampleRate");
 
     if (!strncmp(platform_get_snd_device_backend_interface(SND_DEVICE_IN_HDMI_MIC),
         "SEC_MI2S_TX", sizeof("SEC_MI2S_TX"))) {
@@ -3765,7 +3761,7 @@
         }
     }
 
-    if (property_get_bool("vendor.audio.apptype.multirec.enabled", false))
+    if (property_get_bool("persist.vendor.audio.apptype.multirec.enabled", false))
         my_data->use_generic_handset = true;
 
     /* Initialize keep alive for HDMI/loopback silence */
@@ -6223,8 +6219,6 @@
         } else if (audio_extn_is_hifi_filter_enabled(adev, out, snd_device,
              my_data->codec_variant, channel_count, 1)) {
                 snd_device = SND_DEVICE_OUT_HEADPHONES_HIFI_FILTER;
-        } else if (devices & SND_DEVICE_OUT_HEADPHONES_HIFI_FILTER) {
-                snd_device = SND_DEVICE_OUT_HEADPHONES_HIFI_FILTER;
         } else if (devices & AUDIO_DEVICE_OUT_LINE) {
                 snd_device = SND_DEVICE_OUT_LINE;
         } else