Merge "hal: Fix teardown during back to back pause/play of WFD session"
diff --git a/hal/audio_extn/audio_extn.h b/hal/audio_extn/audio_extn.h
index 80bc434..a17f011 100644
--- a/hal/audio_extn/audio_extn.h
+++ b/hal/audio_extn/audio_extn.h
@@ -211,8 +211,10 @@
 
 #if defined(DS1_DOLBY_DDP_ENABLED) || defined(DS1_DOLBY_DAP_ENABLED)
 void audio_extn_dolby_set_dmid(struct audio_device *adev);
+void audio_extn_dolby_set_license(struct audio_device *adev);
 #else
 #define audio_extn_dolby_set_dmid(adev)                 (0)
+#define audio_extn_dolby_set_license(adev)              (0)
 #endif
 
 #ifndef DS1_DOLBY_DDP_ENABLED
diff --git a/hal/audio_extn/dolby.c b/hal/audio_extn/dolby.c
index 99fa2b7..cb74715 100644
--- a/hal/audio_extn/dolby.c
+++ b/hal/audio_extn/dolby.c
@@ -287,6 +287,15 @@
     int ddp_dev, dev_ch_cap;
     int val, ret;
     char value[32]={0};
+
+    ret = str_parms_get_str(parms, AUDIO_PARAMETER_KEY_SND_CARD_STATUS, value,
+                            sizeof(value));
+    if (ret >= 0) {
+        char *snd_card_status = value + 2;
+        if (strncmp(snd_card_status, "ONLINE", sizeof("ONLINE")) == 0)
+            audio_extn_dolby_set_license(adev);
+    }
+
     ret = str_parms_get_str(parms, AUDIO_PARAMETER_DDP_DEV, value,
                             sizeof(value));
     if (ret >= 0) {
@@ -470,4 +479,29 @@
 
     return;
 }
+
+void audio_extn_dolby_set_license(struct audio_device *adev)
+{
+    int ret, key=0;
+    char value[128] = {0};
+    struct mixer_ctl *ctl;
+    const char *mixer_ctl_name = "DS1 License";
+
+    ctl = mixer_get_ctl_by_name(adev->mixer, mixer_ctl_name);
+    if (!ctl) {
+        ALOGE("%s: Could not get ctl for mixer cmd - %s",
+              __func__, mixer_ctl_name);
+        return;
+    }
+
+    property_get("audio.ds1.metainfo.key",value,"0");
+    key = atoi(value);
+
+    ALOGV("%s Setting DS1 License, key:0x%x",__func__, key);
+    ret = mixer_ctl_set_value(ctl, 0, key);
+    if (ret)
+        ALOGE("%s: cannot set license, error:%d",__func__, ret);
+
+    return;
+}
 #endif /* DS1_DOLBY_DDP_ENABLED || DS1_DOLBY_DAP_ENABLED */
diff --git a/hal/msm8916/platform.c b/hal/msm8916/platform.c
index 4ca7ce7..c71706c 100644
--- a/hal/msm8916/platform.c
+++ b/hal/msm8916/platform.c
@@ -34,6 +34,8 @@
 
 #define MIXER_XML_PATH "/system/etc/mixer_paths.xml"
 #define MIXER_XML_PATH_MTP "/system/etc/mixer_paths_mtp.xml"
+#define MIXER_XML_PATH_QRD_SKUH "/system/etc/mixer_paths_qrd_skuh.xml"
+#define MIXER_XML_PATH_QRD_SKUI "/system/etc/mixer_paths_qrd_skui.xml"
 #define MIXER_XML_PATH_AUXPCM "/system/etc/mixer_paths_auxpcm.xml"
 #define PLATFORM_INFO_XML_PATH      "/system/etc/audio_platform_info.xml"
 #define LIB_ACDB_LOADER "libacdbloader.so"
@@ -402,6 +404,14 @@
                  sizeof("msm8x16-snd-card-mtp"))) {
         strlcpy(mixer_xml_path, MIXER_XML_PATH_MTP,
                 sizeof(MIXER_XML_PATH_MTP));
+    } else if (!strncmp(snd_card_name, "msm8x16-skuh-snd-card",
+                 sizeof("msm8x16-skuh-snd-card"))) {
+        strlcpy(mixer_xml_path, MIXER_XML_PATH_QRD_SKUH,
+                sizeof(MIXER_XML_PATH_QRD_SKUH));
+    } else if (!strncmp(snd_card_name, "msm8x16-skui-snd-card",
+                 sizeof("msm8x16-skui-snd-card"))) {
+        strlcpy(mixer_xml_path, MIXER_XML_PATH_QRD_SKUI,
+                sizeof(MIXER_XML_PATH_QRD_SKUI));
     } else {
         strlcpy(mixer_xml_path, MIXER_XML_PATH,
                 sizeof(MIXER_XML_PATH));
@@ -706,6 +716,9 @@
     /* Read one time ssr property */
     audio_extn_ssr_update_enabled();
     audio_extn_spkr_prot_init(adev);
+
+    audio_extn_dolby_set_license(adev);
+
     return my_data;
 }
 
diff --git a/hal/msm8974/platform.c b/hal/msm8974/platform.c
index 64e090b..ecb8b50 100644
--- a/hal/msm8974/platform.c
+++ b/hal/msm8974/platform.c
@@ -785,6 +785,9 @@
     /* Read one time ssr property */
     audio_extn_ssr_update_enabled();
     audio_extn_spkr_prot_init(adev);
+
+    audio_extn_dolby_set_license(adev);
+
     return my_data;
 }
 
diff --git a/hal/voice_extn/voice_extn.c b/hal/voice_extn/voice_extn.c
index 74dc426..d42cc53 100644
--- a/hal/voice_extn/voice_extn.c
+++ b/hal/voice_extn/voice_extn.c
@@ -302,12 +302,6 @@
             no_of_calls_active++;
     }
 
-    /* When there is only one call active, wait for audio policy manager to set
-     * the mode to AUDIO_MODE_NORMAL and trigger routing to end the last call.
-     */
-    if (no_of_calls_active == 1 && call_state == CALL_INACTIVE)
-        return 0;
-
     if (session) {
         session->state.new = call_state;
         voice_extn_is_in_call(adev, &is_in_call);