Skip to content

Commit c66297d

Browse files
charleskeepaxbroonie
authored andcommitted
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. Reviewed-by: Bard Liao <yung-chuan.liao@linux.intel.com> Signed-off-by: Charles Keepax <ckeepax@opensource.cirrus.com> Link: https://patch.msgid.link/20251127163426.2500633-6-ckeepax@opensource.cirrus.com Signed-off-by: Mark Brown <broonie@kernel.org>
1 parent 2ae4659 commit c66297d

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
@@ -1189,8 +1189,10 @@ static int sof_card_dai_links_create(struct snd_soc_card *card)
11891189
struct asoc_sdw_codec_info *ssp_info;
11901190
struct asoc_sdw_endpoint *sof_ends;
11911191
struct asoc_sdw_dailink *sof_dais;
1192+
struct snd_soc_aux_dev *sof_aux;
11921193
int num_devs = 0;
11931194
int num_ends = 0;
1195+
int num_aux = 0;
11941196
int num_confs;
11951197
struct snd_soc_dai_link *dai_links;
11961198
int num_links;
@@ -1199,7 +1201,7 @@ static int sof_card_dai_links_create(struct snd_soc_card *card)
11991201
unsigned long ssp_mask;
12001202
int ret;
12011203

1202-
ret = asoc_sdw_count_sdw_endpoints(card, &num_devs, &num_ends);
1204+
ret = asoc_sdw_count_sdw_endpoints(card, &num_devs, &num_ends, &num_aux);
12031205
if (ret < 0) {
12041206
dev_err(dev, "failed to count devices/endpoints: %d\n", ret);
12051207
return ret;
@@ -1223,7 +1225,13 @@ static int sof_card_dai_links_create(struct snd_soc_card *card)
12231225
goto err_dai;
12241226
}
12251227

1226-
ret = asoc_sdw_parse_sdw_endpoints(card, sof_dais, sof_ends, &num_confs);
1228+
sof_aux = devm_kcalloc(dev, num_aux, sizeof(*sof_aux), GFP_KERNEL);
1229+
if (!sof_aux) {
1230+
ret = -ENOMEM;
1231+
goto err_dai;
1232+
}
1233+
1234+
ret = asoc_sdw_parse_sdw_endpoints(card, sof_aux, sof_dais, sof_ends, &num_confs);
12271235
if (ret < 0)
12281236
goto err_end;
12291237

@@ -1289,6 +1297,8 @@ static int sof_card_dai_links_create(struct snd_soc_card *card)
12891297
card->num_configs = num_confs;
12901298
card->dai_link = dai_links;
12911299
card->num_links = num_links;
1300+
card->aux_dev = sof_aux;
1301+
card->num_aux_devs = num_aux;
12921302

12931303
/* SDW */
12941304
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
@@ -1252,7 +1252,8 @@ int asoc_sdw_init_simple_dai_link(struct device *dev, struct snd_soc_dai_link *d
12521252
}
12531253
EXPORT_SYMBOL_NS(asoc_sdw_init_simple_dai_link, "SND_SOC_SDW_UTILS");
12541254

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

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

12701281
dev_dbg(dev, "Found %d devices with %d endpoints\n", *num_devs, *num_ends);
@@ -1402,6 +1413,7 @@ static int is_sdca_endpoint_present(struct device *dev,
14021413
}
14031414

14041415
int asoc_sdw_parse_sdw_endpoints(struct snd_soc_card *card,
1416+
struct snd_soc_aux_dev *soc_aux,
14051417
struct asoc_sdw_dailink *soc_dais,
14061418
struct asoc_sdw_endpoint *soc_ends,
14071419
int *num_devs)
@@ -1441,6 +1453,11 @@ int asoc_sdw_parse_sdw_endpoints(struct snd_soc_card *card,
14411453
if (!codec_info)
14421454
return -EINVAL;
14431455

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

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

0 commit comments

Comments
 (0)