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

ASoC: intel: sof_sdw: Support multiple groups on the same link

The current code checks the first device on a link and assumes
that all the other devices on the link will have the same endpoint
aggregation status and endpoint group ID.

Say for example a system looked like:

SDW0 - Amp 1 (Aggregated, Group 1), Mic 1 (Aggregated, Group 2)
SDW1 - Amp 2 (Aggregated, Group 1), Mic 2 (Aggregated, Group 2)

The current code would create the DAI link for the aggregated amps,
although it is worth noting that the only reason Mic 2 is not added is
the additional check that aborts processing the link when the device
changes. Then when processing the DAI link for the microphones, Mic
2 would not be added, as the check will only be done on the first
device, which would be Amp 2 and thus the wrong group, causing the
whole link to be skipped.

Move the endpoint check to be for each device rather than the first
device on each link.
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-10-ckeepax@opensource.cirrus.comSigned-off-by: default avatarMark Brown <broonie@kernel.org>
parent f3eb3d45
...@@ -1288,25 +1288,24 @@ static int get_slave_info(const struct snd_soc_acpi_link_adr *adr_link, ...@@ -1288,25 +1288,24 @@ static int get_slave_info(const struct snd_soc_acpi_link_adr *adr_link,
} }
/* gather other link ID of slaves in the same group */ /* gather other link ID of slaves in the same group */
for (adr_next = adr_link + 1; adr_next && adr_next->num_adr; for (adr_next = adr_link + 1; adr_next && adr_next->num_adr; adr_next++) {
adr_next++) { unsigned int link_codecs = 0;
const struct snd_soc_acpi_endpoint *endpoint;
endpoint = adr_next->adr_d->endpoints; for (i = 0; i < adr_next->num_adr; i++) {
if (!endpoint->aggregated || if (adr_next->adr_d[i].endpoints->aggregated &&
endpoint->group_id != *group_id) adr_next->adr_d[i].endpoints->group_id == *group_id)
continue; link_codecs++;
}
if (link_codecs) {
*codec_num += link_codecs;
if (index >= SDW_MAX_CPU_DAIS) { if (index >= SDW_MAX_CPU_DAIS) {
dev_err(dev, "cpu_dai_id array overflows\n"); dev_err(dev, "cpu_dai_id array overflowed\n");
return -EINVAL; return -EINVAL;
} }
cpu_dai_id[index++] = ffs(adr_next->mask) - 1; cpu_dai_id[index++] = ffs(adr_next->mask) - 1;
for (i = 0; i < adr_next->num_adr; i++) {
if (adr_next->adr_d[i].endpoints->aggregated &&
adr_next->adr_d[i].endpoints->group_id == *group_id)
(*codec_num)++;
} }
} }
...@@ -1369,20 +1368,15 @@ static int create_sdw_dailink(struct snd_soc_card *card, int *link_index, ...@@ -1369,20 +1368,15 @@ static int create_sdw_dailink(struct snd_soc_card *card, int *link_index,
j = adr_index; 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;
int _codec_index = -1; int _codec_index = -1;
endpoints = adr_link_next->adr_d->endpoints;
if (group_id && (!endpoints->aggregated ||
endpoints->group_id != group_id))
continue;
/* skip the link excluded by this processed group */ /* skip the link excluded by this processed group */
if (cpu_dai_id[i] != ffs(adr_link_next->mask) - 1) if (cpu_dai_id[i] != ffs(adr_link_next->mask) - 1)
continue; continue;
/* j reset after loop, adr_index only applies to first link */ /* j reset after loop, adr_index only applies to first link */
for (; j < adr_link_next->num_adr; j++) { for (; j < adr_link_next->num_adr; j++) {
const struct snd_soc_acpi_endpoint *endpoints;
int codec_index; int codec_index;
u64 adr = adr_link_next->adr_d[j].adr; u64 adr = adr_link_next->adr_d[j].adr;
...@@ -1395,6 +1389,12 @@ static int create_sdw_dailink(struct snd_soc_card *card, int *link_index, ...@@ -1395,6 +1389,12 @@ static int create_sdw_dailink(struct snd_soc_card *card, int *link_index,
} }
_codec_index = codec_index; _codec_index = codec_index;
endpoints = adr_link_next->adr_d[j].endpoints;
if (group_id && (!endpoints->aggregated ||
endpoints->group_id != group_id))
continue;
/* sanity check */ /* sanity check */
if (*codec_conf_index >= codec_count) { if (*codec_conf_index >= codec_count) {
dev_err(dev, "codec_conf array overflowed\n"); dev_err(dev, "codec_conf array overflowed\n");
......
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