summaryrefslogtreecommitdiffstats
path: root/firmware/target/coldfire/mpio/audio-mpio.c
diff options
context:
space:
mode:
authorMarcin Bukat <marcin.bukat@gmail.com>2010-04-29 13:14:43 +0000
committerMarcin Bukat <marcin.bukat@gmail.com>2010-04-29 13:14:43 +0000
commitc740af20e70ddc863c3a71f3b25e51b2a20b6795 (patch)
tree440c361a867739a24b87a2fc99916937abeff761 /firmware/target/coldfire/mpio/audio-mpio.c
parent4c03e9a6f0f40cf8d0ffed0d2f35fafdab143738 (diff)
downloadrockbox-c740af20e70ddc863c3a71f3b25e51b2a20b6795.tar.gz
rockbox-c740af20e70ddc863c3a71f3b25e51b2a20b6795.zip
HD200 - add FM support.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@25757 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware/target/coldfire/mpio/audio-mpio.c')
-rw-r--r--firmware/target/coldfire/mpio/audio-mpio.c65
1 files changed, 58 insertions, 7 deletions
diff --git a/firmware/target/coldfire/mpio/audio-mpio.c b/firmware/target/coldfire/mpio/audio-mpio.c
index 28c6419171..217881547e 100644
--- a/firmware/target/coldfire/mpio/audio-mpio.c
+++ b/firmware/target/coldfire/mpio/audio-mpio.c
@@ -23,27 +23,78 @@
#include "audio.h"
#include "sound.h"
+static inline void enable_mclk(bool enable)
+{
+ if(enable)
+ and_l(~(1<<10), &GPIO1_FUNCTION);
+ else
+ or_l((1<<10), &GPIO1_FUNCTION);
+}
+
void audio_set_output_source(int source)
{
+ static const unsigned char txsrc_select[AUDIO_NUM_SOURCES+1] =
+ {
+ [AUDIO_SRC_PLAYBACK+1] = 3, /* PDOR3 */
+ [AUDIO_SRC_MIC+1] = 4, /* IIS1 RcvData */
+ [AUDIO_SRC_LINEIN+1] = 4, /* IIS1 RcvData */
+ [AUDIO_SRC_FMRADIO+1] = 4, /* IIS1 RcvData */
+ };
- (void)source;
int level = set_irq_level(DMA_IRQ_LEVEL);
- /* PDOR3 */
- IIS2CONFIG = (IIS2CONFIG & ~(7 << 8)) | (3 << 8);
+ if ((unsigned)source >= AUDIO_NUM_SOURCES)
+ source = AUDIO_SRC_PLAYBACK;
+
+ IIS2CONFIG = (IIS2CONFIG & ~(7 << 8)) | (txsrc_select[source+1] << 8);
restore_irq(level);
}
void audio_input_mux(int source, unsigned flags)
{
- (void)source;
- (void)flags;
+ /* Prevent pops from unneeded switching */
+ static int last_source = AUDIO_SRC_PLAYBACK;
+ bool recording = flags & SRCF_RECORDING;
+ static bool last_recording = false;
switch(source)
{
+ default:
+ /* playback - no recording */
+ source = AUDIO_SRC_PLAYBACK;
+
+ case AUDIO_SRC_PLAYBACK:
+ if (source != last_source)
+ {
+ audiohw_set_recsrc(source,false);
+ coldfire_set_dataincontrol(0);
+ }
+ break;
+
+ case AUDIO_SRC_MIC:
+ case AUDIO_SRC_LINEIN:
+ /* recording only */
+ if (source != last_source)
+ {
+ audiohw_set_recsrc(source,true);
+ /* Int. when 6 samples in FIFO, PDIR2 src = iis1RcvData */
+ coldfire_set_dataincontrol((3 << 14) | (4 << 3));
+ }
+ break;
+
case AUDIO_SRC_FMRADIO:
- break;
+ if (source == last_source && recording == last_recording)
+ break;
+
+ last_recording = recording;
+
+ /* Int. when 6 samples in FIFO, PDIR2 src = iis1RcvData */
+ coldfire_set_dataincontrol(recording ?
+ ((3 << 14) | (4 << 3)) : 0);
+ audiohw_set_recsrc(source, recording);
+ break;
}
- /* empty stub */
+
+ last_source = source;
}