aboutsummaryrefslogtreecommitdiffstats
path: root/sound
diff options
context:
space:
mode:
authorJorge Eduardo Candelaria <jorge.candelaria@ti.com>2010-12-10 22:05:32 -0500
committerLiam Girdwood <lrg@slimlogic.co.uk>2010-12-14 15:36:37 -0500
commit370a0314ff3e1315e7fdec32a88a7ae49ccd22c8 (patch)
tree031e8d9e39de2a09fce37096e8c40bddfc5c1ea8 /sound
parentcf370a5a0e9d3b111f93216a55f275d66daed952 (diff)
ASoC: twl6040: Add headset and handset mux controls
This patch adds support for the twl6040 headset and handset MUX controls. Signed-off-by: Jorge Eduardo Candelaria <jorge.candelaria@ti.com> Signed-off-by: Margarita Olaya Cabrera <magi.olaya@ti.com> Acked-by: Mark Brown <broonie@opensource.wolfsonmicro.com> Signed-off-by: Liam Girdwood <lrg@slimlogic.co.uk>
Diffstat (limited to 'sound')
-rw-r--r--sound/soc/codecs/twl6040.c100
1 files changed, 73 insertions, 27 deletions
diff --git a/sound/soc/codecs/twl6040.c b/sound/soc/codecs/twl6040.c
index 8a6c62339e39..b575fd3ba3fb 100644
--- a/sound/soc/codecs/twl6040.c
+++ b/sound/soc/codecs/twl6040.c
@@ -476,6 +476,12 @@ static DECLARE_TLV_DB_SCALE(mic_preamp_tlv, -600, 600, 0);
476static DECLARE_TLV_DB_SCALE(mic_amp_tlv, 600, 600, 0); 476static DECLARE_TLV_DB_SCALE(mic_amp_tlv, 600, 600, 0);
477 477
478/* 478/*
479 * AFMGAIN volume control:
480 * from 18 to 24 dB in 6 dB steps
481 */
482static DECLARE_TLV_DB_SCALE(afm_amp_tlv, 1800, 600, 0);
483
484/*
479 * HSGAIN volume control: 485 * HSGAIN volume control:
480 * from -30 to 0 dB in 2 dB steps 486 * from -30 to 0 dB in 2 dB steps
481 */ 487 */
@@ -506,6 +512,28 @@ static const struct soc_enum twl6040_enum[] = {
506 SOC_ENUM_SINGLE(TWL6040_REG_MICRCTL, 3, 3, twl6040_amicr_texts), 512 SOC_ENUM_SINGLE(TWL6040_REG_MICRCTL, 3, 3, twl6040_amicr_texts),
507}; 513};
508 514
515static const char *twl6040_hs_texts[] = {
516 "Off", "HS DAC", "Line-In amp"
517};
518
519static const struct soc_enum twl6040_hs_enum[] = {
520 SOC_ENUM_SINGLE(TWL6040_REG_HSLCTL, 5, ARRAY_SIZE(twl6040_hs_texts),
521 twl6040_hs_texts),
522 SOC_ENUM_SINGLE(TWL6040_REG_HSRCTL, 5, ARRAY_SIZE(twl6040_hs_texts),
523 twl6040_hs_texts),
524};
525
526static const char *twl6040_hf_texts[] = {
527 "Off", "HF DAC", "Line-In amp"
528};
529
530static const struct soc_enum twl6040_hf_enum[] = {
531 SOC_ENUM_SINGLE(TWL6040_REG_HFLCTL, 2, ARRAY_SIZE(twl6040_hf_texts),
532 twl6040_hf_texts),
533 SOC_ENUM_SINGLE(TWL6040_REG_HFRCTL, 2, ARRAY_SIZE(twl6040_hf_texts),
534 twl6040_hf_texts),
535};
536
509static const struct snd_kcontrol_new amicl_control = 537static const struct snd_kcontrol_new amicl_control =
510 SOC_DAPM_ENUM("Route", twl6040_enum[0]); 538 SOC_DAPM_ENUM("Route", twl6040_enum[0]);
511 539
@@ -513,18 +541,18 @@ static const struct snd_kcontrol_new amicr_control =
513 SOC_DAPM_ENUM("Route", twl6040_enum[1]); 541 SOC_DAPM_ENUM("Route", twl6040_enum[1]);
514 542
515/* Headset DAC playback switches */ 543/* Headset DAC playback switches */
516static const struct snd_kcontrol_new hsdacl_switch_controls = 544static const struct snd_kcontrol_new hsl_mux_controls =
517 SOC_DAPM_SINGLE("Switch", TWL6040_REG_HSLCTL, 5, 1, 0); 545 SOC_DAPM_ENUM("Route", twl6040_hs_enum[0]);
518 546
519static const struct snd_kcontrol_new hsdacr_switch_controls = 547static const struct snd_kcontrol_new hsr_mux_controls =
520 SOC_DAPM_SINGLE("Switch", TWL6040_REG_HSRCTL, 5, 1, 0); 548 SOC_DAPM_ENUM("Route", twl6040_hs_enum[1]);
521 549
522/* Handsfree DAC playback switches */ 550/* Handsfree DAC playback switches */
523static const struct snd_kcontrol_new hfdacl_switch_controls = 551static const struct snd_kcontrol_new hfl_mux_controls =
524 SOC_DAPM_SINGLE("Switch", TWL6040_REG_HFLCTL, 2, 1, 0); 552 SOC_DAPM_ENUM("Route", twl6040_hf_enum[0]);
525 553
526static const struct snd_kcontrol_new hfdacr_switch_controls = 554static const struct snd_kcontrol_new hfr_mux_controls =
527 SOC_DAPM_SINGLE("Switch", TWL6040_REG_HFRCTL, 2, 1, 0); 555 SOC_DAPM_ENUM("Route", twl6040_hf_enum[1]);
528 556
529static const struct snd_kcontrol_new ep_driver_switch_controls = 557static const struct snd_kcontrol_new ep_driver_switch_controls =
530 SOC_DAPM_SINGLE("Switch", TWL6040_REG_EARCTL, 0, 1, 0); 558 SOC_DAPM_SINGLE("Switch", TWL6040_REG_EARCTL, 0, 1, 0);
@@ -536,6 +564,10 @@ static const struct snd_kcontrol_new twl6040_snd_controls[] = {
536 SOC_DOUBLE_TLV("Capture Volume", 564 SOC_DOUBLE_TLV("Capture Volume",
537 TWL6040_REG_MICGAIN, 0, 3, 4, 0, mic_amp_tlv), 565 TWL6040_REG_MICGAIN, 0, 3, 4, 0, mic_amp_tlv),
538 566
567 /* AFM gains */
568 SOC_DOUBLE_TLV("Aux FM Volume",
569 TWL6040_REG_LINEGAIN, 0, 5, 0xF, 0, afm_amp_tlv),
570
539 /* Playback gains */ 571 /* Playback gains */
540 SOC_DOUBLE_TLV("Headset Playback Volume", 572 SOC_DOUBLE_TLV("Headset Playback Volume",
541 TWL6040_REG_HSGAIN, 0, 4, 0xF, 1, hs_tlv), 573 TWL6040_REG_HSGAIN, 0, 4, 0xF, 1, hs_tlv),
@@ -572,6 +604,12 @@ static const struct snd_soc_dapm_widget twl6040_dapm_widgets[] = {
572 SND_SOC_DAPM_PGA("MicAmpR", 604 SND_SOC_DAPM_PGA("MicAmpR",
573 TWL6040_REG_MICRCTL, 0, 0, NULL, 0), 605 TWL6040_REG_MICRCTL, 0, 0, NULL, 0),
574 606
607 /* Auxiliary FM PGAs */
608 SND_SOC_DAPM_PGA("AFMAmpL",
609 TWL6040_REG_MICLCTL, 1, 0, NULL, 0),
610 SND_SOC_DAPM_PGA("AFMAmpR",
611 TWL6040_REG_MICRCTL, 1, 0, NULL, 0),
612
575 /* ADCs */ 613 /* ADCs */
576 SND_SOC_DAPM_ADC("ADC Left", "Left Front Capture", 614 SND_SOC_DAPM_ADC("ADC Left", "Left Front Capture",
577 TWL6040_REG_MICLCTL, 2, 0), 615 TWL6040_REG_MICLCTL, 2, 0),
@@ -606,15 +644,15 @@ static const struct snd_soc_dapm_widget twl6040_dapm_widgets[] = {
606 twl6040_power_mode_event, 644 twl6040_power_mode_event,
607 SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD), 645 SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD),
608 646
609 /* Analog playback switches */ 647 SND_SOC_DAPM_MUX("HF Left Playback",
610 SND_SOC_DAPM_SWITCH("HSDAC Left Playback", 648 SND_SOC_NOPM, 0, 0, &hfl_mux_controls),
611 SND_SOC_NOPM, 0, 0, &hsdacl_switch_controls), 649 SND_SOC_DAPM_MUX("HF Right Playback",
612 SND_SOC_DAPM_SWITCH("HSDAC Right Playback", 650 SND_SOC_NOPM, 0, 0, &hfr_mux_controls),
613 SND_SOC_NOPM, 0, 0, &hsdacr_switch_controls), 651 /* Analog playback Muxes */
614 SND_SOC_DAPM_SWITCH("HFDAC Left Playback", 652 SND_SOC_DAPM_MUX("HS Left Playback",
615 SND_SOC_NOPM, 0, 0, &hfdacl_switch_controls), 653 SND_SOC_NOPM, 0, 0, &hsl_mux_controls),
616 SND_SOC_DAPM_SWITCH("HFDAC Right Playback", 654 SND_SOC_DAPM_MUX("HS Right Playback",
617 SND_SOC_NOPM, 0, 0, &hfdacr_switch_controls), 655 SND_SOC_NOPM, 0, 0, &hsr_mux_controls),
618 656
619 /* Analog playback drivers */ 657 /* Analog playback drivers */
620 SND_SOC_DAPM_PGA_E("Handsfree Left Driver", 658 SND_SOC_DAPM_PGA_E("Handsfree Left Driver",
@@ -658,12 +696,18 @@ static const struct snd_soc_dapm_route intercon[] = {
658 {"ADC Left", NULL, "MicAmpL"}, 696 {"ADC Left", NULL, "MicAmpL"},
659 {"ADC Right", NULL, "MicAmpR"}, 697 {"ADC Right", NULL, "MicAmpR"},
660 698
661 /* Headset playback path */ 699 /* AFM path */
662 {"HSDAC Left Playback", "Switch", "HSDAC Left"}, 700 {"AFMAmpL", "NULL", "AFML"},
663 {"HSDAC Right Playback", "Switch", "HSDAC Right"}, 701 {"AFMAmpR", "NULL", "AFMR"},
702
703 {"HS Left Playback", "HS DAC", "HSDAC Left"},
704 {"HS Left Playback", "Line-In amp", "AFMAmpL"},
664 705
665 {"Headset Left Driver", NULL, "HSDAC Left Playback"}, 706 {"HS Right Playback", "HS DAC", "HSDAC Right"},
666 {"Headset Right Driver", NULL, "HSDAC Right Playback"}, 707 {"HS Right Playback", "Line-In amp", "AFMAmpR"},
708
709 {"Headset Left Driver", "NULL", "HS Left Playback"},
710 {"Headset Right Driver", "NULL", "HS Right Playback"},
667 711
668 {"HSOL", NULL, "Headset Left Driver"}, 712 {"HSOL", NULL, "Headset Left Driver"},
669 {"HSOR", NULL, "Headset Right Driver"}, 713 {"HSOR", NULL, "Headset Right Driver"},
@@ -672,12 +716,14 @@ static const struct snd_soc_dapm_route intercon[] = {
672 {"Earphone Driver", "Switch", "HSDAC Left"}, 716 {"Earphone Driver", "Switch", "HSDAC Left"},
673 {"EP", NULL, "Earphone Driver"}, 717 {"EP", NULL, "Earphone Driver"},
674 718
675 /* Handsfree playback path */ 719 {"HF Left Playback", "HF DAC", "HFDAC Left"},
676 {"HFDAC Left Playback", "Switch", "HFDAC Left"}, 720 {"HF Left Playback", "Line-In amp", "AFMAmpL"},
677 {"HFDAC Right Playback", "Switch", "HFDAC Right"}, 721
722 {"HF Right Playback", "HF DAC", "HFDAC Right"},
723 {"HF Right Playback", "Line-In amp", "AFMAmpR"},
678 724
679 {"HFDAC Left PGA", NULL, "HFDAC Left Playback"}, 725 {"HFDAC Left PGA", NULL, "HF Left Playback"},
680 {"HFDAC Right PGA", NULL, "HFDAC Right Playback"}, 726 {"HFDAC Right PGA", NULL, "HF Right Playback"},
681 727
682 {"Handsfree Left Driver", "Switch", "HFDAC Left PGA"}, 728 {"Handsfree Left Driver", "Switch", "HFDAC Left PGA"},
683 {"Handsfree Right Driver", "Switch", "HFDAC Right PGA"}, 729 {"Handsfree Right Driver", "Switch", "HFDAC Right PGA"},