alsa-devel.alsa-project.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/3] ASoC: soc-compress: Add missing brackets around else
@ 2013-01-24  9:44 Charles Keepax
  2013-01-24  9:44 ` [PATCH 2/3] ASoC: soc-compress: Serialise compressed ops Charles Keepax
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Charles Keepax @ 2013-01-24  9:44 UTC (permalink / raw)
  To: broonie
  Cc: vinod.koul, tiwai, patches, alsa-devel, liam.r.girdwood,
	Charles Keepax

Signed-off-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com>
---
 sound/soc/soc-compress.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/sound/soc/soc-compress.c b/sound/soc/soc-compress.c
index 5fbfb06..80040f0 100644
--- a/sound/soc/soc-compress.c
+++ b/sound/soc/soc-compress.c
@@ -112,10 +112,11 @@ static int soc_compr_free(struct snd_compr_stream *cstream)
 			snd_soc_dapm_stream_event(rtd,
 					SNDRV_PCM_STREAM_PLAYBACK,
 					SND_SOC_DAPM_STREAM_STOP);
-		} else
+		} else {
 			rtd->pop_wait = 1;
 			schedule_delayed_work(&rtd->delayed_work,
 				msecs_to_jiffies(rtd->pmdown_time));
+		}
 	} else {
 		/* capture streams can be powered down now */
 		snd_soc_dapm_stream_event(rtd,
-- 
1.7.2.5

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

* [PATCH 2/3] ASoC: soc-compress: Serialise compressed ops
  2013-01-24  9:44 [PATCH 1/3] ASoC: soc-compress: Add missing brackets around else Charles Keepax
@ 2013-01-24  9:44 ` Charles Keepax
  2013-01-24  9:44 ` [PATCH 3/3] ASoC: soc-compress: Initialise delayed work to power down audio Charles Keepax
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Charles Keepax @ 2013-01-24  9:44 UTC (permalink / raw)
  To: broonie
  Cc: vinod.koul, tiwai, patches, alsa-devel, liam.r.girdwood,
	Charles Keepax

Use the pcm_mutex to serialise the compressed ops.

Signed-off-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com>
---
 sound/soc/soc-compress.c |   37 ++++++++++++++++++++++++++++++++++---
 1 files changed, 34 insertions(+), 3 deletions(-)

diff --git a/sound/soc/soc-compress.c b/sound/soc/soc-compress.c
index 80040f0..c48db63 100644
--- a/sound/soc/soc-compress.c
+++ b/sound/soc/soc-compress.c
@@ -33,6 +33,8 @@ static int soc_compr_open(struct snd_compr_stream *cstream)
 	struct snd_soc_dai *codec_dai = rtd->codec_dai;
 	int ret = 0;
 
+	mutex_lock_nested(&rtd->pcm_mutex, rtd->pcm_subclass);
+
 	if (platform->driver->compr_ops && platform->driver->compr_ops->open) {
 		ret = platform->driver->compr_ops->open(cstream);
 		if (ret < 0) {
@@ -61,12 +63,15 @@ static int soc_compr_open(struct snd_compr_stream *cstream)
 	codec_dai->active++;
 	rtd->codec->active++;
 
+	mutex_unlock(&rtd->pcm_mutex);
+
 	return 0;
 
 machine_err:
 	if (platform->driver->compr_ops && platform->driver->compr_ops->free)
 		platform->driver->compr_ops->free(cstream);
 out:
+	mutex_unlock(&rtd->pcm_mutex);
 	return ret;
 }
 
@@ -78,6 +83,8 @@ static int soc_compr_free(struct snd_compr_stream *cstream)
 	struct snd_soc_dai *codec_dai = rtd->codec_dai;
 	struct snd_soc_codec *codec = rtd->codec;
 
+	mutex_lock_nested(&rtd->pcm_mutex, rtd->pcm_subclass);
+
 	if (cstream->direction == SND_COMPRESS_PLAYBACK) {
 		cpu_dai->playback_active--;
 		codec_dai->playback_active--;
@@ -124,6 +131,7 @@ static int soc_compr_free(struct snd_compr_stream *cstream)
 			SND_SOC_DAPM_STREAM_STOP);
 	}
 
+	mutex_unlock(&rtd->pcm_mutex);
 	return 0;
 }
 
@@ -135,10 +143,12 @@ static int soc_compr_trigger(struct snd_compr_stream *cstream, int cmd)
 	struct snd_soc_dai *codec_dai = rtd->codec_dai;
 	int ret = 0;
 
+	mutex_lock_nested(&rtd->pcm_mutex, rtd->pcm_subclass);
+
 	if (platform->driver->compr_ops && platform->driver->compr_ops->trigger) {
 		ret = platform->driver->compr_ops->trigger(cstream, cmd);
 		if (ret < 0)
-			return ret;
+			goto out;
 	}
 
 	if (cmd == SNDRV_PCM_TRIGGER_START)
@@ -146,6 +156,8 @@ static int soc_compr_trigger(struct snd_compr_stream *cstream, int cmd)
 	else if (cmd == SNDRV_PCM_TRIGGER_STOP)
 		snd_soc_dai_digital_mute(codec_dai, 1);
 
+out:
+	mutex_unlock(&rtd->pcm_mutex);
 	return ret;
 }
 
@@ -156,6 +168,8 @@ static int soc_compr_set_params(struct snd_compr_stream *cstream,
 	struct snd_soc_platform *platform = rtd->platform;
 	int ret = 0;
 
+	mutex_lock_nested(&rtd->pcm_mutex, rtd->pcm_subclass);
+
 	/* first we call set_params for the platform driver
 	 * this should configure the soc side
 	 * if the machine has compressed ops then we call that as well
@@ -165,18 +179,20 @@ static int soc_compr_set_params(struct snd_compr_stream *cstream,
 	if (platform->driver->compr_ops && platform->driver->compr_ops->set_params) {
 		ret = platform->driver->compr_ops->set_params(cstream, params);
 		if (ret < 0)
-			return ret;
+			goto out;
 	}
 
 	if (rtd->dai_link->compr_ops && rtd->dai_link->compr_ops->set_params) {
 		ret = rtd->dai_link->compr_ops->set_params(cstream);
 		if (ret < 0)
-			return ret;
+			goto out;
 	}
 
 	snd_soc_dapm_stream_event(rtd, SNDRV_PCM_STREAM_PLAYBACK,
 				SND_SOC_DAPM_STREAM_START);
 
+out:
+	mutex_unlock(&rtd->pcm_mutex);
 	return ret;
 }
 
@@ -187,9 +203,12 @@ static int soc_compr_get_params(struct snd_compr_stream *cstream,
 	struct snd_soc_platform *platform = rtd->platform;
 	int ret = 0;
 
+	mutex_lock_nested(&rtd->pcm_mutex, rtd->pcm_subclass);
+
 	if (platform->driver->compr_ops && platform->driver->compr_ops->get_params)
 		ret = platform->driver->compr_ops->get_params(cstream, params);
 
+	mutex_unlock(&rtd->pcm_mutex);
 	return ret;
 }
 
@@ -200,9 +219,12 @@ static int soc_compr_get_caps(struct snd_compr_stream *cstream,
 	struct snd_soc_platform *platform = rtd->platform;
 	int ret = 0;
 
+	mutex_lock_nested(&rtd->pcm_mutex, rtd->pcm_subclass);
+
 	if (platform->driver->compr_ops && platform->driver->compr_ops->get_caps)
 		ret = platform->driver->compr_ops->get_caps(cstream, caps);
 
+	mutex_unlock(&rtd->pcm_mutex);
 	return ret;
 }
 
@@ -213,9 +235,12 @@ static int soc_compr_get_codec_caps(struct snd_compr_stream *cstream,
 	struct snd_soc_platform *platform = rtd->platform;
 	int ret = 0;
 
+	mutex_lock_nested(&rtd->pcm_mutex, rtd->pcm_subclass);
+
 	if (platform->driver->compr_ops && platform->driver->compr_ops->get_codec_caps)
 		ret = platform->driver->compr_ops->get_codec_caps(cstream, codec);
 
+	mutex_unlock(&rtd->pcm_mutex);
 	return ret;
 }
 
@@ -225,9 +250,12 @@ static int soc_compr_ack(struct snd_compr_stream *cstream, size_t bytes)
 	struct snd_soc_platform *platform = rtd->platform;
 	int ret = 0;
 
+	mutex_lock_nested(&rtd->pcm_mutex, rtd->pcm_subclass);
+
 	if (platform->driver->compr_ops && platform->driver->compr_ops->ack)
 		ret = platform->driver->compr_ops->ack(cstream, bytes);
 
+	mutex_unlock(&rtd->pcm_mutex);
 	return ret;
 }
 
@@ -237,9 +265,12 @@ static int soc_compr_pointer(struct snd_compr_stream *cstream,
 	struct snd_soc_pcm_runtime *rtd = cstream->private_data;
 	struct snd_soc_platform *platform = rtd->platform;
 
+	mutex_lock_nested(&rtd->pcm_mutex, rtd->pcm_subclass);
+
 	if (platform->driver->compr_ops && platform->driver->compr_ops->pointer)
 		 platform->driver->compr_ops->pointer(cstream, tstamp);
 
+	mutex_unlock(&rtd->pcm_mutex);
 	return 0;
 }
 
-- 
1.7.2.5

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

* [PATCH 3/3] ASoC: soc-compress: Initialise delayed work to power down audio
  2013-01-24  9:44 [PATCH 1/3] ASoC: soc-compress: Add missing brackets around else Charles Keepax
  2013-01-24  9:44 ` [PATCH 2/3] ASoC: soc-compress: Serialise compressed ops Charles Keepax
@ 2013-01-24  9:44 ` Charles Keepax
  2013-01-24 10:17 ` [PATCH 1/3] ASoC: soc-compress: Add missing brackets around else Vinod Koul
  2013-01-24 10:54 ` Mark Brown
  3 siblings, 0 replies; 5+ messages in thread
From: Charles Keepax @ 2013-01-24  9:44 UTC (permalink / raw)
  To: broonie
  Cc: vinod.koul, tiwai, patches, alsa-devel, liam.r.girdwood,
	Charles Keepax

Delayed work was scheduled but not initialised, this patch adds the
actual work and initialises it.

Signed-off-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com>
---
 sound/soc/soc-compress.c |   31 +++++++++++++++++++++++++++++++
 1 files changed, 31 insertions(+), 0 deletions(-)

diff --git a/sound/soc/soc-compress.c b/sound/soc/soc-compress.c
index c48db63..3ea7956 100644
--- a/sound/soc/soc-compress.c
+++ b/sound/soc/soc-compress.c
@@ -75,6 +75,34 @@ out:
 	return ret;
 }
 
+/*
+ * Power down the audio subsystem pmdown_time msecs after close is called.
+ * This is to ensure there are no pops or clicks in between any music tracks
+ * due to DAPM power cycling.
+ */
+static void close_delayed_work(struct work_struct *work)
+{
+	struct snd_soc_pcm_runtime *rtd =
+			container_of(work, struct snd_soc_pcm_runtime, delayed_work.work);
+	struct snd_soc_dai *codec_dai = rtd->codec_dai;
+
+	mutex_lock_nested(&rtd->pcm_mutex, rtd->pcm_subclass);
+
+	dev_dbg(rtd->dev, "ASoC: pop wq checking: %s status: %s waiting: %s\n",
+		 codec_dai->driver->playback.stream_name,
+		 codec_dai->playback_active ? "active" : "inactive",
+		 rtd->pop_wait ? "yes" : "no");
+
+	/* are we waiting on this codec DAI stream */
+	if (rtd->pop_wait == 1) {
+		rtd->pop_wait = 0;
+		snd_soc_dapm_stream_event(rtd, SNDRV_PCM_STREAM_PLAYBACK,
+					  SND_SOC_DAPM_STREAM_STOP);
+	}
+
+	mutex_unlock(&rtd->pcm_mutex);
+}
+
 static int soc_compr_free(struct snd_compr_stream *cstream)
 {
 	struct snd_soc_pcm_runtime *rtd = cstream->private_data;
@@ -317,6 +345,9 @@ int soc_new_compress(struct snd_soc_pcm_runtime *rtd, int num)
 		return ret;
 	}
 
+	/* DAPM dai link stream work */
+	INIT_DELAYED_WORK(&rtd->delayed_work, close_delayed_work);
+
 	rtd->compr = compr;
 	compr->private_data = rtd;
 
-- 
1.7.2.5

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

* Re: [PATCH 1/3] ASoC: soc-compress: Add missing brackets around else
  2013-01-24  9:44 [PATCH 1/3] ASoC: soc-compress: Add missing brackets around else Charles Keepax
  2013-01-24  9:44 ` [PATCH 2/3] ASoC: soc-compress: Serialise compressed ops Charles Keepax
  2013-01-24  9:44 ` [PATCH 3/3] ASoC: soc-compress: Initialise delayed work to power down audio Charles Keepax
@ 2013-01-24 10:17 ` Vinod Koul
  2013-01-24 10:54 ` Mark Brown
  3 siblings, 0 replies; 5+ messages in thread
From: Vinod Koul @ 2013-01-24 10:17 UTC (permalink / raw)
  To: Charles Keepax; +Cc: alsa-devel, patches, tiwai, broonie, liam.r.girdwood

On Thu, 2013-01-24 at 09:44 +0000, Charles Keepax wrote:
> Signed-off-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com>
> ---
>  sound/soc/soc-compress.c |    3 ++-
>  1 files changed, 2 insertions(+), 1 deletions(-)
> 
> diff --git a/sound/soc/soc-compress.c b/sound/soc/soc-compress.c
> index 5fbfb06..80040f0 100644
> --- a/sound/soc/soc-compress.c
> +++ b/sound/soc/soc-compress.c
> @@ -112,10 +112,11 @@ static int soc_compr_free(struct snd_compr_stream *cstream)
>  			snd_soc_dapm_stream_event(rtd,
>  					SNDRV_PCM_STREAM_PLAYBACK,
>  					SND_SOC_DAPM_STREAM_STOP);
> -		} else
> +		} else {
>  			rtd->pop_wait = 1;
>  			schedule_delayed_work(&rtd->delayed_work,
>  				msecs_to_jiffies(rtd->pmdown_time));
> +		}
>  	} else {
>  		/* capture streams can be powered down now */
>  		snd_soc_dapm_stream_event(rtd,

All three:
Acked-by: Vinod Koul <vinod.koul@intel.com>
Tested-by: Jeeja KP <jeeja.kp@intel.com>

We had the similar fixes on our BSP, I have one more, will send shortly

Thanks
-- 
~Vinod

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

* Re: [PATCH 1/3] ASoC: soc-compress: Add missing brackets around else
  2013-01-24  9:44 [PATCH 1/3] ASoC: soc-compress: Add missing brackets around else Charles Keepax
                   ` (2 preceding siblings ...)
  2013-01-24 10:17 ` [PATCH 1/3] ASoC: soc-compress: Add missing brackets around else Vinod Koul
@ 2013-01-24 10:54 ` Mark Brown
  3 siblings, 0 replies; 5+ messages in thread
From: Mark Brown @ 2013-01-24 10:54 UTC (permalink / raw)
  To: Charles Keepax; +Cc: vinod.koul, tiwai, patches, alsa-devel, liam.r.girdwood


[-- Attachment #1.1: Type: text/plain, Size: 152 bytes --]

On Thu, Jan 24, 2013 at 09:44:28AM +0000, Charles Keepax wrote:
> Signed-off-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com>

Applied, thanks.

[-- Attachment #1.2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

[-- Attachment #2: Type: text/plain, Size: 0 bytes --]



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

end of thread, other threads:[~2013-01-24 10:54 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-01-24  9:44 [PATCH 1/3] ASoC: soc-compress: Add missing brackets around else Charles Keepax
2013-01-24  9:44 ` [PATCH 2/3] ASoC: soc-compress: Serialise compressed ops Charles Keepax
2013-01-24  9:44 ` [PATCH 3/3] ASoC: soc-compress: Initialise delayed work to power down audio Charles Keepax
2013-01-24 10:17 ` [PATCH 1/3] ASoC: soc-compress: Add missing brackets around else Vinod Koul
2013-01-24 10:54 ` Mark Brown

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).