ASoC: Suppress early calls to snd_soc_dapm_sync()
authorMark Brown <broonie@opensource.wolfsonmicro.com>
Fri, 7 Oct 2011 13:29:19 +0000 (14:29 +0100)
committerMark Brown <broonie@opensource.wolfsonmicro.com>
Sat, 8 Oct 2011 10:47:32 +0000 (11:47 +0100)
Ensure we only have one sync during the initial startup of the card by
making snd_soc_dapm_sync() a noop on non-instantiated cards. This avoids
any bounces due to things like jacks reporting their initial state on
partially initialised cards. The callers that don't also get called at
runtime should just be removed.

Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
sound/soc/soc-core.c
sound/soc/soc-dapm.c

index 2a2507627520e88738fc178d447f24bd93dc2a89..b65e3d40177c48904c7fbf2acf58ac3a95b3ece6 100644 (file)
@@ -1498,6 +1498,7 @@ static void snd_soc_instantiate_card(struct snd_soc_card *card)
 #endif
 
        card->instantiated = 1;
+       snd_soc_dapm_sync(&card->dapm);
        mutex_unlock(&card->mutex);
        return;
 
index 8711aab01445fd2969705dbe7a6a1f7c803000e6..e49c56d4951e6ce4288d822c066acbb9e2303554 100644 (file)
@@ -1845,6 +1845,13 @@ static int snd_soc_dapm_set_pin(struct snd_soc_dapm_context *dapm,
  */
 int snd_soc_dapm_sync(struct snd_soc_dapm_context *dapm)
 {
+       /*
+        * Suppress early reports (eg, jacks syncing their state) to avoid
+        * silly DAPM runs during card startup.
+        */
+       if (!dapm->card || !dapm->card->instantiated)
+               return 0;
+
        return dapm_power_widgets(dapm, SND_SOC_DAPM_STREAM_NOP);
 }
 EXPORT_SYMBOL_GPL(snd_soc_dapm_sync);