Linux Sound subsystem development
 help / color / mirror / Atom feed
* About component->card
@ 2025-12-17  2:39 Kuninori Morimoto
  2025-12-17  8:30 ` Takashi Iwai
  0 siblings, 1 reply; 5+ messages in thread
From: Kuninori Morimoto @ 2025-12-17  2:39 UTC (permalink / raw)
  To: Mark Brown, Lars-Peter Clausen; +Cc: linux-sound


Hi Mark, Lars-Peter

I would like to confirm/suggest about restriction of component->card.
See also this commit

	45655ec69cb954d7fa594054bec33d6d5b99f8d5
	("ASoC: soc-core.c: enable multi Component")

We might have complex system, like this

	+-- Basic Board ---------+
	|+--------+      +------+|
	|| CPU ch0| <--> |CodecA||
	||     ch1| <-+  +------+|
	|+--------+   |          |
	+-------------|----------+
	+-- expansion board -----+
	|             |  +------+|
	|             +->|CodecB||
	|                +------+|
	+------------------------+

We would like to implement it as below, it is intuitive.
This means 1 Component connects to multi Cards.

	 +-driver------+
	 |+-component-+|
	+-card0-------------------------+
	|||           || +-driver------+|
	|||           || |+-component-+||
	|||    ch0 dai|<=>|dai        |||
	|||           || |+-----------+||
	|||           || +-------------+|
	+-------------------------------+
	 ||           ||
	+-card1-------------------------+
	|||           || +-driver------+|
	|||           || |+-component-+||
	|||    ch1 dai|<=>|dai        |||
	|||           || |+-----------+||
	|||           || +-------------+|
	+-------------------------------+
	 |+-----------+|
	 +-------------+

But, we can't this today, beucase we have restriction (A) that 1 Component
can't connect to multi Cards, because of component->card.

	static int soc_probe_component(...)
	{
		...
		if (component->card) {
(A)			if (component->card != card) {
				dev_err(...);
				return -ENODEV;
			}
			return 0;
		}
		...
	}

I haven't fully analyzed it, but I guess this restriction came from
each driver want to access to card, but FW doesn't hand over card pointer ?

	-- ASoC FW --

	/* ASoC hand over component pointer only */
	ops->callback(component);

	-- driver --

	/*
	 * It gets component pointer only, but want to access
	 * to card, too. component->card is added for it.
	 */
	callback(component)
	{
		struct snd_soc_card *card = component->card;
		...
	}

If this is the reason why restriction was created, do you think we can
remove it if ASoC FW hand over both card and component pointer ?

	-- ASoC FW --

	/* ASoC hand over both card and component pointer */
	ops->callback(card, component);
	              ^^^^
	-- driver --

	/*
	 * It gets both card and component pointer.
	 * component->card is no longer needed ?
	 */
	callback(card, component)
	{        ^^^^
		 ...
	}

But are there any other reasons ?

I think it is not strange that DAI has Component pointer.
It is fixed.

	dai->component;

But, Component might be connected to multi Cards, we shouldn't fix it

	component->card;

If above was sane, I would like to cleanup it.
I think ASoC need to hand over Card and DAI pointer (instead of Component) ?
But what do you think ?

Thank you for your help !!

Best regards
---
Kuninori Morimoto

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2025-12-22  1:26 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-12-17  2:39 About component->card Kuninori Morimoto
2025-12-17  8:30 ` Takashi Iwai
2025-12-19  0:49   ` Kuninori Morimoto
2025-12-19  9:10     ` Mark Brown
2025-12-22  1:26       ` Kuninori Morimoto

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox