ASoC: intel: sof_sdw: Device loop should not always start at adr_index
authorCharles Keepax <ckeepax@opensource.cirrus.com>
Tue, 8 Aug 2023 13:20:10 +0000 (14:20 +0100)
committerMark Brown <broonie@kernel.org>
Tue, 8 Aug 2023 17:57:23 +0000 (18:57 +0100)
commitf3eb3d45fdfd693dc004e664544f978ae8d38f48
tree6066a3fe7e33904428f73715d535bc94c00454d3
parent59736ca62e1eeb4466ace99e167cbe7a0f9bc0fa
ASoC: intel: sof_sdw: Device loop should not always start at adr_index

The current loops at the top of create_sdw_dailink process the devices
on each link starting from device index adr_index. But adr_index is only
meaningful on the first on these SoundWire links, as it is the index of
the current device on that link. This means devices will be skipped on
later links.

Say for example the system looks like this:

SDW0 - Codec (Not Aggregated), Amp 1 (Aggregated, Group 1)
SDW1 - Amp 2 (Aggregated, Group 1), Amp 3 (Aggregated, Group 1)

The code should create 2 DAI links, one for the CODEC and one for the
aggregated amps. It will create the DAI link for the codec no problem.
When it creates the DAI link for Group 1 however, create_sdw_dailink
will be called with an adr_index of 1, since that is the index of Amp
1 on SDW0.  However, as the loop in create_sdw_dailink moves onto SDW1
it will again start from adr_index, skipping Amp 2. Resulting in the amp
DAI link only have amps 1 and 3 in it.

It is reasonable to start at adr_index on the first link, since
earlier devices have by definition already been processed. However,
update the code when processing later links to handle all devices.

Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Reviewed-by: Bard Liao <yung-chuan.liao@linux.intel.com>
Signed-off-by: Charles Keepax <ckeepax@opensource.cirrus.com>
Link: https://lore.kernel.org/r/20230808132013.889419-9-ckeepax@opensource.cirrus.com
Signed-off-by: Mark Brown <broonie@kernel.org>
sound/soc/intel/boards/sof_sdw.c