summaryrefslogtreecommitdiff
path: root/firmware/target/arm/audio-pp.c
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/target/arm/audio-pp.c')
-rw-r--r--firmware/target/arm/audio-pp.c84
1 files changed, 84 insertions, 0 deletions
diff --git a/firmware/target/arm/audio-pp.c b/firmware/target/arm/audio-pp.c
new file mode 100644
index 0000000000..c08db8a88a
--- /dev/null
+++ b/firmware/target/arm/audio-pp.c
@@ -0,0 +1,84 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2006 by Michael Sevakis
11 *
12 * All files in this archive are subject to the GNU General Public License.
13 * See the file COPYING in the source tree root for full license agreement.
14 *
15 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
16 * KIND, either express or implied.
17 *
18 ****************************************************************************/
19#include "system.h"
20#include "cpu.h"
21#include "audio.h"
22#include "sound.h"
23
24void audio_set_output_source(int source)
25{
26 if ((unsigned)source >= AUDIO_NUM_SOURCES)
27 source = AUDIO_SRC_PLAYBACK;
28} /* audio_set_output_source */
29
30void audio_set_source(int source, unsigned flags)
31{
32 /* Prevent pops from unneeded switching */
33 static int last_source = AUDIO_SRC_PLAYBACK;
34 bool recording = flags & SRCF_RECORDING;
35 static bool last_recording = false;
36
37 switch (source)
38 {
39 default: /* playback - no recording */
40 source = AUDIO_SRC_PLAYBACK;
41 case AUDIO_SRC_PLAYBACK:
42 if (source != last_source)
43 {
44 audiohw_disable_recording();
45 audiohw_set_monitor(false);
46 }
47 break;
48
49 case AUDIO_SRC_MIC: /* recording only */
50 if (source != last_source)
51 {
52 audiohw_enable_recording(true); /* source mic */
53 audiohw_set_monitor(false);
54 }
55 break;
56
57 case AUDIO_SRC_LINEIN: /* recording only */
58 if (source != last_source)
59 {
60 audiohw_enable_recording(false); /* source line */
61 audiohw_set_monitor(false);
62 }
63 break;
64#ifdef CONFIG_TUNER
65 case AUDIO_SRC_FMRADIO: /* recording and playback */
66 if (!recording)
67 audiohw_set_recvol(0, 0, AUDIO_GAIN_LINEIN);
68
69 if (source == last_source && recording == last_recording)
70 break;
71
72 last_recording = recording;
73
74 /* I2S recording and playback */
75 audiohw_enable_recording(false); /* source line */
76 audiohw_set_monitor(!recording);
77 break;
78#endif
79 } /* end switch */
80
81 last_source = source;
82} /* audio_set_source */
83
84