am 3d746369: am c4ba743c: hal: Fix Hangout and Voice call concurrency issue
* commit '3d74636915254e13957a59fc307dbf8fc396e7e9':
hal: Fix Hangout and Voice call concurrency issue
diff --git a/hal/audio_hw.c b/hal/audio_hw.c
index 275272a..53d650a 100644
--- a/hal/audio_hw.c
+++ b/hal/audio_hw.c
@@ -33,8 +33,8 @@
#include "audio_hw.h"
-#define LIB_ACDB_LOADER "/system/lib/libacdbloader.so"
-#define LIB_CSD_CLIENT "/system/lib/libcsd-client.so"
+#define LIB_ACDB_LOADER "libacdbloader.so"
+#define LIB_CSD_CLIENT "libcsd-client.so"
#define MIXER_XML_PATH "/system/etc/mixer_paths.xml"
#define MIXER_CARD 0
@@ -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 */
@@ -90,6 +94,7 @@
[SND_DEVICE_OUT_SPEAKER_REVERSE] = "speaker-reverse",
[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",
@@ -131,14 +136,27 @@
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_SPEAKER_REVERSE] = 14,
[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,
@@ -146,7 +164,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,
@@ -569,6 +587,44 @@
return ret;
}
+static int set_voice_volume(struct mixer *mixer,
+ int volume)
+{
+ struct mixer_ctl *ctl;
+ const char *mixer_ctl_name = "Voice Rx Volume";
+
+ // Voice volume levels are mapped to adsp volume levels as follows.
+ // 100 -> 5, 80 -> 4, 60 -> 3, 40 -> 2, 20 -> 1 0 -> 0
+ // But this values don't changed in kernel. So, below change is need.
+ volume = volume / 20;
+
+ 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)
{
@@ -977,6 +1033,19 @@
acdb_rx_id, acdb_tx_id);
}
}
+ } else if (usecase->type == VOICE_CALL) {
+ if (adev->acdb_send_voice_cal == NULL) {
+ ALOGE("%s: dlsym error for acdb_send_voice_call", __func__);
+ } else {
+ acdb_rx_id = get_acdb_device_id(out_snd_device);
+ acdb_tx_id = get_acdb_device_id(in_snd_device);
+
+ if (acdb_rx_id > 0 && acdb_tx_id > 0)
+ adev->acdb_send_voice_cal(acdb_rx_id, acdb_tx_id);
+ else
+ ALOGE("%s: Incorrect ACDB IDs (rx: %d tx: %d)", __func__,
+ acdb_rx_id, acdb_tx_id);
+ }
}
return status;
@@ -2033,7 +2102,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__);
@@ -2046,6 +2117,7 @@
} else {
ALOGE("%s: No CSD Client present", __func__);
}
+#endif
}
pthread_mutex_unlock(&adev->lock);
return err;
@@ -2092,6 +2164,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__);
@@ -2104,6 +2179,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 08426de..5c326e9 100644
--- a/hal/audio_hw.h
+++ b/hal/audio_hw.h
@@ -54,6 +54,7 @@
SND_DEVICE_OUT_SPEAKER_REVERSE,
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,