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;
45 default: /* playback - no recording */
46 source
= AUDIO_SRC_PLAYBACK
;
47 case AUDIO_SRC_PLAYBACK
:
49 if (source
!= last_source
)
51 audiohw_set_monitor(false);
52 audiohw_disable_recording();
57 case AUDIO_SRC_MIC
: /* recording only */
58 if (source
!= last_source
)
60 audiohw_set_monitor(false);
61 audiohw_enable_recording(true); /* source mic */
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);
71 if (source
!= last_source
)
73 audiohw_set_monitor(false);
74 audiohw_enable_recording(false); /* source line */
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 */
85 audiohw_set_recvol(0x1f, 0x1f, AUDIO_GAIN_LINEIN
);
86 #else /* Set line-in vol to 0dB*/
88 audiohw_set_recvol(0x17, 0x17, AUDIO_GAIN_LINEIN
);
90 if (source
== last_source
&& recording
== last_recording
)
93 last_recording
= recording
;
97 audiohw_set_monitor(false); /* disable bypass mode */
98 audiohw_enable_recording(false); /* select line-in source */
102 audiohw_disable_recording();
103 audiohw_set_monitor(true); /* enable bypass mode */
109 last_source
= source
;
110 } /* audio_input_mux */
111 #endif /* INPUT_SRC_CAPS != 0 */