Pablo Greco d6c4c4
From 79b0618304c9a7512aba223ae187a8405656aa8e Mon Sep 17 00:00:00 2001
Pablo Greco d6c4c4
From: Colin Ian King <colin.king@canonical.com>
Pablo Greco d6c4c4
Date: Sun, 25 Nov 2018 23:12:08 +0000
Pablo Greco d6c4c4
Subject: [PATCH 001/109] ALSA: usb-audio: fix spelling mistake "Frequence" ->
Pablo Greco d6c4c4
 "Frequency"
Pablo Greco d6c4c4
Pablo Greco d6c4c4
There are spelling mistakes in equalizer name fields, fix them.
Pablo Greco d6c4c4
Pablo Greco d6c4c4
Signed-off-by: Colin Ian King <colin.king@canonical.com>
Pablo Greco d6c4c4
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Pablo Greco d6c4c4
Pablo Greco d6c4c4
Signed-off-by: Jaroslav Kysela <jkysela@redhat.com>
Pablo Greco d6c4c4
(cherry picked from commit 940f457392e684bf0005628f6a155040648c5894)
Pablo Greco d6c4c4
Bugzilla: 1772498
Pablo Greco d6c4c4
---
Pablo Greco d6c4c4
 sound/usb/mixer_us16x08.c | 8 ++++----
Pablo Greco d6c4c4
 1 file changed, 4 insertions(+), 4 deletions(-)
Pablo Greco d6c4c4
Pablo Greco d6c4c4
diff --git a/sound/usb/mixer_us16x08.c b/sound/usb/mixer_us16x08.c
Pablo Greco d6c4c4
index f0e8e1539450..aea3b4ad7ded 100644
Pablo Greco d6c4c4
--- a/sound/usb/mixer_us16x08.c
Pablo Greco d6c4c4
+++ b/sound/usb/mixer_us16x08.c
Pablo Greco d6c4c4
@@ -1109,7 +1109,7 @@ static const struct snd_us16x08_control_params eq_controls[] = {
Pablo Greco d6c4c4
 		.control_id = SND_US16X08_ID_EQLOWFREQ,
Pablo Greco d6c4c4
 		.type = USB_MIXER_U8,
Pablo Greco d6c4c4
 		.num_channels = 16,
Pablo Greco d6c4c4
-		.name = "EQ Low Frequence",
Pablo Greco d6c4c4
+		.name = "EQ Low Frequency",
Pablo Greco d6c4c4
 	},
Pablo Greco d6c4c4
 	{ /* EQ mid low gain */
Pablo Greco d6c4c4
 		.kcontrol_new = &snd_us16x08_eq_gain_ctl,
Pablo Greco d6c4c4
@@ -1123,7 +1123,7 @@ static const struct snd_us16x08_control_params eq_controls[] = {
Pablo Greco d6c4c4
 		.control_id = SND_US16X08_ID_EQLOWMIDFREQ,
Pablo Greco d6c4c4
 		.type = USB_MIXER_U8,
Pablo Greco d6c4c4
 		.num_channels = 16,
Pablo Greco d6c4c4
-		.name = "EQ MidLow Frequence",
Pablo Greco d6c4c4
+		.name = "EQ MidLow Frequency",
Pablo Greco d6c4c4
 	},
Pablo Greco d6c4c4
 	{ /* EQ mid low Q */
Pablo Greco d6c4c4
 		.kcontrol_new = &snd_us16x08_eq_mid_width_ctl,
Pablo Greco d6c4c4
@@ -1144,7 +1144,7 @@ static const struct snd_us16x08_control_params eq_controls[] = {
Pablo Greco d6c4c4
 		.control_id = SND_US16X08_ID_EQHIGHMIDFREQ,
Pablo Greco d6c4c4
 		.type = USB_MIXER_U8,
Pablo Greco d6c4c4
 		.num_channels = 16,
Pablo Greco d6c4c4
-		.name = "EQ MidHigh Frequence",
Pablo Greco d6c4c4
+		.name = "EQ MidHigh Frequency",
Pablo Greco d6c4c4
 	},
Pablo Greco d6c4c4
 	{ /* EQ mid high Q */
Pablo Greco d6c4c4
 		.kcontrol_new = &snd_us16x08_eq_mid_width_ctl,
Pablo Greco d6c4c4
@@ -1165,7 +1165,7 @@ static const struct snd_us16x08_control_params eq_controls[] = {
Pablo Greco d6c4c4
 		.control_id = SND_US16X08_ID_EQHIGHFREQ,
Pablo Greco d6c4c4
 		.type = USB_MIXER_U8,
Pablo Greco d6c4c4
 		.num_channels = 16,
Pablo Greco d6c4c4
-		.name = "EQ High Frequence",
Pablo Greco d6c4c4
+		.name = "EQ High Frequency",
Pablo Greco d6c4c4
 	},
Pablo Greco d6c4c4
 };
Pablo Greco d6c4c4
 
Pablo Greco d6c4c4
-- 
Pablo Greco d6c4c4
2.24.1
Pablo Greco d6c4c4
Pablo Greco d6c4c4
From 042dd0cc1f179d52acfea699239b87ef93dbd70d Mon Sep 17 00:00:00 2001
Pablo Greco d6c4c4
From: Takashi Iwai <tiwai@suse.de>
Pablo Greco d6c4c4
Date: Thu, 14 Nov 2019 17:56:13 +0100
Pablo Greco d6c4c4
Subject: [PATCH 003/109] ALSA: usb-audio: Add skip_validation option
Pablo Greco d6c4c4
Pablo Greco d6c4c4
The unit descriptor validation may lead to a probe error when the
Pablo Greco d6c4c4
device provides a buggy descriptor or the validator detected
Pablo Greco d6c4c4
incorrectly.  For identifying such an error and band-aiding, give a
Pablo Greco d6c4c4
new module option, skip_validation.  With this option, the driver
Pablo Greco d6c4c4
ignores the validation errors with the hexdump of the unit
Pablo Greco d6c4c4
descriptor, so we can check it in a bit more details.
Pablo Greco d6c4c4
Pablo Greco d6c4c4
Link: https://lore.kernel.org/r/20191114165613.7422-2-tiwai@suse.de
Pablo Greco d6c4c4
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Pablo Greco d6c4c4
Pablo Greco d6c4c4
Signed-off-by: Jaroslav Kysela <jkysela@redhat.com>
Pablo Greco d6c4c4
(cherry picked from commit f35ef592477c5347b8f780a5f0d4970671e22c61)
Pablo Greco d6c4c4
Bugzilla: 1772498
Pablo Greco d6c4c4
---
Pablo Greco d6c4c4
 sound/usb/card.c     |  3 +++
Pablo Greco d6c4c4
 sound/usb/usbaudio.h |  1 +
Pablo Greco d6c4c4
 sound/usb/validate.c | 23 ++++++++++++++++++++---
Pablo Greco d6c4c4
 3 files changed, 24 insertions(+), 3 deletions(-)
Pablo Greco d6c4c4
Pablo Greco d6c4c4
diff --git a/sound/usb/card.c b/sound/usb/card.c
Pablo Greco d6c4c4
index db91dc76cc91..9f743ebae615 100644
Pablo Greco d6c4c4
--- a/sound/usb/card.c
Pablo Greco d6c4c4
+++ b/sound/usb/card.c
Pablo Greco d6c4c4
@@ -74,6 +74,7 @@ static bool autoclock = true;
Pablo Greco d6c4c4
 static char *quirk_alias[SNDRV_CARDS];
Pablo Greco d6c4c4
 
Pablo Greco d6c4c4
 bool snd_usb_use_vmalloc = true;
Pablo Greco d6c4c4
+bool snd_usb_skip_validation;
Pablo Greco d6c4c4
 
Pablo Greco d6c4c4
 module_param_array(index, int, NULL, 0444);
Pablo Greco d6c4c4
 MODULE_PARM_DESC(index, "Index value for the USB audio adapter.");
Pablo Greco d6c4c4
@@ -96,6 +97,8 @@ module_param_array(quirk_alias, charp, NULL, 0444);
Pablo Greco d6c4c4
 MODULE_PARM_DESC(quirk_alias, "Quirk aliases, e.g. 0123abcd:5678beef.");
Pablo Greco d6c4c4
 module_param_named(use_vmalloc, snd_usb_use_vmalloc, bool, 0444);
Pablo Greco d6c4c4
 MODULE_PARM_DESC(use_vmalloc, "Use vmalloc for PCM intermediate buffers (default: yes).");
Pablo Greco d6c4c4
+module_param_named(skip_validation, snd_usb_skip_validation, bool, 0444);
Pablo Greco d6c4c4
+MODULE_PARM_DESC(skip_validation, "Skip unit descriptor validation (default: no).");
Pablo Greco d6c4c4
 
Pablo Greco d6c4c4
 /*
Pablo Greco d6c4c4
  * we keep the snd_usb_audio_t instances by ourselves for merging
Pablo Greco d6c4c4
diff --git a/sound/usb/usbaudio.h b/sound/usb/usbaudio.h
Pablo Greco d6c4c4
index e360680f45f3..6fe3ab582ec6 100644
Pablo Greco d6c4c4
--- a/sound/usb/usbaudio.h
Pablo Greco d6c4c4
+++ b/sound/usb/usbaudio.h
Pablo Greco d6c4c4
@@ -121,5 +121,6 @@ int snd_usb_lock_shutdown(struct snd_usb_audio *chip);
Pablo Greco d6c4c4
 void snd_usb_unlock_shutdown(struct snd_usb_audio *chip);
Pablo Greco d6c4c4
 
Pablo Greco d6c4c4
 extern bool snd_usb_use_vmalloc;
Pablo Greco d6c4c4
+extern bool snd_usb_skip_validation;
Pablo Greco d6c4c4
 
Pablo Greco d6c4c4
 #endif /* __USBAUDIO_H */
Pablo Greco d6c4c4
diff --git a/sound/usb/validate.c b/sound/usb/validate.c
Pablo Greco d6c4c4
index 5a3c4f7882b0..c43d8c3895a9 100644
Pablo Greco d6c4c4
--- a/sound/usb/validate.c
Pablo Greco d6c4c4
+++ b/sound/usb/validate.c
Pablo Greco d6c4c4
@@ -322,11 +322,28 @@ static bool validate_desc(unsigned char *hdr, int protocol,
Pablo Greco d6c4c4
 
Pablo Greco d6c4c4
 bool snd_usb_validate_audio_desc(void *p, int protocol)
Pablo Greco d6c4c4
 {
Pablo Greco d6c4c4
-	return validate_desc(p, protocol, audio_validators);
Pablo Greco d6c4c4
+	unsigned char *c = p;
Pablo Greco d6c4c4
+	bool valid;
Pablo Greco d6c4c4
+
Pablo Greco d6c4c4
+	valid = validate_desc(p, protocol, audio_validators);
Pablo Greco d6c4c4
+	if (!valid && snd_usb_skip_validation) {
Pablo Greco d6c4c4
+		print_hex_dump(KERN_ERR, "USB-audio: buggy audio desc: ",
Pablo Greco d6c4c4
+			       DUMP_PREFIX_NONE, 16, 1, c, c[0], true);
Pablo Greco d6c4c4
+		valid = true;
Pablo Greco d6c4c4
+	}
Pablo Greco d6c4c4
+	return valid;
Pablo Greco d6c4c4
 }
Pablo Greco d6c4c4
 
Pablo Greco d6c4c4
 bool snd_usb_validate_midi_desc(void *p)
Pablo Greco d6c4c4
 {
Pablo Greco d6c4c4
-	return validate_desc(p, UAC_VERSION_1, midi_validators);
Pablo Greco d6c4c4
+	unsigned char *c = p;
Pablo Greco d6c4c4
+	bool valid;
Pablo Greco d6c4c4
+
Pablo Greco d6c4c4
+	valid = validate_desc(p, UAC_VERSION_1, midi_validators);
Pablo Greco d6c4c4
+	if (!valid && snd_usb_skip_validation) {
Pablo Greco d6c4c4
+		print_hex_dump(KERN_ERR, "USB-audio: buggy midi desc: ",
Pablo Greco d6c4c4
+			       DUMP_PREFIX_NONE, 16, 1, c, c[0], true);
Pablo Greco d6c4c4
+		valid = true;
Pablo Greco d6c4c4
+	}
Pablo Greco d6c4c4
+	return valid;
Pablo Greco d6c4c4
 }
Pablo Greco d6c4c4
-
Pablo Greco d6c4c4
-- 
Pablo Greco d6c4c4
2.24.1
Pablo Greco d6c4c4
Pablo Greco d6c4c4
From 8d5568b5492d468acd4a49eefccaaed28dc62d22 Mon Sep 17 00:00:00 2001
Pablo Greco d6c4c4
From: Jaroslav Kysela <perex@perex.cz>
Pablo Greco d6c4c4
Date: Tue, 22 Oct 2019 19:43:12 +0200
Pablo Greco d6c4c4
Subject: [PATCH 004/109] ALSA: hda: add Intel DSP configuration / probe code
Pablo Greco d6c4c4
Pablo Greco d6c4c4
For distributions, we need one place where we can decide
Pablo Greco d6c4c4
which driver will be activated for the auto-configation of the
Pablo Greco d6c4c4
Intel's HDA hardware with DSP. Actually, we cover three drivers:
Pablo Greco d6c4c4
Pablo Greco d6c4c4
* Legacy HDA
Pablo Greco d6c4c4
* Intel SST
Pablo Greco d6c4c4
* Intel Sound Open Firmware (SOF)
Pablo Greco d6c4c4
Pablo Greco d6c4c4
All those drivers registers similar PCI IDs, so the first
Pablo Greco d6c4c4
driver probed from the PCI stack can win. But... it is not
Pablo Greco d6c4c4
guaranteed that the correct driver wins.
Pablo Greco d6c4c4
Pablo Greco d6c4c4
This commit changes Intel's NHLT ACPI module to a common
Pablo Greco d6c4c4
DSP probe module for the Intel's hardware. All above sound
Pablo Greco d6c4c4
drivers calls this code. The user can force another behaviour
Pablo Greco d6c4c4
using the module parameter 'dsp_driver' located in
Pablo Greco d6c4c4
the 'snd-intel-dspcfg' module.
Pablo Greco d6c4c4
Pablo Greco d6c4c4
This change allows to add specific dmi checks for the specific
Pablo Greco d6c4c4
systems. The examples are taken from the pull request:
Pablo Greco d6c4c4
Pablo Greco d6c4c4
  https://github.com/thesofproject/linux/pull/927
Pablo Greco d6c4c4
Pablo Greco d6c4c4
Tested on Lenovo Carbon X1 7th gen.
Pablo Greco d6c4c4
Pablo Greco d6c4c4
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
Pablo Greco d6c4c4
Tested-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Pablo Greco d6c4c4
Link: https://lore.kernel.org/r/20191022174313.29087-1-perex@perex.cz
Pablo Greco d6c4c4
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Pablo Greco d6c4c4
Pablo Greco d6c4c4
Signed-off-by: Jaroslav Kysela <jkysela@redhat.com>
Pablo Greco d6c4c4
(cherry picked from commit 82d9d54a6c0ee8b12211fa4e59fd940a2da4e063)
Pablo Greco d6c4c4
Bugzilla: 1772498
Pablo Greco d6c4c4
---
Pablo Greco d6c4c4
 include/sound/intel-dsp-config.h |  34 +++++
Pablo Greco d6c4c4
 sound/hda/Kconfig                |  10 +-
Pablo Greco d6c4c4
 sound/hda/Makefile               |   5 +-
Pablo Greco d6c4c4
 sound/hda/intel-dsp-config.c     | 249 +++++++++++++++++++++++++++++++
Pablo Greco d6c4c4
 sound/hda/intel-nhlt.c           |   3 -
Pablo Greco d6c4c4
 sound/pci/hda/Kconfig            |  11 +-
Pablo Greco d6c4c4
 sound/pci/hda/hda_intel.c        |  49 ++----
Pablo Greco d6c4c4
 sound/soc/intel/Kconfig          |   2 +-
Pablo Greco d6c4c4
 sound/soc/intel/skylake/skl.c    |  19 +--
Pablo Greco d6c4c4
 sound/soc/sof/intel/Kconfig      |   2 +-
Pablo Greco d6c4c4
 sound/soc/sof/sof-pci-dev.c      |   6 +
Pablo Greco d6c4c4
 11 files changed, 322 insertions(+), 68 deletions(-)
Pablo Greco d6c4c4
 create mode 100644 include/sound/intel-dsp-config.h
Pablo Greco d6c4c4
 create mode 100644 sound/hda/intel-dsp-config.c
Pablo Greco d6c4c4
Pablo Greco d6c4c4
diff --git a/include/sound/intel-dsp-config.h b/include/sound/intel-dsp-config.h
Pablo Greco d6c4c4
new file mode 100644
Pablo Greco d6c4c4
index 000000000000..c36622bee3f8
Pablo Greco d6c4c4
--- /dev/null
Pablo Greco d6c4c4
+++ b/include/sound/intel-dsp-config.h
Pablo Greco d6c4c4
@@ -0,0 +1,34 @@
Pablo Greco d6c4c4
+/* SPDX-License-Identifier: GPL-2.0-only */
Pablo Greco d6c4c4
+/*
Pablo Greco d6c4c4
+ *  intel-dsp-config.h - Intel DSP config
Pablo Greco d6c4c4
+ *
Pablo Greco d6c4c4
+ *  Copyright (c) 2019 Jaroslav Kysela <perex@perex.cz>
Pablo Greco d6c4c4
+ */
Pablo Greco d6c4c4
+
Pablo Greco d6c4c4
+#ifndef __INTEL_DSP_CONFIG_H__
Pablo Greco d6c4c4
+#define __INTEL_DSP_CONFIG_H__
Pablo Greco d6c4c4
+
Pablo Greco d6c4c4
+struct pci_dev;
Pablo Greco d6c4c4
+
Pablo Greco d6c4c4
+enum {
Pablo Greco d6c4c4
+	SND_INTEL_DSP_DRIVER_ANY = 0,
Pablo Greco d6c4c4
+	SND_INTEL_DSP_DRIVER_LEGACY,
Pablo Greco d6c4c4
+	SND_INTEL_DSP_DRIVER_SST,
Pablo Greco d6c4c4
+	SND_INTEL_DSP_DRIVER_SOF,
Pablo Greco d6c4c4
+	SND_INTEL_DSP_DRIVER_LAST = SND_INTEL_DSP_DRIVER_SOF
Pablo Greco d6c4c4
+};
Pablo Greco d6c4c4
+
Pablo Greco d6c4c4
+#if IS_ENABLED(CONFIG_SND_INTEL_DSP_CONFIG)
Pablo Greco d6c4c4
+
Pablo Greco d6c4c4
+int snd_intel_dsp_driver_probe(struct pci_dev *pci);
Pablo Greco d6c4c4
+
Pablo Greco d6c4c4
+#else
Pablo Greco d6c4c4
+
Pablo Greco d6c4c4
+static inline int snd_intel_dsp_driver_probe(struct pci_dev *pci)
Pablo Greco d6c4c4
+{
Pablo Greco d6c4c4
+	return SND_INTEL_DSP_DRIVER_ANY;
Pablo Greco d6c4c4
+}
Pablo Greco d6c4c4
+
Pablo Greco d6c4c4
+#endif
Pablo Greco d6c4c4
+
Pablo Greco d6c4c4
+#endif
Pablo Greco d6c4c4
diff --git a/sound/hda/Kconfig b/sound/hda/Kconfig
Pablo Greco d6c4c4
index 3d33fc1757ba..b0c88fe040ee 100644
Pablo Greco d6c4c4
--- a/sound/hda/Kconfig
Pablo Greco d6c4c4
+++ b/sound/hda/Kconfig
Pablo Greco d6c4c4
@@ -34,6 +34,12 @@ config SND_HDA_PREALLOC_SIZE
Pablo Greco d6c4c4
 	  via a proc file (/proc/asound/card*/pcm*/sub*/prealloc), too.
Pablo Greco d6c4c4
 
Pablo Greco d6c4c4
 config SND_INTEL_NHLT
Pablo Greco d6c4c4
-	tristate
Pablo Greco d6c4c4
+	bool
Pablo Greco d6c4c4
 	# this config should be selected only for Intel ACPI platforms.
Pablo Greco d6c4c4
-	# A fallback is provided so that the code compiles in all cases.
Pablo Greco d6c4c4
\ No newline at end of file
Pablo Greco d6c4c4
+	# A fallback is provided so that the code compiles in all cases.
Pablo Greco d6c4c4
+
Pablo Greco d6c4c4
+config SND_INTEL_DSP_CONFIG
Pablo Greco d6c4c4
+	tristate
Pablo Greco d6c4c4
+	select SND_INTEL_NHLT if ACPI
Pablo Greco d6c4c4
+	# this config should be selected only for Intel DSP platforms.
Pablo Greco d6c4c4
+	# A fallback is provided so that the code compiles in all cases.
Pablo Greco d6c4c4
diff --git a/sound/hda/Makefile b/sound/hda/Makefile
Pablo Greco d6c4c4
index 8560f6ef1b19..601e617918b8 100644
Pablo Greco d6c4c4
--- a/sound/hda/Makefile
Pablo Greco d6c4c4
+++ b/sound/hda/Makefile
Pablo Greco d6c4c4
@@ -14,5 +14,6 @@ obj-$(CONFIG_SND_HDA_CORE) += snd-hda-core.o
Pablo Greco d6c4c4
 #extended hda
Pablo Greco d6c4c4
 obj-$(CONFIG_SND_HDA_EXT_CORE) += ext/
Pablo Greco d6c4c4
 
Pablo Greco d6c4c4
-snd-intel-nhlt-objs := intel-nhlt.o
Pablo Greco d6c4c4
-obj-$(CONFIG_SND_INTEL_NHLT) += snd-intel-nhlt.o
Pablo Greco d6c4c4
+snd-intel-dspcfg-objs := intel-dsp-config.o
Pablo Greco d6c4c4
+snd-intel-dspcfg-$(CONFIG_SND_INTEL_NHLT) += intel-nhlt.o
Pablo Greco d6c4c4
+obj-$(CONFIG_SND_INTEL_DSP_CONFIG) += snd-intel-dspcfg.o
Pablo Greco d6c4c4
diff --git a/sound/hda/intel-dsp-config.c b/sound/hda/intel-dsp-config.c
Pablo Greco d6c4c4
new file mode 100644
Pablo Greco d6c4c4
index 000000000000..d9f6d9e872b4
Pablo Greco d6c4c4
--- /dev/null
Pablo Greco d6c4c4
+++ b/sound/hda/intel-dsp-config.c
Pablo Greco d6c4c4
@@ -0,0 +1,249 @@
Pablo Greco d6c4c4
+// SPDX-License-Identifier: GPL-2.0
Pablo Greco d6c4c4
+// Copyright (c) 2019 Jaroslav Kysela <perex@perex.cz>
Pablo Greco d6c4c4
+
Pablo Greco d6c4c4
+#include <linux bits.h="">
Pablo Greco d6c4c4
+#include <linux dmi.h="">
Pablo Greco d6c4c4
+#include <linux module.h="">
Pablo Greco d6c4c4
+#include <linux pci.h="">
Pablo Greco d6c4c4
+#include <sound core.h="">
Pablo Greco d6c4c4
+#include <sound intel-dsp-config.h="">
Pablo Greco d6c4c4
+#include <sound intel-nhlt.h="">
Pablo Greco d6c4c4
+
Pablo Greco d6c4c4
+static int dsp_driver;
Pablo Greco d6c4c4
+
Pablo Greco d6c4c4
+module_param(dsp_driver, int, 0444);
Pablo Greco d6c4c4
+MODULE_PARM_DESC(dsp_driver, "Force the DSP driver for Intel DSP (0=auto, 1=legacy, 2=SST, 3=SOF)");
Pablo Greco d6c4c4
+
Pablo Greco d6c4c4
+#define FLAG_SST		BIT(0)
Pablo Greco d6c4c4
+#define FLAG_SOF		BIT(1)
Pablo Greco d6c4c4
+#define FLAG_SOF_ONLY_IF_DMIC	BIT(16)
Pablo Greco d6c4c4
+
Pablo Greco d6c4c4
+struct config_entry {
Pablo Greco d6c4c4
+	u32 flags;
Pablo Greco d6c4c4
+	u16 device;
Pablo Greco d6c4c4
+	const struct dmi_system_id *dmi_table;
Pablo Greco d6c4c4
+};
Pablo Greco d6c4c4
+
Pablo Greco d6c4c4
+/*
Pablo Greco d6c4c4
+ * configuration table
Pablo Greco d6c4c4
+ * - the order of similar PCI ID entries is important!
Pablo Greco d6c4c4
+ * - the first successful match will win
Pablo Greco d6c4c4
+ */
Pablo Greco d6c4c4
+static const struct config_entry config_table[] = {
Pablo Greco d6c4c4
+/* Cometlake-LP */
Pablo Greco d6c4c4
+#if IS_ENABLED(CONFIG_SND_SOC_INTEL_CML_LP)
Pablo Greco d6c4c4
+	{
Pablo Greco d6c4c4
+		/* prefer SST */
Pablo Greco d6c4c4
+		.flags = FLAG_SST,
Pablo Greco d6c4c4
+		.device = 0x02c8,
Pablo Greco d6c4c4
+	},
Pablo Greco d6c4c4
+#elif IS_ENABLED(CONFIG_SND_SOC_SOF_COMETLAKE_LP)
Pablo Greco d6c4c4
+	{
Pablo Greco d6c4c4
+		.flags = FLAG_SOF,
Pablo Greco d6c4c4
+		.device = 0x02c8,
Pablo Greco d6c4c4
+	},
Pablo Greco d6c4c4
+#endif
Pablo Greco d6c4c4
+/* Cometlake-H */
Pablo Greco d6c4c4
+#if IS_ENABLED(CONFIG_SND_SOC_INTEL_CML_H)
Pablo Greco d6c4c4
+	{
Pablo Greco d6c4c4
+		.flags = FLAG_SST,
Pablo Greco d6c4c4
+		.device = 0x06c8,
Pablo Greco d6c4c4
+	},
Pablo Greco d6c4c4
+#elif IS_ENABLED(CONFIG_SND_SOC_SOF_COMETLAKE_H)
Pablo Greco d6c4c4
+	{
Pablo Greco d6c4c4
+		.flags = FLAG_SOF,
Pablo Greco d6c4c4
+		.device = 0x06c8,
Pablo Greco d6c4c4
+	},
Pablo Greco d6c4c4
+#endif
Pablo Greco d6c4c4
+/* Merrifield */
Pablo Greco d6c4c4
+#if IS_ENABLED(CONFIG_SND_SOC_SOF_MERRIFIELD)
Pablo Greco d6c4c4
+	{
Pablo Greco d6c4c4
+		.flags = FLAG_SOF,
Pablo Greco d6c4c4
+		.device = 0x119a,
Pablo Greco d6c4c4
+	},
Pablo Greco d6c4c4
+#endif
Pablo Greco d6c4c4
+/* Broxton-T */
Pablo Greco d6c4c4
+#if IS_ENABLED(CONFIG_SND_SOC_SOF_APOLLOLAKE)
Pablo Greco d6c4c4
+	{
Pablo Greco d6c4c4
+		.flags = FLAG_SOF | FLAG_SOF_ONLY_IF_DMIC,
Pablo Greco d6c4c4
+		.device = 0x1a98,
Pablo Greco d6c4c4
+	},
Pablo Greco d6c4c4
+#endif
Pablo Greco d6c4c4
+/* Geminilake */
Pablo Greco d6c4c4
+#if IS_ENABLED(CONFIG_SND_SOC_SOF_GEMINILAKE)
Pablo Greco d6c4c4
+	{
Pablo Greco d6c4c4
+		.flags = FLAG_SOF,
Pablo Greco d6c4c4
+		.device = 0x3198,
Pablo Greco d6c4c4
+		.dmi_table = (const struct dmi_system_id []) {
Pablo Greco d6c4c4
+			{
Pablo Greco d6c4c4
+				.ident = "Google Chromebooks",
Pablo Greco d6c4c4
+				.matches = {
Pablo Greco d6c4c4
+					DMI_MATCH(DMI_SYS_VENDOR, "Google"),
Pablo Greco d6c4c4
+				}
Pablo Greco d6c4c4
+			},
Pablo Greco d6c4c4
+			{}
Pablo Greco d6c4c4
+		}
Pablo Greco d6c4c4
+	},
Pablo Greco d6c4c4
+#endif
Pablo Greco d6c4c4
+#if IS_ENABLED(CONFIG_SND_SOC_INTEL_GLK)
Pablo Greco d6c4c4
+	{
Pablo Greco d6c4c4
+		.flags = FLAG_SST,
Pablo Greco d6c4c4
+		.device = 0x3198,
Pablo Greco d6c4c4
+	},
Pablo Greco d6c4c4
+#endif
Pablo Greco d6c4c4
+/* Icelake */
Pablo Greco d6c4c4
+#if IS_ENABLED(CONFIG_SND_SOC_SOF_ICELAKE)
Pablo Greco d6c4c4
+	{
Pablo Greco d6c4c4
+		.flags = FLAG_SOF | FLAG_SOF_ONLY_IF_DMIC,
Pablo Greco d6c4c4
+		.device = 0x34c8,
Pablo Greco d6c4c4
+	},
Pablo Greco d6c4c4
+#endif
Pablo Greco d6c4c4
+/* Elkhart Lake */
Pablo Greco d6c4c4
+#if IS_ENABLED(CONFIG_SND_SOC_SOF_ELKHARTLAKE)
Pablo Greco d6c4c4
+	{
Pablo Greco d6c4c4
+		.flags = FLAG_SOF | FLAG_SOF_ONLY_IF_DMIC,
Pablo Greco d6c4c4
+		.device = 0x4b55,
Pablo Greco d6c4c4
+	},
Pablo Greco d6c4c4
+#endif
Pablo Greco d6c4c4
+/* Appololake (Broxton-P) */
Pablo Greco d6c4c4
+#if IS_ENABLED(CONFIG_SND_SOC_SOF_APOLLOLAKE)
Pablo Greco d6c4c4
+	{
Pablo Greco d6c4c4
+		.flags = FLAG_SOF,
Pablo Greco d6c4c4
+		.device = 0x5a98,
Pablo Greco d6c4c4
+		.dmi_table = (const struct dmi_system_id []) {
Pablo Greco d6c4c4
+			{
Pablo Greco d6c4c4
+				.ident = "Up Squared",
Pablo Greco d6c4c4
+				.matches = {
Pablo Greco d6c4c4
+					DMI_MATCH(DMI_SYS_VENDOR, "AAEON"),
Pablo Greco d6c4c4
+					DMI_MATCH(DMI_BOARD_NAME, "UP-APL01"),
Pablo Greco d6c4c4
+				}
Pablo Greco d6c4c4
+			},
Pablo Greco d6c4c4
+			{}
Pablo Greco d6c4c4
+		}
Pablo Greco d6c4c4
+	},
Pablo Greco d6c4c4
+#endif
Pablo Greco d6c4c4
+#if IS_ENABLED(CONFIG_SND_SOC_INTEL_APL)
Pablo Greco d6c4c4
+	{
Pablo Greco d6c4c4
+		.flags = FLAG_SST,
Pablo Greco d6c4c4
+		.device = 0x5a98,
Pablo Greco d6c4c4
+	},
Pablo Greco d6c4c4
+#endif
Pablo Greco d6c4c4
+/* Cannonlake */
Pablo Greco d6c4c4
+#if IS_ENABLED(CONFIG_SND_SOC_SOF_CANNONLAKE)
Pablo Greco d6c4c4
+	{
Pablo Greco d6c4c4
+		.flags = FLAG_SOF | FLAG_SOF_ONLY_IF_DMIC,
Pablo Greco d6c4c4
+		.device = 0x9dc8,
Pablo Greco d6c4c4
+	},
Pablo Greco d6c4c4
+#endif
Pablo Greco d6c4c4
+/* Sunrise Point-LP */
Pablo Greco d6c4c4
+#if IS_ENABLED(CONFIG_SND_SOC_SOF_SKYLAKE)
Pablo Greco d6c4c4
+	{
Pablo Greco d6c4c4
+		.flags = FLAG_SOF | FLAG_SOF_ONLY_IF_DMIC,
Pablo Greco d6c4c4
+		.device = 0x9d70,
Pablo Greco d6c4c4
+	},
Pablo Greco d6c4c4
+#endif
Pablo Greco d6c4c4
+/* Kabylake-LP */
Pablo Greco d6c4c4
+#if IS_ENABLED(CONFIG_SND_SOC_SOF_KABYLAKE)
Pablo Greco d6c4c4
+	{
Pablo Greco d6c4c4
+		.flags = FLAG_SOF | FLAG_SOF_ONLY_IF_DMIC,
Pablo Greco d6c4c4
+		.device = 0x9d71,
Pablo Greco d6c4c4
+	},
Pablo Greco d6c4c4
+#endif
Pablo Greco d6c4c4
+/* Tigerlake */
Pablo Greco d6c4c4
+#if IS_ENABLED(CONFIG_SND_SOC_SOF_TIGERLAKE)
Pablo Greco d6c4c4
+	{
Pablo Greco d6c4c4
+		.flags = FLAG_SOF | FLAG_SOF_ONLY_IF_DMIC,
Pablo Greco d6c4c4
+		.device = 0xa0c8,
Pablo Greco d6c4c4
+	},
Pablo Greco d6c4c4
+#endif
Pablo Greco d6c4c4
+/* Coffelake */
Pablo Greco d6c4c4
+#if IS_ENABLED(CONFIG_SND_SOC_SOF_COFFEELAKE)
Pablo Greco d6c4c4
+	{
Pablo Greco d6c4c4
+		.flags = FLAG_SOF | FLAG_SOF_ONLY_IF_DMIC,
Pablo Greco d6c4c4
+		.device = 0xa348,
Pablo Greco d6c4c4
+	},
Pablo Greco d6c4c4
+#endif
Pablo Greco d6c4c4
+};
Pablo Greco d6c4c4
+
Pablo Greco d6c4c4
+static const struct config_entry *snd_intel_dsp_find_config
Pablo Greco d6c4c4
+		(struct pci_dev *pci, const struct config_entry *table, u32 len)
Pablo Greco d6c4c4
+{
Pablo Greco d6c4c4
+	u16 device;
Pablo Greco d6c4c4
+
Pablo Greco d6c4c4
+	device = pci->device;
Pablo Greco d6c4c4
+	for (; len > 0; len--, table++) {
Pablo Greco d6c4c4
+		if (table->device != device)
Pablo Greco d6c4c4
+			continue;
Pablo Greco d6c4c4
+		if (table->dmi_table && !dmi_check_system(table->dmi_table))
Pablo Greco d6c4c4
+			continue;
Pablo Greco d6c4c4
+		return table;
Pablo Greco d6c4c4
+	}
Pablo Greco d6c4c4
+	return NULL;
Pablo Greco d6c4c4
+}
Pablo Greco d6c4c4
+
Pablo Greco d6c4c4
+static int snd_intel_dsp_check_dmic(struct pci_dev *pci)
Pablo Greco d6c4c4
+{
Pablo Greco d6c4c4
+	struct nhlt_acpi_table *nhlt;
Pablo Greco d6c4c4
+	int ret = 0;
Pablo Greco d6c4c4
+
Pablo Greco d6c4c4
+	nhlt = intel_nhlt_init(&pci->dev);
Pablo Greco d6c4c4
+	if (nhlt) {
Pablo Greco d6c4c4
+		if (intel_nhlt_get_dmic_geo(&pci->dev, nhlt))
Pablo Greco d6c4c4
+			ret = 1;
Pablo Greco d6c4c4
+		intel_nhlt_free(nhlt);
Pablo Greco d6c4c4
+	}
Pablo Greco d6c4c4
+	return ret;
Pablo Greco d6c4c4
+}
Pablo Greco d6c4c4
+
Pablo Greco d6c4c4
+int snd_intel_dsp_driver_probe(struct pci_dev *pci)
Pablo Greco d6c4c4
+{
Pablo Greco d6c4c4
+	const struct config_entry *cfg;
Pablo Greco d6c4c4
+
Pablo Greco d6c4c4
+	if (dsp_driver > 0 && dsp_driver <= SND_INTEL_DSP_DRIVER_LAST)
Pablo Greco d6c4c4
+		return dsp_driver;
Pablo Greco d6c4c4
+
Pablo Greco d6c4c4
+	/* Intel vendor only */
Pablo Greco d6c4c4
+	if (snd_BUG_ON(pci->vendor != 0x8086))
Pablo Greco d6c4c4
+		return SND_INTEL_DSP_DRIVER_ANY;
Pablo Greco d6c4c4
+
Pablo Greco d6c4c4
+	/*
Pablo Greco d6c4c4
+	 * detect DSP by checking class/subclass/prog-id information
Pablo Greco d6c4c4
+	 * class=04 subclass 03 prog-if 00: no DSP, use legacy driver
Pablo Greco d6c4c4
+	 * class=04 subclass 01 prog-if 00: DSP is present
Pablo Greco d6c4c4
+	 *  (and may be required e.g. for DMIC or SSP support)
Pablo Greco d6c4c4
+	 * class=04 subclass 03 prog-if 80: use DSP or legacy mode
Pablo Greco d6c4c4
+	 */
Pablo Greco d6c4c4
+	if (pci->class == 0x040300)
Pablo Greco d6c4c4
+		return SND_INTEL_DSP_DRIVER_LEGACY;
Pablo Greco d6c4c4
+	if (pci->class != 0x040100 && pci->class != 0x040380) {
Pablo Greco d6c4c4
+		dev_err(&pci->dev, "Unknown PCI class/subclass/prog-if information (0x%06x) found, selecting HDA legacy driver\n", pci->class);
Pablo Greco d6c4c4
+		return SND_INTEL_DSP_DRIVER_LEGACY;
Pablo Greco d6c4c4
+	}
Pablo Greco d6c4c4
+
Pablo Greco d6c4c4
+	dev_info(&pci->dev, "DSP detected with PCI class/subclass/prog-if info 0x%06x\n", pci->class);
Pablo Greco d6c4c4
+
Pablo Greco d6c4c4
+	/* find the configuration for the specific device */
Pablo Greco d6c4c4
+	cfg = snd_intel_dsp_find_config(pci, config_table, ARRAY_SIZE(config_table));
Pablo Greco d6c4c4
+	if (!cfg)
Pablo Greco d6c4c4
+		return SND_INTEL_DSP_DRIVER_ANY;
Pablo Greco d6c4c4
+
Pablo Greco d6c4c4
+	if (cfg->flags & FLAG_SOF) {
Pablo Greco d6c4c4
+		if (cfg->flags & FLAG_SOF_ONLY_IF_DMIC) {
Pablo Greco d6c4c4
+			if (snd_intel_dsp_check_dmic(pci)) {
Pablo Greco d6c4c4
+				dev_info(&pci->dev, "Digital mics found on Skylake+ platform, using SOF driver\n");
Pablo Greco d6c4c4
+				return SND_INTEL_DSP_DRIVER_SOF;
Pablo Greco d6c4c4
+			}
Pablo Greco d6c4c4
+		} else {
Pablo Greco d6c4c4
+			return SND_INTEL_DSP_DRIVER_SOF;
Pablo Greco d6c4c4
+		}
Pablo Greco d6c4c4
+	}
Pablo Greco d6c4c4
+
Pablo Greco d6c4c4
+	if (cfg->flags & FLAG_SST)
Pablo Greco d6c4c4
+		return SND_INTEL_DSP_DRIVER_SST;
Pablo Greco d6c4c4
+
Pablo Greco d6c4c4
+	return SND_INTEL_DSP_DRIVER_LEGACY;
Pablo Greco d6c4c4
+}
Pablo Greco d6c4c4
+EXPORT_SYMBOL_GPL(snd_intel_dsp_driver_probe);
Pablo Greco d6c4c4
+
Pablo Greco d6c4c4
+MODULE_LICENSE("GPL v2");
Pablo Greco d6c4c4
+MODULE_DESCRIPTION("Intel DSP config driver");
Pablo Greco d6c4c4
diff --git a/sound/hda/intel-nhlt.c b/sound/hda/intel-nhlt.c
Pablo Greco d6c4c4
index daede96f28ee..097ff6c10099 100644
Pablo Greco d6c4c4
--- a/sound/hda/intel-nhlt.c
Pablo Greco d6c4c4
+++ b/sound/hda/intel-nhlt.c
Pablo Greco d6c4c4
@@ -102,6 +102,3 @@ int intel_nhlt_get_dmic_geo(struct device *dev, struct nhlt_acpi_table *nhlt)
Pablo Greco d6c4c4
 	return dmic_geo;
Pablo Greco d6c4c4
 }
Pablo Greco d6c4c4
 EXPORT_SYMBOL_GPL(intel_nhlt_get_dmic_geo);
Pablo Greco d6c4c4
-
Pablo Greco d6c4c4
-MODULE_LICENSE("GPL v2");
Pablo Greco d6c4c4
-MODULE_DESCRIPTION("Intel NHLT driver");
Pablo Greco d6c4c4
diff --git a/sound/pci/hda/Kconfig b/sound/pci/hda/Kconfig
Pablo Greco d6c4c4
index dae47a45b2b8..bd48335d09d7 100644
Pablo Greco d6c4c4
--- a/sound/pci/hda/Kconfig
Pablo Greco d6c4c4
+++ b/sound/pci/hda/Kconfig
Pablo Greco d6c4c4
@@ -12,7 +12,7 @@ config SND_HDA_INTEL
Pablo Greco d6c4c4
 	tristate "HD Audio PCI"
Pablo Greco d6c4c4
 	depends on SND_PCI
Pablo Greco d6c4c4
 	select SND_HDA
Pablo Greco d6c4c4
-	select SND_INTEL_NHLT if ACPI
Pablo Greco d6c4c4
+	select SND_INTEL_DSP_CONFIG
Pablo Greco d6c4c4
 	help
Pablo Greco d6c4c4
 	  Say Y here to include support for Intel "High Definition
Pablo Greco d6c4c4
 	  Audio" (Azalia) and its compatible devices.
Pablo Greco d6c4c4
@@ -23,15 +23,6 @@ config SND_HDA_INTEL
Pablo Greco d6c4c4
 	  To compile this driver as a module, choose M here: the module
Pablo Greco d6c4c4
 	  will be called snd-hda-intel.
Pablo Greco d6c4c4
 
Pablo Greco d6c4c4
-config SND_HDA_INTEL_DETECT_DMIC
Pablo Greco d6c4c4
-	bool "DMIC detection and probe abort"
Pablo Greco d6c4c4
-	depends on SND_HDA_INTEL
Pablo Greco d6c4c4
-	help
Pablo Greco d6c4c4
-	  Say Y to detect digital microphones on SKL+ devices. DMICs
Pablo Greco d6c4c4
-	  cannot be handled by the HDaudio legacy driver and are
Pablo Greco d6c4c4
-	  currently only supported by the SOF driver.
Pablo Greco d6c4c4
-	  If unsure say N.
Pablo Greco d6c4c4
-
Pablo Greco d6c4c4
 config SND_HDA_TEGRA
Pablo Greco d6c4c4
 	tristate "NVIDIA Tegra HD Audio"
Pablo Greco d6c4c4
 	depends on ARCH_TEGRA
Pablo Greco d6c4c4
diff --git a/sound/pci/hda/hda_intel.c b/sound/pci/hda/hda_intel.c
Pablo Greco d6c4c4
index 85beb172d810..2888f710e7e1 100644
Pablo Greco d6c4c4
--- a/sound/pci/hda/hda_intel.c
Pablo Greco d6c4c4
+++ b/sound/pci/hda/hda_intel.c
Pablo Greco d6c4c4
@@ -46,7 +46,7 @@
Pablo Greco d6c4c4
 #include <sound initval.h="">
Pablo Greco d6c4c4
 #include <sound hdaudio.h="">
Pablo Greco d6c4c4
 #include <sound hda_i915.h="">
Pablo Greco d6c4c4
-#include <sound intel-nhlt.h="">
Pablo Greco d6c4c4
+#include <sound intel-dsp-config.h="">
Pablo Greco d6c4c4
 #include <linux vgaarb.h="">
Pablo Greco d6c4c4
 #include <linux vga_switcheroo.h="">
Pablo Greco d6c4c4
 #include <linux firmware.h="">
Pablo Greco d6c4c4
@@ -124,7 +124,7 @@ static char *patch[SNDRV_CARDS];
Pablo Greco d6c4c4
 static bool beep_mode[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS-1)] =
Pablo Greco d6c4c4
 					CONFIG_SND_HDA_INPUT_BEEP_MODE};
Pablo Greco d6c4c4
 #endif
Pablo Greco d6c4c4
-static bool dmic_detect = IS_ENABLED(CONFIG_SND_HDA_INTEL_DETECT_DMIC);
Pablo Greco d6c4c4
+static bool dsp_driver = 1;
Pablo Greco d6c4c4
 
Pablo Greco d6c4c4
 module_param_array(index, int, NULL, 0444);
Pablo Greco d6c4c4
 MODULE_PARM_DESC(index, "Index value for Intel HD audio interface.");
Pablo Greco d6c4c4
@@ -159,8 +159,9 @@ module_param_array(beep_mode, bool, NULL, 0444);
Pablo Greco d6c4c4
 MODULE_PARM_DESC(beep_mode, "Select HDA Beep registration mode "
Pablo Greco d6c4c4
 			    "(0=off, 1=on) (default=1).");
Pablo Greco d6c4c4
 #endif
Pablo Greco d6c4c4
-module_param(dmic_detect, bool, 0444);
Pablo Greco d6c4c4
-MODULE_PARM_DESC(dmic_detect, "DMIC detect on SKL+ platforms");
Pablo Greco d6c4c4
+module_param(dsp_driver, bool, 0444);
Pablo Greco d6c4c4
+MODULE_PARM_DESC(dsp_driver, "Allow DSP driver selection (bypass this driver) "
Pablo Greco d6c4c4
+			     "(0=off, 1=on) (default=1)");
Pablo Greco d6c4c4
 
Pablo Greco d6c4c4
 #ifdef CONFIG_PM
Pablo Greco d6c4c4
 static int param_set_xint(const char *val, const struct kernel_param *kp);
Pablo Greco d6c4c4
@@ -2030,25 +2031,6 @@ static const struct hda_controller_ops pci_hda_ops = {
Pablo Greco d6c4c4
 	.position_check = azx_position_check,
Pablo Greco d6c4c4
 };
Pablo Greco d6c4c4
 
Pablo Greco d6c4c4
-static int azx_check_dmic(struct pci_dev *pci, struct azx *chip)
Pablo Greco d6c4c4
-{
Pablo Greco d6c4c4
-	struct nhlt_acpi_table *nhlt;
Pablo Greco d6c4c4
-	int ret = 0;
Pablo Greco d6c4c4
-
Pablo Greco d6c4c4
-	if (chip->driver_type == AZX_DRIVER_SKL &&
Pablo Greco d6c4c4
-	    pci->class != 0x040300) {
Pablo Greco d6c4c4
-		nhlt = intel_nhlt_init(&pci->dev);
Pablo Greco d6c4c4
-		if (nhlt) {
Pablo Greco d6c4c4
-			if (intel_nhlt_get_dmic_geo(&pci->dev, nhlt)) {
Pablo Greco d6c4c4
-				ret = -ENODEV;
Pablo Greco d6c4c4
-				dev_info(&pci->dev, "Digital mics found on Skylake+ platform, aborting probe\n");
Pablo Greco d6c4c4
-			}
Pablo Greco d6c4c4
-			intel_nhlt_free(nhlt);
Pablo Greco d6c4c4
-		}
Pablo Greco d6c4c4
-	}
Pablo Greco d6c4c4
-	return ret;
Pablo Greco d6c4c4
-}
Pablo Greco d6c4c4
-
Pablo Greco d6c4c4
 static int azx_probe(struct pci_dev *pci,
Pablo Greco d6c4c4
 		     const struct pci_device_id *pci_id)
Pablo Greco d6c4c4
 {
Pablo Greco d6c4c4
@@ -2066,6 +2048,16 @@ static int azx_probe(struct pci_dev *pci,
Pablo Greco d6c4c4
 		return -ENOENT;
Pablo Greco d6c4c4
 	}
Pablo Greco d6c4c4
 
Pablo Greco d6c4c4
+	/*
Pablo Greco d6c4c4
+	 * stop probe if another Intel's DSP driver should be activated
Pablo Greco d6c4c4
+	 */
Pablo Greco d6c4c4
+	if (dsp_driver) {
Pablo Greco d6c4c4
+		err = snd_intel_dsp_driver_probe(pci);
Pablo Greco d6c4c4
+		if (err != SND_INTEL_DSP_DRIVER_ANY &&
Pablo Greco d6c4c4
+		    err != SND_INTEL_DSP_DRIVER_LEGACY)
Pablo Greco d6c4c4
+			return -ENODEV;
Pablo Greco d6c4c4
+	}
Pablo Greco d6c4c4
+
Pablo Greco d6c4c4
 	err = snd_card_new(&pci->dev, index[dev], id[dev], THIS_MODULE,
Pablo Greco d6c4c4
 			   0, &card);
Pablo Greco d6c4c4
 	if (err < 0) {
Pablo Greco d6c4c4
@@ -2079,17 +2071,6 @@ static int azx_probe(struct pci_dev *pci,
Pablo Greco d6c4c4
 	card->private_data = chip;
Pablo Greco d6c4c4
 	hda = container_of(chip, struct hda_intel, chip);
Pablo Greco d6c4c4
 
Pablo Greco d6c4c4
-	/*
Pablo Greco d6c4c4
-	 * stop probe if digital microphones detected on Skylake+ platform
Pablo Greco d6c4c4
-	 * with the DSP enabled. This is an opt-in behavior defined at build
Pablo Greco d6c4c4
-	 * time or at run-time with a module parameter
Pablo Greco d6c4c4
-	 */
Pablo Greco d6c4c4
-	if (dmic_detect) {
Pablo Greco d6c4c4
-		err = azx_check_dmic(pci, chip);
Pablo Greco d6c4c4
-		if (err < 0)
Pablo Greco d6c4c4
-			goto out_free;
Pablo Greco d6c4c4
-	}
Pablo Greco d6c4c4
-
Pablo Greco d6c4c4
 	pci_set_drvdata(pci, card);
Pablo Greco d6c4c4
 
Pablo Greco d6c4c4
 	err = register_vga_switcheroo(chip);
Pablo Greco d6c4c4
diff --git a/sound/soc/intel/Kconfig b/sound/soc/intel/Kconfig
Pablo Greco d6c4c4
index ef493cae78ff..c15230cec851 100644
Pablo Greco d6c4c4
--- a/sound/soc/intel/Kconfig
Pablo Greco d6c4c4
+++ b/sound/soc/intel/Kconfig
Pablo Greco d6c4c4
@@ -218,7 +218,7 @@ config SND_SOC_INTEL_SKYLAKE_COMMON
Pablo Greco d6c4c4
 	select SND_SOC_INTEL_SST
Pablo Greco d6c4c4
 	select SND_SOC_HDAC_HDA if SND_SOC_INTEL_SKYLAKE_HDAUDIO_CODEC
Pablo Greco d6c4c4
 	select SND_SOC_ACPI_INTEL_MATCH
Pablo Greco d6c4c4
-	select SND_INTEL_NHLT if ACPI
Pablo Greco d6c4c4
+	select SND_INTEL_DSP_CONFIG
Pablo Greco d6c4c4
 	help
Pablo Greco d6c4c4
 	  If you have a Intel Skylake/Broxton/ApolloLake/KabyLake/
Pablo Greco d6c4c4
 	  GeminiLake or CannonLake platform with the DSP enabled in the BIOS
Pablo Greco d6c4c4
diff --git a/sound/soc/intel/skylake/skl.c b/sound/soc/intel/skylake/skl.c
Pablo Greco d6c4c4
index 141dbbf975ac..58ba3e9469ba 100644
Pablo Greco d6c4c4
--- a/sound/soc/intel/skylake/skl.c
Pablo Greco d6c4c4
+++ b/sound/soc/intel/skylake/skl.c
Pablo Greco d6c4c4
@@ -27,6 +27,7 @@
Pablo Greco d6c4c4
 #include <sound hda_i915.h="">
Pablo Greco d6c4c4
 #include <sound hda_codec.h="">
Pablo Greco d6c4c4
 #include <sound intel-nhlt.h="">
Pablo Greco d6c4c4
+#include <sound intel-dsp-config.h="">
Pablo Greco d6c4c4
 #include "skl.h"
Pablo Greco d6c4c4
 #include "skl-sst-dsp.h"
Pablo Greco d6c4c4
 #include "skl-sst-ipc.h"
Pablo Greco d6c4c4
@@ -987,22 +988,10 @@ static int skl_probe(struct pci_dev *pci,
Pablo Greco d6c4c4
 
Pablo Greco d6c4c4
 	switch (skl_pci_binding) {
Pablo Greco d6c4c4
 	case SND_SKL_PCI_BIND_AUTO:
Pablo Greco d6c4c4
-		/*
Pablo Greco d6c4c4
-		 * detect DSP by checking class/subclass/prog-id information
Pablo Greco d6c4c4
-		 * class=04 subclass 03 prog-if 00: no DSP, use legacy driver
Pablo Greco d6c4c4
-		 * class=04 subclass 01 prog-if 00: DSP is present
Pablo Greco d6c4c4
-		 *   (and may be required e.g. for DMIC or SSP support)
Pablo Greco d6c4c4
-		 * class=04 subclass 03 prog-if 80: use DSP or legacy mode
Pablo Greco d6c4c4
-		 */
Pablo Greco d6c4c4
-		if (pci->class == 0x040300) {
Pablo Greco d6c4c4
-			dev_info(&pci->dev, "The DSP is not enabled on this platform, aborting probe\n");
Pablo Greco d6c4c4
+		err = snd_intel_dsp_driver_probe(pci);
Pablo Greco d6c4c4
+		if (err != SND_INTEL_DSP_DRIVER_ANY &&
Pablo Greco d6c4c4
+		    err != SND_INTEL_DSP_DRIVER_SST)
Pablo Greco d6c4c4
 			return -ENODEV;
Pablo Greco d6c4c4
-		}
Pablo Greco d6c4c4
-		if (pci->class != 0x040100 && pci->class != 0x040380) {
Pablo Greco d6c4c4
-			dev_err(&pci->dev, "Unknown PCI class/subclass/prog-if information (0x%06x) found, aborting probe\n", pci->class);
Pablo Greco d6c4c4
-			return -ENODEV;
Pablo Greco d6c4c4
-		}
Pablo Greco d6c4c4
-		dev_info(&pci->dev, "DSP detected with PCI class/subclass/prog-if info 0x%06x\n", pci->class);
Pablo Greco d6c4c4
 		break;
Pablo Greco d6c4c4
 	case SND_SKL_PCI_BIND_LEGACY:
Pablo Greco d6c4c4
 		dev_info(&pci->dev, "Module parameter forced binding with HDaudio legacy, aborting probe\n");
Pablo Greco d6c4c4
diff --git a/sound/soc/sof/intel/Kconfig b/sound/soc/sof/intel/Kconfig
Pablo Greco d6c4c4
index 8421b97d949e..d6d65e70eebb 100644
Pablo Greco d6c4c4
--- a/sound/soc/sof/intel/Kconfig
Pablo Greco d6c4c4
+++ b/sound/soc/sof/intel/Kconfig
Pablo Greco d6c4c4
@@ -304,7 +304,7 @@ config SND_SOC_SOF_HDA
Pablo Greco d6c4c4
 	tristate
Pablo Greco d6c4c4
 	select SND_HDA_EXT_CORE if SND_SOC_SOF_HDA_LINK
Pablo Greco d6c4c4
 	select SND_SOC_HDAC_HDA if SND_SOC_SOF_HDA_AUDIO_CODEC
Pablo Greco d6c4c4
-	select SND_INTEL_NHLT if ACPI
Pablo Greco d6c4c4
+	select SND_INTEL_DSP_CONFIG
Pablo Greco d6c4c4
 	help
Pablo Greco d6c4c4
 	  This option is not user-selectable but automagically handled by
Pablo Greco d6c4c4
 	  'select' statements at a higher level
Pablo Greco d6c4c4
diff --git a/sound/soc/sof/sof-pci-dev.c b/sound/soc/sof/sof-pci-dev.c
Pablo Greco d6c4c4
index d66412a77873..3a9e0e2a150d 100644
Pablo Greco d6c4c4
--- a/sound/soc/sof/sof-pci-dev.c
Pablo Greco d6c4c4
+++ b/sound/soc/sof/sof-pci-dev.c
Pablo Greco d6c4c4
@@ -12,6 +12,7 @@
Pablo Greco d6c4c4
 #include <linux module.h="">
Pablo Greco d6c4c4
 #include <linux pci.h="">
Pablo Greco d6c4c4
 #include <linux pm_runtime.h="">
Pablo Greco d6c4c4
+#include <sound intel-dsp-config.h="">
Pablo Greco d6c4c4
 #include <sound soc-acpi.h="">
Pablo Greco d6c4c4
 #include <sound soc-acpi-intel-match.h="">
Pablo Greco d6c4c4
 #include <sound sof.h="">
Pablo Greco d6c4c4
@@ -277,6 +278,11 @@ static int sof_pci_probe(struct pci_dev *pci,
Pablo Greco d6c4c4
 	const struct snd_sof_dsp_ops *ops;
Pablo Greco d6c4c4
 	int ret;
Pablo Greco d6c4c4
 
Pablo Greco d6c4c4
+	ret = snd_intel_dsp_driver_probe(pci);
Pablo Greco d6c4c4
+	if (ret != SND_INTEL_DSP_DRIVER_ANY &&
Pablo Greco d6c4c4
+	    ret != SND_INTEL_DSP_DRIVER_SOF)
Pablo Greco d6c4c4
+		return -ENODEV;
Pablo Greco d6c4c4
+
Pablo Greco d6c4c4
 	dev_dbg(&pci->dev, "PCI DSP detected");
Pablo Greco d6c4c4
 
Pablo Greco d6c4c4
 	/* get ops for platform */
Pablo Greco d6c4c4
-- 
Pablo Greco d6c4c4
2.24.1
Pablo Greco d6c4c4
Pablo Greco d6c4c4
From 08086a70efd7f4db4645e2a7b60b2aba4b620b18 Mon Sep 17 00:00:00 2001
Pablo Greco d6c4c4
From: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Pablo Greco d6c4c4
Date: Tue, 22 Oct 2019 19:43:13 +0200
Pablo Greco d6c4c4
Subject: [PATCH 005/109] ALSA: hda: fix intel DSP config
Pablo Greco d6c4c4
Pablo Greco d6c4c4
Reshuffle list of devices by historical order and add correct
Pablo Greco d6c4c4
information as needed.
Pablo Greco d6c4c4
Pablo Greco d6c4c4
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Pablo Greco d6c4c4
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
Pablo Greco d6c4c4
Link: https://lore.kernel.org/r/20191022174313.29087-2-perex@perex.cz
Pablo Greco d6c4c4
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Pablo Greco d6c4c4
Pablo Greco d6c4c4
Signed-off-by: Jaroslav Kysela <jkysela@redhat.com>
Pablo Greco d6c4c4
(cherry picked from commit cc8f81c7e625168a60843b2b39e3a327cf5170fe)
Pablo Greco d6c4c4
Bugzilla: 1772498
Pablo Greco d6c4c4
---
Pablo Greco d6c4c4
 sound/hda/intel-dsp-config.c | 220 ++++++++++++++++++++++++++---------
Pablo Greco d6c4c4
 1 file changed, 164 insertions(+), 56 deletions(-)
Pablo Greco d6c4c4
Pablo Greco d6c4c4
diff --git a/sound/hda/intel-dsp-config.c b/sound/hda/intel-dsp-config.c
Pablo Greco d6c4c4
index d9f6d9e872b4..0b2a7201a46a 100644
Pablo Greco d6c4c4
--- a/sound/hda/intel-dsp-config.c
Pablo Greco d6c4c4
+++ b/sound/hda/intel-dsp-config.c
Pablo Greco d6c4c4
@@ -30,45 +30,98 @@ struct config_entry {
Pablo Greco d6c4c4
  * - the first successful match will win
Pablo Greco d6c4c4
  */
Pablo Greco d6c4c4
 static const struct config_entry config_table[] = {
Pablo Greco d6c4c4
-/* Cometlake-LP */
Pablo Greco d6c4c4
-#if IS_ENABLED(CONFIG_SND_SOC_INTEL_CML_LP)
Pablo Greco d6c4c4
+/* Merrifield */
Pablo Greco d6c4c4
+#if IS_ENABLED(CONFIG_SND_SOC_SOF_MERRIFIELD)
Pablo Greco d6c4c4
 	{
Pablo Greco d6c4c4
-		/* prefer SST */
Pablo Greco d6c4c4
-		.flags = FLAG_SST,
Pablo Greco d6c4c4
-		.device = 0x02c8,
Pablo Greco d6c4c4
+		.flags = FLAG_SOF,
Pablo Greco d6c4c4
+		.device = 0x119a,
Pablo Greco d6c4c4
 	},
Pablo Greco d6c4c4
-#elif IS_ENABLED(CONFIG_SND_SOC_SOF_COMETLAKE_LP)
Pablo Greco d6c4c4
+#endif
Pablo Greco d6c4c4
+/* Broxton-T */
Pablo Greco d6c4c4
+#if IS_ENABLED(CONFIG_SND_SOC_SOF_APOLLOLAKE)
Pablo Greco d6c4c4
 	{
Pablo Greco d6c4c4
 		.flags = FLAG_SOF,
Pablo Greco d6c4c4
-		.device = 0x02c8,
Pablo Greco d6c4c4
+		.device = 0x1a98,
Pablo Greco d6c4c4
 	},
Pablo Greco d6c4c4
 #endif
Pablo Greco d6c4c4
-/* Cometlake-H */
Pablo Greco d6c4c4
-#if IS_ENABLED(CONFIG_SND_SOC_INTEL_CML_H)
Pablo Greco d6c4c4
+/*
Pablo Greco d6c4c4
+ * Apollolake (Broxton-P)
Pablo Greco d6c4c4
+ * the legacy HDaudio driver is used except on Up Squared (SOF) and
Pablo Greco d6c4c4
+ * Chromebooks (SST)
Pablo Greco d6c4c4
+ */
Pablo Greco d6c4c4
+#if IS_ENABLED(CONFIG_SND_SOC_SOF_APOLLOLAKE)
Pablo Greco d6c4c4
 	{
Pablo Greco d6c4c4
-		.flags = FLAG_SST,
Pablo Greco d6c4c4
-		.device = 0x06c8,
Pablo Greco d6c4c4
+		.flags = FLAG_SOF,
Pablo Greco d6c4c4
+		.device = 0x5a98,
Pablo Greco d6c4c4
+		.dmi_table = (const struct dmi_system_id []) {
Pablo Greco d6c4c4
+			{
Pablo Greco d6c4c4
+				.ident = "Up Squared",
Pablo Greco d6c4c4
+				.matches = {
Pablo Greco d6c4c4
+					DMI_MATCH(DMI_SYS_VENDOR, "AAEON"),
Pablo Greco d6c4c4
+					DMI_MATCH(DMI_BOARD_NAME, "UP-APL01"),
Pablo Greco d6c4c4
+				}
Pablo Greco d6c4c4
+			},
Pablo Greco d6c4c4
+			{}
Pablo Greco d6c4c4
+		}
Pablo Greco d6c4c4
 	},
Pablo Greco d6c4c4
-#elif IS_ENABLED(CONFIG_SND_SOC_SOF_COMETLAKE_H)
Pablo Greco d6c4c4
+#endif
Pablo Greco d6c4c4
+#if IS_ENABLED(CONFIG_SND_SOC_INTEL_APL)
Pablo Greco d6c4c4
 	{
Pablo Greco d6c4c4
-		.flags = FLAG_SOF,
Pablo Greco d6c4c4
-		.device = 0x06c8,
Pablo Greco d6c4c4
+		.flags = FLAG_SST,
Pablo Greco d6c4c4
+		.device = 0x5a98,
Pablo Greco d6c4c4
+		.dmi_table = (const struct dmi_system_id []) {
Pablo Greco d6c4c4
+			{
Pablo Greco d6c4c4
+				.ident = "Google Chromebooks",
Pablo Greco d6c4c4
+				.matches = {
Pablo Greco d6c4c4
+					DMI_MATCH(DMI_SYS_VENDOR, "Google"),
Pablo Greco d6c4c4
+				}
Pablo Greco d6c4c4
+			},
Pablo Greco d6c4c4
+			{}
Pablo Greco d6c4c4
+		}
Pablo Greco d6c4c4
 	},
Pablo Greco d6c4c4
 #endif
Pablo Greco d6c4c4
-/* Merrifield */
Pablo Greco d6c4c4
-#if IS_ENABLED(CONFIG_SND_SOC_SOF_MERRIFIELD)
Pablo Greco d6c4c4
+/*
Pablo Greco d6c4c4
+ * Skylake and Kabylake use legacy HDaudio driver except for Google
Pablo Greco d6c4c4
+ * Chromebooks (SST)
Pablo Greco d6c4c4
+ */
Pablo Greco d6c4c4
+
Pablo Greco d6c4c4
+/* Sunrise Point-LP */
Pablo Greco d6c4c4
+#if IS_ENABLED(CONFIG_SND_SOC_INTEL_SKL)
Pablo Greco d6c4c4
 	{
Pablo Greco d6c4c4
-		.flags = FLAG_SOF,
Pablo Greco d6c4c4
-		.device = 0x119a,
Pablo Greco d6c4c4
+		.flags = FLAG_SST,
Pablo Greco d6c4c4
+		.device = 0x9d70,
Pablo Greco d6c4c4
+		.dmi_table = (const struct dmi_system_id []) {
Pablo Greco d6c4c4
+			{
Pablo Greco d6c4c4
+				.ident = "Google Chromebooks",
Pablo Greco d6c4c4
+				.matches = {
Pablo Greco d6c4c4
+					DMI_MATCH(DMI_SYS_VENDOR, "Google"),
Pablo Greco d6c4c4
+				}
Pablo Greco d6c4c4
+			},
Pablo Greco d6c4c4
+			{}
Pablo Greco d6c4c4
+		}
Pablo Greco d6c4c4
 	},
Pablo Greco d6c4c4
 #endif
Pablo Greco d6c4c4
-/* Broxton-T */
Pablo Greco d6c4c4
-#if IS_ENABLED(CONFIG_SND_SOC_SOF_APOLLOLAKE)
Pablo Greco d6c4c4
+/* Kabylake-LP */
Pablo Greco d6c4c4
+#if IS_ENABLED(CONFIG_SND_SOC_INTEL_KBL)
Pablo Greco d6c4c4
 	{
Pablo Greco d6c4c4
-		.flags = FLAG_SOF | FLAG_SOF_ONLY_IF_DMIC,
Pablo Greco d6c4c4
-		.device = 0x1a98,
Pablo Greco d6c4c4
+		.flags = FLAG_SST,
Pablo Greco d6c4c4
+		.device = 0x9d71,
Pablo Greco d6c4c4
+		.dmi_table = (const struct dmi_system_id []) {
Pablo Greco d6c4c4
+			{
Pablo Greco d6c4c4
+				.ident = "Google Chromebooks",
Pablo Greco d6c4c4
+				.matches = {
Pablo Greco d6c4c4
+					DMI_MATCH(DMI_SYS_VENDOR, "Google"),
Pablo Greco d6c4c4
+				}
Pablo Greco d6c4c4
+			},
Pablo Greco d6c4c4
+			{}
Pablo Greco d6c4c4
+		}
Pablo Greco d6c4c4
 	},
Pablo Greco d6c4c4
 #endif
Pablo Greco d6c4c4
+
Pablo Greco d6c4c4
+/*
Pablo Greco d6c4c4
+ * Geminilake uses legacy HDaudio driver except for Google
Pablo Greco d6c4c4
+ * Chromebooks
Pablo Greco d6c4c4
+ */
Pablo Greco d6c4c4
 /* Geminilake */
Pablo Greco d6c4c4
 #if IS_ENABLED(CONFIG_SND_SOC_SOF_GEMINILAKE)
Pablo Greco d6c4c4
 	{
Pablo Greco d6c4c4
@@ -85,84 +138,139 @@ static const struct config_entry config_table[] = {
Pablo Greco d6c4c4
 		}
Pablo Greco d6c4c4
 	},
Pablo Greco d6c4c4
 #endif
Pablo Greco d6c4c4
-#if IS_ENABLED(CONFIG_SND_SOC_INTEL_GLK)
Pablo Greco d6c4c4
+
Pablo Greco d6c4c4
+/*
Pablo Greco d6c4c4
+ * CoffeeLake, CannonLake, CometLake, IceLake, TigerLake use legacy
Pablo Greco d6c4c4
+ * HDaudio driver except for Google Chromebooks and when DMICs are
Pablo Greco d6c4c4
+ * present. Two cases are required since Coreboot does not expose NHLT
Pablo Greco d6c4c4
+ * tables.
Pablo Greco d6c4c4
+ *
Pablo Greco d6c4c4
+ * When the Chromebook quirk is not present, it's based on information
Pablo Greco d6c4c4
+ * that no such device exists. When the quirk is present, it could be
Pablo Greco d6c4c4
+ * either based on product information or a placeholder.
Pablo Greco d6c4c4
+ */
Pablo Greco d6c4c4
+
Pablo Greco d6c4c4
+/* Cannonlake */
Pablo Greco d6c4c4
+#if IS_ENABLED(CONFIG_SND_SOC_SOF_CANNONLAKE)
Pablo Greco d6c4c4
 	{
Pablo Greco d6c4c4
-		.flags = FLAG_SST,
Pablo Greco d6c4c4
-		.device = 0x3198,
Pablo Greco d6c4c4
+		.flags = FLAG_SOF,
Pablo Greco d6c4c4
+		.device = 0x9dc8,
Pablo Greco d6c4c4
+		.dmi_table = (const struct dmi_system_id []) {
Pablo Greco d6c4c4
+			{
Pablo Greco d6c4c4
+				.ident = "Google Chromebooks",
Pablo Greco d6c4c4
+				.matches = {
Pablo Greco d6c4c4
+					DMI_MATCH(DMI_SYS_VENDOR, "Google"),
Pablo Greco d6c4c4
+				}
Pablo Greco d6c4c4
+			},
Pablo Greco d6c4c4
+			{}
Pablo Greco d6c4c4
+		}
Pablo Greco d6c4c4
 	},
Pablo Greco d6c4c4
-#endif
Pablo Greco d6c4c4
-/* Icelake */
Pablo Greco d6c4c4
-#if IS_ENABLED(CONFIG_SND_SOC_SOF_ICELAKE)
Pablo Greco d6c4c4
 	{
Pablo Greco d6c4c4
 		.flags = FLAG_SOF | FLAG_SOF_ONLY_IF_DMIC,
Pablo Greco d6c4c4
-		.device = 0x34c8,
Pablo Greco d6c4c4
+		.device = 0x9dc8,
Pablo Greco d6c4c4
 	},
Pablo Greco d6c4c4
 #endif
Pablo Greco d6c4c4
-/* Elkhart Lake */
Pablo Greco d6c4c4
-#if IS_ENABLED(CONFIG_SND_SOC_SOF_ELKHARTLAKE)
Pablo Greco d6c4c4
+
Pablo Greco d6c4c4
+/* Coffelake */
Pablo Greco d6c4c4
+#if IS_ENABLED(CONFIG_SND_SOC_SOF_COFFEELAKE)
Pablo Greco d6c4c4
+	{
Pablo Greco d6c4c4
+		.flags = FLAG_SOF,
Pablo Greco d6c4c4
+		.device = 0xa348,
Pablo Greco d6c4c4
+		.dmi_table = (const struct dmi_system_id []) {
Pablo Greco d6c4c4
+			{
Pablo Greco d6c4c4
+				.ident = "Google Chromebooks",
Pablo Greco d6c4c4
+				.matches = {
Pablo Greco d6c4c4
+					DMI_MATCH(DMI_SYS_VENDOR, "Google"),
Pablo Greco d6c4c4
+				}
Pablo Greco d6c4c4
+			},
Pablo Greco d6c4c4
+			{}
Pablo Greco d6c4c4
+		}
Pablo Greco d6c4c4
+	},
Pablo Greco d6c4c4
 	{
Pablo Greco d6c4c4
 		.flags = FLAG_SOF | FLAG_SOF_ONLY_IF_DMIC,
Pablo Greco d6c4c4
-		.device = 0x4b55,
Pablo Greco d6c4c4
+		.device = 0xa348,
Pablo Greco d6c4c4
 	},
Pablo Greco d6c4c4
 #endif
Pablo Greco d6c4c4
-/* Appololake (Broxton-P) */
Pablo Greco d6c4c4
-#if IS_ENABLED(CONFIG_SND_SOC_SOF_APOLLOLAKE)
Pablo Greco d6c4c4
+
Pablo Greco d6c4c4
+/* Cometlake-LP */
Pablo Greco d6c4c4
+#if IS_ENABLED(CONFIG_SND_SOC_SOF_COMETLAKE_LP)
Pablo Greco d6c4c4
 	{
Pablo Greco d6c4c4
 		.flags = FLAG_SOF,
Pablo Greco d6c4c4
-		.device = 0x5a98,
Pablo Greco d6c4c4
+		.device = 0x02c8,
Pablo Greco d6c4c4
 		.dmi_table = (const struct dmi_system_id []) {
Pablo Greco d6c4c4
 			{
Pablo Greco d6c4c4
-				.ident = "Up Squared",
Pablo Greco d6c4c4
+				.ident = "Google Chromebooks",
Pablo Greco d6c4c4
 				.matches = {
Pablo Greco d6c4c4
-					DMI_MATCH(DMI_SYS_VENDOR, "AAEON"),
Pablo Greco d6c4c4
-					DMI_MATCH(DMI_BOARD_NAME, "UP-APL01"),
Pablo Greco d6c4c4
+					DMI_MATCH(DMI_SYS_VENDOR, "Google"),
Pablo Greco d6c4c4
 				}
Pablo Greco d6c4c4
 			},
Pablo Greco d6c4c4
 			{}
Pablo Greco d6c4c4
 		}
Pablo Greco d6c4c4
 	},
Pablo Greco d6c4c4
-#endif
Pablo Greco d6c4c4
-#if IS_ENABLED(CONFIG_SND_SOC_INTEL_APL)
Pablo Greco d6c4c4
 	{
Pablo Greco d6c4c4
-		.flags = FLAG_SST,
Pablo Greco d6c4c4
-		.device = 0x5a98,
Pablo Greco d6c4c4
+		.flags = FLAG_SOF | FLAG_SOF_ONLY_IF_DMIC,
Pablo Greco d6c4c4
+		.device = 0x02c8,
Pablo Greco d6c4c4
 	},
Pablo Greco d6c4c4
 #endif
Pablo Greco d6c4c4
-/* Cannonlake */
Pablo Greco d6c4c4
-#if IS_ENABLED(CONFIG_SND_SOC_SOF_CANNONLAKE)
Pablo Greco d6c4c4
+/* Cometlake-H */
Pablo Greco d6c4c4
+#if IS_ENABLED(CONFIG_SND_SOC_SOF_COMETLAKE_H)
Pablo Greco d6c4c4
 	{
Pablo Greco d6c4c4
 		.flags = FLAG_SOF | FLAG_SOF_ONLY_IF_DMIC,
Pablo Greco d6c4c4
-		.device = 0x9dc8,
Pablo Greco d6c4c4
+		.device = 0x06c8,
Pablo Greco d6c4c4
 	},
Pablo Greco d6c4c4
 #endif
Pablo Greco d6c4c4
-/* Sunrise Point-LP */
Pablo Greco d6c4c4
-#if IS_ENABLED(CONFIG_SND_SOC_SOF_SKYLAKE)
Pablo Greco d6c4c4
+
Pablo Greco d6c4c4
+/* Icelake */
Pablo Greco d6c4c4
+#if IS_ENABLED(CONFIG_SND_SOC_SOF_ICELAKE)
Pablo Greco d6c4c4
 	{
Pablo Greco d6c4c4
-		.flags = FLAG_SOF | FLAG_SOF_ONLY_IF_DMIC,
Pablo Greco d6c4c4
-		.device = 0x9d70,
Pablo Greco d6c4c4
+		.flags = FLAG_SOF,
Pablo Greco d6c4c4
+		.device = 0x34c8,
Pablo Greco d6c4c4
+		.dmi_table = (const struct dmi_system_id []) {
Pablo Greco d6c4c4
+			{
Pablo Greco d6c4c4
+				.ident = "Google Chromebooks",
Pablo Greco d6c4c4
+				.matches = {
Pablo Greco d6c4c4
+					DMI_MATCH(DMI_SYS_VENDOR, "Google"),
Pablo Greco d6c4c4
+				}
Pablo Greco d6c4c4
+			},
Pablo Greco d6c4c4
+			{}
Pablo Greco d6c4c4
+		}
Pablo Greco d6c4c4
 	},
Pablo Greco d6c4c4
-#endif
Pablo Greco d6c4c4
-/* Kabylake-LP */
Pablo Greco d6c4c4
-#if IS_ENABLED(CONFIG_SND_SOC_SOF_KABYLAKE)
Pablo Greco d6c4c4
 	{
Pablo Greco d6c4c4
 		.flags = FLAG_SOF | FLAG_SOF_ONLY_IF_DMIC,
Pablo Greco d6c4c4
-		.device = 0x9d71,
Pablo Greco d6c4c4
+		.device = 0x34c8,
Pablo Greco d6c4c4
 	},
Pablo Greco d6c4c4
 #endif
Pablo Greco d6c4c4
+
Pablo Greco d6c4c4
 /* Tigerlake */
Pablo Greco d6c4c4
 #if IS_ENABLED(CONFIG_SND_SOC_SOF_TIGERLAKE)
Pablo Greco d6c4c4
+	{
Pablo Greco d6c4c4
+		.flags = FLAG_SOF,
Pablo Greco d6c4c4
+		.device = 0xa0c8,
Pablo Greco d6c4c4
+		.dmi_table = (const struct dmi_system_id []) {
Pablo Greco d6c4c4
+			{
Pablo Greco d6c4c4
+				.ident = "Google Chromebooks",
Pablo Greco d6c4c4
+				.matches = {
Pablo Greco d6c4c4
+					DMI_MATCH(DMI_SYS_VENDOR, "Google"),
Pablo Greco d6c4c4
+				}
Pablo Greco d6c4c4
+			},
Pablo Greco d6c4c4
+			{}
Pablo Greco d6c4c4
+		}
Pablo Greco d6c4c4
+	},
Pablo Greco d6c4c4
+
Pablo Greco d6c4c4
 	{
Pablo Greco d6c4c4
 		.flags = FLAG_SOF | FLAG_SOF_ONLY_IF_DMIC,
Pablo Greco d6c4c4
 		.device = 0xa0c8,
Pablo Greco d6c4c4
 	},
Pablo Greco d6c4c4
 #endif
Pablo Greco d6c4c4
-/* Coffelake */
Pablo Greco d6c4c4
-#if IS_ENABLED(CONFIG_SND_SOC_SOF_COFFEELAKE)
Pablo Greco d6c4c4
+
Pablo Greco d6c4c4
+/* Elkhart Lake */
Pablo Greco d6c4c4
+#if IS_ENABLED(CONFIG_SND_SOC_SOF_ELKHARTLAKE)
Pablo Greco d6c4c4
 	{
Pablo Greco d6c4c4
 		.flags = FLAG_SOF | FLAG_SOF_ONLY_IF_DMIC,
Pablo Greco d6c4c4
-		.device = 0xa348,
Pablo Greco d6c4c4
+		.device = 0x4b55,
Pablo Greco d6c4c4
 	},
Pablo Greco d6c4c4
 #endif
Pablo Greco d6c4c4
+
Pablo Greco d6c4c4
 };
Pablo Greco d6c4c4
 
Pablo Greco d6c4c4
 static const struct config_entry *snd_intel_dsp_find_config
Pablo Greco d6c4c4
-- 
Pablo Greco d6c4c4
2.24.1
Pablo Greco d6c4c4
Pablo Greco d6c4c4
From 5cd51df6f836090343aadd7ea4eacfde511660ad Mon Sep 17 00:00:00 2001
Pablo Greco d6c4c4
From: Jaroslav Kysela <perex@perex.cz>
Pablo Greco d6c4c4
Date: Mon, 28 Oct 2019 17:46:24 +0100
Pablo Greco d6c4c4
Subject: [PATCH 006/109] ASoC: intel - fix the card names
Pablo Greco d6c4c4
Pablo Greco d6c4c4
Those strings are exposed to the user space as the
Pablo Greco d6c4c4
card name thus used in the GUIs. The common
Pablo Greco d6c4c4
standard is to avoid '_' here. The worst case
Pablo Greco d6c4c4
is 'sof-skl_hda_card' string.
Pablo Greco d6c4c4
Pablo Greco d6c4c4
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
Pablo Greco d6c4c4
Cc: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Pablo Greco d6c4c4
Cc: Mark Brown <broonie@kernel.org>
Pablo Greco d6c4c4
Acked-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Pablo Greco d6c4c4
Link: https://lore.kernel.org/r/20191028164624.14334-1-perex@perex.cz
Pablo Greco d6c4c4
Signed-off-by: Mark Brown <broonie@kernel.org>
Pablo Greco d6c4c4
Pablo Greco d6c4c4
Signed-off-by: Jaroslav Kysela <jkysela@redhat.com>
Pablo Greco d6c4c4
(cherry picked from commit d745cc1ab65945b2d17ec9c5652f38299c054649)
Pablo Greco d6c4c4
Bugzilla: 1772498
Pablo Greco d6c4c4
---
Pablo Greco d6c4c4
 sound/soc/intel/boards/kbl_rt5663_rt5514_max98927.c | 2 +-
Pablo Greco d6c4c4
 sound/soc/intel/boards/skl_hda_dsp_generic.c        | 2 +-
Pablo Greco d6c4c4
 sound/soc/intel/boards/sof_rt5682.c                 | 2 +-
Pablo Greco d6c4c4
 3 files changed, 3 insertions(+), 3 deletions(-)
Pablo Greco d6c4c4
Pablo Greco d6c4c4
diff --git a/sound/soc/intel/boards/kbl_rt5663_rt5514_max98927.c b/sound/soc/intel/boards/kbl_rt5663_rt5514_max98927.c
Pablo Greco d6c4c4
index 67b276a65a8d..8ad31c91fc75 100644
Pablo Greco d6c4c4
--- a/sound/soc/intel/boards/kbl_rt5663_rt5514_max98927.c
Pablo Greco d6c4c4
+++ b/sound/soc/intel/boards/kbl_rt5663_rt5514_max98927.c
Pablo Greco d6c4c4
@@ -626,7 +626,7 @@ static int kabylake_card_late_probe(struct snd_soc_card *card)
Pablo Greco d6c4c4
  * kabylake audio machine driver for  MAX98927 + RT5514 + RT5663
Pablo Greco d6c4c4
  */
Pablo Greco d6c4c4
 static struct snd_soc_card kabylake_audio_card = {
Pablo Greco d6c4c4
-	.name = "kbl_r5514_5663_max",
Pablo Greco d6c4c4
+	.name = "kbl-r5514-5663-max",
Pablo Greco d6c4c4
 	.owner = THIS_MODULE,
Pablo Greco d6c4c4
 	.dai_link = kabylake_dais,
Pablo Greco d6c4c4
 	.num_links = ARRAY_SIZE(kabylake_dais),
Pablo Greco d6c4c4
diff --git a/sound/soc/intel/boards/skl_hda_dsp_generic.c b/sound/soc/intel/boards/skl_hda_dsp_generic.c
Pablo Greco d6c4c4
index 1778acdc367c..e8d676c192f6 100644
Pablo Greco d6c4c4
--- a/sound/soc/intel/boards/skl_hda_dsp_generic.c
Pablo Greco d6c4c4
+++ b/sound/soc/intel/boards/skl_hda_dsp_generic.c
Pablo Greco d6c4c4
@@ -90,7 +90,7 @@ skl_hda_add_dai_link(struct snd_soc_card *card, struct snd_soc_dai_link *link)
Pablo Greco d6c4c4
 }
Pablo Greco d6c4c4
 
Pablo Greco d6c4c4
 static struct snd_soc_card hda_soc_card = {
Pablo Greco d6c4c4
-	.name = "skl_hda_card",
Pablo Greco d6c4c4
+	.name = "hda-dsp",
Pablo Greco d6c4c4
 	.owner = THIS_MODULE,
Pablo Greco d6c4c4
 	.dai_link = skl_hda_be_dai_links,
Pablo Greco d6c4c4
 	.dapm_widgets = skl_hda_widgets,
Pablo Greco d6c4c4
diff --git a/sound/soc/intel/boards/sof_rt5682.c b/sound/soc/intel/boards/sof_rt5682.c
Pablo Greco d6c4c4
index 4f6e58c3954a..320a9b9273db 100644
Pablo Greco d6c4c4
--- a/sound/soc/intel/boards/sof_rt5682.c
Pablo Greco d6c4c4
+++ b/sound/soc/intel/boards/sof_rt5682.c
Pablo Greco d6c4c4
@@ -370,7 +370,7 @@ static int dmic_init(struct snd_soc_pcm_runtime *rtd)
Pablo Greco d6c4c4
 
Pablo Greco d6c4c4
 /* sof audio machine driver for rt5682 codec */
Pablo Greco d6c4c4
 static struct snd_soc_card sof_audio_card_rt5682 = {
Pablo Greco d6c4c4
-	.name = "sof_rt5682",
Pablo Greco d6c4c4
+	.name = "rt5682", /* the sof- prefix is added by the core */
Pablo Greco d6c4c4
 	.owner = THIS_MODULE,
Pablo Greco d6c4c4
 	.controls = sof_controls,
Pablo Greco d6c4c4
 	.num_controls = ARRAY_SIZE(sof_controls),
Pablo Greco d6c4c4
-- 
Pablo Greco d6c4c4
2.24.1
Pablo Greco d6c4c4
Pablo Greco d6c4c4
From 6d7c3f54de921a90a4ec08f5c9570222d9f647f3 Mon Sep 17 00:00:00 2001
Pablo Greco d6c4c4
From: Takashi Iwai <tiwai@suse.de>
Pablo Greco d6c4c4
Date: Mon, 28 Oct 2019 14:06:34 +0100
Pablo Greco d6c4c4
Subject: [PATCH 007/109] ALSA: hda: Allow non-Intel device probe gracefully
Pablo Greco d6c4c4
Pablo Greco d6c4c4
The recent addition of snd_intel_dsp_driver_probe() check caused a
Pablo Greco d6c4c4
spurious kernel warning when the driver is loaded for a non-Intel
Pablo Greco d6c4c4
hardware due to snd_BUG_ON().  Moreover, for such a hardware, we
Pablo Greco d6c4c4
should always return SND_INTEL_DSP_DRIVER_ANY, not check the
Pablo Greco d6c4c4
dsp_driver option at all.
Pablo Greco d6c4c4
Pablo Greco d6c4c4
This patch fixes these issues for non-Intel devices.
Pablo Greco d6c4c4
Pablo Greco d6c4c4
Fixes: 82d9d54a6c0e ("ALSA: hda: add Intel DSP configuration / probe code")
Pablo Greco d6c4c4
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Pablo Greco d6c4c4
Link: https://lore.kernel.org/r/20191028130634.3501-1-tiwai@suse.de
Pablo Greco d6c4c4
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Pablo Greco d6c4c4
Pablo Greco d6c4c4
Signed-off-by: Jaroslav Kysela <jkysela@redhat.com>
Pablo Greco d6c4c4
(cherry picked from commit 91636a82044a2821201b54faac4d1d2425260842)
Pablo Greco d6c4c4
Bugzilla: 1772498
Pablo Greco d6c4c4
---
Pablo Greco d6c4c4
 sound/hda/intel-dsp-config.c | 8 ++++----
Pablo Greco d6c4c4
 1 file changed, 4 insertions(+), 4 deletions(-)
Pablo Greco d6c4c4
Pablo Greco d6c4c4
diff --git a/sound/hda/intel-dsp-config.c b/sound/hda/intel-dsp-config.c
Pablo Greco d6c4c4
index 0b2a7201a46a..be1df80ed013 100644
Pablo Greco d6c4c4
--- a/sound/hda/intel-dsp-config.c
Pablo Greco d6c4c4
+++ b/sound/hda/intel-dsp-config.c
Pablo Greco d6c4c4
@@ -307,13 +307,13 @@ int snd_intel_dsp_driver_probe(struct pci_dev *pci)
Pablo Greco d6c4c4
 {
Pablo Greco d6c4c4
 	const struct config_entry *cfg;
Pablo Greco d6c4c4
 
Pablo Greco d6c4c4
-	if (dsp_driver > 0 && dsp_driver <= SND_INTEL_DSP_DRIVER_LAST)
Pablo Greco d6c4c4
-		return dsp_driver;
Pablo Greco d6c4c4
-
Pablo Greco d6c4c4
 	/* Intel vendor only */
Pablo Greco d6c4c4
-	if (snd_BUG_ON(pci->vendor != 0x8086))
Pablo Greco d6c4c4
+	if (pci->vendor != 0x8086)
Pablo Greco d6c4c4
 		return SND_INTEL_DSP_DRIVER_ANY;
Pablo Greco d6c4c4
 
Pablo Greco d6c4c4
+	if (dsp_driver > 0 && dsp_driver <= SND_INTEL_DSP_DRIVER_LAST)
Pablo Greco d6c4c4
+		return dsp_driver;
Pablo Greco d6c4c4
+
Pablo Greco d6c4c4
 	/*
Pablo Greco d6c4c4
 	 * detect DSP by checking class/subclass/prog-id information
Pablo Greco d6c4c4
 	 * class=04 subclass 03 prog-if 00: no DSP, use legacy driver
Pablo Greco d6c4c4
-- 
Pablo Greco d6c4c4
2.24.1
Pablo Greco d6c4c4
Pablo Greco d6c4c4
From d1e23b8b780640a6bcf75c854857034c45cd99f2 Mon Sep 17 00:00:00 2001
Pablo Greco d6c4c4
From: Takashi Iwai <tiwai@suse.de>
Pablo Greco d6c4c4
Date: Tue, 5 Nov 2019 09:18:06 +0100
Pablo Greco d6c4c4
Subject: [PATCH 008/109] ALSA: hda: Disable regmap internal locking
Pablo Greco d6c4c4
Pablo Greco d6c4c4
Since we apply the own mutex (bus->cmd_mutex) in HDA core side, the
Pablo Greco d6c4c4
internal locking in regmap is superfluous.  This patch adds the flag
Pablo Greco d6c4c4
to indicate that.
Pablo Greco d6c4c4
Pablo Greco d6c4c4
Also, an infamous side-effect by this change is that it disables the
Pablo Greco d6c4c4
regmap debugfs, too, and this is seen rather good; the regmap debugfs
Pablo Greco d6c4c4
isn't quite useful for HD-audio as it provides the very sparse
Pablo Greco d6c4c4
registers and its debugfs access tends to lead to the way too high
Pablo Greco d6c4c4
resource usages or sometimes hang up.  So it'd be rather safe to
Pablo Greco d6c4c4
disable it altogether.
Pablo Greco d6c4c4
Pablo Greco d6c4c4
Link: https://lore.kernel.org/r/2029139028.10333037.1572874551626.JavaMail.zimbra@redhat.com
Pablo Greco d6c4c4
Link: https://lore.kernel.org/r/20191105081806.4896-1-tiwai@suse.de
Pablo Greco d6c4c4
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Pablo Greco d6c4c4
Pablo Greco d6c4c4
Signed-off-by: Jaroslav Kysela <jkysela@redhat.com>
Pablo Greco d6c4c4
(cherry picked from commit 42ec336f1f9d54049811b749f729e9e01c152ade)
Pablo Greco d6c4c4
Bugzilla: 1772498
Pablo Greco d6c4c4
---
Pablo Greco d6c4c4
 sound/hda/hdac_regmap.c | 1 +
Pablo Greco d6c4c4
 1 file changed, 1 insertion(+)
Pablo Greco d6c4c4
Pablo Greco d6c4c4
diff --git a/sound/hda/hdac_regmap.c b/sound/hda/hdac_regmap.c
Pablo Greco d6c4c4
index 286361ecd640..906b1e20bae0 100644
Pablo Greco d6c4c4
--- a/sound/hda/hdac_regmap.c
Pablo Greco d6c4c4
+++ b/sound/hda/hdac_regmap.c
Pablo Greco d6c4c4
@@ -363,6 +363,7 @@ static const struct regmap_config hda_regmap_cfg = {
Pablo Greco d6c4c4
 	.reg_write = hda_reg_write,
Pablo Greco d6c4c4
 	.use_single_read = true,
Pablo Greco d6c4c4
 	.use_single_write = true,
Pablo Greco d6c4c4
+	.disable_locking = true,
Pablo Greco d6c4c4
 };
Pablo Greco d6c4c4
 
Pablo Greco d6c4c4
 /**
Pablo Greco d6c4c4
-- 
Pablo Greco d6c4c4
2.24.1
Pablo Greco d6c4c4
Pablo Greco d6c4c4
From 0f9c61a795f0ad4faab0582c7b792cebd85976c2 Mon Sep 17 00:00:00 2001
Pablo Greco d6c4c4
From: Kai Vehmanen <kai.vehmanen@linux.intel.com>
Pablo Greco d6c4c4
Date: Tue, 29 Oct 2019 15:40:09 +0200
Pablo Greco d6c4c4
Subject: [PATCH 009/109] ALSA: hda/hdmi - implement mst_no_extra_pcms flag
Pablo Greco d6c4c4
Pablo Greco d6c4c4
To support the DP-MST multiple streams via single connector feature,
Pablo Greco d6c4c4
the HDMI driver was extended with the concept of backup PCMs. See
Pablo Greco d6c4c4
commit 9152085defb6 ("ALSA: hda - add DP MST audio support").
Pablo Greco d6c4c4
Pablo Greco d6c4c4
This implementation works fine with snd_hda_intel.c as PCM topology
Pablo Greco d6c4c4
is fully managed within the single driver.
Pablo Greco d6c4c4
Pablo Greco d6c4c4
When the HDA codec driver is used from ASoC components, the concept
Pablo Greco d6c4c4
of backup PCMs no longer fits. For ASoC topologies, the physical
Pablo Greco d6c4c4
HDMI converters are presented as backend DAIs and these should match
Pablo Greco d6c4c4
with hardware capabilities. The ASoC topology may define arbitrary
Pablo Greco d6c4c4
PCMs (i.e. frontend DAIs) and have processing elements before eventual
Pablo Greco d6c4c4
routing to the HDMI BE DAIs. With backup PCMs, the link between
Pablo Greco d6c4c4
FE and BE DAIs would become dynamic and change when monitors are
Pablo Greco d6c4c4
(un)plugged. This would lead to modifying the topology every time
Pablo Greco d6c4c4
hotplug events happen, which is not currently possible in ASoC and
Pablo Greco d6c4c4
there does not seem to be any obvious benefits from this design.
Pablo Greco d6c4c4
Pablo Greco d6c4c4
To overcome above problems and enable the HDMI driver to be used
Pablo Greco d6c4c4
from ASoC, this patch adds a new mode (mst_no_extra_pcms flags) to
Pablo Greco d6c4c4
patch_hdmi.c. In this mode, the codec driver does not assume
Pablo Greco d6c4c4
the backup PCMs to be created.
Pablo Greco d6c4c4
Pablo Greco d6c4c4
Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
Pablo Greco d6c4c4
Reviewed-by: Takashi Iwai <tiwai@suse.de>
Pablo Greco d6c4c4
Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Pablo Greco d6c4c4
Link: https://lore.kernel.org/r/20191029134017.18901-2-kai.vehmanen@linux.intel.com
Pablo Greco d6c4c4
Signed-off-by: Mark Brown <broonie@kernel.org>
Pablo Greco d6c4c4
Pablo Greco d6c4c4
Signed-off-by: Jaroslav Kysela <jkysela@redhat.com>
Pablo Greco d6c4c4
(cherry picked from commit 2a2edfbbfee47947dd05f5860c66c0e80ee5e09d)
Pablo Greco d6c4c4
Bugzilla: 1772498
Pablo Greco d6c4c4
---
Pablo Greco d6c4c4
 include/sound/hda_codec.h  |  1 +
Pablo Greco d6c4c4
 sound/pci/hda/patch_hdmi.c | 19 ++++++++++++++-----
Pablo Greco d6c4c4
 2 files changed, 15 insertions(+), 5 deletions(-)
Pablo Greco d6c4c4
Pablo Greco d6c4c4
diff --git a/include/sound/hda_codec.h b/include/sound/hda_codec.h
Pablo Greco d6c4c4
index 9a0393cf024c..ac18f428eda6 100644
Pablo Greco d6c4c4
--- a/include/sound/hda_codec.h
Pablo Greco d6c4c4
+++ b/include/sound/hda_codec.h
Pablo Greco d6c4c4
@@ -254,6 +254,7 @@ struct hda_codec {
Pablo Greco d6c4c4
 	unsigned int force_pin_prefix:1; /* Add location prefix */
Pablo Greco d6c4c4
 	unsigned int link_down_at_suspend:1; /* link down at runtime suspend */
Pablo Greco d6c4c4
 	unsigned int relaxed_resume:1;	/* don't resume forcibly for jack */
Pablo Greco d6c4c4
+	unsigned int mst_no_extra_pcms:1; /* no backup PCMs for DP-MST */
Pablo Greco d6c4c4
 
Pablo Greco d6c4c4
 #ifdef CONFIG_PM
Pablo Greco d6c4c4
 	unsigned long power_on_acct;
Pablo Greco d6c4c4
diff --git a/sound/pci/hda/patch_hdmi.c b/sound/pci/hda/patch_hdmi.c
Pablo Greco d6c4c4
index 8ac805a634f4..1a29453bc26f 100644
Pablo Greco d6c4c4
--- a/sound/pci/hda/patch_hdmi.c
Pablo Greco d6c4c4
+++ b/sound/pci/hda/patch_hdmi.c
Pablo Greco d6c4c4
@@ -2082,15 +2082,24 @@ static bool is_hdmi_pcm_attached(struct hdac_device *hdac, int pcm_idx)
Pablo Greco d6c4c4
 static int generic_hdmi_build_pcms(struct hda_codec *codec)
Pablo Greco d6c4c4
 {
Pablo Greco d6c4c4
 	struct hdmi_spec *spec = codec->spec;
Pablo Greco d6c4c4
-	int idx;
Pablo Greco d6c4c4
+	int idx, pcm_num;
Pablo Greco d6c4c4
 
Pablo Greco d6c4c4
 	/*
Pablo Greco d6c4c4
 	 * for non-mst mode, pcm number is the same as before
Pablo Greco d6c4c4
-	 * for DP MST mode, pcm number is (nid number + dev_num - 1)
Pablo Greco d6c4c4
-	 *  dev_num is the device entry number in a pin
Pablo Greco d6c4c4
-	 *
Pablo Greco d6c4c4
+	 * for DP MST mode without extra PCM, pcm number is same
Pablo Greco d6c4c4
+	 * for DP MST mode with extra PCMs, pcm number is
Pablo Greco d6c4c4
+	 *  (nid number + dev_num - 1)
Pablo Greco d6c4c4
+	 * dev_num is the device entry number in a pin
Pablo Greco d6c4c4
 	 */
Pablo Greco d6c4c4
-	for (idx = 0; idx < spec->num_nids + spec->dev_num - 1; idx++) {
Pablo Greco d6c4c4
+
Pablo Greco d6c4c4
+	if (codec->mst_no_extra_pcms)
Pablo Greco d6c4c4
+		pcm_num = spec->num_nids;
Pablo Greco d6c4c4
+	else
Pablo Greco d6c4c4
+		pcm_num = spec->num_nids + spec->dev_num - 1;
Pablo Greco d6c4c4
+
Pablo Greco d6c4c4
+	codec_dbg(codec, "hdmi: pcm_num set to %d\n", pcm_num);
Pablo Greco d6c4c4
+
Pablo Greco d6c4c4
+	for (idx = 0; idx < pcm_num; idx++) {
Pablo Greco d6c4c4
 		struct hda_pcm *info;
Pablo Greco d6c4c4
 		struct hda_pcm_stream *pstr;
Pablo Greco d6c4c4
 
Pablo Greco d6c4c4
-- 
Pablo Greco d6c4c4
2.24.1
Pablo Greco d6c4c4
Pablo Greco d6c4c4
From 33115cd895693c04723026e19a9eee0f34c4b853 Mon Sep 17 00:00:00 2001
Pablo Greco d6c4c4
From: Takashi Iwai <tiwai@suse.de>
Pablo Greco d6c4c4
Date: Mon, 11 Nov 2019 20:09:37 +0100
Pablo Greco d6c4c4
Subject: [PATCH 010/109] ALSA: hda/hdmi - Clean up Intel platform-specific
Pablo Greco d6c4c4
 fixup checks
Pablo Greco d6c4c4
Pablo Greco d6c4c4
Introduce a new flag in hdmi_spec to indicate the Intel platform-
Pablo Greco d6c4c4
specific fixups so that we can get rid of the lengthy codec ID
Pablo Greco d6c4c4
checks.  The flag is set in intel_hsw_common_init() commonly.
Pablo Greco d6c4c4
Pablo Greco d6c4c4
Reviewed-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
Pablo Greco d6c4c4
Link: https://lore.kernel.org/r/20191111190937.19186-1-tiwai@suse.de
Pablo Greco d6c4c4
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Pablo Greco d6c4c4
Pablo Greco d6c4c4
Signed-off-by: Jaroslav Kysela <jkysela@redhat.com>
Pablo Greco d6c4c4
(cherry picked from commit cb45722b289b54476b68883985c2824c69a7fba9)
Pablo Greco d6c4c4
Bugzilla: 1772498
Pablo Greco d6c4c4
---
Pablo Greco d6c4c4
 sound/pci/hda/patch_hdmi.c | 27 +++++----------------------
Pablo Greco d6c4c4
 1 file changed, 5 insertions(+), 22 deletions(-)
Pablo Greco d6c4c4
Pablo Greco d6c4c4
diff --git a/sound/pci/hda/patch_hdmi.c b/sound/pci/hda/patch_hdmi.c
Pablo Greco d6c4c4
index 1a29453bc26f..3f97a04de197 100644
Pablo Greco d6c4c4
--- a/sound/pci/hda/patch_hdmi.c
Pablo Greco d6c4c4
+++ b/sound/pci/hda/patch_hdmi.c
Pablo Greco d6c4c4
@@ -38,25 +38,6 @@ static bool static_hdmi_pcm;
Pablo Greco d6c4c4
 module_param(static_hdmi_pcm, bool, 0644);
Pablo Greco d6c4c4
 MODULE_PARM_DESC(static_hdmi_pcm, "Don't restrict PCM parameters per ELD info");
Pablo Greco d6c4c4
 
Pablo Greco d6c4c4
-#define is_haswell(codec)  ((codec)->core.vendor_id == 0x80862807)
Pablo Greco d6c4c4
-#define is_broadwell(codec)    ((codec)->core.vendor_id == 0x80862808)
Pablo Greco d6c4c4
-#define is_skylake(codec) ((codec)->core.vendor_id == 0x80862809)
Pablo Greco d6c4c4
-#define is_broxton(codec) ((codec)->core.vendor_id == 0x8086280a)
Pablo Greco d6c4c4
-#define is_kabylake(codec) ((codec)->core.vendor_id == 0x8086280b)
Pablo Greco d6c4c4
-#define is_geminilake(codec) (((codec)->core.vendor_id == 0x8086280d) || \
Pablo Greco d6c4c4
-				((codec)->core.vendor_id == 0x80862800))
Pablo Greco d6c4c4
-#define is_cannonlake(codec) ((codec)->core.vendor_id == 0x8086280c)
Pablo Greco d6c4c4
-#define is_icelake(codec) ((codec)->core.vendor_id == 0x8086280f)
Pablo Greco d6c4c4
-#define is_tigerlake(codec) ((codec)->core.vendor_id == 0x80862812)
Pablo Greco d6c4c4
-#define is_haswell_plus(codec) (is_haswell(codec) || is_broadwell(codec) \
Pablo Greco d6c4c4
-				|| is_skylake(codec) || is_broxton(codec) \
Pablo Greco d6c4c4
-				|| is_kabylake(codec) || is_geminilake(codec) \
Pablo Greco d6c4c4
-				|| is_cannonlake(codec) || is_icelake(codec) \
Pablo Greco d6c4c4
-				|| is_tigerlake(codec))
Pablo Greco d6c4c4
-#define is_valleyview(codec) ((codec)->core.vendor_id == 0x80862882)
Pablo Greco d6c4c4
-#define is_cherryview(codec) ((codec)->core.vendor_id == 0x80862883)
Pablo Greco d6c4c4
-#define is_valleyview_plus(codec) (is_valleyview(codec) || is_cherryview(codec))
Pablo Greco d6c4c4
-
Pablo Greco d6c4c4
 struct hdmi_spec_per_cvt {
Pablo Greco d6c4c4
 	hda_nid_t cvt_nid;
Pablo Greco d6c4c4
 	int assigned;
Pablo Greco d6c4c4
@@ -163,6 +144,7 @@ struct hdmi_spec {
Pablo Greco d6c4c4
 
Pablo Greco d6c4c4
 	bool dyn_pin_out;
Pablo Greco d6c4c4
 	bool dyn_pcm_assign;
Pablo Greco d6c4c4
+	bool intel_hsw_fixup;	/* apply Intel platform-specific fixups */
Pablo Greco d6c4c4
 	/*
Pablo Greco d6c4c4
 	 * Non-generic VIA/NVIDIA specific
Pablo Greco d6c4c4
 	 */
Pablo Greco d6c4c4
@@ -926,7 +908,7 @@ static int hdmi_setup_stream(struct hda_codec *codec, hda_nid_t cvt_nid,
Pablo Greco d6c4c4
 		return err;
Pablo Greco d6c4c4
 	}
Pablo Greco d6c4c4
 
Pablo Greco d6c4c4
-	if (is_haswell_plus(codec)) {
Pablo Greco d6c4c4
+	if (spec->intel_hsw_fixup) {
Pablo Greco d6c4c4
 
Pablo Greco d6c4c4
 		/*
Pablo Greco d6c4c4
 		 * on recent platforms IEC Coding Type is required for HBR
Pablo Greco d6c4c4
@@ -1714,7 +1696,7 @@ static int hdmi_add_pin(struct hda_codec *codec, hda_nid_t pin_nid)
Pablo Greco d6c4c4
 	 * To simplify the implementation, malloc all
Pablo Greco d6c4c4
 	 * the virtual pins in the initialization statically
Pablo Greco d6c4c4
 	 */
Pablo Greco d6c4c4
-	if (is_haswell_plus(codec)) {
Pablo Greco d6c4c4
+	if (spec->intel_hsw_fixup) {
Pablo Greco d6c4c4
 		/*
Pablo Greco d6c4c4
 		 * On Intel platforms, device entries number is
Pablo Greco d6c4c4
 		 * changed dynamically. If there is a DP MST
Pablo Greco d6c4c4
@@ -1763,7 +1745,7 @@ static int hdmi_add_pin(struct hda_codec *codec, hda_nid_t pin_nid)
Pablo Greco d6c4c4
 		per_pin->dev_id = i;
Pablo Greco d6c4c4
 		per_pin->non_pcm = false;
Pablo Greco d6c4c4
 		snd_hda_set_dev_select(codec, pin_nid, i);
Pablo Greco d6c4c4
-		if (is_haswell_plus(codec))
Pablo Greco d6c4c4
+		if (spec->intel_hsw_fixup)
Pablo Greco d6c4c4
 			intel_haswell_fixup_connect_list(codec, pin_nid);
Pablo Greco d6c4c4
 		err = hdmi_read_pin_conn(codec, pin_idx);
Pablo Greco d6c4c4
 		if (err < 0)
Pablo Greco d6c4c4
@@ -2832,6 +2814,7 @@ static int intel_hsw_common_init(struct hda_codec *codec, hda_nid_t vendor_nid,
Pablo Greco d6c4c4
 	spec->vendor_nid = vendor_nid;
Pablo Greco d6c4c4
 	spec->port_map = port_map;
Pablo Greco d6c4c4
 	spec->port_num = port_num;
Pablo Greco d6c4c4
+	spec->intel_hsw_fixup = true;
Pablo Greco d6c4c4
 
Pablo Greco d6c4c4
 	intel_haswell_enable_all_pins(codec, true);
Pablo Greco d6c4c4
 	intel_haswell_fixup_enable_dp12(codec);
Pablo Greco d6c4c4
-- 
Pablo Greco d6c4c4
2.24.1
Pablo Greco d6c4c4
Pablo Greco d6c4c4
From 75ce7bbf2d5d1de529a07eca217e02a9897d0277 Mon Sep 17 00:00:00 2001
Pablo Greco d6c4c4
From: Kai Vehmanen <kai.vehmanen@linux.intel.com>
Pablo Greco d6c4c4
Date: Fri, 15 Nov 2019 14:44:47 +0200
Pablo Greco d6c4c4
Subject: [PATCH 011/109] ALSA: hda: hdmi - fix port numbering for ICL and TGL
Pablo Greco d6c4c4
 platforms
Pablo Greco d6c4c4
Pablo Greco d6c4c4
Semantics of port#0 differ between ICL and TGL:
Pablo Greco d6c4c4
Pablo Greco d6c4c4
 ICL port#0   -> never used for HDAudio
Pablo Greco d6c4c4
 ICL port#1   -> should be mapped to first pin (0x04)
Pablo Greco d6c4c4
 TGL port#0   -> typically not used, but HW has the support,
Pablo Greco d6c4c4
		 so should be mapped to first pin (0x04)
Pablo Greco d6c4c4
 TGL port#1   -> should be mapped to 2nd pin (0x06)
Pablo Greco d6c4c4
Pablo Greco d6c4c4
Refactor the port mapping logic to allow to take the above
Pablo Greco d6c4c4
differences into account. Fixes issues with HDAudio on some
Pablo Greco d6c4c4
TGL platforms.
Pablo Greco d6c4c4
Pablo Greco d6c4c4
Co-developed-by: Pan Xiuli <xiuli.pan@linux.intel.com>
Pablo Greco d6c4c4
Signed-off-by: Pan Xiuli <xiuli.pan@linux.intel.com>
Pablo Greco d6c4c4
Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
Pablo Greco d6c4c4
Link: https://lore.kernel.org/r/20191115124449.20512-2-kai.vehmanen@linux.intel.com
Pablo Greco d6c4c4
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Pablo Greco d6c4c4
Pablo Greco d6c4c4
Signed-off-by: Jaroslav Kysela <jkysela@redhat.com>
Pablo Greco d6c4c4
(cherry picked from commit d577cf76fa3192f9e656bb101aa54d25a6a71347)
Pablo Greco d6c4c4
Bugzilla: 1772498
Pablo Greco d6c4c4
---
Pablo Greco d6c4c4
 sound/pci/hda/patch_hdmi.c | 12 ++++++------
Pablo Greco d6c4c4
 1 file changed, 6 insertions(+), 6 deletions(-)
Pablo Greco d6c4c4
Pablo Greco d6c4c4
diff --git a/sound/pci/hda/patch_hdmi.c b/sound/pci/hda/patch_hdmi.c
Pablo Greco d6c4c4
index 3f97a04de197..75f0d2799847 100644
Pablo Greco d6c4c4
--- a/sound/pci/hda/patch_hdmi.c
Pablo Greco d6c4c4
+++ b/sound/pci/hda/patch_hdmi.c
Pablo Greco d6c4c4
@@ -2671,7 +2671,7 @@ static int intel_pin2port(void *audio_ptr, int pin_nid)
Pablo Greco d6c4c4
 	 */
Pablo Greco d6c4c4
 	for (i = 0; i < spec->port_num; i++) {
Pablo Greco d6c4c4
 		if (pin_nid == spec->port_map[i])
Pablo Greco d6c4c4
-			return i + 1;
Pablo Greco d6c4c4
+			return i;
Pablo Greco d6c4c4
 	}
Pablo Greco d6c4c4
 
Pablo Greco d6c4c4
 	/* return -1 if pin number exceeds our expectation */
Pablo Greco d6c4c4
@@ -2691,9 +2691,9 @@ static int intel_port2pin(struct hda_codec *codec, int port)
Pablo Greco d6c4c4
 		return port + intel_base_nid(codec) - 1;
Pablo Greco d6c4c4
 	}
Pablo Greco d6c4c4
 
Pablo Greco d6c4c4
-	if (port < 1 || port > spec->port_num)
Pablo Greco d6c4c4
+	if (port < 0 || port >= spec->port_num)
Pablo Greco d6c4c4
 		return 0;
Pablo Greco d6c4c4
-	return spec->port_map[port - 1];
Pablo Greco d6c4c4
+	return spec->port_map[port];
Pablo Greco d6c4c4
 }
Pablo Greco d6c4c4
 
Pablo Greco d6c4c4
 static void intel_pin_eld_notify(void *audio_ptr, int port, int pipe)
Pablo Greco d6c4c4
@@ -2845,9 +2845,9 @@ static int patch_i915_icl_hdmi(struct hda_codec *codec)
Pablo Greco d6c4c4
 {
Pablo Greco d6c4c4
 	/*
Pablo Greco d6c4c4
 	 * pin to port mapping table where the value indicate the pin number and
Pablo Greco d6c4c4
-	 * the index indicate the port number with 1 base.
Pablo Greco d6c4c4
+	 * the index indicate the port number.
Pablo Greco d6c4c4
 	 */
Pablo Greco d6c4c4
-	static const int map[] = {0x4, 0x6, 0x8, 0xa, 0xb};
Pablo Greco d6c4c4
+	static const int map[] = {0x0, 0x4, 0x6, 0x8, 0xa, 0xb};
Pablo Greco d6c4c4
 
Pablo Greco d6c4c4
 	return intel_hsw_common_init(codec, 0x02, map, ARRAY_SIZE(map));
Pablo Greco d6c4c4
 }
Pablo Greco d6c4c4
@@ -2856,7 +2856,7 @@ static int patch_i915_tgl_hdmi(struct hda_codec *codec)
Pablo Greco d6c4c4
 {
Pablo Greco d6c4c4
 	/*
Pablo Greco d6c4c4
 	 * pin to port mapping table where the value indicate the pin number and
Pablo Greco d6c4c4
-	 * the index indicate the port number with 1 base.
Pablo Greco d6c4c4
+	 * the index indicate the port number.
Pablo Greco d6c4c4
 	 */
Pablo Greco d6c4c4
 	static const int map[] = {0x4, 0x6, 0x8, 0xa, 0xb, 0xc, 0xd, 0xe, 0xf};
Pablo Greco d6c4c4
 
Pablo Greco d6c4c4
-- 
Pablo Greco d6c4c4
2.24.1
Pablo Greco d6c4c4
Pablo Greco d6c4c4
From a8196a93444f3ff34e15c254f68ee046bef27109 Mon Sep 17 00:00:00 2001
Pablo Greco d6c4c4
From: Kai Vehmanen <kai.vehmanen@linux.intel.com>
Pablo Greco d6c4c4
Date: Fri, 15 Nov 2019 14:44:48 +0200
Pablo Greco d6c4c4
Subject: [PATCH 012/109] ALSA: hda: hdmi - remove redundant code comments
Pablo Greco d6c4c4
Pablo Greco d6c4c4
Remove unnecessary comments related to pin mapping on
Pablo Greco d6c4c4
Intel platforms.
Pablo Greco d6c4c4
Pablo Greco d6c4c4
Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
Pablo Greco d6c4c4
Link: https://lore.kernel.org/r/20191115124449.20512-3-kai.vehmanen@linux.intel.com
Pablo Greco d6c4c4
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Pablo Greco d6c4c4
Pablo Greco d6c4c4
Signed-off-by: Jaroslav Kysela <jkysela@redhat.com>
Pablo Greco d6c4c4
(cherry picked from commit c8e3eb9be57f91751aeb9397118755390dbff9a4)
Pablo Greco d6c4c4
Bugzilla: 1772498
Pablo Greco d6c4c4
---
Pablo Greco d6c4c4
 sound/pci/hda/patch_hdmi.c | 5 +----
Pablo Greco d6c4c4
 1 file changed, 1 insertion(+), 4 deletions(-)
Pablo Greco d6c4c4
Pablo Greco d6c4c4
diff --git a/sound/pci/hda/patch_hdmi.c b/sound/pci/hda/patch_hdmi.c
Pablo Greco d6c4c4
index 75f0d2799847..2044bbb830f9 100644
Pablo Greco d6c4c4
--- a/sound/pci/hda/patch_hdmi.c
Pablo Greco d6c4c4
+++ b/sound/pci/hda/patch_hdmi.c
Pablo Greco d6c4c4
@@ -2662,7 +2662,7 @@ static int intel_pin2port(void *audio_ptr, int pin_nid)
Pablo Greco d6c4c4
 		base_nid = intel_base_nid(codec);
Pablo Greco d6c4c4
 		if (WARN_ON(pin_nid < base_nid || pin_nid >= base_nid + 3))
Pablo Greco d6c4c4
 			return -1;
Pablo Greco d6c4c4
-		return pin_nid - base_nid + 1; /* intel port is 1-based */
Pablo Greco d6c4c4
+		return pin_nid - base_nid + 1;
Pablo Greco d6c4c4
 	}
Pablo Greco d6c4c4
 
Pablo Greco d6c4c4
 	/*
Pablo Greco d6c4c4
@@ -2674,7 +2674,6 @@ static int intel_pin2port(void *audio_ptr, int pin_nid)
Pablo Greco d6c4c4
 			return i;
Pablo Greco d6c4c4
 	}
Pablo Greco d6c4c4
 
Pablo Greco d6c4c4
-	/* return -1 if pin number exceeds our expectation */
Pablo Greco d6c4c4
 	codec_info(codec, "Can't find the HDMI/DP port for pin %d\n", pin_nid);
Pablo Greco d6c4c4
 	return -1;
Pablo Greco d6c4c4
 }
Pablo Greco d6c4c4
@@ -2687,7 +2686,6 @@ static int intel_port2pin(struct hda_codec *codec, int port)
Pablo Greco d6c4c4
 		/* we assume only from port-B to port-D */
Pablo Greco d6c4c4
 		if (port < 1 || port > 3)
Pablo Greco d6c4c4
 			return 0;
Pablo Greco d6c4c4
-		/* intel port is 1-based */
Pablo Greco d6c4c4
 		return port + intel_base_nid(codec) - 1;
Pablo Greco d6c4c4
 	}
Pablo Greco d6c4c4
 
Pablo Greco d6c4c4
@@ -2863,7 +2861,6 @@ static int patch_i915_tgl_hdmi(struct hda_codec *codec)
Pablo Greco d6c4c4
 	return intel_hsw_common_init(codec, 0x02, map, ARRAY_SIZE(map));
Pablo Greco d6c4c4
 }
Pablo Greco d6c4c4
 
Pablo Greco d6c4c4
-
Pablo Greco d6c4c4
 /* Intel Baytrail and Braswell; with eld notifier */
Pablo Greco d6c4c4
 static int patch_i915_byt_hdmi(struct hda_codec *codec)
Pablo Greco d6c4c4
 {
Pablo Greco d6c4c4
-- 
Pablo Greco d6c4c4
2.24.1
Pablo Greco d6c4c4
Pablo Greco d6c4c4
From ad0389ef5e486a09a98cbfacd2bf56090b1346f1 Mon Sep 17 00:00:00 2001
Pablo Greco d6c4c4
From: Kai Vehmanen <kai.vehmanen@linux.intel.com>
Pablo Greco d6c4c4
Date: Fri, 15 Nov 2019 14:44:49 +0200
Pablo Greco d6c4c4
Subject: [PATCH 013/109] ALSA: hda - remove forced polling workaround for CFL
Pablo Greco d6c4c4
 and CNL
Pablo Greco d6c4c4
Pablo Greco d6c4c4
Remove the workarounds added in commit fa763f1b2858 ("ALSA:
Pablo Greco d6c4c4
hda - Force polling mode on CNL for fixing codec communication")
Pablo Greco d6c4c4
and commit a8d7bde23e71 ("ALSA: hda - Force polling mode on CFL
Pablo Greco d6c4c4
for fixing codec communication").
Pablo Greco d6c4c4
Pablo Greco d6c4c4
The workarounds are no longer needed after the more generic
Pablo Greco d6c4c4
change done in commit 2756d9143aa5 ("ALSA: hda - Fix intermittent
Pablo Greco d6c4c4
CORB/RIRB stall on Intel chips"). This change applies to a larger
Pablo Greco d6c4c4
set of hardware and covers CFL and CNL as well.
Pablo Greco d6c4c4
Pablo Greco d6c4c4
Similar change was already done to SOF DSP HDA driver with
Pablo Greco d6c4c4
no regressions detected.
Pablo Greco d6c4c4
Pablo Greco d6c4c4
Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
Pablo Greco d6c4c4
Link: https://lore.kernel.org/r/20191115124449.20512-4-kai.vehmanen@linux.intel.com
Pablo Greco d6c4c4
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Pablo Greco d6c4c4
Pablo Greco d6c4c4
Signed-off-by: Jaroslav Kysela <jkysela@redhat.com>
Pablo Greco d6c4c4
(cherry picked from commit ee906c6b9c6e7e4ad749f5cfdf65768455f4bf43)
Pablo Greco d6c4c4
Bugzilla: 1772498
Pablo Greco d6c4c4
---
Pablo Greco d6c4c4
 sound/pci/hda/hda_intel.c | 6 ------
Pablo Greco d6c4c4
 1 file changed, 6 deletions(-)
Pablo Greco d6c4c4
Pablo Greco d6c4c4
diff --git a/sound/pci/hda/hda_intel.c b/sound/pci/hda/hda_intel.c
Pablo Greco d6c4c4
index 2888f710e7e1..e2c08517a24c 100644
Pablo Greco d6c4c4
--- a/sound/pci/hda/hda_intel.c
Pablo Greco d6c4c4
+++ b/sound/pci/hda/hda_intel.c
Pablo Greco d6c4c4
@@ -370,8 +370,6 @@ enum {
Pablo Greco d6c4c4
 					((pci)->device == 0x160c))
Pablo Greco d6c4c4
 
Pablo Greco d6c4c4
 #define IS_BXT(pci) ((pci)->vendor == 0x8086 && (pci)->device == 0x5a98)
Pablo Greco d6c4c4
-#define IS_CFL(pci) ((pci)->vendor == 0x8086 && (pci)->device == 0xa348)
Pablo Greco d6c4c4
-#define IS_CNL(pci) ((pci)->vendor == 0x8086 && (pci)->device == 0x9dc8)
Pablo Greco d6c4c4
 
Pablo Greco d6c4c4
 static char *driver_short_names[] = {
Pablo Greco d6c4c4
 	[AZX_DRIVER_ICH] = "HDA Intel",
Pablo Greco d6c4c4
@@ -1764,10 +1762,6 @@ static int azx_create(struct snd_card *card, struct pci_dev *pci,
Pablo Greco d6c4c4
 	if (!azx_snoop(chip))
Pablo Greco d6c4c4
 		azx_bus(chip)->dma_type = SNDRV_DMA_TYPE_DEV_UC;
Pablo Greco d6c4c4
 
Pablo Greco d6c4c4
-	/* Workaround for a communication error on CFL (bko#199007) and CNL */
Pablo Greco d6c4c4
-	if (IS_CFL(pci) || IS_CNL(pci))
Pablo Greco d6c4c4
-		azx_bus(chip)->polling_mode = 1;
Pablo Greco d6c4c4
-
Pablo Greco d6c4c4
 	if (chip->driver_type == AZX_DRIVER_NVIDIA) {
Pablo Greco d6c4c4
 		dev_dbg(chip->card->dev, "Enable delay in RIRB handling\n");
Pablo Greco d6c4c4
 		chip->bus.needs_damn_long_delay = 1;
Pablo Greco d6c4c4
-- 
Pablo Greco d6c4c4
2.24.1
Pablo Greco d6c4c4
Pablo Greco d6c4c4
From 588faa6b4c0d18c504e6c32863ef82b63b6531ec Mon Sep 17 00:00:00 2001
Pablo Greco d6c4c4
From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Pablo Greco d6c4c4
Date: Tue, 15 Oct 2019 14:44:09 +0900
Pablo Greco d6c4c4
Subject: [PATCH 014/109] ASoC: sof: include types.h at header.h
Pablo Greco d6c4c4
MIME-Version: 1.0
Pablo Greco d6c4c4
Content-Type: text/plain; charset=UTF-8
Pablo Greco d6c4c4
Content-Transfer-Encoding: 8bit
Pablo Greco d6c4c4
Pablo Greco d6c4c4
Content-Transfer-Encoding: 8bit
Pablo Greco d6c4c4
Pablo Greco d6c4c4
Without <types.h> we will get these error
Pablo Greco d6c4c4
Pablo Greco d6c4c4
linux/include/sound/sof/header.h:125:2: error: unknown type name ‘uint32_t’uint32_t size;
Pablo Greco d6c4c4
linux/include/sound/sof/header.h:136:2: error: unknown type name ‘uint32_t’uint32_t size;
Pablo Greco d6c4c4
linux/include/sound/sof/header.h:137:2: error: unknown type name ‘uint32_t’uint32_t cmd;
Pablo Greco d6c4c4
...
Pablo Greco d6c4c4
linux/include/sound/sof/dai-imx.h:18:2: error: unknown type name ‘uint16_t’uint16_t reserved1;
Pablo Greco d6c4c4
linux/include/sound/sof/dai-imx.h:30:2: error: unknown type name ‘uint16_t’uint16_t tdm_slot_width;
Pablo Greco d6c4c4
linux/include/sound/sof/dai-imx.h:31:2: error: unknown type name ‘uint16_t’uint16_t reserved2;
Pablo Greco d6c4c4
Pablo Greco d6c4c4
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Pablo Greco d6c4c4
Link: https://lore.kernel.org/r/87a7a24l7r.wl-kuninori.morimoto.gx@renesas.com
Pablo Greco d6c4c4
Signed-off-by: Mark Brown <broonie@kernel.org>
Pablo Greco d6c4c4
Pablo Greco d6c4c4
Signed-off-by: Jaroslav Kysela <jkysela@redhat.com>
Pablo Greco d6c4c4
(cherry picked from commit 03048217624a9472c1c7a205c8ea9bf8d4026e59)
Pablo Greco d6c4c4
Bugzilla: 1772498
Pablo Greco d6c4c4
---
Pablo Greco d6c4c4
 include/sound/sof/header.h | 1 +
Pablo Greco d6c4c4
 1 file changed, 1 insertion(+)
Pablo Greco d6c4c4
Pablo Greco d6c4c4
diff --git a/include/sound/sof/header.h b/include/sound/sof/header.h
Pablo Greco d6c4c4
index 10f00c08dbb7..332143ff7278 100644
Pablo Greco d6c4c4
--- a/include/sound/sof/header.h
Pablo Greco d6c4c4
+++ b/include/sound/sof/header.h
Pablo Greco d6c4c4
@@ -9,6 +9,7 @@
Pablo Greco d6c4c4
 #ifndef __INCLUDE_SOUND_SOF_HEADER_H__
Pablo Greco d6c4c4
 #define __INCLUDE_SOUND_SOF_HEADER_H__
Pablo Greco d6c4c4
 
Pablo Greco d6c4c4
+#include <linux types.h="">
Pablo Greco d6c4c4
 #include <uapi sound="" sof="" abi.h="">
Pablo Greco d6c4c4
 
Pablo Greco d6c4c4
 /** \addtogroup sof_uapi uAPI
Pablo Greco d6c4c4
-- 
Pablo Greco d6c4c4
2.24.1
Pablo Greco d6c4c4
Pablo Greco d6c4c4
From 0378a1586c604515d4084c29ae689b5700315b7f Mon Sep 17 00:00:00 2001
Pablo Greco d6c4c4
From: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Pablo Greco d6c4c4
Date: Fri, 27 Sep 2019 15:05:28 -0500
Pablo Greco d6c4c4
Subject: [PATCH 015/109] ASoC: SOF: trace: move to opt-in with Kconfig and
Pablo Greco d6c4c4
 module parameter
Pablo Greco d6c4c4
Pablo Greco d6c4c4
In a number of debug cases, the DMA-based trace can add problems
Pablo Greco d6c4c4
(e.g. with HDaudio channel allocation). It also generates additional
Pablo Greco d6c4c4
traffic on the bus and if the DMA handling is unreliable will prevent
Pablo Greco d6c4c4
audio use-cases from working normally. Using the trace also requires
Pablo Greco d6c4c4
tools to be installed on the target.
Pablo Greco d6c4c4
Pablo Greco d6c4c4
The trace can be instead handled as dynamic debug. We can use a
Pablo Greco d6c4c4
Kconfig to force the trace to be enabled in all cases, or use a module
Pablo Greco d6c4c4
parameter to enable it on a need-basis, e.g. by setting "options
Pablo Greco d6c4c4
snd_sof sof_debug=0x1" in a /etc/modprobe.d file.
Pablo Greco d6c4c4
Pablo Greco d6c4c4
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Pablo Greco d6c4c4
Link: https://lore.kernel.org/r/20190927200538.660-4-pierre-louis.bossart@linux.intel.com
Pablo Greco d6c4c4
Signed-off-by: Mark Brown <broonie@kernel.org>
Pablo Greco d6c4c4
Pablo Greco d6c4c4
Signed-off-by: Jaroslav Kysela <jkysela@redhat.com>
Pablo Greco d6c4c4
(cherry picked from commit 2ab4c50f6955514150f83b47b7aee3ba5fe3ac1d)
Pablo Greco d6c4c4
Bugzilla: 1772498
Pablo Greco d6c4c4
---
Pablo Greco d6c4c4
 sound/soc/sof/Kconfig    |  8 ++++++++
Pablo Greco d6c4c4
 sound/soc/sof/core.c     | 25 +++++++++++++++++++------
Pablo Greco d6c4c4
 sound/soc/sof/sof-priv.h | 13 +++++++++----
Pablo Greco d6c4c4
 sound/soc/sof/trace.c    | 17 ++++++++++++++++-
Pablo Greco d6c4c4
 4 files changed, 52 insertions(+), 11 deletions(-)
Pablo Greco d6c4c4
Pablo Greco d6c4c4
diff --git a/sound/soc/sof/Kconfig b/sound/soc/sof/Kconfig
Pablo Greco d6c4c4
index bb8036ae567e..cc592bcadae7 100644
Pablo Greco d6c4c4
--- a/sound/soc/sof/Kconfig
Pablo Greco d6c4c4
+++ b/sound/soc/sof/Kconfig
Pablo Greco d6c4c4
@@ -142,6 +142,14 @@ config SND_SOC_SOF_DEBUG_ENABLE_DEBUGFS_CACHE
Pablo Greco d6c4c4
 	  Say Y if you want to enable caching the memory windows.
Pablo Greco d6c4c4
 	  If unsure, select "N".
Pablo Greco d6c4c4
 
Pablo Greco d6c4c4
+config SND_SOC_SOF_DEBUG_ENABLE_FIRMWARE_TRACE
Pablo Greco d6c4c4
+	bool "SOF enable firmware trace"
Pablo Greco d6c4c4
+	help
Pablo Greco d6c4c4
+	  The firmware trace can be enabled either at build-time with
Pablo Greco d6c4c4
+	  this option, or dynamically by setting flags in the SOF core
Pablo Greco d6c4c4
+	  module parameter (similar to dynamic debug)
Pablo Greco d6c4c4
+	  If unsure, select "N".
Pablo Greco d6c4c4
+
Pablo Greco d6c4c4
 config SND_SOC_SOF_DEBUG_IPC_FLOOD_TEST
Pablo Greco d6c4c4
 	bool "SOF enable IPC flood test"
Pablo Greco d6c4c4
 	help
Pablo Greco d6c4c4
diff --git a/sound/soc/sof/core.c b/sound/soc/sof/core.c
Pablo Greco d6c4c4
index 12aec140819a..1e7addfc0f61 100644
Pablo Greco d6c4c4
--- a/sound/soc/sof/core.c
Pablo Greco d6c4c4
+++ b/sound/soc/sof/core.c
Pablo Greco d6c4c4
@@ -16,6 +16,11 @@
Pablo Greco d6c4c4
 #include "sof-priv.h"
Pablo Greco d6c4c4
 #include "ops.h"
Pablo Greco d6c4c4
 
Pablo Greco d6c4c4
+/* see SOF_DBG_ flags */
Pablo Greco d6c4c4
+int sof_core_debug;
Pablo Greco d6c4c4
+module_param_named(sof_debug, sof_core_debug, int, 0444);
Pablo Greco d6c4c4
+MODULE_PARM_DESC(sof_debug, "SOF core debug options (0x0 all off)");
Pablo Greco d6c4c4
+
Pablo Greco d6c4c4
 /* SOF defaults if not provided by the platform in ms */
Pablo Greco d6c4c4
 #define TIMEOUT_DEFAULT_IPC_MS  500
Pablo Greco d6c4c4
 #define TIMEOUT_DEFAULT_BOOT_MS 2000
Pablo Greco d6c4c4
@@ -397,12 +402,20 @@ static int sof_probe_continue(struct snd_sof_dev *sdev)
Pablo Greco d6c4c4
 		goto fw_run_err;
Pablo Greco d6c4c4
 	}
Pablo Greco d6c4c4
 
Pablo Greco d6c4c4
-	/* init DMA trace */
Pablo Greco d6c4c4
-	ret = snd_sof_init_trace(sdev);
Pablo Greco d6c4c4
-	if (ret < 0) {
Pablo Greco d6c4c4
-		/* non fatal */
Pablo Greco d6c4c4
-		dev_warn(sdev->dev,
Pablo Greco d6c4c4
-			 "warning: failed to initialize trace %d\n", ret);
Pablo Greco d6c4c4
+	if (IS_ENABLED(CONFIG_SND_SOC_SOF_DEBUG_ENABLE_FIRMWARE_TRACE) ||
Pablo Greco d6c4c4
+	    (sof_core_debug & SOF_DBG_ENABLE_TRACE)) {
Pablo Greco d6c4c4
+		sdev->dtrace_is_supported = true;
Pablo Greco d6c4c4
+
Pablo Greco d6c4c4
+		/* init DMA trace */
Pablo Greco d6c4c4
+		ret = snd_sof_init_trace(sdev);
Pablo Greco d6c4c4
+		if (ret < 0) {
Pablo Greco d6c4c4
+			/* non fatal */
Pablo Greco d6c4c4
+			dev_warn(sdev->dev,
Pablo Greco d6c4c4
+				 "warning: failed to initialize trace %d\n",
Pablo Greco d6c4c4
+				 ret);
Pablo Greco d6c4c4
+		}
Pablo Greco d6c4c4
+	} else {
Pablo Greco d6c4c4
+		dev_dbg(sdev->dev, "SOF firmware trace disabled\n");
Pablo Greco d6c4c4
 	}
Pablo Greco d6c4c4
 
Pablo Greco d6c4c4
 	/* hereafter all FW boot flows are for PM reasons */
Pablo Greco d6c4c4
diff --git a/sound/soc/sof/sof-priv.h b/sound/soc/sof/sof-priv.h
Pablo Greco d6c4c4
index 7b329bd99674..e68f3cb78cda 100644
Pablo Greco d6c4c4
--- a/sound/soc/sof/sof-priv.h
Pablo Greco d6c4c4
+++ b/sound/soc/sof/sof-priv.h
Pablo Greco d6c4c4
@@ -28,10 +28,14 @@
Pablo Greco d6c4c4
 #include <uapi sound="" sof="" fw.h="">
Pablo Greco d6c4c4
 
Pablo Greco d6c4c4
 /* debug flags */
Pablo Greco d6c4c4
-#define SOF_DBG_REGS	BIT(1)
Pablo Greco d6c4c4
-#define SOF_DBG_MBOX	BIT(2)
Pablo Greco d6c4c4
-#define SOF_DBG_TEXT	BIT(3)
Pablo Greco d6c4c4
-#define SOF_DBG_PCI	BIT(4)
Pablo Greco d6c4c4
+#define SOF_DBG_ENABLE_TRACE	BIT(0)
Pablo Greco d6c4c4
+#define SOF_DBG_REGS		BIT(1)
Pablo Greco d6c4c4
+#define SOF_DBG_MBOX		BIT(2)
Pablo Greco d6c4c4
+#define SOF_DBG_TEXT		BIT(3)
Pablo Greco d6c4c4
+#define SOF_DBG_PCI		BIT(4)
Pablo Greco d6c4c4
+
Pablo Greco d6c4c4
+/* global debug state set by SOF_DBG_ flags */
Pablo Greco d6c4c4
+extern int sof_core_debug;
Pablo Greco d6c4c4
 
Pablo Greco d6c4c4
 /* max BARs mmaped devices can use */
Pablo Greco d6c4c4
 #define SND_SOF_BARS	8
Pablo Greco d6c4c4
@@ -443,6 +447,7 @@ struct snd_sof_dev {
Pablo Greco d6c4c4
 	int dma_trace_pages;
Pablo Greco d6c4c4
 	wait_queue_head_t trace_sleep;
Pablo Greco d6c4c4
 	u32 host_offset;
Pablo Greco d6c4c4
+	u32 dtrace_is_supported; /* set with Kconfig or module parameter */
Pablo Greco d6c4c4
 	u32 dtrace_is_enabled;
Pablo Greco d6c4c4
 	u32 dtrace_error;
Pablo Greco d6c4c4
 	u32 dtrace_draining;
Pablo Greco d6c4c4
diff --git a/sound/soc/sof/trace.c b/sound/soc/sof/trace.c
Pablo Greco d6c4c4
index 4c3cff031fd6..b0e4556c8536 100644
Pablo Greco d6c4c4
--- a/sound/soc/sof/trace.c
Pablo Greco d6c4c4
+++ b/sound/soc/sof/trace.c
Pablo Greco d6c4c4
@@ -162,6 +162,9 @@ int snd_sof_init_trace_ipc(struct snd_sof_dev *sdev)
Pablo Greco d6c4c4
 	struct sof_ipc_reply ipc_reply;
Pablo Greco d6c4c4
 	int ret;
Pablo Greco d6c4c4
 
Pablo Greco d6c4c4
+	if (!sdev->dtrace_is_supported)
Pablo Greco d6c4c4
+		return 0;
Pablo Greco d6c4c4
+
Pablo Greco d6c4c4
 	if (sdev->dtrace_is_enabled || !sdev->dma_trace_pages)
Pablo Greco d6c4c4
 		return -EINVAL;
Pablo Greco d6c4c4
 
Pablo Greco d6c4c4
@@ -222,6 +225,9 @@ int snd_sof_init_trace(struct snd_sof_dev *sdev)
Pablo Greco d6c4c4
 {
Pablo Greco d6c4c4
 	int ret;
Pablo Greco d6c4c4
 
Pablo Greco d6c4c4
+	if (!sdev->dtrace_is_supported)
Pablo Greco d6c4c4
+		return 0;
Pablo Greco d6c4c4
+
Pablo Greco d6c4c4
 	/* set false before start initialization */
Pablo Greco d6c4c4
 	sdev->dtrace_is_enabled = false;
Pablo Greco d6c4c4
 
Pablo Greco d6c4c4
@@ -277,6 +283,9 @@ EXPORT_SYMBOL(snd_sof_init_trace);
Pablo Greco d6c4c4
 int snd_sof_trace_update_pos(struct snd_sof_dev *sdev,
Pablo Greco d6c4c4
 			     struct sof_ipc_dma_trace_posn *posn)
Pablo Greco d6c4c4
 {
Pablo Greco d6c4c4
+	if (!sdev->dtrace_is_supported)
Pablo Greco d6c4c4
+		return 0;
Pablo Greco d6c4c4
+
Pablo Greco d6c4c4
 	if (sdev->dtrace_is_enabled && sdev->host_offset != posn->host_offset) {
Pablo Greco d6c4c4
 		sdev->host_offset = posn->host_offset;
Pablo Greco d6c4c4
 		wake_up(&sdev->trace_sleep);
Pablo Greco d6c4c4
@@ -293,6 +302,9 @@ int snd_sof_trace_update_pos(struct snd_sof_dev *sdev,
Pablo Greco d6c4c4
 /* an error has occurred within the DSP that prevents further trace */
Pablo Greco d6c4c4
 void snd_sof_trace_notify_for_error(struct snd_sof_dev *sdev)
Pablo Greco d6c4c4
 {
Pablo Greco d6c4c4
+	if (!sdev->dtrace_is_supported)
Pablo Greco d6c4c4
+		return;
Pablo Greco d6c4c4
+
Pablo Greco d6c4c4
 	if (sdev->dtrace_is_enabled) {
Pablo Greco d6c4c4
 		dev_err(sdev->dev, "error: waking up any trace sleepers\n");
Pablo Greco d6c4c4
 		sdev->dtrace_error = true;
Pablo Greco d6c4c4
@@ -305,7 +317,7 @@ void snd_sof_release_trace(struct snd_sof_dev *sdev)
Pablo Greco d6c4c4
 {
Pablo Greco d6c4c4
 	int ret;
Pablo Greco d6c4c4
 
Pablo Greco d6c4c4
-	if (!sdev->dtrace_is_enabled)
Pablo Greco d6c4c4
+	if (!sdev->dtrace_is_supported || !sdev->dtrace_is_enabled)
Pablo Greco d6c4c4
 		return;
Pablo Greco d6c4c4
 
Pablo Greco d6c4c4
 	ret = snd_sof_dma_trace_trigger(sdev, SNDRV_PCM_TRIGGER_STOP);
Pablo Greco d6c4c4
@@ -326,6 +338,9 @@ EXPORT_SYMBOL(snd_sof_release_trace);
Pablo Greco d6c4c4
 
Pablo Greco d6c4c4
 void snd_sof_free_trace(struct snd_sof_dev *sdev)
Pablo Greco d6c4c4
 {
Pablo Greco d6c4c4
+	if (!sdev->dtrace_is_supported)
Pablo Greco d6c4c4
+		return;
Pablo Greco d6c4c4
+
Pablo Greco d6c4c4
 	snd_sof_release_trace(sdev);
Pablo Greco d6c4c4
 
Pablo Greco d6c4c4
 	snd_dma_free_pages(&sdev->dmatb);
Pablo Greco d6c4c4
-- 
Pablo Greco d6c4c4
2.24.1
Pablo Greco d6c4c4
Pablo Greco d6c4c4
From 2e85462e14f0f736f4cace881c704ac8fa050475 Mon Sep 17 00:00:00 2001
Pablo Greco d6c4c4
From: Liam Girdwood <liam.r.girdwood@linux.intel.com>
Pablo Greco d6c4c4
Date: Fri, 27 Sep 2019 15:05:29 -0500
Pablo Greco d6c4c4
Subject: [PATCH 016/109] ASoC: SOF: ipc: retain DSP context after FW
Pablo Greco d6c4c4
 exception.
Pablo Greco d6c4c4
Pablo Greco d6c4c4
Add config option to prevent DSP entering D3 after any FW exception.
Pablo Greco d6c4c4
This can then be used to dump FW context for debug.
Pablo Greco d6c4c4
Pablo Greco d6c4c4
Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
Pablo Greco d6c4c4
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Pablo Greco d6c4c4
Link: https://lore.kernel.org/r/20190927200538.660-5-pierre-louis.bossart@linux.intel.com
Pablo Greco d6c4c4
Signed-off-by: Mark Brown <broonie@kernel.org>
Pablo Greco d6c4c4
Pablo Greco d6c4c4
Signed-off-by: Jaroslav Kysela <jkysela@redhat.com>
Pablo Greco d6c4c4
(cherry picked from commit 9a06508bf7824ba34f2e1e9e08df505ac14a44c2)
Pablo Greco d6c4c4
Bugzilla: 1772498
Pablo Greco d6c4c4
---
Pablo Greco d6c4c4
 sound/soc/sof/Kconfig    |  8 ++++++++
Pablo Greco d6c4c4
 sound/soc/sof/debug.c    | 16 ++++++++++++++++
Pablo Greco d6c4c4
 sound/soc/sof/ipc.c      |  4 +---
Pablo Greco d6c4c4
 sound/soc/sof/sof-priv.h |  2 ++
Pablo Greco d6c4c4
 4 files changed, 27 insertions(+), 3 deletions(-)
Pablo Greco d6c4c4
Pablo Greco d6c4c4
diff --git a/sound/soc/sof/Kconfig b/sound/soc/sof/Kconfig
Pablo Greco d6c4c4
index cc592bcadae7..56a3ab66b46b 100644
Pablo Greco d6c4c4
--- a/sound/soc/sof/Kconfig
Pablo Greco d6c4c4
+++ b/sound/soc/sof/Kconfig
Pablo Greco d6c4c4
@@ -158,6 +158,14 @@ config SND_SOC_SOF_DEBUG_IPC_FLOOD_TEST
Pablo Greco d6c4c4
 	  Say Y if you want to enable IPC flood test.
Pablo Greco d6c4c4
 	  If unsure, select "N".
Pablo Greco d6c4c4
 
Pablo Greco d6c4c4
+config SND_SOC_SOF_DEBUG_RETAIN_DSP_CONTEXT
Pablo Greco d6c4c4
+	bool "SOF retain DSP context on any FW exceptions"
Pablo Greco d6c4c4
+	help
Pablo Greco d6c4c4
+	  This option keeps the DSP in D0 state so that firmware debug
Pablo Greco d6c4c4
+	  information can be retained and dumped to userspace.
Pablo Greco d6c4c4
+	  Say Y if you want to retain DSP context for FW exceptions.
Pablo Greco d6c4c4
+	  If unsure, select "N".
Pablo Greco d6c4c4
+
Pablo Greco d6c4c4
 endif ## SND_SOC_SOF_DEBUG
Pablo Greco d6c4c4
 
Pablo Greco d6c4c4
 endif ## SND_SOC_SOF_OPTIONS
Pablo Greco d6c4c4
diff --git a/sound/soc/sof/debug.c b/sound/soc/sof/debug.c
Pablo Greco d6c4c4
index 5529e8eeca46..d2b3b99d3a20 100644
Pablo Greco d6c4c4
--- a/sound/soc/sof/debug.c
Pablo Greco d6c4c4
+++ b/sound/soc/sof/debug.c
Pablo Greco d6c4c4
@@ -463,3 +463,19 @@ void snd_sof_free_debug(struct snd_sof_dev *sdev)
Pablo Greco d6c4c4
 	debugfs_remove_recursive(sdev->debugfs_root);
Pablo Greco d6c4c4
 }
Pablo Greco d6c4c4
 EXPORT_SYMBOL_GPL(snd_sof_free_debug);
Pablo Greco d6c4c4
+
Pablo Greco d6c4c4
+void snd_sof_handle_fw_exception(struct snd_sof_dev *sdev)
Pablo Greco d6c4c4
+{
Pablo Greco d6c4c4
+	if (IS_ENABLED(CONFIG_SND_SOC_SOF_DEBUG_RETAIN_DSP_CONTEXT) ||
Pablo Greco d6c4c4
+	    (sof_core_debug & SOF_DBG_RETAIN_CTX)) {
Pablo Greco d6c4c4
+		/* should we prevent DSP entering D3 ? */
Pablo Greco d6c4c4
+		dev_info(sdev->dev, "info: preventing DSP entering D3 state to preserve context\n");
Pablo Greco d6c4c4
+		pm_runtime_get_noresume(sdev->dev);
Pablo Greco d6c4c4
+	}
Pablo Greco d6c4c4
+
Pablo Greco d6c4c4
+	/* dump vital information to the logs */
Pablo Greco d6c4c4
+	snd_sof_dsp_dbg_dump(sdev, SOF_DBG_REGS | SOF_DBG_MBOX);
Pablo Greco d6c4c4
+	snd_sof_ipc_dump(sdev);
Pablo Greco d6c4c4
+	snd_sof_trace_notify_for_error(sdev);
Pablo Greco d6c4c4
+}
Pablo Greco d6c4c4
+EXPORT_SYMBOL(snd_sof_handle_fw_exception);
Pablo Greco d6c4c4
diff --git a/sound/soc/sof/ipc.c b/sound/soc/sof/ipc.c
Pablo Greco d6c4c4
index 8984d965037d..bc292f071a4f 100644
Pablo Greco d6c4c4
--- a/sound/soc/sof/ipc.c
Pablo Greco d6c4c4
+++ b/sound/soc/sof/ipc.c
Pablo Greco d6c4c4
@@ -210,9 +210,7 @@ static int tx_wait_done(struct snd_sof_ipc *ipc, struct snd_sof_ipc_msg *msg,
Pablo Greco d6c4c4
 	if (ret == 0) {
Pablo Greco d6c4c4
 		dev_err(sdev->dev, "error: ipc timed out for 0x%x size %d\n",
Pablo Greco d6c4c4
 			hdr->cmd, hdr->size);
Pablo Greco d6c4c4
-		snd_sof_dsp_dbg_dump(ipc->sdev, SOF_DBG_REGS | SOF_DBG_MBOX);
Pablo Greco d6c4c4
-		snd_sof_ipc_dump(ipc->sdev);
Pablo Greco d6c4c4
-		snd_sof_trace_notify_for_error(ipc->sdev);
Pablo Greco d6c4c4
+		snd_sof_handle_fw_exception(ipc->sdev);
Pablo Greco d6c4c4
 		ret = -ETIMEDOUT;
Pablo Greco d6c4c4
 	} else {
Pablo Greco d6c4c4
 		/* copy the data returned from DSP */
Pablo Greco d6c4c4
diff --git a/sound/soc/sof/sof-priv.h b/sound/soc/sof/sof-priv.h
Pablo Greco d6c4c4
index e68f3cb78cda..a769687b576d 100644
Pablo Greco d6c4c4
--- a/sound/soc/sof/sof-priv.h
Pablo Greco d6c4c4
+++ b/sound/soc/sof/sof-priv.h
Pablo Greco d6c4c4
@@ -33,6 +33,7 @@
Pablo Greco d6c4c4
 #define SOF_DBG_MBOX		BIT(2)
Pablo Greco d6c4c4
 #define SOF_DBG_TEXT		BIT(3)
Pablo Greco d6c4c4
 #define SOF_DBG_PCI		BIT(4)
Pablo Greco d6c4c4
+#define SOF_DBG_RETAIN_CTX	BIT(5)	/* prevent DSP D3 on FW exception */
Pablo Greco d6c4c4
 
Pablo Greco d6c4c4
 /* global debug state set by SOF_DBG_ flags */
Pablo Greco d6c4c4
 extern int sof_core_debug;
Pablo Greco d6c4c4
@@ -589,6 +590,7 @@ void snd_sof_get_status(struct snd_sof_dev *sdev, u32 panic_code,
Pablo Greco d6c4c4
 			struct sof_ipc_panic_info *panic_info,
Pablo Greco d6c4c4
 			void *stack, size_t stack_words);
Pablo Greco d6c4c4
 int snd_sof_init_trace_ipc(struct snd_sof_dev *sdev);
Pablo Greco d6c4c4
+void snd_sof_handle_fw_exception(struct snd_sof_dev *sdev);
Pablo Greco d6c4c4
 
Pablo Greco d6c4c4
 /*
Pablo Greco d6c4c4
  * Platform specific ops.
Pablo Greco d6c4c4
-- 
Pablo Greco d6c4c4
2.24.1
Pablo Greco d6c4c4
Pablo Greco d6c4c4
From d55d009f0d9c4ef5c4b693b1f5ec6a0ae1f84c1d Mon Sep 17 00:00:00 2001
Pablo Greco d6c4c4
From: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Pablo Greco d6c4c4
Date: Fri, 27 Sep 2019 15:05:32 -0500
Pablo Greco d6c4c4
Subject: [PATCH 017/109] ASoC: SOF: core: check for mandatory fw_ready op
Pablo Greco d6c4c4
 during SOF probe
Pablo Greco d6c4c4
Pablo Greco d6c4c4
fw_ready should be a mandatory op. Make sure fw_ready ops is set
Pablo Greco d6c4c4
during probe.
Pablo Greco d6c4c4
Pablo Greco d6c4c4
Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Pablo Greco d6c4c4
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Pablo Greco d6c4c4
Link: https://lore.kernel.org/r/20190927200538.660-8-pierre-louis.bossart@linux.intel.com
Pablo Greco d6c4c4
Signed-off-by: Mark Brown <broonie@kernel.org>
Pablo Greco d6c4c4
Pablo Greco d6c4c4
Signed-off-by: Jaroslav Kysela <jkysela@redhat.com>
Pablo Greco d6c4c4
(cherry picked from commit 8692d498d675e2e1433274c5f03b855824f3f35d)
Pablo Greco d6c4c4
Bugzilla: 1772498
Pablo Greco d6c4c4
---
Pablo Greco d6c4c4
 sound/soc/sof/core.c     | 3 ++-
Pablo Greco d6c4c4
 sound/soc/sof/ipc.c      | 6 ------
Pablo Greco d6c4c4
 sound/soc/sof/sof-priv.h | 2 +-
Pablo Greco d6c4c4
 3 files changed, 3 insertions(+), 8 deletions(-)
Pablo Greco d6c4c4
Pablo Greco d6c4c4
diff --git a/sound/soc/sof/core.c b/sound/soc/sof/core.c
Pablo Greco d6c4c4
index 1e7addfc0f61..8a23739aa545 100644
Pablo Greco d6c4c4
--- a/sound/soc/sof/core.c
Pablo Greco d6c4c4
+++ b/sound/soc/sof/core.c
Pablo Greco d6c4c4
@@ -504,7 +504,8 @@ int snd_sof_device_probe(struct device *dev, struct snd_sof_pdata *plat_data)
Pablo Greco d6c4c4
 	if (!sof_ops(sdev) || !sof_ops(sdev)->probe || !sof_ops(sdev)->run ||
Pablo Greco d6c4c4
 	    !sof_ops(sdev)->block_read || !sof_ops(sdev)->block_write ||
Pablo Greco d6c4c4
 	    !sof_ops(sdev)->send_msg || !sof_ops(sdev)->load_firmware ||
Pablo Greco d6c4c4
-	    !sof_ops(sdev)->ipc_msg_data || !sof_ops(sdev)->ipc_pcm_params)
Pablo Greco d6c4c4
+	    !sof_ops(sdev)->ipc_msg_data || !sof_ops(sdev)->ipc_pcm_params ||
Pablo Greco d6c4c4
+	    !sof_ops(sdev)->fw_ready)
Pablo Greco d6c4c4
 		return -EINVAL;
Pablo Greco d6c4c4
 
Pablo Greco d6c4c4
 	INIT_LIST_HEAD(&sdev->pcm_list);
Pablo Greco d6c4c4
diff --git a/sound/soc/sof/ipc.c b/sound/soc/sof/ipc.c
Pablo Greco d6c4c4
index bc292f071a4f..dfe429f9e33f 100644
Pablo Greco d6c4c4
--- a/sound/soc/sof/ipc.c
Pablo Greco d6c4c4
+++ b/sound/soc/sof/ipc.c
Pablo Greco d6c4c4
@@ -787,12 +787,6 @@ struct snd_sof_ipc *snd_sof_ipc_init(struct snd_sof_dev *sdev)
Pablo Greco d6c4c4
 	struct snd_sof_ipc *ipc;
Pablo Greco d6c4c4
 	struct snd_sof_ipc_msg *msg;
Pablo Greco d6c4c4
 
Pablo Greco d6c4c4
-	/* check if mandatory ops required for ipc are defined */
Pablo Greco d6c4c4
-	if (!sof_ops(sdev)->fw_ready) {
Pablo Greco d6c4c4
-		dev_err(sdev->dev, "error: ipc mandatory ops not defined\n");
Pablo Greco d6c4c4
-		return NULL;
Pablo Greco d6c4c4
-	}
Pablo Greco d6c4c4
-
Pablo Greco d6c4c4
 	ipc = devm_kzalloc(sdev->dev, sizeof(*ipc), GFP_KERNEL);
Pablo Greco d6c4c4
 	if (!ipc)
Pablo Greco d6c4c4
 		return NULL;
Pablo Greco d6c4c4
diff --git a/sound/soc/sof/sof-priv.h b/sound/soc/sof/sof-priv.h
Pablo Greco d6c4c4
index a769687b576d..eb919527dd21 100644
Pablo Greco d6c4c4
--- a/sound/soc/sof/sof-priv.h
Pablo Greco d6c4c4
+++ b/sound/soc/sof/sof-priv.h
Pablo Greco d6c4c4
@@ -133,7 +133,7 @@ struct snd_sof_dsp_ops {
Pablo Greco d6c4c4
 	 * FW ready checks for ABI compatibility and creates
Pablo Greco d6c4c4
 	 * memory windows at first boot
Pablo Greco d6c4c4
 	 */
Pablo Greco d6c4c4
-	int (*fw_ready)(struct snd_sof_dev *sdev, u32 msg_id); /* optional */
Pablo Greco d6c4c4
+	int (*fw_ready)(struct snd_sof_dev *sdev, u32 msg_id); /* mandatory */
Pablo Greco d6c4c4
 
Pablo Greco d6c4c4
 	/* connect pcm substream to a host stream */
Pablo Greco d6c4c4
 	int (*pcm_open)(struct snd_sof_dev *sdev,
Pablo Greco d6c4c4
-- 
Pablo Greco d6c4c4
2.24.1
Pablo Greco d6c4c4
Pablo Greco d6c4c4
From bed2180906afe06547bc434b4101da52ef5ef912 Mon Sep 17 00:00:00 2001
Pablo Greco d6c4c4
From: Marcin Rajwa <marcin.rajwa@linux.intel.com>
Pablo Greco d6c4c4
Date: Fri, 27 Sep 2019 15:05:33 -0500
Pablo Greco d6c4c4
Subject: [PATCH 018/109] ASoC: SOF: ipc: introduce no_stream_position in
Pablo Greco d6c4c4
 sof_ipc_stream_params struct
Pablo Greco d6c4c4
Pablo Greco d6c4c4
The host period bytes value needs to be passed to firmware.
Pablo Greco d6c4c4
However current implementation uses this field for different
Pablo Greco d6c4c4
purpose - to indicate whether FW should send stream position
Pablo Greco d6c4c4
to the host. Therefore this patch introduces another field
Pablo Greco d6c4c4
"no_stream_position", a boolean value aimed to store information
Pablo Greco d6c4c4
about position tracking. This way host_period_bytes preserves its
Pablo Greco d6c4c4
original value.
Pablo Greco d6c4c4
Pablo Greco d6c4c4
Signed-off-by: Marcin Rajwa <marcin.rajwa@linux.intel.com>
Pablo Greco d6c4c4
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Pablo Greco d6c4c4
Link: https://lore.kernel.org/r/20190927200538.660-9-pierre-louis.bossart@linux.intel.com
Pablo Greco d6c4c4
Signed-off-by: Mark Brown <broonie@kernel.org>
Pablo Greco d6c4c4
Pablo Greco d6c4c4
Signed-off-by: Jaroslav Kysela <jkysela@redhat.com>
Pablo Greco d6c4c4
(cherry picked from commit e3ebfd0ab5b4880bfb6a9f32614c2e389cc3da56)
Pablo Greco d6c4c4
Bugzilla: 1772498
Pablo Greco d6c4c4
---
Pablo Greco d6c4c4
 include/sound/sof/stream.h | 4 ++--
Pablo Greco d6c4c4
 1 file changed, 2 insertions(+), 2 deletions(-)
Pablo Greco d6c4c4
Pablo Greco d6c4c4
diff --git a/include/sound/sof/stream.h b/include/sound/sof/stream.h
Pablo Greco d6c4c4
index 0b71b381b952..7facefb541b3 100644
Pablo Greco d6c4c4
--- a/include/sound/sof/stream.h
Pablo Greco d6c4c4
+++ b/include/sound/sof/stream.h
Pablo Greco d6c4c4
@@ -83,10 +83,10 @@ struct sof_ipc_stream_params {
Pablo Greco d6c4c4
 	uint16_t sample_valid_bytes;
Pablo Greco d6c4c4
 	uint16_t sample_container_bytes;
Pablo Greco d6c4c4
 
Pablo Greco d6c4c4
-	/* for notifying host period has completed - 0 means no period IRQ */
Pablo Greco d6c4c4
 	uint32_t host_period_bytes;
Pablo Greco d6c4c4
+	uint16_t no_stream_position; /**< 1 means don't send stream position */
Pablo Greco d6c4c4
 
Pablo Greco d6c4c4
-	uint32_t reserved[2];
Pablo Greco d6c4c4
+	uint16_t reserved[3];
Pablo Greco d6c4c4
 	uint16_t chmap[SOF_IPC_MAX_CHANNELS];	/**< channel map - SOF_CHMAP_ */
Pablo Greco d6c4c4
 } __packed;
Pablo Greco d6c4c4
 
Pablo Greco d6c4c4
-- 
Pablo Greco d6c4c4
2.24.1
Pablo Greco d6c4c4
Pablo Greco d6c4c4
From 621e4be575f4ab56711478b4306ea7ba78cc922a Mon Sep 17 00:00:00 2001
Pablo Greco d6c4c4
From: Marcin Rajwa <marcin.rajwa@linux.intel.com>
Pablo Greco d6c4c4
Date: Fri, 27 Sep 2019 15:05:34 -0500
Pablo Greco d6c4c4
Subject: [PATCH 019/109] ASoC: SOF: Intel: hda: fix reset of host_period_bytes
Pablo Greco d6c4c4
Pablo Greco d6c4c4
This patch prevents the reset of host period bytes
Pablo Greco d6c4c4
and uses no_stream_position to record requests
Pablo Greco d6c4c4
for stream position.
Pablo Greco d6c4c4
Pablo Greco d6c4c4
Signed-off-by: Marcin Rajwa <marcin.rajwa@linux.intel.com>
Pablo Greco d6c4c4
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Pablo Greco d6c4c4
Link: https://lore.kernel.org/r/20190927200538.660-10-pierre-louis.bossart@linux.intel.com
Pablo Greco d6c4c4
Signed-off-by: Mark Brown <broonie@kernel.org>
Pablo Greco d6c4c4
Pablo Greco d6c4c4
Signed-off-by: Jaroslav Kysela <jkysela@redhat.com>
Pablo Greco d6c4c4
(cherry picked from commit f567ff6c76f7e9b317248fcab7a0eb3ef432dc9e)
Pablo Greco d6c4c4
Bugzilla: 1772498
Pablo Greco d6c4c4
---
Pablo Greco d6c4c4
 sound/soc/sof/intel/hda-pcm.c | 15 ++++++++++++---
Pablo Greco d6c4c4
 1 file changed, 12 insertions(+), 3 deletions(-)
Pablo Greco d6c4c4
Pablo Greco d6c4c4
diff --git a/sound/soc/sof/intel/hda-pcm.c b/sound/soc/sof/intel/hda-pcm.c
Pablo Greco d6c4c4
index 9b730f183529..575f5f5877d8 100644
Pablo Greco d6c4c4
--- a/sound/soc/sof/intel/hda-pcm.c
Pablo Greco d6c4c4
+++ b/sound/soc/sof/intel/hda-pcm.c
Pablo Greco d6c4c4
@@ -89,6 +89,7 @@ int hda_dsp_pcm_hw_params(struct snd_sof_dev *sdev,
Pablo Greco d6c4c4
 	struct hdac_ext_stream *stream = stream_to_hdac_ext_stream(hstream);
Pablo Greco d6c4c4
 	struct sof_intel_hda_dev *hda = sdev->pdata->hw_pdata;
Pablo Greco d6c4c4
 	struct snd_dma_buffer *dmab;
Pablo Greco d6c4c4
+	struct sof_ipc_fw_version *v = &sdev->fw_ready.version;
Pablo Greco d6c4c4
 	int ret;
Pablo Greco d6c4c4
 	u32 size, rate, bits;
Pablo Greco d6c4c4
 
Pablo Greco d6c4c4
@@ -116,9 +117,17 @@ int hda_dsp_pcm_hw_params(struct snd_sof_dev *sdev,
Pablo Greco d6c4c4
 	/* disable SPIB, to enable buffer wrap for stream */
Pablo Greco d6c4c4
 	hda_dsp_stream_spib_config(sdev, stream, HDA_DSP_SPIB_DISABLE, 0);
Pablo Greco d6c4c4
 
Pablo Greco d6c4c4
-	/* set host_period_bytes to 0 if no IPC position */
Pablo Greco d6c4c4
-	if (hda && hda->no_ipc_position)
Pablo Greco d6c4c4
-		ipc_params->host_period_bytes = 0;
Pablo Greco d6c4c4
+	/* update no_stream_position flag for ipc params */
Pablo Greco d6c4c4
+	if (hda && hda->no_ipc_position) {
Pablo Greco d6c4c4
+		/* For older ABIs set host_period_bytes to zero to inform
Pablo Greco d6c4c4
+		 * FW we don't want position updates. Newer versions use
Pablo Greco d6c4c4
+		 * no_stream_position for this purpose.
Pablo Greco d6c4c4
+		 */
Pablo Greco d6c4c4
+		if (v->abi_version < SOF_ABI_VER(3, 10, 0))
Pablo Greco d6c4c4
+			ipc_params->host_period_bytes = 0;
Pablo Greco d6c4c4
+		else
Pablo Greco d6c4c4
+			ipc_params->no_stream_position = 1;
Pablo Greco d6c4c4
+	}
Pablo Greco d6c4c4
 
Pablo Greco d6c4c4
 	ipc_params->stream_tag = hstream->stream_tag;
Pablo Greco d6c4c4
 
Pablo Greco d6c4c4
-- 
Pablo Greco d6c4c4
2.24.1
Pablo Greco d6c4c4
Pablo Greco d6c4c4
From 244e3dece4e48b1aac798f9b1bf49565697cba87 Mon Sep 17 00:00:00 2001
Pablo Greco d6c4c4
From: Liam Girdwood <liam.r.girdwood@linux.intel.com>
Pablo Greco d6c4c4
Date: Fri, 27 Sep 2019 15:05:37 -0500
Pablo Greco d6c4c4
Subject: [PATCH 020/109] ASoC: SOF: Intel: Add context data to any IPC
Pablo Greco d6c4c4
 timeout.
Pablo Greco d6c4c4
Pablo Greco d6c4c4
Helps with FW debug as it provides DSP IPC processing context.
Pablo Greco d6c4c4
Pablo Greco d6c4c4
Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
Pablo Greco d6c4c4
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Pablo Greco d6c4c4
Link: https://lore.kernel.org/r/20190927200538.660-13-pierre-louis.bossart@linux.intel.com
Pablo Greco d6c4c4
Signed-off-by: Mark Brown <broonie@kernel.org>
Pablo Greco d6c4c4
Pablo Greco d6c4c4
Signed-off-by: Jaroslav Kysela <jkysela@redhat.com>
Pablo Greco d6c4c4
(cherry picked from commit 3a9e204d4e36904a464a2e53206b053a7ffc7bad)
Pablo Greco d6c4c4
Bugzilla: 1772498
Pablo Greco d6c4c4
---
Pablo Greco d6c4c4
 sound/soc/sof/intel/bdw.c | 22 +++++++++++++++++++++-
Pablo Greco d6c4c4
 sound/soc/sof/intel/byt.c | 23 ++++++++++++++++++++++-
Pablo Greco d6c4c4
 2 files changed, 43 insertions(+), 2 deletions(-)
Pablo Greco d6c4c4
Pablo Greco d6c4c4
diff --git a/sound/soc/sof/intel/bdw.c b/sound/soc/sof/intel/bdw.c
Pablo Greco d6c4c4
index 80e2826fb447..f395d0638876 100644
Pablo Greco d6c4c4
--- a/sound/soc/sof/intel/bdw.c
Pablo Greco d6c4c4
+++ b/sound/soc/sof/intel/bdw.c
Pablo Greco d6c4c4
@@ -247,7 +247,7 @@ static void bdw_dump(struct snd_sof_dev *sdev, u32 flags)
Pablo Greco d6c4c4
 	struct sof_ipc_dsp_oops_xtensa xoops;
Pablo Greco d6c4c4
 	struct sof_ipc_panic_info panic_info;
Pablo Greco d6c4c4
 	u32 stack[BDW_STACK_DUMP_SIZE];
Pablo Greco d6c4c4
-	u32 status, panic;
Pablo Greco d6c4c4
+	u32 status, panic, imrx, imrd;
Pablo Greco d6c4c4
 
Pablo Greco d6c4c4
 	/* now try generic SOF status messages */
Pablo Greco d6c4c4
 	status = snd_sof_dsp_read(sdev, BDW_DSP_BAR, SHIM_IPCD);
Pablo Greco d6c4c4
@@ -256,6 +256,26 @@ static void bdw_dump(struct snd_sof_dev *sdev, u32 flags)
Pablo Greco d6c4c4
 			  BDW_STACK_DUMP_SIZE);
Pablo Greco d6c4c4
 	snd_sof_get_status(sdev, status, panic, &xoops, &panic_info, stack,
Pablo Greco d6c4c4
 			   BDW_STACK_DUMP_SIZE);
Pablo Greco d6c4c4
+
Pablo Greco d6c4c4
+	/* provide some context for firmware debug */
Pablo Greco d6c4c4
+	imrx = snd_sof_dsp_read(sdev, BDW_DSP_BAR, SHIM_IMRX);
Pablo Greco d6c4c4
+	imrd = snd_sof_dsp_read(sdev, BDW_DSP_BAR, SHIM_IMRD);
Pablo Greco d6c4c4
+	dev_err(sdev->dev,
Pablo Greco d6c4c4
+		"error: ipc host -> DSP: pending %s complete %s raw 0x%8.8x\n",
Pablo Greco d6c4c4
+		panic & SHIM_IPCX_BUSY ? "yes" : "no",
Pablo Greco d6c4c4
+		panic & SHIM_IPCX_DONE ? "yes" : "no", panic);
Pablo Greco d6c4c4
+	dev_err(sdev->dev,
Pablo Greco d6c4c4
+		"error: mask host: pending %s complete %s raw 0x%8.8x\n",
Pablo Greco d6c4c4
+		imrx & SHIM_IMRX_BUSY ? "yes" : "no",
Pablo Greco d6c4c4
+		imrx & SHIM_IMRX_DONE ? "yes" : "no", imrx);
Pablo Greco d6c4c4
+	dev_err(sdev->dev,
Pablo Greco d6c4c4
+		"error: ipc DSP -> host: pending %s complete %s raw 0x%8.8x\n",
Pablo Greco d6c4c4
+		status & SHIM_IPCD_BUSY ? "yes" : "no",
Pablo Greco d6c4c4
+		status & SHIM_IPCD_DONE ? "yes" : "no", status);
Pablo Greco d6c4c4
+	dev_err(sdev->dev,
Pablo Greco d6c4c4
+		"error: mask DSP: pending %s complete %s raw 0x%8.8x\n",
Pablo Greco d6c4c4
+		imrd & SHIM_IMRD_BUSY ? "yes" : "no",
Pablo Greco d6c4c4
+		imrd & SHIM_IMRD_DONE ? "yes" : "no", imrd);
Pablo Greco d6c4c4
 }
Pablo Greco d6c4c4
 
Pablo Greco d6c4c4
 /*
Pablo Greco d6c4c4
diff --git a/sound/soc/sof/intel/byt.c b/sound/soc/sof/intel/byt.c
Pablo Greco d6c4c4
index 41008c974ac6..3138d9a2c621 100644
Pablo Greco d6c4c4
--- a/sound/soc/sof/intel/byt.c
Pablo Greco d6c4c4
+++ b/sound/soc/sof/intel/byt.c
Pablo Greco d6c4c4
@@ -146,7 +146,7 @@ static void byt_dump(struct snd_sof_dev *sdev, u32 flags)
Pablo Greco d6c4c4
 	struct sof_ipc_dsp_oops_xtensa xoops;
Pablo Greco d6c4c4
 	struct sof_ipc_panic_info panic_info;
Pablo Greco d6c4c4
 	u32 stack[BYT_STACK_DUMP_SIZE];
Pablo Greco d6c4c4
-	u32 status, panic;
Pablo Greco d6c4c4
+	u32 status, panic, imrd, imrx;
Pablo Greco d6c4c4
 
Pablo Greco d6c4c4
 	/* now try generic SOF status messages */
Pablo Greco d6c4c4
 	status = snd_sof_dsp_read(sdev, BYT_DSP_BAR, SHIM_IPCD);
Pablo Greco d6c4c4
@@ -155,6 +155,27 @@ static void byt_dump(struct snd_sof_dev *sdev, u32 flags)
Pablo Greco d6c4c4
 			  BYT_STACK_DUMP_SIZE);
Pablo Greco d6c4c4
 	snd_sof_get_status(sdev, status, panic, &xoops, &panic_info, stack,
Pablo Greco d6c4c4
 			   BYT_STACK_DUMP_SIZE);
Pablo Greco d6c4c4
+
Pablo Greco d6c4c4
+	/* provide some context for firmware debug */
Pablo Greco d6c4c4
+	imrx = snd_sof_dsp_read(sdev, BYT_DSP_BAR, SHIM_IMRX);
Pablo Greco d6c4c4
+	imrd = snd_sof_dsp_read(sdev, BYT_DSP_BAR, SHIM_IMRD);
Pablo Greco d6c4c4
+	dev_err(sdev->dev,
Pablo Greco d6c4c4
+		"error: ipc host -> DSP: pending %s complete %s raw 0x%8.8x\n",
Pablo Greco d6c4c4
+		panic & SHIM_IPCX_BUSY ? "yes" : "no",
Pablo Greco d6c4c4
+		panic & SHIM_IPCX_DONE ? "yes" : "no", panic);
Pablo Greco d6c4c4
+	dev_err(sdev->dev,
Pablo Greco d6c4c4
+		"error: mask host: pending %s complete %s raw 0x%8.8x\n",
Pablo Greco d6c4c4
+		imrx & SHIM_IMRX_BUSY ? "yes" : "no",
Pablo Greco d6c4c4
+		imrx & SHIM_IMRX_DONE ? "yes" : "no", imrx);
Pablo Greco d6c4c4
+	dev_err(sdev->dev,
Pablo Greco d6c4c4
+		"error: ipc DSP -> host: pending %s complete %s raw 0x%8.8x\n",
Pablo Greco d6c4c4
+		status & SHIM_IPCD_BUSY ? "yes" : "no",
Pablo Greco d6c4c4
+		status & SHIM_IPCD_DONE ? "yes" : "no", status);
Pablo Greco d6c4c4
+	dev_err(sdev->dev,
Pablo Greco d6c4c4
+		"error: mask DSP: pending %s complete %s raw 0x%8.8x\n",
Pablo Greco d6c4c4
+		imrd & SHIM_IMRD_BUSY ? "yes" : "no",
Pablo Greco d6c4c4
+		imrd & SHIM_IMRD_DONE ? "yes" : "no", imrd);
Pablo Greco d6c4c4
+
Pablo Greco d6c4c4
 }
Pablo Greco d6c4c4
 
Pablo Greco d6c4c4
 /*
Pablo Greco d6c4c4
-- 
Pablo Greco d6c4c4
2.24.1
Pablo Greco d6c4c4
Pablo Greco d6c4c4
From 2ce45551453d13f25f89c4273934efd179c34195 Mon Sep 17 00:00:00 2001
Pablo Greco d6c4c4
From: Jaska Uimonen <jaska.uimonen@linux.intel.com>
Pablo Greco d6c4c4
Date: Tue, 8 Oct 2019 11:44:41 -0500
Pablo Greco d6c4c4
Subject: [PATCH 021/109] ASoC: SOF: enable dual control for pga
Pablo Greco d6c4c4
Pablo Greco d6c4c4
Currently sof pga element supports only 1 kcontrol and you can't create
Pablo Greco d6c4c4
for example a mixer element with combined volume slider and mute switch.
Pablo Greco d6c4c4
So enable sof pga to have more than 1 kcontrol associated with it. Also
Pablo Greco d6c4c4
check for possible NULL tlv pointer as switch element might not have it.
Pablo Greco d6c4c4
Pablo Greco d6c4c4
Signed-off-by: Jaska Uimonen <jaska.uimonen@linux.intel.com>
Pablo Greco d6c4c4
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Pablo Greco d6c4c4
Link: https://lore.kernel.org/r/20191008164443.1358-8-pierre-louis.bossart@linux.intel.com
Pablo Greco d6c4c4
Signed-off-by: Mark Brown <broonie@kernel.org>
Pablo Greco d6c4c4
Pablo Greco d6c4c4
Signed-off-by: Jaroslav Kysela <jkysela@redhat.com>
Pablo Greco d6c4c4
(cherry picked from commit a68c6b6cc77b841dc37c17a5d9a7074e26801af5)
Pablo Greco d6c4c4
Bugzilla: 1772498
Pablo Greco d6c4c4
---
Pablo Greco d6c4c4
 sound/soc/sof/topology.c | 5 +++--
Pablo Greco d6c4c4
 1 file changed, 3 insertions(+), 2 deletions(-)
Pablo Greco d6c4c4
Pablo Greco d6c4c4
diff --git a/sound/soc/sof/topology.c b/sound/soc/sof/topology.c
Pablo Greco d6c4c4
index fa299e078156..96c20c889fa4 100644
Pablo Greco d6c4c4
--- a/sound/soc/sof/topology.c
Pablo Greco d6c4c4
+++ b/sound/soc/sof/topology.c
Pablo Greco d6c4c4
@@ -1581,7 +1581,7 @@ static int sof_widget_load_pga(struct snd_soc_component *scomp, int index,
Pablo Greco d6c4c4
 	if (!volume)
Pablo Greco d6c4c4
 		return -ENOMEM;
Pablo Greco d6c4c4
 
Pablo Greco d6c4c4
-	if (le32_to_cpu(tw->num_kcontrols) != 1) {
Pablo Greco d6c4c4
+	if (!le32_to_cpu(tw->num_kcontrols)) {
Pablo Greco d6c4c4
 		dev_err(sdev->dev, "error: invalid kcontrol count %d for volume\n",
Pablo Greco d6c4c4
 			tw->num_kcontrols);
Pablo Greco d6c4c4
 		ret = -EINVAL;
Pablo Greco d6c4c4
@@ -1618,7 +1618,8 @@ static int sof_widget_load_pga(struct snd_soc_component *scomp, int index,
Pablo Greco d6c4c4
 	swidget->private = volume;
Pablo Greco d6c4c4
 
Pablo Greco d6c4c4
 	list_for_each_entry(scontrol, &sdev->kcontrol_list, list) {
Pablo Greco d6c4c4
-		if (scontrol->comp_id == swidget->comp_id) {
Pablo Greco d6c4c4
+		if (scontrol->comp_id == swidget->comp_id &&
Pablo Greco d6c4c4
+		    scontrol->volume_table) {
Pablo Greco d6c4c4
 			min_step = scontrol->min_volume_step;
Pablo Greco d6c4c4
 			max_step = scontrol->max_volume_step;
Pablo Greco d6c4c4
 			volume->min_value = scontrol->volume_table[min_step];
Pablo Greco d6c4c4
-- 
Pablo Greco d6c4c4
2.24.1
Pablo Greco d6c4c4
Pablo Greco d6c4c4
From 1abf144571f2f8791c1d6b5f9242da41e3ed8c2e Mon Sep 17 00:00:00 2001
Pablo Greco d6c4c4
From: Kai Vehmanen <kai.vehmanen@linux.intel.com>
Pablo Greco d6c4c4
Date: Tue, 8 Oct 2019 11:44:36 -0500
Pablo Greco d6c4c4
Subject: [PATCH 022/109] Revert "ASoC: SOF: Force polling mode on CFL and CNL"
Pablo Greco d6c4c4
Pablo Greco d6c4c4
This reverts commit 64ca9d9fcb3e3c86b1417e3d17a90b43dd660f81.
Pablo Greco d6c4c4
Pablo Greco d6c4c4
The workaround is no longer needed after configuring HDAC
Pablo Greco d6c4c4
bus with sync_write=1.
Pablo Greco d6c4c4
Pablo Greco d6c4c4
Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
Pablo Greco d6c4c4
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Pablo Greco d6c4c4
Link: https://lore.kernel.org/r/20191008164443.1358-3-pierre-louis.bossart@linux.intel.com
Pablo Greco d6c4c4
Signed-off-by: Mark Brown <broonie@kernel.org>
Pablo Greco d6c4c4
Pablo Greco d6c4c4
Signed-off-by: Jaroslav Kysela <jkysela@redhat.com>
Pablo Greco d6c4c4
(cherry picked from commit 902fd492d5ea2c02666ddadc1da977ca94e6b52c)
Pablo Greco d6c4c4
Bugzilla: 1772498
Pablo Greco d6c4c4
---
Pablo Greco d6c4c4
 sound/soc/sof/intel/hda.c | 7 -------
Pablo Greco d6c4c4
 1 file changed, 7 deletions(-)
Pablo Greco d6c4c4
Pablo Greco d6c4c4
diff --git a/sound/soc/sof/intel/hda.c b/sound/soc/sof/intel/hda.c
Pablo Greco d6c4c4
index 3c4b604412f0..ff3fa8670fd8 100644
Pablo Greco d6c4c4
--- a/sound/soc/sof/intel/hda.c
Pablo Greco d6c4c4
+++ b/sound/soc/sof/intel/hda.c
Pablo Greco d6c4c4
@@ -32,9 +32,6 @@
Pablo Greco d6c4c4
 /* platform specific devices */
Pablo Greco d6c4c4
 #include "shim.h"
Pablo Greco d6c4c4
 
Pablo Greco d6c4c4
-#define IS_CFL(pci) ((pci)->vendor == 0x8086 && (pci)->device == 0xa348)
Pablo Greco d6c4c4
-#define IS_CNL(pci) ((pci)->vendor == 0x8086 && (pci)->device == 0x9dc8)
Pablo Greco d6c4c4
-
Pablo Greco d6c4c4
 #define EXCEPT_MAX_HDR_SIZE	0x400
Pablo Greco d6c4c4
 
Pablo Greco d6c4c4
 /*
Pablo Greco d6c4c4
@@ -262,10 +259,6 @@ static int hda_init(struct snd_sof_dev *sdev)
Pablo Greco d6c4c4
 	/* HDA bus init */
Pablo Greco d6c4c4
 	sof_hda_bus_init(bus, &pci->dev);
Pablo Greco d6c4c4
 
Pablo Greco d6c4c4
-	/* Workaround for a communication error on CFL (bko#199007) and CNL */
Pablo Greco d6c4c4
-	if (IS_CFL(pci) || IS_CNL(pci))
Pablo Greco d6c4c4
-		bus->polling_mode = 1;
Pablo Greco d6c4c4
-
Pablo Greco d6c4c4
 	bus->use_posbuf = 1;
Pablo Greco d6c4c4
 	bus->bdl_pos_adj = 0;
Pablo Greco d6c4c4
 	bus->sync_write = 1;
Pablo Greco d6c4c4
-- 
Pablo Greco d6c4c4
2.24.1
Pablo Greco d6c4c4
Pablo Greco d6c4c4
From 7947c07881d4fa46b74c5884d5e0a5ecbd2825b3 Mon Sep 17 00:00:00 2001
Pablo Greco d6c4c4
From: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Pablo Greco d6c4c4
Date: Tue, 8 Oct 2019 11:44:37 -0500
Pablo Greco d6c4c4
Subject: [PATCH 023/109] ASoC: SOF: acpi: add debug module param
Pablo Greco d6c4c4
Pablo Greco d6c4c4
Add debug parameter for snd-sof-acpi.
Pablo Greco d6c4c4
Pablo Greco d6c4c4
One of the usages for this debug parameter to disable pm_runtime,
Pablo Greco d6c4c4
which can be useful for platform bringup, or keep the parent device
Pablo Greco d6c4c4
active while enabling pm_runtime for child devices (e.g. with
Pablo Greco d6c4c4
SoundWire or MFD). This can also be useful to measure suspend-resume
Pablo Greco d6c4c4
latencies or child devices.
Pablo Greco d6c4c4
Pablo Greco d6c4c4
Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
Pablo Greco d6c4c4
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Pablo Greco d6c4c4
Link: https://lore.kernel.org/r/20191008164443.1358-4-pierre-louis.bossart@linux.intel.com
Pablo Greco d6c4c4
Signed-off-by: Mark Brown <broonie@kernel.org>
Pablo Greco d6c4c4
Pablo Greco d6c4c4
Signed-off-by: Jaroslav Kysela <jkysela@redhat.com>
Pablo Greco d6c4c4
(cherry picked from commit 70b0c75ae1e3d35f829b5fe7ae5692efae63ca71)
Pablo Greco d6c4c4
Bugzilla: 1772498
Pablo Greco d6c4c4
---
Pablo Greco d6c4c4
 sound/soc/sof/sof-acpi-dev.c | 12 +++++++++++-
Pablo Greco d6c4c4
 1 file changed, 11 insertions(+), 1 deletion(-)
Pablo Greco d6c4c4
Pablo Greco d6c4c4
diff --git a/sound/soc/sof/sof-acpi-dev.c b/sound/soc/sof/sof-acpi-dev.c
Pablo Greco d6c4c4
index ea7b8b895412..df318f50dd0b 100644
Pablo Greco d6c4c4
--- a/sound/soc/sof/sof-acpi-dev.c
Pablo Greco d6c4c4
+++ b/sound/soc/sof/sof-acpi-dev.c
Pablo Greco d6c4c4
@@ -29,6 +29,12 @@ static char *tplg_path;
Pablo Greco d6c4c4
 module_param(tplg_path, charp, 0444);
Pablo Greco d6c4c4
 MODULE_PARM_DESC(tplg_path, "alternate path for SOF topology.");
Pablo Greco d6c4c4
 
Pablo Greco d6c4c4
+static int sof_acpi_debug;
Pablo Greco d6c4c4
+module_param_named(sof_acpi_debug, sof_acpi_debug, int, 0444);
Pablo Greco d6c4c4
+MODULE_PARM_DESC(sof_acpi_debug, "SOF ACPI debug options (0x0 all off)");
Pablo Greco d6c4c4
+
Pablo Greco d6c4c4
+#define SOF_ACPI_DISABLE_PM_RUNTIME BIT(0)
Pablo Greco d6c4c4
+
Pablo Greco d6c4c4
 #if IS_ENABLED(CONFIG_SND_SOC_SOF_HASWELL)
Pablo Greco d6c4c4
 static const struct sof_dev_desc sof_acpi_haswell_desc = {
Pablo Greco d6c4c4
 	.machines = snd_soc_acpi_intel_haswell_machines,
Pablo Greco d6c4c4
@@ -121,6 +127,9 @@ static const struct dev_pm_ops sof_acpi_pm = {
Pablo Greco d6c4c4
 
Pablo Greco d6c4c4
 static void sof_acpi_probe_complete(struct device *dev)
Pablo Greco d6c4c4
 {
Pablo Greco d6c4c4
+	if (sof_acpi_debug & SOF_ACPI_DISABLE_PM_RUNTIME)
Pablo Greco d6c4c4
+		return;
Pablo Greco d6c4c4
+
Pablo Greco d6c4c4
 	/* allow runtime_pm */
Pablo Greco d6c4c4
 	pm_runtime_set_autosuspend_delay(dev, SND_SOF_SUSPEND_DELAY_MS);
Pablo Greco d6c4c4
 	pm_runtime_use_autosuspend(dev);
Pablo Greco d6c4c4
@@ -221,7 +230,8 @@ static int sof_acpi_probe(struct platform_device *pdev)
Pablo Greco d6c4c4
 
Pablo Greco d6c4c4
 static int sof_acpi_remove(struct platform_device *pdev)
Pablo Greco d6c4c4
 {
Pablo Greco d6c4c4
-	pm_runtime_disable(&pdev->dev);
Pablo Greco d6c4c4
+	if (!(sof_acpi_debug & SOF_ACPI_DISABLE_PM_RUNTIME))
Pablo Greco d6c4c4
+		pm_runtime_disable(&pdev->dev);
Pablo Greco d6c4c4
 
Pablo Greco d6c4c4
 	/* call sof helper for DSP hardware remove */
Pablo Greco d6c4c4
 	snd_sof_device_remove(&pdev->dev);
Pablo Greco d6c4c4
-- 
Pablo Greco d6c4c4
2.24.1
Pablo Greco d6c4c4
Pablo Greco d6c4c4
From 21db8b682a3384a910d054fd8795b6dec380d700 Mon Sep 17 00:00:00 2001
Pablo Greco d6c4c4
From: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Pablo Greco d6c4c4
Date: Tue, 8 Oct 2019 11:44:38 -0500
Pablo Greco d6c4c4
Subject: [PATCH 024/109] ASoC: SOF: pci: add debug module param
Pablo Greco d6c4c4
Pablo Greco d6c4c4
Add debug parameter for snd-sof-pci.
Pablo Greco d6c4c4
Pablo Greco d6c4c4
One of the usages for this debug parameter to disable pm_runtime,
Pablo Greco d6c4c4
which can be useful for platform bringup, or keep the parent device
Pablo Greco d6c4c4
active while enabling pm_runtime for child devices (e.g. with
Pablo Greco d6c4c4
SoundWire or MFD). This can also be useful to measure suspend-resume
Pablo Greco d6c4c4
latencies or child devices.
Pablo Greco d6c4c4
Pablo Greco d6c4c4
Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
Pablo Greco d6c4c4
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Pablo Greco d6c4c4
Link: https://lore.kernel.org/r/20191008164443.1358-5-pierre-louis.bossart@linux.intel.com
Pablo Greco d6c4c4
Signed-off-by: Mark Brown <broonie@kernel.org>
Pablo Greco d6c4c4
Pablo Greco d6c4c4
Signed-off-by: Jaroslav Kysela <jkysela@redhat.com>
Pablo Greco d6c4c4
(cherry picked from commit 8b160dc2a92c83a566b0596c79febb5933f9a6b5)
Pablo Greco d6c4c4
Bugzilla: 1772498
Pablo Greco d6c4c4
---
Pablo Greco d6c4c4
 sound/soc/sof/sof-pci-dev.c | 12 +++++++++++-
Pablo Greco d6c4c4
 1 file changed, 11 insertions(+), 1 deletion(-)
Pablo Greco d6c4c4
Pablo Greco d6c4c4
diff --git a/sound/soc/sof/sof-pci-dev.c b/sound/soc/sof/sof-pci-dev.c
Pablo Greco d6c4c4
index 3a9e0e2a150d..be5a8da504c5 100644
Pablo Greco d6c4c4
--- a/sound/soc/sof/sof-pci-dev.c
Pablo Greco d6c4c4
+++ b/sound/soc/sof/sof-pci-dev.c
Pablo Greco d6c4c4
@@ -30,6 +30,12 @@ static char *tplg_path;
Pablo Greco d6c4c4
 module_param(tplg_path, charp, 0444);
Pablo Greco d6c4c4
 MODULE_PARM_DESC(tplg_path, "alternate path for SOF topology.");
Pablo Greco d6c4c4
 
Pablo Greco d6c4c4
+static int sof_pci_debug;
Pablo Greco d6c4c4
+module_param_named(sof_pci_debug, sof_pci_debug, int, 0444);
Pablo Greco d6c4c4
+MODULE_PARM_DESC(sof_pci_debug, "SOF PCI debug options (0x0 all off)");
Pablo Greco d6c4c4
+
Pablo Greco d6c4c4
+#define SOF_PCI_DISABLE_PM_RUNTIME BIT(0)
Pablo Greco d6c4c4
+
Pablo Greco d6c4c4
 #if IS_ENABLED(CONFIG_SND_SOC_SOF_APOLLOLAKE)
Pablo Greco d6c4c4
 static const struct sof_dev_desc bxt_desc = {
Pablo Greco d6c4c4
 	.machines		= snd_soc_acpi_intel_bxt_machines,
Pablo Greco d6c4c4
@@ -250,6 +256,9 @@ static void sof_pci_probe_complete(struct device *dev)
Pablo Greco d6c4c4
 {
Pablo Greco d6c4c4
 	dev_dbg(dev, "Completing SOF PCI probe");
Pablo Greco d6c4c4
 
Pablo Greco d6c4c4
+	if (sof_pci_debug & SOF_PCI_DISABLE_PM_RUNTIME)
Pablo Greco d6c4c4
+		return;
Pablo Greco d6c4c4
+
Pablo Greco d6c4c4
 	/* allow runtime_pm */
Pablo Greco d6c4c4
 	pm_runtime_set_autosuspend_delay(dev, SND_SOF_SUSPEND_DELAY_MS);
Pablo Greco d6c4c4
 	pm_runtime_use_autosuspend(dev);
Pablo Greco d6c4c4
@@ -376,7 +385,8 @@ static void sof_pci_remove(struct pci_dev *pci)
Pablo Greco d6c4c4
 	snd_sof_device_remove(&pci->dev);
Pablo Greco d6c4c4
 
Pablo Greco d6c4c4
 	/* follow recommendation in pci-driver.c to increment usage counter */
Pablo Greco d6c4c4
-	pm_runtime_get_noresume(&pci->dev);
Pablo Greco d6c4c4
+	if (!(sof_pci_debug & SOF_PCI_DISABLE_PM_RUNTIME))
Pablo Greco d6c4c4
+		pm_runtime_get_noresume(&pci->dev);
Pablo Greco d6c4c4
 
Pablo Greco d6c4c4
 	/* release pci regions and disable device */
Pablo Greco d6c4c4
 	pci_release_regions(pci);
Pablo Greco d6c4c4
-- 
Pablo Greco d6c4c4
2.24.1
Pablo Greco d6c4c4
Pablo Greco d6c4c4
From 7b65ba0fedde4554a709dce46318543f07b8fd5a Mon Sep 17 00:00:00 2001
Pablo Greco d6c4c4
From: Jaska Uimonen <jaska.uimonen@linux.intel.com>
Pablo Greco d6c4c4
Date: Tue, 8 Oct 2019 11:44:43 -0500
Pablo Greco d6c4c4
Subject: [PATCH 025/109] ASoC: SOF: acpi led support for switch controls
Pablo Greco d6c4c4
Pablo Greco d6c4c4
Currently sof doesn't support acpi leds with mute switches. So implement
Pablo Greco d6c4c4
acpi leds following quite shamelessly existing HDA implementation by
Pablo Greco d6c4c4
Takashi Iwai.
Pablo Greco d6c4c4
Pablo Greco d6c4c4
Mute leds can be enabled in topology by adding led and direction token
Pablo Greco d6c4c4
in switch control private data.
Pablo Greco d6c4c4
Pablo Greco d6c4c4
Signed-off-by: Jaska Uimonen <jaska.uimonen@linux.intel.com>
Pablo Greco d6c4c4
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Pablo Greco d6c4c4
Link: https://lore.kernel.org/r/20191008164443.1358-10-pierre-louis.bossart@linux.intel.com
Pablo Greco d6c4c4
Signed-off-by: Mark Brown <broonie@kernel.org>
Pablo Greco d6c4c4
Pablo Greco d6c4c4
Signed-off-by: Jaroslav Kysela <jkysela@redhat.com>
Pablo Greco d6c4c4
(cherry picked from commit 5d43001ae43606dc525f55c482c545afba01bb55)
Pablo Greco d6c4c4
Bugzilla: 1772498
Pablo Greco d6c4c4
---
Pablo Greco d6c4c4
 include/uapi/sound/sof/tokens.h |  4 ++++
Pablo Greco d6c4c4
 sound/soc/sof/control.c         | 32 ++++++++++++++++++++++++++++++++
Pablo Greco d6c4c4
 sound/soc/sof/sof-priv.h        |  9 +++++++++
Pablo Greco d6c4c4
 sound/soc/sof/topology.c        | 13 +++++++++++++
Pablo Greco d6c4c4
 4 files changed, 58 insertions(+)
Pablo Greco d6c4c4
Pablo Greco d6c4c4
diff --git a/include/uapi/sound/sof/tokens.h b/include/uapi/sound/sof/tokens.h
Pablo Greco d6c4c4
index 8f996857fb24..28ef01a67765 100644
Pablo Greco d6c4c4
--- a/include/uapi/sound/sof/tokens.h
Pablo Greco d6c4c4
+++ b/include/uapi/sound/sof/tokens.h
Pablo Greco d6c4c4
@@ -114,4 +114,8 @@
Pablo Greco d6c4c4
 #define SOF_TKN_IMX_ESAI_FIRST_TOKEN		1100
Pablo Greco d6c4c4
 /* TODO: Add ESAI tokens */
Pablo Greco d6c4c4
 
Pablo Greco d6c4c4
+/* Led control for mute switches */
Pablo Greco d6c4c4
+#define SOF_TKN_MUTE_LED_USE			1300
Pablo Greco d6c4c4
+#define SOF_TKN_MUTE_LED_DIRECTION		1301
Pablo Greco d6c4c4
+
Pablo Greco d6c4c4
 #endif
Pablo Greco d6c4c4
diff --git a/sound/soc/sof/control.c b/sound/soc/sof/control.c
Pablo Greco d6c4c4
index 2b8711eda362..b73d4587c5da 100644
Pablo Greco d6c4c4
--- a/sound/soc/sof/control.c
Pablo Greco d6c4c4
+++ b/sound/soc/sof/control.c
Pablo Greco d6c4c4
@@ -11,8 +11,37 @@
Pablo Greco d6c4c4
 /* Mixer Controls */
Pablo Greco d6c4c4
 
Pablo Greco d6c4c4
 #include <linux pm_runtime.h="">
Pablo Greco d6c4c4
+#include <linux leds.h="">
Pablo Greco d6c4c4
 #include "sof-priv.h"
Pablo Greco d6c4c4
 
Pablo Greco d6c4c4
+static void update_mute_led(struct snd_sof_control *scontrol,
Pablo Greco d6c4c4
+			    struct snd_kcontrol *kcontrol,
Pablo Greco d6c4c4
+			    struct snd_ctl_elem_value *ucontrol)
Pablo Greco d6c4c4
+{
Pablo Greco d6c4c4
+	unsigned int temp = 0;
Pablo Greco d6c4c4
+	unsigned int mask;
Pablo Greco d6c4c4
+	int i;
Pablo Greco d6c4c4
+
Pablo Greco d6c4c4
+	mask = 1U << snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Pablo Greco d6c4c4
+
Pablo Greco d6c4c4
+	for (i = 0; i < scontrol->num_channels; i++) {
Pablo Greco d6c4c4
+		if (ucontrol->value.integer.value[i]) {
Pablo Greco d6c4c4
+			temp |= mask;
Pablo Greco d6c4c4
+			break;
Pablo Greco d6c4c4
+		}
Pablo Greco d6c4c4
+	}
Pablo Greco d6c4c4
+
Pablo Greco d6c4c4
+	if (temp == scontrol->led_ctl.led_value)
Pablo Greco d6c4c4
+		return;
Pablo Greco d6c4c4
+
Pablo Greco d6c4c4
+	scontrol->led_ctl.led_value = temp;
Pablo Greco d6c4c4
+
Pablo Greco d6c4c4
+	if (!scontrol->led_ctl.direction)
Pablo Greco d6c4c4
+		ledtrig_audio_set(LED_AUDIO_MUTE, temp ? LED_OFF : LED_ON);
Pablo Greco d6c4c4
+	else
Pablo Greco d6c4c4
+		ledtrig_audio_set(LED_AUDIO_MICMUTE, temp ? LED_OFF : LED_ON);
Pablo Greco d6c4c4
+}
Pablo Greco d6c4c4
+
Pablo Greco d6c4c4
 static inline u32 mixer_to_ipc(unsigned int value, u32 *volume_map, int size)
Pablo Greco d6c4c4
 {
Pablo Greco d6c4c4
 	if (value >= size)
Pablo Greco d6c4c4
@@ -118,6 +147,9 @@ int snd_sof_switch_put(struct snd_kcontrol *kcontrol,
Pablo Greco d6c4c4
 		cdata->chanv[i].value = value;
Pablo Greco d6c4c4
 	}
Pablo Greco d6c4c4
 
Pablo Greco d6c4c4
+	if (scontrol->led_ctl.use_led)
Pablo Greco d6c4c4
+		update_mute_led(scontrol, kcontrol, ucontrol);
Pablo Greco d6c4c4
+
Pablo Greco d6c4c4
 	/* notify DSP of mixer updates */
Pablo Greco d6c4c4
 	if (pm_runtime_active(sdev->dev))
Pablo Greco d6c4c4
 		snd_sof_ipc_set_get_comp_data(sdev->ipc, scontrol,
Pablo Greco d6c4c4
diff --git a/sound/soc/sof/sof-priv.h b/sound/soc/sof/sof-priv.h
Pablo Greco d6c4c4
index eb919527dd21..9729deafec08 100644
Pablo Greco d6c4c4
--- a/sound/soc/sof/sof-priv.h
Pablo Greco d6c4c4
+++ b/sound/soc/sof/sof-priv.h
Pablo Greco d6c4c4
@@ -15,6 +15,7 @@
Pablo Greco d6c4c4
 
Pablo Greco d6c4c4
 #include <sound hdaudio.h="">
Pablo Greco d6c4c4
 #include <sound soc.h="">
Pablo Greco d6c4c4
+#include <sound control.h="">
Pablo Greco d6c4c4
 
Pablo Greco d6c4c4
 #include <sound sof.h="">
Pablo Greco d6c4c4
 #include <sound sof="" stream.h=""> /* needs to be included before control.h */
Pablo Greco d6c4c4
@@ -310,6 +311,12 @@ struct snd_sof_pcm {
Pablo Greco d6c4c4
 	bool prepared[2]; /* PCM_PARAMS set successfully */
Pablo Greco d6c4c4
 };
Pablo Greco d6c4c4
 
Pablo Greco d6c4c4
+struct snd_sof_led_control {
Pablo Greco d6c4c4
+	unsigned int use_led;
Pablo Greco d6c4c4
+	unsigned int direction;
Pablo Greco d6c4c4
+	unsigned int led_value;
Pablo Greco d6c4c4
+};
Pablo Greco d6c4c4
+
Pablo Greco d6c4c4
 /* ALSA SOF Kcontrol device */
Pablo Greco d6c4c4
 struct snd_sof_control {
Pablo Greco d6c4c4
 	struct snd_sof_dev *sdev;
Pablo Greco d6c4c4
@@ -324,6 +331,8 @@ struct snd_sof_control {
Pablo Greco d6c4c4
 	u32 *volume_table; /* volume table computed from tlv data*/
Pablo Greco d6c4c4
 
Pablo Greco d6c4c4
 	struct list_head list;	/* list in sdev control list */
Pablo Greco d6c4c4
+
Pablo Greco d6c4c4
+	struct snd_sof_led_control led_ctl;
Pablo Greco d6c4c4
 };
Pablo Greco d6c4c4
 
Pablo Greco d6c4c4
 /* ASoC SOF DAPM widget */
Pablo Greco d6c4c4
diff --git a/sound/soc/sof/topology.c b/sound/soc/sof/topology.c
Pablo Greco d6c4c4
index 96c20c889fa4..a1493961b51c 100644
Pablo Greco d6c4c4
--- a/sound/soc/sof/topology.c
Pablo Greco d6c4c4
+++ b/sound/soc/sof/topology.c
Pablo Greco d6c4c4
@@ -494,6 +494,11 @@ static int sof_control_load_volume(struct snd_soc_component *scomp,
Pablo Greco d6c4c4
 	}
Pablo Greco d6c4c4
 
Pablo Greco d6c4c4
 out:
Pablo Greco d6c4c4
+	/* set up possible led control from mixer private data */
Pablo Greco d6c4c4
+	ret = sof_parse_tokens(scomp, &scontrol->led_ctl, led_tokens,
Pablo Greco d6c4c4
+			       ARRAY_SIZE(led_tokens), mc->priv.array,
Pablo Greco d6c4c4
+			       le32_to_cpu(mc->priv.size));
Pablo Greco d6c4c4
+
Pablo Greco d6c4c4
 	dev_dbg(sdev->dev, "tplg: load kcontrol index %d chans %d\n",
Pablo Greco d6c4c4
 		scontrol->comp_id, scontrol->num_channels);
Pablo Greco d6c4c4
 
Pablo Greco d6c4c4
@@ -840,6 +845,14 @@ static const struct sof_topology_token dmic_pdm_tokens[] = {
Pablo Greco d6c4c4
 static const struct sof_topology_token hda_tokens[] = {
Pablo Greco d6c4c4
 };
Pablo Greco d6c4c4
 
Pablo Greco d6c4c4
+/* Leds */
Pablo Greco d6c4c4
+static const struct sof_topology_token led_tokens[] = {
Pablo Greco d6c4c4
+	{SOF_TKN_MUTE_LED_USE, SND_SOC_TPLG_TUPLE_TYPE_WORD, get_token_u32,
Pablo Greco d6c4c4
+	 offsetof(struct snd_sof_led_control, use_led), 0},
Pablo Greco d6c4c4
+	{SOF_TKN_MUTE_LED_DIRECTION, SND_SOC_TPLG_TUPLE_TYPE_WORD,
Pablo Greco d6c4c4
+	 get_token_u32, offsetof(struct snd_sof_led_control, direction), 0},
Pablo Greco d6c4c4
+};
Pablo Greco d6c4c4
+
Pablo Greco d6c4c4
 static void sof_parse_uuid_tokens(struct snd_soc_component *scomp,
Pablo Greco d6c4c4
 				  void *object,
Pablo Greco d6c4c4
 				  const struct sof_topology_token *tokens,
Pablo Greco d6c4c4
-- 
Pablo Greco d6c4c4
2.24.1
Pablo Greco d6c4c4
Pablo Greco d6c4c4
From 0017ac5f09b9a689a6f1b2ec3f0aa2f95753a1c1 Mon Sep 17 00:00:00 2001
Pablo Greco d6c4c4
From: Daniel Baluta <daniel.baluta@nxp.com>
Pablo Greco d6c4c4
Date: Tue, 8 Oct 2019 11:44:39 -0500
Pablo Greco d6c4c4
Subject: [PATCH 026/109] ASoC: SOF: imx: Describe ESAI parameters to be sent
Pablo Greco d6c4c4
 to DSP
Pablo Greco d6c4c4
Pablo Greco d6c4c4
Introduce sof_ipc_dai_esai_params to keep information that
Pablo Greco d6c4c4
we get from topology and we send to DSP FW.
Pablo Greco d6c4c4
Pablo Greco d6c4c4
Also bump the ABI minor to reflect the changes on DSP FW.
Pablo Greco d6c4c4
Pablo Greco d6c4c4
Signed-off-by: Daniel Baluta <daniel.baluta@nxp.com>
Pablo Greco d6c4c4
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Pablo Greco d6c4c4
Link: https://lore.kernel.org/r/20191008164443.1358-6-pierre-louis.bossart@linux.intel.com
Pablo Greco d6c4c4
Signed-off-by: Mark Brown <broonie@kernel.org>
Pablo Greco d6c4c4
Pablo Greco d6c4c4
Signed-off-by: Jaroslav Kysela <jkysela@redhat.com>
Pablo Greco d6c4c4
(cherry picked from commit b4be427683cf6debda331a5d6a4af34885851d19)
Pablo Greco d6c4c4
Bugzilla: 1772498
Pablo Greco d6c4c4
---
Pablo Greco d6c4c4
 include/sound/sof/dai-imx.h     | 34 +++++++++++++++++++++++++++++++++
Pablo Greco d6c4c4
 include/sound/sof/dai.h         |  2 ++
Pablo Greco d6c4c4
 include/uapi/sound/sof/abi.h    |  2 +-
Pablo Greco d6c4c4
 include/uapi/sound/sof/tokens.h |  3 +--
Pablo Greco d6c4c4
 4 files changed, 38 insertions(+), 3 deletions(-)
Pablo Greco d6c4c4
 create mode 100644 include/sound/sof/dai-imx.h
Pablo Greco d6c4c4
Pablo Greco d6c4c4
diff --git a/include/sound/sof/dai-imx.h b/include/sound/sof/dai-imx.h
Pablo Greco d6c4c4
new file mode 100644
Pablo Greco d6c4c4
index 000000000000..e02fb0b0fae1
Pablo Greco d6c4c4
--- /dev/null
Pablo Greco d6c4c4
+++ b/include/sound/sof/dai-imx.h
Pablo Greco d6c4c4
@@ -0,0 +1,34 @@
Pablo Greco d6c4c4
+/* SPDX-License-Identifier: (GPL-2.0 OR BSD-3-Clause) */
Pablo Greco d6c4c4
+/*
Pablo Greco d6c4c4
+ * Copyright 2019 NXP
Pablo Greco d6c4c4
+ *
Pablo Greco d6c4c4
+ * Author: Daniel Baluta <daniel.baluta@nxp.com>
Pablo Greco d6c4c4
+ */
Pablo Greco d6c4c4
+
Pablo Greco d6c4c4
+#ifndef __INCLUDE_SOUND_SOF_DAI_IMX_H__
Pablo Greco d6c4c4
+#define __INCLUDE_SOUND_SOF_DAI_IMX_H__
Pablo Greco d6c4c4
+
Pablo Greco d6c4c4
+#include <sound sof="" header.h="">
Pablo Greco d6c4c4
+
Pablo Greco d6c4c4
+/* ESAI Configuration Request - SOF_IPC_DAI_ESAI_CONFIG */
Pablo Greco d6c4c4
+struct sof_ipc_dai_esai_params {
Pablo Greco d6c4c4
+	struct sof_ipc_hdr hdr;
Pablo Greco d6c4c4
+
Pablo Greco d6c4c4
+	/* MCLK */
Pablo Greco d6c4c4
+	uint16_t reserved1;
Pablo Greco d6c4c4
+	uint16_t mclk_id;
Pablo Greco d6c4c4
+	uint32_t mclk_direction;
Pablo Greco d6c4c4
+
Pablo Greco d6c4c4
+	uint32_t mclk_rate;	/* MCLK frequency in Hz */
Pablo Greco d6c4c4
+	uint32_t fsync_rate;	/* FSYNC frequency in Hz */
Pablo Greco d6c4c4
+	uint32_t bclk_rate;	/* BCLK frequency in Hz */
Pablo Greco d6c4c4
+
Pablo Greco d6c4c4
+	/* TDM */
Pablo Greco d6c4c4
+	uint32_t tdm_slots;
Pablo Greco d6c4c4
+	uint32_t rx_slots;
Pablo Greco d6c4c4
+	uint32_t tx_slots;
Pablo Greco d6c4c4
+	uint16_t tdm_slot_width;
Pablo Greco d6c4c4
+	uint16_t reserved2;	/* alignment */
Pablo Greco d6c4c4
+} __packed;
Pablo Greco d6c4c4
+
Pablo Greco d6c4c4
+#endif
Pablo Greco d6c4c4
diff --git a/include/sound/sof/dai.h b/include/sound/sof/dai.h
Pablo Greco d6c4c4
index 0f1235022146..c229565767e5 100644
Pablo Greco d6c4c4
--- a/include/sound/sof/dai.h
Pablo Greco d6c4c4
+++ b/include/sound/sof/dai.h
Pablo Greco d6c4c4
@@ -11,6 +11,7 @@
Pablo Greco d6c4c4
 
Pablo Greco d6c4c4
 #include <sound sof="" header.h="">
Pablo Greco d6c4c4
 #include <sound sof="" dai-intel.h="">
Pablo Greco d6c4c4
+#include <sound sof="" dai-imx.h="">
Pablo Greco d6c4c4
 
Pablo Greco d6c4c4
 /*
Pablo Greco d6c4c4
  * DAI Configuration.
Pablo Greco d6c4c4
@@ -73,6 +74,7 @@ struct sof_ipc_dai_config {
Pablo Greco d6c4c4
 		struct sof_ipc_dai_dmic_params dmic;
Pablo Greco d6c4c4
 		struct sof_ipc_dai_hda_params hda;
Pablo Greco d6c4c4
 		struct sof_ipc_dai_alh_params alh;
Pablo Greco d6c4c4
+		struct sof_ipc_dai_esai_params esai;
Pablo Greco d6c4c4
 	};
Pablo Greco d6c4c4
 } __packed;
Pablo Greco d6c4c4
 
Pablo Greco d6c4c4
diff --git a/include/uapi/sound/sof/abi.h b/include/uapi/sound/sof/abi.h
Pablo Greco d6c4c4
index a0fe0d4c4b66..ebfdc20ca081 100644
Pablo Greco d6c4c4
--- a/include/uapi/sound/sof/abi.h
Pablo Greco d6c4c4
+++ b/include/uapi/sound/sof/abi.h
Pablo Greco d6c4c4
@@ -26,7 +26,7 @@
Pablo Greco d6c4c4
 
Pablo Greco d6c4c4
 /* SOF ABI version major, minor and patch numbers */
Pablo Greco d6c4c4
 #define SOF_ABI_MAJOR 3
Pablo Greco d6c4c4
-#define SOF_ABI_MINOR 10
Pablo Greco d6c4c4
+#define SOF_ABI_MINOR 11
Pablo Greco d6c4c4
 #define SOF_ABI_PATCH 0
Pablo Greco d6c4c4
 
Pablo Greco d6c4c4
 /* SOF ABI version number. Format within 32bit word is MMmmmppp */
Pablo Greco d6c4c4
diff --git a/include/uapi/sound/sof/tokens.h b/include/uapi/sound/sof/tokens.h
Pablo Greco d6c4c4
index 28ef01a67765..d65406f34361 100644
Pablo Greco d6c4c4
--- a/include/uapi/sound/sof/tokens.h
Pablo Greco d6c4c4
+++ b/include/uapi/sound/sof/tokens.h
Pablo Greco d6c4c4
@@ -111,8 +111,7 @@
Pablo Greco d6c4c4
 /* TODO: Add SAI tokens */
Pablo Greco d6c4c4
 
Pablo Greco d6c4c4
 /* ESAI */
Pablo Greco d6c4c4
-#define SOF_TKN_IMX_ESAI_FIRST_TOKEN		1100
Pablo Greco d6c4c4
-/* TODO: Add ESAI tokens */
Pablo Greco d6c4c4
+#define SOF_TKN_IMX_ESAI_MCLK_ID		1100
Pablo Greco d6c4c4
 
Pablo Greco d6c4c4
 /* Led control for mute switches */
Pablo Greco d6c4c4
 #define SOF_TKN_MUTE_LED_USE			1300
Pablo Greco d6c4c4
-- 
Pablo Greco d6c4c4
2.24.1
Pablo Greco d6c4c4
Pablo Greco d6c4c4
From 8a031dfe901dd997df316c2138153edff7af5731 Mon Sep 17 00:00:00 2001
Pablo Greco d6c4c4
From: Daniel Baluta <daniel.baluta@nxp.com>
Pablo Greco d6c4c4
Date: Tue, 8 Oct 2019 11:44:40 -0500
Pablo Greco d6c4c4
Subject: [PATCH 027/109] ASoC: SOF: imx: Read ESAI parameters and send them to
Pablo Greco d6c4c4
 DSP
Pablo Greco d6c4c4
Pablo Greco d6c4c4
ESAI parameters are read for topology file, packed into
Pablo Greco d6c4c4
sof_ipc_dai_esai_parms struct and then sent to DSP.
Pablo Greco d6c4c4
Pablo Greco d6c4c4
Signed-off-by: Daniel Baluta <daniel.baluta@nxp.com>
Pablo Greco d6c4c4
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Pablo Greco d6c4c4
Link: https://lore.kernel.org/r/20191008164443.1358-7-pierre-louis.bossart@linux.intel.com
Pablo Greco d6c4c4
Signed-off-by: Mark Brown <broonie@kernel.org>
Pablo Greco d6c4c4
Pablo Greco d6c4c4
Signed-off-by: Jaroslav Kysela <jkysela@redhat.com>
Pablo Greco d6c4c4
(cherry picked from commit a4eff5f86c9c5e7d07d880bd86ce8faad19d7063)
Pablo Greco d6c4c4
Bugzilla: 1772498
Pablo Greco d6c4c4
---
Pablo Greco d6c4c4
 sound/soc/sof/pcm.c      |  8 +++++
Pablo Greco d6c4c4
 sound/soc/sof/topology.c | 69 ++++++++++++++++++++++++++++++++++++++--
Pablo Greco d6c4c4
 2 files changed, 75 insertions(+), 2 deletions(-)
Pablo Greco d6c4c4
Pablo Greco d6c4c4
diff --git a/sound/soc/sof/pcm.c b/sound/soc/sof/pcm.c
Pablo Greco d6c4c4
index 2b876d497447..b0f4217433e5 100644
Pablo Greco d6c4c4
--- a/sound/soc/sof/pcm.c
Pablo Greco d6c4c4
+++ b/sound/soc/sof/pcm.c
Pablo Greco d6c4c4
@@ -691,6 +691,14 @@ static int sof_pcm_dai_link_fixup(struct snd_soc_pcm_runtime *rtd,
Pablo Greco d6c4c4
 	case SOF_DAI_INTEL_ALH:
Pablo Greco d6c4c4
 		/* do nothing for ALH dai_link */
Pablo Greco d6c4c4
 		break;
Pablo Greco d6c4c4
+	case SOF_DAI_IMX_ESAI:
Pablo Greco d6c4c4
+		channels->min = dai->dai_config->esai.tdm_slots;
Pablo Greco d6c4c4
+		channels->max = dai->dai_config->esai.tdm_slots;
Pablo Greco d6c4c4
+
Pablo Greco d6c4c4
+		dev_dbg(sdev->dev,
Pablo Greco d6c4c4
+			"channels_min: %d channels_max: %d\n",
Pablo Greco d6c4c4
+			channels->min, channels->max);
Pablo Greco d6c4c4
+		break;
Pablo Greco d6c4c4
 	default:
Pablo Greco d6c4c4
 		dev_err(sdev->dev, "error: invalid DAI type %d\n",
Pablo Greco d6c4c4
 			dai->dai_config->type);
Pablo Greco d6c4c4
diff --git a/sound/soc/sof/topology.c b/sound/soc/sof/topology.c
Pablo Greco d6c4c4
index a1493961b51c..b2cf450f763f 100644
Pablo Greco d6c4c4
--- a/sound/soc/sof/topology.c
Pablo Greco d6c4c4
+++ b/sound/soc/sof/topology.c
Pablo Greco d6c4c4
@@ -804,6 +804,13 @@ static const struct sof_topology_token dmic_tokens[] = {
Pablo Greco d6c4c4
 
Pablo Greco d6c4c4
 };
Pablo Greco d6c4c4
 
Pablo Greco d6c4c4
+/* ESAI */
Pablo Greco d6c4c4
+static const struct sof_topology_token esai_tokens[] = {
Pablo Greco d6c4c4
+	{SOF_TKN_IMX_ESAI_MCLK_ID,
Pablo Greco d6c4c4
+		SND_SOC_TPLG_TUPLE_TYPE_SHORT, get_token_u16,
Pablo Greco d6c4c4
+		offsetof(struct sof_ipc_dai_esai_params, mclk_id), 0},
Pablo Greco d6c4c4
+};
Pablo Greco d6c4c4
+
Pablo Greco d6c4c4
 /*
Pablo Greco d6c4c4
  * DMIC PDM Tokens
Pablo Greco d6c4c4
  * SOF_TKN_INTEL_DMIC_PDM_CTRL_ID should be the first token
Pablo Greco d6c4c4
@@ -2550,8 +2557,66 @@ static int sof_link_esai_load(struct snd_soc_component *scomp, int index,
Pablo Greco d6c4c4
 			      struct snd_soc_tplg_hw_config *hw_config,
Pablo Greco d6c4c4
 			      struct sof_ipc_dai_config *config)
Pablo Greco d6c4c4
 {
Pablo Greco d6c4c4
-	/*TODO: Add implementation */
Pablo Greco d6c4c4
-	return 0;
Pablo Greco d6c4c4
+	struct snd_sof_dev *sdev = snd_soc_component_get_drvdata(scomp);
Pablo Greco d6c4c4
+	struct snd_soc_tplg_private *private = &cfg->priv;
Pablo Greco d6c4c4
+	struct sof_ipc_reply reply;
Pablo Greco d6c4c4
+	u32 size = sizeof(*config);
Pablo Greco d6c4c4
+	int ret;
Pablo Greco d6c4c4
+
Pablo Greco d6c4c4
+	/* handle master/slave and inverted clocks */
Pablo Greco d6c4c4
+	sof_dai_set_format(hw_config, config);
Pablo Greco d6c4c4
+
Pablo Greco d6c4c4
+	/* init IPC */
Pablo Greco d6c4c4
+	memset(&config->esai, 0, sizeof(struct sof_ipc_dai_esai_params));
Pablo Greco d6c4c4
+	config->hdr.size = size;
Pablo Greco d6c4c4
+
Pablo Greco d6c4c4
+	ret = sof_parse_tokens(scomp, &config->esai, esai_tokens,
Pablo Greco d6c4c4
+			       ARRAY_SIZE(esai_tokens), private->array,
Pablo Greco d6c4c4
+			       le32_to_cpu(private->size));
Pablo Greco d6c4c4
+	if (ret != 0) {
Pablo Greco d6c4c4
+		dev_err(sdev->dev, "error: parse esai tokens failed %d\n",
Pablo Greco d6c4c4
+			le32_to_cpu(private->size));
Pablo Greco d6c4c4
+		return ret;
Pablo Greco d6c4c4
+	}
Pablo Greco d6c4c4
+
Pablo Greco d6c4c4
+	config->esai.mclk_rate = le32_to_cpu(hw_config->mclk_rate);
Pablo Greco d6c4c4
+	config->esai.bclk_rate = le32_to_cpu(hw_config->bclk_rate);
Pablo Greco d6c4c4
+	config->esai.fsync_rate = le32_to_cpu(hw_config->fsync_rate);
Pablo Greco d6c4c4
+	config->esai.mclk_direction = hw_config->mclk_direction;
Pablo Greco d6c4c4
+	config->esai.tdm_slots = le32_to_cpu(hw_config->tdm_slots);
Pablo Greco d6c4c4
+	config->esai.tdm_slot_width = le32_to_cpu(hw_config->tdm_slot_width);
Pablo Greco d6c4c4
+	config->esai.rx_slots = le32_to_cpu(hw_config->rx_slots);
Pablo Greco d6c4c4
+	config->esai.tx_slots = le32_to_cpu(hw_config->tx_slots);
Pablo Greco d6c4c4
+
Pablo Greco d6c4c4
+	dev_info(sdev->dev,
Pablo Greco d6c4c4
+		 "tplg: config ESAI%d fmt 0x%x mclk %d width %d slots %d mclk id %d\n",
Pablo Greco d6c4c4
+		config->dai_index, config->format,
Pablo Greco d6c4c4
+		config->esai.mclk_rate, config->esai.tdm_slot_width,
Pablo Greco d6c4c4
+		config->esai.tdm_slots, config->esai.mclk_id);
Pablo Greco d6c4c4
+
Pablo Greco d6c4c4
+	if (config->esai.tdm_slots < 1 || config->esai.tdm_slots > 8) {
Pablo Greco d6c4c4
+		dev_err(sdev->dev, "error: invalid channel count for ESAI%d\n",
Pablo Greco d6c4c4
+			config->dai_index);
Pablo Greco d6c4c4
+		return -EINVAL;
Pablo Greco d6c4c4
+	}
Pablo Greco d6c4c4
+
Pablo Greco d6c4c4
+	/* send message to DSP */
Pablo Greco d6c4c4
+	ret = sof_ipc_tx_message(sdev->ipc,
Pablo Greco d6c4c4
+				 config->hdr.cmd, config, size, &reply,
Pablo Greco d6c4c4
+				 sizeof(reply));
Pablo Greco d6c4c4
+	if (ret < 0) {
Pablo Greco d6c4c4
+		dev_err(sdev->dev, "error: failed to set DAI config for ESAI%d\n",
Pablo Greco d6c4c4
+			config->dai_index);
Pablo Greco d6c4c4
+		return ret;
Pablo Greco d6c4c4
+	}
Pablo Greco d6c4c4
+
Pablo Greco d6c4c4
+	/* set config for all DAI's with name matching the link name */
Pablo Greco d6c4c4
+	ret = sof_set_dai_config(sdev, size, link, config);
Pablo Greco d6c4c4
+	if (ret < 0)
Pablo Greco d6c4c4
+		dev_err(sdev->dev, "error: failed to save DAI config for ESAI%d\n",
Pablo Greco d6c4c4
+			config->dai_index);
Pablo Greco d6c4c4
+
Pablo Greco d6c4c4
+	return ret;
Pablo Greco d6c4c4
 }
Pablo Greco d6c4c4
 
Pablo Greco d6c4c4
 static int sof_link_dmic_load(struct snd_soc_component *scomp, int index,
Pablo Greco d6c4c4
-- 
Pablo Greco d6c4c4
2.24.1
Pablo Greco d6c4c4
Pablo Greco d6c4c4
From 752cbeda2b3ac929a9b0891fa3a8fdd9a8bcc5d5 Mon Sep 17 00:00:00 2001
Pablo Greco d6c4c4
From: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Pablo Greco d6c4c4
Date: Fri, 11 Oct 2019 11:43:09 -0500
Pablo Greco d6c4c4
Subject: [PATCH 028/109] ASoC: SOF: Intel: byt: fix operator precedence
Pablo Greco d6c4c4
 warnings
Pablo Greco d6c4c4
Pablo Greco d6c4c4
Address cppcheck warnings
Pablo Greco d6c4c4
Pablo Greco d6c4c4
sound/soc/sof/intel/byt.c:163:26: style: Clarify calculation
Pablo Greco d6c4c4
precedence for '&' and '?'. [clarifyCalculation]
Pablo Greco d6c4c4
  panic & SHIM_IPCX_BUSY ? "yes" : "no",
Pablo Greco d6c4c4
                         ^
Pablo Greco d6c4c4
Pablo Greco d6c4c4
sound/soc/sof/intel/byt.c:164:26: style: Clarify calculation
Pablo Greco d6c4c4
precedence for '&' and '?'. [clarifyCalculation]
Pablo Greco d6c4c4
  panic & SHIM_IPCX_DONE ? "yes" : "no", panic);
Pablo Greco d6c4c4
                         ^
Pablo Greco d6c4c4
Pablo Greco d6c4c4
sound/soc/sof/intel/byt.c:167:25: style: Clarify calculation
Pablo Greco d6c4c4
precedence for '&' and '?'. [clarifyCalculation]
Pablo Greco d6c4c4
  imrx & SHIM_IMRX_BUSY ? "yes" : "no",
Pablo Greco d6c4c4
                        ^
Pablo Greco d6c4c4
Pablo Greco d6c4c4
sound/soc/sof/intel/byt.c:168:25: style: Clarify calculation
Pablo Greco d6c4c4
precedence for '&' and '?'. [clarifyCalculation]
Pablo Greco d6c4c4
  imrx & SHIM_IMRX_DONE ? "yes" : "no", imrx);
Pablo Greco d6c4c4
                        ^
Pablo Greco d6c4c4
Pablo Greco d6c4c4
sound/soc/sof/intel/byt.c:171:27: style: Clarify calculation
Pablo Greco d6c4c4
precedence for '&' and '?'. [clarifyCalculation]
Pablo Greco d6c4c4
  status & SHIM_IPCD_BUSY ? "yes" : "no",
Pablo Greco d6c4c4
                          ^
Pablo Greco d6c4c4
Pablo Greco d6c4c4
sound/soc/sof/intel/byt.c:172:27: style: Clarify calculation
Pablo Greco d6c4c4
precedence for '&' and '?'. [clarifyCalculation]
Pablo Greco d6c4c4
  status & SHIM_IPCD_DONE ? "yes" : "no", status);
Pablo Greco d6c4c4
                          ^
Pablo Greco d6c4c4
Pablo Greco d6c4c4
sound/soc/sof/intel/byt.c:175:25: style: Clarify calculation
Pablo Greco d6c4c4
precedence for '&' and '?'. [clarifyCalculation]
Pablo Greco d6c4c4
  imrd & SHIM_IMRD_BUSY ? "yes" : "no",
Pablo Greco d6c4c4
                        ^
Pablo Greco d6c4c4
Pablo Greco d6c4c4
sound/soc/sof/intel/byt.c:176:25: style: Clarify calculation
Pablo Greco d6c4c4
precedence for '&' and '?'. [clarifyCalculation]
Pablo Greco d6c4c4
  imrd & SHIM_IMRD_DONE ? "yes" : "no", imrd);
Pablo Greco d6c4c4
                        ^
Pablo Greco d6c4c4
Pablo Greco d6c4c4
Fixes: 3a9e204d4e369 ("ASoC: SOF: Intel: Add context data to any IPC timeout.")
Pablo Greco d6c4c4
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Pablo Greco d6c4c4
Link: https://lore.kernel.org/r/20191011164312.7988-2-pierre-louis.bossart@linux.intel.com
Pablo Greco d6c4c4
Signed-off-by: Mark Brown <broonie@kernel.org>
Pablo Greco d6c4c4
Pablo Greco d6c4c4
Signed-off-by: Jaroslav Kysela <jkysela@redhat.com>
Pablo Greco d6c4c4
(cherry picked from commit f9f618e7128e834db3f54d290a926c4a71104e02)
Pablo Greco d6c4c4
Bugzilla: 1772498
Pablo Greco d6c4c4
---
Pablo Greco d6c4c4
 sound/soc/sof/intel/byt.c | 16 ++++++++--------
Pablo Greco d6c4c4
 1 file changed, 8 insertions(+), 8 deletions(-)
Pablo Greco d6c4c4
Pablo Greco d6c4c4
diff --git a/sound/soc/sof/intel/byt.c b/sound/soc/sof/intel/byt.c
Pablo Greco d6c4c4
index 3138d9a2c621..84d6069b5075 100644
Pablo Greco d6c4c4
--- a/sound/soc/sof/intel/byt.c
Pablo Greco d6c4c4
+++ b/sound/soc/sof/intel/byt.c
Pablo Greco d6c4c4
@@ -161,20 +161,20 @@ static void byt_dump(struct snd_sof_dev *sdev, u32 flags)
Pablo Greco d6c4c4
 	imrd = snd_sof_dsp_read(sdev, BYT_DSP_BAR, SHIM_IMRD);
Pablo Greco d6c4c4
 	dev_err(sdev->dev,
Pablo Greco d6c4c4
 		"error: ipc host -> DSP: pending %s complete %s raw 0x%8.8x\n",
Pablo Greco d6c4c4
-		panic & SHIM_IPCX_BUSY ? "yes" : "no",
Pablo Greco d6c4c4
-		panic & SHIM_IPCX_DONE ? "yes" : "no", panic);
Pablo Greco d6c4c4
+		(panic & SHIM_IPCX_BUSY) ? "yes" : "no",
Pablo Greco d6c4c4
+		(panic & SHIM_IPCX_DONE) ? "yes" : "no", panic);
Pablo Greco d6c4c4
 	dev_err(sdev->dev,
Pablo Greco d6c4c4
 		"error: mask host: pending %s complete %s raw 0x%8.8x\n",
Pablo Greco d6c4c4
-		imrx & SHIM_IMRX_BUSY ? "yes" : "no",
Pablo Greco d6c4c4
-		imrx & SHIM_IMRX_DONE ? "yes" : "no", imrx);
Pablo Greco d6c4c4
+		(imrx & SHIM_IMRX_BUSY) ? "yes" : "no",
Pablo Greco d6c4c4
+		(imrx & SHIM_IMRX_DONE) ? "yes" : "no", imrx);
Pablo Greco d6c4c4
 	dev_err(sdev->dev,
Pablo Greco d6c4c4
 		"error: ipc DSP -> host: pending %s complete %s raw 0x%8.8x\n",
Pablo Greco d6c4c4
-		status & SHIM_IPCD_BUSY ? "yes" : "no",
Pablo Greco d6c4c4
-		status & SHIM_IPCD_DONE ? "yes" : "no", status);
Pablo Greco d6c4c4
+		(status & SHIM_IPCD_BUSY) ? "yes" : "no",
Pablo Greco d6c4c4
+		(status & SHIM_IPCD_DONE) ? "yes" : "no", status);
Pablo Greco d6c4c4
 	dev_err(sdev->dev,
Pablo Greco d6c4c4
 		"error: mask DSP: pending %s complete %s raw 0x%8.8x\n",
Pablo Greco d6c4c4
-		imrd & SHIM_IMRD_BUSY ? "yes" : "no",
Pablo Greco d6c4c4
-		imrd & SHIM_IMRD_DONE ? "yes" : "no", imrd);
Pablo Greco d6c4c4
+		(imrd & SHIM_IMRD_BUSY) ? "yes" : "no",
Pablo Greco d6c4c4
+		(imrd & SHIM_IMRD_DONE) ? "yes" : "no", imrd);
Pablo Greco d6c4c4
 
Pablo Greco d6c4c4
 }
Pablo Greco d6c4c4
 
Pablo Greco d6c4c4
-- 
Pablo Greco d6c4c4
2.24.1
Pablo Greco d6c4c4
Pablo Greco d6c4c4
From a825e9f8825891dfd84867f2916b0b69cda0de6a Mon Sep 17 00:00:00 2001
Pablo Greco d6c4c4
From: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Pablo Greco d6c4c4
Date: Fri, 11 Oct 2019 11:43:10 -0500
Pablo Greco d6c4c4
Subject: [PATCH 029/109] ASoC: SOF: Intel: bdw: fix operator precedence
Pablo Greco d6c4c4
 warnings
Pablo Greco d6c4c4
Pablo Greco d6c4c4
Address cppcheck warnings
Pablo Greco d6c4c4
Pablo Greco d6c4c4
sound/soc/sof/intel/bdw.c:265:26: style: Clarify calculation precedence
Pablo Greco d6c4c4
for '&' and '?'. [clarifyCalculation]
Pablo Greco d6c4c4
  panic & SHIM_IPCX_BUSY ? "yes" : "no",
Pablo Greco d6c4c4
                         ^
Pablo Greco d6c4c4
Pablo Greco d6c4c4
sound/soc/sof/intel/bdw.c:266:26: style: Clarify calculation
Pablo Greco d6c4c4
precedence for '&' and '?'. [clarifyCalculation]
Pablo Greco d6c4c4
  panic & SHIM_IPCX_DONE ? "yes" : "no", panic);
Pablo Greco d6c4c4
                         ^
Pablo Greco d6c4c4
Pablo Greco d6c4c4
sound/soc/sof/intel/bdw.c:269:25: style: Clarify calculation
Pablo Greco d6c4c4
precedence for '&' and '?'. [clarifyCalculation]
Pablo Greco d6c4c4
  imrx & SHIM_IMRX_BUSY ? "yes" : "no",
Pablo Greco d6c4c4
                        ^
Pablo Greco d6c4c4
Pablo Greco d6c4c4
sound/soc/sof/intel/bdw.c:270:25: style: Clarify calculation
Pablo Greco d6c4c4
precedence for '&' and '?'. [clarifyCalculation]
Pablo Greco d6c4c4
  imrx & SHIM_IMRX_DONE ? "yes" : "no", imrx);
Pablo Greco d6c4c4
                        ^
Pablo Greco d6c4c4
Pablo Greco d6c4c4
sound/soc/sof/intel/bdw.c:273:27: style: Clarify calculation
Pablo Greco d6c4c4
precedence for '&' and '?'. [clarifyCalculation]
Pablo Greco d6c4c4
  status & SHIM_IPCD_BUSY ? "yes" : "no",
Pablo Greco d6c4c4
                          ^
Pablo Greco d6c4c4
Pablo Greco d6c4c4
sound/soc/sof/intel/bdw.c:274:27: style: Clarify calculation
Pablo Greco d6c4c4
precedence for '&' and '?'. [clarifyCalculation]
Pablo Greco d6c4c4
  status & SHIM_IPCD_DONE ? "yes" : "no", status);
Pablo Greco d6c4c4
                          ^
Pablo Greco d6c4c4
Pablo Greco d6c4c4
sound/soc/sof/intel/bdw.c:277:25: style: Clarify calculation
Pablo Greco d6c4c4
precedence for '&' and '?'. [clarifyCalculation]
Pablo Greco d6c4c4
  imrd & SHIM_IMRD_BUSY ? "yes" : "no",
Pablo Greco d6c4c4
                        ^
Pablo Greco d6c4c4
Pablo Greco d6c4c4
sound/soc/sof/intel/bdw.c:278:25: style: Clarify calculation
Pablo Greco d6c4c4
precedence for '&' and '?'. [clarifyCalculation]
Pablo Greco d6c4c4
  imrd & SHIM_IMRD_DONE ? "yes" : "no", imrd);
Pablo Greco d6c4c4
                        ^
Pablo Greco d6c4c4
Pablo Greco d6c4c4
Fixes: 3a9e204d4e369 ("ASoC: SOF: Intel: Add context data to any IPC timeout.")
Pablo Greco d6c4c4
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Pablo Greco d6c4c4
Link: https://lore.kernel.org/r/20191011164312.7988-3-pierre-louis.bossart@linux.intel.com
Pablo Greco d6c4c4
Signed-off-by: Mark Brown <broonie@kernel.org>
Pablo Greco d6c4c4
Pablo Greco d6c4c4
Signed-off-by: Jaroslav Kysela <jkysela@redhat.com>
Pablo Greco d6c4c4
(cherry picked from commit 7ad03a2c848f6fb0a8dea656c9c161929696878e)
Pablo Greco d6c4c4
Bugzilla: 1772498
Pablo Greco d6c4c4
---
Pablo Greco d6c4c4
 sound/soc/sof/intel/bdw.c | 16 ++++++++--------
Pablo Greco d6c4c4
 1 file changed, 8 insertions(+), 8 deletions(-)
Pablo Greco d6c4c4
Pablo Greco d6c4c4
diff --git a/sound/soc/sof/intel/bdw.c b/sound/soc/sof/intel/bdw.c
Pablo Greco d6c4c4
index f395d0638876..bf961a8798a7 100644
Pablo Greco d6c4c4
--- a/sound/soc/sof/intel/bdw.c
Pablo Greco d6c4c4
+++ b/sound/soc/sof/intel/bdw.c
Pablo Greco d6c4c4
@@ -262,20 +262,20 @@ static void bdw_dump(struct snd_sof_dev *sdev, u32 flags)
Pablo Greco d6c4c4
 	imrd = snd_sof_dsp_read(sdev, BDW_DSP_BAR, SHIM_IMRD);
Pablo Greco d6c4c4
 	dev_err(sdev->dev,
Pablo Greco d6c4c4
 		"error: ipc host -> DSP: pending %s complete %s raw 0x%8.8x\n",
Pablo Greco d6c4c4
-		panic & SHIM_IPCX_BUSY ? "yes" : "no",
Pablo Greco d6c4c4
-		panic & SHIM_IPCX_DONE ? "yes" : "no", panic);
Pablo Greco d6c4c4
+		(panic & SHIM_IPCX_BUSY) ? "yes" : "no",
Pablo Greco d6c4c4
+		(panic & SHIM_IPCX_DONE) ? "yes" : "no", panic);
Pablo Greco d6c4c4
 	dev_err(sdev->dev,
Pablo Greco d6c4c4
 		"error: mask host: pending %s complete %s raw 0x%8.8x\n",
Pablo Greco d6c4c4
-		imrx & SHIM_IMRX_BUSY ? "yes" : "no",
Pablo Greco d6c4c4
-		imrx & SHIM_IMRX_DONE ? "yes" : "no", imrx);
Pablo Greco d6c4c4
+		(imrx & SHIM_IMRX_BUSY) ? "yes" : "no",
Pablo Greco d6c4c4
+		(imrx & SHIM_IMRX_DONE) ? "yes" : "no", imrx);
Pablo Greco d6c4c4
 	dev_err(sdev->dev,
Pablo Greco d6c4c4
 		"error: ipc DSP -> host: pending %s complete %s raw 0x%8.8x\n",
Pablo Greco d6c4c4
-		status & SHIM_IPCD_BUSY ? "yes" : "no",
Pablo Greco d6c4c4
-		status & SHIM_IPCD_DONE ? "yes" : "no", status);
Pablo Greco d6c4c4
+		(status & SHIM_IPCD_BUSY) ? "yes" : "no",
Pablo Greco d6c4c4
+		(status & SHIM_IPCD_DONE) ? "yes" : "no", status);
Pablo Greco d6c4c4
 	dev_err(sdev->dev,
Pablo Greco d6c4c4
 		"error: mask DSP: pending %s complete %s raw 0x%8.8x\n",
Pablo Greco d6c4c4
-		imrd & SHIM_IMRD_BUSY ? "yes" : "no",
Pablo Greco d6c4c4
-		imrd & SHIM_IMRD_DONE ? "yes" : "no", imrd);
Pablo Greco d6c4c4
+		(imrd & SHIM_IMRD_BUSY) ? "yes" : "no",
Pablo Greco d6c4c4
+		(imrd & SHIM_IMRD_DONE) ? "yes" : "no", imrd);
Pablo Greco d6c4c4
 }
Pablo Greco d6c4c4
 
Pablo Greco d6c4c4
 /*
Pablo Greco d6c4c4
-- 
Pablo Greco d6c4c4
2.24.1
Pablo Greco d6c4c4
Pablo Greco d6c4c4
From b130f3834c22757c7d8da463e77bc80c31035cd8 Mon Sep 17 00:00:00 2001
Pablo Greco d6c4c4
From: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Pablo Greco d6c4c4
Date: Fri, 11 Oct 2019 11:43:11 -0500
Pablo Greco d6c4c4
Subject: [PATCH 030/109] ASoC: SOF: topology: remove always-true redundant
Pablo Greco d6c4c4
 test
Pablo Greco d6c4c4
Pablo Greco d6c4c4
Address cppcheck warning:
Pablo Greco d6c4c4
Pablo Greco d6c4c4
sound/soc/sof/topology.c:2322:6: style: Condition 'pcm' is always true
Pablo Greco d6c4c4
[knownConditionTrueFalse]
Pablo Greco d6c4c4
 if (pcm) {
Pablo Greco d6c4c4
     ^
Pablo Greco d6c4c4
Pablo Greco d6c4c4
sound/soc/sof/topology.c:2311:6: note: Assuming that condition '!pcm'
Pablo Greco d6c4c4
is not redundant
Pablo Greco d6c4c4
 if (!pcm)
Pablo Greco d6c4c4
     ^
Pablo Greco d6c4c4
Pablo Greco d6c4c4
sound/soc/sof/topology.c:2322:6: note: Condition 'pcm' is always true
Pablo Greco d6c4c4
 if (pcm) {
Pablo Greco d6c4c4
     ^
Pablo Greco d6c4c4
Pablo Greco d6c4c4
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Pablo Greco d6c4c4
Link: https://lore.kernel.org/r/20191011164312.7988-4-pierre-louis.bossart@linux.intel.com
Pablo Greco d6c4c4
Signed-off-by: Mark Brown <broonie@kernel.org>
Pablo Greco d6c4c4
Pablo Greco d6c4c4
Signed-off-by: Jaroslav Kysela <jkysela@redhat.com>
Pablo Greco d6c4c4
(cherry picked from commit 494e8f65da24d550a5e7c6a85b9433ffb181705c)
Pablo Greco d6c4c4
Bugzilla: 1772498
Pablo Greco d6c4c4
---
Pablo Greco d6c4c4
 sound/soc/sof/topology.c | 7 +++----
Pablo Greco d6c4c4
 1 file changed, 3 insertions(+), 4 deletions(-)
Pablo Greco d6c4c4
Pablo Greco d6c4c4
diff --git a/sound/soc/sof/topology.c b/sound/soc/sof/topology.c
Pablo Greco d6c4c4
index b2cf450f763f..4fa38719c703 100644
Pablo Greco d6c4c4
--- a/sound/soc/sof/topology.c
Pablo Greco d6c4c4
+++ b/sound/soc/sof/topology.c
Pablo Greco d6c4c4
@@ -2309,10 +2309,9 @@ static int sof_dai_load(struct snd_soc_component *scomp, int index,
Pablo Greco d6c4c4
 	spcm->stream[SNDRV_PCM_STREAM_PLAYBACK].comp_id = COMP_ID_UNASSIGNED;
Pablo Greco d6c4c4
 	spcm->stream[SNDRV_PCM_STREAM_CAPTURE].comp_id = COMP_ID_UNASSIGNED;
Pablo Greco d6c4c4
 
Pablo Greco d6c4c4
-	if (pcm) {
Pablo Greco d6c4c4
-		spcm->pcm = *pcm;
Pablo Greco d6c4c4
-		dev_dbg(sdev->dev, "tplg: load pcm %s\n", pcm->dai_name);
Pablo Greco d6c4c4
-	}
Pablo Greco d6c4c4
+	spcm->pcm = *pcm;
Pablo Greco d6c4c4
+	dev_dbg(sdev->dev, "tplg: load pcm %s\n", pcm->dai_name);
Pablo Greco d6c4c4
+
Pablo Greco d6c4c4
 	dai_drv->dobj.private = spcm;
Pablo Greco d6c4c4
 	list_add(&spcm->list, &sdev->pcm_list);
Pablo Greco d6c4c4
 
Pablo Greco d6c4c4
-- 
Pablo Greco d6c4c4
2.24.1
Pablo Greco d6c4c4
Pablo Greco d6c4c4
From b23994307d4c6bea1226d7d84c78de8f5a5f9afd Mon Sep 17 00:00:00 2001
Pablo Greco d6c4c4
From: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Pablo Greco d6c4c4
Date: Fri, 11 Oct 2019 11:43:12 -0500
Pablo Greco d6c4c4
Subject: [PATCH 031/109] ASoC: SOF: topology: check errors when parsing LED
Pablo Greco d6c4c4
 tokens
Pablo Greco d6c4c4
Pablo Greco d6c4c4
sof_parse_tokens() returns a value that is checked on every call
Pablo Greco d6c4c4
except for LED tokens, fix with explicit test.
Pablo Greco d6c4c4
Pablo Greco d6c4c4
Detected with cppcheck warning:
Pablo Greco d6c4c4
Pablo Greco d6c4c4
sound/soc/sof/topology.c:973:6: style: Variable 'ret' is assigned a
Pablo Greco d6c4c4
value that is never used. [unreadVariable]
Pablo Greco d6c4c4
 ret = sof_parse_tokens(scomp, &scontrol->led_ctl, led_tokens,
Pablo Greco d6c4c4
     ^
Pablo Greco d6c4c4
Pablo Greco d6c4c4
Fixes: 5d43001ae4360 ("ASoC: SOF: acpi led support for switch controls")
Pablo Greco d6c4c4
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Pablo Greco d6c4c4
Link: https://lore.kernel.org/r/20191011164312.7988-5-pierre-louis.bossart@linux.intel.com
Pablo Greco d6c4c4
Signed-off-by: Mark Brown <broonie@kernel.org>
Pablo Greco d6c4c4
Pablo Greco d6c4c4
Signed-off-by: Jaroslav Kysela <jkysela@redhat.com>
Pablo Greco d6c4c4
(cherry picked from commit 8a3ab38c36926ddbda3d2a3086c0a741fa175cff)
Pablo Greco d6c4c4
Bugzilla: 1772498
Pablo Greco d6c4c4
---
Pablo Greco d6c4c4
 sound/soc/sof/topology.c | 5 +++++
Pablo Greco d6c4c4
 1 file changed, 5 insertions(+)
Pablo Greco d6c4c4
Pablo Greco d6c4c4
diff --git a/sound/soc/sof/topology.c b/sound/soc/sof/topology.c
Pablo Greco d6c4c4
index 4fa38719c703..6a4b59a0d8e6 100644
Pablo Greco d6c4c4
--- a/sound/soc/sof/topology.c
Pablo Greco d6c4c4
+++ b/sound/soc/sof/topology.c
Pablo Greco d6c4c4
@@ -498,6 +498,11 @@ static int sof_control_load_volume(struct snd_soc_component *scomp,
Pablo Greco d6c4c4
 	ret = sof_parse_tokens(scomp, &scontrol->led_ctl, led_tokens,
Pablo Greco d6c4c4
 			       ARRAY_SIZE(led_tokens), mc->priv.array,
Pablo Greco d6c4c4
 			       le32_to_cpu(mc->priv.size));
Pablo Greco d6c4c4
+	if (ret != 0) {
Pablo Greco d6c4c4
+		dev_err(sdev->dev, "error: parse led tokens failed %d\n",
Pablo Greco d6c4c4
+			le32_to_cpu(mc->priv.size));
Pablo Greco d6c4c4
+		return ret;
Pablo Greco d6c4c4
+	}
Pablo Greco d6c4c4
 
Pablo Greco d6c4c4
 	dev_dbg(sdev->dev, "tplg: load kcontrol index %d chans %d\n",
Pablo Greco d6c4c4
 		scontrol->comp_id, scontrol->num_channels);
Pablo Greco d6c4c4
-- 
Pablo Greco d6c4c4
2.24.1
Pablo Greco d6c4c4
Pablo Greco d6c4c4
From 0fce4bacf9c669391c8e149a1d50feeea8e7b45a Mon Sep 17 00:00:00 2001
Pablo Greco d6c4c4
From: YueHaibing <yuehaibing@huawei.com>
Pablo Greco d6c4c4
Date: Mon, 14 Oct 2019 17:13:08 +0800
Pablo Greco d6c4c4
Subject: [PATCH 032/109] ASoC: SOF: Fix randbuild error
Pablo Greco d6c4c4
Pablo Greco d6c4c4
When LEDS_TRIGGER_AUDIO is m and SND_SOC_SOF is y,
Pablo Greco d6c4c4
Pablo Greco d6c4c4
sound/soc/sof/control.o: In function `snd_sof_switch_put':
Pablo Greco d6c4c4
control.c:(.text+0x587): undefined reference to `ledtrig_audio_set'
Pablo Greco d6c4c4
control.c:(.text+0x593): undefined reference to `ledtrig_audio_set'
Pablo Greco d6c4c4
Pablo Greco d6c4c4
Reported-by: Hulk Robot <hulkci@huawei.com>
Pablo Greco d6c4c4
Fixes: 5d43001ae436 ("ASoC: SOF: acpi led support for switch controls")
Pablo Greco d6c4c4
Signed-off-by: YueHaibing <yuehaibing@huawei.com>
Pablo Greco d6c4c4
Acked-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Pablo Greco d6c4c4
Link: https://lore.kernel.org/r/20191014091308.23688-1-yuehaibing@huawei.com
Pablo Greco d6c4c4
Signed-off-by: Mark Brown <broonie@kernel.org>
Pablo Greco d6c4c4
Pablo Greco d6c4c4
Signed-off-by: Jaroslav Kysela <jkysela@redhat.com>
Pablo Greco d6c4c4
(cherry picked from commit 9899a7a869935c4c93247b290ac7a70e0deab202)
Pablo Greco d6c4c4
Bugzilla: 1772498
Pablo Greco d6c4c4
---
Pablo Greco d6c4c4
 sound/soc/sof/control.c | 2 ++
Pablo Greco d6c4c4
 1 file changed, 2 insertions(+)
Pablo Greco d6c4c4
Pablo Greco d6c4c4
diff --git a/sound/soc/sof/control.c b/sound/soc/sof/control.c
Pablo Greco d6c4c4
index b73d4587c5da..7baf7f1507c3 100644
Pablo Greco d6c4c4
--- a/sound/soc/sof/control.c
Pablo Greco d6c4c4
+++ b/sound/soc/sof/control.c
Pablo Greco d6c4c4
@@ -36,10 +36,12 @@ static void update_mute_led(struct snd_sof_control *scontrol,
Pablo Greco d6c4c4
 
Pablo Greco d6c4c4
 	scontrol->led_ctl.led_value = temp;
Pablo Greco d6c4c4
 
Pablo Greco d6c4c4
+#if IS_REACHABLE(CONFIG_LEDS_TRIGGER_AUDIO)
Pablo Greco d6c4c4
 	if (!scontrol->led_ctl.direction)
Pablo Greco d6c4c4
 		ledtrig_audio_set(LED_AUDIO_MUTE, temp ? LED_OFF : LED_ON);
Pablo Greco d6c4c4
 	else
Pablo Greco d6c4c4
 		ledtrig_audio_set(LED_AUDIO_MICMUTE, temp ? LED_OFF : LED_ON);
Pablo Greco d6c4c4
+#endif
Pablo Greco d6c4c4
 }
Pablo Greco d6c4c4
 
Pablo Greco d6c4c4
 static inline u32 mixer_to_ipc(unsigned int value, u32 *volume_map, int size)
Pablo Greco d6c4c4
-- 
Pablo Greco d6c4c4
2.24.1
Pablo Greco d6c4c4
Pablo Greco d6c4c4
From c0ad6198c8bf64123877e61ebff462fff7c37402 Mon Sep 17 00:00:00 2001
Pablo Greco d6c4c4
From: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Pablo Greco d6c4c4
Date: Tue, 22 Oct 2019 14:28:43 -0500
Pablo Greco d6c4c4
Subject: [PATCH 033/109] ASoC: SOF: Intel: hda-loader: improve error handling
Pablo Greco d6c4c4
Pablo Greco d6c4c4
If a ROM timeout is detected, we still stop the DMA but will return
Pablo Greco d6c4c4
the initial error should the DMA stop also fail.
Pablo Greco d6c4c4
Pablo Greco d6c4c4
Likewise the cleanup is handled regardless of the status, but we
Pablo Greco d6c4c4
return the initial error.
Pablo Greco d6c4c4
Pablo Greco d6c4c4
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Pablo Greco d6c4c4
Link: https://lore.kernel.org/r/20191022192844.21022-2-pierre-louis.bossart@linux.intel.com
Pablo Greco d6c4c4
Signed-off-by: Mark Brown <broonie@kernel.org>
Pablo Greco d6c4c4
Pablo Greco d6c4c4
Signed-off-by: Jaroslav Kysela <jkysela@redhat.com>
Pablo Greco d6c4c4
(cherry picked from commit 76dc6a2b312d15c91ff4b4d171e98cdc73ba3745)
Pablo Greco d6c4c4
Bugzilla: 1772498
Pablo Greco d6c4c4
---
Pablo Greco d6c4c4
 sound/soc/sof/intel/hda-loader.c | 12 ++++++++++--
Pablo Greco d6c4c4
 1 file changed, 10 insertions(+), 2 deletions(-)
Pablo Greco d6c4c4
Pablo Greco d6c4c4
diff --git a/sound/soc/sof/intel/hda-loader.c b/sound/soc/sof/intel/hda-loader.c
Pablo Greco d6c4c4
index 356bb134ae93..e24b99fd7d39 100644
Pablo Greco d6c4c4
--- a/sound/soc/sof/intel/hda-loader.c
Pablo Greco d6c4c4
+++ b/sound/soc/sof/intel/hda-loader.c
Pablo Greco d6c4c4
@@ -253,10 +253,16 @@ static int cl_copy_fw(struct snd_sof_dev *sdev, struct hdac_ext_stream *stream)
Pablo Greco d6c4c4
 					HDA_DSP_REG_POLL_INTERVAL_US,
Pablo Greco d6c4c4
 					HDA_DSP_BASEFW_TIMEOUT_US);
Pablo Greco d6c4c4
 
Pablo Greco d6c4c4
+	/*
Pablo Greco d6c4c4
+	 * even in case of errors we still need to stop the DMAs,
Pablo Greco d6c4c4
+	 * but we return the initial error should the DMA stop also fail
Pablo Greco d6c4c4
+	 */
Pablo Greco d6c4c4
+
Pablo Greco d6c4c4
 	ret = cl_trigger(sdev, stream, SNDRV_PCM_TRIGGER_STOP);
Pablo Greco d6c4c4
 	if (ret < 0) {
Pablo Greco d6c4c4
 		dev_err(sdev->dev, "error: DMA trigger stop failed\n");
Pablo Greco d6c4c4
-		return ret;
Pablo Greco d6c4c4
+		if (!status)
Pablo Greco d6c4c4
+			status = ret;
Pablo Greco d6c4c4
 	}
Pablo Greco d6c4c4
 
Pablo Greco d6c4c4
 	return status;
Pablo Greco d6c4c4
@@ -340,13 +346,15 @@ int hda_dsp_cl_boot_firmware(struct snd_sof_dev *sdev)
Pablo Greco d6c4c4
 	/*
Pablo Greco d6c4c4
 	 * Perform codeloader stream cleanup.
Pablo Greco d6c4c4
 	 * This should be done even if firmware loading fails.
Pablo Greco d6c4c4
+	 * If the cleanup also fails, we return the initial error
Pablo Greco d6c4c4
 	 */
Pablo Greco d6c4c4
 	ret1 = cl_cleanup(sdev, &sdev->dmab, stream);
Pablo Greco d6c4c4
 	if (ret1 < 0) {
Pablo Greco d6c4c4
 		dev_err(sdev->dev, "error: Code loader DSP cleanup failed\n");
Pablo Greco d6c4c4
 
Pablo Greco d6c4c4
 		/* set return value to indicate cleanup failure */
Pablo Greco d6c4c4
-		ret = ret1;
Pablo Greco d6c4c4
+		if (!ret)
Pablo Greco d6c4c4
+			ret = ret1;
Pablo Greco d6c4c4
 	}
Pablo Greco d6c4c4
 
Pablo Greco d6c4c4
 	/*
Pablo Greco d6c4c4
-- 
Pablo Greco d6c4c4
2.24.1
Pablo Greco d6c4c4
Pablo Greco d6c4c4
From e057b265445a38082f2f566809c98b4615cadbb6 Mon Sep 17 00:00:00 2001
Pablo Greco d6c4c4
From: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Pablo Greco d6c4c4
Date: Tue, 22 Oct 2019 14:28:44 -0500
Pablo Greco d6c4c4
Subject: [PATCH 034/109] ASoC: SOF: Intel: hda: add dev_err() traces for
Pablo Greco d6c4c4
 snd_sof_dsp_read_poll_timeout()
Pablo Greco d6c4c4
Pablo Greco d6c4c4
Such traces should be extremely rare but extremely useful for debug.
Pablo Greco d6c4c4
Pablo Greco d6c4c4
Report errors for all calls to sdn_sof_dsp_read_poll_timeout(), but
Pablo Greco d6c4c4
only on negative values for consistency.
Pablo Greco d6c4c4
Pablo Greco d6c4c4
Add traces that enable each timeout to be uniquely identified.
Pablo Greco d6c4c4
Pablo Greco d6c4c4
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Pablo Greco d6c4c4
Link: https://lore.kernel.org/r/20191022192844.21022-3-pierre-louis.bossart@linux.intel.com
Pablo Greco d6c4c4
Signed-off-by: Mark Brown <broonie@kernel.org>
Pablo Greco d6c4c4
Pablo Greco d6c4c4
Signed-off-by: Jaroslav Kysela <jkysela@redhat.com>
Pablo Greco d6c4c4
(cherry picked from commit 6a414489e0f3309a221f26b3d11c19d1a96a3635)
Pablo Greco d6c4c4
Bugzilla: 1772498
Pablo Greco d6c4c4
---
Pablo Greco d6c4c4
 sound/soc/sof/intel/hda-dsp.c    | 30 +++++++++++++++++++++++++++---
Pablo Greco d6c4c4
 sound/soc/sof/intel/hda-loader.c | 13 ++++++++++++-
Pablo Greco d6c4c4
 sound/soc/sof/intel/hda-stream.c | 24 ++++++++++++++++++++----
Pablo Greco d6c4c4
 3 files changed, 59 insertions(+), 8 deletions(-)
Pablo Greco d6c4c4