From: Takashi Iwai Subject: ALSA: Backport snd_pci_quirk*() extension Patch-mainline: References: bnc#511306 Backport the extension of snd_pci_quirk*() helper for updating the HD-audio stuff. To avoid the conflict, all renamed and localized into snd-hda-intel driver. Signed-off-by: Takashi Iwai --- sound/pci/hda/hda_codec.c | 15 +++++++++++++ sound/pci/hda/hda_codec.h | 51 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 66 insertions(+) --- a/sound/pci/hda/hda_codec.c +++ b/sound/pci/hda/hda_codec.c @@ -3432,3 +3432,18 @@ buf[j] = '\0'; /* necessary when j == 0 */ } +/* backported */ +const struct snd_pci_quirk * +snd_hda_quirk_lookup(struct pci_dev *pci, const struct snd_pci_quirk *list) +{ + const struct snd_pci_quirk *q; + + for (q = list; q->subvendor; q++) { + if (q->subvendor != pci->subsystem_vendor) + continue; + if (!q->subdevice || + (pci->subsystem_device & q->subdevice_mask) == q->subdevice) + return q; + } + return NULL; +} --- a/sound/pci/hda/hda_codec.h +++ b/sound/pci/hda/hda_codec.h @@ -26,6 +26,57 @@ #include #include + +/* + * quirk with mask; backported + */ + +/* PCI quirk list helper */ +struct snd_hda_quirk { + unsigned short subvendor; /* PCI subvendor ID */ + unsigned short subdevice; /* PCI subdevice ID */ + unsigned short subdevice_mask; /* bitmask to match */ + int value; /* value */ +#ifdef CONFIG_SND_DEBUG_VERBOSE + const char *name; /* name of the device (optional) */ +#endif +}; + +#define snd_pci_quirk snd_hda_quirk +#undef _SND_PCI_QUIRK_ID_MASK +#undef _SND_PCI_QUIRK_ID +#undef SND_PCI_QUIRK_ID +#undef SND_PCI_QUIRK +#undef SND_PCI_QUIRK_MASK +#undef SND_PCI_QUIRK_VENDOR + +#define _SND_PCI_QUIRK_ID_MASK(vend, mask, dev) \ + .subvendor = (vend), .subdevice = (dev), .subdevice_mask = (mask) +#define _SND_PCI_QUIRK_ID(vend, dev) \ + _SND_PCI_QUIRK_ID_MASK(vend, 0xffff, dev) +#define SND_PCI_QUIRK_ID(vend,dev) {_SND_PCI_QUIRK_ID(vend, dev)} +#ifdef CONFIG_SND_DEBUG_VERBOSE +#define SND_PCI_QUIRK(vend,dev,xname,val) \ + {_SND_PCI_QUIRK_ID(vend, dev), .value = (val), .name = (xname)} +#define SND_PCI_QUIRK_VENDOR(vend, xname, val) \ + {_SND_PCI_QUIRK_ID_MASK(vend, 0, 0), .value = (val), .name = (xname)} +#define SND_PCI_QUIRK_MASK(vend, mask, dev, xname, val) \ + {_SND_PCI_QUIRK_ID_MASK(vend, mask, dev), \ + .value = (val), .name = (xname)} +#else +#define SND_PCI_QUIRK(vend,dev,xname,val) \ + {_SND_PCI_QUIRK_ID(vend, dev), .value = (val)} +#define SND_PCI_QUIRK_MASK(vend, mask, dev, xname, val) \ + {_SND_PCI_QUIRK_ID_MASK(vend, mask, dev), .value = (val)} +#define SND_PCI_QUIRK_VENDOR(vend, xname, val) \ + {_SND_PCI_QUIRK_ID_MASK(vend, 0, 0), .value = (val)} +#endif + +const struct snd_pci_quirk * +snd_hda_quirk_lookup(struct pci_dev *pci, const struct snd_pci_quirk *list); + +#define snd_pci_quirk_lookup snd_hda_quirk_lookup + #if defined(CONFIG_PM) || defined(CONFIG_SND_HDA_POWER_SAVE) #define SND_HDA_NEEDS_RESUME /* resume control code is required */ #endif