diff options
author | Lopez Cruz, Misael <x0052729@ti.com> | 2009-04-30 22:47:22 -0400 |
---|---|---|
committer | Mark Brown <broonie@opensource.wolfsonmicro.com> | 2009-05-05 05:12:14 -0400 |
commit | fcd274a345875b05c348ba19bc6b3dd48ecbb7d0 (patch) | |
tree | d3261cda9510a878f50669f8893b59cca2a87f84 /sound/soc/codecs/twl4030.c | |
parent | 4072604b9dd18f25a98cc0f4d3d4553ed1ad4152 (diff) |
ASoC: TWL4030: Add VDL analog bypass
This patch adds voice downlink analog bypass switch. It follows
the same approach as in other analog bypass switches.
DAC switch is moved from 'DAC Voice' to 'Analog Voice Playback Mixer',
that will also allow voice DAC to be powered in digital voice
loopback (sidetone).
Signed-off-by: Misael Lopez Cruz <x0052729@ti.com>
Acked-by: Peter Ujfalusi <peter.ujfalusi@nokia.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Diffstat (limited to 'sound/soc/codecs/twl4030.c')
-rw-r--r-- | sound/soc/codecs/twl4030.c | 37 |
1 files changed, 31 insertions, 6 deletions
diff --git a/sound/soc/codecs/twl4030.c b/sound/soc/codecs/twl4030.c index efa1a80b806c..efb371f6f01c 100644 --- a/sound/soc/codecs/twl4030.c +++ b/sound/soc/codecs/twl4030.c | |||
@@ -468,6 +468,10 @@ static const struct snd_kcontrol_new twl4030_dapm_abypassr2_control = | |||
468 | static const struct snd_kcontrol_new twl4030_dapm_abypassl2_control = | 468 | static const struct snd_kcontrol_new twl4030_dapm_abypassl2_control = |
469 | SOC_DAPM_SINGLE("Switch", TWL4030_REG_ARXL2_APGA_CTL, 2, 1, 0); | 469 | SOC_DAPM_SINGLE("Switch", TWL4030_REG_ARXL2_APGA_CTL, 2, 1, 0); |
470 | 470 | ||
471 | /* Analog bypass for Voice */ | ||
472 | static const struct snd_kcontrol_new twl4030_dapm_abypassv_control = | ||
473 | SOC_DAPM_SINGLE("Switch", TWL4030_REG_VDL_APGA_CTL, 2, 1, 0); | ||
474 | |||
471 | /* Digital bypass gain, 0 mutes the bypass */ | 475 | /* Digital bypass gain, 0 mutes the bypass */ |
472 | static const unsigned int twl4030_dapm_dbypass_tlv[] = { | 476 | static const unsigned int twl4030_dapm_dbypass_tlv[] = { |
473 | TLV_DB_RANGE_HEAD(2), | 477 | TLV_DB_RANGE_HEAD(2), |
@@ -585,7 +589,7 @@ static int bypass_event(struct snd_soc_dapm_widget *w, | |||
585 | struct soc_mixer_control *m = | 589 | struct soc_mixer_control *m = |
586 | (struct soc_mixer_control *)w->kcontrols->private_value; | 590 | (struct soc_mixer_control *)w->kcontrols->private_value; |
587 | struct twl4030_priv *twl4030 = w->codec->private_data; | 591 | struct twl4030_priv *twl4030 = w->codec->private_data; |
588 | unsigned char reg; | 592 | unsigned char reg, misc; |
589 | 593 | ||
590 | reg = twl4030_read_reg_cache(w->codec, m->reg); | 594 | reg = twl4030_read_reg_cache(w->codec, m->reg); |
591 | 595 | ||
@@ -597,14 +601,28 @@ static int bypass_event(struct snd_soc_dapm_widget *w, | |||
597 | else | 601 | else |
598 | twl4030->bypass_state &= | 602 | twl4030->bypass_state &= |
599 | ~(1 << (m->reg - TWL4030_REG_ARXL1_APGA_CTL)); | 603 | ~(1 << (m->reg - TWL4030_REG_ARXL1_APGA_CTL)); |
604 | } else if (m->reg == TWL4030_REG_VDL_APGA_CTL) { | ||
605 | /* Analog voice bypass */ | ||
606 | if (reg & (1 << m->shift)) | ||
607 | twl4030->bypass_state |= (1 << 4); | ||
608 | else | ||
609 | twl4030->bypass_state &= ~(1 << 4); | ||
600 | } else { | 610 | } else { |
601 | /* Digital bypass */ | 611 | /* Digital bypass */ |
602 | if (reg & (0x7 << m->shift)) | 612 | if (reg & (0x7 << m->shift)) |
603 | twl4030->bypass_state |= (1 << (m->shift ? 5 : 4)); | 613 | twl4030->bypass_state |= (1 << (m->shift ? 6 : 5)); |
604 | else | 614 | else |
605 | twl4030->bypass_state &= ~(1 << (m->shift ? 5 : 4)); | 615 | twl4030->bypass_state &= ~(1 << (m->shift ? 6 : 5)); |
606 | } | 616 | } |
607 | 617 | ||
618 | /* Enable master analog loopback mode if any analog switch is enabled*/ | ||
619 | misc = twl4030_read_reg_cache(w->codec, TWL4030_REG_MISC_SET_1); | ||
620 | if (twl4030->bypass_state & 0x1F) | ||
621 | misc |= TWL4030_FMLOOP_EN; | ||
622 | else | ||
623 | misc &= ~TWL4030_FMLOOP_EN; | ||
624 | twl4030_write(w->codec, TWL4030_REG_MISC_SET_1, misc); | ||
625 | |||
608 | if (w->codec->bias_level == SND_SOC_BIAS_STANDBY) { | 626 | if (w->codec->bias_level == SND_SOC_BIAS_STANDBY) { |
609 | if (twl4030->bypass_state) | 627 | if (twl4030->bypass_state) |
610 | twl4030_codec_mute(w->codec, 0); | 628 | twl4030_codec_mute(w->codec, 0); |
@@ -935,7 +953,7 @@ static const struct snd_soc_dapm_widget twl4030_dapm_widgets[] = { | |||
935 | SND_SOC_DAPM_DAC("DAC Left2", "Left Rear Playback", | 953 | SND_SOC_DAPM_DAC("DAC Left2", "Left Rear Playback", |
936 | SND_SOC_NOPM, 0, 0), | 954 | SND_SOC_NOPM, 0, 0), |
937 | SND_SOC_DAPM_DAC("DAC Voice", "Voice Playback", | 955 | SND_SOC_DAPM_DAC("DAC Voice", "Voice Playback", |
938 | TWL4030_REG_AVDAC_CTL, 4, 0), | 956 | SND_SOC_NOPM, 0, 0), |
939 | 957 | ||
940 | /* Analog PGAs */ | 958 | /* Analog PGAs */ |
941 | SND_SOC_DAPM_PGA("ARXR1_APGA", TWL4030_REG_ARXR1_APGA_CTL, | 959 | SND_SOC_DAPM_PGA("ARXR1_APGA", TWL4030_REG_ARXR1_APGA_CTL, |
@@ -962,6 +980,9 @@ static const struct snd_soc_dapm_widget twl4030_dapm_widgets[] = { | |||
962 | SND_SOC_DAPM_SWITCH_E("Left2 Analog Loopback", SND_SOC_NOPM, 0, 0, | 980 | SND_SOC_DAPM_SWITCH_E("Left2 Analog Loopback", SND_SOC_NOPM, 0, 0, |
963 | &twl4030_dapm_abypassl2_control, | 981 | &twl4030_dapm_abypassl2_control, |
964 | bypass_event, SND_SOC_DAPM_POST_REG), | 982 | bypass_event, SND_SOC_DAPM_POST_REG), |
983 | SND_SOC_DAPM_SWITCH_E("Voice Analog Loopback", SND_SOC_NOPM, 0, 0, | ||
984 | &twl4030_dapm_abypassv_control, | ||
985 | bypass_event, SND_SOC_DAPM_POST_REG), | ||
965 | 986 | ||
966 | /* Digital bypasses */ | 987 | /* Digital bypasses */ |
967 | SND_SOC_DAPM_SWITCH_E("Left Digital Loopback", SND_SOC_NOPM, 0, 0, | 988 | SND_SOC_DAPM_SWITCH_E("Left Digital Loopback", SND_SOC_NOPM, 0, 0, |
@@ -979,6 +1000,8 @@ static const struct snd_soc_dapm_widget twl4030_dapm_widgets[] = { | |||
979 | 2, 0, NULL, 0), | 1000 | 2, 0, NULL, 0), |
980 | SND_SOC_DAPM_MIXER("Analog L2 Playback Mixer", TWL4030_REG_AVDAC_CTL, | 1001 | SND_SOC_DAPM_MIXER("Analog L2 Playback Mixer", TWL4030_REG_AVDAC_CTL, |
981 | 3, 0, NULL, 0), | 1002 | 3, 0, NULL, 0), |
1003 | SND_SOC_DAPM_MIXER("Analog Voice Playback Mixer", TWL4030_REG_AVDAC_CTL, | ||
1004 | 4, 0, NULL, 0), | ||
982 | 1005 | ||
983 | /* Output MIXER controls */ | 1006 | /* Output MIXER controls */ |
984 | /* Earpiece */ | 1007 | /* Earpiece */ |
@@ -1067,13 +1090,13 @@ static const struct snd_soc_dapm_route intercon[] = { | |||
1067 | {"Analog R1 Playback Mixer", NULL, "DAC Right1"}, | 1090 | {"Analog R1 Playback Mixer", NULL, "DAC Right1"}, |
1068 | {"Analog L2 Playback Mixer", NULL, "DAC Left2"}, | 1091 | {"Analog L2 Playback Mixer", NULL, "DAC Left2"}, |
1069 | {"Analog R2 Playback Mixer", NULL, "DAC Right2"}, | 1092 | {"Analog R2 Playback Mixer", NULL, "DAC Right2"}, |
1093 | {"Analog Voice Playback Mixer", NULL, "DAC Voice"}, | ||
1070 | 1094 | ||
1071 | {"ARXL1_APGA", NULL, "Analog L1 Playback Mixer"}, | 1095 | {"ARXL1_APGA", NULL, "Analog L1 Playback Mixer"}, |
1072 | {"ARXR1_APGA", NULL, "Analog R1 Playback Mixer"}, | 1096 | {"ARXR1_APGA", NULL, "Analog R1 Playback Mixer"}, |
1073 | {"ARXL2_APGA", NULL, "Analog L2 Playback Mixer"}, | 1097 | {"ARXL2_APGA", NULL, "Analog L2 Playback Mixer"}, |
1074 | {"ARXR2_APGA", NULL, "Analog R2 Playback Mixer"}, | 1098 | {"ARXR2_APGA", NULL, "Analog R2 Playback Mixer"}, |
1075 | 1099 | {"VDL_APGA", NULL, "Analog Voice Playback Mixer"}, | |
1076 | {"VDL_APGA", NULL, "DAC Voice"}, | ||
1077 | 1100 | ||
1078 | /* Internal playback routings */ | 1101 | /* Internal playback routings */ |
1079 | /* Earpiece */ | 1102 | /* Earpiece */ |
@@ -1169,11 +1192,13 @@ static const struct snd_soc_dapm_route intercon[] = { | |||
1169 | {"Left1 Analog Loopback", "Switch", "Analog Left Capture Route"}, | 1192 | {"Left1 Analog Loopback", "Switch", "Analog Left Capture Route"}, |
1170 | {"Right2 Analog Loopback", "Switch", "Analog Right Capture Route"}, | 1193 | {"Right2 Analog Loopback", "Switch", "Analog Right Capture Route"}, |
1171 | {"Left2 Analog Loopback", "Switch", "Analog Left Capture Route"}, | 1194 | {"Left2 Analog Loopback", "Switch", "Analog Left Capture Route"}, |
1195 | {"Voice Analog Loopback", "Switch", "Analog Left Capture Route"}, | ||
1172 | 1196 | ||
1173 | {"Analog R1 Playback Mixer", NULL, "Right1 Analog Loopback"}, | 1197 | {"Analog R1 Playback Mixer", NULL, "Right1 Analog Loopback"}, |
1174 | {"Analog L1 Playback Mixer", NULL, "Left1 Analog Loopback"}, | 1198 | {"Analog L1 Playback Mixer", NULL, "Left1 Analog Loopback"}, |
1175 | {"Analog R2 Playback Mixer", NULL, "Right2 Analog Loopback"}, | 1199 | {"Analog R2 Playback Mixer", NULL, "Right2 Analog Loopback"}, |
1176 | {"Analog L2 Playback Mixer", NULL, "Left2 Analog Loopback"}, | 1200 | {"Analog L2 Playback Mixer", NULL, "Left2 Analog Loopback"}, |
1201 | {"Analog Voice Playback Mixer", NULL, "Voice Analog Loopback"}, | ||
1177 | 1202 | ||
1178 | /* Digital bypass routes */ | 1203 | /* Digital bypass routes */ |
1179 | {"Right Digital Loopback", "Volume", "TX1 Capture Route"}, | 1204 | {"Right Digital Loopback", "Volume", "TX1 Capture Route"}, |