alsa-devel.alsa-project.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/2] ASoC: soc-core: share same logic code
@ 2020-11-27  0:07 Kuninori Morimoto
  2020-11-27  0:07 ` [PATCH 1/2] ASoC: soc-core: add soc_playback_digital_mute() Kuninori Morimoto
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Kuninori Morimoto @ 2020-11-27  0:07 UTC (permalink / raw)
  To: Mark Brown; +Cc: Linux-ALSA


Hi Mark

soc-core is using almost same code at some point.
The difference is only used parameter.
It is just duplicate code, and we can share it.
This patch-set sharing code for mute and for suspend/resume.

Kuninori Morimoto (2):
  ASoC: soc-core: add soc_playback_digital_mute()
  ASoC: soc-core: add soc_dapm_suspend_resume()

 sound/soc/soc-core.c | 84 ++++++++++++++++++++------------------------
 1 file changed, 38 insertions(+), 46 deletions(-)

-- 
2.25.1


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

* [PATCH 1/2] ASoC: soc-core: add soc_playback_digital_mute()
  2020-11-27  0:07 [PATCH 0/2] ASoC: soc-core: share same logic code Kuninori Morimoto
@ 2020-11-27  0:07 ` Kuninori Morimoto
  2020-11-27  0:07 ` [PATCH 2/2] ASoC: soc-core: add soc_dapm_suspend_resume() Kuninori Morimoto
  2020-11-27 14:15 ` [PATCH 0/2] ASoC: soc-core: share same logic code Mark Brown
  2 siblings, 0 replies; 4+ messages in thread
From: Kuninori Morimoto @ 2020-11-27  0:07 UTC (permalink / raw)
  To: Mark Brown; +Cc: Linux-ALSA


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

snd_soc_suspend() and soc_resume_deferred() are calling
same snd_soc_dai_digital_mute() with same logic with different parameter.
This patch adds new soc_playback_digital_mute() and share the code.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
 sound/soc/soc-core.c | 46 ++++++++++++++++++++------------------------
 1 file changed, 21 insertions(+), 25 deletions(-)

diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index cb7333da58f1..c03b7107cb77 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -520,13 +520,31 @@ static void snd_soc_flush_all_delayed_work(struct snd_soc_card *card)
 }
 
 #ifdef CONFIG_PM_SLEEP
+static void soc_playback_digital_mute(struct snd_soc_card *card, int mute)
+{
+	struct snd_soc_pcm_runtime *rtd;
+	struct snd_soc_dai *dai;
+	int playback = SNDRV_PCM_STREAM_PLAYBACK;
+	int i;
+
+	for_each_card_rtds(card, rtd) {
+
+		if (rtd->dai_link->ignore_suspend)
+			continue;
+
+		for_each_rtd_dais(rtd, i, dai) {
+			if (snd_soc_dai_stream_active(dai, playback))
+				snd_soc_dai_digital_mute(dai, mute, playback);
+		}
+	}
+}
+
 /* powers down audio subsystem for suspend */
 int snd_soc_suspend(struct device *dev)
 {
 	struct snd_soc_card *card = dev_get_drvdata(dev);
 	struct snd_soc_component *component;
 	struct snd_soc_pcm_runtime *rtd;
-	int playback = SNDRV_PCM_STREAM_PLAYBACK;
 	int i;
 
 	/* If the card is not initialized yet there is nothing to do */
@@ -543,17 +561,7 @@ int snd_soc_suspend(struct device *dev)
 	snd_power_change_state(card->snd_card, SNDRV_CTL_POWER_D3hot);
 
 	/* mute any active DACs */
-	for_each_card_rtds(card, rtd) {
-		struct snd_soc_dai *dai;
-
-		if (rtd->dai_link->ignore_suspend)
-			continue;
-
-		for_each_rtd_dais(rtd, i, dai) {
-			if (snd_soc_dai_stream_active(dai, playback))
-				snd_soc_dai_digital_mute(dai, 1, playback);
-		}
-	}
+	soc_playback_digital_mute(card, 1);
 
 	/* suspend all pcms */
 	for_each_card_rtds(card, rtd) {
@@ -650,7 +658,6 @@ static void soc_resume_deferred(struct work_struct *work)
 				     deferred_resume_work);
 	struct snd_soc_pcm_runtime *rtd;
 	struct snd_soc_component *component;
-	int i;
 
 	/*
 	 * our power state is still SNDRV_CTL_POWER_D3hot from suspend time,
@@ -681,18 +688,7 @@ static void soc_resume_deferred(struct work_struct *work)
 	}
 
 	/* unmute any active DACs */
-	for_each_card_rtds(card, rtd) {
-		struct snd_soc_dai *dai;
-		int playback = SNDRV_PCM_STREAM_PLAYBACK;
-
-		if (rtd->dai_link->ignore_suspend)
-			continue;
-
-		for_each_rtd_dais(rtd, i, dai) {
-			if (snd_soc_dai_stream_active(dai, playback))
-				snd_soc_dai_digital_mute(dai, 0, playback);
-		}
-	}
+	soc_playback_digital_mute(card, 0);
 
 	snd_soc_card_resume_post(card);
 
-- 
2.25.1


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

* [PATCH 2/2] ASoC: soc-core: add soc_dapm_suspend_resume()
  2020-11-27  0:07 [PATCH 0/2] ASoC: soc-core: share same logic code Kuninori Morimoto
  2020-11-27  0:07 ` [PATCH 1/2] ASoC: soc-core: add soc_playback_digital_mute() Kuninori Morimoto
@ 2020-11-27  0:07 ` Kuninori Morimoto
  2020-11-27 14:15 ` [PATCH 0/2] ASoC: soc-core: share same logic code Mark Brown
  2 siblings, 0 replies; 4+ messages in thread
From: Kuninori Morimoto @ 2020-11-27  0:07 UTC (permalink / raw)
  To: Mark Brown; +Cc: Linux-ALSA


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

snd_soc_suspend() and soc_resume_deferred() are calling
same snd_soc_dapm_stream_event() with same logic with different parameter.
This patch adds new soc_dapm_suspend_resume() and share the code.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
 sound/soc/soc-core.c | 38 +++++++++++++++++---------------------
 1 file changed, 17 insertions(+), 21 deletions(-)

diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index c03b7107cb77..50b4ce6374a0 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -539,6 +539,21 @@ static void soc_playback_digital_mute(struct snd_soc_card *card, int mute)
 	}
 }
 
+static void soc_dapm_suspend_resume(struct snd_soc_card *card, int event)
+{
+	struct snd_soc_pcm_runtime *rtd;
+	int stream;
+
+	for_each_card_rtds(card, rtd) {
+
+		if (rtd->dai_link->ignore_suspend)
+			continue;
+
+		for_each_pcm_streams(stream)
+			snd_soc_dapm_stream_event(rtd, stream, event);
+	}
+}
+
 /* powers down audio subsystem for suspend */
 int snd_soc_suspend(struct device *dev)
 {
@@ -576,16 +591,7 @@ int snd_soc_suspend(struct device *dev)
 	/* close any waiting streams */
 	snd_soc_flush_all_delayed_work(card);
 
-	for_each_card_rtds(card, rtd) {
-		int stream;
-
-		if (rtd->dai_link->ignore_suspend)
-			continue;
-
-		for_each_pcm_streams(stream)
-			snd_soc_dapm_stream_event(rtd, stream,
-						  SND_SOC_DAPM_STREAM_SUSPEND);
-	}
+	soc_dapm_suspend_resume(card, SND_SOC_DAPM_STREAM_SUSPEND);
 
 	/* Recheck all endpoints too, their state is affected by suspend */
 	dapm_mark_endpoints_dirty(card);
@@ -656,7 +662,6 @@ static void soc_resume_deferred(struct work_struct *work)
 	struct snd_soc_card *card =
 			container_of(work, struct snd_soc_card,
 				     deferred_resume_work);
-	struct snd_soc_pcm_runtime *rtd;
 	struct snd_soc_component *component;
 
 	/*
@@ -676,16 +681,7 @@ static void soc_resume_deferred(struct work_struct *work)
 			snd_soc_component_resume(component);
 	}
 
-	for_each_card_rtds(card, rtd) {
-		int stream;
-
-		if (rtd->dai_link->ignore_suspend)
-			continue;
-
-		for_each_pcm_streams(stream)
-			snd_soc_dapm_stream_event(rtd, stream,
-						  SND_SOC_DAPM_STREAM_RESUME);
-	}
+	soc_dapm_suspend_resume(card, SND_SOC_DAPM_STREAM_RESUME);
 
 	/* unmute any active DACs */
 	soc_playback_digital_mute(card, 0);
-- 
2.25.1


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

* Re: [PATCH 0/2] ASoC: soc-core: share same logic code
  2020-11-27  0:07 [PATCH 0/2] ASoC: soc-core: share same logic code Kuninori Morimoto
  2020-11-27  0:07 ` [PATCH 1/2] ASoC: soc-core: add soc_playback_digital_mute() Kuninori Morimoto
  2020-11-27  0:07 ` [PATCH 2/2] ASoC: soc-core: add soc_dapm_suspend_resume() Kuninori Morimoto
@ 2020-11-27 14:15 ` Mark Brown
  2 siblings, 0 replies; 4+ messages in thread
From: Mark Brown @ 2020-11-27 14:15 UTC (permalink / raw)
  To: Kuninori Morimoto; +Cc: Linux-ALSA

On 27 Nov 2020 09:07:14 +0900, Kuninori Morimoto wrote:
> soc-core is using almost same code at some point.
> The difference is only used parameter.
> It is just duplicate code, and we can share it.
> This patch-set sharing code for mute and for suspend/resume.
> 
> Kuninori Morimoto (2):
>   ASoC: soc-core: add soc_playback_digital_mute()
>   ASoC: soc-core: add soc_dapm_suspend_resume()
> 
> [...]

Applied to

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

Thanks!

[1/2] ASoC: soc-core: add soc_playback_digital_mute()
      commit: d4c1d9eb6611fee6cd3623e810282342757b57f6
[2/2] ASoC: soc-core: add soc_dapm_suspend_resume()
      commit: baed393e8550fa075512772fad27e98ba9dcb527

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

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

end of thread, other threads:[~2020-11-27 14:17 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-27  0:07 [PATCH 0/2] ASoC: soc-core: share same logic code Kuninori Morimoto
2020-11-27  0:07 ` [PATCH 1/2] ASoC: soc-core: add soc_playback_digital_mute() Kuninori Morimoto
2020-11-27  0:07 ` [PATCH 2/2] ASoC: soc-core: add soc_dapm_suspend_resume() Kuninori Morimoto
2020-11-27 14:15 ` [PATCH 0/2] ASoC: soc-core: share same logic code 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).