diff options
Diffstat (limited to 'firmware/drivers/wm8731l.c')
-rw-r--r-- | firmware/drivers/wm8731l.c | 65 |
1 files changed, 63 insertions, 2 deletions
diff --git a/firmware/drivers/wm8731l.c b/firmware/drivers/wm8731l.c index a690aade48..4f0f249149 100644 --- a/firmware/drivers/wm8731l.c +++ b/firmware/drivers/wm8731l.c | |||
@@ -220,12 +220,73 @@ void audiohw_set_sample_rate(int sampling_control) | |||
220 | 220 | ||
221 | void audiohw_enable_recording(bool source_mic) | 221 | void audiohw_enable_recording(bool source_mic) |
222 | { | 222 | { |
223 | (void)source_mic; | 223 | static int line_level = 0x17; |
224 | static int mic_boost = true; | ||
225 | codec_set_active(0x0); | ||
226 | |||
227 | /* set BCLKINV=0(Dont invert BCLK) MS=1(Enable Master) LRSWAP=0 | ||
228 | * LRP=0 IWL=00(16 bit) FORMAT=10(I2S format) */ | ||
229 | wmcodec_write(AINTFCE, 0x42); | ||
230 | |||
231 | wmcodec_write(LOUTVOL, 0x0); /* headphone mute left */ | ||
232 | wmcodec_write(ROUTVOL, 0x0); /* headphone mute right */ | ||
233 | |||
234 | |||
235 | if(source_mic){ | ||
236 | wmcodec_write(LINVOL, 0x80); /* line in mute left */ | ||
237 | wmcodec_write(RINVOL, 0x80); /* line in mute right */ | ||
238 | |||
239 | |||
240 | if (mic_boost) { | ||
241 | wmcodec_write(AAPCTRL, 0x5); /* INSEL=mic, MIC_BOOST=enable */ | ||
242 | } else { | ||
243 | wmcodec_write(AAPCTRL, 0x4); /* INSEL=mic */ | ||
244 | } | ||
245 | } else { | ||
246 | if (line_level == 0) { | ||
247 | wmcodec_write(LINVOL, 0x80); | ||
248 | wmcodec_write(RINVOL, 0x80); | ||
249 | } else { | ||
250 | wmcodec_write(LINVOL, line_level); | ||
251 | wmcodec_write(RINVOL, line_level); | ||
252 | } | ||
253 | wmcodec_write(AAPCTRL, 0xa); /* BY PASS, mute mic, INSEL=line in */ | ||
254 | } | ||
255 | |||
256 | /* disable ADC high pass filter, mute dac */ | ||
257 | wmcodec_write(DACCTRL, 0x9); | ||
258 | |||
259 | /* power on (PWR_OFF=0) */ | ||
260 | if(source_mic){ | ||
261 | /* CLKOUTPD OSCPD OUTPD DACPD LINEINPD */ | ||
262 | wmcodec_write(PWRMGMT, 0x79); | ||
263 | } else { | ||
264 | wmcodec_write(PWRMGMT, 0x7a); /* MICPD */ | ||
265 | } | ||
266 | |||
267 | codec_set_active(0x1); | ||
224 | } | 268 | } |
225 | 269 | ||
226 | void audiohw_disable_recording(void) | 270 | void audiohw_disable_recording(void) |
227 | { | 271 | { |
228 | 272 | /* set DACMU=1 DEEMPH=0 */ | |
273 | wmcodec_write(DACCTRL, 0x8); | ||
274 | |||
275 | /* ACTIVE=0 */ | ||
276 | codec_set_active(0x0); | ||
277 | |||
278 | /* line in mute left & right*/ | ||
279 | wmcodec_write(LINVOL, 0x80); | ||
280 | wmcodec_write(RINVOL, 0x80); | ||
281 | |||
282 | /* set DACSEL=0, MUTEMIC=1 */ | ||
283 | wmcodec_write(AAPCTRL, 0x2); | ||
284 | |||
285 | /* set POWEROFF=0 OUTPD=0 DACPD=1 */ | ||
286 | wmcodec_write(PWRMGMT, 0x6f); | ||
287 | |||
288 | /* set POWEROFF=1 OUTPD=1 DACPD=1 */ | ||
289 | wmcodec_write(PWRMGMT, 0xff); | ||
229 | } | 290 | } |
230 | 291 | ||
231 | void audiohw_set_recvol(int left, int right, int type) | 292 | void audiohw_set_recvol(int left, int right, int type) |