From d71b94b59e8b0c5bfeed8d1be8c1d5b6f3d6428c Mon Sep 17 00:00:00 2001 From: Karthik Reddy Katta Date: Mon, 19 Jan 2015 14:06:53 +0530 Subject: [PATCH] hal: add quad mic support for audio recording and VoIP calls Add quad mic recording support for standalone audio recording and for VoIP calls using audio path. Change-Id: I10724b6350b9940b93971ac720747dee1a9936cb --- hal/msm8916/platform.c | 69 +++++++++++++++++++++++++++++------------- hal/msm8916/platform.h | 4 +++ 2 files changed, 52 insertions(+), 21 deletions(-) diff --git a/hal/msm8916/platform.c b/hal/msm8916/platform.c index 968ae395..be8735ed 100755 --- a/hal/msm8916/platform.c +++ b/hal/msm8916/platform.c @@ -291,6 +291,10 @@ static const char * const device_table[SND_DEVICE_MAX] = { [SND_DEVICE_IN_SPEAKER_DMIC_NS_BROADSIDE] = "speaker-dmic-broadside", [SND_DEVICE_IN_SPEAKER_DMIC_AEC_NS_BROADSIDE] = "speaker-dmic-broadside", [SND_DEVICE_IN_VOICE_FLUENCE_DMIC_AANC] = "aanc-fluence-dmic-handset", + [SND_DEVICE_IN_HANDSET_QMIC] = "quad-mic", + [SND_DEVICE_IN_SPEAKER_QMIC_AEC] = "quad-mic", + [SND_DEVICE_IN_SPEAKER_QMIC_NS] = "quad-mic", + [SND_DEVICE_IN_SPEAKER_QMIC_AEC_NS] = "quad-mic", }; /* ACDB IDs (audio DSP path configuration IDs) for each sound device */ @@ -377,6 +381,10 @@ static int acdb_device_table[SND_DEVICE_MAX] = { [SND_DEVICE_IN_SPEAKER_DMIC_NS_BROADSIDE] = 121, [SND_DEVICE_IN_SPEAKER_DMIC_AEC_NS_BROADSIDE] = 120, [SND_DEVICE_IN_VOICE_FLUENCE_DMIC_AANC] = 135, + [SND_DEVICE_IN_HANDSET_QMIC] = 125, + [SND_DEVICE_IN_SPEAKER_QMIC_AEC] = 126, + [SND_DEVICE_IN_SPEAKER_QMIC_NS] = 127, + [SND_DEVICE_IN_SPEAKER_QMIC_AEC_NS] = 129, }; struct snd_device_index { @@ -463,6 +471,10 @@ struct snd_device_index snd_device_name_index[SND_DEVICE_MAX] = { {TO_NAME_INDEX(SND_DEVICE_IN_SPEAKER_STEREO_DMIC)}, {TO_NAME_INDEX(SND_DEVICE_IN_CAPTURE_VI_FEEDBACK)}, {TO_NAME_INDEX(SND_DEVICE_IN_VOICE_FLUENCE_DMIC_AANC)}, + {TO_NAME_INDEX(SND_DEVICE_IN_HANDSET_QMIC)}, + {TO_NAME_INDEX(SND_DEVICE_IN_SPEAKER_QMIC_AEC)}, + {TO_NAME_INDEX(SND_DEVICE_IN_SPEAKER_QMIC_NS)}, + {TO_NAME_INDEX(SND_DEVICE_IN_SPEAKER_QMIC_AEC_NS)}, }; #define NO_COLS 2 @@ -1909,12 +1921,15 @@ snd_device_t platform_get_input_snd_device(void *platform, audio_devices_t out_d if (adev->active_input->enable_aec && adev->active_input->enable_ns) { if (in_device & AUDIO_DEVICE_IN_BACK_MIC) { - if (my_data->fluence_type & FLUENCE_DUAL_MIC && - my_data->fluence_in_spkr_mode) { - if (my_data->fluence_mode == FLUENCE_BROADSIDE) - snd_device = SND_DEVICE_IN_SPEAKER_DMIC_AEC_NS_BROADSIDE; - else - snd_device = SND_DEVICE_IN_SPEAKER_DMIC_AEC_NS; + if (my_data->fluence_in_spkr_mode) { + if (my_data->fluence_type & FLUENCE_QUAD_MIC) { + snd_device = SND_DEVICE_IN_SPEAKER_QMIC_AEC_NS; + } else if (my_data->fluence_type & FLUENCE_DUAL_MIC) { + if (my_data->fluence_mode == FLUENCE_BROADSIDE) + snd_device = SND_DEVICE_IN_SPEAKER_DMIC_AEC_NS_BROADSIDE; + else + snd_device = SND_DEVICE_IN_SPEAKER_DMIC_AEC_NS; + } adev->acdb_settings |= DMIC_FLAG; } else snd_device = SND_DEVICE_IN_SPEAKER_MIC_AEC_NS; @@ -1930,12 +1945,15 @@ snd_device_t platform_get_input_snd_device(void *platform, audio_devices_t out_d platform_set_echo_reference(adev->platform, true); } else if (adev->active_input->enable_aec) { if (in_device & AUDIO_DEVICE_IN_BACK_MIC) { - if (my_data->fluence_type & FLUENCE_DUAL_MIC && - my_data->fluence_in_spkr_mode) { - if (my_data->fluence_mode == FLUENCE_BROADSIDE) - snd_device = SND_DEVICE_IN_SPEAKER_DMIC_AEC_BROADSIDE; - else - snd_device = SND_DEVICE_IN_SPEAKER_DMIC_AEC; + if (my_data->fluence_in_spkr_mode) { + if (my_data->fluence_type & FLUENCE_QUAD_MIC) { + snd_device = SND_DEVICE_IN_SPEAKER_QMIC_AEC; + } else if (my_data->fluence_type & FLUENCE_DUAL_MIC) { + if (my_data->fluence_mode == FLUENCE_BROADSIDE) + snd_device = SND_DEVICE_IN_SPEAKER_DMIC_AEC_BROADSIDE; + else + snd_device = SND_DEVICE_IN_SPEAKER_DMIC_AEC; + } adev->acdb_settings |= DMIC_FLAG; } else snd_device = SND_DEVICE_IN_SPEAKER_MIC_AEC; @@ -1951,12 +1969,15 @@ snd_device_t platform_get_input_snd_device(void *platform, audio_devices_t out_d platform_set_echo_reference(adev->platform, true); } else if (adev->active_input->enable_ns) { if (in_device & AUDIO_DEVICE_IN_BACK_MIC) { - if (my_data->fluence_type & FLUENCE_DUAL_MIC && - my_data->fluence_in_spkr_mode) { - if (my_data->fluence_mode == FLUENCE_BROADSIDE) - snd_device = SND_DEVICE_IN_SPEAKER_DMIC_NS_BROADSIDE; - else - snd_device = SND_DEVICE_IN_SPEAKER_DMIC_NS; + if (my_data->fluence_in_spkr_mode) { + if (my_data->fluence_type & FLUENCE_QUAD_MIC) { + snd_device = SND_DEVICE_IN_SPEAKER_QMIC_NS; + } else if (my_data->fluence_type & FLUENCE_DUAL_MIC) { + if (my_data->fluence_mode == FLUENCE_BROADSIDE) + snd_device = SND_DEVICE_IN_SPEAKER_DMIC_NS_BROADSIDE; + else + snd_device = SND_DEVICE_IN_SPEAKER_DMIC_NS; + } adev->acdb_settings |= DMIC_FLAG; } else snd_device = SND_DEVICE_IN_SPEAKER_MIC_NS; @@ -1976,9 +1997,15 @@ snd_device_t platform_get_input_snd_device(void *platform, audio_devices_t out_d } else if (source == AUDIO_SOURCE_MIC) { if (in_device & AUDIO_DEVICE_IN_BUILTIN_MIC && channel_count == 1 ) { - if(my_data->fluence_type & FLUENCE_DUAL_MIC && - my_data->fluence_in_audio_rec) - snd_device = SND_DEVICE_IN_HANDSET_DMIC; + if(my_data->fluence_in_audio_rec) { + if(my_data->fluence_type & FLUENCE_QUAD_MIC) { + snd_device = SND_DEVICE_IN_HANDSET_QMIC; + platform_set_echo_reference(adev->platform, true); + } else if (my_data->fluence_type & FLUENCE_DUAL_MIC) { + snd_device = SND_DEVICE_IN_HANDSET_DMIC; + platform_set_echo_reference(adev->platform, true); + } + } } } else if (source == AUDIO_SOURCE_FM_RX || source == AUDIO_SOURCE_FM_RX_A2DP) { diff --git a/hal/msm8916/platform.h b/hal/msm8916/platform.h index 35b577ea..6c81b95c 100644 --- a/hal/msm8916/platform.h +++ b/hal/msm8916/platform.h @@ -141,6 +141,10 @@ enum { SND_DEVICE_IN_SPEAKER_DMIC_NS_BROADSIDE, SND_DEVICE_IN_SPEAKER_DMIC_AEC_NS_BROADSIDE, SND_DEVICE_IN_VOICE_FLUENCE_DMIC_AANC, + SND_DEVICE_IN_HANDSET_QMIC, + SND_DEVICE_IN_SPEAKER_QMIC_AEC, + SND_DEVICE_IN_SPEAKER_QMIC_NS, + SND_DEVICE_IN_SPEAKER_QMIC_AEC_NS, SND_DEVICE_IN_END, SND_DEVICE_MAX = SND_DEVICE_IN_END,