1 /***************************************************************************
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
10 * Copyright (C) 2010 Marcin Bukat
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
20 ****************************************************************************/
26 static inline void enable_mclk(bool enable
)
29 and_l(~(1<<10), &GPIO1_FUNCTION
);
31 or_l((1<<10), &GPIO1_FUNCTION
);
34 void audio_set_output_source(int source
)
36 static const unsigned char txsrc_select
[AUDIO_NUM_SOURCES
+1] =
38 [AUDIO_SRC_PLAYBACK
+1] = 3, /* PDOR3 */
39 #if (INPUT_SRC_CAPS & SRC_CAP_MIC)
40 [AUDIO_SRC_MIC
+1] = 4, /* IIS1 RcvData */
42 #if (INPUT_SRC_CAPS & SRC_CAP_LINEIN)
43 [AUDIO_SRC_LINEIN
+1] = 4, /* IIS1 RcvData */
45 #if (INPUT_SRC_CAPS & SRC_CAP_FMRADIO)
46 [AUDIO_SRC_FMRADIO
+1] = 4, /* IIS1 RcvData */
50 int level
= set_irq_level(DMA_IRQ_LEVEL
);
52 if ((unsigned)source
>= AUDIO_NUM_SOURCES
)
53 source
= AUDIO_SRC_PLAYBACK
;
55 /* route incoming audio samples to DAC */
56 IIS2CONFIG
= (IIS2CONFIG
& ~(7 << 8)) | (txsrc_select
[source
+1] << 8);
61 void audio_input_mux(int source
, unsigned flags
)
63 /* Prevent pops from unneeded switching */
64 static int last_source
= AUDIO_SRC_PLAYBACK
;
65 bool recording
= flags
& SRCF_RECORDING
;
66 static bool last_recording
= false;
71 /* playback - no recording */
72 source
= AUDIO_SRC_PLAYBACK
;
74 case AUDIO_SRC_PLAYBACK
:
75 if (source
!= last_source
)
77 audiohw_set_recsrc(source
,false);
78 coldfire_set_dataincontrol(0);
83 #if (INPUT_SRC_CAPS & SRC_CAP_LINEIN)
84 case AUDIO_SRC_LINEIN
:
87 if (source
!= last_source
)
89 audiohw_set_recsrc(source
,true);
90 /* Int. when 6 samples in FIFO, PDIR2 src = iis1RcvData */
91 coldfire_set_dataincontrol((3 << 14) | (4 << 3));
95 case AUDIO_SRC_FMRADIO
:
96 if (source
== last_source
&& recording
== last_recording
)
99 last_recording
= recording
;
101 audiohw_set_recsrc(source
,recording
);
102 /* Int. when 6 samples in FIFO, PDIR2 src = iis1RcvData */
103 coldfire_set_dataincontrol(recording
?
104 ((3 << 14) | (4 << 3)) : 0);
108 last_source
= source
;