ahal: send audio route instance to sthal when init done

Notify sthal when audio route init is done from ahal,
then sthal can share the same route instance with ahal.
This is to make the active count of mixer ctls are
managed by audio route for concurrency handling.

Change-Id: Iba0a76bd4447bcc528722eacc113b8dad8189313
diff --git a/hal/audio_extn/soundtrigger.c b/hal/audio_extn/soundtrigger.c
index 52dd070..a97ccf0 100644
--- a/hal/audio_extn/soundtrigger.c
+++ b/hal/audio_extn/soundtrigger.c
@@ -37,6 +37,7 @@
 #include <pthread.h>
 #include <log/log.h>
 #include <unistd.h>
+#include <cutils/properties.h>
 #include "audio_hw.h"
 #include "audio_extn.h"
 #include "platform.h"
@@ -85,7 +86,8 @@
     AUDIO_EVENT_BATTERY_STATUS_CHANGED,
     AUDIO_EVENT_GET_PARAM,
     AUDIO_EVENT_UPDATE_ECHO_REF,
-    AUDIO_EVENT_SCREEN_STATUS_CHANGED
+    AUDIO_EVENT_SCREEN_STATUS_CHANGED,
+    AUDIO_EVENT_ROUTE_INIT_DONE
 } audio_event_type_t;
 
 typedef enum {
@@ -147,6 +149,7 @@
         struct audio_hal_usecase usecase;
         bool audio_ec_ref_enabled;
         struct sound_trigger_get_param_data st_get_param_data;
+        struct audio_route *audio_route;
     } u;
     struct sound_trigger_device_info device_info;
 };
@@ -208,6 +211,7 @@
     pthread_mutex_t lock;
     unsigned int sthal_prop_api_version;
     bool st_ec_ref_enabled;
+    bool shared_mixer;
 };
 
 static struct sound_trigger_audio_device *st_dev;
@@ -493,6 +497,9 @@
         return ret;
     }
 
+    if (st_dev->shared_mixer)
+        return ret;
+
     pthread_mutex_lock(&st_dev->lock);
     if (st_dev->st_ec_ref_enabled) {
         ret = true;
@@ -514,6 +521,9 @@
         return;
     }
 
+    if (st_dev->shared_mixer)
+        return;
+
     ev_info.u.audio_ec_ref_enabled = on;
     st_dev->st_callback(AUDIO_EVENT_UPDATE_ECHO_REF, &ev_info);
     ALOGD("%s: update audio echo ref status %s",__func__,
@@ -790,6 +800,7 @@
     int status = 0;
     char sound_trigger_lib[100];
     void *sthal_prop_api_version;
+    audio_event_info_t event = {{0}, {0}};
 
     ALOGI("%s: Enter", __func__);
 
@@ -837,9 +848,15 @@
 
     st_dev->adev = adev;
     st_dev->st_ec_ref_enabled = false;
+    st_dev->shared_mixer =
+        property_get_bool("persist.vendor.audio.shared_mixer.enabled", false);
     list_init(&st_dev->st_ses_list);
     audio_extn_snd_mon_register_listener(st_dev, stdev_snd_mon_cb);
-
+    if (st_dev->shared_mixer) {
+        event.u.audio_route = adev->audio_route;
+        st_dev->st_callback(AUDIO_EVENT_ROUTE_INIT_DONE, &event);
+        ALOGD("%s: send the audio route instance to sthal",  __func__);
+    }
     return 0;
 
 cleanup: