diff options
author | Max Krummenacher <max.krummenacher@toradex.com> | 2017-04-16 23:52:26 +0200 |
---|---|---|
committer | Marcel Ziswiler <marcel.ziswiler@toradex.com> | 2020-02-09 22:45:34 +0100 |
commit | 7601422c171ab192492a2b5f4451246c41e7cfc6 (patch) | |
tree | 44fb9d2c401fc501fcf56889a3055647bbcfed95 /sound | |
parent | 1a6f2a0ebafd1d25cad3c8c5c504fc5e1a036ceb (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>
(cherry picked from commit a2130af576ac29935b8062574f45ca6999852ba4)
Diffstat (limited to 'sound')
-rw-r--r-- | sound/soc/codecs/sgtl5000.c | 63 |
1 files changed, 34 insertions, 29 deletions
diff --git a/sound/soc/codecs/sgtl5000.c b/sound/soc/codecs/sgtl5000.c index a8952ed4185f..73a7aeaed6ed 100644 --- a/sound/soc/codecs/sgtl5000.c +++ b/sound/soc/codecs/sgtl5000.c @@ -323,6 +323,13 @@ static int vag_and_mute_control(struct snd_soc_component *component, break; case SND_SOC_DAPM_PRE_PMD: /* + * Don't clear VAG_POWERUP when there is a local loop + * from LINE_IN to the HP. + */ + 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 * operational to prevent inadvertently starving the * other one of them. @@ -342,38 +349,36 @@ static int vag_and_mute_control(struct snd_soc_component *component, } /* - * Mute Headphone when power it up/down. - * Control VAG power on HP power path. + * 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_pga_event(struct snd_soc_dapm_widget *w, +static int headphone_mux_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_component *component = - snd_soc_dapm_to_component(w->dapm); - - return vag_and_mute_control(component, event, HP_POWER_EVENT); -} - -/* As manual describes, ADC/DAC powering up/down requires - * to mute outputs to avoid pops. - * Control VAG power on ADC/DAC power path. - */ -static int adc_updown_depop(struct snd_soc_dapm_widget *w, - struct snd_kcontrol *kcontrol, int event) -{ - struct snd_soc_component *component = - snd_soc_dapm_to_component(w->dapm); - - return vag_and_mute_control(component, event, ADC_POWER_EVENT); -} + struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); -static int dac_updown_depop(struct snd_soc_dapm_widget *w, - struct snd_kcontrol *kcontrol, int event) -{ - struct snd_soc_component *component = - snd_soc_dapm_to_component(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 vag_and_mute_control(component, event, DAC_POWER_EVENT); + return 0; } /* input sources for ADC */ @@ -419,8 +424,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", |