ASoC: add soc-component.c
cover ASoC: add soc-component.c
Hi Mark
I want to add multi CPU DAI support to ALSA SoC. But I noticed that we want to cleanup ALSA SoC before that. These patches will do nothing from "technical" point of view, but, will makes code readable.
These are focusing to "component". Actually, soc-io.c is also for component. I'm thinking that we can merge soc-io.c into soc-component.c, but do nothing by these patch-set.
Kuninori Morimoto (25):
ASoC: add soc-component.c
ASoC: soc-component: add snd_soc_component_get/put()
ASoC: soc-component: add snd_soc_component_open()
ASoC: soc-component: add snd_soc_component_close()
ASoC: soc-component: add snd_soc_component_prepare()
ASoC: soc-component: add snd_soc_component_hw_params()
ASoC: soc-component: add snd_soc_component_hw_free()
ASoC: soc-component: add snd_soc_component_trigger()
ASoC: soc-component: add snd_soc_component_pointer()
ASoC: soc-component: add snd_soc_component_ioctrl()
ASoC: soc-component: add snd_soc_component_copy_user()
ASoC: soc-component: add snd_soc_component_page()
ASoC: soc-component: add snd_soc_component_mmap()
ASoC: soc-component: add snd_soc_component_pcm_new()
ASoC: soc-component: add snd_soc_component_pcm_free()
ASoC: soc-component: add snd_soc_component_suspend()
ASoC: soc-component: add snd_soc_component_resume()
ASoC: soc-component: add snd_soc_component_is_suspended()
ASoC: soc-component: add snd_soc_component_probe()
ASoC: soc-component: add snd_soc_component_remove()
ASoC: soc-component: add snd_soc_component_of_xlate_dai_id()
ASoC: soc-component: add snd_soc_component_of_xlate_dai_name()
ASoC: soc-component: move snd_soc_component_seq_notifier()
ASoC: soc-component: move snd_soc_component_stream_event()
ASoC: soc-component: move snd_soc_component_set_bias_level()
include/sound/soc-component.h | 378 +++++++++++++++++++++++++++++++ include/sound/soc.h | 306 +------------------------- sound/soc/Makefile | 2 +- sound/soc/soc-component.c | 500 ++++++++++++++++++++++++++++++++++++++++++ sound/soc/soc-core.c | 126 ++--------- sound/soc/soc-jack.c | 18 -- sound/soc/soc-pcm.c | 98 +++------ sound/soc/soc-utils.c | 199 ----------------- 8 files changed, 931 insertions(+), 696 deletions(-) create mode 100644 include/sound/soc-component.h create mode 100644 sound/soc/soc-component.c
Signature · 1 line
2.7.4
PATCH 1/25 ASoC: add soc-component.c
From: Kuninori Morimoto <[email protected]>
ALSA SoC has many snd_soc_component_xxx(), but these are randomly located in many files. Because of it, code is difficult to read. This patch creates new soc-component.c, and moves existing snd_soc_component_xxx() into it.
But not yet fully. We need more cleanup it.
--- include/sound/soc-component.h | 320 ++++++++++++++++++++++++++++++++++++++++++ include/sound/soc.h | 306 +--------------------------------------- sound/soc/Makefile | 2 +- sound/soc/soc-component.c | 269 +++++++++++++++++++++++++++++++++++ sound/soc/soc-core.c | 44 ------ sound/soc/soc-jack.c | 18 --- sound/soc/soc-utils.c | 199 -------------------------- 7 files changed, 591 insertions(+), 567 deletions(-) create mode 100644 include/sound/soc-component.h create mode 100644 sound/soc/soc-component.c
include/sound/soc-component.h new file +320 -0
@@ -0,0 +1,320 @@ +/* +* soc-component.h +* +* Copyright (c) 2019 Kuninori Morimoto <[email protected]> +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License version 2 as +* published by the Free Software Foundation. +*/ +#ifndef __SOC_COMPONENT_H +#define __SOC_COMPONENT_H + +#include <sound/soc.h> + +/* +* Component probe and remove ordering levels for components with runtime +* dependencies. +*/ +#define SND_SOC_COMP_ORDER_FIRST -2 +#define SND_SOC_COMP_ORDER_EARLY -1 +#define SND_SOC_COMP_ORDER_NORMAL 0 +#define SND_SOC_COMP_ORDER_LATE 1 +#define SND_SOC_COMP_ORDER_LAST 2 + +#define for_each_comp_order (order) \ + for (order = SND_SOC_COMP_ORDER_FIRST; \ + order <= SND_SOC_COMP_ORDER_LAST; \ + order++) + +/* component interface */ +struct snd_soc_component_driver { +const char *name; + +/* Default control and setup, added after probe() is run */ +const struct snd_kcontrol_new *controls; +unsigned int num_controls; +const struct snd_soc_dapm_widget *dapm_widgets; +unsigned int num_dapm_widgets; +const struct snd_soc_dapm_route *dapm_routes; +unsigned int num_dapm_routes; + +int (*probe)(struct snd_soc_component *); +void (*remove)(struct snd_soc_component *); +int (*suspend)(struct snd_soc_component *); +int (*resume)(struct snd_soc_component *); + +unsigned int (*read)(struct snd_soc_component *,unsigned int ); +int (*write)(struct snd_soc_component *,unsigned int ,unsigned int ); + +/* pcm creation and destruction */ +int (*pcm_new)(struct snd_soc_pcm_runtime *); +void (*pcm_free)(struct snd_pcm *); + +/* component wide operations */ +int (*set_sysclk)(struct snd_soc_component *component, +int clk_id,int source,unsigned int freq,int dir); +int (*set_pll)(struct snd_soc_component *component,int pll_id, +int source,unsigned int freq_in,unsigned int freq_out); +int (*set_jack)(struct snd_soc_component *component, +struct snd_soc_jack *jack,void *data); + +/* DT */ +int (*of_xlate_dai_name)(struct snd_soc_component *component, +struct of_phandle_args *args, +const char **dai_name); +int (*of_xlate_dai_id)(struct snd_soc_component *comment, +struct device_node *endpoint); +void (*seq_notifier)(struct snd_soc_component *,enum snd_soc_dapm_type , +int subseq); +int (*stream_event)(struct snd_soc_component *,int event); +int (*set_bias_level)(struct snd_soc_component *component, +enum snd_soc_bias_level level); + +const struct snd_pcm_ops *ops; +const struct snd_compr_ops *compr_ops; + +/* probe ordering - for components with runtime dependencies */ +int probe_order; +int remove_order; + +/* +* signal if the module handling the component should not be removed +* if a pcm is open. Setting this would prevent the module +* refcount being incremented in probe() but allow it be incremented +* when a pcm is opened and decremented when it is closed. +*/ +unsigned int module_get_upon_open:1 ; + +/* bits */ +unsigned int idle_bias_on:1 ; +unsigned int suspend_bias_off:1 ; +unsigned int use_pmdown_time:1 ;/* care pmdown_time at stop */ +unsigned int endianness:1 ; +unsigned int non_legacy_dai_naming:1 ; + +/* this component uses topology and ignore machine driver FEs */ +const char *ignore_machine; +const char *topology_name_prefix; +int (*be_hw_params_fixup)(struct snd_soc_pcm_runtime *rtd, +struct snd_pcm_hw_params *params); +bool use_dai_pcm_id;/* use the DAI link PCM ID as PCM device number */ +int be_pcm_base;/* base device ID for all BE PCMs */ +}; + +struct snd_soc_component { +const char *name; +int id; +const char *name_prefix; +struct device *dev; +struct snd_soc_card *card; + +unsigned int active; + +unsigned int suspended:1 ;/* is in suspend PM state */ + +struct list_head list; +struct list_head card_aux_list;/* for auxiliary bound components */ +struct list_head card_list; + +const struct snd_soc_component_driver *driver; + +struct list_head dai_list; +int num_dai; + +struct regmap *regmap; +int val_bytes; + +struct mutex io_mutex; + +/* attached dynamic objects */ +struct list_head dobj_list; + +/* +* DO NOT use any of the fields below in drivers, they are temporary and +* are going to be removed again soon. If you use them in driver code the +* driver will be marked as BROKEN when these fields are removed. +*/ + +/* Don't use these, use snd_soc_component_get_dapm() */ +struct snd_soc_dapm_context dapm; + +/* machine specific init */ +int (*init)(struct snd_soc_component *component); + +#ifdef CONFIG_DEBUG_FS +struct dentry *debugfs_root; +const char *debugfs_prefix; +#endif +}; + +#define for_each_component_dais (component, dai)\ + list_for_each_entry(dai, &(component)->dai_list, list) +#define for_each_component_dais_safe (component, dai, _dai)\ + list_for_each_entry_safe(dai, _dai, &(component)->dai_list, list) + +/** +* snd_soc_dapm_to_component() - Casts a DAPM context to the component it is +* embedded in +* @dapm: The DAPM context to cast to the component +* +* This function must only be used on DAPM contexts that are known to be part of +* a component (e.g. in a component driver). Otherwise the behavior is +* undefined. +*/ +static inline struct snd_soc_component *snd_soc_dapm_to_component ( +struct snd_soc_dapm_context *dapm) +{ + return container_of(dapm, struct snd_soc_component, dapm); +} + +/** +* snd_soc_component_get_dapm() - Returns the DAPM context associated with a +* component +* @component: The component for which to get the DAPM context +*/ +static inline struct snd_soc_dapm_context *snd_soc_component_get_dapm ( +struct snd_soc_component *component) +{ +return &component->dapm; +} + +/** +* snd_soc_component_init_bias_level() - Initialize COMPONENT DAPM bias level +* @component: The COMPONENT for which to initialize the DAPM bias level +* @level: The DAPM level to initialize to +* +* Initializes the COMPONENT DAPM bias level. See snd_soc_dapm_init_bias_level(). +*/ +static inline void +snd_soc_component_init_bias_level (struct snd_soc_component *component, +enum snd_soc_bias_level level) +{ +snd_soc_dapm_init_bias_level ( +snd_soc_component_get_dapm (component), level); +} + +/** +* snd_soc_component_get_bias_level() - Get current COMPONENT DAPM bias level +* @component: The COMPONENT for which to get the DAPM bias level +* +* Returns: The current DAPM bias level of the COMPONENT. +*/ +static inline enum snd_soc_bias_level +snd_soc_component_get_bias_level (struct snd_soc_component *component) +{ +return snd_soc_dapm_get_bias_level ( +snd_soc_component_get_dapm (component)); +} + +/** +* snd_soc_component_force_bias_level() - Set the COMPONENT DAPM bias level +* @component: The COMPONENT for which to set the level +* @level: The level to set to +* +* Forces the COMPONENT bias level to a specific state. See +* snd_soc_dapm_force_bias_level(). +*/ +static inline int +snd_soc_component_force_bias_level (struct snd_soc_component *component, +enum snd_soc_bias_level level) +{ +return snd_soc_dapm_force_bias_level ( +snd_soc_component_get_dapm (component), + level); +} + +/** +* snd_soc_dapm_kcontrol_component() - Returns the component associated to a kcontrol +* @kcontrol: The kcontrol +* +* This function must only be used on DAPM contexts that are known to be part of +* a COMPONENT (e.g. in a COMPONENT driver). Otherwise the behavior is undefined. +*/ +static inline struct snd_soc_component *snd_soc_dapm_kcontrol_component ( +struct snd_kcontrol *kcontrol) +{ +return snd_soc_dapm_to_component (snd_soc_dapm_kcontrol_dapm (kcontrol)); +} + +/** +* snd_soc_component_cache_sync() - Sync the register cache with the hardware +* @component: COMPONENT to sync +* +* Note: This function will call regcache_sync() +*/ +static inline int snd_soc_component_cache_sync ( +struct snd_soc_component *component) +{ +return regcache_sync (component->regmap); +} + +/* component IO */ +int snd_soc_component_read (struct snd_soc_component *component, +unsigned int reg,unsigned int *val); +unsigned int snd_soc_component_read32 (struct snd_soc_component *component, +unsigned int reg); +int snd_soc_component_write (struct snd_soc_component *component, +unsigned int reg,unsigned int val); +int snd_soc_component_update_bits (struct snd_soc_component *component, +unsigned int reg,unsigned int mask,unsigned int val); +int snd_soc_component_update_bits_async (struct snd_soc_component *component, +unsigned int reg,unsigned int mask,unsigned int val); +void snd_soc_component_async_complete (struct snd_soc_component *component); +int snd_soc_component_test_bits (struct snd_soc_component *component, +unsigned int reg,unsigned int mask,unsigned int value); + +/* component wide operations */ +int snd_soc_component_set_sysclk (struct snd_soc_component *component, +int clk_id,int source,unsigned int freq,int dir); +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 snd_soc_component_set_jack (struct snd_soc_component *component, +struct snd_soc_jack *jack,void *data); + +#ifdef CONFIG_REGMAP +void snd_soc_component_init_regmap (struct snd_soc_component *component, +struct regmap *regmap); +void snd_soc_component_exit_regmap (struct snd_soc_component *component); +#endif + +static inline void snd_soc_component_set_drvdata (struct snd_soc_component *c, +void *data) +{ +dev_set_drvdata (c->dev, data); +} + +static inline void *snd_soc_component_get_drvdata (struct snd_soc_component *c) +{ +return dev_get_drvdata (c->dev); +} + +static inline bool snd_soc_component_is_active ( +struct snd_soc_component *component) +{ +return component->active !=0 ; +} + +/* component pin */ +int snd_soc_component_enable_pin (struct snd_soc_component *component, +const char *pin); +int snd_soc_component_enable_pin_unlocked (struct snd_soc_component *component, +const char *pin); +int snd_soc_component_disable_pin (struct snd_soc_component *component, +const char *pin); +int snd_soc_component_disable_pin_unlocked (struct snd_soc_component *component, +const char *pin); +int snd_soc_component_nc_pin (struct snd_soc_component *component, +const char *pin); +int snd_soc_component_nc_pin_unlocked (struct snd_soc_component *component, +const char *pin); +int snd_soc_component_get_pin_status (struct snd_soc_component *component, +const char *pin); +int snd_soc_component_force_enable_pin (struct snd_soc_component *component, +const char *pin); +int snd_soc_component_force_enable_pin_unlocked ( +struct snd_soc_component *component, +const char *pin); + +#endif /* __SOC_COMPONENT_H */
include/sound/soc.h +1 -305
341 lines not on this page · raw message
sound/soc/Makefile +1 -1
@@ -1,5 +1,5 @@ # 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 +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 snd-soc-core-$(CONFIG_SND_SOC_COMPRESS) += soc-compress.o
sound/soc/soc-component.c new file +269 -0
269 lines not on this page · raw message
sound/soc/soc-core.c +0 -44
50 lines not on this page · raw message
sound/soc/soc-jack.c +0 -18
@@ -24,24 +24,6 @@ struct jack_gpio_tbl { };/** -* snd_soc_component_set_jack - configure component jack. -* @component: COMPONENTs -* @jack: structure to use for the jack -* @data: can be used if codec driver need extra data for configuring jack -* -* Configures and enables jack detection function. -*/ -int snd_soc_component_set_jack (struct snd_soc_component *component, -struct snd_soc_jack *jack,void *data) -{ -if (component->driver->set_jack) -return component->driver->set_jack (component, jack, data); - -return -ENOTSUPP ; -} -EXPORT_SYMBOL_GPL (snd_soc_component_set_jack); - -/** * snd_soc_card_jack_new - Create a new jack * @card: ASoC card * @id: an identifying string for this jack
sound/soc/soc-utils.c +0 -199
205 lines not on this page · raw message
Signature · 1 line
2.7.4
PATCH 2/25 ASoC: soc-component: add snd_soc_component_get/put()
In reply to Kuninori MorimotoFrom: Kuninori Morimoto <[email protected]>
ALSA SoC is calling try_module_get()/module_put() based on component->driver->module_get_upon_open.
To keep simple and readable code, we should create its function. This patch adds new snd_soc_component_get/put().
--- include/sound/soc-component.h | 5 +++++ sound/soc/soc-component.c | 18 ++++++++++++++++++ sound/soc/soc-core.c | 9 ++++----- sound/soc/soc-pcm.c | 10 ++++------ 4 files changed, 31 insertions(+), 11 deletions(-)
include/sound/soc-component.h +5 -0
@@ -279,6 +279,11 @@ void snd_soc_component_init_regmap(struct snd_soc_component *component,void snd_soc_component_exit_regmap (struct snd_soc_component *component);#endif +int snd_soc_component_module_get (struct snd_soc_component *component, +int has_flags); +void snd_soc_component_module_put (struct snd_soc_component *component, +int has_flags); +static inline void snd_soc_component_set_drvdata (struct snd_soc_component *c,void *data) {
sound/soc/soc-component.c +18 -0
@@ -5,6 +5,7 @@// Copyright (C) 2019 Renesas Electronics Corp. // Kuninori Morimoto <[email protected]> // +#include <linux/module.h> #include <sound/soc.h> /**
@@ -267,3 +268,20 @@ int snd_soc_component_set_jack(struct snd_soc_component *component,return -ENOTSUPP ; }EXPORT_SYMBOL_GPL (snd_soc_component_set_jack); + +int snd_soc_component_module_get (struct snd_soc_component *component, +int has_flags) +{ +if (component->driver->module_get_upon_open == !!has_flags && + !try_module_get (component->dev->driver->owner)) +return -ENODEV ; + +return 0 ; +} + +void snd_soc_component_module_put (struct snd_soc_component *component, +int has_flags) +{ +if (component->driver->module_get_upon_open == !!has_flags) +module_put (component->dev->driver->owner); +}
sound/soc/soc-core.c +4 -5
@@ -967,8 +967,7 @@ static void soc_cleanup_component(struct snd_soc_component *component)snd_soc_dapm_free (snd_soc_component_get_dapm (component));soc_cleanup_component_debugfs (component); component->card =NULL ; -if (!component->driver->module_get_upon_open) -module_put (component->dev->driver->owner); +snd_soc_component_module_put (component,0 ); }static void soc_remove_component (struct snd_soc_component *component)
@@ -1296,9 +1295,9 @@ static int soc_probe_component(struct snd_soc_card *card,return 0 ; } -if (!component->driver->module_get_upon_open && - !try_module_get (component->dev->driver->owner)) -return -ENODEV ; + ret =snd_soc_component_module_get (component,0 ); +if (ret <0 ) +return ret; component->card = card; dapm->card = card;
sound/soc/soc-pcm.c +4 -6
@@ -15,7 +15,6 @@#include <linux/delay.h> #include <linux/pinctrl/consumer.h> #include <linux/pm_runtime.h> -#include <linux/module.h> #include <linux/slab.h> #include <linux/workqueue.h> #include <linux/export.h>
@@ -440,12 +439,12 @@ static int soc_pcm_components_open(struct snd_pcm_substream *substream, component = rtdcom->component; *last = component; -if (component->driver->module_get_upon_open && - !try_module_get (component->dev->driver->owner)) { + ret =snd_soc_component_module_get (component,1 ); +if (ret <0 ) {dev_err (component->dev,"ASoC: can't get module %s\n" , component->name); -return -ENODEV ; +return ret; } if (!component->driver->ops ||
@@ -481,8 +480,7 @@ static int soc_pcm_components_close(struct snd_pcm_substream *substream, component->driver->ops->close) component->driver->ops->close (substream); -if (component->driver->module_get_upon_open) -module_put (component->dev->driver->owner); +snd_soc_component_module_put (component,1 ); }return 0 ;
Signature · 1 line
2.7.4
Re: [PATCH 02/25] ASoC: soc-component: add snd_soc_component_get/put()
Quoted 15 lines · Kuninori Morimoto
From: Kuninori Morimoto <[email protected]>
ALSA SoC is calling try_module_get()/module_put() based on
component->driver->module_get_upon_open.
To keep simple and readable code, we should create its function. This patch adds new snd_soc_component_get/put().Signed-off-by Kuninori Morimoto <[email protected]>---
include/sound/soc-component.h +0
-0
include/sound/soc-component.h void snd_soc_component_init_regmap(struct snd_soc_component *component, · line 285
Quoted 7 lines
include/sound/soc-component.h +4
-0@@ -279,6 +279,11 @@ void snd_soc_component_init_regmap(struct snd_soc_component *component,void snd_soc_component_exit_regmap (struct snd_soc_component *component);#endif +int snd_soc_component_module_get (struct snd_soc_component *component, +int has_flags); +void snd_soc_component_module_put (struct snd_soc_component *component, +int has_flags);
The name has_flags feels a little vague here, is the intention to support more flags in the future? Or would something like require_get_upon_open or something be better?
Thanks,
Charles
Re: [PATCH 02/25] ASoC: soc-component: add snd_soc_component_get/put()
Hi Charles
Quoted 8 lines
include/sound/soc-component.h void snd_soc_component_init_regmap(struct snd_soc_component *component, · line 285
Quoted 4 lines
include/sound/soc-component.h +4
-0+int snd_soc_component_module_get (struct snd_soc_component *component, +int has_flags); +void snd_soc_component_module_put (struct snd_soc_component *component, +int has_flags);The name
has_flagsfeels a little vague here, is the intention to support more flags in the future? Or would something likerequire_get_upon_openor something be better?
Yeah, indeed.
I will re-consider about it.
Thank you for your help !!
Best regards
---
Kuninori Morimoto
PATCH 3/25 ASoC: soc-component: add snd_soc_component_open()
In reply to Kuninori MorimotoFrom: Kuninori Morimoto <[email protected]>
Current ALSA SoC is directly using component->driver->ops->xxx, thus, it is deep nested, and makes code difficult to read, and is not good for encapsulation.
This patch adds new snd_soc_component_open() and use it.
--- include/sound/soc-component.h | 4 ++++ sound/soc/soc-component.c | 10 ++++++++++ sound/soc/soc-pcm.c | 6 +----- 3 files changed, 15 insertions(+), 5 deletions(-)
include/sound/soc-component.h +4 -0
@@ -322,4 +322,8 @@ int snd_soc_component_force_enable_pin_unlocked(struct snd_soc_component *component, const char *pin); +/* component driver ops */ +int snd_soc_component_open (struct snd_soc_component *component, +struct snd_pcm_substream *substream); +#endif /* __SOC_COMPONENT_H */
sound/soc/soc-component.c +10 -0
@@ -285,3 +285,13 @@ void snd_soc_component_module_put(struct snd_soc_component *component,if (component->driver->module_get_upon_open == !!has_flags)module_put (component->dev->driver->owner); } + +int snd_soc_component_open (struct snd_soc_component *component, +struct snd_pcm_substream *substream) +{ +if (component->driver->ops && + component->driver->ops->open) +return component->driver->ops->open (substream); + +return 0 ; +}
sound/soc/soc-pcm.c +1 -5
@@ -447,11 +447,7 @@ static int soc_pcm_components_open(struct snd_pcm_substream *substream,return ret; } -if (!component->driver->ops || - !component->driver->ops->open) -continue ; - - ret = component->driver->ops->open (substream); + ret =snd_soc_component_open (component, substream);if (ret <0 ) { dev_err(component->dev, "ASoC: can't open component %s: %d\n",
Signature · 1 line
2.7.4
PATCH 4/25 ASoC: soc-component: add snd_soc_component_close()
In reply to Kuninori MorimotoFrom: Kuninori Morimoto <[email protected]>
Current ALSA SoC is directly using component->driver->ops->xxx, thus, it is deep nested, and makes code difficult to read, and is not good for encapsulation.
This patch adds new snd_soc_component_close() and use it.
--- include/sound/soc-component.h | 2 ++ sound/soc/soc-component.c | 10 ++++++++++ sound/soc/soc-pcm.c | 5 +---- 3 files changed, 13 insertions(+), 4 deletions(-)
include/sound/soc-component.h +2 -0
@@ -325,5 +325,7 @@ int snd_soc_component_force_enable_pin_unlocked(/* component driver ops */ 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);#endif /* __SOC_COMPONENT_H */
sound/soc/soc-component.c +10 -0
@@ -295,3 +295,13 @@ int snd_soc_component_open(struct snd_soc_component *component,return 0 ; } + +int snd_soc_component_close (struct snd_soc_component *component, +struct snd_pcm_substream *substream) +{ +if (component->driver->ops && + component->driver->ops->close) +return component->driver->ops->close (substream); + +return 0 ; +}
sound/soc/soc-pcm.c +1 -4
@@ -472,10 +472,7 @@ static int soc_pcm_components_close(struct snd_pcm_substream *substream,if (component == last)break ; -if (component->driver->ops && - component->driver->ops->close) - component->driver->ops->close (substream); - +snd_soc_component_close (component, substream);snd_soc_component_module_put (component,1 ); }
Signature · 1 line
2.7.4
PATCH 5/25 ASoC: soc-component: add snd_soc_component_prepare()
In reply to Kuninori MorimotoFrom: Kuninori Morimoto <[email protected]>
Current ALSA SoC is directly using component->driver->ops->xxx, thus, it is deep nested, and makes code difficult to read, and is not good for encapsulation.
This patch adds new snd_soc_component_prepare() and use it.
--- include/sound/soc-component.h | 2 ++ sound/soc/soc-component.c | 10 ++++++++++ sound/soc/soc-pcm.c | 6 +----- 3 files changed, 13 insertions(+), 5 deletions(-)
include/sound/soc-component.h +2 -0
@@ -327,5 +327,7 @@ 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);#endif /* __SOC_COMPONENT_H */
sound/soc/soc-component.c +10 -0
@@ -305,3 +305,13 @@ int snd_soc_component_close(struct snd_soc_component *component,return 0 ; } + +int snd_soc_component_prepare (struct snd_soc_component *component, +struct snd_pcm_substream *substream) +{ +if (component->driver->ops && + component->driver->ops->prepare) +return component->driver->ops->prepare (substream); + +return 0 ; +}
sound/soc/soc-pcm.c +1 -5
@@ -774,11 +774,7 @@ static int soc_pcm_prepare(struct snd_pcm_substream *substream)for_each_rtdcom (rtd, rtdcom) { component = rtdcom->component; -if (!component->driver->ops || - !component->driver->ops->prepare) -continue ; - - ret = component->driver->ops->prepare (substream); +snd_soc_component_prepare (component, substream);if (ret <0 ) {dev_err (component->dev,"ASoC: platform prepare error: %d\n" , ret);
Signature · 1 line
2.7.4
Re: [PATCH 05/25] ASoC: soc-component: add snd_soc_component_prepare()
On 2019-07-24 03:51, Kuninori Morimoto wrote:> +
Quoted 17 lines
sound/soc/soc-component.c +9
-0+int snd_soc_component_prepare (struct snd_soc_component *component, +struct snd_pcm_substream *substream) +{ +if (component->driver->ops && + component->driver->ops->prepare) +return component->driver->ops->prepare (substream); + +return 0 ; +}sound/soc/soc-pcm.c +0
-0@@ -774,11 +774,7 @@ static int soc_pcm_prepare(struct snd_pcm_substream *substream)for_each_rtdcom (rtd, rtdcom) { component = rtdcom->component;
sound/soc/soc-pcm.c static int soc_pcm_prepare(struct snd_pcm_substream *substream) · line 780
Quoted 10 lines
sound/soc/soc-pcm.c +1
-5-if (!component->driver->ops || - !component->driver->ops->prepare) -continue ; - - ret = component->driver->ops->prepare (substream); +snd_soc_component_prepare (component, substream);if (ret <0 ) {dev_err (component->dev,"ASoC: platform prepare error: %d\n" , ret);
Compared to old code, ret gets ignored here. Guess unintended modification?
Re: [PATCH 05/25] ASoC: soc-component: add snd_soc_component_prepare()
Hi Cezary
Quoted 7 lines
Quoted 7 lines
sound/soc/soc-pcm.c +0
-3@@ -774,11 +774,7 @@ static int soc_pcm_prepare(struct snd_pcm_substream *substream)for_each_rtdcom (rtd, rtdcom) { component = rtdcom->component; - if (!component->driver->ops || - !component->driver->ops->prepare) - continue; -
Quoted 8 lines
sound/soc/soc-pcm.c static int soc_pcm_prepare(struct snd_pcm_substream *substream) · line 780
Quoted 6 lines
sound/soc/soc-pcm.c +1
-1- ret = component->driver->ops->prepare (substream); +snd_soc_component_prepare (component, substream);if (ret <0 ) {dev_err (component->dev,"ASoC: platform prepare error: %d\n" , ret);Compared to old code, ret gets ignored here. Guess unintended modification?
Thank you for your report.
Yes, I have noticed same issue.
will be fixed at v2
Thank you for your help !!
Best regards
---
Kuninori Morimoto
PATCH 6/25 ASoC: soc-component: add snd_soc_component_hw_params()
In reply to Kuninori MorimotoFrom: Kuninori Morimoto <[email protected]>
Current ALSA SoC is directly using component->driver->ops->xxx, thus, it is deep nested, and makes code difficult to read, and is not good for encapsulation.
This patch adds new snd_soc_component_hw_params() and use it.
--- include/sound/soc-component.h | 3 +++ sound/soc/soc-component.c | 11 +++++++++++ sound/soc/soc-pcm.c | 6 +----- 3 files changed, 15 insertions(+), 5 deletions(-)
include/sound/soc-component.h +3 -0
@@ -329,5 +329,8 @@ 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);#endif /* __SOC_COMPONENT_H */
sound/soc/soc-component.c +11 -0
@@ -315,3 +315,14 @@ int snd_soc_component_prepare(struct snd_soc_component *component,return 0 ; } + +int snd_soc_component_hw_params (struct snd_soc_component *component, +struct snd_pcm_substream *substream, +struct snd_pcm_hw_params *params) +{ +if (component->driver->ops && + component->driver->ops->hw_params) +return component->driver->ops->hw_params (substream, params); + +return 0 ; +}
sound/soc/soc-pcm.c +1 -5
@@ -940,11 +940,7 @@ static int soc_pcm_hw_params(struct snd_pcm_substream *substream,for_each_rtdcom (rtd, rtdcom) { component = rtdcom->component; -if (!component->driver->ops || - !component->driver->ops->hw_params) -continue ; - - ret = component->driver->ops->hw_params (substream, params); + ret =snd_soc_component_hw_params (component, substream, params);if (ret <0 ) { dev_err(component->dev, "ASoC: %s hw params failed: %d\n",
Signature · 1 line
2.7.4
PATCH 7/25 ASoC: soc-component: add snd_soc_component_hw_free()
In reply to Kuninori MorimotoFrom: Kuninori Morimoto <[email protected]>
Current ALSA SoC is directly using component->driver->ops->xxx, thus, it is deep nested, and makes code difficult to read, and is not good for encapsulation.
This patch adds new snd_soc_component_hw_free() and use it.
--- include/sound/soc-component.h | 2 ++ sound/soc/soc-component.c | 10 ++++++++++ sound/soc/soc-pcm.c | 6 +----- 3 files changed, 13 insertions(+), 5 deletions(-)
include/sound/soc-component.h +2 -0
@@ -332,5 +332,7 @@ int snd_soc_component_prepare(struct snd_soc_component *component,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);#endif /* __SOC_COMPONENT_H */
sound/soc/soc-component.c +10 -0
@@ -326,3 +326,13 @@ int snd_soc_component_hw_params(struct snd_soc_component *component,return 0 ; } + +int snd_soc_component_hw_free (struct snd_soc_component *component, +struct snd_pcm_substream *substream) +{ +if (component->driver->ops && + component->driver->ops->hw_free) +return component->driver->ops->hw_free (substream); + +return 0 ; +}
sound/soc/soc-pcm.c +1 -5
@@ -843,11 +843,7 @@ static int soc_pcm_components_hw_free(struct snd_pcm_substream *substream,if (component == last)break ; -if (!component->driver->ops || - !component->driver->ops->hw_free) -continue ; - - component->driver->ops->hw_free (substream); +snd_soc_component_hw_free (component, substream); }return 0 ;
Signature · 1 line
2.7.4
Re: [PATCH 07/25] ASoC: soc-component: add snd_soc_component_hw_free()
Quoted 52 lines · Kuninori Morimoto
From: Kuninori Morimoto <[email protected]>
Current ALSA SoC is directly using
component->driver->ops->xxx, thus, it is deep nested, and makes code difficult to read, and is not good for encapsulation.
This patch adds newsnd_soc_component_hw_free()and use it.Signed-off-by Kuninori Morimoto <[email protected]>--- include/sound/soc-component.h | 2 ++ sound/soc/soc-component.c | 10 ++++++++++ sound/soc/soc-pcm.c | 6 +----- 3 files changed, 13 insertions(+), 5 deletions(-)include/sound/soc- renamed from include/sound/soc-component.h +0
-0
component.h
index ac93189..9ec67a3 100644include/sound/soc-component.h +2
-0@@ -332,5 +332,7 @@ int snd_soc_component_prepare(structsnd_soc_component *component, 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);#endif /*
__SOC_COMPONENT_H*/sound/soc/soc-component.c +10
-0@@ -326,3 +326,13 @@ int snd_soc_component_hw_params(structsnd_soc_component *component, return 0; } + +int snd_soc_component_hw_free (struct snd_soc_component *component, +struct snd_pcm_substream *substream) +{ +if (component->driver->ops && + component->driver->ops->hw_free) +return component->driver->ops->hw_free (substream); + +return 0 ; +}sound/soc/soc-pcm.c +0
-0
sound/soc/soc-pcm.c static int soc_pcm_components_hw_free(struct · line 847
Quoted 10 lines
sound/soc/soc-pcm.c +1
-5@@ -843,11 +843,7 @@ static int soc_pcm_components_hw_free(struct snd_pcm_substream *substream, if (component == last) break; -if (!component->driver->ops || - !component->driver->ops->hw_free) -continue ; - - component->driver->ops->hw_free (substream); +snd_soc_component_hw_free (component, substream);
Morimoto-san,
Just wondering why we dont care about the return value here. I see that the original code ignores the return value too but is it something that should be addressed?
Thanks,
Ranjani
Quoted 3 lines
sound/soc/soc-pcm.c +0
-0}return 0;
Re: [PATCH 07/25] ASoC: soc-component: add snd_soc_component_hw_free()
Hi Ranjani
Quoted 13 lines
sound/soc/soc-pcm.c static int soc_pcm_components_hw_free(struct · line 847
Quoted 11 lines
sound/soc/soc-pcm.c +1
-5@@ -843,11 +843,7 @@ static int soc_pcm_components_hw_free(struct snd_pcm_substream *substream, if (component == last) break; -if (!component->driver->ops || - !component->driver->ops->hw_free) -continue ; - - component->driver->ops->hw_free (substream); +snd_soc_component_hw_free (component, substream);Morimoto-san,
Quoted 3 lines
Just wondering why we dont care about the return value here. I see that the original code ignores the return value too but is it something that should be addressed?
Yes, indeed.
Thank you for your feedback.
I will fix up it at v2
Thank you for your help !!
Best regards
---
Kuninori Morimoto
PATCH 8/25 ASoC: soc-component: add snd_soc_component_trigger()
In reply to Kuninori MorimotoFrom: Kuninori Morimoto <[email protected]>
Current ALSA SoC is directly using component->driver->ops->xxx, thus, it is deep nested, and makes code difficult to read, and is not good for encapsulation.
This patch adds new snd_soc_component_trigger() and use it.
--- include/sound/soc-component.h | 3 +++ sound/soc/soc-component.c | 11 +++++++++++ sound/soc/soc-pcm.c | 6 +----- 3 files changed, 15 insertions(+), 5 deletions(-)
include/sound/soc-component.h +3 -0
@@ -334,5 +334,8 @@ int snd_soc_component_hw_params(struct snd_soc_component *component, 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, +struct snd_pcm_substream *substream, +int cmd);#endif /* __SOC_COMPONENT_H */
sound/soc/soc-component.c +11 -0
@@ -336,3 +336,14 @@ int snd_soc_component_hw_free(struct snd_soc_component *component,return 0 ; } + +int snd_soc_component_trigger (struct snd_soc_component *component, +struct snd_pcm_substream *substream, +int cmd) +{ +if (component->driver->ops && + component->driver->ops->trigger) +return component->driver->ops->trigger (substream, cmd); + +return 0 ; +}
sound/soc/soc-pcm.c +1 -5
@@ -1053,11 +1053,7 @@ static int soc_pcm_trigger(struct snd_pcm_substream *substream, int cmd)for_each_rtdcom (rtd, rtdcom) { component = rtdcom->component; -if (!component->driver->ops || - !component->driver->ops->trigger) -continue ; - - ret = component->driver->ops->trigger (substream, cmd); + ret =snd_soc_component_trigger (component, substream, cmd);if (ret <0 )return ret; }
Signature · 1 line
2.7.4
PATCH 9/25 ASoC: soc-component: add snd_soc_component_pointer()
In reply to Kuninori MorimotoFrom: Kuninori Morimoto <[email protected]>
Current ALSA SoC is directly using component->driver->ops->xxx, thus, it is deep nested, and makes code difficult to read, and is not good for encapsulation.
This patch adds new snd_soc_component_pointer() and use it.
--- include/sound/soc-component.h | 2 ++ sound/soc/soc-component.c | 10 ++++++++++ sound/soc/soc-pcm.c | 9 +++------ 3 files changed, 15 insertions(+), 6 deletions(-)
include/sound/soc-component.h +2 -0
@@ -337,5 +337,7 @@ int snd_soc_component_hw_free(struct snd_soc_component *component,int snd_soc_component_trigger (struct snd_soc_component *component,struct snd_pcm_substream *substream,int cmd); +int snd_soc_component_pointer (struct snd_soc_component *component, +struct snd_pcm_substream *substream);#endif /* __SOC_COMPONENT_H */
sound/soc/soc-component.c +10 -0
@@ -347,3 +347,13 @@ int snd_soc_component_trigger(struct snd_soc_component *component,return 0 ; } + +int snd_soc_component_pointer (struct snd_soc_component *component, +struct snd_pcm_substream *substream) +{ +if (component->driver->ops && + component->driver->ops->pointer) +return component->driver->ops->pointer (substream); + +return 0 ; +}
sound/soc/soc-pcm.c +3 -6
@@ -1115,13 +1115,10 @@ static snd_pcm_uframes_t soc_pcm_pointer(struct snd_pcm_substream *substream)for_each_rtdcom (rtd, rtdcom) { component = rtdcom->component; -if (!component->driver->ops || - !component->driver->ops->pointer) -continue ; - + offset =snd_soc_component_pointer (component, substream);/* FIXME: use 1st pointer */ - offset = component->driver->ops->pointer (substream); -break ; +if (offset >0 ) +break ; }/* base delay if assigned in pointer callback */ delay = runtime->delay;
Signature · 1 line
2.7.4
Re: [PATCH 09/25] ASoC: soc-component: add snd_soc_component_pointer()
Quoted 24 lines · Kuninori Morimoto
From: Kuninori Morimoto <[email protected]>
Current ALSA SoC is directly using
component->driver->ops->xxx, thus, it is deep nested, and makes code difficult to read, and is not good for encapsulation.
This patch adds newsnd_soc_component_pointer()and use it.Signed-off-by Kuninori Morimoto <[email protected]>---
sound/soc/soc-component.c +9
-0+int snd_soc_component_pointer (struct snd_soc_component *component, +struct snd_pcm_substream *substream) +{ +if (component->driver->ops && + component->driver->ops->pointer) +return component->driver->ops->pointer (substream); + +return 0 ; +}@@ -1115,13 +1115,10 @@ static snd_pcm_uframes_t soc_pcm_pointer(struct snd_pcm_substream *substream)for_each_rtdcom (rtd, rtdcom) { component = rtdcom->component;
sound/soc/soc-component.c static snd_pcm_uframes_t soc_pcm_pointer(struct snd_pcm_substream *substream) · line 1121
Quoted 10 lines
sound/soc/soc-component.c +3
-6-if (!component->driver->ops || - !component->driver->ops->pointer) -continue ; - + offset =snd_soc_component_pointer (component, substream);/* FIXME: use 1st pointer */ - offset = component->driver->ops->pointer (substream); -break ; +if (offset >0 ) +break ;
This doesn't feel like it is equivalent to the previous code, is zero not a valid value for pointer to return?
Thanks,
Charles
Re: [PATCH 09/25] ASoC: soc-component: add snd_soc_component_pointer()
Hi Charles
Quoted 14 lines
Quoted 14 lines
sound/soc/soc-component.c +9
-0+int snd_soc_component_pointer (struct snd_soc_component *component, +struct snd_pcm_substream *substream) +{ +if (component->driver->ops && + component->driver->ops->pointer) +return component->driver->ops->pointer (substream); + +return 0 ; +}@@ -1115,13 +1115,10 @@ static snd_pcm_uframes_t soc_pcm_pointer(struct snd_pcm_substream *substream)for_each_rtdcom (rtd, rtdcom) { component = rtdcom->component;
Quoted 13 lines
sound/soc/soc-pcm.c static snd_pcm_uframes_t soc_pcm_pointer(struct snd_pcm_substream *substream) · line 1121
Quoted 10 lines
sound/soc/soc-pcm.c +3
-6-if (!component->driver->ops || - !component->driver->ops->pointer) -continue ; - + offset =snd_soc_component_pointer (component, substream);/* FIXME: use 1st pointer */ - offset = component->driver->ops->pointer (substream); -break ; +if (offset >0 ) +break ;This doesn't feel like it is equivalent to the previous code, is zero not a valid value for pointer to return?
Hmm.. indeed.
using -ENOTSUPP make sense ?
Thank you for your help !!
Best regards
---
Kuninori Morimoto
PATCH 10/25 ASoC: soc-component: add snd_soc_component_ioctrl()
In reply to Kuninori MorimotoFrom: Kuninori Morimoto <[email protected]>
Current ALSA SoC is directly using component->driver->ops->xxx, thus, it is deep nested, and makes code difficult to read, and is not good for encapsulation.
This patch adds new snd_soc_component_ioctrl() and use it.
--- include/sound/soc-component.h | 3 +++ sound/soc/soc-component.c | 11 +++++++++++ sound/soc/soc-pcm.c | 10 +++++----- 3 files changed, 19 insertions(+), 5 deletions(-)
include/sound/soc-component.h +3 -0
@@ -339,5 +339,8 @@ int snd_soc_component_trigger(struct snd_soc_component *component, int cmd);int snd_soc_component_pointer (struct snd_soc_component *component,struct snd_pcm_substream *substream); +int snd_soc_component_ioctl (struct snd_soc_component *component, +struct snd_pcm_substream *substream, +unsigned int cmd,void *arg);#endif /* __SOC_COMPONENT_H */
sound/soc/soc-component.c +11 -0
@@ -357,3 +357,14 @@ int snd_soc_component_pointer(struct snd_soc_component *component,return 0 ; } + +int snd_soc_component_ioctl (struct snd_soc_component *component, +struct snd_pcm_substream *substream, +unsigned int cmd,void *arg) +{ +if (component->driver->ops && + component->driver->ops->ioctl) +return component->driver->ops->ioctl (substream, cmd, arg); + +return -ENOTSUPP ; +}
sound/soc/soc-pcm.c +5 -5
@@ -1116,6 +1116,7 @@ static snd_pcm_uframes_t soc_pcm_pointer(struct snd_pcm_substream *substream) component = rtdcom->component; offset =snd_soc_component_pointer (component, substream); +/* FIXME: use 1st pointer */ if (offset >0 )break ;
@@ -2455,16 +2456,15 @@ static int soc_pcm_ioctl(struct snd_pcm_substream *substream,struct snd_soc_pcm_runtime *rtd = substream->private_data;struct snd_soc_component *component;struct snd_soc_rtdcom_list *rtdcom; +int ret;for_each_rtdcom (rtd, rtdcom) { component = rtdcom->component; -if (!component->driver->ops || - !component->driver->ops->ioctl) -continue ; - + ret =snd_soc_component_ioctl (component, substream, cmd, arg);/* FIXME: use 1st ioctl */ -return component->driver->ops->ioctl (substream, cmd, arg); +if (ret != -ENOTSUPP ) +return ret; }return snd_pcm_lib_ioctl (substream, cmd, arg);
Signature · 1 line
2.7.4
Re: [PATCH 10/25] ASoC: soc-component: add snd_soc_component_ioctrl()
Quoted 15 lines · Kuninori Morimoto
From: Kuninori Morimoto <[email protected]>
Current ALSA SoC is directly using
component->driver->ops->xxx, thus, it is deep nested, and makes code difficult to read, and is not good for encapsulation.
This patch adds newsnd_soc_component_ioctrl()and use it.Signed-off-by Kuninori Morimoto <[email protected]>---
sound/soc/soc-pcm.c +0
-0
sound/soc/soc-pcm.c static snd_pcm_uframes_t soc_pcm_pointer(struct snd_pcm_substream *substream) · line 1119
Quoted 4 lines
sound/soc/soc-pcm.c +1
-0@@ -1116,6 +1116,7 @@ static snd_pcm_uframes_t soc_pcm_pointer(struct snd_pcm_substream *substream) component = rtdcom->component; offset =snd_soc_component_pointer (component, substream); +
This whitespace change belongs in the previous patch.
Quoted 11 lines
sound/soc/soc-pcm.c +1
-0/* FIXME: use 1st pointer */ if (offset >0 )break ;@@ -2455,16 +2456,15 @@ static int soc_pcm_ioctl(struct snd_pcm_substream *substream,struct snd_soc_pcm_runtime *rtd = substream->private_data;struct snd_soc_component *component;struct snd_soc_rtdcom_list *rtdcom; +int ret;for_each_rtdcom (rtd, rtdcom) { component = rtdcom->component;
sound/soc/soc-pcm.c static int soc_pcm_ioctl(struct snd_pcm_substream *substream, · line 2467
Quoted 10 lines
sound/soc/soc-pcm.c +3
-5-if (!component->driver->ops || - !component->driver->ops->ioctl) -continue ; - + ret =snd_soc_component_ioctl (component, substream, cmd, arg);/* FIXME: use 1st ioctl */ -return component->driver->ops->ioctl (substream, cmd, arg); +if (ret != -ENOTSUPP ) +return ret;
This feels a little forced, and also changes behaviour if any ioctl callbacks already report -ENOTSUPP.
I wonder if for some/all of these functions it might be worth abstracting them at a higher level so the whole for_each_rtdcom loop moves into the helper function similar to what I did with compress stuff, for example in these patches:
1e57b82891ad ("ASoC: compress: Add helper functions for component open/free") 4ef0ecb80e34 ("ASoC: compress: Add helper functions for component trigger/set_params")
Thanks,
Charles
Re: [PATCH 10/25] ASoC: soc-component: add snd_soc_component_ioctrl()
Hi Charles
Quoted 16 lines
sound/soc/soc-pcm.c static int soc_pcm_ioctl(struct snd_pcm_substream *substream, · line 2467
Quoted 12 lines
sound/soc/soc-pcm.c +3
-5for_each_rtdcom (rtd, rtdcom) { component = rtdcom->component; -if (!component->driver->ops || - !component->driver->ops->ioctl) -continue ; - + ret =snd_soc_component_ioctl (component, substream, cmd, arg);/* FIXME: use 1st ioctl */ -return component->driver->ops->ioctl (substream, cmd, arg); +if (ret != -ENOTSUPP ) +return ret;This feels a little forced, and also changes behaviour if any ioctl callbacks already report
-ENOTSUPP.
Quoted 7 lines
I wonder if for some/all of these functions it might be worth abstracting them at a higher level so the whole
for_each_rtdcomloop moves into the helper function similar to what I did with compress stuff, for example in these patches:
1e57b82891ad("ASoC: compress: Add helper functions for component open/free")4ef0ecb80e34("ASoC: compress: Add helper functions for component trigger/set_params")
Thank you for your feedback.
It sounds nice idea for me.
will fix in v2
Thank you for your help !!
Best regards
---
Kuninori Morimoto
PATCH 11/25 ASoC: soc-component: add snd_soc_component_copy_user()
In reply to Kuninori MorimotoFrom: Kuninori Morimoto <[email protected]>
Current ALSA SoC is directly using component->driver->ops->xxx, thus, it is deep nested, and makes code difficult to read, and is not good for encapsulation.
This patch adds new snd_soc_component_copy_user() and use it.
--- include/sound/soc-component.h | 4 ++++ sound/soc/soc-component.c | 13 +++++++++++++ sound/soc/soc-pcm.c | 11 +++++------ 3 files changed, 22 insertions(+), 6 deletions(-)
include/sound/soc-component.h +4 -0
@@ -342,5 +342,9 @@ int snd_soc_component_pointer(struct snd_soc_component *component,int snd_soc_component_ioctl (struct snd_soc_component *component,struct snd_pcm_substream *substream,unsigned int cmd,void *arg); +int snd_soc_component_copy_user (struct snd_soc_component *component, +struct snd_pcm_substream *substream, +int channel,unsigned long pos, +void __user *buf,unsigned long bytes);#endif /* __SOC_COMPONENT_H */
sound/soc/soc-component.c +13 -0
@@ -368,3 +368,16 @@ int snd_soc_component_ioctl(struct snd_soc_component *component,return -ENOTSUPP ; } + +int snd_soc_component_copy_user (struct snd_soc_component *component, +struct snd_pcm_substream *substream, +int channel,unsigned long pos, +void __user *buf,unsigned long bytes) +{ +if (component->driver->ops && + component->driver->ops->copy_user) +return component->driver->ops->copy_user (substream, channel, + pos, buf, bytes); + +return -ENOTSUPP ; +}
sound/soc/soc-pcm.c +5 -6
@@ -2862,17 +2862,16 @@ static int soc_rtdcom_copy_user(struct snd_pcm_substream *substream, int channelstruct snd_soc_pcm_runtime *rtd = substream->private_data;struct snd_soc_rtdcom_list *rtdcom;struct snd_soc_component *component; +int ret;for_each_rtdcom (rtd, rtdcom) { component = rtdcom->component; -if (!component->driver->ops || - !component->driver->ops->copy_user) -continue ; - + ret =snd_soc_component_copy_user (component, substream, channel, + pos, buf, bytes);/* FIXME. it returns 1st copy now */ -return component->driver->ops->copy_user (substream, channel, - pos, buf, bytes); +if (ret != -ENOTSUPP ) +return ret; }return -EINVAL ;
Signature · 1 line
2.7.4
PATCH 12/25 ASoC: soc-component: add snd_soc_component_page()
In reply to Kuninori MorimotoFrom: Kuninori Morimoto <[email protected]>
Current ALSA SoC is directly using component->driver->ops->xxx, thus, it is deep nested, and makes code difficult to read, and is not good for encapsulation.
This patch adds new snd_soc_component_page() and use it.
--- include/sound/soc-component.h | 3 +++ sound/soc/soc-component.c | 11 +++++++++++ sound/soc/soc-pcm.c | 8 ++------ 3 files changed, 16 insertions(+), 6 deletions(-)
include/sound/soc-component.h +3 -0
@@ -346,5 +346,8 @@ int snd_soc_component_copy_user(struct snd_soc_component *component,struct snd_pcm_substream *substream, int channel, unsigned long pos, void __user *buf, unsigned long bytes); +struct page *snd_soc_component_page (struct snd_soc_component *component, +struct snd_pcm_substream *substream, +unsigned long offset);#endif /* __SOC_COMPONENT_H */
sound/soc/soc-component.c +11 -0
@@ -381,3 +381,14 @@ int snd_soc_component_copy_user(struct snd_soc_component *component,return -ENOTSUPP ; } + +struct page *snd_soc_component_page (struct snd_soc_component *component, +struct snd_pcm_substream *substream, +unsigned long offset) +{ +if (component->driver->ops && + component->driver->ops->page) +return component->driver->ops->page (substream, offset); + +return ERR_PTR (-ENOTSUPP ); +}
sound/soc/soc-pcm.c +2 -6
@@ -2932,13 +2932,9 @@ static struct page *soc_rtdcom_page(struct snd_pcm_substream *substream,for_each_rtdcom (rtd, rtdcom) { component = rtdcom->component; -if (!component->driver->ops || - !component->driver->ops->page) -continue ; -/* FIXME. it returns 1st page now */ - page = component->driver->ops->page (substream, offset); -if (page) + page =snd_soc_component_page (component, substream, offset); +if (page !=ERR_PTR (-ENOTSUPP ))return page; }
Signature · 1 line
2.7.4
PATCH 13/25 ASoC: soc-component: add snd_soc_component_mmap()
In reply to Kuninori MorimotoFrom: Kuninori Morimoto <[email protected]>
Current ALSA SoC is directly using component->driver->ops->xxx, thus, it is deep nested, and makes code difficult to read, and is not good for encapsulation.
This patch adds new snd_soc_component_mmap() and use it.
--- include/sound/soc-component.h | 3 +++ sound/soc/soc-component.c | 11 +++++++++++ sound/soc/soc-pcm.c | 9 ++++----- 3 files changed, 18 insertions(+), 5 deletions(-)
include/sound/soc-component.h +3 -0
@@ -349,5 +349,8 @@ int snd_soc_component_copy_user(struct snd_soc_component *component,struct page *snd_soc_component_page (struct snd_soc_component *component,struct snd_pcm_substream *substream,unsigned long offset); +int snd_soc_component_mmap (struct snd_soc_component *component, +struct snd_pcm_substream *substream, +struct vm_area_struct *vma);#endif /* __SOC_COMPONENT_H */
sound/soc/soc-component.c +11 -0
@@ -392,3 +392,14 @@ struct page *snd_soc_component_page(struct snd_soc_component *component,return ERR_PTR (-ENOTSUPP ); } + +int snd_soc_component_mmap (struct snd_soc_component *component, +struct snd_pcm_substream *substream, +struct vm_area_struct *vma) +{ +if (component->driver->ops && + component->driver->ops->mmap) +return component->driver->ops->mmap (substream, vma); + +return -ENOTSUPP ; +}
sound/soc/soc-pcm.c +4 -5
@@ -2947,16 +2947,15 @@ static int soc_rtdcom_mmap(struct snd_pcm_substream *substream,struct snd_soc_pcm_runtime *rtd = substream->private_data;struct snd_soc_rtdcom_list *rtdcom;struct snd_soc_component *component; +int ret;for_each_rtdcom (rtd, rtdcom) { component = rtdcom->component; -if (!component->driver->ops || - !component->driver->ops->mmap) -continue ; - + ret =snd_soc_component_mmap (component, substream, vma);/* FIXME. it returns 1st mmap now */ -return component->driver->ops->mmap (substream, vma); +if (ret != -ENOTSUPP ) +return ret; }return -EINVAL ;
Signature · 1 line
2.7.4
PATCH 14/25 ASoC: soc-component: add snd_soc_component_pcm_new()
In reply to Kuninori MorimotoFrom: Kuninori Morimoto <[email protected]>
Current ALSA SoC is directly using component->driver->xxx, thus, it is deep nested, and makes code difficult to read, and is not good for encapsulation.
This patch adds new snd_soc_component_pcm() and use it.
--- include/sound/soc-component.h | 2 ++ sound/soc/soc-component.c | 9 +++++++++ sound/soc/soc-pcm.c | 5 +---- 3 files changed, 12 insertions(+), 4 deletions(-)
include/sound/soc-component.h +2 -0
@@ -352,5 +352,7 @@ struct page *snd_soc_component_page(struct snd_soc_component *component,int snd_soc_component_mmap (struct snd_soc_component *component,struct snd_pcm_substream *substream,struct vm_area_struct *vma); +int snd_soc_component_pcm_new (struct snd_soc_component *component, +struct snd_soc_pcm_runtime *rtd);#endif /* __SOC_COMPONENT_H */
sound/soc/soc-component.c +9 -0
@@ -403,3 +403,12 @@ int snd_soc_component_mmap(struct snd_soc_component *component,return -ENOTSUPP ; } + +int snd_soc_component_pcm_new (struct snd_soc_component *component, +struct snd_soc_pcm_runtime *rtd) +{ +if (component->driver->pcm_new) +return component->driver->pcm_new (rtd); + +return 0 ; +}
sound/soc/soc-pcm.c +1 -4
@@ -3089,10 +3089,7 @@ int soc_new_pcm(struct snd_soc_pcm_runtime *rtd, int num)for_each_rtdcom (rtd, rtdcom) { component = rtdcom->component; -if (!component->driver->pcm_new) -continue ; - - ret = component->driver->pcm_new (rtd); + ret =snd_soc_component_pcm_new (component, rtd);if (ret <0 ) { dev_err(component->dev, "ASoC: pcm constructor failed: %d\n",
Signature · 1 line
2.7.4
PATCH 15/25 ASoC: soc-component: add snd_soc_component_pcm_free()
In reply to Kuninori MorimotoFrom: Kuninori Morimoto <[email protected]>
Current ALSA SoC is directly using component->driver->xxx, thus, it is deep nested, and makes code difficult to read, and is not good for encapsulation.
This patch adds new snd_soc_component_pcm_free() and use it.
--- include/sound/soc-component.h | 2 ++ sound/soc/soc-component.c | 7 +++++++ sound/soc/soc-pcm.c | 3 +-- 3 files changed, 10 insertions(+), 2 deletions(-)
include/sound/soc-component.h +2 -0
@@ -354,5 +354,7 @@ int snd_soc_component_mmap(struct snd_soc_component *component, struct vm_area_struct *vma);int snd_soc_component_pcm_new (struct snd_soc_component *component,struct snd_soc_pcm_runtime *rtd); +void snd_soc_component_pcm_free (struct snd_soc_component *component, +struct snd_pcm *pcm);#endif /* __SOC_COMPONENT_H */
sound/soc/soc-component.c +7 -0
@@ -412,3 +412,10 @@ int snd_soc_component_pcm_new(struct snd_soc_component *component,return 0 ; } + +void snd_soc_component_pcm_free (struct snd_soc_component *component, +struct snd_pcm *pcm) +{ +if (component->driver->pcm_free) + component->driver->pcm_free (pcm); +}
sound/soc/soc-pcm.c +1 -2
@@ -2830,8 +2830,7 @@ static void soc_pcm_private_free(struct snd_pcm *pcm)for_each_rtdcom (rtd, rtdcom) { component = rtdcom->component; -if (component->driver->pcm_free) - component->driver->pcm_free (pcm); +snd_soc_component_pcm_free (component, pcm); } }
Signature · 1 line
2.7.4
PATCH 16/25 ASoC: soc-component: add snd_soc_component_suspend()
In reply to Kuninori MorimotoFrom: Kuninori Morimoto <[email protected]>
Current ALSA SoC is directly using component->driver->xxx, thus, it is deep nested, and makes code difficult to read, and is not good for encapsulation.
This patch adds new snd_soc_component_suspend() and use it.
--- include/sound/soc-component.h | 1 + sound/soc/soc-component.c | 7 +++++++ sound/soc/soc-core.c | 4 +--- 3 files changed, 9 insertions(+), 3 deletions(-)
include/sound/soc-component.h +1 -0
@@ -356,5 +356,6 @@ int snd_soc_component_pcm_new(struct snd_soc_component *component, struct snd_soc_pcm_runtime *rtd);void snd_soc_component_pcm_free (struct snd_soc_component *component,struct snd_pcm *pcm); +void snd_soc_component_suspend (struct snd_soc_component *component);#endif /* __SOC_COMPONENT_H */
sound/soc/soc-component.c +7 -0
@@ -419,3 +419,10 @@ void snd_soc_component_pcm_free(struct snd_soc_component *component,if (component->driver->pcm_free) component->driver->pcm_free (pcm); } + +void snd_soc_component_suspend (struct snd_soc_component *component) +{ +if (component->driver->suspend) + component->driver->suspend (component); + component->suspended =1 ; +}
sound/soc/soc-core.c +1 -3
@@ -561,9 +561,7 @@ int snd_soc_suspend(struct device *dev)/* fall through */ case SND_SOC_BIAS_OFF : -if (component->driver->suspend) - component->driver->suspend (component); - component->suspended =1 ; +snd_soc_component_suspend (component);if (component->regmap)regcache_mark_dirty (component->regmap);/* deactivate pins to sleep state */
Signature · 1 line
2.7.4
PATCH 17/25 ASoC: soc-component: add snd_soc_component_resume()
In reply to Kuninori MorimotoFrom: Kuninori Morimoto <[email protected]>
Current ALSA SoC is directly using component->driver->xxx, thus, it is deep nested, and makes code difficult to read, and is not good for encapsulation.
This patch adds new snd_soc_component_resume() and use it.
--- include/sound/soc-component.h | 1 + sound/soc/soc-component.c | 7 +++++++ sound/soc/soc-core.c | 4 +--- 3 files changed, 9 insertions(+), 3 deletions(-)
include/sound/soc-component.h +1 -0
@@ -357,5 +357,6 @@ int snd_soc_component_pcm_new(struct snd_soc_component *component,void snd_soc_component_pcm_free (struct snd_soc_component *component,struct snd_pcm *pcm);void snd_soc_component_suspend (struct snd_soc_component *component); +void snd_soc_component_resume (struct snd_soc_component *component);#endif /* __SOC_COMPONENT_H */
sound/soc/soc-component.c +7 -0
@@ -426,3 +426,10 @@ void snd_soc_component_suspend(struct snd_soc_component *component) component->driver->suspend (component); component->suspended =1 ; } + +void snd_soc_component_resume (struct snd_soc_component *component) +{ +if (component->driver->resume) + component->driver->resume (component); + component->suspended =0 ; +}
sound/soc/soc-core.c +1 -3
@@ -634,9 +634,7 @@ static void soc_resume_deferred(struct work_struct *work)for_each_card_components (card, component) {if (component->suspended) { -if (component->driver->resume) - component->driver->resume (component); - component->suspended =0 ; +snd_soc_component_resume (component); } }
Signature · 1 line
2.7.4
PATCH 18/25 ASoC: soc-component: add snd_soc_component_is_suspended()
In reply to Kuninori MorimotoFrom: Kuninori Morimoto <[email protected]>
Current ALSA SoC is directly using component->xxx, But, it is not good for encapsulation.
This patch adds new snd_soc_component_is_suspended() and use it.
--- include/sound/soc-component.h | 1 + sound/soc/soc-component.c | 5 +++++ sound/soc/soc-core.c | 5 ++--- 3 files changed, 8 insertions(+), 3 deletions(-)
include/sound/soc-component.h +1 -0
@@ -358,5 +358,6 @@ void snd_soc_component_pcm_free(struct snd_soc_component *component, struct snd_pcm *pcm);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);#endif /* __SOC_COMPONENT_H */
sound/soc/soc-component.c +5 -0
@@ -433,3 +433,8 @@ void snd_soc_component_resume(struct snd_soc_component *component) component->driver->resume (component); component->suspended =0 ; } + +int snd_soc_component_is_suspended (struct snd_soc_component *component) +{ +return component->suspended; +}
sound/soc/soc-core.c +2 -3
@@ -544,7 +544,7 @@ int snd_soc_suspend(struct device *dev)* If there are paths active then the COMPONENT will be held * with bias _ON and should not be suspended. */ -if (!component->suspended) { +if (!snd_soc_component_is_suspended (component)) {switch (snd_soc_dapm_get_bias_level (dapm)) {case SND_SOC_BIAS_STANDBY :/*
@@ -633,9 +633,8 @@ static void soc_resume_deferred(struct work_struct *work) }for_each_card_components (card, component) { -if (component->suspended) { +if (snd_soc_component_is_suspended (component))snd_soc_component_resume (component); - } }for_each_card_rtds (card, rtd) {
Signature · 1 line
2.7.4
PATCH 19/25 ASoC: soc-component: add snd_soc_component_probe()
In reply to Kuninori MorimotoFrom: Kuninori Morimoto <[email protected]>
Current ALSA SoC is directly using component->driver->xxx, thus, it is deep nested, and makes code difficult to read, and is not good for encapsulation.
This patch adds new snd_soc_component_probe() and use it.
--- include/sound/soc-component.h | 1 + sound/soc/soc-component.c | 7 +++++++ sound/soc/soc-core.c | 12 +++++------- 3 files changed, 13 insertions(+), 7 deletions(-)
include/sound/soc-component.h +1 -0
@@ -359,5 +359,6 @@ void snd_soc_component_pcm_free(struct snd_soc_component *component,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); +int snd_soc_component_probe (struct snd_soc_component *component);#endif /* __SOC_COMPONENT_H */
sound/soc/soc-component.c +7 -0
@@ -438,3 +438,10 @@ int snd_soc_component_is_suspended(struct snd_soc_component *component) {return component->suspended; } + +int snd_soc_component_probe (struct snd_soc_component *component) +{ +if (component->driver->probe) +return component->driver->probe (component); +return 0 ; +}
sound/soc/soc-core.c +5 -7
@@ -1323,13 +1323,11 @@ static int soc_probe_component(struct snd_soc_card *card, } } -if (component->driver->probe) { - ret = component->driver->probe (component); -if (ret <0 ) { -dev_err (component->dev, -"ASoC: failed to probe component %d\n" , ret); - goto err_probe; - } + ret =snd_soc_component_probe (component); +if (ret <0 ) { +dev_err (component->dev, +"ASoC: failed to probe component %d\n" , ret); + goto err_probe; } WARN(dapm->idle_bias_off && dapm->bias_level != SND_SOC_BIAS_OFF,
Signature · 1 line
2.7.4
PATCH 20/25 ASoC: soc-component: add snd_soc_component_remove()
In reply to Kuninori MorimotoFrom: Kuninori Morimoto <[email protected]>
Current ALSA SoC is directly using component->driver->xxx, thus, it is deep nested, and makes code difficult to read, and is not good for encapsulation.
This patch adds new snd_soc_component_remove() and use it.
--- include/sound/soc-component.h | 1 + sound/soc/soc-component.c | 6 ++++++ sound/soc/soc-core.c | 3 +-- 3 files changed, 8 insertions(+), 2 deletions(-)
include/sound/soc-component.h +1 -0
@@ -360,5 +360,6 @@ 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);int snd_soc_component_probe (struct snd_soc_component *component); +void snd_soc_component_remove (struct snd_soc_component *component);#endif /* __SOC_COMPONENT_H */
sound/soc/soc-component.c +6 -0
@@ -445,3 +445,9 @@ int snd_soc_component_probe(struct snd_soc_component *component)return component->driver->probe (component);return 0 ; } + +void snd_soc_component_remove (struct snd_soc_component *component) +{ +if (component->driver->remove) + component->driver->remove (component); +}
sound/soc/soc-core.c +1 -2
@@ -970,8 +970,7 @@ static void soc_remove_component(struct snd_soc_component *component)if (!component->card)return ; -if (component->driver->remove) - component->driver->remove (component); +snd_soc_component_remove (component);soc_cleanup_component (component); }
Signature · 1 line
2.7.4
PATCH 21/25 ASoC: soc-component: add snd_soc_component_of_xlate_dai_id()
In reply to Kuninori MorimotoFrom: Kuninori Morimoto <[email protected]>
Current ALSA SoC is directly using component->driver->xxx, thus, it is deep nested, and makes code difficult to read, and is not good for encapsulation.
This patch adds new snd_soc_component_of_xlate_dai_id() and use it.
--- include/sound/soc-component.h | 2 ++ sound/soc/soc-component.c | 8 ++++++++ sound/soc/soc-core.c | 5 ++--- 3 files changed, 12 insertions(+), 3 deletions(-)
include/sound/soc-component.h +2 -0
@@ -361,5 +361,7 @@ void snd_soc_component_resume(struct snd_soc_component *component);int snd_soc_component_is_suspended (struct snd_soc_component *component);int snd_soc_component_probe (struct snd_soc_component *component);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);#endif /* __SOC_COMPONENT_H */
sound/soc/soc-component.c +8 -0
@@ -451,3 +451,11 @@ void snd_soc_component_remove(struct snd_soc_component *component)if (component->driver->remove) component->driver->remove (component); } + +int snd_soc_component_of_xlate_dai_id (struct snd_soc_component *component, +struct device_node *ep) +{ +if (component->driver->of_xlate_dai_id) +return component->driver->of_xlate_dai_id (component, ep); +return -ENOTSUPP ; +}
sound/soc/soc-core.c +2 -3
@@ -3380,9 +3380,8 @@ int snd_soc_get_dai_id(struct device_node *ep) ret = -ENOTSUPP ;mutex_lock (&client_mutex); component =soc_find_component (&dlc); -if (component && - component->driver->of_xlate_dai_id) - ret = component->driver->of_xlate_dai_id (component, ep); +if (component) + ret =snd_soc_component_of_xlate_dai_id (component, ep);mutex_unlock (&client_mutex);of_node_put (dlc.of_node);
Signature · 1 line
2.7.4
PATCH 22/25 ASoC: soc-component: add snd_soc_component_of_xlate_dai_name()
In reply to Kuninori MorimotoFrom: Kuninori Morimoto <[email protected]>
Current ALSA SoC is directly using component->driver->xxx, thus, it is deep nested, and makes code difficult to read, and is not good for encapsulation.
This patch adds new snd_soc_component_of_xlate_dai_name() and use it
--- include/sound/soc-component.h | 3 +++ sound/soc/soc-component.c | 10 ++++++++++ sound/soc/soc-core.c | 7 ++----- 3 files changed, 15 insertions(+), 5 deletions(-)
include/sound/soc-component.h +3 -0
@@ -363,5 +363,8 @@ int snd_soc_component_probe(struct snd_soc_component *component);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 snd_soc_component_of_xlate_dai_name (struct snd_soc_component *component, +struct of_phandle_args *args, +const char **dai_name);#endif /* __SOC_COMPONENT_H */
sound/soc/soc-component.c +10 -0
@@ -459,3 +459,13 @@ int snd_soc_component_of_xlate_dai_id(struct snd_soc_component *component,return component->driver->of_xlate_dai_id (component, ep);return -ENOTSUPP ; } + +int snd_soc_component_of_xlate_dai_name (struct snd_soc_component *component, +struct of_phandle_args *args, +const char **dai_name) +{ +if (component->driver->of_xlate_dai_name) +return component->driver->of_xlate_dai_name (component, + args, dai_name); +return -ENOTSUPP ; +}
sound/soc/soc-core.c +2 -5
@@ -3404,11 +3404,8 @@ int snd_soc_get_dai_name(struct of_phandle_args *args,if (component_of_node != args->np)continue ; -if (pos->driver->of_xlate_dai_name) { - ret = pos->driver->of_xlate_dai_name (pos, - args, - dai_name); - }else { + ret =snd_soc_component_of_xlate_dai_name (pos, args, dai_name); +if (ret == -ENOTSUPP ) {struct snd_soc_dai *dai;int id =-1 ;
Signature · 1 line
2.7.4
PATCH 23/25 ASoC: soc-component: move snd_soc_component_seq_notifier()
In reply to Kuninori MorimotoFrom: Kuninori Morimoto <[email protected]>
This patch moves snd_soc_component_seq_notifier() to soc-component.c It will be used at soc-dapm.c :: dapm_seq_run(),
but no effect by this patch.
static void dapm_seq_run(...)
{
...
=> if (cur_dapm && cur_dapm->seq_notifier) {
for (i = 0; i < ARRAY_SIZE(dapm_up_seq); i++)
if (sort[i] == cur_sort)
=> cur_dapm->seq_notifier(cur_dapm,
i,
cur_subseq);
}
...
}--- include/sound/soc-component.h | 4 ++++ sound/soc/soc-component.c | 9 +++++++++ sound/soc/soc-core.c | 11 +---------- 3 files changed, 14 insertions(+), 10 deletions(-)
include/sound/soc-component.h +4 -0
@@ -273,6 +273,10 @@ int snd_soc_component_set_pll(struct snd_soc_component *component, int pll_id,int snd_soc_component_set_jack (struct snd_soc_component *component,struct snd_soc_jack *jack,void *data); +/* for dapm */ +void snd_soc_component_seq_notifier (struct snd_soc_dapm_context *dapm, +enum snd_soc_dapm_type type,int subseq); +#ifdef CONFIG_REGMAP void snd_soc_component_init_regmap (struct snd_soc_component *component,struct regmap *regmap);
sound/soc/soc-component.c +9 -0
@@ -52,6 +52,15 @@ int snd_soc_component_set_pll(struct snd_soc_component *component, int pll_id, }EXPORT_SYMBOL_GPL (snd_soc_component_set_pll); +void snd_soc_component_seq_notifier (struct snd_soc_dapm_context *dapm, +enum snd_soc_dapm_type type,int subseq) +{ +struct snd_soc_component *component = dapm->component; + +if (component->driver->seq_notifier) + component->driver->seq_notifier (component, type, subseq); +} +int snd_soc_component_enable_pin (struct snd_soc_component *component,const char *pin) {
sound/soc/soc-core.c +1 -10
@@ -2692,14 +2692,6 @@ int snd_soc_register_dai(struct snd_soc_component *component, }EXPORT_SYMBOL_GPL (snd_soc_register_dai); -static void snd_soc_component_seq_notifier (struct snd_soc_dapm_context *dapm, -enum snd_soc_dapm_type type,int subseq) -{ -struct snd_soc_component *component = dapm->component; - - component->driver->seq_notifier (component, type, subseq); -} -static int snd_soc_component_stream_event (struct snd_soc_dapm_context *dapm,int event) {
@@ -2736,8 +2728,7 @@ static int snd_soc_component_initialize(struct snd_soc_component *component, dapm->bias_level =SND_SOC_BIAS_OFF ; dapm->idle_bias_off = !driver->idle_bias_on; dapm->suspend_bias_off = driver->suspend_bias_off; -if (driver->seq_notifier) - dapm->seq_notifier = snd_soc_component_seq_notifier; + dapm->seq_notifier = snd_soc_component_seq_notifier;if (driver->stream_event) dapm->stream_event = snd_soc_component_stream_event;if (driver->set_bias_level)
Signature · 1 line
2.7.4
Re: [PATCH 23/25] ASoC: soc-component: move snd_soc_component_seq_notifier()
Quoted 41 lines · Kuninori Morimoto
From: Kuninori Morimoto <[email protected]>
This patch moves
snd_soc_component_seq_notifier()tosoc-component.cIt will be used atsoc-dapm.c::dapm_seq_run(),
but no effect by this patch.static void dapm_seq_run(...) { ... => if (cur_dapm && cur_dapm->seq_notifier) { for (i = 0; i < ARRAY_SIZE(dapm_up_seq); i++) if (sort[i] == cur_sort) => cur_dapm->seq_notifier(cur_dapm, i, cur_subseq); } ... }Signed-off-by Kuninori Morimoto <[email protected]>---
sound/soc/soc-component.c +9
-0+void snd_soc_component_seq_notifier (struct snd_soc_dapm_context *dapm, +enum snd_soc_dapm_type type,int subseq) +{ +struct snd_soc_component *component = dapm->component; + +if (component->driver->seq_notifier) + component->driver->seq_notifier (component, type, subseq); +} +int snd_soc_component_enable_pin (struct snd_soc_component *component,const char *pin) {sound/soc/soc-core.c +0
-0static int snd_soc_component_stream_event (struct snd_soc_dapm_context *dapm,int event) {
sound/soc/soc-core.c static int snd_soc_component_initialize(struct snd_soc_component *component, · line 2731
Quoted 6 lines
sound/soc/soc-core.c +1
-2@@ -2736,8 +2728,7 @@ static int snd_soc_component_initialize(struct snd_soc_component *component, dapm->bias_level =SND_SOC_BIAS_OFF ; dapm->idle_bias_off = !driver->idle_bias_on; dapm->suspend_bias_off = driver->suspend_bias_off; -if (driver->seq_notifier) - dapm->seq_notifier = snd_soc_component_seq_notifier; + dapm->seq_notifier = snd_soc_component_seq_notifier;
If we are updating this to always set a seq_notifier would it be worth removing the NULL checks in soc-dapm.c? At the moment I guess it will end up checking twice, DAPM checks if dapm->seq_notifier is NULL but it never will be, then the helper checks if driver->seq_notifier is NULL.
Thanks,
Charles
Re: [PATCH 23/25] ASoC: soc-component: move snd_soc_component_seq_notifier()
Hi Charles
Quoted 5 lines
Quoted 5 lines
sound/soc/soc-core.c +0
-1@@ -2736,8 +2728,7 @@ static int snd_soc_component_initialize(struct snd_soc_component *component, dapm->bias_level =SND_SOC_BIAS_OFF ; dapm->idle_bias_off = !driver->idle_bias_on; dapm->suspend_bias_off = driver->suspend_bias_off; -if (driver->seq_notifier)
Quoted 8 lines
sound/soc/soc-core.c static int snd_soc_component_initialize(struct snd_soc_component *component, · line 2731
Quoted 2 lines
sound/soc/soc-core.c +1
-1- dapm->seq_notifier = snd_soc_component_seq_notifier; + dapm->seq_notifier = snd_soc_component_seq_notifier;If we are updating this to always set a
seq_notifierwould it be worth removing the NULL checks insoc-dapm.c? At the moment I guess it will end up checking twice, DAPM checks ifdapm->seq_notifieris NULL but it never will be, then the helper checks ifdriver->seq_notifieris NULL.
Yes, indeed.
I will double-check it, and will fix it at v2
Thank you for your help !!
Best regards
---
Kuninori Morimoto
PATCH 24/25 ASoC: soc-component: move snd_soc_component_stream_event()
In reply to Kuninori MorimotoFrom: Kuninori Morimoto <[email protected]>
This patch moves snd_soc_component_stream_event() to soc-component.c It will be used at soc-dapm.c :: dapm_power_widgets(), but no effect by this patch.
static int dapm_power_widgets(struct snd_soc_card *card, int event)
{
...
list_for_each_entry(d, &card->dapm_list, list) {
=> if (d->stream_event)
=> d->stream_event(d, event);
}
...
}--- include/sound/soc-component.h | 2 ++ sound/soc/soc-component.c | 10 ++++++++++ sound/soc/soc-core.c | 11 +---------- 3 files changed, 13 insertions(+), 10 deletions(-)
include/sound/soc-component.h +2 -0
@@ -276,6 +276,8 @@ int snd_soc_component_set_jack(struct snd_soc_component *component,/* for dapm */ void snd_soc_component_seq_notifier (struct snd_soc_dapm_context *dapm,enum snd_soc_dapm_type type,int subseq); +int snd_soc_component_stream_event (struct snd_soc_dapm_context *dapm, +int event);#ifdef CONFIG_REGMAP void snd_soc_component_init_regmap(struct snd_soc_component *component,
sound/soc/soc-component.c +10 -0
@@ -61,6 +61,16 @@ void snd_soc_component_seq_notifier(struct snd_soc_dapm_context *dapm, component->driver->seq_notifier (component, type, subseq); } +int snd_soc_component_stream_event (struct snd_soc_dapm_context *dapm, +int event) +{ +struct snd_soc_component *component = dapm->component; + +if (component->driver->stream_event) +return component->driver->stream_event (component, event); +return 0 ; +} +int snd_soc_component_enable_pin (struct snd_soc_component *component,const char *pin) {
sound/soc/soc-core.c +1 -10
@@ -2692,14 +2692,6 @@ int snd_soc_register_dai(struct snd_soc_component *component, }EXPORT_SYMBOL_GPL (snd_soc_register_dai); -static int snd_soc_component_stream_event (struct snd_soc_dapm_context *dapm, -int event) -{ -struct snd_soc_component *component = dapm->component; - -return component->driver->stream_event (component, event); -} -static int snd_soc_component_set_bias_level (struct snd_soc_dapm_context *dapm,enum snd_soc_bias_level level) {
@@ -2729,8 +2721,7 @@ static int snd_soc_component_initialize(struct snd_soc_component *component, dapm->idle_bias_off = !driver->idle_bias_on; dapm->suspend_bias_off = driver->suspend_bias_off; dapm->seq_notifier = snd_soc_component_seq_notifier; -if (driver->stream_event) - dapm->stream_event = snd_soc_component_stream_event; + dapm->stream_event = snd_soc_component_stream_event;if (driver->set_bias_level) dapm->set_bias_level = snd_soc_component_set_bias_level;
Signature · 1 line
2.7.4
Re: [PATCH 24/25] ASoC: soc-component: move snd_soc_component_stream_event()
Quoted 24 lines · Kuninori Morimoto
From: Kuninori Morimoto <[email protected]>
This patch moves
snd_soc_component_stream_event()tosoc-component.cIt will be used atsoc-dapm.c::dapm_power_widgets(), but no effect by this patch.static int dapm_power_widgets(struct snd_soc_card *card, int event) { ... list_for_each_entry(d, &card->dapm_list, list) { => if (d->stream_event) => d->stream_event(d, event); } ... }Signed-off-by Kuninori Morimoto <[email protected]>---
sound/soc/soc-component.c +0
-0@@ -61,6 +61,16 @@ void snd_soc_component_seq_notifier(struct snd_soc_dapm_context *dapm, component->driver->seq_notifier (component, type, subseq);
sound/soc/soc-component.c void snd_soc_component_seq_notifier(struct snd_soc_dapm_context *dapm, · line 71
Quoted 10 lines
sound/soc/soc-component.c +8
-0} +int snd_soc_component_stream_event (struct snd_soc_dapm_context *dapm, +int event) +{ +struct snd_soc_component *component = dapm->component; + +if (component->driver->stream_event) +return component->driver->stream_event (component, event); +return 0 ;
Minor nitpick but a blank line before the return would be more normal and consistent with your other patches.
sound/soc/soc-component.c static int snd_soc_component_initialize(struct snd_soc_component *component, · line 2724
Quoted 7 lines
sound/soc/soc-component.c +1
-2@@ -2729,8 +2721,7 @@ static int snd_soc_component_initialize(struct snd_soc_component *component, dapm->idle_bias_off = !driver->idle_bias_on; dapm->suspend_bias_off = driver->suspend_bias_off; dapm->seq_notifier = snd_soc_component_seq_notifier; -if (driver->stream_event) - dapm->stream_event = snd_soc_component_stream_event; + dapm->stream_event = snd_soc_component_stream_event;
Obviously same comment regarding the NULL checks in DAPM applies here.
Thanks,
Charles
Re: [PATCH 24/25] ASoC: soc-component: move snd_soc_component_stream_event()
Hi Charles
Thank you for your feedback
I will fix it at v2
Quoted 25 lines
sound/soc/soc-component.c void snd_soc_component_seq_notifier(struct snd_soc_dapm_context *dapm, · line 71
Quoted 8 lines
sound/soc/soc-component.c +8
-0+int snd_soc_component_stream_event (struct snd_soc_dapm_context *dapm, +int event) +{ +struct snd_soc_component *component = dapm->component; + +if (component->driver->stream_event) +return component->driver->stream_event (component, event); +return 0 ;Minor nitpick but a blank line before the return would be more normal and consistent with your other patches.
sound/soc/soc-core.c static int snd_soc_component_initialize(struct snd_soc_component *component, · line 2724
Quoted 7 lines
sound/soc/soc-core.c +1
-2@@ -2729,8 +2721,7 @@ static int snd_soc_component_initialize(struct snd_soc_component *component, dapm->idle_bias_off = !driver->idle_bias_on; dapm->suspend_bias_off = driver->suspend_bias_off; dapm->seq_notifier = snd_soc_component_seq_notifier; -if (driver->stream_event) - dapm->stream_event = snd_soc_component_stream_event; + dapm->stream_event = snd_soc_component_stream_event;Obviously same comment regarding the NULL checks in DAPM applies here.
Thanks,
Charles
PATCH 25/25 ASoC: soc-component: move snd_soc_component_set_bias_level()
In reply to Kuninori MorimotoFrom: Kuninori Morimoto <[email protected]>
This patch moves snd_soc_component_set_bias_level() to soc-component.c It will be used at soc-dapm.c :: snd_soc_dapm_force_bias_level(), but no effect by this patch.
int snd_soc_dapm_force_bias_level(...)
{=> int ret = 0;
=> if (dapm->set_bias_level)
=> ret = dapm->set_bias_level(dapm, level); ... }
--- include/sound/soc-component.h | 2 ++ sound/soc/soc-component.c | 10 ++++++++++ sound/soc/soc-core.c | 11 +---------- 3 files changed, 13 insertions(+), 10 deletions(-)
include/sound/soc-component.h +2 -0
@@ -278,6 +278,8 @@ void snd_soc_component_seq_notifier(struct snd_soc_dapm_context *dapm, enum snd_soc_dapm_type type, int subseq);int snd_soc_component_stream_event (struct snd_soc_dapm_context *dapm,int event); +int snd_soc_component_set_bias_level (struct snd_soc_dapm_context *dapm, +enum snd_soc_bias_level level);#ifdef CONFIG_REGMAP void snd_soc_component_init_regmap(struct snd_soc_component *component,
sound/soc/soc-component.c +10 -0
@@ -71,6 +71,16 @@ int snd_soc_component_stream_event(struct snd_soc_dapm_context *dapm,return 0 ; } +int snd_soc_component_set_bias_level (struct snd_soc_dapm_context *dapm, +enum snd_soc_bias_level level) +{ +struct snd_soc_component *component = dapm->component; + +if (component->driver->set_bias_level) +return component->driver->set_bias_level (component, level); +return 0 ; +} +int snd_soc_component_enable_pin (struct snd_soc_component *component,const char *pin) {
sound/soc/soc-core.c +1 -10
@@ -2692,14 +2692,6 @@ int snd_soc_register_dai(struct snd_soc_component *component, }EXPORT_SYMBOL_GPL (snd_soc_register_dai); -static int snd_soc_component_set_bias_level (struct snd_soc_dapm_context *dapm, -enum snd_soc_bias_level level) -{ -struct snd_soc_component *component = dapm->component; - -return component->driver->set_bias_level (component, level); -} -static int snd_soc_component_initialize (struct snd_soc_component *component,const struct snd_soc_component_driver *driver,struct device *dev) {
@@ -2722,8 +2714,7 @@ static int snd_soc_component_initialize(struct snd_soc_component *component, dapm->suspend_bias_off = driver->suspend_bias_off; dapm->seq_notifier = snd_soc_component_seq_notifier; dapm->stream_event = snd_soc_component_stream_event; -if (driver->set_bias_level) - dapm->set_bias_level = snd_soc_component_set_bias_level; + dapm->set_bias_level = snd_soc_component_set_bias_level;INIT_LIST_HEAD (&component->dai_list);mutex_init (&component->io_mutex);
Signature · 1 line
2.7.4