[alsa-devel] [PATCH 00/25] 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
From: Kuninori Morimoto kuninori.morimoto.gx@renesas.com
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.
Signed-off-by: Kuninori Morimoto kuninori.morimoto.gx@renesas.com --- 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
diff --git a/include/sound/soc-component.h b/include/sound/soc-component.h new file mode 100644 index 0000000..d2f94cf --- /dev/null +++ b/include/sound/soc-component.h @@ -0,0 +1,320 @@ +/* + * soc-component.h + * + * Copyright (c) 2019 Kuninori Morimoto kuninori.morimoto.gx@renesas.com + * + * 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 */ diff --git a/include/sound/soc.h b/include/sound/soc.h index d770606..a4c39b0 100644 --- a/include/sound/soc.h +++ b/include/sound/soc.h @@ -363,21 +363,6 @@ const struct soc_enum name = SOC_ENUM_SINGLE_VIRT(ARRAY_SIZE(xtexts), xtexts)
/* - * 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++) - -/* * Bias levels * * @ON: Bias is fully on for audio playback and capture operations. @@ -747,132 +732,6 @@ struct snd_soc_compr_ops { int (*trigger)(struct snd_compr_stream *); };
-/* 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) - struct snd_soc_rtdcom_list { struct snd_soc_component *component; struct list_head list; /* rtd::component_list */ @@ -1338,134 +1197,6 @@ struct soc_enum { struct snd_soc_dobj dobj; };
-/** - * 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 - /* device driver data */
static inline void snd_soc_card_set_drvdata(struct snd_soc_card *card, @@ -1479,17 +1210,6 @@ static inline void *snd_soc_card_get_drvdata(struct snd_soc_card *card) return card->drvdata; }
-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 void snd_soc_initialize_card_lists(struct snd_soc_card *card) { INIT_LIST_HEAD(&card->widgets); @@ -1536,12 +1256,6 @@ static inline unsigned int snd_soc_enum_item_to_val(struct soc_enum *e, return e->values[item]; }
-static inline bool snd_soc_component_is_active( - struct snd_soc_component *component) -{ - return component->active != 0; -} - /** * snd_soc_kcontrol_component() - Returns the component that registered the * control @@ -1677,24 +1391,6 @@ static inline void snd_soc_dapm_mutex_unlock(struct snd_soc_dapm_context *dapm) mutex_unlock(&dapm->card->dapm_mutex); }
-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); +#include <sound/soc-component.h>
#endif diff --git a/sound/soc/Makefile b/sound/soc/Makefile index 919c3c0..250a0de 100644 --- a/sound/soc/Makefile +++ b/sound/soc/Makefile @@ -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
diff --git a/sound/soc/soc-component.c b/sound/soc/soc-component.c new file mode 100644 index 0000000..e19f78b --- /dev/null +++ b/sound/soc/soc-component.c @@ -0,0 +1,269 @@ +// SPDX-License-Identifier: GPL-2.0 +// +// soc-component.c +// +// Copyright (C) 2019 Renesas Electronics Corp. +// Kuninori Morimoto kuninori.morimoto.gx@renesas.com +// +#include <sound/soc.h> + +/** + * snd_soc_component_set_sysclk - configure COMPONENT system or master clock. + * @component: COMPONENT + * @clk_id: DAI specific clock ID + * @source: Source for the clock + * @freq: new clock frequency in Hz + * @dir: new clock direction - input/output. + * + * Configures the CODEC master (MCLK) or system (SYSCLK) clocking. + */ +int snd_soc_component_set_sysclk(struct snd_soc_component *component, + int clk_id, int source, unsigned int freq, + int dir) +{ + if (component->driver->set_sysclk) + return component->driver->set_sysclk(component, clk_id, source, + freq, dir); + + return -ENOTSUPP; +} +EXPORT_SYMBOL_GPL(snd_soc_component_set_sysclk); + +/* + * snd_soc_component_set_pll - configure component PLL. + * @component: COMPONENT + * @pll_id: DAI specific PLL ID + * @source: DAI specific source for the PLL + * @freq_in: PLL input clock frequency in Hz + * @freq_out: requested PLL output clock frequency in Hz + * + * Configures and enables PLL to generate output clock based on input clock. + */ +int snd_soc_component_set_pll(struct snd_soc_component *component, int pll_id, + int source, unsigned int freq_in, + unsigned int freq_out) +{ + if (component->driver->set_pll) + return component->driver->set_pll(component, pll_id, source, + freq_in, freq_out); + + return -EINVAL; +} +EXPORT_SYMBOL_GPL(snd_soc_component_set_pll); + +int snd_soc_component_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_enable_pin(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); + kfree(full_name); + + return ret; +} +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; +} +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; +} +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; +} +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; +} +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; +} +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; +} +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; +} +EXPORT_SYMBOL_GPL(snd_soc_component_force_enable_pin); + +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; +} +EXPORT_SYMBOL_GPL(snd_soc_component_force_enable_pin_unlocked); + +/** + * 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); diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index 7ecfe64..b67e72f 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -2391,50 +2391,6 @@ int snd_soc_add_dai_controls(struct snd_soc_dai *dai, } EXPORT_SYMBOL_GPL(snd_soc_add_dai_controls);
-/** - * snd_soc_component_set_sysclk - configure COMPONENT system or master clock. - * @component: COMPONENT - * @clk_id: DAI specific clock ID - * @source: Source for the clock - * @freq: new clock frequency in Hz - * @dir: new clock direction - input/output. - * - * Configures the CODEC master (MCLK) or system (SYSCLK) clocking. - */ -int snd_soc_component_set_sysclk(struct snd_soc_component *component, - int clk_id, int source, unsigned int freq, - int dir) -{ - if (component->driver->set_sysclk) - return component->driver->set_sysclk(component, clk_id, source, - freq, dir); - - return -ENOTSUPP; -} -EXPORT_SYMBOL_GPL(snd_soc_component_set_sysclk); - -/* - * snd_soc_component_set_pll - configure component PLL. - * @component: COMPONENT - * @pll_id: DAI specific PLL ID - * @source: DAI specific source for the PLL - * @freq_in: PLL input clock frequency in Hz - * @freq_out: requested PLL output clock frequency in Hz - * - * Configures and enables PLL to generate output clock based on input clock. - */ -int snd_soc_component_set_pll(struct snd_soc_component *component, int pll_id, - int source, unsigned int freq_in, - unsigned int freq_out) -{ - if (component->driver->set_pll) - return component->driver->set_pll(component, pll_id, source, - freq_in, freq_out); - - return -EINVAL; -} -EXPORT_SYMBOL_GPL(snd_soc_component_set_pll); - static int snd_soc_bind_card(struct snd_soc_card *card) { struct snd_soc_pcm_runtime *rtd; diff --git a/sound/soc/soc-jack.c b/sound/soc/soc-jack.c index c7b990a..a71d234 100644 --- a/sound/soc/soc-jack.c +++ b/sound/soc/soc-jack.c @@ -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 diff --git a/sound/soc/soc-utils.c b/sound/soc/soc-utils.c index e3b9dd6..54dcece 100644 --- a/sound/soc/soc-utils.c +++ b/sound/soc/soc-utils.c @@ -52,205 +52,6 @@ int snd_soc_params_to_bclk(struct snd_pcm_hw_params *params) } EXPORT_SYMBOL_GPL(snd_soc_params_to_bclk);
-int snd_soc_component_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_enable_pin(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); - kfree(full_name); - - return ret; -} -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; -} -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; -} -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; -} -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; -} -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; -} -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; -} -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; -} -EXPORT_SYMBOL_GPL(snd_soc_component_force_enable_pin); - -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; -} -EXPORT_SYMBOL_GPL(snd_soc_component_force_enable_pin_unlocked); - static const struct snd_pcm_hardware dummy_dma_hardware = { /* Random values to keep userspace happy when checking constraints */ .info = SNDRV_PCM_INFO_INTERLEAVED |
From: Kuninori Morimoto kuninori.morimoto.gx@renesas.com
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 kuninori.morimoto.gx@renesas.com --- 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(-)
diff --git a/include/sound/soc-component.h b/include/sound/soc-component.h index d2f94cf..57270c2 100644 --- a/include/sound/soc-component.h +++ b/include/sound/soc-component.h @@ -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) { diff --git a/sound/soc/soc-component.c b/sound/soc/soc-component.c index e19f78b..cf6dfb9 100644 --- a/sound/soc/soc-component.c +++ b/sound/soc/soc-component.c @@ -5,6 +5,7 @@ // Copyright (C) 2019 Renesas Electronics Corp. // Kuninori Morimoto kuninori.morimoto.gx@renesas.com // +#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); +} diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index b67e72f..83b04d9 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -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; diff --git a/sound/soc/soc-pcm.c b/sound/soc/soc-pcm.c index fabeac1..5a59319 100644 --- a/sound/soc/soc-pcm.c +++ b/sound/soc/soc-pcm.c @@ -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;
On Wed, Jul 24, 2019 at 10:51:23AM +0900, Kuninori Morimoto wrote:
From: Kuninori Morimoto kuninori.morimoto.gx@renesas.com
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 kuninori.morimoto.gx@renesas.com
diff --git a/include/sound/soc-component.h b/include/sound/soc-component.h index d2f94cf..57270c2 100644 --- a/include/sound/soc-component.h +++ b/include/sound/soc-component.h @@ -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
Hi Charles
+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?
Yeah, indeed. I will re-consider about it.
Thank you for your help !! Best regards --- Kuninori Morimoto
From: Kuninori Morimoto kuninori.morimoto.gx@renesas.com
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.
Signed-off-by: Kuninori Morimoto kuninori.morimoto.gx@renesas.com --- 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(-)
diff --git a/include/sound/soc-component.h b/include/sound/soc-component.h index 57270c2..306c9cf 100644 --- a/include/sound/soc-component.h +++ b/include/sound/soc-component.h @@ -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 */ diff --git a/sound/soc/soc-component.c b/sound/soc/soc-component.c index cf6dfb9..3e9172e 100644 --- a/sound/soc/soc-component.c +++ b/sound/soc/soc-component.c @@ -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; +} diff --git a/sound/soc/soc-pcm.c b/sound/soc/soc-pcm.c index 5a59319..c98b4da 100644 --- a/sound/soc/soc-pcm.c +++ b/sound/soc/soc-pcm.c @@ -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",
From: Kuninori Morimoto kuninori.morimoto.gx@renesas.com
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.
Signed-off-by: Kuninori Morimoto kuninori.morimoto.gx@renesas.com --- 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(-)
diff --git a/include/sound/soc-component.h b/include/sound/soc-component.h index 306c9cf..6357c0a 100644 --- a/include/sound/soc-component.h +++ b/include/sound/soc-component.h @@ -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 */ diff --git a/sound/soc/soc-component.c b/sound/soc/soc-component.c index 3e9172e..d9191df 100644 --- a/sound/soc/soc-component.c +++ b/sound/soc/soc-component.c @@ -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; +} diff --git a/sound/soc/soc-pcm.c b/sound/soc/soc-pcm.c index c98b4da..86d2e6b 100644 --- a/sound/soc/soc-pcm.c +++ b/sound/soc/soc-pcm.c @@ -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); }
From: Kuninori Morimoto kuninori.morimoto.gx@renesas.com
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.
Signed-off-by: Kuninori Morimoto kuninori.morimoto.gx@renesas.com --- 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(-)
diff --git a/include/sound/soc-component.h b/include/sound/soc-component.h index 6357c0a..9f31d60 100644 --- a/include/sound/soc-component.h +++ b/include/sound/soc-component.h @@ -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 */ diff --git a/sound/soc/soc-component.c b/sound/soc/soc-component.c index d9191df..34838d9 100644 --- a/sound/soc/soc-component.c +++ b/sound/soc/soc-component.c @@ -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; +} diff --git a/sound/soc/soc-pcm.c b/sound/soc/soc-pcm.c index 86d2e6b..a77a14c 100644 --- a/sound/soc/soc-pcm.c +++ b/sound/soc/soc-pcm.c @@ -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);
On 2019-07-24 03:51, Kuninori Morimoto wrote:> +
+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;
+} diff --git a/sound/soc/soc-pcm.c b/sound/soc/soc-pcm.c index 86d2e6b..a77a14c 100644 --- a/sound/soc/soc-pcm.c +++ b/sound/soc/soc-pcm.c @@ -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);
if (ret < 0) { dev_err(component->dev, "ASoC: platform prepare error: %d\n", ret);snd_soc_component_prepare(component, substream);
Compared to old code, ret gets ignored here. Guess unintended modification?
Hi Cezary
@@ -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);
if (ret < 0) { dev_err(component->dev, "ASoC: platform prepare error: %d\n", ret);snd_soc_component_prepare(component, substream);
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
From: Kuninori Morimoto kuninori.morimoto.gx@renesas.com
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.
Signed-off-by: Kuninori Morimoto kuninori.morimoto.gx@renesas.com --- 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(-)
diff --git a/include/sound/soc-component.h b/include/sound/soc-component.h index 9f31d60..ac93189 100644 --- a/include/sound/soc-component.h +++ b/include/sound/soc-component.h @@ -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 */ diff --git a/sound/soc/soc-component.c b/sound/soc/soc-component.c index 34838d9..249dac4 100644 --- a/sound/soc/soc-component.c +++ b/sound/soc/soc-component.c @@ -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; +} diff --git a/sound/soc/soc-pcm.c b/sound/soc/soc-pcm.c index a77a14c..26f73af 100644 --- a/sound/soc/soc-pcm.c +++ b/sound/soc/soc-pcm.c @@ -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",
From: Kuninori Morimoto kuninori.morimoto.gx@renesas.com
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.
Signed-off-by: Kuninori Morimoto kuninori.morimoto.gx@renesas.com --- 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(-)
diff --git a/include/sound/soc-component.h b/include/sound/soc-component.h index ac93189..9ec67a3 100644 --- a/include/sound/soc-component.h +++ b/include/sound/soc-component.h @@ -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 */ diff --git a/sound/soc/soc-component.c b/sound/soc/soc-component.c index 249dac4..7246518 100644 --- a/sound/soc/soc-component.c +++ b/sound/soc/soc-component.c @@ -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; +} diff --git a/sound/soc/soc-pcm.c b/sound/soc/soc-pcm.c index 26f73af..780a119 100644 --- a/sound/soc/soc-pcm.c +++ b/sound/soc/soc-pcm.c @@ -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;
On Wed, 2019-07-24 at 10:51 +0900, Kuninori Morimoto wrote:
From: Kuninori Morimoto kuninori.morimoto.gx@renesas.com
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.
Signed-off-by: Kuninori Morimoto kuninori.morimoto.gx@renesas.com
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(-)
diff --git a/include/sound/soc-component.h b/include/sound/soc- component.h index ac93189..9ec67a3 100644 --- a/include/sound/soc-component.h +++ b/include/sound/soc-component.h @@ -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 */ diff --git a/sound/soc/soc-component.c b/sound/soc/soc-component.c index 249dac4..7246518 100644 --- a/sound/soc/soc-component.c +++ b/sound/soc/soc-component.c @@ -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;
+} diff --git a/sound/soc/soc-pcm.c b/sound/soc/soc-pcm.c index 26f73af..780a119 100644 --- a/sound/soc/soc-pcm.c +++ b/sound/soc/soc-pcm.c @@ -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
}
return 0;
Hi Ranjani
@@ -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?
Yes, indeed. Thank you for your feedback. I will fix up it at v2
Thank you for your help !! Best regards --- Kuninori Morimoto
From: Kuninori Morimoto kuninori.morimoto.gx@renesas.com
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.
Signed-off-by: Kuninori Morimoto kuninori.morimoto.gx@renesas.com --- 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(-)
diff --git a/include/sound/soc-component.h b/include/sound/soc-component.h index 9ec67a3..48ef43b 100644 --- a/include/sound/soc-component.h +++ b/include/sound/soc-component.h @@ -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 */ diff --git a/sound/soc/soc-component.c b/sound/soc/soc-component.c index 7246518..bb06994 100644 --- a/sound/soc/soc-component.c +++ b/sound/soc/soc-component.c @@ -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; +} diff --git a/sound/soc/soc-pcm.c b/sound/soc/soc-pcm.c index 780a119..2a1ef4a 100644 --- a/sound/soc/soc-pcm.c +++ b/sound/soc/soc-pcm.c @@ -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; }
From: Kuninori Morimoto kuninori.morimoto.gx@renesas.com
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.
Signed-off-by: Kuninori Morimoto kuninori.morimoto.gx@renesas.com --- 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(-)
diff --git a/include/sound/soc-component.h b/include/sound/soc-component.h index 48ef43b..c923d04 100644 --- a/include/sound/soc-component.h +++ b/include/sound/soc-component.h @@ -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 */ diff --git a/sound/soc/soc-component.c b/sound/soc/soc-component.c index bb06994..7cb936a 100644 --- a/sound/soc/soc-component.c +++ b/sound/soc/soc-component.c @@ -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; +} diff --git a/sound/soc/soc-pcm.c b/sound/soc/soc-pcm.c index 2a1ef4a..7ab68de 100644 --- a/sound/soc/soc-pcm.c +++ b/sound/soc/soc-pcm.c @@ -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;
On Wed, Jul 24, 2019 at 10:52:00AM +0900, Kuninori Morimoto wrote:
From: Kuninori Morimoto kuninori.morimoto.gx@renesas.com
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.
Signed-off-by: Kuninori Morimoto kuninori.morimoto.gx@renesas.com
+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;
if (!component->driver->ops ||
!component->driver->ops->pointer)
continue;
/* FIXME: use 1st pointer */offset = snd_soc_component_pointer(component, substream);
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
Hi Charles
+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;
if (!component->driver->ops ||
!component->driver->ops->pointer)
continue;
/* FIXME: use 1st pointer */offset = snd_soc_component_pointer(component, substream);
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
From: Kuninori Morimoto kuninori.morimoto.gx@renesas.com
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.
Signed-off-by: Kuninori Morimoto kuninori.morimoto.gx@renesas.com --- 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(-)
diff --git a/include/sound/soc-component.h b/include/sound/soc-component.h index c923d04..8230519 100644 --- a/include/sound/soc-component.h +++ b/include/sound/soc-component.h @@ -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 */ diff --git a/sound/soc/soc-component.c b/sound/soc/soc-component.c index 7cb936a..dbc8295 100644 --- a/sound/soc/soc-component.c +++ b/sound/soc/soc-component.c @@ -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; +} diff --git a/sound/soc/soc-pcm.c b/sound/soc/soc-pcm.c index 7ab68de..064d16c 100644 --- a/sound/soc/soc-pcm.c +++ b/sound/soc/soc-pcm.c @@ -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);
On Wed, Jul 24, 2019 at 10:52:05AM +0900, Kuninori Morimoto wrote:
From: Kuninori Morimoto kuninori.morimoto.gx@renesas.com
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.
Signed-off-by: Kuninori Morimoto kuninori.morimoto.gx@renesas.com
diff --git a/sound/soc/soc-pcm.c b/sound/soc/soc-pcm.c index 7ab68de..064d16c 100644 --- a/sound/soc/soc-pcm.c +++ b/sound/soc/soc-pcm.c @@ -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.
/* 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;
/* FIXME: use 1st ioctl */ret = snd_soc_component_ioctl(component, substream, cmd, arg);
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
Hi Charles
for_each_rtdcom(rtd, rtdcom) { component = rtdcom->component;
if (!component->driver->ops ||
!component->driver->ops->ioctl)
continue;
/* FIXME: use 1st ioctl */ret = snd_soc_component_ioctl(component, substream, cmd, arg);
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")
Thank you for your feedback. It sounds nice idea for me. will fix in v2
Thank you for your help !! Best regards --- Kuninori Morimoto
From: Kuninori Morimoto kuninori.morimoto.gx@renesas.com
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.
Signed-off-by: Kuninori Morimoto kuninori.morimoto.gx@renesas.com --- 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(-)
diff --git a/include/sound/soc-component.h b/include/sound/soc-component.h index 8230519..b86aecf 100644 --- a/include/sound/soc-component.h +++ b/include/sound/soc-component.h @@ -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 */ diff --git a/sound/soc/soc-component.c b/sound/soc/soc-component.c index dbc8295..881450d2 100644 --- a/sound/soc/soc-component.c +++ b/sound/soc/soc-component.c @@ -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; +} diff --git a/sound/soc/soc-pcm.c b/sound/soc/soc-pcm.c index 064d16c..f1d3404 100644 --- a/sound/soc/soc-pcm.c +++ b/sound/soc/soc-pcm.c @@ -2862,17 +2862,16 @@ static int soc_rtdcom_copy_user(struct snd_pcm_substream *substream, int channel 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->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;
From: Kuninori Morimoto kuninori.morimoto.gx@renesas.com
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.
Signed-off-by: Kuninori Morimoto kuninori.morimoto.gx@renesas.com --- 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(-)
diff --git a/include/sound/soc-component.h b/include/sound/soc-component.h index b86aecf..f3314d0 100644 --- a/include/sound/soc-component.h +++ b/include/sound/soc-component.h @@ -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 */ diff --git a/sound/soc/soc-component.c b/sound/soc/soc-component.c index 881450d2..dcf27c8 100644 --- a/sound/soc/soc-component.c +++ b/sound/soc/soc-component.c @@ -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); +} diff --git a/sound/soc/soc-pcm.c b/sound/soc/soc-pcm.c index f1d3404..bbc9471 100644 --- a/sound/soc/soc-pcm.c +++ b/sound/soc/soc-pcm.c @@ -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; }
From: Kuninori Morimoto kuninori.morimoto.gx@renesas.com
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.
Signed-off-by: Kuninori Morimoto kuninori.morimoto.gx@renesas.com --- 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(-)
diff --git a/include/sound/soc-component.h b/include/sound/soc-component.h index f3314d0..223b0ce 100644 --- a/include/sound/soc-component.h +++ b/include/sound/soc-component.h @@ -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 */ diff --git a/sound/soc/soc-component.c b/sound/soc/soc-component.c index dcf27c8..166a8c8 100644 --- a/sound/soc/soc-component.c +++ b/sound/soc/soc-component.c @@ -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; +} diff --git a/sound/soc/soc-pcm.c b/sound/soc/soc-pcm.c index bbc9471..c483db0 100644 --- a/sound/soc/soc-pcm.c +++ b/sound/soc/soc-pcm.c @@ -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;
From: Kuninori Morimoto kuninori.morimoto.gx@renesas.com
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.
Signed-off-by: Kuninori Morimoto kuninori.morimoto.gx@renesas.com --- 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(-)
diff --git a/include/sound/soc-component.h b/include/sound/soc-component.h index 223b0ce..9e61a52 100644 --- a/include/sound/soc-component.h +++ b/include/sound/soc-component.h @@ -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 */ diff --git a/sound/soc/soc-component.c b/sound/soc/soc-component.c index 166a8c8..8f3679e 100644 --- a/sound/soc/soc-component.c +++ b/sound/soc/soc-component.c @@ -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; +} diff --git a/sound/soc/soc-pcm.c b/sound/soc/soc-pcm.c index c483db0..466802f 100644 --- a/sound/soc/soc-pcm.c +++ b/sound/soc/soc-pcm.c @@ -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",
From: Kuninori Morimoto kuninori.morimoto.gx@renesas.com
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.
Signed-off-by: Kuninori Morimoto kuninori.morimoto.gx@renesas.com --- 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(-)
diff --git a/include/sound/soc-component.h b/include/sound/soc-component.h index 9e61a52..96ea44e 100644 --- a/include/sound/soc-component.h +++ b/include/sound/soc-component.h @@ -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 */ diff --git a/sound/soc/soc-component.c b/sound/soc/soc-component.c index 8f3679e..4473f55 100644 --- a/sound/soc/soc-component.c +++ b/sound/soc/soc-component.c @@ -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); +} diff --git a/sound/soc/soc-pcm.c b/sound/soc/soc-pcm.c index 466802f..53b8a95 100644 --- a/sound/soc/soc-pcm.c +++ b/sound/soc/soc-pcm.c @@ -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); } }
From: Kuninori Morimoto kuninori.morimoto.gx@renesas.com
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.
Signed-off-by: Kuninori Morimoto kuninori.morimoto.gx@renesas.com --- 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(-)
diff --git a/include/sound/soc-component.h b/include/sound/soc-component.h index 96ea44e..cf41ba4 100644 --- a/include/sound/soc-component.h +++ b/include/sound/soc-component.h @@ -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 */ diff --git a/sound/soc/soc-component.c b/sound/soc/soc-component.c index 4473f55..165d111 100644 --- a/sound/soc/soc-component.c +++ b/sound/soc/soc-component.c @@ -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; +} diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index 83b04d9..39b5a64 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -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 */
From: Kuninori Morimoto kuninori.morimoto.gx@renesas.com
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.
Signed-off-by: Kuninori Morimoto kuninori.morimoto.gx@renesas.com --- 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(-)
diff --git a/include/sound/soc-component.h b/include/sound/soc-component.h index cf41ba4..52684d3 100644 --- a/include/sound/soc-component.h +++ b/include/sound/soc-component.h @@ -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 */ diff --git a/sound/soc/soc-component.c b/sound/soc/soc-component.c index 165d111..d4b972c 100644 --- a/sound/soc/soc-component.c +++ b/sound/soc/soc-component.c @@ -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; +} diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index 39b5a64..442d6a7 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -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); } }
From: Kuninori Morimoto kuninori.morimoto.gx@renesas.com
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.
Signed-off-by: Kuninori Morimoto kuninori.morimoto.gx@renesas.com --- 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(-)
diff --git a/include/sound/soc-component.h b/include/sound/soc-component.h index 52684d3..63e47cd 100644 --- a/include/sound/soc-component.h +++ b/include/sound/soc-component.h @@ -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 */ diff --git a/sound/soc/soc-component.c b/sound/soc/soc-component.c index d4b972c..fbb7493 100644 --- a/sound/soc/soc-component.c +++ b/sound/soc/soc-component.c @@ -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; +} diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index 442d6a7..6283b17d 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -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) {
From: Kuninori Morimoto kuninori.morimoto.gx@renesas.com
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.
Signed-off-by: Kuninori Morimoto kuninori.morimoto.gx@renesas.com --- 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(-)
diff --git a/include/sound/soc-component.h b/include/sound/soc-component.h index 63e47cd..d01f36a 100644 --- a/include/sound/soc-component.h +++ b/include/sound/soc-component.h @@ -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 */ diff --git a/sound/soc/soc-component.c b/sound/soc/soc-component.c index fbb7493..2e7f254 100644 --- a/sound/soc/soc-component.c +++ b/sound/soc/soc-component.c @@ -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; +} diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index 6283b17d..9be12ae 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -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,
From: Kuninori Morimoto kuninori.morimoto.gx@renesas.com
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.
Signed-off-by: Kuninori Morimoto kuninori.morimoto.gx@renesas.com --- 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(-)
diff --git a/include/sound/soc-component.h b/include/sound/soc-component.h index d01f36a..7cef7ed 100644 --- a/include/sound/soc-component.h +++ b/include/sound/soc-component.h @@ -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 */ diff --git a/sound/soc/soc-component.c b/sound/soc/soc-component.c index 2e7f254..af26e8e 100644 --- a/sound/soc/soc-component.c +++ b/sound/soc/soc-component.c @@ -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); +} diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index 9be12ae..067c340 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -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); }
From: Kuninori Morimoto kuninori.morimoto.gx@renesas.com
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.
Signed-off-by: Kuninori Morimoto kuninori.morimoto.gx@renesas.com --- 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(-)
diff --git a/include/sound/soc-component.h b/include/sound/soc-component.h index 7cef7ed..b8553aa 100644 --- a/include/sound/soc-component.h +++ b/include/sound/soc-component.h @@ -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 */ diff --git a/sound/soc/soc-component.c b/sound/soc/soc-component.c index af26e8e..7dabcf7 100644 --- a/sound/soc/soc-component.c +++ b/sound/soc/soc-component.c @@ -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; +} diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index 067c340..9ec34a6 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -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);
From: Kuninori Morimoto kuninori.morimoto.gx@renesas.com
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
Signed-off-by: Kuninori Morimoto kuninori.morimoto.gx@renesas.com --- 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(-)
diff --git a/include/sound/soc-component.h b/include/sound/soc-component.h index b8553aa..37b25cc 100644 --- a/include/sound/soc-component.h +++ b/include/sound/soc-component.h @@ -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 */ diff --git a/sound/soc/soc-component.c b/sound/soc/soc-component.c index 7dabcf7..732f06a 100644 --- a/sound/soc/soc-component.c +++ b/sound/soc/soc-component.c @@ -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; +} diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index 9ec34a6..573192d 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -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;
From: Kuninori Morimoto kuninori.morimoto.gx@renesas.com
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); } ... }
Signed-off-by: Kuninori Morimoto kuninori.morimoto.gx@renesas.com --- 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(-)
diff --git a/include/sound/soc-component.h b/include/sound/soc-component.h index 37b25cc..4711138 100644 --- a/include/sound/soc-component.h +++ b/include/sound/soc-component.h @@ -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); diff --git a/sound/soc/soc-component.c b/sound/soc/soc-component.c index 732f06a..e4e8fc4 100644 --- a/sound/soc/soc-component.c +++ b/sound/soc/soc-component.c @@ -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) { diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index 573192d..84ded01 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -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)
On Wed, Jul 24, 2019 at 10:53:22AM +0900, Kuninori Morimoto wrote:
From: Kuninori Morimoto kuninori.morimoto.gx@renesas.com
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); } ... }
Signed-off-by: Kuninori Morimoto kuninori.morimoto.gx@renesas.com
+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) { diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index 573192d..84ded01 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c 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 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
Hi Charles
@@ -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.
Yes, indeed. I will double-check it, and will fix it at v2
Thank you for your help !! Best regards --- Kuninori Morimoto
From: Kuninori Morimoto kuninori.morimoto.gx@renesas.com
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); } ... }
Signed-off-by: Kuninori Morimoto kuninori.morimoto.gx@renesas.com --- 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(-)
diff --git a/include/sound/soc-component.h b/include/sound/soc-component.h index 4711138..8c88058 100644 --- a/include/sound/soc-component.h +++ b/include/sound/soc-component.h @@ -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, diff --git a/sound/soc/soc-component.c b/sound/soc/soc-component.c index e4e8fc4..ab8e7cc 100644 --- a/sound/soc/soc-component.c +++ b/sound/soc/soc-component.c @@ -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) { diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index 84ded01..6f7de6a 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -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;
On Wed, Jul 24, 2019 at 10:53:37AM +0900, Kuninori Morimoto wrote:
From: Kuninori Morimoto kuninori.morimoto.gx@renesas.com
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); } ... }
Signed-off-by: Kuninori Morimoto kuninori.morimoto.gx@renesas.com
diff --git a/sound/soc/soc-component.c b/sound/soc/soc-component.c index e4e8fc4..ab8e7cc 100644 --- a/sound/soc/soc-component.c +++ b/sound/soc/soc-component.c @@ -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;
Minor nitpick but a blank line before the return would be more normal and consistent with your other patches.
@@ -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
Hi Charles
Thank you for your feedback I will fix it at v2
+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.
@@ -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
From: Kuninori Morimoto kuninori.morimoto.gx@renesas.com
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); ... }
Signed-off-by: Kuninori Morimoto kuninori.morimoto.gx@renesas.com --- 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(-)
diff --git a/include/sound/soc-component.h b/include/sound/soc-component.h index 8c88058..7c9ae25 100644 --- a/include/sound/soc-component.h +++ b/include/sound/soc-component.h @@ -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, diff --git a/sound/soc/soc-component.c b/sound/soc/soc-component.c index ab8e7cc..b7a7ec7 100644 --- a/sound/soc/soc-component.c +++ b/sound/soc/soc-component.c @@ -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) { diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index 6f7de6a..112bde1 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -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);
participants (4)
-
Cezary Rojewski
-
Charles Keepax
-
Kuninori Morimoto
-
Ranjani Sridharan