2023-07-11 13:01:10

by Amadeusz Sławiński

[permalink] [raw]
Subject: [PATCH 03/13] ALSA: hda: Add controller matching macros

Some HDA controllers require additional handling, so there are macros to
match them, however those are spread across multiple files. Add them all
in one place, so they can be reused.

Signed-off-by: Amadeusz Sławiński <[email protected]>
---
include/sound/hdaudio.h | 27 +++++++++++++++++++++++++++
1 file changed, 27 insertions(+)

diff --git a/include/sound/hdaudio.h b/include/sound/hdaudio.h
index 2ffdf58bd6d4..aacacca456d5 100644
--- a/include/sound/hdaudio.h
+++ b/include/sound/hdaudio.h
@@ -11,6 +11,7 @@
#include <linux/io.h>
#include <linux/io-64-nonatomic-lo-hi.h>
#include <linux/iopoll.h>
+#include <linux/pci.h>
#include <linux/pm_runtime.h>
#include <linux/timecounter.h>
#include <sound/core.h>
@@ -704,4 +705,30 @@ static inline unsigned int snd_array_index(struct snd_array *array, void *ptr)
for ((idx) = 0, (ptr) = (array)->list; (idx) < (array)->used; \
(ptr) = snd_array_elem(array, ++(idx)))

+/*
+ * Device matching
+ */
+
+#define HDA_CONTROLLER_IS_HSW(pci) (pci_match_id((struct pci_device_id []){ \
+ { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_HDA_HSW_0) }, \
+ { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_HDA_HSW_2) }, \
+ { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_HDA_HSW_3) }, \
+ { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_HDA_BDW) }, \
+ { } \
+ }, pci))
+
+#define HDA_CONTROLLER_IS_APL(pci) (pci_match_id((struct pci_device_id []){ \
+ { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_HDA_APL) }, \
+ { } \
+ }, pci))
+
+#define HDA_CONTROLLER_IN_GPU(pci) (HDA_CONTROLLER_IS_HSW(pci) || \
+ pci_match_id((struct pci_device_id []){ \
+ { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_HDA_DG1) }, \
+ { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_HDA_DG2_0) }, \
+ { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_HDA_DG2_1) }, \
+ { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_HDA_DG2_2) }, \
+ { } \
+ }, pci))
+
#endif /* __SOUND_HDAUDIO_H */
--
2.34.1



2023-07-11 14:18:49

by Andy Shevchenko

[permalink] [raw]
Subject: Re: [PATCH 03/13] ALSA: hda: Add controller matching macros

On Tue, Jul 11, 2023 at 02:57:16PM +0200, Amadeusz Sławiński wrote:
> Some HDA controllers require additional handling, so there are macros to
> match them, however those are spread across multiple files. Add them all
> in one place, so they can be reused.

FWIW,
Reviewed-by: Andy Shevchenko <[email protected]>

One nit-pick below.

> Signed-off-by: Amadeusz Sławiński <[email protected]>
> ---
> include/sound/hdaudio.h | 27 +++++++++++++++++++++++++++
> 1 file changed, 27 insertions(+)
>
> diff --git a/include/sound/hdaudio.h b/include/sound/hdaudio.h
> index 2ffdf58bd6d4..aacacca456d5 100644
> --- a/include/sound/hdaudio.h
> +++ b/include/sound/hdaudio.h
> @@ -11,6 +11,7 @@
> #include <linux/io.h>
> #include <linux/io-64-nonatomic-lo-hi.h>
> #include <linux/iopoll.h>
> +#include <linux/pci.h>
> #include <linux/pm_runtime.h>
> #include <linux/timecounter.h>
> #include <sound/core.h>
> @@ -704,4 +705,30 @@ static inline unsigned int snd_array_index(struct snd_array *array, void *ptr)
> for ((idx) = 0, (ptr) = (array)->list; (idx) < (array)->used; \
> (ptr) = snd_array_elem(array, ++(idx)))
>
> +/*
> + * Device matching
> + */
> +
> +#define HDA_CONTROLLER_IS_HSW(pci) (pci_match_id((struct pci_device_id []){ \
> + { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_HDA_HSW_0) }, \
> + { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_HDA_HSW_2) }, \
> + { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_HDA_HSW_3) }, \
> + { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_HDA_BDW) }, \
> + { } \
> + }, pci))
> +
> +#define HDA_CONTROLLER_IS_APL(pci) (pci_match_id((struct pci_device_id []){ \
> + { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_HDA_APL) }, \
> + { } \
> + }, pci))
> +
> +#define HDA_CONTROLLER_IN_GPU(pci) (HDA_CONTROLLER_IS_HSW(pci) || \
> + pci_match_id((struct pci_device_id []){ \

I think if you start with pci_match_id() and move HDA_CONTROLLER_IS_HSW() at
the end it will make this macro aligned with the rest, so easier to get them
all at once.

> + { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_HDA_DG1) }, \
> + { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_HDA_DG2_0) }, \
> + { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_HDA_DG2_1) }, \
> + { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_HDA_DG2_2) }, \
> + { } \
> + }, pci))

--
With Best Regards,
Andy Shevchenko



2023-07-12 11:28:18

by Amadeusz Sławiński

[permalink] [raw]
Subject: Re: [PATCH 03/13] ALSA: hda: Add controller matching macros

On 7/11/2023 3:36 PM, Andy Shevchenko wrote:
>> +#define HDA_CONTROLLER_IN_GPU(pci) (HDA_CONTROLLER_IS_HSW(pci) || \
>> + pci_match_id((struct pci_device_id []){ \
> I think if you start with pci_match_id() and move HDA_CONTROLLER_IS_HSW() at
> the end it will make this macro aligned with the rest, so easier to get them
> all at once.
>

Ack.