Commit f3eb3d45 authored by Charles Keepax's avatar Charles Keepax Committed by Mark Brown

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: default avatarPierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Reviewed-by: default avatarBard Liao <yung-chuan.liao@linux.intel.com>
Signed-off-by: default avatarCharles Keepax <ckeepax@opensource.cirrus.com>
Link: https://lore.kernel.org/r/20230808132013.889419-9-ckeepax@opensource.cirrus.comSigned-off-by: default avatarMark Brown <broonie@kernel.org>
parent 59736ca6
...@@ -1366,6 +1366,7 @@ static int create_sdw_dailink(struct snd_soc_card *card, int *link_index, ...@@ -1366,6 +1366,7 @@ static int create_sdw_dailink(struct snd_soc_card *card, int *link_index,
return -ENOMEM; return -ENOMEM;
/* generate codec name on different links in the same group */ /* generate codec name on different links in the same group */
j = adr_index;
for (adr_link_next = adr_link; adr_link_next && adr_link_next->num_adr && for (adr_link_next = adr_link; adr_link_next && adr_link_next->num_adr &&
i < cpu_dai_num; adr_link_next++) { i < cpu_dai_num; adr_link_next++) {
const struct snd_soc_acpi_endpoint *endpoints; const struct snd_soc_acpi_endpoint *endpoints;
...@@ -1380,7 +1381,8 @@ static int create_sdw_dailink(struct snd_soc_card *card, int *link_index, ...@@ -1380,7 +1381,8 @@ static int create_sdw_dailink(struct snd_soc_card *card, int *link_index,
if (cpu_dai_id[i] != ffs(adr_link_next->mask) - 1) if (cpu_dai_id[i] != ffs(adr_link_next->mask) - 1)
continue; continue;
for (j = adr_index; j < adr_link_next->num_adr; j++) { /* j reset after loop, adr_index only applies to first link */
for (; j < adr_link_next->num_adr; j++) {
int codec_index; int codec_index;
u64 adr = adr_link_next->adr_d[j].adr; u64 adr = adr_link_next->adr_d[j].adr;
...@@ -1412,6 +1414,7 @@ static int create_sdw_dailink(struct snd_soc_card *card, int *link_index, ...@@ -1412,6 +1414,7 @@ static int create_sdw_dailink(struct snd_soc_card *card, int *link_index,
codec_dlc_index++; codec_dlc_index++;
(*codec_conf_index)++; (*codec_conf_index)++;
} }
j = 0;
/* check next link to create codec dai in the processed group */ /* check next link to create codec dai in the processed group */
i++; i++;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment