Skip to content

Commit 8be15c4

Browse files
committed
ASoC: intel: sof_sdw: Add ability to have auxiliary devices
Currently the sof_sdw machine driver assumes that all devices involved in the sound card are connected through a DAI link. However for SDCA devices we still want the HID (Human Interface Device, used for jack buttons) to be part of the sound card, but it contains no DAI links. Add support into the machine driver to specify a list of auxiliary devices to merged into the card. Signed-off-by: Charles Keepax <ckeepax@opensource.cirrus.com>
1 parent 0dd30f0 commit 8be15c4

5 files changed

Lines changed: 62 additions & 10 deletions

File tree

include/sound/soc_sdw_utils.h

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#include <sound/soc-acpi.h>
1414

1515
#define SOC_SDW_MAX_DAI_NUM 8
16+
#define SOC_SDW_MAX_AUX_NUM 2
1617
#define SOC_SDW_MAX_NO_PROPS 2
1718
#define SOC_SDW_JACK_JDSRC(quirk) ((quirk) & GENMASK(3, 0))
1819

@@ -65,6 +66,10 @@ struct asoc_sdw_dai_info {
6566
bool quirk_exclude;
6667
};
6768

69+
struct asoc_sdw_aux_info {
70+
const char *codec_name;
71+
};
72+
6873
struct asoc_sdw_codec_info {
6974
const int part_id;
7075
const int version_id;
@@ -75,6 +80,8 @@ struct asoc_sdw_codec_info {
7580
const struct snd_soc_ops *ops;
7681
struct asoc_sdw_dai_info dais[SOC_SDW_MAX_DAI_NUM];
7782
const int dai_num;
83+
struct asoc_sdw_aux_info auxs[SOC_SDW_MAX_AUX_NUM];
84+
const int aux_num;
7885

7986
int (*codec_card_late_probe)(struct snd_soc_card *card);
8087

@@ -165,13 +172,15 @@ int asoc_sdw_init_simple_dai_link(struct device *dev, struct snd_soc_dai_link *d
165172
int no_pcm, int (*init)(struct snd_soc_pcm_runtime *rtd),
166173
const struct snd_soc_ops *ops);
167174

168-
int asoc_sdw_count_sdw_endpoints(struct snd_soc_card *card, int *num_devs, int *num_ends);
175+
int asoc_sdw_count_sdw_endpoints(struct snd_soc_card *card,
176+
int *num_devs, int *num_ends, int *num_aux);
169177

170178
struct asoc_sdw_dailink *asoc_sdw_find_dailink(struct asoc_sdw_dailink *dailinks,
171179
const struct snd_soc_acpi_endpoint *new);
172180
int asoc_sdw_get_dai_type(u32 type);
173181

174182
int asoc_sdw_parse_sdw_endpoints(struct snd_soc_card *card,
183+
struct snd_soc_aux_dev *soc_aux,
175184
struct asoc_sdw_dailink *soc_dais,
176185
struct asoc_sdw_endpoint *soc_ends,
177186
int *num_devs);

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

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -360,16 +360,18 @@ static int soc_card_dai_links_create(struct snd_soc_card *card)
360360
struct snd_soc_acpi_mach_params *mach_params = &mach->mach_params;
361361
struct asoc_sdw_endpoint *soc_ends __free(kfree) = NULL;
362362
struct asoc_sdw_dailink *soc_dais __free(kfree) = NULL;
363+
struct snd_soc_aux_dev *soc_aux;
363364
struct snd_soc_codec_conf *codec_conf;
364365
struct snd_soc_dai_link *dai_links;
365366
int num_devs = 0;
366367
int num_ends = 0;
368+
int num_aux = 0;
367369
int num_confs;
368370
int num_links;
369371
int be_id = 0;
370372
int ret;
371373

372-
ret = asoc_sdw_count_sdw_endpoints(card, &num_devs, &num_ends);
374+
ret = asoc_sdw_count_sdw_endpoints(card, &num_devs, &num_ends, &num_aux);
373375
if (ret < 0) {
374376
dev_err(dev, "failed to count devices/endpoints: %d\n", ret);
375377
return ret;
@@ -387,7 +389,11 @@ static int soc_card_dai_links_create(struct snd_soc_card *card)
387389
if (!soc_ends)
388390
return -ENOMEM;
389391

390-
ret = asoc_sdw_parse_sdw_endpoints(card, soc_dais, soc_ends, &num_confs);
392+
soc_aux = devm_kcalloc(dev, num_aux, sizeof(*soc_aux), GFP_KERNEL);
393+
if (!soc_aux)
394+
return -ENOMEM;
395+
396+
ret = asoc_sdw_parse_sdw_endpoints(card, soc_aux, soc_dais, soc_ends, &num_confs);
391397
if (ret < 0)
392398
return ret;
393399

@@ -413,6 +419,8 @@ static int soc_card_dai_links_create(struct snd_soc_card *card)
413419
card->num_configs = num_confs;
414420
card->dai_link = dai_links;
415421
card->num_links = num_links;
422+
card->aux_dev = soc_aux;
423+
card->num_aux_devs = num_aux;
416424

417425
/* SDW */
418426
if (sdw_be_num) {

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

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -272,15 +272,17 @@ static int sof_card_dai_links_create(struct snd_soc_card *card)
272272
struct snd_soc_acpi_mach_params *mach_params = &mach->mach_params;
273273
struct asoc_sdw_endpoint *sof_ends __free(kfree) = NULL;
274274
struct asoc_sdw_dailink *sof_dais __free(kfree) = NULL;
275+
struct snd_soc_aux_dev *sof_aux;
275276
struct snd_soc_codec_conf *codec_conf;
276277
struct snd_soc_dai_link *dai_links;
277278
int num_devs = 0;
278279
int num_ends = 0;
280+
int num_aux = 0;
279281
int num_links;
280282
int be_id = 0;
281283
int ret;
282284

283-
ret = asoc_sdw_count_sdw_endpoints(card, &num_devs, &num_ends);
285+
ret = asoc_sdw_count_sdw_endpoints(card, &num_devs, &num_ends, &num_aux);
284286
if (ret < 0) {
285287
dev_err(dev, "failed to count devices/endpoints: %d\n", ret);
286288
return ret;
@@ -296,7 +298,11 @@ static int sof_card_dai_links_create(struct snd_soc_card *card)
296298
if (!sof_ends)
297299
return -ENOMEM;
298300

299-
ret = asoc_sdw_parse_sdw_endpoints(card, sof_dais, sof_ends, &num_devs);
301+
sof_aux = devm_kcalloc(dev, num_aux, sizeof(*sof_aux), GFP_KERNEL);
302+
if (!sof_aux)
303+
return -ENOMEM;
304+
305+
ret = asoc_sdw_parse_sdw_endpoints(card, sof_aux, sof_dais, sof_ends, &num_devs);
300306
if (ret < 0)
301307
return ret;
302308

@@ -322,6 +328,8 @@ static int sof_card_dai_links_create(struct snd_soc_card *card)
322328
card->num_configs = num_devs;
323329
card->dai_link = dai_links;
324330
card->num_links = num_links;
331+
card->aux_dev = sof_aux;
332+
card->num_aux_devs = num_aux;
325333

326334
/* SDW */
327335
if (sdw_be_num) {

sound/soc/intel/boards/sof_sdw.c

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1208,8 +1208,10 @@ static int sof_card_dai_links_create(struct snd_soc_card *card)
12081208
struct asoc_sdw_codec_info *ssp_info;
12091209
struct asoc_sdw_endpoint *sof_ends;
12101210
struct asoc_sdw_dailink *sof_dais;
1211+
struct snd_soc_aux_dev *sof_aux;
12111212
int num_devs = 0;
12121213
int num_ends = 0;
1214+
int num_aux = 0;
12131215
int num_confs;
12141216
struct snd_soc_dai_link *dai_links;
12151217
int num_links;
@@ -1218,7 +1220,7 @@ static int sof_card_dai_links_create(struct snd_soc_card *card)
12181220
unsigned long ssp_mask;
12191221
int ret;
12201222

1221-
ret = asoc_sdw_count_sdw_endpoints(card, &num_devs, &num_ends);
1223+
ret = asoc_sdw_count_sdw_endpoints(card, &num_devs, &num_ends, &num_aux);
12221224
if (ret < 0) {
12231225
dev_err(dev, "failed to count devices/endpoints: %d\n", ret);
12241226
return ret;
@@ -1242,7 +1244,13 @@ static int sof_card_dai_links_create(struct snd_soc_card *card)
12421244
goto err_dai;
12431245
}
12441246

1245-
ret = asoc_sdw_parse_sdw_endpoints(card, sof_dais, sof_ends, &num_confs);
1247+
sof_aux = devm_kcalloc(dev, num_aux, sizeof(*sof_aux), GFP_KERNEL);
1248+
if (!sof_aux) {
1249+
ret = -ENOMEM;
1250+
goto err_dai;
1251+
}
1252+
1253+
ret = asoc_sdw_parse_sdw_endpoints(card, sof_aux, sof_dais, sof_ends, &num_confs);
12461254
if (ret < 0)
12471255
goto err_end;
12481256

@@ -1308,6 +1316,8 @@ static int sof_card_dai_links_create(struct snd_soc_card *card)
13081316
card->num_configs = num_confs;
13091317
card->dai_link = dai_links;
13101318
card->num_links = num_links;
1319+
card->aux_dev = sof_aux;
1320+
card->num_aux_devs = num_aux;
13111321

13121322
/* SDW */
13131323
if (sdw_be_num) {

sound/soc/sdw_utils/soc_sdw_utils.c

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1251,7 +1251,8 @@ int asoc_sdw_init_simple_dai_link(struct device *dev, struct snd_soc_dai_link *d
12511251
}
12521252
EXPORT_SYMBOL_NS(asoc_sdw_init_simple_dai_link, "SND_SOC_SDW_UTILS");
12531253

1254-
int asoc_sdw_count_sdw_endpoints(struct snd_soc_card *card, int *num_devs, int *num_ends)
1254+
int asoc_sdw_count_sdw_endpoints(struct snd_soc_card *card,
1255+
int *num_devs, int *num_ends, int *num_aux)
12551256
{
12561257
struct device *dev = card->dev;
12571258
struct snd_soc_acpi_mach *mach = dev_get_platdata(dev);
@@ -1262,8 +1263,18 @@ int asoc_sdw_count_sdw_endpoints(struct snd_soc_card *card, int *num_devs, int *
12621263
for (adr_link = mach_params->links; adr_link->num_adr; adr_link++) {
12631264
*num_devs += adr_link->num_adr;
12641265

1265-
for (i = 0; i < adr_link->num_adr; i++)
1266-
*num_ends += adr_link->adr_d[i].num_endpoints;
1266+
for (i = 0; i < adr_link->num_adr; i++) {
1267+
const struct snd_soc_acpi_adr_device *adr_dev = &adr_link->adr_d[i];
1268+
struct asoc_sdw_codec_info *codec_info;
1269+
1270+
*num_ends += adr_dev->num_endpoints;
1271+
1272+
codec_info = asoc_sdw_find_codec_info_part(adr_dev->adr);
1273+
if (!codec_info)
1274+
return -EINVAL;
1275+
1276+
*num_aux += codec_info->aux_num;
1277+
}
12671278
}
12681279

12691280
dev_dbg(dev, "Found %d devices with %d endpoints\n", *num_devs, *num_ends);
@@ -1401,6 +1412,7 @@ static int is_sdca_endpoint_present(struct device *dev,
14011412
}
14021413

14031414
int asoc_sdw_parse_sdw_endpoints(struct snd_soc_card *card,
1415+
struct snd_soc_aux_dev *soc_aux,
14041416
struct asoc_sdw_dailink *soc_dais,
14051417
struct asoc_sdw_endpoint *soc_ends,
14061418
int *num_devs)
@@ -1440,6 +1452,11 @@ int asoc_sdw_parse_sdw_endpoints(struct snd_soc_card *card,
14401452
if (!codec_info)
14411453
return -EINVAL;
14421454

1455+
for (j = 0; j < codec_info->aux_num; j++) {
1456+
soc_aux->dlc.name = codec_info->auxs[j].codec_name;
1457+
soc_aux++;
1458+
}
1459+
14431460
ctx->ignore_internal_dmic |= codec_info->ignore_internal_dmic;
14441461

14451462
if (codec_info->count_sidecar && codec_info->add_sidecar) {

0 commit comments

Comments
 (0)