alsa-devel.alsa-project.org archive mirror
 help / color / mirror / Atom feed
From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
To: Mark Brown <broonie@kernel.org>
Cc: Linux-ALSA <alsa-devel@alsa-project.org>
Subject: [alsa-devel] [PATCH v3 resend 7/8] ASoC: soc-dapm: add snd_soc_dapm_stream_stop()
Date: 10 Jan 2020 11:36:23 +0900	[thread overview]
Message-ID: <871rs8t4uw.wl-kuninori.morimoto.gx@renesas.com> (raw)
In-Reply-To: <87blrct4xg.wl-kuninori.morimoto.gx@renesas.com>


From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

When we stop stream, if it was Playback, we might need to care
about power down time. In such case, we need to use delayed work.

We have same implementation for it at soc-pcm.c and soc-compress.c,
but we don't want to have duplicate code.
This patch adds snd_soc_dapm_stream_stop(), and share same code.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Reviewed-By: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
---
 include/sound/soc-dapm.h |  1 +
 sound/soc/soc-compress.c | 18 +-----------------
 sound/soc/soc-dapm.c     | 23 +++++++++++++++++++++++
 sound/soc/soc-pcm.c      | 19 +------------------
 4 files changed, 26 insertions(+), 35 deletions(-)

diff --git a/include/sound/soc-dapm.h b/include/sound/soc-dapm.h
index 6e8a312..1b6afbc 100644
--- a/include/sound/soc-dapm.h
+++ b/include/sound/soc-dapm.h
@@ -434,6 +434,7 @@ void snd_soc_dapm_reset_cache(struct snd_soc_dapm_context *dapm);
 /* dapm events */
 void snd_soc_dapm_stream_event(struct snd_soc_pcm_runtime *rtd, int stream,
 	int event);
+void snd_soc_dapm_stream_stop(struct snd_soc_pcm_runtime *rtd, int stream);
 void snd_soc_dapm_shutdown(struct snd_soc_card *card);
 
 /* external DAPM widget events */
diff --git a/sound/soc/soc-compress.c b/sound/soc/soc-compress.c
index 7249471..392a1c5 100644
--- a/sound/soc/soc-compress.c
+++ b/sound/soc/soc-compress.c
@@ -259,23 +259,7 @@ static int soc_compr_free(struct snd_compr_stream *cstream)
 	if (cpu_dai->driver->cops && cpu_dai->driver->cops->shutdown)
 		cpu_dai->driver->cops->shutdown(cstream, cpu_dai);
 
-	if (cstream->direction == SND_COMPRESS_PLAYBACK) {
-		if (snd_soc_runtime_ignore_pmdown_time(rtd)) {
-			snd_soc_dapm_stream_event(rtd,
-						  SNDRV_PCM_STREAM_PLAYBACK,
-						  SND_SOC_DAPM_STREAM_STOP);
-		} else {
-			rtd->pop_wait = 1;
-			queue_delayed_work(system_power_efficient_wq,
-					   &rtd->delayed_work,
-					   msecs_to_jiffies(rtd->pmdown_time));
-		}
-	} else {
-		/* capture streams can be powered down now */
-		snd_soc_dapm_stream_event(rtd,
-					  SNDRV_PCM_STREAM_CAPTURE,
-					  SND_SOC_DAPM_STREAM_STOP);
-	}
+	snd_soc_dapm_stream_stop(rtd, stream);
 
 	mutex_unlock(&rtd->card->pcm_mutex);
 
diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c
index b6378f0..442846f 100644
--- a/sound/soc/soc-dapm.c
+++ b/sound/soc/soc-dapm.c
@@ -4447,6 +4447,29 @@ void snd_soc_dapm_stream_event(struct snd_soc_pcm_runtime *rtd, int stream,
 	mutex_unlock(&card->dapm_mutex);
 }
 
+void snd_soc_dapm_stream_stop(struct snd_soc_pcm_runtime *rtd, int stream)
+{
+	if (stream == SNDRV_PCM_STREAM_PLAYBACK) {
+		if (snd_soc_runtime_ignore_pmdown_time(rtd)) {
+			/* powered down playback stream now */
+			snd_soc_dapm_stream_event(rtd,
+						  SNDRV_PCM_STREAM_PLAYBACK,
+						  SND_SOC_DAPM_STREAM_STOP);
+		} else {
+			/* start delayed pop wq here for playback streams */
+			rtd->pop_wait = 1;
+			queue_delayed_work(system_power_efficient_wq,
+					   &rtd->delayed_work,
+					   msecs_to_jiffies(rtd->pmdown_time));
+		}
+	} else {
+		/* capture streams can be powered down now */
+		snd_soc_dapm_stream_event(rtd, SNDRV_PCM_STREAM_CAPTURE,
+					  SND_SOC_DAPM_STREAM_STOP);
+	}
+}
+EXPORT_SYMBOL_GPL(snd_soc_dapm_stream_stop);
+
 /**
  * snd_soc_dapm_enable_pin_unlocked - enable pin.
  * @dapm: DAPM context
diff --git a/sound/soc/soc-pcm.c b/sound/soc/soc-pcm.c
index ad908e0..dfff2dd 100644
--- a/sound/soc/soc-pcm.c
+++ b/sound/soc/soc-pcm.c
@@ -672,24 +672,7 @@ static int soc_pcm_close(struct snd_pcm_substream *substream)
 
 	soc_pcm_components_close(substream, NULL);
 
-	if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
-		if (snd_soc_runtime_ignore_pmdown_time(rtd)) {
-			/* powered down playback stream now */
-			snd_soc_dapm_stream_event(rtd,
-						  SNDRV_PCM_STREAM_PLAYBACK,
-						  SND_SOC_DAPM_STREAM_STOP);
-		} else {
-			/* start delayed pop wq here for playback streams */
-			rtd->pop_wait = 1;
-			queue_delayed_work(system_power_efficient_wq,
-					   &rtd->delayed_work,
-					   msecs_to_jiffies(rtd->pmdown_time));
-		}
-	} else {
-		/* capture streams can be powered down now */
-		snd_soc_dapm_stream_event(rtd, SNDRV_PCM_STREAM_CAPTURE,
-					  SND_SOC_DAPM_STREAM_STOP);
-	}
+	snd_soc_dapm_stream_stop(rtd, substream->stream);
 
 	mutex_unlock(&rtd->card->pcm_mutex);
 
-- 
2.7.4

_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel

  parent reply	other threads:[~2020-01-10  2:41 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-01-10  2:34 [alsa-devel] [PATCH v3 resend 0/8] ASoC: soc-core cleanup step8 Kuninori Morimoto
2020-01-10  2:35 ` [alsa-devel] [PATCH v3 resend 1/8] ASoC: soc-core: remove snd_soc_rtdcom_list Kuninori Morimoto
2020-01-10 13:37   ` [alsa-devel] Applied "ASoC: soc-core: remove snd_soc_rtdcom_list" to the asoc tree Mark Brown
2020-01-10  2:35 ` [alsa-devel] [PATCH v3 resend 2/8] ASoC: soc-core: rename snd_soc_rtdcom_add() to snd_soc_rtd_add_component() Kuninori Morimoto
2020-01-10 13:37   ` [alsa-devel] Applied "ASoC: soc-core: rename snd_soc_rtdcom_add() to snd_soc_rtd_add_component()" to the asoc tree Mark Brown
2020-01-10  2:36 ` [alsa-devel] [PATCH v3 resend 3/8] ASoC: soc-core: care .ignore_suspend for Component suspend Kuninori Morimoto
2020-01-10 13:37   ` [alsa-devel] Applied "ASoC: soc-core: care .ignore_suspend for Component suspend" to the asoc tree Mark Brown
2020-01-10  2:36 ` [alsa-devel] [PATCH v3 resend 4/8] ASoC: soc-core: remove duplicate pinctrl operation when suspend Kuninori Morimoto
2020-01-10 13:37   ` [alsa-devel] Applied "ASoC: soc-core: remove duplicate pinctrl operation when suspend" to the asoc tree Mark Brown
2020-01-10  2:36 ` [alsa-devel] [PATCH v3 resend 5/8] ASoC: soc-core: do pinctrl_pm_select_xxx() as component Kuninori Morimoto
2020-01-10 13:37   ` [alsa-devel] Applied "ASoC: soc-core: do pinctrl_pm_select_xxx() as component" to the asoc tree Mark Brown
2020-01-10  2:36 ` [alsa-devel] [PATCH v3 resend 6/8] ASoC: soc-core: add snd_soc_close_delayed_work() Kuninori Morimoto
2020-01-10 13:37   ` [alsa-devel] Applied "ASoC: soc-core: add snd_soc_close_delayed_work()" to the asoc tree Mark Brown
2020-01-10  2:36 ` Kuninori Morimoto [this message]
2020-01-10 13:37   ` [alsa-devel] Applied "ASoC: soc-dapm: add snd_soc_dapm_stream_stop()" " Mark Brown
2020-01-10  2:36 ` [alsa-devel] [PATCH v3 resend 8/8] ASoC: soc-pcm/soc-compress: use snd_soc_dapm_stream_stop() for SND_SOC_DAPM_STREAM_STOP Kuninori Morimoto
2020-01-10 13:37   ` [alsa-devel] Applied "ASoC: soc-pcm/soc-compress: use snd_soc_dapm_stream_stop() for SND_SOC_DAPM_STREAM_STOP" to the asoc tree Mark Brown

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=871rs8t4uw.wl-kuninori.morimoto.gx@renesas.com \
    --to=kuninori.morimoto.gx@renesas.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=broonie@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).