All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/5] ASoC: Intel: machine driver updates for 5.16
@ 2021-10-04 21:35 Pierre-Louis Bossart
  2021-10-04 21:35 ` [PATCH 1/5] ASoC: Intel: soc-acpi: apl/glk/tgl: add entry for devices based on ES8336 codec Pierre-Louis Bossart
                   ` (5 more replies)
  0 siblings, 6 replies; 11+ messages in thread
From: Pierre-Louis Bossart @ 2021-10-04 21:35 UTC (permalink / raw)
  To: alsa-devel; +Cc: tiwai, broonie, Pierre-Louis Bossart

One quirk for a Dell TigerLake/SoundWire device, and initial support
for platforms based on the ES8336 codec (aka ES8316). For full
functionality, an update of the codec driver will be needed.

Pierre-Louis Bossart (5):
  ASoC: Intel: soc-acpi: apl/glk/tgl: add entry for devices based on
    ES8336 codec
  ALSA: intel-dsp-config: add quirk for APL/GLK/TGL devices based on
    ES8336 codec
  ASoC: Intel: add machine driver for SOF+ES8336
  ASoC: Intel: soc-acpi: add missing quirk for TGL SDCA single amp
  ASoC: Intel: sof_sdw: add missing quirk for Dell SKU 0A45

 sound/hda/intel-dsp-config.c                  |  22 +-
 sound/soc/intel/boards/Kconfig                |  14 +
 sound/soc/intel/boards/Makefile               |   2 +
 sound/soc/intel/boards/sof_es8336.c           | 569 ++++++++++++++++++
 sound/soc/intel/boards/sof_sdw.c              |  10 +
 .../intel/common/soc-acpi-intel-bxt-match.c   |   6 +
 .../intel/common/soc-acpi-intel-glk-match.c   |   7 +-
 .../intel/common/soc-acpi-intel-tgl-match.c   |  47 ++
 8 files changed, 674 insertions(+), 3 deletions(-)
 create mode 100644 sound/soc/intel/boards/sof_es8336.c

-- 
2.25.1


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PATCH 1/5] ASoC: Intel: soc-acpi: apl/glk/tgl: add entry for devices based on ES8336 codec
  2021-10-04 21:35 [PATCH 0/5] ASoC: Intel: machine driver updates for 5.16 Pierre-Louis Bossart
@ 2021-10-04 21:35 ` Pierre-Louis Bossart
  2021-10-04 21:35 ` [PATCH 2/5] ALSA: intel-dsp-config: add quirk for APL/GLK/TGL " Pierre-Louis Bossart
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 11+ messages in thread
From: Pierre-Louis Bossart @ 2021-10-04 21:35 UTC (permalink / raw)
  To: alsa-devel; +Cc: tiwai, Huajun Li, broonie, Pierre-Louis Bossart, Kai Vehmanen

A number of devices, such as the "Chuwi HI10x" and "UNIQCELL Q15.6",
are based on APL/GLK with an I2C/I2S ES8336 codec.

Add table to find topology and firmware files.

Co-developed-by: Huajun Li <huajun.li@intel.com>
Signed-off-by: Huajun Li <huajun.li@intel.com>
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Reviewed-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
---
 sound/soc/intel/common/soc-acpi-intel-bxt-match.c | 6 ++++++
 sound/soc/intel/common/soc-acpi-intel-glk-match.c | 7 ++++++-
 sound/soc/intel/common/soc-acpi-intel-tgl-match.c | 6 ++++++
 3 files changed, 18 insertions(+), 1 deletion(-)

diff --git a/sound/soc/intel/common/soc-acpi-intel-bxt-match.c b/sound/soc/intel/common/soc-acpi-intel-bxt-match.c
index 576407b5daf2..78cfdc48ad45 100644
--- a/sound/soc/intel/common/soc-acpi-intel-bxt-match.c
+++ b/sound/soc/intel/common/soc-acpi-intel-bxt-match.c
@@ -82,6 +82,12 @@ struct snd_soc_acpi_mach snd_soc_acpi_intel_bxt_machines[] = {
 		.sof_fw_filename = "sof-apl.ri",
 		.sof_tplg_filename = "sof-apl-tdf8532.tplg",
 	},
+	{
+		.id = "ESSX8336",
+		.drv_name = "sof-essx8336",
+		.sof_fw_filename = "sof-apl.ri",
+		.sof_tplg_filename = "sof-apl-es8336.tplg",
+	},
 	{},
 };
 EXPORT_SYMBOL_GPL(snd_soc_acpi_intel_bxt_machines);
diff --git a/sound/soc/intel/common/soc-acpi-intel-glk-match.c b/sound/soc/intel/common/soc-acpi-intel-glk-match.c
index da1e151190b4..32fff9389eb3 100644
--- a/sound/soc/intel/common/soc-acpi-intel-glk-match.c
+++ b/sound/soc/intel/common/soc-acpi-intel-glk-match.c
@@ -49,7 +49,12 @@ struct snd_soc_acpi_mach snd_soc_acpi_intel_glk_machines[] = {
 		.sof_fw_filename = "sof-glk.ri",
 		.sof_tplg_filename = "sof-glk-cs42l42.tplg",
 	},
-
+	{
+		.id = "ESSX8336",
+		.drv_name = "sof-essx8336",
+		.sof_fw_filename = "sof-glk.ri",
+		.sof_tplg_filename = "sof-glk-es8336.tplg",
+	},
 	{},
 };
 EXPORT_SYMBOL_GPL(snd_soc_acpi_intel_glk_machines);
diff --git a/sound/soc/intel/common/soc-acpi-intel-tgl-match.c b/sound/soc/intel/common/soc-acpi-intel-tgl-match.c
index 91ef71c2535d..5332f96eb938 100644
--- a/sound/soc/intel/common/soc-acpi-intel-tgl-match.c
+++ b/sound/soc/intel/common/soc-acpi-intel-tgl-match.c
@@ -355,6 +355,12 @@ struct snd_soc_acpi_mach snd_soc_acpi_intel_tgl_machines[] = {
 		.sof_fw_filename = "sof-tgl.ri",
 		.sof_tplg_filename = "sof-tgl-rt1011-rt5682.tplg",
 	},
+	{
+		.id = "ESSX8336",
+		.drv_name = "sof-essx8336",
+		.sof_fw_filename = "sof-tgl.ri",
+		.sof_tplg_filename = "sof-tgl-es8336.tplg",
+	},
 	{},
 };
 EXPORT_SYMBOL_GPL(snd_soc_acpi_intel_tgl_machines);
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH 2/5] ALSA: intel-dsp-config: add quirk for APL/GLK/TGL devices based on ES8336 codec
  2021-10-04 21:35 [PATCH 0/5] ASoC: Intel: machine driver updates for 5.16 Pierre-Louis Bossart
  2021-10-04 21:35 ` [PATCH 1/5] ASoC: Intel: soc-acpi: apl/glk/tgl: add entry for devices based on ES8336 codec Pierre-Louis Bossart
@ 2021-10-04 21:35 ` Pierre-Louis Bossart
  2021-10-04 21:35 ` [PATCH 3/5] ASoC: Intel: add machine driver for SOF+ES8336 Pierre-Louis Bossart
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 11+ messages in thread
From: Pierre-Louis Bossart @ 2021-10-04 21:35 UTC (permalink / raw)
  To: alsa-devel; +Cc: tiwai, Huajun Li, broonie, Pierre-Louis Bossart, Kai Vehmanen

These devices are based on an I2C/I2S device, we need to force the use
of the SOF driver otherwise the legacy HDaudio driver will be loaded -
only HDMI will be supported.

Co-developed-by: Huajun Li <huajun.li@intel.com>
Signed-off-by: Huajun Li <huajun.li@intel.com>
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Reviewed-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
---
 sound/hda/intel-dsp-config.c | 22 ++++++++++++++++++++--
 1 file changed, 20 insertions(+), 2 deletions(-)

diff --git a/sound/hda/intel-dsp-config.c b/sound/hda/intel-dsp-config.c
index c9d0ba353463..b9ac9e9e45a4 100644
--- a/sound/hda/intel-dsp-config.c
+++ b/sound/hda/intel-dsp-config.c
@@ -31,6 +31,7 @@ struct config_entry {
 	u16 device;
 	u8 acpi_hid[ACPI_ID_LEN];
 	const struct dmi_system_id *dmi_table;
+	u8 codec_hid[ACPI_ID_LEN];
 };
 
 /*
@@ -56,7 +57,7 @@ static const struct config_entry config_table[] = {
 /*
  * Apollolake (Broxton-P)
  * the legacy HDAudio driver is used except on Up Squared (SOF) and
- * Chromebooks (SST)
+ * Chromebooks (SST), as well as devices based on the ES8336 codec
  */
 #if IS_ENABLED(CONFIG_SND_SOC_SOF_APOLLOLAKE)
 	{
@@ -73,6 +74,11 @@ static const struct config_entry config_table[] = {
 			{}
 		}
 	},
+	{
+		.flags = FLAG_SOF,
+		.device = 0x5a98,
+		.codec_hid = "ESSX8336",
+	},
 #endif
 #if IS_ENABLED(CONFIG_SND_SOC_INTEL_APL)
 	{
@@ -137,7 +143,7 @@ static const struct config_entry config_table[] = {
 
 /*
  * Geminilake uses legacy HDAudio driver except for Google
- * Chromebooks
+ * Chromebooks and devices based on the ES8336 codec
  */
 /* Geminilake */
 #if IS_ENABLED(CONFIG_SND_SOC_SOF_GEMINILAKE)
@@ -154,6 +160,11 @@ static const struct config_entry config_table[] = {
 			{}
 		}
 	},
+	{
+		.flags = FLAG_SOF,
+		.device = 0x3198,
+		.codec_hid = "ESSX8336",
+	},
 #endif
 
 /*
@@ -311,6 +322,11 @@ static const struct config_entry config_table[] = {
 		.flags = FLAG_SOF | FLAG_SOF_ONLY_IF_DMIC_OR_SOUNDWIRE,
 		.device = 0x43c8,
 	},
+	{
+		.flags = FLAG_SOF,
+		.device = 0xa0c8,
+		.codec_hid = "ESSX8336",
+	},
 #endif
 
 /* Elkhart Lake */
@@ -354,6 +370,8 @@ static const struct config_entry *snd_intel_dsp_find_config
 			continue;
 		if (table->dmi_table && !dmi_check_system(table->dmi_table))
 			continue;
+		if (table->codec_hid[0] && !acpi_dev_present(table->codec_hid, NULL, -1))
+			continue;
 		return table;
 	}
 	return NULL;
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH 3/5] ASoC: Intel: add machine driver for SOF+ES8336
  2021-10-04 21:35 [PATCH 0/5] ASoC: Intel: machine driver updates for 5.16 Pierre-Louis Bossart
  2021-10-04 21:35 ` [PATCH 1/5] ASoC: Intel: soc-acpi: apl/glk/tgl: add entry for devices based on ES8336 codec Pierre-Louis Bossart
  2021-10-04 21:35 ` [PATCH 2/5] ALSA: intel-dsp-config: add quirk for APL/GLK/TGL " Pierre-Louis Bossart
@ 2021-10-04 21:35 ` Pierre-Louis Bossart
  2021-11-21 19:00   ` Mauro Carvalho Chehab
  2021-10-04 21:35 ` [PATCH 4/5] ASoC: Intel: soc-acpi: add missing quirk for TGL SDCA single amp Pierre-Louis Bossart
                   ` (2 subsequent siblings)
  5 siblings, 1 reply; 11+ messages in thread
From: Pierre-Louis Bossart @ 2021-10-04 21:35 UTC (permalink / raw)
  To: alsa-devel; +Cc: tiwai, Huajun Li, broonie, Pierre-Louis Bossart, Kai Vehmanen

Add machine driver to support APL/GLK/TGL platforms.
The TGL platform supports DMIC, APL and GLK do not.

Co-developed-by: Huajun Li <huajun.li@intel.com>
Signed-off-by: Huajun Li <huajun.li@intel.com>
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Reviewed-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
---
 sound/soc/intel/boards/Kconfig      |  14 +
 sound/soc/intel/boards/Makefile     |   2 +
 sound/soc/intel/boards/sof_es8336.c | 569 ++++++++++++++++++++++++++++
 3 files changed, 585 insertions(+)
 create mode 100644 sound/soc/intel/boards/sof_es8336.c

diff --git a/sound/soc/intel/boards/Kconfig b/sound/soc/intel/boards/Kconfig
index 3e20c697b569..5a225a4ce604 100644
--- a/sound/soc/intel/boards/Kconfig
+++ b/sound/soc/intel/boards/Kconfig
@@ -512,6 +512,20 @@ config SND_SOC_INTEL_SOF_PCM512x_MACH
 	  Say Y or m if you have such a device.
 	  If unsure select "N".
 
+config SND_SOC_INTEL_SOF_ES8336_MACH
+	tristate "SOF with ES8336 codec in I2S mode"
+	depends on I2C && ACPI && GPIOLIB
+	depends on MFD_INTEL_LPSS || COMPILE_TEST
+	depends on SND_HDA_CODEC_HDMI && SND_SOC_SOF_HDA_AUDIO_CODEC
+	select SND_SOC_ES8316
+	select SND_SOC_DMIC
+	select SND_SOC_INTEL_HDA_DSP_COMMON
+	help
+	   This adds support for ASoC machine driver for SOF platforms
+	   with es8336 codec.
+	   Say Y if you have such a device.
+	   If unsure select "N".
+
 endif ## SND_SOC_SOF_HDA_LINK || SND_SOC_SOF_BAYTRAIL
 
 if (SND_SOC_SOF_COMETLAKE && SND_SOC_SOF_HDA_LINK)
diff --git a/sound/soc/intel/boards/Makefile b/sound/soc/intel/boards/Makefile
index ed21b82a4cf6..9ee8ed864f5d 100644
--- a/sound/soc/intel/boards/Makefile
+++ b/sound/soc/intel/boards/Makefile
@@ -21,6 +21,7 @@ snd-soc-sst-byt-cht-es8316-objs := bytcht_es8316.o
 snd-soc-sst-byt-cht-nocodec-objs := bytcht_nocodec.o
 snd-soc-sof_rt5682-objs := sof_rt5682.o sof_realtek_common.o
 snd-soc-sof_cs42l42-objs := sof_cs42l42.o
+snd-soc-sof_es8336-objs := sof_es8336.o
 snd-soc-cml_rt1011_rt5682-objs := cml_rt1011_rt5682.o
 snd-soc-kbl_da7219_max98357a-objs := kbl_da7219_max98357a.o
 snd-soc-kbl_da7219_max98927-objs := kbl_da7219_max98927.o
@@ -42,6 +43,7 @@ snd-soc-sof-sdw-objs += sof_sdw.o				\
 			sof_sdw_dmic.o sof_sdw_hdmi.o
 obj-$(CONFIG_SND_SOC_INTEL_SOF_RT5682_MACH) += snd-soc-sof_rt5682.o
 obj-$(CONFIG_SND_SOC_INTEL_SOF_CS42L42_MACH) += snd-soc-sof_cs42l42.o
+obj-$(CONFIG_SND_SOC_INTEL_SOF_ES8336_MACH) += snd-soc-sof_es8336.o
 obj-$(CONFIG_SND_SOC_INTEL_HASWELL_MACH) += snd-soc-sst-haswell.o
 obj-$(CONFIG_SND_SOC_INTEL_BXT_DA7219_MAX98357A_COMMON) += snd-soc-sst-bxt-da7219_max98357a.o
 obj-$(CONFIG_SND_SOC_INTEL_BXT_RT298_MACH) += snd-soc-sst-bxt-rt298.o
diff --git a/sound/soc/intel/boards/sof_es8336.c b/sound/soc/intel/boards/sof_es8336.c
new file mode 100644
index 000000000000..20d577eaab6d
--- /dev/null
+++ b/sound/soc/intel/boards/sof_es8336.c
@@ -0,0 +1,569 @@
+// SPDX-License-Identifier: GPL-2.0-only
+// Copyright(c) 2021 Intel Corporation.
+
+/*
+ * Intel SOF Machine Driver with es8336 Codec
+ */
+
+#include <linux/device.h>
+#include <linux/dmi.h>
+#include <linux/gpio/consumer.h>
+#include <linux/gpio/machine.h>
+#include <linux/i2c.h>
+#include <linux/input.h>
+#include <linux/module.h>
+#include <linux/platform_device.h>
+#include <linux/slab.h>
+#include <sound/jack.h>
+#include <sound/pcm.h>
+#include <sound/pcm_params.h>
+#include <sound/soc.h>
+#include <sound/soc-acpi.h>
+#include "hda_dsp_common.h"
+
+#define SOF_ES8336_SSP_CODEC(quirk)		((quirk) & GENMASK(3, 0))
+#define SOF_ES8336_SSP_CODEC_MASK		(GENMASK(3, 0))
+
+#define SOF_ES8336_TGL_GPIO_QUIRK		BIT(4)
+#define SOF_ES8336_ENABLE_DMIC			BIT(5)
+
+static unsigned long quirk;
+
+static int quirk_override = -1;
+module_param_named(quirk, quirk_override, int, 0444);
+MODULE_PARM_DESC(quirk, "Board-specific quirk override");
+
+struct sof_es8336_private {
+	struct device *codec_dev;
+	struct gpio_desc *gpio_pa;
+	struct snd_soc_jack jack;
+	struct list_head hdmi_pcm_list;
+	bool speaker_en;
+};
+
+struct sof_hdmi_pcm {
+	struct list_head head;
+	struct snd_soc_dai *codec_dai;
+	int device;
+};
+
+static const struct acpi_gpio_params pa_enable_gpio = { 0, 0, true };
+static const struct acpi_gpio_mapping acpi_es8336_gpios[] = {
+	{ "pa-enable-gpios", &pa_enable_gpio, 1 },
+	{ }
+};
+
+static const struct acpi_gpio_params quirk_pa_enable_gpio = { 1, 0, true };
+static const struct acpi_gpio_mapping quirk_acpi_es8336_gpios[] = {
+	{ "pa-enable-gpios", &quirk_pa_enable_gpio, 1 },
+	{ }
+};
+
+static const struct acpi_gpio_mapping *gpio_mapping = acpi_es8336_gpios;
+
+static void log_quirks(struct device *dev)
+{
+	dev_info(dev, "quirk SSP%ld",  SOF_ES8336_SSP_CODEC(quirk));
+}
+
+static int sof_es8316_speaker_power_event(struct snd_soc_dapm_widget *w,
+					  struct snd_kcontrol *kcontrol, int event)
+{
+	struct snd_soc_card *card = w->dapm->card;
+	struct sof_es8336_private *priv = snd_soc_card_get_drvdata(card);
+
+	if (SND_SOC_DAPM_EVENT_ON(event))
+		priv->speaker_en = false;
+	else
+		priv->speaker_en = true;
+
+	gpiod_set_value_cansleep(priv->gpio_pa, priv->speaker_en);
+
+	return 0;
+}
+
+static const struct snd_soc_dapm_widget sof_es8316_widgets[] = {
+	SND_SOC_DAPM_SPK("Speaker", NULL),
+	SND_SOC_DAPM_HP("Headphone", NULL),
+	SND_SOC_DAPM_MIC("Headset Mic", NULL),
+	SND_SOC_DAPM_MIC("Internal Mic", NULL),
+
+	SND_SOC_DAPM_SUPPLY("Speaker Power", SND_SOC_NOPM, 0, 0,
+			    sof_es8316_speaker_power_event,
+			    SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMU),
+};
+
+static const struct snd_soc_dapm_widget dmic_widgets[] = {
+	SND_SOC_DAPM_MIC("SoC DMIC", NULL),
+};
+
+static const struct snd_soc_dapm_route sof_es8316_audio_map[] = {
+	{"Headphone", NULL, "HPOL"},
+	{"Headphone", NULL, "HPOR"},
+
+	/*
+	 * There is no separate speaker output instead the speakers are muxed to
+	 * the HP outputs. The mux is controlled by the "Speaker Power" supply.
+	 */
+	{"Speaker", NULL, "HPOL"},
+	{"Speaker", NULL, "HPOR"},
+	{"Speaker", NULL, "Speaker Power"},
+};
+
+static const struct snd_soc_dapm_route sof_es8316_intmic_in1_map[] = {
+	{"MIC1", NULL, "Internal Mic"},
+	{"MIC2", NULL, "Headset Mic"},
+};
+
+static const struct snd_soc_dapm_route dmic_map[] = {
+	/* digital mics */
+	{"DMic", NULL, "SoC DMIC"},
+};
+
+static const struct snd_kcontrol_new sof_es8316_controls[] = {
+	SOC_DAPM_PIN_SWITCH("Speaker"),
+	SOC_DAPM_PIN_SWITCH("Headphone"),
+	SOC_DAPM_PIN_SWITCH("Headset Mic"),
+	SOC_DAPM_PIN_SWITCH("Internal Mic"),
+};
+
+static struct snd_soc_jack_pin sof_es8316_jack_pins[] = {
+	{
+		.pin	= "Headphone",
+		.mask	= SND_JACK_HEADPHONE,
+	},
+	{
+		.pin	= "Headset Mic",
+		.mask	= SND_JACK_MICROPHONE,
+	},
+};
+
+static int dmic_init(struct snd_soc_pcm_runtime *runtime)
+{
+	struct snd_soc_card *card = runtime->card;
+	int ret;
+
+	ret = snd_soc_dapm_new_controls(&card->dapm, dmic_widgets,
+					ARRAY_SIZE(dmic_widgets));
+	if (ret) {
+		dev_err(card->dev, "DMic widget addition failed: %d\n", ret);
+		return ret;
+	}
+
+	ret = snd_soc_dapm_add_routes(&card->dapm, dmic_map,
+				      ARRAY_SIZE(dmic_map));
+	if (ret)
+		dev_err(card->dev, "DMic map addition failed: %d\n", ret);
+
+	return ret;
+}
+
+static int sof_hdmi_init(struct snd_soc_pcm_runtime *runtime)
+{
+	struct sof_es8336_private *priv = snd_soc_card_get_drvdata(runtime->card);
+	struct snd_soc_dai *dai = asoc_rtd_to_codec(runtime, 0);
+	struct sof_hdmi_pcm *pcm;
+
+	pcm = devm_kzalloc(runtime->card->dev, sizeof(*pcm), GFP_KERNEL);
+	if (!pcm)
+		return -ENOMEM;
+
+	/* dai_link id is 1:1 mapped to the PCM device */
+	pcm->device = runtime->dai_link->id;
+	pcm->codec_dai = dai;
+
+	list_add_tail(&pcm->head, &priv->hdmi_pcm_list);
+
+	return 0;
+}
+
+static int sof_es8316_init(struct snd_soc_pcm_runtime *runtime)
+{
+	struct snd_soc_component *codec = asoc_rtd_to_codec(runtime, 0)->component;
+	struct snd_soc_card *card = runtime->card;
+	struct sof_es8336_private *priv = snd_soc_card_get_drvdata(card);
+	const struct snd_soc_dapm_route *custom_map;
+	int num_routes;
+	int ret;
+
+	card->dapm.idle_bias_off = true;
+
+	custom_map = sof_es8316_intmic_in1_map;
+	num_routes = ARRAY_SIZE(sof_es8316_intmic_in1_map);
+
+	ret = snd_soc_dapm_add_routes(&card->dapm, custom_map, num_routes);
+	if (ret)
+		return ret;
+
+	ret = snd_soc_card_jack_new(card, "Headset",
+				    SND_JACK_HEADSET | SND_JACK_BTN_0,
+				    &priv->jack, sof_es8316_jack_pins,
+				    ARRAY_SIZE(sof_es8316_jack_pins));
+	if (ret) {
+		dev_err(card->dev, "jack creation failed %d\n", ret);
+		return ret;
+	}
+
+	snd_jack_set_key(priv->jack.jack, SND_JACK_BTN_0, KEY_PLAYPAUSE);
+
+	snd_soc_component_set_jack(codec, &priv->jack, NULL);
+
+	return 0;
+}
+
+static void sof_es8316_exit(struct snd_soc_pcm_runtime *rtd)
+{
+	struct snd_soc_component *component = asoc_rtd_to_codec(rtd, 0)->component;
+
+	snd_soc_component_set_jack(component, NULL, NULL);
+}
+
+static int sof_es8336_quirk_cb(const struct dmi_system_id *id)
+{
+	quirk = (unsigned long)id->driver_data;
+
+	if (quirk & SOF_ES8336_TGL_GPIO_QUIRK)
+		gpio_mapping = quirk_acpi_es8336_gpios;
+
+	return 1;
+}
+
+static const struct dmi_system_id sof_es8336_quirk_table[] = {
+	{
+		.callback = sof_es8336_quirk_cb,
+		.matches = {
+			DMI_MATCH(DMI_SYS_VENDOR, "CHUWI Innovation And Technology"),
+			DMI_MATCH(DMI_BOARD_NAME, "Hi10 X"),
+		},
+		.driver_data = (void *)SOF_ES8336_SSP_CODEC(2)
+	},
+	{
+		.callback = sof_es8336_quirk_cb,
+		.matches = {
+			DMI_MATCH(DMI_SYS_VENDOR, "IP3 tech"),
+			DMI_MATCH(DMI_BOARD_NAME, "WN1"),
+		},
+		.driver_data = (void *)(SOF_ES8336_SSP_CODEC(0) |
+					SOF_ES8336_TGL_GPIO_QUIRK |
+					SOF_ES8336_ENABLE_DMIC)
+	},
+	{}
+};
+
+static int sof_es8336_hw_params(struct snd_pcm_substream *substream,
+				struct snd_pcm_hw_params *params)
+{
+	struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream);
+	struct snd_soc_dai *codec_dai = asoc_rtd_to_codec(rtd, 0);
+	const int sysclk = 19200000;
+	int ret;
+
+	ret = snd_soc_dai_set_sysclk(codec_dai, 1, sysclk, SND_SOC_CLOCK_OUT);
+	if (ret < 0) {
+		dev_err(rtd->dev, "%s, Failed to set ES8336 SYSCLK: %d\n",
+			__func__, ret);
+		return ret;
+	}
+
+	return 0;
+}
+
+/* machine stream operations */
+static struct snd_soc_ops sof_es8336_ops = {
+	.hw_params = sof_es8336_hw_params,
+};
+
+static struct snd_soc_dai_link_component platform_component[] = {
+	{
+		/* name might be overridden during probe */
+		.name = "0000:00:1f.3"
+	}
+};
+
+SND_SOC_DAILINK_DEF(ssp1_codec,
+	DAILINK_COMP_ARRAY(COMP_CODEC("i2c-ESSX8336:00", "ES8316 HiFi")));
+
+static struct snd_soc_dai_link_component dmic_component[] = {
+	{
+		.name = "dmic-codec",
+		.dai_name = "dmic-hifi",
+	}
+};
+
+static int sof_es8336_late_probe(struct snd_soc_card *card)
+{
+	struct sof_es8336_private *priv = snd_soc_card_get_drvdata(card);
+	struct sof_hdmi_pcm *pcm;
+
+	if (list_empty(&priv->hdmi_pcm_list))
+		return -ENOENT;
+
+	pcm = list_first_entry(&priv->hdmi_pcm_list, struct sof_hdmi_pcm, head);
+
+	return hda_dsp_hdmi_build_controls(card, pcm->codec_dai->component);
+}
+
+/* SoC card */
+static struct snd_soc_card sof_es8336_card = {
+	.name = "essx8336", /* sof- prefix added automatically */
+	.owner = THIS_MODULE,
+	.dapm_widgets = sof_es8316_widgets,
+	.num_dapm_widgets = ARRAY_SIZE(sof_es8316_widgets),
+	.dapm_routes = sof_es8316_audio_map,
+	.num_dapm_routes = ARRAY_SIZE(sof_es8316_audio_map),
+	.controls = sof_es8316_controls,
+	.num_controls = ARRAY_SIZE(sof_es8316_controls),
+	.fully_routed = true,
+	.late_probe = sof_es8336_late_probe,
+	.num_links = 1,
+};
+
+static struct snd_soc_dai_link *sof_card_dai_links_create(struct device *dev,
+							  int ssp_codec,
+							  int dmic_be_num,
+							  int hdmi_num)
+{
+	struct snd_soc_dai_link_component *cpus;
+	struct snd_soc_dai_link *links;
+	struct snd_soc_dai_link_component *idisp_components;
+	int hdmi_id_offset = 0;
+	int id = 0;
+	int i;
+
+	links = devm_kcalloc(dev, sof_es8336_card.num_links,
+			     sizeof(struct snd_soc_dai_link), GFP_KERNEL);
+	cpus = devm_kcalloc(dev, sof_es8336_card.num_links,
+			    sizeof(struct snd_soc_dai_link_component), GFP_KERNEL);
+	if (!links || !cpus)
+		goto devm_err;
+
+	/* codec SSP */
+	links[id].name = devm_kasprintf(dev, GFP_KERNEL,
+					"SSP%d-Codec", ssp_codec);
+	if (!links[id].name)
+		goto devm_err;
+
+	links[id].id = id;
+	links[id].codecs = ssp1_codec;
+	links[id].num_codecs = ARRAY_SIZE(ssp1_codec);
+	links[id].platforms = platform_component;
+	links[id].num_platforms = ARRAY_SIZE(platform_component);
+	links[id].init = sof_es8316_init;
+	links[id].exit = sof_es8316_exit;
+	links[id].ops = &sof_es8336_ops;
+	links[id].nonatomic = true;
+	links[id].dpcm_playback = 1;
+	links[id].dpcm_capture = 1;
+	links[id].no_pcm = 1;
+	links[id].cpus = &cpus[id];
+	links[id].num_cpus = 1;
+
+	links[id].cpus->dai_name = devm_kasprintf(dev, GFP_KERNEL,
+						  "SSP%d Pin",
+						  ssp_codec);
+	if (!links[id].cpus->dai_name)
+		goto devm_err;
+
+	id++;
+
+	/* dmic */
+	if (dmic_be_num > 0) {
+		/* at least we have dmic01 */
+		links[id].name = "dmic01";
+		links[id].cpus = &cpus[id];
+		links[id].cpus->dai_name = "DMIC01 Pin";
+		links[id].init = dmic_init;
+		if (dmic_be_num > 1) {
+			/* set up 2 BE links at most */
+			links[id + 1].name = "dmic16k";
+			links[id + 1].cpus = &cpus[id + 1];
+			links[id + 1].cpus->dai_name = "DMIC16k Pin";
+			dmic_be_num = 2;
+		}
+	} else {
+		/* HDMI dai link starts at 3 according to current topology settings */
+		hdmi_id_offset = 2;
+	}
+
+	for (i = 0; i < dmic_be_num; i++) {
+		links[id].id = id;
+		links[id].num_cpus = 1;
+		links[id].codecs = dmic_component;
+		links[id].num_codecs = ARRAY_SIZE(dmic_component);
+		links[id].platforms = platform_component;
+		links[id].num_platforms = ARRAY_SIZE(platform_component);
+		links[id].ignore_suspend = 1;
+		links[id].dpcm_capture = 1;
+		links[id].no_pcm = 1;
+
+		id++;
+	}
+
+	/* HDMI */
+	if (hdmi_num > 0) {
+		idisp_components = devm_kzalloc(dev,
+						sizeof(struct snd_soc_dai_link_component) *
+						hdmi_num, GFP_KERNEL);
+		if (!idisp_components)
+			goto devm_err;
+	}
+
+	for (i = 1; i <= hdmi_num; i++) {
+		links[id].name = devm_kasprintf(dev, GFP_KERNEL,
+						"iDisp%d", i);
+		if (!links[id].name)
+			goto devm_err;
+
+		links[id].id = id + hdmi_id_offset;
+		links[id].cpus = &cpus[id];
+		links[id].num_cpus = 1;
+		links[id].cpus->dai_name = devm_kasprintf(dev, GFP_KERNEL,
+							  "iDisp%d Pin", i);
+		if (!links[id].cpus->dai_name)
+			goto devm_err;
+
+		idisp_components[i - 1].name = "ehdaudio0D2";
+		idisp_components[i - 1].dai_name = devm_kasprintf(dev,
+								  GFP_KERNEL,
+								  "intel-hdmi-hifi%d",
+								  i);
+		if (!idisp_components[i - 1].dai_name)
+			goto devm_err;
+
+		links[id].codecs = &idisp_components[i - 1];
+		links[id].num_codecs = 1;
+		links[id].platforms = platform_component;
+		links[id].num_platforms = ARRAY_SIZE(platform_component);
+		links[id].init = sof_hdmi_init;
+		links[id].dpcm_playback = 1;
+		links[id].no_pcm = 1;
+
+		id++;
+	}
+
+	return links;
+
+devm_err:
+	return NULL;
+}
+
+ /* i2c-<HID>:00 with HID being 8 chars */
+static char codec_name[SND_ACPI_I2C_ID_LEN];
+
+static int sof_es8336_probe(struct platform_device *pdev)
+{
+	struct device *dev = &pdev->dev;
+	struct snd_soc_card *card;
+	struct snd_soc_acpi_mach *mach = pdev->dev.platform_data;
+	struct sof_es8336_private *priv;
+	struct acpi_device *adev;
+	struct snd_soc_dai_link *dai_links;
+	struct device *codec_dev;
+	int dmic_be_num = 0;
+	int hdmi_num = 3;
+	int ret;
+
+	priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
+	if (!priv)
+		return -ENOMEM;
+
+	card = &sof_es8336_card;
+	card->dev = dev;
+
+	if (!dmi_check_system(sof_es8336_quirk_table))
+		quirk = SOF_ES8336_SSP_CODEC(2);
+
+	if (quirk & SOF_ES8336_ENABLE_DMIC)
+		dmic_be_num = 2;
+
+	if (quirk_override != -1) {
+		dev_info(dev, "Overriding quirk 0x%lx => 0x%x\n",
+			 quirk, quirk_override);
+		quirk = quirk_override;
+	}
+	log_quirks(dev);
+
+	sof_es8336_card.num_links += dmic_be_num + hdmi_num;
+	dai_links = sof_card_dai_links_create(dev,
+					      SOF_ES8336_SSP_CODEC(quirk),
+					      dmic_be_num, hdmi_num);
+	if (!dai_links)
+		return -ENOMEM;
+
+	sof_es8336_card.dai_link = dai_links;
+
+	/* fixup codec name based on HID */
+	adev = acpi_dev_get_first_match_dev(mach->id, NULL, -1);
+	if (adev) {
+		snprintf(codec_name, sizeof(codec_name),
+			 "i2c-%s", acpi_dev_name(adev));
+		put_device(&adev->dev);
+		dai_links[0].codecs->name = codec_name;
+	}
+
+	ret = snd_soc_fixup_dai_links_platform_name(&sof_es8336_card,
+						    mach->mach_params.platform);
+	if (ret)
+		return ret;
+
+	/* get speaker enable GPIO */
+	codec_dev = bus_find_device_by_name(&i2c_bus_type, NULL, codec_name);
+	if (!codec_dev)
+		return -EPROBE_DEFER;
+
+	ret = devm_acpi_dev_add_driver_gpios(codec_dev, gpio_mapping);
+	if (ret)
+		dev_warn(codec_dev, "unable to add GPIO mapping table\n");
+
+	priv->gpio_pa = gpiod_get(codec_dev, "pa-enable", GPIOD_OUT_LOW);
+	if (IS_ERR(priv->gpio_pa)) {
+		ret = PTR_ERR(priv->gpio_pa);
+		dev_err(codec_dev, "%s, could not get pa-enable: %d\n",
+			__func__, ret);
+		goto err;
+	}
+
+	priv->codec_dev = codec_dev;
+	INIT_LIST_HEAD(&priv->hdmi_pcm_list);
+
+	snd_soc_card_set_drvdata(card, priv);
+
+	ret = devm_snd_soc_register_card(dev, card);
+	if (ret) {
+		gpiod_put(priv->gpio_pa);
+		dev_err(dev, "snd_soc_register_card failed: %d\n", ret);
+		goto err;
+	}
+	platform_set_drvdata(pdev, &sof_es8336_card);
+	return 0;
+
+err:
+	put_device(codec_dev);
+	return ret;
+}
+
+static int sof_es8336_remove(struct platform_device *pdev)
+{
+	struct snd_soc_card *card = platform_get_drvdata(pdev);
+	struct sof_es8336_private *priv = snd_soc_card_get_drvdata(card);
+
+	gpiod_put(priv->gpio_pa);
+	put_device(priv->codec_dev);
+
+	return 0;
+}
+
+static struct platform_driver sof_es8336_driver = {
+	.driver = {
+		.name = "sof-essx8336",
+		.pm = &snd_soc_pm_ops,
+	},
+	.probe = sof_es8336_probe,
+	.remove = sof_es8336_remove,
+};
+module_platform_driver(sof_es8336_driver);
+
+MODULE_DESCRIPTION("ASoC Intel(R) SOF + ES8336 Machine driver");
+MODULE_LICENSE("GPL");
+MODULE_ALIAS("platform:sof-essx8336");
+MODULE_IMPORT_NS(SND_SOC_INTEL_HDA_DSP_COMMON);
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH 4/5] ASoC: Intel: soc-acpi: add missing quirk for TGL SDCA single amp
  2021-10-04 21:35 [PATCH 0/5] ASoC: Intel: machine driver updates for 5.16 Pierre-Louis Bossart
                   ` (2 preceding siblings ...)
  2021-10-04 21:35 ` [PATCH 3/5] ASoC: Intel: add machine driver for SOF+ES8336 Pierre-Louis Bossart
@ 2021-10-04 21:35 ` Pierre-Louis Bossart
  2021-10-04 21:35 ` [PATCH 5/5] ASoC: Intel: sof_sdw: add missing quirk for Dell SKU 0A45 Pierre-Louis Bossart
  2021-10-05 15:37 ` [PATCH 0/5] ASoC: Intel: machine driver updates for 5.16 Mark Brown
  5 siblings, 0 replies; 11+ messages in thread
From: Pierre-Louis Bossart @ 2021-10-04 21:35 UTC (permalink / raw)
  To: alsa-devel; +Cc: tiwai, broonie, Pierre-Louis Bossart, Bard Liao, Rander Wang

We don't have a configuration for a single amp on link1.

BugLink: https://github.com/thesofproject/linux/issues/3161
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Reviewed-by: Rander Wang <rander.wang@intel.com>
Reviewed-by: Bard Liao <bard.liao@intel.com>
---
 .../intel/common/soc-acpi-intel-tgl-match.c   | 41 +++++++++++++++++++
 1 file changed, 41 insertions(+)

diff --git a/sound/soc/intel/common/soc-acpi-intel-tgl-match.c b/sound/soc/intel/common/soc-acpi-intel-tgl-match.c
index 5332f96eb938..9d89f01d6b84 100644
--- a/sound/soc/intel/common/soc-acpi-intel-tgl-match.c
+++ b/sound/soc/intel/common/soc-acpi-intel-tgl-match.c
@@ -156,6 +156,15 @@ static const struct snd_soc_acpi_adr_device rt711_sdca_0_adr[] = {
 	}
 };
 
+static const struct snd_soc_acpi_adr_device rt1316_1_single_adr[] = {
+	{
+		.adr = 0x000131025D131601ull,
+		.num_endpoints = 1,
+		.endpoints = &single_endpoint,
+		.name_prefix = "rt1316-1"
+	}
+};
+
 static const struct snd_soc_acpi_adr_device rt1316_1_group1_adr[] = {
 	{
 		.adr = 0x000131025D131601ull, /* unique ID is set for some reason */
@@ -320,6 +329,25 @@ static const struct snd_soc_acpi_link_adr tgl_3_in_1_sdca[] = {
 	{}
 };
 
+static const struct snd_soc_acpi_link_adr tgl_3_in_1_sdca_mono[] = {
+	{
+		.mask = BIT(0),
+		.num_adr = ARRAY_SIZE(rt711_sdca_0_adr),
+		.adr_d = rt711_sdca_0_adr,
+	},
+	{
+		.mask = BIT(1),
+		.num_adr = ARRAY_SIZE(rt1316_1_single_adr),
+		.adr_d = rt1316_1_single_adr,
+	},
+	{
+		.mask = BIT(3),
+		.num_adr = ARRAY_SIZE(rt714_3_adr),
+		.adr_d = rt714_3_adr,
+	},
+	{}
+};
+
 static const struct snd_soc_acpi_codecs tgl_max98373_amp = {
 	.num_codecs = 1,
 	.codecs = {"MX98373"}
@@ -418,6 +446,19 @@ struct snd_soc_acpi_mach snd_soc_acpi_intel_tgl_sdw_machines[] = {
 		.drv_name = "sof_sdw",
 		.sof_tplg_filename = "sof-tgl-rt711-rt1316-rt714.tplg",
 	},
+	{
+		/*
+		 * link_mask should be 0xB, but all links are enabled by BIOS.
+		 * This entry will be selected if there is no rt1316 amplifier exposed
+		 * on link2 since it will fail to match the above entry.
+		 */
+
+		.link_mask = 0xF, /* 4 active links required */
+		.links = tgl_3_in_1_sdca_mono,
+		.drv_name = "sof_sdw",
+		.sof_tplg_filename = "sof-tgl-rt711-l0-rt1316-l1-mono-rt714-l3.tplg",
+	},
+
 	{
 		.link_mask = 0x3, /* rt711 on link 0 and 1 rt1308 on link 1 */
 		.links = tgl_hp,
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH 5/5] ASoC: Intel: sof_sdw: add missing quirk for Dell SKU 0A45
  2021-10-04 21:35 [PATCH 0/5] ASoC: Intel: machine driver updates for 5.16 Pierre-Louis Bossart
                   ` (3 preceding siblings ...)
  2021-10-04 21:35 ` [PATCH 4/5] ASoC: Intel: soc-acpi: add missing quirk for TGL SDCA single amp Pierre-Louis Bossart
@ 2021-10-04 21:35 ` Pierre-Louis Bossart
  2021-10-05 15:37 ` [PATCH 0/5] ASoC: Intel: machine driver updates for 5.16 Mark Brown
  5 siblings, 0 replies; 11+ messages in thread
From: Pierre-Louis Bossart @ 2021-10-04 21:35 UTC (permalink / raw)
  To: alsa-devel; +Cc: tiwai, broonie, Pierre-Louis Bossart, Bard Liao, Rander Wang

This device is based on SDCA codecs but with a single amplifier
instead of two.

BugLink: https://github.com/thesofproject/linux/issues/3161
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Reviewed-by: Rander Wang <rander.wang@intel.com>
Reviewed-by: Bard Liao <bard.liao@intel.com>
---
 sound/soc/intel/boards/sof_sdw.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/sound/soc/intel/boards/sof_sdw.c b/sound/soc/intel/boards/sof_sdw.c
index 6b06248a9327..f10496206cee 100644
--- a/sound/soc/intel/boards/sof_sdw.c
+++ b/sound/soc/intel/boards/sof_sdw.c
@@ -213,6 +213,16 @@ static const struct dmi_system_id sof_sdw_quirk_table[] = {
 					SOF_RT715_DAI_ID_FIX |
 					SOF_SDW_FOUR_SPK),
 	},
+	{
+		.callback = sof_sdw_quirk_cb,
+		.matches = {
+			DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc"),
+			DMI_EXACT_MATCH(DMI_PRODUCT_SKU, "0A45")
+		},
+		.driver_data = (void *)(SOF_SDW_TGL_HDMI |
+					RT711_JD2 |
+					SOF_RT715_DAI_ID_FIX),
+	},
 	/* AlderLake devices */
 	{
 		.callback = sof_sdw_quirk_cb,
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* Re: [PATCH 0/5] ASoC: Intel: machine driver updates for 5.16
  2021-10-04 21:35 [PATCH 0/5] ASoC: Intel: machine driver updates for 5.16 Pierre-Louis Bossart
                   ` (4 preceding siblings ...)
  2021-10-04 21:35 ` [PATCH 5/5] ASoC: Intel: sof_sdw: add missing quirk for Dell SKU 0A45 Pierre-Louis Bossart
@ 2021-10-05 15:37 ` Mark Brown
  5 siblings, 0 replies; 11+ messages in thread
From: Mark Brown @ 2021-10-05 15:37 UTC (permalink / raw)
  To: Pierre-Louis Bossart, alsa-devel; +Cc: tiwai, Mark Brown

On Mon, 4 Oct 2021 16:35:07 -0500, Pierre-Louis Bossart wrote:
> One quirk for a Dell TigerLake/SoundWire device, and initial support
> for platforms based on the ES8336 codec (aka ES8316). For full
> functionality, an update of the codec driver will be needed.
> 
> Pierre-Louis Bossart (5):
>   ASoC: Intel: soc-acpi: apl/glk/tgl: add entry for devices based on
>     ES8336 codec
>   ALSA: intel-dsp-config: add quirk for APL/GLK/TGL devices based on
>     ES8336 codec
>   ASoC: Intel: add machine driver for SOF+ES8336
>   ASoC: Intel: soc-acpi: add missing quirk for TGL SDCA single amp
>   ASoC: Intel: sof_sdw: add missing quirk for Dell SKU 0A45
> 
> [...]

Applied to

   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next

Thanks!

[1/5] ASoC: Intel: soc-acpi: apl/glk/tgl: add entry for devices based on ES8336 codec
      commit: 790049fb6623af8bc25d63b1c5103bbd51f95d89
[2/5] ALSA: intel-dsp-config: add quirk for APL/GLK/TGL devices based on ES8336 codec
      commit: 9d36ceab94151f07cf3fcb067213ac87937adf12
[3/5] ASoC: Intel: add machine driver for SOF+ES8336
      commit: a164137ce91a95a1a5e2f2ca381741aa5ba14b63
[4/5] ASoC: Intel: soc-acpi: add missing quirk for TGL SDCA single amp
      commit: f2470679b070a77ea22f8b791fae7084c2340c7d
[5/5] ASoC: Intel: sof_sdw: add missing quirk for Dell SKU 0A45
      commit: 64ba6d2ce72ffde70dc5a1794917bf1573203716

All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying
to this mail.

Thanks,
Mark

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 3/5] ASoC: Intel: add machine driver for SOF+ES8336
  2021-10-04 21:35 ` [PATCH 3/5] ASoC: Intel: add machine driver for SOF+ES8336 Pierre-Louis Bossart
@ 2021-11-21 19:00   ` Mauro Carvalho Chehab
  2021-11-22 16:45     ` Pierre-Louis Bossart
  0 siblings, 1 reply; 11+ messages in thread
From: Mauro Carvalho Chehab @ 2021-11-21 19:00 UTC (permalink / raw)
  To: Pierre-Louis Bossart, Bard Liao
  Cc: tiwai, alsa-devel, broonie, Huajun Li, Kai Vehmanen

Hi,

Em Mon,  4 Oct 2021 16:35:10 -0500
Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com> escreveu:

> Add machine driver to support APL/GLK/TGL platforms.
> The TGL platform supports DMIC, APL and GLK do not.

I just bought a Comet Lake notebook with ES8336, but I'm having a hard
time to make audio work on it.

some info about the system from dmidecode:

    BIOS Information
	Vendor: HUAWEI
	Version: 1.35
	Release Date: 06/23/2021
    System Information
        Manufacturer: HUAWEI
        Product Name: BOHB-WAX9
        Version: M1110
    Base Board Information
        Manufacturer: HUAWEI
        Product Name: BOHB-WAX9-PCB-B2
        Version: M1110

Some relevant data from DSDT:

	 * Original Table Header:
	 *     Signature        "DSDT"
	 *     Length           0x00033D35 (212277)
	 *     Revision         0x02
	 *     Checksum         0x38
	 *     OEM ID           "HUAWEI"
	 *     OEM Table ID     "CML-ULT"
	 *     OEM Revision     0x00000002 (2)
	 *     Compiler ID      "    "
	 *     Compiler Version 0x01000013 (16777235)

        Device (ESSX)
        {
            Name (_ADR, Zero)  // _ADR: Address
            Name (_HID, "ESSX8336")  // _HID: Hardware ID
            Name (_CID, "ESSX8336")  // _CID: Compatible ID
            Name (_DDN, "ES8336")  // _DDN: DOS Device Name
            Name (_UID, One)  // _UID: Unique ID
            Name (SBUF, ResourceTemplate ()
            {
                I2cSerialBusV2 (0x0010, ControllerInitiated, 0x00061A80,
                    AddressingMode7Bit, "\\_SB.PCI0.I2C1",
                    0x00, ResourceConsumer, , Exclusive,
                    )
                GpioIo (Exclusive, PullDefault, 0x0000, 0x0000, IoRestrictionOutputOnly,
                    "\\_SB.PCI0.GPI0", 0x00, ResourceConsumer, ,
                    )
                    {   // Pin list
                        0x0000
                    }
                GpioIo (Exclusive, PullDefault, 0x0000, 0x0000, IoRestrictionOutputOnly,
                    "\\_SB.PCI0.GPI0", 0x00, ResourceConsumer, ,
                    )
                    {   // Pin list
                        0x0000
                    }
                GpioInt (Edge, ActiveHigh, ExclusiveAndWake, PullDefault, 0x0000,
                    "\\_SB.PCI0.GPI0", 0x00, ResourceConsumer, ,
                    )
                    {   // Pin list
                        0x0000
                    }
            })


lpci output:

    00:1f.3 Multimedia audio controller [0401]: Intel Corporation Comet Lake PCH-LP cAVS [8086:02c8]
	Subsystem: QUANTA Computer Inc Device [152d:125d]
	Flags: bus master, fast devsel, latency 32, IRQ 149
	Memory at b121c000 (64-bit, non-prefetchable) [size=16K]
	Memory at b1000000 (64-bit, non-prefetchable) [size=1M]
	Capabilities: [50] Power Management version 3
	Capabilities: [80] Vendor Specific Information: Len=14 <?>
	Capabilities: [60] MSI: Enable+ Count=1/1 Maskable- 64bit+
	Kernel driver in use: sof-audio-pci-intel-cnl
	Kernel modules: snd_hda_intel, snd_soc_skl, snd_sof_pci_intel_cnl

So far I was unable to make speaker/mic to work on it on none of the
tree modes (SOF, SST, legacy). With SST, nothing is recognized.
With legacy mode, only HDMI works. With SOF, it says sound is disabled.

On SOF mode, sof-essx8336 doesn't load (it loads instead snd_soc_es8316).
While I never played with SOF, I suspect that it is because there's 
no entry for ES8336 at soc-acpi-intel-cml-match.c nor there are any 
firmwares for CML available at upstream sof-bin tree.

Also, it currently complains about different firmware ABIs:

[    9.547277] sof-audio-pci-intel-cnl 0000:00:1f.3: Firmware info: version 1:9:0-fa857
[    9.547313] sof-audio-pci-intel-cnl 0000:00:1f.3: Firmware: ABI 3:19:0 Kernel ABI 3:18:0
[    9.547316] sof-audio-pci-intel-cnl 0000:00:1f.3: warn: FW ABI is more recent than kernel
[    9.577525] sof-audio-pci-intel-cnl 0000:00:1f.3: Topology: ABI 3:19:0 Kernel ABI 3:18:0
[    9.577536] sof-audio-pci-intel-cnl 0000:00:1f.3: warn: topology ABI is more recent than kernel
[    9.617573] input: sof-hda-dsp HDMI/DP,pcm=1 as /devices/pci0000:00/0000:00:1f.3/skl_hda_dsp_generic/sound/card0/input14
[    9.622472] input: sof-hda-dsp HDMI/DP,pcm=2 as /devices/pci0000:00/0000:00:1f.3/skl_hda_dsp_generic/sound/card0/input15
[    9.623151] input: sof-hda-dsp HDMI/DP,pcm=3 as /devices/pci0000:00/0000:00:1f.3/skl_hda_dsp_generic/sound/card0/input16

Any tips to make it start producing some sound?

More details at:
	https://alsa-project.org/db/?f=29b323d31ab516c5683356f5af56a2a631085bf9

PS.: Tests were done against next-20211118.

Thanks!
Mauro

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 3/5] ASoC: Intel: add machine driver for SOF+ES8336
  2021-11-21 19:00   ` Mauro Carvalho Chehab
@ 2021-11-22 16:45     ` Pierre-Louis Bossart
  2021-12-23 11:45       ` Mauro Carvalho Chehab
  0 siblings, 1 reply; 11+ messages in thread
From: Pierre-Louis Bossart @ 2021-11-22 16:45 UTC (permalink / raw)
  To: Mauro Carvalho Chehab, Bard Liao
  Cc: tiwai, alsa-devel, broonie, Huajun Li, Kai Vehmanen


Hi Mauro,

>> Add machine driver to support APL/GLK/TGL platforms.
>> The TGL platform supports DMIC, APL and GLK do not.
> 
> I just bought a Comet Lake notebook with ES8336, but I'm having a hard
> time to make audio work on it.

Yes, we're aware of this design and we've tried to help. There's a
series of devices based on this I2C/I2S device, which is the exception
to the rule that all Windows-based designs are based on HDaudio or
SoundWire. Intel wasn't informed of this device so we we've added quirks
device after device, as bug reports came in.

The CometLake enablement is tracked at
https://github.com/thesofproject/linux/issues/3248

I will upstream the two quirks for CometLake later today.

The latest hacky recipe to get the driver to probe is at
https://github.com/thesofproject/linux/pull/3107

There is still work to do for the 'topology' part. The comment
https://github.com/thesofproject/linux/issues/3248#issuecomment-959573378 has
a tar file with 3 possible options for the I2S/SSP connection.

The remaining part will be the codec driver, which is problematic for
now, we're still waiting for updates from the vendor and it's unclear
if/when they will be submitted.

Hope this helps
-Pierre


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 3/5] ASoC: Intel: add machine driver for SOF+ES8336
  2021-11-22 16:45     ` Pierre-Louis Bossart
@ 2021-12-23 11:45       ` Mauro Carvalho Chehab
  2021-12-23 12:38         ` Mauro Carvalho Chehab
  0 siblings, 1 reply; 11+ messages in thread
From: Mauro Carvalho Chehab @ 2021-12-23 11:45 UTC (permalink / raw)
  To: Pierre-Louis Bossart
  Cc: alsa-devel, Kai Vehmanen, tiwai, Huajun Li, broonie, Bard Liao

Hi Pierre-Louis,

Em Mon, 22 Nov 2021 10:45:35 -0600
Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com> escreveu:

> Hi Mauro,
> 
> >> Add machine driver to support APL/GLK/TGL platforms.
> >> The TGL platform supports DMIC, APL and GLK do not.  
> > 
> > I just bought a Comet Lake notebook with ES8336, but I'm having a hard
> > time to make audio work on it.  
> 
> Yes, we're aware of this design and we've tried to help. There's a
> series of devices based on this I2C/I2S device, which is the exception
> to the rule that all Windows-based designs are based on HDaudio or
> SoundWire. Intel wasn't informed of this device so we we've added quirks
> device after device, as bug reports came in.
> 
> The CometLake enablement is tracked at
> https://github.com/thesofproject/linux/issues/3248
> 
> I will upstream the two quirks for CometLake later today.
> 
> The latest hacky recipe to get the driver to probe is at
> https://github.com/thesofproject/linux/pull/3107
> 
> There is still work to do for the 'topology' part. The comment
> https://github.com/thesofproject/linux/issues/3248#issuecomment-959573378 has
> a tar file with 3 possible options for the I2S/SSP connection.
> 
> The remaining part will be the codec driver, which is problematic for
> now, we're still waiting for updates from the vendor and it's unclear
> if/when they will be submitted.

Sorry for taking a long time to answer. I lost access to the notebook,
due to a travel.

I applied all "es8336" branches from your tree altogether:

	8af10fc5d7f4 (HEAD) Merge remote-tracking branch 'plbossart/fix/es8336-codec' into HEAD
	f47dc3daf1da Merge remote-tracking branch 'plbossart/fix/es8336-cml' into HEAD
	b8df4ae02c0a Merge remote-tracking branch 'plbossart/fix/es8336-acpi-hid' into HEAD
	5e149dc4d6e9 (plbossart/fix/sof-es8336-quirk) fixup! ALSA: intel-nhlt: add helper to detect SSP link mask

Unfortunately, it is failing to modprobe the SOF driver:

[    3.479810] snd_hda_intel 0000:00:1f.3: DSP detected with PCI class/subclass/prog-if info 0x040100
[    3.479828] snd_hda_intel 0000:00:1f.3: Digital mics found on Skylake+ platform, using SOF driver
[    3.479830] [681] snd_hda_intel 0000:00:1f.3: HDAudio driver not selected, aborting probe
[    3.655569] snd_soc_skl 0000:00:1f.3: DSP detected with PCI class/subclass/prog-if info 0x040100
[    3.655587] snd_soc_skl 0000:00:1f.3: Digital mics found on Skylake+ platform, using SOF driver
[    3.706810] RPC: Registered named UNIX socket transport module.
[    3.730708] sof-audio-pci-intel-cnl 0000:00:1f.3: DSP detected with PCI class/subclass/prog-if info 0x040100
[    3.730728] sof-audio-pci-intel-cnl 0000:00:1f.3: Digital mics found on Skylake+ platform, using SOF driver
[    3.730952] sof-audio-pci-intel-cnl 0000:00:1f.3: enabling device (0000 -> 0002)
[    3.731103] sof-audio-pci-intel-cnl 0000:00:1f.3: DSP detected with PCI class/subclass/prog-if 0x040100
[    3.731204] sof-audio-pci-intel-cnl 0000:00:1f.3: bound 0000:00:02.0 (ops i915_audio_component_bind_ops [i915])
[    3.741143] sof-audio-pci-intel-cnl 0000:00:1f.3: use msi interrupt mode
[    3.791894] [80] sof-audio-pci-intel-cnl 0000:00:1f.3: intel_nhlt_get_dmic_geo: found 2 format definitions
[    3.791898] [80] sof-audio-pci-intel-cnl 0000:00:1f.3: intel_nhlt_get_dmic_geo: max channels found 2
[    3.791900] [80] sof-audio-pci-intel-cnl 0000:00:1f.3: intel_nhlt_get_dmic_geo: Array with 2 dmics
[    3.791902] [80] sof-audio-pci-intel-cnl 0000:00:1f.3: intel_nhlt_get_dmic_geo: dmic number 2 max_ch 2
[    3.791904] sof-audio-pci-intel-cnl 0000:00:1f.3: hda codecs found, mask 4
[    3.793102] sof-audio-pci-intel-cnl 0000:00:1f.3: Firmware info: version 1:9:2-e096c
[    3.793108] sof-audio-pci-intel-cnl 0000:00:1f.3: Firmware: ABI 3:20:0 Kernel ABI 3:18:0
[    3.793110] sof-audio-pci-intel-cnl 0000:00:1f.3: warn: FW ABI is more recent than kernel
[    3.793114] sof-audio-pci-intel-cnl 0000:00:1f.3: unknown sof_ext_man header type 3 size 0x30
[    3.852602] Bluetooth: BNEP socket layer initialized
[    3.891581] sof-audio-pci-intel-cnl 0000:00:1f.3: Firmware info: version 1:9:2-e096c
[    3.891585] sof-audio-pci-intel-cnl 0000:00:1f.3: Firmware: ABI 3:20:0 Kernel ABI 3:18:0
[    3.891588] sof-audio-pci-intel-cnl 0000:00:1f.3: warn: FW ABI is more recent than kernel
[    3.901310] sof-essx8336 sof-essx8336: quirk SSP2
[    3.903162] sof-audio-pci-intel-cnl 0000:00:1f.3: Topology: ABI 3:20:0 Kernel ABI 3:18:0
[    3.903167] sof-audio-pci-intel-cnl 0000:00:1f.3: warn: topology ABI is more recent than kernel
[    3.903180] sof-audio-pci-intel-cnl 0000:00:1f.3: error: can't connect DAI SSP0.OUT stream SSP0-Codec
[    3.903182] sof-audio-pci-intel-cnl 0000:00:1f.3: error: failed to add widget id 0 type 27 name : SSP0.OUT stream SSP0-Codec
[    3.903184] sof-essx8336 sof-essx8336: ASoC: failed to load widget SSP0.OUT
[    3.903185] sof-essx8336 sof-essx8336: ASoC: topology: could not load header: -22
[    3.903187] sof-audio-pci-intel-cnl 0000:00:1f.3: error: tplg component load failed -22
[    3.903191] sof-audio-pci-intel-cnl 0000:00:1f.3: error: failed to load DSP topology -22
[    3.903193] sof-audio-pci-intel-cnl 0000:00:1f.3: ASoC: error at snd_soc_component_probe on 0000:00:1f.3: -22
[    3.903201] sof-essx8336 sof-essx8336: ASoC: failed to instantiate card -22
[    3.903302] sof-essx8336 sof-essx8336: snd_soc_register_card failed: -22
[    3.903304] sof-essx8336: probe of sof-essx8336 failed with error -22

Any hints about how to fix the topology issues on it?

Thanks,
Mauro

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 3/5] ASoC: Intel: add machine driver for SOF+ES8336
  2021-12-23 11:45       ` Mauro Carvalho Chehab
@ 2021-12-23 12:38         ` Mauro Carvalho Chehab
  0 siblings, 0 replies; 11+ messages in thread
From: Mauro Carvalho Chehab @ 2021-12-23 12:38 UTC (permalink / raw)
  To: Pierre-Louis Bossart
  Cc: alsa-devel, Kai Vehmanen, tiwai, Huajun Li, broonie, Bard Liao

Em Thu, 23 Dec 2021 12:45:15 +0100
Mauro Carvalho Chehab <mchehab@kernel.org> escreveu:

> Hi Pierre-Louis,
> 
> Em Mon, 22 Nov 2021 10:45:35 -0600
> Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com> escreveu:
> 
> > Hi Mauro,
> > 
> > >> Add machine driver to support APL/GLK/TGL platforms.
> > >> The TGL platform supports DMIC, APL and GLK do not.  
> > > 
> > > I just bought a Comet Lake notebook with ES8336, but I'm having a hard
> > > time to make audio work on it.  
> > 
> > Yes, we're aware of this design and we've tried to help. There's a
> > series of devices based on this I2C/I2S device, which is the exception
> > to the rule that all Windows-based designs are based on HDaudio or
> > SoundWire. Intel wasn't informed of this device so we we've added quirks
> > device after device, as bug reports came in.
> > 
> > The CometLake enablement is tracked at
> > https://github.com/thesofproject/linux/issues/3248
> > 
> > I will upstream the two quirks for CometLake later today.
> > 
> > The latest hacky recipe to get the driver to probe is at
> > https://github.com/thesofproject/linux/pull/3107
> > 
> > There is still work to do for the 'topology' part. The comment
> > https://github.com/thesofproject/linux/issues/3248#issuecomment-959573378 has
> > a tar file with 3 possible options for the I2S/SSP connection.
> > 
> > The remaining part will be the codec driver, which is problematic for
> > now, we're still waiting for updates from the vendor and it's unclear
> > if/when they will be submitted.
> 
> Sorry for taking a long time to answer. I lost access to the notebook,
> due to a travel.
> 
> I applied all "es8336" branches from your tree altogether:
> 
> 	8af10fc5d7f4 (HEAD) Merge remote-tracking branch 'plbossart/fix/es8336-codec' into HEAD
> 	f47dc3daf1da Merge remote-tracking branch 'plbossart/fix/es8336-cml' into HEAD
> 	b8df4ae02c0a Merge remote-tracking branch 'plbossart/fix/es8336-acpi-hid' into HEAD
> 	5e149dc4d6e9 (plbossart/fix/sof-es8336-quirk) fixup! ALSA: intel-nhlt: add helper to detect SSP link mask
> 
> Unfortunately, it is failing to modprobe the SOF driver:
> 
> [    3.479810] snd_hda_intel 0000:00:1f.3: DSP detected with PCI class/subclass/prog-if info 0x040100
> [    3.479828] snd_hda_intel 0000:00:1f.3: Digital mics found on Skylake+ platform, using SOF driver
> [    3.479830] [681] snd_hda_intel 0000:00:1f.3: HDAudio driver not selected, aborting probe
> [    3.655569] snd_soc_skl 0000:00:1f.3: DSP detected with PCI class/subclass/prog-if info 0x040100
> [    3.655587] snd_soc_skl 0000:00:1f.3: Digital mics found on Skylake+ platform, using SOF driver
> [    3.706810] RPC: Registered named UNIX socket transport module.
> [    3.730708] sof-audio-pci-intel-cnl 0000:00:1f.3: DSP detected with PCI class/subclass/prog-if info 0x040100
> [    3.730728] sof-audio-pci-intel-cnl 0000:00:1f.3: Digital mics found on Skylake+ platform, using SOF driver
> [    3.730952] sof-audio-pci-intel-cnl 0000:00:1f.3: enabling device (0000 -> 0002)
> [    3.731103] sof-audio-pci-intel-cnl 0000:00:1f.3: DSP detected with PCI class/subclass/prog-if 0x040100
> [    3.731204] sof-audio-pci-intel-cnl 0000:00:1f.3: bound 0000:00:02.0 (ops i915_audio_component_bind_ops [i915])
> [    3.741143] sof-audio-pci-intel-cnl 0000:00:1f.3: use msi interrupt mode
> [    3.791894] [80] sof-audio-pci-intel-cnl 0000:00:1f.3: intel_nhlt_get_dmic_geo: found 2 format definitions
> [    3.791898] [80] sof-audio-pci-intel-cnl 0000:00:1f.3: intel_nhlt_get_dmic_geo: max channels found 2
> [    3.791900] [80] sof-audio-pci-intel-cnl 0000:00:1f.3: intel_nhlt_get_dmic_geo: Array with 2 dmics
> [    3.791902] [80] sof-audio-pci-intel-cnl 0000:00:1f.3: intel_nhlt_get_dmic_geo: dmic number 2 max_ch 2
> [    3.791904] sof-audio-pci-intel-cnl 0000:00:1f.3: hda codecs found, mask 4
> [    3.793102] sof-audio-pci-intel-cnl 0000:00:1f.3: Firmware info: version 1:9:2-e096c
> [    3.793108] sof-audio-pci-intel-cnl 0000:00:1f.3: Firmware: ABI 3:20:0 Kernel ABI 3:18:0
> [    3.793110] sof-audio-pci-intel-cnl 0000:00:1f.3: warn: FW ABI is more recent than kernel
> [    3.793114] sof-audio-pci-intel-cnl 0000:00:1f.3: unknown sof_ext_man header type 3 size 0x30
> [    3.852602] Bluetooth: BNEP socket layer initialized
> [    3.891581] sof-audio-pci-intel-cnl 0000:00:1f.3: Firmware info: version 1:9:2-e096c
> [    3.891585] sof-audio-pci-intel-cnl 0000:00:1f.3: Firmware: ABI 3:20:0 Kernel ABI 3:18:0
> [    3.891588] sof-audio-pci-intel-cnl 0000:00:1f.3: warn: FW ABI is more recent than kernel
> [    3.901310] sof-essx8336 sof-essx8336: quirk SSP2
> [    3.903162] sof-audio-pci-intel-cnl 0000:00:1f.3: Topology: ABI 3:20:0 Kernel ABI 3:18:0
> [    3.903167] sof-audio-pci-intel-cnl 0000:00:1f.3: warn: topology ABI is more recent than kernel
> [    3.903180] sof-audio-pci-intel-cnl 0000:00:1f.3: error: can't connect DAI SSP0.OUT stream SSP0-Codec
> [    3.903182] sof-audio-pci-intel-cnl 0000:00:1f.3: error: failed to add widget id 0 type 27 name : SSP0.OUT stream SSP0-Codec
> [    3.903184] sof-essx8336 sof-essx8336: ASoC: failed to load widget SSP0.OUT
> [    3.903185] sof-essx8336 sof-essx8336: ASoC: topology: could not load header: -22
> [    3.903187] sof-audio-pci-intel-cnl 0000:00:1f.3: error: tplg component load failed -22
> [    3.903191] sof-audio-pci-intel-cnl 0000:00:1f.3: error: failed to load DSP topology -22
> [    3.903193] sof-audio-pci-intel-cnl 0000:00:1f.3: ASoC: error at snd_soc_component_probe on 0000:00:1f.3: -22
> [    3.903201] sof-essx8336 sof-essx8336: ASoC: failed to instantiate card -22
> [    3.903302] sof-essx8336 sof-essx8336: snd_soc_register_card failed: -22
> [    3.903304] sof-essx8336: probe of sof-essx8336 failed with error -22
> 
> Any hints about how to fix the topology issues on it?

Adding a quirk to modprobe partially solved the issue:

	https://github.com/thesofproject/linux/issues/3248#issuecomment-1000275241

With that, the speaker is now working fine, but microphone is marked
as unavailable, and headphones aren't working yet.

Thanks,
Mauro

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2021-12-23 12:39 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-04 21:35 [PATCH 0/5] ASoC: Intel: machine driver updates for 5.16 Pierre-Louis Bossart
2021-10-04 21:35 ` [PATCH 1/5] ASoC: Intel: soc-acpi: apl/glk/tgl: add entry for devices based on ES8336 codec Pierre-Louis Bossart
2021-10-04 21:35 ` [PATCH 2/5] ALSA: intel-dsp-config: add quirk for APL/GLK/TGL " Pierre-Louis Bossart
2021-10-04 21:35 ` [PATCH 3/5] ASoC: Intel: add machine driver for SOF+ES8336 Pierre-Louis Bossart
2021-11-21 19:00   ` Mauro Carvalho Chehab
2021-11-22 16:45     ` Pierre-Louis Bossart
2021-12-23 11:45       ` Mauro Carvalho Chehab
2021-12-23 12:38         ` Mauro Carvalho Chehab
2021-10-04 21:35 ` [PATCH 4/5] ASoC: Intel: soc-acpi: add missing quirk for TGL SDCA single amp Pierre-Louis Bossart
2021-10-04 21:35 ` [PATCH 5/5] ASoC: Intel: sof_sdw: add missing quirk for Dell SKU 0A45 Pierre-Louis Bossart
2021-10-05 15:37 ` [PATCH 0/5] ASoC: Intel: machine driver updates for 5.16 Mark Brown

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.