From 6e36ac547c23c3890439a3b81772d7e3c1ce938d Mon Sep 17 00:00:00 2001 From: Michael Sevakis Date: Sun, 11 Nov 2007 19:11:23 +0000 Subject: [PATCH] H10: Touch-up the audio source switching a bit. Actually fix my earlier errors when enabling recording from Line/FM. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@15580 a1c6a512-1295-4272-9138-f99709370657 --- firmware/drivers/audio/wm8731.c | 17 +++++++---------- firmware/target/arm/audio-pp.c | 18 +++++++++++++----- 2 files changed, 20 insertions(+), 15 deletions(-) diff --git a/firmware/drivers/audio/wm8731.c b/firmware/drivers/audio/wm8731.c index 44aeefe791..66eb1e859a 100644 --- a/firmware/drivers/audio/wm8731.c +++ b/firmware/drivers/audio/wm8731.c @@ -238,6 +238,8 @@ void audiohw_enable_recording(bool source_mic) codec_set_active(false); wm8731_regs[PDCTRL] &= ~PDCTRL_ADCPD; + /* NOTE: When switching to digital monitoring we will not want + * the DAC disabled. */ wm8731_regs[PDCTRL] |= PDCTRL_DACPD; wm8731_regs[AAPCTRL] &= ~AAPCTRL_DACSEL; @@ -247,7 +249,7 @@ void audiohw_enable_recording(bool source_mic) wm8731_regs[PDCTRL] &= ~PDCTRL_MICPD; wm8731_regs[PDCTRL] |= PDCTRL_LINEINPD; wm8731_regs[AAPCTRL] |= AAPCTRL_INSEL | AAPCTRL_SIDETONE; - wm8731_regs[AAPCTRL] &= ~AAPCTRL_MUTEMIC; + wm8731_regs[AAPCTRL] &= ~(AAPCTRL_MUTEMIC | AAPCTRL_BYPASS); } else { wm8731_regs[PDCTRL] |= PDCTRL_MICPD; wm8731_regs[PDCTRL] &= ~PDCTRL_LINEINPD; @@ -259,9 +261,6 @@ void audiohw_enable_recording(bool source_mic) wm8731_write(AAPCTRL, wm8731_regs[AAPCTRL]); if (!source_mic) { - wm8731_regs[AAPCTRL] |= AAPCTRL_INSEL | AAPCTRL_SIDETONE; - wm8731_regs[AAPCTRL] &= ~(AAPCTRL_MUTEMIC | AAPCTRL_BYPASS); - } else { wm8731_write_and(LINVOL, ~LINVOL_LINMUTE); wm8731_write_and(RINVOL, ~RINVOL_RINMUTE); } @@ -321,13 +320,11 @@ void audiohw_set_monitor(int enable) { if(enable) { - wm8731_regs[AAPCTRL] |= AAPCTRL_BYPASS; - wm8731_regs[AAPCTRL] &=~ (AAPCTRL_DACSEL | AAPCTRL_SIDETONE); - wm8731_write(AAPCTRL, wm8731_regs[AAPCTRL]); + wm8731_write_and(PDCTRL, ~PDCTRL_LINEINPD); + wm8731_write_or(AAPCTRL, AAPCTRL_BYPASS); } else { - wm8731_regs[AAPCTRL] &=~ AAPCTRL_BYPASS; - wm8731_regs[AAPCTRL] |= AAPCTRL_DACSEL | AAPCTRL_SIDETONE; - wm8731_write(AAPCTRL, wm8731_regs[AAPCTRL]); + wm8731_write_and(AAPCTRL, ~AAPCTRL_BYPASS); + wm8731_write_or(PDCTRL, PDCTRL_LINEINPD); } } diff --git a/firmware/target/arm/audio-pp.c b/firmware/target/arm/audio-pp.c index 783342ef37..2c94e36359 100644 --- a/firmware/target/arm/audio-pp.c +++ b/firmware/target/arm/audio-pp.c @@ -47,8 +47,8 @@ void audio_input_mux(int source, unsigned flags) #ifdef HAVE_RECORDING if (source != last_source) { - audiohw_disable_recording(); audiohw_set_monitor(false); + audiohw_disable_recording(); } #endif break; @@ -56,8 +56,8 @@ void audio_input_mux(int source, unsigned flags) case AUDIO_SRC_MIC: /* recording only */ if (source != last_source) { - audiohw_enable_recording(true); /* source mic */ audiohw_set_monitor(false); + audiohw_enable_recording(true); /* source mic */ } break; #endif @@ -69,8 +69,8 @@ void audio_input_mux(int source, unsigned flags) #endif if (source != last_source) { - audiohw_enable_recording(false); /* source line */ audiohw_set_monitor(false); + audiohw_enable_recording(false); /* source line */ } break; #endif @@ -88,8 +88,16 @@ void audio_input_mux(int source, unsigned flags) last_recording = recording; - audiohw_enable_recording(false); /* select line-in source */ - audiohw_set_monitor(!recording); /* enable bypass mode */ + if (recording) + { + audiohw_set_monitor(false); /* disable bypass mode */ + audiohw_enable_recording(false); /* select line-in source */ + } + else + { + audiohw_disable_recording(); + audiohw_set_monitor(true); /* enable bypass mode */ + } break; #endif } /* end switch */