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 ****************************************************************************/
27 void audio_set_output_source(int source
)
29 int level
= set_irq_level(DMA_IRQ_LEVEL
);
32 if ((unsigned)source
>= AUDIO_NUM_SOURCES
)
33 txsrc
= (3 << 8); /* playback, PDOR3 */
35 txsrc
= (4 << 8); /* recording, iis1RcvData */
37 IIS1CONFIG
= (IIS1CONFIG
& ~(7 << 8)) | txsrc
;
39 } /* audio_set_output_source */
41 void audio_input_mux(int source
, unsigned flags
)
43 /* Prevent pops from unneeded switching */
44 static int last_source
= AUDIO_SRC_PLAYBACK
;
45 static bool last_recording
= false;
47 bool recording
= flags
& SRCF_RECORDING
;
51 default: /* playback - no recording */
52 source
= AUDIO_SRC_PLAYBACK
;
53 case AUDIO_SRC_PLAYBACK
:
54 if (source
!= last_source
)
56 audiohw_disable_recording();
57 audiohw_set_monitor(false);
58 coldfire_set_dataincontrol(0);
62 case AUDIO_SRC_MIC
: /* recording only */
63 if (source
!= last_source
)
65 audiohw_enable_recording(true); /* source mic */
66 /* Int. when 6 samples in FIFO, PDIR2 src = iis1RcvData */
67 coldfire_set_dataincontrol((3 << 14) | (4 << 3));
71 case AUDIO_SRC_LINEIN
: /* recording only */
72 if (source
!= last_source
)
74 audiohw_enable_recording(false); /* source line */
75 /* Int. when 6 samples in FIFO, PDIR2 src = iis1RcvData */
76 coldfire_set_dataincontrol((3 << 14) | (4 << 3));
80 case AUDIO_SRC_FMRADIO
: /* recording and playback */
82 audiohw_set_recvol(23, 23, AUDIO_GAIN_LINEIN
);
84 /* I2S recording and analog playback */
85 if (source
== last_source
&& recording
== last_recording
)
88 last_recording
= recording
;
92 /* Int. when 6 samples in FIFO, PDIR2 src = iis1RcvData */
93 coldfire_set_dataincontrol((3 << 14) | (4 << 3));
94 audiohw_enable_recording(false); /* source line */
98 audiohw_disable_recording();
99 audiohw_set_monitor(true); /* analog bypass */
100 coldfire_set_dataincontrol(0);
105 /* set line multiplexer */
106 if (source
== AUDIO_SRC_FMRADIO
)
107 and_l(~(1 << 25), &GPIO1_OUT
); /* FM radio */
109 or_l((1 << 25), &GPIO1_OUT
); /* Line In */
111 or_l((1 << 25), &GPIO1_ENABLE
);
112 or_l((1 << 25), &GPIO1_FUNCTION
);
114 last_source
= source
;
115 } /* audio_input_mux */