1 /***************************************************************************
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
10 * Copyright (C) 2008 by Nils Wallménius
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 audiohw_enable_tone_controls(bool enable
);
27 void audiohw_enable_depth_3d(bool enable
);
29 /* Set the audio source for IIS TX */
30 void audio_set_output_source(int source
)
35 case AUDIO_SRC_PLAYBACK
:
36 audiohw_enable_tone_controls(true);
37 audiohw_enable_depth_3d(true);
38 /* Receive data from PORT2 (SSI2) */
39 AUDMUX_PDCR4
= AUDMUX_PDCR_RXDSEL_PORT2
;
40 /* wmc_clear(WMC_COMPANDING_CTRL, WMC_LOOPBACK); */
43 case AUDIO_SRC_FMRADIO
:
44 /* Analog path doesn't support these and digital radio playback
45 * cannot be done without mixing on the MCU if voice is to be
46 * heard. Any recording should match what is heard. */
47 audiohw_enable_tone_controls(false);
48 audiohw_enable_depth_3d(false);
49 /* External source - receive data from self (loopback to TX) */
50 AUDMUX_PDCR4
= AUDMUX_PDCR_RXDSEL_PORT4
;
51 /* wmc_set(WMC_COMPANDING_CTRL, WMC_LOOPBACK); */
56 void audio_input_mux(int source
, unsigned int flags
)
58 /* Prevent pops from unneeded switching */
59 static int last_source
= AUDIO_SRC_PLAYBACK
;
60 bool recording
= flags
& SRCF_RECORDING
;
61 static bool last_recording
= false;
66 source
= AUDIO_SRC_PLAYBACK
;
68 case AUDIO_SRC_PLAYBACK
: /* playback - no recording */
69 if (source
!= last_source
)
70 audiohw_set_recsrc(AUDIO_SRC_PLAYBACK
, false);
73 case AUDIO_SRC_FMRADIO
: /* recording and playback */
74 if (source
!= last_source
|| recording
!= last_recording
)
75 audiohw_set_recsrc(AUDIO_SRC_FMRADIO
, recording
);
80 last_recording
= recording
;