From 054e1b4892271731453fbfa8658899050196e427 Mon Sep 17 00:00:00 2001 From: Charles Keepax Date: Tue, 20 Jan 2015 16:31:50 +0000 Subject: ASoC: arizona: Add delay for output disable Give the output disable sequence a chance to fully complete, otherwise there is a danger we may remove the clock before it is finished resulting in a pop noise. The delay for each output must be cumulative and these are coalesced into a single delay. Signed-off-by: Charles Keepax Signed-off-by: Mark Brown --- sound/soc/codecs/arizona.c | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) (limited to 'sound/soc/codecs/arizona.c') diff --git a/sound/soc/codecs/arizona.c b/sound/soc/codecs/arizona.c index 9550d74..9e203ef 100644 --- a/sound/soc/codecs/arizona.c +++ b/sound/soc/codecs/arizona.c @@ -734,6 +734,8 @@ int arizona_out_ev(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { + struct arizona_priv *priv = snd_soc_codec_get_drvdata(w->codec); + switch (event) { case SND_SOC_DAPM_POST_PMU: switch (w->shift) { @@ -750,6 +752,39 @@ int arizona_out_ev(struct snd_soc_dapm_widget *w, break; } break; + case SND_SOC_DAPM_PRE_PMD: + switch (w->shift) { + case ARIZONA_OUT1L_ENA_SHIFT: + case ARIZONA_OUT1R_ENA_SHIFT: + case ARIZONA_OUT2L_ENA_SHIFT: + case ARIZONA_OUT2R_ENA_SHIFT: + case ARIZONA_OUT3L_ENA_SHIFT: + case ARIZONA_OUT3R_ENA_SHIFT: + priv->out_down_pending++; + priv->out_down_delay++; + break; + default: + break; + } + break; + case SND_SOC_DAPM_POST_PMD: + switch (w->shift) { + case ARIZONA_OUT1L_ENA_SHIFT: + case ARIZONA_OUT1R_ENA_SHIFT: + case ARIZONA_OUT2L_ENA_SHIFT: + case ARIZONA_OUT2R_ENA_SHIFT: + case ARIZONA_OUT3L_ENA_SHIFT: + case ARIZONA_OUT3R_ENA_SHIFT: + priv->out_down_pending--; + if (!priv->out_down_pending) { + msleep(priv->out_down_delay); + priv->out_down_delay = 0; + } + break; + default: + break; + } + break; } return 0; @@ -772,6 +807,8 @@ int arizona_hp_ev(struct snd_soc_dapm_widget *w, case SND_SOC_DAPM_PRE_PMD: val = 0; break; + case SND_SOC_DAPM_POST_PMD: + return arizona_out_ev(w, kcontrol, event); default: return -EINVAL; } -- cgit v1.1