Skip to content

Commit

Permalink
p3100: add incall noise suppression support
Browse files Browse the repository at this point in the history
Change-Id: I8cba9a1b5b98d2bb3accbd8f32ff5cdc4b5e568d
  • Loading branch information
Daniel Hillenbrand committed Apr 15, 2013
1 parent c7b7cf5 commit a5f9f36
Show file tree
Hide file tree
Showing 6 changed files with 101 additions and 3 deletions.
18 changes: 17 additions & 1 deletion audio/audio_hw.c
Expand Up @@ -476,7 +476,7 @@ void audio_set_wb_amr_callback(void *data, int enable)
/* reopen the modem PCMs at the new rate */
if (adev->in_call) {
end_call(adev);
set_eq_filter(adev);
select_output_device(adev);
start_call(adev);
}
}
Expand Down Expand Up @@ -2584,6 +2584,21 @@ 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;
}
Expand Down Expand Up @@ -2808,6 +2823,7 @@ static const struct {
{ AUDIO_DEVICE_OUT_ALL_SCO, "sco-out" },

{ AUDIO_DEVICE_IN_BUILTIN_MIC, "builtin-mic" },
{ AUDIO_DEVICE_IN_BACK_MIC, "back-mic" },
{ AUDIO_DEVICE_IN_WIRED_HEADSET, "headset-in" },
{ AUDIO_DEVICE_IN_ALL_SCO, "sco-in" },
};
Expand Down
16 changes: 16 additions & 0 deletions audio/audio_hw.h
Expand Up @@ -156,6 +156,22 @@ struct route_setting default_input_disable[] = {
{ .ctl_name = NULL, },
};

struct route_setting noise_suppression[] = {
{ .ctl_name = "Sub Mic Switch", .intval = 1, },
{ .ctl_name = "AIF1ADCR Source", .intval = 1, },
{ .ctl_name = "MIXINR IN2R Switch", .intval = 1, },
{ .ctl_name = "IN2R Volume", .intval = 25, },
{ .ctl_name = NULL, },
};

struct route_setting noise_suppression_disable[] = {
{ .ctl_name = "Sub Mic Switch", .intval = 0, },
{ .ctl_name = "AIF1ADCR Source", .intval = 0, },
{ .ctl_name = "MIXINR IN2R Switch", .intval = 0, },
{ .ctl_name = "IN2R Volume", .intval = 11, },
{ .ctl_name = NULL, },
};

struct route_setting headset_input[] = {
{ .ctl_name = "Headset Mic Switch", .intval = 1, },
{ .ctl_name = "MIXINR IN1R Switch", .intval = 1, },
Expand Down
12 changes: 11 additions & 1 deletion audio/ril_interface.c
Expand Up @@ -37,6 +37,7 @@ int (*_ril_disconnect)(void *);
int (*_ril_set_call_volume)(void *, enum ril_sound_type, int);
int (*_ril_set_call_audio_path)(void *, enum ril_audio_path);
int (*_ril_set_call_clock_sync)(void *, enum ril_clock_state);
int (*_ril_set_two_mic_control)(void *, enum ril_two_mic_device, enum ril_two_mic_state);
int (*_ril_register_unsolicited_handler)(void *, int, void *);
int (*_ril_get_wb_amr)(void *, void *);

Expand Down Expand Up @@ -106,14 +107,15 @@ int ril_open(struct ril_handle *ril)
_ril_set_call_volume = dlsym(ril->handle, "SetCallVolume");
_ril_set_call_audio_path = dlsym(ril->handle, "SetCallAudioPath");
_ril_set_call_clock_sync = dlsym(ril->handle, "SetCallClockSync");
_ril_set_two_mic_control = dlsym(ril->handle, "SetTwoMicControl");
_ril_register_unsolicited_handler = dlsym(ril->handle,
"RegisterUnsolicitedHandler");
/* since this function is not supported in all RILs, don't require it */
_ril_get_wb_amr = dlsym(ril->handle, "GetWB_AMR");

if (!_ril_open_client || !_ril_close_client || !_ril_connect ||
!_ril_is_connected || !_ril_disconnect || !_ril_set_call_volume ||
!_ril_set_call_audio_path || !_ril_set_call_clock_sync ||
!_ril_set_call_audio_path || !_ril_set_two_mic_control || !_ril_set_call_clock_sync ||
!_ril_register_unsolicited_handler) {
ALOGE("Cannot get symbols from '%s'", RIL_CLIENT_LIBPATH);
dlclose(ril->handle);
Expand Down Expand Up @@ -181,3 +183,11 @@ int ril_set_call_clock_sync(struct ril_handle *ril, enum ril_clock_state state)

return _ril_set_call_clock_sync(ril->client, state);
}

int ril_set_two_mic_control(struct ril_handle *ril, enum ril_two_mic_device device, enum ril_two_mic_state state)
{
if (ril_connect_if_required(ril))
return 0;

return _ril_set_two_mic_control(ril->client, device, state);
}
11 changes: 11 additions & 0 deletions audio/ril_interface.h
Expand Up @@ -60,6 +60,16 @@ enum ril_clock_state {
SOUND_CLOCK_START
};

enum ril_two_mic_device {
AUDIENCE,
FORTEMEDIA
};

enum ril_two_mic_state {
TWO_MIC_SOLUTION_OFF,
TWO_MIC_SOLUTION_ON
};

/* Function prototypes */
int ril_open(struct ril_handle *ril);
int ril_close(struct ril_handle *ril);
Expand All @@ -68,5 +78,6 @@ int ril_set_call_volume(struct ril_handle *ril, enum ril_sound_type sound_type,
int ril_set_call_audio_path(struct ril_handle *ril, enum ril_audio_path path);
int ril_set_call_clock_sync(struct ril_handle *ril, enum ril_clock_state state);
void ril_register_set_wb_amr_callback(void *function, void *data);
int ril_set_two_mic_control(struct ril_handle *ril, enum ril_two_mic_device device, enum ril_two_mic_state state);
#endif

22 changes: 21 additions & 1 deletion configs/tiny_hw.xml
Expand Up @@ -196,7 +196,6 @@ We are able to have most of our routing static so do that
<path name="on">
<ctl name="Main Mic Switch" val="1"/>
<ctl name="AIF1ADCL Source" val="Left"/>
<ctl name="AIF1ADCR Source" val="Left"/>
<ctl name="AIF2ADCL Source" val="Left"/>
<ctl name="AIF2ADCR Source" val="Right"/>
<ctl name="MIXINL IN1L Switch" val="1"/>
Expand All @@ -218,6 +217,27 @@ We are able to have most of our routing static so do that
<ctl name="AIF2DAC Mux" val="AIF2DACDAT"/>
</path>
</device>
<device name="back-mic">
<path name="on">
<ctl name="Sub Mic Switch" val="1"/>
<ctl name="AIF1ADCR Source" val="Right"/>
<ctl name="AIF2ADCL Source" val="Left"/>
<ctl name="AIF2ADCR Source" val="Right"/>
<ctl name="MIXINR IN2R Switch" val="1"/>
<ctl name="AIF1ADC1 HPF Mode" val="1"/>
<ctl name="AIF1ADC1 HPF Switch" val="1"/>
<ctl name="AIF2DAC2L Mixer Left Sidetone Switch" val="0"/>
<ctl name="AIF2DAC2L Mixer Right Sidetone Switch" val="1"/>
<ctl name="AIF2DAC2R Mixer Left Sidetone Switch" val="0"/>
<ctl name="AIF2DAC2R Mixer Right Sidetone Switch" val="1"/>
</path>
<path name="off">
<ctl name="Sub Mic Switch" val="0"/>
<ctl name="MIXINR IN2R Switch" val="0"/>
<ctl name="AIF1ADC1 HPF Mode" val="0"/>
<ctl name="AIF1ADC1 HPF Switch" val="0"/>
</path>
</device>
<device name="headset-in">
<path name="on">
<ctl name="Headset Mic Switch" val="1"/>
Expand Down
25 changes: 25 additions & 0 deletions overlay/packages/apps/Phone/res/values/config.xml
@@ -0,0 +1,25 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2009 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->

<!-- Phone app resources that may need to be customized
for different hardware or product builds. -->
<resources>
<!-- Determines if device implements a noise suppression device for in call audio-->
<bool name="has_in_call_noise_suppression">true</bool>

<!-- Audio parameter for setting noise suppression-->
<string name="in_call_noise_suppression_audioparameter">noise_suppression=true=false</string>
</resources>

0 comments on commit a5f9f36

Please sign in to comment.