All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH AUTOSEL 5.15 01/22] ASoC: soc-card: Add storage for PCI SSID
@ 2023-11-07 15:51 Sasha Levin
  2023-11-07 15:51 ` [PATCH AUTOSEL 5.15 02/22] crypto: pcrypt - Fix hungtask for PADATA_RESET Sasha Levin
                   ` (20 more replies)
  0 siblings, 21 replies; 24+ messages in thread
From: Sasha Levin @ 2023-11-07 15:51 UTC (permalink / raw)
  To: linux-kernel, stable
  Cc: Richard Fitzgerald, Pierre-Louis Bossart, Mark Brown,
	Sasha Levin, lgirdwood, perex, tiwai, linux-sound

From: Richard Fitzgerald <rf@opensource.cirrus.com>

[ Upstream commit 47f56e38a199bd45514b8e0142399cba4feeaf1a ]

Add members to struct snd_soc_card to store the PCI subsystem ID (SSID)
of the soundcard.

The PCI specification provides two registers to store a vendor-specific
SSID that can be read by drivers to uniquely identify a particular
"soundcard". This is defined in the PCI specification to distinguish
products that use the same silicon (and therefore have the same silicon
ID) so that product-specific differences can be applied.

PCI only defines 0xFFFF as an invalid value. 0x0000 is not defined as
invalid. So the usual pattern of zero-filling the struct and then
assuming a zero value unset will not work. A flag is included to
indicate when the SSID information has been filled in.

Unlike DMI information, which has a free-format entirely up to the vendor,
the PCI SSID has a strictly defined format and a registry of vendor IDs.

It is usual in Windows drivers that the SSID is used as the sole identifier
of the specific end-product and the Windows driver contains tables mapping
that to information about the hardware setup, rather than using ACPI
properties.

This SSID is important information for ASoC components that need to apply
hardware-specific configuration on PCI-based systems.

As the SSID is a generic part of the PCI specification and is treated as
identifying the "soundcard", it is reasonable to include this information
in struct snd_soc_card, instead of components inventing their own custom
ways to pass this information around.

Signed-off-by: Richard Fitzgerald <rf@opensource.cirrus.com>
Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Link: https://lore.kernel.org/r/20230912163207.3498161-2-rf@opensource.cirrus.com
Signed-off-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 include/sound/soc-card.h | 37 +++++++++++++++++++++++++++++++++++++
 include/sound/soc.h      | 11 +++++++++++
 2 files changed, 48 insertions(+)

diff --git a/include/sound/soc-card.h b/include/sound/soc-card.h
index 4f2cc4fb56b7f..9a5429260ece5 100644
--- a/include/sound/soc-card.h
+++ b/include/sound/soc-card.h
@@ -40,6 +40,43 @@ int snd_soc_card_add_dai_link(struct snd_soc_card *card,
 void snd_soc_card_remove_dai_link(struct snd_soc_card *card,
 				  struct snd_soc_dai_link *dai_link);
 
+#ifdef CONFIG_PCI
+static inline void snd_soc_card_set_pci_ssid(struct snd_soc_card *card,
+					     unsigned short vendor,
+					     unsigned short device)
+{
+	card->pci_subsystem_vendor = vendor;
+	card->pci_subsystem_device = device;
+	card->pci_subsystem_set = true;
+}
+
+static inline int snd_soc_card_get_pci_ssid(struct snd_soc_card *card,
+					    unsigned short *vendor,
+					    unsigned short *device)
+{
+	if (!card->pci_subsystem_set)
+		return -ENOENT;
+
+	*vendor = card->pci_subsystem_vendor;
+	*device = card->pci_subsystem_device;
+
+	return 0;
+}
+#else /* !CONFIG_PCI */
+static inline void snd_soc_card_set_pci_ssid(struct snd_soc_card *card,
+					     unsigned short vendor,
+					     unsigned short device)
+{
+}
+
+static inline int snd_soc_card_get_pci_ssid(struct snd_soc_card *card,
+					    unsigned short *vendor,
+					    unsigned short *device)
+{
+	return -ENOENT;
+}
+#endif /* CONFIG_PCI */
+
 /* device driver data */
 static inline void snd_soc_card_set_drvdata(struct snd_soc_card *card,
 					    void *data)
diff --git a/include/sound/soc.h b/include/sound/soc.h
index 5872a8864f3b6..3f0369aae2faf 100644
--- a/include/sound/soc.h
+++ b/include/sound/soc.h
@@ -880,6 +880,17 @@ struct snd_soc_card {
 #ifdef CONFIG_DMI
 	char dmi_longname[80];
 #endif /* CONFIG_DMI */
+
+#ifdef CONFIG_PCI
+	/*
+	 * PCI does not define 0 as invalid, so pci_subsystem_set indicates
+	 * whether a value has been written to these fields.
+	 */
+	unsigned short pci_subsystem_vendor;
+	unsigned short pci_subsystem_device;
+	bool pci_subsystem_set;
+#endif /* CONFIG_PCI */
+
 	char topology_shortname[32];
 
 	struct device *dev;
-- 
2.42.0


^ permalink raw reply related	[flat|nested] 24+ messages in thread

end of thread, other threads:[~2023-11-07 16:18 UTC | newest]

Thread overview: 24+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-11-07 15:51 [PATCH AUTOSEL 5.15 01/22] ASoC: soc-card: Add storage for PCI SSID Sasha Levin
2023-11-07 15:51 ` [PATCH AUTOSEL 5.15 02/22] crypto: pcrypt - Fix hungtask for PADATA_RESET Sasha Levin
2023-11-07 15:51 ` [PATCH AUTOSEL 5.15 03/22] RDMA/hfi1: Use FIELD_GET() to extract Link Width Sasha Levin
2023-11-07 15:51 ` [PATCH AUTOSEL 5.15 04/22] scsi: hisi_sas: Set debugfs_dir pointer to NULL after removing debugfs Sasha Levin
2023-11-07 15:51 ` [PATCH AUTOSEL 5.15 05/22] scsi: ibmvfc: Remove BUG_ON in the case of an empty event pool Sasha Levin
2023-11-07 15:51   ` Sasha Levin
2023-11-07 15:51 ` [PATCH AUTOSEL 5.15 06/22] fs/jfs: Add check for negative db_l2nbperpage Sasha Levin
2023-11-07 15:51 ` [PATCH AUTOSEL 5.15 07/22] fs/jfs: Add validity check for db_maxag and db_agpref Sasha Levin
2023-11-07 15:51 ` [PATCH AUTOSEL 5.15 08/22] jfs: fix array-index-out-of-bounds in dbFindLeaf Sasha Levin
2023-11-07 15:51 ` [PATCH AUTOSEL 5.15 09/22] jfs: fix array-index-out-of-bounds in diAlloc Sasha Levin
2023-11-07 15:51 ` [PATCH AUTOSEL 5.15 10/22] HID: lenovo: Detect quirk-free fw on cptkbd and stop applying workaround Sasha Levin
2023-11-07 15:51 ` [PATCH AUTOSEL 5.15 11/22] ARM: 9320/1: fix stack depot IRQ stack filter Sasha Levin
2023-11-07 15:51   ` Sasha Levin
2023-11-07 15:51 ` [PATCH AUTOSEL 5.15 12/22] ALSA: hda: Fix possible null-ptr-deref when assigning a stream Sasha Levin
2023-11-07 15:51 ` [PATCH AUTOSEL 5.15 13/22] PCI: tegra194: Use FIELD_GET()/FIELD_PREP() with Link Width fields Sasha Levin
2023-11-07 15:51 ` [PATCH AUTOSEL 5.15 14/22] atm: iphase: Do PCI error checks on own line Sasha Levin
2023-11-07 15:51 ` [PATCH AUTOSEL 5.15 15/22] scsi: libfc: Fix potential NULL pointer dereference in fc_lport_ptp_setup() Sasha Levin
2023-11-07 15:51 ` [PATCH AUTOSEL 5.15 16/22] PCI: Use FIELD_GET() to extract Link Width Sasha Levin
2023-11-07 15:51 ` [PATCH AUTOSEL 5.15 17/22] PCI: Extract ATS disabling to a helper function Sasha Levin
2023-11-07 15:51 ` [PATCH AUTOSEL 5.15 18/22] PCI: Disable ATS for specific Intel IPU E2000 devices Sasha Levin
2023-11-07 15:51 ` [PATCH AUTOSEL 5.15 19/22] misc: pci_endpoint_test: Add Device ID for R-Car S4-8 PCIe controller Sasha Levin
2023-11-07 15:51 ` [PATCH AUTOSEL 5.15 20/22] PCI: Use FIELD_GET() in Sapphire RX 5600 XT Pulse quirk Sasha Levin
2023-11-07 15:51 ` [PATCH AUTOSEL 5.15 21/22] HID: Add quirk for Dell Pro Wireless Keyboard and Mouse KM5221W Sasha Levin
2023-11-07 15:51 ` [PATCH AUTOSEL 5.15 22/22] exfat: support handle zero-size directory Sasha Levin

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.