mirror of
https://github.com/torvalds/linux.git
synced 2024-12-03 09:31:26 +00:00
ASoC: SOF: amd: add machine select logic for soundwire based platforms
Add machine select logic for soundwire endpoints for AMD platforms. Signed-off-by: Vijendar Mukunda <Vijendar.Mukunda@amd.com> Link: https://msgid.link/r/20240129055147.1493853-11-Vijendar.Mukunda@amd.com Signed-off-by: Mark Brown <broonie@kernel.org>
This commit is contained in:
parent
14d89e55de
commit
5f97c59a77
@ -118,16 +118,72 @@ void amd_sof_dump(struct snd_sof_dev *sdev, u32 flags)
|
||||
&panic_info, stack, AMD_STACK_DUMP_SIZE);
|
||||
}
|
||||
|
||||
#if IS_ENABLED(CONFIG_SND_SOC_SOF_AMD_SOUNDWIRE)
|
||||
static int amd_sof_sdw_get_slave_info(struct snd_sof_dev *sdev)
|
||||
{
|
||||
struct acp_dev_data *acp_data = sdev->pdata->hw_pdata;
|
||||
|
||||
return sdw_amd_get_slave_info(acp_data->sdw);
|
||||
}
|
||||
|
||||
static struct snd_soc_acpi_mach *amd_sof_sdw_machine_select(struct snd_sof_dev *sdev)
|
||||
{
|
||||
struct snd_soc_acpi_mach *mach;
|
||||
const struct snd_soc_acpi_link_adr *link;
|
||||
struct acp_dev_data *acp_data = sdev->pdata->hw_pdata;
|
||||
int ret, i;
|
||||
|
||||
if (acp_data->info.count) {
|
||||
ret = amd_sof_sdw_get_slave_info(sdev);
|
||||
if (ret) {
|
||||
dev_info(sdev->dev, "failed to read slave information\n");
|
||||
return NULL;
|
||||
}
|
||||
for (mach = sdev->pdata->desc->alt_machines; mach; mach++) {
|
||||
if (!mach->links)
|
||||
break;
|
||||
link = mach->links;
|
||||
for (i = 0; i < acp_data->info.count && link->num_adr; link++, i++) {
|
||||
if (!snd_soc_acpi_sdw_link_slaves_found(sdev->dev, link,
|
||||
acp_data->sdw->ids,
|
||||
acp_data->sdw->num_slaves))
|
||||
break;
|
||||
}
|
||||
if (i == acp_data->info.count || !link->num_adr)
|
||||
break;
|
||||
}
|
||||
if (mach && mach->link_mask) {
|
||||
mach->mach_params.links = mach->links;
|
||||
mach->mach_params.link_mask = mach->link_mask;
|
||||
mach->mach_params.platform = dev_name(sdev->dev);
|
||||
return mach;
|
||||
}
|
||||
}
|
||||
dev_info(sdev->dev, "No SoundWire machine driver found\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
#else
|
||||
static struct snd_soc_acpi_mach *amd_sof_sdw_machine_select(struct snd_sof_dev *sdev)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
#endif
|
||||
|
||||
struct snd_soc_acpi_mach *amd_sof_machine_select(struct snd_sof_dev *sdev)
|
||||
{
|
||||
struct snd_sof_pdata *sof_pdata = sdev->pdata;
|
||||
const struct sof_dev_desc *desc = sof_pdata->desc;
|
||||
struct snd_soc_acpi_mach *mach;
|
||||
struct snd_soc_acpi_mach *mach = NULL;
|
||||
|
||||
mach = snd_soc_acpi_find_machine(desc->machines);
|
||||
if (desc->machines)
|
||||
mach = snd_soc_acpi_find_machine(desc->machines);
|
||||
if (!mach) {
|
||||
dev_warn(sdev->dev, "No matching ASoC machine driver found\n");
|
||||
return NULL;
|
||||
mach = amd_sof_sdw_machine_select(sdev);
|
||||
if (!mach) {
|
||||
dev_warn(sdev->dev, "No matching ASoC machine driver found\n");
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
sof_pdata->tplg_filename = mach->sof_tplg_filename;
|
||||
@ -204,5 +260,6 @@ EXPORT_SYMBOL_NS(sof_acp_common_ops, SND_SOC_SOF_AMD_COMMON);
|
||||
|
||||
MODULE_IMPORT_NS(SND_SOC_SOF_AMD_COMMON);
|
||||
MODULE_IMPORT_NS(SND_SOC_SOF_XTENSA);
|
||||
MODULE_IMPORT_NS(SOUNDWIRE_AMD_INIT);
|
||||
MODULE_DESCRIPTION("ACP SOF COMMON Driver");
|
||||
MODULE_LICENSE("Dual BSD/GPL");
|
||||
|
Loading…
Reference in New Issue
Block a user