Merge "st-hal: send LPI SVA acdb id to driver"
diff --git a/sound_trigger_platform.c b/sound_trigger_platform.c
index d4d76fb..303d761 100644
--- a/sound_trigger_platform.c
+++ b/sound_trigger_platform.c
@@ -3609,12 +3609,14 @@
         ret = my_data->audio_hw_acdb_init_v2(stdev->mixer);
         if (ret) {
             ALOGE("%s: ERROR. audio_hw_acdb_init_v2 failed status %d", __func__, ret);
+            my_data->acdb_deinit();
             goto cleanup;
         }
     } else if (my_data->audio_hw_acdb_init) {
             ret = my_data->audio_hw_acdb_init(snd_card_num);
             if (ret) {
                 ALOGE("%s: ERROR. audio_hw_acdb_init failed status %d", __func__, ret);
+                my_data->acdb_deinit();
                 goto cleanup;
             }
     } else {
@@ -3978,7 +3980,7 @@
     case AUDIO_DEVICE_IN_WIRED_HEADSET:
         if ((ST_EXEC_MODE_CPE == exec_mode) ||
             (ST_EXEC_MODE_ADSP == exec_mode)) {
-            if (my_data->codec_backend_cfg.lpi_enable)
+            if (my_data->stdev->lpi_enable)
                 st_device = ST_DEVICE_HEADSET_MIC_LPI;
             else
                 st_device = ST_DEVICE_HEADSET_MIC;
@@ -4046,10 +4048,10 @@
                 else
                     st_device = ST_DEVICE_HANDSET_DMIC;
             } else if (channel_count == SOUND_TRIGGER_CHANNEL_MODE_MONO) {
-                if (v_info->profile_type != ST_PROFILE_TYPE_NONE)
-                    st_device = ST_DEVICE_HANDSET_MIC_PP;
-                else
+                if (my_data->stdev->lpi_enable)
                     st_device = ST_DEVICE_HANDSET_MIC;
+                else
+                    st_device = ST_DEVICE_HANDSET_MIC_PP;
             } else {
                 ALOGE("%s: Invalid channel count %d", __func__, channel_count);
             }
@@ -5745,12 +5747,13 @@
 
 void platform_stdev_check_and_append_usecase
 (
-   void *platform __unused,
-   char *use_case,
-   st_profile_type_t profile_type
+   void *platform,
+   char *use_case
 )
 {
-    if (profile_type != ST_PROFILE_TYPE_NONE)
+    struct platform_data *my_data = (struct platform_data *)platform;
+
+    if (!my_data->stdev->lpi_enable)
         strlcat(use_case, " preproc", USECASE_STRING_SIZE);
 
     ALOGV("%s: return usecase %s", __func__, use_case);
diff --git a/sound_trigger_platform.h b/sound_trigger_platform.h
index 4d976cf..59dd5d5 100644
--- a/sound_trigger_platform.h
+++ b/sound_trigger_platform.h
@@ -657,8 +657,7 @@
 void platform_stdev_check_and_append_usecase
 (
    void *platform,
-   char *use_case,
-   st_profile_type_t profile_type
+   char *use_case
 );
 
 void platform_stdev_check_and_update_ec_ref_config
diff --git a/st_hw_session_lsm.c b/st_hw_session_lsm.c
index d2e673e..1ff1abc 100644
--- a/st_hw_session_lsm.c
+++ b/st_hw_session_lsm.c
@@ -611,7 +611,7 @@
                 p_ses->stdev->ape_pcm_use_cases[p_ses->use_case_idx].use_case,
                 USECASE_STRING_SIZE);
         platform_stdev_check_and_append_usecase(p_ses->stdev->platform,
-                                               use_case, profile_type);
+                                                use_case);
         ALOGD("%s: enable use case = %s", __func__, use_case);
         platform_stdev_send_stream_app_type_cfg(p_ses->stdev->platform,
                                    p_lsm_ses->pcm_id, p_ses->st_device,
@@ -648,7 +648,6 @@
 {
     int ret = 0;
     char port_ctrl[USECASE_STRING_SIZE] = {0};
-    st_profile_type_t profile_type = get_profile_type(p_ses);
     st_hw_session_lsm_t *p_lsm_ses = (st_hw_session_lsm_t *)p_ses;
 
     if (enable) {
@@ -656,7 +655,7 @@
                 p_ses->stdev->ape_pcm_use_cases[p_ses->use_case_idx].use_case,
                 USECASE_STRING_SIZE);
         platform_stdev_check_and_append_usecase(p_ses->stdev->platform,
-                                                port_ctrl, profile_type);
+                                                port_ctrl);
         strlcat(port_ctrl, " port", USECASE_STRING_SIZE);
 
         ALOGV("%s: enable = %s", __func__, port_ctrl);
diff --git a/st_session.c b/st_session.c
index f54c999..32a6e90 100644
--- a/st_session.c
+++ b/st_session.c
@@ -3972,6 +3972,7 @@
         if (status)
             ALOGE("%s:[%d] stop_session failed %d", __func__, st_ses->sm_handle,
                   status);
+        STATE_TRANSITION(st_ses, loaded_state_fn);
     }
 
     status = hw_ses->fptrs->dereg_sm(hw_ses);
@@ -4060,6 +4061,7 @@
         if (status)
             ALOGE("%s:[%d] stop_session failed %d", __func__,
                 st_ses->sm_handle, status);
+        STATE_TRANSITION(st_ses, loaded_state_fn);
     }
 
     status = hw_ses->fptrs->dereg_sm(hw_ses);