Skip to content

Commit 4f66dac

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 7445cf6 commit 4f66dac

1 file changed

Lines changed: 31 additions & 2 deletions

File tree

sound/soc/intel/boards/sof_sdw.c

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1196,6 +1196,28 @@ 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, "LoopbackCapture_virtual_DAI");
1205+
1206+
if (!name)
1207+
return -ENOMEM;
1208+
1209+
ret = asoc_sdw_init_simple_dai_link(dev, *dai_links, be_id, name,
1210+
0, 1, "snd-soc-dummy-dai", "dummy",
1211+
snd_soc_dummy_dlc.name, snd_soc_dummy_dlc.dai_name,
1212+
1, NULL, NULL);
1213+
if (ret)
1214+
return ret;
1215+
1216+
(*dai_links)++;
1217+
1218+
return 0;
1219+
}
1220+
11991221
static int sof_card_dai_links_create(struct snd_soc_card *card)
12001222
{
12011223
struct device *dev = card->dev;
@@ -1293,8 +1315,8 @@ static int sof_card_dai_links_create(struct snd_soc_card *card)
12931315
goto err_end;
12941316
}
12951317

1296-
/* allocate BE dailinks */
1297-
num_links = sdw_be_num + ssp_num + dmic_num + hdmi_num + bt_num;
1318+
/* allocate BE dailinks, add an extra DAI link for echo reference capture */
1319+
num_links = sdw_be_num + ssp_num + dmic_num + hdmi_num + bt_num + 1;
12981320
dai_links = devm_kcalloc(dev, num_links, sizeof(*dai_links), GFP_KERNEL);
12991321
if (!dai_links) {
13001322
ret = -ENOMEM;
@@ -1341,6 +1363,13 @@ static int sof_card_dai_links_create(struct snd_soc_card *card)
13411363
goto err_end;
13421364
}
13431365

1366+
/* dummy echo ref link. keep this as the last DAI link. The DAI link ID does not matter */
1367+
ret = create_echoref_dailink(card, &dai_links, &be_id);
1368+
if (ret) {
1369+
dev_err(dev, "failed to create echo ref dai link: %d\n", ret);
1370+
goto err_end;
1371+
}
1372+
13441373
WARN_ON(codec_conf != card->codec_conf + card->num_configs);
13451374
WARN_ON(dai_links != card->dai_link + card->num_links);
13461375

0 commit comments

Comments
 (0)