hal : native DSD concurrency support over headphone.

 -Enable ASRC mode for headphone backend if headphone 44.1 or
  native DSD backend is active.
 -Disable headphone backend and reopen it with ASRC mode for upcoming
  use case over headphone 44.1 or native DSD backend

Change-Id: Ic8fb0ab9f254d3472fda49dbb824f622d518a451
diff --git a/hal/msm8974/platform.c b/hal/msm8974/platform.c
index 9c85d10..f12114a 100644
--- a/hal/msm8974/platform.c
+++ b/hal/msm8974/platform.c
@@ -248,6 +248,7 @@
     int source_mic_type;
     int max_mic_count;
     bool is_dsd_supported;
+    bool is_asrc_supported;
 };
 
 static int pcm_device_table[AUDIO_USECASE_MAX][2] = {
@@ -1759,6 +1760,7 @@
     if(strstr(snd_card_name, "tavil")) {
         ALOGD("%s:DSD playback is supported", __func__);
         my_data->is_dsd_supported = true;
+        my_data->is_asrc_supported = true;
         platform_set_native_support(NATIVE_AUDIO_MODE_MULTIPLE_44_1);
     }
 
@@ -1924,6 +1926,32 @@
     return result;
 }
 
+bool platform_check_if_backend_has_to_be_disabled(snd_device_t new_snd_device,
+                                                  snd_device_t cuurent_snd_device)
+{
+    bool result = false;
+
+    ALOGV("%s: current snd device = %s, new snd device = %s", __func__,
+                platform_get_snd_device_name(cuurent_snd_device),
+                platform_get_snd_device_name(new_snd_device));
+
+    if ((new_snd_device < SND_DEVICE_MIN) || (new_snd_device >= SND_DEVICE_OUT_END) ||
+            (cuurent_snd_device < SND_DEVICE_MIN) || (cuurent_snd_device >= SND_DEVICE_OUT_END)) {
+        ALOGE("%s: Invalid snd_device",__func__);
+        return false;
+    }
+
+    if (cuurent_snd_device == SND_DEVICE_OUT_HEADPHONES &&
+            (new_snd_device == SND_DEVICE_OUT_HEADPHONES_44_1 ||
+             new_snd_device == SND_DEVICE_OUT_HEADPHONES_DSD)) {
+        result = true;
+    }
+
+    ALOGV("%s: Need to disable current backend %s, %d",
+          __func__, platform_get_snd_device_name(cuurent_snd_device), result);
+    return result;
+}
+
 int platform_get_pcm_device_id(audio_usecase_t usecase, int device_type)
 {
     int device_id;
@@ -2131,6 +2159,12 @@
     return my_data->is_dsd_supported;
 }
 
+bool platform_check_codec_asrc_support(void *platform)
+{
+    struct platform_data *my_data = (struct platform_data *)platform;
+    return my_data->is_asrc_supported;
+}
+
 int platform_get_native_support()
 {
     int ret = NATIVE_AUDIO_MODE_INVALID;