summaryrefslogtreecommitdiff
path: root/sound/soc/soc-core.c
AgeCommit message (Collapse)Author
2021-05-24ASoC: core: Fix Null-point-dereference in fmt_single_name()Kefeng Wang
Check the return value of devm_kstrdup() in case of Null-point-dereference. Fixes: 45dd9943fce0 ("ASoC: core: remove artificial component and DAI name constraint") Cc: Dmitry Baryshkov <dmitry.baryshkov@linaro.org> Reported-by: Hulk Robot <hulkci@huawei.com> Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com> Link: https://lore.kernel.org/r/20210524024941.159952-1-wangkefeng.wang@huawei.com Signed-off-by: Mark Brown <broonie@kernel.org>
2021-04-19ASoC: soc-core: fix always-false conditionPierre-Louis Bossart
cppcheck warning: sound/soc/soc-core.c:2784:6: style: Condition '!num_routes' is always false [knownConditionTrueFalse] if (!num_routes) { ^ sound/soc/soc-core.c:2777:17: note: Assuming that condition 'num_routes<0' is not redundant if (num_routes < 0 || num_routes & 1) { ^ sound/soc/soc-core.c:2783:2: note: Compound assignment '/=', assigned value is 0 num_routes /= 2; ^ sound/soc/soc-core.c:2784:6: note: Condition '!num_routes' is always false if (!num_routes) { ^ The documentation for of_property_count_string reads " * Returns the number of strings on * success, -EINVAL if the property does not exist, -ENODATA if property * does not have a value, and -EILSEQ if the string is not null-terminated * within the length of the property data. " Since the case for num_routes == 0 is not possible, let's remove this test. Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com> Reviewed-by: Daniel Baluta <daniel.baluta@gmail.com> Reviewed-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com> Link: https://lore.kernel.org/r/20210416191144.27006-4-pierre-louis.bossart@linux.intel.com Signed-off-by: Mark Brown <broonie@kernel.org>
2021-04-19ASoC: soc-core: fix signed/unsigned issuePierre-Louis Bossart
cppcheck warning: sound/soc/soc-core.c:2237:13: warning: %x in format string (no. 1) requires 'unsigned int *' but the argument type is 'signed int *'. [invalidScanfArgType_int] } else if (sscanf(name, "%x-%x", &id1, &id2) == 2) { ^ sound/soc/soc-core.c:2237:13: warning: %x in format string (no. 2) requires 'unsigned int *' but the argument type is 'signed int *'. [invalidScanfArgType_int] } else if (sscanf(name, "%x-%x", &id1, &id2) == 2) { ^ Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com> Reviewed-by: Daniel Baluta <daniel.baluta@gmail.com> Reviewed-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com> Link: https://lore.kernel.org/r/20210416191144.27006-3-pierre-louis.bossart@linux.intel.com Signed-off-by: Mark Brown <broonie@kernel.org>
2021-04-16Merge series "ASoC: soc-pcm: ignore dummy-DAI at soc_pcm_params_symmetry()" ↵Mark Brown
from Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>: Hi Mark I noticed if we have... 1) Sound Card used DPCM 2) It exchanges rate to 48kHz by using .be_hw_params_fixup() 3) Codec had symmetric_rate = 1 We will get below error. I didn't confirm, but maybe same things happen if it exchanged channels/sample_bits. # aplay 44100.wav # aplay 44100.wav => [kernel] be.ak4613-hifi: ASoC: unmatched rate symmetry: snd-soc-dummy-dai:44100 - soc_pcm_params_symmetry:48000 [kernel] be.ak4613-hifi: ASoC: hw_params BE failed -22 [kernel] fe.rsnd-dai.0: ASoC: hw_params BE failed -22 aplay: set_params:1407: Unable to install hw params: ACCESS: RW_INTERLEAVED FORMAT: S16_LE SUBFORMAT: STD SAMPLE_BITS: 16 FRAME_BITS: 32 CHANNELS: 2 RATE: 44100 PERIOD_TIME: (23219 23220) PERIOD_SIZE: 1024 PERIOD_BYTES: 4096 PERIODS: 4 BUFFER_TIME: (92879 92880) BUFFER_SIZE: 4096 BUFFER_BYTES: 16384 TICK_TIME: 0 This patch-set solves this issue. patch 1) - 3) are just cleanup patches. 4) is fot this issue. Link: https://lore.kernel.org/r/87a6q0z4xt.wl-kuninori.morimoto.gx@renesas.com Kuninori Morimoto (4): ASoC: soc-pcm: don't use "name" on __soc_pcm_params_symmetry() macro ASoC: soc-pcm: indicate DAI name if soc_pcm_params_symmetry() failed ASoC: soc-utils: add snd_soc_component_is_dummy() ASoC: soc-pcm: ignore dummy-DAI at soc_pcm_params_symmetry() include/sound/soc-component.h | 1 + sound/soc/soc-core.c | 2 +- sound/soc/soc-pcm.c | 14 ++++++++------ sound/soc/soc-utils.c | 6 ++++++ 4 files changed, 16 insertions(+), 7 deletions(-) -- 2.25.1
2021-04-16ASoC: soc-utils: add snd_soc_component_is_dummy()Kuninori Morimoto
There is snd_soc_dai_is_dummy(), but not for component. This patch adds it. Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> Link: https://lore.kernel.org/r/87zgxzxa2t.wl-kuninori.morimoto.gx@renesas.com Signed-off-by: Mark Brown <broonie@kernel.org>
2021-04-16ASoC: core: Don't set platform name when of_node is setDaniel Baluta
A DAI link has 3 components: * CPU * platform * codec(s) A component is specified via: * name * of_node * dai_name In order to avoid confusion when building a sound card we disallow matching by both name and of_node (1). soc_check_tplg_fes allows overriding certain BE links by overriding BE link name. This doesn't work well if BE link was specified via DT, because we end up with a link with both name and of_node specified which is conflicting with (1). In order to fix this we need to: * override of_node if component was specified via DT * override name, otherwise. Signed-off-by: Daniel Baluta <daniel.baluta@nxp.com> Link: https://lore.kernel.org/r/20210414101212.65573-1-daniel.baluta@oss.nxp.com Signed-off-by: Mark Brown <broonie@kernel.org>
2021-03-31ASoC: soc-core: use device_unregister() if rtd allocation failedKuninori Morimoto
Because soc_free_pcm_runtime(rtd) checks rtd pointer and freeing rtd->xxx, it doesn't work correctly in case of rtd allocation failed. We need to use device_unregister(dev) in such case. This patch fixup it. Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> Link: https://lore.kernel.org/r/87r1jxxldd.wl-kuninori.morimoto.gx@renesas.com Signed-off-by: Mark Brown <broonie@kernel.org>
2021-03-31ASoC: soc-core: add comment for rtd freeingKuninori Morimoto
We don't need to mind freeing for rtd, because it was created from devm_kzalloc(dev, xxx) which is rtd->dev. This means, if rtd->dev was freed, rtd will be also freed automatically. soc_new_pcm_runtime(...) { ... rtd = devm_kzalloc(dev, ...); rtd->dev = dev; ... } This explanation was missing at soc_free_pcm_runtime() comment. This patch indicates it. Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> Link: https://lore.kernel.org/r/87sg4dxldn.wl-kuninori.morimoto.gx@renesas.com Signed-off-by: Mark Brown <broonie@kernel.org>
2021-03-19ASoC: don't indicate error message for snd_soc_[pcm_]component_xxx()Kuninori Morimoto
All snd_soc_component_xxx() and snd_soc_pcm_component_xxx() itself indicate error message if failed. Its caller doesn't need to indicate duplicated error message. This patch removes it. All snd_soc_component_xxx() indicate error message if failed. Its caller doesn't need to indicate duplicated error message. This patch removes it. Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> Link: https://lore.kernel.org/r/878s6puta6.wl-kuninori.morimoto.gx@renesas.com Signed-off-by: Mark Brown <broonie@kernel.org>
2021-03-19ASoC: don't indicate error message for snd_soc_[pcm_]dai_xxx()Kuninori Morimoto
All snd_soc_dai_xxx() and snd_soc_pcm_dai_xxx() itself indicate error message if failed. Its caller doesn't need to indicate duplicated error message. This patch removes it. Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> Link: https://lore.kernel.org/r/87a6r5utaa.wl-kuninori.morimoto.gx@renesas.com Signed-off-by: Mark Brown <broonie@kernel.org>
2021-03-11ASoC: soc-core: fix DMI handlingPierre-Louis Bossart
When DMI information is not present, trying to assign the card long name results in the following warning. WARNING KERN tegra-audio-graph-card sound: ASoC: no DMI vendor name! The initial solution suggested was to test if the card device is an ACPI one. This causes a regression visible to userspace on all Intel platforms, with UCM unable to load card profiles based on DMI information: the card devices are not necessarily ACPI ones, e.g. when the parent creates platform devices on Intel devices. To fix this problem, this patch exports the existing dmi_available variable and tests it in the ASoC core. Fixes: c014170408bc ("ASoC: soc-core: Prevent warning if no DMI table is present") Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com> Reviewed-by: Takashi Iwai <tiwai@suse.de> Acked-by: Jean Delvare <jdelvare@suse.de> Link: https://lore.kernel.org/r/20210310193928.108850-1-pierre-louis.bossart@linux.intel.com Signed-off-by: Mark Brown <broonie@kernel.org>
2021-03-10ASoC: constify of_phandle_args in snd_soc_get_dai_name()Krzysztof Kozlowski
The pointer to of_phandle_args passed to snd_soc_get_dai_name() and of_xlate_dai_name() implementations is not modified. Since it is being used only to translate passed OF node to a DAI name, it should not be modified, so mark it as const for correctness and safer code. Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org> Link: https://lore.kernel.org/r/20210221153024.453583-1-krzk@kernel.org Signed-off-by: Mark Brown <broonie@kernel.org>
2021-03-10ASoC: soc-core: Prevent warning if no DMI table is presentJon Hunter
Many systems do not use ACPI and hence do not provide a DMI table. On non-ACPI systems a warning, such as the following, is printed on boot. WARNING KERN tegra-audio-graph-card sound: ASoC: no DMI vendor name! The variable 'dmi_available' is not exported and so currently cannot be used by kernel modules without adding an accessor. However, it is possible to use the function is_acpi_device_node() to determine if the sound card is an ACPI device and hence indicate if we expect a DMI table to be present. Therefore, call is_acpi_device_node() to see if we are using ACPI and only parse the DMI table if we are booting with ACPI. Signed-off-by: Jon Hunter <jonathanh@nvidia.com> Link: https://lore.kernel.org/r/20210303115526.419458-1-jonathanh@nvidia.com Signed-off-by: Mark Brown <broonie@kernel.org>
2020-12-04Merge tag 'auxbus-5.11-rc1' of ↵Mark Brown
git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core into asoc-5.11 Auxiliary Bus support tag for 5.11-rc1 This is a signed tag for other subsystems to be able to pull in the auxiliary bus support into their trees for the 5.11-rc1 merge. Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2020-11-30ASoC: soc-core: tidyup jack.hKuninori Morimoto
soc-core.c don't need sound/jack.h anymore, but asoc.h needs it. This patch fixup header magic. Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> Link: https://lore.kernel.org/r/87y2iju3zm.wl-kuninori.morimoto.gx@renesas.com Signed-off-by: Mark Brown <broonie@kernel.org>
2020-11-27ASoC: soc-core: add soc_dapm_suspend_resume()Kuninori Morimoto
snd_soc_suspend() and soc_resume_deferred() are calling same snd_soc_dapm_stream_event() with same logic with different parameter. This patch adds new soc_dapm_suspend_resume() and share the code. Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> Link: https://lore.kernel.org/r/87im9rekfp.wl-kuninori.morimoto.gx@renesas.com Signed-off-by: Mark Brown <broonie@kernel.org>
2020-11-27ASoC: soc-core: add soc_playback_digital_mute()Kuninori Morimoto
snd_soc_suspend() and soc_resume_deferred() are calling same snd_soc_dai_digital_mute() with same logic with different parameter. This patch adds new soc_playback_digital_mute() and share the code. Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> Link: https://lore.kernel.org/r/87k0u7ekfv.wl-kuninori.morimoto.gx@renesas.com Signed-off-by: Mark Brown <broonie@kernel.org>
2020-11-10ASoC: soc-core: Fix component name_prefix parsingSameer Pujar
The "prefix" can be defined in DAI link node or it can be specified as part of the component node itself. Currently "sound-name-prefix" defined in a component is not taking effect. Actually the property is not getting parsed. It can be fixed by parsing "sound-name-prefix" property whenever "prefix" is missing in DAI link Codec node. Signed-off-by: Sameer Pujar <spujar@nvidia.com> Link: https://lore.kernel.org/r/1604329814-24779-2-git-send-email-spujar@nvidia.com Signed-off-by: Mark Brown <broonie@kernel.org>
2020-10-26ALSA: fix kernel-doc markupsMauro Carvalho Chehab
Kernel-doc markups should use this format: identifier - description There is a common comment marked, instead, with kernel-doc notation. Some identifiers have different names between their prototypes and the kernel-doc markup. Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org> Acked-by: Mark Brown <broonie@kernel.org> Link: https://lore.kernel.org/r/535182d6f55d7a7de293dda9676df68f5f60afc6.1603469755.git.mchehab+huawei@kernel.org Signed-off-by: Takashi Iwai <tiwai@suse.de>
2020-10-06Merge tag 'v5.9-rc5' into asoc-5.10Mark Brown
Linux 5.9-rc5
2020-09-30ASoC: soc-core: use devm_snd_soc_register_card()Qinglang Miao
Using devm_snd_soc_register_card() can make the code shorter and cleaner. Signed-off-by: Qinglang Miao <miaoqinglang@huawei.com> Link: https://lore.kernel.org/r/20200929112933.46977-1-miaoqinglang@huawei.com Signed-off-by: Mark Brown <broonie@kernel.org>
2020-08-28ASoC: core: remove artificial component and DAI name constraintDmitry Baryshkov
Current fmt_single_name code limits maximum name of a DAI or component to 32 bytes. On some systems corresponding device names might be longer than that (e.g. 17300000.remoteproc:glink-edge:apr:apr-service@8:routing). This will result in duplicate DAI/component names. Rewrite fmt_single_name() to remove such length limitations. Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org> Link: https://lore.kernel.org/r/20200827205100.1479331-1-dmitry.baryshkov@linaro.org Signed-off-by: Mark Brown <broonie@kernel.org>
2020-08-27ASoC: soc-core: add snd_soc_find_dai_with_mutex()Kuninori Morimoto
commit 25612477d20b52 ("ASoC: soc-dai: set dai_link dpcm_ flags with a helper") added snd_soc_dai_link_set_capabilities(). But it is using snd_soc_find_dai() (A) which is required client_mutex (B). And client_mutex is soc-core.c local. struct snd_soc_dai *snd_soc_find_dai(xxx) { ... (B) lockdep_assert_held(&client_mutex); ... } void snd_soc_dai_link_set_capabilities(xxx) { ... for_each_pcm_streams(direction) { ... for_each_link_cpus(dai_link, i, cpu) { (A) dai = snd_soc_find_dai(cpu); ... } ... for_each_link_codecs(dai_link, i, codec) { (A) dai = snd_soc_find_dai(codec); ... } } ... } Because of these background, we will get WARNING if .config has CONFIG_LOCKDEP. WARNING: CPU: 2 PID: 53 at sound/soc/soc-core.c:814 snd_soc_find_dai+0xf8/0x100 CPU: 2 PID: 53 Comm: kworker/2:1 Not tainted 5.7.0-rc1+ #328 Hardware name: Renesas H3ULCB Kingfisher board based on r8a77951 (DT) Workqueue: events deferred_probe_work_func pstate: 60000005 (nZCv daif -PAN -UAO) pc : snd_soc_find_dai+0xf8/0x100 lr : snd_soc_find_dai+0xf4/0x100 ... Call trace: snd_soc_find_dai+0xf8/0x100 snd_soc_dai_link_set_capabilities+0xa0/0x16c graph_dai_link_of_dpcm+0x390/0x3c0 graph_for_each_link+0x134/0x200 graph_probe+0x144/0x230 platform_drv_probe+0x5c/0xb0 really_probe+0xe4/0x430 driver_probe_device+0x60/0xf4 snd_soc_find_dai() will be used from (X) CPU/Codec/Platform driver with mutex lock, and (Y) Card driver without mutex lock. This snd_soc_dai_link_set_capabilities() is for Card driver, this means called without mutex. This patch adds snd_soc_find_dai_with_mutex() to solve it. Fixes: 25612477d20b52 ("ASoC: soc-dai: set dai_link dpcm_ flags with a helper") Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> Link: https://lore.kernel.org/r/87blixvuab.wl-kuninori.morimoto.gx@renesas.com Signed-off-by: Mark Brown <broonie@kernel.org>
2020-08-23treewide: Use fallthrough pseudo-keywordGustavo A. R. Silva
Replace the existing /* fall through */ comments and its variants with the new pseudo-keyword macro fallthrough[1]. Also, remove unnecessary fall-through markings when it is the case. [1] https://www.kernel.org/doc/html/v5.7/process/deprecated.html?highlight=fallthrough#implicit-switch-case-fall-through Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
2020-08-18ASoC: core: Add common helper to parse aux devs from device treeStephan Gerhold
simple-card.c and meson-card-utils.c use pretty much the same helper function to parse auxiliary devices from the device tree. Make it easier for other drivers to parse these from the device tree as well by adding a shared helper function to soc-core.c. snd_soc_of_parse_aux_devs() is pretty much a copy of meson_card_add_aux_devices() from meson-card-utils.c with two minor changes: - Make property name configurable as parameter - Change dev_err() message slightly for consistency with other error messages in soc-core.c Signed-off-by: Stephan Gerhold <stephan@gerhold.net> Reviewed-by: Jerome Brunet <jbrunet@baylibre.com> Link: https://lore.kernel.org/r/20200801100257.22658-1-stephan@gerhold.net Signed-off-by: Mark Brown <broonie@kernel.org>
2020-07-31Merge remote-tracking branch 'asoc/for-5.9' into asoc-nextMark Brown
2020-07-31ASoC: core: Two step component registrationCezary Rojewski
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 <cezary.rojewski@intel.com> Link: https://lore.kernel.org/r/20200731144146.6678-4-cezary.rojewski@intel.com Signed-off-by: Mark Brown <broonie@kernel.org>
2020-07-31ASoC: core: Simplify snd_soc_component_initialize declarationCezary Rojewski
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 <cezary.rojewski@intel.com> Link: https://lore.kernel.org/r/20200731144146.6678-3-cezary.rojewski@intel.com Signed-off-by: Mark Brown <broonie@kernel.org>
2020-07-31ASoC: core: Relocate and expose snd_soc_component_initializeCezary Rojewski
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 <cezary.rojewski@intel.com> Link: https://lore.kernel.org/r/20200731144146.6678-2-cezary.rojewski@intel.com Signed-off-by: Mark Brown <broonie@kernel.org>
2020-07-30ASoC: soc-core: Fix regression causing sysfs entries to disappearCharles Keepax
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 <ckeepax@opensource.cirrus.com> Link: https://lore.kernel.org/r/20200730120715.637-1-ckeepax@opensource.cirrus.com Signed-off-by: Mark Brown <broonie@kernel.org>
2020-07-17ASoC: soc-core: snd_soc_dai_digital_mute() for both CPU/CodecKuninori Morimoto
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 <kuninori.morimoto.gx@renesas.com> Reviewed-by: Peter Ujfalusi <peter.ujfalusi@ti.com> Link: https://lore.kernel.org/r/87ft9r2dqr.wl-kuninori.morimoto.gx@renesas.com Signed-off-by: Mark Brown <broonie@kernel.org>
2020-07-08Merge series "ASoC: topology: fix error handling flow" from Pierre-Louis ↵Mark Brown
Bossart <pierre-louis.bossart@linux.intel.com>: While experimenting and introducing errors in Baytrail topology files until I got them right, I encountered multiple kernel oopses and memory leaks. This is a first batch to harden the code, but we should probably think of a tool to fuzz the topology... Pierre-Louis Bossart (5): ASoC: topology: fix kernel oops on route addition error ASoC: topology: fix tlvs in error handling for widget_dmixer ASoC: topology: use break on errors, not continue ASoC: topology: factor kfree(se) in error handling ASoC: topology: add more logs when topology load fails. sound/soc/soc-topology.c | 97 ++++++++++++++++++++++++---------------- 1 file changed, 58 insertions(+), 39 deletions(-) base-commit: a5911ac5790acaf98c929b826b3f7b4a438f9759 -- 2.25.1
2020-07-07ASoC: core: Remove only the registered component in devm functionsMaxime Ripard
The ASoC devm_ functions that register a component (devm_snd_soc_register_component and devm_snd_dmaengine_pcm_register) will clean their component by running snd_soc_unregister_component. snd_soc_unregister_component will then remove all the components for the device that was used to register the component in the first place. However, some drivers register several components (such as a DAI and a dmaengine PCM) on the same device, and if the dmaengine PCM is registered first, then the DAI will be cleaned up first and snd_dmaengine_pcm_unregister will be called next. snd_dmaengine_pcm_unregister will then lookup the dmaengine PCM component on the device, and if there's one unregister that component and release its dmaengine channels. That doesn't happen in practice though since the first call to snd_soc_unregister_component removed all the components, so we never get the chance to release the dmaengine channels. In order to fix this, instead of removing all the components for a given device, we can simply remove the component that was registered in the first place. We should have the same number of component registration than we have components, so it should work just fine. Signed-off-by: Maxime Ripard <maxime@cerno.tech> Link: https://lore.kernel.org/r/20200707074237.287171-1-maxime@cerno.tech Signed-off-by: Mark Brown <broonie@kernel.org>
2020-06-23ASoC: soc-link: introduce exit() callbackPierre-Louis Bossart
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 <andriy.shevchenko@linux.intel.com> Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com> Reviewed-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com> Reviewed-by: Curtis Malainey <curtis@malainey.com> Link: https://lore.kernel.org/r/20200622154241.29053-2-pierre-louis.bossart@linux.intel.com Signed-off-by: Mark Brown <broonie@kernel.org>
2020-06-15Merge series "ASoC: improve core dmesg logs and verbosity" from Pierre-Louis ↵Mark Brown
Bossart <pierre-louis.bossart@linux.intel.com>: Try to both reduce useless verbosity and keep useful error reports. Pierre-Louis Bossart (3): ASoC: soc-core: reduce verbosity of BE override message ASoC: soc-pcm: improve error messages in soc_pcm_new() ASoC: soc-pcm/compress: reduce verbosity on mapping ok messages sound/soc/soc-compress.c | 4 ++-- sound/soc/soc-core.c | 4 ++-- sound/soc/soc-pcm.c | 13 +++++++------ 3 files changed, 11 insertions(+), 10 deletions(-) -- 2.20.1
2020-06-15ASoC: soc-component: add snd_soc_component_init()Kuninori Morimoto
we wantn't to directly access to component related parameter as much as possible to keep encapsulation. This patch adds snd_soc_component_init() for it. Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> Reviewed-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com> Link: https://lore.kernel.org/r/87img7w8x2.wl-kuninori.morimoto.gx@renesas.com Signed-off-by: Mark Brown <broonie@kernel.org>
2020-06-15ASoC: soc-component: move snd_soc_component_initialize() to soc-component.cKuninori Morimoto
snd_soc_component_xxx() should be implemented at soc-component.c Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> Reviewed-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com> Link: https://lore.kernel.org/r/87r1uvw8zb.wl-kuninori.morimoto.gx@renesas.com Signed-off-by: Mark Brown <broonie@kernel.org>
2020-06-15ASoC: soc-component: move snd_soc_component_xxx_regmap() to soc-componentKuninori Morimoto
soc-component is handling snd_soc_component_xxx(). Move snd_soc_component_xxx_regmap() to it. Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> Reviewed-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com> Link: https://lore.kernel.org/r/87sgfbw8zl.wl-kuninori.morimoto.gx@renesas.com Signed-off-by: Mark Brown <broonie@kernel.org>
2020-06-15ASoC: soc-core: reduce verbosity of BE override messagePierre-Louis Bossart
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 <pierre-louis.bossart@linux.intel.com> Reviewed-by: Bard Liao <yung-chuan.liao@linux.intel.com> Reviewed-by: Kai Vehmanen <kai.vehmanen@linux.intel.com> Link: https://lore.kernel.org/r/20200612204050.25901-2-pierre-louis.bossart@linux.intel.com Signed-off-by: Mark Brown <broonie@kernel.org>
2020-06-12ASoC: soc-card: export snd_soc_lookup_component_nolockedShengjiu Wang
snd_soc_lookup_component_nolocked can be used for the DPCM case that Front-End needs to get the unused platform component but added by Back-End cpu dai driver. If the component is gotten, then we can get the dma chan created by Back-End component and reused it in Front-End. Signed-off-by: Shengjiu Wang <shengjiu.wang@nxp.com> Reviewed-by: Nicolin Chen <nicoleotsuka@gmail.com> Link: https://lore.kernel.org/r/55f6e0d76f67a517b9a44136d790ff2a06b5caa8.1591947428.git.shengjiu.wang@nxp.com Signed-off-by: Mark Brown <broonie@kernel.org>
2020-06-09ASoC: core: only convert non DPCM link to DPCM linkBard Liao
Additional checks for valid DAIs expose a corner case, where existing BE dailinks get modified, e.g. HDMI links are tagged with dpcm_capture=1 even if the DAIs are for playback. This patch makes those changes conditional and flags configuration issues when a BE dailink is has no_pcm=0 but dpcm_playback or dpcm_capture=1 (which makes no sense). As discussed on the alsa-devel mailing list, there are redundant flags for dpcm_playback, dpcm_capture, playback_only, capture_only. This will have to be cleaned-up in a future update. For now only correct and flag problematic configurations. Fixes: 218fe9b7ec7f3 ("ASoC: soc-core: Set dpcm_playback / dpcm_capture") Suggested-by: Daniel Baluta <daniel.baluta@nxp.com> Signed-off-by: Bard Liao <yung-chuan.liao@linux.intel.com> Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com> Reviewed-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com> Reviewed-by: Daniel Baluta <daniel.baluta@gmail.com> Reviewed-by: Bard Liao <yung-chuan.liao@linux.intel.com> Link: https://lore.kernel.org/r/20200608194415.4663-3-pierre-louis.bossart@linux.intel.com Signed-off-by: Mark Brown <broonie@kernel.org>
2020-05-30ASoC: soc-card: add snd_soc_card_remove_dai_link()Kuninori Morimoto
Card related function should be implemented at soc-card now. This patch adds it. Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> Reviewed-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com> Link: https://lore.kernel.org/r/87mu5szv2h.wl-kuninori.morimoto.gx@renesas.com Signed-off-by: Mark Brown <broonie@kernel.org>
2020-05-30ASoC: soc-card: add snd_soc_card_add_dai_link()Kuninori Morimoto
Card related function should be implemented at soc-card now. This patch adds it. This patch adds missing return when error case. Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> Reviewed-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com> Link: https://lore.kernel.org/r/87o8q8zv2m.wl-kuninori.morimoto.gx@renesas.com Signed-off-by: Mark Brown <broonie@kernel.org>
2020-05-30ASoC: soc-card: add snd_soc_card_remove()Kuninori Morimoto
Card related function should be implemented at soc-card now. This patch adds it. Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> Reviewed-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com> Link: https://lore.kernel.org/r/87tv00zv4p.wl-kuninori.morimoto.gx@renesas.com Signed-off-by: Mark Brown <broonie@kernel.org>
2020-05-30ASoC: soc-card: add snd_soc_card_late_probe()Kuninori Morimoto
Card related function should be implemented at soc-card now. This patch adds it. card has "card->probe" and "card->late_probe" callbacks, and "late_probe" callback is called after "probe". This means, we can set "card->probed" flag afer "late_probe" for all cases. Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> Reviewed-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com> Link: https://lore.kernel.org/r/87v9kgzv4w.wl-kuninori.morimoto.gx@renesas.com Signed-off-by: Mark Brown <broonie@kernel.org>
2020-05-30ASoC: soc-card: add snd_soc_card_probe()Kuninori Morimoto
Card related function should be implemented at soc-card now. This patch adds it. One note here is that card has "card->probe" and "card->late_probe" callbacks. Because it needs to care "late_probe", "card->probed" flag is set under if (card->probe) at snd_soc_card_probe(). Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> Reviewed-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com> Link: https://lore.kernel.org/r/87wo4wzv54.wl-kuninori.morimoto.gx@renesas.com Signed-off-by: Mark Brown <broonie@kernel.org>
2020-05-30ASoC: soc-card: add probed bit field to snd_soc_cardKuninori Morimoto
We already have bit field to control snd_soc_card. Let's add "probed" field on it instead of local variable. One note here is that soc_cleanup_card_resources() will be called as (A) formal cleanup or as (B) error handling, thus, it needs to distinguish these. In (A) case, card will have "instantiated" flag if all probe callback functions were called without error. Thus, snd_soc_unbind_card() is using it to judging card was probed. But this this patch removes it, because it is no longer needed. Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> Reviewed-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com> Link: https://lore.kernel.org/r/87r1v4zv36.wl-kuninori.morimoto.gx@renesas.com Signed-off-by: Mark Brown <broonie@kernel.org>
2020-05-30ASoC: soc-card: add snd_soc_card_resume_post()Kuninori Morimoto
Card related function should be implemented at soc-card now. This patch adds it. Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> Reviewed-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com> Link: https://lore.kernel.org/r/87y2pczv5d.wl-kuninori.morimoto.gx@renesas.com Signed-off-by: Mark Brown <broonie@kernel.org>
2020-05-30ASoC: soc-card: add snd_soc_card_resume_pre()Kuninori Morimoto
Card related function should be implemented at soc-card now. This patch adds it. Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> Reviewed-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com> Link: https://lore.kernel.org/r/87zh9szv5k.wl-kuninori.morimoto.gx@renesas.com Signed-off-by: Mark Brown <broonie@kernel.org>
2020-05-30ASoC: soc-card: add snd_soc_card_suspend_post()Kuninori Morimoto
Card related function should be implemented at soc-card now. This patch adds it. Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> Reviewed-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com> Link: https://lore.kernel.org/r/871rn425j3.wl-kuninori.morimoto.gx@renesas.com Signed-off-by: Mark Brown <broonie@kernel.org>