Merge "hal: Clear VI feedback cal after VI capture path is started"
diff --git a/hal/audio_extn/audio_extn.h b/hal/audio_extn/audio_extn.h
index af0b285..96e8a5f 100644
--- a/hal/audio_extn/audio_extn.h
+++ b/hal/audio_extn/audio_extn.h
@@ -166,7 +166,7 @@
 #endif
 
 #ifndef DS1_DOLBY_DDP_ENABLED
-#define audio_extn_dolby_set_endpoint()                 (0)
+#define audio_extn_dolby_set_endpoint(adev)                 (0)
 #else
 void audio_extn_dolby_set_endpoint(struct audio_device *adev);
 #endif
@@ -174,7 +174,7 @@
 #ifndef DS1_DOLBY_DDP_ENABLED
 #define audio_extn_ddp_set_parameters(adev, parms)      (0)
 #define audio_extn_is_dolby_format(format)              (0)
-#define audio_extn_dolby_get_snd_codec_id(format)       (0)
+#define audio_extn_dolby_get_snd_codec_id(adev, out, format)       (0)
 #define audio_extn_dolby_send_ddp_endp_params(adev)     (0)
 #else
 bool audio_extn_is_dolby_format(audio_format_t format);
diff --git a/hal/msm8960/platform.c b/hal/msm8960/platform.c
index 298c60d..dacf68e 100644
--- a/hal/msm8960/platform.c
+++ b/hal/msm8960/platform.c
@@ -551,6 +551,12 @@
     return ret;
 }
 
+int platform_set_device_mute(void *platform, bool state, char *dir)
+{
+    LOGE("%s: Not implemented", __func__);
+    return -ENOSYS;
+}
+
 snd_device_t platform_get_output_snd_device(void *platform, audio_devices_t devices)
 {
     struct platform_data *my_data = (struct platform_data *)platform;
diff --git a/hal/msm8974/platform.c b/hal/msm8974/platform.c
index 1f4e3d5..1188c23 100644
--- a/hal/msm8974/platform.c
+++ b/hal/msm8974/platform.c
@@ -872,6 +872,44 @@
     return ret;
 }
 
+int platform_set_device_mute(void *platform, bool state, char *dir)
+{
+    struct platform_data *my_data = (struct platform_data *)platform;
+    struct audio_device *adev = my_data->adev;
+    struct mixer_ctl *ctl;
+    char *mixer_ctl_name = NULL;
+    int ret = 0;
+    uint32_t set_values[ ] = {0,
+                              ALL_SESSION_VSID,
+                              0};
+    if(dir == NULL) {
+        ALOGE("%s: Invalid direction:%s", __func__, dir);
+        return -EINVAL;
+    }
+
+    if (!strncmp("rx", dir, sizeof("rx"))) {
+        mixer_ctl_name = "Voice Rx Device Mute";
+    } else if (!strncmp("tx", dir, sizeof("tx"))) {
+        mixer_ctl_name = "Voice Tx Device Mute";
+    } else {
+        return -EINVAL;
+    }
+
+    set_values[0] = state;
+    ctl = mixer_get_ctl_by_name(adev->mixer, mixer_ctl_name);
+    if (!ctl) {
+        ALOGE("%s: Could not get ctl for mixer cmd - %s",
+              __func__, mixer_ctl_name);
+        return -EINVAL;
+    }
+
+    ALOGV("%s: Setting device mute state: %d, mixer ctrl:%s",
+          __func__,state, mixer_ctl_name);
+    mixer_ctl_set_array(ctl, set_values, ARRAY_SIZE(set_values));
+
+    return ret;
+}
+
 snd_device_t platform_get_output_snd_device(void *platform, audio_devices_t devices)
 {
     struct platform_data *my_data = (struct platform_data *)platform;
diff --git a/hal/msm8974/platform.h b/hal/msm8974/platform.h
index b71ae29..0ea57ae 100644
--- a/hal/msm8974/platform.h
+++ b/hal/msm8974/platform.h
@@ -170,6 +170,17 @@
 #define HFP_PCM_RX 5
 
 #define INCALL_MUSIC_UPLINK_PCM_DEVICE 1
+
+#ifdef PLATFORM_MSM8610
+#define INCALL_MUSIC_UPLINK2_PCM_DEVICE 15
+#elif PLATFORM_MSM8x26
+#define INCALL_MUSIC_UPLINK2_PCM_DEVICE 16
+#elif PLATFORM_MSM8974
+#define INCALL_MUSIC_UPLINK2_PCM_DEVICE 35
+#else
+#define INCALL_MUSIC_UPLINK2_PCM_DEVICE -1
+#endif
+
 #define SPKR_PROT_CALIB_RX_PCM_DEVICE 5
 #define SPKR_PROT_CALIB_TX_PCM_DEVICE 25
 #define PLAYBACK_OFFLOAD_DEVICE 9
@@ -222,12 +233,6 @@
 #define HFP_ASM_RX_TX 24
 #endif
 
-#ifdef PLATFORM_MSM8610
-#define INCALL_MUSIC_UPLINK2_PCM_DEVICE 15
-#else
-#define INCALL_MUSIC_UPLINK2_PCM_DEVICE 16
-#endif
-
 #define LIB_CSD_CLIENT "libcsd-client.so"
 /* CSD-CLIENT related functions */
 typedef int (*init_t)();
diff --git a/hal/platform_api.h b/hal/platform_api.h
index 306aaad..9e87275 100644
--- a/hal/platform_api.h
+++ b/hal/platform_api.h
@@ -39,6 +39,7 @@
 int platform_stop_voice_call(void *platform, uint32_t vsid);
 int platform_set_voice_volume(void *platform, int volume);
 int platform_set_mic_mute(void *platform, bool state);
+int platform_set_device_mute(void *platform, bool state, char *dir);
 snd_device_t platform_get_output_snd_device(void *platform, audio_devices_t devices);
 snd_device_t platform_get_input_snd_device(void *platform, audio_devices_t out_device);
 int platform_set_hdmi_channels(void *platform, int channel_count);
diff --git a/hal/voice_extn/voice_extn.c b/hal/voice_extn/voice_extn.c
index f2dc6bc..f6083f3 100644
--- a/hal/voice_extn/voice_extn.c
+++ b/hal/voice_extn/voice_extn.c
@@ -38,6 +38,8 @@
 #define AUDIO_PARAMETER_KEY_CALL_STATE          "call_state"
 #define AUDIO_PARAMETER_KEY_AUDIO_MODE          "audio_mode"
 #define AUDIO_PARAMETER_KEY_ALL_CALL_STATES     "all_call_states"
+#define AUDIO_PARAMETER_KEY_DEVICE_MUTE         "device_mute"
+#define AUDIO_PARAMETER_KEY_DIRECTION           "direction"
 
 #define VOICE_EXTN_PARAMETER_VALUE_MAX_LEN 256
 
@@ -440,6 +442,7 @@
     int value;
     int ret = 0, err;
     char *kv_pairs = str_parms_to_str(parms);
+    char str_value[256] = {0};
 
     ALOGV_IF(kv_pairs != NULL, "%s: enter: %s", __func__, kv_pairs);
 
@@ -465,8 +468,34 @@
             ret = -EINVAL;
             goto done;
         }
-    } else {
-        ALOGV("%s: Not handled here", __func__);
+    }
+
+    err = str_parms_get_str(parms, AUDIO_PARAMETER_KEY_DEVICE_MUTE, str_value,
+                            sizeof(str_value));
+    if (err >= 0) {
+        str_parms_del(parms, AUDIO_PARAMETER_KEY_DEVICE_MUTE);
+        bool mute = false;
+
+        if (!strncmp("true", str_value, sizeof("true"))) {
+            mute = true;
+        }
+
+        err = str_parms_get_str(parms, AUDIO_PARAMETER_KEY_DIRECTION, str_value,
+                                sizeof(str_value));
+        if (err >= 0) {
+            str_parms_del(parms, AUDIO_PARAMETER_KEY_DIRECTION);
+        } else {
+            ALOGE("%s: direction key not found", __func__);
+            ret = -EINVAL;
+            goto done;
+        }
+
+        ret = platform_set_device_mute(adev->platform, mute, str_value);
+        if (ret != 0) {
+            ALOGE("%s: Failed to set mute err:%d", __func__, ret);
+            ret = -EINVAL;
+            goto done;
+        }
     }
 
 done:
diff --git a/post_proc/bass_boost.c b/post_proc/bass_boost.c
index 53ec77f..221bbc4 100644
--- a/post_proc/bass_boost.c
+++ b/post_proc/bass_boost.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013, The Linux Foundation. All rights reserved.
+ * Copyright (c) 2013-2014, The Linux Foundation. All rights reserved.
  * Not a Contribution.
  *
  * Copyright (C) 2013 The Android Open Source Project
@@ -153,7 +153,10 @@
     bass_ctxt->device = device;
     if((device == AUDIO_DEVICE_OUT_SPEAKER) ||
        (device == AUDIO_DEVICE_OUT_BLUETOOTH_SCO_CARKIT) ||
-       (device == AUDIO_DEVICE_OUT_BLUETOOTH_A2DP_SPEAKER)) {
+       (device == AUDIO_DEVICE_OUT_BLUETOOTH_A2DP_SPEAKER) ||
+       (device == AUDIO_DEVICE_OUT_PROXY) ||
+       (device == AUDIO_DEVICE_OUT_AUX_DIGITAL) ||
+       (device == AUDIO_DEVICE_OUT_ANLG_DOCK_HEADSET)) {
         if (offload_bassboost_get_enable_flag(&(bass_ctxt->offload_bass))) {
             offload_bassboost_set_enable_flag(&(bass_ctxt->offload_bass), false);
             bass_ctxt->temp_disabled = true;
diff --git a/post_proc/effect_api.c b/post_proc/effect_api.c
index a2e4f45..570ca8b 100644
--- a/post_proc/effect_api.c
+++ b/post_proc/effect_api.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013, The Linux Foundation. All rights reserved.
+ * Copyright (c) 2013-2014, 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
@@ -391,7 +391,7 @@
 {
     ALOGV("%s", __func__);
     if (preset && (preset <= NUM_OSL_REVERB_PRESETS_SUPPORTED))
-        reverb->preset = map_reverb_opensl_preset_2_offload_preset[preset][1];
+        reverb->preset = map_reverb_opensl_preset_2_offload_preset[preset-1][1];
 }
 
 void offload_reverb_set_wet_mix(struct reverb_params *reverb, int wet_mix)
diff --git a/post_proc/virtualizer.c b/post_proc/virtualizer.c
index 3f65f00..3d6f908 100644
--- a/post_proc/virtualizer.c
+++ b/post_proc/virtualizer.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013, The Linux Foundation. All rights reserved.
+ * Copyright (c) 2013-2014, The Linux Foundation. All rights reserved.
  * Not a Contribution.
  *
  * Copyright (C) 2013 The Android Open Source Project
@@ -153,7 +153,10 @@
     virt_ctxt->device = device;
     if((device == AUDIO_DEVICE_OUT_SPEAKER) ||
        (device == AUDIO_DEVICE_OUT_BLUETOOTH_SCO_CARKIT) ||
-       (device == AUDIO_DEVICE_OUT_BLUETOOTH_A2DP_SPEAKER)) {
+       (device == AUDIO_DEVICE_OUT_BLUETOOTH_A2DP_SPEAKER) ||
+       (device == AUDIO_DEVICE_OUT_PROXY) ||
+       (device == AUDIO_DEVICE_OUT_AUX_DIGITAL) ||
+       (device == AUDIO_DEVICE_OUT_ANLG_DOCK_HEADSET)) {
         if (offload_virtualizer_get_enable_flag(&(virt_ctxt->offload_virt))) {
             offload_virtualizer_set_enable_flag(&(virt_ctxt->offload_virt), false);
             virt_ctxt->temp_disabled = true;