1 /***************************************************************************
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
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 ****************************************************************************/
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
)
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;
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
)
49 GPIO_CLEAR_BITWISE(GPIOI_OUTPUT_VAL
, 0x40);
50 GPIO_CLEAR_BITWISE(GPIOA_OUTPUT_VAL
, 0x04);
55 GPIO_SET_BITWISE(GPIOI_OUTPUT_VAL
, 0x40);
56 GPIO_SET_BITWISE(GPIOA_OUTPUT_VAL
, 0x04);
58 #endif /* IPOD_COLOR || IPOD_4G */
62 default: /* playback - no recording */
63 source
= AUDIO_SRC_PLAYBACK
;
64 case AUDIO_SRC_PLAYBACK
:
66 if (source
!= last_source
)
68 audiohw_set_monitor(false);
69 audiohw_disable_recording();
74 case AUDIO_SRC_MIC
: /* recording only */
75 if (source
!= last_source
)
77 audiohw_set_monitor(false);
78 audiohw_enable_recording(true); /* source mic */
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);
88 if (source
!= last_source
)
90 audiohw_set_monitor(false);
91 audiohw_enable_recording(false); /* source line */
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 */
102 audiohw_set_recvol(0x1f, 0x1f, AUDIO_GAIN_LINEIN
);
103 #else /* Set line-in vol to 0dB*/
105 audiohw_set_recvol(0x17, 0x17, AUDIO_GAIN_LINEIN
);
108 if (source
== last_source
&& recording
== last_recording
)
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 */
120 audiohw_set_monitor(false); /* disable bypass mode */
121 audiohw_enable_recording(false); /* select line-in source */
125 audiohw_disable_recording();
126 audiohw_set_monitor(true); /* enable bypass mode */
133 last_source
= source
;
134 } /* audio_input_mux */
135 #endif /* INPUT_SRC_CAPS != 0 */