Ensure consistency between header file and implementation for iPod drivers, by #inclu...
[kugel-rb.git] / firmware / target / arm / audio-pp.c
blobba52118e0ffebb60323d6c46743b8ffd5f0e2097
1 /***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
10 * Copyright (C) 2006 by Michael Sevakis
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 "system.h"
22 #include "cpu.h"
23 #include "audio.h"
24 #include "sound.h"
26 #if INPUT_SRC_CAPS != 0
27 void audio_set_output_source(int source)
29 if ((unsigned)source >= AUDIO_NUM_SOURCES)
30 source = AUDIO_SRC_PLAYBACK;
31 } /* audio_set_output_source */
33 void audio_input_mux(int source, unsigned flags)
35 (void)flags;
36 /* Prevent pops from unneeded switching */
37 static int last_source = AUDIO_SRC_PLAYBACK;
38 #ifdef HAVE_FMRADIO_REC
39 bool recording = flags & SRCF_RECORDING;
40 static bool last_recording = false;
41 #endif
43 switch (source)
45 default: /* playback - no recording */
46 source = AUDIO_SRC_PLAYBACK;
47 case AUDIO_SRC_PLAYBACK:
48 #ifdef HAVE_RECORDING
49 if (source != last_source)
51 audiohw_set_monitor(false);
52 audiohw_disable_recording();
54 #endif
55 break;
56 #ifdef HAVE_MIC_REC
57 case AUDIO_SRC_MIC: /* recording only */
58 if (source != last_source)
60 audiohw_set_monitor(false);
61 audiohw_enable_recording(true); /* source mic */
63 break;
64 #endif
65 #ifdef HAVE_LINE_REC
66 case AUDIO_SRC_LINEIN: /* recording only */
67 #if defined(IRIVER_H10) || defined(IRIVER_H10_5GB)
68 /* Switch line in source to line-in */
69 GPIO_SET_BITWISE(GPIOB_OUTPUT_VAL, 0x04);
70 #endif
71 if (source != last_source)
73 audiohw_set_monitor(false);
74 audiohw_enable_recording(false); /* source line */
76 break;
77 #endif
78 #ifdef HAVE_FMRADIO_REC
79 case AUDIO_SRC_FMRADIO: /* recording and playback */
80 #if defined(IRIVER_H10) || defined(IRIVER_H10_5GB)
81 /* Switch line in source to tuner */
82 GPIO_CLEAR_BITWISE(GPIOB_OUTPUT_VAL, 0x04);
83 /* Set line-in vol to +12dB, which is proper for H10's */
84 if (!recording)
85 audiohw_set_recvol(0x1f, 0x1f, AUDIO_GAIN_LINEIN);
86 #else /* Set line-in vol to 0dB*/
87 if (!recording)
88 audiohw_set_recvol(0x17, 0x17, AUDIO_GAIN_LINEIN);
89 #endif
90 if (source == last_source && recording == last_recording)
91 break;
93 last_recording = recording;
95 if (recording)
97 audiohw_set_monitor(false); /* disable bypass mode */
98 audiohw_enable_recording(false); /* select line-in source */
100 else
102 audiohw_disable_recording();
103 audiohw_set_monitor(true); /* enable bypass mode */
105 break;
106 #endif
107 } /* end switch */
109 last_source = source;
110 } /* audio_input_mux */
111 #endif /* INPUT_SRC_CAPS != 0 */