Trim down peak calculation a bit.
[kugel-rb.git] / firmware / target / arm / as3525 / audio-as3525.c
blobc56024f2b5e64b6c6140c00fe76952d569e0581b
1 /***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
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 ****************************************************************************/
21 #include "config.h"
22 #include "system.h"
23 #include "cpu.h"
24 #include "audio.h"
25 #include "audiohw.h"
26 #include "sound.h"
28 void audio_set_output_source(int source)
30 (void)source;
33 void audio_input_mux(int source, unsigned flags)
35 static int last_source = AUDIO_SRC_PLAYBACK;
36 #if defined(HAVE_RECORDING) && (INPUT_SRC_CAPS & SRC_CAP_FMRADIO)
37 static bool last_recording = false;
38 const bool recording = flags & SRCF_RECORDING;
39 #else
40 (void) flags;
41 #endif
43 switch (source)
45 default: /* playback - no recording */
46 source = AUDIO_SRC_PLAYBACK;
47 case AUDIO_SRC_PLAYBACK:
48 if (source != last_source)
50 #if defined(HAVE_RECORDING) || defined(HAVE_FMRADIO_IN)
51 audiohw_set_monitor(false);
52 #endif
53 #ifdef HAVE_RECORDING
54 audiohw_disable_recording();
55 #endif
57 break;
59 #if defined(HAVE_RECORDING) && (INPUT_SRC_CAPS & SRC_CAP_MIC)
60 case AUDIO_SRC_MIC: /* recording only */
61 if (source != last_source)
63 audiohw_set_monitor(false);
64 audiohw_enable_recording(true); /* source mic */
66 break;
67 #endif
69 #if (INPUT_SRC_CAPS & SRC_CAP_FMRADIO)
71 case AUDIO_SRC_FMRADIO: /* recording and playback */
72 if (source == last_source
73 #ifdef HAVE_RECORDING
74 && recording == last_recording
75 #endif
77 break;
79 #ifdef HAVE_RECORDING
80 last_recording = recording;
82 if (recording)
84 audiohw_set_monitor(false);
85 audiohw_enable_recording(false);
87 else
88 #endif
90 #ifdef HAVE_RECORDING
91 audiohw_disable_recording();
92 #endif
93 #if defined(HAVE_RECORDING) || defined(HAVE_FMRADIO_IN)
94 audiohw_set_monitor(true); /* line 2 analog audio path */
95 #endif
97 break;
98 #endif /* (INPUT_SRC_CAPS & SRC_CAP_FMRADIO) */
101 last_source = source;