Skip to content

Commit c5bfd63

Browse files
committed
ASoC: Intel: sof_sdw: Add a DAI link for loopback capture
Add a DAI link for loopback capture as the last link to make sure the other DAI link ID's remain unaffected. It serves as a dummy DAI link to enable echo reference capture in the SDW topologies which do not have an actual backend capture DAI. Signed-off-by: Ranjani Sridharan <[email protected]>
1 parent 216feda commit c5bfd63

1 file changed

Lines changed: 35 additions & 2 deletions

File tree

sound/soc/intel/boards/sof_sdw.c

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1196,6 +1196,32 @@ static int create_bt_dailinks(struct snd_soc_card *card,
11961196
return 0;
11971197
}
11981198

1199+
static int create_echoref_dailink(struct snd_soc_card *card,
1200+
struct snd_soc_dai_link **dai_links, int *be_id)
1201+
{
1202+
struct device *dev = card->dev;
1203+
int ret;
1204+
char *name = devm_kasprintf(dev, GFP_KERNEL, "Loopback_Virtual");
1205+
1206+
if (!name)
1207+
return -ENOMEM;
1208+
1209+
/*
1210+
* use dummy DAI names as this wont be connected to an actual DAI but just to establish a
1211+
* fe <-> be connection for loopback capture for echo reference
1212+
*/
1213+
ret = asoc_sdw_init_simple_dai_link(dev, *dai_links, be_id, name,
1214+
0, 1, "snd-soc-dummy-dai", "dummy",
1215+
snd_soc_dummy_dlc.name, snd_soc_dummy_dlc.dai_name,
1216+
1, NULL, NULL);
1217+
if (ret)
1218+
return ret;
1219+
1220+
(*dai_links)++;
1221+
1222+
return 0;
1223+
}
1224+
11991225
static int sof_card_dai_links_create(struct snd_soc_card *card)
12001226
{
12011227
struct device *dev = card->dev;
@@ -1304,8 +1330,8 @@ static int sof_card_dai_links_create(struct snd_soc_card *card)
13041330
goto err_end;
13051331
}
13061332

1307-
/* allocate BE dailinks */
1308-
num_links = sdw_be_num + ssp_num + dmic_num + hdmi_num + bt_num;
1333+
/* allocate BE dailinks, add an extra DAI link for echo reference capture */
1334+
num_links = sdw_be_num + ssp_num + dmic_num + hdmi_num + bt_num + 1;
13091335
dai_links = devm_kcalloc(dev, num_links, sizeof(*dai_links), GFP_KERNEL);
13101336
if (!dai_links) {
13111337
ret = -ENOMEM;
@@ -1354,6 +1380,13 @@ static int sof_card_dai_links_create(struct snd_soc_card *card)
13541380
goto err_end;
13551381
}
13561382

1383+
/* dummy echo ref link. keep this as the last DAI link. The DAI link ID does not matter */
1384+
ret = create_echoref_dailink(card, &dai_links, &be_id);
1385+
if (ret) {
1386+
dev_err(dev, "failed to create echo ref dai link: %d\n", ret);
1387+
goto err_end;
1388+
}
1389+
13571390
WARN_ON(codec_conf != card->codec_conf + card->num_configs);
13581391
WARN_ON(dai_links != card->dai_link + card->num_links);
13591392

0 commit comments

Comments
 (0)