summaryrefslogtreecommitdiffstats
path: root/audio/audio_hw.c
diff options
context:
space:
mode:
authorDheeraj CVR <cvr.dheeraj@gmail.com>2015-05-19 00:56:45 +0400
committertilaksidduram <tilaksidduram@gmail.com>2015-06-22 10:33:54 +0530
commit572e512bbedc361d211dc48a4fb2b74301368f6f (patch)
tree1407d373ac734c70dc742b740c14cbdf490bc162 /audio/audio_hw.c
parentfe82fa6be7b74762da37a069fdde15a55e616c42 (diff)
downloaddevice_samsung_n7100-572e512bbedc361d211dc48a4fb2b74301368f6f.zip
device_samsung_n7100-572e512bbedc361d211dc48a4fb2b74301368f6f.tar.gz
device_samsung_n7100-572e512bbedc361d211dc48a4fb2b74301368f6f.tar.bz2
audio: enable noise suppression by default
Framework was responsible for enabling or disabling the noise suppression using audio parameters. However, this is currently broken in lollipop and most of the newer devices have noise suppression enabled by default. Use noise suppression when using the default input device (main microphone). Change-Id: Ie8bdfe1d9860fdad996640d1664e8111df7d3cec
Diffstat (limited to 'audio/audio_hw.c')
-rw-r--r--audio/audio_hw.c34
1 files changed, 19 insertions, 15 deletions
diff --git a/audio/audio_hw.c b/audio/audio_hw.c
index d53cd94..f266c35 100644
--- a/audio/audio_hw.c
+++ b/audio/audio_hw.c
@@ -200,6 +200,7 @@ struct m0_dev_cfg {
static void select_output_device(struct m0_audio_device *adev);
static void select_input_device(struct m0_audio_device *adev);
+static void set_noise_supression(struct m0_audio_device *adev, int enable);
static int adev_set_voice_volume(struct audio_hw_device *dev, float volume);
static int do_input_standby(struct m0_stream_in *in);
static int do_output_standby(struct m0_stream_out *out);
@@ -593,6 +594,7 @@ static void select_mode(struct m0_audio_device *adev)
set_bigroute_by_array(adev->mixer, voicecall_default_disable, 1);
ALOGD("%s: set voicecall route: default_input_disable", __func__);
set_bigroute_by_array(adev->mixer, default_input_disable, 1);
+ set_noise_supression(adev, 0);
ALOGD("%s: set voicecall route: headset_input_disable", __func__);
set_bigroute_by_array(adev->mixer, headset_input_disable, 1);
ALOGD("%s: set voicecall route: bt_disable", __func__);
@@ -671,9 +673,11 @@ static void select_output_device(struct m0_audio_device *adev)
if (speaker_on || earpiece_on || headphone_on) {
ALOGD("%s: set voicecall route: default_input", __func__);
set_bigroute_by_array(adev->mixer, default_input, 1);
+ set_noise_supression(adev, 1);
} else {
ALOGD("%s: set voicecall route: default_input_disable", __func__);
set_bigroute_by_array(adev->mixer, default_input_disable, 1);
+ set_noise_supression(adev, 0);
}
if (headset_on) {
@@ -726,6 +730,21 @@ static void select_input_device(struct m0_audio_device *adev)
select_devices(adev);
}
+static void set_noise_supression(struct m0_audio_device *adev, int enable)
+{
+ if (enable) {
+ // Enable Noise suppression for builtin microphone
+ ALOGE("%s: enabling two mic control", __func__);
+ ril_set_two_mic_control(&adev->ril, AUDIENCE, TWO_MIC_SOLUTION_ON);
+ set_bigroute_by_array(adev->mixer, noise_suppression, 1);
+ } else {
+ // Disable Noise suppression for builtin microphone
+ ALOGE("%s: disabling two mic control", __func__);
+ ril_set_two_mic_control(&adev->ril, AUDIENCE, TWO_MIC_SOLUTION_OFF);
+ set_bigroute_by_array(adev->mixer, noise_suppression_disable, 1);
+ }
+}
+
/* must be called with hw device and output stream mutexes locked */
static int start_output_stream_low_latency(struct m0_stream_out *out)
{
@@ -2543,21 +2562,6 @@ static int adev_set_parameters(struct audio_hw_device *dev, const char *kvpairs)
adev->screen_off = true;
}
- ret = str_parms_get_str(parms, "noise_suppression", value, sizeof(value));
- if (ret >= 0) {
- if (strcmp(value, "true") == 0) {
- ALOGE("%s: enabling two mic control", __func__);
- ril_set_two_mic_control(&adev->ril, AUDIENCE, TWO_MIC_SOLUTION_ON);
- /* sub mic */
- set_bigroute_by_array(adev->mixer, noise_suppression, 1);
- } else {
- ALOGE("%s: disabling two mic control", __func__);
- ril_set_two_mic_control(&adev->ril, AUDIENCE, TWO_MIC_SOLUTION_OFF);
- /* sub mic */
- set_bigroute_by_array(adev->mixer, noise_suppression_disable, 1);
- }
- }
-
str_parms_destroy(parms);
return ret;
}