diff options
author | Max Krummenacher <max.krummenacher@toradex.com> | 2017-04-16 23:52:26 +0200 |
---|---|---|
committer | Stefan Agner <stefan.agner@toradex.com> | 2017-05-30 13:49:18 -0700 |
commit | a2130af576ac29935b8062574f45ca6999852ba4 (patch) | |
tree | 7e27683a63cd4982998e04d3a178bff2b0f88bd2 /sound | |
parent | b48a96aacc7036db39730889bafec354ad9a9126 (diff) |
sgtl5000: improve switch on vag power for line_in -> output
Commit '3e3ea9ba80e8 sgtl5000: switch on vag power for line_in -> output'
switched on VAG power when using a direct connection from line_in ->
headphone output, but it did not switch it off when switching back
to DAC -> HP.
Additionally with commit 'abff9e8b0ddf ASoC: sgtl5000: fix VAG power
up timing' the combination of the two commits introduced a pop on the
headphone when using DAC -> HP.
Detect the HP muxing state differently and thus address both issues.
Signed-off-by: Max Krummenacher <max.krummenacher@toradex.com>
Acked-by: Stefan Agner <stefan.agner@toradex.com>
Diffstat (limited to 'sound')
-rw-r--r-- | sound/soc/codecs/sgtl5000.c | 42 |
1 files changed, 38 insertions, 4 deletions
diff --git a/sound/soc/codecs/sgtl5000.c b/sound/soc/codecs/sgtl5000.c index 1de99718ada4..ed9a25276efa 100644 --- a/sound/soc/codecs/sgtl5000.c +++ b/sound/soc/codecs/sgtl5000.c @@ -173,9 +173,10 @@ static int power_vag_event(struct snd_soc_dapm_widget *w, case SND_SOC_DAPM_PRE_PMD: /* * Don't clear VAG_POWERUP when there is a local loop - * from LINE_IN to the DAC. + * from LINE_IN to the HP. */ - if (snd_soc_read(codec, SGTL5000_CHIP_ANA_CTRL) & (1<<6)) + if (snd_soc_read(codec, SGTL5000_CHIP_ANA_CTRL) & + SGTL5000_HP_SEL_MASK) break; /* * Don't clear VAG_POWERUP, when both DAC and ADC are @@ -196,6 +197,39 @@ static int power_vag_event(struct snd_soc_dapm_widget *w, return 0; } +/* + * If we mux a direct path from LINE_IN to HP, VAG must be powered up. + * With the SND_SOC_DAPM_POST_REG event the new state of the headphone mux is + * available. + */ +static int headphone_mux_event(struct snd_soc_dapm_widget *w, + struct snd_kcontrol *kcontrol, int event) +{ + struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); + + /* + * switch on VAG unconditionally on any change of the headphone muxer + * early to lessen pop. + */ + switch (event) { + case SND_SOC_DAPM_PRE_REG: + snd_soc_update_bits(codec, SGTL5000_CHIP_ANA_POWER, + SGTL5000_VAG_POWERUP, SGTL5000_VAG_POWERUP); + break; + /* + * The call to power_vag_event() switches VAG off again, if VAG need + * not be switched on. + */ + case SND_SOC_DAPM_POST_REG: + power_vag_event(w, kcontrol, SND_SOC_DAPM_PRE_PMD); + break; + default: + break; + } + + return 0; +} + /* input sources for ADC */ static const char *adc_mux_text[] = { "MIC_IN", "LINE_IN" @@ -236,8 +270,8 @@ static const struct snd_soc_dapm_widget sgtl5000_dapm_widgets[] = { SND_SOC_DAPM_MUX("Capture Mux", SND_SOC_NOPM, 0, 0, &adc_mux), SND_SOC_DAPM_MUX_E("Headphone Mux", SND_SOC_NOPM, 0, 0, &dac_mux, - power_vag_event, - SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_PRE_POST_PMD), + headphone_mux_event, + SND_SOC_DAPM_PRE_REG | SND_SOC_DAPM_POST_REG), /* aif for i2s input */ SND_SOC_DAPM_AIF_IN("AIFIN", "Playback", |