All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 00/17] ASoC: soc-dai: add snd_soc_dai_xxx()
@ 2020-04-22 23:13 Kuninori Morimoto
  2020-04-22 23:13 ` [PATCH 01/17] ASoC: soc-dai: add soc_dai_err() Kuninori Morimoto
                   ` (16 more replies)
  0 siblings, 17 replies; 28+ messages in thread
From: Kuninori Morimoto @ 2020-04-22 23:13 UTC (permalink / raw)
  To: Mark Brown; +Cc: Linux-ALSA


Hi Mark

We have soc-dai.c today. DAI related functions
should be implemented in it.
These patches are do it.

Kuninori Morimoto (17):
  ASoC: soc-dai: add soc_dai_err()
  ASoC: soc-dai: don't overwide dai->driver->ops
  ASoC: soc-dai: add snd_soc_pcm_dai_new()
  ASoC: soc-dai: add snd_soc_pcm_dai_prepare()
  ASoC: soc-dai: add snd_soc_pcm_dai_trigger()
  ASoC: soc-dai: add snd_soc_pcm_dai_bespoke_trigger()
  ASoC: soc-dai: add snd_soc_pcm_dai_probe()
  ASoC: soc-dai: add snd_soc_pcm_dai_remove()
  ASoC: soc-dai: add snd_soc_dai_compr_start()
  ASoC: soc-dai: add snd_soc_dai_compr_shutdown()
  ASoC: soc-dai: add snd_soc_dai_compr_trigger()
  ASoC: soc-dai: add snd_soc_dai_compr_set_params()
  ASoC: soc-dai: add snd_soc_dai_compr_get_params()
  ASoC: soc-dai: add snd_soc_dai_compr_ack()
  ASoC: soc-dai: add snd_soc_dai_compr_pointer()
  ASoC: soc-dai: add snd_soc_dai_compr_set_metadata()
  ASoC: soc-dai: add snd_soc_dai_compr_get_metadata()

 include/sound/soc-dai.h  |  41 +++-
 sound/soc/soc-compress.c | 104 ++++-----
 sound/soc/soc-core.c     |  85 +-------
 sound/soc/soc-dai.c      | 453 +++++++++++++++++++++++++++++----------
 sound/soc/soc-pcm.c      |  50 ++---
 5 files changed, 436 insertions(+), 297 deletions(-)

-- 
2.17.1


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

* [PATCH 01/17] ASoC: soc-dai: add soc_dai_err()
  2020-04-22 23:13 [PATCH 00/17] ASoC: soc-dai: add snd_soc_dai_xxx() Kuninori Morimoto
@ 2020-04-22 23:13 ` Kuninori Morimoto
  2020-04-23 18:33   ` Pierre-Louis Bossart
  2020-04-22 23:14 ` [PATCH 02/17] ASoC: soc-dai: don't overwide dai->driver->ops Kuninori Morimoto
                   ` (15 subsequent siblings)
  16 siblings, 1 reply; 28+ messages in thread
From: Kuninori Morimoto @ 2020-04-22 23:13 UTC (permalink / raw)
  To: Mark Brown; +Cc: Linux-ALSA


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

At soc-dai.c, it is good idea to indicate error function and
its component name if there was error.
This patch adds soc_dai_err() for it.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
 sound/soc/soc-dai.c | 155 +++++++++++++++++++++++++++-----------------
 1 file changed, 96 insertions(+), 59 deletions(-)

diff --git a/sound/soc/soc-dai.c b/sound/soc/soc-dai.c
index 31c41559034b..d591b3bd8b99 100644
--- a/sound/soc/soc-dai.c
+++ b/sound/soc/soc-dai.c
@@ -9,6 +9,24 @@
 #include <sound/soc.h>
 #include <sound/soc-dai.h>
 
+#define soc_dai_ret(dai, ret) _soc_dai_ret(dai, __func__, ret)
+static inline int _soc_dai_ret(struct snd_soc_dai *dai,
+			       const char *func, int ret)
+{
+	switch (ret) {
+	case -EPROBE_DEFER:
+	case -ENOTSUPP:
+	case 0:
+		break;
+	default:
+		dev_err(dai->dev,
+			"ASoC: error at %s on %s: %d\n",
+			func, dai->name, ret);
+	}
+
+	return ret;
+}
+
 /**
  * snd_soc_dai_set_sysclk - configure DAI system or master clock.
  * @dai: DAI
@@ -21,11 +39,15 @@
 int snd_soc_dai_set_sysclk(struct snd_soc_dai *dai, int clk_id,
 			   unsigned int freq, int dir)
 {
+	int ret;
+
 	if (dai->driver->ops->set_sysclk)
-		return dai->driver->ops->set_sysclk(dai, clk_id, freq, dir);
+		ret = dai->driver->ops->set_sysclk(dai, clk_id, freq, dir);
+	else
+		ret = snd_soc_component_set_sysclk(dai->component, clk_id, 0,
+						   freq, dir);
 
-	return snd_soc_component_set_sysclk(dai->component, clk_id, 0,
-					    freq, dir);
+	return soc_dai_ret(dai, ret);
 }
 EXPORT_SYMBOL_GPL(snd_soc_dai_set_sysclk);
 
@@ -42,10 +64,12 @@ EXPORT_SYMBOL_GPL(snd_soc_dai_set_sysclk);
 int snd_soc_dai_set_clkdiv(struct snd_soc_dai *dai,
 			   int div_id, int div)
 {
+	int ret = -EINVAL;
+
 	if (dai->driver->ops->set_clkdiv)
-		return dai->driver->ops->set_clkdiv(dai, div_id, div);
-	else
-		return -EINVAL;
+		ret = dai->driver->ops->set_clkdiv(dai, div_id, div);
+
+	return soc_dai_ret(dai, ret);
 }
 EXPORT_SYMBOL_GPL(snd_soc_dai_set_clkdiv);
 
@@ -62,12 +86,16 @@ EXPORT_SYMBOL_GPL(snd_soc_dai_set_clkdiv);
 int snd_soc_dai_set_pll(struct snd_soc_dai *dai, int pll_id, int source,
 			unsigned int freq_in, unsigned int freq_out)
 {
+	int ret;
+
 	if (dai->driver->ops->set_pll)
-		return dai->driver->ops->set_pll(dai, pll_id, source,
-						 freq_in, freq_out);
+		ret = dai->driver->ops->set_pll(dai, pll_id, source,
+						freq_in, freq_out);
+	else
+		ret = snd_soc_component_set_pll(dai->component, pll_id, source,
+						freq_in, freq_out);
 
-	return snd_soc_component_set_pll(dai->component, pll_id, source,
-					 freq_in, freq_out);
+	return soc_dai_ret(dai, ret);
 }
 EXPORT_SYMBOL_GPL(snd_soc_dai_set_pll);
 
@@ -80,10 +108,12 @@ EXPORT_SYMBOL_GPL(snd_soc_dai_set_pll);
  */
 int snd_soc_dai_set_bclk_ratio(struct snd_soc_dai *dai, unsigned int ratio)
 {
+	int ret = -EINVAL;
+
 	if (dai->driver->ops->set_bclk_ratio)
-		return dai->driver->ops->set_bclk_ratio(dai, ratio);
-	else
-		return -EINVAL;
+		ret = dai->driver->ops->set_bclk_ratio(dai, ratio);
+
+	return soc_dai_ret(dai, ret);
 }
 EXPORT_SYMBOL_GPL(snd_soc_dai_set_bclk_ratio);
 
@@ -96,9 +126,12 @@ EXPORT_SYMBOL_GPL(snd_soc_dai_set_bclk_ratio);
  */
 int snd_soc_dai_set_fmt(struct snd_soc_dai *dai, unsigned int fmt)
 {
-	if (dai->driver->ops->set_fmt == NULL)
-		return -ENOTSUPP;
-	return dai->driver->ops->set_fmt(dai, fmt);
+	int ret = -ENOTSUPP;
+
+	if (dai->driver->ops->set_fmt)
+		ret = dai->driver->ops->set_fmt(dai, fmt);
+
+	return soc_dai_ret(dai, ret);
 }
 EXPORT_SYMBOL_GPL(snd_soc_dai_set_fmt);
 
@@ -153,6 +186,8 @@ int snd_soc_dai_set_tdm_slot(struct snd_soc_dai *dai,
 			     unsigned int tx_mask, unsigned int rx_mask,
 			     int slots, int slot_width)
 {
+	int ret = -ENOTSUPP;
+
 	if (dai->driver->ops->xlate_tdm_slot_mask)
 		dai->driver->ops->xlate_tdm_slot_mask(slots,
 						      &tx_mask, &rx_mask);
@@ -163,10 +198,9 @@ int snd_soc_dai_set_tdm_slot(struct snd_soc_dai *dai,
 	dai->rx_mask = rx_mask;
 
 	if (dai->driver->ops->set_tdm_slot)
-		return dai->driver->ops->set_tdm_slot(dai, tx_mask, rx_mask,
+		ret = dai->driver->ops->set_tdm_slot(dai, tx_mask, rx_mask,
 						      slots, slot_width);
-	else
-		return -ENOTSUPP;
+	return soc_dai_ret(dai, ret);
 }
 EXPORT_SYMBOL_GPL(snd_soc_dai_set_tdm_slot);
 
@@ -186,11 +220,12 @@ int snd_soc_dai_set_channel_map(struct snd_soc_dai *dai,
 				unsigned int tx_num, unsigned int *tx_slot,
 				unsigned int rx_num, unsigned int *rx_slot)
 {
+	int ret = -ENOTSUPP;
+
 	if (dai->driver->ops->set_channel_map)
-		return dai->driver->ops->set_channel_map(dai, tx_num, tx_slot,
-							 rx_num, rx_slot);
-	else
-		return -ENOTSUPP;
+		ret = dai->driver->ops->set_channel_map(dai, tx_num, tx_slot,
+							rx_num, rx_slot);
+	return soc_dai_ret(dai, ret);
 }
 EXPORT_SYMBOL_GPL(snd_soc_dai_set_channel_map);
 
@@ -208,11 +243,12 @@ int snd_soc_dai_get_channel_map(struct snd_soc_dai *dai,
 				unsigned int *tx_num, unsigned int *tx_slot,
 				unsigned int *rx_num, unsigned int *rx_slot)
 {
+	int ret = -ENOTSUPP;
+
 	if (dai->driver->ops->get_channel_map)
-		return dai->driver->ops->get_channel_map(dai, tx_num, tx_slot,
-							 rx_num, rx_slot);
-	else
-		return -ENOTSUPP;
+		ret = dai->driver->ops->get_channel_map(dai, tx_num, tx_slot,
+							rx_num, rx_slot);
+	return soc_dai_ret(dai, ret);
 }
 EXPORT_SYMBOL_GPL(snd_soc_dai_get_channel_map);
 
@@ -225,10 +261,12 @@ EXPORT_SYMBOL_GPL(snd_soc_dai_get_channel_map);
  */
 int snd_soc_dai_set_tristate(struct snd_soc_dai *dai, int tristate)
 {
+	int ret = -EINVAL;
+
 	if (dai->driver->ops->set_tristate)
-		return dai->driver->ops->set_tristate(dai, tristate);
-	else
-		return -EINVAL;
+		ret = dai->driver->ops->set_tristate(dai, tristate);
+
+	return soc_dai_ret(dai, ret);
 }
 EXPORT_SYMBOL_GPL(snd_soc_dai_set_tristate);
 
@@ -243,13 +281,15 @@ EXPORT_SYMBOL_GPL(snd_soc_dai_set_tristate);
 int snd_soc_dai_digital_mute(struct snd_soc_dai *dai, int mute,
 			     int direction)
 {
+	int ret = -ENOTSUPP;
+
 	if (dai->driver->ops->mute_stream)
-		return dai->driver->ops->mute_stream(dai, mute, direction);
+		ret = dai->driver->ops->mute_stream(dai, mute, direction);
 	else if (direction == SNDRV_PCM_STREAM_PLAYBACK &&
 		 dai->driver->ops->digital_mute)
-		return dai->driver->ops->digital_mute(dai, mute);
-	else
-		return -ENOTSUPP;
+		ret = dai->driver->ops->digital_mute(dai, mute);
+
+	return soc_dai_ret(dai, ret);
 }
 EXPORT_SYMBOL_GPL(snd_soc_dai_digital_mute);
 
@@ -258,29 +298,19 @@ int snd_soc_dai_hw_params(struct snd_soc_dai *dai,
 			  struct snd_pcm_hw_params *params)
 {
 	struct snd_soc_pcm_runtime *rtd = substream->private_data;
-	int ret;
+	int ret = 0;
 
 	/* perform any topology hw_params fixups before DAI  */
 	if (rtd->dai_link->be_hw_params_fixup) {
 		ret = rtd->dai_link->be_hw_params_fixup(rtd, params);
-		if (ret < 0) {
-			dev_err(rtd->dev,
-				"ASoC: hw_params topology fixup failed %d\n",
-				ret);
-			return ret;
-		}
+		if (ret < 0)
+			goto end;
 	}
 
-	if (dai->driver->ops->hw_params) {
+	if (dai->driver->ops->hw_params)
 		ret = dai->driver->ops->hw_params(substream, params, dai);
-		if (ret < 0) {
-			dev_err(dai->dev, "ASoC: can't set %s hw params: %d\n",
-				dai->name, ret);
-			return ret;
-		}
-	}
-
-	return 0;
+end:
+	return soc_dai_ret(dai, ret);
 }
 
 void snd_soc_dai_hw_free(struct snd_soc_dai *dai,
@@ -298,7 +328,7 @@ int snd_soc_dai_startup(struct snd_soc_dai *dai,
 	if (dai->driver->ops->startup)
 		ret = dai->driver->ops->startup(substream, dai);
 
-	return ret;
+	return soc_dai_ret(dai, ret);
 }
 
 void snd_soc_dai_shutdown(struct snd_soc_dai *dai,
@@ -316,7 +346,7 @@ int snd_soc_dai_prepare(struct snd_soc_dai *dai,
 	if (dai->driver->ops->prepare)
 		ret = dai->driver->ops->prepare(substream, dai);
 
-	return ret;
+	return soc_dai_ret(dai, ret);
 }
 
 int snd_soc_dai_trigger(struct snd_soc_dai *dai,
@@ -340,7 +370,7 @@ int snd_soc_dai_bespoke_trigger(struct snd_soc_dai *dai,
 	if (dai->driver->ops->bespoke_trigger)
 		ret = dai->driver->ops->bespoke_trigger(substream, cmd, dai);
 
-	return ret;
+	return soc_dai_ret(dai, ret);
 }
 
 snd_pcm_sframes_t snd_soc_dai_delay(struct snd_soc_dai *dai,
@@ -356,24 +386,31 @@ snd_pcm_sframes_t snd_soc_dai_delay(struct snd_soc_dai *dai,
 
 int snd_soc_dai_probe(struct snd_soc_dai *dai)
 {
+	int ret = 0;
+
 	if (dai->driver->probe)
-		return dai->driver->probe(dai);
-	return 0;
+		ret = dai->driver->probe(dai);
+
+	return soc_dai_ret(dai, ret);
 }
 
 int snd_soc_dai_remove(struct snd_soc_dai *dai)
 {
+	int ret = 0;
+
 	if (dai->driver->remove)
-		return dai->driver->remove(dai);
-	return 0;
+		ret = dai->driver->remove(dai);
+
+	return soc_dai_ret(dai, ret);
 }
 
 int snd_soc_dai_compress_new(struct snd_soc_dai *dai,
 			     struct snd_soc_pcm_runtime *rtd, int num)
 {
+	int ret = -ENOTSUPP;
 	if (dai->driver->compress_new)
-		return dai->driver->compress_new(rtd, num);
-	return -ENOTSUPP;
+		ret = dai->driver->compress_new(rtd, num);
+	return soc_dai_ret(dai, ret);
 }
 
 /*
-- 
2.17.1


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

* [PATCH 02/17] ASoC: soc-dai: don't overwide dai->driver->ops
  2020-04-22 23:13 [PATCH 00/17] ASoC: soc-dai: add snd_soc_dai_xxx() Kuninori Morimoto
  2020-04-22 23:13 ` [PATCH 01/17] ASoC: soc-dai: add soc_dai_err() Kuninori Morimoto
@ 2020-04-22 23:14 ` Kuninori Morimoto
  2020-04-23 15:09   ` broonie
  2020-04-22 23:14 ` [PATCH 03/17] ASoC: soc-dai: add snd_soc_pcm_dai_new() Kuninori Morimoto
                   ` (14 subsequent siblings)
  16 siblings, 1 reply; 28+ messages in thread
From: Kuninori Morimoto @ 2020-04-22 23:14 UTC (permalink / raw)
  To: Mark Brown; +Cc: Linux-ALSA


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

Current ASoC overwides dai->driver->ops if it was NULL.
But, it is not good idea, because dai->driver might be reused
when modprobe/rmmod or bind/unbind, etc.

This patch checks dai->driver->ops when use DAI callbacks,
and removes null_dai_ops from ASoC.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
 sound/soc/soc-core.c |  5 ----
 sound/soc/soc-dai.c  | 58 +++++++++++++++++++++++++++++---------------
 2 files changed, 39 insertions(+), 24 deletions(-)

diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index 8321e75ff244..6778eeffb48f 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -742,9 +742,6 @@ static inline void soc_resume_init(struct snd_soc_card *card)
 }
 #endif
 
-static const struct snd_soc_dai_ops null_dai_ops = {
-};
-
 static struct device_node
 *soc_component_to_node(struct snd_soc_component *component)
 {
@@ -2406,8 +2403,6 @@ struct snd_soc_dai *snd_soc_register_dai(struct snd_soc_component *component,
 	dai->component = component;
 	dai->dev = dev;
 	dai->driver = dai_drv;
-	if (!dai->driver->ops)
-		dai->driver->ops = &null_dai_ops;
 
 	/* see for_each_component_dais */
 	list_add_tail(&dai->list, &component->dai_list);
diff --git a/sound/soc/soc-dai.c b/sound/soc/soc-dai.c
index d591b3bd8b99..93e03c9ec164 100644
--- a/sound/soc/soc-dai.c
+++ b/sound/soc/soc-dai.c
@@ -41,7 +41,8 @@ int snd_soc_dai_set_sysclk(struct snd_soc_dai *dai, int clk_id,
 {
 	int ret;
 
-	if (dai->driver->ops->set_sysclk)
+	if (dai->driver->ops &&
+	    dai->driver->ops->set_sysclk)
 		ret = dai->driver->ops->set_sysclk(dai, clk_id, freq, dir);
 	else
 		ret = snd_soc_component_set_sysclk(dai->component, clk_id, 0,
@@ -66,7 +67,8 @@ int snd_soc_dai_set_clkdiv(struct snd_soc_dai *dai,
 {
 	int ret = -EINVAL;
 
-	if (dai->driver->ops->set_clkdiv)
+	if (dai->driver->ops &&
+	    dai->driver->ops->set_clkdiv)
 		ret = dai->driver->ops->set_clkdiv(dai, div_id, div);
 
 	return soc_dai_ret(dai, ret);
@@ -88,7 +90,8 @@ int snd_soc_dai_set_pll(struct snd_soc_dai *dai, int pll_id, int source,
 {
 	int ret;
 
-	if (dai->driver->ops->set_pll)
+	if (dai->driver->ops &&
+	    dai->driver->ops->set_pll)
 		ret = dai->driver->ops->set_pll(dai, pll_id, source,
 						freq_in, freq_out);
 	else
@@ -110,7 +113,8 @@ int snd_soc_dai_set_bclk_ratio(struct snd_soc_dai *dai, unsigned int ratio)
 {
 	int ret = -EINVAL;
 
-	if (dai->driver->ops->set_bclk_ratio)
+	if (dai->driver->ops &&
+	    dai->driver->ops->set_bclk_ratio)
 		ret = dai->driver->ops->set_bclk_ratio(dai, ratio);
 
 	return soc_dai_ret(dai, ret);
@@ -128,7 +132,8 @@ int snd_soc_dai_set_fmt(struct snd_soc_dai *dai, unsigned int fmt)
 {
 	int ret = -ENOTSUPP;
 
-	if (dai->driver->ops->set_fmt)
+	if (dai->driver->ops &&
+	    dai->driver->ops->set_fmt)
 		ret = dai->driver->ops->set_fmt(dai, fmt);
 
 	return soc_dai_ret(dai, ret);
@@ -188,7 +193,8 @@ int snd_soc_dai_set_tdm_slot(struct snd_soc_dai *dai,
 {
 	int ret = -ENOTSUPP;
 
-	if (dai->driver->ops->xlate_tdm_slot_mask)
+	if (dai->driver->ops &&
+	    dai->driver->ops->xlate_tdm_slot_mask)
 		dai->driver->ops->xlate_tdm_slot_mask(slots,
 						      &tx_mask, &rx_mask);
 	else
@@ -197,7 +203,8 @@ int snd_soc_dai_set_tdm_slot(struct snd_soc_dai *dai,
 	dai->tx_mask = tx_mask;
 	dai->rx_mask = rx_mask;
 
-	if (dai->driver->ops->set_tdm_slot)
+	if (dai->driver->ops &&
+	    dai->driver->ops->set_tdm_slot)
 		ret = dai->driver->ops->set_tdm_slot(dai, tx_mask, rx_mask,
 						      slots, slot_width);
 	return soc_dai_ret(dai, ret);
@@ -222,7 +229,8 @@ int snd_soc_dai_set_channel_map(struct snd_soc_dai *dai,
 {
 	int ret = -ENOTSUPP;
 
-	if (dai->driver->ops->set_channel_map)
+	if (dai->driver->ops &&
+	    dai->driver->ops->set_channel_map)
 		ret = dai->driver->ops->set_channel_map(dai, tx_num, tx_slot,
 							rx_num, rx_slot);
 	return soc_dai_ret(dai, ret);
@@ -245,7 +253,8 @@ int snd_soc_dai_get_channel_map(struct snd_soc_dai *dai,
 {
 	int ret = -ENOTSUPP;
 
-	if (dai->driver->ops->get_channel_map)
+	if (dai->driver->ops &&
+	    dai->driver->ops->get_channel_map)
 		ret = dai->driver->ops->get_channel_map(dai, tx_num, tx_slot,
 							rx_num, rx_slot);
 	return soc_dai_ret(dai, ret);
@@ -263,7 +272,8 @@ int snd_soc_dai_set_tristate(struct snd_soc_dai *dai, int tristate)
 {
 	int ret = -EINVAL;
 
-	if (dai->driver->ops->set_tristate)
+	if (dai->driver->ops &&
+	    dai->driver->ops->set_tristate)
 		ret = dai->driver->ops->set_tristate(dai, tristate);
 
 	return soc_dai_ret(dai, ret);
@@ -283,9 +293,11 @@ int snd_soc_dai_digital_mute(struct snd_soc_dai *dai, int mute,
 {
 	int ret = -ENOTSUPP;
 
-	if (dai->driver->ops->mute_stream)
+	if (dai->driver->ops &&
+	    dai->driver->ops->mute_stream)
 		ret = dai->driver->ops->mute_stream(dai, mute, direction);
 	else if (direction == SNDRV_PCM_STREAM_PLAYBACK &&
+		 dai->driver->ops &&
 		 dai->driver->ops->digital_mute)
 		ret = dai->driver->ops->digital_mute(dai, mute);
 
@@ -307,7 +319,8 @@ int snd_soc_dai_hw_params(struct snd_soc_dai *dai,
 			goto end;
 	}
 
-	if (dai->driver->ops->hw_params)
+	if (dai->driver->ops &&
+	    dai->driver->ops->hw_params)
 		ret = dai->driver->ops->hw_params(substream, params, dai);
 end:
 	return soc_dai_ret(dai, ret);
@@ -316,7 +329,8 @@ int snd_soc_dai_hw_params(struct snd_soc_dai *dai,
 void snd_soc_dai_hw_free(struct snd_soc_dai *dai,
 			 struct snd_pcm_substream *substream)
 {
-	if (dai->driver->ops->hw_free)
+	if (dai->driver->ops &&
+	    dai->driver->ops->hw_free)
 		dai->driver->ops->hw_free(substream, dai);
 }
 
@@ -325,7 +339,8 @@ int snd_soc_dai_startup(struct snd_soc_dai *dai,
 {
 	int ret = 0;
 
-	if (dai->driver->ops->startup)
+	if (dai->driver->ops &&
+	    dai->driver->ops->startup)
 		ret = dai->driver->ops->startup(substream, dai);
 
 	return soc_dai_ret(dai, ret);
@@ -334,7 +349,8 @@ int snd_soc_dai_startup(struct snd_soc_dai *dai,
 void snd_soc_dai_shutdown(struct snd_soc_dai *dai,
 			 struct snd_pcm_substream *substream)
 {
-	if (dai->driver->ops->shutdown)
+	if (dai->driver->ops &&
+	    dai->driver->ops->shutdown)
 		dai->driver->ops->shutdown(substream, dai);
 }
 
@@ -343,7 +359,8 @@ int snd_soc_dai_prepare(struct snd_soc_dai *dai,
 {
 	int ret = 0;
 
-	if (dai->driver->ops->prepare)
+	if (dai->driver->ops &&
+	    dai->driver->ops->prepare)
 		ret = dai->driver->ops->prepare(substream, dai);
 
 	return soc_dai_ret(dai, ret);
@@ -355,7 +372,8 @@ int snd_soc_dai_trigger(struct snd_soc_dai *dai,
 {
 	int ret = 0;
 
-	if (dai->driver->ops->trigger)
+	if (dai->driver->ops &&
+	    dai->driver->ops->trigger)
 		ret = dai->driver->ops->trigger(substream, cmd, dai);
 
 	return ret;
@@ -367,7 +385,8 @@ int snd_soc_dai_bespoke_trigger(struct snd_soc_dai *dai,
 {
 	int ret = 0;
 
-	if (dai->driver->ops->bespoke_trigger)
+	if (dai->driver->ops &&
+	    dai->driver->ops->bespoke_trigger)
 		ret = dai->driver->ops->bespoke_trigger(substream, cmd, dai);
 
 	return soc_dai_ret(dai, ret);
@@ -378,7 +397,8 @@ snd_pcm_sframes_t snd_soc_dai_delay(struct snd_soc_dai *dai,
 {
 	int delay = 0;
 
-	if (dai->driver->ops->delay)
+	if (dai->driver->ops &&
+	    dai->driver->ops->delay)
 		delay = dai->driver->ops->delay(substream, dai);
 
 	return delay;
-- 
2.17.1


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

* [PATCH 03/17] ASoC: soc-dai: add snd_soc_pcm_dai_new()
  2020-04-22 23:13 [PATCH 00/17] ASoC: soc-dai: add snd_soc_dai_xxx() Kuninori Morimoto
  2020-04-22 23:13 ` [PATCH 01/17] ASoC: soc-dai: add soc_dai_err() Kuninori Morimoto
  2020-04-22 23:14 ` [PATCH 02/17] ASoC: soc-dai: don't overwide dai->driver->ops Kuninori Morimoto
@ 2020-04-22 23:14 ` Kuninori Morimoto
  2020-04-22 23:14 ` [PATCH 04/17] ASoC: soc-dai: add snd_soc_pcm_dai_prepare() Kuninori Morimoto
                   ` (13 subsequent siblings)
  16 siblings, 0 replies; 28+ messages in thread
From: Kuninori Morimoto @ 2020-04-22 23:14 UTC (permalink / raw)
  To: Mark Brown; +Cc: Linux-ALSA


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

We have 2 type of component functions
snd_soc_dai_xxx()     is focusing to dai itself,
snd_soc_pcm_dai_xxx() is focusing to rtd related dai.

Now we can update soc_dai_pcm_new() to
snd_soc_pcm_dai_new(). This patch do it.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
 include/sound/soc-dai.h |  2 ++
 sound/soc/soc-core.c    | 23 +----------------------
 sound/soc/soc-dai.c     | 16 ++++++++++++++++
 3 files changed, 19 insertions(+), 22 deletions(-)

diff --git a/include/sound/soc-dai.h b/include/sound/soc-dai.h
index b33abe93b905..fd7e203315e6 100644
--- a/include/sound/soc-dai.h
+++ b/include/sound/soc-dai.h
@@ -170,6 +170,8 @@ int snd_soc_dai_compress_new(struct snd_soc_dai *dai,
 			     struct snd_soc_pcm_runtime *rtd, int num);
 bool snd_soc_dai_stream_valid(struct snd_soc_dai *dai, int stream);
 
+int snd_soc_pcm_dai_new(struct snd_soc_pcm_runtime *rtd);
+
 struct snd_soc_dai_ops {
 	/*
 	 * DAI clocking configuration, all optional.
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index 6778eeffb48f..76167fa264af 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -1036,27 +1036,6 @@ int snd_soc_add_pcm_runtime(struct snd_soc_card *card,
 }
 EXPORT_SYMBOL_GPL(snd_soc_add_pcm_runtime);
 
-static int soc_dai_pcm_new(struct snd_soc_pcm_runtime *rtd)
-{
-	struct snd_soc_dai *dai;
-	int i, ret = 0;
-
-	for_each_rtd_dais(rtd, i, dai) {
-		struct snd_soc_dai_driver *drv = dai->driver;
-
-		if (drv->pcm_new)
-			ret = drv->pcm_new(rtd, dai);
-		if (ret < 0) {
-			dev_err(dai->dev,
-				"ASoC: Failed to bind %s with pcm device\n",
-				dai->name);
-			return ret;
-		}
-	}
-
-	return 0;
-}
-
 static int soc_init_pcm_runtime(struct snd_soc_card *card,
 				struct snd_soc_pcm_runtime *rtd)
 {
@@ -1121,7 +1100,7 @@ static int soc_init_pcm_runtime(struct snd_soc_card *card,
 		return ret;
 	}
 
-	return soc_dai_pcm_new(rtd);
+	return snd_soc_pcm_dai_new(rtd);
 }
 
 static void soc_set_name_prefix(struct snd_soc_card *card,
diff --git a/sound/soc/soc-dai.c b/sound/soc/soc-dai.c
index 93e03c9ec164..1b45e6e114ad 100644
--- a/sound/soc/soc-dai.c
+++ b/sound/soc/soc-dai.c
@@ -445,3 +445,19 @@ bool snd_soc_dai_stream_valid(struct snd_soc_dai *dai, int dir)
 	/* If the codec specifies any channels at all, it supports the stream */
 	return stream->channels_min;
 }
+
+int snd_soc_pcm_dai_new(struct snd_soc_pcm_runtime *rtd)
+{
+	struct snd_soc_dai *dai;
+	int i, ret = 0;
+
+	for_each_rtd_dais(rtd, i, dai) {
+		if (dai->driver->pcm_new) {
+			ret = dai->driver->pcm_new(rtd, dai);
+			if (ret < 0)
+				return soc_dai_ret(dai, ret);
+		}
+	}
+
+	return 0;
+}
-- 
2.17.1


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

* [PATCH 04/17] ASoC: soc-dai: add snd_soc_pcm_dai_prepare()
  2020-04-22 23:13 [PATCH 00/17] ASoC: soc-dai: add snd_soc_dai_xxx() Kuninori Morimoto
                   ` (2 preceding siblings ...)
  2020-04-22 23:14 ` [PATCH 03/17] ASoC: soc-dai: add snd_soc_pcm_dai_new() Kuninori Morimoto
@ 2020-04-22 23:14 ` Kuninori Morimoto
  2020-04-22 23:14 ` [PATCH 05/17] ASoC: soc-dai: add snd_soc_pcm_dai_trigger() Kuninori Morimoto
                   ` (12 subsequent siblings)
  16 siblings, 0 replies; 28+ messages in thread
From: Kuninori Morimoto @ 2020-04-22 23:14 UTC (permalink / raw)
  To: Mark Brown; +Cc: Linux-ALSA


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

We have 2 type of component functions
snd_soc_dai_xxx()     is focusing to dai itself,
snd_soc_pcm_dai_xxx() is focusing to rtd related dai.

Now we can update snd_soc_dai_prepare() to
snd_soc_pcm_dai_prepare(). This patch do it.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
 include/sound/soc-dai.h |  3 +--
 sound/soc/soc-dai.c     | 30 ++++++++++++++++++------------
 sound/soc/soc-pcm.c     | 11 ++++-------
 3 files changed, 23 insertions(+), 21 deletions(-)

diff --git a/include/sound/soc-dai.h b/include/sound/soc-dai.h
index fd7e203315e6..1b25318b6325 100644
--- a/include/sound/soc-dai.h
+++ b/include/sound/soc-dai.h
@@ -154,8 +154,6 @@ int snd_soc_dai_startup(struct snd_soc_dai *dai,
 			struct snd_pcm_substream *substream);
 void snd_soc_dai_shutdown(struct snd_soc_dai *dai,
 			  struct snd_pcm_substream *substream);
-int snd_soc_dai_prepare(struct snd_soc_dai *dai,
-			struct snd_pcm_substream *substream);
 int snd_soc_dai_trigger(struct snd_soc_dai *dai,
 			struct snd_pcm_substream *substream, int cmd);
 int snd_soc_dai_bespoke_trigger(struct snd_soc_dai *dai,
@@ -171,6 +169,7 @@ int snd_soc_dai_compress_new(struct snd_soc_dai *dai,
 bool snd_soc_dai_stream_valid(struct snd_soc_dai *dai, int stream);
 
 int snd_soc_pcm_dai_new(struct snd_soc_pcm_runtime *rtd);
+int snd_soc_pcm_dai_prepare(struct snd_pcm_substream *substream);
 
 struct snd_soc_dai_ops {
 	/*
diff --git a/sound/soc/soc-dai.c b/sound/soc/soc-dai.c
index 1b45e6e114ad..1a9cfdcfc736 100644
--- a/sound/soc/soc-dai.c
+++ b/sound/soc/soc-dai.c
@@ -354,18 +354,6 @@ void snd_soc_dai_shutdown(struct snd_soc_dai *dai,
 		dai->driver->ops->shutdown(substream, dai);
 }
 
-int snd_soc_dai_prepare(struct snd_soc_dai *dai,
-			struct snd_pcm_substream *substream)
-{
-	int ret = 0;
-
-	if (dai->driver->ops &&
-	    dai->driver->ops->prepare)
-		ret = dai->driver->ops->prepare(substream, dai);
-
-	return soc_dai_ret(dai, ret);
-}
-
 int snd_soc_dai_trigger(struct snd_soc_dai *dai,
 			struct snd_pcm_substream *substream,
 			int cmd)
@@ -461,3 +449,21 @@ int snd_soc_pcm_dai_new(struct snd_soc_pcm_runtime *rtd)
 
 	return 0;
 }
+
+int snd_soc_pcm_dai_prepare(struct snd_pcm_substream *substream)
+{
+	struct snd_soc_pcm_runtime *rtd = substream->private_data;
+	struct snd_soc_dai *dai;
+	int i, ret;
+
+	for_each_rtd_dais(rtd, i, dai) {
+		if (dai->driver->ops &&
+		    dai->driver->ops->prepare) {
+			ret = dai->driver->ops->prepare(substream, dai);
+			if (ret < 0)
+				return soc_dai_ret(dai, ret);
+		}
+	}
+
+	return 0;
+}
diff --git a/sound/soc/soc-pcm.c b/sound/soc/soc-pcm.c
index 77a680da366f..f7b3dca1d152 100644
--- a/sound/soc/soc-pcm.c
+++ b/sound/soc/soc-pcm.c
@@ -950,13 +950,10 @@ static int soc_pcm_prepare(struct snd_pcm_substream *substream)
 		}
 	}
 
-	for_each_rtd_dais(rtd, i, dai) {
-		ret = snd_soc_dai_prepare(dai, substream);
-		if (ret < 0) {
-			dev_err(dai->dev,
-				"ASoC: DAI prepare error: %d\n", ret);
-			goto out;
-		}
+	ret = snd_soc_pcm_dai_prepare(substream);
+	if (ret < 0) {
+		dev_err(rtd->dev, "ASoC: DAI prepare error: %d\n", ret);
+		goto out;
 	}
 
 	/* cancel any delayed stream shutdown that is pending */
-- 
2.17.1


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

* [PATCH 05/17] ASoC: soc-dai: add snd_soc_pcm_dai_trigger()
  2020-04-22 23:13 [PATCH 00/17] ASoC: soc-dai: add snd_soc_dai_xxx() Kuninori Morimoto
                   ` (3 preceding siblings ...)
  2020-04-22 23:14 ` [PATCH 04/17] ASoC: soc-dai: add snd_soc_pcm_dai_prepare() Kuninori Morimoto
@ 2020-04-22 23:14 ` Kuninori Morimoto
  2020-04-23  1:16   ` Ranjani Sridharan
  2020-04-22 23:14 ` [PATCH 06/17] ASoC: soc-dai: add snd_soc_pcm_dai_bespoke_trigger() Kuninori Morimoto
                   ` (11 subsequent siblings)
  16 siblings, 1 reply; 28+ messages in thread
From: Kuninori Morimoto @ 2020-04-22 23:14 UTC (permalink / raw)
  To: Mark Brown; +Cc: Linux-ALSA


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

We have 2 type of component functions
snd_soc_dai_xxx()     is focusing to dai itself,
snd_soc_pcm_dai_xxx() is focusing to rtd related dai.

Now we can update snd_soc_dai_trigger() to
snd_soc_pcm_dai_trigger(). This patch do it.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
 include/sound/soc-dai.h |  3 +--
 sound/soc/soc-dai.c     | 32 +++++++++++++++++++-------------
 sound/soc/soc-pcm.c     | 18 ++++++------------
 3 files changed, 26 insertions(+), 27 deletions(-)

diff --git a/include/sound/soc-dai.h b/include/sound/soc-dai.h
index 1b25318b6325..3da850b4aefe 100644
--- a/include/sound/soc-dai.h
+++ b/include/sound/soc-dai.h
@@ -154,8 +154,6 @@ int snd_soc_dai_startup(struct snd_soc_dai *dai,
 			struct snd_pcm_substream *substream);
 void snd_soc_dai_shutdown(struct snd_soc_dai *dai,
 			  struct snd_pcm_substream *substream);
-int snd_soc_dai_trigger(struct snd_soc_dai *dai,
-			struct snd_pcm_substream *substream, int cmd);
 int snd_soc_dai_bespoke_trigger(struct snd_soc_dai *dai,
 			struct snd_pcm_substream *substream, int cmd);
 snd_pcm_sframes_t snd_soc_dai_delay(struct snd_soc_dai *dai,
@@ -170,6 +168,7 @@ bool snd_soc_dai_stream_valid(struct snd_soc_dai *dai, int stream);
 
 int snd_soc_pcm_dai_new(struct snd_soc_pcm_runtime *rtd);
 int snd_soc_pcm_dai_prepare(struct snd_pcm_substream *substream);
+int snd_soc_pcm_dai_trigger(struct snd_pcm_substream *substream, int cmd);
 
 struct snd_soc_dai_ops {
 	/*
diff --git a/sound/soc/soc-dai.c b/sound/soc/soc-dai.c
index 1a9cfdcfc736..29587d7e75ca 100644
--- a/sound/soc/soc-dai.c
+++ b/sound/soc/soc-dai.c
@@ -354,19 +354,6 @@ void snd_soc_dai_shutdown(struct snd_soc_dai *dai,
 		dai->driver->ops->shutdown(substream, dai);
 }
 
-int snd_soc_dai_trigger(struct snd_soc_dai *dai,
-			struct snd_pcm_substream *substream,
-			int cmd)
-{
-	int ret = 0;
-
-	if (dai->driver->ops &&
-	    dai->driver->ops->trigger)
-		ret = dai->driver->ops->trigger(substream, cmd, dai);
-
-	return ret;
-}
-
 int snd_soc_dai_bespoke_trigger(struct snd_soc_dai *dai,
 				struct snd_pcm_substream *substream,
 				int cmd)
@@ -467,3 +454,22 @@ int snd_soc_pcm_dai_prepare(struct snd_pcm_substream *substream)
 
 	return 0;
 }
+
+int snd_soc_pcm_dai_trigger(struct snd_pcm_substream *substream,
+			    int cmd)
+{
+	struct snd_soc_pcm_runtime *rtd = substream->private_data;
+	struct snd_soc_dai *dai;
+	int i, ret;
+
+	for_each_rtd_dais(rtd, i, dai) {
+		if (dai->driver->ops &&
+		    dai->driver->ops->trigger) {
+			ret = dai->driver->ops->trigger(substream, cmd, dai);
+			if (ret < 0)
+				return soc_dai_ret(dai, ret);
+		}
+	}
+
+	return 0;
+}
diff --git a/sound/soc/soc-pcm.c b/sound/soc/soc-pcm.c
index f7b3dca1d152..bc55a249aa61 100644
--- a/sound/soc/soc-pcm.c
+++ b/sound/soc/soc-pcm.c
@@ -1192,7 +1192,6 @@ static int soc_pcm_trigger_start(struct snd_pcm_substream *substream, int cmd)
 {
 	struct snd_soc_pcm_runtime *rtd = substream->private_data;
 	struct snd_soc_component *component;
-	struct snd_soc_dai *dai;
 	int i, ret;
 
 	ret = soc_rtd_trigger(rtd, substream, cmd);
@@ -1205,11 +1204,9 @@ static int soc_pcm_trigger_start(struct snd_pcm_substream *substream, int cmd)
 			return ret;
 	}
 
-	for_each_rtd_dais(rtd, i, dai) {
-		ret = snd_soc_dai_trigger(dai, substream, cmd);
-		if (ret < 0)
-			return ret;
-	}
+	ret = snd_soc_pcm_dai_trigger(substream, cmd);
+	if (ret < 0)
+		return ret;
 
 	return 0;
 }
@@ -1218,14 +1215,11 @@ static int soc_pcm_trigger_stop(struct snd_pcm_substream *substream, int cmd)
 {
 	struct snd_soc_pcm_runtime *rtd = substream->private_data;
 	struct snd_soc_component *component;
-	struct snd_soc_dai *dai;
 	int i, ret;
 
-	for_each_rtd_dais(rtd, i, dai) {
-		ret = snd_soc_dai_trigger(dai, substream, cmd);
-		if (ret < 0)
-			return ret;
-	}
+	ret = snd_soc_pcm_dai_trigger(substream, cmd);
+	if (ret < 0)
+		return ret;
 
 	for_each_rtd_components(rtd, i, component) {
 		ret = snd_soc_component_trigger(component, substream, cmd);
-- 
2.17.1


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

* [PATCH 06/17] ASoC: soc-dai: add snd_soc_pcm_dai_bespoke_trigger()
  2020-04-22 23:13 [PATCH 00/17] ASoC: soc-dai: add snd_soc_dai_xxx() Kuninori Morimoto
                   ` (4 preceding siblings ...)
  2020-04-22 23:14 ` [PATCH 05/17] ASoC: soc-dai: add snd_soc_pcm_dai_trigger() Kuninori Morimoto
@ 2020-04-22 23:14 ` Kuninori Morimoto
  2020-04-22 23:15 ` [PATCH 07/17] ASoC: soc-dai: add snd_soc_pcm_dai_probe() Kuninori Morimoto
                   ` (10 subsequent siblings)
  16 siblings, 0 replies; 28+ messages in thread
From: Kuninori Morimoto @ 2020-04-22 23:14 UTC (permalink / raw)
  To: Mark Brown; +Cc: Linux-ALSA


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

We have 2 type of component functions
snd_soc_dai_xxx()     is focusing to dai itself,
snd_soc_pcm_dai_xxx() is focusing to rtd related dai.

Now we can update soc_pcm_bespoke_trigger() to
snd_soc_pcm_dai_bespoke_trigger(). This patch do it.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
 include/sound/soc-dai.h |  4 ++--
 sound/soc/soc-dai.c     | 33 ++++++++++++++++++++-------------
 sound/soc/soc-pcm.c     | 21 +++------------------
 3 files changed, 25 insertions(+), 33 deletions(-)

diff --git a/include/sound/soc-dai.h b/include/sound/soc-dai.h
index 3da850b4aefe..a0c7ac112b86 100644
--- a/include/sound/soc-dai.h
+++ b/include/sound/soc-dai.h
@@ -154,8 +154,6 @@ int snd_soc_dai_startup(struct snd_soc_dai *dai,
 			struct snd_pcm_substream *substream);
 void snd_soc_dai_shutdown(struct snd_soc_dai *dai,
 			  struct snd_pcm_substream *substream);
-int snd_soc_dai_bespoke_trigger(struct snd_soc_dai *dai,
-			struct snd_pcm_substream *substream, int cmd);
 snd_pcm_sframes_t snd_soc_dai_delay(struct snd_soc_dai *dai,
 				    struct snd_pcm_substream *substream);
 void snd_soc_dai_suspend(struct snd_soc_dai *dai);
@@ -169,6 +167,8 @@ bool snd_soc_dai_stream_valid(struct snd_soc_dai *dai, int stream);
 int snd_soc_pcm_dai_new(struct snd_soc_pcm_runtime *rtd);
 int snd_soc_pcm_dai_prepare(struct snd_pcm_substream *substream);
 int snd_soc_pcm_dai_trigger(struct snd_pcm_substream *substream, int cmd);
+int snd_soc_pcm_dai_bespoke_trigger(struct snd_pcm_substream *substream,
+				    int cmd);
 
 struct snd_soc_dai_ops {
 	/*
diff --git a/sound/soc/soc-dai.c b/sound/soc/soc-dai.c
index 29587d7e75ca..226c51b9089c 100644
--- a/sound/soc/soc-dai.c
+++ b/sound/soc/soc-dai.c
@@ -354,19 +354,6 @@ void snd_soc_dai_shutdown(struct snd_soc_dai *dai,
 		dai->driver->ops->shutdown(substream, dai);
 }
 
-int snd_soc_dai_bespoke_trigger(struct snd_soc_dai *dai,
-				struct snd_pcm_substream *substream,
-				int cmd)
-{
-	int ret = 0;
-
-	if (dai->driver->ops &&
-	    dai->driver->ops->bespoke_trigger)
-		ret = dai->driver->ops->bespoke_trigger(substream, cmd, dai);
-
-	return soc_dai_ret(dai, ret);
-}
-
 snd_pcm_sframes_t snd_soc_dai_delay(struct snd_soc_dai *dai,
 				    struct snd_pcm_substream *substream)
 {
@@ -473,3 +460,23 @@ int snd_soc_pcm_dai_trigger(struct snd_pcm_substream *substream,
 
 	return 0;
 }
+
+int snd_soc_pcm_dai_bespoke_trigger(struct snd_pcm_substream *substream,
+				    int cmd)
+{
+	struct snd_soc_pcm_runtime *rtd = substream->private_data;
+	struct snd_soc_dai *dai;
+	int i, ret;
+
+	for_each_rtd_dais(rtd, i, dai) {
+		if (dai->driver->ops &&
+		    dai->driver->ops->bespoke_trigger) {
+			ret = dai->driver->ops->bespoke_trigger(substream,
+								cmd, dai);
+			if (ret < 0)
+				return soc_dai_ret(dai, ret);
+		}
+	}
+
+	return 0;
+}
diff --git a/sound/soc/soc-pcm.c b/sound/soc/soc-pcm.c
index bc55a249aa61..ff54d25f303f 100644
--- a/sound/soc/soc-pcm.c
+++ b/sound/soc/soc-pcm.c
@@ -1256,21 +1256,6 @@ static int soc_pcm_trigger(struct snd_pcm_substream *substream, int cmd)
 	return ret;
 }
 
-static int soc_pcm_bespoke_trigger(struct snd_pcm_substream *substream,
-				   int cmd)
-{
-	struct snd_soc_pcm_runtime *rtd = substream->private_data;
-	struct snd_soc_dai *dai;
-	int i, ret;
-
-	for_each_rtd_dais(rtd, i, dai) {
-		ret = snd_soc_dai_bespoke_trigger(dai, substream, cmd);
-		if (ret < 0)
-			return ret;
-	}
-
-	return 0;
-}
 /*
  * soc level wrapper for pointer callback
  * If cpu_dai, codec_dai, component driver has the delay callback, then
@@ -2474,7 +2459,7 @@ static int dpcm_fe_dai_do_trigger(struct snd_pcm_substream *substream, int cmd)
 		dev_dbg(fe->dev, "ASoC: bespoke trigger FE %s cmd %d\n",
 				fe->dai_link->name, cmd);
 
-		ret = soc_pcm_bespoke_trigger(substream, cmd);
+		ret = snd_soc_pcm_dai_bespoke_trigger(substream, cmd);
 		break;
 	default:
 		dev_err(fe->dev, "ASoC: invalid trigger cmd %d for %s\n", cmd,
@@ -2619,7 +2604,7 @@ static int dpcm_run_update_shutdown(struct snd_soc_pcm_runtime *fe, int stream)
 		dev_dbg(fe->dev, "ASoC: bespoke trigger FE %s cmd stop\n",
 				fe->dai_link->name);
 
-		err = soc_pcm_bespoke_trigger(substream, SNDRV_PCM_TRIGGER_STOP);
+		err = snd_soc_pcm_dai_bespoke_trigger(substream, SNDRV_PCM_TRIGGER_STOP);
 		if (err < 0)
 			dev_err(fe->dev,"ASoC: trigger FE failed %d\n", err);
 	} else {
@@ -2697,7 +2682,7 @@ static int dpcm_run_update_startup(struct snd_soc_pcm_runtime *fe, int stream)
 		dev_dbg(fe->dev, "ASoC: bespoke trigger FE %s cmd start\n",
 				fe->dai_link->name);
 
-		ret = soc_pcm_bespoke_trigger(substream, SNDRV_PCM_TRIGGER_START);
+		ret = snd_soc_pcm_dai_bespoke_trigger(substream, SNDRV_PCM_TRIGGER_START);
 		if (ret < 0) {
 			dev_err(fe->dev,"ASoC: bespoke trigger FE failed %d\n", ret);
 			goto hw_free;
-- 
2.17.1


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

* [PATCH 07/17] ASoC: soc-dai: add snd_soc_pcm_dai_probe()
  2020-04-22 23:13 [PATCH 00/17] ASoC: soc-dai: add snd_soc_dai_xxx() Kuninori Morimoto
                   ` (5 preceding siblings ...)
  2020-04-22 23:14 ` [PATCH 06/17] ASoC: soc-dai: add snd_soc_pcm_dai_bespoke_trigger() Kuninori Morimoto
@ 2020-04-22 23:15 ` Kuninori Morimoto
  2020-04-22 23:15 ` [PATCH 08/17] ASoC: soc-dai: add snd_soc_pcm_dai_remove() Kuninori Morimoto
                   ` (9 subsequent siblings)
  16 siblings, 0 replies; 28+ messages in thread
From: Kuninori Morimoto @ 2020-04-22 23:15 UTC (permalink / raw)
  To: Mark Brown; +Cc: Linux-ALSA


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

We have 2 type of component functions
snd_soc_dai_xxx()     is focusing to dai itself,
snd_soc_pcm_dai_xxx() is focusing to rtd related dai.

Now we can update snd_soc_dai_probe() to
snd_soc_pcm_dai_probe(). This patch do it.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
 include/sound/soc-dai.h |  2 +-
 sound/soc/soc-core.c    | 33 +++++----------------------------
 sound/soc/soc-dai.c     | 32 ++++++++++++++++++++++----------
 3 files changed, 28 insertions(+), 39 deletions(-)

diff --git a/include/sound/soc-dai.h b/include/sound/soc-dai.h
index a0c7ac112b86..bdb79df637af 100644
--- a/include/sound/soc-dai.h
+++ b/include/sound/soc-dai.h
@@ -158,12 +158,12 @@ snd_pcm_sframes_t snd_soc_dai_delay(struct snd_soc_dai *dai,
 				    struct snd_pcm_substream *substream);
 void snd_soc_dai_suspend(struct snd_soc_dai *dai);
 void snd_soc_dai_resume(struct snd_soc_dai *dai);
-int snd_soc_dai_probe(struct snd_soc_dai *dai);
 int snd_soc_dai_remove(struct snd_soc_dai *dai);
 int snd_soc_dai_compress_new(struct snd_soc_dai *dai,
 			     struct snd_soc_pcm_runtime *rtd, int num);
 bool snd_soc_dai_stream_valid(struct snd_soc_dai *dai, int stream);
 
+int snd_soc_pcm_dai_probe(struct snd_soc_pcm_runtime *rtd, int order);
 int snd_soc_pcm_dai_new(struct snd_soc_pcm_runtime *rtd);
 int snd_soc_pcm_dai_prepare(struct snd_pcm_substream *substream);
 int snd_soc_pcm_dai_trigger(struct snd_pcm_substream *substream, int cmd);
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index 76167fa264af..8cafca4e1405 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -1273,26 +1273,6 @@ static void soc_remove_dai(struct snd_soc_dai *dai, int order)
 	dai->probed = 0;
 }
 
-static int soc_probe_dai(struct snd_soc_dai *dai, int order)
-{
-	int ret;
-
-	if (dai->probed ||
-	    dai->driver->probe_order != order)
-		return 0;
-
-	ret = snd_soc_dai_probe(dai);
-	if (ret < 0) {
-		dev_err(dai->dev, "ASoC: failed to probe DAI %s: %d\n",
-			dai->name, ret);
-		return ret;
-	}
-
-	dai->probed = 1;
-
-	return 0;
-}
-
 static void soc_remove_link_dais(struct snd_soc_card *card)
 {
 	int i;
@@ -1311,9 +1291,8 @@ static void soc_remove_link_dais(struct snd_soc_card *card)
 
 static int soc_probe_link_dais(struct snd_soc_card *card)
 {
-	struct snd_soc_dai *dai;
 	struct snd_soc_pcm_runtime *rtd;
-	int i, order, ret;
+	int order, ret;
 
 	for_each_comp_order(order) {
 		for_each_card_rtds(card, rtd) {
@@ -1322,12 +1301,10 @@ static int soc_probe_link_dais(struct snd_soc_card *card)
 				"ASoC: probe %s dai link %d late %d\n",
 				card->name, rtd->num, order);
 
-			/* probe the CPU DAI */
-			for_each_rtd_dais(rtd, i, dai) {
-				ret = soc_probe_dai(dai, order);
-				if (ret)
-					return ret;
-			}
+			/* probe all rtd connected DAIs in good order */
+			ret = snd_soc_pcm_dai_probe(rtd, order);
+			if (ret)
+				return ret;
 		}
 	}
 
diff --git a/sound/soc/soc-dai.c b/sound/soc/soc-dai.c
index 226c51b9089c..48f5eb5ef387 100644
--- a/sound/soc/soc-dai.c
+++ b/sound/soc/soc-dai.c
@@ -366,16 +366,6 @@ snd_pcm_sframes_t snd_soc_dai_delay(struct snd_soc_dai *dai,
 	return delay;
 }
 
-int snd_soc_dai_probe(struct snd_soc_dai *dai)
-{
-	int ret = 0;
-
-	if (dai->driver->probe)
-		ret = dai->driver->probe(dai);
-
-	return soc_dai_ret(dai, ret);
-}
-
 int snd_soc_dai_remove(struct snd_soc_dai *dai)
 {
 	int ret = 0;
@@ -408,6 +398,28 @@ bool snd_soc_dai_stream_valid(struct snd_soc_dai *dai, int dir)
 	return stream->channels_min;
 }
 
+int snd_soc_pcm_dai_probe(struct snd_soc_pcm_runtime *rtd, int order)
+{
+	struct snd_soc_dai *dai;
+	int i;
+
+	for_each_rtd_dais(rtd, i, dai) {
+		if (dai->driver->probe_order != order)
+			continue;
+
+		if (dai->driver->probe) {
+			int ret = dai->driver->probe(dai);
+
+			if (ret < 0)
+				return soc_dai_ret(dai, ret);
+		}
+
+		dai->probed = 1;
+	}
+
+	return 0;
+}
+
 int snd_soc_pcm_dai_new(struct snd_soc_pcm_runtime *rtd)
 {
 	struct snd_soc_dai *dai;
-- 
2.17.1


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

* [PATCH 08/17] ASoC: soc-dai: add snd_soc_pcm_dai_remove()
  2020-04-22 23:13 [PATCH 00/17] ASoC: soc-dai: add snd_soc_dai_xxx() Kuninori Morimoto
                   ` (6 preceding siblings ...)
  2020-04-22 23:15 ` [PATCH 07/17] ASoC: soc-dai: add snd_soc_pcm_dai_probe() Kuninori Morimoto
@ 2020-04-22 23:15 ` Kuninori Morimoto
  2020-04-22 23:15 ` [PATCH 09/17] ASoC: soc-dai: add snd_soc_dai_compr_start() Kuninori Morimoto
                   ` (8 subsequent siblings)
  16 siblings, 0 replies; 28+ messages in thread
From: Kuninori Morimoto @ 2020-04-22 23:15 UTC (permalink / raw)
  To: Mark Brown; +Cc: Linux-ALSA


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

We have 2 type of component functions
snd_soc_dai_xxx()     is focusing to dai itself,
snd_soc_pcm_dai_xxx() is focusing to rtd related dai.

Now we can update snd_soc_dai_remove() to
snd_soc_pcm_dai_remove(). This patch do it.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
 include/sound/soc-dai.h |  2 +-
 sound/soc/soc-core.c    | 24 ++----------------------
 sound/soc/soc-dai.c     | 32 ++++++++++++++++++++++----------
 3 files changed, 25 insertions(+), 33 deletions(-)

diff --git a/include/sound/soc-dai.h b/include/sound/soc-dai.h
index bdb79df637af..cf7d09f210bc 100644
--- a/include/sound/soc-dai.h
+++ b/include/sound/soc-dai.h
@@ -158,12 +158,12 @@ snd_pcm_sframes_t snd_soc_dai_delay(struct snd_soc_dai *dai,
 				    struct snd_pcm_substream *substream);
 void snd_soc_dai_suspend(struct snd_soc_dai *dai);
 void snd_soc_dai_resume(struct snd_soc_dai *dai);
-int snd_soc_dai_remove(struct snd_soc_dai *dai);
 int snd_soc_dai_compress_new(struct snd_soc_dai *dai,
 			     struct snd_soc_pcm_runtime *rtd, int num);
 bool snd_soc_dai_stream_valid(struct snd_soc_dai *dai, int stream);
 
 int snd_soc_pcm_dai_probe(struct snd_soc_pcm_runtime *rtd, int order);
+int snd_soc_pcm_dai_remove(struct snd_soc_pcm_runtime *rtd, int order);
 int snd_soc_pcm_dai_new(struct snd_soc_pcm_runtime *rtd);
 int snd_soc_pcm_dai_prepare(struct snd_pcm_substream *substream);
 int snd_soc_pcm_dai_trigger(struct snd_pcm_substream *substream, int cmd);
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index 8cafca4e1405..95d8189e45ab 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -1256,35 +1256,15 @@ static int soc_probe_component(struct snd_soc_card *card,
 	return ret;
 }
 
-static void soc_remove_dai(struct snd_soc_dai *dai, int order)
-{
-	int err;
-
-	if (!dai || !dai->probed || !dai->driver ||
-	    dai->driver->remove_order != order)
-		return;
-
-	err = snd_soc_dai_remove(dai);
-	if (err < 0)
-		dev_err(dai->dev,
-			"ASoC: failed to remove %s: %d\n",
-			dai->name, err);
-
-	dai->probed = 0;
-}
-
 static void soc_remove_link_dais(struct snd_soc_card *card)
 {
-	int i;
-	struct snd_soc_dai *dai;
 	struct snd_soc_pcm_runtime *rtd;
 	int order;
 
 	for_each_comp_order(order) {
 		for_each_card_rtds(card, rtd) {
-			/* remove DAIs */
-			for_each_rtd_dais(rtd, i, dai)
-				soc_remove_dai(dai, order);
+			/* remove all rtd connected DAIs in good order */
+			snd_soc_pcm_dai_remove(rtd, order);
 		}
 	}
 }
diff --git a/sound/soc/soc-dai.c b/sound/soc/soc-dai.c
index 48f5eb5ef387..2bc452fe02ff 100644
--- a/sound/soc/soc-dai.c
+++ b/sound/soc/soc-dai.c
@@ -366,16 +366,6 @@ snd_pcm_sframes_t snd_soc_dai_delay(struct snd_soc_dai *dai,
 	return delay;
 }
 
-int snd_soc_dai_remove(struct snd_soc_dai *dai)
-{
-	int ret = 0;
-
-	if (dai->driver->remove)
-		ret = dai->driver->remove(dai);
-
-	return soc_dai_ret(dai, ret);
-}
-
 int snd_soc_dai_compress_new(struct snd_soc_dai *dai,
 			     struct snd_soc_pcm_runtime *rtd, int num)
 {
@@ -420,6 +410,28 @@ int snd_soc_pcm_dai_probe(struct snd_soc_pcm_runtime *rtd, int order)
 	return 0;
 }
 
+int snd_soc_pcm_dai_remove(struct snd_soc_pcm_runtime *rtd, int order)
+{
+	struct snd_soc_dai *dai;
+	int i, r, ret = 0;
+
+	for_each_rtd_dais(rtd, i, dai) {
+		if (dai->driver->remove_order != order)
+			continue;
+
+		if (dai->probed &&
+		    dai->driver->remove) {
+			r = dai->driver->remove(dai);
+			if (r < 0)
+				ret = r; /* use last error */
+		}
+
+		dai->probed = 0;
+	}
+
+	return ret;
+}
+
 int snd_soc_pcm_dai_new(struct snd_soc_pcm_runtime *rtd)
 {
 	struct snd_soc_dai *dai;
-- 
2.17.1


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

* [PATCH 09/17] ASoC: soc-dai: add snd_soc_dai_compr_start()
  2020-04-22 23:13 [PATCH 00/17] ASoC: soc-dai: add snd_soc_dai_xxx() Kuninori Morimoto
                   ` (7 preceding siblings ...)
  2020-04-22 23:15 ` [PATCH 08/17] ASoC: soc-dai: add snd_soc_pcm_dai_remove() Kuninori Morimoto
@ 2020-04-22 23:15 ` Kuninori Morimoto
  2020-04-22 23:15 ` [PATCH 10/17] ASoC: soc-dai: add snd_soc_dai_compr_shutdown() Kuninori Morimoto
                   ` (7 subsequent siblings)
  16 siblings, 0 replies; 28+ messages in thread
From: Kuninori Morimoto @ 2020-04-22 23:15 UTC (permalink / raw)
  To: Mark Brown; +Cc: Linux-ALSA


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

dai related function should be implemented at soc-dai.c.
This patch adds snd_soc_dai_compr_start().

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
 include/sound/soc-dai.h  |  3 +++
 sound/soc/soc-compress.c | 24 ++++++------------------
 sound/soc/soc-dai.c      | 13 +++++++++++++
 3 files changed, 22 insertions(+), 18 deletions(-)

diff --git a/include/sound/soc-dai.h b/include/sound/soc-dai.h
index cf7d09f210bc..deb99b1469b4 100644
--- a/include/sound/soc-dai.h
+++ b/include/sound/soc-dai.h
@@ -170,6 +170,9 @@ int snd_soc_pcm_dai_trigger(struct snd_pcm_substream *substream, int cmd);
 int snd_soc_pcm_dai_bespoke_trigger(struct snd_pcm_substream *substream,
 				    int cmd);
 
+int snd_soc_dai_compr_startup(struct snd_soc_dai *dai,
+			      struct snd_compr_stream *cstream);
+
 struct snd_soc_dai_ops {
 	/*
 	 * DAI clocking configuration, all optional.
diff --git a/sound/soc/soc-compress.c b/sound/soc/soc-compress.c
index ceaf976db0bb..4065e7b4138d 100644
--- a/sound/soc/soc-compress.c
+++ b/sound/soc/soc-compress.c
@@ -87,15 +87,9 @@ static int soc_compr_open(struct snd_compr_stream *cstream)
 
 	mutex_lock_nested(&rtd->card->pcm_mutex, rtd->card->pcm_subclass);
 
-	if (cpu_dai->driver->cops && cpu_dai->driver->cops->startup) {
-		ret = cpu_dai->driver->cops->startup(cstream, cpu_dai);
-		if (ret < 0) {
-			dev_err(cpu_dai->dev,
-				"Compress ASoC: can't open interface %s: %d\n",
-				cpu_dai->name, ret);
-			goto out;
-		}
-	}
+	ret = snd_soc_dai_compr_startup(cpu_dai, cstream);
+	if (ret < 0)
+		goto out;
 
 	ret = soc_compr_components_open(cstream, &component);
 	if (ret < 0)
@@ -178,15 +172,9 @@ static int soc_compr_open_fe(struct snd_compr_stream *cstream)
 		goto out;
 	}
 
-	if (cpu_dai->driver->cops && cpu_dai->driver->cops->startup) {
-		ret = cpu_dai->driver->cops->startup(cstream, cpu_dai);
-		if (ret < 0) {
-			dev_err(cpu_dai->dev,
-				"Compress ASoC: can't open interface %s: %d\n",
-				cpu_dai->name, ret);
-			goto out;
-		}
-	}
+	ret = snd_soc_dai_compr_startup(cpu_dai, cstream);
+	if (ret < 0)
+		goto out;
 
 	ret = soc_compr_components_open(cstream, &component);
 	if (ret < 0)
diff --git a/sound/soc/soc-dai.c b/sound/soc/soc-dai.c
index 2bc452fe02ff..5c88f80b781d 100644
--- a/sound/soc/soc-dai.c
+++ b/sound/soc/soc-dai.c
@@ -504,3 +504,16 @@ int snd_soc_pcm_dai_bespoke_trigger(struct snd_pcm_substream *substream,
 
 	return 0;
 }
+
+int snd_soc_dai_compr_startup(struct snd_soc_dai *dai,
+			      struct snd_compr_stream *cstream)
+{
+	int ret = 0;
+
+	if (dai->driver->cops &&
+	    dai->driver->cops->startup)
+		ret = dai->driver->cops->startup(cstream, dai);
+
+	return soc_dai_ret(dai, ret);
+}
+EXPORT_SYMBOL_GPL(snd_soc_dai_compr_startup);
-- 
2.17.1


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

* [PATCH 10/17] ASoC: soc-dai: add snd_soc_dai_compr_shutdown()
  2020-04-22 23:13 [PATCH 00/17] ASoC: soc-dai: add snd_soc_dai_xxx() Kuninori Morimoto
                   ` (8 preceding siblings ...)
  2020-04-22 23:15 ` [PATCH 09/17] ASoC: soc-dai: add snd_soc_dai_compr_start() Kuninori Morimoto
@ 2020-04-22 23:15 ` Kuninori Morimoto
  2020-04-23  1:31   ` Ranjani Sridharan
  2020-04-22 23:15 ` [PATCH 11/17] ASoC: soc-dai: add snd_soc_dai_compr_trigger() Kuninori Morimoto
                   ` (6 subsequent siblings)
  16 siblings, 1 reply; 28+ messages in thread
From: Kuninori Morimoto @ 2020-04-22 23:15 UTC (permalink / raw)
  To: Mark Brown; +Cc: Linux-ALSA


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

dai related function should be implemented at soc-dai.c.
This patch adds snd_soc_dai_compr_shutdown().

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
 include/sound/soc-dai.h  |  2 ++
 sound/soc/soc-compress.c | 12 ++++--------
 sound/soc/soc-dai.c      |  9 +++++++++
 3 files changed, 15 insertions(+), 8 deletions(-)

diff --git a/include/sound/soc-dai.h b/include/sound/soc-dai.h
index deb99b1469b4..abf4ad25ce68 100644
--- a/include/sound/soc-dai.h
+++ b/include/sound/soc-dai.h
@@ -172,6 +172,8 @@ int snd_soc_pcm_dai_bespoke_trigger(struct snd_pcm_substream *substream,
 
 int snd_soc_dai_compr_startup(struct snd_soc_dai *dai,
 			      struct snd_compr_stream *cstream);
+void snd_soc_dai_compr_shutdown(struct snd_soc_dai *dai,
+				struct snd_compr_stream *cstream);
 
 struct snd_soc_dai_ops {
 	/*
diff --git a/sound/soc/soc-compress.c b/sound/soc/soc-compress.c
index 4065e7b4138d..945d1d15e1d2 100644
--- a/sound/soc/soc-compress.c
+++ b/sound/soc/soc-compress.c
@@ -114,8 +114,7 @@ static int soc_compr_open(struct snd_compr_stream *cstream)
 machine_err:
 	soc_compr_components_free(cstream, component);
 
-	if (cpu_dai->driver->cops && cpu_dai->driver->cops->shutdown)
-		cpu_dai->driver->cops->shutdown(cstream, cpu_dai);
+	snd_soc_dai_compr_shutdown(cpu_dai, cstream);
 out:
 	mutex_unlock(&rtd->card->pcm_mutex);
 pm_err:
@@ -204,8 +203,7 @@ static int soc_compr_open_fe(struct snd_compr_stream *cstream)
 machine_err:
 	soc_compr_components_free(cstream, component);
 open_err:
-	if (cpu_dai->driver->cops && cpu_dai->driver->cops->shutdown)
-		cpu_dai->driver->cops->shutdown(cstream, cpu_dai);
+	snd_soc_dai_compr_shutdown(cpu_dai, cstream);
 out:
 	dpcm_path_put(&list);
 be_err:
@@ -244,8 +242,7 @@ static int soc_compr_free(struct snd_compr_stream *cstream)
 
 	soc_compr_components_free(cstream, NULL);
 
-	if (cpu_dai->driver->cops && cpu_dai->driver->cops->shutdown)
-		cpu_dai->driver->cops->shutdown(cstream, cpu_dai);
+	snd_soc_dai_compr_shutdown(cpu_dai, cstream);
 
 	snd_soc_dapm_stream_stop(rtd, stream);
 
@@ -301,8 +298,7 @@ static int soc_compr_free_fe(struct snd_compr_stream *cstream)
 
 	soc_compr_components_free(cstream, NULL);
 
-	if (cpu_dai->driver->cops && cpu_dai->driver->cops->shutdown)
-		cpu_dai->driver->cops->shutdown(cstream, cpu_dai);
+	snd_soc_dai_compr_shutdown(cpu_dai, cstream);
 
 	mutex_unlock(&fe->card->mutex);
 	return 0;
diff --git a/sound/soc/soc-dai.c b/sound/soc/soc-dai.c
index 5c88f80b781d..d5cb8b0853a7 100644
--- a/sound/soc/soc-dai.c
+++ b/sound/soc/soc-dai.c
@@ -517,3 +517,12 @@ int snd_soc_dai_compr_startup(struct snd_soc_dai *dai,
 	return soc_dai_ret(dai, ret);
 }
 EXPORT_SYMBOL_GPL(snd_soc_dai_compr_startup);
+
+void snd_soc_dai_compr_shutdown(struct snd_soc_dai *dai,
+				struct snd_compr_stream *cstream)
+{
+	if (dai->driver->cops &&
+	    dai->driver->cops->shutdown)
+		dai->driver->cops->shutdown(cstream, dai);
+}
+EXPORT_SYMBOL_GPL(snd_soc_dai_compr_shutdown);
-- 
2.17.1


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

* [PATCH 11/17] ASoC: soc-dai: add snd_soc_dai_compr_trigger()
  2020-04-22 23:13 [PATCH 00/17] ASoC: soc-dai: add snd_soc_dai_xxx() Kuninori Morimoto
                   ` (9 preceding siblings ...)
  2020-04-22 23:15 ` [PATCH 10/17] ASoC: soc-dai: add snd_soc_dai_compr_shutdown() Kuninori Morimoto
@ 2020-04-22 23:15 ` Kuninori Morimoto
  2020-04-22 23:15 ` [PATCH 12/17] ASoC: soc-dai: add snd_soc_dai_compr_set_params() Kuninori Morimoto
                   ` (5 subsequent siblings)
  16 siblings, 0 replies; 28+ messages in thread
From: Kuninori Morimoto @ 2020-04-22 23:15 UTC (permalink / raw)
  To: Mark Brown; +Cc: Linux-ALSA


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

dai related function should be implemented at soc-dai.c.
This patch adds snd_soc_dai_compr_trigger().

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
 include/sound/soc-dai.h  |  2 ++
 sound/soc/soc-compress.c | 13 ++++++-------
 sound/soc/soc-dai.c      | 13 +++++++++++++
 3 files changed, 21 insertions(+), 7 deletions(-)

diff --git a/include/sound/soc-dai.h b/include/sound/soc-dai.h
index abf4ad25ce68..ae04575ed8bc 100644
--- a/include/sound/soc-dai.h
+++ b/include/sound/soc-dai.h
@@ -174,6 +174,8 @@ int snd_soc_dai_compr_startup(struct snd_soc_dai *dai,
 			      struct snd_compr_stream *cstream);
 void snd_soc_dai_compr_shutdown(struct snd_soc_dai *dai,
 				struct snd_compr_stream *cstream);
+int snd_soc_dai_compr_trigger(struct snd_soc_dai *dai,
+			      struct snd_compr_stream *cstream, int cmd);
 
 struct snd_soc_dai_ops {
 	/*
diff --git a/sound/soc/soc-compress.c b/sound/soc/soc-compress.c
index 945d1d15e1d2..7b4afe1d871b 100644
--- a/sound/soc/soc-compress.c
+++ b/sound/soc/soc-compress.c
@@ -338,8 +338,9 @@ static int soc_compr_trigger(struct snd_compr_stream *cstream, int cmd)
 	if (ret < 0)
 		goto out;
 
-	if (cpu_dai->driver->cops && cpu_dai->driver->cops->trigger)
-		cpu_dai->driver->cops->trigger(cstream, cmd, cpu_dai);
+	ret = snd_soc_dai_compr_trigger(cpu_dai, cstream, cmd);
+	if (ret < 0)
+		goto out;
 
 	switch (cmd) {
 	case SNDRV_PCM_TRIGGER_START:
@@ -372,11 +373,9 @@ static int soc_compr_trigger_fe(struct snd_compr_stream *cstream, int cmd)
 
 	mutex_lock_nested(&fe->card->mutex, SND_SOC_CARD_CLASS_RUNTIME);
 
-	if (cpu_dai->driver->cops && cpu_dai->driver->cops->trigger) {
-		ret = cpu_dai->driver->cops->trigger(cstream, cmd, cpu_dai);
-		if (ret < 0)
-			goto out;
-	}
+	ret = snd_soc_dai_compr_trigger(cpu_dai, cstream, cmd);
+	if (ret < 0)
+		goto out;
 
 	ret = soc_compr_components_trigger(cstream, cmd);
 	if (ret < 0)
diff --git a/sound/soc/soc-dai.c b/sound/soc/soc-dai.c
index d5cb8b0853a7..844b52528174 100644
--- a/sound/soc/soc-dai.c
+++ b/sound/soc/soc-dai.c
@@ -526,3 +526,16 @@ void snd_soc_dai_compr_shutdown(struct snd_soc_dai *dai,
 		dai->driver->cops->shutdown(cstream, dai);
 }
 EXPORT_SYMBOL_GPL(snd_soc_dai_compr_shutdown);
+
+int snd_soc_dai_compr_trigger(struct snd_soc_dai *dai,
+			      struct snd_compr_stream *cstream, int cmd)
+{
+	int ret = 0;
+
+	if (dai->driver->cops &&
+	    dai->driver->cops->trigger)
+		ret = dai->driver->cops->trigger(cstream, cmd, dai);
+
+	return soc_dai_ret(dai, ret);
+}
+EXPORT_SYMBOL_GPL(snd_soc_dai_compr_trigger);
-- 
2.17.1


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

* [PATCH 12/17] ASoC: soc-dai: add snd_soc_dai_compr_set_params()
  2020-04-22 23:13 [PATCH 00/17] ASoC: soc-dai: add snd_soc_dai_xxx() Kuninori Morimoto
                   ` (10 preceding siblings ...)
  2020-04-22 23:15 ` [PATCH 11/17] ASoC: soc-dai: add snd_soc_dai_compr_trigger() Kuninori Morimoto
@ 2020-04-22 23:15 ` Kuninori Morimoto
  2020-04-22 23:15 ` [PATCH 13/17] ASoC: soc-dai: add snd_soc_dai_compr_get_params() Kuninori Morimoto
                   ` (4 subsequent siblings)
  16 siblings, 0 replies; 28+ messages in thread
From: Kuninori Morimoto @ 2020-04-22 23:15 UTC (permalink / raw)
  To: Mark Brown; +Cc: Linux-ALSA


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

dai related function should be implemented at soc-dai.c.
This patch adds snd_soc_dai_compr_set_params().

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
 include/sound/soc-dai.h  |  3 +++
 sound/soc/soc-compress.c | 16 ++++++----------
 sound/soc/soc-dai.c      | 14 ++++++++++++++
 3 files changed, 23 insertions(+), 10 deletions(-)

diff --git a/include/sound/soc-dai.h b/include/sound/soc-dai.h
index ae04575ed8bc..1a2ef3002b6a 100644
--- a/include/sound/soc-dai.h
+++ b/include/sound/soc-dai.h
@@ -176,6 +176,9 @@ void snd_soc_dai_compr_shutdown(struct snd_soc_dai *dai,
 				struct snd_compr_stream *cstream);
 int snd_soc_dai_compr_trigger(struct snd_soc_dai *dai,
 			      struct snd_compr_stream *cstream, int cmd);
+int snd_soc_dai_compr_set_params(struct snd_soc_dai *dai,
+				 struct snd_compr_stream *cstream,
+				 struct snd_compr_params *params);
 
 struct snd_soc_dai_ops {
 	/*
diff --git a/sound/soc/soc-compress.c b/sound/soc/soc-compress.c
index 7b4afe1d871b..6d2a896b3dbc 100644
--- a/sound/soc/soc-compress.c
+++ b/sound/soc/soc-compress.c
@@ -443,11 +443,9 @@ static int soc_compr_set_params(struct snd_compr_stream *cstream,
 	 * that these callbacks will configure everything for this compress
 	 * path, like configuring a PCM port for a CODEC.
 	 */
-	if (cpu_dai->driver->cops && cpu_dai->driver->cops->set_params) {
-		ret = cpu_dai->driver->cops->set_params(cstream, params, cpu_dai);
-		if (ret < 0)
-			goto err;
-	}
+	ret = snd_soc_dai_compr_set_params(cpu_dai, cstream, params);
+	if (ret < 0)
+		goto err;
 
 	ret = soc_compr_components_set_params(cstream, params);
 	if (ret < 0)
@@ -513,11 +511,9 @@ static int soc_compr_set_params_fe(struct snd_compr_stream *cstream,
 	if (ret < 0)
 		goto out;
 
-	if (cpu_dai->driver->cops && cpu_dai->driver->cops->set_params) {
-		ret = cpu_dai->driver->cops->set_params(cstream, params, cpu_dai);
-		if (ret < 0)
-			goto out;
-	}
+	ret = snd_soc_dai_compr_set_params(cpu_dai, cstream, params);
+	if (ret < 0)
+		goto out;
 
 	ret = soc_compr_components_set_params(cstream, params);
 	if (ret < 0)
diff --git a/sound/soc/soc-dai.c b/sound/soc/soc-dai.c
index 844b52528174..44e754f03947 100644
--- a/sound/soc/soc-dai.c
+++ b/sound/soc/soc-dai.c
@@ -539,3 +539,17 @@ int snd_soc_dai_compr_trigger(struct snd_soc_dai *dai,
 	return soc_dai_ret(dai, ret);
 }
 EXPORT_SYMBOL_GPL(snd_soc_dai_compr_trigger);
+
+int snd_soc_dai_compr_set_params(struct snd_soc_dai *dai,
+				 struct snd_compr_stream *cstream,
+				 struct snd_compr_params *params)
+{
+	int ret = 0;
+
+	if (dai->driver->cops &&
+	    dai->driver->cops->set_params)
+		ret = dai->driver->cops->set_params(cstream, params, dai);
+
+	return soc_dai_ret(dai, ret);
+}
+EXPORT_SYMBOL_GPL(snd_soc_dai_compr_set_params);
-- 
2.17.1


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

* [PATCH 13/17] ASoC: soc-dai: add snd_soc_dai_compr_get_params()
  2020-04-22 23:13 [PATCH 00/17] ASoC: soc-dai: add snd_soc_dai_xxx() Kuninori Morimoto
                   ` (11 preceding siblings ...)
  2020-04-22 23:15 ` [PATCH 12/17] ASoC: soc-dai: add snd_soc_dai_compr_set_params() Kuninori Morimoto
@ 2020-04-22 23:15 ` Kuninori Morimoto
  2020-04-22 23:15 ` [PATCH 14/17] ASoC: soc-dai: add snd_soc_dai_compr_ack() Kuninori Morimoto
                   ` (3 subsequent siblings)
  16 siblings, 0 replies; 28+ messages in thread
From: Kuninori Morimoto @ 2020-04-22 23:15 UTC (permalink / raw)
  To: Mark Brown; +Cc: Linux-ALSA


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

dai related function should be implemented at soc-dai.c.
This patch adds snd_soc_dai_compr_get_params().

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
 include/sound/soc-dai.h  |  3 +++
 sound/soc/soc-compress.c |  8 +++-----
 sound/soc/soc-dai.c      | 14 ++++++++++++++
 3 files changed, 20 insertions(+), 5 deletions(-)

diff --git a/include/sound/soc-dai.h b/include/sound/soc-dai.h
index 1a2ef3002b6a..ba48dc9d0a73 100644
--- a/include/sound/soc-dai.h
+++ b/include/sound/soc-dai.h
@@ -179,6 +179,9 @@ int snd_soc_dai_compr_trigger(struct snd_soc_dai *dai,
 int snd_soc_dai_compr_set_params(struct snd_soc_dai *dai,
 				 struct snd_compr_stream *cstream,
 				 struct snd_compr_params *params);
+int snd_soc_dai_compr_get_params(struct snd_soc_dai *dai,
+				 struct snd_compr_stream *cstream,
+				 struct snd_codec *params);
 
 struct snd_soc_dai_ops {
 	/*
diff --git a/sound/soc/soc-compress.c b/sound/soc/soc-compress.c
index 6d2a896b3dbc..031f7d95b112 100644
--- a/sound/soc/soc-compress.c
+++ b/sound/soc/soc-compress.c
@@ -544,11 +544,9 @@ static int soc_compr_get_params(struct snd_compr_stream *cstream,
 
 	mutex_lock_nested(&rtd->card->pcm_mutex, rtd->card->pcm_subclass);
 
-	if (cpu_dai->driver->cops && cpu_dai->driver->cops->get_params) {
-		ret = cpu_dai->driver->cops->get_params(cstream, params, cpu_dai);
-		if (ret < 0)
-			goto err;
-	}
+	ret = snd_soc_dai_compr_get_params(cpu_dai, cstream, params);
+	if (ret < 0)
+		goto err;
 
 	for_each_rtd_components(rtd, i, component) {
 		if (!component->driver->compress_ops ||
diff --git a/sound/soc/soc-dai.c b/sound/soc/soc-dai.c
index 44e754f03947..c06e510855f2 100644
--- a/sound/soc/soc-dai.c
+++ b/sound/soc/soc-dai.c
@@ -553,3 +553,17 @@ int snd_soc_dai_compr_set_params(struct snd_soc_dai *dai,
 	return soc_dai_ret(dai, ret);
 }
 EXPORT_SYMBOL_GPL(snd_soc_dai_compr_set_params);
+
+int snd_soc_dai_compr_get_params(struct snd_soc_dai *dai,
+				 struct snd_compr_stream *cstream,
+				 struct snd_codec *params)
+{
+	int ret = 0;
+
+	if (dai->driver->cops &&
+	    dai->driver->cops->get_params)
+		ret = dai->driver->cops->get_params(cstream, params, dai);
+
+	return soc_dai_ret(dai, ret);
+}
+EXPORT_SYMBOL_GPL(snd_soc_dai_compr_get_params);
-- 
2.17.1


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

* [PATCH 14/17] ASoC: soc-dai: add snd_soc_dai_compr_ack()
  2020-04-22 23:13 [PATCH 00/17] ASoC: soc-dai: add snd_soc_dai_xxx() Kuninori Morimoto
                   ` (12 preceding siblings ...)
  2020-04-22 23:15 ` [PATCH 13/17] ASoC: soc-dai: add snd_soc_dai_compr_get_params() Kuninori Morimoto
@ 2020-04-22 23:15 ` Kuninori Morimoto
  2020-04-22 23:15 ` [PATCH 15/17] ASoC: soc-dai: add snd_soc_dai_compr_pointer() Kuninori Morimoto
                   ` (2 subsequent siblings)
  16 siblings, 0 replies; 28+ messages in thread
From: Kuninori Morimoto @ 2020-04-22 23:15 UTC (permalink / raw)
  To: Mark Brown; +Cc: Linux-ALSA


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

dai related function should be implemented at soc-dai.c.
This patch adds snd_soc_dai_compr_ack().

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
 include/sound/soc-dai.h  |  3 +++
 sound/soc/soc-compress.c |  8 +++-----
 sound/soc/soc-dai.c      | 14 ++++++++++++++
 3 files changed, 20 insertions(+), 5 deletions(-)

diff --git a/include/sound/soc-dai.h b/include/sound/soc-dai.h
index ba48dc9d0a73..16dc9248f7f0 100644
--- a/include/sound/soc-dai.h
+++ b/include/sound/soc-dai.h
@@ -182,6 +182,9 @@ int snd_soc_dai_compr_set_params(struct snd_soc_dai *dai,
 int snd_soc_dai_compr_get_params(struct snd_soc_dai *dai,
 				 struct snd_compr_stream *cstream,
 				 struct snd_codec *params);
+int snd_soc_dai_compr_ack(struct snd_soc_dai *dai,
+			  struct snd_compr_stream *cstream,
+			  size_t bytes);
 
 struct snd_soc_dai_ops {
 	/*
diff --git a/sound/soc/soc-compress.c b/sound/soc/soc-compress.c
index 031f7d95b112..d4b016d99e5d 100644
--- a/sound/soc/soc-compress.c
+++ b/sound/soc/soc-compress.c
@@ -618,11 +618,9 @@ static int soc_compr_ack(struct snd_compr_stream *cstream, size_t bytes)
 
 	mutex_lock_nested(&rtd->card->pcm_mutex, rtd->card->pcm_subclass);
 
-	if (cpu_dai->driver->cops && cpu_dai->driver->cops->ack) {
-		ret = cpu_dai->driver->cops->ack(cstream, bytes, cpu_dai);
-		if (ret < 0)
-			goto err;
-	}
+	ret = snd_soc_dai_compr_ack(cpu_dai, cstream, bytes);
+	if (ret < 0)
+		goto err;
 
 	for_each_rtd_components(rtd, i, component) {
 		if (!component->driver->compress_ops ||
diff --git a/sound/soc/soc-dai.c b/sound/soc/soc-dai.c
index c06e510855f2..bf52ecb26c0e 100644
--- a/sound/soc/soc-dai.c
+++ b/sound/soc/soc-dai.c
@@ -567,3 +567,17 @@ int snd_soc_dai_compr_get_params(struct snd_soc_dai *dai,
 	return soc_dai_ret(dai, ret);
 }
 EXPORT_SYMBOL_GPL(snd_soc_dai_compr_get_params);
+
+int snd_soc_dai_compr_ack(struct snd_soc_dai *dai,
+			  struct snd_compr_stream *cstream,
+			  size_t bytes)
+{
+	int ret = 0;
+
+	if (dai->driver->cops &&
+	    dai->driver->cops->ack)
+		ret = dai->driver->cops->ack(cstream, bytes, dai);
+
+	return soc_dai_ret(dai, ret);
+}
+EXPORT_SYMBOL_GPL(snd_soc_dai_compr_ack);
-- 
2.17.1


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

* [PATCH 15/17] ASoC: soc-dai: add snd_soc_dai_compr_pointer()
  2020-04-22 23:13 [PATCH 00/17] ASoC: soc-dai: add snd_soc_dai_xxx() Kuninori Morimoto
                   ` (13 preceding siblings ...)
  2020-04-22 23:15 ` [PATCH 14/17] ASoC: soc-dai: add snd_soc_dai_compr_ack() Kuninori Morimoto
@ 2020-04-22 23:15 ` Kuninori Morimoto
  2020-04-22 23:16 ` [PATCH 16/17] ASoC: soc-dai: add snd_soc_dai_compr_set_metadata() Kuninori Morimoto
  2020-04-22 23:16 ` [PATCH 17/17] ASoC: soc-dai: add snd_soc_dai_compr_get_metadata() Kuninori Morimoto
  16 siblings, 0 replies; 28+ messages in thread
From: Kuninori Morimoto @ 2020-04-22 23:15 UTC (permalink / raw)
  To: Mark Brown; +Cc: Linux-ALSA


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

dai related function should be implemented at soc-dai.c.
This patch adds snd_soc_dai_compr_pointer().

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
 include/sound/soc-dai.h  |  3 +++
 sound/soc/soc-compress.c |  7 ++++---
 sound/soc/soc-dai.c      | 14 ++++++++++++++
 3 files changed, 21 insertions(+), 3 deletions(-)

diff --git a/include/sound/soc-dai.h b/include/sound/soc-dai.h
index 16dc9248f7f0..8101ec030e63 100644
--- a/include/sound/soc-dai.h
+++ b/include/sound/soc-dai.h
@@ -185,6 +185,9 @@ int snd_soc_dai_compr_get_params(struct snd_soc_dai *dai,
 int snd_soc_dai_compr_ack(struct snd_soc_dai *dai,
 			  struct snd_compr_stream *cstream,
 			  size_t bytes);
+int snd_soc_dai_compr_pointer(struct snd_soc_dai *dai,
+			      struct snd_compr_stream *cstream,
+			      struct snd_compr_tstamp *tstamp);
 
 struct snd_soc_dai_ops {
 	/*
diff --git a/sound/soc/soc-compress.c b/sound/soc/soc-compress.c
index d4b016d99e5d..062a8c521876 100644
--- a/sound/soc/soc-compress.c
+++ b/sound/soc/soc-compress.c
@@ -648,8 +648,9 @@ static int soc_compr_pointer(struct snd_compr_stream *cstream,
 
 	mutex_lock_nested(&rtd->card->pcm_mutex, rtd->card->pcm_subclass);
 
-	if (cpu_dai->driver->cops && cpu_dai->driver->cops->pointer)
-		cpu_dai->driver->cops->pointer(cstream, tstamp, cpu_dai);
+	ret = snd_soc_dai_compr_pointer(cpu_dai, cstream, tstamp);
+	if (ret < 0)
+		goto out;
 
 	for_each_rtd_components(rtd, i, component) {
 		if (!component->driver->compress_ops ||
@@ -660,7 +661,7 @@ static int soc_compr_pointer(struct snd_compr_stream *cstream,
 			component, cstream, tstamp);
 		break;
 	}
-
+out:
 	mutex_unlock(&rtd->card->pcm_mutex);
 	return ret;
 }
diff --git a/sound/soc/soc-dai.c b/sound/soc/soc-dai.c
index bf52ecb26c0e..89fcf194c45e 100644
--- a/sound/soc/soc-dai.c
+++ b/sound/soc/soc-dai.c
@@ -581,3 +581,17 @@ int snd_soc_dai_compr_ack(struct snd_soc_dai *dai,
 	return soc_dai_ret(dai, ret);
 }
 EXPORT_SYMBOL_GPL(snd_soc_dai_compr_ack);
+
+int snd_soc_dai_compr_pointer(struct snd_soc_dai *dai,
+			      struct snd_compr_stream *cstream,
+			      struct snd_compr_tstamp *tstamp)
+{
+	int ret = 0;
+
+	if (dai->driver->cops &&
+	    dai->driver->cops->pointer)
+		ret = dai->driver->cops->pointer(cstream, tstamp, dai);
+
+	return soc_dai_ret(dai, ret);
+}
+EXPORT_SYMBOL_GPL(snd_soc_dai_compr_pointer);
-- 
2.17.1


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

* [PATCH 16/17] ASoC: soc-dai: add snd_soc_dai_compr_set_metadata()
  2020-04-22 23:13 [PATCH 00/17] ASoC: soc-dai: add snd_soc_dai_xxx() Kuninori Morimoto
                   ` (14 preceding siblings ...)
  2020-04-22 23:15 ` [PATCH 15/17] ASoC: soc-dai: add snd_soc_dai_compr_pointer() Kuninori Morimoto
@ 2020-04-22 23:16 ` Kuninori Morimoto
  2020-04-22 23:16 ` [PATCH 17/17] ASoC: soc-dai: add snd_soc_dai_compr_get_metadata() Kuninori Morimoto
  16 siblings, 0 replies; 28+ messages in thread
From: Kuninori Morimoto @ 2020-04-22 23:16 UTC (permalink / raw)
  To: Mark Brown; +Cc: Linux-ALSA


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

dai related function should be implemented at soc-dai.c.
This patch adds snd_soc_dai_compr_set_metadata().

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
 include/sound/soc-dai.h  |  3 +++
 sound/soc/soc-compress.c |  8 +++-----
 sound/soc/soc-dai.c      | 14 ++++++++++++++
 3 files changed, 20 insertions(+), 5 deletions(-)

diff --git a/include/sound/soc-dai.h b/include/sound/soc-dai.h
index 8101ec030e63..d21a2a33b7bc 100644
--- a/include/sound/soc-dai.h
+++ b/include/sound/soc-dai.h
@@ -188,6 +188,9 @@ int snd_soc_dai_compr_ack(struct snd_soc_dai *dai,
 int snd_soc_dai_compr_pointer(struct snd_soc_dai *dai,
 			      struct snd_compr_stream *cstream,
 			      struct snd_compr_tstamp *tstamp);
+int snd_soc_dai_compr_set_metadata(struct snd_soc_dai *dai,
+				   struct snd_compr_stream *cstream,
+				   struct snd_compr_metadata *metadata);
 
 struct snd_soc_dai_ops {
 	/*
diff --git a/sound/soc/soc-compress.c b/sound/soc/soc-compress.c
index 062a8c521876..01f10204efdc 100644
--- a/sound/soc/soc-compress.c
+++ b/sound/soc/soc-compress.c
@@ -697,11 +697,9 @@ static int soc_compr_set_metadata(struct snd_compr_stream *cstream,
 	struct snd_soc_dai *cpu_dai = asoc_rtd_to_cpu(rtd, 0);
 	int i, ret;
 
-	if (cpu_dai->driver->cops && cpu_dai->driver->cops->set_metadata) {
-		ret = cpu_dai->driver->cops->set_metadata(cstream, metadata, cpu_dai);
-		if (ret < 0)
-			return ret;
-	}
+	ret = snd_soc_dai_compr_set_metadata(cpu_dai, cstream, metadata);
+	if (ret < 0)
+		return ret;
 
 	for_each_rtd_components(rtd, i, component) {
 		if (!component->driver->compress_ops ||
diff --git a/sound/soc/soc-dai.c b/sound/soc/soc-dai.c
index 89fcf194c45e..88990792fe49 100644
--- a/sound/soc/soc-dai.c
+++ b/sound/soc/soc-dai.c
@@ -595,3 +595,17 @@ int snd_soc_dai_compr_pointer(struct snd_soc_dai *dai,
 	return soc_dai_ret(dai, ret);
 }
 EXPORT_SYMBOL_GPL(snd_soc_dai_compr_pointer);
+
+int snd_soc_dai_compr_set_metadata(struct snd_soc_dai *dai,
+				   struct snd_compr_stream *cstream,
+				   struct snd_compr_metadata *metadata)
+{
+	int ret = 0;
+
+	if (dai->driver->cops &&
+	    dai->driver->cops->set_metadata)
+		ret = dai->driver->cops->set_metadata(cstream, metadata, dai);
+
+	return soc_dai_ret(dai, ret);
+}
+EXPORT_SYMBOL_GPL(snd_soc_dai_compr_set_metadata);
-- 
2.17.1


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

* [PATCH 17/17] ASoC: soc-dai: add snd_soc_dai_compr_get_metadata()
  2020-04-22 23:13 [PATCH 00/17] ASoC: soc-dai: add snd_soc_dai_xxx() Kuninori Morimoto
                   ` (15 preceding siblings ...)
  2020-04-22 23:16 ` [PATCH 16/17] ASoC: soc-dai: add snd_soc_dai_compr_set_metadata() Kuninori Morimoto
@ 2020-04-22 23:16 ` Kuninori Morimoto
  16 siblings, 0 replies; 28+ messages in thread
From: Kuninori Morimoto @ 2020-04-22 23:16 UTC (permalink / raw)
  To: Mark Brown; +Cc: Linux-ALSA


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

dai related function should be implemented at soc-dai.c.
This patch adds snd_soc_dai_compr_get_metadata().

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
 include/sound/soc-dai.h  |  3 +++
 sound/soc/soc-compress.c |  8 +++-----
 sound/soc/soc-dai.c      | 14 ++++++++++++++
 3 files changed, 20 insertions(+), 5 deletions(-)

diff --git a/include/sound/soc-dai.h b/include/sound/soc-dai.h
index d21a2a33b7bc..2a0a5af1c1ae 100644
--- a/include/sound/soc-dai.h
+++ b/include/sound/soc-dai.h
@@ -191,6 +191,9 @@ int snd_soc_dai_compr_pointer(struct snd_soc_dai *dai,
 int snd_soc_dai_compr_set_metadata(struct snd_soc_dai *dai,
 				   struct snd_compr_stream *cstream,
 				   struct snd_compr_metadata *metadata);
+int snd_soc_dai_compr_get_metadata(struct snd_soc_dai *dai,
+				   struct snd_compr_stream *cstream,
+				   struct snd_compr_metadata *metadata);
 
 struct snd_soc_dai_ops {
 	/*
diff --git a/sound/soc/soc-compress.c b/sound/soc/soc-compress.c
index 01f10204efdc..1dd043e1e407 100644
--- a/sound/soc/soc-compress.c
+++ b/sound/soc/soc-compress.c
@@ -723,11 +723,9 @@ static int soc_compr_get_metadata(struct snd_compr_stream *cstream,
 	struct snd_soc_dai *cpu_dai = asoc_rtd_to_cpu(rtd, 0);
 	int i, ret;
 
-	if (cpu_dai->driver->cops && cpu_dai->driver->cops->get_metadata) {
-		ret = cpu_dai->driver->cops->get_metadata(cstream, metadata, cpu_dai);
-		if (ret < 0)
-			return ret;
-	}
+	ret = snd_soc_dai_compr_get_metadata(cpu_dai, cstream, metadata);
+	if (ret < 0)
+		return ret;
 
 	for_each_rtd_components(rtd, i, component) {
 		if (!component->driver->compress_ops ||
diff --git a/sound/soc/soc-dai.c b/sound/soc/soc-dai.c
index 88990792fe49..8e5fe012aa1d 100644
--- a/sound/soc/soc-dai.c
+++ b/sound/soc/soc-dai.c
@@ -609,3 +609,17 @@ int snd_soc_dai_compr_set_metadata(struct snd_soc_dai *dai,
 	return soc_dai_ret(dai, ret);
 }
 EXPORT_SYMBOL_GPL(snd_soc_dai_compr_set_metadata);
+
+int snd_soc_dai_compr_get_metadata(struct snd_soc_dai *dai,
+				   struct snd_compr_stream *cstream,
+				   struct snd_compr_metadata *metadata)
+{
+	int ret = 0;
+
+	if (dai->driver->cops &&
+	    dai->driver->cops->get_metadata)
+		ret = dai->driver->cops->get_metadata(cstream, metadata, dai);
+
+	return soc_dai_ret(dai, ret);
+}
+EXPORT_SYMBOL_GPL(snd_soc_dai_compr_get_metadata);
-- 
2.17.1


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

* Re: [PATCH 05/17] ASoC: soc-dai: add snd_soc_pcm_dai_trigger()
  2020-04-22 23:14 ` [PATCH 05/17] ASoC: soc-dai: add snd_soc_pcm_dai_trigger() Kuninori Morimoto
@ 2020-04-23  1:16   ` Ranjani Sridharan
  2020-04-23  1:44     ` Kuninori Morimoto
  0 siblings, 1 reply; 28+ messages in thread
From: Ranjani Sridharan @ 2020-04-23  1:16 UTC (permalink / raw)
  To: Kuninori Morimoto, Mark Brown; +Cc: Linux-ALSA

On Thu, 2020-04-23 at 08:14 +0900, Kuninori Morimoto wrote:
> From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
> 
> We have 2 type of component functions
> snd_soc_dai_xxx()     is focusing to dai itself,
> snd_soc_pcm_dai_xxx() is focusing to rtd related dai.
> 
> Now we can update snd_soc_dai_trigger() to
> snd_soc_pcm_dai_trigger(). This patch do it.
> 
> Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
> ---
>  include/sound/soc-dai.h |  3 +--
>  sound/soc/soc-dai.c     | 32 +++++++++++++++++++-------------
>  sound/soc/soc-pcm.c     | 18 ++++++------------
>  3 files changed, 26 insertions(+), 27 deletions(-)
> 
> diff --git a/include/sound/soc-dai.h b/include/sound/soc-dai.h
> index 1b25318b6325..3da850b4aefe 100644
> --- a/include/sound/soc-dai.h
> +++ b/include/sound/soc-dai.h
> @@ -154,8 +154,6 @@ int snd_soc_dai_startup(struct snd_soc_dai *dai,
>  			struct snd_pcm_substream *substream);
>  void snd_soc_dai_shutdown(struct snd_soc_dai *dai,
>  			  struct snd_pcm_substream *substream);
> -int snd_soc_dai_trigger(struct snd_soc_dai *dai,
> -			struct snd_pcm_substream *substream, int cmd);
>  int snd_soc_dai_bespoke_trigger(struct snd_soc_dai *dai,
>  			struct snd_pcm_substream *substream, int cmd);
>  snd_pcm_sframes_t snd_soc_dai_delay(struct snd_soc_dai *dai,
> @@ -170,6 +168,7 @@ bool snd_soc_dai_stream_valid(struct snd_soc_dai
> *dai, int stream);
>  
>  int snd_soc_pcm_dai_new(struct snd_soc_pcm_runtime *rtd);
>  int snd_soc_pcm_dai_prepare(struct snd_pcm_substream *substream);
> +int snd_soc_pcm_dai_trigger(struct snd_pcm_substream *substream, int
> cmd);
>  
>  struct snd_soc_dai_ops {
>  	/*
> diff --git a/sound/soc/soc-dai.c b/sound/soc/soc-dai.c
> index 1a9cfdcfc736..29587d7e75ca 100644
> --- a/sound/soc/soc-dai.c
> +++ b/sound/soc/soc-dai.c
> @@ -354,19 +354,6 @@ void snd_soc_dai_shutdown(struct snd_soc_dai
> *dai,
>  		dai->driver->ops->shutdown(substream, dai);
>  }
>  
> -int snd_soc_dai_trigger(struct snd_soc_dai *dai,
> -			struct snd_pcm_substream *substream,
> -			int cmd)
> -{
> -	int ret = 0;
> -
> -	if (dai->driver->ops &&
> -	    dai->driver->ops->trigger)
> -		ret = dai->driver->ops->trigger(substream, cmd, dai);
> -
> -	return ret;
> -}
> -
>  int snd_soc_dai_bespoke_trigger(struct snd_soc_dai *dai,
>  				struct snd_pcm_substream *substream,
>  				int cmd)
> @@ -467,3 +454,22 @@ int snd_soc_pcm_dai_prepare(struct
> snd_pcm_substream *substream)
>  
>  	return 0;
>  }
> +
> +int snd_soc_pcm_dai_trigger(struct snd_pcm_substream *substream,
> +			    int cmd)
> +{
> +	struct snd_soc_pcm_runtime *rtd = substream->private_data;
> +	struct snd_soc_dai *dai;
> +	int i, ret;
> +
> +	for_each_rtd_dais(rtd, i, dai) {
> +		if (dai->driver->ops &&
> +		    dai->driver->ops->trigger) {
> +			ret = dai->driver->ops->trigger(substream, cmd,
> dai);
> +			if (ret < 0)
> +				return soc_dai_ret(dai, ret);
> +		}
> +	}
> +
> +	return 0;
> +}
> diff --git a/sound/soc/soc-pcm.c b/sound/soc/soc-pcm.c
> index f7b3dca1d152..bc55a249aa61 100644
> --- a/sound/soc/soc-pcm.c
> +++ b/sound/soc/soc-pcm.c
> @@ -1192,7 +1192,6 @@ static int soc_pcm_trigger_start(struct
> snd_pcm_substream *substream, int cmd)
>  {
>  	struct snd_soc_pcm_runtime *rtd = substream->private_data;
>  	struct snd_soc_component *component;
> -	struct snd_soc_dai *dai;
>  	int i, ret;
>  
>  	ret = soc_rtd_trigger(rtd, substream, cmd);
> @@ -1205,11 +1204,9 @@ static int soc_pcm_trigger_start(struct
> snd_pcm_substream *substream, int cmd)
>  			return ret;
>  	}
>  
> -	for_each_rtd_dais(rtd, i, dai) {
> -		ret = snd_soc_dai_trigger(dai, substream, cmd);
> -		if (ret < 0)
> -			return ret;
> -	}
> +	ret = snd_soc_pcm_dai_trigger(substream, cmd);
> +	if (ret < 0)
> +		return ret;
>  
>  	return 0;
Maybe just "return snd_soc_pcm_dai_trigger(substream, cmd);" here?

Thanks,
Ranjani


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

* Re: [PATCH 10/17] ASoC: soc-dai: add snd_soc_dai_compr_shutdown()
  2020-04-22 23:15 ` [PATCH 10/17] ASoC: soc-dai: add snd_soc_dai_compr_shutdown() Kuninori Morimoto
@ 2020-04-23  1:31   ` Ranjani Sridharan
  2020-04-23  1:46     ` Kuninori Morimoto
  0 siblings, 1 reply; 28+ messages in thread
From: Ranjani Sridharan @ 2020-04-23  1:31 UTC (permalink / raw)
  To: Kuninori Morimoto, Mark Brown; +Cc: Linux-ALSA

On Thu, 2020-04-23 at 08:15 +0900, Kuninori Morimoto wrote:
> From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
> 
> dai related function should be implemented at soc-dai.c.
> This patch adds snd_soc_dai_compr_shutdown().
> 
> Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
> ---
>  include/sound/soc-dai.h  |  2 ++
>  sound/soc/soc-compress.c | 12 ++++--------
>  sound/soc/soc-dai.c      |  9 +++++++++
>  3 files changed, 15 insertions(+), 8 deletions(-)
> 
> diff --git a/include/sound/soc-dai.h b/include/sound/soc-dai.h
> index deb99b1469b4..abf4ad25ce68 100644
> --- a/include/sound/soc-dai.h
> +++ b/include/sound/soc-dai.h
> @@ -172,6 +172,8 @@ int snd_soc_pcm_dai_bespoke_trigger(struct
> snd_pcm_substream *substream,
>  
>  int snd_soc_dai_compr_startup(struct snd_soc_dai *dai,
>  			      struct snd_compr_stream *cstream);
> +void snd_soc_dai_compr_shutdown(struct snd_soc_dai *dai,
> +				struct snd_compr_stream *cstream);
>  
>  struct snd_soc_dai_ops {
>  	/*
> diff --git a/sound/soc/soc-compress.c b/sound/soc/soc-compress.c
> index 4065e7b4138d..945d1d15e1d2 100644
> --- a/sound/soc/soc-compress.c
> +++ b/sound/soc/soc-compress.c
> @@ -114,8 +114,7 @@ static int soc_compr_open(struct snd_compr_stream
> *cstream)
>  machine_err:
>  	soc_compr_components_free(cstream, component);
>  
> -	if (cpu_dai->driver->cops && cpu_dai->driver->cops->shutdown)
> -		cpu_dai->driver->cops->shutdown(cstream, cpu_dai);
> +	snd_soc_dai_compr_shutdown(cpu_dai, cstream);
>  out:
>  	mutex_unlock(&rtd->card->pcm_mutex);
>  pm_err:
> @@ -204,8 +203,7 @@ static int soc_compr_open_fe(struct
> snd_compr_stream *cstream)
>  machine_err:
>  	soc_compr_components_free(cstream, component);
>  open_err:
> -	if (cpu_dai->driver->cops && cpu_dai->driver->cops->shutdown)
> -		cpu_dai->driver->cops->shutdown(cstream, cpu_dai);
> +	snd_soc_dai_compr_shutdown(cpu_dai, cstream);
>  out:
>  	dpcm_path_put(&list);
>  be_err:
> @@ -244,8 +242,7 @@ static int soc_compr_free(struct snd_compr_stream
> *cstream)
>  
>  	soc_compr_components_free(cstream, NULL);
>  
> -	if (cpu_dai->driver->cops && cpu_dai->driver->cops->shutdown)
> -		cpu_dai->driver->cops->shutdown(cstream, cpu_dai);
> +	snd_soc_dai_compr_shutdown(cpu_dai, cstream);
>  
>  	snd_soc_dapm_stream_stop(rtd, stream);
>  
> @@ -301,8 +298,7 @@ static int soc_compr_free_fe(struct
> snd_compr_stream *cstream)
>  
>  	soc_compr_components_free(cstream, NULL);
>  
> -	if (cpu_dai->driver->cops && cpu_dai->driver->cops->shutdown)
> -		cpu_dai->driver->cops->shutdown(cstream, cpu_dai);
> +	snd_soc_dai_compr_shutdown(cpu_dai, cstream);
>  
>  	mutex_unlock(&fe->card->mutex);
>  	return 0;
> diff --git a/sound/soc/soc-dai.c b/sound/soc/soc-dai.c
> index 5c88f80b781d..d5cb8b0853a7 100644
> --- a/sound/soc/soc-dai.c
> +++ b/sound/soc/soc-dai.c
> @@ -517,3 +517,12 @@ int snd_soc_dai_compr_startup(struct snd_soc_dai
> *dai,
>  	return soc_dai_ret(dai, ret);
>  }
>  EXPORT_SYMBOL_GPL(snd_soc_dai_compr_startup);
> +
> +void snd_soc_dai_compr_shutdown(struct snd_soc_dai *dai,
> +				struct snd_compr_stream *cstream)
> +{
> +	if (dai->driver->cops &&
> +	    dai->driver->cops->shutdown)
> +		dai->driver->cops->shutdown(cstream, dai);
I see the original code doesnt check the return value. But I think we
should here, no?

Thanks,
Ranjani


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

* Re: [PATCH 05/17] ASoC: soc-dai: add snd_soc_pcm_dai_trigger()
  2020-04-23  1:16   ` Ranjani Sridharan
@ 2020-04-23  1:44     ` Kuninori Morimoto
  0 siblings, 0 replies; 28+ messages in thread
From: Kuninori Morimoto @ 2020-04-23  1:44 UTC (permalink / raw)
  To: Ranjani Sridharan; +Cc: Linux-ALSA, Mark Brown


Hi Ranjani

Thank you for reviewing

> > From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
> > 
> > We have 2 type of component functions
> > snd_soc_dai_xxx()     is focusing to dai itself,
> > snd_soc_pcm_dai_xxx() is focusing to rtd related dai.
> > 
> > Now we can update snd_soc_dai_trigger() to
> > snd_soc_pcm_dai_trigger(). This patch do it.
> > 
> > Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
> > ---
(snip)
> > -	for_each_rtd_dais(rtd, i, dai) {
> > -		ret = snd_soc_dai_trigger(dai, substream, cmd);
> > -		if (ret < 0)
> > -			return ret;
> > -	}
> > +	ret = snd_soc_pcm_dai_trigger(substream, cmd);
> > +	if (ret < 0)
> > +		return ret;
> >  
> >  	return 0;
> Maybe just "return snd_soc_pcm_dai_trigger(substream, cmd);" here?

Ohh, yes indeed.
Thank you. will fix in v2


Thank you for your help !!

Best regards
---
Kuninori Morimoto

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

* Re: [PATCH 10/17] ASoC: soc-dai: add snd_soc_dai_compr_shutdown()
  2020-04-23  1:31   ` Ranjani Sridharan
@ 2020-04-23  1:46     ` Kuninori Morimoto
  2020-04-23  1:50       ` Ranjani Sridharan
  0 siblings, 1 reply; 28+ messages in thread
From: Kuninori Morimoto @ 2020-04-23  1:46 UTC (permalink / raw)
  To: Ranjani Sridharan; +Cc: Linux-ALSA, Mark Brown


Hi Ranjani

Thank you for reviwing

> > From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
> > 
> > dai related function should be implemented at soc-dai.c.
> > This patch adds snd_soc_dai_compr_shutdown().
> > 
> > Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
> > ---
(snip)
> > +void snd_soc_dai_compr_shutdown(struct snd_soc_dai *dai,
> > +				struct snd_compr_stream *cstream)
> > +{
> > +	if (dai->driver->cops &&
> > +	    dai->driver->cops->shutdown)
> > +		dai->driver->cops->shutdown(cstream, dai);
> I see the original code doesnt check the return value. But I think we
> should here, no?

Yes, indeed.
But it is shutdown function.
Just reporting dev_err() is enough I think.
What do you think ?

Thank you for your help !!

Best regards
---
Kuninori Morimoto

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

* Re: [PATCH 10/17] ASoC: soc-dai: add snd_soc_dai_compr_shutdown()
  2020-04-23  1:46     ` Kuninori Morimoto
@ 2020-04-23  1:50       ` Ranjani Sridharan
  0 siblings, 0 replies; 28+ messages in thread
From: Ranjani Sridharan @ 2020-04-23  1:50 UTC (permalink / raw)
  To: Kuninori Morimoto; +Cc: Linux-ALSA, Mark Brown

On Thu, 2020-04-23 at 10:46 +0900, Kuninori Morimoto wrote:
> Hi Ranjani
> 
> Thank you for reviwing
> 
> > > From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
> > > 
> > > dai related function should be implemented at soc-dai.c.
> > > This patch adds snd_soc_dai_compr_shutdown().
> > > 
> > > Signed-off-by: Kuninori Morimoto <
> > > kuninori.morimoto.gx@renesas.com>
> > > ---
> 
> (snip)
> > > +void snd_soc_dai_compr_shutdown(struct snd_soc_dai *dai,
> > > +				struct snd_compr_stream *cstream)
> > > +{
> > > +	if (dai->driver->cops &&
> > > +	    dai->driver->cops->shutdown)
> > > +		dai->driver->cops->shutdown(cstream, dai);
> > 
> > I see the original code doesnt check the return value. But I think
> > we
> > should here, no?
> 
> Yes, indeed.
> But it is shutdown function.
> Just reporting dev_err() is enough I think.
> What do you think ?
Yes, but now that you mention it, maybe we dont even need to report it.
The actual driver shutdown op would probably report it anyway.

Thanks,
Ranjani


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

* Re: [PATCH 02/17] ASoC: soc-dai: don't overwide dai->driver->ops
  2020-04-22 23:14 ` [PATCH 02/17] ASoC: soc-dai: don't overwide dai->driver->ops Kuninori Morimoto
@ 2020-04-23 15:09   ` broonie
  2020-04-23 22:39     ` Kuninori Morimoto
  0 siblings, 1 reply; 28+ messages in thread
From: broonie @ 2020-04-23 15:09 UTC (permalink / raw)
  To: Kuninori Morimoto; +Cc: Linux-ALSA

[-- Attachment #1: Type: text/plain, Size: 664 bytes --]

On Thu, Apr 23, 2020 at 08:14:05AM +0900, Kuninori Morimoto wrote:
> 
> From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
> 
> Current ASoC overwides dai->driver->ops if it was NULL.
> But, it is not good idea, because dai->driver might be reused
> when modprobe/rmmod or bind/unbind, etc.

> This patch checks dai->driver->ops when use DAI callbacks,
> and removes null_dai_ops from ASoC.

This is fine but it's not a correctness issue since we're always filling
the same value in - the big issue with putting stuff in structures is
when you end up using the same struct for two different different things
so you fill different values in.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

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

* Re: [PATCH 01/17] ASoC: soc-dai: add soc_dai_err()
  2020-04-22 23:13 ` [PATCH 01/17] ASoC: soc-dai: add soc_dai_err() Kuninori Morimoto
@ 2020-04-23 18:33   ` Pierre-Louis Bossart
  2020-04-24  4:32     ` Kuninori Morimoto
  0 siblings, 1 reply; 28+ messages in thread
From: Pierre-Louis Bossart @ 2020-04-23 18:33 UTC (permalink / raw)
  To: Kuninori Morimoto, Mark Brown; +Cc: Linux-ALSA



On 4/22/20 6:13 PM, Kuninori Morimoto wrote:
> 
> From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
> 
> At soc-dai.c, it is good idea to indicate error function and
> its component name if there was error.
> This patch adds soc_dai_err() for it.

the code below adds soc_dai_ret(), is this a typo?

> 
> Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
> ---
>   sound/soc/soc-dai.c | 155 +++++++++++++++++++++++++++-----------------
>   1 file changed, 96 insertions(+), 59 deletions(-)
> 
> diff --git a/sound/soc/soc-dai.c b/sound/soc/soc-dai.c
> index 31c41559034b..d591b3bd8b99 100644
> --- a/sound/soc/soc-dai.c
> +++ b/sound/soc/soc-dai.c
> @@ -9,6 +9,24 @@
>   #include <sound/soc.h>
>   #include <sound/soc-dai.h>
>   
> +#define soc_dai_ret(dai, ret) _soc_dai_ret(dai, __func__, ret)
> +static inline int _soc_dai_ret(struct snd_soc_dai *dai,
> +			       const char *func, int ret)
> +{
> +	switch (ret) {
> +	case -EPROBE_DEFER:
> +	case -ENOTSUPP:
> +	case 0:
> +		break;
> +	default:
> +		dev_err(dai->dev,
> +			"ASoC: error at %s on %s: %d\n",
> +			func, dai->name, ret);
> +	}
> +
> +	return ret;
> +}
> +


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

* Re: [PATCH 02/17] ASoC: soc-dai: don't overwide dai->driver->ops
  2020-04-23 15:09   ` broonie
@ 2020-04-23 22:39     ` Kuninori Morimoto
  2020-04-24  9:30       ` Mark Brown
  0 siblings, 1 reply; 28+ messages in thread
From: Kuninori Morimoto @ 2020-04-23 22:39 UTC (permalink / raw)
  To: broonie; +Cc: Linux-ALSA


Hi Mark

> > From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
> > 
> > Current ASoC overwides dai->driver->ops if it was NULL.
> > But, it is not good idea, because dai->driver might be reused
> > when modprobe/rmmod or bind/unbind, etc.
> 
> > This patch checks dai->driver->ops when use DAI callbacks,
> > and removes null_dai_ops from ASoC.
> 
> This is fine but it's not a correctness issue since we're always filling
> the same value in - the big issue with putting stuff in structures is
> when you end up using the same struct for two different different things
> so you fill different values in.

I see.
But all my remaining patches are based on this patch,
and rebase without it seems very difficult.

So, I want to keep it.
v2 patchset still has it, but adds different git-log.

Thank you for your help !!

Best regards
---
Kuninori Morimoto

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

* Re: [PATCH 01/17] ASoC: soc-dai: add soc_dai_err()
  2020-04-23 18:33   ` Pierre-Louis Bossart
@ 2020-04-24  4:32     ` Kuninori Morimoto
  0 siblings, 0 replies; 28+ messages in thread
From: Kuninori Morimoto @ 2020-04-24  4:32 UTC (permalink / raw)
  To: Pierre-Louis Bossart; +Cc: Linux-ALSA, Mark Brown


Hi Pierre-Louis

> > From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
> > 
> > At soc-dai.c, it is good idea to indicate error function and
> > its component name if there was error.
> > This patch adds soc_dai_err() for it.
> 
> the code below adds soc_dai_ret(), is this a typo?

Oops, It is typo.
The original code was _err, and I updated it to _ret

Mark
Do I need to post v3 patch ?

Thank you for your help !!

Best regards
---
Kuninori Morimoto

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

* Re: [PATCH 02/17] ASoC: soc-dai: don't overwide dai->driver->ops
  2020-04-23 22:39     ` Kuninori Morimoto
@ 2020-04-24  9:30       ` Mark Brown
  0 siblings, 0 replies; 28+ messages in thread
From: Mark Brown @ 2020-04-24  9:30 UTC (permalink / raw)
  To: Kuninori Morimoto; +Cc: Linux-ALSA

[-- Attachment #1: Type: text/plain, Size: 850 bytes --]

On Fri, Apr 24, 2020 at 07:39:58AM +0900, Kuninori Morimoto wrote:
> > > From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

> > > Current ASoC overwides dai->driver->ops if it was NULL.
> > > But, it is not good idea, because dai->driver might be reused
> > > when modprobe/rmmod or bind/unbind, etc.

> > This is fine but it's not a correctness issue since we're always filling
> > the same value in - the big issue with putting stuff in structures is
> > when you end up using the same struct for two different different things
> > so you fill different values in.

> I see.
> But all my remaining patches are based on this patch,
> and rebase without it seems very difficult.

> So, I want to keep it.
> v2 patchset still has it, but adds different git-log.

Right, like I say the change is fine - it was just a note about the
changelog.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

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

end of thread, other threads:[~2020-04-24  9:32 UTC | newest]

Thread overview: 28+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-22 23:13 [PATCH 00/17] ASoC: soc-dai: add snd_soc_dai_xxx() Kuninori Morimoto
2020-04-22 23:13 ` [PATCH 01/17] ASoC: soc-dai: add soc_dai_err() Kuninori Morimoto
2020-04-23 18:33   ` Pierre-Louis Bossart
2020-04-24  4:32     ` Kuninori Morimoto
2020-04-22 23:14 ` [PATCH 02/17] ASoC: soc-dai: don't overwide dai->driver->ops Kuninori Morimoto
2020-04-23 15:09   ` broonie
2020-04-23 22:39     ` Kuninori Morimoto
2020-04-24  9:30       ` Mark Brown
2020-04-22 23:14 ` [PATCH 03/17] ASoC: soc-dai: add snd_soc_pcm_dai_new() Kuninori Morimoto
2020-04-22 23:14 ` [PATCH 04/17] ASoC: soc-dai: add snd_soc_pcm_dai_prepare() Kuninori Morimoto
2020-04-22 23:14 ` [PATCH 05/17] ASoC: soc-dai: add snd_soc_pcm_dai_trigger() Kuninori Morimoto
2020-04-23  1:16   ` Ranjani Sridharan
2020-04-23  1:44     ` Kuninori Morimoto
2020-04-22 23:14 ` [PATCH 06/17] ASoC: soc-dai: add snd_soc_pcm_dai_bespoke_trigger() Kuninori Morimoto
2020-04-22 23:15 ` [PATCH 07/17] ASoC: soc-dai: add snd_soc_pcm_dai_probe() Kuninori Morimoto
2020-04-22 23:15 ` [PATCH 08/17] ASoC: soc-dai: add snd_soc_pcm_dai_remove() Kuninori Morimoto
2020-04-22 23:15 ` [PATCH 09/17] ASoC: soc-dai: add snd_soc_dai_compr_start() Kuninori Morimoto
2020-04-22 23:15 ` [PATCH 10/17] ASoC: soc-dai: add snd_soc_dai_compr_shutdown() Kuninori Morimoto
2020-04-23  1:31   ` Ranjani Sridharan
2020-04-23  1:46     ` Kuninori Morimoto
2020-04-23  1:50       ` Ranjani Sridharan
2020-04-22 23:15 ` [PATCH 11/17] ASoC: soc-dai: add snd_soc_dai_compr_trigger() Kuninori Morimoto
2020-04-22 23:15 ` [PATCH 12/17] ASoC: soc-dai: add snd_soc_dai_compr_set_params() Kuninori Morimoto
2020-04-22 23:15 ` [PATCH 13/17] ASoC: soc-dai: add snd_soc_dai_compr_get_params() Kuninori Morimoto
2020-04-22 23:15 ` [PATCH 14/17] ASoC: soc-dai: add snd_soc_dai_compr_ack() Kuninori Morimoto
2020-04-22 23:15 ` [PATCH 15/17] ASoC: soc-dai: add snd_soc_dai_compr_pointer() Kuninori Morimoto
2020-04-22 23:16 ` [PATCH 16/17] ASoC: soc-dai: add snd_soc_dai_compr_set_metadata() Kuninori Morimoto
2020-04-22 23:16 ` [PATCH 17/17] ASoC: soc-dai: add snd_soc_dai_compr_get_metadata() Kuninori Morimoto

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.