ALSA: hda: add Intel DSP configuration / probe code
Subsystems (4)
Jaroslav Kysela
maintainerPATCH v2 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 like proposed in the pull request:
https://github.com/thesofproject/linux/pull/927
Tested on Lenovo Carbon X1 7th gen.
--- include/sound/intel-dsp-config.h | 34 ++++++++++ sound/hda/Kconfig | 10 ++- sound/hda/Makefile | 7 ++- sound/hda/intel-dsp-config.c | 105 +++++++++++++++++++++++++++++++ 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, 179 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
@@ -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
@@ -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. + # 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
@@ -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 +105 -0
105 lines not on this page · raw message
sound/hda/intel-nhlt.c +0 -3
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
sound/hda/intel-dsp-config.c line 13
Quoted 3 lines
sound/hda/intel-dsp-config.c new file +2
-0+module_param (dsp_driver, int,0444 ); +MODULE_PARM_DESC (dsp_driver,"Force the DSP driver for Intel DSP (0=auto, 1=noDSP, 2=legacy, 3=SST, 4=SOF)" );
remove noDSP?
Quoted 7 lines
sound/hda/intel-dsp-config.c new file +7
-0+ +static const u16 sof_skl_table[] = { +#if IS_ENABLED(CONFIG_SND_SOC_SOF_COMETLAKE_LP) +0x02c8 ,/* Cometlake-LP */ +#endif +#if IS_ENABLED(CONFIG_SND_SOC_SOF_COMETLAKE_H) + 0x06c8, /* Cometlake-H */
sound/hda/intel-dsp-config.c line 30
Quoted 10 lines
sound/hda/intel-dsp-config.c new file +10
-0+#endif +#if IS_ENABLED (CONFIG_SND_SOC_SOF_GEMINILAKE ) + 0x3198, /* Geminilake */ +#endif +#if IS_ENABLED (CONFIG_SND_SOC_SOF_CANNONLAKE ) + 0x9dc8, /* Cannonlake */ +#endif +#if IS_ENABLED (CONFIG_SND_SOC_SOF_COFFEELAKE ) + 0xa348, /* Coffelake */ +#endif
I am lost here, is this to handle the cases between legacy and SOF? If yes, we need to add all PCI IDs after gemini lake.
Quoted 51 lines
sound/hda/intel-dsp-config.c new file +51
-0+}; + +static int snd_intel_dsp_check_device (u16 device,const u16 *table,u32 len) +{ +for (; len >0 ; len--, table++) { +if (*table == device) +return 1 ; + } +return 0 ; +} + +static int snd_intel_dsp_check_dmic (struct pci_dev *pci) +{ +struct nhlt_acpi_table *nhlt; +int ret =0 ; + +if (snd_intel_dsp_check_device (pci->device, sof_skl_table,ARRAY_SIZE (sof_skl_table))) { + nhlt =intel_nhlt_init (&pci->dev); +if (nhlt) { +if (intel_nhlt_get_dmic_geo (&pci->dev, nhlt)) + ret =1 ; +intel_nhlt_free (nhlt); + } + } +return ret; +} + +int snd_intel_dsp_driver_probe (struct pci_dev *pci) +{ +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 ; +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 ; + } + +dev_info (&pci->dev,"DSP detected with PCI class/subclass/prog-if info 0x%06x\n" , pci->class);
sound/hda/intel-dsp-config.c line 91
Quoted 10 lines
sound/hda/intel-dsp-config.c new file +10
-0+ +/* Prefer SST driver for Broxton-P (Appololake) */ +#if IS_ENABLED (CONFIG_SND_SOC_INTEL_APL ) ||IS_ENABLED (CONFIG_SND_SOC_SOF_APOLLOLAKE ) + if (pci->device == 0x5a98) +#if IS_ENABLED (CONFIG_SND_SOC_INTEL_APL ) +return SND_INTEL_DSP_DRIVER_SST ; +#else +return SND_INTEL_DSP_DRIVER_SOF ; +#endif +#endif
This should be done with quirks, where we select SST for Chromebooks for APL, SKL, KBL.
Using the PCI ID + class only will break at least one device, I remotely debugged Hans de Goede's APL platform and saw the same issues with HDMI probe as on Linus' laptop.
I am running out of time for this week, so will check updates next week.
sound/hda/intel-dsp-config.c line 101
Quoted 10 lines
sound/hda/intel-dsp-config.c new file +10
-0+ +/* DMIC check for Skylake+ */ +if (snd_intel_dsp_check_dmic (pci)) { +dev_info (&pci->dev,"Digital mics found on Skylake+ platform, using SOF driver\n" ); +return SND_INTEL_DSP_DRIVER_SOF ; + } + +return SND_INTEL_DSP_DRIVER_ANY ; +} +
_______________________________________________
Alsa-devel mailing list
[email protected]
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel
Jaroslav Kysela
maintainerDne 02. 10. 19 v 19:06 Pierre-Louis Bossart napsal(a):
Quoted 92 lines
sound/hda/intel-dsp-config.c line 13
Quoted 3 lines
sound/hda/intel-dsp-config.c new file +2
-0+module_param (dsp_driver, int,0444 ); +MODULE_PARM_DESC (dsp_driver,"Force the DSP driver for Intel DSP (0=auto, 1=noDSP, 2=legacy, 3=SST, 4=SOF)" );remove noDSP?
Quoted 7 lines
sound/hda/intel-dsp-config.c new file +7
-0+ +static const u16 sof_skl_table[] = { +#if IS_ENABLED(CONFIG_SND_SOC_SOF_COMETLAKE_LP) +0x02c8 ,/* Cometlake-LP */ +#endif +#if IS_ENABLED(CONFIG_SND_SOC_SOF_COMETLAKE_H) + 0x06c8, /* Cometlake-H */sound/hda/intel-dsp-config.c line 30
Quoted 10 lines
sound/hda/intel-dsp-config.c new file +10
-0+#endif +#if IS_ENABLED (CONFIG_SND_SOC_SOF_GEMINILAKE ) + 0x3198, /* Geminilake */ +#endif +#if IS_ENABLED (CONFIG_SND_SOC_SOF_CANNONLAKE ) + 0x9dc8, /* Cannonlake */ +#endif +#if IS_ENABLED (CONFIG_SND_SOC_SOF_COFFEELAKE ) + 0xa348, /* Coffelake */ +#endif I am lost here, is this to handle the cases between legacy and SOF? If yes, we need to add all PCI IDs after gemini lake.
Quoted 51 lines
sound/hda/intel-dsp-config.c new file +51
-0+}; + +static int snd_intel_dsp_check_device (u16 device,const u16 *table,u32 len) +{ +for (; len >0 ; len--, table++) { +if (*table == device) +return 1 ; + } +return 0 ; +} + +static int snd_intel_dsp_check_dmic (struct pci_dev *pci) +{ +struct nhlt_acpi_table *nhlt; +int ret =0 ; + +if (snd_intel_dsp_check_device (pci->device, sof_skl_table,ARRAY_SIZE (sof_skl_table))) { + nhlt =intel_nhlt_init (&pci->dev); +if (nhlt) { +if (intel_nhlt_get_dmic_geo (&pci->dev, nhlt)) + ret =1 ; +intel_nhlt_free (nhlt); + } + } +return ret; +} + +int snd_intel_dsp_driver_probe (struct pci_dev *pci) +{ +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 ; +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 ; + } + +dev_info (&pci->dev,"DSP detected with PCI class/subclass/prog-if info 0x%06x\n" , pci->class);sound/hda/intel-dsp-config.c line 91
Quoted 10 lines
sound/hda/intel-dsp-config.c new file +10
-0+ +/* Prefer SST driver for Broxton-P (Appololake) */ +#if IS_ENABLED (CONFIG_SND_SOC_INTEL_APL ) ||IS_ENABLED (CONFIG_SND_SOC_SOF_APOLLOLAKE ) + if (pci->device == 0x5a98) +#if IS_ENABLED (CONFIG_SND_SOC_INTEL_APL ) +return SND_INTEL_DSP_DRIVER_SST ; +#else +return SND_INTEL_DSP_DRIVER_SOF ; +#endif +#endif This should be done with quirks, where we select SST for Chromebooks for APL, SKL, KBL.
Quoted 5 lines
Using the PCI ID + class only will break at least one device, I remotely debugged Hans de Goede's APL platform and saw the same issues with HDMI probe as on Linus' laptop.
I am running out of time for this week, so will check updates next week.
I reworked the logic in the code (v3 of the patch) to use one table with the configuration entries for all platforms including dmi based quirks. Please, review it, if you see any problems there. I believe that we are reaching really nice and clean solution for this problem.
Thank you,
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