Commit Graph

1217 Commits

Author SHA1 Message Date
Mark Brown aeb2e9c4ee
ASoC: Merge up fixes
Merge the fixes branch up so we can apply further AMD work.
2022-11-29 12:55:51 +00:00
Cezary Rojewski c7eb967d70
ASoC: core: Exit all links before removing their components
Flows leading to link->init() and link->exit() are not symmetric.
Currently the relevant part of card probe sequence goes as:

	for_each_card_rtds(card, rtd)
		for_each_rtd_components(rtd, i, component)
			component->probe()
	for_each_card_rtds(card, rtd)
		for_each_rtd_dais(rtd, i, dai)
			dai->probe()
	for_each_card_rtds(card, rtd)
		rtd->init()

On the other side, equivalent remove sequence goes as:

	for_each_card_rtds(card, rtd)
		for_each_rtd_dais(rtd, i, dai)
			dai->remove()
	for_each_card_rtds(card, rtd)
		for_each_rtd_components(rtd, i, component)
			component->remove()
	for_each_card_rtds(card, rtd)
		rtd->exit()

what can lead to errors as link->exit() may still operate on resources
owned by its components despite the probability of them being freed
during the component->remove().

This change modifies the remove sequence to:

	for_each_card_rtds(card, rtd)
		rtd->exit()
	for_each_card_rtds(card, rtd)
		for_each_rtd_dais(rtd, i, dai)
			dai->remove()
	for_each_card_rtds(card, rtd)
		for_each_rtd_components(rtd, i, component)
			component->remove()

so code found in link->exit() is safe to touch any component stuff as
component->remove() has not been called yet.

Signed-off-by: Cezary Rojewski <cezary.rojewski@intel.com>
Reviewed-by: Amadeusz Sławiński <amadeuszx.slawinski@linux.intel.com>
Link: https://lore.kernel.org/r/20221027085840.1562698-1-cezary.rojewski@intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2022-11-18 15:38:27 +00:00
lishqchn 66a796c04b
ASoC: core: fix wrong size kzalloc for rtd's components member
The actual space for struct snd_soc_component has been allocated by
snd_soc_register_component, here rtd's components are pointers to
components, I replace the base size from *component to component.

Signed-off-by: lishqchn <lishqchn@qq.com>
Link: https://lore.kernel.org/r/tencent_59850BB028662B6F2D49D7F3624AB84CCF05@qq.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2022-11-15 14:16:19 +00:00
Chen Zhongjin 6ec27c5388
ASoC: core: Fix use-after-free in snd_soc_exit()
KASAN reports a use-after-free:

BUG: KASAN: use-after-free in device_del+0xb5b/0xc60
Read of size 8 at addr ffff888008655050 by task rmmod/387
CPU: 2 PID: 387 Comm: rmmod
Hardware name: QEMU Standard PC (i440FX + PIIX, 1996)
Call Trace:
<TASK>
dump_stack_lvl+0x79/0x9a
print_report+0x17f/0x47b
kasan_report+0xbb/0xf0
device_del+0xb5b/0xc60
platform_device_del.part.0+0x24/0x200
platform_device_unregister+0x2e/0x40
snd_soc_exit+0xa/0x22 [snd_soc_core]
__do_sys_delete_module.constprop.0+0x34f/0x5b0
do_syscall_64+0x3a/0x90
entry_SYSCALL_64_after_hwframe+0x63/0xcd
...
</TASK>

It's bacause in snd_soc_init(), snd_soc_util_init() is possble to fail,
but its ret is ignored, which makes soc_dummy_dev unregistered twice.

snd_soc_init()
    snd_soc_util_init()
        platform_device_register_simple(soc_dummy_dev)
        platform_driver_register() # fail
    	platform_device_unregister(soc_dummy_dev)
    platform_driver_register() # success
...
snd_soc_exit()
    snd_soc_util_exit()
    # soc_dummy_dev will be unregistered for second time

To fix it, handle error and stop snd_soc_init() when util_init() fail.
Also clean debugfs when util_init() or driver_register() fail.

Fixes: fb257897bf ("ASoC: Work around allmodconfig failure")
Signed-off-by: Chen Zhongjin <chenzhongjin@huawei.com>
Link: https://lore.kernel.org/r/20221028031603.59416-1-chenzhongjin@huawei.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2022-10-28 12:58:04 +01:00
Jaroslav Kysela c8d18e4402
ASoC: core: clarify the driver name initialization
The driver field in the struct snd_ctl_card_info is a valid
user space identifier. Actually, many ASoC drivers do not care
and let to initialize this field using a standard wrapping method.
Unfortunately, in this way, this field becomes unusable and
unreadable for the drivers with longer card names. Also,
there is a possibility to have clashes (driver field has
only limit of 15 characters).

This change will print an error when the wrapping is used.
The developers of the affected drivers should fix the problem.

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
Reviewed-by: Nícolas F. R. A. Prado <nfraprado@collabora.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2022-09-29 17:22:41 +01:00
Kuninori Morimoto 3989ade2d1
ASoC: soc.h: remove num_cpus/codecs
Current rtd has both dai_link pointer (A) and num_cpus/codecs (B).

(A)	rtd->dai_link	= dai_link;
(B)	rtd->num_cpus	= dai_link->num_cpus;
(B)	rtd->num_codecs	= dai_link->num_codecs;

But, we can get num_cpus/codecs (B) via dai_link (A).
This means we don't need to keep num_cpus/codecs on rtd.
This patch removes these.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Link: https://lore.kernel.org/r/87sfkmv9n3.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2022-09-20 12:19:30 +01:00
Kuninori Morimoto c403dcd8b0
ASoC: soc-core.c: setup rtd->pmdown_time at soc_new_pcm_runtime()
Almost all default rtd->xxx are setup at soc_new_pcm_runtime()
which is sub-function of snd_soc_add_pcm_runtime() (A).
But "rtd->pmdown_time" is setup at soc_init_pcm_runtime() (B).
It is very random timing setup. This patch setup it at (A),
same as other rtd->xxx.

	static int snd_soc_bind_card(...)
	{
		...
		for_each_card_prelinks(...) {
(A)			ret = snd_soc_add_pcm_runtime(...);
			...
		}
		...
		for_each_card_rtds(...) {
(B)			ret = soc_init_pcm_runtime(...);
			...
		}
		...
	}

One note is that current topology/intel are directly calling
snd_soc_add_pcm_runtime() (A) without calling soc_init_pcm_runtime() (B).
This means, its "rtd->pmdown_time settings" was 0, but will have default
value by this patch.

"rtd->pmdown_time settings" will be used at
snd_soc_runtime_ignore_pmdown_time(). This patch adds
"ignore_pmdown_time" to these driver to keep compatibility.

	bool snd_soc_runtime_ignore_pmdown_time(...)
	{
		...
=>		if (!rtd->pmdown_time || rtd->dai_link->ignore_pmdown_time)
			return true;
		...
	}

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Link: https://lore.kernel.org/r/875yhxmjjd.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2022-09-19 17:52:41 +01:00
Takashi Iwai 628d0f72d5
ASoC: core: Replace sprintf() with sysfs_emit()
For sysfs outputs, it's safer to use a new helper, sysfs_emit(),
instead of the raw sprintf() & co.  This patch replaces the sprintf()
usage straightforwardly with a new helper, sysfs_emit().

Signed-off-by: Takashi Iwai <tiwai@suse.de>
Link: https://lore.kernel.org/r/20220801170108.26340-7-tiwai@suse.de
Signed-off-by: Mark Brown <broonie@kernel.org>
2022-08-15 01:19:49 +01:00
Kuninori Morimoto 9cc6952818
ASoC: soc-core.c: share code for snd_soc_of_get_dai_link_cpus/codecs()
ASoC has snd_soc_of_get_dai_link_cpus/codecs(), and these are almost same
code. The main difference are below.

	for_each_link_cpus()	dai_link->cpus		dai_link->num_cpus
	for_each_link_codecs()	dai_link->codecs	dai_link->num_codecs

Because we need to use these parameters, we can't share full-code for now,
but can share some codes.
This patch adds __snd_soc_of_get/put_xxx() functions, and share the code.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Link: https://lore.kernel.org/r/87y1xpp7ju.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2022-06-29 18:10:15 +01:00
Kuninori Morimoto 586fb26413
ASoC: soc-core.c: fixup snd_soc_of_get_dai_link_cpus()
commit 900dedd7e4 ("ASoC: Introduce snd_soc_of_get_dai_link_cpus")
adds new snd_soc_of_get_dai_link_cpus(), but it is using
"codec" everywhere. It is very strange, and is issue when error case.
It should call cpu instead of codec in error case.
This patch tidyup it.

Fixes: 900dedd7e4 ("ASoC: Introduce snd_soc_of_get_dai_link_cpus")
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Reviewed-by: Martin Povišer <povik+lin@cutebit.org>
Link: https://lore.kernel.org/r/87zgi5p7k1.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2022-06-29 18:10:14 +01:00
Charles Keepax 129f055a21
ASoC: core: Switch core to new DAI naming flag
Now all the drivers are updated to have the new legacy_dai_naming
flag, update the core code so it also uses the new flag. Paving
the way for the old non_legacy_dai_naming flag to be removed.

It should be noted this patch will affect the CODEC drivers that don't
specify the non_legacy_dai_naming flag. These drivers will update from
using legacy DAI naming to the new scheme after this patch, this is
being considered a fix as the intention was for all CODEC drivers to use
the new scheme and all existing CODEC drivers were updated to do so
before componentisation. This just corrects those devices that have
snuck in since componentisation. The corrected devices are as
follows:

adau1372, cros_ec_codec, cs35l41, cs35l45, cx2072x, hdac_hda,
jz4725/60/70, lpass-rx/tx/va/wsa-macro, max98504, max9877,
mt6351/58/59, mt6660, pcm3060, rk3328, rt1308/16, rt5514,
rt5677, rt700/11/15, rt9120, sdw-mockup, tlv320adc3xxx, tscs454,
wcd9335/4x/8x, wsa881x

Some of these devices are used in some in kernel machine drivers,
however it appears all the usages use the actual DAI driver name
(since snd_soc_find_dai checks both the DAI name and the DAI driver
name). So it is not believed this change will break any in tree
machine drivers.

Signed-off-by: Charles Keepax <ckeepax@opensource.cirrus.com>
Link: https://lore.kernel.org/r/20220623125250.2355471-35-ckeepax@opensource.cirrus.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2022-06-27 13:16:45 +01:00
Uwe Kleine-König 1892a99188
ASoC: core: Make snd_soc_unregister_card() return void
The function snd_soc_unregister_card() returned 0 unconditionally and most
callers don't care to check the return value. Make it return void and
adapt the callers that didn't ignore the return value before.

This is a preparation for making platform remove callbacks return void.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Link: https://lore.kernel.org/r/20220621145834.198519-1-u.kleine-koenig@pengutronix.de
Signed-off-by: Mark Brown <broonie@kernel.org>
2022-06-22 13:39:34 +01:00
Martin Povišer df4d27b19b
ASoC: Introduce 'fixup_controls' card method
The new method is called just before the card is registered, providing
an opportune time for machine-level drivers to do some final controls
amending: deactivating individual controls or obtaining control
references for later use.

Some controls can be created by DAPM after 'late_probe' has been called,
hence the need for this new method.

Signed-off-by: Martin Povišer <povik+lin@cutebit.org>
Link: https://lore.kernel.org/r/20220606191910.16580-5-povik+lin@cutebit.org
Signed-off-by: Mark Brown <broonie@kernel.org>
2022-06-10 13:32:20 +01:00
Charles Keepax 6c076273a3
ASoC: core: Always send the CPU DAI a direct clock specifier
All CPU drivers are now updated to accept a direct indication of
whether they are clock provider or consumer, rather than being told
if the CODEC is clock provider. As such update the core to always
pass this direct indication rather than only if the new set_fmt_new
callback is defined. Note this makes no difference to the CODEC
side of the DAI link as it was already being directly told if it
was clock provider under the old system.

Signed-off-by: Charles Keepax <ckeepax@opensource.cirrus.com>
Link: https://lore.kernel.org/r/20220519154318.2153729-29-ckeepax@opensource.cirrus.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2022-06-06 12:33:53 +01:00
Charles Keepax 905f3a04e1
ASoC: core: Add set_fmt_new callback that directly specifies provider
The original set_fmt callback always passes clock provider/consumer
with respect to the CODEC. This made sense when the framework was
directly broken down into platforms and CODECs. Now everything is
componentised it simplifies things if each side of the link is
just told if it is provider or consumer of the clocks. To start
this migration add a new callback that can be used to receive a
direct specification of clocking. As there are more CODEC drivers
than platform drivers, we make the new flags identical to the old
CODEC flags meaning CODEC drivers will not require an update.

Signed-off-by: Charles Keepax <ckeepax@opensource.cirrus.com>
Link: https://lore.kernel.org/r/20220519154318.2153729-2-ckeepax@opensource.cirrus.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2022-06-06 12:33:25 +01:00
Charles Keepax 8c8a0f01c7
ASoC: core: Pass legacy_dai_naming flag directly
Passing the result of the helper function snd_soc_component_is_codec
to snd_soc_register_dai is less clear than just passing the DAI
naming flag directly. snd_soc_register_dai wants to know if it
should use the legacy DAI naming. The CODEC distinction is more
of a historical thing and not obviously directly related, and there
are already a couple of CPU side components that explicitly opt in
to non-legacy DAI naming.

Signed-off-by: Charles Keepax <ckeepax@opensource.cirrus.com>
Link: https://lore.kernel.org/r/20220513090532.1450944-2-ckeepax@opensource.cirrus.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2022-05-16 12:58:40 +01:00
Charles Keepax 64c917d1cf
ASoC: core: Correct spelling fliped -> flipped
Signed-off-by: Charles Keepax <ckeepax@opensource.cirrus.com>
Link: https://lore.kernel.org/r/20220513090532.1450944-1-ckeepax@opensource.cirrus.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2022-05-16 12:58:39 +01:00
Pierre-Louis Bossart 8ad0b83e00
ASoC: soc-core: remove always-false path
cppcheck throws the following warning:

sound/soc/soc-core.c:2773:6: style: Condition '!num_widgets' is always
false [knownConditionTrueFalse]
 if (!num_widgets) {
     ^

sound/soc/soc-core.c:2761:18: note: Assuming that condition
'num_widgets<0' is not redundant
 if (num_widgets < 0) {
                 ^
sound/soc/soc-core.c:2766:18: note: Assuming condition is false
 if (num_widgets & 1) {
                 ^
sound/soc/soc-core.c:2772:2: note: Compound assignment '/=', assigned
value is 0
 num_widgets /= 2;
 ^

We should check upfront all error conditions.

Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Reviewed-by: Bard Liao <yung-chuan.liao@linux.intel.com>
Reviewed-by: Rander Wang <rander.wang@intel.com>
Reviewed-by: Péter Ujfalusi <peter.ujfalusi@linux.intel.com>
Link: https://lore.kernel.org/r/20220421162505.302132-1-pierre-louis.bossart@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2022-04-23 00:16:28 +01:00
Mark Brown 3d5746a187
ASoC: Merge fixes
Pull in wm8731 fix.

Signed-off-by: Mark Brown <broonie@kernel.org>
2022-04-08 12:22:10 +01:00
Heiner Kallweit d462f6ed2a
ASoC: soc-core: add debugfs_prefix member to snd_soc_component_driver
Allow the component debugfs_prefix to be set from
snd_soc_component_driver. First use case is avoiding a duplicate
debugfs entry error in case a device has multiple components
which have the same name therefore.

Note that we don't set component->debugfs_prefix if it's set already.
That's needed because partially component->debugfs_prefix is set
before calling snd_soc_component_initialize().

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
Link: https://lore.kernel.org/r/d18bff6a-1df1-5f95-0cf8-10dbaa62d7be@gmail.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2022-04-05 19:14:20 +01:00
Martin Povišer 900dedd7e4
ASoC: Introduce snd_soc_of_get_dai_link_cpus
This function is an analogue of snd_soc_of_get_dai_link_codecs to help
machine drivers read CPU DAI lists from devicetrees.

Signed-off-by: Martin Povišer <povik+lin@cutebit.org>
Link: https://lore.kernel.org/r/20220331000449.41062-5-povik+lin@cutebit.org
Signed-off-by: Mark Brown <broonie@kernel.org>
2022-04-05 10:23:08 +01:00
Cezary Rojewski da0398099a
ASoC: Export DAI register and widget ctor and dctor functions
To allow for more flexibility i.e. populating component DAIs dynamically
during its initialization, without being limited to topology loading
procedure, expose snd_soc_register(), snd_soc_dapm_new_dai_widgets() and
snd_soc_dapm_free_widget() functions.

Allows users to first check available resources e.g. number of PCMs
supported by HDAudio codec before allocating the number of DAPM
widgets needed. This prevents superfluous objects from being created or
allows driver to adjust to situation when resources are limited.

Signed-off-by: Cezary Rojewski <cezary.rojewski@intel.com>
Link: https://lore.kernel.org/r/20220311153544.136854-3-cezary.rojewski@intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2022-03-11 16:23:53 +00:00
Shengjiu Wang f7d344a2bd
ASoC: soc-core: skip zero num_dai component in searching dai name
In the case like dmaengine which's not a dai but as a component, the
num_dai is zero, dmaengine component has the same component_of_node
as cpu dai, when cpu dai component is not ready, but dmaengine component
is ready, try to get cpu dai name, the snd_soc_get_dai_name() return
-EINVAL, not -EPROBE_DEFER, that cause below error:

asoc-simple-card <card name>: parse error -22
asoc-simple-card: probe of <card name> failed with error -22

The sound card failed to probe.

So this patch fixes the issue above by skipping the zero num_dai
component in searching dai name.

Signed-off-by: Shengjiu Wang <shengjiu.wang@nxp.com>
Link: https://lore.kernel.org/r/1644491952-7457-1-git-send-email-shengjiu.wang@nxp.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2022-02-15 12:52:45 +00:00
Stephan Gerhold 3d4641a42c
ASoC: core: Add snd_soc_of_parse_pin_switches() from simple-card-utils
The ASoC core already has several helpers to parse card properties
from the device tree. Move the parsing code for "pin-switches" from
simple-card-utils to a shared snd_soc_of_parse_pin_switches() function
so other drivers can also use it to set up pin switches configured in
the device tree.

Cc: Paul Cercueil <paul@crapouillou.net>
Signed-off-by: Stephan Gerhold <stephan@gerhold.net>
Link: https://lore.kernel.org/r/20211214142049.20422-2-stephan@gerhold.net
Signed-off-by: Mark Brown <broonie@kernel.org>
2021-12-23 18:34:23 +00:00
Takashi Iwai b7898396f4
ASoC: soc-pcm: Fix and cleanup DPCM locking
The existing locking for DPCM has several issues
a) a confusing mix of card->mutex and card->pcm_mutex.
b) a dpcm_lock spinlock added inconsistently and on paths that could
be recursively taken. The use of irqsave/irqrestore was also overkill.

The suggested model is:

1) The pcm_mutex is the top-most protection of BE links in the FE. The
pcm_mutex is applied always on either the top PCM callbacks or the
external call from DAPM, not taken in the internal functions.

2) the FE stream lock is taken in higher levels before invoking
dpcm_be_dai_trigger()

3) when adding and deleting a BE, both the pcm_mutex and FE stream
lock are taken.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
[clarification of commit message by plbossart]
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Reviewed-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
Reviewed-by: Bard Liao <yung-chuan.liao@linux.intel.com>
Reviewed-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Link: https://lore.kernel.org/r/20211207173745.15850-4-pierre-louis.bossart@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2021-12-14 17:15:45 +00:00
Amadeusz Sławiński 7db53c21b1
ASoC: core: Remove invalid snd_soc_component_set_jack call
If snd_soc_component_set_jack() is called after
snd_soc_component_remove() it may operate on memory which is freed in
->remove handler.

Signed-off-by: Amadeusz Sławiński <amadeuszx.slawinski@linux.intel.com>
Signed-off-by: Cezary Rojewski <cezary.rojewski@intel.com>
Link: https://lore.kernel.org/r/20211015161257.27052-2-cezary.rojewski@intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2021-10-29 16:49:40 +01:00
Mark Brown bfceb9c216
Merge branch 'asoc-5.15' into asoc-5.16 2021-10-18 21:15:13 +01:00
Kuninori Morimoto 7db07e37e1
ASoC: soc-core: accept zero format at snd_soc_runtime_set_dai_fmt()
Do nothing if format was zero at snd_soc_runtime_set_dai_fmt().
soc-core.c can be more simple code by this patch.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Link: https://lore.kernel.org/r/87ee8jt7d3.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2021-10-18 13:56:40 +01:00
Kuninori Morimoto 41b1774fb8
ASoC: soc-core: tidyup empty function
This patch makes empty function to 1 line.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Link: https://lore.kernel.org/r/87fsszt7dd.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2021-10-18 13:56:38 +01:00
Kuninori Morimoto 01e90ee15e
ASoC: soc-component: add snd_soc_component_is_codec()
Checking .non_legacy_dai_naming is not readable.
Let's add new snd_soc_component_is_codec().

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Link: https://lore.kernel.org/r/87h7dft7dn.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2021-10-18 13:56:37 +01:00
Yang Yingliang c448b7aa3e
ASoC: soc-core: fix null-ptr-deref in snd_soc_del_component_unlocked()
'component' is allocated in snd_soc_register_component(), but component->list
is not initalized, this may cause snd_soc_del_component_unlocked() deref null
ptr in the error handing case.

KASAN: null-ptr-deref in range [0x0000000000000000-0x0000000000000007]
RIP: 0010:__list_del_entry_valid+0x81/0xf0
Call Trace:
 snd_soc_del_component_unlocked+0x69/0x1b0 [snd_soc_core]
 snd_soc_add_component.cold+0x54/0x6c [snd_soc_core]
 snd_soc_register_component+0x70/0x90 [snd_soc_core]
 devm_snd_soc_register_component+0x5e/0xd0 [snd_soc_core]
 tas2552_probe+0x265/0x320 [snd_soc_tas2552]
 ? tas2552_component_probe+0x1e0/0x1e0 [snd_soc_tas2552]
 i2c_device_probe+0xa31/0xbe0

Fix by adding INIT_LIST_HEAD() to snd_soc_component_initialize().

Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
Link: https://lore.kernel.org/r/20211009065840.3196239-1-yangyingliang@huawei.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2021-10-11 13:19:14 +01:00
Kuninori Morimoto 51a3dd5842
ASoC: soc-core: cleanup cppcheck warning at snd_soc_of_parse_audio_routing()
This patch cleanups below cppcheck warning.

sound/soc/soc-core.c:2931:9: style: The scope of the variable 'ret' can be reduced. [variableScope]
 int i, ret;
        ^

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Link: https://lore.kernel.org/r/87o8alyl67.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2021-07-29 15:35:45 +01:00
Kuninori Morimoto 99c68653a5
ASoC: soc-core: cleanup cppcheck warning at snd_soc_of_parse_audio_simple_widgets()
This patch cleanups below cppcheck warning.

sound/soc/soc-core.c:2777:25: style: The scope of the variable 'ret' can be reduced. [variableScope]
 int i, j, num_widgets, ret;
                        ^

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Link: https://lore.kernel.org/r/87pmv1yl6b.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2021-07-29 15:35:44 +01:00
Kuninori Morimoto eaf2469c34
ASoC: soc-core: cleanup cppcheck warning at snd_soc_add_controls()
This patch cleanups below cppcheck warning.

sound/soc/soc-core.c:2239:6: style: The scope of the variable 'err' can be reduced. [variableScope]
 int err, i;
     ^

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Link: https://lore.kernel.org/r/87r1fhyl6f.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2021-07-29 15:35:43 +01:00
Kuninori Morimoto 5600f3d5ac
ASoC: soc-core: cleanup cppcheck warning at snd_soc_unregister_component()
This patch cleanups below cppcheck warning.

sound/soc/soc-core.c:2719:28: style: The scope of the variable 'component' can be reduced. [variableScope]
 struct snd_soc_component *component;
                           ^

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Link: https://lore.kernel.org/r/87sfzxyl6k.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2021-07-29 15:35:42 +01:00
Kuninori Morimoto 5ad76775a5
ASoC: soc-core: cleanup cppcheck warning at snd_soc_daifmt_parse_format()
This patch cleanups below cppcheck warning.

sound/soc/soc-core.c:3056:11: style: The scope of the variable 'i' can be reduced. [variableScope]
 int ret, i;
          ^

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Link: https://lore.kernel.org/r/87tukdyl6p.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2021-07-29 15:35:41 +01:00
Kuninori Morimoto bce00560a2
ASoC: soc-core: cleanup cppcheck warning at snd_soc_get_dai_name()
This patch cleanups below cppcheck warning.

sound/soc/soc-core.c:3203:22: style: The scope of the variable 'component_of_node' can be reduced. [variableScope]
 struct device_node *component_of_node;
                     ^

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Link: https://lore.kernel.org/r/87v94tyl6t.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2021-07-29 15:35:40 +01:00
Kuninori Morimoto cdb76568b0
ASoC: soc-core: cleanup cppcheck warning at snd_soc_set_dmi_name()
This patch cleanups below cppcheck warning.

 const char *vendor, *product, *product_version, *board;
                                ^

sound/soc/soc-core.c:1721:33: style: The scope of the variable 'product_version' can be reduced. [variableScope]
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Link: https://lore.kernel.org/r/87wnp9yl6y.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2021-07-29 15:35:39 +01:00
Takashi Iwai 50de417b7a ASoC: Updates for v5.14
This release sees a nice new feature in the core from Morimoto-san,
 support for automatic negotiation of DAI formats between the components
 on the link.  Otherwise the big highlight was the merging of the Tegra
 machine drivers into a single driver avoiding a bunch of duplication.
 
  - Support for automatic negotiation of DAI formats.
  - Accessory detection support for several Qualcomm parts.
  - Support for IEC958 control with hdmi-codec.
  - Merging of Tegra machine drivers into a single driver.
  - Support for AmLogic SM1 TOACODEC, Intel AlderLake-M, several NXP
    i.MX8 variants, NXP TFA1 and TDF9897, Rockchip RK817, Qualcomm
    Quinary MI2S, Texas Instruments TAS2505
 -----BEGIN PGP SIGNATURE-----
 
 iQEzBAABCgAdFiEEreZoqmdXGLWf4p/qJNaLcl1Uh9AFAmDZzCgACgkQJNaLcl1U
 h9DmKAf+IhmeYLxMuSe7uC/BZHQN1PFFHDb9rNyznqYD0kCzgfqvt7RIbbpOB83g
 Rw6+SnKWq1k2LOtJc7nVfFXfCrWTCH/GkqH22YoDWUjc2ZLTLE4V/dZhrYzggkjz
 qE4bOUNBHUyqO0Xir1iMFCdr9V4+Fc5iYT83FccHB+hF+o8GNcU0MkovUKgiTeuz
 EChmQlfsOHxKU6DbRUQrO30plSTaCQZ9CHAOXlGRQnGaYH/99ecav2O7sM1F4SrI
 uHR544UuJUiZ26PcZ5M66GvuwAOoSw/v6Tr/OykBulgFUX8wafDcHq7vGK5A6WCE
 qGwWpe12E+veMsJjn7wzifryaxJ9zQ==
 =F1Zu
 -----END PGP SIGNATURE-----

Merge tag 'asoc-v5.14' of https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound into for-linus

ASoC: Updates for v5.14

This release sees a nice new feature in the core from Morimoto-san,
support for automatic negotiation of DAI formats between the components
on the link.  Otherwise the big highlight was the merging of the Tegra
machine drivers into a single driver avoiding a bunch of duplication.

 - Support for automatic negotiation of DAI formats.
 - Accessory detection support for several Qualcomm parts.
 - Support for IEC958 control with hdmi-codec.
 - Merging of Tegra machine drivers into a single driver.
 - Support for AmLogic SM1 TOACODEC, Intel AlderLake-M, several NXP
   i.MX8 variants, NXP TFA1 and TDF9897, Rockchip RK817, Qualcomm
   Quinary MI2S, Texas Instruments TAS2505
2021-07-01 08:36:12 +02:00
Takashi Iwai 5c89c2c7fb ASoC: Fixes for v5.13
A final batch of fixes for v5.13, this is larger than I'd like due to
 the fixes for a series of suspend issues that Intel turned up in their
 testing this week.
 -----BEGIN PGP SIGNATURE-----
 
 iQEzBAABCgAdFiEEreZoqmdXGLWf4p/qJNaLcl1Uh9AFAmDTZ30ACgkQJNaLcl1U
 h9C5dQf6AjDh6y0SfB264cv2kSCLtYsOstSeamrEv3HBjqGiWEDgzfdB5Z+5d+EJ
 ScWsfsZ8eMr7WcMZJ+wEGNKxcZO2uHEaC29dpNrDeE4Ffr9hsSucPhJ8Fm+K0qDH
 VqX4kDPFY+OiuOf5RipDyAgoHo4zhIeaE9Rgxd4lbNH/xpWtgalN22iyYLpiYZLP
 YJk+/8L37ZcKYX3uCImMEe4yseH3AFzGz7yi/tyyWCUP7GEwtWgzv2vadxewjY5E
 h12ToqsTMQIrix0ZfMbYW9KJ7ANn6PFBz10vH8XuGbUlBW33pVzqP+Wr9adXGG4N
 XLs6wRpbDbdJc3aDpDjA1nRlBl5XEg==
 =h2+R
 -----END PGP SIGNATURE-----

Merge tag 'asoc-fix-v5.13-rc7' of https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound into for-next

ASoC: Fixes for v5.13

A final batch of fixes for v5.13, this is larger than I'd like due to
the fixes for a series of suspend issues that Intel turned up in their
testing this week.
2021-06-24 10:02:45 +02:00
Kuninori Morimoto 8439c5861c
ASoC: soc-core: remove snd_soc_of_parse_daifmt()
No driver is using snd_soc_of_parse_daifmt().
This patch removes it.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Link: https://lore.kernel.org/r/87zgvtuuro.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2021-06-21 13:05:22 +01:00
Kuninori Morimoto 7766861d1f
ASoC: soc-core: add snd_soc_daifmt_parse_format/clock_provider()
snd_soc_of_parse_daifmt() parses daifmt, but bitclock/frame provider
parsing part is one of headacke, because we are assuming below both cases.

A)	node {
		bitclock-master;
		frame-master;
		...
	};

B)	link {
		bitclock-master = <&xxx>;
		frame-master = <&xxx>;
		...
	};

The original was style A), and style B) was added later
by commit b3ca11ff59 ("ASoC: simple-card: Move dai-link level
properties away from dai subnodes").

snd_soc_of_parse_daifmt() parses it as style A),
and user need to update it to style B) if needed.

To handle it more flexibile, this patch adds new functions
which separates snd_soc_of_parse_daifmt() helper function.

 snd_soc_daifmt_parse_format()			 :for DAI format
 snd_soc_daifmt_parse_clock_provider_as_flag()	 :for style A)
 snd_soc_daifmt_parse_clock_provider_as_phandl() :for style B)
 snd_soc_daifmt_parse_clock_provider_as_bitmap() :use with _from_bitmap

This means

 snd_soc_of_parse_daifmt() ==
	snd_soc_daifmt_parse_format() |
	snd_soc_daifmt_parse_clock_provider_as_flag()

This patch also indicate relatesionship comment for
snd_soc_daifmt_clock_provider_from_bitmap().

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Link: https://lore.kernel.org/r/877dixw9ej.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2021-06-21 13:05:17 +01:00
Kuninori Morimoto b44a67f893
ASoC: soc-core: add snd_soc_daifmt_clock_provider_fliped()
Sometimes we want to get CLOCK_PROVIDER fliped dai_fmt.
This patch adds new snd_soc_daifmt_clock_provider_fliped() for it.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Link: https://lore.kernel.org/r/878s3dw9ex.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2021-06-21 13:05:16 +01:00
Kuninori Morimoto 91ae447762
ASoC: soc-core: add snd_soc_daifmt_clock_provider_from_bitmap()
This patch adds snd_soc_daifmt_clock_provider_from_bitmap() function
to judge clock/frame master from its bitmap.
This is prepare for snd_soc_of_parse_daifmt() cleanup.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Link: https://lore.kernel.org/r/87a6ntw9f5.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2021-06-21 13:05:15 +01:00
Zhen Lei 7d3865a10b
ASoC: soc-core: Fix the error return code in snd_soc_of_parse_audio_routing()
When devm_kcalloc() fails, the error code -ENOMEM should be returned
instead of -EINVAL.

Signed-off-by: Zhen Lei <thunder.leizhen@huawei.com>
Link: https://lore.kernel.org/r/20210617103729.1918-1-thunder.leizhen@huawei.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2021-06-17 13:47:04 +01:00
Kuninori Morimoto 640eac4c84
ASoC: soc-core: don't use discriminatory terms on snd_soc_runtime_get_dai_fmt()
snd_soc_runtime_get_dai_fmt() is using discriminatory terms.
This patch fixup it.

Fixes: ba9e82a1c8 ("ASoC: soc-core: add snd_soc_runtime_get_dai_fmt()")
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Link: https://lore.kernel.org/r/874ke9dxkp.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2021-06-08 13:36:47 +01:00
Kuninori Morimoto ba9e82a1c8
ASoC: soc-core: add snd_soc_runtime_get_dai_fmt()
ASoC is using dai_link which specify DAI format (= dai_link->dai_fmt),
and it is selected by "Sound Card" driver in corrent implementation.
In other words, Sound Card *needs* to setup it.
But, it should be possible to automatically selected from CPU and
Codec driver settings.

This patch adds new .auto_selectable_formats support
at snd_soc_dai_ops.

By this patch, dai_fmt can be automatically selected from each
driver if both CPU / Codec driver had it.
Automatically selectable *field* is depends on each drivers.

For example, some driver want to select format "automatically",
but want to select other fields "manually", because of complex limitation.
Or other example, in case of both CPU and Codec are possible to be
clock provider, but the quality was different.
In these case, user need/want to *manually* select each fields
from Sound Card driver.

This .auto_selectable_formats can set priority.
For example, no limitaion format can be HI priority,
supported but has picky limitation format can be next priority, etc.

It uses Sound Card specified fields preferentially, and try to select
non-specific fields from CPU and Codec driver automatically
if all drivers have .auto_selectable_formats.

In other words, we can select all dai_fmt via Sound Card driver
same as before.

Link: https://lore.kernel.org/r/871rb3hypy.wl-kuninori.morimoto.gx@renesas.com
Link: https://lore.kernel.org/r/871racbx0w.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Link: https://lore.kernel.org/r/87h7ionc8s.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2021-06-07 15:55:12 +01:00
Kuninori Morimoto 4d1a98b5f1
ASoC: soc-core: move snd_soc_runtime_set_dai_fmt() to upside
This patch moves snd_soc_runtime_set_dai_fmt() to upside.
This is prepare to support snd_soc_runtime_get_dai_fmt().

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Link: https://lore.kernel.org/r/87im34nc9r.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2021-06-07 15:55:11 +01:00
Mark Brown d4e9889b02
Merge branch 'for-5.13' of https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound into asoc-5.14 2021-05-25 16:44:26 +01:00
Takashi Iwai b6cc78da36 ALSA: Drop superfluous argument from snd_power_wait()
The power_state argument of snd_power_wait() is superfluous, receiving
only SNDRV_POWER_STATE_D0.  Let's drop it in all callers for
simplicity.

Reviewed-by: Jaroslav Kysela <perex@perex.cz>
Acked-by: Mark Brown <broonie@kernel.org>
Link: https://lore.kernel.org/r/20210523090920.15345-6-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2021-05-25 08:49:39 +02:00