am 20d28cb2: (-s ours) Reconcile with jb-mr2-release - do not merge

* commit '20d28cb2dc069a17af843ce666420fc3702973e0':
diff --git a/hal/audio_hw.c b/hal/audio_hw.c
index c874aa8..9b3ec13 100644
--- a/hal/audio_hw.c
+++ b/hal/audio_hw.c
@@ -78,7 +78,11 @@
     [USECASE_AUDIO_PLAYBACK_MULTI_CH] = {1, 1},
     [USECASE_AUDIO_RECORD] = {0, 0},
     [USECASE_AUDIO_RECORD_LOW_LATENCY] = {14, 14},
+#ifdef MSM8974
+    [USECASE_VOICE_CALL] = {2, 2},
+#else
     [USECASE_VOICE_CALL] = {12, 12},
+#endif
 };
 
 /* Array to store sound devices */
@@ -89,6 +93,7 @@
     [SND_DEVICE_OUT_SPEAKER] = "speaker",
     [SND_DEVICE_OUT_HEADPHONES] = "headphones",
     [SND_DEVICE_OUT_SPEAKER_AND_HEADPHONES] = "speaker-and-headphones",
+    [SND_DEVICE_OUT_VOICE_HANDSET] = "voice-handset",
     [SND_DEVICE_OUT_VOICE_SPEAKER] = "voice-speaker",
     [SND_DEVICE_OUT_VOICE_HEADPHONES] = "voice-headphones",
     [SND_DEVICE_OUT_HDMI] = "hdmi",
@@ -130,13 +135,26 @@
 static const int acdb_device_table[SND_DEVICE_MAX] = {
     [SND_DEVICE_NONE] = -1,
     [SND_DEVICE_OUT_HANDSET] = 7,
+#ifdef MSM8974
+    [SND_DEVICE_OUT_SPEAKER] = 15,
+#else
     [SND_DEVICE_OUT_SPEAKER] = 14,
+#endif
     [SND_DEVICE_OUT_HEADPHONES] = 10,
     [SND_DEVICE_OUT_SPEAKER_AND_HEADPHONES] = 10,
+    [SND_DEVICE_OUT_VOICE_HANDSET] = 7,
+#ifdef MSM8974
+    [SND_DEVICE_OUT_VOICE_SPEAKER] = 15,
+#else
     [SND_DEVICE_OUT_VOICE_SPEAKER] = 14,
+#endif
     [SND_DEVICE_OUT_VOICE_HEADPHONES] = 10,
     [SND_DEVICE_OUT_HDMI] = 18,
+#ifdef MSM8974
+    [SND_DEVICE_OUT_SPEAKER_AND_HDMI] = 15,
+#else
     [SND_DEVICE_OUT_SPEAKER_AND_HDMI] = 14,
+#endif
     [SND_DEVICE_OUT_BT_SCO] = 22,
     [SND_DEVICE_OUT_VOICE_HANDSET_TMUS] = 81,
     [SND_DEVICE_OUT_VOICE_TTY_FULL_HEADPHONES] = 17,
@@ -144,7 +162,7 @@
     [SND_DEVICE_OUT_VOICE_TTY_HCO_HANDSET] = 37,
 
     [SND_DEVICE_IN_HANDSET_MIC] = 4,
-    [SND_DEVICE_IN_SPEAKER_MIC] = 4,
+    [SND_DEVICE_IN_SPEAKER_MIC] = 4, /* ToDo: Check if this needs to changed to 11 */
     [SND_DEVICE_IN_HEADSET_MIC] = 8,
     [SND_DEVICE_IN_HANDSET_MIC_AEC] = 40,
     [SND_DEVICE_IN_SPEAKER_MIC_AEC] = 42,
@@ -501,6 +519,38 @@
     return ret;
 }
 
+static int set_voice_volume(struct mixer *mixer,
+                             int volume)
+{
+    struct mixer_ctl *ctl;
+    const char *mixer_ctl_name = "Voice Rx Volume";
+    ctl = mixer_get_ctl_by_name(mixer, mixer_ctl_name);
+    if (!ctl) {
+        ALOGE("%s: Could not get ctl for mixer cmd - %s",
+              __func__, mixer_ctl_name);
+        return -EINVAL;
+    }
+    ALOGV("Setting voice volume: %d", volume);
+    mixer_ctl_set_value(ctl, 0, volume);
+    return 0;
+}
+
+static int set_mic_mute(struct mixer *mixer,
+                        int mute)
+{
+    struct mixer_ctl *ctl;
+    const char *mixer_ctl_name = "Voice Tx Mute";
+    ctl = mixer_get_ctl_by_name(mixer, mixer_ctl_name);
+    if (!ctl) {
+        ALOGE("%s: Could not get ctl for mixer cmd - %s",
+              __func__, mixer_ctl_name);
+        return -EINVAL;
+    }
+    ALOGV("Setting mic mute: %d", mute);
+    mixer_ctl_set_value(ctl, 0, mute);
+    return 0;
+}
+
 static snd_device_t get_output_snd_device(struct audio_device *adev,
                                           audio_devices_t devices)
 {
@@ -1924,7 +1974,9 @@
         // 0 -> 5, 20 -> 4, 40 ->3, 60 -> 2, 80 -> 1, 100 -> 0
         // So adjust the volume to get the correct volume index in driver
         vol = 100 - vol;
-
+#ifdef MSM8974
+        set_voice_volume(adev->mixer, vol);
+#else
         if (adev->csd_client) {
             if (adev->csd_volume == NULL) {
                 ALOGE("%s: dlsym error for csd_client_volume", __func__);
@@ -1937,6 +1989,7 @@
         } else {
             ALOGE("%s: No CSD Client present", __func__);
         }
+#endif
     }
     pthread_mutex_unlock(&adev->lock);
     return err;
@@ -1983,6 +2036,9 @@
     pthread_mutex_lock(&adev->lock);
     adev->mic_mute = state;
     if (adev->mode == AUDIO_MODE_IN_CALL) {
+#ifdef MSM8974
+        set_mic_mute(adev->mixer, state);
+#else
         if (adev->csd_client) {
             if (adev->csd_mic_mute == NULL) {
                 ALOGE("%s: dlsym error for csd_mic_mute", __func__);
@@ -1995,6 +2051,7 @@
         } else {
             ALOGE("%s: No CSD Client present", __func__);
         }
+#endif
     }
     pthread_mutex_unlock(&adev->lock);
     return err;
diff --git a/hal/audio_hw.h b/hal/audio_hw.h
index cb2f817..bb63d4f 100644
--- a/hal/audio_hw.h
+++ b/hal/audio_hw.h
@@ -53,6 +53,7 @@
     SND_DEVICE_OUT_SPEAKER,
     SND_DEVICE_OUT_HEADPHONES,
     SND_DEVICE_OUT_SPEAKER_AND_HEADPHONES,
+    SND_DEVICE_OUT_VOICE_HANDSET,
     SND_DEVICE_OUT_VOICE_SPEAKER,
     SND_DEVICE_OUT_VOICE_HEADPHONES,
     SND_DEVICE_OUT_HDMI,