Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 26 additions & 15 deletions sound/soc/intel/boards/sof_sdw.c
Original file line number Diff line number Diff line change
Expand Up @@ -411,25 +411,36 @@ static int create_codec_dai_name(struct device *dev,

static int set_codec_init_func(const struct snd_soc_acpi_link_adr *link,
struct snd_soc_dai_link *dai_links,
bool playback)
bool playback, int group_id)
{
int i;

for (i = 0; i < link->num_adr; i++) {
unsigned int part_id;
int codec_index;

part_id = SDW_PART_ID(link->adr_d[i].adr);
codec_index = find_codec_info_part(part_id);
do {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Took me a while to figure out why we need to loop here. It looks like now with aggregation the loop over links in sof_card_dai_links_create() only calls create_sdw_dailink() for the first link in each group. That's why you now have to walk over all links, looking for others from the same group. Maybe you could add a comment about that for the next reader :-)

/*
* Initialize the codec. If codec is part of an aggregated
* group (group_id>0), initialize all codecs belonging to
* same group.
*/
for (i = 0; i < link->num_adr; i++) {
unsigned int part_id;
int codec_index;

if (codec_index < 0)
return codec_index;
part_id = SDW_PART_ID(link->adr_d[i].adr);
codec_index = find_codec_info_part(part_id);

if (codec_info_list[codec_index].init)
codec_info_list[codec_index].init(link, dai_links,
&codec_info_list[codec_index],
playback);
}
if (codec_index < 0)
return codec_index;
/* The group_id is > 0 iff the codec is aggregated */
if (link->adr_d[i].endpoints->group_id != group_id)
continue;
if (codec_info_list[codec_index].init)
codec_info_list[codec_index].init(link,
dai_links,
&codec_info_list[codec_index],
playback);
}
link++;
} while (link->mask && group_id);

return 0;
}
Expand Down Expand Up @@ -623,7 +634,7 @@ static int create_sdw_dailink(struct device *dev, int *be_index,
NULL, &sdw_ops);

ret = set_codec_init_func(link, dai_links + (*be_index)++,
playback);
playback, group_id);
if (ret < 0) {
dev_err(dev, "failed to init codec %d", codec_index);
return ret;
Expand Down