All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 resend 0/6] ASoC: soc-pcm cleanup step5
@ 2020-03-06  1:09 Kuninori Morimoto
  2020-03-06  1:09 ` [PATCH v2 resend 1/6] ASoC: soc-pcm: move dpcm_fe_dai_close() Kuninori Morimoto
                   ` (5 more replies)
  0 siblings, 6 replies; 9+ messages in thread
From: Kuninori Morimoto @ 2020-03-06  1:09 UTC (permalink / raw)
  To: Mark Brown; +Cc: Linux-ALSA


Hi Mark

These are v2 resend of soc-pcm cleanup step5.
1) - 4) are rebased to latest for-5.7 branch.
5) - 6) are remaked of previous [6/8], [7/8] which were mistaken patch.

Kuninori Morimoto (6):
  1) ASoC: soc-pcm: move dpcm_fe_dai_close()
  2) ASoC: soc-pcm: add dpcm_fe_dai_cleanup()
  3) ASoC: soc-pcm: use snd_soc_dai_get_pcm_stream() at dpcm_set_fe_runtime()
  4) ASoC: soc-pcm: tidyup dulicate handing at dpcm_fe_dai_startup()
  5) ASoC: soc-pcm: check DAI's activity more simply
  6) ASoC: soc-pcm: Do Digital Mute for both CPU/Codec in same timing.

 sound/soc/soc-pcm.c | 97 ++++++++++++++++++++++-----------------------
 1 file changed, 47 insertions(+), 50 deletions(-)

-- 
2.17.1


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

* [PATCH v2 resend 1/6] ASoC: soc-pcm: move dpcm_fe_dai_close()
  2020-03-06  1:09 [PATCH v2 resend 0/6] ASoC: soc-pcm cleanup step5 Kuninori Morimoto
@ 2020-03-06  1:09 ` Kuninori Morimoto
  2020-03-06  1:09 ` [PATCH v2 resend 2/6] ASoC: soc-pcm: add dpcm_fe_dai_cleanup() Kuninori Morimoto
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 9+ messages in thread
From: Kuninori Morimoto @ 2020-03-06  1:09 UTC (permalink / raw)
  To: Mark Brown; +Cc: Linux-ALSA


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

move dpcm_fe_dai_close() next to dpcm_fe_dai_open().
This is prepare for dpcm_fe_dai_open() cleanup

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Reviewed-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
---
 sound/soc/soc-pcm.c | 40 ++++++++++++++++++++--------------------
 1 file changed, 20 insertions(+), 20 deletions(-)

diff --git a/sound/soc/soc-pcm.c b/sound/soc/soc-pcm.c
index e3a2c4f7757b..3686dda097e2 100644
--- a/sound/soc/soc-pcm.c
+++ b/sound/soc/soc-pcm.c
@@ -2978,6 +2978,26 @@ int soc_dpcm_runtime_update(struct snd_soc_card *card)
 	return ret;
 }
 
+static int dpcm_fe_dai_close(struct snd_pcm_substream *fe_substream)
+{
+	struct snd_soc_pcm_runtime *fe = fe_substream->private_data;
+	struct snd_soc_dpcm *dpcm;
+	int stream = fe_substream->stream, ret;
+
+	mutex_lock_nested(&fe->card->mutex, SND_SOC_CARD_CLASS_RUNTIME);
+	ret = dpcm_fe_dai_shutdown(fe_substream);
+
+	/* mark FE's links ready to prune */
+	for_each_dpcm_be(fe, stream, dpcm)
+		dpcm->state = SND_SOC_DPCM_LINK_STATE_FREE;
+
+	dpcm_be_disconnect(fe, stream);
+
+	fe->dpcm[stream].runtime = NULL;
+	mutex_unlock(&fe->card->mutex);
+	return ret;
+}
+
 static int dpcm_fe_dai_open(struct snd_pcm_substream *fe_substream)
 {
 	struct snd_soc_pcm_runtime *fe = fe_substream->private_data;
@@ -3017,26 +3037,6 @@ static int dpcm_fe_dai_open(struct snd_pcm_substream *fe_substream)
 	return ret;
 }
 
-static int dpcm_fe_dai_close(struct snd_pcm_substream *fe_substream)
-{
-	struct snd_soc_pcm_runtime *fe = fe_substream->private_data;
-	struct snd_soc_dpcm *dpcm;
-	int stream = fe_substream->stream, ret;
-
-	mutex_lock_nested(&fe->card->mutex, SND_SOC_CARD_CLASS_RUNTIME);
-	ret = dpcm_fe_dai_shutdown(fe_substream);
-
-	/* mark FE's links ready to prune */
-	for_each_dpcm_be(fe, stream, dpcm)
-		dpcm->state = SND_SOC_DPCM_LINK_STATE_FREE;
-
-	dpcm_be_disconnect(fe, stream);
-
-	fe->dpcm[stream].runtime = NULL;
-	mutex_unlock(&fe->card->mutex);
-	return ret;
-}
-
 /* create a new pcm */
 int soc_new_pcm(struct snd_soc_pcm_runtime *rtd, int num)
 {
-- 
2.17.1


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

* [PATCH v2 resend 2/6] ASoC: soc-pcm: add dpcm_fe_dai_cleanup()
  2020-03-06  1:09 [PATCH v2 resend 0/6] ASoC: soc-pcm cleanup step5 Kuninori Morimoto
  2020-03-06  1:09 ` [PATCH v2 resend 1/6] ASoC: soc-pcm: move dpcm_fe_dai_close() Kuninori Morimoto
@ 2020-03-06  1:09 ` Kuninori Morimoto
  2020-03-06  1:09 ` [PATCH v2 resend 3/6] ASoC: soc-pcm: use snd_soc_dai_get_pcm_stream() at dpcm_set_fe_runtime() Kuninori Morimoto
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 9+ messages in thread
From: Kuninori Morimoto @ 2020-03-06  1:09 UTC (permalink / raw)
  To: Mark Brown; +Cc: Linux-ALSA


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

dpcm_fe_dai_close() and error case of dpcm_fe_dai_open()
need to do same cleanup operation.
To avoid duplicate code, this patch adds dpcm_fe_dai_cleanup()
and use it.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Reviewed-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
---
 sound/soc/soc-pcm.c | 30 ++++++++++++++++--------------
 1 file changed, 16 insertions(+), 14 deletions(-)

diff --git a/sound/soc/soc-pcm.c b/sound/soc/soc-pcm.c
index 3686dda097e2..b405fb3a181b 100644
--- a/sound/soc/soc-pcm.c
+++ b/sound/soc/soc-pcm.c
@@ -2978,14 +2978,11 @@ int soc_dpcm_runtime_update(struct snd_soc_card *card)
 	return ret;
 }
 
-static int dpcm_fe_dai_close(struct snd_pcm_substream *fe_substream)
+static void dpcm_fe_dai_cleanup(struct snd_pcm_substream *fe_substream)
 {
 	struct snd_soc_pcm_runtime *fe = fe_substream->private_data;
 	struct snd_soc_dpcm *dpcm;
-	int stream = fe_substream->stream, ret;
-
-	mutex_lock_nested(&fe->card->mutex, SND_SOC_CARD_CLASS_RUNTIME);
-	ret = dpcm_fe_dai_shutdown(fe_substream);
+	int stream = fe_substream->stream;
 
 	/* mark FE's links ready to prune */
 	for_each_dpcm_be(fe, stream, dpcm)
@@ -2994,6 +2991,18 @@ static int dpcm_fe_dai_close(struct snd_pcm_substream *fe_substream)
 	dpcm_be_disconnect(fe, stream);
 
 	fe->dpcm[stream].runtime = NULL;
+}
+
+static int dpcm_fe_dai_close(struct snd_pcm_substream *fe_substream)
+{
+	struct snd_soc_pcm_runtime *fe = fe_substream->private_data;
+	int ret;
+
+	mutex_lock_nested(&fe->card->mutex, SND_SOC_CARD_CLASS_RUNTIME);
+	ret = dpcm_fe_dai_shutdown(fe_substream);
+
+	dpcm_fe_dai_cleanup(fe_substream);
+
 	mutex_unlock(&fe->card->mutex);
 	return ret;
 }
@@ -3001,7 +3010,6 @@ static int dpcm_fe_dai_close(struct snd_pcm_substream *fe_substream)
 static int dpcm_fe_dai_open(struct snd_pcm_substream *fe_substream)
 {
 	struct snd_soc_pcm_runtime *fe = fe_substream->private_data;
-	struct snd_soc_dpcm *dpcm;
 	struct snd_soc_dapm_widget_list *list;
 	int ret;
 	int stream = fe_substream->stream;
@@ -3021,14 +3029,8 @@ static int dpcm_fe_dai_open(struct snd_pcm_substream *fe_substream)
 	dpcm_process_paths(fe, stream, &list, 1);
 
 	ret = dpcm_fe_dai_startup(fe_substream);
-	if (ret < 0) {
-		/* clean up all links */
-		for_each_dpcm_be(fe, stream, dpcm)
-			dpcm->state = SND_SOC_DPCM_LINK_STATE_FREE;
-
-		dpcm_be_disconnect(fe, stream);
-		fe->dpcm[stream].runtime = NULL;
-	}
+	if (ret < 0)
+		dpcm_fe_dai_cleanup(fe_substream);
 
 	dpcm_clear_pending_state(fe, stream);
 	dpcm_path_put(&list);
-- 
2.17.1


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

* [PATCH v2 resend 3/6] ASoC: soc-pcm: use snd_soc_dai_get_pcm_stream() at dpcm_set_fe_runtime()
  2020-03-06  1:09 [PATCH v2 resend 0/6] ASoC: soc-pcm cleanup step5 Kuninori Morimoto
  2020-03-06  1:09 ` [PATCH v2 resend 1/6] ASoC: soc-pcm: move dpcm_fe_dai_close() Kuninori Morimoto
  2020-03-06  1:09 ` [PATCH v2 resend 2/6] ASoC: soc-pcm: add dpcm_fe_dai_cleanup() Kuninori Morimoto
@ 2020-03-06  1:09 ` Kuninori Morimoto
  2020-03-06  1:09 ` [PATCH v2 resend 4/6] ASoC: soc-pcm: tidyup dulicate handing at dpcm_fe_dai_startup() Kuninori Morimoto
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 9+ messages in thread
From: Kuninori Morimoto @ 2020-03-06  1:09 UTC (permalink / raw)
  To: Mark Brown; +Cc: Linux-ALSA

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

We already have snd_soc_dai_get_pcm_stream(),
let's use it

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Reviewed-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
---
 sound/soc/soc-pcm.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/sound/soc/soc-pcm.c b/sound/soc/soc-pcm.c
index b405fb3a181b..3a30776858bf 100644
--- a/sound/soc/soc-pcm.c
+++ b/sound/soc/soc-pcm.c
@@ -2022,7 +2022,6 @@ static void dpcm_set_fe_runtime(struct snd_pcm_substream *substream)
 	struct snd_pcm_runtime *runtime = substream->runtime;
 	struct snd_soc_pcm_runtime *rtd = substream->private_data;
 	struct snd_soc_dai *cpu_dai;
-	struct snd_soc_dai_driver *cpu_dai_drv;
 	int i;
 
 	for_each_rtd_cpu_dai(rtd, i, cpu_dai) {
@@ -2033,11 +2032,9 @@ static void dpcm_set_fe_runtime(struct snd_pcm_substream *substream)
 		if (!snd_soc_dai_stream_valid(cpu_dai, substream->stream))
 			continue;
 
-		cpu_dai_drv = cpu_dai->driver;
-		if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
-			dpcm_init_runtime_hw(runtime, &cpu_dai_drv->playback);
-		else
-			dpcm_init_runtime_hw(runtime, &cpu_dai_drv->capture);
+		dpcm_init_runtime_hw(runtime,
+			snd_soc_dai_get_pcm_stream(cpu_dai,
+						   substream->stream));
 	}
 
 	dpcm_runtime_merge_format(substream, &runtime->hw.formats);
-- 
2.17.1


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

* [PATCH v2 resend 4/6] ASoC: soc-pcm: tidyup dulicate handing at dpcm_fe_dai_startup()
  2020-03-06  1:09 [PATCH v2 resend 0/6] ASoC: soc-pcm cleanup step5 Kuninori Morimoto
                   ` (2 preceding siblings ...)
  2020-03-06  1:09 ` [PATCH v2 resend 3/6] ASoC: soc-pcm: use snd_soc_dai_get_pcm_stream() at dpcm_set_fe_runtime() Kuninori Morimoto
@ 2020-03-06  1:09 ` Kuninori Morimoto
  2020-03-06  1:10 ` [PATCH v2 resend 5/6] ASoC: soc-pcm: check DAI's activity more simply Kuninori Morimoto
  2020-03-06  1:10 ` [PATCH v2 resend 6/6] ASoC: soc-pcm: Do Digital Mute for both CPU/Codec in same timing Kuninori Morimoto
  5 siblings, 0 replies; 9+ messages in thread
From: Kuninori Morimoto @ 2020-03-06  1:09 UTC (permalink / raw)
  To: Mark Brown; +Cc: Linux-ALSA

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

error handling at dpcm_fe_dai_startup() has duplicate code.
This patch tidyup it.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Reviewed-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
---
 sound/soc/soc-pcm.c | 10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)

diff --git a/sound/soc/soc-pcm.c b/sound/soc/soc-pcm.c
index 3a30776858bf..7d787e0966f3 100644
--- a/sound/soc/soc-pcm.c
+++ b/sound/soc/soc-pcm.c
@@ -2162,17 +2162,13 @@ static int dpcm_fe_dai_startup(struct snd_pcm_substream *fe_substream)
 	snd_pcm_limit_hw_rates(runtime);
 
 	ret = dpcm_apply_symmetry(fe_substream, stream);
-	if (ret < 0) {
+	if (ret < 0)
 		dev_err(fe->dev, "ASoC: failed to apply dpcm symmetry %d\n",
 			ret);
-		goto unwind;
-	}
-
-	dpcm_set_fe_update_state(fe, stream, SND_SOC_DPCM_UPDATE_NO);
-	return 0;
 
 unwind:
-	dpcm_be_dai_startup_unwind(fe, stream);
+	if (ret < 0)
+		dpcm_be_dai_startup_unwind(fe, stream);
 be_err:
 	dpcm_set_fe_update_state(fe, stream, SND_SOC_DPCM_UPDATE_NO);
 	return ret;
-- 
2.17.1


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

* [PATCH v2 resend 5/6] ASoC: soc-pcm: check DAI's activity more simply
  2020-03-06  1:09 [PATCH v2 resend 0/6] ASoC: soc-pcm cleanup step5 Kuninori Morimoto
                   ` (3 preceding siblings ...)
  2020-03-06  1:09 ` [PATCH v2 resend 4/6] ASoC: soc-pcm: tidyup dulicate handing at dpcm_fe_dai_startup() Kuninori Morimoto
@ 2020-03-06  1:10 ` Kuninori Morimoto
  2020-03-06 15:03   ` Applied "ASoC: soc-pcm: check DAI's activity more simply" to the asoc tree Mark Brown
  2020-03-06  1:10 ` [PATCH v2 resend 6/6] ASoC: soc-pcm: Do Digital Mute for both CPU/Codec in same timing Kuninori Morimoto
  5 siblings, 1 reply; 9+ messages in thread
From: Kuninori Morimoto @ 2020-03-06  1:10 UTC (permalink / raw)
  To: Mark Brown; +Cc: Linux-ALSA


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

soc_pcm_hw_free() want to call snd_soc_dai_digital_mute()
if it was last user of Playback or Capture.

	bool playback = substream->stream == SNDRV_PCM_STREAM_PLAYBACK;
	int playback_active = dai->stream_active[SNDRV_PCM_STREAM_PLAYBACK];
	int capture_active  = dai->stream_active[SNDRV_PCM_STREAM_CAPTURE];

	if ((playback  && playback_active == 1) ||
	    (!playback && capture_active  == 1))
		snd_soc_dai_digital_mute(...)

But it is same as

	int active = dai->stream_active[substream->stream];

	if (active == 1)
		snd_soc_dai_digital_mute(...)

This patch simplify the code.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
 sound/soc/soc-pcm.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/sound/soc/soc-pcm.c b/sound/soc/soc-pcm.c
index 7d787e0966f3..af0e17bfeeab 100644
--- a/sound/soc/soc-pcm.c
+++ b/sound/soc/soc-pcm.c
@@ -1202,7 +1202,6 @@ static int soc_pcm_hw_free(struct snd_pcm_substream *substream)
 	struct snd_soc_pcm_runtime *rtd = substream->private_data;
 	struct snd_soc_dai *cpu_dai;
 	struct snd_soc_dai *codec_dai;
-	bool playback = substream->stream == SNDRV_PCM_STREAM_PLAYBACK;
 	int i;
 
 	mutex_lock_nested(&rtd->card->pcm_mutex, rtd->card->pcm_subclass);
@@ -1226,11 +1225,9 @@ static int soc_pcm_hw_free(struct snd_pcm_substream *substream)
 
 	/* apply codec digital mute */
 	for_each_rtd_codec_dai(rtd, i, codec_dai) {
-		int playback_active = codec_dai->stream_active[SNDRV_PCM_STREAM_PLAYBACK];
-		int capture_active  = codec_dai->stream_active[SNDRV_PCM_STREAM_CAPTURE];
+		int active = codec_dai->stream_active[substream->stream];
 
-		if ((playback && playback_active == 1) ||
-		    (!playback && capture_active == 1))
+		if (active == 1)
 			snd_soc_dai_digital_mute(codec_dai, 1,
 						 substream->stream);
 	}
-- 
2.17.1


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

* [PATCH v2 resend 6/6] ASoC: soc-pcm: Do Digital Mute for both CPU/Codec in same timing.
  2020-03-06  1:09 [PATCH v2 resend 0/6] ASoC: soc-pcm cleanup step5 Kuninori Morimoto
                   ` (4 preceding siblings ...)
  2020-03-06  1:10 ` [PATCH v2 resend 5/6] ASoC: soc-pcm: check DAI's activity more simply Kuninori Morimoto
@ 2020-03-06  1:10 ` Kuninori Morimoto
  2020-03-06 15:03   ` Applied "ASoC: soc-pcm: Do Digital Mute for both CPU/Codec in same timing." to the asoc tree Mark Brown
  5 siblings, 1 reply; 9+ messages in thread
From: Kuninori Morimoto @ 2020-03-06  1:10 UTC (permalink / raw)
  To: Mark Brown; +Cc: Linux-ALSA

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

Digital Mute for CPU   is done at soc_pcm_close(), and
Digital Mute for Codec is done at soc_pcm_hw_free().
It is just confusable.
This patch do Digital Mute for both CPU/Codec in same timing.
Then, it cares DAI activity

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
 sound/soc/soc-pcm.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/sound/soc/soc-pcm.c b/sound/soc/soc-pcm.c
index af0e17bfeeab..90d26fccb0da 100644
--- a/sound/soc/soc-pcm.c
+++ b/sound/soc/soc-pcm.c
@@ -760,9 +760,6 @@ static int soc_pcm_close(struct snd_pcm_substream *substream)
 
 	snd_soc_runtime_deactivate(rtd, substream->stream);
 
-	for_each_rtd_cpu_dai(rtd, i, cpu_dai)
-		snd_soc_dai_digital_mute(cpu_dai, 1, substream->stream);
-
 	for_each_rtd_cpu_dai(rtd, i, cpu_dai)
 		snd_soc_dai_shutdown(cpu_dai, substream);
 
@@ -1232,6 +1229,14 @@ static int soc_pcm_hw_free(struct snd_pcm_substream *substream)
 						 substream->stream);
 	}
 
+	for_each_rtd_cpu_dai(rtd, i, cpu_dai) {
+		int active = cpu_dai->stream_active[substream->stream];
+
+		if (active == 1)
+			snd_soc_dai_digital_mute(cpu_dai, 1,
+						 substream->stream);
+	}
+
 	/* free any machine hw params */
 	soc_rtd_hw_free(rtd, substream);
 
-- 
2.17.1


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

* Applied "ASoC: soc-pcm: Do Digital Mute for both CPU/Codec in same timing." to the asoc tree
  2020-03-06  1:10 ` [PATCH v2 resend 6/6] ASoC: soc-pcm: Do Digital Mute for both CPU/Codec in same timing Kuninori Morimoto
@ 2020-03-06 15:03   ` Mark Brown
  0 siblings, 0 replies; 9+ messages in thread
From: Mark Brown @ 2020-03-06 15:03 UTC (permalink / raw)
  To: Kuninori Morimoto; +Cc: Linux-ALSA, Mark Brown

The patch

   ASoC: soc-pcm: Do Digital Mute for both CPU/Codec in same timing.

has been applied to the asoc tree at

   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git 

All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.  

You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying
to this mail.

Thanks,
Mark

From a9ee331b537a3dfe6778fa4e07c0801f33e474f5 Mon Sep 17 00:00:00 2001
From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Date: Fri, 6 Mar 2020 10:10:17 +0900
Subject: [PATCH] ASoC: soc-pcm: Do Digital Mute for both CPU/Codec in same
 timing.

Digital Mute for CPU   is done at soc_pcm_close(), and
Digital Mute for Codec is done at soc_pcm_hw_free().
It is just confusable.
This patch do Digital Mute for both CPU/Codec in same timing.
Then, it cares DAI activity

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Link: https://lore.kernel.org/r/87imjip9ty.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
---
 sound/soc/soc-pcm.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/sound/soc/soc-pcm.c b/sound/soc/soc-pcm.c
index af0e17bfeeab..90d26fccb0da 100644
--- a/sound/soc/soc-pcm.c
+++ b/sound/soc/soc-pcm.c
@@ -760,9 +760,6 @@ static int soc_pcm_close(struct snd_pcm_substream *substream)
 
 	snd_soc_runtime_deactivate(rtd, substream->stream);
 
-	for_each_rtd_cpu_dai(rtd, i, cpu_dai)
-		snd_soc_dai_digital_mute(cpu_dai, 1, substream->stream);
-
 	for_each_rtd_cpu_dai(rtd, i, cpu_dai)
 		snd_soc_dai_shutdown(cpu_dai, substream);
 
@@ -1232,6 +1229,14 @@ static int soc_pcm_hw_free(struct snd_pcm_substream *substream)
 						 substream->stream);
 	}
 
+	for_each_rtd_cpu_dai(rtd, i, cpu_dai) {
+		int active = cpu_dai->stream_active[substream->stream];
+
+		if (active == 1)
+			snd_soc_dai_digital_mute(cpu_dai, 1,
+						 substream->stream);
+	}
+
 	/* free any machine hw params */
 	soc_rtd_hw_free(rtd, substream);
 
-- 
2.20.1


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

* Applied "ASoC: soc-pcm: check DAI's activity more simply" to the asoc tree
  2020-03-06  1:10 ` [PATCH v2 resend 5/6] ASoC: soc-pcm: check DAI's activity more simply Kuninori Morimoto
@ 2020-03-06 15:03   ` Mark Brown
  0 siblings, 0 replies; 9+ messages in thread
From: Mark Brown @ 2020-03-06 15:03 UTC (permalink / raw)
  To: Kuninori Morimoto; +Cc: Linux-ALSA, Mark Brown

The patch

   ASoC: soc-pcm: check DAI's activity more simply

has been applied to the asoc tree at

   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git 

All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.  

You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying
to this mail.

Thanks,
Mark

From 67ad877757cea329f74c1e169ec54131c3f223ce Mon Sep 17 00:00:00 2001
From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Date: Fri, 6 Mar 2020 10:10:04 +0900
Subject: [PATCH] ASoC: soc-pcm: check DAI's activity more simply

soc_pcm_hw_free() want to call snd_soc_dai_digital_mute()
if it was last user of Playback or Capture.

	bool playback = substream->stream == SNDRV_PCM_STREAM_PLAYBACK;
	int playback_active = dai->stream_active[SNDRV_PCM_STREAM_PLAYBACK];
	int capture_active  = dai->stream_active[SNDRV_PCM_STREAM_CAPTURE];

	if ((playback  && playback_active == 1) ||
	    (!playback && capture_active  == 1))
		snd_soc_dai_digital_mute(...)

But it is same as

	int active = dai->stream_active[substream->stream];

	if (active == 1)
		snd_soc_dai_digital_mute(...)

This patch simplify the code.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Link: https://lore.kernel.org/r/87k13yp9ub.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
---
 sound/soc/soc-pcm.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/sound/soc/soc-pcm.c b/sound/soc/soc-pcm.c
index 7d787e0966f3..af0e17bfeeab 100644
--- a/sound/soc/soc-pcm.c
+++ b/sound/soc/soc-pcm.c
@@ -1202,7 +1202,6 @@ static int soc_pcm_hw_free(struct snd_pcm_substream *substream)
 	struct snd_soc_pcm_runtime *rtd = substream->private_data;
 	struct snd_soc_dai *cpu_dai;
 	struct snd_soc_dai *codec_dai;
-	bool playback = substream->stream == SNDRV_PCM_STREAM_PLAYBACK;
 	int i;
 
 	mutex_lock_nested(&rtd->card->pcm_mutex, rtd->card->pcm_subclass);
@@ -1226,11 +1225,9 @@ static int soc_pcm_hw_free(struct snd_pcm_substream *substream)
 
 	/* apply codec digital mute */
 	for_each_rtd_codec_dai(rtd, i, codec_dai) {
-		int playback_active = codec_dai->stream_active[SNDRV_PCM_STREAM_PLAYBACK];
-		int capture_active  = codec_dai->stream_active[SNDRV_PCM_STREAM_CAPTURE];
+		int active = codec_dai->stream_active[substream->stream];
 
-		if ((playback && playback_active == 1) ||
-		    (!playback && capture_active == 1))
+		if (active == 1)
 			snd_soc_dai_digital_mute(codec_dai, 1,
 						 substream->stream);
 	}
-- 
2.20.1


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

end of thread, other threads:[~2020-03-06 15:05 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-06  1:09 [PATCH v2 resend 0/6] ASoC: soc-pcm cleanup step5 Kuninori Morimoto
2020-03-06  1:09 ` [PATCH v2 resend 1/6] ASoC: soc-pcm: move dpcm_fe_dai_close() Kuninori Morimoto
2020-03-06  1:09 ` [PATCH v2 resend 2/6] ASoC: soc-pcm: add dpcm_fe_dai_cleanup() Kuninori Morimoto
2020-03-06  1:09 ` [PATCH v2 resend 3/6] ASoC: soc-pcm: use snd_soc_dai_get_pcm_stream() at dpcm_set_fe_runtime() Kuninori Morimoto
2020-03-06  1:09 ` [PATCH v2 resend 4/6] ASoC: soc-pcm: tidyup dulicate handing at dpcm_fe_dai_startup() Kuninori Morimoto
2020-03-06  1:10 ` [PATCH v2 resend 5/6] ASoC: soc-pcm: check DAI's activity more simply Kuninori Morimoto
2020-03-06 15:03   ` Applied "ASoC: soc-pcm: check DAI's activity more simply" to the asoc tree Mark Brown
2020-03-06  1:10 ` [PATCH v2 resend 6/6] ASoC: soc-pcm: Do Digital Mute for both CPU/Codec in same timing Kuninori Morimoto
2020-03-06 15:03   ` Applied "ASoC: soc-pcm: Do Digital Mute for both CPU/Codec in same timing." to the asoc tree 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.