[PATCH 0/2] ASoC: soc-core: share same logic code
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(-)
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);
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);
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
participants (2)
-
Kuninori Morimoto
-
Mark Brown