Merge "hal: add get_parameter support slowtalk"
diff --git a/hal/audio_hw.c b/hal/audio_hw.c
index 873e5e2..5537115 100644
--- a/hal/audio_hw.c
+++ b/hal/audio_hw.c
@@ -657,8 +657,8 @@
      * device.
      */
     if (usecase->type == VOICE_CALL || usecase->type == VOIP_CALL) {
-        disable_all_usecases_of_type(adev, usecase->type, true);
         status = platform_switch_voice_call_device_pre(adev->platform);
+        disable_all_usecases_of_type(adev, VOICE_CALL, true);
     }
 
     /* Disable current sound devices */
@@ -699,6 +699,15 @@
     else
         enable_audio_route(adev, usecase, true);
 
+    /* Applicable only on the targets that has external modem.
+     * Enable device command should be sent to modem only after
+     * enabling voice call mixer controls
+     */
+    if (usecase->type == VOICE_CALL)
+        status = platform_switch_voice_call_usecase_route_post(adev->platform,
+                                                               out_snd_device,
+                                                               in_snd_device);
+
     return status;
 }
 
@@ -1975,7 +1984,7 @@
     out->handle = handle;
 
     /* Init use case and pcm_config */
-    if (out->flags & AUDIO_OUTPUT_FLAG_DIRECT &&
+    if (out->flags == AUDIO_OUTPUT_FLAG_DIRECT &&
         out->devices & AUDIO_DEVICE_OUT_AUX_DIGITAL) {
         pthread_mutex_lock(&adev->lock);
         ret = read_hdmi_channel_masks(out);
diff --git a/hal/msm8974/platform.c b/hal/msm8974/platform.c
index 486943c..5578653 100644
--- a/hal/msm8974/platform.c
+++ b/hal/msm8974/platform.c
@@ -640,7 +640,8 @@
     struct platform_data *my_data = (struct platform_data *)platform;
     int ret = 0;
 
-    if (my_data->csd != NULL) {
+    if (my_data->csd != NULL &&
+        my_data->adev->mode == AUDIO_MODE_IN_CALL) {
         /* This must be called before disabling mixer controls on APQ side */
         ret = my_data->csd->disable_device();
         if (ret < 0) {
@@ -657,14 +658,13 @@
 {
     struct platform_data *my_data = (struct platform_data *)platform;
     int acdb_rx_id, acdb_tx_id;
-    int ret = 0;
-
-    acdb_rx_id = acdb_device_table[out_snd_device];
-    acdb_tx_id = acdb_device_table[in_snd_device];
 
     if (my_data->acdb_send_voice_cal == NULL) {
         ALOGE("%s: dlsym error for acdb_send_voice_call", __func__);
     } else {
+        acdb_rx_id = acdb_device_table[out_snd_device];
+        acdb_tx_id = acdb_device_table[in_snd_device];
+
         if (acdb_rx_id > 0 && acdb_tx_id > 0)
             my_data->acdb_send_voice_cal(acdb_rx_id, acdb_tx_id);
         else
@@ -672,8 +672,22 @@
                   acdb_rx_id, acdb_tx_id);
     }
 
+    return 0;
+}
+
+int platform_switch_voice_call_usecase_route_post(void *platform,
+                                                  snd_device_t out_snd_device,
+                                                  snd_device_t in_snd_device)
+{
+    struct platform_data *my_data = (struct platform_data *)platform;
+    int acdb_rx_id, acdb_tx_id;
+    int ret = 0;
+
+    acdb_rx_id = acdb_device_table[out_snd_device];
+    acdb_tx_id = acdb_device_table[in_snd_device];
+
     if (my_data->csd != NULL) {
-        if (acdb_rx_id > 0 || acdb_tx_id > 0) {
+        if (acdb_rx_id > 0 && acdb_tx_id > 0) {
             ret = my_data->csd->enable_device(acdb_rx_id, acdb_tx_id,
                                               my_data->adev->acdb_settings);
             if (ret < 0) {
diff --git a/hal/platform_api.h b/hal/platform_api.h
index dac3fd9..44ad790 100644
--- a/hal/platform_api.h
+++ b/hal/platform_api.h
@@ -32,6 +32,9 @@
 int platform_switch_voice_call_device_post(void *platform,
                                            snd_device_t out_snd_device,
                                            snd_device_t in_snd_device);
+int platform_switch_voice_call_usecase_route_post(void *platform,
+                                                  snd_device_t out_snd_device,
+                                                  snd_device_t in_snd_device);
 int platform_start_voice_call(void *platform, uint32_t vsid);
 int platform_stop_voice_call(void *platform, uint32_t vsid);
 int platform_set_voice_volume(void *platform, int volume);
diff --git a/hal/voice.c b/hal/voice.c
index 62449d2..dc5c417 100644
--- a/hal/voice.c
+++ b/hal/voice.c
@@ -231,7 +231,6 @@
             return ret;
         }
 
-        in->config = pcm_config_voice_call;
         session_id = voice_get_active_session_id(adev);
         ret = platform_set_incall_recoding_session_id(adev->platform,
                                                       session_id);