All of lore.kernel.org
 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: [PATCH 2/7] ASoC: soc-link: move soc_rtd_xxx()
Date: 19 May 2020 10:01:39 +0900	[thread overview]
Message-ID: <874ksc68lo.wl-kuninori.morimoto.gx@renesas.com> (raw)
In-Reply-To: <877dx868op.wl-kuninori.morimoto.gx@renesas.com>


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

dai_link related function should be implemented at soc-link.c.
This patch moves soc-pcm soc_rtd_xxx() to soc-link as snd_soc_link_xxx()

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
 include/sound/soc-link.h | 13 ++++++++
 sound/soc/soc-link.c     | 65 ++++++++++++++++++++++++++++++++++++
 sound/soc/soc-pcm.c      | 72 +++++-----------------------------------
 3 files changed, 87 insertions(+), 63 deletions(-)

diff --git a/include/sound/soc-link.h b/include/sound/soc-link.h
index 7fc5cead5942..689aa93be78e 100644
--- a/include/sound/soc-link.h
+++ b/include/sound/soc-link.h
@@ -9,5 +9,18 @@
 #define __SOC_LINK_H
 
 int snd_soc_link_init(struct snd_soc_pcm_runtime *rtd);
+int snd_soc_link_startup(struct snd_soc_pcm_runtime *rtd,
+			 struct snd_pcm_substream *substream);
+void snd_soc_link_shutdown(struct snd_soc_pcm_runtime *rtd,
+			   struct snd_pcm_substream *substream);
+int snd_soc_link_prepare(struct snd_soc_pcm_runtime *rtd,
+			 struct snd_pcm_substream *substream);
+int snd_soc_link_hw_params(struct snd_soc_pcm_runtime *rtd,
+			   struct snd_pcm_substream *substream,
+			   struct snd_pcm_hw_params *params);
+void snd_soc_link_hw_free(struct snd_soc_pcm_runtime *rtd,
+			  struct snd_pcm_substream *substream);
+int snd_soc_link_trigger(struct snd_soc_pcm_runtime *rtd,
+			 struct snd_pcm_substream *substream, int cmd);
 
 #endif /* __SOC_LINK_H */
diff --git a/sound/soc/soc-link.c b/sound/soc/soc-link.c
index 4bdd8d0dd93a..be6a6ecfc9dc 100644
--- a/sound/soc/soc-link.c
+++ b/sound/soc/soc-link.c
@@ -34,3 +34,68 @@ int snd_soc_link_init(struct snd_soc_pcm_runtime *rtd)
 
 	return soc_link_ret(rtd, ret);
 }
+
+int snd_soc_link_startup(struct snd_soc_pcm_runtime *rtd,
+			 struct snd_pcm_substream *substream)
+{
+	int ret = 0;
+
+	if (rtd->dai_link->ops &&
+	    rtd->dai_link->ops->startup)
+		ret = rtd->dai_link->ops->startup(substream);
+
+	return soc_link_ret(rtd, ret);
+}
+
+void snd_soc_link_shutdown(struct snd_soc_pcm_runtime *rtd,
+			   struct snd_pcm_substream *substream)
+{
+	if (rtd->dai_link->ops &&
+	    rtd->dai_link->ops->shutdown)
+		rtd->dai_link->ops->shutdown(substream);
+}
+
+int snd_soc_link_prepare(struct snd_soc_pcm_runtime *rtd,
+			 struct snd_pcm_substream *substream)
+{
+	int ret = 0;
+
+	if (rtd->dai_link->ops &&
+	    rtd->dai_link->ops->prepare)
+		ret = rtd->dai_link->ops->prepare(substream);
+
+	return soc_link_ret(rtd, ret);
+}
+
+int snd_soc_link_hw_params(struct snd_soc_pcm_runtime *rtd,
+			   struct snd_pcm_substream *substream,
+			   struct snd_pcm_hw_params *params)
+{
+	int ret = 0;
+
+	if (rtd->dai_link->ops &&
+	    rtd->dai_link->ops->hw_params)
+		ret = rtd->dai_link->ops->hw_params(substream, params);
+
+	return soc_link_ret(rtd, ret);
+}
+
+void snd_soc_link_hw_free(struct snd_soc_pcm_runtime *rtd,
+			  struct snd_pcm_substream *substream)
+{
+	if (rtd->dai_link->ops &&
+	    rtd->dai_link->ops->hw_free)
+		rtd->dai_link->ops->hw_free(substream);
+}
+
+int snd_soc_link_trigger(struct snd_soc_pcm_runtime *rtd,
+			 struct snd_pcm_substream *substream, int cmd)
+{
+	int ret = 0;
+
+	if (rtd->dai_link->ops &&
+	    rtd->dai_link->ops->trigger)
+		ret = rtd->dai_link->ops->trigger(substream, cmd);
+
+	return soc_link_ret(rtd, ret);
+}
diff --git a/sound/soc/soc-pcm.c b/sound/soc/soc-pcm.c
index b7899da4217e..20857145bd6d 100644
--- a/sound/soc/soc-pcm.c
+++ b/sound/soc/soc-pcm.c
@@ -202,60 +202,6 @@ static inline void dpcm_remove_debugfs_state(struct snd_soc_dpcm *dpcm)
 }
 #endif
 
-static int soc_rtd_startup(struct snd_soc_pcm_runtime *rtd,
-			   struct snd_pcm_substream *substream)
-{
-	if (rtd->dai_link->ops &&
-	    rtd->dai_link->ops->startup)
-		return rtd->dai_link->ops->startup(substream);
-	return 0;
-}
-
-static void soc_rtd_shutdown(struct snd_soc_pcm_runtime *rtd,
-			     struct snd_pcm_substream *substream)
-{
-	if (rtd->dai_link->ops &&
-	    rtd->dai_link->ops->shutdown)
-		rtd->dai_link->ops->shutdown(substream);
-}
-
-static int soc_rtd_prepare(struct snd_soc_pcm_runtime *rtd,
-			   struct snd_pcm_substream *substream)
-{
-	if (rtd->dai_link->ops &&
-	    rtd->dai_link->ops->prepare)
-		return rtd->dai_link->ops->prepare(substream);
-	return 0;
-}
-
-static int soc_rtd_hw_params(struct snd_soc_pcm_runtime *rtd,
-			     struct snd_pcm_substream *substream,
-			     struct snd_pcm_hw_params *params)
-{
-	if (rtd->dai_link->ops &&
-	    rtd->dai_link->ops->hw_params)
-		return rtd->dai_link->ops->hw_params(substream, params);
-	return 0;
-}
-
-static void soc_rtd_hw_free(struct snd_soc_pcm_runtime *rtd,
-			    struct snd_pcm_substream *substream)
-{
-	if (rtd->dai_link->ops &&
-	    rtd->dai_link->ops->hw_free)
-		rtd->dai_link->ops->hw_free(substream);
-}
-
-static int soc_rtd_trigger(struct snd_soc_pcm_runtime *rtd,
-			   struct snd_pcm_substream *substream,
-			   int cmd)
-{
-	if (rtd->dai_link->ops &&
-	    rtd->dai_link->ops->trigger)
-		return rtd->dai_link->ops->trigger(substream, cmd);
-	return 0;
-}
-
 /**
  * snd_soc_runtime_action() - Increment/Decrement active count for
  * PCM runtime components
@@ -736,7 +682,7 @@ static int soc_pcm_close(struct snd_pcm_substream *substream)
 	for_each_rtd_dais(rtd, i, dai)
 		snd_soc_dai_shutdown(dai, substream);
 
-	soc_rtd_shutdown(rtd, substream);
+	snd_soc_link_shutdown(rtd, substream);
 
 	soc_pcm_components_close(substream);
 
@@ -783,7 +729,7 @@ static int soc_pcm_open(struct snd_pcm_substream *substream)
 	if (ret < 0)
 		goto component_err;
 
-	ret = soc_rtd_startup(rtd, substream);
+	ret = snd_soc_link_startup(rtd, substream);
 	if (ret < 0) {
 		pr_err("ASoC: %s startup failed: %d\n",
 		       rtd->dai_link->name, ret);
@@ -870,7 +816,7 @@ static int soc_pcm_open(struct snd_pcm_substream *substream)
 	for_each_rtd_dais(rtd, i, dai)
 		snd_soc_dai_shutdown(dai, substream);
 
-	soc_rtd_shutdown(rtd, substream);
+	snd_soc_link_shutdown(rtd, substream);
 rtd_startup_err:
 	soc_pcm_components_close(substream);
 component_err:
@@ -912,7 +858,7 @@ static int soc_pcm_prepare(struct snd_pcm_substream *substream)
 
 	mutex_lock_nested(&rtd->card->pcm_mutex, rtd->card->pcm_subclass);
 
-	ret = soc_rtd_prepare(rtd, substream);
+	ret = snd_soc_link_prepare(rtd, substream);
 	if (ret < 0) {
 		dev_err(rtd->card->dev,
 			"ASoC: machine prepare error: %d\n", ret);
@@ -1002,7 +948,7 @@ static int soc_pcm_hw_params(struct snd_pcm_substream *substream,
 	if (ret)
 		goto out;
 
-	ret = soc_rtd_hw_params(rtd, substream, params);
+	ret = snd_soc_link_hw_params(rtd, substream, params);
 	if (ret < 0) {
 		dev_err(rtd->card->dev,
 			"ASoC: machine hw_params failed: %d\n", ret);
@@ -1117,7 +1063,7 @@ static int soc_pcm_hw_params(struct snd_pcm_substream *substream,
 		codec_dai->rate = 0;
 	}
 
-	soc_rtd_hw_free(rtd, substream);
+	snd_soc_link_hw_free(rtd, substream);
 
 	mutex_unlock(&rtd->card->pcm_mutex);
 	return ret;
@@ -1149,7 +1095,7 @@ static int soc_pcm_hw_free(struct snd_pcm_substream *substream)
 	}
 
 	/* free any machine hw params */
-	soc_rtd_hw_free(rtd, substream);
+	snd_soc_link_hw_free(rtd, substream);
 
 	/* free any component resources */
 	soc_pcm_components_hw_free(substream, NULL);
@@ -1172,7 +1118,7 @@ static int soc_pcm_trigger_start(struct snd_pcm_substream *substream, int cmd)
 	struct snd_soc_component *component;
 	int i, ret;
 
-	ret = soc_rtd_trigger(rtd, substream, cmd);
+	ret = snd_soc_link_trigger(rtd, substream, cmd);
 	if (ret < 0)
 		return ret;
 
@@ -1201,7 +1147,7 @@ static int soc_pcm_trigger_stop(struct snd_pcm_substream *substream, int cmd)
 			return ret;
 	}
 
-	ret = soc_rtd_trigger(rtd, substream, cmd);
+	ret = snd_soc_link_trigger(rtd, substream, cmd);
 	if (ret < 0)
 		return ret;
 
-- 
2.17.1


  parent reply	other threads:[~2020-05-19  1:02 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-19  0:59 [PATCH 0/7] ASoC: add soc-link Kuninori Morimoto
2020-05-19  1:01 ` [PATCH 1/7] ASoC: add soc-link.c Kuninori Morimoto
2020-05-19  1:42   ` Ranjani Sridharan
2020-05-19  4:20     ` Kuninori Morimoto
2020-05-19  1:01 ` Kuninori Morimoto [this message]
2020-05-19  1:01 ` [PATCH 3/7] ASoC: soc-link: remove unneeded parameter from snd_soc_link_xxx() Kuninori Morimoto
2020-05-19  1:02 ` [PATCH 4/7] ASoC: soc-link: add snd_soc_link_be_hw_params_fixup() Kuninori Morimoto
2020-05-19  1:45   ` Ranjani Sridharan
2020-05-19  4:16     ` Kuninori Morimoto
2020-05-19  1:02 ` [PATCH 5/7] ASoC: soc-link: add snd_soc_link_compr_startup() Kuninori Morimoto
2020-05-19  1:47   ` Ranjani Sridharan
2020-05-19  4:18     ` Kuninori Morimoto
2020-05-19  1:02 ` [PATCH 6/7] ASoC: soc-link: add snd_soc_link_compr_shutdown() Kuninori Morimoto
2020-05-19  1:02 ` [PATCH 7/7] ASoC: soc-link: add snd_soc_link_compr_set_params() Kuninori Morimoto

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=874ksc68lo.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 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.