Sansa AMS: The internal SD does not use the IDE AHB interface so remove references...
[kugel-rb.git] / firmware / target / arm / audio-pp.c
blob6b5b082cc78f4b7c1bf0473e7526695e0552a6e9
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 #if defined(IPOD_COLOR) || defined (IPOD_4G)
44 /* The usual magic from IPL - I'm guessing this configures the headphone
45 socket to be input or output. */
46 if ((flags & SRCF_RECORDING) && source != AUDIO_SRC_PLAYBACK)
48 /* input */
49 GPIO_CLEAR_BITWISE(GPIOI_OUTPUT_VAL, 0x40);
50 GPIO_CLEAR_BITWISE(GPIOA_OUTPUT_VAL, 0x04);
52 else
54 /* output */
55 GPIO_SET_BITWISE(GPIOI_OUTPUT_VAL, 0x40);
56 GPIO_SET_BITWISE(GPIOA_OUTPUT_VAL, 0x04);
58 #endif /* IPOD_COLOR || IPOD_4G */
60 switch (source)
62 default: /* playback - no recording */
63 source = AUDIO_SRC_PLAYBACK;
64 case AUDIO_SRC_PLAYBACK:
65 #ifdef HAVE_RECORDING
66 if (source != last_source)
68 audiohw_set_monitor(false);
69 audiohw_disable_recording();
71 #endif
72 break;
73 #ifdef HAVE_MIC_REC
74 case AUDIO_SRC_MIC: /* recording only */
75 if (source != last_source)
77 audiohw_set_monitor(false);
78 audiohw_enable_recording(true); /* source mic */
80 break;
81 #endif
82 #ifdef HAVE_LINE_REC
83 case AUDIO_SRC_LINEIN: /* recording only */
84 #if defined(IRIVER_H10) || defined(IRIVER_H10_5GB)
85 /* Switch line in source to line-in */
86 GPIO_SET_BITWISE(GPIOB_OUTPUT_VAL, 0x04);
87 #endif
88 if (source != last_source)
90 audiohw_set_monitor(false);
91 audiohw_enable_recording(false); /* source line */
93 break;
94 #endif
95 #ifdef HAVE_FMRADIO_REC
96 case AUDIO_SRC_FMRADIO: /* recording and playback */
97 #if defined(IRIVER_H10) || defined(IRIVER_H10_5GB)
98 /* Switch line in source to tuner */
99 GPIO_CLEAR_BITWISE(GPIOB_OUTPUT_VAL, 0x04);
100 /* Set line-in vol to +12dB, which is proper for H10's */
101 if (!recording)
102 audiohw_set_recvol(0x1f, 0x1f, AUDIO_GAIN_LINEIN);
103 #else /* Set line-in vol to 0dB*/
104 if (!recording)
105 audiohw_set_recvol(0x17, 0x17, AUDIO_GAIN_LINEIN);
106 #endif
108 if (source == last_source && recording == last_recording)
109 break;
111 last_recording = recording;
113 #if CONFIG_TUNER & IPOD_REMOTE_TUNER
114 /* Ipod FM tuner is in the remote connected to line-in */
115 audiohw_enable_recording(false); /* source line */
116 audiohw_set_monitor(true); /* enable bypass mode */
117 #else
118 if (recording)
120 audiohw_set_monitor(false); /* disable bypass mode */
121 audiohw_enable_recording(false); /* select line-in source */
123 else
125 audiohw_disable_recording();
126 audiohw_set_monitor(true); /* enable bypass mode */
128 #endif
129 break;
130 #endif
131 } /* end switch */
133 last_source = source;
134 } /* audio_input_mux */
135 #endif /* INPUT_SRC_CAPS != 0 */