summaryrefslogtreecommitdiff
path: root/sound
diff options
context:
space:
mode:
authorMax Krummenacher <max.krummenacher@toradex.com>2017-04-16 23:52:26 +0200
committerMarcel Ziswiler <marcel.ziswiler@toradex.com>2018-12-24 01:27:29 +0100
commit68910099bfe9184a7cdf45ad589a9513dd6ea400 (patch)
tree6a777468ed261d43df7e2a7f78c65d902db26033 /sound
parent99801c4aa93072ad2194906b45bd557e67543a8e (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.c42
1 files changed, 38 insertions, 4 deletions
diff --git a/sound/soc/codecs/sgtl5000.c b/sound/soc/codecs/sgtl5000.c
index 9f909e19599e..2d242cfd7e8e 100644
--- a/sound/soc/codecs/sgtl5000.c
+++ b/sound/soc/codecs/sgtl5000.c
@@ -165,9 +165,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
@@ -188,6 +189,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"
@@ -228,8 +262,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",