Commit ba2de401 authored by Richard Fitzgerald's avatar Richard Fitzgerald Committed by Mark Brown

ASoC: SOF: Pass PCI SSID to machine driver

Pass the PCI SSID of the audio interface through to the machine driver.
This allows the machine driver to use the SSID to uniquely identify the
specific hardware configuration and apply any platform-specific
configuration.

struct snd_sof_pdata is passed around inside the SOF code, but it then
passes configuration information to the machine driver through
struct snd_soc_acpi_mach and struct snd_soc_acpi_mach_params. So SSID
information has been added to both snd_sof_pdata and
snd_soc_acpi_mach_params.

PCI does not define 0x0000 as an invalid value so we can't use zero to
indicate that the struct member was not written. Instead a flag is
included to indicate that a value has been written to the
subsystem_vendor and subsystem_device members.

sof_pci_probe() creates the struct snd_sof_pdata. It is passed a struct
pci_dev so it can fill in the SSID value.

sof_machine_check() finds the appropriate struct snd_soc_acpi_mach. It
copies the SSID information across to the struct snd_soc_acpi_mach_params.
This done before calling any custom set_mach_params() so that it could be
used by the set_mach_params() callback to apply variant params.

The machine driver receives the struct snd_soc_acpi_mach as its
platform_data.
Signed-off-by: default avatarRichard Fitzgerald <rf@opensource.cirrus.com>
Reviewed-by: default avatarPierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Link: https://lore.kernel.org/r/20230912163207.3498161-3-rf@opensource.cirrus.comSigned-off-by: default avatarMark Brown <broonie@kernel.org>
parent 47f56e38
...@@ -68,6 +68,10 @@ static inline struct snd_soc_acpi_mach *snd_soc_acpi_codec_list(void *arg) ...@@ -68,6 +68,10 @@ static inline struct snd_soc_acpi_mach *snd_soc_acpi_codec_list(void *arg)
* @i2s_link_mask: I2S/TDM links enabled on the board * @i2s_link_mask: I2S/TDM links enabled on the board
* @num_dai_drivers: number of elements in @dai_drivers * @num_dai_drivers: number of elements in @dai_drivers
* @dai_drivers: pointer to dai_drivers, used e.g. in nocodec mode * @dai_drivers: pointer to dai_drivers, used e.g. in nocodec mode
* @subsystem_vendor: optional PCI SSID vendor value
* @subsystem_device: optional PCI SSID device value
* @subsystem_id_set: true if a value has been written to
* subsystem_vendor and subsystem_device.
*/ */
struct snd_soc_acpi_mach_params { struct snd_soc_acpi_mach_params {
u32 acpi_ipc_irq_index; u32 acpi_ipc_irq_index;
...@@ -80,6 +84,9 @@ struct snd_soc_acpi_mach_params { ...@@ -80,6 +84,9 @@ struct snd_soc_acpi_mach_params {
u32 i2s_link_mask; u32 i2s_link_mask;
u32 num_dai_drivers; u32 num_dai_drivers;
struct snd_soc_dai_driver *dai_drivers; struct snd_soc_dai_driver *dai_drivers;
unsigned short subsystem_vendor;
unsigned short subsystem_device;
bool subsystem_id_set;
}; };
/** /**
......
...@@ -64,6 +64,14 @@ struct snd_sof_pdata { ...@@ -64,6 +64,14 @@ struct snd_sof_pdata {
const char *name; const char *name;
const char *platform; const char *platform;
/*
* PCI SSID. As PCI does not define 0 as invalid, the subsystem_id_set
* flag indicates that a value has been written to these members.
*/
unsigned short subsystem_vendor;
unsigned short subsystem_device;
bool subsystem_id_set;
struct device *dev; struct device *dev;
/* /*
......
...@@ -1031,6 +1031,13 @@ int sof_machine_check(struct snd_sof_dev *sdev) ...@@ -1031,6 +1031,13 @@ int sof_machine_check(struct snd_sof_dev *sdev)
mach = snd_sof_machine_select(sdev); mach = snd_sof_machine_select(sdev);
if (mach) { if (mach) {
sof_pdata->machine = mach; sof_pdata->machine = mach;
if (sof_pdata->subsystem_id_set) {
mach->mach_params.subsystem_vendor = sof_pdata->subsystem_vendor;
mach->mach_params.subsystem_device = sof_pdata->subsystem_device;
mach->mach_params.subsystem_id_set = true;
}
snd_sof_set_mach_params(mach, sdev); snd_sof_set_mach_params(mach, sdev);
return 0; return 0;
} }
......
...@@ -214,6 +214,14 @@ int sof_pci_probe(struct pci_dev *pci, const struct pci_device_id *pci_id) ...@@ -214,6 +214,14 @@ int sof_pci_probe(struct pci_dev *pci, const struct pci_device_id *pci_id)
return ret; return ret;
sof_pdata->name = pci_name(pci); sof_pdata->name = pci_name(pci);
/* PCI defines a vendor ID of 0xFFFF as invalid. */
if (pci->subsystem_vendor != 0xFFFF) {
sof_pdata->subsystem_vendor = pci->subsystem_vendor;
sof_pdata->subsystem_device = pci->subsystem_device;
sof_pdata->subsystem_id_set = true;
}
sof_pdata->desc = desc; sof_pdata->desc = desc;
sof_pdata->dev = dev; sof_pdata->dev = dev;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment