1 /***************************************************************************
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
10 * Copyright (C) 2006 by Michael Sevakis
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 void audio_set_output_source(int source
)
28 int level
= set_irq_level(DMA_IRQ_LEVEL
);
31 if ((unsigned)source
>= AUDIO_NUM_SOURCES
)
32 txsrc
= (3 << 8); /* playback, PDOR3 */
34 txsrc
= (4 << 8); /* recording, iis1RcvData */
36 IIS1CONFIG
= (IIS1CONFIG
& ~(7 << 8)) | txsrc
;
38 } /* audio_set_output_source */
40 void audio_input_mux(int source
, unsigned flags
)
42 /* Prevent pops from unneeded switching */
43 static int last_source
= AUDIO_SRC_PLAYBACK
;
44 static bool last_recording
= false;
46 bool recording
= flags
& SRCF_RECORDING
;
50 default: /* playback - no recording */
51 source
= AUDIO_SRC_PLAYBACK
;
52 case AUDIO_SRC_PLAYBACK
:
53 if (source
!= last_source
)
55 audiohw_disable_recording();
56 audiohw_set_monitor(false);
57 coldfire_set_dataincontrol(0);
61 case AUDIO_SRC_MIC
: /* recording only */
62 if (source
!= last_source
)
64 audiohw_enable_recording(true); /* source mic */
65 /* Int. when 6 samples in FIFO, PDIR2 src = iis1RcvData */
66 coldfire_set_dataincontrol((3 << 14) | (4 << 3));
70 case AUDIO_SRC_LINEIN
: /* recording only */
71 if (source
!= last_source
)
73 audiohw_enable_recording(false); /* source line */
74 /* Int. when 6 samples in FIFO, PDIR2 src = iis1RcvData */
75 coldfire_set_dataincontrol((3 << 14) | (4 << 3));
79 case AUDIO_SRC_FMRADIO
: /* recording and playback */
81 audiohw_set_recvol(23, 23, AUDIO_GAIN_LINEIN
);
83 /* I2S recording and analog playback */
84 if (source
== last_source
&& recording
== last_recording
)
87 last_recording
= recording
;
91 /* Int. when 6 samples in FIFO, PDIR2 src = iis1RcvData */
92 coldfire_set_dataincontrol((3 << 14) | (4 << 3));
93 audiohw_enable_recording(false); /* source line */
97 audiohw_disable_recording();
98 audiohw_set_monitor(true); /* analog bypass */
99 coldfire_set_dataincontrol(0);
104 /* set line multiplexer */
105 if (source
== AUDIO_SRC_FMRADIO
)
106 and_l(~(1 << 29), &GPIO_OUT
); /* FM radio */
108 or_l((1 << 29), &GPIO_OUT
); /* Line In */
110 or_l((1 << 29), &GPIO_ENABLE
);
111 or_l((1 << 29), &GPIO_FUNCTION
);
113 last_source
= source
;
114 } /* audio_input_mux */