summaryrefslogtreecommitdiff
path: root/firmware/target/coldfire/mpio/audio-mpio.c
diff options
context:
space:
mode:
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 @@
23#include "audio.h" 23#include "audio.h"
24#include "sound.h" 24#include "sound.h"
25 25
26static inline void enable_mclk(bool enable)
27{
28 if(enable)
29 and_l(~(1<<10), &GPIO1_FUNCTION);
30 else
31 or_l((1<<10), &GPIO1_FUNCTION);
32}
33
26void audio_set_output_source(int source) 34void audio_set_output_source(int source)
27{ 35{
36 static const unsigned char txsrc_select[AUDIO_NUM_SOURCES+1] =
37 {
38 [AUDIO_SRC_PLAYBACK+1] = 3, /* PDOR3 */
39 [AUDIO_SRC_MIC+1] = 4, /* IIS1 RcvData */
40 [AUDIO_SRC_LINEIN+1] = 4, /* IIS1 RcvData */
41 [AUDIO_SRC_FMRADIO+1] = 4, /* IIS1 RcvData */
42 };
28 43
29 (void)source;
30 int level = set_irq_level(DMA_IRQ_LEVEL); 44 int level = set_irq_level(DMA_IRQ_LEVEL);
31 45
32 /* PDOR3 */ 46 if ((unsigned)source >= AUDIO_NUM_SOURCES)
33 IIS2CONFIG = (IIS2CONFIG & ~(7 << 8)) | (3 << 8); 47 source = AUDIO_SRC_PLAYBACK;
48
49 IIS2CONFIG = (IIS2CONFIG & ~(7 << 8)) | (txsrc_select[source+1] << 8);
34 50
35 restore_irq(level); 51 restore_irq(level);
36} 52}
37 53
38void audio_input_mux(int source, unsigned flags) 54void audio_input_mux(int source, unsigned flags)
39{ 55{
40 (void)source; 56 /* Prevent pops from unneeded switching */
41 (void)flags; 57 static int last_source = AUDIO_SRC_PLAYBACK;
58 bool recording = flags & SRCF_RECORDING;
59 static bool last_recording = false;
42 60
43 switch(source) 61 switch(source)
44 { 62 {
63 default:
64 /* playback - no recording */
65 source = AUDIO_SRC_PLAYBACK;
66
67 case AUDIO_SRC_PLAYBACK:
68 if (source != last_source)
69 {
70 audiohw_set_recsrc(source,false);
71 coldfire_set_dataincontrol(0);
72 }
73 break;
74
75 case AUDIO_SRC_MIC:
76 case AUDIO_SRC_LINEIN:
77 /* recording only */
78 if (source != last_source)
79 {
80 audiohw_set_recsrc(source,true);
81 /* Int. when 6 samples in FIFO, PDIR2 src = iis1RcvData */
82 coldfire_set_dataincontrol((3 << 14) | (4 << 3));
83 }
84 break;
85
45 case AUDIO_SRC_FMRADIO: 86 case AUDIO_SRC_FMRADIO:
46 break; 87 if (source == last_source && recording == last_recording)
88 break;
89
90 last_recording = recording;
91
92 /* Int. when 6 samples in FIFO, PDIR2 src = iis1RcvData */
93 coldfire_set_dataincontrol(recording ?
94 ((3 << 14) | (4 << 3)) : 0);
95 audiohw_set_recsrc(source, recording);
96 break;
47 } 97 }
48 /* empty stub */ 98
99 last_source = source;
49} 100}