Skip to contentSkip to conversation

ALSA: hda: add Intel DSP configuration / probe code

PATCH Superseded Jaroslav Kysela 3 participants 8 messages Oct 6, 2019 – Oct 9, 2019

Subsystems (4)

v3 of 5 Superseded Latest is v5 →

lore
Share & tools
lore

Jaroslav Kysela

author maintainer
#0 lore raw

PATCH v3 1/1 ALSA: hda: add Intel DSP configuration / probe code

For distributions, we need one place where we can decide which driver will be activated for the auto-configation of the Intel's HDA hardware with DSP. Actually, we cover three drivers:

* Legacy HDA
* Intel SST
* Intel Sound Open Firmware (SOF)

All those drivers registers similar PCI IDs, so the first driver probed from the PCI stack can win. But... it is not guaranteed that the correct driver wins.

This commit changes Intel's NHLT ACPI module to a common DSP probe module for the Intel's hardware. All above sound drivers calls this code. The user can force another behaviour using the module parameter 'dsp_driver' located in the 'snd-intel-dspcfg' module.

This change allows to add specific dmi checks for the specific systems. The examples are taken from the pull request:

https://github.com/thesofproject/linux/pull/927

Tested on Lenovo Carbon X1 7th gen.

Cc Pierre-Louis Bossart <[email protected]>
Cc Cezary Rojewski <[email protected]>
---
 include/sound/intel-dsp-config.h |  34 +++++
 sound/hda/Kconfig                |  10 +-
 sound/hda/Makefile               |   7 +-
 sound/hda/intel-dsp-config.c     | 247 +++++++++++++++++++++++++++++++
 sound/hda/intel-nhlt.c           |   3 -
 sound/pci/hda/Kconfig            |  11 +-
 sound/pci/hda/hda_intel.c        |  48 ++----
 sound/soc/intel/Kconfig          |   2 +-
 sound/soc/intel/skylake/skl.c    |  19 +--
 sound/soc/sof/intel/Kconfig      |   2 +-
 sound/soc/sof/sof-pci-dev.c      |   6 +
 11 files changed, 321 insertions(+), 68 deletions(-)
 create mode 100644 include/sound/intel-dsp-config.h
 create mode 100644 sound/hda/intel-dsp-config.c
include/sound/intel-dsp-config.h new file +34 -0
new file mode 100644
index 000000000000..c36622bee3f8
@@ -0,0 +1,34 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+/*
+ *  intel-dsp-config.h - Intel DSP config
+ *
+ *  Copyright (c) 2019 Jaroslav Kysela <[email protected]>
+ */
+
+#ifndef __INTEL_DSP_CONFIG_H__
+#define __INTEL_DSP_CONFIG_H__
+
+struct pci_dev;
+
+enum {
+	SND_INTEL_DSP_DRIVER_ANY = 0,
+	SND_INTEL_DSP_DRIVER_LEGACY,
+	SND_INTEL_DSP_DRIVER_SST,
+	SND_INTEL_DSP_DRIVER_SOF,
+	SND_INTEL_DSP_DRIVER_LAST = SND_INTEL_DSP_DRIVER_SOF
+};
+
+#if IS_ENABLED(CONFIG_SND_INTEL_DSP_CONFIG)
+
+int snd_intel_dsp_driver_probe(struct pci_dev *pci);
+
+#else
+
+static inline int snd_intel_dsp_driver_probe(struct pci_dev *pci)
+{
+	return SND_INTEL_DSP_DRIVER_ANY;
+}
+
+#endif
+
+#endif
sound/hda/Kconfig +8 -2
index 3d33fc1757ba..b0c88fe040ee 100644
@@ -34,6 +34,12 @@ config SND_HDA_PREALLOC_SIZE
 	  via a proc file (/proc/asound/card*/pcm*/sub*/prealloc), too.
 
 config SND_INTEL_NHLT
-	tristate
+	bool
 	# this config should be selected only for Intel ACPI platforms.
-	# A fallback is provided so that the code compiles in all cases.
\ No newline at end of file
+	# A fallback is provided so that the code compiles in all cases.
+
+config SND_INTEL_DSP_CONFIG
+	tristate
+	select SND_INTEL_NHLT if ACPI
+	# this config should be selected only for Intel DSP platforms.
+	# A fallback is provided so that the code compiles in all cases.
sound/hda/Makefile +5 -2
index 8560f6ef1b19..c593253c9829 100644
@@ -14,5 +14,8 @@ obj-$(CONFIG_SND_HDA_CORE) += snd-hda-core.o
 #extended hda
 obj-$(CONFIG_SND_HDA_EXT_CORE) += ext/
 
-snd-intel-nhlt-objs := intel-nhlt.o
-obj-$(CONFIG_SND_INTEL_NHLT) += snd-intel-nhlt.o
+snd-intel-dspcfg-objs := intel-dsp-config.o
+ifneq ($(CONFIG_ACPI),)
+  snd-intel-dspcfg-objs += intel-nhlt.o
+endif
+obj-$(CONFIG_SND_INTEL_DSP_CONFIG) += snd-intel-dspcfg.o
sound/hda/intel-dsp-config.c new file +247 -0

247 lines not on this page · raw message

sound/hda/intel-nhlt.c +0 -3
index daede96f28ee..097ff6c10099 100644
@@ -102,6 +102,3 @@ int intel_nhlt_get_dmic_geo(struct device *dev, struct nhlt_acpi_table *nhlt)
 	return dmic_geo;
 }
 EXPORT_SYMBOL_GPL(intel_nhlt_get_dmic_geo);
-
-MODULE_LICENSE("GPL v2");
-MODULE_DESCRIPTION("Intel NHLT driver");
sound/pci/hda/Kconfig +1 -10
index dae47a45b2b8..bd48335d09d7 100644
@@ -12,7 +12,7 @@ config SND_HDA_INTEL
 	tristate "HD Audio PCI"
 	depends on SND_PCI
 	select SND_HDA
-	select SND_INTEL_NHLT if ACPI
+	select SND_INTEL_DSP_CONFIG
 	help
 	  Say Y here to include support for Intel "High Definition
 	  Audio" (Azalia) and its compatible devices.
@@ -23,15 +23,6 @@ config SND_HDA_INTEL
 	  To compile this driver as a module, choose M here: the module
 	  will be called snd-hda-intel.
 
-config SND_HDA_INTEL_DETECT_DMIC
-	bool "DMIC detection and probe abort"
-	depends on SND_HDA_INTEL
-	help
-	  Say Y to detect digital microphones on SKL+ devices. DMICs
-	  cannot be handled by the HDaudio legacy driver and are
-	  currently only supported by the SOF driver.
-	  If unsure say N.
-
 config SND_HDA_TEGRA
 	tristate "NVIDIA Tegra HD Audio"
 	depends on ARCH_TEGRA
sound/pci/hda/hda_intel.c +14 -34

84 lines not on this page · raw message

sound/soc/intel/Kconfig +1 -1
index 01c99750212a..9ad89d56092b 100644
@@ -215,7 +215,7 @@ config SND_SOC_INTEL_SKYLAKE_COMMON
 	select SND_SOC_INTEL_SST
 	select SND_SOC_HDAC_HDA if SND_SOC_INTEL_SKYLAKE_HDAUDIO_CODEC
 	select SND_SOC_ACPI_INTEL_MATCH
-	select SND_INTEL_NHLT if ACPI
+	select SND_INTEL_DSP_CONFIG
 	help
 	  If you have a Intel Skylake/Broxton/ApolloLake/KabyLake/
 	  GeminiLake or CannonLake platform with the DSP enabled in the BIOS
sound/soc/intel/skylake/skl.c +4 -15
index 141dbbf975ac..58ba3e9469ba 100644
@@ -27,6 +27,7 @@
 #include <sound/hda_i915.h>
 #include <sound/hda_codec.h>
 #include <sound/intel-nhlt.h>
+#include <sound/intel-dsp-config.h>
 #include "skl.h"
 #include "skl-sst-dsp.h"
 #include "skl-sst-ipc.h"
@@ -987,22 +988,10 @@ static int skl_probe(struct pci_dev *pci,
 
 	switch (skl_pci_binding) {
 	case SND_SKL_PCI_BIND_AUTO:
-		/*
-		 * detect DSP by checking class/subclass/prog-id information
-		 * class=04 subclass 03 prog-if 00: no DSP, use legacy driver
-		 * class=04 subclass 01 prog-if 00: DSP is present
-		 *   (and may be required e.g. for DMIC or SSP support)
-		 * class=04 subclass 03 prog-if 80: use DSP or legacy mode
-		 */
-		if (pci->class == 0x040300) {
-			dev_info(&pci->dev, "The DSP is not enabled on this platform, aborting probe\n");
+		err = snd_intel_dsp_driver_probe(pci);
+		if (err != SND_INTEL_DSP_DRIVER_ANY &&
+		    err != SND_INTEL_DSP_DRIVER_SST)
 			return -ENODEV;
-		}
-		if (pci->class != 0x040100 && pci->class != 0x040380) {
-			dev_err(&pci->dev, "Unknown PCI class/subclass/prog-if information (0x%06x) found, aborting probe\n", pci->class);
-			return -ENODEV;
-		}
-		dev_info(&pci->dev, "DSP detected with PCI class/subclass/prog-if info 0x%06x\n", pci->class);
 		break;
 	case SND_SKL_PCI_BIND_LEGACY:
 		dev_info(&pci->dev, "Module parameter forced binding with HDaudio legacy, aborting probe\n");
sound/soc/sof/intel/Kconfig +1 -1
index 479ba249e219..8a5d5c0f95f2 100644
@@ -286,7 +286,7 @@ config SND_SOC_SOF_HDA
 	tristate
 	select SND_HDA_EXT_CORE if SND_SOC_SOF_HDA_LINK
 	select SND_SOC_HDAC_HDA if SND_SOC_SOF_HDA_AUDIO_CODEC
-	select SND_INTEL_NHLT if ACPI
+	select SND_INTEL_DSP_CONFIG
 	help
 	  This option is not user-selectable but automagically handled by
 	  'select' statements at a higher level
sound/soc/sof/sof-pci-dev.c +6 -0
index d66412a77873..3a9e0e2a150d 100644
@@ -12,6 +12,7 @@
 #include <linux/module.h>
 #include <linux/pci.h>
 #include <linux/pm_runtime.h>
+#include <sound/intel-dsp-config.h>
 #include <sound/soc-acpi.h>
 #include <sound/soc-acpi-intel-match.h>
 #include <sound/sof.h>
@@ -277,6 +278,11 @@ static int sof_pci_probe(struct pci_dev *pci,
 	const struct snd_sof_dsp_ops *ops;
 	int ret;
 
+	ret = snd_intel_dsp_driver_probe(pci);
+	if (ret != SND_INTEL_DSP_DRIVER_ANY &&
+	    ret != SND_INTEL_DSP_DRIVER_SOF)
+		return -ENODEV;
+
 	dev_dbg(&pci->dev, "PCI DSP detected");
 
 	/* get ops for platform */
Signature · 5 lines
2.20.1
_______________________________________________
Alsa-devel mailing list
[email protected]
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel
#1 lore raw
Quoted 22 lines · Jaroslav Kysela

For distributions, we need one place where we can decide which driver will be activated for the auto-configation of the Intel's HDA hardware with DSP. Actually, we cover three drivers:

* Legacy HDA
* Intel SST
* Intel Sound Open Firmware (SOF)

All those drivers registers similar PCI IDs, so the first driver probed from the PCI stack can win. But... it is not guaranteed that the correct driver wins.

This commit changes Intel's NHLT ACPI module to a common DSP probe module for the Intel's hardware. All above sound drivers calls this code. The user can force another behaviour using the module parameter 'dsp_driver' located in the 'snd-intel-dspcfg' module.

This change allows to add specific dmi checks for the specific systems. The examples are taken from the pull request:

Quoted 7 lines

https://github.com/thesofproject/linux/pull/927

Tested on Lenovo Carbon X1 7th gen.

Cc Pierre-Louis Bossart <[email protected]>
Cc Cezary Rojewski <[email protected]>

Since I've been still traveling, just a few nitpicking:

sound/hda/Makefile obj-$(CONFIG_SND_HDA_CORE) += snd-hda-core.o · line 20

Quoted 12 lines
sound/hda/Makefile +4 -2
@@ -14,5 +14,8 @@ obj-$(CONFIG_SND_HDA_CORE) += snd-hda-core.o
 #extended hda
 obj-$(CONFIG_SND_HDA_EXT_CORE) += ext/
 
-snd-intel-nhlt-objs := intel-nhlt.o
-obj-$(CONFIG_SND_INTEL_NHLT) += snd-intel-nhlt.o
+snd-intel-dspcfg-objs := intel-dsp-config.o
+ifneq ($(CONFIG_ACPI),)
+  snd-intel-dspcfg-objs += intel-nhlt.o
+endif

This can be simplified by
snd-intel-dspcfg-$(CONFIG_SND_INTEL_NHLT) += intel-nhlt.o

sound/hda/intel-dsp-config.c line 9

Quoted 12 lines
sound/hda/intel-dsp-config.c new file +9 -0
@@ -0,0 +1,247 @@
+// SPDX-License-Identifier: GPL-2.0
+// Copyright (c) 2019 Jaroslav Kysela <[email protected]>
+
+#include <sound/core.h>
+#include <linux/module.h>
+#include <linux/pci.h>
+#include <linux/dmi.h>
+#include <sound/intel-nhlt.h>
+#include <sound/intel-dsp-config.h>

Please put sound/core.h after linux/*.h inclusions.
Also in general the inclusions are arranged in the alphabetical order nowadays.

Quoted 14 lines
sound/hda/intel-dsp-config.c new file +14 -0
+int snd_intel_dsp_driver_probe(struct pci_dev *pci)
+{
+	const struct config_entry *cfg;
+
+	if (dsp_driver > 0 && dsp_driver <= SND_INTEL_DSP_DRIVER_LAST)
+		return dsp_driver;
+
+	/* Intel vendor only */
+	if (snd_BUG_ON(pci->vendor != 0x8086))
+		return SND_INTEL_DSP_DRIVER_ANY;
+
+	/*
+	 * detect DSP by checking class/subclass/prog-id information
+	 * class=04 subclass 03 prog-if 00: no DSP, use legacy driver

sound/hda/intel-dsp-config.c line 218

Quoted 10 lines
sound/hda/intel-dsp-config.c new file +10 -0
+	 * class=04 subclass 01 prog-if 00: DSP is present
+	 *  (and may be required e.g. for DMIC or SSP support)
+	 * class=04 subclass 03 prog-if 80: use DSP or legacy mode
+	 */
+	if (pci->class == 0x040300)
+		return SND_INTEL_DSP_DRIVER_LEGACY;
+	if (pci->class != 0x040100 && pci->class != 0x040380) {
+		dev_err(&pci->dev, "Unknown PCI class/subclass/prog-if information (0x%06x) found, selecting HDA legacy driver\n", pci->class);
+		return SND_INTEL_DSP_DRIVER_LEGACY;
+	}

If we treat this as an error, we should provide a code to work around this (e.g. quirk entry or such), so that the error can be avoided later. Or, just make it dev_info() for now so that it won't appear in the splash screen.

Quoted 2 lines
sound/pci/hda/hda_intel.c +0 -0

....

Quoted 10 lines
sound/pci/hda/hda_intel.c +1 -1
@@ -124,7 +124,7 @@ static char *patch[SNDRV_CARDS];
 static bool beep_mode[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS-1)] =
 					CONFIG_SND_HDA_INPUT_BEEP_MODE};
 #endif
-static bool dmic_detect = IS_ENABLED(CONFIG_SND_HDA_INTEL_DETECT_DMIC);
+static bool no_dsp_driver;
 
 module_param_array(index, int, NULL, 0444);
 MODULE_PARM_DESC(index, "Index value for Intel HD audio interface.");

sound/pci/hda/hda_intel.c module_param_array(beep_mode, bool, NULL, 0444); · line 163

Quoted 7 lines
sound/pci/hda/hda_intel.c +2 -2
@@ -159,8 +159,8 @@ module_param_array(beep_mode, bool, NULL, 0444);
 MODULE_PARM_DESC(beep_mode, "Select HDA Beep registration mode "
 			    "(0=off, 1=on) (default=1).");
 #endif
-module_param(dmic_detect, bool, 0444);
-MODULE_PARM_DESC(dmic_detect, "DMIC detect on SKL+ platforms");
+module_param(no_dsp_driver, bool, 0444);
+MODULE_PARM_DESC(no_dsp_driver, "Force this driver to be used and bypass the DSP driver selection");

A negative option is often confusing, e.g. you may pass like no_dsp_driver=no. Better to use a positive form if possible.

I'll be still off until the Thursday in the next week, so the further reply may be delayed.

thanks,

Takashi
_______________________________________________
Alsa-devel mailing list
[email protected]
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel

author maintainer
#2 lore raw

Dne 07. 10. 19 v 3:50 Takashi Iwai napsal(a):

Quoted 40 lines
Quoted 22 lines · Jaroslav Kysela

For distributions, we need one place where we can decide which driver will be activated for the auto-configation of the Intel's HDA hardware with DSP. Actually, we cover three drivers:

* Legacy HDA
* Intel SST
* Intel Sound Open Firmware (SOF)

All those drivers registers similar PCI IDs, so the first driver probed from the PCI stack can win. But... it is not guaranteed that the correct driver wins.

This commit changes Intel's NHLT ACPI module to a common DSP probe module for the Intel's hardware. All above sound drivers calls this code. The user can force another behaviour using the module parameter 'dsp_driver' located in the 'snd-intel-dspcfg' module.

This change allows to add specific dmi checks for the specific systems. The examples are taken from the pull request:

Quoted 7 lines

https://github.com/thesofproject/linux/pull/927

Tested on Lenovo Carbon X1 7th gen.

Cc Pierre-Louis Bossart <[email protected]>
Cc Cezary Rojewski <[email protected]>

Since I've been still traveling, just a few nitpicking:

Quoted 6 lines
sound/hda/Makefile +0 -0
@@ -14,5 +14,8 @@ obj-$(CONFIG_SND_HDA_CORE) += snd-hda-core.o
 #extended hda
 obj-$(CONFIG_SND_HDA_EXT_CORE) += ext/
 
Quoted 9 lines

sound/hda/Makefile obj-$(CONFIG_SND_HDA_CORE) += snd-hda-core.o · line 20

Quoted 6 lines
sound/hda/Makefile +4 -2
-snd-intel-nhlt-objs := intel-nhlt.o
-obj-$(CONFIG_SND_INTEL_NHLT) += snd-intel-nhlt.o
+snd-intel-dspcfg-objs := intel-dsp-config.o
+ifneq ($(CONFIG_ACPI),)
+  snd-intel-dspcfg-objs += intel-nhlt.o
+endif

This can be simplified by
snd-intel-dspcfg-$(CONFIG_SND_INTEL_NHLT) += intel-nhlt.o

Yes, I added the ACPI condition later and didn't return back to Makefile. Fixed in v4 (will post after comments from Pierre-Louis).

Quoted 8 lines
Quoted 8 lines
sound/hda/intel-dsp-config.c new file +5 -0
@@ -0,0 +1,247 @@
+// SPDX-License-Identifier: GPL-2.0
+// Copyright (c) 2019 Jaroslav Kysela <[email protected]>
+
+#include <sound/core.h>
+#include <linux/module.h>
Quoted 8 lines

sound/hda/intel-dsp-config.c line 9

Quoted 4 lines
sound/hda/intel-dsp-config.c new file +4 -0
+#include <linux/pci.h>
+#include <linux/dmi.h>
+#include <sound/intel-nhlt.h>
+#include <sound/intel-dsp-config.h>

Please put sound/core.h after linux/*.h inclusions.
Also in general the inclusions are arranged in the alphabetical order nowadays.

Uff. Rules and rules for rules. Will fix that in v4.

Quoted 20 lines
Quoted 20 lines
sound/hda/intel-dsp-config.c new file +20 -0
+int snd_intel_dsp_driver_probe(struct pci_dev *pci)
+{
+	const struct config_entry *cfg;
+
+	if (dsp_driver > 0 && dsp_driver <= SND_INTEL_DSP_DRIVER_LAST)
+		return dsp_driver;
+
+	/* Intel vendor only */
+	if (snd_BUG_ON(pci->vendor != 0x8086))
+		return SND_INTEL_DSP_DRIVER_ANY;
+
+	/*
+	 * detect DSP by checking class/subclass/prog-id information
+	 * class=04 subclass 03 prog-if 00: no DSP, use legacy driver
+	 * class=04 subclass 01 prog-if 00: DSP is present
+	 *  (and may be required e.g. for DMIC or SSP support)
+	 * class=04 subclass 03 prog-if 80: use DSP or legacy mode
+	 */
+	if (pci->class == 0x040300)
+		return SND_INTEL_DSP_DRIVER_LEGACY;
Quoted 8 lines

sound/hda/intel-dsp-config.c line 218

Quoted 4 lines
sound/hda/intel-dsp-config.c new file +4 -0
+	if (pci->class != 0x040100 && pci->class != 0x040380) {
+		dev_err(&pci->dev, "Unknown PCI class/subclass/prog-if information (0x%06x) found, selecting HDA legacy driver\n", pci->class);
+		return SND_INTEL_DSP_DRIVER_LEGACY;
+	}

If we treat this as an error, we should provide a code to work around this (e.g. quirk entry or such), so that the error can be avoided later.

It' s really an error. This path should not be executed with the known, functional hardware. The user might use dsp_driver module parameter to change the behaviour.

Quoted 11 lines
Quoted 3 lines
sound/pci/hda/hda_intel.c +0 -0

....

Quoted 7 lines
sound/pci/hda/hda_intel.c +1 -1
@@ -124,7 +124,7 @@ static char *patch[SNDRV_CARDS];
 static bool beep_mode[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS-1)] =
 					CONFIG_SND_HDA_INPUT_BEEP_MODE};
 #endif
-static bool dmic_detect = IS_ENABLED(CONFIG_SND_HDA_INTEL_DETECT_DMIC);
+static bool no_dsp_driver;
 
Quoted 13 lines

sound/pci/hda/hda_intel.c module_param_array(beep_mode, bool, NULL, 0444); · line 163

Quoted 10 lines
sound/pci/hda/hda_intel.c +2 -2
 module_param_array(index, int, NULL, 0444);
 MODULE_PARM_DESC(index, "Index value for Intel HD audio interface.");
@@ -159,8 +159,8 @@ module_param_array(beep_mode, bool, NULL, 0444);
 MODULE_PARM_DESC(beep_mode, "Select HDA Beep registration mode "
 			    "(0=off, 1=on) (default=1).");
 #endif
-module_param(dmic_detect, bool, 0444);
-MODULE_PARM_DESC(dmic_detect, "DMIC detect on SKL+ platforms");
+module_param(no_dsp_driver, bool, 0444);
+MODULE_PARM_DESC(no_dsp_driver, "Force this driver to be used and bypass the DSP driver selection");

A negative option is often confusing, e.g. you may pass like no_dsp_driver=no. Better to use a positive form if possible.

I just tried to copy the dmic_detect value, but yes, it might be confusion. I will change that in v4.

Jaroslav

Signature · 6 lines
Jaroslav Kysela <[email protected]>
Linux Sound Maintainer; ALSA Project; Red Hat, Inc.
_______________________________________________
Alsa-devel mailing list
[email protected]
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel
#3 lore raw
In reply to Jaroslav Kysela
Quoted 18 lines · Jaroslav Kysela

For distributions, we need one place where we can decide which driver will be activated for the auto-configation of the Intel's HDA hardware with DSP. Actually, we cover three drivers:

* Legacy HDA
* Intel SST
* Intel Sound Open Firmware (SOF)

All those drivers registers similar PCI IDs, so the first driver probed from the PCI stack can win. But... it is not guaranteed that the correct driver wins.

This commit changes Intel's NHLT ACPI module to a common DSP probe module for the Intel's hardware. All above sound drivers calls this code. The user can force another behaviour using the module parameter 'dsp_driver' located in the 'snd-intel-dspcfg' module.

Quoted 6 lines

This change allows to add specific dmi checks for the specific systems. The examples are taken from the pull request:

https://github.com/thesofproject/linux/pull/927

Tested on Lenovo Carbon X1 7th gen.

Thanks Jaroslav, I like the ideas in the patch, the flags+DMI table is quite elegant.

We will need to do additional checks for the quirks, e.g. I know there is a 'Phaser' Chromebook with HDaudio and I don't recall if they use DMICs. I also don't know if we always have the NHTL information when the legacy BIOS is used.

It's likely that we will have multiple iterations before getting this right. And we'll have to add SoundWire support as well (which isn't that hard, I already have all the ACPI parsing needed to detect if a link is enabled).

Some additional comments below.

Quoted 5 lines
sound/hda/intel-dsp-config.c new file +5 -0
+module_param(dsp_driver, int, 0444);
+MODULE_PARM_DESC(dsp_driver, "Force the DSP driver for Intel DSP (0=auto, 1=legacy, 2=SST, 3=SOF)");
+
+#define FLAG_SST		(1<<0)
+#define FLAG_SOF		(1<<1)

sound/hda/intel-dsp-config.c line 27

Quoted 10 lines
sound/hda/intel-dsp-config.c new file +10 -0
+#define FLAG_SOF_ONLY_IF_DMIC	(1<<16)
+
+struct config_entry {
+	u32 flags;
+	u16 device;
+	const struct dmi_system_id *dmi_table;
+};
+
+/*
+ * configuration table - the order of entries is important!

It's not really the order but the exclusion between SST and SOF for the same PCI ID?

sound/hda/intel-dsp-config.c line 39

Quoted 12 lines

+ */

sound/hda/intel-dsp-config.c new file +11 -0
+static const struct config_entry config_table[] = {
+/* Cometlake-LP */
+#if IS_ENABLED(CONFIG_SND_SOC_INTEL_CML_LP)
+	{
+		/* prefer SST */
+		.flags = FLAG_SST,
+		.device = 0x02c8,
+	},
+#elif IS_ENABLED(CONFIG_SND_SOC_SOF_COMETLAKE_LP)
+	{
+		.flags = FLAG_SOF,

need to add FLAG_SOF_ONLY_IF_DMIC

sound/hda/intel-dsp-config.c line 51

Quoted 12 lines
sound/hda/intel-dsp-config.c new file +12 -0
+		.device = 0x02c8,
+	},
+#endif
+/* Cometlake-H */
+#if IS_ENABLED(CONFIG_SND_SOC_INTEL_CML_H)
+	{
+		.flags = FLAG_SST,
+		.device = 0x06c8,
+	},
+#elif IS_ENABLED(CONFIG_SND_SOC_SOF_COMETLAKE_H)
+	{
+		.flags = FLAG_SOF,

| FLAG_SOF_ONLY_IF_DMIC

Quoted 11 lines
sound/hda/intel-dsp-config.c new file +11 -0
+		.device = 0x06c8,
+	},
+#endif
+/* Merrifield */
+#if IS_ENABLED(CONFIG_SND_SOC_SOF_MERRIFIELD)
+	{
+		.flags = FLAG_SOF,
+		.device = 0x119a,
+	},
+#endif
+/* Broxton-T */

sound/hda/intel-dsp-config.c line 72

Quoted 10 lines
sound/hda/intel-dsp-config.c new file +10 -0
+#if IS_ENABLED(CONFIG_SND_SOC_SOF_APOLLOLAKE)
+	{
+		.flags = FLAG_SOF | FLAG_SOF_ONLY_IF_DMIC,
+		.device = 0x1a98,
+	},
+#endif
+/* Geminilake */
+#if IS_ENABLED(CONFIG_SND_SOC_SOF_GEMINILAKE)
+	{
+		.flags = FLAG_SOF,

can we have more than one table per PCI ID? e.g. in this case it'd be good to have the DMIC case separate from Google.

sound/hda/intel-dsp-config.c line 85

Quoted 13 lines
sound/hda/intel-dsp-config.c new file +13 -0
+		.device = 0x3198,
+		.dmi_table = (const struct dmi_system_id []) {
+			{
+				.ident = "Google Chromebooks",
+				.matches = {
+					DMI_MATCH(DMI_SYS_VENDOR, "Google"),
+				}
+			},
+			{}
+		}
+	},
+#endif
+#if IS_ENABLED(CONFIG_SND_SOC_INTEL_GLK)

should it be elif, as done for CometLake/CML?

Quoted 27 lines
sound/hda/intel-dsp-config.c new file +27 -0
+	{
+		.flags = FLAG_SST,
+		.device = 0x3198,
+	},
+#endif
+/* Icelake */
+#if IS_ENABLED(CONFIG_SND_SOC_SOF_ICELAKE)
+	{
+		.flags = FLAG_SOF | FLAG_SOF_ONLY_IF_DMIC,
+		.device = 0x34c8,
+	},
+#endif
+/* Elkhart Lake */
+#if IS_ENABLED(CONFIG_SND_SOC_SOF_ELKHARTLAKE)
+	{
+		.flags = FLAG_SOF | FLAG_SOF_ONLY_IF_DMIC,
+		.device = 0x4b55,
+	},
+#endif
+/* Appololake (Broxton-P) */
+#if IS_ENABLED(CONFIG_SND_SOC_SOF_APOLLOLAKE)
+	{
+		.flags = FLAG_SOF,
+		.device = 0x5a98,
+		.dmi_table = (const struct dmi_system_id []) {
+			{
+				.ident = "Up Squared",

sound/hda/intel-dsp-config.c line 122

Quoted 10 lines
sound/hda/intel-dsp-config.c new file +10 -0
+				.matches = {
+					DMI_MATCH(DMI_SYS_VENDOR, "AAEON"),
+					DMI_MATCH(DMI_BOARD_NAME, "UP-APL01"),
+				}
+			},
+			{}
+		}
+	},
+#endif
+#if IS_ENABLED(CONFIG_SND_SOC_INTEL_APL)

elif?

Quoted 16 lines
sound/hda/intel-dsp-config.c new file +16 -0
+	{
+		.flags = FLAG_SST,
+		.device = 0x5a98,
+	},
+#endif
+/* Cannonlake */
+#if IS_ENABLED(CONFIG_SND_SOC_SOF_CANNONLAKE)
+	{
+		.flags = FLAG_SOF | FLAG_SOF_ONLY_IF_DMIC,
+		.device = 0x9dc8,
+	},
+#endif
+/* Sunrise Point-LP */
+#if IS_ENABLED(CONFIG_SND_SOC_SOF_SKYLAKE)
+	{
+		.flags = FLAG_SOF | FLAG_SOF_ONLY_IF_DMIC,

sound/hda/intel-dsp-config.c line 148

Quoted 10 lines
sound/hda/intel-dsp-config.c new file +10 -0
+		.device = 0x9d70,
+	},
+#endif
+/* Kabylake-LP */
+#if IS_ENABLED(CONFIG_SND_SOC_SOF_KABYLAKE)
+	{
+		.flags = FLAG_SOF | FLAG_SOF_ONLY_IF_DMIC,
+		.device = 0x9d71,
+	},
+#endif

SKL and SKL are not supported by SOF for now, and SST doesn't support HDaudio+DMIC combinations

This should be FLAG_SST but only for Google Chromebooks, e.g.

		.flags = FLAG_SST,
		.device = 0x9d70 or 0x9d71
		.dmi_table = (const struct dmi_system_id []) {
			{
				.ident = "Google Chromebooks",
				.matches = {
					DMI_MATCH(DMI_SYS_VENDOR, "Google"),
				}
			},
			{}
		}
	},

_______________________________________________
Alsa-devel mailing list
[email protected]
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel

author maintainer
#4 lore raw

Dne 07. 10. 19 v 16:05 Pierre-Louis Bossart napsal(a):

Quoted 53 lines · Jaroslav Kysela
Quoted 18 lines

For distributions, we need one place where we can decide which driver will be activated for the auto-configation of the Intel's HDA hardware with DSP. Actually, we cover three drivers:

* Legacy HDA
* Intel SST
* Intel Sound Open Firmware (SOF)

All those drivers registers similar PCI IDs, so the first driver probed from the PCI stack can win. But... it is not guaranteed that the correct driver wins.

This commit changes Intel's NHLT ACPI module to a common DSP probe module for the Intel's hardware. All above sound drivers calls this code. The user can force another behaviour using the module parameter 'dsp_driver' located in the 'snd-intel-dspcfg' module.

Quoted 6 lines

This change allows to add specific dmi checks for the specific systems. The examples are taken from the pull request:

https://github.com/thesofproject/linux/pull/927

Tested on Lenovo Carbon X1 7th gen.

Thanks Jaroslav, I like the ideas in the patch, the flags+DMI table is quite elegant.

We will need to do additional checks for the quirks, e.g. I know there is a 'Phaser' Chromebook with HDaudio and I don't recall if they use DMICs. I also don't know if we always have the NHTL information when the legacy BIOS is used.

It's likely that we will have multiple iterations before getting this right. And we'll have to add SoundWire support as well (which isn't that hard, I already have all the ACPI parsing needed to detect if a link is enabled).

Some additional comments below.

Quoted 10 lines
sound/hda/intel-dsp-config.c new file +10 -0
+module_param(dsp_driver, int, 0444);
+MODULE_PARM_DESC(dsp_driver, "Force the DSP driver for Intel DSP (0=auto, 1=legacy, 2=SST, 3=SOF)");
+
+#define FLAG_SST		(1<<0)
+#define FLAG_SOF		(1<<1)
+#define FLAG_SOF_ONLY_IF_DMIC	(1<<16)
+
+struct config_entry {
+	u32 flags;
+	u16 device;
Quoted 8 lines

sound/hda/intel-dsp-config.c line 27

Quoted 5 lines
sound/hda/intel-dsp-config.c new file +5 -0
+	const struct dmi_system_id *dmi_table;
+};
+
+/*
+ * configuration table - the order of entries is important!

It's not really the order but the exclusion between SST and SOF for the same PCI ID?

Yes, I'll rephrase this as:

* configuration table
* - the order of similar PCI ID entries is important!
* - the first successful match will win

Quoted 6 lines
Quoted 6 lines

+ */

sound/hda/intel-dsp-config.c new file +5 -0
+static const struct config_entry config_table[] = {
+/* Cometlake-LP */
+#if IS_ENABLED(CONFIG_SND_SOC_INTEL_CML_LP)
+	{
+		/* prefer SST */
Quoted 8 lines

sound/hda/intel-dsp-config.c line 39

Quoted 6 lines
sound/hda/intel-dsp-config.c new file +6 -0
+		.flags = FLAG_SST,
+		.device = 0x02c8,
+	},
+#elif IS_ENABLED(CONFIG_SND_SOC_SOF_COMETLAKE_LP)
+	{
+		.flags = FLAG_SOF,

need to add FLAG_SOF_ONLY_IF_DMIC

Aaghrr. We have 0x02C8 not 0x02c8 in hda_intel.c so I didn't found them using the case-sensitive grep. I will fix that.

Quoted 31 lines

sound/hda/intel-dsp-config.c line 51

Quoted 12 lines
sound/hda/intel-dsp-config.c new file +12 -0
+		.device = 0x02c8,
+	},
+#endif
+/* Cometlake-H */
+#if IS_ENABLED(CONFIG_SND_SOC_INTEL_CML_H)
+	{
+		.flags = FLAG_SST,
+		.device = 0x06c8,
+	},
+#elif IS_ENABLED(CONFIG_SND_SOC_SOF_COMETLAKE_H)
+	{
+		.flags = FLAG_SOF,

| FLAG_SOF_ONLY_IF_DMIC

Quoted 16 lines
sound/hda/intel-dsp-config.c new file +16 -0
+		.device = 0x06c8,
+	},
+#endif
+/* Merrifield */
+#if IS_ENABLED(CONFIG_SND_SOC_SOF_MERRIFIELD)
+	{
+		.flags = FLAG_SOF,
+		.device = 0x119a,
+	},
+#endif
+/* Broxton-T */
+#if IS_ENABLED(CONFIG_SND_SOC_SOF_APOLLOLAKE)
+	{
+		.flags = FLAG_SOF | FLAG_SOF_ONLY_IF_DMIC,
+		.device = 0x1a98,
+	},
Quoted 8 lines

sound/hda/intel-dsp-config.c line 72

Quoted 5 lines
sound/hda/intel-dsp-config.c new file +5 -0
+#endif
+/* Geminilake */
+#if IS_ENABLED(CONFIG_SND_SOC_SOF_GEMINILAKE)
+	{
+		.flags = FLAG_SOF,

can we have more than one table per PCI ID? e.g. in this case it'd be good to have the DMIC case separate from Google.

Yes, first match wins. So we need to add flags = FLAG_SOF | FLAG_SOF_ONLY_IF_DMIC entry bellow the dmi exceptions for device == 0x3198, too?

Quoted 16 lines
Quoted 4 lines
sound/hda/intel-dsp-config.c new file +3 -0
+		.device = 0x3198,
+		.dmi_table = (const struct dmi_system_id []) {
+			{

sound/hda/intel-dsp-config.c line 85

Quoted 10 lines
sound/hda/intel-dsp-config.c new file +10 -0
+				.ident = "Google Chromebooks",
+				.matches = {
+					DMI_MATCH(DMI_SYS_VENDOR, "Google"),
+				}
+			},
+			{}
+		}
+	},
+#endif
+#if IS_ENABLED(CONFIG_SND_SOC_INTEL_GLK)

should it be elif, as done for CometLake/CML?

I though that the SST driver is the default for 0x3198. Or the legacy driver is in the game, too? If yes, we need to add conditional SST entries.

Quoted 31 lines
Quoted 31 lines
sound/hda/intel-dsp-config.c new file +31 -0
+	{
+		.flags = FLAG_SST,
+		.device = 0x3198,
+	},
+#endif
+/* Icelake */
+#if IS_ENABLED(CONFIG_SND_SOC_SOF_ICELAKE)
+	{
+		.flags = FLAG_SOF | FLAG_SOF_ONLY_IF_DMIC,
+		.device = 0x34c8,
+	},
+#endif
+/* Elkhart Lake */
+#if IS_ENABLED(CONFIG_SND_SOC_SOF_ELKHARTLAKE)
+	{
+		.flags = FLAG_SOF | FLAG_SOF_ONLY_IF_DMIC,
+		.device = 0x4b55,
+	},
+#endif
+/* Appololake (Broxton-P) */
+#if IS_ENABLED(CONFIG_SND_SOC_SOF_APOLLOLAKE)
+	{
+		.flags = FLAG_SOF,
+		.device = 0x5a98,
+		.dmi_table = (const struct dmi_system_id []) {
+			{
+				.ident = "Up Squared",
+				.matches = {
+					DMI_MATCH(DMI_SYS_VENDOR, "AAEON"),
+					DMI_MATCH(DMI_BOARD_NAME, "UP-APL01"),
+				}
Quoted 8 lines

sound/hda/intel-dsp-config.c line 122

Quoted 6 lines
sound/hda/intel-dsp-config.c new file +6 -0
+			},
+			{}
+		}
+	},
+#endif
+#if IS_ENABLED(CONFIG_SND_SOC_INTEL_APL)

elif?

Same. What's the default driver for APL?

Quoted 34 lines
Quoted 17 lines
sound/hda/intel-dsp-config.c new file +16 -0
+	{
+		.flags = FLAG_SST,
+		.device = 0x5a98,
+	},
+#endif
+/* Cannonlake */
+#if IS_ENABLED(CONFIG_SND_SOC_SOF_CANNONLAKE)
+	{
+		.flags = FLAG_SOF | FLAG_SOF_ONLY_IF_DMIC,
+		.device = 0x9dc8,
+	},
+#endif
+/* Sunrise Point-LP */
+#if IS_ENABLED(CONFIG_SND_SOC_SOF_SKYLAKE)
+	{
+		.flags = FLAG_SOF | FLAG_SOF_ONLY_IF_DMIC,

sound/hda/intel-dsp-config.c line 148

Quoted 10 lines
sound/hda/intel-dsp-config.c new file +10 -0
+		.device = 0x9d70,
+	},
+#endif
+/* Kabylake-LP */
+#if IS_ENABLED(CONFIG_SND_SOC_SOF_KABYLAKE)
+	{
+		.flags = FLAG_SOF | FLAG_SOF_ONLY_IF_DMIC,
+		.device = 0x9d71,
+	},
+#endif

SKL and SKL are not supported by SOF for now, and SST doesn't support HDaudio+DMIC combinations

This should be FLAG_SST but only for Google Chromebooks, e.g.

Quoted 13 lines
		.flags = FLAG_SST,
		.device = 0x9d70 or 0x9d71
		.dmi_table = (const struct dmi_system_id []) {
			{
				.ident = "Google Chromebooks",
				.matches = {
					DMI_MATCH(DMI_SYS_VENDOR, "Google"),
				}
			},
			{}
		}
	},

Added. Will be in v4. Thanks for all of the input.

Jaroslav

Signature · 6 lines
Jaroslav Kysela <[email protected]>
Linux Sound Maintainer; ALSA Project; Red Hat, Inc.
_______________________________________________
Alsa-devel mailing list
[email protected]
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel
#5 lore raw
Quoted 10 lines
Quoted 7 lines

sound/hda/intel-dsp-config.c line 72

Quoted 4 lines
sound/hda/intel-dsp-config.c new file +3 -0
+#if IS_ENABLED(CONFIG_SND_SOC_SOF_GEMINILAKE)
+	{
+		.flags = FLAG_SOF,

can we have more than one table per PCI ID? e.g. in this case it'd be good to have the DMIC case separate from Google.

Yes, first match wins. So we need to add flags = FLAG_SOF | FLAG_SOF_ONLY_IF_DMIC entry bellow the dmi exceptions for device == 0x3198, too?

I need to check this, I am not sure if the firmware (Coreboot or Legacy) includes the NHLT definitions.

Quoted 18 lines
Quoted 17 lines
Quoted 5 lines
sound/hda/intel-dsp-config.c new file +3 -0
+		.device = 0x3198,
+		.dmi_table = (const struct dmi_system_id []) {
+			{

sound/hda/intel-dsp-config.c line 85

Quoted 10 lines
sound/hda/intel-dsp-config.c new file +10 -0
+				.ident = "Google Chromebooks",
+				.matches = {
+					DMI_MATCH(DMI_SYS_VENDOR, "Google"),
+				}
+			},
+			{}
+		}
+	},
+#endif
+#if IS_ENABLED(CONFIG_SND_SOC_INTEL_GLK)

should it be elif, as done for CometLake/CML?

Quoted 2 lines

I though that the SST driver is the default for 0x3198. Or the legacy driver is in the game, too? If yes, we need to add conditional SST entries.

I am not aware of any GLK platform where the SST driver is required.

let me work off-line on a list of quirks that are needed.

Quoted 41 lines
Quoted 32 lines
Quoted 32 lines
sound/hda/intel-dsp-config.c new file +31 -0
+	{
+		.flags = FLAG_SST,
+		.device = 0x3198,
+	},
+#endif
+/* Icelake */
+#if IS_ENABLED(CONFIG_SND_SOC_SOF_ICELAKE)
+	{
+		.flags = FLAG_SOF | FLAG_SOF_ONLY_IF_DMIC,
+		.device = 0x34c8,
+	},
+#endif
+/* Elkhart Lake */
+#if IS_ENABLED(CONFIG_SND_SOC_SOF_ELKHARTLAKE)
+	{
+		.flags = FLAG_SOF | FLAG_SOF_ONLY_IF_DMIC,
+		.device = 0x4b55,
+	},
+#endif
+/* Appololake (Broxton-P) */
+#if IS_ENABLED(CONFIG_SND_SOC_SOF_APOLLOLAKE)
+	{
+		.flags = FLAG_SOF,
+		.device = 0x5a98,
+		.dmi_table = (const struct dmi_system_id []) {
+			{
+				.ident = "Up Squared",
+				.matches = {
+					DMI_MATCH(DMI_SYS_VENDOR, "AAEON"),
+					DMI_MATCH(DMI_BOARD_NAME, "UP-APL01"),
+				}
Quoted 8 lines

sound/hda/intel-dsp-config.c line 122

Quoted 6 lines
sound/hda/intel-dsp-config.c new file +6 -0
+			},
+			{}
+		}
+	},
+#endif
+#if IS_ENABLED(CONFIG_SND_SOC_INTEL_APL)

elif?

Quoted 1 line

Same. What's the default driver for APL?

Should be legacy except for Chromebooks where it's SST.

_______________________________________________
Alsa-devel mailing list
[email protected]
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel

#6 lore raw
In reply to Jaroslav Kysela
Quoted 2 lines

Added. Will be in v4. Thanks for all of the input.

I took the liberty of adding suggested fixes on top this v3 in a GitHub PR:

https://github.com/thesofproject/linux/pull/1290

That PR also references changes to our default .config where all 3 drivers are enabled. Hopefully we get test results on multiple platforms and can double-check the quirks
_______________________________________________
Alsa-devel mailing list
[email protected]
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel

author maintainer
#7 lore raw

Dne 08. 10. 19 v 20:44 Pierre-Louis Bossart napsal(a):

Quoted 6 lines
Quoted 2 lines

Added. Will be in v4. Thanks for all of the input.

I took the liberty of adding suggested fixes on top this v3 in a GitHub PR:

https://github.com/thesofproject/linux/pull/1290

Thanks. I put other little modifications to v4 (without the table changes - I was waiting to your input), so you can stack the modifications on top.

I just tried to fix the Takashi's nitpicking and I saw some warnings from your CI (bit definitions, EXPORT_SYMBOL), so I addressed them, too.

Please, rebase your changes on top of v4.

Thanks,
Jaroslav

Signature · 6 lines
Jaroslav Kysela <[email protected]>
Linux Sound Maintainer; ALSA Project; Red Hat, Inc.
_______________________________________________
Alsa-devel mailing list
[email protected]
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel