All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ASoC: Suppress early calls to snd_soc_dapm_sync()
@ 2011-10-07 13:34 Mark Brown
  2011-10-07 14:18 ` Péter Ujfalusi
  0 siblings, 1 reply; 3+ messages in thread
From: Mark Brown @ 2011-10-07 13:34 UTC (permalink / raw)
  To: Peter Ujfalusi, Liam Girdwood; +Cc: alsa-devel, patches, Mark Brown

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 |    1 +
 sound/soc/soc-dapm.c |    7 +++++++
 2 files changed, 8 insertions(+), 0 deletions(-)

diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index 2a25076..b65e3d4 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -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;
 
diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c
index 8711aab..e49c56d 100644
--- a/sound/soc/soc-dapm.c
+++ b/sound/soc/soc-dapm.c
@@ -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);
-- 
1.7.6.3

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] ASoC: Suppress early calls to snd_soc_dapm_sync()
  2011-10-07 13:34 [PATCH] ASoC: Suppress early calls to snd_soc_dapm_sync() Mark Brown
@ 2011-10-07 14:18 ` Péter Ujfalusi
  2011-10-07 14:33   ` Mark Brown
  0 siblings, 1 reply; 3+ messages in thread
From: Péter Ujfalusi @ 2011-10-07 14:18 UTC (permalink / raw)
  To: Mark Brown; +Cc: alsa-devel, patches, Liam Girdwood

On Friday 07 October 2011 14:34:02 Mark Brown wrote:
> 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 |    1 +
>  sound/soc/soc-dapm.c |    7 +++++++
>  2 files changed, 8 insertions(+), 0 deletions(-)
> 
> diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
> index 2a25076..b65e3d4 100644
> --- a/sound/soc/soc-core.c
> +++ b/sound/soc/soc-core.c
> @@ -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);

Without prior snd_soc_dapm_new_widgets() call we just moved the kernel crash
here.

>  	mutex_unlock(&card->mutex);
>  	return;
> 
> diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c
> index 8711aab..e49c56d 100644
> --- a/sound/soc/soc-dapm.c
> +++ b/sound/soc/soc-dapm.c
> @@ -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);

--
Péter

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] ASoC: Suppress early calls to snd_soc_dapm_sync()
  2011-10-07 14:18 ` Péter Ujfalusi
@ 2011-10-07 14:33   ` Mark Brown
  0 siblings, 0 replies; 3+ messages in thread
From: Mark Brown @ 2011-10-07 14:33 UTC (permalink / raw)
  To: Péter Ujfalusi; +Cc: alsa-devel, patches, Liam Girdwood

On Fri, Oct 07, 2011 at 05:18:19PM +0300, Péter Ujfalusi wrote:
> On Friday 07 October 2011 14:34:02 Mark Brown wrote:

> >  	card->instantiated = 1;
> > +	snd_soc_dapm_sync(&card->dapm);

> Without prior snd_soc_dapm_new_widgets() call we just moved the kernel crash
> here.

As I keep saying new_wigets() is orthogonal to the syncing.  They are
two totally separate issues.  There's a good solid reason why I didn't
mention any issues with uninitialized widgets in the changelog which is
that this patch is not intended to help with that in any way, it's
intended to stop us wasting our time (and potentially introducing pops
and clicks from bouncing power) performing needless syncs while starting
up.

The syncs that are being suppressed are totally pointless regardless of
anything else.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2011-10-07 14:33 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-10-07 13:34 [PATCH] ASoC: Suppress early calls to snd_soc_dapm_sync() Mark Brown
2011-10-07 14:18 ` Péter Ujfalusi
2011-10-07 14:33   ` Mark Brown

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.