aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrandon McAnsh <brandon.mcansh@gmail.com>2017-01-03 08:15:50 -0500
committerc457 <android.c357@gmail.com>2017-01-21 11:22:13 -0600
commitda015a3911e845c4484315b803f4093b9d5c9259 (patch)
treeef140a414df450c2740a965f271b128e71c87a98
parent4e6f4891b62a74c695e5eef0169d087646a50077 (diff)
amp: Handle voice routing
* Also handle mono left/right vs speaker Change-Id: I2fcf160bf495246287899bf453b65eaa711bb371 Signed-off-by: Brandon McAnsh <brandon.mcansh@gmail.com>
-rw-r--r--audio_amplifier/audio_amplifier.c50
1 files changed, 36 insertions, 14 deletions
diff --git a/audio_amplifier/audio_amplifier.c b/audio_amplifier/audio_amplifier.c
index feb47a7..fa145ac 100644
--- a/audio_amplifier/audio_amplifier.c
+++ b/audio_amplifier/audio_amplifier.c
@@ -45,31 +45,53 @@ typedef struct tfa9890_device {
static tfa9890_device_t *tfa9890_dev = NULL;
-static int is_spkr_needed(uint32_t snd_device) {
- int spkr_needed = 0;
+enum {
+ NO_SPEAKER = 0,
+ MONO_RIGHT,
+ MONO_LEFT,
+ STEREO_SPEAKER
+};
+static int is_spkr_needed(uint32_t snd_device) {
switch (snd_device) {
case SND_DEVICE_OUT_SPEAKER:
case SND_DEVICE_OUT_VOICE_SPEAKER:
- spkr_needed = 1;
- break;
+ return STEREO_SPEAKER;
+ case SND_DEVICE_OUT_HANDSET:
+ case SND_DEVICE_OUT_VOICE_HANDSET:
+ return MONO_RIGHT;
+ default:
+ return NO_SPEAKER;
}
-
- return spkr_needed;
}
static int amp_enable_output_devices(hw_device_t *device, uint32_t devices, bool enable) {
tfa9890_device_t *tfa9890 = (tfa9890_device_t*) device;
- if (is_spkr_needed(devices)) {
- if (enable) {
- tfa9890->speaker_needed(1, 1);
- tfa9890->speaker_on();
- } else {
- tfa9890->speaker_needed(0, 0);
- tfa9890->speaker_off();
- }
+ if (enable) {
+ switch (is_spkr_needed(devices)) {
+ case STEREO_SPEAKER:
+ tfa9890->speaker_needed(1, 1);
+ tfa9890->speaker_on();
+ break;
+ case MONO_RIGHT:
+ tfa9890->speaker_needed(0, 1);
+ tfa9890->speaker_on();
+ break;
+ case MONO_LEFT:
+ tfa9890->speaker_needed(1, 0);
+ tfa9890->speaker_on();
+ break;
+ case NO_SPEAKER:
+ tfa9890->speaker_needed(0, 0);
+ tfa9890->speaker_off();
+ break;
+ }
+ } else {
+ tfa9890->speaker_needed(0, 0);
+ tfa9890->speaker_off() ;
}
+
return 0;
}