1 /***************************************************************************
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
10 * Copyright (C) 2009 by Bertrik Sikken
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 ****************************************************************************/
28 int audio_channels
= 2;
30 void audio_set_output_source(int source
)
32 bitset32(&CGU_PERI
, CGU_I2SOUT_APB_CLOCK_ENABLE
);
33 if (source
== AUDIO_SRC_PLAYBACK
)
34 I2SOUT_CONTROL
&= ~(1<<5);
36 I2SOUT_CONTROL
|= 1<<5; /* source = loopback from i2sin fifo */
39 void audio_input_mux(int source
, unsigned flags
)
41 static int last_source
= AUDIO_SRC_PLAYBACK
;
42 #if defined(HAVE_RECORDING) && (INPUT_SRC_CAPS & SRC_CAP_FMRADIO)
43 static bool last_recording
= false;
44 const 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
)
57 #if defined(HAVE_RECORDING) || defined(HAVE_FMRADIO_IN)
58 audiohw_set_monitor(false);
61 audiohw_disable_recording();
66 #if defined(HAVE_RECORDING) && (INPUT_SRC_CAPS & SRC_CAP_MIC)
67 case AUDIO_SRC_MIC
: /* recording only */
68 if (source
!= last_source
)
71 audiohw_set_monitor(false);
72 audiohw_enable_recording(true); /* source mic */
77 #if (INPUT_SRC_CAPS & SRC_CAP_FMRADIO)
79 case AUDIO_SRC_FMRADIO
: /* recording and playback */
80 if (source
== last_source
82 && recording
== last_recording
89 last_recording
= recording
;
93 audiohw_set_monitor(false);
94 audiohw_enable_recording(false);
100 audiohw_disable_recording();
102 #if defined(HAVE_RECORDING) || defined(HAVE_FMRADIO_IN)
103 audiohw_set_monitor(true); /* line 2 analog audio path */
107 #endif /* (INPUT_SRC_CAPS & SRC_CAP_FMRADIO) */
110 last_source
= source
;