diff options
author | Simon Wilson <simonwilson@google.com> | 2011-06-27 22:07:47 -0700 |
---|---|---|
committer | Simon Wilson <simonwilson@google.com> | 2011-06-27 22:09:22 -0700 |
commit | e7c6299d7ddfdc0db0e3fda19d3a32ffcdc581e4 (patch) | |
tree | 8b47f9da71067534d4984fbed33d41b20acde441 /audio | |
parent | 857306dd7f15f4d312fed1a30c2559af826ee0a9 (diff) | |
download | device_samsung_tuna-e7c6299d7ddfdc0db0e3fda19d3a32ffcdc581e4.zip device_samsung_tuna-e7c6299d7ddfdc0db0e3fda19d3a32ffcdc581e4.tar.gz device_samsung_tuna-e7c6299d7ddfdc0db0e3fda19d3a32ffcdc581e4.tar.bz2 |
audio: add headset output device
Change-Id: I0f5cb58d0f1fc0372f459a6fb55f30683da414d9
Diffstat (limited to 'audio')
-rw-r--r-- | audio/audio_hw.c | 31 |
1 files changed, 20 insertions, 11 deletions
diff --git a/audio/audio_hw.c b/audio/audio_hw.c index 24069a9..5f590e0 100644 --- a/audio/audio_hw.c +++ b/audio/audio_hw.c @@ -91,6 +91,10 @@ #define RESAMPLER_BUFFER_SIZE 8192 +#define AUDIO_DEVICE_OUT_ALL_HEADSET (AUDIO_DEVICE_OUT_EARPIECE |\ + AUDIO_DEVICE_OUT_WIRED_HEADSET |\ + AUDIO_DEVICE_OUT_WIRED_HEADPHONE) + struct pcm_config pcm_config_mm = { .channels = 2, .rate = 48000, @@ -192,12 +196,16 @@ struct route_setting defaults[] = { .strval = MIXER_PLAYBACK_HS_DAC, }, - /* earphone */ + { + .ctl_name = NULL, + }, +}; + +struct route_setting earpiece_switch[] = { { .ctl_name = MIXER_EARPHONE_DRIVER_SWITCH, .intval = 1, }, - { .ctl_name = NULL, }, @@ -447,13 +455,14 @@ static void select_mode(struct tuna_audio_device *adev) } } +/* Note: currently the headset/earpiece route gets priority +over speaker if both are selected as output devices. */ static void select_output_device(struct tuna_audio_device *adev) { struct mixer_ctl *ctl; /* Select output device */ - switch (adev->out_device) { - case AUDIO_DEVICE_OUT_SPEAKER: + if (adev->out_device & AUDIO_DEVICE_OUT_SPEAKER) { if (adev->in_call) { /* tear down call stream before changing route, otherwise microphone does not function */ @@ -462,8 +471,7 @@ static void select_output_device(struct tuna_audio_device *adev) start_call(adev); } else set_route_by_array(adev->mixer, speaker_mm, 1); - break; - case AUDIO_DEVICE_OUT_EARPIECE: + } else if (adev->out_device & AUDIO_DEVICE_OUT_ALL_HEADSET) { if (adev->in_call) { /* tear down call stream before changing route, otherwise microphone does not function */ @@ -472,11 +480,12 @@ static void select_output_device(struct tuna_audio_device *adev) start_call(adev); } else set_route_by_array(adev->mixer, headset_mm, 1); - break; - default: - /* unknown */ - break; - }; + } + + if (adev->out_device & AUDIO_DEVICE_OUT_EARPIECE) + set_route_by_array(adev->mixer, earpiece_switch, 1); + else + set_route_by_array(adev->mixer, earpiece_switch, 0); } static uint32_t out_get_sample_rate(const struct audio_stream *stream) |