Skip to content

Commit da52441

Browse files
charleskeepaxbroonie
authored andcommitted
ASoC: Intel: sof_sdw: Add callbacks to register sidecar devices
Add support for systems that have additional non-SoundWire devices (sidecars) connected to one of the SoundWire devices in the system. This is done through the addition of two callbacks, one used at endpoint parsing time that will return the number of devices and DAI links to be added, and another called later as the DAI links are created that will populate those devices into the appropriate arrays. Reviewed-by: Bard Liao <[email protected]> Signed-off-by: Charles Keepax <[email protected]> Signed-off-by: Pierre-Louis Bossart <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Mark Brown <[email protected]>
1 parent 628cc5d commit da52441

File tree

2 files changed

+26
-2
lines changed

2 files changed

+26
-2
lines changed

sound/soc/intel/boards/sof_sdw.c

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1280,6 +1280,7 @@ struct sof_sdw_endpoint {
12801280
u32 link_mask;
12811281
const char *codec_name;
12821282
const char *name_prefix;
1283+
bool include_sidecar;
12831284

12841285
struct sof_sdw_codec_info *codec_info;
12851286
const struct sof_sdw_dai_info *dai_info;
@@ -1335,7 +1336,8 @@ static struct sof_sdw_dailink *find_dailink(struct sof_sdw_dailink *dailinks,
13351336

13361337
static int parse_sdw_endpoints(struct snd_soc_card *card,
13371338
struct sof_sdw_dailink *sof_dais,
1338-
struct sof_sdw_endpoint *sof_ends)
1339+
struct sof_sdw_endpoint *sof_ends,
1340+
int *num_devs)
13391341
{
13401342
struct device *dev = card->dev;
13411343
struct mc_private *ctx = snd_soc_card_get_drvdata(card);
@@ -1345,6 +1347,7 @@ static int parse_sdw_endpoints(struct snd_soc_card *card,
13451347
struct sof_sdw_endpoint *sof_end = sof_ends;
13461348
int num_dais = 0;
13471349
int i, j;
1350+
int ret;
13481351

13491352
for (adr_link = mach_params->links; adr_link->num_adr; adr_link++) {
13501353
int num_link_dailinks = 0;
@@ -1381,6 +1384,14 @@ static int parse_sdw_endpoints(struct snd_soc_card *card,
13811384

13821385
sof_end->name_prefix = adr_dev->name_prefix;
13831386

1387+
if (codec_info->count_sidecar && codec_info->add_sidecar) {
1388+
ret = codec_info->count_sidecar(card, &num_dais, num_devs);
1389+
if (ret)
1390+
return ret;
1391+
1392+
sof_end->include_sidecar = true;
1393+
}
1394+
13841395
for (j = 0; j < adr_dev->num_endpoints; j++) {
13851396
const struct snd_soc_acpi_endpoint *adr_end;
13861397
const struct sof_sdw_dai_info *dai_info;
@@ -1453,13 +1464,20 @@ static int create_sdw_dailink(struct snd_soc_card *card,
14531464
struct mc_private *ctx = snd_soc_card_get_drvdata(card);
14541465
struct sof_sdw_endpoint *sof_end;
14551466
int stream;
1467+
int ret;
14561468

14571469
list_for_each_entry(sof_end, &sof_dai->endpoints, list) {
14581470
if (sof_end->name_prefix) {
14591471
(*codec_conf)->dlc.name = sof_end->codec_name;
14601472
(*codec_conf)->name_prefix = sof_end->name_prefix;
14611473
(*codec_conf)++;
14621474
}
1475+
1476+
if (sof_end->include_sidecar) {
1477+
ret = sof_end->codec_info->add_sidecar(card, dai_links, codec_conf);
1478+
if (ret)
1479+
return ret;
1480+
}
14631481
}
14641482

14651483
for_each_pcm_streams(stream) {
@@ -1757,7 +1775,7 @@ static int sof_card_dai_links_create(struct snd_soc_card *card)
17571775
goto err_dai;
17581776
}
17591777

1760-
ret = parse_sdw_endpoints(card, sof_dais, sof_ends);
1778+
ret = parse_sdw_endpoints(card, sof_dais, sof_ends, &num_devs);
17611779
if (ret < 0)
17621780
goto err_end;
17631781

sound/soc/intel/boards/sof_sdw_common.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,12 @@ struct sof_sdw_codec_info {
9898
const int dai_num;
9999

100100
int (*codec_card_late_probe)(struct snd_soc_card *card);
101+
102+
int (*count_sidecar)(struct snd_soc_card *card,
103+
int *num_dais, int *num_devs);
104+
int (*add_sidecar)(struct snd_soc_card *card,
105+
struct snd_soc_dai_link **dai_links,
106+
struct snd_soc_codec_conf **codec_conf);
101107
};
102108

103109
struct mc_private {

0 commit comments

Comments
 (0)