summaryrefslogtreecommitdiff
path: root/firmware/drivers/wm8975.c
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/drivers/wm8975.c')
-rw-r--r--firmware/drivers/wm8975.c73
1 files changed, 70 insertions, 3 deletions
diff --git a/firmware/drivers/wm8975.c b/firmware/drivers/wm8975.c
index d2b1fa64b2..011d771a13 100644
--- a/firmware/drivers/wm8975.c
+++ b/firmware/drivers/wm8975.c
@@ -224,13 +224,80 @@ void audiohw_set_sample_rate(int sampling_control) {
224 224
225} 225}
226 226
227void audiohw_enable_recording(bool source_mic) { 227void audiohw_enable_recording(bool source_mic)
228{
229 (void)source_mic;
228 230
229 (void)source_mic; 231 /* reset the I2S controller into known state */
230} 232 i2s_reset();
233
234 /*
235 * 1. Switch on power supplies.
236 * By default the WM8750L is in Standby Mode, the DAC is
237 * digitally muted and the Audio Interface, Line outputs
238 * and Headphone outputs are all OFF (DACMU = 1 Power
239 * Management registers 1 and 2 are all zeros).
240 */
241 wmcodec_write(0x0f, 0x1ff);
242 wmcodec_write(0x0f, 0x000);
243
244 /* 2. Enable Vmid and VREF. */
245 wmcodec_write(0x19, 0xc0); /*Pwr Mgmt(1)*/
246
247 /* 3. Enable ADCs as required. */
248 wmcodec_write(0x19, 0xcc); /*Pwr Mgmt(1)*/
249 wmcodec_write(0x1a, 0x180); /*Pwr Mgmt(2)*/
250
251 /* 4. Enable line and / or headphone output buffers as required. */
252 wmcodec_write(0x19, 0xfc); /*Pwr Mgmt(1)*/
253
254 /* BCLKINV=0(Dont invert BCLK) MS=1(Enable Master) LRSWAP=0 LRP=0 */
255 /* IWL=00(16 bit) FORMAT=10(I2S format) */
256 wmcodec_write(0x07, 0x42);
257
258 /* The iPod can handle multiple frequencies, but fix at 44.1KHz for now */
259 wmcodec_set_sample_rate(WM8975_44100HZ);
260
261 /* unmute inputs */
262 wmcodec_write(0x00, 0x17); /* LINVOL (def 0dB) */
263 wmcodec_write(0x01, 0x117); /* RINVOL (def 0dB) */
264
265 wmcodec_write(0x15, 0x1d7); /* LADCVOL max vol x was ff */
266 wmcodec_write(0x16, 0x1d7); /* RADCVOL max vol x was ff */
267
268 if (source_mic) {
269 /* VSEL=10(def) DATSEL=10 (use right ADC only) */
270 wmcodec_write(0x17, 0xc8); /* Additional control(1) */
231 271
272 /* VROI=1 (sets output resistance to 40kohms) */
273 wmcodec_write(0x1b, 0x40); /* Additional control(3) */
274
275 /* LINSEL=1 (LINPUT2) LMICBOOST=10 (20dB boost) */
276 wmcodec_write(0x20, 0x60); /* ADCL signal path */
277 wmcodec_write(0x21, 0x60); /* ADCR signal path */
278 } else {
279 /* VSEL=10(def) DATSEL=00 (left->left, right->right) */
280 wmcodec_write(0x17, 0xc0); /* Additional control(1) */
281
282 /* VROI=1 (sets output resistance to 40kohms) */
283 wmcodec_write(0x1b, 0x40); /* Additional control(3) */
284
285 /* LINSEL=0 (LINPUT1) LMICBOOST=00 (bypass boost) */
286 wmcodec_write(0x20, 0x00); /* ADCL signal path */
287 /* RINSEL=0 (RINPUT1) RMICBOOST=00 (bypass boost) */
288 wmcodec_write(0x21, 0x00); /* ADCR signal path */
289 }
290}
291
232void audiohw_disable_recording(void) { 292void audiohw_disable_recording(void) {
293 /* 1. Set DACMU = 1 to soft-mute the audio DACs. */
294 wmcodec_write(0x05, 0x8);
233 295
296 /* 2. Disable all output buffers. */
297 wmcodec_write(0x1a, 0x0); /*Pwr Mgmt(2)*/
298
299 /* 3. Switch off the power supplies. */
300 wmcodec_write(0x19, 0x0); /*Pwr Mgmt(1)*/
234} 301}
235 302
236void audiohw_set_recvol(int left, int right, int type) { 303void audiohw_set_recvol(int left, int right, int type) {