From 82f3248400efb474e61831902f46700f3ed0eb66 Mon Sep 17 00:00:00 2001 From: Andreas Schneider Date: Mon, 6 Feb 2017 09:00:48 +0100 Subject: [PATCH] audio: Add support for two mic control Change-Id: I0176b41b071577e9e55f5177ec1219d4e9aa91a2 --- audio/audio_hw.c | 21 ++++++++++++++------- audio/audio_hw.h | 2 ++ audio/voice.c | 9 +++++++++ audio/voice.h | 2 ++ 4 files changed, 27 insertions(+), 7 deletions(-) diff --git a/audio/audio_hw.c b/audio/audio_hw.c index d43fecb..abec559 100644 --- a/audio/audio_hw.c +++ b/audio/audio_hw.c @@ -323,6 +323,8 @@ static const char * const device_table[SND_DEVICE_MAX] = { [SND_DEVICE_IN_EARPIECE_MIC_AEC] = "earpiece-mic", [SND_DEVICE_IN_SPEAKER_MIC_AEC] = "voice-speaker-mic", [SND_DEVICE_IN_HEADSET_MIC_AEC] = "headset-mic", + [SND_DEVICE_IN_VOICE_MIC] = "voice-mic", + [SND_DEVICE_IN_VOICE_EARPIECE_MIC] = "voice-earpiece-mic", [SND_DEVICE_IN_VOICE_SPEAKER_MIC] = "voice-speaker-mic", [SND_DEVICE_IN_VOICE_HEADSET_MIC] = "voice-headset-mic", [SND_DEVICE_IN_HDMI_MIC] = "hdmi-mic", @@ -609,15 +611,20 @@ static snd_device_t get_input_snd_device(struct audio_device *adev, audio_device goto exit; } - if (out_device & AUDIO_DEVICE_OUT_EARPIECE || - out_device & AUDIO_DEVICE_OUT_WIRED_HEADPHONE) { - snd_device = SND_DEVICE_IN_EARPIECE_MIC; - } else if (out_device & AUDIO_DEVICE_OUT_WIRED_HEADSET) { + snd_device = SND_DEVICE_IN_VOICE_MIC; + if (out_device & AUDIO_DEVICE_OUT_WIRED_HEADSET) { snd_device = SND_DEVICE_IN_VOICE_HEADSET_MIC; } else if (out_device & AUDIO_DEVICE_OUT_ALL_SCO) { - snd_device = SND_DEVICE_IN_BT_SCO_MIC ; - } else if (out_device & AUDIO_DEVICE_OUT_SPEAKER) { - snd_device = SND_DEVICE_IN_VOICE_SPEAKER_MIC; + snd_device = SND_DEVICE_IN_BT_SCO_MIC; + } + + if (voice_session_uses_twomic(adev->voice.session)) { + if (out_device & AUDIO_DEVICE_OUT_EARPIECE || + out_device & AUDIO_DEVICE_OUT_WIRED_HEADPHONE) { + snd_device = SND_DEVICE_IN_VOICE_EARPIECE_MIC; + } else if (out_device & AUDIO_DEVICE_OUT_SPEAKER) { + snd_device = SND_DEVICE_IN_VOICE_SPEAKER_MIC; + } } } else if (source == AUDIO_SOURCE_CAMCORDER) { if (in_device & AUDIO_DEVICE_IN_BUILTIN_MIC || diff --git a/audio/audio_hw.h b/audio/audio_hw.h index 8a507ed..74be201 100644 --- a/audio/audio_hw.h +++ b/audio/audio_hw.h @@ -87,6 +87,8 @@ enum { SND_DEVICE_IN_EARPIECE_MIC_AEC, SND_DEVICE_IN_SPEAKER_MIC_AEC, SND_DEVICE_IN_HEADSET_MIC_AEC, + SND_DEVICE_IN_VOICE_MIC, + SND_DEVICE_IN_VOICE_EARPIECE_MIC, SND_DEVICE_IN_VOICE_SPEAKER_MIC, SND_DEVICE_IN_VOICE_HEADSET_MIC, SND_DEVICE_IN_HDMI_MIC, diff --git a/audio/voice.c b/audio/voice.c index f10d8ed..e59565a 100644 --- a/audio/voice.c +++ b/audio/voice.c @@ -244,6 +244,15 @@ void set_voice_session_volume(struct voice_session *session, float volume) ril_set_call_volume(&session->ril, sound_type, volume); } +bool voice_session_uses_twomic(struct voice_session *session) +{ + if (session->two_mic_disabled) { + return false; + } + + return session->two_mic_control; +} + static void voice_session_wb_amr_callback(void *data, int enable) { struct audio_device *adev = (struct audio_device *)data; diff --git a/audio/voice.h b/audio/voice.h index 0e32f0a..c63cd26 100644 --- a/audio/voice.h +++ b/audio/voice.h @@ -40,6 +40,8 @@ void stop_voice_session(struct voice_session *session); void set_voice_session_volume(struct voice_session *session, float volume); void set_voice_session_audio_path(struct voice_session *session); +bool voice_session_uses_twomic(struct voice_session *session); + struct voice_session *voice_session_init(struct audio_device *adev); void voice_session_deinit(struct voice_session *s); -- 2.20.1