linux-stable/sound
Kuninori Morimoto 6b1dff0266
ASoC: soc-core: call soc_bind_dai_link() under snd_soc_add_dai_link()
If we focus to soc_bind_dai_link() at snd_soc_instantiate_card(),
we will notice very complex operation.

static int snd_soc_instantiate_card(...)
{
	...
	/*
	 * (1) Bind dai_link via card pre-linked dai_link
	 *
	 * Bind dai_link via card pre-linked.
	 * 1 dai_link will be 1 rtd, and connected to card.
	 * for_each_card_prelinks() is for card pre-linked dai_link.
	 *
	 * Image
	 *
	 * card
	 * - rtd(A)
	 * - rtd(A)
	 */
	for_each_card_prelinks(card, i, dai_link) {
		ret = soc_bind_dai_link(card, dai_link);
		...
	}
	...
	/*
	 * (2) Connect card pre-linked dai_link to card list
	 *
	 * Connect all card pre-linked dai_link to *card list*.
	 * Here, (A) means from card pre-linked.
	 *
	 * Image
	 *
	 * card		card list
	 *  - rtd(A)	 - dai_link(A)
	 *  - rtd(A)	 - dai_link(A)
	 *  - ...	 - ...
	 */
	for_each_card_prelinks(card, i, dai_link) {
		ret = snd_soc_add_dai_link(card, dai_link);
		...
	}
	...
	/*
	 * (3) Probe binded component
	 *
	 * Each rtd has many components.
	 * Here probes each rtd connected components.
	 * rtd(A) in Image is the probe target.
	 *
	 * During this component probe, topology may add new dai_link to
	 * *card list* by using snd_soc_add_dai_link() which is
	 * used at (2).
	 * Here, (B) means from topology
	 *
	 * Image
	 *
	 * card		card list
	 *  - rtd(A)	 - dai_link(A)
	 *  - rtd(A)	 - dai_link(A)
	 *  - ...	 - ...
	 *		 - dai_link(B)
	 *		 - dai_link(B)
	 */
	ret = soc_probe_link_components(card);
	...

	/*
	 * (4) Bind dai_link again
	 *
	 * Bind dai_link again for topology.
	 * Note, (1) used for_each_card_prelinks(),
	 * here is using  for_each_card_links()
	 *
	 * This means from card list.
	 * As Image indicating, it has dai_link(A) (from card pre-link)
	 * and dai_link(B) (from topology).
	 * main target here is dai_link(B).
	 * soc_bind_dai_link() ignores already used
	 * dai_link (= dai_link(A))
	 *
	 * Image
	 *
	 * card		card list
	 *  - rtd(A)	 - dai_link(A)
	 *  - rtd(A)	 - dai_link(A)
	 *  - ...	 - ...
	 *  - rtd(B)	 - dai_link(B)
	 *  - rtd(B)	 - dai_link(B)
	 */
	for_each_card_links(card, dai_link) {
		ret = soc_bind_dai_link(card, dai_link);
		...
	}
	...
}

As you see above, it is doing very complex method.
The problem is binding dai_link via "card pre-linked" (= (1)) and
"topology added dai_link" (= (3)) are separated.
The code can be simple if we can bind dai_link when dai_link
is connected to *card list*.
This patch do it.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Reviewed-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Link: https://lore.kernel.org/r/878sou3jnn.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2019-11-05 23:50:01 +00:00
..
ac97 ALSA: ac97: Fix double free of ac97_codec_device 2019-07-23 14:16:11 +02:00
aoa ALSA: aoa: onyx: always initialize register read value 2019-07-29 09:21:39 +02:00
arm ASoC: pxa: remove snd_pcm_ops 2019-10-08 13:47:20 +01:00
atmel treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 500 2019-06-19 17:09:55 +02:00
core ASoC: pcm_dmaengine: Extract snd_dmaengine_pcm_refine_runtime_hwparams 2019-10-01 12:18:25 +01:00
drivers treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 500 2019-06-19 17:09:55 +02:00
firewire ALSA: dice: fix wrong packet parameter for Alesis iO26 2019-09-16 23:46:14 +02:00
hda Merge branch 'asoc-5.4' into asoc-next 2019-09-15 10:31:44 +01:00
i2c ALSA: i2c: ak4xxx-adda: Fix a possible null pointer dereference in build_adc_controls() 2019-07-26 14:25:37 +02:00
isa ALSA: sb: remove redundant assignment to variable result 2019-08-14 17:44:06 +02:00
mips
oss sound: dmasound_atari: Mark expected switch fall-through 2019-07-30 09:36:13 +02:00
parisc
pci ALSA: hda/hdmi - implement mst_no_extra_pcms flag 2019-10-29 17:31:30 +00:00
pcmcia
ppc ALSA: ps3: Remove Unneeded variable: "ret" 2019-07-10 11:53:31 +02:00
sh treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 273 2019-06-05 17:30:30 +02:00
soc ASoC: soc-core: call soc_bind_dai_link() under snd_soc_add_dai_link() 2019-11-05 23:50:01 +00:00
sparc ALSA: sparc: Mark expected switch fall-throughs 2019-07-30 09:37:01 +02:00
spi treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 500 2019-06-19 17:09:55 +02:00
synth
usb ALSA: usb-audio: Add DSD support for EVGA NU Audio 2019-09-24 13:58:20 +02:00
x86 treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 285 2019-06-05 17:36:37 +02:00
xen ASoC: Updates for v5.3 2019-07-08 14:45:34 +02:00
ac97_bus.c
Kconfig
last.c
Makefile
sound_core.c sound: fix a memory leak bug 2019-08-08 08:18:32 +02:00