Commit 370a0314 authored by Jorge Eduardo Candelaria's avatar Jorge Eduardo Candelaria Committed by Liam Girdwood

ASoC: twl6040: Add headset and handset mux controls

This patch adds support for the twl6040 headset and handset
MUX controls.
Signed-off-by: default avatarJorge Eduardo Candelaria <jorge.candelaria@ti.com>
Signed-off-by: default avatarMargarita Olaya Cabrera <magi.olaya@ti.com>
Acked-by: default avatarMark Brown <broonie@opensource.wolfsonmicro.com>
Signed-off-by: default avatarLiam Girdwood <lrg@slimlogic.co.uk>
parent cf370a5a
...@@ -475,6 +475,12 @@ static DECLARE_TLV_DB_SCALE(mic_preamp_tlv, -600, 600, 0); ...@@ -475,6 +475,12 @@ static DECLARE_TLV_DB_SCALE(mic_preamp_tlv, -600, 600, 0);
*/ */
static DECLARE_TLV_DB_SCALE(mic_amp_tlv, 600, 600, 0); static DECLARE_TLV_DB_SCALE(mic_amp_tlv, 600, 600, 0);
/*
* AFMGAIN volume control:
* from 18 to 24 dB in 6 dB steps
*/
static DECLARE_TLV_DB_SCALE(afm_amp_tlv, 1800, 600, 0);
/* /*
* HSGAIN volume control: * HSGAIN volume control:
* from -30 to 0 dB in 2 dB steps * from -30 to 0 dB in 2 dB steps
...@@ -506,6 +512,28 @@ static const struct soc_enum twl6040_enum[] = { ...@@ -506,6 +512,28 @@ static const struct soc_enum twl6040_enum[] = {
SOC_ENUM_SINGLE(TWL6040_REG_MICRCTL, 3, 3, twl6040_amicr_texts), SOC_ENUM_SINGLE(TWL6040_REG_MICRCTL, 3, 3, twl6040_amicr_texts),
}; };
static const char *twl6040_hs_texts[] = {
"Off", "HS DAC", "Line-In amp"
};
static const struct soc_enum twl6040_hs_enum[] = {
SOC_ENUM_SINGLE(TWL6040_REG_HSLCTL, 5, ARRAY_SIZE(twl6040_hs_texts),
twl6040_hs_texts),
SOC_ENUM_SINGLE(TWL6040_REG_HSRCTL, 5, ARRAY_SIZE(twl6040_hs_texts),
twl6040_hs_texts),
};
static const char *twl6040_hf_texts[] = {
"Off", "HF DAC", "Line-In amp"
};
static const struct soc_enum twl6040_hf_enum[] = {
SOC_ENUM_SINGLE(TWL6040_REG_HFLCTL, 2, ARRAY_SIZE(twl6040_hf_texts),
twl6040_hf_texts),
SOC_ENUM_SINGLE(TWL6040_REG_HFRCTL, 2, ARRAY_SIZE(twl6040_hf_texts),
twl6040_hf_texts),
};
static const struct snd_kcontrol_new amicl_control = static const struct snd_kcontrol_new amicl_control =
SOC_DAPM_ENUM("Route", twl6040_enum[0]); SOC_DAPM_ENUM("Route", twl6040_enum[0]);
...@@ -513,18 +541,18 @@ static const struct snd_kcontrol_new amicr_control = ...@@ -513,18 +541,18 @@ static const struct snd_kcontrol_new amicr_control =
SOC_DAPM_ENUM("Route", twl6040_enum[1]); SOC_DAPM_ENUM("Route", twl6040_enum[1]);
/* Headset DAC playback switches */ /* Headset DAC playback switches */
static const struct snd_kcontrol_new hsdacl_switch_controls = static const struct snd_kcontrol_new hsl_mux_controls =
SOC_DAPM_SINGLE("Switch", TWL6040_REG_HSLCTL, 5, 1, 0); SOC_DAPM_ENUM("Route", twl6040_hs_enum[0]);
static const struct snd_kcontrol_new hsdacr_switch_controls = static const struct snd_kcontrol_new hsr_mux_controls =
SOC_DAPM_SINGLE("Switch", TWL6040_REG_HSRCTL, 5, 1, 0); SOC_DAPM_ENUM("Route", twl6040_hs_enum[1]);
/* Handsfree DAC playback switches */ /* Handsfree DAC playback switches */
static const struct snd_kcontrol_new hfdacl_switch_controls = static const struct snd_kcontrol_new hfl_mux_controls =
SOC_DAPM_SINGLE("Switch", TWL6040_REG_HFLCTL, 2, 1, 0); SOC_DAPM_ENUM("Route", twl6040_hf_enum[0]);
static const struct snd_kcontrol_new hfdacr_switch_controls = static const struct snd_kcontrol_new hfr_mux_controls =
SOC_DAPM_SINGLE("Switch", TWL6040_REG_HFRCTL, 2, 1, 0); SOC_DAPM_ENUM("Route", twl6040_hf_enum[1]);
static const struct snd_kcontrol_new ep_driver_switch_controls = static const struct snd_kcontrol_new ep_driver_switch_controls =
SOC_DAPM_SINGLE("Switch", TWL6040_REG_EARCTL, 0, 1, 0); SOC_DAPM_SINGLE("Switch", TWL6040_REG_EARCTL, 0, 1, 0);
...@@ -536,6 +564,10 @@ static const struct snd_kcontrol_new twl6040_snd_controls[] = { ...@@ -536,6 +564,10 @@ static const struct snd_kcontrol_new twl6040_snd_controls[] = {
SOC_DOUBLE_TLV("Capture Volume", SOC_DOUBLE_TLV("Capture Volume",
TWL6040_REG_MICGAIN, 0, 3, 4, 0, mic_amp_tlv), TWL6040_REG_MICGAIN, 0, 3, 4, 0, mic_amp_tlv),
/* AFM gains */
SOC_DOUBLE_TLV("Aux FM Volume",
TWL6040_REG_LINEGAIN, 0, 5, 0xF, 0, afm_amp_tlv),
/* Playback gains */ /* Playback gains */
SOC_DOUBLE_TLV("Headset Playback Volume", SOC_DOUBLE_TLV("Headset Playback Volume",
TWL6040_REG_HSGAIN, 0, 4, 0xF, 1, hs_tlv), TWL6040_REG_HSGAIN, 0, 4, 0xF, 1, hs_tlv),
...@@ -572,6 +604,12 @@ static const struct snd_soc_dapm_widget twl6040_dapm_widgets[] = { ...@@ -572,6 +604,12 @@ static const struct snd_soc_dapm_widget twl6040_dapm_widgets[] = {
SND_SOC_DAPM_PGA("MicAmpR", SND_SOC_DAPM_PGA("MicAmpR",
TWL6040_REG_MICRCTL, 0, 0, NULL, 0), TWL6040_REG_MICRCTL, 0, 0, NULL, 0),
/* Auxiliary FM PGAs */
SND_SOC_DAPM_PGA("AFMAmpL",
TWL6040_REG_MICLCTL, 1, 0, NULL, 0),
SND_SOC_DAPM_PGA("AFMAmpR",
TWL6040_REG_MICRCTL, 1, 0, NULL, 0),
/* ADCs */ /* ADCs */
SND_SOC_DAPM_ADC("ADC Left", "Left Front Capture", SND_SOC_DAPM_ADC("ADC Left", "Left Front Capture",
TWL6040_REG_MICLCTL, 2, 0), TWL6040_REG_MICLCTL, 2, 0),
...@@ -606,15 +644,15 @@ static const struct snd_soc_dapm_widget twl6040_dapm_widgets[] = { ...@@ -606,15 +644,15 @@ static const struct snd_soc_dapm_widget twl6040_dapm_widgets[] = {
twl6040_power_mode_event, twl6040_power_mode_event,
SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD), SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD),
/* Analog playback switches */ SND_SOC_DAPM_MUX("HF Left Playback",
SND_SOC_DAPM_SWITCH("HSDAC Left Playback", SND_SOC_NOPM, 0, 0, &hfl_mux_controls),
SND_SOC_NOPM, 0, 0, &hsdacl_switch_controls), SND_SOC_DAPM_MUX("HF Right Playback",
SND_SOC_DAPM_SWITCH("HSDAC Right Playback", SND_SOC_NOPM, 0, 0, &hfr_mux_controls),
SND_SOC_NOPM, 0, 0, &hsdacr_switch_controls), /* Analog playback Muxes */
SND_SOC_DAPM_SWITCH("HFDAC Left Playback", SND_SOC_DAPM_MUX("HS Left Playback",
SND_SOC_NOPM, 0, 0, &hfdacl_switch_controls), SND_SOC_NOPM, 0, 0, &hsl_mux_controls),
SND_SOC_DAPM_SWITCH("HFDAC Right Playback", SND_SOC_DAPM_MUX("HS Right Playback",
SND_SOC_NOPM, 0, 0, &hfdacr_switch_controls), SND_SOC_NOPM, 0, 0, &hsr_mux_controls),
/* Analog playback drivers */ /* Analog playback drivers */
SND_SOC_DAPM_PGA_E("Handsfree Left Driver", SND_SOC_DAPM_PGA_E("Handsfree Left Driver",
...@@ -658,12 +696,18 @@ static const struct snd_soc_dapm_route intercon[] = { ...@@ -658,12 +696,18 @@ static const struct snd_soc_dapm_route intercon[] = {
{"ADC Left", NULL, "MicAmpL"}, {"ADC Left", NULL, "MicAmpL"},
{"ADC Right", NULL, "MicAmpR"}, {"ADC Right", NULL, "MicAmpR"},
/* Headset playback path */ /* AFM path */
{"HSDAC Left Playback", "Switch", "HSDAC Left"}, {"AFMAmpL", "NULL", "AFML"},
{"HSDAC Right Playback", "Switch", "HSDAC Right"}, {"AFMAmpR", "NULL", "AFMR"},
{"HS Left Playback", "HS DAC", "HSDAC Left"},
{"HS Left Playback", "Line-In amp", "AFMAmpL"},
{"Headset Left Driver", NULL, "HSDAC Left Playback"}, {"HS Right Playback", "HS DAC", "HSDAC Right"},
{"Headset Right Driver", NULL, "HSDAC Right Playback"}, {"HS Right Playback", "Line-In amp", "AFMAmpR"},
{"Headset Left Driver", "NULL", "HS Left Playback"},
{"Headset Right Driver", "NULL", "HS Right Playback"},
{"HSOL", NULL, "Headset Left Driver"}, {"HSOL", NULL, "Headset Left Driver"},
{"HSOR", NULL, "Headset Right Driver"}, {"HSOR", NULL, "Headset Right Driver"},
...@@ -672,12 +716,14 @@ static const struct snd_soc_dapm_route intercon[] = { ...@@ -672,12 +716,14 @@ static const struct snd_soc_dapm_route intercon[] = {
{"Earphone Driver", "Switch", "HSDAC Left"}, {"Earphone Driver", "Switch", "HSDAC Left"},
{"EP", NULL, "Earphone Driver"}, {"EP", NULL, "Earphone Driver"},
/* Handsfree playback path */ {"HF Left Playback", "HF DAC", "HFDAC Left"},
{"HFDAC Left Playback", "Switch", "HFDAC Left"}, {"HF Left Playback", "Line-In amp", "AFMAmpL"},
{"HFDAC Right Playback", "Switch", "HFDAC Right"},
{"HF Right Playback", "HF DAC", "HFDAC Right"},
{"HF Right Playback", "Line-In amp", "AFMAmpR"},
{"HFDAC Left PGA", NULL, "HFDAC Left Playback"}, {"HFDAC Left PGA", NULL, "HF Left Playback"},
{"HFDAC Right PGA", NULL, "HFDAC Right Playback"}, {"HFDAC Right PGA", NULL, "HF Right Playback"},
{"Handsfree Left Driver", "Switch", "HFDAC Left PGA"}, {"Handsfree Left Driver", "Switch", "HFDAC Left PGA"},
{"Handsfree Right Driver", "Switch", "HFDAC Right PGA"}, {"Handsfree Right Driver", "Switch", "HFDAC Right PGA"},
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment