mirror of
https://github.com/raspberrypi/linux.git
synced 2025-12-06 18:09:56 +00:00
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 <yung-chuan.liao@linux.intel.com> Signed-off-by: Charles Keepax <ckeepax@opensource.cirrus.com> Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com> Link: https://lore.kernel.org/r/20240426152123.36284-12-pierre-louis.bossart@linux.intel.com Signed-off-by: Mark Brown <broonie@kernel.org>
This commit is contained in:
committed by
Mark Brown
parent
628cc5d0c4
commit
da52441802
@@ -1280,6 +1280,7 @@ struct sof_sdw_endpoint {
|
|||||||
u32 link_mask;
|
u32 link_mask;
|
||||||
const char *codec_name;
|
const char *codec_name;
|
||||||
const char *name_prefix;
|
const char *name_prefix;
|
||||||
|
bool include_sidecar;
|
||||||
|
|
||||||
struct sof_sdw_codec_info *codec_info;
|
struct sof_sdw_codec_info *codec_info;
|
||||||
const struct sof_sdw_dai_info *dai_info;
|
const struct sof_sdw_dai_info *dai_info;
|
||||||
@@ -1335,7 +1336,8 @@ static struct sof_sdw_dailink *find_dailink(struct sof_sdw_dailink *dailinks,
|
|||||||
|
|
||||||
static int parse_sdw_endpoints(struct snd_soc_card *card,
|
static int parse_sdw_endpoints(struct snd_soc_card *card,
|
||||||
struct sof_sdw_dailink *sof_dais,
|
struct sof_sdw_dailink *sof_dais,
|
||||||
struct sof_sdw_endpoint *sof_ends)
|
struct sof_sdw_endpoint *sof_ends,
|
||||||
|
int *num_devs)
|
||||||
{
|
{
|
||||||
struct device *dev = card->dev;
|
struct device *dev = card->dev;
|
||||||
struct mc_private *ctx = snd_soc_card_get_drvdata(card);
|
struct mc_private *ctx = snd_soc_card_get_drvdata(card);
|
||||||
@@ -1345,6 +1347,7 @@ static int parse_sdw_endpoints(struct snd_soc_card *card,
|
|||||||
struct sof_sdw_endpoint *sof_end = sof_ends;
|
struct sof_sdw_endpoint *sof_end = sof_ends;
|
||||||
int num_dais = 0;
|
int num_dais = 0;
|
||||||
int i, j;
|
int i, j;
|
||||||
|
int ret;
|
||||||
|
|
||||||
for (adr_link = mach_params->links; adr_link->num_adr; adr_link++) {
|
for (adr_link = mach_params->links; adr_link->num_adr; adr_link++) {
|
||||||
int num_link_dailinks = 0;
|
int num_link_dailinks = 0;
|
||||||
@@ -1381,6 +1384,14 @@ static int parse_sdw_endpoints(struct snd_soc_card *card,
|
|||||||
|
|
||||||
sof_end->name_prefix = adr_dev->name_prefix;
|
sof_end->name_prefix = adr_dev->name_prefix;
|
||||||
|
|
||||||
|
if (codec_info->count_sidecar && codec_info->add_sidecar) {
|
||||||
|
ret = codec_info->count_sidecar(card, &num_dais, num_devs);
|
||||||
|
if (ret)
|
||||||
|
return ret;
|
||||||
|
|
||||||
|
sof_end->include_sidecar = true;
|
||||||
|
}
|
||||||
|
|
||||||
for (j = 0; j < adr_dev->num_endpoints; j++) {
|
for (j = 0; j < adr_dev->num_endpoints; j++) {
|
||||||
const struct snd_soc_acpi_endpoint *adr_end;
|
const struct snd_soc_acpi_endpoint *adr_end;
|
||||||
const struct sof_sdw_dai_info *dai_info;
|
const struct sof_sdw_dai_info *dai_info;
|
||||||
@@ -1453,6 +1464,7 @@ static int create_sdw_dailink(struct snd_soc_card *card,
|
|||||||
struct mc_private *ctx = snd_soc_card_get_drvdata(card);
|
struct mc_private *ctx = snd_soc_card_get_drvdata(card);
|
||||||
struct sof_sdw_endpoint *sof_end;
|
struct sof_sdw_endpoint *sof_end;
|
||||||
int stream;
|
int stream;
|
||||||
|
int ret;
|
||||||
|
|
||||||
list_for_each_entry(sof_end, &sof_dai->endpoints, list) {
|
list_for_each_entry(sof_end, &sof_dai->endpoints, list) {
|
||||||
if (sof_end->name_prefix) {
|
if (sof_end->name_prefix) {
|
||||||
@@ -1460,6 +1472,12 @@ static int create_sdw_dailink(struct snd_soc_card *card,
|
|||||||
(*codec_conf)->name_prefix = sof_end->name_prefix;
|
(*codec_conf)->name_prefix = sof_end->name_prefix;
|
||||||
(*codec_conf)++;
|
(*codec_conf)++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (sof_end->include_sidecar) {
|
||||||
|
ret = sof_end->codec_info->add_sidecar(card, dai_links, codec_conf);
|
||||||
|
if (ret)
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for_each_pcm_streams(stream) {
|
for_each_pcm_streams(stream) {
|
||||||
@@ -1757,7 +1775,7 @@ static int sof_card_dai_links_create(struct snd_soc_card *card)
|
|||||||
goto err_dai;
|
goto err_dai;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = parse_sdw_endpoints(card, sof_dais, sof_ends);
|
ret = parse_sdw_endpoints(card, sof_dais, sof_ends, &num_devs);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
goto err_end;
|
goto err_end;
|
||||||
|
|
||||||
|
|||||||
@@ -98,6 +98,12 @@ struct sof_sdw_codec_info {
|
|||||||
const int dai_num;
|
const int dai_num;
|
||||||
|
|
||||||
int (*codec_card_late_probe)(struct snd_soc_card *card);
|
int (*codec_card_late_probe)(struct snd_soc_card *card);
|
||||||
|
|
||||||
|
int (*count_sidecar)(struct snd_soc_card *card,
|
||||||
|
int *num_dais, int *num_devs);
|
||||||
|
int (*add_sidecar)(struct snd_soc_card *card,
|
||||||
|
struct snd_soc_dai_link **dai_links,
|
||||||
|
struct snd_soc_codec_conf **codec_conf);
|
||||||
};
|
};
|
||||||
|
|
||||||
struct mc_private {
|
struct mc_private {
|
||||||
|
|||||||
Reference in New Issue
Block a user