hal: Add support for FBSP in WSA analog mode

Feedback speaker protection(FBSP) is supported in WSA
analog mode. Add the required changes to support this
feature on 8937/8953 internal codec platforms.

CRs-Fixed: 970156
Change-Id: I1e5f6c1408ba6eb1c216cf8b254ac29551837dbb
diff --git a/hal/audio_extn/spkr_protection.c b/hal/audio_extn/spkr_protection.c
index 5d35969..fdfbfad 100644
--- a/hal/audio_extn/spkr_protection.c
+++ b/hal/audio_extn/spkr_protection.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013 - 2015, The Linux Foundation. All rights reserved.
+ * Copyright (c) 2013 - 2016, The Linux Foundation. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions are
@@ -95,6 +95,9 @@
 #define SPKR_PROCESSING_IN_PROGRESS 1
 #define SPKR_PROCESSING_IN_IDLE 0
 
+/* In wsa analog mode vi feedback DAI supports at max 2 channels*/
+#define WSA_ANALOG_MODE_CHANNELS 2
+
 #define MAX_PATH             (256)
 #define THERMAL_SYSFS "/sys/class/thermal"
 #define TZ_TYPE "/sys/class/thermal/thermal_zone%d/type"
@@ -993,6 +996,10 @@
     handle.spkr_prot_t0 = -1;
 
     if (is_wsa_present()) {
+        if (platform_spkr_prot_is_wsa_analog_mode(adev) == 1) {
+            ALOGD("%s: WSA analog mode", __func__);
+            pcm_config_skr_prot.channels = WSA_ANALOG_MODE_CHANNELS;
+        }
         pthread_cond_init(&handle.spkr_calib_cancel, NULL);
         pthread_cond_init(&handle.spkr_calibcancel_ack, NULL);
         pthread_mutex_init(&handle.mutex_spkr_prot, NULL);
diff --git a/hal/msm8916/platform.c b/hal/msm8916/platform.c
index 7cdfc62..14d48a7 100644
--- a/hal/msm8916/platform.c
+++ b/hal/msm8916/platform.c
@@ -5094,16 +5094,20 @@
     return ret;
 }
 
-int platform_get_wsa_mode(void *adev)
+int platform_spkr_prot_is_wsa_analog_mode(void *adev)
 {
     struct audio_device *adev_h = adev;
     char *snd_card_name;
 
+    /*
+     * wsa analog mode is decided based on the sound card name
+     */
     snd_card_name = mixer_get_name(adev_h->mixer);
     if ((!strcmp(snd_card_name, "msm8952-skum-snd-card")) ||
         (!strcmp(snd_card_name, "msm8952-snd-card")) ||
         (!strcmp(snd_card_name, "msm8952-snd-card-mtp")) ||
-        (!strcmp(snd_card_name, "msm8976-skun-snd-card")))
+        (!strcmp(snd_card_name, "msm8976-skun-snd-card")) ||
+        (!strcmp(snd_card_name, "msm8953-snd-card-mtp")))
         return 1;
     else
         return 0;
diff --git a/hal/msm8960/platform.c b/hal/msm8960/platform.c
index be50289..e32a73d 100644
--- a/hal/msm8960/platform.c
+++ b/hal/msm8960/platform.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013-2015, The Linux Foundation. All rights reserved.
+ * Copyright (c) 2013-2016, The Linux Foundation. All rights reserved.
  * Not a contribution.
  *
  * Copyright (C) 2013 The Android Open Source Project
@@ -1206,3 +1206,8 @@
 {
     return -ENOSYS;
 }
+
+int platform_spkr_prot_is_wsa_analog_mode(void *adev __unused)
+{
+    return 0;
+}
diff --git a/hal/msm8974/platform.c b/hal/msm8974/platform.c
index 65ef702..a796e26 100644
--- a/hal/msm8974/platform.c
+++ b/hal/msm8974/platform.c
@@ -4571,6 +4571,11 @@
     }
 }
 
+int platform_spkr_prot_is_wsa_analog_mode(void *adev __unused)
+{
+    return 0;
+}
+
 /*
  * This is a lookup table to map android audio input device to audio h/w interface (backend).
  * The table can be extended for other input devices by adding appropriate entries.
diff --git a/hal/platform_api.h b/hal/platform_api.h
index 44f7d14..fb72e40 100644
--- a/hal/platform_api.h
+++ b/hal/platform_api.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013-2015, The Linux Foundation. All rights reserved.
+ * Copyright (c) 2013-2016, The Linux Foundation. All rights reserved.
  * Not a contribution.
  *
  * Copyright (C) 2013 The Android Open Source Project
@@ -137,4 +137,5 @@
 bool platform_can_enable_spkr_prot_on_device(snd_device_t snd_device);
 int platform_get_spkr_prot_acdb_id(snd_device_t snd_device);
 int platform_get_spkr_prot_snd_device(snd_device_t snd_device);
+int platform_spkr_prot_is_wsa_analog_mode(void *adev);
 #endif // AUDIO_PLATFORM_API_H