am 7c57a3a8: am 59d296d8: hal: select speaker mic for voice communication
* commit '7c57a3a8ab8d526c074bcc373e8cba2fa06b4f23':
hal: select speaker mic for voice communication
diff --git a/hal/audio_hw.c b/hal/audio_hw.c
index 44e7f0d..0f6974a 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",
@@ -127,13 +132,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,
@@ -141,7 +159,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_VOICE_SPEAKER_MIC] = 11,
[SND_DEVICE_IN_VOICE_HEADSET_MIC] = 8,
@@ -479,6 +497,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)
{
@@ -1855,7 +1905,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__);
@@ -1868,6 +1920,7 @@
} else {
ALOGE("%s: No CSD Client present", __func__);
}
+#endif
}
pthread_mutex_unlock(&adev->lock);
return err;
@@ -1914,6 +1967,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__);
@@ -1926,6 +1982,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 dec6ef2..1c34b91 100644
--- a/hal/audio_hw.h
+++ b/hal/audio_hw.h
@@ -50,6 +50,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,