Gigabeat S: Turn off hardware effects (tone and 3d) when doing digital loopback for...
[kugel-rb.git] / firmware / target / arm / imx31 / gigabeat-s / audio-gigabeat-s.c
blob9587b5683c57469a9b75e01bedf2f618a71cea9c
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 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)
32 switch (source)
34 default:
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); */
41 break;
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); */
52 break;
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;
63 switch (source)
65 default:
66 source = AUDIO_SRC_PLAYBACK;
67 /* Fallthrough */
68 case AUDIO_SRC_PLAYBACK: /* playback - no recording */
69 if (source != last_source)
70 audiohw_set_recsrc(AUDIO_SRC_PLAYBACK, false);
71 break;
73 case AUDIO_SRC_FMRADIO: /* recording and playback */
74 if (source != last_source || recording != last_recording)
75 audiohw_set_recsrc(AUDIO_SRC_FMRADIO, recording);
76 break;
79 last_source = source;
80 last_recording = recording;