Gigabeat S: Switch SSI1 and 2 around so that playback can use the shared peripheral...
[kugel-rb.git] / firmware / target / arm / imx31 / gigabeat-s / audio-gigabeat-s.c
blobf5e17a4039e6412717b4e35cc793109d343f56ab
1 /***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
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 ****************************************************************************/
21 #include "config.h"
22 #include "system.h"
23 #include "audiohw.h"
24 #include "audio.h"
26 /* Set the audio source for IIS TX */
27 void audio_set_output_source(int source)
29 switch (source)
31 default:
32 case AUDIO_SRC_PLAYBACK:
33 /* Receive data from PORT2 (SSI2) */
34 AUDMUX_PDCR4 = AUDMUX_PDCR_RXDSEL_PORT2;
35 /* wmc_clear(WMC_COMPANDING_CTRL, WMC_LOOPBACK); */
36 break;
38 case AUDIO_SRC_FMRADIO:
39 /* External source - receive data from self (loopback to TX) */
40 AUDMUX_PDCR4 = AUDMUX_PDCR_RXDSEL_PORT4;
41 /* wmc_set(WMC_COMPANDING_CTRL, WMC_LOOPBACK); */
42 break;
46 void audio_input_mux(int source, unsigned int flags)
48 /* Prevent pops from unneeded switching */
49 static int last_source = AUDIO_SRC_PLAYBACK;
50 bool recording = flags & SRCF_RECORDING;
51 static bool last_recording = false;
53 switch (source)
55 default:
56 source = AUDIO_SRC_PLAYBACK;
57 /* Fallthrough */
58 case AUDIO_SRC_PLAYBACK: /* playback - no recording */
59 if (source != last_source)
60 audiohw_set_recsrc(AUDIO_SRC_PLAYBACK, false);
61 break;
63 case AUDIO_SRC_FMRADIO: /* recording and playback */
64 if (source != last_source || recording != last_recording)
65 audiohw_set_recsrc(AUDIO_SRC_FMRADIO, recording);
66 break;
69 last_source = source;
70 last_recording = recording;