From 1328948fea693679ab81601aa72a9ed6025f81ea Mon Sep 17 00:00:00 2001 From: Pierre-Louis Bossart Date: Fri, 12 Jun 2020 15:40:48 -0500 Subject: ASoC: soc-core: reduce verbosity of BE override message With dynamic debug not enabled, we still see this sort of messages: [ 47.656671] sof_sdw sof_sdw: info: override BE DAI link SDW0-Playback [ 47.656677] sof_sdw sof_sdw: info: override BE DAI link SDW0-Capture [ 47.656682] sof_sdw sof_sdw: info: override BE DAI link SDW1-Playback [ 47.656686] sof_sdw sof_sdw: info: override BE DAI link SDW3-Capture [ 47.656691] sof_sdw sof_sdw: info: override BE DAI link iDisp1 [ 47.656695] sof_sdw sof_sdw: info: override BE DAI link iDisp2 [ 47.656699] sof_sdw sof_sdw: info: override BE DAI link iDisp3 This is not really helpful for most users, move to dev_dbg. Signed-off-by: Pierre-Louis Bossart Reviewed-by: Bard Liao Reviewed-by: Kai Vehmanen Link: https://lore.kernel.org/r/20200612204050.25901-2-pierre-louis.bossart@linux.intel.com Signed-off-by: Mark Brown --- sound/soc/soc-core.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'sound/soc/soc-core.c') diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index 0f30f5aabaa8..e607a4927933 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -1638,8 +1638,8 @@ match: continue; } - dev_info(card->dev, "info: override BE DAI link %s\n", - card->dai_link[i].name); + dev_dbg(card->dev, "info: override BE DAI link %s\n", + card->dai_link[i].name); /* override platform component */ if (!dai_link->platforms) { -- cgit v1.2.3 From c7d75b5938e38a48e5fdac44f88fc5882f1f7bed Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Thu, 4 Jun 2020 17:06:22 +0900 Subject: ASoC: soc-component: move snd_soc_component_xxx_regmap() to soc-component soc-component is handling snd_soc_component_xxx(). Move snd_soc_component_xxx_regmap() to it. Signed-off-by: Kuninori Morimoto Reviewed-by: Ranjani Sridharan Link: https://lore.kernel.org/r/87sgfbw8zl.wl-kuninori.morimoto.gx@renesas.com Signed-off-by: Mark Brown --- sound/soc/soc-core.c | 50 -------------------------------------------------- 1 file changed, 50 deletions(-) (limited to 'sound/soc/soc-core.c') diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index 0f30f5aabaa8..13a59736b2fc 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -2398,56 +2398,6 @@ static int snd_soc_component_initialize(struct snd_soc_component *component, return 0; } -static void snd_soc_component_setup_regmap(struct snd_soc_component *component) -{ - int val_bytes = regmap_get_val_bytes(component->regmap); - - /* Errors are legitimate for non-integer byte multiples */ - if (val_bytes > 0) - component->val_bytes = val_bytes; -} - -#ifdef CONFIG_REGMAP - -/** - * snd_soc_component_init_regmap() - Initialize regmap instance for the - * component - * @component: The component for which to initialize the regmap instance - * @regmap: The regmap instance that should be used by the component - * - * This function allows deferred assignment of the regmap instance that is - * associated with the component. Only use this if the regmap instance is not - * yet ready when the component is registered. The function must also be called - * before the first IO attempt of the component. - */ -void snd_soc_component_init_regmap(struct snd_soc_component *component, - struct regmap *regmap) -{ - component->regmap = regmap; - snd_soc_component_setup_regmap(component); -} -EXPORT_SYMBOL_GPL(snd_soc_component_init_regmap); - -/** - * snd_soc_component_exit_regmap() - De-initialize regmap instance for the - * component - * @component: The component for which to de-initialize the regmap instance - * - * Calls regmap_exit() on the regmap instance associated to the component and - * removes the regmap instance from the component. - * - * This function should only be used if snd_soc_component_init_regmap() was used - * to initialize the regmap instance. - */ -void snd_soc_component_exit_regmap(struct snd_soc_component *component) -{ - regmap_exit(component->regmap); - component->regmap = NULL; -} -EXPORT_SYMBOL_GPL(snd_soc_component_exit_regmap); - -#endif - #define ENDIANNESS_MAP(name) \ (SNDRV_PCM_FMTBIT_##name##LE | SNDRV_PCM_FMTBIT_##name##BE) static u64 endianness_format_map[] = { -- cgit v1.2.3 From 536aba1dd4939bf647f5d182d4f101ae548e6505 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Thu, 4 Jun 2020 17:06:32 +0900 Subject: ASoC: soc-component: move snd_soc_component_initialize() to soc-component.c snd_soc_component_xxx() should be implemented at soc-component.c Signed-off-by: Kuninori Morimoto Reviewed-by: Ranjani Sridharan Link: https://lore.kernel.org/r/87r1uvw8zb.wl-kuninori.morimoto.gx@renesas.com Signed-off-by: Mark Brown --- sound/soc/soc-core.c | 29 ++++++++--------------------- 1 file changed, 8 insertions(+), 21 deletions(-) (limited to 'sound/soc/soc-core.c') diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index 13a59736b2fc..e596e5a765da 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -2378,26 +2378,6 @@ err: return ret; } -static int snd_soc_component_initialize(struct snd_soc_component *component, - const struct snd_soc_component_driver *driver, struct device *dev) -{ - INIT_LIST_HEAD(&component->dai_list); - INIT_LIST_HEAD(&component->dobj_list); - INIT_LIST_HEAD(&component->card_list); - mutex_init(&component->io_mutex); - - component->name = fmt_single_name(dev, &component->id); - if (!component->name) { - dev_err(dev, "ASoC: Failed to allocate name\n"); - return -ENOMEM; - } - - component->dev = dev; - component->driver = driver; - - return 0; -} - #define ENDIANNESS_MAP(name) \ (SNDRV_PCM_FMTBIT_##name##LE | SNDRV_PCM_FMTBIT_##name##BE) static u64 endianness_format_map[] = { @@ -2460,12 +2440,19 @@ int snd_soc_add_component(struct device *dev, struct snd_soc_dai_driver *dai_drv, int num_dai) { + const char *name = fmt_single_name(dev, &component->id); int ret; int i; + if (!name) { + dev_err(dev, "ASoC: Failed to allocate name\n"); + return -ENOMEM; + } + mutex_lock(&client_mutex); - ret = snd_soc_component_initialize(component, component_driver, dev); + ret = snd_soc_component_initialize(component, component_driver, + dev, name); if (ret) goto err_free; -- cgit v1.2.3 From 257c4dac8b7877c865e734533b5f62769c64afb6 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Thu, 4 Jun 2020 17:07:54 +0900 Subject: ASoC: soc-component: add snd_soc_component_init() we wantn't to directly access to component related parameter as much as possible to keep encapsulation. This patch adds snd_soc_component_init() for it. Signed-off-by: Kuninori Morimoto Reviewed-by: Ranjani Sridharan Link: https://lore.kernel.org/r/87img7w8x2.wl-kuninori.morimoto.gx@renesas.com Signed-off-by: Mark Brown --- sound/soc/soc-core.c | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) (limited to 'sound/soc/soc-core.c') diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index e596e5a765da..c38bb423e695 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -1208,15 +1208,14 @@ static int soc_probe_component(struct snd_soc_card *card, component->name); probed = 1; - /* machine specific init */ - if (component->init) { - ret = component->init(component); - if (ret < 0) { - dev_err(component->dev, - "Failed to do machine specific init %d\n", ret); - goto err_probe; - } - } + /* + * machine specific init + * see + * snd_soc_component_set_aux() + */ + ret = snd_soc_component_init(component); + if (ret < 0) + goto err_probe; ret = snd_soc_add_component_controls(component, component->driver->controls, @@ -1330,7 +1329,8 @@ static void soc_unbind_aux_dev(struct snd_soc_card *card) struct snd_soc_component *component, *_component; for_each_card_auxs_safe(card, component, _component) { - component->init = NULL; + /* for snd_soc_component_init() */ + snd_soc_component_set_aux(component, NULL); list_del(&component->card_aux_list); } } @@ -1347,7 +1347,8 @@ static int soc_bind_aux_dev(struct snd_soc_card *card) if (!component) return -EPROBE_DEFER; - component->init = aux->init; + /* for snd_soc_component_init() */ + snd_soc_component_set_aux(component, aux); /* see for_each_card_auxs */ list_add(&component->card_aux_list, &card->aux_comp_list); } -- cgit v1.2.3 From 21a00fb33790f828a34b9ce50ab9f9130bc1ffb4 Mon Sep 17 00:00:00 2001 From: Pierre-Louis Bossart Date: Mon, 22 Jun 2020 10:42:37 -0500 Subject: ASoC: soc-link: introduce exit() callback Some machine drivers allocate or request resources with snd_soc_link_init() phase of the card probe. These resources need to be properly released when removing a card, and this patch suggests a dual exit() callback. The exit() is invoked in soc_remove_pcm_runtime(), which is not completely symmetric with the init() invoked in soc_init_pcm_runtime(). Alternate solutions were considered, e.g. adding a .remove() callback for the platform driver, but that's not symmetrical at all and would be difficult to handle if there are more than one dailink implementing an .init(). We looked also into using .remove_dai_link() callback, but that would also be imbalanced. Note that because of the error handling in snd_soc_bind_card(), which jumps to probe_end, there is no way to guarantee the exit() is invoked with resources allocated in the init(). Prior to releasing those resources, implementations of the exit() callback shall check the resources are valid. Suggested-by: Andy Shevchenko Signed-off-by: Pierre-Louis Bossart Reviewed-by: Guennadi Liakhovetski Reviewed-by: Curtis Malainey Link: https://lore.kernel.org/r/20200622154241.29053-2-pierre-louis.bossart@linux.intel.com Signed-off-by: Mark Brown --- sound/soc/soc-core.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'sound/soc/soc-core.c') diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index 62c0c9482018..adedadcb0efb 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -945,6 +945,9 @@ void snd_soc_remove_pcm_runtime(struct snd_soc_card *card, { lockdep_assert_held(&client_mutex); + /* release machine specific resources */ + snd_soc_link_exit(rtd); + /* * Notify the machine driver for extra destruction */ -- cgit v1.2.3 From a0234d0e6014a17c61311fc39b9adc194114c5f6 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Fri, 17 Jul 2020 09:22:02 +0900 Subject: ASoC: soc-core: snd_soc_dai_digital_mute() for both CPU/Codec snd_soc_dai_digital_mute() is used for both CPU and Codec. For example, soc_pcm_prepare() / soc_pcm_hw_free() are caring both CPU and Codec. But soc_resume_deferred() / snd_soc_suspend() are not. This patch cares it. Signed-off-by: Kuninori Morimoto Reviewed-by: Peter Ujfalusi Link: https://lore.kernel.org/r/87ft9r2dqr.wl-kuninori.morimoto.gx@renesas.com Signed-off-by: Mark Brown --- sound/soc/soc-core.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'sound/soc/soc-core.c') diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index 7c58e45c1c3f..defd96b14c28 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -548,7 +548,7 @@ int snd_soc_suspend(struct device *dev) if (rtd->dai_link->ignore_suspend) continue; - for_each_rtd_codec_dais(rtd, i, dai) { + for_each_rtd_dais(rtd, i, dai) { if (snd_soc_dai_stream_active(dai, playback)) snd_soc_dai_digital_mute(dai, 1, playback); } @@ -687,7 +687,7 @@ static void soc_resume_deferred(struct work_struct *work) if (rtd->dai_link->ignore_suspend) continue; - for_each_rtd_codec_dais(rtd, i, dai) { + for_each_rtd_dais(rtd, i, dai) { if (snd_soc_dai_stream_active(dai, playback)) snd_soc_dai_digital_mute(dai, 0, playback); } -- cgit v1.2.3 From 5c74c9d34aec1ac756de6979dd5580096aba8643 Mon Sep 17 00:00:00 2001 From: Charles Keepax Date: Thu, 30 Jul 2020 13:07:14 +0100 Subject: ASoC: soc-core: Fix regression causing sysfs entries to disappear The allocation order of things in soc_new_pcm_runtime was changed to move the device_register before the allocation of the rtd structure. This was to allow the rtd allocation to be managed by devm. However currently the sysfs entries are added by device_register and their visibility depends on variables within the rtd structure, this causes the pmdown_time and dapm_widgets sysfs entries to be missing for all rtds. Correct this issue by manually calling device_add_groups after the appropriate information is available. Fixes: d918a37610b1 ("ASoC: soc-core: tidyup soc_new_pcm_runtime() alloc order") Signed-off-by: Charles Keepax Link: https://lore.kernel.org/r/20200730120715.637-1-ckeepax@opensource.cirrus.com Signed-off-by: Mark Brown --- sound/soc/soc-core.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'sound/soc/soc-core.c') diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index 2b8abf88ec60..f1d641cd48da 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -446,7 +446,6 @@ static struct snd_soc_pcm_runtime *soc_new_pcm_runtime( dev->parent = card->dev; dev->release = soc_release_rtd_dev; - dev->groups = soc_dev_attr_groups; dev_set_name(dev, "%s", dai_link->name); @@ -503,6 +502,10 @@ static struct snd_soc_pcm_runtime *soc_new_pcm_runtime( /* see for_each_card_rtds */ list_add_tail(&rtd->list, &card->rtd_list); + ret = device_add_groups(dev, soc_dev_attr_groups); + if (ret < 0) + goto free_rtd; + return rtd; free_rtd: -- cgit v1.2.3 From 08ff7209faf21daa01bf66c91c321ce52d4b4bdb Mon Sep 17 00:00:00 2001 From: Cezary Rojewski Date: Fri, 31 Jul 2020 16:41:44 +0200 Subject: ASoC: core: Relocate and expose snd_soc_component_initialize To allow for two-step component registration, expose snd_soc_component_initialize function and move it back to soc-core.c. Signed-off-by: Cezary Rojewski Link: https://lore.kernel.org/r/20200731144146.6678-2-cezary.rojewski@intel.com Signed-off-by: Mark Brown --- sound/soc/soc-core.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'sound/soc/soc-core.c') diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index defd96b14c28..36eba1bb1ce1 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -2438,6 +2438,23 @@ static void snd_soc_del_component_unlocked(struct snd_soc_component *component) list_del(&component->list); } +int snd_soc_component_initialize(struct snd_soc_component *component, + const struct snd_soc_component_driver *driver, + struct device *dev, const char *name) +{ + INIT_LIST_HEAD(&component->dai_list); + INIT_LIST_HEAD(&component->dobj_list); + INIT_LIST_HEAD(&component->card_list); + mutex_init(&component->io_mutex); + + component->name = name; + component->dev = dev; + component->driver = driver; + + return 0; +} +EXPORT_SYMBOL_GPL(snd_soc_component_initialize); + int snd_soc_add_component(struct device *dev, struct snd_soc_component *component, const struct snd_soc_component_driver *component_driver, -- cgit v1.2.3 From 7274d4cd8506bbff9bf2d7c2f73b2febff99abef Mon Sep 17 00:00:00 2001 From: Cezary Rojewski Date: Fri, 31 Jul 2020 16:41:45 +0200 Subject: ASoC: core: Simplify snd_soc_component_initialize declaration Move 'name' field initialization responsibility back to snd_soc_component_initialize to prepare snd_soc_add_component function for being called separatelly as a second registration step. Signed-off-by: Cezary Rojewski Link: https://lore.kernel.org/r/20200731144146.6678-3-cezary.rojewski@intel.com Signed-off-by: Mark Brown --- sound/soc/soc-core.c | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) (limited to 'sound/soc/soc-core.c') diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index 36eba1bb1ce1..d8155402c5e1 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -2440,14 +2440,19 @@ static void snd_soc_del_component_unlocked(struct snd_soc_component *component) int snd_soc_component_initialize(struct snd_soc_component *component, const struct snd_soc_component_driver *driver, - struct device *dev, const char *name) + struct device *dev) { INIT_LIST_HEAD(&component->dai_list); INIT_LIST_HEAD(&component->dobj_list); INIT_LIST_HEAD(&component->card_list); mutex_init(&component->io_mutex); - component->name = name; + component->name = fmt_single_name(dev, &component->id); + if (!component->name) { + dev_err(dev, "ASoC: Failed to allocate name\n"); + return -ENOMEM; + } + component->dev = dev; component->driver = driver; @@ -2461,19 +2466,12 @@ int snd_soc_add_component(struct device *dev, struct snd_soc_dai_driver *dai_drv, int num_dai) { - const char *name = fmt_single_name(dev, &component->id); int ret; int i; - if (!name) { - dev_err(dev, "ASoC: Failed to allocate name\n"); - return -ENOMEM; - } - mutex_lock(&client_mutex); - ret = snd_soc_component_initialize(component, component_driver, - dev, name); + ret = snd_soc_component_initialize(component, component_driver, dev); if (ret) goto err_free; -- cgit v1.2.3 From ea029dd8d0124fcd5db1c7003e87a7bd4ddb3bad Mon Sep 17 00:00:00 2001 From: Cezary Rojewski Date: Fri, 31 Jul 2020 16:41:46 +0200 Subject: ASoC: core: Two step component registration Modify snd_soc_add_component so it calls snd_soc_component_initialize no longer and thus providing true two-step registration. Drivers may choose to change component's fields before actually adding it to ASoC subsystem. Signed-off-by: Cezary Rojewski Link: https://lore.kernel.org/r/20200731144146.6678-4-cezary.rojewski@intel.com Signed-off-by: Mark Brown --- sound/soc/soc-core.c | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) (limited to 'sound/soc/soc-core.c') diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index d8155402c5e1..fe23e936e2d1 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -2460,22 +2460,16 @@ int snd_soc_component_initialize(struct snd_soc_component *component, } EXPORT_SYMBOL_GPL(snd_soc_component_initialize); -int snd_soc_add_component(struct device *dev, - struct snd_soc_component *component, - const struct snd_soc_component_driver *component_driver, - struct snd_soc_dai_driver *dai_drv, - int num_dai) +int snd_soc_add_component(struct snd_soc_component *component, + struct snd_soc_dai_driver *dai_drv, + int num_dai) { int ret; int i; mutex_lock(&client_mutex); - ret = snd_soc_component_initialize(component, component_driver, dev); - if (ret) - goto err_free; - - if (component_driver->endianness) { + if (component->driver->endianness) { for (i = 0; i < num_dai; i++) { convert_endianness_formats(&dai_drv[i].playback); convert_endianness_formats(&dai_drv[i].capture); @@ -2484,7 +2478,8 @@ int snd_soc_add_component(struct device *dev, ret = snd_soc_register_dais(component, dai_drv, num_dai); if (ret < 0) { - dev_err(dev, "ASoC: Failed to register DAIs: %d\n", ret); + dev_err(component->dev, "ASoC: Failed to register DAIs: %d\n", + ret); goto err_cleanup; } @@ -2502,7 +2497,7 @@ int snd_soc_add_component(struct device *dev, err_cleanup: if (ret < 0) snd_soc_del_component_unlocked(component); -err_free: + mutex_unlock(&client_mutex); if (ret == 0) @@ -2518,13 +2513,17 @@ int snd_soc_register_component(struct device *dev, int num_dai) { struct snd_soc_component *component; + int ret; component = devm_kzalloc(dev, sizeof(*component), GFP_KERNEL); if (!component) return -ENOMEM; - return snd_soc_add_component(dev, component, component_driver, - dai_drv, num_dai); + ret = snd_soc_component_initialize(component, component_driver, dev); + if (ret < 0) + return ret; + + return snd_soc_add_component(component, dai_drv, num_dai); } EXPORT_SYMBOL_GPL(snd_soc_register_component); -- cgit v1.2.3