diff options
Diffstat (limited to 'firmware/target/arm/pp/audio-pp.c')
-rw-r--r-- | firmware/target/arm/pp/audio-pp.c | 135 |
1 files changed, 135 insertions, 0 deletions
diff --git a/firmware/target/arm/pp/audio-pp.c b/firmware/target/arm/pp/audio-pp.c new file mode 100644 index 0000000000..6b5b082cc7 --- /dev/null +++ b/firmware/target/arm/pp/audio-pp.c | |||
@@ -0,0 +1,135 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2006 by Michael Sevakis | ||
11 | * | ||
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. | ||
16 | * | ||
17 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
18 | * KIND, either express or implied. | ||
19 | * | ||
20 | ****************************************************************************/ | ||
21 | #include "system.h" | ||
22 | #include "cpu.h" | ||
23 | #include "audio.h" | ||
24 | #include "sound.h" | ||
25 | |||
26 | #if INPUT_SRC_CAPS != 0 | ||
27 | void audio_set_output_source(int source) | ||
28 | { | ||
29 | if ((unsigned)source >= AUDIO_NUM_SOURCES) | ||
30 | source = AUDIO_SRC_PLAYBACK; | ||
31 | } /* audio_set_output_source */ | ||
32 | |||
33 | void audio_input_mux(int source, unsigned flags) | ||
34 | { | ||
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 | ||
42 | |||
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) | ||
47 | { | ||
48 | /* input */ | ||
49 | GPIO_CLEAR_BITWISE(GPIOI_OUTPUT_VAL, 0x40); | ||
50 | GPIO_CLEAR_BITWISE(GPIOA_OUTPUT_VAL, 0x04); | ||
51 | } | ||
52 | else | ||
53 | { | ||
54 | /* output */ | ||
55 | GPIO_SET_BITWISE(GPIOI_OUTPUT_VAL, 0x40); | ||
56 | GPIO_SET_BITWISE(GPIOA_OUTPUT_VAL, 0x04); | ||
57 | } | ||
58 | #endif /* IPOD_COLOR || IPOD_4G */ | ||
59 | |||
60 | switch (source) | ||
61 | { | ||
62 | default: /* playback - no recording */ | ||
63 | source = AUDIO_SRC_PLAYBACK; | ||
64 | case AUDIO_SRC_PLAYBACK: | ||
65 | #ifdef HAVE_RECORDING | ||
66 | if (source != last_source) | ||
67 | { | ||
68 | audiohw_set_monitor(false); | ||
69 | audiohw_disable_recording(); | ||
70 | } | ||
71 | #endif | ||
72 | break; | ||
73 | #ifdef HAVE_MIC_REC | ||
74 | case AUDIO_SRC_MIC: /* recording only */ | ||
75 | if (source != last_source) | ||
76 | { | ||
77 | audiohw_set_monitor(false); | ||
78 | audiohw_enable_recording(true); /* source mic */ | ||
79 | } | ||
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) | ||
89 | { | ||
90 | audiohw_set_monitor(false); | ||
91 | audiohw_enable_recording(false); /* source line */ | ||
92 | } | ||
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 | ||
107 | |||
108 | if (source == last_source && recording == last_recording) | ||
109 | break; | ||
110 | |||
111 | last_recording = recording; | ||
112 | |||
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) | ||
119 | { | ||
120 | audiohw_set_monitor(false); /* disable bypass mode */ | ||
121 | audiohw_enable_recording(false); /* select line-in source */ | ||
122 | } | ||
123 | else | ||
124 | { | ||
125 | audiohw_disable_recording(); | ||
126 | audiohw_set_monitor(true); /* enable bypass mode */ | ||
127 | } | ||
128 | #endif | ||
129 | break; | ||
130 | #endif | ||
131 | } /* end switch */ | ||
132 | |||
133 | last_source = source; | ||
134 | } /* audio_input_mux */ | ||
135 | #endif /* INPUT_SRC_CAPS != 0 */ | ||