diff options
Diffstat (limited to 'firmware/target/coldfire/iaudio/m3/audio-m3.c')
-rw-r--r-- | firmware/target/coldfire/iaudio/m3/audio-m3.c | 114 |
1 files changed, 114 insertions, 0 deletions
diff --git a/firmware/target/coldfire/iaudio/m3/audio-m3.c b/firmware/target/coldfire/iaudio/m3/audio-m3.c new file mode 100644 index 0000000000..4edae48744 --- /dev/null +++ b/firmware/target/coldfire/iaudio/m3/audio-m3.c | |||
@@ -0,0 +1,114 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2006 by Michael Sevakis | ||
11 | * | ||
12 | * All files in this archive are subject to the GNU General Public License. | ||
13 | * See the file COPYING in the source tree root for full license agreement. | ||
14 | * | ||
15 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
16 | * KIND, either express or implied. | ||
17 | * | ||
18 | ****************************************************************************/ | ||
19 | |||
20 | #include "system.h" | ||
21 | #include "cpu.h" | ||
22 | #include "audio.h" | ||
23 | #include "sound.h" | ||
24 | |||
25 | void audio_set_output_source(int source) | ||
26 | { | ||
27 | int level = set_irq_level(DMA_IRQ_LEVEL); | ||
28 | unsigned long txsrc; | ||
29 | |||
30 | if ((unsigned)source >= AUDIO_NUM_SOURCES) | ||
31 | txsrc = (3 << 8); /* playback, PDOR3 */ | ||
32 | else | ||
33 | txsrc = (4 << 8); /* recording, iis1RcvData */ | ||
34 | |||
35 | IIS1CONFIG = (IIS1CONFIG & ~(7 << 8)) | txsrc; | ||
36 | set_irq_level(level); | ||
37 | } /* audio_set_output_source */ | ||
38 | |||
39 | void audio_input_mux(int source, unsigned flags) | ||
40 | { | ||
41 | /* Prevent pops from unneeded switching */ | ||
42 | static int last_source = AUDIO_SRC_PLAYBACK; | ||
43 | static bool last_recording = false; | ||
44 | |||
45 | bool recording = flags & SRCF_RECORDING; | ||
46 | |||
47 | switch (source) | ||
48 | { | ||
49 | default: /* playback - no recording */ | ||
50 | source = AUDIO_SRC_PLAYBACK; | ||
51 | case AUDIO_SRC_PLAYBACK: | ||
52 | if (source != last_source) | ||
53 | { | ||
54 | audiohw_disable_recording(); | ||
55 | audiohw_set_monitor(false); | ||
56 | coldfire_set_dataincontrol(0); | ||
57 | } | ||
58 | break; | ||
59 | |||
60 | case AUDIO_SRC_MIC: /* recording only */ | ||
61 | if (source != last_source) | ||
62 | { | ||
63 | audiohw_enable_recording(true); /* source mic */ | ||
64 | /* Int. when 6 samples in FIFO, PDIR2 src = iis1RcvData */ | ||
65 | coldfire_set_dataincontrol((3 << 14) | (4 << 3)); | ||
66 | } | ||
67 | break; | ||
68 | |||
69 | case AUDIO_SRC_LINEIN: /* recording only */ | ||
70 | if (source != last_source) | ||
71 | { | ||
72 | audiohw_enable_recording(false); /* source line */ | ||
73 | /* Int. when 6 samples in FIFO, PDIR2 src = iis1RcvData */ | ||
74 | coldfire_set_dataincontrol((3 << 14) | (4 << 3)); | ||
75 | } | ||
76 | break; | ||
77 | |||
78 | case AUDIO_SRC_FMRADIO: /* recording and playback */ | ||
79 | if (!recording) | ||
80 | audiohw_set_recvol(23, 23, AUDIO_GAIN_LINEIN); | ||
81 | |||
82 | /* I2S recording and analog playback */ | ||
83 | if (source == last_source && recording == last_recording) | ||
84 | break; | ||
85 | |||
86 | last_recording = recording; | ||
87 | |||
88 | if (recording) | ||
89 | { | ||
90 | /* Int. when 6 samples in FIFO, PDIR2 src = iis1RcvData */ | ||
91 | coldfire_set_dataincontrol((3 << 14) | (4 << 3)); | ||
92 | audiohw_enable_recording(false); /* source line */ | ||
93 | } | ||
94 | else | ||
95 | { | ||
96 | audiohw_disable_recording(); | ||
97 | audiohw_set_monitor(true); /* analog bypass */ | ||
98 | coldfire_set_dataincontrol(0); | ||
99 | } | ||
100 | break; | ||
101 | } /* end switch */ | ||
102 | |||
103 | /* set line multiplexer */ | ||
104 | if (source == AUDIO_SRC_FMRADIO) | ||
105 | and_l(~(1 << 25), &GPIO1_OUT); /* FM radio */ | ||
106 | else | ||
107 | or_l((1 << 25), &GPIO1_OUT); /* Line In */ | ||
108 | |||
109 | or_l((1 << 25), &GPIO1_ENABLE); | ||
110 | or_l((1 << 25), &GPIO1_FUNCTION); | ||
111 | |||
112 | last_source = source; | ||
113 | } /* audio_input_mux */ | ||
114 | |||