Skip to content

Commit 26ee34d

Browse files
charleskeepaxbroonie
authored andcommitted
ASoC: sdw_utils: Add codec_conf for every DAI
The assumption so far is that all the DAI links for a given audio part would be on the same device. However, as SDCA implements each audio function on a separate auxiliary driver this will no longer be true. This means it is necessary to add additional codec_conf structures to get the prefix for an audio part to apply to all the auxiliary drivers that make up that part. Reviewed-by: Bard Liao <yung-chuan.liao@linux.intel.com> Signed-off-by: Charles Keepax <ckeepax@opensource.cirrus.com> Link: https://patch.msgid.link/20251127163426.2500633-4-ckeepax@opensource.cirrus.com Signed-off-by: Mark Brown <broonie@kernel.org>
1 parent 48fa77a commit 26ee34d

3 files changed

Lines changed: 22 additions & 15 deletions

File tree

sound/soc/amd/acp/acp-sdw-legacy-mach.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -364,6 +364,7 @@ static int soc_card_dai_links_create(struct snd_soc_card *card)
364364
struct snd_soc_dai_link *dai_links;
365365
int num_devs = 0;
366366
int num_ends = 0;
367+
int num_confs;
367368
int num_links;
368369
int be_id = 0;
369370
int ret;
@@ -374,6 +375,8 @@ static int soc_card_dai_links_create(struct snd_soc_card *card)
374375
return ret;
375376
}
376377

378+
num_confs = num_ends;
379+
377380
/* One per DAI link, worst case is a DAI link for every endpoint */
378381
soc_dais = kcalloc(num_ends, sizeof(*soc_dais), GFP_KERNEL);
379382
if (!soc_dais)
@@ -384,7 +387,7 @@ static int soc_card_dai_links_create(struct snd_soc_card *card)
384387
if (!soc_ends)
385388
return -ENOMEM;
386389

387-
ret = asoc_sdw_parse_sdw_endpoints(card, soc_dais, soc_ends, &num_devs);
390+
ret = asoc_sdw_parse_sdw_endpoints(card, soc_dais, soc_ends, &num_confs);
388391
if (ret < 0)
389392
return ret;
390393

@@ -396,7 +399,7 @@ static int soc_card_dai_links_create(struct snd_soc_card *card)
396399

397400
dev_dbg(dev, "sdw %d, dmic %d", sdw_be_num, dmic_num);
398401

399-
codec_conf = devm_kcalloc(dev, num_devs, sizeof(*codec_conf), GFP_KERNEL);
402+
codec_conf = devm_kcalloc(dev, num_confs, sizeof(*codec_conf), GFP_KERNEL);
400403
if (!codec_conf)
401404
return -ENOMEM;
402405

@@ -407,7 +410,7 @@ static int soc_card_dai_links_create(struct snd_soc_card *card)
407410
return -ENOMEM;
408411

409412
card->codec_conf = codec_conf;
410-
card->num_configs = num_devs;
413+
card->num_configs = num_confs;
411414
card->dai_link = dai_links;
412415
card->num_links = num_links;
413416

sound/soc/intel/boards/sof_sdw.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1191,6 +1191,7 @@ static int sof_card_dai_links_create(struct snd_soc_card *card)
11911191
struct asoc_sdw_dailink *sof_dais;
11921192
int num_devs = 0;
11931193
int num_ends = 0;
1194+
int num_confs;
11941195
struct snd_soc_dai_link *dai_links;
11951196
int num_links;
11961197
int be_id = 0;
@@ -1204,6 +1205,8 @@ static int sof_card_dai_links_create(struct snd_soc_card *card)
12041205
return ret;
12051206
}
12061207

1208+
num_confs = num_ends;
1209+
12071210
/*
12081211
* One per DAI link, worst case is a DAI link for every endpoint, also
12091212
* add one additional to act as a terminator such that code can iterate
@@ -1220,7 +1223,7 @@ static int sof_card_dai_links_create(struct snd_soc_card *card)
12201223
goto err_dai;
12211224
}
12221225

1223-
ret = asoc_sdw_parse_sdw_endpoints(card, sof_dais, sof_ends, &num_devs);
1226+
ret = asoc_sdw_parse_sdw_endpoints(card, sof_dais, sof_ends, &num_confs);
12241227
if (ret < 0)
12251228
goto err_end;
12261229

@@ -1268,7 +1271,7 @@ static int sof_card_dai_links_create(struct snd_soc_card *card)
12681271
sdw_be_num, ssp_num, dmic_num,
12691272
intel_ctx->hdmi.idisp_codec ? hdmi_num : 0, bt_num);
12701273

1271-
codec_conf = devm_kcalloc(dev, num_devs, sizeof(*codec_conf), GFP_KERNEL);
1274+
codec_conf = devm_kcalloc(dev, num_confs, sizeof(*codec_conf), GFP_KERNEL);
12721275
if (!codec_conf) {
12731276
ret = -ENOMEM;
12741277
goto err_end;
@@ -1283,7 +1286,7 @@ static int sof_card_dai_links_create(struct snd_soc_card *card)
12831286
}
12841287

12851288
card->codec_conf = codec_conf;
1286-
card->num_configs = num_devs;
1289+
card->num_configs = num_confs;
12871290
card->dai_link = dai_links;
12881291
card->num_links = num_links;
12891292

sound/soc/sdw_utils/soc_sdw_utils.c

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1442,15 +1442,6 @@ int asoc_sdw_parse_sdw_endpoints(struct snd_soc_card *card,
14421442

14431443
ctx->ignore_internal_dmic |= codec_info->ignore_internal_dmic;
14441444

1445-
codec_name = asoc_sdw_get_codec_name(dev, codec_info, adr_link, i);
1446-
if (!codec_name)
1447-
return -ENOMEM;
1448-
1449-
dev_dbg(dev, "Adding prefix %s for %s\n",
1450-
adr_dev->name_prefix, codec_name);
1451-
1452-
soc_end->name_prefix = adr_dev->name_prefix;
1453-
14541445
if (codec_info->count_sidecar && codec_info->add_sidecar) {
14551446
ret = codec_info->count_sidecar(card, &num_dais, num_devs);
14561447
if (ret)
@@ -1538,6 +1529,16 @@ int asoc_sdw_parse_sdw_endpoints(struct snd_soc_card *card,
15381529
num_link_dailinks += !!list_empty(&soc_dai->endpoints);
15391530
list_add_tail(&soc_end->list, &soc_dai->endpoints);
15401531

1532+
codec_name = asoc_sdw_get_codec_name(dev, codec_info,
1533+
adr_link, i);
1534+
if (!codec_name)
1535+
return -ENOMEM;
1536+
1537+
dev_dbg(dev, "Adding prefix %s for %s\n",
1538+
adr_dev->name_prefix, codec_name);
1539+
1540+
soc_end->name_prefix = adr_dev->name_prefix;
1541+
15411542
soc_end->link_mask = adr_link->mask;
15421543
soc_end->codec_name = codec_name;
15431544
soc_end->codec_info = codec_info;

0 commit comments

Comments
 (0)