diff options
Diffstat (limited to 'sound/soc/codecs/twl4030.c')
-rw-r--r-- | sound/soc/codecs/twl4030.c | 417 |
1 files changed, 206 insertions, 211 deletions
diff --git a/sound/soc/codecs/twl4030.c b/sound/soc/codecs/twl4030.c index 51848880504..ea370a4f86d 100644 --- a/sound/soc/codecs/twl4030.c +++ b/sound/soc/codecs/twl4030.c | |||
@@ -192,39 +192,51 @@ static void twl4030_init_chip(struct snd_soc_codec *codec) | |||
192 | 192 | ||
193 | /* Earpiece */ | 193 | /* Earpiece */ |
194 | static const char *twl4030_earpiece_texts[] = | 194 | static const char *twl4030_earpiece_texts[] = |
195 | {"Off", "DACL1", "DACL2", "Invalid", "DACR1"}; | 195 | {"Off", "DACL1", "DACL2", "DACR1"}; |
196 | |||
197 | static const unsigned int twl4030_earpiece_values[] = | ||
198 | {0x0, 0x1, 0x2, 0x4}; | ||
196 | 199 | ||
197 | static const struct soc_enum twl4030_earpiece_enum = | 200 | static const struct soc_enum twl4030_earpiece_enum = |
198 | SOC_ENUM_SINGLE(TWL4030_REG_EAR_CTL, 1, | 201 | SOC_VALUE_ENUM_SINGLE(TWL4030_REG_EAR_CTL, 1, 0x7, |
199 | ARRAY_SIZE(twl4030_earpiece_texts), | 202 | ARRAY_SIZE(twl4030_earpiece_texts), |
200 | twl4030_earpiece_texts); | 203 | twl4030_earpiece_texts, |
204 | twl4030_earpiece_values); | ||
201 | 205 | ||
202 | static const struct snd_kcontrol_new twl4030_dapm_earpiece_control = | 206 | static const struct snd_kcontrol_new twl4030_dapm_earpiece_control = |
203 | SOC_DAPM_ENUM("Route", twl4030_earpiece_enum); | 207 | SOC_DAPM_VALUE_ENUM("Route", twl4030_earpiece_enum); |
204 | 208 | ||
205 | /* PreDrive Left */ | 209 | /* PreDrive Left */ |
206 | static const char *twl4030_predrivel_texts[] = | 210 | static const char *twl4030_predrivel_texts[] = |
207 | {"Off", "DACL1", "DACL2", "Invalid", "DACR2"}; | 211 | {"Off", "DACL1", "DACL2", "DACR2"}; |
212 | |||
213 | static const unsigned int twl4030_predrivel_values[] = | ||
214 | {0x0, 0x1, 0x2, 0x4}; | ||
208 | 215 | ||
209 | static const struct soc_enum twl4030_predrivel_enum = | 216 | static const struct soc_enum twl4030_predrivel_enum = |
210 | SOC_ENUM_SINGLE(TWL4030_REG_PREDL_CTL, 1, | 217 | SOC_VALUE_ENUM_SINGLE(TWL4030_REG_PREDL_CTL, 1, 0x7, |
211 | ARRAY_SIZE(twl4030_predrivel_texts), | 218 | ARRAY_SIZE(twl4030_predrivel_texts), |
212 | twl4030_predrivel_texts); | 219 | twl4030_predrivel_texts, |
220 | twl4030_predrivel_values); | ||
213 | 221 | ||
214 | static const struct snd_kcontrol_new twl4030_dapm_predrivel_control = | 222 | static const struct snd_kcontrol_new twl4030_dapm_predrivel_control = |
215 | SOC_DAPM_ENUM("Route", twl4030_predrivel_enum); | 223 | SOC_DAPM_VALUE_ENUM("Route", twl4030_predrivel_enum); |
216 | 224 | ||
217 | /* PreDrive Right */ | 225 | /* PreDrive Right */ |
218 | static const char *twl4030_predriver_texts[] = | 226 | static const char *twl4030_predriver_texts[] = |
219 | {"Off", "DACR1", "DACR2", "Invalid", "DACL2"}; | 227 | {"Off", "DACR1", "DACR2", "DACL2"}; |
228 | |||
229 | static const unsigned int twl4030_predriver_values[] = | ||
230 | {0x0, 0x1, 0x2, 0x4}; | ||
220 | 231 | ||
221 | static const struct soc_enum twl4030_predriver_enum = | 232 | static const struct soc_enum twl4030_predriver_enum = |
222 | SOC_ENUM_SINGLE(TWL4030_REG_PREDR_CTL, 1, | 233 | SOC_VALUE_ENUM_SINGLE(TWL4030_REG_PREDR_CTL, 1, 0x7, |
223 | ARRAY_SIZE(twl4030_predriver_texts), | 234 | ARRAY_SIZE(twl4030_predriver_texts), |
224 | twl4030_predriver_texts); | 235 | twl4030_predriver_texts, |
236 | twl4030_predriver_values); | ||
225 | 237 | ||
226 | static const struct snd_kcontrol_new twl4030_dapm_predriver_control = | 238 | static const struct snd_kcontrol_new twl4030_dapm_predriver_control = |
227 | SOC_DAPM_ENUM("Route", twl4030_predriver_enum); | 239 | SOC_DAPM_VALUE_ENUM("Route", twl4030_predriver_enum); |
228 | 240 | ||
229 | /* Headset Left */ | 241 | /* Headset Left */ |
230 | static const char *twl4030_hsol_texts[] = | 242 | static const char *twl4030_hsol_texts[] = |
@@ -298,28 +310,90 @@ static const struct soc_enum twl4030_handsfreer_enum = | |||
298 | static const struct snd_kcontrol_new twl4030_dapm_handsfreer_control = | 310 | static const struct snd_kcontrol_new twl4030_dapm_handsfreer_control = |
299 | SOC_DAPM_ENUM("Route", twl4030_handsfreer_enum); | 311 | SOC_DAPM_ENUM("Route", twl4030_handsfreer_enum); |
300 | 312 | ||
301 | static int outmixer_event(struct snd_soc_dapm_widget *w, | 313 | /* Left analog microphone selection */ |
314 | static const char *twl4030_analoglmic_texts[] = | ||
315 | {"Off", "Main mic", "Headset mic", "AUXL", "Carkit mic"}; | ||
316 | |||
317 | static const unsigned int twl4030_analoglmic_values[] = | ||
318 | {0x0, 0x1, 0x2, 0x4, 0x8}; | ||
319 | |||
320 | static const struct soc_enum twl4030_analoglmic_enum = | ||
321 | SOC_VALUE_ENUM_SINGLE(TWL4030_REG_ANAMICL, 0, 0xf, | ||
322 | ARRAY_SIZE(twl4030_analoglmic_texts), | ||
323 | twl4030_analoglmic_texts, | ||
324 | twl4030_analoglmic_values); | ||
325 | |||
326 | static const struct snd_kcontrol_new twl4030_dapm_analoglmic_control = | ||
327 | SOC_DAPM_VALUE_ENUM("Route", twl4030_analoglmic_enum); | ||
328 | |||
329 | /* Right analog microphone selection */ | ||
330 | static const char *twl4030_analogrmic_texts[] = | ||
331 | {"Off", "Sub mic", "AUXR"}; | ||
332 | |||
333 | static const unsigned int twl4030_analogrmic_values[] = | ||
334 | {0x0, 0x1, 0x4}; | ||
335 | |||
336 | static const struct soc_enum twl4030_analogrmic_enum = | ||
337 | SOC_VALUE_ENUM_SINGLE(TWL4030_REG_ANAMICR, 0, 0x5, | ||
338 | ARRAY_SIZE(twl4030_analogrmic_texts), | ||
339 | twl4030_analogrmic_texts, | ||
340 | twl4030_analogrmic_values); | ||
341 | |||
342 | static const struct snd_kcontrol_new twl4030_dapm_analogrmic_control = | ||
343 | SOC_DAPM_VALUE_ENUM("Route", twl4030_analogrmic_enum); | ||
344 | |||
345 | /* TX1 L/R Analog/Digital microphone selection */ | ||
346 | static const char *twl4030_micpathtx1_texts[] = | ||
347 | {"Analog", "Digimic0"}; | ||
348 | |||
349 | static const struct soc_enum twl4030_micpathtx1_enum = | ||
350 | SOC_ENUM_SINGLE(TWL4030_REG_ADCMICSEL, 0, | ||
351 | ARRAY_SIZE(twl4030_micpathtx1_texts), | ||
352 | twl4030_micpathtx1_texts); | ||
353 | |||
354 | static const struct snd_kcontrol_new twl4030_dapm_micpathtx1_control = | ||
355 | SOC_DAPM_ENUM("Route", twl4030_micpathtx1_enum); | ||
356 | |||
357 | /* TX2 L/R Analog/Digital microphone selection */ | ||
358 | static const char *twl4030_micpathtx2_texts[] = | ||
359 | {"Analog", "Digimic1"}; | ||
360 | |||
361 | static const struct soc_enum twl4030_micpathtx2_enum = | ||
362 | SOC_ENUM_SINGLE(TWL4030_REG_ADCMICSEL, 2, | ||
363 | ARRAY_SIZE(twl4030_micpathtx2_texts), | ||
364 | twl4030_micpathtx2_texts); | ||
365 | |||
366 | static const struct snd_kcontrol_new twl4030_dapm_micpathtx2_control = | ||
367 | SOC_DAPM_ENUM("Route", twl4030_micpathtx2_enum); | ||
368 | |||
369 | static int micpath_event(struct snd_soc_dapm_widget *w, | ||
302 | struct snd_kcontrol *kcontrol, int event) | 370 | struct snd_kcontrol *kcontrol, int event) |
303 | { | 371 | { |
304 | struct soc_enum *e = (struct soc_enum *)kcontrol->private_value; | 372 | struct soc_enum *e = (struct soc_enum *)w->kcontrols->private_value; |
305 | int ret = 0; | 373 | unsigned char adcmicsel, micbias_ctl; |
306 | int val; | 374 | |
307 | 375 | adcmicsel = twl4030_read_reg_cache(w->codec, TWL4030_REG_ADCMICSEL); | |
308 | switch (e->reg) { | 376 | micbias_ctl = twl4030_read_reg_cache(w->codec, TWL4030_REG_MICBIAS_CTL); |
309 | case TWL4030_REG_PREDL_CTL: | 377 | /* Prepare the bits for the given TX path: |
310 | case TWL4030_REG_PREDR_CTL: | 378 | * shift_l == 0: TX1 microphone path |
311 | case TWL4030_REG_EAR_CTL: | 379 | * shift_l == 2: TX2 microphone path */ |
312 | val = w->value >> e->shift_l; | 380 | if (e->shift_l) { |
313 | if (val == 3) { | 381 | /* TX2 microphone path */ |
314 | printk(KERN_WARNING | 382 | if (adcmicsel & TWL4030_TX2IN_SEL) |
315 | "Invalid MUX setting for register 0x%02x (%d)\n", | 383 | micbias_ctl |= TWL4030_MICBIAS2_CTL; /* digimic */ |
316 | e->reg, val); | 384 | else |
317 | ret = -1; | 385 | micbias_ctl &= ~TWL4030_MICBIAS2_CTL; |
318 | } | 386 | } else { |
319 | break; | 387 | /* TX1 microphone path */ |
388 | if (adcmicsel & TWL4030_TX1IN_SEL) | ||
389 | micbias_ctl |= TWL4030_MICBIAS1_CTL; /* digimic */ | ||
390 | else | ||
391 | micbias_ctl &= ~TWL4030_MICBIAS1_CTL; | ||
320 | } | 392 | } |
321 | 393 | ||
322 | return ret; | 394 | twl4030_write(w->codec, TWL4030_REG_MICBIAS_CTL, micbias_ctl); |
395 | |||
396 | return 0; | ||
323 | } | 397 | } |
324 | 398 | ||
325 | static int handsfree_event(struct snd_soc_dapm_widget *w, | 399 | static int handsfree_event(struct snd_soc_dapm_widget *w, |
@@ -503,162 +577,6 @@ static int snd_soc_put_volsw_r2_twl4030(struct snd_kcontrol *kcontrol, | |||
503 | return err; | 577 | return err; |
504 | } | 578 | } |
505 | 579 | ||
506 | static int twl4030_get_left_input(struct snd_kcontrol *kcontrol, | ||
507 | struct snd_ctl_elem_value *ucontrol) | ||
508 | { | ||
509 | struct snd_soc_codec *codec = kcontrol->private_data; | ||
510 | u8 reg = twl4030_read_reg_cache(codec, TWL4030_REG_ANAMICL); | ||
511 | int result = 0; | ||
512 | |||
513 | /* one bit must be set a time */ | ||
514 | reg &= TWL4030_CKMIC_EN | TWL4030_AUXL_EN | TWL4030_HSMIC_EN | ||
515 | | TWL4030_MAINMIC_EN; | ||
516 | if (reg != 0) { | ||
517 | result++; | ||
518 | while ((reg & 1) == 0) { | ||
519 | result++; | ||
520 | reg >>= 1; | ||
521 | } | ||
522 | } | ||
523 | |||
524 | ucontrol->value.integer.value[0] = result; | ||
525 | return 0; | ||
526 | } | ||
527 | |||
528 | static int twl4030_put_left_input(struct snd_kcontrol *kcontrol, | ||
529 | struct snd_ctl_elem_value *ucontrol) | ||
530 | { | ||
531 | struct snd_soc_codec *codec = kcontrol->private_data; | ||
532 | int value = ucontrol->value.integer.value[0]; | ||
533 | u8 anamicl, micbias, avadc_ctl; | ||
534 | |||
535 | anamicl = twl4030_read_reg_cache(codec, TWL4030_REG_ANAMICL); | ||
536 | anamicl &= ~(TWL4030_CKMIC_EN | TWL4030_AUXL_EN | TWL4030_HSMIC_EN | ||
537 | | TWL4030_MAINMIC_EN); | ||
538 | micbias = twl4030_read_reg_cache(codec, TWL4030_REG_MICBIAS_CTL); | ||
539 | micbias &= ~(TWL4030_HSMICBIAS_EN | TWL4030_MICBIAS1_EN); | ||
540 | avadc_ctl = twl4030_read_reg_cache(codec, TWL4030_REG_AVADC_CTL); | ||
541 | |||
542 | switch (value) { | ||
543 | case 1: | ||
544 | anamicl |= TWL4030_MAINMIC_EN; | ||
545 | micbias |= TWL4030_MICBIAS1_EN; | ||
546 | break; | ||
547 | case 2: | ||
548 | anamicl |= TWL4030_HSMIC_EN; | ||
549 | micbias |= TWL4030_HSMICBIAS_EN; | ||
550 | break; | ||
551 | case 3: | ||
552 | anamicl |= TWL4030_AUXL_EN; | ||
553 | break; | ||
554 | case 4: | ||
555 | anamicl |= TWL4030_CKMIC_EN; | ||
556 | break; | ||
557 | default: | ||
558 | break; | ||
559 | } | ||
560 | |||
561 | /* If some input is selected, enable amp and ADC */ | ||
562 | if (value != 0) { | ||
563 | anamicl |= TWL4030_MICAMPL_EN; | ||
564 | avadc_ctl |= TWL4030_ADCL_EN; | ||
565 | } else { | ||
566 | anamicl &= ~TWL4030_MICAMPL_EN; | ||
567 | avadc_ctl &= ~TWL4030_ADCL_EN; | ||
568 | } | ||
569 | |||
570 | twl4030_write(codec, TWL4030_REG_ANAMICL, anamicl); | ||
571 | twl4030_write(codec, TWL4030_REG_MICBIAS_CTL, micbias); | ||
572 | twl4030_write(codec, TWL4030_REG_AVADC_CTL, avadc_ctl); | ||
573 | |||
574 | return 1; | ||
575 | } | ||
576 | |||
577 | static int twl4030_get_right_input(struct snd_kcontrol *kcontrol, | ||
578 | struct snd_ctl_elem_value *ucontrol) | ||
579 | { | ||
580 | struct snd_soc_codec *codec = kcontrol->private_data; | ||
581 | u8 reg = twl4030_read_reg_cache(codec, TWL4030_REG_ANAMICR); | ||
582 | int value = 0; | ||
583 | |||
584 | reg &= TWL4030_SUBMIC_EN|TWL4030_AUXR_EN; | ||
585 | switch (reg) { | ||
586 | case TWL4030_SUBMIC_EN: | ||
587 | value = 1; | ||
588 | break; | ||
589 | case TWL4030_AUXR_EN: | ||
590 | value = 2; | ||
591 | break; | ||
592 | default: | ||
593 | break; | ||
594 | } | ||
595 | |||
596 | ucontrol->value.integer.value[0] = value; | ||
597 | return 0; | ||
598 | } | ||
599 | |||
600 | static int twl4030_put_right_input(struct snd_kcontrol *kcontrol, | ||
601 | struct snd_ctl_elem_value *ucontrol) | ||
602 | { | ||
603 | struct snd_soc_codec *codec = kcontrol->private_data; | ||
604 | int value = ucontrol->value.integer.value[0]; | ||
605 | u8 anamicr, micbias, avadc_ctl; | ||
606 | |||
607 | anamicr = twl4030_read_reg_cache(codec, TWL4030_REG_ANAMICR); | ||
608 | anamicr &= ~(TWL4030_SUBMIC_EN|TWL4030_AUXR_EN); | ||
609 | micbias = twl4030_read_reg_cache(codec, TWL4030_REG_MICBIAS_CTL); | ||
610 | micbias &= ~TWL4030_MICBIAS2_EN; | ||
611 | avadc_ctl = twl4030_read_reg_cache(codec, TWL4030_REG_AVADC_CTL); | ||
612 | |||
613 | switch (value) { | ||
614 | case 1: | ||
615 | anamicr |= TWL4030_SUBMIC_EN; | ||
616 | micbias |= TWL4030_MICBIAS2_EN; | ||
617 | break; | ||
618 | case 2: | ||
619 | anamicr |= TWL4030_AUXR_EN; | ||
620 | break; | ||
621 | default: | ||
622 | break; | ||
623 | } | ||
624 | |||
625 | if (value != 0) { | ||
626 | anamicr |= TWL4030_MICAMPR_EN; | ||
627 | avadc_ctl |= TWL4030_ADCR_EN; | ||
628 | } else { | ||
629 | anamicr &= ~TWL4030_MICAMPR_EN; | ||
630 | avadc_ctl &= ~TWL4030_ADCR_EN; | ||
631 | } | ||
632 | |||
633 | twl4030_write(codec, TWL4030_REG_ANAMICR, anamicr); | ||
634 | twl4030_write(codec, TWL4030_REG_MICBIAS_CTL, micbias); | ||
635 | twl4030_write(codec, TWL4030_REG_AVADC_CTL, avadc_ctl); | ||
636 | |||
637 | return 1; | ||
638 | } | ||
639 | |||
640 | static const char *twl4030_left_in_sel[] = { | ||
641 | "None", | ||
642 | "Main Mic", | ||
643 | "Headset Mic", | ||
644 | "Line In", | ||
645 | "Carkit Mic", | ||
646 | }; | ||
647 | |||
648 | static const char *twl4030_right_in_sel[] = { | ||
649 | "None", | ||
650 | "Sub Mic", | ||
651 | "Line In", | ||
652 | }; | ||
653 | |||
654 | static const struct soc_enum twl4030_left_input_mux = | ||
655 | SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(twl4030_left_in_sel), | ||
656 | twl4030_left_in_sel); | ||
657 | |||
658 | static const struct soc_enum twl4030_right_input_mux = | ||
659 | SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(twl4030_right_in_sel), | ||
660 | twl4030_right_in_sel); | ||
661 | |||
662 | /* | 580 | /* |
663 | * FGAIN volume control: | 581 | * FGAIN volume control: |
664 | * from -62 to 0 dB in 1 dB steps (mute instead of -63 dB) | 582 | * from -62 to 0 dB in 1 dB steps (mute instead of -63 dB) |
@@ -741,18 +659,15 @@ static const struct snd_kcontrol_new twl4030_snd_controls[] = { | |||
741 | TWL4030_REG_EAR_CTL, 4, 3, 0, output_tvl), | 659 | TWL4030_REG_EAR_CTL, 4, 3, 0, output_tvl), |
742 | 660 | ||
743 | /* Common capture gain controls */ | 661 | /* Common capture gain controls */ |
744 | SOC_DOUBLE_R_TLV("Capture Volume", | 662 | SOC_DOUBLE_R_TLV("TX1 Digital Capture Volume", |
745 | TWL4030_REG_ATXL1PGA, TWL4030_REG_ATXR1PGA, | 663 | TWL4030_REG_ATXL1PGA, TWL4030_REG_ATXR1PGA, |
746 | 0, 0x1f, 0, digital_capture_tlv), | 664 | 0, 0x1f, 0, digital_capture_tlv), |
665 | SOC_DOUBLE_R_TLV("TX2 Digital Capture Volume", | ||
666 | TWL4030_REG_AVTXL2PGA, TWL4030_REG_AVTXR2PGA, | ||
667 | 0, 0x1f, 0, digital_capture_tlv), | ||
747 | 668 | ||
748 | SOC_DOUBLE_TLV("Input Boost Volume", TWL4030_REG_ANAMIC_GAIN, | 669 | SOC_DOUBLE_TLV("Analog Capture Volume", TWL4030_REG_ANAMIC_GAIN, |
749 | 0, 3, 5, 0, input_gain_tlv), | 670 | 0, 3, 5, 0, input_gain_tlv), |
750 | |||
751 | /* Input source controls */ | ||
752 | SOC_ENUM_EXT("Left Input Source", twl4030_left_input_mux, | ||
753 | twl4030_get_left_input, twl4030_put_left_input), | ||
754 | SOC_ENUM_EXT("Right Input Source", twl4030_right_input_mux, | ||
755 | twl4030_get_right_input, twl4030_put_right_input), | ||
756 | }; | 671 | }; |
757 | 672 | ||
758 | /* add non dapm controls */ | 673 | /* add non dapm controls */ |
@@ -772,9 +687,19 @@ static int twl4030_add_controls(struct snd_soc_codec *codec) | |||
772 | } | 687 | } |
773 | 688 | ||
774 | static const struct snd_soc_dapm_widget twl4030_dapm_widgets[] = { | 689 | static const struct snd_soc_dapm_widget twl4030_dapm_widgets[] = { |
775 | SND_SOC_DAPM_INPUT("INL"), | 690 | /* Left channel inputs */ |
776 | SND_SOC_DAPM_INPUT("INR"), | 691 | SND_SOC_DAPM_INPUT("MAINMIC"), |
777 | 692 | SND_SOC_DAPM_INPUT("HSMIC"), | |
693 | SND_SOC_DAPM_INPUT("AUXL"), | ||
694 | SND_SOC_DAPM_INPUT("CARKITMIC"), | ||
695 | /* Right channel inputs */ | ||
696 | SND_SOC_DAPM_INPUT("SUBMIC"), | ||
697 | SND_SOC_DAPM_INPUT("AUXR"), | ||
698 | /* Digital microphones (Stereo) */ | ||
699 | SND_SOC_DAPM_INPUT("DIGIMIC0"), | ||
700 | SND_SOC_DAPM_INPUT("DIGIMIC1"), | ||
701 | |||
702 | /* Outputs */ | ||
778 | SND_SOC_DAPM_OUTPUT("OUTL"), | 703 | SND_SOC_DAPM_OUTPUT("OUTL"), |
779 | SND_SOC_DAPM_OUTPUT("OUTR"), | 704 | SND_SOC_DAPM_OUTPUT("OUTR"), |
780 | SND_SOC_DAPM_OUTPUT("EARPIECE"), | 705 | SND_SOC_DAPM_OUTPUT("EARPIECE"), |
@@ -809,16 +734,13 @@ static const struct snd_soc_dapm_widget twl4030_dapm_widgets[] = { | |||
809 | 734 | ||
810 | /* Output MUX controls */ | 735 | /* Output MUX controls */ |
811 | /* Earpiece */ | 736 | /* Earpiece */ |
812 | SND_SOC_DAPM_MUX_E("Earpiece Mux", SND_SOC_NOPM, 0, 0, | 737 | SND_SOC_DAPM_VALUE_MUX("Earpiece Mux", SND_SOC_NOPM, 0, 0, |
813 | &twl4030_dapm_earpiece_control, outmixer_event, | 738 | &twl4030_dapm_earpiece_control), |
814 | SND_SOC_DAPM_PRE_REG), | ||
815 | /* PreDrivL/R */ | 739 | /* PreDrivL/R */ |
816 | SND_SOC_DAPM_MUX_E("PredriveL Mux", SND_SOC_NOPM, 0, 0, | 740 | SND_SOC_DAPM_VALUE_MUX("PredriveL Mux", SND_SOC_NOPM, 0, 0, |
817 | &twl4030_dapm_predrivel_control, outmixer_event, | 741 | &twl4030_dapm_predrivel_control), |
818 | SND_SOC_DAPM_PRE_REG), | 742 | SND_SOC_DAPM_VALUE_MUX("PredriveR Mux", SND_SOC_NOPM, 0, 0, |
819 | SND_SOC_DAPM_MUX_E("PredriveR Mux", SND_SOC_NOPM, 0, 0, | 743 | &twl4030_dapm_predriver_control), |
820 | &twl4030_dapm_predriver_control, outmixer_event, | ||
821 | SND_SOC_DAPM_PRE_REG), | ||
822 | /* HeadsetL/R */ | 744 | /* HeadsetL/R */ |
823 | SND_SOC_DAPM_MUX("HeadsetL Mux", SND_SOC_NOPM, 0, 0, | 745 | SND_SOC_DAPM_MUX("HeadsetL Mux", SND_SOC_NOPM, 0, 0, |
824 | &twl4030_dapm_hsol_control), | 746 | &twl4030_dapm_hsol_control), |
@@ -837,8 +759,48 @@ static const struct snd_soc_dapm_widget twl4030_dapm_widgets[] = { | |||
837 | &twl4030_dapm_handsfreer_control, handsfree_event, | 759 | &twl4030_dapm_handsfreer_control, handsfree_event, |
838 | SND_SOC_DAPM_POST_PMU|SND_SOC_DAPM_POST_PMD), | 760 | SND_SOC_DAPM_POST_PMU|SND_SOC_DAPM_POST_PMD), |
839 | 761 | ||
840 | SND_SOC_DAPM_ADC("ADCL", "Left Capture", SND_SOC_NOPM, 0, 0), | 762 | /* Introducing four virtual ADC, since TWL4030 have four channel for |
841 | SND_SOC_DAPM_ADC("ADCR", "Right Capture", SND_SOC_NOPM, 0, 0), | 763 | capture */ |
764 | SND_SOC_DAPM_ADC("ADC Virtual Left1", "Left Front Capture", | ||
765 | SND_SOC_NOPM, 0, 0), | ||
766 | SND_SOC_DAPM_ADC("ADC Virtual Right1", "Right Front Capture", | ||
767 | SND_SOC_NOPM, 0, 0), | ||
768 | SND_SOC_DAPM_ADC("ADC Virtual Left2", "Left Rear Capture", | ||
769 | SND_SOC_NOPM, 0, 0), | ||
770 | SND_SOC_DAPM_ADC("ADC Virtual Right2", "Right Rear Capture", | ||
771 | SND_SOC_NOPM, 0, 0), | ||
772 | |||
773 | /* Analog/Digital mic path selection. | ||
774 | TX1 Left/Right: either analog Left/Right or Digimic0 | ||
775 | TX2 Left/Right: either analog Left/Right or Digimic1 */ | ||
776 | SND_SOC_DAPM_MUX_E("TX1 Capture Route", SND_SOC_NOPM, 0, 0, | ||
777 | &twl4030_dapm_micpathtx1_control, micpath_event, | ||
778 | SND_SOC_DAPM_POST_PMU|SND_SOC_DAPM_POST_PMD| | ||
779 | SND_SOC_DAPM_POST_REG), | ||
780 | SND_SOC_DAPM_MUX_E("TX2 Capture Route", SND_SOC_NOPM, 0, 0, | ||
781 | &twl4030_dapm_micpathtx2_control, micpath_event, | ||
782 | SND_SOC_DAPM_POST_PMU|SND_SOC_DAPM_POST_PMD| | ||
783 | SND_SOC_DAPM_POST_REG), | ||
784 | |||
785 | /* Analog input muxes with power switch for the physical ADCL/R */ | ||
786 | SND_SOC_DAPM_VALUE_MUX("Analog Left Capture Route", | ||
787 | TWL4030_REG_AVADC_CTL, 3, 0, &twl4030_dapm_analoglmic_control), | ||
788 | SND_SOC_DAPM_VALUE_MUX("Analog Right Capture Route", | ||
789 | TWL4030_REG_AVADC_CTL, 1, 0, &twl4030_dapm_analogrmic_control), | ||
790 | |||
791 | SND_SOC_DAPM_PGA("Analog Left Amplifier", | ||
792 | TWL4030_REG_ANAMICL, 4, 0, NULL, 0), | ||
793 | SND_SOC_DAPM_PGA("Analog Right Amplifier", | ||
794 | TWL4030_REG_ANAMICR, 4, 0, NULL, 0), | ||
795 | |||
796 | SND_SOC_DAPM_PGA("Digimic0 Enable", | ||
797 | TWL4030_REG_ADCMICSEL, 1, 0, NULL, 0), | ||
798 | SND_SOC_DAPM_PGA("Digimic1 Enable", | ||
799 | TWL4030_REG_ADCMICSEL, 3, 0, NULL, 0), | ||
800 | |||
801 | SND_SOC_DAPM_MICBIAS("Mic Bias 1", TWL4030_REG_MICBIAS_CTL, 0, 0), | ||
802 | SND_SOC_DAPM_MICBIAS("Mic Bias 2", TWL4030_REG_MICBIAS_CTL, 1, 0), | ||
803 | SND_SOC_DAPM_MICBIAS("Headset Mic Bias", TWL4030_REG_MICBIAS_CTL, 2, 0), | ||
842 | }; | 804 | }; |
843 | 805 | ||
844 | static const struct snd_soc_dapm_route intercon[] = { | 806 | static const struct snd_soc_dapm_route intercon[] = { |
@@ -894,9 +856,39 @@ static const struct snd_soc_dapm_route intercon[] = { | |||
894 | {"HFL", NULL, "HandsfreeL Mux"}, | 856 | {"HFL", NULL, "HandsfreeL Mux"}, |
895 | {"HFR", NULL, "HandsfreeR Mux"}, | 857 | {"HFR", NULL, "HandsfreeR Mux"}, |
896 | 858 | ||
897 | /* inputs */ | 859 | /* Capture path */ |
898 | {"ADCL", NULL, "INL"}, | 860 | {"Analog Left Capture Route", "Main mic", "MAINMIC"}, |
899 | {"ADCR", NULL, "INR"}, | 861 | {"Analog Left Capture Route", "Headset mic", "HSMIC"}, |
862 | {"Analog Left Capture Route", "AUXL", "AUXL"}, | ||
863 | {"Analog Left Capture Route", "Carkit mic", "CARKITMIC"}, | ||
864 | |||
865 | {"Analog Right Capture Route", "Sub mic", "SUBMIC"}, | ||
866 | {"Analog Right Capture Route", "AUXR", "AUXR"}, | ||
867 | |||
868 | {"Analog Left Amplifier", NULL, "Analog Left Capture Route"}, | ||
869 | {"Analog Right Amplifier", NULL, "Analog Right Capture Route"}, | ||
870 | |||
871 | {"Digimic0 Enable", NULL, "DIGIMIC0"}, | ||
872 | {"Digimic1 Enable", NULL, "DIGIMIC1"}, | ||
873 | |||
874 | /* TX1 Left capture path */ | ||
875 | {"TX1 Capture Route", "Analog", "Analog Left Amplifier"}, | ||
876 | {"TX1 Capture Route", "Digimic0", "Digimic0 Enable"}, | ||
877 | /* TX1 Right capture path */ | ||
878 | {"TX1 Capture Route", "Analog", "Analog Right Amplifier"}, | ||
879 | {"TX1 Capture Route", "Digimic0", "Digimic0 Enable"}, | ||
880 | /* TX2 Left capture path */ | ||
881 | {"TX2 Capture Route", "Analog", "Analog Left Amplifier"}, | ||
882 | {"TX2 Capture Route", "Digimic1", "Digimic1 Enable"}, | ||
883 | /* TX2 Right capture path */ | ||
884 | {"TX2 Capture Route", "Analog", "Analog Right Amplifier"}, | ||
885 | {"TX2 Capture Route", "Digimic1", "Digimic1 Enable"}, | ||
886 | |||
887 | {"ADC Virtual Left1", NULL, "TX1 Capture Route"}, | ||
888 | {"ADC Virtual Right1", NULL, "TX1 Capture Route"}, | ||
889 | {"ADC Virtual Left2", NULL, "TX2 Capture Route"}, | ||
890 | {"ADC Virtual Right2", NULL, "TX2 Capture Route"}, | ||
891 | |||
900 | }; | 892 | }; |
901 | 893 | ||
902 | static int twl4030_add_widgets(struct snd_soc_codec *codec) | 894 | static int twl4030_add_widgets(struct snd_soc_codec *codec) |
@@ -923,6 +915,7 @@ static void twl4030_power_up(struct snd_soc_codec *codec) | |||
923 | twl4030_write(codec, TWL4030_REG_ANAMICL, | 915 | twl4030_write(codec, TWL4030_REG_ANAMICL, |
924 | anamicl | TWL4030_CNCL_OFFSET_START); | 916 | anamicl | TWL4030_CNCL_OFFSET_START); |
925 | 917 | ||
918 | |||
926 | /* wait for offset cancellation to complete */ | 919 | /* wait for offset cancellation to complete */ |
927 | do { | 920 | do { |
928 | /* this takes a little while, so don't slam i2c */ | 921 | /* this takes a little while, so don't slam i2c */ |
@@ -1287,6 +1280,8 @@ static int twl4030_remove(struct platform_device *pdev) | |||
1287 | struct snd_soc_codec *codec = socdev->codec; | 1280 | struct snd_soc_codec *codec = socdev->codec; |
1288 | 1281 | ||
1289 | printk(KERN_INFO "TWL4030 Audio Codec remove\n"); | 1282 | printk(KERN_INFO "TWL4030 Audio Codec remove\n"); |
1283 | snd_soc_free_pcms(socdev); | ||
1284 | snd_soc_dapm_free(socdev); | ||
1290 | kfree(codec); | 1285 | kfree(codec); |
1291 | 1286 | ||
1292 | return 0; | 1287 | return 0; |