Merge "hal: load CSD library by checking number of modems"
diff --git a/hal/Android.mk b/hal/Android.mk
index 1c3f946..32a9ee9 100644
--- a/hal/Android.mk
+++ b/hal/Android.mk
@@ -121,7 +121,8 @@
 	libtinycompress \
 	libaudioroute \
 	libdl \
-	libexpat
+	libexpat \
+        libmdmdetect
 
 LOCAL_C_INCLUDES += \
 	external/tinyalsa/include \
@@ -131,7 +132,8 @@
 	$(call include-path-for, audio-effects) \
 	$(LOCAL_PATH)/$(AUDIO_PLATFORM) \
 	$(LOCAL_PATH)/audio_extn \
-	$(LOCAL_PATH)/voice_extn
+	$(LOCAL_PATH)/voice_extn \
+        $(TARGET_OUT_HEADERS)/libmdmdetect/inc
 
 ifeq ($(strip $(AUDIO_FEATURE_ENABLED_LISTEN)),true)
     LOCAL_CFLAGS += -DAUDIO_LISTEN_ENABLED
diff --git a/hal/msm8974/platform.c b/hal/msm8974/platform.c
index 3f4de55..4161d87 100644
--- a/hal/msm8974/platform.c
+++ b/hal/msm8974/platform.c
@@ -32,6 +32,7 @@
 #include "audio_extn.h"
 #include "voice_extn.h"
 #include "sound/compress_params.h"
+#include "mdm_detect.h"
 
 #define MIXER_XML_PATH "/system/etc/mixer_paths.xml"
 #define MIXER_XML_PATH_AUXPCM "/system/etc/mixer_paths_auxpcm.xml"
@@ -539,10 +540,28 @@
     }
 }
 
+static void platform_csd_init(struct platform_data *plat_data)
+{
+    struct dev_info mdm_detect_info;
+    int ret = 0;
+
+    /* Call ESOC API to get the number of modems.
+     * If the number of modems is not zero, load CSD Client specific
+     * symbols. Voice call is handled by MDM and apps processor talks to
+     * MDM through CSD Client
+     */
+    ret = get_system_info(&mdm_detect_info);
+    if (ret > 0) {
+        ALOGE("%s: Failed to get system info, ret %d", __func__, ret);
+    }
+    ALOGD("%s: num_modems %d\n", __func__, mdm_detect_info.num_modems);
+
+    if (mdm_detect_info.num_modems > 0)
+        plat_data->csd = open_csd_client();
+}
+
 void *platform_init(struct audio_device *adev)
 {
-    char platform[PROPERTY_VALUE_MAX];
-    char baseband[PROPERTY_VALUE_MAX];
     char value[PROPERTY_VALUE_MAX];
     struct platform_data *my_data = NULL;
     int retry_num = 0, snd_card_num = 0;
@@ -678,16 +697,8 @@
     /* Initialize ACDB ID's */
     platform_info_init();
 
-    /* If platform is apq8084 and baseband is MDM, load CSD Client specific
-     * symbols. Voice call is handled by MDM and apps processor talks to
-     * MDM through CSD Client
-     */
-    property_get("ro.board.platform", platform, "");
-    property_get("ro.baseband", baseband, "");
-    if (!strncmp("apq8084", platform, sizeof("apq8084")) &&
-        !strncmp("mdm", baseband, sizeof("mdm"))) {
-         my_data->csd = open_csd_client();
-    }
+    /* load csd client */
+    platform_csd_init(my_data);
 
     /* init usb */
     audio_extn_usb_init(adev);