hal: Add sound card support for msmfalcon

- Add msmfalcon target variant sound card
  details.

Change-Id: I9b5b281a9ae4209fe163325d889ff248af13e91f
diff --git a/hal/msm8916/hw_info.c b/hal/msm8916/hw_info.c
index 4b760ab..35de9e3 100644
--- a/hal/msm8916/hw_info.c
+++ b/hal/msm8916/hw_info.c
@@ -149,11 +149,17 @@
         strlcpy(hw_info->name, "msm8917", sizeof(hw_info->name));
      } else if (!strcmp(snd_card_name, "msm8940-sku6-snd-card")) {
         strlcpy(hw_info->name, "msm8940", sizeof(hw_info->name));
+    } else if (!strcmp(snd_card_name, "msmfalcon-snd-card")) {
+        strlcpy(hw_info->name, "msmfalcon", sizeof(hw_info->name));
     } else if (!strcmp(snd_card_name, "msmfalcon-snd-card-mtp")) {
         strlcpy(hw_info->name, "msmfalcon", sizeof(hw_info->name));
     } else if (!strcmp(snd_card_name, "msmfalcon-tasha-snd-card")) {
         strlcpy(hw_info->name, "msmfalcon", sizeof(hw_info->name));
-     } else if (!strcmp(snd_card_name, "msm8920-sku7-snd-card")) {
+    } else if (!strcmp(snd_card_name, "msmfalcon-tavil-snd-card")) {
+        strlcpy(hw_info->name, "msmfalcon", sizeof(hw_info->name));
+    } else if (!strcmp(snd_card_name, "msmfalcon-tashalite-snd-card")) {
+        strlcpy(hw_info->name, "msmfalcon", sizeof(hw_info->name));
+    } else if (!strcmp(snd_card_name, "msm8920-sku7-snd-card")) {
         strlcpy(hw_info->name, "msm8920", sizeof(hw_info->name));
     } else if (!strcmp(snd_card_name, "apq8009-tashalite-snd-card")) {
         strlcpy(hw_info->name, "apq8009", sizeof(hw_info->name));
diff --git a/hal/msm8916/platform.c b/hal/msm8916/platform.c
index ea6b743..0f95cce 100644
--- a/hal/msm8916/platform.c
+++ b/hal/msm8916/platform.c
@@ -57,6 +57,7 @@
 #define MIXER_XML_PATH_WCD9306 "/system/etc/mixer_paths_wcd9306.xml"
 #define MIXER_XML_PATH_WCD9330 "/system/etc/mixer_paths_wcd9330.xml"
 #define MIXER_XML_PATH_WCD9335 "/system/etc/mixer_paths_wcd9335.xml"
+#define MIXER_XML_PATH_WCD9340 "/system/etc/mixer_paths_wcd9340.xml"
 #ifdef LINUX_ENABLED
 #define MIXER_XML_PATH "/etc/mixer_paths.xml"
 #define MIXER_XML_PATH_MSM8909_PM8916 "/etc/mixer_paths_msm8909_pm8916.xml"
@@ -75,6 +76,7 @@
 #define MIXER_XML_PATH_SKU2 "/system/etc/mixer_paths_qrd_sku2.xml"
 #define PLATFORM_INFO_XML_PATH_EXTCODEC  "/system/etc/audio_platform_info_extcodec.xml"
 #define MIXER_XML_PATH_WCD9326 "/system/etc/mixer_paths_wcd9326.xml"
+#define MIXER_XML_PATH_SKUN "/system/etc/mixer_paths_qrd_skun.xml"
 #define PLATFORM_INFO_XML_PATH      "/system/etc/audio_platform_info.xml"
 #define MIXER_XML_PATH_WCD9326_I2S  "/system/etc/mixer_paths_wcd9326_i2s.xml"
 #define MIXER_XML_PATH_WCD9330_I2S "/system/etc/mixer_paths_wcd9330_i2s.xml"
@@ -159,6 +161,8 @@
 
 #define  AUDIO_PARAMETER_IS_HW_DECODER_SESSION_AVAILABLE  "is_hw_dec_session_available"
 
+static char *default_rx_backend = NULL;
+
 char dsp_only_decoders_mime[][MAX_MIME_TYPE_LENGTH] = {
     "audio/x-ms-wma" /* wma*/ ,
     "audio/x-ms-wma-lossless" /* wma lossless */ ,
@@ -880,7 +884,11 @@
          !strncmp(snd_card_name, "apq8009-tashalite-snd-card",
                   sizeof("apq8009-tashalite-snd-card")) ||
          !strncmp(snd_card_name, "mdm9607-tomtom-i2s-snd-card",
-                  sizeof("mdm9607-tomtom-i2s-snd-card")))
+                  sizeof("mdm9607-tomtom-i2s-snd-card")) ||
+         !strncmp(snd_card_name, "msmfalcon-tashalite-snd-card",
+                  sizeof("msmfalcon-tashalite-snd-card")) ||
+         !strncmp(snd_card_name, "msmfalcon-tavil-snd-card",
+                  sizeof("msmfalcon-tavil-snd-card")))
      {
          ALOGI("%s: snd_card_name: %s",__func__,snd_card_name);
          is_external_codec = true;
@@ -1168,6 +1176,20 @@
         msm_device_to_be_id = msm_device_to_be_id_internal_codec;
         msm_be_id_array_len  =
             sizeof(msm_device_to_be_id_internal_codec) / sizeof(msm_device_to_be_id_internal_codec[0]);
+    } else if (!strncmp(snd_card_name, "msmfalcon-snd-card",
+                  sizeof("msmfalcon-snd-card"))) {
+        strlcpy(mixer_xml_path, MIXER_XML_PATH,
+               MAX_MIXER_XML_PATH);
+        msm_device_to_be_id = msm_device_to_be_id_internal_codec;
+        msm_be_id_array_len  =
+            sizeof(msm_device_to_be_id_internal_codec) / sizeof(msm_device_to_be_id_internal_codec[0]);
+    } else if (!strncmp(snd_card_name, "msmfalcon-snd-card-mtp",
+                  sizeof("msmfalcon-snd-card-mtp"))) {
+        strlcpy(mixer_xml_path, MIXER_XML_PATH_MTP,
+               MAX_MIXER_XML_PATH);
+        msm_device_to_be_id = msm_device_to_be_id_internal_codec;
+        msm_be_id_array_len  =
+            sizeof(msm_device_to_be_id_internal_codec) / sizeof(msm_device_to_be_id_internal_codec[0]);
     } else if (!strncmp(snd_card_name, "msmfalcon-tasha-snd-card",
                  sizeof("msmfalcon-tasha-snd-card"))) {
         strlcpy(mixer_xml_path, MIXER_XML_PATH_WCD9335,
@@ -1175,6 +1197,20 @@
         msm_device_to_be_id = msm_device_to_be_id_external_codec;
         msm_be_id_array_len  =
             sizeof(msm_device_to_be_id_external_codec) / sizeof(msm_device_to_be_id_external_codec[0]);
+    } else if (!strncmp(snd_card_name, "msmfalcon-tashalite-snd-card",
+                 sizeof("msmfalcon-tashalite-snd-card"))) {
+        strlcpy(mixer_xml_path, MIXER_XML_PATH_WCD9326,
+                sizeof(MIXER_XML_PATH_WCD9326));
+        msm_device_to_be_id = msm_device_to_be_id_external_codec;
+        msm_be_id_array_len  =
+            sizeof(msm_device_to_be_id_external_codec) / sizeof(msm_device_to_be_id_external_codec[0]);
+    } else if (!strncmp(snd_card_name, "msmfalcon-tavil-snd-card",
+                 sizeof("msmfalcon-tavil-snd-card"))) {
+        strlcpy(mixer_xml_path, MIXER_XML_PATH_WCD9340,
+                sizeof(MIXER_XML_PATH_WCD9340));
+        msm_device_to_be_id = msm_device_to_be_id_external_codec;
+        msm_be_id_array_len  =
+            sizeof(msm_device_to_be_id_external_codec) / sizeof(msm_device_to_be_id_external_codec[0]);
     } else if (!strncmp(snd_card_name, "msm8920-sku7-snd-card",
                   sizeof("msm8920-sku7-snd-card"))) {
         strlcpy(mixer_xml_path, MIXER_XML_PATH_SKU1,
@@ -1537,6 +1573,11 @@
         return "msm8953-tasha-snd-card";
     }
 
+    if(!strncmp(snd_card_name, "msmfalcon-tashalite-snd-card",
+             sizeof("msmfalcon-tashalite-snd-card"))) {
+        ALOGD("using tasha ACDB files for tasha-lite");
+        return "msmfalcon-tasha-snd-card";
+    }
    return snd_card_name;
 }
 
@@ -1601,6 +1642,12 @@
     bool found = false;
     int wsa_count = 0;
 
+    /* SL/SH hardware always has wsa by default, no need to add wsa */
+    if(!strncmp(snd_card_name, "msmfalcon", strlen("msmfalcon"))) {
+        ALOGD(" Ignore WSA extension for msm falcon varients");
+        return false;
+    }
+
     if (!getcwd(cwd, sizeof(cwd)))
         return false;
 
@@ -1973,6 +2020,8 @@
 
     my_data->edid_info = NULL;
 
+    default_rx_backend = strdup("SLIMBUS_0_RX");
+
     /* initialize backend config */
     for (idx = 0; idx < MAX_CODEC_BACKENDS; idx++) {
         my_data->current_backend_cfg[idx].sample_rate = CODEC_BACKEND_DEFAULT_SAMPLE_RATE;
@@ -1993,10 +2042,11 @@
         my_data->current_backend_cfg[DEFAULT_CODEC_BACKEND].samplerate_mixer_ctl =
             strdup("SLIM_0_RX SampleRate");
 
-    my_data->current_backend_cfg[DSD_NATIVE_BACKEND].bitwidth_mixer_ctl =
-        strdup("SLIM_2_RX Format");
-    my_data->current_backend_cfg[DSD_NATIVE_BACKEND].samplerate_mixer_ctl =
-        strdup("SLIM_2_RX SampleRate");
+        my_data->current_backend_cfg[DSD_NATIVE_BACKEND].bitwidth_mixer_ctl =
+            strdup("SLIM_2_RX Format");
+        my_data->current_backend_cfg[DSD_NATIVE_BACKEND].samplerate_mixer_ctl =
+            strdup("SLIM_2_RX SampleRate");
+
         my_data->current_backend_cfg[HEADPHONE_44_1_BACKEND].bitwidth_mixer_ctl =
             strdup("SLIM_5_RX Format");
         my_data->current_backend_cfg[HEADPHONE_44_1_BACKEND].samplerate_mixer_ctl =
@@ -2012,15 +2062,38 @@
         my_data->current_backend_cfg[SLIMBUS_0_TX].samplerate_mixer_ctl =
             strdup("SLIM_0_TX SampleRate");
     } else {
-        my_data->current_backend_cfg[DEFAULT_CODEC_BACKEND].bitwidth_mixer_ctl =
-            strdup("MI2S_RX Format");
-        my_data->current_backend_cfg[DEFAULT_CODEC_BACKEND].samplerate_mixer_ctl =
-            strdup("MI2S_RX SampleRate");
+        if (!strncmp(snd_card_name, "msmfalcon", strlen("msmfalcon"))) {
 
-        my_data->current_backend_cfg[DEFAULT_CODEC_TX_BACKEND].bitwidth_mixer_ctl =
-            strdup("MI2S_TX Format");
-        my_data->current_backend_cfg[DEFAULT_CODEC_TX_BACKEND].samplerate_mixer_ctl =
-            strdup("MI2S_TX SampleRate");
+            my_data->current_backend_cfg[DEFAULT_CODEC_BACKEND].bitwidth_mixer_ctl =
+                strdup("INT4_MI2S_RX Format");
+            my_data->current_backend_cfg[DEFAULT_CODEC_BACKEND].samplerate_mixer_ctl =
+                strdup("INT4_MI2S_RX SampleRate");
+
+            my_data->current_backend_cfg[DEFAULT_CODEC_TX_BACKEND].bitwidth_mixer_ctl =
+                strdup("INT3_MI2S_TX Format");
+            my_data->current_backend_cfg[DEFAULT_CODEC_TX_BACKEND].samplerate_mixer_ctl =
+                strdup("INT3_MI2S_TX SampleRate");
+
+            if (default_rx_backend)
+                free(default_rx_backend);
+            default_rx_backend = strdup("INT4_MI2S_RX");
+
+        } else {
+            my_data->current_backend_cfg[DEFAULT_CODEC_BACKEND].bitwidth_mixer_ctl =
+                strdup("MI2S_RX Format");
+            my_data->current_backend_cfg[DEFAULT_CODEC_BACKEND].samplerate_mixer_ctl =
+                strdup("MI2S_RX SampleRate");
+
+            my_data->current_backend_cfg[DEFAULT_CODEC_TX_BACKEND].bitwidth_mixer_ctl =
+                strdup("MI2S_TX Format");
+            my_data->current_backend_cfg[DEFAULT_CODEC_TX_BACKEND].samplerate_mixer_ctl =
+                strdup("MI2S_TX SampleRate");
+        }
+        my_data->current_backend_cfg[HEADPHONE_BACKEND].bitwidth_mixer_ctl =
+            strdup("INT0_MI2S_RX Format");
+        my_data->current_backend_cfg[HEADPHONE_BACKEND].samplerate_mixer_ctl =
+            strdup("INT0_MI2S_RX SampleRate");
+
     }
     my_data->current_backend_cfg[USB_AUDIO_TX_BACKEND].bitwidth_mixer_ctl =
         strdup("USB_AUDIO_TX Format");
@@ -2094,6 +2167,9 @@
         my_data->hw_dep_fd = -1;
     }
 
+    if (default_rx_backend)
+        free(default_rx_backend);
+
     hw_info_deinit(my_data->hw_info);
     close_csd_client(my_data->csd);
 
@@ -2211,9 +2287,9 @@
     if (NULL != be_itf1 && NULL != be_itf2) {
         if ((NULL == strstr(be_itf2, be_itf1)) && (NULL == strstr(be_itf1, be_itf2)))
             result = false;
-    } else if (NULL == be_itf1 && NULL != be_itf2 && (NULL == strstr(be_itf2, DEFAULT_RX_BACKEND))) {
+    } else if (NULL == be_itf1 && NULL != be_itf2 && (NULL == strstr(be_itf2, default_rx_backend))) {
             result = false;
-    } else if (NULL != be_itf1 && NULL == be_itf2 && (NULL == strstr(be_itf1, DEFAULT_RX_BACKEND))) {
+    } else if (NULL != be_itf1 && NULL == be_itf2 && (NULL == strstr(be_itf1, default_rx_backend))) {
             result = false;
     }