Skip to content

Commit 4e33d00

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 <ranjani.sridharan@linux.intel.com>
1 parent 216feda commit 4e33d00

1 file changed

Lines changed: 41 additions & 2 deletions

File tree

sound/soc/intel/boards/sof_sdw.c

Lines changed: 41 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1196,6 +1196,34 @@ 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 won't 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+
dev_dbg(dev, "Added echo reference DAI link\n");
1223+
1224+
return 0;
1225+
}
1226+
11991227
static int sof_card_dai_links_create(struct snd_soc_card *card)
12001228
{
12011229
struct device *dev = card->dev;
@@ -1304,8 +1332,12 @@ static int sof_card_dai_links_create(struct snd_soc_card *card)
13041332
goto err_end;
13051333
}
13061334

1307-
/* allocate BE dailinks */
1308-
num_links = sdw_be_num + ssp_num + dmic_num + hdmi_num + bt_num;
1335+
/*
1336+
* allocate BE dailinks, add an extra DAI link for echo reference capture.
1337+
* This should be the last DAI link and it is expected both for monolithic
1338+
* and functional SOF topologies to support echo reference.
1339+
*/
1340+
num_links = sdw_be_num + ssp_num + dmic_num + hdmi_num + bt_num + 1;
13091341
dai_links = devm_kcalloc(dev, num_links, sizeof(*dai_links), GFP_KERNEL);
13101342
if (!dai_links) {
13111343
ret = -ENOMEM;
@@ -1354,6 +1386,13 @@ static int sof_card_dai_links_create(struct snd_soc_card *card)
13541386
goto err_end;
13551387
}
13561388

1389+
/* dummy echo ref link. keep this as the last DAI link. The DAI link ID does not matter */
1390+
ret = create_echoref_dailink(card, &dai_links, &be_id);
1391+
if (ret) {
1392+
dev_err(dev, "failed to create echo ref dai link: %d\n", ret);
1393+
goto err_end;
1394+
}
1395+
13571396
WARN_ON(codec_conf != card->codec_conf + card->num_configs);
13581397
WARN_ON(dai_links != card->dai_link + card->num_links);
13591398

0 commit comments

Comments
 (0)