]>
Commit | Line | Data |
---|---|---|
2cb7cef9 BS |
1 | From: Takashi Iwai <tiwai@suse.de> |
2 | Subject: ALSA: Backport snd_pci_quirk*() extension | |
3 | Patch-mainline: | |
4 | References: bnc#511306 | |
5 | ||
6 | Backport the extension of snd_pci_quirk*() helper for updating the | |
7 | HD-audio stuff. To avoid the conflict, all renamed and localized into | |
8 | snd-hda-intel driver. | |
9 | ||
10 | Signed-off-by: Takashi Iwai <tiwai@suse.de> | |
11 | ||
12 | --- | |
13 | sound/pci/hda/hda_codec.c | 15 +++++++++++++ | |
14 | sound/pci/hda/hda_codec.h | 51 ++++++++++++++++++++++++++++++++++++++++++++++ | |
15 | 2 files changed, 66 insertions(+) | |
16 | ||
17 | --- a/sound/pci/hda/hda_codec.c | |
18 | +++ b/sound/pci/hda/hda_codec.c | |
19 | @@ -3432,3 +3432,18 @@ | |
20 | buf[j] = '\0'; /* necessary when j == 0 */ | |
21 | } | |
22 | ||
23 | +/* backported */ | |
24 | +const struct snd_pci_quirk * | |
25 | +snd_hda_quirk_lookup(struct pci_dev *pci, const struct snd_pci_quirk *list) | |
26 | +{ | |
27 | + const struct snd_pci_quirk *q; | |
28 | + | |
29 | + for (q = list; q->subvendor; q++) { | |
30 | + if (q->subvendor != pci->subsystem_vendor) | |
31 | + continue; | |
32 | + if (!q->subdevice || | |
33 | + (pci->subsystem_device & q->subdevice_mask) == q->subdevice) | |
34 | + return q; | |
35 | + } | |
36 | + return NULL; | |
37 | +} | |
38 | --- a/sound/pci/hda/hda_codec.h | |
39 | +++ b/sound/pci/hda/hda_codec.h | |
40 | @@ -26,6 +26,57 @@ | |
41 | #include <sound/pcm.h> | |
42 | #include <sound/hwdep.h> | |
43 | ||
44 | + | |
45 | +/* | |
46 | + * quirk with mask; backported | |
47 | + */ | |
48 | + | |
49 | +/* PCI quirk list helper */ | |
50 | +struct snd_hda_quirk { | |
51 | + unsigned short subvendor; /* PCI subvendor ID */ | |
52 | + unsigned short subdevice; /* PCI subdevice ID */ | |
53 | + unsigned short subdevice_mask; /* bitmask to match */ | |
54 | + int value; /* value */ | |
55 | +#ifdef CONFIG_SND_DEBUG_VERBOSE | |
56 | + const char *name; /* name of the device (optional) */ | |
57 | +#endif | |
58 | +}; | |
59 | + | |
60 | +#define snd_pci_quirk snd_hda_quirk | |
61 | +#undef _SND_PCI_QUIRK_ID_MASK | |
62 | +#undef _SND_PCI_QUIRK_ID | |
63 | +#undef SND_PCI_QUIRK_ID | |
64 | +#undef SND_PCI_QUIRK | |
65 | +#undef SND_PCI_QUIRK_MASK | |
66 | +#undef SND_PCI_QUIRK_VENDOR | |
67 | + | |
68 | +#define _SND_PCI_QUIRK_ID_MASK(vend, mask, dev) \ | |
69 | + .subvendor = (vend), .subdevice = (dev), .subdevice_mask = (mask) | |
70 | +#define _SND_PCI_QUIRK_ID(vend, dev) \ | |
71 | + _SND_PCI_QUIRK_ID_MASK(vend, 0xffff, dev) | |
72 | +#define SND_PCI_QUIRK_ID(vend,dev) {_SND_PCI_QUIRK_ID(vend, dev)} | |
73 | +#ifdef CONFIG_SND_DEBUG_VERBOSE | |
74 | +#define SND_PCI_QUIRK(vend,dev,xname,val) \ | |
75 | + {_SND_PCI_QUIRK_ID(vend, dev), .value = (val), .name = (xname)} | |
76 | +#define SND_PCI_QUIRK_VENDOR(vend, xname, val) \ | |
77 | + {_SND_PCI_QUIRK_ID_MASK(vend, 0, 0), .value = (val), .name = (xname)} | |
78 | +#define SND_PCI_QUIRK_MASK(vend, mask, dev, xname, val) \ | |
79 | + {_SND_PCI_QUIRK_ID_MASK(vend, mask, dev), \ | |
80 | + .value = (val), .name = (xname)} | |
81 | +#else | |
82 | +#define SND_PCI_QUIRK(vend,dev,xname,val) \ | |
83 | + {_SND_PCI_QUIRK_ID(vend, dev), .value = (val)} | |
84 | +#define SND_PCI_QUIRK_MASK(vend, mask, dev, xname, val) \ | |
85 | + {_SND_PCI_QUIRK_ID_MASK(vend, mask, dev), .value = (val)} | |
86 | +#define SND_PCI_QUIRK_VENDOR(vend, xname, val) \ | |
87 | + {_SND_PCI_QUIRK_ID_MASK(vend, 0, 0), .value = (val)} | |
88 | +#endif | |
89 | + | |
90 | +const struct snd_pci_quirk * | |
91 | +snd_hda_quirk_lookup(struct pci_dev *pci, const struct snd_pci_quirk *list); | |
92 | + | |
93 | +#define snd_pci_quirk_lookup snd_hda_quirk_lookup | |
94 | + | |
95 | #if defined(CONFIG_PM) || defined(CONFIG_SND_HDA_POWER_SAVE) | |
96 | #define SND_HDA_NEEDS_RESUME /* resume control code is required */ | |
97 | #endif |