summaryrefslogtreecommitdiff
path: root/firmware/drivers/wm8758.c
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/drivers/wm8758.c')
-rw-r--r--firmware/drivers/wm8758.c72
1 files changed, 51 insertions, 21 deletions
diff --git a/firmware/drivers/wm8758.c b/firmware/drivers/wm8758.c
index 22bef73e45..9732d4f776 100644
--- a/firmware/drivers/wm8758.c
+++ b/firmware/drivers/wm8758.c
@@ -7,7 +7,7 @@
7 * \/ \/ \/ \/ \/ 7 * \/ \/ \/ \/ \/
8 * $Id$ 8 * $Id$
9 * 9 *
10 * Driver for WM8758 audio codec 10 * Driver for WM8758 audio codec - based on datasheet for WM8983
11 * 11 *
12 * Based on code from the ipodlinux project - http://ipodlinux.org/ 12 * Based on code from the ipodlinux project - http://ipodlinux.org/
13 * Adapted for Rockbox in December 2005 13 * Adapted for Rockbox in December 2005
@@ -142,30 +142,11 @@ int audiohw_set_mixer_vol(int channel1, int channel2)
142void audiohw_set_bass(int value) 142void audiohw_set_bass(int value)
143{ 143{
144 (void)value; 144 (void)value;
145#if 0
146 /* Not yet implemented - this is the wm8975 code*/
147 int regvalues[]={11, 10, 10, 9, 8, 8, 0xf , 6, 6, 5, 4, 4, 3, 2, 1, 0};
148
149 if ((value >= -6) && (value <= 9)) {
150 /* We use linear bass control with 130Hz cutoff */
151 wmcodec_write(BASSCTRL, regvalues[value+6]);
152 }
153#endif
154} 145}
155 146
156void audiohw_set_treble(int value) 147void audiohw_set_treble(int value)
157{ 148{
158 (void)value; 149 (void)value;
159#if 0
160 /* Not yet implemented - this is the wm8975 code*/
161 int regvalues[]={11, 10, 10, 9, 8, 8, 0xf , 6, 6, 5, 4, 4, 3, 2, 1, 0};
162
163 if ((value >= -6) && (value <= 9)) {
164 /* We use a 8Khz cutoff */
165 wmcodec_write(TREBCTRL, regvalues[value+6]);
166 }
167#endif
168
169} 150}
170 151
171int audiohw_mute(int mute) 152int audiohw_mute(int mute)
@@ -224,11 +205,60 @@ void audiohw_set_sample_rate(int sampling_control)
224 205
225void audiohw_enable_recording(bool source_mic) 206void audiohw_enable_recording(bool source_mic)
226{ 207{
227 (void)source_mic; 208 (void)source_mic; /* We only have a line-in (I think) */
209
210 /* reset the I2S controller into known state */
211 i2s_reset();
212
213 wmcodec_write(RESET, 0x1ff); /*Reset*/
214
215 wmcodec_write(PWRMGMT1, 0x2b);
216 wmcodec_write(PWRMGMT2, 0x18f); /* Enable ADC - 0x0c enables left/right PGA input, and 0x03 turns on power to the ADCs */
217 wmcodec_write(PWRMGMT3, 0x6f);
218
219 wmcodec_write(AINTFCE, 0x10);
220 wmcodec_write(CLKCTRL, 0x49);
221
222 wmcodec_write(OUTCTRL, 1);
223
224 /* The iPod can handle multiple frequencies, but fix at 44.1KHz
225 for now */
226 wmcodec_set_sample_rate(WM8758_44100HZ);
227
228 wmcodec_write(INCTRL,0x44); /* Connect L2 and R2 inputs */
229
230 /* Set L2/R2_2BOOSTVOL to 0db (bits 4-6) */
231 /* 000 = disabled
232 001 = -12dB
233 010 = -9dB
234 011 = -6dB
235 100 = -3dB
236 101 = 0dB
237 110 = 3dB
238 111 = 6dB
239 */
240 wmcodec_write(LADCBOOST,0x50);
241 wmcodec_write(RADCBOOST,0x50);
242
243 /* Set L/R input PGA Volume to 0db */
244 // wm8758_write(LINPGAVOL,0x3f);
245 // wm8758_write(RINPGAVOL,0x13f);
246
247 /* Enable monitoring */
248 wmcodec_write(LOUTMIX,0x17); /* Enable output mixer - BYPL2LMIX @ 0db*/
249 wmcodec_write(ROUTMIX,0x17); /* Enable output mixer - BYPR2RMIX @ 0db*/
250
251 wmcodec_mute(0);
228} 252}
229 253
230void audiohw_disable_recording(void) { 254void audiohw_disable_recording(void) {
255 wmcodec_mute(1);
256
257 wmcodec_write(PWRMGMT3, 0x0);
231 258
259 wmcodec_write(PWRMGMT1, 0x0);
260
261 wmcodec_write(PWRMGMT2, 0x40);
232} 262}
233 263
234void audiohw_set_recvol(int left, int right, int type) { 264void audiohw_set_recvol(int left, int right, int type) {