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>
This commit is contained in:
Charles Keepax 2025-11-27 16:34:24 +00:00 committed by Mark Brown
parent 2ae4659533
commit c66297d09e
No known key found for this signature in database
GPG Key ID: 24D68B725D5487D0
5 changed files with 62 additions and 10 deletions

View File

@ -13,6 +13,7 @@
#include <sound/soc-acpi.h> #include <sound/soc-acpi.h>
#define SOC_SDW_MAX_DAI_NUM 8 #define SOC_SDW_MAX_DAI_NUM 8
#define SOC_SDW_MAX_AUX_NUM 2
#define SOC_SDW_MAX_NO_PROPS 2 #define SOC_SDW_MAX_NO_PROPS 2
#define SOC_SDW_JACK_JDSRC(quirk) ((quirk) & GENMASK(3, 0)) #define SOC_SDW_JACK_JDSRC(quirk) ((quirk) & GENMASK(3, 0))
@ -65,6 +66,10 @@ struct asoc_sdw_dai_info {
bool quirk_exclude; bool quirk_exclude;
}; };
struct asoc_sdw_aux_info {
const char *codec_name;
};
struct asoc_sdw_codec_info { struct asoc_sdw_codec_info {
const int part_id; const int part_id;
const int version_id; const int version_id;
@ -75,6 +80,8 @@ struct asoc_sdw_codec_info {
const struct snd_soc_ops *ops; const struct snd_soc_ops *ops;
struct asoc_sdw_dai_info dais[SOC_SDW_MAX_DAI_NUM]; struct asoc_sdw_dai_info dais[SOC_SDW_MAX_DAI_NUM];
const int dai_num; const int dai_num;
struct asoc_sdw_aux_info auxs[SOC_SDW_MAX_AUX_NUM];
const int aux_num;
int (*codec_card_late_probe)(struct snd_soc_card *card); int (*codec_card_late_probe)(struct snd_soc_card *card);
@ -165,13 +172,15 @@ int asoc_sdw_init_simple_dai_link(struct device *dev, struct snd_soc_dai_link *d
int no_pcm, int (*init)(struct snd_soc_pcm_runtime *rtd), int no_pcm, int (*init)(struct snd_soc_pcm_runtime *rtd),
const struct snd_soc_ops *ops); const struct snd_soc_ops *ops);
int asoc_sdw_count_sdw_endpoints(struct snd_soc_card *card, int *num_devs, int *num_ends); int asoc_sdw_count_sdw_endpoints(struct snd_soc_card *card,
int *num_devs, int *num_ends, int *num_aux);
struct asoc_sdw_dailink *asoc_sdw_find_dailink(struct asoc_sdw_dailink *dailinks, struct asoc_sdw_dailink *asoc_sdw_find_dailink(struct asoc_sdw_dailink *dailinks,
const struct snd_soc_acpi_endpoint *new); const struct snd_soc_acpi_endpoint *new);
int asoc_sdw_get_dai_type(u32 type); int asoc_sdw_get_dai_type(u32 type);
int asoc_sdw_parse_sdw_endpoints(struct snd_soc_card *card, int asoc_sdw_parse_sdw_endpoints(struct snd_soc_card *card,
struct snd_soc_aux_dev *soc_aux,
struct asoc_sdw_dailink *soc_dais, struct asoc_sdw_dailink *soc_dais,
struct asoc_sdw_endpoint *soc_ends, struct asoc_sdw_endpoint *soc_ends,
int *num_devs); int *num_devs);

View File

@ -360,16 +360,18 @@ static int soc_card_dai_links_create(struct snd_soc_card *card)
struct snd_soc_acpi_mach_params *mach_params = &mach->mach_params; struct snd_soc_acpi_mach_params *mach_params = &mach->mach_params;
struct asoc_sdw_endpoint *soc_ends __free(kfree) = NULL; struct asoc_sdw_endpoint *soc_ends __free(kfree) = NULL;
struct asoc_sdw_dailink *soc_dais __free(kfree) = NULL; struct asoc_sdw_dailink *soc_dais __free(kfree) = NULL;
struct snd_soc_aux_dev *soc_aux;
struct snd_soc_codec_conf *codec_conf; struct snd_soc_codec_conf *codec_conf;
struct snd_soc_dai_link *dai_links; struct snd_soc_dai_link *dai_links;
int num_devs = 0; int num_devs = 0;
int num_ends = 0; int num_ends = 0;
int num_aux = 0;
int num_confs; int num_confs;
int num_links; int num_links;
int be_id = 0; int be_id = 0;
int ret; int ret;
ret = asoc_sdw_count_sdw_endpoints(card, &num_devs, &num_ends); ret = asoc_sdw_count_sdw_endpoints(card, &num_devs, &num_ends, &num_aux);
if (ret < 0) { if (ret < 0) {
dev_err(dev, "failed to count devices/endpoints: %d\n", ret); dev_err(dev, "failed to count devices/endpoints: %d\n", ret);
return ret; return ret;
@ -387,7 +389,11 @@ static int soc_card_dai_links_create(struct snd_soc_card *card)
if (!soc_ends) if (!soc_ends)
return -ENOMEM; return -ENOMEM;
ret = asoc_sdw_parse_sdw_endpoints(card, soc_dais, soc_ends, &num_confs); soc_aux = devm_kcalloc(dev, num_aux, sizeof(*soc_aux), GFP_KERNEL);
if (!soc_aux)
return -ENOMEM;
ret = asoc_sdw_parse_sdw_endpoints(card, soc_aux, soc_dais, soc_ends, &num_confs);
if (ret < 0) if (ret < 0)
return ret; return ret;
@ -413,6 +419,8 @@ static int soc_card_dai_links_create(struct snd_soc_card *card)
card->num_configs = num_confs; card->num_configs = num_confs;
card->dai_link = dai_links; card->dai_link = dai_links;
card->num_links = num_links; card->num_links = num_links;
card->aux_dev = soc_aux;
card->num_aux_devs = num_aux;
/* SDW */ /* SDW */
if (sdw_be_num) { if (sdw_be_num) {

View File

@ -272,15 +272,17 @@ static int sof_card_dai_links_create(struct snd_soc_card *card)
struct snd_soc_acpi_mach_params *mach_params = &mach->mach_params; struct snd_soc_acpi_mach_params *mach_params = &mach->mach_params;
struct asoc_sdw_endpoint *sof_ends __free(kfree) = NULL; struct asoc_sdw_endpoint *sof_ends __free(kfree) = NULL;
struct asoc_sdw_dailink *sof_dais __free(kfree) = NULL; struct asoc_sdw_dailink *sof_dais __free(kfree) = NULL;
struct snd_soc_aux_dev *sof_aux;
struct snd_soc_codec_conf *codec_conf; struct snd_soc_codec_conf *codec_conf;
struct snd_soc_dai_link *dai_links; struct snd_soc_dai_link *dai_links;
int num_devs = 0; int num_devs = 0;
int num_ends = 0; int num_ends = 0;
int num_aux = 0;
int num_links; int num_links;
int be_id = 0; int be_id = 0;
int ret; int ret;
ret = asoc_sdw_count_sdw_endpoints(card, &num_devs, &num_ends); ret = asoc_sdw_count_sdw_endpoints(card, &num_devs, &num_ends, &num_aux);
if (ret < 0) { if (ret < 0) {
dev_err(dev, "failed to count devices/endpoints: %d\n", ret); dev_err(dev, "failed to count devices/endpoints: %d\n", ret);
return ret; return ret;
@ -296,7 +298,11 @@ static int sof_card_dai_links_create(struct snd_soc_card *card)
if (!sof_ends) if (!sof_ends)
return -ENOMEM; return -ENOMEM;
ret = asoc_sdw_parse_sdw_endpoints(card, sof_dais, sof_ends, &num_devs); sof_aux = devm_kcalloc(dev, num_aux, sizeof(*sof_aux), GFP_KERNEL);
if (!sof_aux)
return -ENOMEM;
ret = asoc_sdw_parse_sdw_endpoints(card, sof_aux, sof_dais, sof_ends, &num_devs);
if (ret < 0) if (ret < 0)
return ret; return ret;
@ -322,6 +328,8 @@ static int sof_card_dai_links_create(struct snd_soc_card *card)
card->num_configs = num_devs; card->num_configs = num_devs;
card->dai_link = dai_links; card->dai_link = dai_links;
card->num_links = num_links; card->num_links = num_links;
card->aux_dev = sof_aux;
card->num_aux_devs = num_aux;
/* SDW */ /* SDW */
if (sdw_be_num) { if (sdw_be_num) {

View File

@ -1189,8 +1189,10 @@ static int sof_card_dai_links_create(struct snd_soc_card *card)
struct asoc_sdw_codec_info *ssp_info; struct asoc_sdw_codec_info *ssp_info;
struct asoc_sdw_endpoint *sof_ends; struct asoc_sdw_endpoint *sof_ends;
struct asoc_sdw_dailink *sof_dais; struct asoc_sdw_dailink *sof_dais;
struct snd_soc_aux_dev *sof_aux;
int num_devs = 0; int num_devs = 0;
int num_ends = 0; int num_ends = 0;
int num_aux = 0;
int num_confs; int num_confs;
struct snd_soc_dai_link *dai_links; struct snd_soc_dai_link *dai_links;
int num_links; int num_links;
@ -1199,7 +1201,7 @@ static int sof_card_dai_links_create(struct snd_soc_card *card)
unsigned long ssp_mask; unsigned long ssp_mask;
int ret; int ret;
ret = asoc_sdw_count_sdw_endpoints(card, &num_devs, &num_ends); ret = asoc_sdw_count_sdw_endpoints(card, &num_devs, &num_ends, &num_aux);
if (ret < 0) { if (ret < 0) {
dev_err(dev, "failed to count devices/endpoints: %d\n", ret); dev_err(dev, "failed to count devices/endpoints: %d\n", ret);
return ret; return ret;
@ -1223,7 +1225,13 @@ static int sof_card_dai_links_create(struct snd_soc_card *card)
goto err_dai; goto err_dai;
} }
ret = asoc_sdw_parse_sdw_endpoints(card, sof_dais, sof_ends, &num_confs); sof_aux = devm_kcalloc(dev, num_aux, sizeof(*sof_aux), GFP_KERNEL);
if (!sof_aux) {
ret = -ENOMEM;
goto err_dai;
}
ret = asoc_sdw_parse_sdw_endpoints(card, sof_aux, sof_dais, sof_ends, &num_confs);
if (ret < 0) if (ret < 0)
goto err_end; goto err_end;
@ -1289,6 +1297,8 @@ static int sof_card_dai_links_create(struct snd_soc_card *card)
card->num_configs = num_confs; card->num_configs = num_confs;
card->dai_link = dai_links; card->dai_link = dai_links;
card->num_links = num_links; card->num_links = num_links;
card->aux_dev = sof_aux;
card->num_aux_devs = num_aux;
/* SDW */ /* SDW */
if (sdw_be_num) { if (sdw_be_num) {

View File

@ -1252,7 +1252,8 @@ int asoc_sdw_init_simple_dai_link(struct device *dev, struct snd_soc_dai_link *d
} }
EXPORT_SYMBOL_NS(asoc_sdw_init_simple_dai_link, "SND_SOC_SDW_UTILS"); EXPORT_SYMBOL_NS(asoc_sdw_init_simple_dai_link, "SND_SOC_SDW_UTILS");
int asoc_sdw_count_sdw_endpoints(struct snd_soc_card *card, int *num_devs, int *num_ends) int asoc_sdw_count_sdw_endpoints(struct snd_soc_card *card,
int *num_devs, int *num_ends, int *num_aux)
{ {
struct device *dev = card->dev; struct device *dev = card->dev;
struct snd_soc_acpi_mach *mach = dev_get_platdata(dev); 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 *
for (adr_link = mach_params->links; adr_link->num_adr; adr_link++) { for (adr_link = mach_params->links; adr_link->num_adr; adr_link++) {
*num_devs += adr_link->num_adr; *num_devs += adr_link->num_adr;
for (i = 0; i < adr_link->num_adr; i++) for (i = 0; i < adr_link->num_adr; i++) {
*num_ends += adr_link->adr_d[i].num_endpoints; const struct snd_soc_acpi_adr_device *adr_dev = &adr_link->adr_d[i];
struct asoc_sdw_codec_info *codec_info;
*num_ends += adr_dev->num_endpoints;
codec_info = asoc_sdw_find_codec_info_part(adr_dev->adr);
if (!codec_info)
return -EINVAL;
*num_aux += codec_info->aux_num;
}
} }
dev_dbg(dev, "Found %d devices with %d endpoints\n", *num_devs, *num_ends); 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,
} }
int asoc_sdw_parse_sdw_endpoints(struct snd_soc_card *card, int asoc_sdw_parse_sdw_endpoints(struct snd_soc_card *card,
struct snd_soc_aux_dev *soc_aux,
struct asoc_sdw_dailink *soc_dais, struct asoc_sdw_dailink *soc_dais,
struct asoc_sdw_endpoint *soc_ends, struct asoc_sdw_endpoint *soc_ends,
int *num_devs) int *num_devs)
@ -1441,6 +1453,11 @@ int asoc_sdw_parse_sdw_endpoints(struct snd_soc_card *card,
if (!codec_info) if (!codec_info)
return -EINVAL; return -EINVAL;
for (j = 0; j < codec_info->aux_num; j++) {
soc_aux->dlc.name = codec_info->auxs[j].codec_name;
soc_aux++;
}
ctx->ignore_internal_dmic |= codec_info->ignore_internal_dmic; ctx->ignore_internal_dmic |= codec_info->ignore_internal_dmic;
if (codec_info->count_sidecar && codec_info->add_sidecar) { if (codec_info->count_sidecar && codec_info->add_sidecar) {