summaryrefslogtreecommitdiffstats
path: root/audio
diff options
context:
space:
mode:
authorSimon Wilson <simonwilson@google.com>2011-08-26 15:06:32 -0700
committerSimon Wilson <simonwilson@google.com>2011-08-26 16:51:25 -0700
commitdcbb31662c181e95d5f0b9fe0589679c08283402 (patch)
tree89da240b81db5ccacd8c2a1135b96570b3729edf /audio
parentb190ba5df8429ac2ca46b7a9b27be2ccc97f34e4 (diff)
downloaddevice_samsung_tuna-dcbb31662c181e95d5f0b9fe0589679c08283402.zip
device_samsung_tuna-dcbb31662c181e95d5f0b9fe0589679c08283402.tar.gz
device_samsung_tuna-dcbb31662c181e95d5f0b9fe0589679c08283402.tar.bz2
audio: turn off output stages when not in use
The DAC widgets are turned off when not in use in order to save power. They must not be turned off when the output goes into standby if a call is in progress. Change-Id: I3d294a85a86e45c8acc257a8d92b92d7d9b2d4c3
Diffstat (limited to 'audio')
-rw-r--r--audio/audio_hw.c51
1 files changed, 36 insertions, 15 deletions
diff --git a/audio/audio_hw.c b/audio/audio_hw.c
index 518b62b..b9ccfa1 100644
--- a/audio/audio_hw.c
+++ b/audio/audio_hw.c
@@ -204,7 +204,27 @@ struct route_setting defaults[] = {
.intval = DB_TO_CAPTURE_VOLUME(30),
},
- /* speaker */
+ /* headset */
+ {
+ .ctl_name = MIXER_SIDETONE_MIXER_PLAYBACK,
+ .intval = 1,
+ },
+ {
+ .ctl_name = MIXER_DL1_PDM_SWITCH,
+ .intval = 1,
+ },
+
+ /* bt */
+ {
+ .ctl_name = MIXER_BT_UL_VOLUME,
+ .intval = MIXER_ABE_GAIN_0DB,
+ },
+ {
+ .ctl_name = NULL,
+ },
+};
+
+struct route_setting hf_output[] = {
{
.ctl_name = MIXER_HF_LEFT_PLAYBACK,
.strval = MIXER_PLAYBACK_HF_DAC,
@@ -213,16 +233,12 @@ struct route_setting defaults[] = {
.ctl_name = MIXER_HF_RIGHT_PLAYBACK,
.strval = MIXER_PLAYBACK_HF_DAC,
},
-
- /* headset */
- {
- .ctl_name = MIXER_SIDETONE_MIXER_PLAYBACK,
- .intval = 1,
- },
{
- .ctl_name = MIXER_DL1_PDM_SWITCH,
- .intval = 1,
+ .ctl_name = NULL,
},
+};
+
+struct route_setting hs_output[] = {
{
.ctl_name = MIXER_HS_LEFT_PLAYBACK,
.strval = MIXER_PLAYBACK_HS_DAC,
@@ -231,12 +247,6 @@ struct route_setting defaults[] = {
.ctl_name = MIXER_HS_RIGHT_PLAYBACK,
.strval = MIXER_PLAYBACK_HS_DAC,
},
-
- /* bt */
- {
- .ctl_name = MIXER_BT_UL_VOLUME,
- .intval = MIXER_ABE_GAIN_0DB,
- },
{
.ctl_name = NULL,
},
@@ -632,6 +642,10 @@ static void select_output_device(struct tuna_audio_device *adev)
mixer_ctl_set_value(adev->mixer_ctls.dl1_bt, 0, bt_on);
mixer_ctl_set_value(adev->mixer_ctls.earpiece_enable, 0, earpiece_on);
+ /* select output stage */
+ set_route_by_array(adev->mixer, hs_output, headset_on | headphone_on | earpiece_on);
+ set_route_by_array(adev->mixer, hf_output, speaker_on);
+
/* Special case: select input path if in a call, otherwise
in_set_parameters is used to update the input route
todo: use sub mic for handsfree case */
@@ -868,10 +882,17 @@ static int out_set_format(struct audio_stream *stream, int format)
static int out_standby(struct audio_stream *stream)
{
struct tuna_stream_out *out = (struct tuna_stream_out *)stream;
+ struct tuna_audio_device *adev = out->dev;
pthread_mutex_lock(&out->lock);
if (!out->standby) {
pcm_close(out->pcm);
+ /* if in call, don't turn off the output stage. This will
+ be done when the call is ended */
+ if (adev->mode != AUDIO_MODE_IN_CALL) {
+ set_route_by_array(adev->mixer, hs_output, 0);
+ set_route_by_array(adev->mixer, hf_output, 0);
+ }
out->pcm = NULL;
out->standby = 1;
}