From 8e4179bae7730f3bca6ba80e2a4106a395a0e7c9 Mon Sep 17 00:00:00 2001 From: Oleksandr Suvorov Date: Fri, 3 May 2019 11:15:06 +0300 Subject: ASoC: sgtl5000: Fix leading and trailing pops - increase trailing delay after VAG power down to reduce trailing pop; - mute HP/LINE output before VAG power up. Related to: #48500 Signed-off-by: Oleksandr Suvorov --- sound/soc/codecs/sgtl5000.c | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) (limited to 'sound') diff --git a/sound/soc/codecs/sgtl5000.c b/sound/soc/codecs/sgtl5000.c index a78996a4c85d..aa8bbcdc7228 100644 --- a/sound/soc/codecs/sgtl5000.c +++ b/sound/soc/codecs/sgtl5000.c @@ -35,6 +35,8 @@ #define SGTL5000_DAP_REG_OFFSET 0x0100 #define SGTL5000_MAX_REG_OFFSET 0x013A +#define SGTL5000_VAG_POWERDOWN_TIME 500 /* ms */ + /* default value of sgtl5000 registers */ static const struct reg_default sgtl5000_reg_defaults[] = { { SGTL5000_CHIP_DIG_POWER, 0x0000 }, @@ -161,13 +163,21 @@ static int power_vag_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); - const u32 mask = SGTL5000_DAC_POWERUP | SGTL5000_ADC_POWERUP; + const u32 power_mask = SGTL5000_DAC_POWERUP | SGTL5000_ADC_POWERUP; + const u32 mute_mask = SGTL5000_HP_MUTE | SGTL5000_LINE_OUT_MUTE; + static int reg = 0; switch (event) { - case SND_SOC_DAPM_POST_PMU: + case SND_SOC_DAPM_PRE_PMU: + reg = snd_soc_read(codec, SGTL5000_CHIP_ANA_CTRL); + snd_soc_update_bits(codec, SGTL5000_CHIP_ANA_CTRL, + mute_mask, mute_mask); snd_soc_update_bits(codec, SGTL5000_CHIP_ANA_POWER, SGTL5000_VAG_POWERUP, SGTL5000_VAG_POWERUP); - msleep(400); + break; + case SND_SOC_DAPM_POST_PMU: + snd_soc_update_bits(codec, SGTL5000_CHIP_ANA_CTRL, + mute_mask, reg); break; case SND_SOC_DAPM_PRE_PMD: /* @@ -176,10 +186,10 @@ static int power_vag_event(struct snd_soc_dapm_widget *w, * other one of them. */ if ((snd_soc_read(codec, SGTL5000_CHIP_ANA_POWER) & - mask) != mask) { + power_mask) != power_mask) { snd_soc_update_bits(codec, SGTL5000_CHIP_ANA_POWER, SGTL5000_VAG_POWERUP, 0); - msleep(400); + msleep(SGTL5000_VAG_POWERDOWN_TIME); } break; default: -- cgit v1.2.3