as3525v1: duplicate the right channel into the left channel when recording microphone
[kugel-rb.git] / firmware / target / arm / as3525 / audio-as3525.c
blob570ff1491c1a281a0953430578f973bf696e0928
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 int audio_channels = 2;
30 void audio_set_output_source(int source)
32 (void)source;
35 void audio_input_mux(int source, unsigned flags)
37 static int last_source = AUDIO_SRC_PLAYBACK;
38 #if defined(HAVE_RECORDING) && (INPUT_SRC_CAPS & SRC_CAP_FMRADIO)
39 static bool last_recording = false;
40 const bool recording = flags & SRCF_RECORDING;
41 #else
42 (void) flags;
43 #endif
45 switch (source)
47 default: /* playback - no recording */
48 source = AUDIO_SRC_PLAYBACK;
49 case AUDIO_SRC_PLAYBACK:
50 if (source != last_source)
52 audio_channels = 2;
53 #if defined(HAVE_RECORDING) || defined(HAVE_FMRADIO_IN)
54 audiohw_set_monitor(false);
55 #endif
56 #ifdef HAVE_RECORDING
57 audiohw_disable_recording();
58 #endif
60 break;
62 #if defined(HAVE_RECORDING) && (INPUT_SRC_CAPS & SRC_CAP_MIC)
63 case AUDIO_SRC_MIC: /* recording only */
64 if (source != last_source)
66 audio_channels = 1;
67 audiohw_set_monitor(false);
68 audiohw_enable_recording(true); /* source mic */
70 break;
71 #endif
73 #if (INPUT_SRC_CAPS & SRC_CAP_FMRADIO)
75 case AUDIO_SRC_FMRADIO: /* recording and playback */
76 if (source == last_source
77 #ifdef HAVE_RECORDING
78 && recording == last_recording
79 #endif
81 break;
83 audio_channels = 2;
84 #ifdef HAVE_RECORDING
85 last_recording = recording;
87 if (recording)
89 audiohw_set_monitor(false);
90 audiohw_enable_recording(false);
92 else
93 #endif
95 #ifdef HAVE_RECORDING
96 audiohw_disable_recording();
97 #endif
98 #if defined(HAVE_RECORDING) || defined(HAVE_FMRADIO_IN)
99 audiohw_set_monitor(true); /* line 2 analog audio path */
100 #endif
102 break;
103 #endif /* (INPUT_SRC_CAPS & SRC_CAP_FMRADIO) */
106 last_source = source;