Re: [PATCH 3/3] ASoC: codecs: wsa884x: check if set_stream is called for proper bus

From: Pierre-Louis Bossart
Date: Mon Nov 06 2023 - 09:42:11 EST





> We have two Soundwire controllers swr0 and swr3, each with two WSA884x
> speakers (codecs):
>
> -------------
> &swr0 {
> status = "okay";
>
> left_woofer: speaker@0,0 {
> compatible = "sdw20217020400";
> reg = <0 0>;
> // ...
> };
>
> /* WSA8845, Left Tweeter */
> left_tweeter: speaker@0,1 {
> compatible = "sdw20217020400";
> reg = <0 1>;
> // ...
> };
> };
>
> &swr3 {
> status = "okay";
>
> /* WSA8845, Right Woofer */
> right_woofer: speaker@0,0 {
> compatible = "sdw20217020400";
> reg = <0 0>;
> // ...
> };
>
> /* WSA8845, Right Tweeter */
> right_tweeter: speaker@0,1 {
> compatible = "sdw20217020400";
> reg = <0 1>;
> // ...
> };
> };
> -------------
>
> Now, for four-speaker playback, we have sound card with links like:
>
> -------------
> wsa-dai-link {
> link-name = "WSA Playback";
>
> cpu {
> sound-dai = <&q6apmbedai WSA_CODEC_DMA_RX_0>;
> };
>
> codec {
> sound-dai = <&left_woofer>, <&left_tweeter>,
> <&swr0 0>, <&lpass_wsamacro 0>,
> <&right_woofer>, <&right_tweeter>,
> <&swr3 0>, <&lpass_wsa2macro 0>;
> };
>
> platform {
> sound-dai = <&q6apm>;
> };
> };
> -------------
>
> We need to prepare the stream for all four speakers and two soundwire
> controllers (so two different soundwire buses), however without the
> patches here, the stream (sdw_stream_runtime *sruntime) right
> woofer/twitter is set to swr0 (the other bus!). But it should stay as
> swr3 (their bus).
>
> Does it help a bit? I hope I am able to properly explain it.

The configuration seems fine, but the problem is the
"sdw_stream_runtime" definition.

You need *ONE* sdw_stream_runtime, and multiple m_rt contexts added in
the linked lists of this sdw_stream_runtime. In other words, you need to
call sdw_stream_add_master() twice, for swr0 and swr3 respectively.

Put differently, a sdw_stream_runtime does not point to a specific bus,
it provides a top-level structure which can use multiple buses.

The best way to allocate the sdw_stream_runtime is to rely on the
dailink .startup callback. From the description above that's where you
have all the needed information, and then each DAI .startup (or
hw_params) can call sdw_stream_add_master() to update the linked lists.