All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 00/24] ASoC: soc-component: collect component functions
@ 2020-06-01  1:35 Kuninori Morimoto
  2020-06-01  1:35 ` [PATCH 01/24] ASoC: soc-component: add soc_component_pin() and share code Kuninori Morimoto
                   ` (23 more replies)
  0 siblings, 24 replies; 37+ messages in thread
From: Kuninori Morimoto @ 2020-06-01  1:35 UTC (permalink / raw)
  To: Mark Brown; +Cc: Linux-ALSA


Hi Mark

We have soc-component.c now, but still many component related
functions are implemented many place.
This patch-set collect these into soc-component.c.

Kuninori Morimoto (24):
  ASoC: soc-component: add soc_component_pin() and share code
  ASoC: soc-component: move snd_soc_component_xxx_regmap() to soc-component
  ASoC: soc-component: move snd_soc_component_initialize() to soc-component.c
  ASoC: soc-component: add soc_component_err()
  ASoC: soc-component: add snd_soc_pcm_component_prepare()
  ASoC: soc-component: add snd_soc_pcm_component_hw_params()
  ASoC: soc-component: add snd_soc_pcm_component_hw_free()
  ASoC: soc-component: add snd_soc_pcm_component_trigger()
  ASoC: soc-component: add snd_soc_component_compr_open()
  ASoC: soc-component: add snd_soc_component_compr_free()
  ASoC: soc-component: add snd_soc_component_compr_trigger()
  ASoC: soc-component: add snd_soc_component_compr_set_params()
  ASoC: soc-component: add snd_soc_component_compr_get_params()
  ASoC: soc-component: add snd_soc_component_compr_get_caps()
  ASoC: soc-component: add snd_soc_component_compr_get_codec_caps()
  ASoC: soc-component: add snd_soc_component_compr_ack()
  ASoC: soc-component: add snd_soc_component_compr_pointer()
  ASoC: soc-component: add snd_soc_component_compr_copy()
  ASoC: soc-component: add snd_soc_component_compr_set_metadata()
  ASoC: soc-component: add snd_soc_component_compr_get_metadata()
  ASoC: soc-component: add snd_soc_component_init()
  ASoC: soc-component: merge soc-io.c into soc-component.c
  ASoC: soc-component: merge soc_pcm_trigger_start/stop()
  ASoC: soc-component: tidyup Copyright

 include/sound/soc-component.h |  51 +-
 sound/soc/Makefile            |   2 +-
 sound/soc/soc-component.c     | 912 ++++++++++++++++++++++++++--------
 sound/soc/soc-compress.c      | 223 ++-------
 sound/soc/soc-core.c          | 102 +---
 sound/soc/soc-io.c            | 202 --------
 sound/soc/soc-pcm.c           | 115 ++---
 7 files changed, 830 insertions(+), 777 deletions(-)
 delete mode 100644 sound/soc/soc-io.c

-- 
2.17.1


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

* [PATCH 01/24] ASoC: soc-component: add soc_component_pin() and share code
  2020-06-01  1:35 [PATCH 00/24] ASoC: soc-component: collect component functions Kuninori Morimoto
@ 2020-06-01  1:35 ` Kuninori Morimoto
  2020-06-01  1:36 ` [PATCH 02/24] ASoC: soc-component: move snd_soc_component_xxx_regmap() to soc-component Kuninori Morimoto
                   ` (22 subsequent siblings)
  23 siblings, 0 replies; 37+ messages in thread
From: Kuninori Morimoto @ 2020-06-01  1:35 UTC (permalink / raw)
  To: Mark Brown; +Cc: Linux-ALSA

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

soc-component has too many snd_soc_component_xxx_pin_xxx() functions.
The difference between these functions are used function name and
enable/disable.
This patch adds common soc_component_pin() and share code.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
 sound/soc/soc-component.c | 152 +++++---------------------------------
 1 file changed, 20 insertions(+), 132 deletions(-)

diff --git a/sound/soc/soc-component.c b/sound/soc/soc-component.c
index 785a0385cc7f..76f4b953563c 100644
--- a/sound/soc/soc-component.c
+++ b/sound/soc/soc-component.c
@@ -77,8 +77,10 @@ int snd_soc_component_set_bias_level(struct snd_soc_component *component,
 	return 0;
 }
 
-int snd_soc_component_enable_pin(struct snd_soc_component *component,
-				 const char *pin)
+static int soc_component_pin(struct snd_soc_component *component,
+			     const char *pin,
+			     int (*pin_func)(struct snd_soc_dapm_context *dapm,
+					     const char *pin))
 {
 	struct snd_soc_dapm_context *dapm =
 		snd_soc_component_get_dapm(component);
@@ -86,170 +88,71 @@ int snd_soc_component_enable_pin(struct snd_soc_component *component,
 	int ret;
 
 	if (!component->name_prefix)
-		return snd_soc_dapm_enable_pin(dapm, pin);
+		return pin_func(dapm, pin);
 
 	full_name = kasprintf(GFP_KERNEL, "%s %s", component->name_prefix, pin);
 	if (!full_name)
 		return -ENOMEM;
 
-	ret = snd_soc_dapm_enable_pin(dapm, full_name);
+	ret = pin_func(dapm, full_name);
 	kfree(full_name);
 
 	return ret;
 }
+
+int snd_soc_component_enable_pin(struct snd_soc_component *component,
+				 const char *pin)
+{
+	return soc_component_pin(component, pin, snd_soc_dapm_enable_pin);
+}
 EXPORT_SYMBOL_GPL(snd_soc_component_enable_pin);
 
 int snd_soc_component_enable_pin_unlocked(struct snd_soc_component *component,
 					  const char *pin)
 {
-	struct snd_soc_dapm_context *dapm =
-		snd_soc_component_get_dapm(component);
-	char *full_name;
-	int ret;
-
-	if (!component->name_prefix)
-		return snd_soc_dapm_enable_pin_unlocked(dapm, pin);
-
-	full_name = kasprintf(GFP_KERNEL, "%s %s", component->name_prefix, pin);
-	if (!full_name)
-		return -ENOMEM;
-
-	ret = snd_soc_dapm_enable_pin_unlocked(dapm, full_name);
-	kfree(full_name);
-
-	return ret;
+	return soc_component_pin(component, pin, snd_soc_dapm_enable_pin_unlocked);
 }
 EXPORT_SYMBOL_GPL(snd_soc_component_enable_pin_unlocked);
 
 int snd_soc_component_disable_pin(struct snd_soc_component *component,
 				  const char *pin)
 {
-	struct snd_soc_dapm_context *dapm =
-		snd_soc_component_get_dapm(component);
-	char *full_name;
-	int ret;
-
-	if (!component->name_prefix)
-		return snd_soc_dapm_disable_pin(dapm, pin);
-
-	full_name = kasprintf(GFP_KERNEL, "%s %s", component->name_prefix, pin);
-	if (!full_name)
-		return -ENOMEM;
-
-	ret = snd_soc_dapm_disable_pin(dapm, full_name);
-	kfree(full_name);
-
-	return ret;
+	return soc_component_pin(component, pin, snd_soc_dapm_disable_pin);
 }
 EXPORT_SYMBOL_GPL(snd_soc_component_disable_pin);
 
 int snd_soc_component_disable_pin_unlocked(struct snd_soc_component *component,
 					   const char *pin)
 {
-	struct snd_soc_dapm_context *dapm =
-		snd_soc_component_get_dapm(component);
-	char *full_name;
-	int ret;
-
-	if (!component->name_prefix)
-		return snd_soc_dapm_disable_pin_unlocked(dapm, pin);
-
-	full_name = kasprintf(GFP_KERNEL, "%s %s", component->name_prefix, pin);
-	if (!full_name)
-		return -ENOMEM;
-
-	ret = snd_soc_dapm_disable_pin_unlocked(dapm, full_name);
-	kfree(full_name);
-
-	return ret;
+	return soc_component_pin(component, pin, snd_soc_dapm_disable_pin_unlocked);
 }
 EXPORT_SYMBOL_GPL(snd_soc_component_disable_pin_unlocked);
 
 int snd_soc_component_nc_pin(struct snd_soc_component *component,
 			     const char *pin)
 {
-	struct snd_soc_dapm_context *dapm =
-		snd_soc_component_get_dapm(component);
-	char *full_name;
-	int ret;
-
-	if (!component->name_prefix)
-		return snd_soc_dapm_nc_pin(dapm, pin);
-
-	full_name = kasprintf(GFP_KERNEL, "%s %s", component->name_prefix, pin);
-	if (!full_name)
-		return -ENOMEM;
-
-	ret = snd_soc_dapm_nc_pin(dapm, full_name);
-	kfree(full_name);
-
-	return ret;
+	return soc_component_pin(component, pin, snd_soc_dapm_nc_pin);
 }
 EXPORT_SYMBOL_GPL(snd_soc_component_nc_pin);
 
 int snd_soc_component_nc_pin_unlocked(struct snd_soc_component *component,
 				      const char *pin)
 {
-	struct snd_soc_dapm_context *dapm =
-		snd_soc_component_get_dapm(component);
-	char *full_name;
-	int ret;
-
-	if (!component->name_prefix)
-		return snd_soc_dapm_nc_pin_unlocked(dapm, pin);
-
-	full_name = kasprintf(GFP_KERNEL, "%s %s", component->name_prefix, pin);
-	if (!full_name)
-		return -ENOMEM;
-
-	ret = snd_soc_dapm_nc_pin_unlocked(dapm, full_name);
-	kfree(full_name);
-
-	return ret;
+	return soc_component_pin(component, pin, snd_soc_dapm_nc_pin_unlocked);
 }
 EXPORT_SYMBOL_GPL(snd_soc_component_nc_pin_unlocked);
 
 int snd_soc_component_get_pin_status(struct snd_soc_component *component,
 				     const char *pin)
 {
-	struct snd_soc_dapm_context *dapm =
-		snd_soc_component_get_dapm(component);
-	char *full_name;
-	int ret;
-
-	if (!component->name_prefix)
-		return snd_soc_dapm_get_pin_status(dapm, pin);
-
-	full_name = kasprintf(GFP_KERNEL, "%s %s", component->name_prefix, pin);
-	if (!full_name)
-		return -ENOMEM;
-
-	ret = snd_soc_dapm_get_pin_status(dapm, full_name);
-	kfree(full_name);
-
-	return ret;
+	return soc_component_pin(component, pin, snd_soc_dapm_get_pin_status);
 }
 EXPORT_SYMBOL_GPL(snd_soc_component_get_pin_status);
 
 int snd_soc_component_force_enable_pin(struct snd_soc_component *component,
 				       const char *pin)
 {
-	struct snd_soc_dapm_context *dapm =
-		snd_soc_component_get_dapm(component);
-	char *full_name;
-	int ret;
-
-	if (!component->name_prefix)
-		return snd_soc_dapm_force_enable_pin(dapm, pin);
-
-	full_name = kasprintf(GFP_KERNEL, "%s %s", component->name_prefix, pin);
-	if (!full_name)
-		return -ENOMEM;
-
-	ret = snd_soc_dapm_force_enable_pin(dapm, full_name);
-	kfree(full_name);
-
-	return ret;
+	return soc_component_pin(component, pin, snd_soc_dapm_force_enable_pin);
 }
 EXPORT_SYMBOL_GPL(snd_soc_component_force_enable_pin);
 
@@ -257,22 +160,7 @@ int snd_soc_component_force_enable_pin_unlocked(
 	struct snd_soc_component *component,
 	const char *pin)
 {
-	struct snd_soc_dapm_context *dapm =
-		snd_soc_component_get_dapm(component);
-	char *full_name;
-	int ret;
-
-	if (!component->name_prefix)
-		return snd_soc_dapm_force_enable_pin_unlocked(dapm, pin);
-
-	full_name = kasprintf(GFP_KERNEL, "%s %s", component->name_prefix, pin);
-	if (!full_name)
-		return -ENOMEM;
-
-	ret = snd_soc_dapm_force_enable_pin_unlocked(dapm, full_name);
-	kfree(full_name);
-
-	return ret;
+	return soc_component_pin(component, pin, snd_soc_dapm_force_enable_pin_unlocked);
 }
 EXPORT_SYMBOL_GPL(snd_soc_component_force_enable_pin_unlocked);
 
-- 
2.17.1


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

* [PATCH 02/24] ASoC: soc-component: move snd_soc_component_xxx_regmap() to soc-component
  2020-06-01  1:35 [PATCH 00/24] ASoC: soc-component: collect component functions Kuninori Morimoto
  2020-06-01  1:35 ` [PATCH 01/24] ASoC: soc-component: add soc_component_pin() and share code Kuninori Morimoto
@ 2020-06-01  1:36 ` Kuninori Morimoto
  2020-06-01  1:36 ` [PATCH 03/24] ASoC: soc-component: move snd_soc_component_initialize() to soc-component.c Kuninori Morimoto
                   ` (21 subsequent siblings)
  23 siblings, 0 replies; 37+ messages in thread
From: Kuninori Morimoto @ 2020-06-01  1:36 UTC (permalink / raw)
  To: Mark Brown; +Cc: Linux-ALSA

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

soc-component is handling snd_soc_component_xxx().
Move snd_soc_component_xxx_regmap() to it.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
 include/sound/soc-component.h |  1 +
 sound/soc/soc-component.c     | 50 +++++++++++++++++++++++++++++++++++
 sound/soc/soc-core.c          | 50 -----------------------------------
 3 files changed, 51 insertions(+), 50 deletions(-)

diff --git a/include/sound/soc-component.h b/include/sound/soc-component.h
index 5663891148e3..481132141dc2 100644
--- a/include/sound/soc-component.h
+++ b/include/sound/soc-component.h
@@ -359,6 +359,7 @@ int snd_soc_component_stream_event(struct snd_soc_component *component,
 int snd_soc_component_set_bias_level(struct snd_soc_component *component,
 				     enum snd_soc_bias_level level);
 
+void snd_soc_component_setup_regmap(struct snd_soc_component *component);
 #ifdef CONFIG_REGMAP
 void snd_soc_component_init_regmap(struct snd_soc_component *component,
 				   struct regmap *regmap);
diff --git a/sound/soc/soc-component.c b/sound/soc/soc-component.c
index 76f4b953563c..3c96a1adaa8b 100644
--- a/sound/soc/soc-component.c
+++ b/sound/soc/soc-component.c
@@ -302,6 +302,56 @@ int snd_soc_component_of_xlate_dai_name(struct snd_soc_component *component,
 	return -ENOTSUPP;
 }
 
+void snd_soc_component_setup_regmap(struct snd_soc_component *component)
+{
+	int val_bytes = regmap_get_val_bytes(component->regmap);
+
+	/* Errors are legitimate for non-integer byte multiples */
+	if (val_bytes > 0)
+		component->val_bytes = val_bytes;
+}
+
+#ifdef CONFIG_REGMAP
+
+/**
+ * snd_soc_component_init_regmap() - Initialize regmap instance for the
+ *                                   component
+ * @component: The component for which to initialize the regmap instance
+ * @regmap: The regmap instance that should be used by the component
+ *
+ * This function allows deferred assignment of the regmap instance that is
+ * associated with the component. Only use this if the regmap instance is not
+ * yet ready when the component is registered. The function must also be called
+ * before the first IO attempt of the component.
+ */
+void snd_soc_component_init_regmap(struct snd_soc_component *component,
+				   struct regmap *regmap)
+{
+	component->regmap = regmap;
+	snd_soc_component_setup_regmap(component);
+}
+EXPORT_SYMBOL_GPL(snd_soc_component_init_regmap);
+
+/**
+ * snd_soc_component_exit_regmap() - De-initialize regmap instance for the
+ *                                   component
+ * @component: The component for which to de-initialize the regmap instance
+ *
+ * Calls regmap_exit() on the regmap instance associated to the component and
+ * removes the regmap instance from the component.
+ *
+ * This function should only be used if snd_soc_component_init_regmap() was used
+ * to initialize the regmap instance.
+ */
+void snd_soc_component_exit_regmap(struct snd_soc_component *component)
+{
+	regmap_exit(component->regmap);
+	component->regmap = NULL;
+}
+EXPORT_SYMBOL_GPL(snd_soc_component_exit_regmap);
+
+#endif
+
 int snd_soc_pcm_component_pointer(struct snd_pcm_substream *substream)
 {
 	struct snd_soc_pcm_runtime *rtd = substream->private_data;
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index b07eca2c6ccc..8e90426d2770 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -2381,56 +2381,6 @@ static int snd_soc_component_initialize(struct snd_soc_component *component,
 	return 0;
 }
 
-static void snd_soc_component_setup_regmap(struct snd_soc_component *component)
-{
-	int val_bytes = regmap_get_val_bytes(component->regmap);
-
-	/* Errors are legitimate for non-integer byte multiples */
-	if (val_bytes > 0)
-		component->val_bytes = val_bytes;
-}
-
-#ifdef CONFIG_REGMAP
-
-/**
- * snd_soc_component_init_regmap() - Initialize regmap instance for the
- *                                   component
- * @component: The component for which to initialize the regmap instance
- * @regmap: The regmap instance that should be used by the component
- *
- * This function allows deferred assignment of the regmap instance that is
- * associated with the component. Only use this if the regmap instance is not
- * yet ready when the component is registered. The function must also be called
- * before the first IO attempt of the component.
- */
-void snd_soc_component_init_regmap(struct snd_soc_component *component,
-	struct regmap *regmap)
-{
-	component->regmap = regmap;
-	snd_soc_component_setup_regmap(component);
-}
-EXPORT_SYMBOL_GPL(snd_soc_component_init_regmap);
-
-/**
- * snd_soc_component_exit_regmap() - De-initialize regmap instance for the
- *                                   component
- * @component: The component for which to de-initialize the regmap instance
- *
- * Calls regmap_exit() on the regmap instance associated to the component and
- * removes the regmap instance from the component.
- *
- * This function should only be used if snd_soc_component_init_regmap() was used
- * to initialize the regmap instance.
- */
-void snd_soc_component_exit_regmap(struct snd_soc_component *component)
-{
-	regmap_exit(component->regmap);
-	component->regmap = NULL;
-}
-EXPORT_SYMBOL_GPL(snd_soc_component_exit_regmap);
-
-#endif
-
 #define ENDIANNESS_MAP(name) \
 	(SNDRV_PCM_FMTBIT_##name##LE | SNDRV_PCM_FMTBIT_##name##BE)
 static u64 endianness_format_map[] = {
-- 
2.17.1


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

* [PATCH 03/24] ASoC: soc-component: move snd_soc_component_initialize() to soc-component.c
  2020-06-01  1:35 [PATCH 00/24] ASoC: soc-component: collect component functions Kuninori Morimoto
  2020-06-01  1:35 ` [PATCH 01/24] ASoC: soc-component: add soc_component_pin() and share code Kuninori Morimoto
  2020-06-01  1:36 ` [PATCH 02/24] ASoC: soc-component: move snd_soc_component_xxx_regmap() to soc-component Kuninori Morimoto
@ 2020-06-01  1:36 ` Kuninori Morimoto
  2020-06-01  1:36 ` [PATCH 04/24] ASoC: soc-component: add soc_component_err() Kuninori Morimoto
                   ` (20 subsequent siblings)
  23 siblings, 0 replies; 37+ messages in thread
From: Kuninori Morimoto @ 2020-06-01  1:36 UTC (permalink / raw)
  To: Mark Brown; +Cc: Linux-ALSA

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

snd_soc_component_xxx() should be implemented at soc-component.c

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
 include/sound/soc-component.h |  4 ++++
 sound/soc/soc-component.c     | 16 ++++++++++++++++
 sound/soc/soc-core.c          | 29 ++++++++---------------------
 3 files changed, 28 insertions(+), 21 deletions(-)

diff --git a/include/sound/soc-component.h b/include/sound/soc-component.h
index 481132141dc2..cb0d34fa77c6 100644
--- a/include/sound/soc-component.h
+++ b/include/sound/soc-component.h
@@ -324,6 +324,10 @@ static inline int snd_soc_component_cache_sync(
 	return regcache_sync(component->regmap);
 }
 
+int snd_soc_component_initialize(struct snd_soc_component *component,
+				 const struct snd_soc_component_driver *driver,
+				 struct device *dev, const char *name);
+
 /* component IO */
 int snd_soc_component_read(struct snd_soc_component *component,
 			   unsigned int reg, unsigned int *val);
diff --git a/sound/soc/soc-component.c b/sound/soc/soc-component.c
index 3c96a1adaa8b..5bf2e71d3d83 100644
--- a/sound/soc/soc-component.c
+++ b/sound/soc/soc-component.c
@@ -8,6 +8,22 @@
 #include <linux/module.h>
 #include <sound/soc.h>
 
+int snd_soc_component_initialize(struct snd_soc_component *component,
+				 const struct snd_soc_component_driver *driver,
+				 struct device *dev, const char *name)
+{
+	INIT_LIST_HEAD(&component->dai_list);
+	INIT_LIST_HEAD(&component->dobj_list);
+	INIT_LIST_HEAD(&component->card_list);
+	mutex_init(&component->io_mutex);
+
+	component->name		= name;
+	component->dev		= dev;
+	component->driver	= driver;
+
+	return 0;
+}
+
 /**
  * snd_soc_component_set_sysclk - configure COMPONENT system or master clock.
  * @component: COMPONENT
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index 8e90426d2770..7e22facf14ea 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -2361,26 +2361,6 @@ static int snd_soc_register_dais(struct snd_soc_component *component,
 	return ret;
 }
 
-static int snd_soc_component_initialize(struct snd_soc_component *component,
-	const struct snd_soc_component_driver *driver, struct device *dev)
-{
-	INIT_LIST_HEAD(&component->dai_list);
-	INIT_LIST_HEAD(&component->dobj_list);
-	INIT_LIST_HEAD(&component->card_list);
-	mutex_init(&component->io_mutex);
-
-	component->name = fmt_single_name(dev, &component->id);
-	if (!component->name) {
-		dev_err(dev, "ASoC: Failed to allocate name\n");
-		return -ENOMEM;
-	}
-
-	component->dev = dev;
-	component->driver = driver;
-
-	return 0;
-}
-
 #define ENDIANNESS_MAP(name) \
 	(SNDRV_PCM_FMTBIT_##name##LE | SNDRV_PCM_FMTBIT_##name##BE)
 static u64 endianness_format_map[] = {
@@ -2443,12 +2423,19 @@ int snd_soc_add_component(struct device *dev,
 			struct snd_soc_dai_driver *dai_drv,
 			int num_dai)
 {
+	const char *name = fmt_single_name(dev, &component->id);
 	int ret;
 	int i;
 
+	if (!name) {
+		dev_err(dev, "ASoC: Failed to allocate name\n");
+		return -ENOMEM;
+	}
+
 	mutex_lock(&client_mutex);
 
-	ret = snd_soc_component_initialize(component, component_driver, dev);
+	ret = snd_soc_component_initialize(component, component_driver,
+					   dev, name);
 	if (ret)
 		goto err_free;
 
-- 
2.17.1


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

* [PATCH 04/24] ASoC: soc-component: add soc_component_err()
  2020-06-01  1:35 [PATCH 00/24] ASoC: soc-component: collect component functions Kuninori Morimoto
                   ` (2 preceding siblings ...)
  2020-06-01  1:36 ` [PATCH 03/24] ASoC: soc-component: move snd_soc_component_initialize() to soc-component.c Kuninori Morimoto
@ 2020-06-01  1:36 ` Kuninori Morimoto
  2020-06-01  1:36 ` [PATCH 05/24] ASoC: soc-component: add snd_soc_pcm_component_prepare() Kuninori Morimoto
                   ` (19 subsequent siblings)
  23 siblings, 0 replies; 37+ messages in thread
From: Kuninori Morimoto @ 2020-06-01  1:36 UTC (permalink / raw)
  To: Mark Brown; +Cc: Linux-ALSA


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

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

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

diff --git a/sound/soc/soc-component.c b/sound/soc/soc-component.c
index 5bf2e71d3d83..6d29c2de3b24 100644
--- a/sound/soc/soc-component.c
+++ b/sound/soc/soc-component.c
@@ -8,6 +8,28 @@
 #include <linux/module.h>
 #include <sound/soc.h>
 
+#define soc_component_ret(dai, ret) _soc_component_ret(dai, __func__, ret)
+static inline int _soc_component_ret(struct snd_soc_component *component,
+				     const char *func, int ret)
+{
+	/* Positive/Zero values are not errors */
+	if (ret >= 0)
+		return ret;
+
+	/* Negative values might be errors */
+	switch (ret) {
+	case -EPROBE_DEFER:
+	case -ENOTSUPP:
+		break;
+	default:
+		dev_err(component->dev,
+			"ASoC: error at %s on %s: %d\n",
+			func, component->name, ret);
+	}
+
+	return ret;
+}
+
 int snd_soc_component_initialize(struct snd_soc_component *component,
 				 const struct snd_soc_component_driver *driver,
 				 struct device *dev, const char *name)
@@ -38,11 +60,13 @@ int snd_soc_component_set_sysclk(struct snd_soc_component *component,
 				 int clk_id, int source, unsigned int freq,
 				 int dir)
 {
+	int ret = -ENOTSUPP;
+
 	if (component->driver->set_sysclk)
-		return component->driver->set_sysclk(component, clk_id, source,
+		ret = component->driver->set_sysclk(component, clk_id, source,
 						     freq, dir);
 
-	return -ENOTSUPP;
+	return soc_component_ret(component, ret);
 }
 EXPORT_SYMBOL_GPL(snd_soc_component_set_sysclk);
 
@@ -60,11 +84,13 @@ int snd_soc_component_set_pll(struct snd_soc_component *component, int pll_id,
 			      int source, unsigned int freq_in,
 			      unsigned int freq_out)
 {
+	int ret = -EINVAL;
+
 	if (component->driver->set_pll)
-		return component->driver->set_pll(component, pll_id, source,
+		ret = component->driver->set_pll(component, pll_id, source,
 						  freq_in, freq_out);
 
-	return -EINVAL;
+	return soc_component_ret(component, ret);
 }
 EXPORT_SYMBOL_GPL(snd_soc_component_set_pll);
 
@@ -78,19 +104,23 @@ void snd_soc_component_seq_notifier(struct snd_soc_component *component,
 int snd_soc_component_stream_event(struct snd_soc_component *component,
 				   int event)
 {
+	int ret = 0;
+
 	if (component->driver->stream_event)
-		return component->driver->stream_event(component, event);
+		ret = component->driver->stream_event(component, event);
 
-	return 0;
+	return soc_component_ret(component, ret);
 }
 
 int snd_soc_component_set_bias_level(struct snd_soc_component *component,
 				     enum snd_soc_bias_level level)
 {
+	int ret = 0;
+
 	if (component->driver->set_bias_level)
-		return component->driver->set_bias_level(component, level);
+		ret = component->driver->set_bias_level(component, level);
 
-	return 0;
+	return soc_component_ret(component, ret);
 }
 
 static int soc_component_pin(struct snd_soc_component *component,
@@ -103,17 +133,21 @@ static int soc_component_pin(struct snd_soc_component *component,
 	char *full_name;
 	int ret;
 
-	if (!component->name_prefix)
-		return pin_func(dapm, pin);
+	if (!component->name_prefix) {
+		ret = pin_func(dapm, pin);
+		goto end;
+	}
 
 	full_name = kasprintf(GFP_KERNEL, "%s %s", component->name_prefix, pin);
-	if (!full_name)
-		return -ENOMEM;
+	if (!full_name) {
+		ret = -ENOMEM;
+		goto end;
+	}
 
 	ret = pin_func(dapm, full_name);
 	kfree(full_name);
-
-	return ret;
+end:
+	return soc_component_ret(component, ret);
 }
 
 int snd_soc_component_enable_pin(struct snd_soc_component *component,
@@ -191,21 +225,25 @@ EXPORT_SYMBOL_GPL(snd_soc_component_force_enable_pin_unlocked);
 int snd_soc_component_set_jack(struct snd_soc_component *component,
 			       struct snd_soc_jack *jack, void *data)
 {
+	int ret = -ENOTSUPP;
+
 	if (component->driver->set_jack)
-		return component->driver->set_jack(component, jack, data);
+		ret = component->driver->set_jack(component, jack, data);
 
-	return -ENOTSUPP;
+	return soc_component_ret(component, ret);
 }
 EXPORT_SYMBOL_GPL(snd_soc_component_set_jack);
 
 int snd_soc_component_module_get(struct snd_soc_component *component,
 				 int upon_open)
 {
+	int ret = 0;
+
 	if (component->driver->module_get_upon_open == !!upon_open &&
 	    !try_module_get(component->dev->driver->owner))
-		return -ENODEV;
+		ret = -ENODEV;
 
-	return 0;
+	return soc_component_ret(component, ret);
 }
 
 void snd_soc_component_module_put(struct snd_soc_component *component,
@@ -218,52 +256,70 @@ void snd_soc_component_module_put(struct snd_soc_component *component,
 int snd_soc_component_open(struct snd_soc_component *component,
 			   struct snd_pcm_substream *substream)
 {
+	int ret = 0;
+
 	if (component->driver->open)
-		return component->driver->open(component, substream);
-	return 0;
+		ret = component->driver->open(component, substream);
+
+	return soc_component_ret(component, ret);
 }
 
 int snd_soc_component_close(struct snd_soc_component *component,
 			    struct snd_pcm_substream *substream)
 {
+	int ret = 0;
+
 	if (component->driver->close)
-		return component->driver->close(component, substream);
-	return 0;
+		ret = component->driver->close(component, substream);
+
+	return soc_component_ret(component, ret);
 }
 
 int snd_soc_component_prepare(struct snd_soc_component *component,
 			      struct snd_pcm_substream *substream)
 {
+	int ret = 0;
+
 	if (component->driver->prepare)
-		return component->driver->prepare(component, substream);
-	return 0;
+		ret = component->driver->prepare(component, substream);
+
+	return soc_component_ret(component, ret);
 }
 
 int snd_soc_component_hw_params(struct snd_soc_component *component,
 				struct snd_pcm_substream *substream,
 				struct snd_pcm_hw_params *params)
 {
+	int ret = 0;
+
 	if (component->driver->hw_params)
-		return component->driver->hw_params(component,
-						    substream, params);
-	return 0;
+		ret = component->driver->hw_params(component,
+						   substream, params);
+
+	return soc_component_ret(component, ret);
 }
 
 int snd_soc_component_hw_free(struct snd_soc_component *component,
 			       struct snd_pcm_substream *substream)
 {
+	int ret = 0;
+
 	if (component->driver->hw_free)
-		return component->driver->hw_free(component, substream);
-	return 0;
+		ret = component->driver->hw_free(component, substream);
+
+	return soc_component_ret(component, ret);
 }
 
 int snd_soc_component_trigger(struct snd_soc_component *component,
 			      struct snd_pcm_substream *substream,
 			      int cmd)
 {
+	int ret = 0;
+
 	if (component->driver->trigger)
-		return component->driver->trigger(component, substream, cmd);
-	return 0;
+		ret = component->driver->trigger(component, substream, cmd);
+
+	return soc_component_ret(component, ret);
 }
 
 void snd_soc_component_suspend(struct snd_soc_component *component)
@@ -287,10 +343,12 @@ int snd_soc_component_is_suspended(struct snd_soc_component *component)
 
 int snd_soc_component_probe(struct snd_soc_component *component)
 {
+	int ret = 0;
+
 	if (component->driver->probe)
-		return component->driver->probe(component);
+		ret = component->driver->probe(component);
 
-	return 0;
+	return soc_component_ret(component, ret);
 }
 
 void snd_soc_component_remove(struct snd_soc_component *component)
@@ -302,20 +360,25 @@ void snd_soc_component_remove(struct snd_soc_component *component)
 int snd_soc_component_of_xlate_dai_id(struct snd_soc_component *component,
 				      struct device_node *ep)
 {
+	int ret = -ENOTSUPP;
+
 	if (component->driver->of_xlate_dai_id)
-		return component->driver->of_xlate_dai_id(component, ep);
+		ret = component->driver->of_xlate_dai_id(component, ep);
 
-	return -ENOTSUPP;
+	return soc_component_ret(component, ret);
 }
 
 int snd_soc_component_of_xlate_dai_name(struct snd_soc_component *component,
 					struct of_phandle_args *args,
 					const char **dai_name)
 {
+	int ret = -ENOTSUPP;
+
 	if (component->driver->of_xlate_dai_name)
-		return component->driver->of_xlate_dai_name(component,
-						     args, dai_name);
-	return -ENOTSUPP;
+		ret = component->driver->of_xlate_dai_name(component,
+							   args, dai_name);
+
+	return soc_component_ret(component, ret);
 }
 
 void snd_soc_component_setup_regmap(struct snd_soc_component *component)
@@ -392,8 +455,10 @@ int snd_soc_pcm_component_ioctl(struct snd_pcm_substream *substream,
 	/* FIXME: use 1st ioctl */
 	for_each_rtd_components(rtd, i, component)
 		if (component->driver->ioctl)
-			return component->driver->ioctl(component, substream,
-							cmd, arg);
+			return soc_component_ret(
+				component,
+				component->driver->ioctl(component,
+							 substream, cmd, arg));
 
 	return snd_pcm_lib_ioctl(substream, cmd, arg);
 }
@@ -409,7 +474,7 @@ int snd_soc_pcm_component_sync_stop(struct snd_pcm_substream *substream)
 			ret = component->driver->sync_stop(component,
 							   substream);
 			if (ret < 0)
-				return ret;
+				soc_component_ret(component, ret);
 		}
 	}
 
@@ -427,8 +492,11 @@ int snd_soc_pcm_component_copy_user(struct snd_pcm_substream *substream,
 	/* FIXME. it returns 1st copy now */
 	for_each_rtd_components(rtd, i, component)
 		if (component->driver->copy_user)
-			return component->driver->copy_user(
-				component, substream, channel, pos, buf, bytes);
+			return soc_component_ret(
+				component,
+				component->driver->copy_user(
+					component, substream, channel,
+					pos, buf, bytes));
 
 	return -EINVAL;
 }
@@ -464,8 +532,10 @@ int snd_soc_pcm_component_mmap(struct snd_pcm_substream *substream,
 	/* FIXME. it returns 1st mmap now */
 	for_each_rtd_components(rtd, i, component)
 		if (component->driver->mmap)
-			return component->driver->mmap(component,
-						       substream, vma);
+			soc_component_ret(
+				component,
+				component->driver->mmap(component,
+							substream, vma));
 
 	return -EINVAL;
 }
@@ -480,7 +550,7 @@ int snd_soc_pcm_component_new(struct snd_soc_pcm_runtime *rtd)
 		if (component->driver->pcm_construct) {
 			ret = component->driver->pcm_construct(component, rtd);
 			if (ret < 0)
-				return ret;
+				soc_component_ret(component, ret);
 		}
 	}
 
-- 
2.17.1


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

* [PATCH 05/24] ASoC: soc-component: add snd_soc_pcm_component_prepare()
  2020-06-01  1:35 [PATCH 00/24] ASoC: soc-component: collect component functions Kuninori Morimoto
                   ` (3 preceding siblings ...)
  2020-06-01  1:36 ` [PATCH 04/24] ASoC: soc-component: add soc_component_err() Kuninori Morimoto
@ 2020-06-01  1:36 ` Kuninori Morimoto
  2020-06-01 18:22   ` Ranjani Sridharan
  2020-06-01  1:36 ` [PATCH 06/24] ASoC: soc-component: add snd_soc_pcm_component_hw_params() Kuninori Morimoto
                   ` (18 subsequent siblings)
  23 siblings, 1 reply; 37+ messages in thread
From: Kuninori Morimoto @ 2020-06-01  1:36 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_component_xxx()     is focusing to component itself,
snd_soc_pcm_component_xxx() is focusing to rtd related component.

Now we can update snd_soc_component_prepare() to
snd_soc_pcm_component_prepare(). This patch do it.

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

diff --git a/include/sound/soc-component.h b/include/sound/soc-component.h
index cb0d34fa77c6..fc287e910240 100644
--- a/include/sound/soc-component.h
+++ b/include/sound/soc-component.h
@@ -426,8 +426,6 @@ int snd_soc_component_open(struct snd_soc_component *component,
 			   struct snd_pcm_substream *substream);
 int snd_soc_component_close(struct snd_soc_component *component,
 			    struct snd_pcm_substream *substream);
-int snd_soc_component_prepare(struct snd_soc_component *component,
-			      struct snd_pcm_substream *substream);
 int snd_soc_component_hw_params(struct snd_soc_component *component,
 				struct snd_pcm_substream *substream,
 				struct snd_pcm_hw_params *params);
@@ -460,5 +458,6 @@ int snd_soc_pcm_component_mmap(struct snd_pcm_substream *substream,
 			       struct vm_area_struct *vma);
 int snd_soc_pcm_component_new(struct snd_soc_pcm_runtime *rtd);
 void snd_soc_pcm_component_free(struct snd_soc_pcm_runtime *rtd);
+int snd_soc_pcm_component_prepare(struct snd_pcm_substream *substream);
 
 #endif /* __SOC_COMPONENT_H */
diff --git a/sound/soc/soc-component.c b/sound/soc/soc-component.c
index 6d29c2de3b24..1bc155bc8e5e 100644
--- a/sound/soc/soc-component.c
+++ b/sound/soc/soc-component.c
@@ -275,17 +275,6 @@ int snd_soc_component_close(struct snd_soc_component *component,
 	return soc_component_ret(component, ret);
 }
 
-int snd_soc_component_prepare(struct snd_soc_component *component,
-			      struct snd_pcm_substream *substream)
-{
-	int ret = 0;
-
-	if (component->driver->prepare)
-		ret = component->driver->prepare(component, substream);
-
-	return soc_component_ret(component, ret);
-}
-
 int snd_soc_component_hw_params(struct snd_soc_component *component,
 				struct snd_pcm_substream *substream,
 				struct snd_pcm_hw_params *params)
@@ -569,3 +558,20 @@ void snd_soc_pcm_component_free(struct snd_soc_pcm_runtime *rtd)
 		if (component->driver->pcm_destruct)
 			component->driver->pcm_destruct(component, rtd->pcm);
 }
+
+int snd_soc_pcm_component_prepare(struct snd_pcm_substream *substream)
+{
+	struct snd_soc_pcm_runtime *rtd = substream->private_data;
+	struct snd_soc_component *component;
+	int i, ret;
+
+	for_each_rtd_components(rtd, i, component) {
+		if (component->driver->prepare) {
+			ret = component->driver->prepare(component, substream);
+			if (ret < 0)
+				return soc_component_ret(component, ret);
+		}
+	}
+
+	return 0;
+}
diff --git a/sound/soc/soc-pcm.c b/sound/soc/soc-pcm.c
index 276505fb9d50..e61e7a56d95e 100644
--- a/sound/soc/soc-pcm.c
+++ b/sound/soc/soc-pcm.c
@@ -850,7 +850,6 @@ static void codec2codec_close_delayed_work(struct snd_soc_pcm_runtime *rtd)
 static int soc_pcm_prepare(struct snd_pcm_substream *substream)
 {
 	struct snd_soc_pcm_runtime *rtd = substream->private_data;
-	struct snd_soc_component *component;
 	struct snd_soc_dai *dai;
 	int i, ret = 0;
 
@@ -860,13 +859,11 @@ static int soc_pcm_prepare(struct snd_pcm_substream *substream)
 	if (ret < 0)
 		goto out;
 
-	for_each_rtd_components(rtd, i, component) {
-		ret = snd_soc_component_prepare(component, substream);
-		if (ret < 0) {
-			dev_err(component->dev,
-				"ASoC: platform prepare error: %d\n", ret);
-			goto out;
-		}
+	ret = snd_soc_pcm_component_prepare(substream);
+	if (ret < 0) {
+		dev_err(rtd->dev,
+			"ASoC: platform prepare error: %d\n", ret);
+		goto out;
 	}
 
 	ret = snd_soc_pcm_dai_prepare(substream);
-- 
2.17.1


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

* [PATCH 06/24] ASoC: soc-component: add snd_soc_pcm_component_hw_params()
  2020-06-01  1:35 [PATCH 00/24] ASoC: soc-component: collect component functions Kuninori Morimoto
                   ` (4 preceding siblings ...)
  2020-06-01  1:36 ` [PATCH 05/24] ASoC: soc-component: add snd_soc_pcm_component_prepare() Kuninori Morimoto
@ 2020-06-01  1:36 ` Kuninori Morimoto
  2020-06-01  1:36 ` [PATCH 07/24] ASoC: soc-component: add snd_soc_pcm_component_hw_free() Kuninori Morimoto
                   ` (17 subsequent siblings)
  23 siblings, 0 replies; 37+ messages in thread
From: Kuninori Morimoto @ 2020-06-01  1:36 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_component_xxx()     is focusing to component itself,
snd_soc_pcm_component_xxx() is focusing to rtd related component.

Now we can update snd_soc_component_hw_params() to
snd_soc_pcm_component_hw_params(). This patch do it.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
 include/sound/soc-component.h |  6 +++---
 sound/soc/soc-component.c     | 36 ++++++++++++++++++++++-------------
 sound/soc/soc-pcm.c           | 13 +++----------
 3 files changed, 29 insertions(+), 26 deletions(-)

diff --git a/include/sound/soc-component.h b/include/sound/soc-component.h
index fc287e910240..a2898bdd0a3c 100644
--- a/include/sound/soc-component.h
+++ b/include/sound/soc-component.h
@@ -426,9 +426,6 @@ int snd_soc_component_open(struct snd_soc_component *component,
 			   struct snd_pcm_substream *substream);
 int snd_soc_component_close(struct snd_soc_component *component,
 			    struct snd_pcm_substream *substream);
-int snd_soc_component_hw_params(struct snd_soc_component *component,
-				struct snd_pcm_substream *substream,
-				struct snd_pcm_hw_params *params);
 int snd_soc_component_hw_free(struct snd_soc_component *component,
 			      struct snd_pcm_substream *substream);
 int snd_soc_component_trigger(struct snd_soc_component *component,
@@ -459,5 +456,8 @@ int snd_soc_pcm_component_mmap(struct snd_pcm_substream *substream,
 int snd_soc_pcm_component_new(struct snd_soc_pcm_runtime *rtd);
 void snd_soc_pcm_component_free(struct snd_soc_pcm_runtime *rtd);
 int snd_soc_pcm_component_prepare(struct snd_pcm_substream *substream);
+int snd_soc_pcm_component_hw_params(struct snd_pcm_substream *substream,
+				    struct snd_pcm_hw_params *params,
+				    struct snd_soc_component **last);
 
 #endif /* __SOC_COMPONENT_H */
diff --git a/sound/soc/soc-component.c b/sound/soc/soc-component.c
index 1bc155bc8e5e..56341968fe6d 100644
--- a/sound/soc/soc-component.c
+++ b/sound/soc/soc-component.c
@@ -275,19 +275,6 @@ int snd_soc_component_close(struct snd_soc_component *component,
 	return soc_component_ret(component, ret);
 }
 
-int snd_soc_component_hw_params(struct snd_soc_component *component,
-				struct snd_pcm_substream *substream,
-				struct snd_pcm_hw_params *params)
-{
-	int ret = 0;
-
-	if (component->driver->hw_params)
-		ret = component->driver->hw_params(component,
-						   substream, params);
-
-	return soc_component_ret(component, ret);
-}
-
 int snd_soc_component_hw_free(struct snd_soc_component *component,
 			       struct snd_pcm_substream *substream)
 {
@@ -575,3 +562,26 @@ int snd_soc_pcm_component_prepare(struct snd_pcm_substream *substream)
 
 	return 0;
 }
+
+int snd_soc_pcm_component_hw_params(struct snd_pcm_substream *substream,
+				    struct snd_pcm_hw_params *params,
+				    struct snd_soc_component **last)
+{
+	struct snd_soc_pcm_runtime *rtd = substream->private_data;
+	struct snd_soc_component *component;
+	int i, ret;
+
+	for_each_rtd_components(rtd, i, component) {
+		if (component->driver->hw_params) {
+			ret = component->driver->hw_params(component,
+							   substream, params);
+			if (ret < 0) {
+				*last = component;
+				return soc_component_ret(component, ret);
+			}
+		}
+	}
+
+	*last = NULL;
+	return 0;
+}
diff --git a/sound/soc/soc-pcm.c b/sound/soc/soc-pcm.c
index e61e7a56d95e..38d4a340cd7e 100644
--- a/sound/soc/soc-pcm.c
+++ b/sound/soc/soc-pcm.c
@@ -1012,16 +1012,9 @@ static int soc_pcm_hw_params(struct snd_pcm_substream *substream,
 		snd_soc_dapm_update_dai(substream, params, cpu_dai);
 	}
 
-	for_each_rtd_components(rtd, i, component) {
-		ret = snd_soc_component_hw_params(component, substream, params);
-		if (ret < 0) {
-			dev_err(component->dev,
-				"ASoC: %s hw params failed: %d\n",
-				component->name, ret);
-			goto component_err;
-		}
-	}
-	component = NULL;
+	ret = snd_soc_pcm_component_hw_params(substream, params, &component);
+	if (ret < 0)
+		goto component_err;
 
 out:
 	mutex_unlock(&rtd->card->pcm_mutex);
-- 
2.17.1


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

* [PATCH 07/24] ASoC: soc-component: add snd_soc_pcm_component_hw_free()
  2020-06-01  1:35 [PATCH 00/24] ASoC: soc-component: collect component functions Kuninori Morimoto
                   ` (5 preceding siblings ...)
  2020-06-01  1:36 ` [PATCH 06/24] ASoC: soc-component: add snd_soc_pcm_component_hw_params() Kuninori Morimoto
@ 2020-06-01  1:36 ` Kuninori Morimoto
  2020-06-01  1:36 ` [PATCH 08/24] ASoC: soc-component: add snd_soc_pcm_component_trigger() Kuninori Morimoto
                   ` (16 subsequent siblings)
  23 siblings, 0 replies; 37+ messages in thread
From: Kuninori Morimoto @ 2020-06-01  1:36 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_component_xxx()     is focusing to component itself,
snd_soc_pcm_component_xxx() is focusing to rtd related component.

Now we can update snd_soc_component_hw_free() to
snd_soc_pcm_component_hw_free(). This patch do it.

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

diff --git a/include/sound/soc-component.h b/include/sound/soc-component.h
index a2898bdd0a3c..d2f62d529559 100644
--- a/include/sound/soc-component.h
+++ b/include/sound/soc-component.h
@@ -426,8 +426,6 @@ int snd_soc_component_open(struct snd_soc_component *component,
 			   struct snd_pcm_substream *substream);
 int snd_soc_component_close(struct snd_soc_component *component,
 			    struct snd_pcm_substream *substream);
-int snd_soc_component_hw_free(struct snd_soc_component *component,
-			      struct snd_pcm_substream *substream);
 int snd_soc_component_trigger(struct snd_soc_component *component,
 			      struct snd_pcm_substream *substream,
 			      int cmd);
@@ -459,5 +457,7 @@ int snd_soc_pcm_component_prepare(struct snd_pcm_substream *substream);
 int snd_soc_pcm_component_hw_params(struct snd_pcm_substream *substream,
 				    struct snd_pcm_hw_params *params,
 				    struct snd_soc_component **last);
+void snd_soc_pcm_component_hw_free(struct snd_pcm_substream *substream,
+				   struct snd_soc_component *last);
 
 #endif /* __SOC_COMPONENT_H */
diff --git a/sound/soc/soc-component.c b/sound/soc/soc-component.c
index 56341968fe6d..380f6459b5cb 100644
--- a/sound/soc/soc-component.c
+++ b/sound/soc/soc-component.c
@@ -275,17 +275,6 @@ int snd_soc_component_close(struct snd_soc_component *component,
 	return soc_component_ret(component, ret);
 }
 
-int snd_soc_component_hw_free(struct snd_soc_component *component,
-			       struct snd_pcm_substream *substream)
-{
-	int ret = 0;
-
-	if (component->driver->hw_free)
-		ret = component->driver->hw_free(component, substream);
-
-	return soc_component_ret(component, ret);
-}
-
 int snd_soc_component_trigger(struct snd_soc_component *component,
 			      struct snd_pcm_substream *substream,
 			      int cmd)
@@ -585,3 +574,22 @@ int snd_soc_pcm_component_hw_params(struct snd_pcm_substream *substream,
 	*last = NULL;
 	return 0;
 }
+
+void snd_soc_pcm_component_hw_free(struct snd_pcm_substream *substream,
+				   struct snd_soc_component *last)
+{
+	struct snd_soc_pcm_runtime *rtd = substream->private_data;
+	struct snd_soc_component *component;
+	int i, ret;
+
+	for_each_rtd_components(rtd, i, component) {
+		if (component == last)
+			break;
+
+		if (component->driver->hw_free) {
+			ret = component->driver->hw_free(component, substream);
+			if (ret < 0)
+				soc_component_ret(component, ret);
+		}
+	}
+}
diff --git a/sound/soc/soc-pcm.c b/sound/soc/soc-pcm.c
index 38d4a340cd7e..3df620dd80be 100644
--- a/sound/soc/soc-pcm.c
+++ b/sound/soc/soc-pcm.c
@@ -901,25 +901,6 @@ static void soc_pcm_codec_params_fixup(struct snd_pcm_hw_params *params,
 	interval->max = channels;
 }
 
-static int soc_pcm_components_hw_free(struct snd_pcm_substream *substream,
-				      struct snd_soc_component *last)
-{
-	struct snd_soc_pcm_runtime *rtd = substream->private_data;
-	struct snd_soc_component *component;
-	int i, r, ret = 0;
-
-	for_each_rtd_components(rtd, i, component) {
-		if (component == last)
-			break;
-
-		r = snd_soc_component_hw_free(component, substream);
-		if (r < 0)
-			ret = r; /* use last ret */
-	}
-
-	return ret;
-}
-
 /*
  * Called by ALSA when the hardware params are set by application. This
  * function can also be called multiple times and can allocate buffers
@@ -1021,7 +1002,7 @@ static int soc_pcm_hw_params(struct snd_pcm_substream *substream,
 	return ret;
 
 component_err:
-	soc_pcm_components_hw_free(substream, component);
+	snd_soc_pcm_component_hw_free(substream, component);
 
 	i = rtd->num_cpus;
 
@@ -1080,7 +1061,7 @@ static int soc_pcm_hw_free(struct snd_pcm_substream *substream)
 	snd_soc_link_hw_free(substream);
 
 	/* free any component resources */
-	soc_pcm_components_hw_free(substream, NULL);
+	snd_soc_pcm_component_hw_free(substream, NULL);
 
 	/* now free hw params for the DAIs  */
 	for_each_rtd_dais(rtd, i, dai) {
-- 
2.17.1


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

* [PATCH 08/24] ASoC: soc-component: add snd_soc_pcm_component_trigger()
  2020-06-01  1:35 [PATCH 00/24] ASoC: soc-component: collect component functions Kuninori Morimoto
                   ` (6 preceding siblings ...)
  2020-06-01  1:36 ` [PATCH 07/24] ASoC: soc-component: add snd_soc_pcm_component_hw_free() Kuninori Morimoto
@ 2020-06-01  1:36 ` Kuninori Morimoto
  2020-06-01  1:36 ` [PATCH 09/24] ASoC: soc-component: add snd_soc_component_compr_open() Kuninori Morimoto
                   ` (15 subsequent siblings)
  23 siblings, 0 replies; 37+ messages in thread
From: Kuninori Morimoto @ 2020-06-01  1:36 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_component_xxx()     is focusing to component itself,
snd_soc_pcm_component_xxx() is focusing to rtd related component.

Now we can update snd_soc_component_trigger() to
snd_soc_pcm_component_trigger(). This patch do it.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
 include/sound/soc-component.h |  5 ++---
 sound/soc/soc-component.c     | 30 ++++++++++++++++++------------
 sound/soc/soc-pcm.c           | 24 ++++++++----------------
 3 files changed, 28 insertions(+), 31 deletions(-)

diff --git a/include/sound/soc-component.h b/include/sound/soc-component.h
index d2f62d529559..bb26d55a9289 100644
--- a/include/sound/soc-component.h
+++ b/include/sound/soc-component.h
@@ -426,9 +426,6 @@ int snd_soc_component_open(struct snd_soc_component *component,
 			   struct snd_pcm_substream *substream);
 int snd_soc_component_close(struct snd_soc_component *component,
 			    struct snd_pcm_substream *substream);
-int snd_soc_component_trigger(struct snd_soc_component *component,
-			      struct snd_pcm_substream *substream,
-			      int cmd);
 void snd_soc_component_suspend(struct snd_soc_component *component);
 void snd_soc_component_resume(struct snd_soc_component *component);
 int snd_soc_component_is_suspended(struct snd_soc_component *component);
@@ -459,5 +456,7 @@ int snd_soc_pcm_component_hw_params(struct snd_pcm_substream *substream,
 				    struct snd_soc_component **last);
 void snd_soc_pcm_component_hw_free(struct snd_pcm_substream *substream,
 				   struct snd_soc_component *last);
+int snd_soc_pcm_component_trigger(struct snd_pcm_substream *substream,
+				  int cmd);
 
 #endif /* __SOC_COMPONENT_H */
diff --git a/sound/soc/soc-component.c b/sound/soc/soc-component.c
index 380f6459b5cb..150b02be0219 100644
--- a/sound/soc/soc-component.c
+++ b/sound/soc/soc-component.c
@@ -275,18 +275,6 @@ int snd_soc_component_close(struct snd_soc_component *component,
 	return soc_component_ret(component, ret);
 }
 
-int snd_soc_component_trigger(struct snd_soc_component *component,
-			      struct snd_pcm_substream *substream,
-			      int cmd)
-{
-	int ret = 0;
-
-	if (component->driver->trigger)
-		ret = component->driver->trigger(component, substream, cmd);
-
-	return soc_component_ret(component, ret);
-}
-
 void snd_soc_component_suspend(struct snd_soc_component *component)
 {
 	if (component->driver->suspend)
@@ -593,3 +581,21 @@ void snd_soc_pcm_component_hw_free(struct snd_pcm_substream *substream,
 		}
 	}
 }
+
+int snd_soc_pcm_component_trigger(struct snd_pcm_substream *substream,
+				  int cmd)
+{
+	struct snd_soc_pcm_runtime *rtd = substream->private_data;
+	struct snd_soc_component *component;
+	int i, ret;
+
+	for_each_rtd_components(rtd, i, component) {
+		if (component->driver->trigger) {
+			ret = component->driver->trigger(component, substream, cmd);
+			if (ret < 0)
+				return soc_component_ret(component, ret);
+		}
+	}
+
+	return 0;
+}
diff --git a/sound/soc/soc-pcm.c b/sound/soc/soc-pcm.c
index 3df620dd80be..a68c9b0f2b8a 100644
--- a/sound/soc/soc-pcm.c
+++ b/sound/soc/soc-pcm.c
@@ -1077,38 +1077,30 @@ static int soc_pcm_hw_free(struct snd_pcm_substream *substream)
 
 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;
-	int i, ret;
+	int ret;
 
 	ret = snd_soc_link_trigger(substream, cmd);
 	if (ret < 0)
 		return ret;
 
-	for_each_rtd_components(rtd, i, component) {
-		ret = snd_soc_component_trigger(component, substream, cmd);
-		if (ret < 0)
-			return ret;
-	}
+	ret = snd_soc_pcm_component_trigger(substream, cmd);
+	if (ret < 0)
+		return ret;
 
 	return snd_soc_pcm_dai_trigger(substream, cmd);
 }
 
 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;
-	int i, ret;
+	int 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);
-		if (ret < 0)
-			return ret;
-	}
+	ret = snd_soc_pcm_component_trigger(substream, cmd);
+	if (ret < 0)
+		return ret;
 
 	ret = snd_soc_link_trigger(substream, cmd);
 	if (ret < 0)
-- 
2.17.1


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

* [PATCH 09/24] ASoC: soc-component: add snd_soc_component_compr_open()
  2020-06-01  1:35 [PATCH 00/24] ASoC: soc-component: collect component functions Kuninori Morimoto
                   ` (7 preceding siblings ...)
  2020-06-01  1:36 ` [PATCH 08/24] ASoC: soc-component: add snd_soc_pcm_component_trigger() Kuninori Morimoto
@ 2020-06-01  1:36 ` Kuninori Morimoto
  2020-06-01 19:01   ` Ranjani Sridharan
  2020-06-03 16:55   ` Ranjani Sridharan
  2020-06-01  1:36 ` [PATCH 10/24] ASoC: soc-component: add snd_soc_component_compr_free() Kuninori Morimoto
                   ` (14 subsequent siblings)
  23 siblings, 2 replies; 37+ messages in thread
From: Kuninori Morimoto @ 2020-06-01  1:36 UTC (permalink / raw)
  To: Mark Brown; +Cc: Linux-ALSA


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

component related function should be implemented at
soc-component.c.
This patch moves soc-compress soc_compr_components_open()
to soc-component as snd_soc_component_compr_open().

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
 include/sound/soc-component.h |  2 ++
 sound/soc/soc-component.c     | 23 +++++++++++++++++++++++
 sound/soc/soc-compress.c      | 31 ++-----------------------------
 3 files changed, 27 insertions(+), 29 deletions(-)

diff --git a/include/sound/soc-component.h b/include/sound/soc-component.h
index bb26d55a9289..4f82839948d6 100644
--- a/include/sound/soc-component.h
+++ b/include/sound/soc-component.h
@@ -436,6 +436,8 @@ int snd_soc_component_of_xlate_dai_id(struct snd_soc_component *component,
 int snd_soc_component_of_xlate_dai_name(struct snd_soc_component *component,
 					struct of_phandle_args *args,
 					const char **dai_name);
+int snd_soc_component_compr_open(struct snd_compr_stream *cstream,
+				 struct snd_soc_component **last);
 
 int snd_soc_pcm_component_pointer(struct snd_pcm_substream *substream);
 int snd_soc_pcm_component_ioctl(struct snd_pcm_substream *substream,
diff --git a/sound/soc/soc-component.c b/sound/soc/soc-component.c
index 150b02be0219..c2a6046a6380 100644
--- a/sound/soc/soc-component.c
+++ b/sound/soc/soc-component.c
@@ -384,6 +384,29 @@ EXPORT_SYMBOL_GPL(snd_soc_component_exit_regmap);
 
 #endif
 
+int snd_soc_component_compr_open(struct snd_compr_stream *cstream,
+				 struct snd_soc_component **last)
+{
+	struct snd_soc_pcm_runtime *rtd = cstream->private_data;
+	struct snd_soc_component *component;
+	int i, ret;
+
+	for_each_rtd_components(rtd, i, component) {
+		if (component->driver->compress_ops &&
+		    component->driver->compress_ops->open) {
+			ret = component->driver->compress_ops->open(component, cstream);
+			if (ret < 0) {
+				*last = component;
+				return soc_component_ret(component, ret);
+			}
+		}
+	}
+
+	*last = NULL;
+	return 0;
+}
+EXPORT_SYMBOL_GPL(snd_soc_component_compr_open);
+
 int snd_soc_pcm_component_pointer(struct snd_pcm_substream *substream)
 {
 	struct snd_soc_pcm_runtime *rtd = substream->private_data;
diff --git a/sound/soc/soc-compress.c b/sound/soc/soc-compress.c
index 4984b6a2c370..2a0d554013a4 100644
--- a/sound/soc/soc-compress.c
+++ b/sound/soc/soc-compress.c
@@ -22,33 +22,6 @@
 #include <sound/soc-link.h>
 #include <linux/pm_runtime.h>
 
-static int soc_compr_components_open(struct snd_compr_stream *cstream,
-				     struct snd_soc_component **last)
-{
-	struct snd_soc_pcm_runtime *rtd = cstream->private_data;
-	struct snd_soc_component *component;
-	int i, ret;
-
-	for_each_rtd_components(rtd, i, component) {
-		if (!component->driver->compress_ops ||
-		    !component->driver->compress_ops->open)
-			continue;
-
-		ret = component->driver->compress_ops->open(component, cstream);
-		if (ret < 0) {
-			dev_err(component->dev,
-				"Compress ASoC: can't open platform %s: %d\n",
-				component->name, ret);
-
-			*last = component;
-			return ret;
-		}
-	}
-
-	*last = NULL;
-	return 0;
-}
-
 static int soc_compr_components_free(struct snd_compr_stream *cstream,
 				     struct snd_soc_component *last)
 {
@@ -92,7 +65,7 @@ static int soc_compr_open(struct snd_compr_stream *cstream)
 	if (ret < 0)
 		goto out;
 
-	ret = soc_compr_components_open(cstream, &component);
+	ret = snd_soc_component_compr_open(cstream, &component);
 	if (ret < 0)
 		goto machine_err;
 
@@ -170,7 +143,7 @@ static int soc_compr_open_fe(struct snd_compr_stream *cstream)
 	if (ret < 0)
 		goto out;
 
-	ret = soc_compr_components_open(cstream, &component);
+	ret = snd_soc_component_compr_open(cstream, &component);
 	if (ret < 0)
 		goto open_err;
 
-- 
2.17.1


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

* [PATCH 10/24] ASoC: soc-component: add snd_soc_component_compr_free()
  2020-06-01  1:35 [PATCH 00/24] ASoC: soc-component: collect component functions Kuninori Morimoto
                   ` (8 preceding siblings ...)
  2020-06-01  1:36 ` [PATCH 09/24] ASoC: soc-component: add snd_soc_component_compr_open() Kuninori Morimoto
@ 2020-06-01  1:36 ` Kuninori Morimoto
  2020-06-01  1:36 ` [PATCH 11/24] ASoC: soc-component: add snd_soc_component_compr_trigger() Kuninori Morimoto
                   ` (13 subsequent siblings)
  23 siblings, 0 replies; 37+ messages in thread
From: Kuninori Morimoto @ 2020-06-01  1:36 UTC (permalink / raw)
  To: Mark Brown; +Cc: Linux-ALSA


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

component related function should be implemented at
soc-component.c.
This patch moves soc-compress soc_compr_components_free()
to soc-component as snd_soc_component_compr_free().

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

diff --git a/include/sound/soc-component.h b/include/sound/soc-component.h
index 4f82839948d6..090ea500d11d 100644
--- a/include/sound/soc-component.h
+++ b/include/sound/soc-component.h
@@ -438,6 +438,8 @@ int snd_soc_component_of_xlate_dai_name(struct snd_soc_component *component,
 					const char **dai_name);
 int snd_soc_component_compr_open(struct snd_compr_stream *cstream,
 				 struct snd_soc_component **last);
+void snd_soc_component_compr_free(struct snd_compr_stream *cstream,
+				  struct snd_soc_component *last);
 
 int snd_soc_pcm_component_pointer(struct snd_pcm_substream *substream);
 int snd_soc_pcm_component_ioctl(struct snd_pcm_substream *substream,
diff --git a/sound/soc/soc-component.c b/sound/soc/soc-component.c
index c2a6046a6380..375319142305 100644
--- a/sound/soc/soc-component.c
+++ b/sound/soc/soc-component.c
@@ -407,6 +407,24 @@ int snd_soc_component_compr_open(struct snd_compr_stream *cstream,
 }
 EXPORT_SYMBOL_GPL(snd_soc_component_compr_open);
 
+void snd_soc_component_compr_free(struct snd_compr_stream *cstream,
+				  struct snd_soc_component *last)
+{
+	struct snd_soc_pcm_runtime *rtd = cstream->private_data;
+	struct snd_soc_component *component;
+	int i;
+
+	for_each_rtd_components(rtd, i, component) {
+		if (component == last)
+			break;
+
+		if (component->driver->compress_ops &&
+		    component->driver->compress_ops->free)
+			component->driver->compress_ops->free(component, cstream);
+	}
+}
+EXPORT_SYMBOL_GPL(snd_soc_component_compr_free);
+
 int snd_soc_pcm_component_pointer(struct snd_pcm_substream *substream)
 {
 	struct snd_soc_pcm_runtime *rtd = substream->private_data;
diff --git a/sound/soc/soc-compress.c b/sound/soc/soc-compress.c
index 2a0d554013a4..c164b93c8a0e 100644
--- a/sound/soc/soc-compress.c
+++ b/sound/soc/soc-compress.c
@@ -22,27 +22,6 @@
 #include <sound/soc-link.h>
 #include <linux/pm_runtime.h>
 
-static int soc_compr_components_free(struct snd_compr_stream *cstream,
-				     struct snd_soc_component *last)
-{
-	struct snd_soc_pcm_runtime *rtd = cstream->private_data;
-	struct snd_soc_component *component;
-	int i;
-
-	for_each_rtd_components(rtd, i, component) {
-		if (component == last)
-			break;
-
-		if (!component->driver->compress_ops ||
-		    !component->driver->compress_ops->free)
-			continue;
-
-		component->driver->compress_ops->free(component, cstream);
-	}
-
-	return 0;
-}
-
 static int soc_compr_open(struct snd_compr_stream *cstream)
 {
 	struct snd_soc_pcm_runtime *rtd = cstream->private_data;
@@ -80,7 +59,7 @@ static int soc_compr_open(struct snd_compr_stream *cstream)
 	return 0;
 
 machine_err:
-	soc_compr_components_free(cstream, component);
+	snd_soc_component_compr_free(cstream, component);
 
 	snd_soc_dai_compr_shutdown(cpu_dai, cstream);
 out:
@@ -164,7 +143,7 @@ static int soc_compr_open_fe(struct snd_compr_stream *cstream)
 	return 0;
 
 machine_err:
-	soc_compr_components_free(cstream, component);
+	snd_soc_component_compr_free(cstream, component);
 open_err:
 	snd_soc_dai_compr_shutdown(cpu_dai, cstream);
 out:
@@ -202,7 +181,7 @@ static int soc_compr_free(struct snd_compr_stream *cstream)
 
 	snd_soc_link_compr_shutdown(cstream);
 
-	soc_compr_components_free(cstream, NULL);
+	snd_soc_component_compr_free(cstream, NULL);
 
 	snd_soc_dai_compr_shutdown(cpu_dai, cstream);
 
@@ -257,7 +236,7 @@ static int soc_compr_free_fe(struct snd_compr_stream *cstream)
 
 	snd_soc_link_compr_shutdown(cstream);
 
-	soc_compr_components_free(cstream, NULL);
+	snd_soc_component_compr_free(cstream, NULL);
 
 	snd_soc_dai_compr_shutdown(cpu_dai, cstream);
 
-- 
2.17.1


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

* [PATCH 11/24] ASoC: soc-component: add snd_soc_component_compr_trigger()
  2020-06-01  1:35 [PATCH 00/24] ASoC: soc-component: collect component functions Kuninori Morimoto
                   ` (9 preceding siblings ...)
  2020-06-01  1:36 ` [PATCH 10/24] ASoC: soc-component: add snd_soc_component_compr_free() Kuninori Morimoto
@ 2020-06-01  1:36 ` Kuninori Morimoto
  2020-06-01  1:36 ` [PATCH 12/24] ASoC: soc-component: add snd_soc_component_compr_set_params() Kuninori Morimoto
                   ` (12 subsequent siblings)
  23 siblings, 0 replies; 37+ messages in thread
From: Kuninori Morimoto @ 2020-06-01  1:36 UTC (permalink / raw)
  To: Mark Brown; +Cc: Linux-ALSA

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

component related function should be implemented at
soc-component.c.
This patch moves soc-compress soc_compr_components_trigger()
to soc-component as snd_soc_component_compr_trigger().

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

diff --git a/include/sound/soc-component.h b/include/sound/soc-component.h
index 090ea500d11d..e09cd7627ce9 100644
--- a/include/sound/soc-component.h
+++ b/include/sound/soc-component.h
@@ -440,6 +440,7 @@ int snd_soc_component_compr_open(struct snd_compr_stream *cstream,
 				 struct snd_soc_component **last);
 void snd_soc_component_compr_free(struct snd_compr_stream *cstream,
 				  struct snd_soc_component *last);
+int snd_soc_component_compr_trigger(struct snd_compr_stream *cstream, int cmd);
 
 int snd_soc_pcm_component_pointer(struct snd_pcm_substream *substream);
 int snd_soc_pcm_component_ioctl(struct snd_pcm_substream *substream,
diff --git a/sound/soc/soc-component.c b/sound/soc/soc-component.c
index 375319142305..99f3ecfef4ab 100644
--- a/sound/soc/soc-component.c
+++ b/sound/soc/soc-component.c
@@ -425,6 +425,26 @@ void snd_soc_component_compr_free(struct snd_compr_stream *cstream,
 }
 EXPORT_SYMBOL_GPL(snd_soc_component_compr_free);
 
+int snd_soc_component_compr_trigger(struct snd_compr_stream *cstream, int cmd)
+{
+	struct snd_soc_pcm_runtime *rtd = cstream->private_data;
+	struct snd_soc_component *component;
+	int i, ret;
+
+	for_each_rtd_components(rtd, i, component) {
+		if (component->driver->compress_ops &&
+		    component->driver->compress_ops->trigger) {
+			ret = component->driver->compress_ops->trigger(
+				component, cstream, cmd);
+			if (ret < 0)
+				return soc_component_ret(component, ret);
+		}
+	}
+
+	return 0;
+}
+EXPORT_SYMBOL_GPL(snd_soc_component_compr_trigger);
+
 int snd_soc_pcm_component_pointer(struct snd_pcm_substream *substream)
 {
 	struct snd_soc_pcm_runtime *rtd = substream->private_data;
diff --git a/sound/soc/soc-compress.c b/sound/soc/soc-compress.c
index c164b93c8a0e..7a989d0bb369 100644
--- a/sound/soc/soc-compress.c
+++ b/sound/soc/soc-compress.c
@@ -244,27 +244,6 @@ static int soc_compr_free_fe(struct snd_compr_stream *cstream)
 	return 0;
 }
 
-static int soc_compr_components_trigger(struct snd_compr_stream *cstream,
-					int cmd)
-{
-	struct snd_soc_pcm_runtime *rtd = cstream->private_data;
-	struct snd_soc_component *component;
-	int i, ret;
-
-	for_each_rtd_components(rtd, i, component) {
-		if (!component->driver->compress_ops ||
-		    !component->driver->compress_ops->trigger)
-			continue;
-
-		ret = component->driver->compress_ops->trigger(
-			component, cstream, cmd);
-		if (ret < 0)
-			return ret;
-	}
-
-	return 0;
-}
-
 static int soc_compr_trigger(struct snd_compr_stream *cstream, int cmd)
 {
 	struct snd_soc_pcm_runtime *rtd = cstream->private_data;
@@ -274,7 +253,7 @@ static int soc_compr_trigger(struct snd_compr_stream *cstream, int cmd)
 
 	mutex_lock_nested(&rtd->card->pcm_mutex, rtd->card->pcm_subclass);
 
-	ret = soc_compr_components_trigger(cstream, cmd);
+	ret = snd_soc_component_compr_trigger(cstream, cmd);
 	if (ret < 0)
 		goto out;
 
@@ -304,7 +283,7 @@ static int soc_compr_trigger_fe(struct snd_compr_stream *cstream, int cmd)
 
 	if (cmd == SND_COMPR_TRIGGER_PARTIAL_DRAIN ||
 	    cmd == SND_COMPR_TRIGGER_DRAIN)
-		return soc_compr_components_trigger(cstream, cmd);
+		return snd_soc_component_compr_trigger(cstream, cmd);
 
 	if (cstream->direction == SND_COMPRESS_PLAYBACK)
 		stream = SNDRV_PCM_STREAM_PLAYBACK;
@@ -317,7 +296,7 @@ static int soc_compr_trigger_fe(struct snd_compr_stream *cstream, int cmd)
 	if (ret < 0)
 		goto out;
 
-	ret = soc_compr_components_trigger(cstream, cmd);
+	ret = snd_soc_component_compr_trigger(cstream, cmd);
 	if (ret < 0)
 		goto out;
 
-- 
2.17.1


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

* [PATCH 12/24] ASoC: soc-component: add snd_soc_component_compr_set_params()
  2020-06-01  1:35 [PATCH 00/24] ASoC: soc-component: collect component functions Kuninori Morimoto
                   ` (10 preceding siblings ...)
  2020-06-01  1:36 ` [PATCH 11/24] ASoC: soc-component: add snd_soc_component_compr_trigger() Kuninori Morimoto
@ 2020-06-01  1:36 ` Kuninori Morimoto
  2020-06-01  1:36 ` [PATCH 13/24] ASoC: soc-component: add snd_soc_component_compr_get_params() Kuninori Morimoto
                   ` (11 subsequent siblings)
  23 siblings, 0 replies; 37+ messages in thread
From: Kuninori Morimoto @ 2020-06-01  1:36 UTC (permalink / raw)
  To: Mark Brown; +Cc: Linux-ALSA

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

component related function should be implemented at
soc-component.c.
This patch moves soc-compress soc_compr_components_set_params()
to soc-component as snd_soc_component_compr_set_params().

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

diff --git a/include/sound/soc-component.h b/include/sound/soc-component.h
index e09cd7627ce9..92a6c3ac18e7 100644
--- a/include/sound/soc-component.h
+++ b/include/sound/soc-component.h
@@ -441,6 +441,8 @@ int snd_soc_component_compr_open(struct snd_compr_stream *cstream,
 void snd_soc_component_compr_free(struct snd_compr_stream *cstream,
 				  struct snd_soc_component *last);
 int snd_soc_component_compr_trigger(struct snd_compr_stream *cstream, int cmd);
+int snd_soc_component_compr_set_params(struct snd_compr_stream *cstream,
+				       struct snd_compr_params *params);
 
 int snd_soc_pcm_component_pointer(struct snd_pcm_substream *substream);
 int snd_soc_pcm_component_ioctl(struct snd_pcm_substream *substream,
diff --git a/sound/soc/soc-component.c b/sound/soc/soc-component.c
index 99f3ecfef4ab..bba6ef645282 100644
--- a/sound/soc/soc-component.c
+++ b/sound/soc/soc-component.c
@@ -445,6 +445,27 @@ int snd_soc_component_compr_trigger(struct snd_compr_stream *cstream, int cmd)
 }
 EXPORT_SYMBOL_GPL(snd_soc_component_compr_trigger);
 
+int snd_soc_component_compr_set_params(struct snd_compr_stream *cstream,
+				       struct snd_compr_params *params)
+{
+	struct snd_soc_pcm_runtime *rtd = cstream->private_data;
+	struct snd_soc_component *component;
+	int i, ret;
+
+	for_each_rtd_components(rtd, i, component) {
+		if (component->driver->compress_ops &&
+		    component->driver->compress_ops->set_params) {
+			ret = component->driver->compress_ops->set_params(
+				component, cstream, params);
+			if (ret < 0)
+				return soc_component_ret(component, ret);
+		}
+	}
+
+	return 0;
+}
+EXPORT_SYMBOL_GPL(snd_soc_component_compr_set_params);
+
 int snd_soc_pcm_component_pointer(struct snd_pcm_substream *substream)
 {
 	struct snd_soc_pcm_runtime *rtd = substream->private_data;
diff --git a/sound/soc/soc-compress.c b/sound/soc/soc-compress.c
index 7a989d0bb369..a2d693603119 100644
--- a/sound/soc/soc-compress.c
+++ b/sound/soc/soc-compress.c
@@ -325,27 +325,6 @@ static int soc_compr_trigger_fe(struct snd_compr_stream *cstream, int cmd)
 	return ret;
 }
 
-static int soc_compr_components_set_params(struct snd_compr_stream *cstream,
-					   struct snd_compr_params *params)
-{
-	struct snd_soc_pcm_runtime *rtd = cstream->private_data;
-	struct snd_soc_component *component;
-	int i, ret;
-
-	for_each_rtd_components(rtd, i, component) {
-		if (!component->driver->compress_ops ||
-		    !component->driver->compress_ops->set_params)
-			continue;
-
-		ret = component->driver->compress_ops->set_params(
-			component, cstream, params);
-		if (ret < 0)
-			return ret;
-	}
-
-	return 0;
-}
-
 static int soc_compr_set_params(struct snd_compr_stream *cstream,
 				struct snd_compr_params *params)
 {
@@ -366,7 +345,7 @@ static int soc_compr_set_params(struct snd_compr_stream *cstream,
 	if (ret < 0)
 		goto err;
 
-	ret = soc_compr_components_set_params(cstream, params);
+	ret = snd_soc_component_compr_set_params(cstream, params);
 	if (ret < 0)
 		goto err;
 
@@ -432,7 +411,7 @@ static int soc_compr_set_params_fe(struct snd_compr_stream *cstream,
 	if (ret < 0)
 		goto out;
 
-	ret = soc_compr_components_set_params(cstream, params);
+	ret = snd_soc_component_compr_set_params(cstream, params);
 	if (ret < 0)
 		goto out;
 
-- 
2.17.1


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

* [PATCH 13/24] ASoC: soc-component: add snd_soc_component_compr_get_params()
  2020-06-01  1:35 [PATCH 00/24] ASoC: soc-component: collect component functions Kuninori Morimoto
                   ` (11 preceding siblings ...)
  2020-06-01  1:36 ` [PATCH 12/24] ASoC: soc-component: add snd_soc_component_compr_set_params() Kuninori Morimoto
@ 2020-06-01  1:36 ` Kuninori Morimoto
  2020-06-01  1:37 ` [PATCH 14/24] ASoC: soc-component: add snd_soc_component_compr_get_caps() Kuninori Morimoto
                   ` (10 subsequent siblings)
  23 siblings, 0 replies; 37+ messages in thread
From: Kuninori Morimoto @ 2020-06-01  1:36 UTC (permalink / raw)
  To: Mark Brown; +Cc: Linux-ALSA

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

component related function should be implemented at
soc-component.c.
This patch adds snd_soc_component_compr_get_params().

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

diff --git a/include/sound/soc-component.h b/include/sound/soc-component.h
index 92a6c3ac18e7..0af759187b24 100644
--- a/include/sound/soc-component.h
+++ b/include/sound/soc-component.h
@@ -443,6 +443,8 @@ void snd_soc_component_compr_free(struct snd_compr_stream *cstream,
 int snd_soc_component_compr_trigger(struct snd_compr_stream *cstream, int cmd);
 int snd_soc_component_compr_set_params(struct snd_compr_stream *cstream,
 				       struct snd_compr_params *params);
+int snd_soc_component_compr_get_params(struct snd_compr_stream *cstream,
+				       struct snd_codec *params);
 
 int snd_soc_pcm_component_pointer(struct snd_pcm_substream *substream);
 int snd_soc_pcm_component_ioctl(struct snd_pcm_substream *substream,
diff --git a/sound/soc/soc-component.c b/sound/soc/soc-component.c
index bba6ef645282..8ab3fe0e142a 100644
--- a/sound/soc/soc-component.c
+++ b/sound/soc/soc-component.c
@@ -466,6 +466,27 @@ int snd_soc_component_compr_set_params(struct snd_compr_stream *cstream,
 }
 EXPORT_SYMBOL_GPL(snd_soc_component_compr_set_params);
 
+int snd_soc_component_compr_get_params(struct snd_compr_stream *cstream,
+				       struct snd_codec *params)
+{
+	struct snd_soc_pcm_runtime *rtd = cstream->private_data;
+	struct snd_soc_component *component;
+	int i, ret;
+
+	for_each_rtd_components(rtd, i, component) {
+		if (component->driver->compress_ops &&
+		    component->driver->compress_ops->get_params) {
+			ret = component->driver->compress_ops->get_params(
+				component, cstream, params);
+			if (ret < 0)
+				return soc_component_ret(component, ret);
+		}
+	}
+
+	return 0;
+}
+EXPORT_SYMBOL_GPL(snd_soc_component_compr_get_params);
+
 int snd_soc_pcm_component_pointer(struct snd_pcm_substream *substream)
 {
 	struct snd_soc_pcm_runtime *rtd = substream->private_data;
diff --git a/sound/soc/soc-compress.c b/sound/soc/soc-compress.c
index a2d693603119..cefb60cd48d8 100644
--- a/sound/soc/soc-compress.c
+++ b/sound/soc/soc-compress.c
@@ -432,9 +432,8 @@ static int soc_compr_get_params(struct snd_compr_stream *cstream,
 				struct snd_codec *params)
 {
 	struct snd_soc_pcm_runtime *rtd = cstream->private_data;
-	struct snd_soc_component *component;
 	struct snd_soc_dai *cpu_dai = asoc_rtd_to_cpu(rtd, 0);
-	int i, ret = 0;
+	int ret = 0;
 
 	mutex_lock_nested(&rtd->card->pcm_mutex, rtd->card->pcm_subclass);
 
@@ -442,16 +441,7 @@ static int soc_compr_get_params(struct snd_compr_stream *cstream,
 	if (ret < 0)
 		goto err;
 
-	for_each_rtd_components(rtd, i, component) {
-		if (!component->driver->compress_ops ||
-		    !component->driver->compress_ops->get_params)
-			continue;
-
-		ret = component->driver->compress_ops->get_params(
-			component, cstream, params);
-		break;
-	}
-
+	ret = snd_soc_component_compr_get_params(cstream, params);
 err:
 	mutex_unlock(&rtd->card->pcm_mutex);
 	return ret;
-- 
2.17.1


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

* [PATCH 14/24] ASoC: soc-component: add snd_soc_component_compr_get_caps()
  2020-06-01  1:35 [PATCH 00/24] ASoC: soc-component: collect component functions Kuninori Morimoto
                   ` (12 preceding siblings ...)
  2020-06-01  1:36 ` [PATCH 13/24] ASoC: soc-component: add snd_soc_component_compr_get_params() Kuninori Morimoto
@ 2020-06-01  1:37 ` Kuninori Morimoto
  2020-06-01  1:37 ` [PATCH 15/24] ASoC: soc-component: add snd_soc_component_compr_get_codec_caps() Kuninori Morimoto
                   ` (9 subsequent siblings)
  23 siblings, 0 replies; 37+ messages in thread
From: Kuninori Morimoto @ 2020-06-01  1:37 UTC (permalink / raw)
  To: Mark Brown; +Cc: Linux-ALSA

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

component related function should be implemented at
soc-component.c.
This patch adds snd_soc_component_compr_get_caps().

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

diff --git a/include/sound/soc-component.h b/include/sound/soc-component.h
index 0af759187b24..fabece54a41d 100644
--- a/include/sound/soc-component.h
+++ b/include/sound/soc-component.h
@@ -445,6 +445,8 @@ int snd_soc_component_compr_set_params(struct snd_compr_stream *cstream,
 				       struct snd_compr_params *params);
 int snd_soc_component_compr_get_params(struct snd_compr_stream *cstream,
 				       struct snd_codec *params);
+int snd_soc_component_compr_get_caps(struct snd_compr_stream *cstream,
+				     struct snd_compr_caps *caps);
 
 int snd_soc_pcm_component_pointer(struct snd_pcm_substream *substream);
 int snd_soc_pcm_component_ioctl(struct snd_pcm_substream *substream,
diff --git a/sound/soc/soc-component.c b/sound/soc/soc-component.c
index 8ab3fe0e142a..037b4818fc0e 100644
--- a/sound/soc/soc-component.c
+++ b/sound/soc/soc-component.c
@@ -487,6 +487,27 @@ int snd_soc_component_compr_get_params(struct snd_compr_stream *cstream,
 }
 EXPORT_SYMBOL_GPL(snd_soc_component_compr_get_params);
 
+int snd_soc_component_compr_get_caps(struct snd_compr_stream *cstream,
+				     struct snd_compr_caps *caps)
+{
+	struct snd_soc_pcm_runtime *rtd = cstream->private_data;
+	struct snd_soc_component *component;
+	int i, ret;
+
+	for_each_rtd_components(rtd, i, component) {
+		if (component->driver->compress_ops &&
+		    component->driver->compress_ops->get_caps) {
+			ret = component->driver->compress_ops->get_caps(
+				component, cstream, caps);
+			if (ret < 0)
+				return soc_component_ret(component, ret);
+		}
+	}
+
+	return 0;
+}
+EXPORT_SYMBOL_GPL(snd_soc_component_compr_get_caps);
+
 int snd_soc_pcm_component_pointer(struct snd_pcm_substream *substream)
 {
 	struct snd_soc_pcm_runtime *rtd = substream->private_data;
diff --git a/sound/soc/soc-compress.c b/sound/soc/soc-compress.c
index cefb60cd48d8..5b93fb543d22 100644
--- a/sound/soc/soc-compress.c
+++ b/sound/soc/soc-compress.c
@@ -451,20 +451,11 @@ static int soc_compr_get_caps(struct snd_compr_stream *cstream,
 			      struct snd_compr_caps *caps)
 {
 	struct snd_soc_pcm_runtime *rtd = cstream->private_data;
-	struct snd_soc_component *component;
-	int i, ret = 0;
+	int ret;
 
 	mutex_lock_nested(&rtd->card->pcm_mutex, rtd->card->pcm_subclass);
 
-	for_each_rtd_components(rtd, i, component) {
-		if (!component->driver->compress_ops ||
-		    !component->driver->compress_ops->get_caps)
-			continue;
-
-		ret = component->driver->compress_ops->get_caps(
-			component, cstream, caps);
-		break;
-	}
+	ret = snd_soc_component_compr_get_caps(cstream, caps);
 
 	mutex_unlock(&rtd->card->pcm_mutex);
 	return ret;
-- 
2.17.1


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

* [PATCH 15/24] ASoC: soc-component: add snd_soc_component_compr_get_codec_caps()
  2020-06-01  1:35 [PATCH 00/24] ASoC: soc-component: collect component functions Kuninori Morimoto
                   ` (13 preceding siblings ...)
  2020-06-01  1:37 ` [PATCH 14/24] ASoC: soc-component: add snd_soc_component_compr_get_caps() Kuninori Morimoto
@ 2020-06-01  1:37 ` Kuninori Morimoto
  2020-06-01  1:37 ` [PATCH 16/24] ASoC: soc-component: add snd_soc_component_compr_ack() Kuninori Morimoto
                   ` (8 subsequent siblings)
  23 siblings, 0 replies; 37+ messages in thread
From: Kuninori Morimoto @ 2020-06-01  1:37 UTC (permalink / raw)
  To: Mark Brown; +Cc: Linux-ALSA

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

component related function should be implemented at
soc-component.c.
This patch adds snd_soc_component_compr_get_codec_caps().

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

diff --git a/include/sound/soc-component.h b/include/sound/soc-component.h
index fabece54a41d..0a893cead647 100644
--- a/include/sound/soc-component.h
+++ b/include/sound/soc-component.h
@@ -447,6 +447,8 @@ int snd_soc_component_compr_get_params(struct snd_compr_stream *cstream,
 				       struct snd_codec *params);
 int snd_soc_component_compr_get_caps(struct snd_compr_stream *cstream,
 				     struct snd_compr_caps *caps);
+int snd_soc_component_compr_get_codec_caps(struct snd_compr_stream *cstream,
+					   struct snd_compr_codec_caps *codec);
 
 int snd_soc_pcm_component_pointer(struct snd_pcm_substream *substream);
 int snd_soc_pcm_component_ioctl(struct snd_pcm_substream *substream,
diff --git a/sound/soc/soc-component.c b/sound/soc/soc-component.c
index 037b4818fc0e..3a67d5fc1b67 100644
--- a/sound/soc/soc-component.c
+++ b/sound/soc/soc-component.c
@@ -508,6 +508,27 @@ int snd_soc_component_compr_get_caps(struct snd_compr_stream *cstream,
 }
 EXPORT_SYMBOL_GPL(snd_soc_component_compr_get_caps);
 
+int snd_soc_component_compr_get_codec_caps(struct snd_compr_stream *cstream,
+					   struct snd_compr_codec_caps *codec)
+{
+	struct snd_soc_pcm_runtime *rtd = cstream->private_data;
+	struct snd_soc_component *component;
+	int i, ret;
+
+	for_each_rtd_components(rtd, i, component) {
+		if (component->driver->compress_ops &&
+		    component->driver->compress_ops->get_codec_caps) {
+			ret = component->driver->compress_ops->get_codec_caps(
+				component, cstream, codec);
+			if (ret < 0)
+				return soc_component_ret(component, ret);
+		}
+	}
+
+	return 0;
+}
+EXPORT_SYMBOL_GPL(snd_soc_component_compr_get_codec_caps);
+
 int snd_soc_pcm_component_pointer(struct snd_pcm_substream *substream)
 {
 	struct snd_soc_pcm_runtime *rtd = substream->private_data;
diff --git a/sound/soc/soc-compress.c b/sound/soc/soc-compress.c
index 5b93fb543d22..7016a0b79796 100644
--- a/sound/soc/soc-compress.c
+++ b/sound/soc/soc-compress.c
@@ -465,20 +465,11 @@ static int soc_compr_get_codec_caps(struct snd_compr_stream *cstream,
 				    struct snd_compr_codec_caps *codec)
 {
 	struct snd_soc_pcm_runtime *rtd = cstream->private_data;
-	struct snd_soc_component *component;
-	int i, ret = 0;
+	int ret;
 
 	mutex_lock_nested(&rtd->card->pcm_mutex, rtd->card->pcm_subclass);
 
-	for_each_rtd_components(rtd, i, component) {
-		if (!component->driver->compress_ops ||
-		    !component->driver->compress_ops->get_codec_caps)
-			continue;
-
-		ret = component->driver->compress_ops->get_codec_caps(
-			component, cstream, codec);
-		break;
-	}
+	ret = snd_soc_component_compr_get_codec_caps(cstream, codec);
 
 	mutex_unlock(&rtd->card->pcm_mutex);
 	return ret;
-- 
2.17.1


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

* [PATCH 16/24] ASoC: soc-component: add snd_soc_component_compr_ack()
  2020-06-01  1:35 [PATCH 00/24] ASoC: soc-component: collect component functions Kuninori Morimoto
                   ` (14 preceding siblings ...)
  2020-06-01  1:37 ` [PATCH 15/24] ASoC: soc-component: add snd_soc_component_compr_get_codec_caps() Kuninori Morimoto
@ 2020-06-01  1:37 ` Kuninori Morimoto
  2020-06-01  1:37 ` [PATCH 17/24] ASoC: soc-component: add snd_soc_component_compr_pointer() Kuninori Morimoto
                   ` (7 subsequent siblings)
  23 siblings, 0 replies; 37+ messages in thread
From: Kuninori Morimoto @ 2020-06-01  1:37 UTC (permalink / raw)
  To: Mark Brown; +Cc: Linux-ALSA


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

component related function should be implemented at
soc-component.c.
This patch adds snd_soc_component_compr_ack().

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
 include/sound/soc-component.h |  1 +
 sound/soc/soc-component.c     | 20 ++++++++++++++++++++
 sound/soc/soc-compress.c      | 15 ++-------------
 3 files changed, 23 insertions(+), 13 deletions(-)

diff --git a/include/sound/soc-component.h b/include/sound/soc-component.h
index 0a893cead647..da1d89d0b476 100644
--- a/include/sound/soc-component.h
+++ b/include/sound/soc-component.h
@@ -449,6 +449,7 @@ int snd_soc_component_compr_get_caps(struct snd_compr_stream *cstream,
 				     struct snd_compr_caps *caps);
 int snd_soc_component_compr_get_codec_caps(struct snd_compr_stream *cstream,
 					   struct snd_compr_codec_caps *codec);
+int snd_soc_component_compr_ack(struct snd_compr_stream *cstream, size_t bytes);
 
 int snd_soc_pcm_component_pointer(struct snd_pcm_substream *substream);
 int snd_soc_pcm_component_ioctl(struct snd_pcm_substream *substream,
diff --git a/sound/soc/soc-component.c b/sound/soc/soc-component.c
index 3a67d5fc1b67..8f223dd060e8 100644
--- a/sound/soc/soc-component.c
+++ b/sound/soc/soc-component.c
@@ -529,6 +529,26 @@ int snd_soc_component_compr_get_codec_caps(struct snd_compr_stream *cstream,
 }
 EXPORT_SYMBOL_GPL(snd_soc_component_compr_get_codec_caps);
 
+int snd_soc_component_compr_ack(struct snd_compr_stream *cstream, size_t bytes)
+{
+	struct snd_soc_pcm_runtime *rtd = cstream->private_data;
+	struct snd_soc_component *component;
+	int i, ret;
+
+	for_each_rtd_components(rtd, i, component) {
+		if (component->driver->compress_ops &&
+		    component->driver->compress_ops->ack) {
+			ret = component->driver->compress_ops->ack(
+				component, cstream, bytes);
+			if (ret < 0)
+				return soc_component_ret(component, ret);
+		}
+	}
+
+	return 0;
+}
+EXPORT_SYMBOL_GPL(snd_soc_component_compr_ack);
+
 int snd_soc_pcm_component_pointer(struct snd_pcm_substream *substream)
 {
 	struct snd_soc_pcm_runtime *rtd = substream->private_data;
diff --git a/sound/soc/soc-compress.c b/sound/soc/soc-compress.c
index 7016a0b79796..4798c20bd9b5 100644
--- a/sound/soc/soc-compress.c
+++ b/sound/soc/soc-compress.c
@@ -478,9 +478,8 @@ static int soc_compr_get_codec_caps(struct snd_compr_stream *cstream,
 static int soc_compr_ack(struct snd_compr_stream *cstream, size_t bytes)
 {
 	struct snd_soc_pcm_runtime *rtd = cstream->private_data;
-	struct snd_soc_component *component;
 	struct snd_soc_dai *cpu_dai = asoc_rtd_to_cpu(rtd, 0);
-	int i, ret = 0;
+	int ret;
 
 	mutex_lock_nested(&rtd->card->pcm_mutex, rtd->card->pcm_subclass);
 
@@ -488,17 +487,7 @@ static int soc_compr_ack(struct snd_compr_stream *cstream, size_t bytes)
 	if (ret < 0)
 		goto err;
 
-	for_each_rtd_components(rtd, i, component) {
-		if (!component->driver->compress_ops ||
-		    !component->driver->compress_ops->ack)
-			continue;
-
-		ret = component->driver->compress_ops->ack(
-			component, cstream, bytes);
-		if (ret < 0)
-			goto err;
-	}
-
+	ret = snd_soc_component_compr_ack(cstream, bytes);
 err:
 	mutex_unlock(&rtd->card->pcm_mutex);
 	return ret;
-- 
2.17.1


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

* [PATCH 17/24] ASoC: soc-component: add snd_soc_component_compr_pointer()
  2020-06-01  1:35 [PATCH 00/24] ASoC: soc-component: collect component functions Kuninori Morimoto
                   ` (15 preceding siblings ...)
  2020-06-01  1:37 ` [PATCH 16/24] ASoC: soc-component: add snd_soc_component_compr_ack() Kuninori Morimoto
@ 2020-06-01  1:37 ` Kuninori Morimoto
  2020-06-03 17:35   ` Ranjani Sridharan
  2020-06-01  1:37 ` [PATCH 18/24] ASoC: soc-component: add snd_soc_component_compr_copy() Kuninori Morimoto
                   ` (6 subsequent siblings)
  23 siblings, 1 reply; 37+ messages in thread
From: Kuninori Morimoto @ 2020-06-01  1:37 UTC (permalink / raw)
  To: Mark Brown; +Cc: Linux-ALSA

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

component related function should be implemented at
soc-component.c.
This patch adds snd_soc_component_compr_pointer().

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

diff --git a/include/sound/soc-component.h b/include/sound/soc-component.h
index da1d89d0b476..0e05aedaee05 100644
--- a/include/sound/soc-component.h
+++ b/include/sound/soc-component.h
@@ -450,6 +450,8 @@ int snd_soc_component_compr_get_caps(struct snd_compr_stream *cstream,
 int snd_soc_component_compr_get_codec_caps(struct snd_compr_stream *cstream,
 					   struct snd_compr_codec_caps *codec);
 int snd_soc_component_compr_ack(struct snd_compr_stream *cstream, size_t bytes);
+int snd_soc_component_compr_pointer(struct snd_compr_stream *cstream,
+				    struct snd_compr_tstamp *tstamp);
 
 int snd_soc_pcm_component_pointer(struct snd_pcm_substream *substream);
 int snd_soc_pcm_component_ioctl(struct snd_pcm_substream *substream,
diff --git a/sound/soc/soc-component.c b/sound/soc/soc-component.c
index 8f223dd060e8..8a24d6f3572a 100644
--- a/sound/soc/soc-component.c
+++ b/sound/soc/soc-component.c
@@ -549,6 +549,27 @@ int snd_soc_component_compr_ack(struct snd_compr_stream *cstream, size_t bytes)
 }
 EXPORT_SYMBOL_GPL(snd_soc_component_compr_ack);
 
+int snd_soc_component_compr_pointer(struct snd_compr_stream *cstream,
+				    struct snd_compr_tstamp *tstamp)
+{
+	struct snd_soc_pcm_runtime *rtd = cstream->private_data;
+	struct snd_soc_component *component;
+	int i, ret;
+
+	for_each_rtd_components(rtd, i, component) {
+		if (component->driver->compress_ops &&
+		    component->driver->compress_ops->pointer) {
+			ret = component->driver->compress_ops->pointer(
+				component, cstream, tstamp);
+			if (ret < 0)
+				return soc_component_ret(component, ret);
+		}
+	}
+
+	return 0;
+}
+EXPORT_SYMBOL_GPL(snd_soc_component_compr_pointer);
+
 int snd_soc_pcm_component_pointer(struct snd_pcm_substream *substream)
 {
 	struct snd_soc_pcm_runtime *rtd = substream->private_data;
diff --git a/sound/soc/soc-compress.c b/sound/soc/soc-compress.c
index 4798c20bd9b5..39fe2c58fa88 100644
--- a/sound/soc/soc-compress.c
+++ b/sound/soc/soc-compress.c
@@ -497,8 +497,7 @@ static int soc_compr_pointer(struct snd_compr_stream *cstream,
 			     struct snd_compr_tstamp *tstamp)
 {
 	struct snd_soc_pcm_runtime *rtd = cstream->private_data;
-	struct snd_soc_component *component;
-	int i, ret = 0;
+	int ret;
 	struct snd_soc_dai *cpu_dai = asoc_rtd_to_cpu(rtd, 0);
 
 	mutex_lock_nested(&rtd->card->pcm_mutex, rtd->card->pcm_subclass);
@@ -507,15 +506,7 @@ static int soc_compr_pointer(struct snd_compr_stream *cstream,
 	if (ret < 0)
 		goto out;
 
-	for_each_rtd_components(rtd, i, component) {
-		if (!component->driver->compress_ops ||
-		    !component->driver->compress_ops->pointer)
-			continue;
-
-		ret = component->driver->compress_ops->pointer(
-			component, cstream, tstamp);
-		break;
-	}
+	ret = snd_soc_component_compr_pointer(cstream, tstamp);
 out:
 	mutex_unlock(&rtd->card->pcm_mutex);
 	return ret;
-- 
2.17.1


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

* [PATCH 18/24] ASoC: soc-component: add snd_soc_component_compr_copy()
  2020-06-01  1:35 [PATCH 00/24] ASoC: soc-component: collect component functions Kuninori Morimoto
                   ` (16 preceding siblings ...)
  2020-06-01  1:37 ` [PATCH 17/24] ASoC: soc-component: add snd_soc_component_compr_pointer() Kuninori Morimoto
@ 2020-06-01  1:37 ` Kuninori Morimoto
  2020-06-03 17:39   ` Ranjani Sridharan
  2020-06-01  1:37 ` [PATCH 19/24] ASoC: soc-component: add snd_soc_component_compr_set_metadata() Kuninori Morimoto
                   ` (5 subsequent siblings)
  23 siblings, 1 reply; 37+ messages in thread
From: Kuninori Morimoto @ 2020-06-01  1:37 UTC (permalink / raw)
  To: Mark Brown; +Cc: Linux-ALSA


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

component related function should be implemented at
soc-component.c.
This patch adds snd_soc_component_compr_copy().

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

diff --git a/include/sound/soc-component.h b/include/sound/soc-component.h
index 0e05aedaee05..255014fe6264 100644
--- a/include/sound/soc-component.h
+++ b/include/sound/soc-component.h
@@ -452,6 +452,8 @@ int snd_soc_component_compr_get_codec_caps(struct snd_compr_stream *cstream,
 int snd_soc_component_compr_ack(struct snd_compr_stream *cstream, size_t bytes);
 int snd_soc_component_compr_pointer(struct snd_compr_stream *cstream,
 				    struct snd_compr_tstamp *tstamp);
+int snd_soc_component_compr_copy(struct snd_compr_stream *cstream,
+				 char __user *buf, size_t count);
 
 int snd_soc_pcm_component_pointer(struct snd_pcm_substream *substream);
 int snd_soc_pcm_component_ioctl(struct snd_pcm_substream *substream,
diff --git a/sound/soc/soc-component.c b/sound/soc/soc-component.c
index 8a24d6f3572a..6a47255767a0 100644
--- a/sound/soc/soc-component.c
+++ b/sound/soc/soc-component.c
@@ -570,6 +570,27 @@ int snd_soc_component_compr_pointer(struct snd_compr_stream *cstream,
 }
 EXPORT_SYMBOL_GPL(snd_soc_component_compr_pointer);
 
+int snd_soc_component_compr_copy(struct snd_compr_stream *cstream,
+				 char __user *buf, size_t count)
+{
+	struct snd_soc_pcm_runtime *rtd = cstream->private_data;
+	struct snd_soc_component *component;
+	int i, ret;
+
+	for_each_rtd_components(rtd, i, component) {
+		if (component->driver->compress_ops &&
+		    component->driver->compress_ops->copy) {
+			ret = component->driver->compress_ops->copy(
+				component, cstream, buf, count);
+			if (ret < 0)
+				return soc_component_ret(component, ret);
+		}
+	}
+
+	return 0;
+}
+EXPORT_SYMBOL_GPL(snd_soc_component_compr_copy);
+
 int snd_soc_pcm_component_pointer(struct snd_pcm_substream *substream)
 {
 	struct snd_soc_pcm_runtime *rtd = substream->private_data;
diff --git a/sound/soc/soc-compress.c b/sound/soc/soc-compress.c
index 39fe2c58fa88..7e05f263b655 100644
--- a/sound/soc/soc-compress.c
+++ b/sound/soc/soc-compress.c
@@ -516,20 +516,11 @@ static int soc_compr_copy(struct snd_compr_stream *cstream,
 			  char __user *buf, size_t count)
 {
 	struct snd_soc_pcm_runtime *rtd = cstream->private_data;
-	struct snd_soc_component *component;
-	int i, ret = 0;
+	int ret;
 
 	mutex_lock_nested(&rtd->card->pcm_mutex, rtd->card->pcm_subclass);
 
-	for_each_rtd_components(rtd, i, component) {
-		if (!component->driver->compress_ops ||
-		    !component->driver->compress_ops->copy)
-			continue;
-
-		ret = component->driver->compress_ops->copy(
-			component, cstream, buf, count);
-		break;
-	}
+	ret = snd_soc_component_compr_copy(cstream, buf, count);
 
 	mutex_unlock(&rtd->card->pcm_mutex);
 	return ret;
-- 
2.17.1


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

* [PATCH 19/24] ASoC: soc-component: add snd_soc_component_compr_set_metadata()
  2020-06-01  1:35 [PATCH 00/24] ASoC: soc-component: collect component functions Kuninori Morimoto
                   ` (17 preceding siblings ...)
  2020-06-01  1:37 ` [PATCH 18/24] ASoC: soc-component: add snd_soc_component_compr_copy() Kuninori Morimoto
@ 2020-06-01  1:37 ` Kuninori Morimoto
  2020-06-03 17:40   ` Ranjani Sridharan
  2020-06-01  1:37 ` [PATCH 20/24] ASoC: soc-component: add snd_soc_component_compr_get_metadata() Kuninori Morimoto
                   ` (4 subsequent siblings)
  23 siblings, 1 reply; 37+ messages in thread
From: Kuninori Morimoto @ 2020-06-01  1:37 UTC (permalink / raw)
  To: Mark Brown; +Cc: Linux-ALSA

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

component related function should be implemented at
soc-component.c.
This patch adds snd_soc_component_compr_set_metadata().

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

diff --git a/include/sound/soc-component.h b/include/sound/soc-component.h
index 255014fe6264..ce1df96bb274 100644
--- a/include/sound/soc-component.h
+++ b/include/sound/soc-component.h
@@ -454,6 +454,8 @@ int snd_soc_component_compr_pointer(struct snd_compr_stream *cstream,
 				    struct snd_compr_tstamp *tstamp);
 int snd_soc_component_compr_copy(struct snd_compr_stream *cstream,
 				 char __user *buf, size_t count);
+int snd_soc_component_compr_set_metadata(struct snd_compr_stream *cstream,
+					 struct snd_compr_metadata *metadata);
 
 int snd_soc_pcm_component_pointer(struct snd_pcm_substream *substream);
 int snd_soc_pcm_component_ioctl(struct snd_pcm_substream *substream,
diff --git a/sound/soc/soc-component.c b/sound/soc/soc-component.c
index 6a47255767a0..1ac353cf48c5 100644
--- a/sound/soc/soc-component.c
+++ b/sound/soc/soc-component.c
@@ -591,6 +591,27 @@ int snd_soc_component_compr_copy(struct snd_compr_stream *cstream,
 }
 EXPORT_SYMBOL_GPL(snd_soc_component_compr_copy);
 
+int snd_soc_component_compr_set_metadata(struct snd_compr_stream *cstream,
+					 struct snd_compr_metadata *metadata)
+{
+	struct snd_soc_pcm_runtime *rtd = cstream->private_data;
+	struct snd_soc_component *component;
+	int i, ret;
+
+	for_each_rtd_components(rtd, i, component) {
+		if (component->driver->compress_ops &&
+		    component->driver->compress_ops->set_metadata) {
+			ret = component->driver->compress_ops->set_metadata(
+				component, cstream, metadata);
+			if (ret < 0)
+				return soc_component_ret(component, ret);
+		}
+	}
+
+	return 0;
+}
+EXPORT_SYMBOL_GPL(snd_soc_component_compr_set_metadata);
+
 int snd_soc_pcm_component_pointer(struct snd_pcm_substream *substream)
 {
 	struct snd_soc_pcm_runtime *rtd = substream->private_data;
diff --git a/sound/soc/soc-compress.c b/sound/soc/soc-compress.c
index 7e05f263b655..62925adb1042 100644
--- a/sound/soc/soc-compress.c
+++ b/sound/soc/soc-compress.c
@@ -530,26 +530,16 @@ static int soc_compr_set_metadata(struct snd_compr_stream *cstream,
 				  struct snd_compr_metadata *metadata)
 {
 	struct snd_soc_pcm_runtime *rtd = cstream->private_data;
-	struct snd_soc_component *component;
 	struct snd_soc_dai *cpu_dai = asoc_rtd_to_cpu(rtd, 0);
-	int i, ret;
+	int 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 ||
-		    !component->driver->compress_ops->set_metadata)
-			continue;
-
-		ret = component->driver->compress_ops->set_metadata(
-			component, cstream, metadata);
-		if (ret < 0)
-			return ret;
-	}
+	ret = snd_soc_component_compr_set_metadata(cstream, metadata);
 
-	return 0;
+	return ret;
 }
 
 static int soc_compr_get_metadata(struct snd_compr_stream *cstream,
-- 
2.17.1


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

* [PATCH 20/24] ASoC: soc-component: add snd_soc_component_compr_get_metadata()
  2020-06-01  1:35 [PATCH 00/24] ASoC: soc-component: collect component functions Kuninori Morimoto
                   ` (18 preceding siblings ...)
  2020-06-01  1:37 ` [PATCH 19/24] ASoC: soc-component: add snd_soc_component_compr_set_metadata() Kuninori Morimoto
@ 2020-06-01  1:37 ` Kuninori Morimoto
  2020-06-03 17:41   ` Ranjani Sridharan
  2020-06-01  1:37 ` [PATCH 21/24] ASoC: soc-component: add snd_soc_component_init() Kuninori Morimoto
                   ` (3 subsequent siblings)
  23 siblings, 1 reply; 37+ messages in thread
From: Kuninori Morimoto @ 2020-06-01  1:37 UTC (permalink / raw)
  To: Mark Brown; +Cc: Linux-ALSA

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

component related function should be implemented at
soc-component.c.
This patch adds snd_soc_component_compr_get_metadata().

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

diff --git a/include/sound/soc-component.h b/include/sound/soc-component.h
index ce1df96bb274..5b8a4d847089 100644
--- a/include/sound/soc-component.h
+++ b/include/sound/soc-component.h
@@ -456,6 +456,8 @@ int snd_soc_component_compr_copy(struct snd_compr_stream *cstream,
 				 char __user *buf, size_t count);
 int snd_soc_component_compr_set_metadata(struct snd_compr_stream *cstream,
 					 struct snd_compr_metadata *metadata);
+int snd_soc_component_compr_get_metadata(struct snd_compr_stream *cstream,
+					 struct snd_compr_metadata *metadata);
 
 int snd_soc_pcm_component_pointer(struct snd_pcm_substream *substream);
 int snd_soc_pcm_component_ioctl(struct snd_pcm_substream *substream,
diff --git a/sound/soc/soc-component.c b/sound/soc/soc-component.c
index 1ac353cf48c5..45a5c496454a 100644
--- a/sound/soc/soc-component.c
+++ b/sound/soc/soc-component.c
@@ -612,6 +612,24 @@ int snd_soc_component_compr_set_metadata(struct snd_compr_stream *cstream,
 }
 EXPORT_SYMBOL_GPL(snd_soc_component_compr_set_metadata);
 
+int snd_soc_component_compr_get_metadata(struct snd_compr_stream *cstream,
+					 struct snd_compr_metadata *metadata)
+{
+	struct snd_soc_pcm_runtime *rtd = cstream->private_data;
+	struct snd_soc_component *component;
+	int i;
+
+	for_each_rtd_components(rtd, i, component) {
+		if (component->driver->compress_ops &&
+		    component->driver->compress_ops->get_metadata)
+			return component->driver->compress_ops->get_metadata(
+				component, cstream, metadata);
+	}
+
+	return 0;
+}
+EXPORT_SYMBOL_GPL(snd_soc_component_compr_get_metadata);
+
 int snd_soc_pcm_component_pointer(struct snd_pcm_substream *substream)
 {
 	struct snd_soc_pcm_runtime *rtd = substream->private_data;
diff --git a/sound/soc/soc-compress.c b/sound/soc/soc-compress.c
index 62925adb1042..475722adb2a5 100644
--- a/sound/soc/soc-compress.c
+++ b/sound/soc/soc-compress.c
@@ -546,24 +546,16 @@ static int soc_compr_get_metadata(struct snd_compr_stream *cstream,
 				  struct snd_compr_metadata *metadata)
 {
 	struct snd_soc_pcm_runtime *rtd = cstream->private_data;
-	struct snd_soc_component *component;
 	struct snd_soc_dai *cpu_dai = asoc_rtd_to_cpu(rtd, 0);
-	int i, ret;
+	int 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 ||
-		    !component->driver->compress_ops->get_metadata)
-			continue;
+	ret = snd_soc_component_compr_get_metadata(cstream, metadata);
 
-		return component->driver->compress_ops->get_metadata(
-			component, cstream, metadata);
-	}
-
-	return 0;
+	return ret;
 }
 
 /* ASoC Compress operations */
-- 
2.17.1


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

* [PATCH 21/24] ASoC: soc-component: add snd_soc_component_init()
  2020-06-01  1:35 [PATCH 00/24] ASoC: soc-component: collect component functions Kuninori Morimoto
                   ` (19 preceding siblings ...)
  2020-06-01  1:37 ` [PATCH 20/24] ASoC: soc-component: add snd_soc_component_compr_get_metadata() Kuninori Morimoto
@ 2020-06-01  1:37 ` Kuninori Morimoto
  2020-06-01  1:37 ` [PATCH 22/24] ASoC: soc-component: merge soc-io.c into soc-component.c Kuninori Morimoto
                   ` (2 subsequent siblings)
  23 siblings, 0 replies; 37+ messages in thread
From: Kuninori Morimoto @ 2020-06-01  1:37 UTC (permalink / raw)
  To: Mark Brown; +Cc: Linux-ALSA


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

we wantn't to directly access to component related parameter
as much as possible to keep encapsulation.
This patch adds snd_soc_component_init() for it.

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

diff --git a/include/sound/soc-component.h b/include/sound/soc-component.h
index 5b8a4d847089..8edc5ee5bd16 100644
--- a/include/sound/soc-component.h
+++ b/include/sound/soc-component.h
@@ -327,6 +327,9 @@ static inline int snd_soc_component_cache_sync(
 int snd_soc_component_initialize(struct snd_soc_component *component,
 				 const struct snd_soc_component_driver *driver,
 				 struct device *dev, const char *name);
+void snd_soc_component_set_aux(struct snd_soc_component *component,
+			       struct snd_soc_aux_dev *aux);
+int snd_soc_component_init(struct snd_soc_component *component);
 
 /* component IO */
 int snd_soc_component_read(struct snd_soc_component *component,
diff --git a/sound/soc/soc-component.c b/sound/soc/soc-component.c
index 45a5c496454a..f1707b05505e 100644
--- a/sound/soc/soc-component.c
+++ b/sound/soc/soc-component.c
@@ -46,6 +46,22 @@ int snd_soc_component_initialize(struct snd_soc_component *component,
 	return 0;
 }
 
+void snd_soc_component_set_aux(struct snd_soc_component *component,
+			       struct snd_soc_aux_dev *aux)
+{
+	component->init = (aux) ? aux->init : NULL;
+}
+
+int snd_soc_component_init(struct snd_soc_component *component)
+{
+	int ret = 0;
+
+	if (component->init)
+		ret = component->init(component);
+
+	return soc_component_ret(component, ret);
+}
+
 /**
  * snd_soc_component_set_sysclk - configure COMPONENT system or master clock.
  * @component: COMPONENT
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index 7e22facf14ea..73f2decfc2fe 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -1207,15 +1207,14 @@ static int soc_probe_component(struct snd_soc_card *card,
 	     component->name);
 	probed = 1;
 
-	/* machine specific init */
-	if (component->init) {
-		ret = component->init(component);
-		if (ret < 0) {
-			dev_err(component->dev,
-				"Failed to do machine specific init %d\n", ret);
-			goto err_probe;
-		}
-	}
+	/*
+	 * machine specific init
+	 * see
+	 *	snd_soc_component_set_aux()
+	 */
+	ret = snd_soc_component_init(component);
+	if (ret < 0)
+		goto err_probe;
 
 	ret = snd_soc_add_component_controls(component,
 					     component->driver->controls,
@@ -1329,7 +1328,8 @@ static void soc_unbind_aux_dev(struct snd_soc_card *card)
 	struct snd_soc_component *component, *_component;
 
 	for_each_card_auxs_safe(card, component, _component) {
-		component->init = NULL;
+		/* for snd_soc_component_init() */
+		snd_soc_component_set_aux(component, NULL);
 		list_del(&component->card_aux_list);
 	}
 }
@@ -1346,7 +1346,8 @@ static int soc_bind_aux_dev(struct snd_soc_card *card)
 		if (!component)
 			return -EPROBE_DEFER;
 
-		component->init = aux->init;
+		/* for snd_soc_component_init() */
+		snd_soc_component_set_aux(component, aux);
 		/* see for_each_card_auxs */
 		list_add(&component->card_aux_list, &card->aux_comp_list);
 	}
-- 
2.17.1


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

* [PATCH 22/24] ASoC: soc-component: merge soc-io.c into soc-component.c
  2020-06-01  1:35 [PATCH 00/24] ASoC: soc-component: collect component functions Kuninori Morimoto
                   ` (20 preceding siblings ...)
  2020-06-01  1:37 ` [PATCH 21/24] ASoC: soc-component: add snd_soc_component_init() Kuninori Morimoto
@ 2020-06-01  1:37 ` Kuninori Morimoto
  2020-06-01  1:37 ` [PATCH 23/24] ASoC: soc-component: merge soc_pcm_trigger_start/stop() Kuninori Morimoto
  2020-06-01  1:37 ` [PATCH 24/24] ASoC: soc-component: tidyup Copyright Kuninori Morimoto
  23 siblings, 0 replies; 37+ messages in thread
From: Kuninori Morimoto @ 2020-06-01  1:37 UTC (permalink / raw)
  To: Mark Brown; +Cc: Linux-ALSA

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

soc-io.c has snd_soc_component_xxx() functions for I/O.
We have soc-componennt.c for it.
Let's merge soc-io.c into soc-component.c

By this patch, original soc-io.c functions start to use
soc_component_err() when error case.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
 sound/soc/Makefile        |   2 +-
 sound/soc/soc-component.c | 194 ++++++++++++++++++++++++++++++++++++
 sound/soc/soc-io.c        | 202 --------------------------------------
 3 files changed, 195 insertions(+), 203 deletions(-)
 delete mode 100644 sound/soc/soc-io.c

diff --git a/sound/soc/Makefile b/sound/soc/Makefile
index 7f1747518e79..ddbac3a2169f 100644
--- a/sound/soc/Makefile
+++ b/sound/soc/Makefile
@@ -1,6 +1,6 @@
 # SPDX-License-Identifier: GPL-2.0
 snd-soc-core-objs := soc-core.o soc-dapm.o soc-jack.o soc-utils.o soc-dai.o soc-component.o
-snd-soc-core-objs += soc-pcm.o soc-io.o soc-devres.o soc-ops.o soc-link.o soc-card.o
+snd-soc-core-objs += soc-pcm.o soc-devres.o soc-ops.o soc-link.o soc-card.o
 snd-soc-core-$(CONFIG_SND_SOC_COMPRESS) += soc-compress.o
 
 ifneq ($(CONFIG_SND_SOC_TOPOLOGY),)
diff --git a/sound/soc/soc-component.c b/sound/soc/soc-component.c
index f1707b05505e..c7394adda8f4 100644
--- a/sound/soc/soc-component.c
+++ b/sound/soc/soc-component.c
@@ -2,7 +2,10 @@
 //
 // soc-component.c
 //
+// Copyright 2009-2011 Wolfson Microelectronics PLC.
 // Copyright (C) 2019 Renesas Electronics Corp.
+//
+// Mark Brown <broonie@opensource.wolfsonmicro.com>
 // Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
 //
 #include <linux/module.h>
@@ -646,6 +649,197 @@ int snd_soc_component_compr_get_metadata(struct snd_compr_stream *cstream,
 }
 EXPORT_SYMBOL_GPL(snd_soc_component_compr_get_metadata);
 
+/**
+ * snd_soc_component_read() - Read register value
+ * @component: Component to read from
+ * @reg: Register to read
+ * @val: Pointer to where the read value is stored
+ *
+ * Return: 0 on success, a negative error code otherwise.
+ */
+int snd_soc_component_read(struct snd_soc_component *component,
+			   unsigned int reg, unsigned int *val)
+{
+	int ret;
+
+	if (component->regmap)
+		ret = regmap_read(component->regmap, reg, val);
+	else if (component->driver->read) {
+		*val = component->driver->read(component, reg);
+		ret = 0;
+	}
+	else
+		ret = -EIO;
+
+	return soc_component_ret(component, ret);
+}
+EXPORT_SYMBOL_GPL(snd_soc_component_read);
+
+unsigned int snd_soc_component_read32(struct snd_soc_component *component,
+				      unsigned int reg)
+{
+	unsigned int val;
+	int ret;
+
+	ret = snd_soc_component_read(component, reg, &val);
+	if (ret < 0)
+		return soc_component_ret(component, -1);
+
+	return val;
+}
+EXPORT_SYMBOL_GPL(snd_soc_component_read32);
+
+/**
+ * snd_soc_component_write() - Write register value
+ * @component: Component to write to
+ * @reg: Register to write
+ * @val: Value to write to the register
+ *
+ * Return: 0 on success, a negative error code otherwise.
+ */
+int snd_soc_component_write(struct snd_soc_component *component,
+			    unsigned int reg, unsigned int val)
+{
+	int ret = -EIO;
+
+	if (component->regmap)
+		ret = regmap_write(component->regmap, reg, val);
+	else if (component->driver->write)
+		ret = component->driver->write(component, reg, val);
+
+	return soc_component_ret(component, ret);
+}
+EXPORT_SYMBOL_GPL(snd_soc_component_write);
+
+static int snd_soc_component_update_bits_legacy(
+	struct snd_soc_component *component, unsigned int reg,
+	unsigned int mask, unsigned int val, bool *change)
+{
+	unsigned int old, new;
+	int ret;
+
+	mutex_lock(&component->io_mutex);
+
+	ret = snd_soc_component_read(component, reg, &old);
+	if (ret < 0)
+		goto out_unlock;
+
+	new = (old & ~mask) | (val & mask);
+	*change = old != new;
+	if (*change)
+		ret = snd_soc_component_write(component, reg, new);
+out_unlock:
+	mutex_unlock(&component->io_mutex);
+
+	return soc_component_ret(component, ret);
+}
+
+/**
+ * snd_soc_component_update_bits() - Perform read/modify/write cycle
+ * @component: Component to update
+ * @reg: Register to update
+ * @mask: Mask that specifies which bits to update
+ * @val: New value for the bits specified by mask
+ *
+ * Return: 1 if the operation was successful and the value of the register
+ * changed, 0 if the operation was successful, but the value did not change.
+ * Returns a negative error code otherwise.
+ */
+int snd_soc_component_update_bits(struct snd_soc_component *component,
+				  unsigned int reg, unsigned int mask, unsigned int val)
+{
+	bool change;
+	int ret;
+
+	if (component->regmap)
+		ret = regmap_update_bits_check(component->regmap, reg, mask,
+					       val, &change);
+	else
+		ret = snd_soc_component_update_bits_legacy(component, reg,
+							   mask, val, &change);
+
+	if (ret < 0)
+		return soc_component_ret(component, ret);
+	return change;
+}
+EXPORT_SYMBOL_GPL(snd_soc_component_update_bits);
+
+/**
+ * snd_soc_component_update_bits_async() - Perform asynchronous
+ *  read/modify/write cycle
+ * @component: Component to update
+ * @reg: Register to update
+ * @mask: Mask that specifies which bits to update
+ * @val: New value for the bits specified by mask
+ *
+ * This function is similar to snd_soc_component_update_bits(), but the update
+ * operation is scheduled asynchronously. This means it may not be completed
+ * when the function returns. To make sure that all scheduled updates have been
+ * completed snd_soc_component_async_complete() must be called.
+ *
+ * Return: 1 if the operation was successful and the value of the register
+ * changed, 0 if the operation was successful, but the value did not change.
+ * Returns a negative error code otherwise.
+ */
+int snd_soc_component_update_bits_async(struct snd_soc_component *component,
+					unsigned int reg, unsigned int mask, unsigned int val)
+{
+	bool change;
+	int ret;
+
+	if (component->regmap)
+		ret = regmap_update_bits_check_async(component->regmap, reg,
+						     mask, val, &change);
+	else
+		ret = snd_soc_component_update_bits_legacy(component, reg,
+							   mask, val, &change);
+
+	if (ret < 0)
+		return soc_component_ret(component, ret);
+	return change;
+}
+EXPORT_SYMBOL_GPL(snd_soc_component_update_bits_async);
+
+/**
+ * snd_soc_component_async_complete() - Ensure asynchronous I/O has completed
+ * @component: Component for which to wait
+ *
+ * This function blocks until all asynchronous I/O which has previously been
+ * scheduled using snd_soc_component_update_bits_async() has completed.
+ */
+void snd_soc_component_async_complete(struct snd_soc_component *component)
+{
+	if (component->regmap)
+		regmap_async_complete(component->regmap);
+}
+EXPORT_SYMBOL_GPL(snd_soc_component_async_complete);
+
+/**
+ * snd_soc_component_test_bits - Test register for change
+ * @component: component
+ * @reg: Register to test
+ * @mask: Mask that specifies which bits to test
+ * @value: Value to test against
+ *
+ * Tests a register with a new value and checks if the new value is
+ * different from the old value.
+ *
+ * Return: 1 for change, otherwise 0.
+ */
+int snd_soc_component_test_bits(struct snd_soc_component *component,
+				unsigned int reg, unsigned int mask, unsigned int value)
+{
+	unsigned int old, new;
+	int ret;
+
+	ret = snd_soc_component_read(component, reg, &old);
+	if (ret < 0)
+		return soc_component_ret(component, ret);
+	new = (old & ~mask) | value;
+	return old != new;
+}
+EXPORT_SYMBOL_GPL(snd_soc_component_test_bits);
+
 int snd_soc_pcm_component_pointer(struct snd_pcm_substream *substream)
 {
 	struct snd_soc_pcm_runtime *rtd = substream->private_data;
diff --git a/sound/soc/soc-io.c b/sound/soc/soc-io.c
deleted file mode 100644
index 1ff9175e9d5e..000000000000
--- a/sound/soc/soc-io.c
+++ /dev/null
@@ -1,202 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0+
-//
-// soc-io.c  --  ASoC register I/O helpers
-//
-// Copyright 2009-2011 Wolfson Microelectronics PLC.
-//
-// Author: Mark Brown <broonie@opensource.wolfsonmicro.com>
-
-#include <linux/i2c.h>
-#include <linux/spi/spi.h>
-#include <linux/regmap.h>
-#include <linux/export.h>
-#include <sound/soc.h>
-
-/**
- * snd_soc_component_read() - Read register value
- * @component: Component to read from
- * @reg: Register to read
- * @val: Pointer to where the read value is stored
- *
- * Return: 0 on success, a negative error code otherwise.
- */
-int snd_soc_component_read(struct snd_soc_component *component,
-	unsigned int reg, unsigned int *val)
-{
-	int ret;
-
-	if (component->regmap)
-		ret = regmap_read(component->regmap, reg, val);
-	else if (component->driver->read) {
-		*val = component->driver->read(component, reg);
-		ret = 0;
-	}
-	else
-		ret = -EIO;
-
-	return ret;
-}
-EXPORT_SYMBOL_GPL(snd_soc_component_read);
-
-unsigned int snd_soc_component_read32(struct snd_soc_component *component,
-				      unsigned int reg)
-{
-	unsigned int val;
-	int ret;
-
-	ret = snd_soc_component_read(component, reg, &val);
-	if (ret < 0)
-		return -1;
-
-	return val;
-}
-EXPORT_SYMBOL_GPL(snd_soc_component_read32);
-
-/**
- * snd_soc_component_write() - Write register value
- * @component: Component to write to
- * @reg: Register to write
- * @val: Value to write to the register
- *
- * Return: 0 on success, a negative error code otherwise.
- */
-int snd_soc_component_write(struct snd_soc_component *component,
-	unsigned int reg, unsigned int val)
-{
-	if (component->regmap)
-		return regmap_write(component->regmap, reg, val);
-	else if (component->driver->write)
-		return component->driver->write(component, reg, val);
-	else
-		return -EIO;
-}
-EXPORT_SYMBOL_GPL(snd_soc_component_write);
-
-static int snd_soc_component_update_bits_legacy(
-	struct snd_soc_component *component, unsigned int reg,
-	unsigned int mask, unsigned int val, bool *change)
-{
-	unsigned int old, new;
-	int ret;
-
-	mutex_lock(&component->io_mutex);
-
-	ret = snd_soc_component_read(component, reg, &old);
-	if (ret < 0)
-		goto out_unlock;
-
-	new = (old & ~mask) | (val & mask);
-	*change = old != new;
-	if (*change)
-		ret = snd_soc_component_write(component, reg, new);
-out_unlock:
-	mutex_unlock(&component->io_mutex);
-
-	return ret;
-}
-
-/**
- * snd_soc_component_update_bits() - Perform read/modify/write cycle
- * @component: Component to update
- * @reg: Register to update
- * @mask: Mask that specifies which bits to update
- * @val: New value for the bits specified by mask
- *
- * Return: 1 if the operation was successful and the value of the register
- * changed, 0 if the operation was successful, but the value did not change.
- * Returns a negative error code otherwise.
- */
-int snd_soc_component_update_bits(struct snd_soc_component *component,
-	unsigned int reg, unsigned int mask, unsigned int val)
-{
-	bool change;
-	int ret;
-
-	if (component->regmap)
-		ret = regmap_update_bits_check(component->regmap, reg, mask,
-			val, &change);
-	else
-		ret = snd_soc_component_update_bits_legacy(component, reg,
-			mask, val, &change);
-
-	if (ret < 0)
-		return ret;
-	return change;
-}
-EXPORT_SYMBOL_GPL(snd_soc_component_update_bits);
-
-/**
- * snd_soc_component_update_bits_async() - Perform asynchronous
- *  read/modify/write cycle
- * @component: Component to update
- * @reg: Register to update
- * @mask: Mask that specifies which bits to update
- * @val: New value for the bits specified by mask
- *
- * This function is similar to snd_soc_component_update_bits(), but the update
- * operation is scheduled asynchronously. This means it may not be completed
- * when the function returns. To make sure that all scheduled updates have been
- * completed snd_soc_component_async_complete() must be called.
- *
- * Return: 1 if the operation was successful and the value of the register
- * changed, 0 if the operation was successful, but the value did not change.
- * Returns a negative error code otherwise.
- */
-int snd_soc_component_update_bits_async(struct snd_soc_component *component,
-	unsigned int reg, unsigned int mask, unsigned int val)
-{
-	bool change;
-	int ret;
-
-	if (component->regmap)
-		ret = regmap_update_bits_check_async(component->regmap, reg,
-			mask, val, &change);
-	else
-		ret = snd_soc_component_update_bits_legacy(component, reg,
-			mask, val, &change);
-
-	if (ret < 0)
-		return ret;
-	return change;
-}
-EXPORT_SYMBOL_GPL(snd_soc_component_update_bits_async);
-
-/**
- * snd_soc_component_async_complete() - Ensure asynchronous I/O has completed
- * @component: Component for which to wait
- *
- * This function blocks until all asynchronous I/O which has previously been
- * scheduled using snd_soc_component_update_bits_async() has completed.
- */
-void snd_soc_component_async_complete(struct snd_soc_component *component)
-{
-	if (component->regmap)
-		regmap_async_complete(component->regmap);
-}
-EXPORT_SYMBOL_GPL(snd_soc_component_async_complete);
-
-/**
- * snd_soc_component_test_bits - Test register for change
- * @component: component
- * @reg: Register to test
- * @mask: Mask that specifies which bits to test
- * @value: Value to test against
- *
- * Tests a register with a new value and checks if the new value is
- * different from the old value.
- *
- * Return: 1 for change, otherwise 0.
- */
-int snd_soc_component_test_bits(struct snd_soc_component *component,
-	unsigned int reg, unsigned int mask, unsigned int value)
-{
-	unsigned int old, new;
-	int ret;
-
-	ret = snd_soc_component_read(component, reg, &old);
-	if (ret < 0)
-		return ret;
-	new = (old & ~mask) | value;
-	return old != new;
-}
-EXPORT_SYMBOL_GPL(snd_soc_component_test_bits);
-- 
2.17.1


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

* [PATCH 23/24] ASoC: soc-component: merge soc_pcm_trigger_start/stop()
  2020-06-01  1:35 [PATCH 00/24] ASoC: soc-component: collect component functions Kuninori Morimoto
                   ` (21 preceding siblings ...)
  2020-06-01  1:37 ` [PATCH 22/24] ASoC: soc-component: merge soc-io.c into soc-component.c Kuninori Morimoto
@ 2020-06-01  1:37 ` Kuninori Morimoto
  2020-06-01  1:37 ` [PATCH 24/24] ASoC: soc-component: tidyup Copyright Kuninori Morimoto
  23 siblings, 0 replies; 37+ messages in thread
From: Kuninori Morimoto @ 2020-06-01  1:37 UTC (permalink / raw)
  To: Mark Brown; +Cc: Linux-ALSA


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

Now, soc_pcm_trigger_start/stop() are simple enough.
Let's merge these into soc_pcm_trigger().

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

diff --git a/sound/soc/soc-pcm.c b/sound/soc/soc-pcm.c
index a68c9b0f2b8a..e36d6eec19e8 100644
--- a/sound/soc/soc-pcm.c
+++ b/sound/soc/soc-pcm.c
@@ -1075,57 +1075,37 @@ static int soc_pcm_hw_free(struct snd_pcm_substream *substream)
 	return 0;
 }
 
-static int soc_pcm_trigger_start(struct snd_pcm_substream *substream, int cmd)
-{
-	int ret;
-
-	ret = snd_soc_link_trigger(substream, cmd);
-	if (ret < 0)
-		return ret;
-
-	ret = snd_soc_pcm_component_trigger(substream, cmd);
-	if (ret < 0)
-		return ret;
-
-	return snd_soc_pcm_dai_trigger(substream, cmd);
-}
-
-static int soc_pcm_trigger_stop(struct snd_pcm_substream *substream, int cmd)
-{
-	int ret;
-
-	ret = snd_soc_pcm_dai_trigger(substream, cmd);
-	if (ret < 0)
-		return ret;
-
-	ret = snd_soc_pcm_component_trigger(substream, cmd);
-	if (ret < 0)
-		return ret;
-
-	ret = snd_soc_link_trigger(substream, cmd);
-	if (ret < 0)
-		return ret;
-
-	return 0;
-}
-
 static int soc_pcm_trigger(struct snd_pcm_substream *substream, int cmd)
 {
-	int ret;
+	int ret = -EINVAL;
 
 	switch (cmd) {
 	case SNDRV_PCM_TRIGGER_START:
 	case SNDRV_PCM_TRIGGER_RESUME:
 	case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
-		ret = soc_pcm_trigger_start(substream, cmd);
+		ret = snd_soc_link_trigger(substream, cmd);
+		if (ret < 0)
+			break;
+
+		ret = snd_soc_pcm_component_trigger(substream, cmd);
+		if (ret < 0)
+			break;
+
+		ret = snd_soc_pcm_dai_trigger(substream, cmd);
 		break;
 	case SNDRV_PCM_TRIGGER_STOP:
 	case SNDRV_PCM_TRIGGER_SUSPEND:
 	case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
-		ret = soc_pcm_trigger_stop(substream, cmd);
+		ret = snd_soc_pcm_dai_trigger(substream, cmd);
+		if (ret < 0)
+			break;
+
+		ret = snd_soc_pcm_component_trigger(substream, cmd);
+		if (ret < 0)
+			break;
+
+		ret = snd_soc_link_trigger(substream, cmd);
 		break;
-	default:
-		return -EINVAL;
 	}
 
 	return ret;
-- 
2.17.1


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

* [PATCH 24/24] ASoC: soc-component: tidyup Copyright
  2020-06-01  1:35 [PATCH 00/24] ASoC: soc-component: collect component functions Kuninori Morimoto
                   ` (22 preceding siblings ...)
  2020-06-01  1:37 ` [PATCH 23/24] ASoC: soc-component: merge soc_pcm_trigger_start/stop() Kuninori Morimoto
@ 2020-06-01  1:37 ` Kuninori Morimoto
  23 siblings, 0 replies; 37+ messages in thread
From: Kuninori Morimoto @ 2020-06-01  1:37 UTC (permalink / raw)
  To: Mark Brown; +Cc: Linux-ALSA


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

This patch add missing company copyright

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
 include/sound/soc-component.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/include/sound/soc-component.h b/include/sound/soc-component.h
index 8edc5ee5bd16..b44ae9e21361 100644
--- a/include/sound/soc-component.h
+++ b/include/sound/soc-component.h
@@ -2,7 +2,8 @@
  *
  * soc-component.h
  *
- * Copyright (c) 2019 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
+ * Copyright (C) 2019 Renesas Electronics Corp.
+ * Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
  */
 #ifndef __SOC_COMPONENT_H
 #define __SOC_COMPONENT_H
-- 
2.17.1


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

* Re: [PATCH 05/24] ASoC: soc-component: add snd_soc_pcm_component_prepare()
  2020-06-01  1:36 ` [PATCH 05/24] ASoC: soc-component: add snd_soc_pcm_component_prepare() Kuninori Morimoto
@ 2020-06-01 18:22   ` Ranjani Sridharan
  2020-06-01 23:12     ` Kuninori Morimoto
  0 siblings, 1 reply; 37+ messages in thread
From: Ranjani Sridharan @ 2020-06-01 18:22 UTC (permalink / raw)
  To: Kuninori Morimoto, Mark Brown; +Cc: Linux-ALSA

On Mon, 2020-06-01 at 10:36 +0900, Kuninori Morimoto wrote:
> From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
> 
> We have 2 type of component functions
> snd_soc_component_xxx()     is focusing to component itself,
> snd_soc_pcm_component_xxx() is focusing to rtd related component.
> 
> Now we can update snd_soc_component_prepare() to
> snd_soc_pcm_component_prepare(). This patch do it.
> 
> Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
> ---
>  include/sound/soc-component.h |  3 +--
>  sound/soc/soc-component.c     | 28 +++++++++++++++++-----------
>  sound/soc/soc-pcm.c           | 13 +++++--------
>  3 files changed, 23 insertions(+), 21 deletions(-)
> 
> diff --git a/include/sound/soc-component.h b/include/sound/soc-
> component.h
> index cb0d34fa77c6..fc287e910240 100644
> --- a/include/sound/soc-component.h
> +++ b/include/sound/soc-component.h
> @@ -426,8 +426,6 @@ int snd_soc_component_open(struct
> snd_soc_component *component,
>  			   struct snd_pcm_substream *substream);
>  int snd_soc_component_close(struct snd_soc_component *component,
>  			    struct snd_pcm_substream *substream);
> -int snd_soc_component_prepare(struct snd_soc_component *component,
> -			      struct snd_pcm_substream *substream);
>  int snd_soc_component_hw_params(struct snd_soc_component *component,
>  				struct snd_pcm_substream *substream,
>  				struct snd_pcm_hw_params *params);
> @@ -460,5 +458,6 @@ int snd_soc_pcm_component_mmap(struct
> snd_pcm_substream *substream,
>  			       struct vm_area_struct *vma);
>  int snd_soc_pcm_component_new(struct snd_soc_pcm_runtime *rtd);
>  void snd_soc_pcm_component_free(struct snd_soc_pcm_runtime *rtd);
> +int snd_soc_pcm_component_prepare(struct snd_pcm_substream
> *substream);
>  
>  #endif /* __SOC_COMPONENT_H */
> diff --git a/sound/soc/soc-component.c b/sound/soc/soc-component.c
> index 6d29c2de3b24..1bc155bc8e5e 100644
> --- a/sound/soc/soc-component.c
> +++ b/sound/soc/soc-component.c
> @@ -275,17 +275,6 @@ int snd_soc_component_close(struct
> snd_soc_component *component,
>  	return soc_component_ret(component, ret);
>  }
>  
> -int snd_soc_component_prepare(struct snd_soc_component *component,
> -			      struct snd_pcm_substream *substream)
> -{
> -	int ret = 0;
> -
> -	if (component->driver->prepare)
> -		ret = component->driver->prepare(component, substream);
> -
> -	return soc_component_ret(component, ret);
> -}
> -
>  int snd_soc_component_hw_params(struct snd_soc_component *component,
>  				struct snd_pcm_substream *substream,
>  				struct snd_pcm_hw_params *params)
> @@ -569,3 +558,20 @@ void snd_soc_pcm_component_free(struct
> snd_soc_pcm_runtime *rtd)
>  		if (component->driver->pcm_destruct)
>  			component->driver->pcm_destruct(component, rtd-
> >pcm);
>  }
> +
> +int snd_soc_pcm_component_prepare(struct snd_pcm_substream
> *substream)
> +{
> +	struct snd_soc_pcm_runtime *rtd = substream->private_data;
> +	struct snd_soc_component *component;
> +	int i, ret;
> +
> +	for_each_rtd_components(rtd, i, component) {
> +		if (component->driver->prepare) {
> +			ret = component->driver->prepare(component,
> substream);
> +			if (ret < 0)
> +				return soc_component_ret(component,
> ret);
> +		}
> +	}
> +
> +	return 0;
> +}
> diff --git a/sound/soc/soc-pcm.c b/sound/soc/soc-pcm.c
> index 276505fb9d50..e61e7a56d95e 100644
> --- a/sound/soc/soc-pcm.c
> +++ b/sound/soc/soc-pcm.c
> @@ -850,7 +850,6 @@ static void codec2codec_close_delayed_work(struct
> snd_soc_pcm_runtime *rtd)
>  static int soc_pcm_prepare(struct snd_pcm_substream *substream)
>  {
>  	struct snd_soc_pcm_runtime *rtd = substream->private_data;
> -	struct snd_soc_component *component;
>  	struct snd_soc_dai *dai;
>  	int i, ret = 0;
>  
> @@ -860,13 +859,11 @@ static int soc_pcm_prepare(struct
> snd_pcm_substream *substream)
>  	if (ret < 0)
>  		goto out;
>  
> -	for_each_rtd_components(rtd, i, component) {
> -		ret = snd_soc_component_prepare(component, substream);
> -		if (ret < 0) {
> -			dev_err(component->dev,
> -				"ASoC: platform prepare error: %d\n",
> ret);
> -			goto out;
> -		}
> +	ret = snd_soc_pcm_component_prepare(substream);
> +	if (ret < 0) {
> +		dev_err(rtd->dev,
> +			"ASoC: platform prepare error: %d\n", ret);
Morimoto-san,
We should remove this. This will be a duplicate error message as
snd_soc_pcm_component_prepare() would already print the error before
returning.

Thanks,
Ranjani


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

* Re: [PATCH 09/24] ASoC: soc-component: add snd_soc_component_compr_open()
  2020-06-01  1:36 ` [PATCH 09/24] ASoC: soc-component: add snd_soc_component_compr_open() Kuninori Morimoto
@ 2020-06-01 19:01   ` Ranjani Sridharan
  2020-06-01 23:16     ` Kuninori Morimoto
  2020-06-03 16:55   ` Ranjani Sridharan
  1 sibling, 1 reply; 37+ messages in thread
From: Ranjani Sridharan @ 2020-06-01 19:01 UTC (permalink / raw)
  To: Kuninori Morimoto, Mark Brown; +Cc: Linux-ALSA

On Mon, 2020-06-01 at 10:36 +0900, Kuninori Morimoto wrote:
> From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
> 
> component related function should be implemented at
> soc-component.c.
> This patch moves soc-compress soc_compr_components_open()
> to soc-component as snd_soc_component_compr_open().
Morimoto-san,

This is change is justified in one way but it also feels like maybe
because the functions are so specific to compr devices, it is best to
leave them here. Maybe others should also chime in.

Thanks,
Ranjani


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

* Re: [PATCH 05/24] ASoC: soc-component: add snd_soc_pcm_component_prepare()
  2020-06-01 18:22   ` Ranjani Sridharan
@ 2020-06-01 23:12     ` Kuninori Morimoto
  0 siblings, 0 replies; 37+ messages in thread
From: Kuninori Morimoto @ 2020-06-01 23:12 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_component_xxx()     is focusing to component itself,
> > snd_soc_pcm_component_xxx() is focusing to rtd related component.
> > 
> > Now we can update snd_soc_component_prepare() to
> > snd_soc_pcm_component_prepare(). This patch do it.
> > 
> > Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
> > ---
(snip)
> > -	for_each_rtd_components(rtd, i, component) {
> > -		ret = snd_soc_component_prepare(component, substream);
> > -		if (ret < 0) {
> > -			dev_err(component->dev,
> > -				"ASoC: platform prepare error: %d\n",
> > ret);
> > -			goto out;
> > -		}
> > +	ret = snd_soc_pcm_component_prepare(substream);
> > +	if (ret < 0) {
> > +		dev_err(rtd->dev,
> > +			"ASoC: platform prepare error: %d\n", ret);
> Morimoto-san,
> We should remove this. This will be a duplicate error message as
> snd_soc_pcm_component_prepare() would already print the error before
> returning.

Ohh, yes.
will fix in v2

Thank you for your help !!

Best regards
---
Kuninori Morimoto

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

* Re: [PATCH 09/24] ASoC: soc-component: add snd_soc_component_compr_open()
  2020-06-01 19:01   ` Ranjani Sridharan
@ 2020-06-01 23:16     ` Kuninori Morimoto
  2020-06-03 10:40       ` Mark Brown
  0 siblings, 1 reply; 37+ messages in thread
From: Kuninori Morimoto @ 2020-06-01 23:16 UTC (permalink / raw)
  To: Ranjani Sridharan; +Cc: Linux-ALSA, Mark Brown


Hi Ranjani
Cc Mark

> > From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
> > 
> > component related function should be implemented at
> > soc-component.c.
> > This patch moves soc-compress soc_compr_components_open()
> > to soc-component as snd_soc_component_compr_open().
> Morimoto-san,
> 
> This is change is justified in one way but it also feels like maybe
> because the functions are so specific to compr devices, it is best to
> leave them here. Maybe others should also chime in.

Hmm.. I'm not sure.
Such kind of functions are already has been changed...
Let's ask to Maintainer.

Mark, what do you think ?

Thank you for your help !!

Best regards
---
Kuninori Morimoto

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

* Re: [PATCH 09/24] ASoC: soc-component: add snd_soc_component_compr_open()
  2020-06-01 23:16     ` Kuninori Morimoto
@ 2020-06-03 10:40       ` Mark Brown
  2020-06-04  0:52         ` Kuninori Morimoto
  0 siblings, 1 reply; 37+ messages in thread
From: Mark Brown @ 2020-06-03 10:40 UTC (permalink / raw)
  To: Kuninori Morimoto; +Cc: Linux-ALSA, Ranjani Sridharan

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

On Tue, Jun 02, 2020 at 08:16:00AM +0900, Kuninori Morimoto wrote:
> > > From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

> > > component related function should be implemented at
> > > soc-component.c.
> > > This patch moves soc-compress soc_compr_components_open()
> > > to soc-component as snd_soc_component_compr_open().

> > This is change is justified in one way but it also feels like maybe
> > because the functions are so specific to compr devices, it is best to
> > leave them here. Maybe others should also chime in.

> Hmm.. I'm not sure.
> Such kind of functions are already has been changed...
> Let's ask to Maintainer.

> Mark, what do you think ?

I don't think there's one right answer here.  I guess if we have to pick
we should do the same as is being done for PCM for compressed open but
either option is fine I think.

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

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

* Re: [PATCH 09/24] ASoC: soc-component: add snd_soc_component_compr_open()
  2020-06-01  1:36 ` [PATCH 09/24] ASoC: soc-component: add snd_soc_component_compr_open() Kuninori Morimoto
  2020-06-01 19:01   ` Ranjani Sridharan
@ 2020-06-03 16:55   ` Ranjani Sridharan
  1 sibling, 0 replies; 37+ messages in thread
From: Ranjani Sridharan @ 2020-06-03 16:55 UTC (permalink / raw)
  To: Kuninori Morimoto, Mark Brown; +Cc: Linux-ALSA

On Mon, 2020-06-01 at 10:36 +0900, Kuninori Morimoto wrote:
> From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
> 
> component related function should be implemented at
> soc-component.c.
> This patch moves soc-compress soc_compr_components_open()
> to soc-component as snd_soc_component_compr_open().
> 
> Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
> ---
>  include/sound/soc-component.h |  2 ++
>  sound/soc/soc-component.c     | 23 +++++++++++++++++++++++
>  sound/soc/soc-compress.c      | 31 ++-----------------------------
>  3 files changed, 27 insertions(+), 29 deletions(-)
> 
> diff --git a/include/sound/soc-component.h b/include/sound/soc-
> component.h
> index bb26d55a9289..4f82839948d6 100644
> --- a/include/sound/soc-component.h
> +++ b/include/sound/soc-component.h
> @@ -436,6 +436,8 @@ int snd_soc_component_of_xlate_dai_id(struct
> snd_soc_component *component,
>  int snd_soc_component_of_xlate_dai_name(struct snd_soc_component
> *component,
>  					struct of_phandle_args *args,
>  					const char **dai_name);
> +int snd_soc_component_compr_open(struct snd_compr_stream *cstream,
> +				 struct snd_soc_component **last);
>  
>  int snd_soc_pcm_component_pointer(struct snd_pcm_substream
> *substream);
>  int snd_soc_pcm_component_ioctl(struct snd_pcm_substream *substream,
> diff --git a/sound/soc/soc-component.c b/sound/soc/soc-component.c
> index 150b02be0219..c2a6046a6380 100644
> --- a/sound/soc/soc-component.c
> +++ b/sound/soc/soc-component.c
> @@ -384,6 +384,29 @@
> EXPORT_SYMBOL_GPL(snd_soc_component_exit_regmap);
>  
>  #endif
>  
> +int snd_soc_component_compr_open(struct snd_compr_stream *cstream,
> +				 struct snd_soc_component **last)
> +{
> +	struct snd_soc_pcm_runtime *rtd = cstream->private_data;
> +	struct snd_soc_component *component;
> +	int i, ret;
> +
> +	for_each_rtd_components(rtd, i, component) {
> +		if (component->driver->compress_ops &&
> +		    component->driver->compress_ops->open) {
> +			ret = component->driver->compress_ops-
> >open(component, cstream);
> +			if (ret < 0) {
> +				*last = component;
> +				return soc_component_ret(component,
> ret);
> +			}
> +		}
> +	}
> +
> +	*last = NULL;
> +	return 0;
> +}
> +EXPORT_SYMBOL_GPL(snd_soc_component_compr_open);
> +
>  int snd_soc_pcm_component_pointer(struct snd_pcm_substream
> *substream)
>  {
>  	struct snd_soc_pcm_runtime *rtd = substream->private_data;
> diff --git a/sound/soc/soc-compress.c b/sound/soc/soc-compress.c
> index 4984b6a2c370..2a0d554013a4 100644
> --- a/sound/soc/soc-compress.c
> +++ b/sound/soc/soc-compress.c
> @@ -22,33 +22,6 @@
>  #include <sound/soc-link.h>
>  #include <linux/pm_runtime.h>
>  
> -static int soc_compr_components_open(struct snd_compr_stream
> *cstream,
> -				     struct snd_soc_component **last)
> -{
> -	struct snd_soc_pcm_runtime *rtd = cstream->private_data;
> -	struct snd_soc_component *component;
> -	int i, ret;
> -
> -	for_each_rtd_components(rtd, i, component) {
> -		if (!component->driver->compress_ops ||
> -		    !component->driver->compress_ops->open)
> -			continue;
> -
> -		ret = component->driver->compress_ops->open(component,
> cstream);
> -		if (ret < 0) {
> -			dev_err(component->dev,
> -				"Compress ASoC: can't open platform %s:
> %d\n",
> -				component->name, ret);
> -
> -			*last = component;
> -			return ret;
> -		}
> -	}
> -
> -	*last = NULL;
> -	return 0;
> -}
> -
>  static int soc_compr_components_free(struct snd_compr_stream
> *cstream,
>  				     struct snd_soc_component *last)
>  {
> @@ -92,7 +65,7 @@ static int soc_compr_open(struct snd_compr_stream
> *cstream)
>  	if (ret < 0)
>  		goto out;
>  
> -	ret = soc_compr_components_open(cstream, &component);
> +	ret = snd_soc_component_compr_open(cstream, &component);
If you do decide to keep your changes to move all these functions to
soc-component.c, we need to include soc-component.h in soc-compress.c
isnt it?

Thanks,
Ranjani


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

* Re: [PATCH 17/24] ASoC: soc-component: add snd_soc_component_compr_pointer()
  2020-06-01  1:37 ` [PATCH 17/24] ASoC: soc-component: add snd_soc_component_compr_pointer() Kuninori Morimoto
@ 2020-06-03 17:35   ` Ranjani Sridharan
  0 siblings, 0 replies; 37+ messages in thread
From: Ranjani Sridharan @ 2020-06-03 17:35 UTC (permalink / raw)
  To: Kuninori Morimoto, Mark Brown; +Cc: Linux-ALSA

On Mon, 2020-06-01 at 10:37 +0900, Kuninori Morimoto wrote:
> From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
> 
> component related function should be implemented at
> soc-component.c.
> This patch adds snd_soc_component_compr_pointer().
> 
> Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
> ---
>  include/sound/soc-component.h |  2 ++
>  sound/soc/soc-component.c     | 21 +++++++++++++++++++++
>  sound/soc/soc-compress.c      | 13 ++-----------
>  3 files changed, 25 insertions(+), 11 deletions(-)
> 
> diff --git a/include/sound/soc-component.h b/include/sound/soc-
> component.h
> index da1d89d0b476..0e05aedaee05 100644
> --- a/include/sound/soc-component.h
> +++ b/include/sound/soc-component.h
> @@ -450,6 +450,8 @@ int snd_soc_component_compr_get_caps(struct
> snd_compr_stream *cstream,
>  int snd_soc_component_compr_get_codec_caps(struct snd_compr_stream
> *cstream,
>  					   struct snd_compr_codec_caps
> *codec);
>  int snd_soc_component_compr_ack(struct snd_compr_stream *cstream,
> size_t bytes);
> +int snd_soc_component_compr_pointer(struct snd_compr_stream
> *cstream,
> +				    struct snd_compr_tstamp *tstamp);
>  
>  int snd_soc_pcm_component_pointer(struct snd_pcm_substream
> *substream);
>  int snd_soc_pcm_component_ioctl(struct snd_pcm_substream *substream,
> diff --git a/sound/soc/soc-component.c b/sound/soc/soc-component.c
> index 8f223dd060e8..8a24d6f3572a 100644
> --- a/sound/soc/soc-component.c
> +++ b/sound/soc/soc-component.c
> @@ -549,6 +549,27 @@ int snd_soc_component_compr_ack(struct
> snd_compr_stream *cstream, size_t bytes)
>  }
>  EXPORT_SYMBOL_GPL(snd_soc_component_compr_ack);
>  
> +int snd_soc_component_compr_pointer(struct snd_compr_stream
> *cstream,
> +				    struct snd_compr_tstamp *tstamp)
> +{
> +	struct snd_soc_pcm_runtime *rtd = cstream->private_data;
> +	struct snd_soc_component *component;
> +	int i, ret;
> +
> +	for_each_rtd_components(rtd, i, component) {
> +		if (component->driver->compress_ops &&
> +		    component->driver->compress_ops->pointer) {
> +			ret = component->driver->compress_ops->pointer(
> +				component, cstream, tstamp);
> +			if (ret < 0)
> +				return soc_component_ret(component,
> ret);
Morimoto-san,

This seems slightly different from the original loop in
soc_compr_pointer() where we break as soon as the condition is true. So
should we return irrespective of the return value here?

Thanks,
Ranjani


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

* Re: [PATCH 18/24] ASoC: soc-component: add snd_soc_component_compr_copy()
  2020-06-01  1:37 ` [PATCH 18/24] ASoC: soc-component: add snd_soc_component_compr_copy() Kuninori Morimoto
@ 2020-06-03 17:39   ` Ranjani Sridharan
  0 siblings, 0 replies; 37+ messages in thread
From: Ranjani Sridharan @ 2020-06-03 17:39 UTC (permalink / raw)
  To: Kuninori Morimoto, Mark Brown; +Cc: Linux-ALSA

On Mon, 2020-06-01 at 10:37 +0900, Kuninori Morimoto wrote:
> From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
> 
> component related function should be implemented at
> soc-component.c.
> This patch adds snd_soc_component_compr_copy().
> 
> Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
> ---
>  include/sound/soc-component.h |  2 ++
>  sound/soc/soc-component.c     | 21 +++++++++++++++++++++
>  sound/soc/soc-compress.c      | 13 ++-----------
>  3 files changed, 25 insertions(+), 11 deletions(-)
> 
> diff --git a/include/sound/soc-component.h b/include/sound/soc-
> component.h
> index 0e05aedaee05..255014fe6264 100644
> --- a/include/sound/soc-component.h
> +++ b/include/sound/soc-component.h
> @@ -452,6 +452,8 @@ int snd_soc_component_compr_get_codec_caps(struct
> snd_compr_stream *cstream,
>  int snd_soc_component_compr_ack(struct snd_compr_stream *cstream,
> size_t bytes);
>  int snd_soc_component_compr_pointer(struct snd_compr_stream
> *cstream,
>  				    struct snd_compr_tstamp *tstamp);
> +int snd_soc_component_compr_copy(struct snd_compr_stream *cstream,
> +				 char __user *buf, size_t count);
>  
>  int snd_soc_pcm_component_pointer(struct snd_pcm_substream
> *substream);
>  int snd_soc_pcm_component_ioctl(struct snd_pcm_substream *substream,
> diff --git a/sound/soc/soc-component.c b/sound/soc/soc-component.c
> index 8a24d6f3572a..6a47255767a0 100644
> --- a/sound/soc/soc-component.c
> +++ b/sound/soc/soc-component.c
> @@ -570,6 +570,27 @@ int snd_soc_component_compr_pointer(struct
> snd_compr_stream *cstream,
>  }
>  EXPORT_SYMBOL_GPL(snd_soc_component_compr_pointer);
>  
> +int snd_soc_component_compr_copy(struct snd_compr_stream *cstream,
> +				 char __user *buf, size_t count)
> +{
> +	struct snd_soc_pcm_runtime *rtd = cstream->private_data;
> +	struct snd_soc_component *component;
> +	int i, ret;
> +
> +	for_each_rtd_components(rtd, i, component) {
> +		if (component->driver->compress_ops &&
> +		    component->driver->compress_ops->copy) {
> +			ret = component->driver->compress_ops->copy(
> +				component, cstream, buf, count);
> +			if (ret < 0)
> +				return soc_component_ret(component,
> ret);
Same here as well. Should we return in all cases?

Thanks,
Ranjani


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

* Re: [PATCH 19/24] ASoC: soc-component: add snd_soc_component_compr_set_metadata()
  2020-06-01  1:37 ` [PATCH 19/24] ASoC: soc-component: add snd_soc_component_compr_set_metadata() Kuninori Morimoto
@ 2020-06-03 17:40   ` Ranjani Sridharan
  0 siblings, 0 replies; 37+ messages in thread
From: Ranjani Sridharan @ 2020-06-03 17:40 UTC (permalink / raw)
  To: Kuninori Morimoto, Mark Brown; +Cc: Linux-ALSA

On Mon, 2020-06-01 at 10:37 +0900, Kuninori Morimoto wrote:
> From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
> 
> component related function should be implemented at
> soc-component.c.
> This patch adds snd_soc_component_compr_set_metadata().
> 
> Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
> ---
>  include/sound/soc-component.h |  2 ++
>  sound/soc/soc-component.c     | 21 +++++++++++++++++++++
>  sound/soc/soc-compress.c      | 16 +++-------------
>  3 files changed, 26 insertions(+), 13 deletions(-)
> 
> diff --git a/include/sound/soc-component.h b/include/sound/soc-
> component.h
> index 255014fe6264..ce1df96bb274 100644
> --- a/include/sound/soc-component.h
> +++ b/include/sound/soc-component.h
> @@ -454,6 +454,8 @@ int snd_soc_component_compr_pointer(struct
> snd_compr_stream *cstream,
>  				    struct snd_compr_tstamp *tstamp);
>  int snd_soc_component_compr_copy(struct snd_compr_stream *cstream,
>  				 char __user *buf, size_t count);
> +int snd_soc_component_compr_set_metadata(struct snd_compr_stream
> *cstream,
> +					 struct snd_compr_metadata
> *metadata);
>  
>  int snd_soc_pcm_component_pointer(struct snd_pcm_substream
> *substream);
>  int snd_soc_pcm_component_ioctl(struct snd_pcm_substream *substream,
> diff --git a/sound/soc/soc-component.c b/sound/soc/soc-component.c
> index 6a47255767a0..1ac353cf48c5 100644
> --- a/sound/soc/soc-component.c
> +++ b/sound/soc/soc-component.c
> @@ -591,6 +591,27 @@ int snd_soc_component_compr_copy(struct
> snd_compr_stream *cstream,
>  }
>  EXPORT_SYMBOL_GPL(snd_soc_component_compr_copy);
>  
> +int snd_soc_component_compr_set_metadata(struct snd_compr_stream
> *cstream,
> +					 struct snd_compr_metadata
> *metadata)
> +{
> +	struct snd_soc_pcm_runtime *rtd = cstream->private_data;
> +	struct snd_soc_component *component;
> +	int i, ret;
> +
> +	for_each_rtd_components(rtd, i, component) {
> +		if (component->driver->compress_ops &&
> +		    component->driver->compress_ops->set_metadata) {
> +			ret = component->driver->compress_ops-
> >set_metadata(
> +				component, cstream, metadata);
> +			if (ret < 0)
> +				return soc_component_ret(component,
> ret);
> +		}
> +	}
> +
> +	return 0;
> +}
> +EXPORT_SYMBOL_GPL(snd_soc_component_compr_set_metadata);
> +
>  int snd_soc_pcm_component_pointer(struct snd_pcm_substream
> *substream)
>  {
>  	struct snd_soc_pcm_runtime *rtd = substream->private_data;
> diff --git a/sound/soc/soc-compress.c b/sound/soc/soc-compress.c
> index 7e05f263b655..62925adb1042 100644
> --- a/sound/soc/soc-compress.c
> +++ b/sound/soc/soc-compress.c
> @@ -530,26 +530,16 @@ static int soc_compr_set_metadata(struct
> snd_compr_stream *cstream,
>  				  struct snd_compr_metadata *metadata)
>  {
>  	struct snd_soc_pcm_runtime *rtd = cstream->private_data;
> -	struct snd_soc_component *component;
>  	struct snd_soc_dai *cpu_dai = asoc_rtd_to_cpu(rtd, 0);
> -	int i, ret;
> +	int 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 ||
> -		    !component->driver->compress_ops->set_metadata)
> -			continue;
> -
> -		ret = component->driver->compress_ops->set_metadata(
> -			component, cstream, metadata);
> -		if (ret < 0)
> -			return ret;
> -	}
> +	ret = snd_soc_component_compr_set_metadata(cstream, metadata);
>  
> -	return 0;
> +	return ret;
maybe just,
return snd_soc_component_compr_set_metadata(cstream, metadata);?

Thanks,
Ranjani


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

* Re: [PATCH 20/24] ASoC: soc-component: add snd_soc_component_compr_get_metadata()
  2020-06-01  1:37 ` [PATCH 20/24] ASoC: soc-component: add snd_soc_component_compr_get_metadata() Kuninori Morimoto
@ 2020-06-03 17:41   ` Ranjani Sridharan
  0 siblings, 0 replies; 37+ messages in thread
From: Ranjani Sridharan @ 2020-06-03 17:41 UTC (permalink / raw)
  To: Kuninori Morimoto, Mark Brown; +Cc: Linux-ALSA

On Mon, 2020-06-01 at 10:37 +0900, Kuninori Morimoto wrote:
> From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
> 
> component related function should be implemented at
> soc-component.c.
> This patch adds snd_soc_component_compr_get_metadata().
> 
> Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
> ---
>  include/sound/soc-component.h |  2 ++
>  sound/soc/soc-component.c     | 18 ++++++++++++++++++
>  sound/soc/soc-compress.c      | 14 +++-----------
>  3 files changed, 23 insertions(+), 11 deletions(-)
> 
> diff --git a/include/sound/soc-component.h b/include/sound/soc-
> component.h
> index ce1df96bb274..5b8a4d847089 100644
> --- a/include/sound/soc-component.h
> +++ b/include/sound/soc-component.h
> @@ -456,6 +456,8 @@ int snd_soc_component_compr_copy(struct
> snd_compr_stream *cstream,
>  				 char __user *buf, size_t count);
>  int snd_soc_component_compr_set_metadata(struct snd_compr_stream
> *cstream,
>  					 struct snd_compr_metadata
> *metadata);
> +int snd_soc_component_compr_get_metadata(struct snd_compr_stream
> *cstream,
> +					 struct snd_compr_metadata
> *metadata);
>  
>  int snd_soc_pcm_component_pointer(struct snd_pcm_substream
> *substream);
>  int snd_soc_pcm_component_ioctl(struct snd_pcm_substream *substream,
> diff --git a/sound/soc/soc-component.c b/sound/soc/soc-component.c
> index 1ac353cf48c5..45a5c496454a 100644
> --- a/sound/soc/soc-component.c
> +++ b/sound/soc/soc-component.c
> @@ -612,6 +612,24 @@ int snd_soc_component_compr_set_metadata(struct
> snd_compr_stream *cstream,
>  }
>  EXPORT_SYMBOL_GPL(snd_soc_component_compr_set_metadata);
>  
> +int snd_soc_component_compr_get_metadata(struct snd_compr_stream
> *cstream,
> +					 struct snd_compr_metadata
> *metadata)
> +{
> +	struct snd_soc_pcm_runtime *rtd = cstream->private_data;
> +	struct snd_soc_component *component;
> +	int i;
> +
> +	for_each_rtd_components(rtd, i, component) {
> +		if (component->driver->compress_ops &&
> +		    component->driver->compress_ops->get_metadata)
> +			return component->driver->compress_ops-
> >get_metadata(
> +				component, cstream, metadata);
> +	}
> +
> +	return 0;
> +}
> +EXPORT_SYMBOL_GPL(snd_soc_component_compr_get_metadata);
> +
>  int snd_soc_pcm_component_pointer(struct snd_pcm_substream
> *substream)
>  {
>  	struct snd_soc_pcm_runtime *rtd = substream->private_data;
> diff --git a/sound/soc/soc-compress.c b/sound/soc/soc-compress.c
> index 62925adb1042..475722adb2a5 100644
> --- a/sound/soc/soc-compress.c
> +++ b/sound/soc/soc-compress.c
> @@ -546,24 +546,16 @@ static int soc_compr_get_metadata(struct
> snd_compr_stream *cstream,
>  				  struct snd_compr_metadata *metadata)
>  {
>  	struct snd_soc_pcm_runtime *rtd = cstream->private_data;
> -	struct snd_soc_component *component;
>  	struct snd_soc_dai *cpu_dai = asoc_rtd_to_cpu(rtd, 0);
> -	int i, ret;
> +	int 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 ||
> -		    !component->driver->compress_ops->get_metadata)
> -			continue;
> +	ret = snd_soc_component_compr_get_metadata(cstream, metadata);
>  
> -		return component->driver->compress_ops->get_metadata(
> -			component, cstream, metadata);
> -	}
> -
> -	return 0;
> +	return ret;
same here.
return snd_soc_component_compr_get_metadata(cstream, metadata);?

Thanks,
Ranjani


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

* Re: [PATCH 09/24] ASoC: soc-component: add snd_soc_component_compr_open()
  2020-06-03 10:40       ` Mark Brown
@ 2020-06-04  0:52         ` Kuninori Morimoto
  2020-06-04  4:23           ` Kuninori Morimoto
  0 siblings, 1 reply; 37+ messages in thread
From: Kuninori Morimoto @ 2020-06-04  0:52 UTC (permalink / raw)
  To: Mark Brown; +Cc: Linux-ALSA, Ranjani Sridharan


Hi Mark, Ranjani

Thank you for your feedback

> > > This is change is justified in one way but it also feels like maybe
> > > because the functions are so specific to compr devices, it is best to
> > > leave them here. Maybe others should also chime in.
(snip)
> I don't think there's one right answer here.  I guess if we have to pick
> we should do the same as is being done for PCM for compressed open but
> either option is fine I think.

I re-checked the patch.
The original code is soc_compr_xxx() and doing compress things.
I agree to keeping original code at original file.
I will remove these patched from v2 patch-set.

Thank you for your help !!

Best regards
---
Kuninori Morimoto

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

* Re: [PATCH 09/24] ASoC: soc-component: add snd_soc_component_compr_open()
  2020-06-04  0:52         ` Kuninori Morimoto
@ 2020-06-04  4:23           ` Kuninori Morimoto
  0 siblings, 0 replies; 37+ messages in thread
From: Kuninori Morimoto @ 2020-06-04  4:23 UTC (permalink / raw)
  To: Mark Brown; +Cc: Linux-ALSA, Ranjani Sridharan


Hi Mark, Ranjani again

> > > > This is change is justified in one way but it also feels like maybe
> > > > because the functions are so specific to compr devices, it is best to
> > > > leave them here. Maybe others should also chime in.
> (snip)
> > I don't think there's one right answer here.  I guess if we have to pick
> > we should do the same as is being done for PCM for compressed open but
> > either option is fine I think.
> 
> I re-checked the patch.
> The original code is soc_compr_xxx() and doing compress things.
> I agree to keeping original code at original file.
> I will remove these patched from v2 patch-set.

I re-re-checked.
I will drop this patch this time, but might post it again in the future.
Because we already have same/similar functon for DAI (= snd_soc_dai_compr_xxx()).

And I plan to add snd_soc_component_xxx() specific future, and
compr can use it.

Thank you for your help !!

Best regards
---
Kuninori Morimoto

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

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

Thread overview: 37+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-01  1:35 [PATCH 00/24] ASoC: soc-component: collect component functions Kuninori Morimoto
2020-06-01  1:35 ` [PATCH 01/24] ASoC: soc-component: add soc_component_pin() and share code Kuninori Morimoto
2020-06-01  1:36 ` [PATCH 02/24] ASoC: soc-component: move snd_soc_component_xxx_regmap() to soc-component Kuninori Morimoto
2020-06-01  1:36 ` [PATCH 03/24] ASoC: soc-component: move snd_soc_component_initialize() to soc-component.c Kuninori Morimoto
2020-06-01  1:36 ` [PATCH 04/24] ASoC: soc-component: add soc_component_err() Kuninori Morimoto
2020-06-01  1:36 ` [PATCH 05/24] ASoC: soc-component: add snd_soc_pcm_component_prepare() Kuninori Morimoto
2020-06-01 18:22   ` Ranjani Sridharan
2020-06-01 23:12     ` Kuninori Morimoto
2020-06-01  1:36 ` [PATCH 06/24] ASoC: soc-component: add snd_soc_pcm_component_hw_params() Kuninori Morimoto
2020-06-01  1:36 ` [PATCH 07/24] ASoC: soc-component: add snd_soc_pcm_component_hw_free() Kuninori Morimoto
2020-06-01  1:36 ` [PATCH 08/24] ASoC: soc-component: add snd_soc_pcm_component_trigger() Kuninori Morimoto
2020-06-01  1:36 ` [PATCH 09/24] ASoC: soc-component: add snd_soc_component_compr_open() Kuninori Morimoto
2020-06-01 19:01   ` Ranjani Sridharan
2020-06-01 23:16     ` Kuninori Morimoto
2020-06-03 10:40       ` Mark Brown
2020-06-04  0:52         ` Kuninori Morimoto
2020-06-04  4:23           ` Kuninori Morimoto
2020-06-03 16:55   ` Ranjani Sridharan
2020-06-01  1:36 ` [PATCH 10/24] ASoC: soc-component: add snd_soc_component_compr_free() Kuninori Morimoto
2020-06-01  1:36 ` [PATCH 11/24] ASoC: soc-component: add snd_soc_component_compr_trigger() Kuninori Morimoto
2020-06-01  1:36 ` [PATCH 12/24] ASoC: soc-component: add snd_soc_component_compr_set_params() Kuninori Morimoto
2020-06-01  1:36 ` [PATCH 13/24] ASoC: soc-component: add snd_soc_component_compr_get_params() Kuninori Morimoto
2020-06-01  1:37 ` [PATCH 14/24] ASoC: soc-component: add snd_soc_component_compr_get_caps() Kuninori Morimoto
2020-06-01  1:37 ` [PATCH 15/24] ASoC: soc-component: add snd_soc_component_compr_get_codec_caps() Kuninori Morimoto
2020-06-01  1:37 ` [PATCH 16/24] ASoC: soc-component: add snd_soc_component_compr_ack() Kuninori Morimoto
2020-06-01  1:37 ` [PATCH 17/24] ASoC: soc-component: add snd_soc_component_compr_pointer() Kuninori Morimoto
2020-06-03 17:35   ` Ranjani Sridharan
2020-06-01  1:37 ` [PATCH 18/24] ASoC: soc-component: add snd_soc_component_compr_copy() Kuninori Morimoto
2020-06-03 17:39   ` Ranjani Sridharan
2020-06-01  1:37 ` [PATCH 19/24] ASoC: soc-component: add snd_soc_component_compr_set_metadata() Kuninori Morimoto
2020-06-03 17:40   ` Ranjani Sridharan
2020-06-01  1:37 ` [PATCH 20/24] ASoC: soc-component: add snd_soc_component_compr_get_metadata() Kuninori Morimoto
2020-06-03 17:41   ` Ranjani Sridharan
2020-06-01  1:37 ` [PATCH 21/24] ASoC: soc-component: add snd_soc_component_init() Kuninori Morimoto
2020-06-01  1:37 ` [PATCH 22/24] ASoC: soc-component: merge soc-io.c into soc-component.c Kuninori Morimoto
2020-06-01  1:37 ` [PATCH 23/24] ASoC: soc-component: merge soc_pcm_trigger_start/stop() Kuninori Morimoto
2020-06-01  1:37 ` [PATCH 24/24] ASoC: soc-component: tidyup Copyright 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.