diff --git a/0402-ASoC-es8316-Add-power-management.patch b/0400-ASoC-es8316-Add-power-management.patch similarity index 90% rename from 0402-ASoC-es8316-Add-power-management.patch rename to 0400-ASoC-es8316-Add-power-management.patch index 358cf24..532ddc9 100644 --- a/0402-ASoC-es8316-Add-power-management.patch +++ b/0400-ASoC-es8316-Add-power-management.patch @@ -1,14 +1,14 @@ -From 92e9381554cebe67ca4311812031561e545faa97 Mon Sep 17 00:00:00 2001 +From 617e76cb4dd7bcdff475d6c4ca25f047cdc0e509 Mon Sep 17 00:00:00 2001 From: Vasily Vinogradov Date: Sat, 9 Jul 2022 13:51:27 +0300 -Subject: [PATCH 402/403] ASoC: es8316: Add power management +Subject: [PATCH 400/424] ASoC: es8316: Add power management --- sound/soc/codecs/es8316.c | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/sound/soc/codecs/es8316.c b/sound/soc/codecs/es8316.c -index 8f30a3ea8..c63f3b300 100644 +index 5fb02635c..dfc967277 100644 --- a/sound/soc/codecs/es8316.c +++ b/sound/soc/codecs/es8316.c @@ -728,6 +728,8 @@ static int es8316_probe(struct snd_soc_component *component) @@ -73,7 +73,7 @@ index 8f30a3ea8..c63f3b300 100644 }; static int es8316_i2c_probe(struct i2c_client *i2c_client, -@@ -851,6 +889,7 @@ static struct i2c_driver es8316_i2c_driver = { +@@ -850,6 +888,7 @@ static struct i2c_driver es8316_i2c_driver = { .name = "es8316", .acpi_match_table = ACPI_PTR(es8316_acpi_match), .of_match_table = of_match_ptr(es8316_of_match), diff --git a/0403-ASoC-es8316-Use-increased-GPIO-debounce-time.patch b/0401-ASoC-es8316-Use-increased-GPIO-debounce-time.patch similarity index 78% rename from 0403-ASoC-es8316-Use-increased-GPIO-debounce-time.patch rename to 0401-ASoC-es8316-Use-increased-GPIO-debounce-time.patch index b9bf47e..8869976 100644 --- a/0403-ASoC-es8316-Use-increased-GPIO-debounce-time.patch +++ b/0401-ASoC-es8316-Use-increased-GPIO-debounce-time.patch @@ -1,14 +1,14 @@ -From c29a27439f1a48c7e707fd794e806f037d70a85f Mon Sep 17 00:00:00 2001 +From 2cd3afa8f4e05c11bfb730da3e637d28aeeed54e Mon Sep 17 00:00:00 2001 From: Vasily Vinogradov Date: Sat, 9 Jul 2022 13:52:51 +0300 -Subject: [PATCH 403/403] ASoC: es8316: Use increased GPIO debounce time +Subject: [PATCH 401/424] ASoC: es8316: Use increased GPIO debounce time --- sound/soc/codecs/es8316.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sound/soc/codecs/es8316.c b/sound/soc/codecs/es8316.c -index c63f3b300..9778c988e 100644 +index dfc967277..536fda946 100644 --- a/sound/soc/codecs/es8316.c +++ b/sound/soc/codecs/es8316.c @@ -553,7 +553,7 @@ static void es8316_enable_micbias_for_mic_gnd_short_detect( diff --git a/0401-ASoC-Intel-add-machine-driver-for-SOF-ES8336.patch b/0402-ASoC-Intel-add-machine-driver-for-SOF-ES8336.patch similarity index 56% rename from 0401-ASoC-Intel-add-machine-driver-for-SOF-ES8336.patch rename to 0402-ASoC-Intel-add-machine-driver-for-SOF-ES8336.patch index 80cf388..11da8b2 100644 --- a/0401-ASoC-Intel-add-machine-driver-for-SOF-ES8336.patch +++ b/0402-ASoC-Intel-add-machine-driver-for-SOF-ES8336.patch @@ -1,102 +1,29 @@ -From d337bd736a5bed33cbf6693ff5362a182ac502cd Mon Sep 17 00:00:00 2001 -From: Vasily Vinogradov -Date: Sat, 9 Jul 2022 13:48:56 +0300 -Subject: [PATCH 401/403] ASoC: Intel: add machine driver for SOF+ES8336 +From b19de4a5ef12b7858bc8e8ed16e217c4dd9febcb Mon Sep 17 00:00:00 2001 +From: Pierre-Louis Bossart +Date: Mon, 4 Oct 2021 16:35:10 -0500 +Subject: [PATCH 402/424] ASoC: Intel: add machine driver for SOF+ES8336 +Add machine driver to support APL/GLK/TGL platforms. +The TGL platform supports DMIC, APL and GLK do not. + +Co-developed-by: Huajun Li +Signed-off-by: Huajun Li +Signed-off-by: Pierre-Louis Bossart +Reviewed-by: Kai Vehmanen +Link: https://lore.kernel.org/r/20211004213512.220836-4-pierre-louis.bossart@linux.intel.com +Signed-off-by: Mark Brown --- - sound/hda/intel-dsp-config.c | 24 +- - sound/soc/codecs/es8316.c | 1 + - sound/soc/intel/boards/Kconfig | 13 + - sound/soc/intel/boards/Makefile | 2 + - sound/soc/intel/boards/sof_es8336.c | 684 ++++++++++++++++++ - .../intel/common/soc-acpi-intel-bxt-match.c | 6 + - .../intel/common/soc-acpi-intel-cml-match.c | 6 + - .../intel/common/soc-acpi-intel-glk-match.c | 7 +- - .../intel/common/soc-acpi-intel-jsl-match.c | 6 + - .../intel/common/soc-acpi-intel-tgl-match.c | 6 + - 10 files changed, 742 insertions(+), 13 deletions(-) + 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/hda/intel-dsp-config.c b/sound/hda/intel-dsp-config.c -index 4208fa8a4..f63114317 100644 ---- a/sound/hda/intel-dsp-config.c -+++ b/sound/hda/intel-dsp-config.c -@@ -249,13 +249,13 @@ static const struct config_entry config_table[] = { - } - }, - { -- .flags = FLAG_SOF | FLAG_SOF_ONLY_IF_DMIC_OR_SOUNDWIRE, -+ .flags = FLAG_SOF, - .device = 0x02c8, -+ .codec_hid = "ESSX8336", - }, - { -- .flags = FLAG_SOF, -+ .flags = FLAG_SOF | FLAG_SOF_ONLY_IF_DMIC_OR_SOUNDWIRE, - .device = 0x02c8, -- .codec_hid = "ESSX8336", - }, - /* Cometlake-H */ - { -@@ -278,14 +278,14 @@ static const struct config_entry config_table[] = { - } - }, - { -- .flags = FLAG_SOF | FLAG_SOF_ONLY_IF_DMIC_OR_SOUNDWIRE, -- .device = 0x06c8, -- }, -- { - .flags = FLAG_SOF, - .device = 0x06c8, - .codec_hid = "ESSX8336", - }, -+ { -+ .flags = FLAG_SOF | FLAG_SOF_ONLY_IF_DMIC_OR_SOUNDWIRE, -+ .device = 0x06c8, -+ }, - #endif - - /* Icelake */ -@@ -334,17 +334,17 @@ static const struct config_entry config_table[] = { - } - }, - { -- .flags = FLAG_SOF | FLAG_SOF_ONLY_IF_DMIC_OR_SOUNDWIRE, -+ .flags = FLAG_SOF, - .device = 0xa0c8, -+ .codec_hid = "ESSX8336", - }, - { - .flags = FLAG_SOF | FLAG_SOF_ONLY_IF_DMIC_OR_SOUNDWIRE, -- .device = 0x43c8, -+ .device = 0xa0c8, - }, - { -- .flags = FLAG_SOF, -- .device = 0xa0c8, -- .codec_hid = "ESSX8336", -+ .flags = FLAG_SOF | FLAG_SOF_ONLY_IF_DMIC_OR_SOUNDWIRE, -+ .device = 0x43c8, - }, - #endif - -diff --git a/sound/soc/codecs/es8316.c b/sound/soc/codecs/es8316.c -index 5fb02635c..8f30a3ea8 100644 ---- a/sound/soc/codecs/es8316.c -+++ b/sound/soc/codecs/es8316.c -@@ -840,6 +840,7 @@ MODULE_DEVICE_TABLE(of, es8316_of_match); - #ifdef CONFIG_ACPI - static const struct acpi_device_id es8316_acpi_match[] = { - {"ESSX8316", 0}, -+ {"ESSX8336", 0}, - {}, - }; - MODULE_DEVICE_TABLE(acpi, es8316_acpi_match); diff --git a/sound/soc/intel/boards/Kconfig b/sound/soc/intel/boards/Kconfig -index 61b71d6c4..a5b70ad98 100644 +index 61b71d6c4..89b6430e7 100644 --- a/sound/soc/intel/boards/Kconfig +++ b/sound/soc/intel/boards/Kconfig -@@ -511,6 +511,19 @@ config SND_SOC_INTEL_SOF_PCM512x_MACH +@@ -511,6 +511,20 @@ config SND_SOC_INTEL_SOF_PCM512x_MACH Say Y or m if you have such a device. If unsure select "N". @@ -107,6 +34,7 @@ index 61b71d6c4..a5b70ad98 100644 + 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. @@ -117,17 +45,17 @@ index 61b71d6c4..a5b70ad98 100644 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 ed21b82a4..de72ef292 100644 +index ed21b82a4..9ee8ed864 100644 --- a/sound/soc/intel/boards/Makefile +++ b/sound/soc/intel/boards/Makefile -@@ -22,6 +22,7 @@ snd-soc-sst-byt-cht-nocodec-objs := bytcht_nocodec.o +@@ -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-cml_rt1011_rt5682-objs := cml_rt1011_rt5682.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 - snd-soc-kbl_rt5663_max98927-objs := kbl_rt5663_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 @@ -138,10 +66,10 @@ index ed21b82a4..de72ef292 100644 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 000000000..dd19f2894 +index 000000000..20d577eaa --- /dev/null +++ b/sound/soc/intel/boards/sof_es8336.c -@@ -0,0 +1,684 @@ +@@ -0,0 +1,569 @@ +// SPDX-License-Identifier: GPL-2.0-only +// Copyright(c) 2021 Intel Corporation. + @@ -165,17 +93,11 @@ index 000000000..dd19f2894 +#include +#include "hda_dsp_common.h" + -+/* jd-inv + terminating entry */ -+#define MAX_NO_PROPS 2 -+ +#define SOF_ES8336_SSP_CODEC(quirk) ((quirk) & GENMASK(3, 0)) +#define SOF_ES8336_SSP_CODEC_MASK (GENMASK(3, 0)) + -+#define SOF_ES8336_SPEAKERS_EN_GPIO1_QUIRK BIT(4) ++#define SOF_ES8336_TGL_GPIO_QUIRK BIT(4) +#define SOF_ES8336_ENABLE_DMIC BIT(5) -+#define SOF_ES8336_JD_INVERTED BIT(6) -+#define SOF_ES8336_HEADPHONE_GPIO BIT(7) -+#define SOC_ES8336_HEADSET_MIC1 BIT(8) + +static unsigned long quirk; + @@ -185,7 +107,7 @@ index 000000000..dd19f2894 + +struct sof_es8336_private { + struct device *codec_dev; -+ struct gpio_desc *gpio_speakers, *gpio_headphone; ++ struct gpio_desc *gpio_pa; + struct snd_soc_jack jack; + struct list_head hdmi_pcm_list; + bool speaker_en; @@ -197,46 +119,23 @@ index 000000000..dd19f2894 + int device; +}; + -+static const struct acpi_gpio_params enable_gpio0 = { 0, 0, true }; -+static const struct acpi_gpio_params enable_gpio1 = { 1, 0, true }; -+ -+static const struct acpi_gpio_mapping acpi_speakers_enable_gpio0[] = { -+ { "speakers-enable-gpios", &enable_gpio0, 1 }, ++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_mapping acpi_speakers_enable_gpio1[] = { -+ { "speakers-enable-gpios", &enable_gpio1, 1 }, -+}; -+ -+static const struct acpi_gpio_mapping acpi_enable_both_gpios[] = { -+ { "speakers-enable-gpios", &enable_gpio0, 1 }, -+ { "headphone-enable-gpios", &enable_gpio1, 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 acpi_enable_both_gpios_rev_order[] = { -+ { "speakers-enable-gpios", &enable_gpio1, 1 }, -+ { "headphone-enable-gpios", &enable_gpio0, 1 }, -+ { } -+}; -+ -+static const struct acpi_gpio_mapping *gpio_mapping = acpi_speakers_enable_gpio0; ++static const struct acpi_gpio_mapping *gpio_mapping = acpi_es8336_gpios; + +static void log_quirks(struct device *dev) +{ -+ dev_info(dev, "quirk mask %#lx\n", quirk); -+ dev_info(dev, "quirk SSP%ld\n", SOF_ES8336_SSP_CODEC(quirk)); -+ if (quirk & SOF_ES8336_ENABLE_DMIC) -+ dev_info(dev, "quirk DMIC enabled\n"); -+ if (quirk & SOF_ES8336_SPEAKERS_EN_GPIO1_QUIRK) -+ dev_info(dev, "Speakers GPIO1 quirk enabled\n"); -+ if (quirk & SOF_ES8336_HEADPHONE_GPIO) -+ dev_info(dev, "quirk headphone GPIO enabled\n"); -+ if (quirk & SOF_ES8336_JD_INVERTED) -+ dev_info(dev, "quirk JD inverted enabled\n"); -+ if (quirk & SOC_ES8336_HEADSET_MIC1) -+ dev_info(dev, "quirk headset at mic1 port enabled\n"); ++ dev_info(dev, "quirk SSP%ld", SOF_ES8336_SSP_CODEC(quirk)); +} + +static int sof_es8316_speaker_power_event(struct snd_soc_dapm_widget *w, @@ -245,23 +144,12 @@ index 000000000..dd19f2894 + struct snd_soc_card *card = w->dapm->card; + struct sof_es8336_private *priv = snd_soc_card_get_drvdata(card); + -+ if (priv->speaker_en == !SND_SOC_DAPM_EVENT_ON(event)) -+ return 0; -+ -+ priv->speaker_en = !SND_SOC_DAPM_EVENT_ON(event); -+ + if (SND_SOC_DAPM_EVENT_ON(event)) -+ msleep(70); ++ priv->speaker_en = false; ++ else ++ priv->speaker_en = true; + -+ gpiod_set_value_cansleep(priv->gpio_speakers, priv->speaker_en); -+ -+ if (!(quirk & SOF_ES8336_HEADPHONE_GPIO)) -+ return 0; -+ -+ if (SND_SOC_DAPM_EVENT_ON(event)) -+ msleep(70); -+ -+ gpiod_set_value_cansleep(priv->gpio_headphone, priv->speaker_en); ++ gpiod_set_value_cansleep(priv->gpio_pa, priv->speaker_en); + + return 0; +} @@ -287,23 +175,18 @@ index 000000000..dd19f2894 + + /* + * There is no separate speaker output instead the speakers are muxed to -+ * the HP outputs. The mux is controlled Speaker and/or headphone switch. ++ * 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_headset_mic2_map[] = { ++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 sof_es8316_headset_mic1_map[] = { -+ {"MIC2", NULL, "Internal Mic"}, -+ {"MIC1", NULL, "Headset Mic"}, -+}; -+ +static const struct snd_soc_dapm_route dmic_map[] = { + /* digital mics */ + {"DMic", NULL, "SoC DMIC"}, @@ -377,13 +260,8 @@ index 000000000..dd19f2894 + + card->dapm.idle_bias_off = true; + -+ if (quirk & SOC_ES8336_HEADSET_MIC1) { -+ custom_map = sof_es8316_headset_mic1_map; -+ num_routes = ARRAY_SIZE(sof_es8316_headset_mic1_map); -+ } else { -+ custom_map = sof_es8316_headset_mic2_map; -+ num_routes = ARRAY_SIZE(sof_es8316_headset_mic2_map); -+ } ++ 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) @@ -416,46 +294,30 @@ index 000000000..dd19f2894 +{ + quirk = (unsigned long)id->driver_data; + -+ if (quirk & SOF_ES8336_HEADPHONE_GPIO) { -+ if (quirk & SOF_ES8336_SPEAKERS_EN_GPIO1_QUIRK) -+ gpio_mapping = acpi_enable_both_gpios; -+ else -+ gpio_mapping = acpi_enable_both_gpios_rev_order; -+ } else if (quirk & SOF_ES8336_SPEAKERS_EN_GPIO1_QUIRK) { -+ gpio_mapping = acpi_speakers_enable_gpio1; -+ } ++ if (quirk & SOF_ES8336_TGL_GPIO_QUIRK) ++ gpio_mapping = quirk_acpi_es8336_gpios; + + return 1; +} + -+/* -+ * this table should only be used to add GPIO or jack-detection quirks -+ * that cannot be detected from ACPI tables. The SSP and DMIC -+ * information are providing by the platform driver and are aligned -+ * with the topology used. -+ * -+ * If the GPIO support is missing, the quirk parameter can be used to -+ * enable speakers. In that case it's recommended to keep the SSP and DMIC -+ * information consistent, overriding the SSP and DMIC can only be done -+ * if the topology file is modified as well. -+ */ +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_SPEAKERS_EN_GPIO1_QUIRK) -+ }, -+ { -+ .callback = sof_es8336_quirk_cb, -+ .matches = { -+ DMI_MATCH(DMI_SYS_VENDOR, "HUAWEI"), -+ DMI_MATCH(DMI_BOARD_NAME, "BOHB-WAX9-PCB-B2"), -+ }, -+ .driver_data = (void *)(SOF_ES8336_HEADPHONE_GPIO | -+ SOC_ES8336_HEADSET_MIC1) ++ .driver_data = (void *)(SOF_ES8336_SSP_CODEC(0) | ++ SOF_ES8336_TGL_GPIO_QUIRK | ++ SOF_ES8336_ENABLE_DMIC) + }, + {} +}; @@ -490,7 +352,7 @@ index 000000000..dd19f2894 + } +}; + -+SND_SOC_DAILINK_DEF(es8336_codec, ++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[] = { @@ -554,8 +416,8 @@ index 000000000..dd19f2894 + goto devm_err; + + links[id].id = id; -+ links[id].codecs = es8336_codec; -+ links[id].num_codecs = ARRAY_SIZE(es8336_codec); ++ 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; @@ -657,8 +519,6 @@ index 000000000..dd19f2894 + return NULL; +} + -+static char soc_components[30]; -+ + /* i2c-:00 with HID being 8 chars */ +static char codec_name[SND_ACPI_I2C_ID_LEN]; + @@ -667,13 +527,10 @@ index 000000000..dd19f2894 + struct device *dev = &pdev->dev; + struct snd_soc_card *card; + struct snd_soc_acpi_mach *mach = pdev->dev.platform_data; -+ struct property_entry props[MAX_NO_PROPS] = {}; + struct sof_es8336_private *priv; -+ struct fwnode_handle *fwnode; + struct acpi_device *adev; + struct snd_soc_dai_link *dai_links; + struct device *codec_dev; -+ unsigned int cnt = 0; + int dmic_be_num = 0; + int hdmi_num = 3; + int ret; @@ -685,11 +542,11 @@ index 000000000..dd19f2894 + card = &sof_es8336_card; + card->dev = dev; + -+ /* check GPIO DMI quirks */ -+ dmi_check_system(sof_es8336_quirk_table); ++ if (!dmi_check_system(sof_es8336_quirk_table)) ++ quirk = SOF_ES8336_SSP_CODEC(2); + -+ if (mach->mach_params.dmic_num) -+ quirk |= SOF_ES8336_ENABLE_DMIC; ++ if (quirk & SOF_ES8336_ENABLE_DMIC) ++ dmic_be_num = 2; + + if (quirk_override != -1) { + dev_info(dev, "Overriding quirk 0x%lx => 0x%x\n", @@ -698,9 +555,6 @@ index 000000000..dd19f2894 + } + log_quirks(dev); + -+ if (quirk & SOF_ES8336_ENABLE_DMIC) -+ dmic_be_num = 2; -+ + sof_es8336_card.num_links += dmic_be_num + hdmi_num; + dai_links = sof_card_dai_links_create(dev, + SOF_ES8336_SSP_CODEC(quirk), @@ -717,13 +571,6 @@ index 000000000..dd19f2894 + "i2c-%s", acpi_dev_name(adev)); + put_device(&adev->dev); + dai_links[0].codecs->name = codec_name; -+ -+ /* also fixup codec dai name if relevant */ -+ if (!strncmp(mach->id, "ESSX8326", SND_ACPI_I2C_ID_LEN)) -+ dai_links[0].codecs->dai_name = "ES8326 HiFi"; -+ } else { -+ dev_err(dev, "Error cannot find '%s' dev\n", mach->id); -+ return -ENXIO; + } + + ret = snd_soc_fixup_dai_links_platform_name(&sof_es8336_card, @@ -731,71 +578,38 @@ index 000000000..dd19f2894 + if (ret) + return ret; + -+ codec_dev = acpi_get_first_physical_node(adev); ++ /* get speaker enable GPIO */ ++ codec_dev = bus_find_device_by_name(&i2c_bus_type, NULL, codec_name); + if (!codec_dev) + return -EPROBE_DEFER; -+ priv->codec_dev = get_device(codec_dev); + -+ if (quirk & SOF_ES8336_JD_INVERTED) -+ props[cnt++] = PROPERTY_ENTRY_BOOL("everest,jack-detect-inverted"); -+ -+ if (cnt) { -+ fwnode = fwnode_create_software_node(props, NULL); -+ if (IS_ERR(fwnode)) { -+ put_device(codec_dev); -+ return PTR_ERR(fwnode); -+ } -+ -+ ret = device_add_software_node(codec_dev, to_software_node(fwnode)); -+ -+ fwnode_handle_put(fwnode); -+ -+ if (ret) { -+ put_device(codec_dev); -+ return ret; -+ } -+ } -+ -+ /* get speaker enable GPIO */ + 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_speakers = gpiod_get_optional(codec_dev, "speakers-enable", GPIOD_OUT_LOW); -+ if (IS_ERR(priv->gpio_speakers)) { -+ ret = dev_err_probe(dev, PTR_ERR(priv->gpio_speakers), -+ "could not get speakers-enable GPIO\n"); -+ goto err_put_codec; -+ } -+ -+ priv->gpio_headphone = gpiod_get_optional(codec_dev, "headphone-enable", GPIOD_OUT_LOW); -+ if (IS_ERR(priv->gpio_headphone)) { -+ ret = dev_err_probe(dev, PTR_ERR(priv->gpio_headphone), -+ "could not get headphone-enable GPIO\n"); -+ goto err_put_codec; ++ 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); + -+ if (mach->mach_params.dmic_num > 0) { -+ snprintf(soc_components, sizeof(soc_components), -+ "cfg-dmics:%d", mach->mach_params.dmic_num); -+ card->components = soc_components; -+ } -+ + ret = devm_snd_soc_register_card(dev, card); + if (ret) { -+ gpiod_put(priv->gpio_speakers); ++ gpiod_put(priv->gpio_pa); + dev_err(dev, "snd_soc_register_card failed: %d\n", ret); -+ goto err_put_codec; ++ goto err; + } + platform_set_drvdata(pdev, &sof_es8336_card); + return 0; + -+err_put_codec: -+ device_remove_software_node(priv->codec_dev); ++err: + put_device(codec_dev); + return ret; +} @@ -805,8 +619,7 @@ index 000000000..dd19f2894 + struct snd_soc_card *card = platform_get_drvdata(pdev); + struct sof_es8336_private *priv = snd_soc_card_get_drvdata(card); + -+ gpiod_put(priv->gpio_speakers); -+ device_remove_software_node(priv->codec_dev); ++ gpiod_put(priv->gpio_pa); + put_device(priv->codec_dev); + + return 0; @@ -826,92 +639,6 @@ index 000000000..dd19f2894 +MODULE_LICENSE("GPL"); +MODULE_ALIAS("platform:sof-essx8336"); +MODULE_IMPORT_NS(SND_SOC_INTEL_HDA_DSP_COMMON); -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 576407b5d..78cfdc48a 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-cml-match.c b/sound/soc/intel/common/soc-acpi-intel-cml-match.c -index b591c6fd1..f03fcc080 100644 ---- a/sound/soc/intel/common/soc-acpi-intel-cml-match.c -+++ b/sound/soc/intel/common/soc-acpi-intel-cml-match.c -@@ -81,6 +81,12 @@ struct snd_soc_acpi_mach snd_soc_acpi_intel_cml_machines[] = { - .sof_fw_filename = "sof-cml.ri", - .sof_tplg_filename = "sof-cml-da7219-max98390.tplg", - }, -+ { -+ .id = "ESSX8336", -+ .drv_name = "sof-essx8336", -+ .sof_fw_filename = "sof-cml.ri", -+ .sof_tplg_filename = "sof-cml-es8336.tplg", -+ }, - {}, - }; - EXPORT_SYMBOL_GPL(snd_soc_acpi_intel_cml_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 da1e15119..32fff9389 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-jsl-match.c b/sound/soc/intel/common/soc-acpi-intel-jsl-match.c -index 69ff7286d..87923bcf9 100644 ---- a/sound/soc/intel/common/soc-acpi-intel-jsl-match.c -+++ b/sound/soc/intel/common/soc-acpi-intel-jsl-match.c -@@ -81,6 +81,12 @@ struct snd_soc_acpi_mach snd_soc_acpi_intel_jsl_machines[] = { - .quirk_data = &mx98360a_spk, - .sof_tplg_filename = "sof-jsl-cs42l42-mx98360a.tplg", - }, -+ { -+ .id = "ESSX8336", -+ .drv_name = "sof-essx8336", -+ .sof_fw_filename = "sof-jsl.ri", -+ .sof_tplg_filename = "sof-jsl-es8336.tplg", -+ }, - {}, - }; - EXPORT_SYMBOL_GPL(snd_soc_acpi_intel_jsl_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 c93d8019b..5f20e9d42 100644 ---- a/sound/soc/intel/common/soc-acpi-intel-tgl-match.c -+++ b/sound/soc/intel/common/soc-acpi-intel-tgl-match.c -@@ -383,6 +383,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.35.2 diff --git a/0403-ASoC-Intel-sof_es8336-add-quirk-for-Huawei-D15-2021.patch b/0403-ASoC-Intel-sof_es8336-add-quirk-for-Huawei-D15-2021.patch new file mode 100644 index 0000000..fbb324a --- /dev/null +++ b/0403-ASoC-Intel-sof_es8336-add-quirk-for-Huawei-D15-2021.patch @@ -0,0 +1,38 @@ +From 81dc2895f43053e11a5f751dda7779c7f11ed3bd Mon Sep 17 00:00:00 2001 +From: Mauro Carvalho Chehab +Date: Fri, 24 Dec 2021 14:09:50 +0100 +Subject: [PATCH 403/424] ASoC: Intel: sof_es8336: add quirk for Huawei D15 + 2021 + +Huawei D15 uses SSP_CODEC(0). + +Signed-off-by: Mauro Carvalho Chehab +Signed-off-by: Mauro Carvalho Chehab +Link: https://lore.kernel.org/r/d560a1c76edb633c37acf04a9a82518b6233a719.1640351150.git.mchehab@kernel.org +Signed-off-by: Mark Brown +--- + sound/soc/intel/boards/sof_es8336.c | 8 ++++++++ + 1 file changed, 8 insertions(+) + +diff --git a/sound/soc/intel/boards/sof_es8336.c b/sound/soc/intel/boards/sof_es8336.c +index 20d577eaa..e6d599f0c 100644 +--- a/sound/soc/intel/boards/sof_es8336.c ++++ b/sound/soc/intel/boards/sof_es8336.c +@@ -247,6 +247,14 @@ static const struct dmi_system_id sof_es8336_quirk_table[] = { + SOF_ES8336_TGL_GPIO_QUIRK | + SOF_ES8336_ENABLE_DMIC) + }, ++ { ++ .callback = sof_es8336_quirk_cb, ++ .matches = { ++ DMI_MATCH(DMI_SYS_VENDOR, "HUAWEI"), ++ DMI_MATCH(DMI_BOARD_NAME, "BOHB-WAX9-PCB-B2"), ++ }, ++ .driver_data = (void *)SOF_ES8336_SSP_CODEC(0) ++ }, + {} + }; + +-- +2.35.2 + diff --git a/0404-ASoC-Intel-sof_es8336-make-gpio-optional.patch b/0404-ASoC-Intel-sof_es8336-make-gpio-optional.patch new file mode 100644 index 0000000..ba36b84 --- /dev/null +++ b/0404-ASoC-Intel-sof_es8336-make-gpio-optional.patch @@ -0,0 +1,42 @@ +From d24c723ffe777c57037fd67a1c56956851b34ae0 Mon Sep 17 00:00:00 2001 +From: Pierre-Louis Bossart +Date: Tue, 8 Mar 2022 13:26:01 -0600 +Subject: [PATCH 404/424] ASoC: Intel: sof_es8336: make gpio optional +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Do not fail if the GPIO used for speakers is not present, at least the +headphone, headset and internal mics should work. + +Signed-off-by: Pierre-Louis Bossart +Reviewed-by: Bard Liao +Reviewed-by: Péter Ujfalusi +Link: https://lore.kernel.org/r/20220308192610.392950-12-pierre-louis.bossart@linux.intel.com +Signed-off-by: Mark Brown +--- + sound/soc/intel/boards/sof_es8336.c | 7 +++---- + 1 file changed, 3 insertions(+), 4 deletions(-) + +diff --git a/sound/soc/intel/boards/sof_es8336.c b/sound/soc/intel/boards/sof_es8336.c +index e6d599f0c..eb792bd91 100644 +--- a/sound/soc/intel/boards/sof_es8336.c ++++ b/sound/soc/intel/boards/sof_es8336.c +@@ -523,11 +523,10 @@ static int sof_es8336_probe(struct platform_device *pdev) + 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); ++ priv->gpio_pa = gpiod_get_optional(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); ++ ret = dev_err_probe(dev, PTR_ERR(priv->gpio_pa), ++ "could not get pa-enable GPIO\n"); + goto err; + } + +-- +2.35.2 + diff --git a/0405-ASoC-Intel-sof_es8336-get-codec-device-with-ACPI-ins.patch b/0405-ASoC-Intel-sof_es8336-get-codec-device-with-ACPI-ins.patch new file mode 100644 index 0000000..02b4b9b --- /dev/null +++ b/0405-ASoC-Intel-sof_es8336-get-codec-device-with-ACPI-ins.patch @@ -0,0 +1,51 @@ +From d27f0a78c42650dae9b89adf824dfbeb0adcae1b Mon Sep 17 00:00:00 2001 +From: Pierre-Louis Bossart +Date: Tue, 8 Mar 2022 13:26:02 -0600 +Subject: [PATCH 405/424] ASoC: Intel: sof_es8336: get codec device with ACPI + instead of bus search +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +We have an existing 'adev' handle from which we can find the codec +device, no need for an I2C bus search. + +This change aligns this driver will all other I2S-based machine +drivers. + +Signed-off-by: Pierre-Louis Bossart +Reviewed-by: Bard Liao +Reviewed-by: Péter Ujfalusi +Link: https://lore.kernel.org/r/20220308192610.392950-13-pierre-louis.bossart@linux.intel.com +Signed-off-by: Mark Brown +--- + sound/soc/intel/boards/sof_es8336.c | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/sound/soc/intel/boards/sof_es8336.c b/sound/soc/intel/boards/sof_es8336.c +index eb792bd91..bb4a3491d 100644 +--- a/sound/soc/intel/boards/sof_es8336.c ++++ b/sound/soc/intel/boards/sof_es8336.c +@@ -515,9 +515,10 @@ static int sof_es8336_probe(struct platform_device *pdev) + return ret; + + /* get speaker enable GPIO */ +- codec_dev = bus_find_device_by_name(&i2c_bus_type, NULL, codec_name); ++ codec_dev = acpi_get_first_physical_node(adev); + if (!codec_dev) + return -EPROBE_DEFER; ++ priv->codec_dev = get_device(codec_dev); + + ret = devm_acpi_dev_add_driver_gpios(codec_dev, gpio_mapping); + if (ret) +@@ -530,7 +531,6 @@ static int sof_es8336_probe(struct platform_device *pdev) + goto err; + } + +- priv->codec_dev = codec_dev; + INIT_LIST_HEAD(&priv->hdmi_pcm_list); + + snd_soc_card_set_drvdata(card, priv); +-- +2.35.2 + diff --git a/0406-ASoC-Intel-Revert-ASoC-Intel-sof_es8336-add-quirk-fo.patch b/0406-ASoC-Intel-Revert-ASoC-Intel-sof_es8336-add-quirk-fo.patch new file mode 100644 index 0000000..93906dd --- /dev/null +++ b/0406-ASoC-Intel-Revert-ASoC-Intel-sof_es8336-add-quirk-fo.patch @@ -0,0 +1,46 @@ +From cf87bd31e461a12f70e990316d2cd698744b60ed Mon Sep 17 00:00:00 2001 +From: Pierre-Louis Bossart +Date: Tue, 8 Mar 2022 13:26:03 -0600 +Subject: [PATCH 406/424] ASoC: Intel: Revert "ASoC: Intel: sof_es8336: add + quirk for Huawei D15 2021" +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +This reverts commit ce6a70bfce21bb4edb7c0f29ecfb0522fa34ab71. + +The next patch will add run-time detection of the required SSP and +this hard-coded quirk is not needed. + +Acked-by: Mauro Carvalho Chehab +Signed-off-by: Pierre-Louis Bossart +Reviewed-by: Bard Liao +Reviewed-by: Péter Ujfalusi +Link: https://lore.kernel.org/r/20220308192610.392950-14-pierre-louis.bossart@linux.intel.com +Signed-off-by: Mark Brown +--- + sound/soc/intel/boards/sof_es8336.c | 8 -------- + 1 file changed, 8 deletions(-) + +diff --git a/sound/soc/intel/boards/sof_es8336.c b/sound/soc/intel/boards/sof_es8336.c +index bb4a3491d..3376bd360 100644 +--- a/sound/soc/intel/boards/sof_es8336.c ++++ b/sound/soc/intel/boards/sof_es8336.c +@@ -247,14 +247,6 @@ static const struct dmi_system_id sof_es8336_quirk_table[] = { + SOF_ES8336_TGL_GPIO_QUIRK | + SOF_ES8336_ENABLE_DMIC) + }, +- { +- .callback = sof_es8336_quirk_cb, +- .matches = { +- DMI_MATCH(DMI_SYS_VENDOR, "HUAWEI"), +- DMI_MATCH(DMI_BOARD_NAME, "BOHB-WAX9-PCB-B2"), +- }, +- .driver_data = (void *)SOF_ES8336_SSP_CODEC(0) +- }, + {} + }; + +-- +2.35.2 + diff --git a/0407-ASoC-Intel-sof_es8336-use-NHLT-information-to-set-dm.patch b/0407-ASoC-Intel-sof_es8336-use-NHLT-information-to-set-dm.patch new file mode 100644 index 0000000..1886a88 --- /dev/null +++ b/0407-ASoC-Intel-sof_es8336-use-NHLT-information-to-set-dm.patch @@ -0,0 +1,125 @@ +From 7bb0f760d572b076fba4d90d3760d7d7605cae14 Mon Sep 17 00:00:00 2001 +From: Pierre-Louis Bossart +Date: Tue, 8 Mar 2022 13:26:04 -0600 +Subject: [PATCH 407/424] ASoC: Intel: sof_es8336: use NHLT information to set + dmic and SSP +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Since we see a proliferation of devices with various configurations, +we want to automatically set the DMIC and SSP information. This patch +relies on the information extracted from NHLT and partially reverts +existing DMI quirks added by commit a164137ce91a ("ASoC: Intel: add +machine driver for SOF+ES8336") + +Note that NHLT can report multiple SSPs, choosing from the +ssp_link_mask in an MSB-first manner was found experimentally to work +fine. + +The only thing that cannot be detected is the GPIO type, and users may +want to use the quirk override parameter if the 'wrong' solution is +provided. + +Tested-by: Mauro Carvalho Chehab +Signed-off-by: Pierre-Louis Bossart +Reviewed-by: Bard Liao +Reviewed-by: Péter Ujfalusi +Link: https://lore.kernel.org/r/20220308192610.392950-15-pierre-louis.bossart@linux.intel.com +Signed-off-by: Mark Brown +--- + sound/soc/intel/boards/sof_es8336.c | 56 +++++++++++++++++++++-------- + 1 file changed, 41 insertions(+), 15 deletions(-) + +diff --git a/sound/soc/intel/boards/sof_es8336.c b/sound/soc/intel/boards/sof_es8336.c +index 3376bd360..1a8680470 100644 +--- a/sound/soc/intel/boards/sof_es8336.c ++++ b/sound/soc/intel/boards/sof_es8336.c +@@ -228,24 +228,25 @@ static int sof_es8336_quirk_cb(const struct dmi_system_id *id) + return 1; + } + ++/* ++ * this table should only be used to add GPIO or jack-detection quirks ++ * that cannot be detected from ACPI tables. The SSP and DMIC ++ * information are providing by the platform driver and are aligned ++ * with the topology used. ++ * ++ * If the GPIO support is missing, the quirk parameter can be used to ++ * enable speakers. In that case it's recommended to keep the SSP and DMIC ++ * information consistent, overriding the SSP and DMIC can only be done ++ * if the topology file is modified as well. ++ */ + 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) ++ .driver_data = (void *)(SOF_ES8336_TGL_GPIO_QUIRK) + }, + {} + }; +@@ -470,11 +471,33 @@ static int sof_es8336_probe(struct platform_device *pdev) + card = &sof_es8336_card; + card->dev = dev; + +- if (!dmi_check_system(sof_es8336_quirk_table)) +- quirk = SOF_ES8336_SSP_CODEC(2); ++ /* check GPIO DMI quirks */ ++ dmi_check_system(sof_es8336_quirk_table); + +- if (quirk & SOF_ES8336_ENABLE_DMIC) +- dmic_be_num = 2; ++ if (!mach->mach_params.i2s_link_mask) { ++ dev_warn(dev, "No I2S link information provided, using SSP0. This may need to be modified with the quirk module parameter\n"); ++ } else { ++ /* ++ * Set configuration based on platform NHLT. ++ * In this machine driver, we can only support one SSP for the ++ * ES8336 link, the else-if below are intentional. ++ * In some cases multiple SSPs can be reported by NHLT, starting MSB-first ++ * seems to pick the right connection. ++ */ ++ unsigned long ssp = 0; ++ ++ if (mach->mach_params.i2s_link_mask & BIT(2)) ++ ssp = SOF_ES8336_SSP_CODEC(2); ++ else if (mach->mach_params.i2s_link_mask & BIT(1)) ++ ssp = SOF_ES8336_SSP_CODEC(1); ++ else if (mach->mach_params.i2s_link_mask & BIT(0)) ++ ssp = SOF_ES8336_SSP_CODEC(0); ++ ++ quirk |= ssp; ++ } ++ ++ if (mach->mach_params.dmic_num) ++ quirk |= SOF_ES8336_ENABLE_DMIC; + + if (quirk_override != -1) { + dev_info(dev, "Overriding quirk 0x%lx => 0x%x\n", +@@ -483,6 +506,9 @@ static int sof_es8336_probe(struct platform_device *pdev) + } + log_quirks(dev); + ++ if (quirk & SOF_ES8336_ENABLE_DMIC) ++ dmic_be_num = 2; ++ + sof_es8336_card.num_links += dmic_be_num + hdmi_num; + dai_links = sof_card_dai_links_create(dev, + SOF_ES8336_SSP_CODEC(quirk), +-- +2.35.2 + diff --git a/0408-ASoC-Intel-sof_es8336-log-all-quirks.patch b/0408-ASoC-Intel-sof_es8336-log-all-quirks.patch new file mode 100644 index 0000000..40d197f --- /dev/null +++ b/0408-ASoC-Intel-sof_es8336-log-all-quirks.patch @@ -0,0 +1,41 @@ +From 4a8534c45283718a4fcd01c031a06b49a2f47240 Mon Sep 17 00:00:00 2001 +From: Pierre-Louis Bossart +Date: Tue, 8 Mar 2022 13:26:05 -0600 +Subject: [PATCH 408/424] ASoC: Intel: sof_es8336: log all quirks +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +We only logged the SSP quirk, make sure the GPIO and DMIC quirks are +exposed. + +Signed-off-by: Pierre-Louis Bossart +Reviewed-by: Bard Liao +Reviewed-by: Péter Ujfalusi +Link: https://lore.kernel.org/r/20220308192610.392950-16-pierre-louis.bossart@linux.intel.com +Signed-off-by: Mark Brown +--- + sound/soc/intel/boards/sof_es8336.c | 7 ++++++- + 1 file changed, 6 insertions(+), 1 deletion(-) + +diff --git a/sound/soc/intel/boards/sof_es8336.c b/sound/soc/intel/boards/sof_es8336.c +index 1a8680470..e2daa5790 100644 +--- a/sound/soc/intel/boards/sof_es8336.c ++++ b/sound/soc/intel/boards/sof_es8336.c +@@ -63,7 +63,12 @@ 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)); ++ dev_info(dev, "quirk mask %#lx\n", quirk); ++ dev_info(dev, "quirk SSP%ld\n", SOF_ES8336_SSP_CODEC(quirk)); ++ if (quirk & SOF_ES8336_ENABLE_DMIC) ++ dev_info(dev, "quirk DMIC enabled\n"); ++ if (quirk & SOF_ES8336_TGL_GPIO_QUIRK) ++ dev_info(dev, "quirk TGL GPIO enabled\n"); + } + + static int sof_es8316_speaker_power_event(struct snd_soc_dapm_widget *w, +-- +2.35.2 + diff --git a/0409-ASoC-Intel-sof_es8336-move-comment-to-the-right-plac.patch b/0409-ASoC-Intel-sof_es8336-move-comment-to-the-right-plac.patch new file mode 100644 index 0000000..3470b6d --- /dev/null +++ b/0409-ASoC-Intel-sof_es8336-move-comment-to-the-right-plac.patch @@ -0,0 +1,42 @@ +From c9766db550a078f52eee43fa6ba76eae2dda948d Mon Sep 17 00:00:00 2001 +From: Pierre-Louis Bossart +Date: Tue, 8 Mar 2022 13:26:06 -0600 +Subject: [PATCH 409/424] ASoC: Intel: sof_es8336: move comment to the right + place +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Additional code was added and the comment on the speaker GPIO needs to +be moved before we actually try to get the GPIO. + +Signed-off-by: Pierre-Louis Bossart +Reviewed-by: Bard Liao +Reviewed-by: Péter Ujfalusi +Link: https://lore.kernel.org/r/20220308192610.392950-17-pierre-louis.bossart@linux.intel.com +Signed-off-by: Mark Brown +--- + sound/soc/intel/boards/sof_es8336.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/sound/soc/intel/boards/sof_es8336.c b/sound/soc/intel/boards/sof_es8336.c +index e2daa5790..d7dff61c9 100644 +--- a/sound/soc/intel/boards/sof_es8336.c ++++ b/sound/soc/intel/boards/sof_es8336.c +@@ -537,12 +537,12 @@ static int sof_es8336_probe(struct platform_device *pdev) + if (ret) + return ret; + +- /* get speaker enable GPIO */ + codec_dev = acpi_get_first_physical_node(adev); + if (!codec_dev) + return -EPROBE_DEFER; + priv->codec_dev = get_device(codec_dev); + ++ /* get speaker enable GPIO */ + ret = devm_acpi_dev_add_driver_gpios(codec_dev, gpio_mapping); + if (ret) + dev_warn(codec_dev, "unable to add GPIO mapping table\n"); +-- +2.35.2 + diff --git a/0410-ASoC-Intel-sof_es8336-add-support-for-JD-inverted-qu.patch b/0410-ASoC-Intel-sof_es8336-add-support-for-JD-inverted-qu.patch new file mode 100644 index 0000000..92a7ba0 --- /dev/null +++ b/0410-ASoC-Intel-sof_es8336-add-support-for-JD-inverted-qu.patch @@ -0,0 +1,139 @@ +From 6b88f48611fae90490e0e3faeb5e23474388b8ea Mon Sep 17 00:00:00 2001 +From: Pierre-Louis Bossart +Date: Tue, 8 Mar 2022 13:26:07 -0600 +Subject: [PATCH 410/424] ASoC: Intel: sof_es8336: add support for JD inverted + quirk +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +The codec driver exposes a set of properties that can be set from the +machine driver - as done in bytcht_es8316.c + +Start by adding the JD_INVERTED quirk. + +Signed-off-by: Pierre-Louis Bossart +Reviewed-by: Bard Liao +Reviewed-by: Péter Ujfalusi +Link: https://lore.kernel.org/r/20220308192610.392950-18-pierre-louis.bossart@linux.intel.com +Signed-off-by: Mark Brown +--- + sound/soc/intel/boards/sof_es8336.c | 40 ++++++++++++++++++++++++++--- + 1 file changed, 37 insertions(+), 3 deletions(-) + +diff --git a/sound/soc/intel/boards/sof_es8336.c b/sound/soc/intel/boards/sof_es8336.c +index d7dff61c9..932a80e62 100644 +--- a/sound/soc/intel/boards/sof_es8336.c ++++ b/sound/soc/intel/boards/sof_es8336.c +@@ -21,11 +21,15 @@ + #include + #include "hda_dsp_common.h" + ++/* jd-inv + terminating entry */ ++#define MAX_NO_PROPS 2 ++ + #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) ++#define SOF_ES8336_JD_INVERTED BIT(6) + + static unsigned long quirk; + +@@ -69,6 +73,8 @@ static void log_quirks(struct device *dev) + dev_info(dev, "quirk DMIC enabled\n"); + if (quirk & SOF_ES8336_TGL_GPIO_QUIRK) + dev_info(dev, "quirk TGL GPIO enabled\n"); ++ if (quirk & SOF_ES8336_JD_INVERTED) ++ dev_info(dev, "quirk JD inverted enabled\n"); + } + + static int sof_es8316_speaker_power_event(struct snd_soc_dapm_widget *w, +@@ -461,10 +467,13 @@ 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 property_entry props[MAX_NO_PROPS] = {}; + struct sof_es8336_private *priv; ++ struct fwnode_handle *fwnode; + struct acpi_device *adev; + struct snd_soc_dai_link *dai_links; + struct device *codec_dev; ++ unsigned int cnt = 0; + int dmic_be_num = 0; + int hdmi_num = 3; + int ret; +@@ -530,6 +539,9 @@ static int sof_es8336_probe(struct platform_device *pdev) + "i2c-%s", acpi_dev_name(adev)); + put_device(&adev->dev); + dai_links[0].codecs->name = codec_name; ++ } else { ++ dev_err(dev, "Error cannot find '%s' dev\n", mach->id); ++ return -ENXIO; + } + + ret = snd_soc_fixup_dai_links_platform_name(&sof_es8336_card, +@@ -542,6 +554,26 @@ static int sof_es8336_probe(struct platform_device *pdev) + return -EPROBE_DEFER; + priv->codec_dev = get_device(codec_dev); + ++ if (quirk & SOF_ES8336_JD_INVERTED) ++ props[cnt++] = PROPERTY_ENTRY_BOOL("everest,jack-detect-inverted"); ++ ++ if (cnt) { ++ fwnode = fwnode_create_software_node(props, NULL); ++ if (IS_ERR(fwnode)) { ++ put_device(codec_dev); ++ return PTR_ERR(fwnode); ++ } ++ ++ ret = device_add_software_node(codec_dev, to_software_node(fwnode)); ++ ++ fwnode_handle_put(fwnode); ++ ++ if (ret) { ++ put_device(codec_dev); ++ return ret; ++ } ++ } ++ + /* get speaker enable GPIO */ + ret = devm_acpi_dev_add_driver_gpios(codec_dev, gpio_mapping); + if (ret) +@@ -551,7 +583,7 @@ static int sof_es8336_probe(struct platform_device *pdev) + if (IS_ERR(priv->gpio_pa)) { + ret = dev_err_probe(dev, PTR_ERR(priv->gpio_pa), + "could not get pa-enable GPIO\n"); +- goto err; ++ goto err_put_codec; + } + + INIT_LIST_HEAD(&priv->hdmi_pcm_list); +@@ -562,12 +594,13 @@ static int sof_es8336_probe(struct platform_device *pdev) + if (ret) { + gpiod_put(priv->gpio_pa); + dev_err(dev, "snd_soc_register_card failed: %d\n", ret); +- goto err; ++ goto err_put_codec; + } + platform_set_drvdata(pdev, &sof_es8336_card); + return 0; + +-err: ++err_put_codec: ++ device_remove_software_node(priv->codec_dev); + put_device(codec_dev); + return ret; + } +@@ -578,6 +611,7 @@ static int sof_es8336_remove(struct platform_device *pdev) + struct sof_es8336_private *priv = snd_soc_card_get_drvdata(card); + + gpiod_put(priv->gpio_pa); ++ device_remove_software_node(priv->codec_dev); + put_device(priv->codec_dev); + + return 0; +-- +2.35.2 + diff --git a/0411-ASoC-Intel-sof_es8336-extend-machine-driver-to-suppo.patch b/0411-ASoC-Intel-sof_es8336-extend-machine-driver-to-suppo.patch new file mode 100644 index 0000000..780d749 --- /dev/null +++ b/0411-ASoC-Intel-sof_es8336-extend-machine-driver-to-suppo.patch @@ -0,0 +1,81 @@ +From 8e36b0949f9e542aeca53a8c34c4205b4106311e Mon Sep 17 00:00:00 2001 +From: Pierre-Louis Bossart +Date: Tue, 8 Mar 2022 13:26:08 -0600 +Subject: [PATCH 411/424] ASoC: Intel: sof_es8336: extend machine driver to + support ES8326 codec +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +The ES8326 requires a different codec driver than ES8316/8336, fixup +the codec name and dai name depending on the ACPI _HID exposed in the +DSDT. + +Also add the select in Kconfig + +Signed-off-by: Pierre-Louis Bossart +Reviewed-by: Bard Liao +Reviewed-by: Péter Ujfalusi +Link: https://lore.kernel.org/r/20220308192610.392950-19-pierre-louis.bossart@linux.intel.com +Signed-off-by: Mark Brown +--- + sound/soc/intel/boards/Kconfig | 3 ++- + sound/soc/intel/boards/sof_es8336.c | 10 +++++++--- + 2 files changed, 9 insertions(+), 4 deletions(-) + +diff --git a/sound/soc/intel/boards/Kconfig b/sound/soc/intel/boards/Kconfig +index 89b6430e7..20874faa3 100644 +--- a/sound/soc/intel/boards/Kconfig ++++ b/sound/soc/intel/boards/Kconfig +@@ -512,11 +512,12 @@ config SND_SOC_INTEL_SOF_PCM512x_MACH + If unsure select "N". + + config SND_SOC_INTEL_SOF_ES8336_MACH +- tristate "SOF with ES8336 codec in I2S mode" ++ tristate "SOF with ES8336 or ES8326 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_ES8326 + select SND_SOC_DMIC + select SND_SOC_INTEL_HDA_DSP_COMMON + help +diff --git a/sound/soc/intel/boards/sof_es8336.c b/sound/soc/intel/boards/sof_es8336.c +index 932a80e62..32f530304 100644 +--- a/sound/soc/intel/boards/sof_es8336.c ++++ b/sound/soc/intel/boards/sof_es8336.c +@@ -292,7 +292,7 @@ static struct snd_soc_dai_link_component platform_component[] = { + } + }; + +-SND_SOC_DAILINK_DEF(ssp1_codec, ++SND_SOC_DAILINK_DEF(es8336_codec, + DAILINK_COMP_ARRAY(COMP_CODEC("i2c-ESSX8336:00", "ES8316 HiFi"))); + + static struct snd_soc_dai_link_component dmic_component[] = { +@@ -356,8 +356,8 @@ static struct snd_soc_dai_link *sof_card_dai_links_create(struct device *dev, + goto devm_err; + + links[id].id = id; +- links[id].codecs = ssp1_codec; +- links[id].num_codecs = ARRAY_SIZE(ssp1_codec); ++ links[id].codecs = es8336_codec; ++ links[id].num_codecs = ARRAY_SIZE(es8336_codec); + links[id].platforms = platform_component; + links[id].num_platforms = ARRAY_SIZE(platform_component); + links[id].init = sof_es8316_init; +@@ -539,6 +539,10 @@ static int sof_es8336_probe(struct platform_device *pdev) + "i2c-%s", acpi_dev_name(adev)); + put_device(&adev->dev); + dai_links[0].codecs->name = codec_name; ++ ++ /* also fixup codec dai name if relevant */ ++ if (!strncmp(mach->id, "ESSX8326", SND_ACPI_I2C_ID_LEN)) ++ dai_links[0].codecs->dai_name = "ES8326 HiFi"; + } else { + dev_err(dev, "Error cannot find '%s' dev\n", mach->id); + return -ENXIO; +-- +2.35.2 + diff --git a/0412-ASoC-Intel-sof_es8336-add-cfg-dmics-component-for-UC.patch b/0412-ASoC-Intel-sof_es8336-add-cfg-dmics-component-for-UC.patch new file mode 100644 index 0000000..00f5325 --- /dev/null +++ b/0412-ASoC-Intel-sof_es8336-add-cfg-dmics-component-for-UC.patch @@ -0,0 +1,51 @@ +From 293fb4e7f652e1dd219b2681fd66be58d289304e Mon Sep 17 00:00:00 2001 +From: Pierre-Louis Bossart +Date: Tue, 8 Mar 2022 13:26:09 -0600 +Subject: [PATCH 412/424] ASoC: Intel: sof_es8336: add cfg-dmics component for + UCM support +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +The presence of DMICs needs to be signaled to UCM, follow the HDaudio +example and use the 'cfg-dmics' component string to report the number +of dmics present on the platform. + +Signed-off-by: Pierre-Louis Bossart +Reviewed-by: Bard Liao +Reviewed-by: Péter Ujfalusi +Link: https://lore.kernel.org/r/20220308192610.392950-20-pierre-louis.bossart@linux.intel.com +Signed-off-by: Mark Brown +--- + sound/soc/intel/boards/sof_es8336.c | 8 ++++++++ + 1 file changed, 8 insertions(+) + +diff --git a/sound/soc/intel/boards/sof_es8336.c b/sound/soc/intel/boards/sof_es8336.c +index 32f530304..5e0529aa4 100644 +--- a/sound/soc/intel/boards/sof_es8336.c ++++ b/sound/soc/intel/boards/sof_es8336.c +@@ -459,6 +459,8 @@ static struct snd_soc_dai_link *sof_card_dai_links_create(struct device *dev, + return NULL; + } + ++static char soc_components[30]; ++ + /* i2c-:00 with HID being 8 chars */ + static char codec_name[SND_ACPI_I2C_ID_LEN]; + +@@ -594,6 +596,12 @@ static int sof_es8336_probe(struct platform_device *pdev) + + snd_soc_card_set_drvdata(card, priv); + ++ if (mach->mach_params.dmic_num > 0) { ++ snprintf(soc_components, sizeof(soc_components), ++ "cfg-dmics:%d", mach->mach_params.dmic_num); ++ card->components = soc_components; ++ } ++ + ret = devm_snd_soc_register_card(dev, card); + if (ret) { + gpiod_put(priv->gpio_pa); +-- +2.35.2 + diff --git a/0413-ASoC-Intel-sof_es8336-simplify-speaker-gpio-naming.patch b/0413-ASoC-Intel-sof_es8336-simplify-speaker-gpio-naming.patch new file mode 100644 index 0000000..ae2dbc8 --- /dev/null +++ b/0413-ASoC-Intel-sof_es8336-simplify-speaker-gpio-naming.patch @@ -0,0 +1,145 @@ +From 7999ab3c637267c529b47376a02f0aa8b07c834a Mon Sep 17 00:00:00 2001 +From: Pierre-Louis Bossart +Date: Thu, 7 Apr 2022 20:49:56 +0200 +Subject: [PATCH 413/424] ASoC: Intel: sof_es8336: simplify speaker gpio naming + +In preparation for the support of an additional gpio for headphone +control, rename GPIOs to make explicit references to speakers and +gpio0 or gpio1. + +No functionality change. + +Signed-off-by: Pierre-Louis Bossart +Signed-off-by: Mauro Carvalho Chehab +Acked-by: Pierre-Louis Bossart +Link: https://lore.kernel.org/r/3008c576ca45d5cc99ad4a18d1d30de45a0aff80.1649357263.git.mchehab@kernel.org +Signed-off-by: Mark Brown +--- + sound/soc/intel/boards/sof_es8336.c | 42 ++++++++++++++--------------- + 1 file changed, 21 insertions(+), 21 deletions(-) + +diff --git a/sound/soc/intel/boards/sof_es8336.c b/sound/soc/intel/boards/sof_es8336.c +index 5e0529aa4..e4829a376 100644 +--- a/sound/soc/intel/boards/sof_es8336.c ++++ b/sound/soc/intel/boards/sof_es8336.c +@@ -27,7 +27,7 @@ + #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_SPEAKERS_EN_GPIO1_QUIRK BIT(4) + #define SOF_ES8336_ENABLE_DMIC BIT(5) + #define SOF_ES8336_JD_INVERTED BIT(6) + +@@ -39,7 +39,7 @@ MODULE_PARM_DESC(quirk, "Board-specific quirk override"); + + struct sof_es8336_private { + struct device *codec_dev; +- struct gpio_desc *gpio_pa; ++ struct gpio_desc *gpio_speakers; + struct snd_soc_jack jack; + struct list_head hdmi_pcm_list; + bool speaker_en; +@@ -51,19 +51,19 @@ struct sof_hdmi_pcm { + 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 speakers_enable_gpio0 = { 0, 0, true }; ++static const struct acpi_gpio_mapping acpi_speakers_enable_gpio0[] = { ++ { "speakers-enable-gpios", &speakers_enable_gpio0, 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_params speakers_enable_gpio1 = { 1, 0, true }; ++static const struct acpi_gpio_mapping acpi_speakers_enable_gpio1[] = { ++ { "speakers-enable-gpios", &speakers_enable_gpio1, 1 }, + { } + }; + +-static const struct acpi_gpio_mapping *gpio_mapping = acpi_es8336_gpios; ++static const struct acpi_gpio_mapping *gpio_mapping = acpi_speakers_enable_gpio0; + + static void log_quirks(struct device *dev) + { +@@ -71,8 +71,8 @@ static void log_quirks(struct device *dev) + dev_info(dev, "quirk SSP%ld\n", SOF_ES8336_SSP_CODEC(quirk)); + if (quirk & SOF_ES8336_ENABLE_DMIC) + dev_info(dev, "quirk DMIC enabled\n"); +- if (quirk & SOF_ES8336_TGL_GPIO_QUIRK) +- dev_info(dev, "quirk TGL GPIO enabled\n"); ++ if (quirk & SOF_ES8336_SPEAKERS_EN_GPIO1_QUIRK) ++ dev_info(dev, "Speakers GPIO1 quirk enabled\n"); + if (quirk & SOF_ES8336_JD_INVERTED) + dev_info(dev, "quirk JD inverted enabled\n"); + } +@@ -88,7 +88,7 @@ static int sof_es8316_speaker_power_event(struct snd_soc_dapm_widget *w, + else + priv->speaker_en = true; + +- gpiod_set_value_cansleep(priv->gpio_pa, priv->speaker_en); ++ gpiod_set_value_cansleep(priv->gpio_speakers, priv->speaker_en); + + return 0; + } +@@ -233,8 +233,8 @@ 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; ++ if (quirk & SOF_ES8336_SPEAKERS_EN_GPIO1_QUIRK) ++ gpio_mapping = acpi_speakers_enable_gpio1; + + return 1; + } +@@ -257,7 +257,7 @@ static const struct dmi_system_id sof_es8336_quirk_table[] = { + DMI_MATCH(DMI_SYS_VENDOR, "IP3 tech"), + DMI_MATCH(DMI_BOARD_NAME, "WN1"), + }, +- .driver_data = (void *)(SOF_ES8336_TGL_GPIO_QUIRK) ++ .driver_data = (void *)(SOF_ES8336_SPEAKERS_EN_GPIO1_QUIRK) + }, + {} + }; +@@ -585,10 +585,10 @@ static int sof_es8336_probe(struct platform_device *pdev) + if (ret) + dev_warn(codec_dev, "unable to add GPIO mapping table\n"); + +- priv->gpio_pa = gpiod_get_optional(codec_dev, "pa-enable", GPIOD_OUT_LOW); +- if (IS_ERR(priv->gpio_pa)) { +- ret = dev_err_probe(dev, PTR_ERR(priv->gpio_pa), +- "could not get pa-enable GPIO\n"); ++ priv->gpio_speakers = gpiod_get_optional(codec_dev, "speakers-enable", GPIOD_OUT_LOW); ++ if (IS_ERR(priv->gpio_speakers)) { ++ ret = dev_err_probe(dev, PTR_ERR(priv->gpio_speakers), ++ "could not get speakers-enable GPIO\n"); + goto err_put_codec; + } + +@@ -604,7 +604,7 @@ static int sof_es8336_probe(struct platform_device *pdev) + + ret = devm_snd_soc_register_card(dev, card); + if (ret) { +- gpiod_put(priv->gpio_pa); ++ gpiod_put(priv->gpio_speakers); + dev_err(dev, "snd_soc_register_card failed: %d\n", ret); + goto err_put_codec; + } +@@ -622,7 +622,7 @@ 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); ++ gpiod_put(priv->gpio_speakers); + device_remove_software_node(priv->codec_dev); + put_device(priv->codec_dev); + +-- +2.35.2 + diff --git a/0414-ASoC-Intel-sof_es8336-support-a-separate-gpio-to-con.patch b/0414-ASoC-Intel-sof_es8336-support-a-separate-gpio-to-con.patch new file mode 100644 index 0000000..5183bfe --- /dev/null +++ b/0414-ASoC-Intel-sof_es8336-support-a-separate-gpio-to-con.patch @@ -0,0 +1,152 @@ +From c562640395bc22cc2bb239b831bf9bb52738f4f2 Mon Sep 17 00:00:00 2001 +From: Mauro Carvalho Chehab +Date: Thu, 7 Apr 2022 20:49:57 +0200 +Subject: [PATCH 414/424] ASoC: Intel: sof_es8336: support a separate gpio to + control headphone + +Some devices may use both gpio0 and gpio1 to independently switch +the speaker and the headphone. + +Add support for that. + +Acked-by: Hans de Goede +Signed-off-by: Mauro Carvalho Chehab +Acked-by: Pierre-Louis Bossart +Link: https://lore.kernel.org/r/535454c0c598a8454487fe29b164527370e2db81.1649357263.git.mchehab@kernel.org +Signed-off-by: Mark Brown +--- + sound/soc/intel/boards/sof_es8336.c | 59 ++++++++++++++++++++++++----- + 1 file changed, 49 insertions(+), 10 deletions(-) + +diff --git a/sound/soc/intel/boards/sof_es8336.c b/sound/soc/intel/boards/sof_es8336.c +index e4829a376..d15a58666 100644 +--- a/sound/soc/intel/boards/sof_es8336.c ++++ b/sound/soc/intel/boards/sof_es8336.c +@@ -30,6 +30,7 @@ + #define SOF_ES8336_SPEAKERS_EN_GPIO1_QUIRK BIT(4) + #define SOF_ES8336_ENABLE_DMIC BIT(5) + #define SOF_ES8336_JD_INVERTED BIT(6) ++#define SOF_ES8336_HEADPHONE_GPIO BIT(7) + + static unsigned long quirk; + +@@ -39,7 +40,7 @@ MODULE_PARM_DESC(quirk, "Board-specific quirk override"); + + struct sof_es8336_private { + struct device *codec_dev; +- struct gpio_desc *gpio_speakers; ++ struct gpio_desc *gpio_speakers, *gpio_headphone; + struct snd_soc_jack jack; + struct list_head hdmi_pcm_list; + bool speaker_en; +@@ -51,15 +52,27 @@ struct sof_hdmi_pcm { + int device; + }; + +-static const struct acpi_gpio_params speakers_enable_gpio0 = { 0, 0, true }; ++static const struct acpi_gpio_params enable_gpio0 = { 0, 0, true }; ++static const struct acpi_gpio_params enable_gpio1 = { 1, 0, true }; ++ + static const struct acpi_gpio_mapping acpi_speakers_enable_gpio0[] = { +- { "speakers-enable-gpios", &speakers_enable_gpio0, 1 }, ++ { "speakers-enable-gpios", &enable_gpio0, 1 }, + { } + }; + +-static const struct acpi_gpio_params speakers_enable_gpio1 = { 1, 0, true }; + static const struct acpi_gpio_mapping acpi_speakers_enable_gpio1[] = { +- { "speakers-enable-gpios", &speakers_enable_gpio1, 1 }, ++ { "speakers-enable-gpios", &enable_gpio1, 1 }, ++}; ++ ++static const struct acpi_gpio_mapping acpi_enable_both_gpios[] = { ++ { "speakers-enable-gpios", &enable_gpio0, 1 }, ++ { "headphone-enable-gpios", &enable_gpio1, 1 }, ++ { } ++}; ++ ++static const struct acpi_gpio_mapping acpi_enable_both_gpios_rev_order[] = { ++ { "speakers-enable-gpios", &enable_gpio1, 1 }, ++ { "headphone-enable-gpios", &enable_gpio0, 1 }, + { } + }; + +@@ -73,6 +86,8 @@ static void log_quirks(struct device *dev) + dev_info(dev, "quirk DMIC enabled\n"); + if (quirk & SOF_ES8336_SPEAKERS_EN_GPIO1_QUIRK) + dev_info(dev, "Speakers GPIO1 quirk enabled\n"); ++ if (quirk & SOF_ES8336_HEADPHONE_GPIO) ++ dev_info(dev, "quirk headphone GPIO enabled\n"); + if (quirk & SOF_ES8336_JD_INVERTED) + dev_info(dev, "quirk JD inverted enabled\n"); + } +@@ -83,13 +98,24 @@ static int sof_es8316_speaker_power_event(struct snd_soc_dapm_widget *w, + struct snd_soc_card *card = w->dapm->card; + struct sof_es8336_private *priv = snd_soc_card_get_drvdata(card); + ++ if (priv->speaker_en == !SND_SOC_DAPM_EVENT_ON(event)) ++ return 0; ++ ++ priv->speaker_en = !SND_SOC_DAPM_EVENT_ON(event); ++ + if (SND_SOC_DAPM_EVENT_ON(event)) +- priv->speaker_en = false; +- else +- priv->speaker_en = true; ++ msleep(70); + + gpiod_set_value_cansleep(priv->gpio_speakers, priv->speaker_en); + ++ if (!(quirk & SOF_ES8336_HEADPHONE_GPIO)) ++ return 0; ++ ++ if (SND_SOC_DAPM_EVENT_ON(event)) ++ msleep(70); ++ ++ gpiod_set_value_cansleep(priv->gpio_headphone, priv->speaker_en); ++ + return 0; + } + +@@ -114,7 +140,7 @@ static const struct snd_soc_dapm_route sof_es8316_audio_map[] = { + + /* + * There is no separate speaker output instead the speakers are muxed to +- * the HP outputs. The mux is controlled by the "Speaker Power" supply. ++ * the HP outputs. The mux is controlled Speaker and/or headphone switch. + */ + {"Speaker", NULL, "HPOL"}, + {"Speaker", NULL, "HPOR"}, +@@ -233,8 +259,14 @@ static int sof_es8336_quirk_cb(const struct dmi_system_id *id) + { + quirk = (unsigned long)id->driver_data; + +- if (quirk & SOF_ES8336_SPEAKERS_EN_GPIO1_QUIRK) ++ if (quirk & SOF_ES8336_HEADPHONE_GPIO) { ++ if (quirk & SOF_ES8336_SPEAKERS_EN_GPIO1_QUIRK) ++ gpio_mapping = acpi_enable_both_gpios; ++ else ++ gpio_mapping = acpi_enable_both_gpios_rev_order; ++ } else if (quirk & SOF_ES8336_SPEAKERS_EN_GPIO1_QUIRK) { + gpio_mapping = acpi_speakers_enable_gpio1; ++ } + + return 1; + } +@@ -592,6 +624,13 @@ static int sof_es8336_probe(struct platform_device *pdev) + goto err_put_codec; + } + ++ priv->gpio_headphone = gpiod_get_optional(codec_dev, "headphone-enable", GPIOD_OUT_LOW); ++ if (IS_ERR(priv->gpio_headphone)) { ++ ret = dev_err_probe(dev, PTR_ERR(priv->gpio_headphone), ++ "could not get headphone-enable GPIO\n"); ++ goto err_put_codec; ++ } ++ + INIT_LIST_HEAD(&priv->hdmi_pcm_list); + + snd_soc_card_set_drvdata(card, priv); +-- +2.35.2 + diff --git a/0415-ASoC-Intel-sof_es8336-add-a-quirk-for-headset-at-mic.patch b/0415-ASoC-Intel-sof_es8336-add-a-quirk-for-headset-at-mic.patch new file mode 100644 index 0000000..9d8382f --- /dev/null +++ b/0415-ASoC-Intel-sof_es8336-add-a-quirk-for-headset-at-mic.patch @@ -0,0 +1,81 @@ +From a4ff92b5dd7b0bde469a3cafd2f5559f377c2599 Mon Sep 17 00:00:00 2001 +From: Mauro Carvalho Chehab +Date: Thu, 7 Apr 2022 20:49:58 +0200 +Subject: [PATCH 415/424] ASoC: Intel: sof_es8336: add a quirk for headset at + mic1 port + +The headset/internal mic can either be routed as mic1/mic2 +or vice-versa. + +By default, the driver assumes that the headset is mapped as +mic2, but not all devices map this way. + +So, add a quirk to support changing it to mic1, using mic2 +for the internal analog mic (if any). + +Signed-off-by: Mauro Carvalho Chehab +Acked-by: Pierre-Louis Bossart +Link: https://lore.kernel.org/r/5d88fc29b79be7ab77dae391c8e5ee929fd36c27.1649357263.git.mchehab@kernel.org +Signed-off-by: Mark Brown +--- + sound/soc/intel/boards/sof_es8336.c | 19 ++++++++++++++++--- + 1 file changed, 16 insertions(+), 3 deletions(-) + +diff --git a/sound/soc/intel/boards/sof_es8336.c b/sound/soc/intel/boards/sof_es8336.c +index d15a58666..c71842be9 100644 +--- a/sound/soc/intel/boards/sof_es8336.c ++++ b/sound/soc/intel/boards/sof_es8336.c +@@ -31,6 +31,7 @@ + #define SOF_ES8336_ENABLE_DMIC BIT(5) + #define SOF_ES8336_JD_INVERTED BIT(6) + #define SOF_ES8336_HEADPHONE_GPIO BIT(7) ++#define SOC_ES8336_HEADSET_MIC1 BIT(8) + + static unsigned long quirk; + +@@ -90,6 +91,8 @@ static void log_quirks(struct device *dev) + dev_info(dev, "quirk headphone GPIO enabled\n"); + if (quirk & SOF_ES8336_JD_INVERTED) + dev_info(dev, "quirk JD inverted enabled\n"); ++ if (quirk & SOC_ES8336_HEADSET_MIC1) ++ dev_info(dev, "quirk headset at mic1 port enabled\n"); + } + + static int sof_es8316_speaker_power_event(struct snd_soc_dapm_widget *w, +@@ -147,11 +150,16 @@ static const struct snd_soc_dapm_route sof_es8316_audio_map[] = { + {"Speaker", NULL, "Speaker Power"}, + }; + +-static const struct snd_soc_dapm_route sof_es8316_intmic_in1_map[] = { ++static const struct snd_soc_dapm_route sof_es8316_headset_mic2_map[] = { + {"MIC1", NULL, "Internal Mic"}, + {"MIC2", NULL, "Headset Mic"}, + }; + ++static const struct snd_soc_dapm_route sof_es8316_headset_mic1_map[] = { ++ {"MIC2", NULL, "Internal Mic"}, ++ {"MIC1", NULL, "Headset Mic"}, ++}; ++ + static const struct snd_soc_dapm_route dmic_map[] = { + /* digital mics */ + {"DMic", NULL, "SoC DMIC"}, +@@ -225,8 +233,13 @@ static int sof_es8316_init(struct snd_soc_pcm_runtime *runtime) + + card->dapm.idle_bias_off = true; + +- custom_map = sof_es8316_intmic_in1_map; +- num_routes = ARRAY_SIZE(sof_es8316_intmic_in1_map); ++ if (quirk & SOC_ES8336_HEADSET_MIC1) { ++ custom_map = sof_es8316_headset_mic1_map; ++ num_routes = ARRAY_SIZE(sof_es8316_headset_mic1_map); ++ } else { ++ custom_map = sof_es8316_headset_mic2_map; ++ num_routes = ARRAY_SIZE(sof_es8316_headset_mic2_map); ++ } + + ret = snd_soc_dapm_add_routes(&card->dapm, custom_map, num_routes); + if (ret) +-- +2.35.2 + diff --git a/0416-ASoC-Intel-sof_es8336-Add-a-quirk-for-Huawei-Mateboo.patch b/0416-ASoC-Intel-sof_es8336-Add-a-quirk-for-Huawei-Mateboo.patch new file mode 100644 index 0000000..94a25a2 --- /dev/null +++ b/0416-ASoC-Intel-sof_es8336-Add-a-quirk-for-Huawei-Mateboo.patch @@ -0,0 +1,45 @@ +From fe676f7c92783813348d12ee2baf6b3bbac8bedb Mon Sep 17 00:00:00 2001 +From: Mauro Carvalho Chehab +Date: Thu, 7 Apr 2022 20:49:59 +0200 +Subject: [PATCH 416/424] ASoC: Intel: sof_es8336: Add a quirk for Huawei + Matebook D15 + +Based on experimental tests, Huawei Matebook D15 actually uses +both gpio0 and gpio1: the first one controls the speaker, while +the other one controls the headphone. + +Also, the headset is mapped as MIC1, instead of MIC2. + +So, add a quirk for it. + +Signed-off-by: Mauro Carvalho Chehab +Acked-by: Pierre-Louis Bossart +Link: https://lore.kernel.org/r/d678aef9fc9a07aced611aa7cb8c9b800c649e5a.1649357263.git.mchehab@kernel.org +Signed-off-by: Mark Brown +--- + sound/soc/intel/boards/sof_es8336.c | 9 +++++++++ + 1 file changed, 9 insertions(+) + +diff --git a/sound/soc/intel/boards/sof_es8336.c b/sound/soc/intel/boards/sof_es8336.c +index c71842be9..9d617831d 100644 +--- a/sound/soc/intel/boards/sof_es8336.c ++++ b/sound/soc/intel/boards/sof_es8336.c +@@ -304,6 +304,15 @@ static const struct dmi_system_id sof_es8336_quirk_table[] = { + }, + .driver_data = (void *)(SOF_ES8336_SPEAKERS_EN_GPIO1_QUIRK) + }, ++ { ++ .callback = sof_es8336_quirk_cb, ++ .matches = { ++ DMI_MATCH(DMI_SYS_VENDOR, "HUAWEI"), ++ DMI_MATCH(DMI_BOARD_NAME, "BOHB-WAX9-PCB-B2"), ++ }, ++ .driver_data = (void *)(SOF_ES8336_HEADPHONE_GPIO | ++ SOC_ES8336_HEADSET_MIC1) ++ }, + {} + }; + +-- +2.35.2 + diff --git a/0417-ASoC-Intel-sof_es8336-Fix-GPIO-quirks-set-via-module.patch b/0417-ASoC-Intel-sof_es8336-Fix-GPIO-quirks-set-via-module.patch new file mode 100644 index 0000000..65adcf5 --- /dev/null +++ b/0417-ASoC-Intel-sof_es8336-Fix-GPIO-quirks-set-via-module.patch @@ -0,0 +1,77 @@ +From ab940eb1f4b514b80a2ab8af48ff557f0dd7bfe5 Mon Sep 17 00:00:00 2001 +From: Andrey Turkin +Date: Mon, 25 Jul 2022 14:49:02 -0500 +Subject: [PATCH 417/424] ASoC: Intel: sof_es8336: Fix GPIO quirks set via + module option + +The two GPIO quirk bits only affected actual GPIO selection +when set by the quirks table. They were reported as being +in effect when set via module options but actually did nothing. + +Reviewed-by: Andy Shevchenko +Signed-off-by: Andrey Turkin +Signed-off-by: Pierre-Louis Bossart +Link: https://lore.kernel.org/r/20220725194909.145418-4-pierre-louis.bossart@linux.intel.com +Signed-off-by: Mark Brown +--- + sound/soc/intel/boards/sof_es8336.c | 23 ++++++++++++----------- + 1 file changed, 12 insertions(+), 11 deletions(-) + +diff --git a/sound/soc/intel/boards/sof_es8336.c b/sound/soc/intel/boards/sof_es8336.c +index 9d617831d..81e12f03e 100644 +--- a/sound/soc/intel/boards/sof_es8336.c ++++ b/sound/soc/intel/boards/sof_es8336.c +@@ -77,8 +77,6 @@ static const struct acpi_gpio_mapping acpi_enable_both_gpios_rev_order[] = { + { } + }; + +-static const struct acpi_gpio_mapping *gpio_mapping = acpi_speakers_enable_gpio0; +- + static void log_quirks(struct device *dev) + { + dev_info(dev, "quirk mask %#lx\n", quirk); +@@ -272,15 +270,6 @@ static int sof_es8336_quirk_cb(const struct dmi_system_id *id) + { + quirk = (unsigned long)id->driver_data; + +- if (quirk & SOF_ES8336_HEADPHONE_GPIO) { +- if (quirk & SOF_ES8336_SPEAKERS_EN_GPIO1_QUIRK) +- gpio_mapping = acpi_enable_both_gpios; +- else +- gpio_mapping = acpi_enable_both_gpios_rev_order; +- } else if (quirk & SOF_ES8336_SPEAKERS_EN_GPIO1_QUIRK) { +- gpio_mapping = acpi_speakers_enable_gpio1; +- } +- + return 1; + } + +@@ -529,6 +518,7 @@ static int sof_es8336_probe(struct platform_device *pdev) + struct acpi_device *adev; + struct snd_soc_dai_link *dai_links; + struct device *codec_dev; ++ const struct acpi_gpio_mapping *gpio_mapping; + unsigned int cnt = 0; + int dmic_be_num = 0; + int hdmi_num = 3; +@@ -635,6 +625,17 @@ static int sof_es8336_probe(struct platform_device *pdev) + } + + /* get speaker enable GPIO */ ++ if (quirk & SOF_ES8336_HEADPHONE_GPIO) { ++ if (quirk & SOF_ES8336_SPEAKERS_EN_GPIO1_QUIRK) ++ gpio_mapping = acpi_enable_both_gpios; ++ else ++ gpio_mapping = acpi_enable_both_gpios_rev_order; ++ } else if (quirk & SOF_ES8336_SPEAKERS_EN_GPIO1_QUIRK) { ++ gpio_mapping = acpi_speakers_enable_gpio1; ++ } else { ++ gpio_mapping = acpi_speakers_enable_gpio0; ++ } ++ + ret = devm_acpi_dev_add_driver_gpios(codec_dev, gpio_mapping); + if (ret) + dev_warn(codec_dev, "unable to add GPIO mapping table\n"); +-- +2.35.2 + diff --git a/0418-ASoC-Intel-sof_es8336-ignore-GpioInt-when-looking-fo.patch b/0418-ASoC-Intel-sof_es8336-ignore-GpioInt-when-looking-fo.patch new file mode 100644 index 0000000..2aff532 --- /dev/null +++ b/0418-ASoC-Intel-sof_es8336-ignore-GpioInt-when-looking-fo.patch @@ -0,0 +1,57 @@ +From a47f6edd5509c6b638ae726f6f1c9c22c864a3ee Mon Sep 17 00:00:00 2001 +From: Andrey Turkin +Date: Mon, 25 Jul 2022 14:49:03 -0500 +Subject: [PATCH 418/424] ASoC: Intel: sof_es8336: ignore GpioInt when looking + for speaker/headset GPIO lines + +This fixes speaker GPIO detection on machines those ACPI tables +list their jack detection GpioInt before output GpioIo. +GpioInt entry can never be the speaker/headphone amplifier control +so it makes sense to only look for GpioIo entries when looking for them. + +Reviewed-by: Andy Shevchenko +Signed-off-by: Andrey Turkin +Signed-off-by: Pierre-Louis Bossart +Link: https://lore.kernel.org/r/20220725194909.145418-5-pierre-louis.bossart@linux.intel.com +Signed-off-by: Mark Brown +--- + sound/soc/intel/boards/sof_es8336.c | 12 ++++++------ + 1 file changed, 6 insertions(+), 6 deletions(-) + +diff --git a/sound/soc/intel/boards/sof_es8336.c b/sound/soc/intel/boards/sof_es8336.c +index 81e12f03e..dade1749c 100644 +--- a/sound/soc/intel/boards/sof_es8336.c ++++ b/sound/soc/intel/boards/sof_es8336.c +@@ -57,23 +57,23 @@ static const struct acpi_gpio_params enable_gpio0 = { 0, 0, true }; + static const struct acpi_gpio_params enable_gpio1 = { 1, 0, true }; + + static const struct acpi_gpio_mapping acpi_speakers_enable_gpio0[] = { +- { "speakers-enable-gpios", &enable_gpio0, 1 }, ++ { "speakers-enable-gpios", &enable_gpio0, 1, ACPI_GPIO_QUIRK_ONLY_GPIOIO }, + { } + }; + + static const struct acpi_gpio_mapping acpi_speakers_enable_gpio1[] = { +- { "speakers-enable-gpios", &enable_gpio1, 1 }, ++ { "speakers-enable-gpios", &enable_gpio1, 1, ACPI_GPIO_QUIRK_ONLY_GPIOIO }, + }; + + static const struct acpi_gpio_mapping acpi_enable_both_gpios[] = { +- { "speakers-enable-gpios", &enable_gpio0, 1 }, +- { "headphone-enable-gpios", &enable_gpio1, 1 }, ++ { "speakers-enable-gpios", &enable_gpio0, 1, ACPI_GPIO_QUIRK_ONLY_GPIOIO }, ++ { "headphone-enable-gpios", &enable_gpio1, 1, ACPI_GPIO_QUIRK_ONLY_GPIOIO }, + { } + }; + + static const struct acpi_gpio_mapping acpi_enable_both_gpios_rev_order[] = { +- { "speakers-enable-gpios", &enable_gpio1, 1 }, +- { "headphone-enable-gpios", &enable_gpio0, 1 }, ++ { "speakers-enable-gpios", &enable_gpio1, 1, ACPI_GPIO_QUIRK_ONLY_GPIOIO }, ++ { "headphone-enable-gpios", &enable_gpio0, 1, ACPI_GPIO_QUIRK_ONLY_GPIOIO }, + { } + }; + +-- +2.35.2 + diff --git a/0419-ASoC-Intel-sof_es8336-add-support-for-HDMI_In-captur.patch b/0419-ASoC-Intel-sof_es8336-add-support-for-HDMI_In-captur.patch new file mode 100644 index 0000000..10b6488 --- /dev/null +++ b/0419-ASoC-Intel-sof_es8336-add-support-for-HDMI_In-captur.patch @@ -0,0 +1,235 @@ +From 8c10c513be98384f752b4425855764b59f9ba830 Mon Sep 17 00:00:00 2001 +From: Muralidhar Reddy +Date: Mon, 25 Jul 2022 14:49:04 -0500 +Subject: [PATCH 419/424] ASoC: Intel: sof_es8336: add support for HDMI_In + capture + +Adding support for 2 streams of HDMI-In capture via I2S in CBP_CFP +configuration (codec provides bit clock and frame sync). + +Reviewed-by: Bard Liao +Signed-off-by: Muralidhar Reddy +Signed-off-by: Pierre-Louis Bossart +Link: https://lore.kernel.org/r/20220725194909.145418-6-pierre-louis.bossart@linux.intel.com +Signed-off-by: Mark Brown + +--- + sound/soc/intel/boards/sof_es8336.c | 126 +++++++++++++++--- + .../intel/common/soc-acpi-intel-adl-match.c | 12 ++ + 2 files changed, 118 insertions(+), 20 deletions(-) + +diff --git a/sound/soc/intel/boards/sof_es8336.c b/sound/soc/intel/boards/sof_es8336.c +index dade1749c..6d102ad19 100644 +--- a/sound/soc/intel/boards/sof_es8336.c ++++ b/sound/soc/intel/boards/sof_es8336.c +@@ -28,6 +28,24 @@ + #define SOF_ES8336_SSP_CODEC_MASK (GENMASK(3, 0)) + + #define SOF_ES8336_SPEAKERS_EN_GPIO1_QUIRK BIT(4) ++ ++/* HDMI capture*/ ++#define SOF_SSP_HDMI_CAPTURE_PRESENT BIT(14) ++#define SOF_NO_OF_HDMI_CAPTURE_SSP_SHIFT 15 ++#define SOF_NO_OF_HDMI_CAPTURE_SSP_MASK (GENMASK(16, 15)) ++#define SOF_NO_OF_HDMI_CAPTURE_SSP(quirk) \ ++ (((quirk) << SOF_NO_OF_HDMI_CAPTURE_SSP_SHIFT) & SOF_NO_OF_HDMI_CAPTURE_SSP_MASK) ++ ++#define SOF_HDMI_CAPTURE_1_SSP_SHIFT 7 ++#define SOF_HDMI_CAPTURE_1_SSP_MASK (GENMASK(9, 7)) ++#define SOF_HDMI_CAPTURE_1_SSP(quirk) \ ++ (((quirk) << SOF_HDMI_CAPTURE_1_SSP_SHIFT) & SOF_HDMI_CAPTURE_1_SSP_MASK) ++ ++#define SOF_HDMI_CAPTURE_2_SSP_SHIFT 10 ++#define SOF_HDMI_CAPTURE_2_SSP_MASK (GENMASK(12, 10)) ++#define SOF_HDMI_CAPTURE_2_SSP(quirk) \ ++ (((quirk) << SOF_HDMI_CAPTURE_2_SSP_SHIFT) & SOF_HDMI_CAPTURE_2_SSP_MASK) ++ + #define SOF_ES8336_ENABLE_DMIC BIT(5) + #define SOF_ES8336_JD_INVERTED BIT(6) + #define SOF_ES8336_HEADPHONE_GPIO BIT(7) +@@ -345,6 +363,13 @@ static struct snd_soc_dai_link_component dmic_component[] = { + } + }; + ++static struct snd_soc_dai_link_component dummy_component[] = { ++ { ++ .name = "snd-soc-dummy", ++ .dai_name = "snd-soc-dummy-dai", ++ } ++}; ++ + static int sof_es8336_late_probe(struct snd_soc_card *card) + { + struct sof_es8336_private *priv = snd_soc_card_get_drvdata(card); +@@ -496,6 +521,37 @@ static struct snd_soc_dai_link *sof_card_dai_links_create(struct device *dev, + id++; + } + ++ /* HDMI-In SSP */ ++ if (quirk & SOF_SSP_HDMI_CAPTURE_PRESENT) { ++ int num_of_hdmi_ssp = (quirk & SOF_NO_OF_HDMI_CAPTURE_SSP_MASK) >> ++ SOF_NO_OF_HDMI_CAPTURE_SSP_SHIFT; ++ ++ for (i = 1; i <= num_of_hdmi_ssp; i++) { ++ int port = (i == 1 ? (quirk & SOF_HDMI_CAPTURE_1_SSP_MASK) >> ++ SOF_HDMI_CAPTURE_1_SSP_SHIFT : ++ (quirk & SOF_HDMI_CAPTURE_2_SSP_MASK) >> ++ SOF_HDMI_CAPTURE_2_SSP_SHIFT); ++ ++ links[id].cpus = &cpus[id]; ++ links[id].cpus->dai_name = devm_kasprintf(dev, GFP_KERNEL, ++ "SSP%d Pin", port); ++ if (!links[id].cpus->dai_name) ++ return NULL; ++ links[id].name = devm_kasprintf(dev, GFP_KERNEL, "SSP%d-HDMI", port); ++ if (!links[id].name) ++ return NULL; ++ links[id].id = id + hdmi_id_offset; ++ links[id].codecs = dummy_component; ++ links[id].num_codecs = ARRAY_SIZE(dummy_component); ++ links[id].platforms = platform_component; ++ links[id].num_platforms = ARRAY_SIZE(platform_component); ++ links[id].dpcm_capture = 1; ++ links[id].no_pcm = 1; ++ links[id].num_cpus = 1; ++ id++; ++ } ++ } ++ + return links; + + devm_err: +@@ -531,29 +587,38 @@ static int sof_es8336_probe(struct platform_device *pdev) + card = &sof_es8336_card; + card->dev = dev; + ++ if (pdev->id_entry && pdev->id_entry->driver_data) ++ quirk = (unsigned long)pdev->id_entry->driver_data; ++ + /* check GPIO DMI quirks */ + dmi_check_system(sof_es8336_quirk_table); + +- if (!mach->mach_params.i2s_link_mask) { +- dev_warn(dev, "No I2S link information provided, using SSP0. This may need to be modified with the quirk module parameter\n"); +- } else { +- /* +- * Set configuration based on platform NHLT. +- * In this machine driver, we can only support one SSP for the +- * ES8336 link, the else-if below are intentional. +- * In some cases multiple SSPs can be reported by NHLT, starting MSB-first +- * seems to pick the right connection. +- */ +- unsigned long ssp = 0; +- +- if (mach->mach_params.i2s_link_mask & BIT(2)) +- ssp = SOF_ES8336_SSP_CODEC(2); +- else if (mach->mach_params.i2s_link_mask & BIT(1)) +- ssp = SOF_ES8336_SSP_CODEC(1); +- else if (mach->mach_params.i2s_link_mask & BIT(0)) +- ssp = SOF_ES8336_SSP_CODEC(0); +- +- quirk |= ssp; ++ /* Use NHLT configuration only for Non-HDMI capture use case. ++ * Because more than one SSP will be enabled for HDMI capture hence wrong codec ++ * SSP will be set. ++ */ ++ if (mach->tplg_quirk_mask & SND_SOC_ACPI_TPLG_INTEL_SSP_NUMBER) { ++ if (!mach->mach_params.i2s_link_mask) { ++ dev_warn(dev, "No I2S link information provided, using SSP0. This may need to be modified with the quirk module parameter\n"); ++ } else { ++ /* ++ * Set configuration based on platform NHLT. ++ * In this machine driver, we can only support one SSP for the ++ * ES8336 link, the else-if below are intentional. ++ * In some cases multiple SSPs can be reported by NHLT, starting MSB-first ++ * seems to pick the right connection. ++ */ ++ unsigned long ssp = 0; ++ ++ if (mach->mach_params.i2s_link_mask & BIT(2)) ++ ssp = SOF_ES8336_SSP_CODEC(2); ++ else if (mach->mach_params.i2s_link_mask & BIT(1)) ++ ssp = SOF_ES8336_SSP_CODEC(1); ++ else if (mach->mach_params.i2s_link_mask & BIT(0)) ++ ssp = SOF_ES8336_SSP_CODEC(0); ++ ++ quirk |= ssp; ++ } + } + + if (mach->mach_params.dmic_num) +@@ -570,6 +635,11 @@ static int sof_es8336_probe(struct platform_device *pdev) + dmic_be_num = 2; + + sof_es8336_card.num_links += dmic_be_num + hdmi_num; ++ ++ if (quirk & SOF_SSP_HDMI_CAPTURE_PRESENT) ++ sof_es8336_card.num_links += (quirk & SOF_NO_OF_HDMI_CAPTURE_SSP_MASK) >> ++ SOF_NO_OF_HDMI_CAPTURE_SSP_SHIFT; ++ + dai_links = sof_card_dai_links_create(dev, + SOF_ES8336_SSP_CODEC(quirk), + dmic_be_num, hdmi_num); +@@ -691,6 +761,21 @@ static int sof_es8336_remove(struct platform_device *pdev) + return 0; + } + ++static const struct platform_device_id board_ids[] = { ++ { ++ .name = "adl_es83x6_c1_h02", ++ .driver_data = (kernel_ulong_t)(SOF_ES8336_SSP_CODEC(1) | ++ SOF_NO_OF_HDMI_CAPTURE_SSP(2) | ++ SOF_HDMI_CAPTURE_1_SSP(0) | ++ SOF_HDMI_CAPTURE_2_SSP(2) | ++ SOF_SSP_HDMI_CAPTURE_PRESENT | ++ SOF_ES8336_SPEAKERS_EN_GPIO1_QUIRK | ++ SOF_ES8336_JD_INVERTED), ++ }, ++ { } ++}; ++MODULE_DEVICE_TABLE(platform, board_ids); ++ + static struct platform_driver sof_es8336_driver = { + .driver = { + .name = "sof-essx8336", +@@ -698,6 +783,7 @@ static struct platform_driver sof_es8336_driver = { + }, + .probe = sof_es8336_probe, + .remove = sof_es8336_remove, ++ .id_table = board_ids, + }; + module_platform_driver(sof_es8336_driver); + +diff --git a/sound/soc/intel/common/soc-acpi-intel-adl-match.c b/sound/soc/intel/common/soc-acpi-intel-adl-match.c +index a0f6a69c7..ca5a34471 100644 +--- a/sound/soc/intel/common/soc-acpi-intel-adl-match.c ++++ b/sound/soc/intel/common/soc-acpi-intel-adl-match.c +@@ -280,6 +280,11 @@ static const struct snd_soc_acpi_codecs adl_max98357a_amp = { + .codecs = {"MX98357A"} + }; + ++static const struct snd_soc_acpi_codecs adl_lt6911_hdmi = { ++ .num_codecs = 1, ++ .codecs = {"INTC10B0"} ++}; ++ + struct snd_soc_acpi_mach snd_soc_acpi_intel_adl_machines[] = { + { + .id = "10EC5682", +@@ -333,6 +338,13 @@ struct snd_soc_acpi_mach snd_soc_acpi_intel_adl_sdw_machines[] = { + .drv_name = "sof_sdw", + .sof_tplg_filename = "sof-adl-rt711.tplg", + }, ++ { ++ .comp_ids = &essx_83x6, ++ .drv_name = "adl_es83x6_c1_h02", ++ .machine_quirk = snd_soc_acpi_codec_list, ++ .quirk_data = &adl_lt6911_hdmi, ++ .sof_tplg_filename = "sof-adl-es83x6-ssp1-hdmi-ssp02.tplg", ++ }, + { + .link_mask = 0x5, /* rt5682 on link0 & 2xmax98373 on link 2 */ + .links = adl_chromebook_base, +-- +2.35.2 + diff --git a/0420-ASoC-Intel-sof_es8336-reset-the-num_links-during-pro.patch b/0420-ASoC-Intel-sof_es8336-reset-the-num_links-during-pro.patch new file mode 100644 index 0000000..ae2a069 --- /dev/null +++ b/0420-ASoC-Intel-sof_es8336-reset-the-num_links-during-pro.patch @@ -0,0 +1,35 @@ +From 3a65eff7aa2b951b3b1f3afd3a11234b7f421fc8 Mon Sep 17 00:00:00 2001 +From: Muralidhar Reddy +Date: Mon, 25 Jul 2022 14:49:05 -0500 +Subject: [PATCH 420/424] ASoC: Intel: sof_es8336: reset the num_links during + probe + +The number of dai_links for sound cards needs to be reset during +probe. This is done in all machine drivers except this one. + +Reviewed-by: Bard Liao +Signed-off-by: Muralidhar Reddy +Signed-off-by: Pierre-Louis Bossart +Link: https://lore.kernel.org/r/20220725194909.145418-7-pierre-louis.bossart@linux.intel.com +Signed-off-by: Mark Brown +--- + sound/soc/intel/boards/sof_es8336.c | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +diff --git a/sound/soc/intel/boards/sof_es8336.c b/sound/soc/intel/boards/sof_es8336.c +index 6d102ad19..027a302ef 100644 +--- a/sound/soc/intel/boards/sof_es8336.c ++++ b/sound/soc/intel/boards/sof_es8336.c +@@ -634,7 +634,8 @@ static int sof_es8336_probe(struct platform_device *pdev) + if (quirk & SOF_ES8336_ENABLE_DMIC) + dmic_be_num = 2; + +- sof_es8336_card.num_links += dmic_be_num + hdmi_num; ++ /* compute number of dai links */ ++ sof_es8336_card.num_links = 1 + dmic_be_num + hdmi_num; + + if (quirk & SOF_SSP_HDMI_CAPTURE_PRESENT) + sof_es8336_card.num_links += (quirk & SOF_NO_OF_HDMI_CAPTURE_SSP_MASK) >> +-- +2.35.2 + diff --git a/0421-ASoC-Intel-sof_es8336-remove-hard-coded-SSP-selectio.patch b/0421-ASoC-Intel-sof_es8336-remove-hard-coded-SSP-selectio.patch new file mode 100644 index 0000000..fe2fc10 --- /dev/null +++ b/0421-ASoC-Intel-sof_es8336-remove-hard-coded-SSP-selectio.patch @@ -0,0 +1,54 @@ +From 18ae22ea81ff06adeec43f178e99e667046a2c15 Mon Sep 17 00:00:00 2001 +From: Pierre-Louis Bossart +Date: Mon, 25 Jul 2022 14:49:06 -0500 +Subject: [PATCH 421/424] ASoC: Intel: sof_es8336: remove hard-coded SSP + selection + +For some reason we open-coded the SSP selection and only supported +SSP0, 1 and 2. On ApolloLake platforms, the SSP5 can be used as well +for the ES8336 hardware link. + +Remove hard-coded if/else code and align with same code already used +in the SOF driver. + +BugLink: https://github.com/thesofproject/sof/issues/6015 +Reviewed-by: Ranjani Sridharan +Reviewed-by: Bard Liao +Signed-off-by: Pierre-Louis Bossart +Link: https://lore.kernel.org/r/20220725194909.145418-8-pierre-louis.bossart@linux.intel.com +Signed-off-by: Mark Brown +--- + sound/soc/intel/boards/sof_es8336.c | 14 +++++--------- + 1 file changed, 5 insertions(+), 9 deletions(-) + +diff --git a/sound/soc/intel/boards/sof_es8336.c b/sound/soc/intel/boards/sof_es8336.c +index 027a302ef..f2beee1a7 100644 +--- a/sound/soc/intel/boards/sof_es8336.c ++++ b/sound/soc/intel/boards/sof_es8336.c +@@ -604,18 +604,14 @@ static int sof_es8336_probe(struct platform_device *pdev) + /* + * Set configuration based on platform NHLT. + * In this machine driver, we can only support one SSP for the +- * ES8336 link, the else-if below are intentional. ++ * ES8336 link. + * In some cases multiple SSPs can be reported by NHLT, starting MSB-first + * seems to pick the right connection. + */ +- unsigned long ssp = 0; +- +- if (mach->mach_params.i2s_link_mask & BIT(2)) +- ssp = SOF_ES8336_SSP_CODEC(2); +- else if (mach->mach_params.i2s_link_mask & BIT(1)) +- ssp = SOF_ES8336_SSP_CODEC(1); +- else if (mach->mach_params.i2s_link_mask & BIT(0)) +- ssp = SOF_ES8336_SSP_CODEC(0); ++ unsigned long ssp; ++ ++ /* fls returns 1-based results, SSPs indices are 0-based */ ++ ssp = fls(mach->mach_params.i2s_link_mask) - 1; + + quirk |= ssp; + } +-- +2.35.2 + diff --git a/0422-ASoC-Intel-fix-sof_es8336-probe.patch b/0422-ASoC-Intel-fix-sof_es8336-probe.patch new file mode 100644 index 0000000..4628ab7 --- /dev/null +++ b/0422-ASoC-Intel-fix-sof_es8336-probe.patch @@ -0,0 +1,47 @@ +From 3a81a58074505e2d2f3981951ba0b084544f2ec5 Mon Sep 17 00:00:00 2001 +From: Pierre-Louis Bossart +Date: Fri, 5 Aug 2022 15:33:32 +0200 +Subject: [PATCH 422/424] ASoC: Intel: fix sof_es8336 probe + +Changes to add HDMI capture support broke the machine driver probe for +all other platforms. The commit listed in the Fixes tag added a +board_id descriptor but didn't add the default name for the +sof_essx8336 machine driver. + +Add the missing entry and remove the now-useless platform driver +alias. + +Reported-by: Eugene J Markow +BugLink: https://github.com/thesofproject/linux/issues/3336 +Fixes: 86b1959a2ccb ("ASoC: Intel: sof_es8336: add support for HDMI_In capture") +Reviewed-by: Bard Liao +Signed-off-by: Pierre-Louis Bossart +Link: https://lore.kernel.org/r/20220805133332.207932-1-pierre-louis.bossart@linux.intel.com +Signed-off-by: Mark Brown +--- + sound/soc/intel/boards/sof_es8336.c | 4 +++- + 1 file changed, 3 insertions(+), 1 deletion(-) + +diff --git a/sound/soc/intel/boards/sof_es8336.c b/sound/soc/intel/boards/sof_es8336.c +index f2beee1a7..fd43fd773 100644 +--- a/sound/soc/intel/boards/sof_es8336.c ++++ b/sound/soc/intel/boards/sof_es8336.c +@@ -759,6 +759,9 @@ static int sof_es8336_remove(struct platform_device *pdev) + } + + static const struct platform_device_id board_ids[] = { ++ { ++ .name = "sof-essx8336", /* default quirk == 0 */ ++ }, + { + .name = "adl_es83x6_c1_h02", + .driver_data = (kernel_ulong_t)(SOF_ES8336_SSP_CODEC(1) | +@@ -786,5 +789,4 @@ 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.35.2 + diff --git a/0423-sound-backport-firmware-matches.patch b/0423-sound-backport-firmware-matches.patch new file mode 100644 index 0000000..e4df659 --- /dev/null +++ b/0423-sound-backport-firmware-matches.patch @@ -0,0 +1,185 @@ +From 5b2a2488785953e8f9c26b03ccb32e1dd563a359 Mon Sep 17 00:00:00 2001 +From: Mikhail Novosyolov +Date: Wed, 7 Sep 2022 14:06:40 +0300 +Subject: [PATCH 423/424] sound: backport firmware matches + +Backpot of commits like https://github.com/torvalds/linux/commit/8a6cc0ded6d942e4a506c421c4d87a634bda6e75 +from kernels 5.16+ into 5.15 + +Taken from patch by Vasily Vinogradov + +Co-authored-by: Vasily Vinogradov +--- + sound/hda/intel-dsp-config.c | 24 +++++++++---------- + sound/soc/codecs/es8316.c | 1 + + .../intel/common/soc-acpi-intel-bxt-match.c | 6 +++++ + .../intel/common/soc-acpi-intel-cml-match.c | 6 +++++ + .../intel/common/soc-acpi-intel-glk-match.c | 7 +++++- + .../intel/common/soc-acpi-intel-jsl-match.c | 6 +++++ + .../intel/common/soc-acpi-intel-tgl-match.c | 6 +++++ + 7 files changed, 43 insertions(+), 13 deletions(-) + +diff --git a/sound/hda/intel-dsp-config.c b/sound/hda/intel-dsp-config.c +index 4208fa8a4..f63114317 100644 +--- a/sound/hda/intel-dsp-config.c ++++ b/sound/hda/intel-dsp-config.c +@@ -249,13 +249,13 @@ static const struct config_entry config_table[] = { + } + }, + { +- .flags = FLAG_SOF | FLAG_SOF_ONLY_IF_DMIC_OR_SOUNDWIRE, ++ .flags = FLAG_SOF, + .device = 0x02c8, ++ .codec_hid = "ESSX8336", + }, + { +- .flags = FLAG_SOF, ++ .flags = FLAG_SOF | FLAG_SOF_ONLY_IF_DMIC_OR_SOUNDWIRE, + .device = 0x02c8, +- .codec_hid = "ESSX8336", + }, + /* Cometlake-H */ + { +@@ -278,14 +278,14 @@ static const struct config_entry config_table[] = { + } + }, + { +- .flags = FLAG_SOF | FLAG_SOF_ONLY_IF_DMIC_OR_SOUNDWIRE, +- .device = 0x06c8, +- }, +- { + .flags = FLAG_SOF, + .device = 0x06c8, + .codec_hid = "ESSX8336", + }, ++ { ++ .flags = FLAG_SOF | FLAG_SOF_ONLY_IF_DMIC_OR_SOUNDWIRE, ++ .device = 0x06c8, ++ }, + #endif + + /* Icelake */ +@@ -334,17 +334,17 @@ static const struct config_entry config_table[] = { + } + }, + { +- .flags = FLAG_SOF | FLAG_SOF_ONLY_IF_DMIC_OR_SOUNDWIRE, ++ .flags = FLAG_SOF, + .device = 0xa0c8, ++ .codec_hid = "ESSX8336", + }, + { + .flags = FLAG_SOF | FLAG_SOF_ONLY_IF_DMIC_OR_SOUNDWIRE, +- .device = 0x43c8, ++ .device = 0xa0c8, + }, + { +- .flags = FLAG_SOF, +- .device = 0xa0c8, +- .codec_hid = "ESSX8336", ++ .flags = FLAG_SOF | FLAG_SOF_ONLY_IF_DMIC_OR_SOUNDWIRE, ++ .device = 0x43c8, + }, + #endif + +diff --git a/sound/soc/codecs/es8316.c b/sound/soc/codecs/es8316.c +index 536fda946..9778c988e 100644 +--- a/sound/soc/codecs/es8316.c ++++ b/sound/soc/codecs/es8316.c +@@ -878,6 +878,7 @@ MODULE_DEVICE_TABLE(of, es8316_of_match); + #ifdef CONFIG_ACPI + static const struct acpi_device_id es8316_acpi_match[] = { + {"ESSX8316", 0}, ++ {"ESSX8336", 0}, + {}, + }; + MODULE_DEVICE_TABLE(acpi, es8316_acpi_match); +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 576407b5d..78cfdc48a 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-cml-match.c b/sound/soc/intel/common/soc-acpi-intel-cml-match.c +index b591c6fd1..f03fcc080 100644 +--- a/sound/soc/intel/common/soc-acpi-intel-cml-match.c ++++ b/sound/soc/intel/common/soc-acpi-intel-cml-match.c +@@ -81,6 +81,12 @@ struct snd_soc_acpi_mach snd_soc_acpi_intel_cml_machines[] = { + .sof_fw_filename = "sof-cml.ri", + .sof_tplg_filename = "sof-cml-da7219-max98390.tplg", + }, ++ { ++ .id = "ESSX8336", ++ .drv_name = "sof-essx8336", ++ .sof_fw_filename = "sof-cml.ri", ++ .sof_tplg_filename = "sof-cml-es8336.tplg", ++ }, + {}, + }; + EXPORT_SYMBOL_GPL(snd_soc_acpi_intel_cml_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 da1e15119..32fff9389 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-jsl-match.c b/sound/soc/intel/common/soc-acpi-intel-jsl-match.c +index 69ff7286d..87923bcf9 100644 +--- a/sound/soc/intel/common/soc-acpi-intel-jsl-match.c ++++ b/sound/soc/intel/common/soc-acpi-intel-jsl-match.c +@@ -81,6 +81,12 @@ struct snd_soc_acpi_mach snd_soc_acpi_intel_jsl_machines[] = { + .quirk_data = &mx98360a_spk, + .sof_tplg_filename = "sof-jsl-cs42l42-mx98360a.tplg", + }, ++ { ++ .id = "ESSX8336", ++ .drv_name = "sof-essx8336", ++ .sof_fw_filename = "sof-jsl.ri", ++ .sof_tplg_filename = "sof-jsl-es8336.tplg", ++ }, + {}, + }; + EXPORT_SYMBOL_GPL(snd_soc_acpi_intel_jsl_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 c93d8019b..5f20e9d42 100644 +--- a/sound/soc/intel/common/soc-acpi-intel-tgl-match.c ++++ b/sound/soc/intel/common/soc-acpi-intel-tgl-match.c +@@ -383,6 +383,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.35.2 + diff --git a/0424-ASoC-Intel-sof_es8336-Add-a-quirk-for-Aquarius-NS685.patch b/0424-ASoC-Intel-sof_es8336-Add-a-quirk-for-Aquarius-NS685.patch new file mode 100644 index 0000000..12470db --- /dev/null +++ b/0424-ASoC-Intel-sof_es8336-Add-a-quirk-for-Aquarius-NS685.patch @@ -0,0 +1,42 @@ +From 9e9cf05832f8a3afe35e45ea6bb9a808052b4122 Mon Sep 17 00:00:00 2001 +From: Mikhail Novosyolov +Date: Wed, 7 Sep 2022 14:17:35 +0300 +Subject: [PATCH 424/424] ASoC: Intel: sof_es8336: Add a quirk for Aquarius + NS685U R11 + +Sound worked with such a trick (+ changes in ALSA UCM configs): +echo "options snd_soc_sof_es8336 quirk=0x40" > /etc/modprobe.d/sof-essx8336.conf + +More information about this notebook: +https://linux-hardware.org/?probe=339dc3db60&log=dmidecode + +See also: +https://git.altlinux.org/gears/k/kernel-image-std-def.git?p=kernel-image-std-def.git;a=commitdiff;h=740693f7fc02612bef2036426449c575ec4f4161 +--- + sound/soc/intel/boards/sof_es8336.c | 10 ++++++++++ + 1 file changed, 10 insertions(+) + +diff --git a/sound/soc/intel/boards/sof_es8336.c b/sound/soc/intel/boards/sof_es8336.c +index fd43fd773..4a66d502c 100644 +--- a/sound/soc/intel/boards/sof_es8336.c ++++ b/sound/soc/intel/boards/sof_es8336.c +@@ -311,6 +311,16 @@ static const struct dmi_system_id sof_es8336_quirk_table[] = { + }, + .driver_data = (void *)(SOF_ES8336_SPEAKERS_EN_GPIO1_QUIRK) + }, ++ /* Aquarius NS685U R11 (https://linux-hardware.org/?probe=339dc3db60) */ ++ { ++ .callback = sof_es8336_quirk_cb, ++ .matches = { ++ DMI_MATCH(DMI_SYS_VENDOR, "AQUARIUS"), ++ DMI_MATCH(DMI_BOARD_NAME, "NS685Uv3"), ++ }, ++ .driver_data = (void *)(SOF_ES8336_SSP_CODEC(0) | ++ SOF_ES8336_JD_INVERTED) ++ }, + { + .callback = sof_es8336_quirk_cb, + .matches = { +-- +2.35.2 + diff --git a/0425-ASoC-Intel-sof_es8336-Add-more-quirks-for-Russian-ha.patch b/0425-ASoC-Intel-sof_es8336-Add-more-quirks-for-Russian-ha.patch new file mode 100644 index 0000000..84bf1b8 --- /dev/null +++ b/0425-ASoC-Intel-sof_es8336-Add-more-quirks-for-Russian-ha.patch @@ -0,0 +1,92 @@ +From 515a24183cc54328bddca9a3101572b6d0dd2d42 Mon Sep 17 00:00:00 2001 +From: Mikhail Novosyolov +Date: Wed, 7 Sep 2022 15:13:53 +0300 +Subject: [PATCH] ASoC: Intel: sof_es8336: Add more quirks for Russian hardware + +Ported from: +https://git.altlinux.org/gears/k/kernel-image-std-def.git?p=kernel-image-std-def.git;a=blob_plain;f=sound/soc/intel/boards/sof_es8336.c;h=d2a8309c3d520d97fb3e9a1747fa374dd7786beb;hb=882bb4ce852b88412e92bf6d508b19acdcee29e3 + +Except hardware added by commit https://git.altlinux.org/gears/k/kernel-image-std-def.git?p=kernel-image-std-def.git;a=commitdiff;h=5de44dd5ed0c6fa97f7142bad3157d6a897686b9 +(see: https://github.com/thesofproject/linux/issues/3412) +because that is a complex patch and I currently do not have such hardware for tests. + +Original authors: +Nikolai Kostrigin +Vasiliy Kovalev +--- + sound/soc/intel/boards/sof_es8336.c | 59 +++++++++++++++++++++++++++++ + 1 file changed, 59 insertions(+) + +diff --git a/sound/soc/intel/boards/sof_es8336.c b/sound/soc/intel/boards/sof_es8336.c +index 4a66d502c..f1a2a4af1 100644 +--- a/sound/soc/intel/boards/sof_es8336.c ++++ b/sound/soc/intel/boards/sof_es8336.c +@@ -321,6 +321,65 @@ static const struct dmi_system_id sof_es8336_quirk_table[] = { + .driver_data = (void *)(SOF_ES8336_SSP_CODEC(0) | + SOF_ES8336_JD_INVERTED) + }, ++ { ++ .callback = sof_es8336_quirk_cb, ++ .ident = "pa-enable ACPI deviant", ++ .matches = { ++ DMI_MATCH(DMI_SYS_VENDOR, "3Logic Group"), ++ DMI_MATCH(DMI_PRODUCT_NAME, "Graviton N15i"), ++ }, ++ .driver_data = (void *)(SOF_ES8336_SSP_CODEC(0) | ++ SOF_ES8336_SPEAKERS_EN_GPIO1_QUIRK) ++ }, ++ { ++ .callback = sof_es8336_quirk_cb, ++ .ident = "pa-enable ACPI deviant", ++ .matches = { ++ DMI_MATCH(DMI_SYS_VENDOR, "3Logic Group"), ++ DMI_MATCH(DMI_PRODUCT_NAME, "Lime 15.6"), ++ }, ++ .driver_data = (void *)(SOF_ES8336_SSP_CODEC(0) | ++ SOF_ES8336_SPEAKERS_EN_GPIO1_QUIRK) ++ }, ++ { ++ .callback = sof_es8336_quirk_cb, ++ .ident = "pa-enable ACPI deviant", ++ .matches = { ++ DMI_MATCH(DMI_SYS_VENDOR, "ICL"), ++ DMI_MATCH(DMI_BOARD_NAME, "Si16"), ++ }, ++ .driver_data = (void *)(SOF_ES8336_SSP_CODEC(0) | ++ SOF_ES8336_SPEAKERS_EN_GPIO1_QUIRK) ++ }, ++ { ++ .callback = sof_es8336_quirk_cb, ++ .ident = "pa-enable ACPI deviant", ++ .matches = { ++ /* market name: HIPER TeachBook HTHLP-04R */ ++ DMI_MATCH(DMI_SYS_VENDOR, "mtech"), ++ DMI_MATCH(DMI_PRODUCT_NAME, "MTL1578"), ++ }, ++ .driver_data = (void *)(SOF_ES8336_SSP_CODEC(0) | ++ SOF_ES8336_SPEAKERS_EN_GPIO1_QUIRK) ++ }, ++ { ++ .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 = { ++ /* market name: Kraftway ACCORD S15T */ ++ DMI_MATCH(DMI_SYS_VENDOR, "Kraftway"), ++ DMI_MATCH(DMI_BOARD_NAME, "S15T"), ++ }, ++ .driver_data = (void *)(SOF_ES8336_SSP_CODEC(0) | ++ SOF_ES8336_JD_INVERTED) ++ }, + { + .callback = sof_es8336_quirk_cb, + .matches = { +-- +2.35.2 + diff --git a/0426-ASoC-SOF-Intel-hda-report-SSP-link-mask-to-machine-d.patch b/0426-ASoC-SOF-Intel-hda-report-SSP-link-mask-to-machine-d.patch new file mode 100644 index 0000000..ac88eb3 --- /dev/null +++ b/0426-ASoC-SOF-Intel-hda-report-SSP-link-mask-to-machine-d.patch @@ -0,0 +1,72 @@ +From dbcf5bacadce817447500064768c7e9b97b93d12 Mon Sep 17 00:00:00 2001 +From: Pierre-Louis Bossart +Date: Tue, 8 Mar 2022 13:25:55 -0600 +Subject: [PATCH 426/429] ASoC: SOF: Intel: hda: report SSP link mask to + machine driver +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +For devices designed for Windows, the SSP information should be listed +in the NHLT, and when present can be used to set quirks automatically +in the machine driver. + +The NHLT information exposes BT and analog audio connections +separately, for now we are only interested in the analog audio parts. + +The use of dev_info() for the SSP mask is intentional so that we can +immediately flag devices with an ES8336 codec. Since NHLT is not used +for recent Chromebooks these messages should be rare. + +Signed-off-by: Pierre-Louis Bossart +Reviewed-by: Bard Liao +Reviewed-by: Péter Ujfalusi +Link: https://lore.kernel.org/r/20220308192610.392950-6-pierre-louis.bossart@linux.intel.com +Signed-off-by: Mark Brown +--- + sound/soc/sof/intel/hda.c | 22 ++++++++++++++++++++++ + 1 file changed, 22 insertions(+) + +diff --git a/sound/soc/sof/intel/hda.c b/sound/soc/sof/intel/hda.c +index 35cbef171..0606ab264 100644 +--- a/sound/soc/sof/intel/hda.c ++++ b/sound/soc/sof/intel/hda.c +@@ -534,6 +534,25 @@ static int hda_init(struct snd_sof_dev *sdev) + return ret; + } + ++static int check_nhlt_ssp_mask(struct snd_sof_dev *sdev) ++{ ++ struct nhlt_acpi_table *nhlt; ++ int ssp_mask = 0; ++ ++ nhlt = intel_nhlt_init(sdev->dev); ++ if (!nhlt) ++ return ssp_mask; ++ ++ if (intel_nhlt_has_endpoint_type(nhlt, NHLT_LINK_SSP)) { ++ ssp_mask = intel_nhlt_ssp_endpoint_mask(nhlt, NHLT_DEVICE_I2S); ++ if (ssp_mask) ++ dev_info(sdev->dev, "NHLT_DEVICE_I2S detected, ssp_mask %#x\n", ssp_mask); ++ } ++ intel_nhlt_free(nhlt); ++ ++ return ssp_mask; ++} ++ + #if IS_ENABLED(CONFIG_SND_SOC_SOF_HDA) || IS_ENABLED(CONFIG_SND_SOC_SOF_INTEL_SOUNDWIRE) + + static int check_nhlt_dmic(struct snd_sof_dev *sdev) +@@ -1287,6 +1306,9 @@ void hda_machine_select(struct snd_sof_dev *sdev) + mach->mach_params.links = mach->links; + mach->mach_params.link_mask = mach->link_mask; + } ++ ++ /* report SSP link mask to machine driver */ ++ mach->mach_params.i2s_link_mask = check_nhlt_ssp_mask(sdev); + } + + /* +-- +2.35.2 + diff --git a/0427-ASoC-Intel-soc-acpi-quirk-topology-filename-dynamica.patch b/0427-ASoC-Intel-soc-acpi-quirk-topology-filename-dynamica.patch new file mode 100644 index 0000000..b69a776 --- /dev/null +++ b/0427-ASoC-Intel-soc-acpi-quirk-topology-filename-dynamica.patch @@ -0,0 +1,247 @@ +From f9ff5f932126612549617d8eef3e657b2140ee1f Mon Sep 17 00:00:00 2001 +From: Pierre-Louis Bossart +Date: Tue, 8 Mar 2022 13:25:56 -0600 +Subject: [PATCH 427/429] ASoC: Intel: soc-acpi: quirk topology filename + dynamically +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Different topology filenames may be required depending on which SSP is +used, and whether or not digital mics are present. + +This patch adds a tplg_quirk_mask and in the case of the SOF driver +adds the relevant configurations. + +This is a short-term solution to the ES8336 support issues. + +In a long-term solution, we would need an interface where the machine +driver or platform driver have the ability to alter the topology +hard-coded low-level hardware support, e.g. by substituting an +interface for another, or disabling an interface that is not supported +on a given skew. + +BugLink: https://github.com/thesofproject/linux/issues/3248 +Signed-off-by: Pierre-Louis Bossart +Reviewed-by: Bard Liao +Reviewed-by: Péter Ujfalusi +Link: https://lore.kernel.org/r/20220308192610.392950-7-pierre-louis.bossart@linux.intel.com +Signed-off-by: Mark Brown +--- + include/sound/soc-acpi.h | 20 +++++++ + .../intel/common/soc-acpi-intel-bxt-match.c | 5 +- + .../intel/common/soc-acpi-intel-cml-match.c | 5 +- + .../intel/common/soc-acpi-intel-glk-match.c | 5 +- + .../intel/common/soc-acpi-intel-jsl-match.c | 5 +- + .../intel/common/soc-acpi-intel-tgl-match.c | 5 +- + sound/soc/sof/intel/hda.c | 52 +++++++++++++++++++ + 7 files changed, 92 insertions(+), 5 deletions(-) + +diff --git a/include/sound/soc-acpi.h b/include/sound/soc-acpi.h +index 2f3fa385c..3313e2e21 100644 +--- a/include/sound/soc-acpi.h ++++ b/include/sound/soc-acpi.h +@@ -122,6 +122,24 @@ struct snd_soc_acpi_link_adr { + const struct snd_soc_acpi_adr_device *adr_d; + }; + ++/* ++ * when set the topology uses the -ssp suffix, where N is determined based on ++ * BIOS or DMI information ++ */ ++#define SND_SOC_ACPI_TPLG_INTEL_SSP_NUMBER BIT(0) ++ ++/* ++ * when more than one SSP is reported in the link mask, use the most significant. ++ * This choice was found to be valid on platforms with ES8336 codecs. ++ */ ++#define SND_SOC_ACPI_TPLG_INTEL_SSP_MSB BIT(1) ++ ++/* ++ * when set the topology uses the -dmicch suffix, where N is determined based on ++ * BIOS or DMI information ++ */ ++#define SND_SOC_ACPI_TPLG_INTEL_DMIC_NUMBER BIT(2) ++ + /** + * snd_soc_acpi_mach: ACPI-based machine descriptor. Most of the fields are + * related to the hardware, except for the firmware and topology file names. +@@ -142,6 +160,7 @@ struct snd_soc_acpi_link_adr { + * is not constant since this field may be updated at run-time + * @sof_fw_filename: Sound Open Firmware file name, if enabled + * @sof_tplg_filename: Sound Open Firmware topology file name, if enabled ++ * @tplg_quirk_mask: quirks to select different topology files dynamically + */ + /* Descriptor for SST ASoC machine driver */ + struct snd_soc_acpi_mach { +@@ -157,6 +176,7 @@ struct snd_soc_acpi_mach { + struct snd_soc_acpi_mach_params mach_params; + const char *sof_fw_filename; + const char *sof_tplg_filename; ++ const u32 tplg_quirk_mask; + }; + + #define SND_SOC_ACPI_MAX_CODECS 3 +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 78cfdc48a..676ea2d15 100644 +--- a/sound/soc/intel/common/soc-acpi-intel-bxt-match.c ++++ b/sound/soc/intel/common/soc-acpi-intel-bxt-match.c +@@ -86,7 +86,10 @@ struct snd_soc_acpi_mach snd_soc_acpi_intel_bxt_machines[] = { + .id = "ESSX8336", + .drv_name = "sof-essx8336", + .sof_fw_filename = "sof-apl.ri", +- .sof_tplg_filename = "sof-apl-es8336.tplg", ++ .sof_tplg_filename = "sof-apl-es8336", /* the tplg suffix is added at run time */ ++ .tplg_quirk_mask = SND_SOC_ACPI_TPLG_INTEL_SSP_NUMBER | ++ SND_SOC_ACPI_TPLG_INTEL_SSP_MSB | ++ SND_SOC_ACPI_TPLG_INTEL_DMIC_NUMBER, + }, + {}, + }; +diff --git a/sound/soc/intel/common/soc-acpi-intel-cml-match.c b/sound/soc/intel/common/soc-acpi-intel-cml-match.c +index f03fcc080..45f3ca3d5 100644 +--- a/sound/soc/intel/common/soc-acpi-intel-cml-match.c ++++ b/sound/soc/intel/common/soc-acpi-intel-cml-match.c +@@ -85,7 +85,10 @@ struct snd_soc_acpi_mach snd_soc_acpi_intel_cml_machines[] = { + .id = "ESSX8336", + .drv_name = "sof-essx8336", + .sof_fw_filename = "sof-cml.ri", +- .sof_tplg_filename = "sof-cml-es8336.tplg", ++ .sof_tplg_filename = "sof-cml-es8336", /* the tplg suffix is added at run time */ ++ .tplg_quirk_mask = SND_SOC_ACPI_TPLG_INTEL_SSP_NUMBER | ++ SND_SOC_ACPI_TPLG_INTEL_SSP_MSB | ++ SND_SOC_ACPI_TPLG_INTEL_DMIC_NUMBER, + }, + {}, + }; +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 32fff9389..62e2d4847 100644 +--- a/sound/soc/intel/common/soc-acpi-intel-glk-match.c ++++ b/sound/soc/intel/common/soc-acpi-intel-glk-match.c +@@ -53,7 +53,10 @@ struct snd_soc_acpi_mach snd_soc_acpi_intel_glk_machines[] = { + .id = "ESSX8336", + .drv_name = "sof-essx8336", + .sof_fw_filename = "sof-glk.ri", +- .sof_tplg_filename = "sof-glk-es8336.tplg", ++ .sof_tplg_filename = "sof-glk-es8336", /* the tplg suffix is added at run time */ ++ .tplg_quirk_mask = SND_SOC_ACPI_TPLG_INTEL_SSP_NUMBER | ++ SND_SOC_ACPI_TPLG_INTEL_SSP_MSB | ++ SND_SOC_ACPI_TPLG_INTEL_DMIC_NUMBER, + }, + {}, + }; +diff --git a/sound/soc/intel/common/soc-acpi-intel-jsl-match.c b/sound/soc/intel/common/soc-acpi-intel-jsl-match.c +index 87923bcf9..3e02203ed 100644 +--- a/sound/soc/intel/common/soc-acpi-intel-jsl-match.c ++++ b/sound/soc/intel/common/soc-acpi-intel-jsl-match.c +@@ -85,7 +85,10 @@ struct snd_soc_acpi_mach snd_soc_acpi_intel_jsl_machines[] = { + .id = "ESSX8336", + .drv_name = "sof-essx8336", + .sof_fw_filename = "sof-jsl.ri", +- .sof_tplg_filename = "sof-jsl-es8336.tplg", ++ .sof_tplg_filename = "sof-jsl-es8336", /* the tplg suffix is added at run time */ ++ .tplg_quirk_mask = SND_SOC_ACPI_TPLG_INTEL_SSP_NUMBER | ++ SND_SOC_ACPI_TPLG_INTEL_SSP_MSB | ++ SND_SOC_ACPI_TPLG_INTEL_DMIC_NUMBER, + }, + {}, + }; +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 5f20e9d42..03c83c9b4 100644 +--- a/sound/soc/intel/common/soc-acpi-intel-tgl-match.c ++++ b/sound/soc/intel/common/soc-acpi-intel-tgl-match.c +@@ -387,7 +387,10 @@ struct snd_soc_acpi_mach snd_soc_acpi_intel_tgl_machines[] = { + .id = "ESSX8336", + .drv_name = "sof-essx8336", + .sof_fw_filename = "sof-tgl.ri", +- .sof_tplg_filename = "sof-tgl-es8336.tplg", ++ .sof_tplg_filename = "sof-tgl-es8336", /* the tplg suffix is added at run time */ ++ .tplg_quirk_mask = SND_SOC_ACPI_TPLG_INTEL_SSP_NUMBER | ++ SND_SOC_ACPI_TPLG_INTEL_SSP_MSB | ++ SND_SOC_ACPI_TPLG_INTEL_DMIC_NUMBER, + }, + {}, + }; +diff --git a/sound/soc/sof/intel/hda.c b/sound/soc/sof/intel/hda.c +index 0606ab264..c2062d4d8 100644 +--- a/sound/soc/sof/intel/hda.c ++++ b/sound/soc/sof/intel/hda.c +@@ -1290,9 +1290,12 @@ void hda_machine_select(struct snd_sof_dev *sdev) + struct snd_sof_pdata *sof_pdata = sdev->pdata; + const struct sof_dev_desc *desc = sof_pdata->desc; + struct snd_soc_acpi_mach *mach; ++ const char *tplg_filename; + + mach = snd_soc_acpi_find_machine(desc->machines); + if (mach) { ++ bool add_extension = false; ++ + /* + * If tplg file name is overridden, use it instead of + * the one set in mach table +@@ -1302,6 +1305,21 @@ void hda_machine_select(struct snd_sof_dev *sdev) + + sof_pdata->machine = mach; + ++ if (mach->tplg_quirk_mask & SND_SOC_ACPI_TPLG_INTEL_DMIC_NUMBER && ++ mach->mach_params.dmic_num) { ++ tplg_filename = devm_kasprintf(sdev->dev, GFP_KERNEL, ++ "%s%s%d%s", ++ sof_pdata->tplg_filename, ++ "-dmic", ++ mach->mach_params.dmic_num, ++ "ch"); ++ if (!tplg_filename) ++ return NULL; ++ ++ sof_pdata->tplg_filename = tplg_filename; ++ add_extension = true; ++ } ++ + if (mach->link_mask) { + mach->mach_params.links = mach->links; + mach->mach_params.link_mask = mach->link_mask; +@@ -1309,6 +1327,40 @@ void hda_machine_select(struct snd_sof_dev *sdev) + + /* report SSP link mask to machine driver */ + mach->mach_params.i2s_link_mask = check_nhlt_ssp_mask(sdev); ++ ++ if (mach->tplg_quirk_mask & SND_SOC_ACPI_TPLG_INTEL_SSP_NUMBER && ++ mach->mach_params.i2s_link_mask) { ++ int ssp_num; ++ ++ if (hweight_long(mach->mach_params.i2s_link_mask) > 1 && ++ !(mach->tplg_quirk_mask & SND_SOC_ACPI_TPLG_INTEL_SSP_MSB)) ++ dev_warn(sdev->dev, "More than one SSP exposed by NHLT, choosing MSB\n"); ++ ++ /* fls returns 1-based results, SSPs indices are 0-based */ ++ ssp_num = fls(mach->mach_params.i2s_link_mask) - 1; ++ ++ tplg_filename = devm_kasprintf(sdev->dev, GFP_KERNEL, ++ "%s%s%d", ++ sof_pdata->tplg_filename, ++ "-ssp", ++ ssp_num); ++ if (!tplg_filename) ++ return NULL; ++ ++ sof_pdata->tplg_filename = tplg_filename; ++ add_extension = true; ++ } ++ ++ if (add_extension) { ++ tplg_filename = devm_kasprintf(sdev->dev, GFP_KERNEL, ++ "%s%s", ++ sof_pdata->tplg_filename, ++ ".tplg"); ++ if (!tplg_filename) ++ return NULL; ++ ++ sof_pdata->tplg_filename = tplg_filename; ++ } + } + + /* +-- +2.35.2 + diff --git a/0428-ASoC-soc-acpi-fix-kernel-doc-descriptor.patch b/0428-ASoC-soc-acpi-fix-kernel-doc-descriptor.patch new file mode 100644 index 0000000..b23660d --- /dev/null +++ b/0428-ASoC-soc-acpi-fix-kernel-doc-descriptor.patch @@ -0,0 +1,40 @@ +From 7a37f4855e5333cec6e0b92823d81d8340ad31f2 Mon Sep 17 00:00:00 2001 +From: Pierre-Louis Bossart +Date: Tue, 8 Mar 2022 13:25:51 -0600 +Subject: [PATCH 428/429] ASoC: soc-acpi: fix kernel-doc descriptor +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Add missing dmic_num mention and clarify that 'links' mean 'SoundWire +links', not to be used for other links. + +Signed-off-by: Pierre-Louis Bossart +Reviewed-by: Bard Liao +Reviewed-by: Péter Ujfalusi +Link: https://lore.kernel.org/r/20220308192610.392950-2-pierre-louis.bossart@linux.intel.com +Signed-off-by: Mark Brown +--- + include/sound/soc-acpi.h | 5 +++-- + 1 file changed, 3 insertions(+), 2 deletions(-) + +diff --git a/include/sound/soc-acpi.h b/include/sound/soc-acpi.h +index 3313e2e21..4664d80f8 100644 +--- a/include/sound/soc-acpi.h ++++ b/include/sound/soc-acpi.h +@@ -60,9 +60,10 @@ static inline struct snd_soc_acpi_mach *snd_soc_acpi_codec_list(void *arg) + * @acpi_ipc_irq_index: used for BYT-CR detection + * @platform: string used for HDAudio codec support + * @codec_mask: used for HDAudio support ++ * @dmic_num: number of SoC- or chipset-attached PDM digital microphones + * @common_hdmi_codec_drv: use commom HDAudio HDMI codec driver +- * @link_mask: links enabled on the board +- * @links: array of link _ADR descriptors, null terminated ++ * @link_mask: SoundWire links enabled on the board ++ * @links: array of SoundWire link _ADR descriptors, null terminated + * @num_dai_drivers: number of elements in @dai_drivers + * @dai_drivers: pointer to dai_drivers, used e.g. in nocodec mode + */ +-- +2.35.2 + diff --git a/0429-ASoC-soc-acpi-add-information-on-I2S-TDM-link-mask.patch b/0429-ASoC-soc-acpi-add-information-on-I2S-TDM-link-mask.patch new file mode 100644 index 0000000..1a72074 --- /dev/null +++ b/0429-ASoC-soc-acpi-add-information-on-I2S-TDM-link-mask.patch @@ -0,0 +1,46 @@ +From 9cacc3eaf89aa0f5cd2cf68f810c8204fbaa114d Mon Sep 17 00:00:00 2001 +From: Pierre-Louis Bossart +Date: Tue, 8 Mar 2022 13:25:52 -0600 +Subject: [PATCH 429/429] ASoC: soc-acpi: add information on I2S/TDM link mask +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +The platform driver may have information on which I2S/TDM link(s) to +enable in the machine driver. In the case of Intel devices, this may +be extracted from NHLT tables in platform firmware. This link +information is necessary to make sure machine driver and topology are +aligned. + +Signed-off-by: Pierre-Louis Bossart +Reviewed-by: Bard Liao +Reviewed-by: Péter Ujfalusi +Link: https://lore.kernel.org/r/20220308192610.392950-3-pierre-louis.bossart@linux.intel.com +Signed-off-by: Mark Brown +--- + include/sound/soc-acpi.h | 2 ++ + 1 file changed, 2 insertions(+) + +diff --git a/include/sound/soc-acpi.h b/include/sound/soc-acpi.h +index 4664d80f8..d4fecd025 100644 +--- a/include/sound/soc-acpi.h ++++ b/include/sound/soc-acpi.h +@@ -64,6 +64,7 @@ static inline struct snd_soc_acpi_mach *snd_soc_acpi_codec_list(void *arg) + * @common_hdmi_codec_drv: use commom HDAudio HDMI codec driver + * @link_mask: SoundWire links enabled on the board + * @links: array of SoundWire link _ADR descriptors, null terminated ++ * @i2s_link_mask: I2S/TDM links enabled on the board + * @num_dai_drivers: number of elements in @dai_drivers + * @dai_drivers: pointer to dai_drivers, used e.g. in nocodec mode + */ +@@ -75,6 +76,7 @@ struct snd_soc_acpi_mach_params { + bool common_hdmi_codec_drv; + u32 link_mask; + const struct snd_soc_acpi_link_adr *links; ++ u32 i2s_link_mask; + u32 num_dai_drivers; + struct snd_soc_dai_driver *dai_drivers; + }; +-- +2.35.2 + diff --git a/0430-ALSA-hda-Fill-gaps-in-NHLT-endpoint-interface.patch b/0430-ALSA-hda-Fill-gaps-in-NHLT-endpoint-interface.patch new file mode 100644 index 0000000..0becc70 --- /dev/null +++ b/0430-ALSA-hda-Fill-gaps-in-NHLT-endpoint-interface.patch @@ -0,0 +1,204 @@ +From 787e785dfc81b70ff9b7a06f7f1a8e32be244a1e Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Amadeusz=20S=C5=82awi=C5=84ski?= + +Date: Fri, 26 Nov 2021 15:03:53 +0100 +Subject: [PATCH 430/432] ALSA: hda: Fill gaps in NHLT endpoint-interface +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Two key operations missings are: endpoint presence-check and retrieval +of matching endpoint hardware configuration (blob). Add operations for +both use cases. + +Signed-off-by: Amadeusz Sławiński +Signed-off-by: Cezary Rojewski +Link: https://lore.kernel.org/r/20211126140355.1042684-2-cezary.rojewski@intel.com +Signed-off-by: Takashi Iwai +--- + include/sound/intel-nhlt.h | 37 +++++++++++--- + sound/hda/intel-nhlt.c | 102 +++++++++++++++++++++++++++++++++++++ + 2 files changed, 131 insertions(+), 8 deletions(-) + +diff --git a/include/sound/intel-nhlt.h b/include/sound/intel-nhlt.h +index d05748058..089a760d3 100644 +--- a/include/sound/intel-nhlt.h ++++ b/include/sound/intel-nhlt.h +@@ -10,6 +10,14 @@ + + #include + ++enum nhlt_link_type { ++ NHLT_LINK_HDA = 0, ++ NHLT_LINK_DSP = 1, ++ NHLT_LINK_DMIC = 2, ++ NHLT_LINK_SSP = 3, ++ NHLT_LINK_INVALID ++}; ++ + #if IS_ENABLED(CONFIG_ACPI) && IS_ENABLED(CONFIG_SND_INTEL_NHLT) + + struct wav_fmt { +@@ -33,14 +41,6 @@ struct wav_fmt_ext { + u8 sub_fmt[16]; + } __packed; + +-enum nhlt_link_type { +- NHLT_LINK_HDA = 0, +- NHLT_LINK_DSP = 1, +- NHLT_LINK_DMIC = 2, +- NHLT_LINK_SSP = 3, +- NHLT_LINK_INVALID +-}; +- + enum nhlt_device_type { + NHLT_DEVICE_BT = 0, + NHLT_DEVICE_DMIC = 1, +@@ -132,6 +132,12 @@ void intel_nhlt_free(struct nhlt_acpi_table *addr); + + int intel_nhlt_get_dmic_geo(struct device *dev, struct nhlt_acpi_table *nhlt); + ++bool intel_nhlt_has_endpoint_type(struct nhlt_acpi_table *nhlt, u8 link_type); ++struct nhlt_specific_cfg * ++intel_nhlt_get_endpoint_blob(struct device *dev, struct nhlt_acpi_table *nhlt, ++ u32 bus_id, u8 link_type, u8 vbps, u8 bps, ++ u8 num_ch, u32 rate, u8 dir, u8 dev_type); ++ + #else + + struct nhlt_acpi_table; +@@ -150,6 +156,21 @@ static inline int intel_nhlt_get_dmic_geo(struct device *dev, + { + return 0; + } ++ ++static inline bool intel_nhlt_has_endpoint_type(struct nhlt_acpi_table *nhlt, ++ u8 link_type) ++{ ++ return false; ++} ++ ++static inline struct nhlt_specific_cfg * ++intel_nhlt_get_endpoint_blob(struct device *dev, struct nhlt_acpi_table *nhlt, ++ u32 bus_id, u8 link_type, u8 vbps, u8 bps, ++ u8 num_ch, u32 rate, u8 dir, u8 dev_type) ++{ ++ return NULL; ++} ++ + #endif + + #endif +diff --git a/sound/hda/intel-nhlt.c b/sound/hda/intel-nhlt.c +index e2237239d..128476aa7 100644 +--- a/sound/hda/intel-nhlt.c ++++ b/sound/hda/intel-nhlt.c +@@ -110,3 +110,105 @@ int intel_nhlt_get_dmic_geo(struct device *dev, struct nhlt_acpi_table *nhlt) + return dmic_geo; + } + EXPORT_SYMBOL_GPL(intel_nhlt_get_dmic_geo); ++ ++bool intel_nhlt_has_endpoint_type(struct nhlt_acpi_table *nhlt, u8 link_type) ++{ ++ struct nhlt_endpoint *epnt; ++ int i; ++ ++ if (!nhlt) ++ return false; ++ ++ epnt = (struct nhlt_endpoint *)nhlt->desc; ++ for (i = 0; i < nhlt->endpoint_count; i++) { ++ if (epnt->linktype == link_type) ++ return true; ++ ++ epnt = (struct nhlt_endpoint *)((u8 *)epnt + epnt->length); ++ } ++ return false; ++} ++EXPORT_SYMBOL(intel_nhlt_has_endpoint_type); ++ ++static struct nhlt_specific_cfg * ++nhlt_get_specific_cfg(struct device *dev, struct nhlt_fmt *fmt, u8 num_ch, ++ u32 rate, u8 vbps, u8 bps) ++{ ++ struct nhlt_fmt_cfg *cfg = fmt->fmt_config; ++ struct wav_fmt *wfmt; ++ u16 _bps, _vbps; ++ int i; ++ ++ dev_dbg(dev, "Endpoint format count=%d\n", fmt->fmt_count); ++ ++ for (i = 0; i < fmt->fmt_count; i++) { ++ wfmt = &cfg->fmt_ext.fmt; ++ _bps = wfmt->bits_per_sample; ++ _vbps = cfg->fmt_ext.sample.valid_bits_per_sample; ++ ++ dev_dbg(dev, "Endpoint format: ch=%d fmt=%d/%d rate=%d\n", ++ wfmt->channels, _vbps, _bps, wfmt->samples_per_sec); ++ ++ if (wfmt->channels == num_ch && wfmt->samples_per_sec == rate && ++ vbps == _vbps && bps == _bps) ++ return &cfg->config; ++ ++ cfg = (struct nhlt_fmt_cfg *)(cfg->config.caps + cfg->config.size); ++ } ++ ++ return NULL; ++} ++ ++static bool nhlt_check_ep_match(struct device *dev, struct nhlt_endpoint *epnt, ++ u32 bus_id, u8 link_type, u8 dir, u8 dev_type) ++{ ++ dev_dbg(dev, "Endpoint: vbus_id=%d link_type=%d dir=%d dev_type = %d\n", ++ epnt->virtual_bus_id, epnt->linktype, ++ epnt->direction, epnt->device_type); ++ ++ if ((epnt->virtual_bus_id != bus_id) || ++ (epnt->linktype != link_type) || ++ (epnt->direction != dir)) ++ return false; ++ ++ /* link of type DMIC bypasses device_type check */ ++ return epnt->linktype == NHLT_LINK_DMIC || ++ epnt->device_type == dev_type; ++} ++ ++struct nhlt_specific_cfg * ++intel_nhlt_get_endpoint_blob(struct device *dev, struct nhlt_acpi_table *nhlt, ++ u32 bus_id, u8 link_type, u8 vbps, u8 bps, ++ u8 num_ch, u32 rate, u8 dir, u8 dev_type) ++{ ++ struct nhlt_specific_cfg *cfg; ++ struct nhlt_endpoint *epnt; ++ struct nhlt_fmt *fmt; ++ int i; ++ ++ if (!nhlt) ++ return NULL; ++ ++ dev_dbg(dev, "Looking for configuration:\n"); ++ dev_dbg(dev, " vbus_id=%d link_type=%d dir=%d, dev_type=%d\n", ++ bus_id, link_type, dir, dev_type); ++ dev_dbg(dev, " ch=%d fmt=%d/%d rate=%d\n", num_ch, vbps, bps, rate); ++ dev_dbg(dev, "Endpoint count=%d\n", nhlt->endpoint_count); ++ ++ epnt = (struct nhlt_endpoint *)nhlt->desc; ++ ++ for (i = 0; i < nhlt->endpoint_count; i++) { ++ if (nhlt_check_ep_match(dev, epnt, bus_id, link_type, dir, dev_type)) { ++ fmt = (struct nhlt_fmt *)(epnt->config.caps + epnt->config.size); ++ ++ cfg = nhlt_get_specific_cfg(dev, fmt, num_ch, rate, vbps, bps); ++ if (cfg) ++ return cfg; ++ } ++ ++ epnt = (struct nhlt_endpoint *)((u8 *)epnt + epnt->length); ++ } ++ ++ return NULL; ++} ++EXPORT_SYMBOL(intel_nhlt_get_endpoint_blob); +-- +2.35.2 + diff --git a/0431-ASoC-SOF-avoid-casting-const-attribute-away.patch b/0431-ASoC-SOF-avoid-casting-const-attribute-away.patch new file mode 100644 index 0000000..c921a75 --- /dev/null +++ b/0431-ASoC-SOF-avoid-casting-const-attribute-away.patch @@ -0,0 +1,403 @@ +From 934a63001393268181d6ef91fa38b97d33cf319b Mon Sep 17 00:00:00 2001 +From: Guennadi Liakhovetski +Date: Thu, 16 Dec 2021 17:24:20 -0600 +Subject: [PATCH 431/432] ASoC: SOF: avoid casting "const" attribute away + +Casting "const" attribute away is dangerous, obtain a writable +pointer instead to avoid that. + +Signed-off-by: Guennadi Liakhovetski +Signed-off-by: Pierre-Louis Bossart +Link: https://lore.kernel.org/r/20211216232422.345164-2-pierre-louis.bossart@linux.intel.com +Signed-off-by: Mark Brown + +[ mikhailnov: +dropped diff for sound/soc/sof/amd/renoir.c when backporting to 5.15 +because that file does not exist ] +--- + sound/soc/sof/intel/atom.c | 13 +++++---- + sound/soc/sof/intel/atom.h | 4 +-- + sound/soc/sof/intel/bdw.c | 11 +++---- + sound/soc/sof/intel/hda.c | 60 ++++++++++++++++++-------------------- + sound/soc/sof/intel/hda.h | 4 +-- + sound/soc/sof/ops.h | 8 +++-- + sound/soc/sof/sof-audio.c | 9 +++--- + sound/soc/sof/sof-priv.h | 4 +-- + 8 files changed, 58 insertions(+), 55 deletions(-) + +diff --git a/sound/soc/sof/intel/atom.c b/sound/soc/sof/intel/atom.c +index d8804efed..f2c1dcecb 100644 +--- a/sound/soc/sof/intel/atom.c ++++ b/sound/soc/sof/intel/atom.c +@@ -337,7 +337,7 @@ static const char *fixup_tplg_name(struct snd_sof_dev *sdev, + return tplg_filename; + } + +-void atom_machine_select(struct snd_sof_dev *sdev) ++struct snd_soc_acpi_mach *atom_machine_select(struct snd_sof_dev *sdev) + { + struct snd_sof_pdata *sof_pdata = sdev->pdata; + const struct sof_dev_desc *desc = sof_pdata->desc; +@@ -348,7 +348,7 @@ void atom_machine_select(struct snd_sof_dev *sdev) + mach = snd_soc_acpi_find_machine(desc->machines); + if (!mach) { + dev_warn(sdev->dev, "warning: No matching ASoC machine driver found\n"); +- return; ++ return NULL; + } + + pdev = to_platform_device(sdev->dev); +@@ -366,12 +366,13 @@ void atom_machine_select(struct snd_sof_dev *sdev) + if (!tplg_filename) { + dev_dbg(sdev->dev, + "error: no topology filename\n"); +- return; ++ return NULL; + } + + sof_pdata->tplg_filename = tplg_filename; + mach->mach_params.acpi_ipc_irq_index = desc->irqindex_host_ipc; +- sof_pdata->machine = mach; ++ ++ return mach; + } + EXPORT_SYMBOL_NS(atom_machine_select, SND_SOC_SOF_INTEL_ATOM_HIFI_EP); + +@@ -446,14 +447,14 @@ struct snd_soc_dai_driver atom_dai[] = { + }; + EXPORT_SYMBOL_NS(atom_dai, SND_SOC_SOF_INTEL_ATOM_HIFI_EP); + +-void atom_set_mach_params(const struct snd_soc_acpi_mach *mach, ++void atom_set_mach_params(struct snd_soc_acpi_mach *mach, + struct snd_sof_dev *sdev) + { + struct snd_sof_pdata *pdata = sdev->pdata; + const struct sof_dev_desc *desc = pdata->desc; + struct snd_soc_acpi_mach_params *mach_params; + +- mach_params = (struct snd_soc_acpi_mach_params *)&mach->mach_params; ++ mach_params = &mach->mach_params; + mach_params->platform = dev_name(sdev->dev); + mach_params->num_dai_drivers = desc->ops->num_drv; + mach_params->dai_drivers = desc->ops->drv; +diff --git a/sound/soc/sof/intel/atom.h b/sound/soc/sof/intel/atom.h +index 96a462c7a..b965e5e08 100644 +--- a/sound/soc/sof/intel/atom.h ++++ b/sound/soc/sof/intel/atom.h +@@ -65,8 +65,8 @@ int atom_run(struct snd_sof_dev *sdev); + int atom_reset(struct snd_sof_dev *sdev); + void atom_dump(struct snd_sof_dev *sdev, u32 flags); + +-void atom_machine_select(struct snd_sof_dev *sdev); +-void atom_set_mach_params(const struct snd_soc_acpi_mach *mach, ++struct snd_soc_acpi_mach *atom_machine_select(struct snd_sof_dev *sdev); ++void atom_set_mach_params(struct snd_soc_acpi_mach *mach, + struct snd_sof_dev *sdev); + + extern struct snd_soc_dai_driver atom_dai[]; +diff --git a/sound/soc/sof/intel/bdw.c b/sound/soc/sof/intel/bdw.c +index 89a6c1f04..5e06a5876 100644 +--- a/sound/soc/sof/intel/bdw.c ++++ b/sound/soc/sof/intel/bdw.c +@@ -541,7 +541,7 @@ static int bdw_probe(struct snd_sof_dev *sdev) + return ret; + } + +-static void bdw_machine_select(struct snd_sof_dev *sdev) ++static struct snd_soc_acpi_mach *bdw_machine_select(struct snd_sof_dev *sdev) + { + struct snd_sof_pdata *sof_pdata = sdev->pdata; + const struct sof_dev_desc *desc = sof_pdata->desc; +@@ -550,22 +550,23 @@ static void bdw_machine_select(struct snd_sof_dev *sdev) + mach = snd_soc_acpi_find_machine(desc->machines); + if (!mach) { + dev_warn(sdev->dev, "warning: No matching ASoC machine driver found\n"); +- return; ++ return NULL; + } + + sof_pdata->tplg_filename = mach->sof_tplg_filename; + mach->mach_params.acpi_ipc_irq_index = desc->irqindex_host_ipc; +- sof_pdata->machine = mach; ++ ++ return mach; + } + +-static void bdw_set_mach_params(const struct snd_soc_acpi_mach *mach, ++static void bdw_set_mach_params(struct snd_soc_acpi_mach *mach, + struct snd_sof_dev *sdev) + { + struct snd_sof_pdata *pdata = sdev->pdata; + const struct sof_dev_desc *desc = pdata->desc; + struct snd_soc_acpi_mach_params *mach_params; + +- mach_params = (struct snd_soc_acpi_mach_params *)&mach->mach_params; ++ mach_params = &mach->mach_params; + mach_params->platform = dev_name(sdev->dev); + mach_params->num_dai_drivers = desc->ops->num_drv; + mach_params->dai_drivers = desc->ops->drv; +diff --git a/sound/soc/sof/intel/hda.c b/sound/soc/sof/intel/hda.c +index c2062d4d8..7efbe6125 100644 +--- a/sound/soc/sof/intel/hda.c ++++ b/sound/soc/sof/intel/hda.c +@@ -1006,7 +1006,8 @@ int hda_dsp_remove(struct snd_sof_dev *sdev) + } + + #if IS_ENABLED(CONFIG_SND_SOC_SOF_HDA) +-static int hda_generic_machine_select(struct snd_sof_dev *sdev) ++static void hda_generic_machine_select(struct snd_sof_dev *sdev, ++ struct snd_soc_acpi_mach **mach) + { + struct hdac_bus *bus = sof_to_bus(sdev); + struct snd_soc_acpi_mach_params *mach_params; +@@ -1038,7 +1039,7 @@ static int hda_generic_machine_select(struct snd_sof_dev *sdev) + * - one HDMI codec, and/or + * - one external HDAudio codec + */ +- if (!pdata->machine && codec_num <= 2) { ++ if (!*mach && codec_num <= 2) { + hda_mach = snd_soc_acpi_intel_hda_machines; + + dev_info(bus->dev, "using HDA machine driver %s now\n", +@@ -1053,10 +1054,9 @@ static int hda_generic_machine_select(struct snd_sof_dev *sdev) + tplg_filename = hda_mach->sof_tplg_filename; + ret = dmic_topology_fixup(sdev, &tplg_filename, idisp_str, &dmic_num); + if (ret < 0) +- return ret; ++ return; + + hda_mach->mach_params.dmic_num = dmic_num; +- pdata->machine = hda_mach; + pdata->tplg_filename = tplg_filename; + + if (codec_num == 2) { +@@ -1066,23 +1066,22 @@ static int hda_generic_machine_select(struct snd_sof_dev *sdev) + */ + hda_mach->mach_params.link_mask = 0; + } ++ ++ *mach = hda_mach; + } + } + + /* used by hda machine driver to create dai links */ +- if (pdata->machine) { +- mach_params = (struct snd_soc_acpi_mach_params *) +- &pdata->machine->mach_params; ++ if (*mach) { ++ mach_params = &(*mach)->mach_params; + mach_params->codec_mask = bus->codec_mask; + mach_params->common_hdmi_codec_drv = hda_codec_use_common_hdmi; + } +- +- return 0; + } + #else +-static int hda_generic_machine_select(struct snd_sof_dev *sdev) ++static void hda_generic_machine_select(struct snd_sof_dev *sdev, ++ struct snd_soc_acpi_mach **mach) + { +- return 0; + } + #endif + +@@ -1170,7 +1169,7 @@ static bool link_slaves_found(struct snd_sof_dev *sdev, + return true; + } + +-static int hda_sdw_machine_select(struct snd_sof_dev *sdev) ++static struct snd_soc_acpi_mach *hda_sdw_machine_select(struct snd_sof_dev *sdev) + { + struct snd_sof_pdata *pdata = sdev->pdata; + const struct snd_soc_acpi_link_adr *link; +@@ -1188,7 +1187,7 @@ static int hda_sdw_machine_select(struct snd_sof_dev *sdev) + * machines, for mixed cases with I2C/I2S the detection relies + * on the HID list. + */ +- if (link_mask && !pdata->machine) { ++ if (link_mask) { + for (mach = pdata->desc->alt_machines; + mach && mach->link_mask; mach++) { + /* +@@ -1223,7 +1222,6 @@ static int hda_sdw_machine_select(struct snd_sof_dev *sdev) + if (mach && mach->link_mask) { + int dmic_num = 0; + +- pdata->machine = mach; + mach->mach_params.links = mach->links; + mach->mach_params.link_mask = mach->link_mask; + mach->mach_params.platform = dev_name(sdev->dev); +@@ -1245,9 +1243,8 @@ static int hda_sdw_machine_select(struct snd_sof_dev *sdev) + int ret; + + ret = dmic_topology_fixup(sdev, &tplg_filename, "", &dmic_num); +- + if (ret < 0) +- return ret; ++ return NULL; + + pdata->tplg_filename = tplg_filename; + } +@@ -1257,35 +1254,36 @@ static int hda_sdw_machine_select(struct snd_sof_dev *sdev) + "SoundWire machine driver %s topology %s\n", + mach->drv_name, + pdata->tplg_filename); +- } else { +- dev_info(sdev->dev, +- "No SoundWire machine driver found\n"); ++ ++ return mach; + } ++ ++ dev_info(sdev->dev, "No SoundWire machine driver found\n"); + } + +- return 0; ++ return NULL; + } + #else +-static int hda_sdw_machine_select(struct snd_sof_dev *sdev) ++static struct snd_soc_acpi_mach *hda_sdw_machine_select(struct snd_sof_dev *sdev) + { +- return 0; ++ return NULL; + } + #endif + +-void hda_set_mach_params(const struct snd_soc_acpi_mach *mach, ++void hda_set_mach_params(struct snd_soc_acpi_mach *mach, + struct snd_sof_dev *sdev) + { + struct snd_sof_pdata *pdata = sdev->pdata; + const struct sof_dev_desc *desc = pdata->desc; + struct snd_soc_acpi_mach_params *mach_params; + +- mach_params = (struct snd_soc_acpi_mach_params *)&mach->mach_params; ++ mach_params = &mach->mach_params; + mach_params->platform = dev_name(sdev->dev); + mach_params->num_dai_drivers = desc->ops->num_drv; + mach_params->dai_drivers = desc->ops->drv; + } + +-void hda_machine_select(struct snd_sof_dev *sdev) ++struct snd_soc_acpi_mach *hda_machine_select(struct snd_sof_dev *sdev) + { + struct snd_sof_pdata *sof_pdata = sdev->pdata; + const struct sof_dev_desc *desc = sof_pdata->desc; +@@ -1303,8 +1301,6 @@ void hda_machine_select(struct snd_sof_dev *sdev) + if (!sof_pdata->tplg_filename) + sof_pdata->tplg_filename = mach->sof_tplg_filename; + +- sof_pdata->machine = mach; +- + if (mach->tplg_quirk_mask & SND_SOC_ACPI_TPLG_INTEL_DMIC_NUMBER && + mach->mach_params.dmic_num) { + tplg_filename = devm_kasprintf(sdev->dev, GFP_KERNEL, +@@ -1366,16 +1362,18 @@ void hda_machine_select(struct snd_sof_dev *sdev) + /* + * If I2S fails, try SoundWire + */ +- hda_sdw_machine_select(sdev); ++ if (!mach) ++ mach = hda_sdw_machine_select(sdev); + + /* + * Choose HDA generic machine driver if mach is NULL. + * Otherwise, set certain mach params. + */ +- hda_generic_machine_select(sdev); +- +- if (!sof_pdata->machine) ++ hda_generic_machine_select(sdev, &mach); ++ if (!mach) + dev_warn(sdev->dev, "warning: No matching ASoC machine driver found\n"); ++ ++ return mach; + } + + int hda_pci_intel_probe(struct pci_dev *pci, const struct pci_device_id *pci_id) +diff --git a/sound/soc/sof/intel/hda.h b/sound/soc/sof/intel/hda.h +index 4fdfb1086..9091c7f38 100644 +--- a/sound/soc/sof/intel/hda.h ++++ b/sound/soc/sof/intel/hda.h +@@ -767,8 +767,8 @@ extern const struct sof_intel_dsp_desc jsl_chip_info; + extern const struct sof_intel_dsp_desc adls_chip_info; + + /* machine driver select */ +-void hda_machine_select(struct snd_sof_dev *sdev); +-void hda_set_mach_params(const struct snd_soc_acpi_mach *mach, ++struct snd_soc_acpi_mach *hda_machine_select(struct snd_sof_dev *sdev); ++void hda_set_mach_params(struct snd_soc_acpi_mach *mach, + struct snd_sof_dev *sdev); + + /* PCI driver selection and probe */ +diff --git a/sound/soc/sof/ops.h b/sound/soc/sof/ops.h +index 4a5d6e497..96833cde0 100644 +--- a/sound/soc/sof/ops.h ++++ b/sound/soc/sof/ops.h +@@ -488,15 +488,17 @@ snd_sof_machine_unregister(struct snd_sof_dev *sdev, void *pdata) + sof_ops(sdev)->machine_unregister(sdev, pdata); + } + +-static inline void ++static inline struct snd_soc_acpi_mach * + snd_sof_machine_select(struct snd_sof_dev *sdev) + { + if (sof_ops(sdev) && sof_ops(sdev)->machine_select) +- sof_ops(sdev)->machine_select(sdev); ++ return sof_ops(sdev)->machine_select(sdev); ++ ++ return NULL; + } + + static inline void +-snd_sof_set_mach_params(const struct snd_soc_acpi_mach *mach, ++snd_sof_set_mach_params(struct snd_soc_acpi_mach *mach, + struct snd_sof_dev *sdev) + { + if (sof_ops(sdev) && sof_ops(sdev)->set_mach_params) +diff --git a/sound/soc/sof/sof-audio.c b/sound/soc/sof/sof-audio.c +index 989912f2b..10e39777d 100644 +--- a/sound/soc/sof/sof-audio.c ++++ b/sound/soc/sof/sof-audio.c +@@ -500,9 +500,10 @@ int sof_machine_check(struct snd_sof_dev *sdev) + if (!IS_ENABLED(CONFIG_SND_SOC_SOF_FORCE_NOCODEC_MODE)) { + + /* find machine */ +- snd_sof_machine_select(sdev); +- if (sof_pdata->machine) { +- snd_sof_set_mach_params(sof_pdata->machine, sdev); ++ mach = snd_sof_machine_select(sdev); ++ if (mach) { ++ sof_pdata->machine = mach; ++ snd_sof_set_mach_params(mach, sdev); + return 0; + } + +@@ -524,7 +525,7 @@ int sof_machine_check(struct snd_sof_dev *sdev) + sof_pdata->tplg_filename = desc->nocodec_tplg_filename; + + sof_pdata->machine = mach; +- snd_sof_set_mach_params(sof_pdata->machine, sdev); ++ snd_sof_set_mach_params(mach, sdev); + + return 0; + } +diff --git a/sound/soc/sof/sof-priv.h b/sound/soc/sof/sof-priv.h +index fd8423172..eb67a9b46 100644 +--- a/sound/soc/sof/sof-priv.h ++++ b/sound/soc/sof/sof-priv.h +@@ -257,8 +257,8 @@ struct snd_sof_dsp_ops { + void *pdata); /* optional */ + void (*machine_unregister)(struct snd_sof_dev *sdev, + void *pdata); /* optional */ +- void (*machine_select)(struct snd_sof_dev *sdev); /* optional */ +- void (*set_mach_params)(const struct snd_soc_acpi_mach *mach, ++ struct snd_soc_acpi_mach * (*machine_select)(struct snd_sof_dev *sdev); /* optional */ ++ void (*set_mach_params)(struct snd_soc_acpi_mach *mach, + struct snd_sof_dev *sdev); /* optional */ + + /* DAI ops */ +-- +2.35.2 + diff --git a/0432-ALSA-intel-dsp-config-add-more-ACPI-HIDs-for-ES83x6-.patch b/0432-ALSA-intel-dsp-config-add-more-ACPI-HIDs-for-ES83x6-.patch new file mode 100644 index 0000000..261151c --- /dev/null +++ b/0432-ALSA-intel-dsp-config-add-more-ACPI-HIDs-for-ES83x6-.patch @@ -0,0 +1,125 @@ +From c1d0ad8fe95a87c8514558591b82deee04024729 Mon Sep 17 00:00:00 2001 +From: Pierre-Louis Bossart +Date: Tue, 8 Mar 2022 13:25:57 -0600 +Subject: [PATCH 432/432] ALSA: intel-dsp-config: add more ACPI HIDs for ES83x6 + devices +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +We only saw ESSX8336 so far, but now with reports of 'ESSX8326' we +need to expand to a full list. Let's reuse the 'snd_soc_acpi_codecs' +structure to store the information. + +Reported-by: anthony tonitch +Signed-off-by: Pierre-Louis Bossart +Reviewed-by: Bard Liao +Reviewed-by: Péter Ujfalusi +Acked-by: Takashi Iwai +Link: https://lore.kernel.org/r/20220308192610.392950-8-pierre-louis.bossart@linux.intel.com +Signed-off-by: Mark Brown +--- + sound/hda/intel-dsp-config.c | 31 ++++++++++++++++++++++--------- + 1 file changed, 22 insertions(+), 9 deletions(-) + +diff --git a/sound/hda/intel-dsp-config.c b/sound/hda/intel-dsp-config.c +index f63114317..036ba4889 100644 +--- a/sound/hda/intel-dsp-config.c ++++ b/sound/hda/intel-dsp-config.c +@@ -11,6 +11,7 @@ + #include + #include + #include ++#include + + static int dsp_driver; + +@@ -31,7 +32,12 @@ struct config_entry { + u16 device; + u8 acpi_hid[ACPI_ID_LEN]; + const struct dmi_system_id *dmi_table; +- u8 codec_hid[ACPI_ID_LEN]; ++ const struct snd_soc_acpi_codecs *codec_hid; ++}; ++ ++static const struct snd_soc_acpi_codecs __maybe_unused essx_83x6 = { ++ .num_codecs = 3, ++ .codecs = { "ESSX8316", "ESSX8326", "ESSX8336"}, + }; + + /* +@@ -77,7 +83,7 @@ static const struct config_entry config_table[] = { + { + .flags = FLAG_SOF, + .device = 0x5a98, +- .codec_hid = "ESSX8336", ++ .codec_hid = &essx_83x6, + }, + #endif + #if IS_ENABLED(CONFIG_SND_SOC_INTEL_APL) +@@ -163,7 +169,7 @@ static const struct config_entry config_table[] = { + { + .flags = FLAG_SOF, + .device = 0x3198, +- .codec_hid = "ESSX8336", ++ .codec_hid = &essx_83x6, + }, + #endif + +@@ -251,7 +257,7 @@ static const struct config_entry config_table[] = { + { + .flags = FLAG_SOF, + .device = 0x02c8, +- .codec_hid = "ESSX8336", ++ .codec_hid = &essx_83x6, + }, + { + .flags = FLAG_SOF | FLAG_SOF_ONLY_IF_DMIC_OR_SOUNDWIRE, +@@ -280,7 +286,7 @@ static const struct config_entry config_table[] = { + { + .flags = FLAG_SOF, + .device = 0x06c8, +- .codec_hid = "ESSX8336", ++ .codec_hid = &essx_83x6, + }, + { + .flags = FLAG_SOF | FLAG_SOF_ONLY_IF_DMIC_OR_SOUNDWIRE, +@@ -314,7 +320,7 @@ static const struct config_entry config_table[] = { + { + .flags = FLAG_SOF, + .device = 0x4dc8, +- .codec_hid = "ESSX8336", ++ .codec_hid = &essx_83x6, + }, + #endif + +@@ -336,7 +342,7 @@ static const struct config_entry config_table[] = { + { + .flags = FLAG_SOF, + .device = 0xa0c8, +- .codec_hid = "ESSX8336", ++ .codec_hid = &essx_83x6, + }, + { + .flags = FLAG_SOF | FLAG_SOF_ONLY_IF_DMIC_OR_SOUNDWIRE, +@@ -389,8 +395,15 @@ 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; ++ if (table->codec_hid) { ++ int i; ++ ++ for (i = 0; i < table->codec_hid->num_codecs; i++) ++ if (acpi_dev_present(table->codec_hid->codecs[i], NULL, -1)) ++ break; ++ if (i == table->codec_hid->num_codecs) ++ continue; ++ } + return table; + } + return NULL; +-- +2.35.2 + diff --git a/0433-ASoC-soc-acpi-add-comp_ids-field-for-machine-driver-.patch b/0433-ASoC-soc-acpi-add-comp_ids-field-for-machine-driver-.patch new file mode 100644 index 0000000..f9fb08f --- /dev/null +++ b/0433-ASoC-soc-acpi-add-comp_ids-field-for-machine-driver-.patch @@ -0,0 +1,85 @@ +From 2741c914411cdc260eafe7887536e80d9d1c6966 Mon Sep 17 00:00:00 2001 +From: Brent Lu +Date: Sat, 30 Oct 2021 01:14:04 +0800 +Subject: [PATCH 433/435] ASoC: soc-acpi: add comp_ids field for machine driver + matching + +A machine driver needs to be enumerated by more than one ACPI HID if +it supports second headphone driver (i.e. rt5682 and rt5682s). +However, the id field in snd_soc_acpi_mach structure could contain +only one HID. By adding a 'comp_ids' field which can contain several +HIDs, we can enumerate a machine driver by multiple ACPI HIDs. + +Signed-off-by: Brent Lu +Link: https://lore.kernel.org/r/20211029171409.611600-2-brent.lu@intel.com +Signed-off-by: Mark Brown +--- + include/sound/soc-acpi.h | 3 +++ + sound/soc/soc-acpi.c | 24 ++++++++++++++++++++++-- + 2 files changed, 25 insertions(+), 2 deletions(-) + +diff --git a/include/sound/soc-acpi.h b/include/sound/soc-acpi.h +index d4fecd025..20958aedc 100644 +--- a/include/sound/soc-acpi.h ++++ b/include/sound/soc-acpi.h +@@ -150,6 +150,8 @@ struct snd_soc_acpi_link_adr { + * all firmware/topology related fields. + * + * @id: ACPI ID (usually the codec's) used to find a matching machine driver. ++ * @comp_ids: list of compatible audio codecs using the same machine driver, ++ * firmware and topology + * @link_mask: describes required board layout, e.g. for SoundWire. + * @links: array of link _ADR descriptors, null terminated. + * @drv_name: machine driver name +@@ -168,6 +170,7 @@ struct snd_soc_acpi_link_adr { + /* Descriptor for SST ASoC machine driver */ + struct snd_soc_acpi_mach { + const u8 id[ACPI_ID_LEN]; ++ const struct snd_soc_acpi_codecs *comp_ids; + const u32 link_mask; + const struct snd_soc_acpi_link_adr *links; + const char *drv_name; +diff --git a/sound/soc/soc-acpi.c b/sound/soc/soc-acpi.c +index 395229bf5..2ae99b49d 100644 +--- a/sound/soc/soc-acpi.c ++++ b/sound/soc/soc-acpi.c +@@ -8,14 +8,34 @@ + #include + #include + ++static bool snd_soc_acpi_id_present(struct snd_soc_acpi_mach *machine) ++{ ++ const struct snd_soc_acpi_codecs *comp_ids = machine->comp_ids; ++ int i; ++ ++ if (machine->id[0]) { ++ if (acpi_dev_present(machine->id, NULL, -1)) ++ return true; ++ } ++ ++ if (comp_ids) { ++ for (i = 0; i < comp_ids->num_codecs; i++) { ++ if (acpi_dev_present(comp_ids->codecs[i], NULL, -1)) ++ return true; ++ } ++ } ++ ++ return false; ++} ++ + struct snd_soc_acpi_mach * + snd_soc_acpi_find_machine(struct snd_soc_acpi_mach *machines) + { + struct snd_soc_acpi_mach *mach; + struct snd_soc_acpi_mach *mach_alt; + +- for (mach = machines; mach->id[0]; mach++) { +- if (acpi_dev_present(mach->id, NULL, -1)) { ++ for (mach = machines; mach->id[0] || mach->comp_ids; mach++) { ++ if (snd_soc_acpi_id_present(mach)) { + if (mach->machine_quirk) { + mach_alt = mach->machine_quirk(mach); + if (!mach_alt) +-- +2.35.2 + diff --git a/0434-ALSA-hda-intel-dsp-config-update-AlderLake-PCI-IDs.patch b/0434-ALSA-hda-intel-dsp-config-update-AlderLake-PCI-IDs.patch new file mode 100644 index 0000000..ea381ad --- /dev/null +++ b/0434-ALSA-hda-intel-dsp-config-update-AlderLake-PCI-IDs.patch @@ -0,0 +1,68 @@ +From ba8dd3ed39111ad502e4bcf4f163aba178395ef2 Mon Sep 17 00:00:00 2001 +From: Pierre-Louis Bossart +Date: Wed, 6 Apr 2022 14:04:18 -0500 +Subject: [PATCH 434/435] ALSA: hda: intel-dsp-config: update AlderLake PCI IDs + +Add missing AlderLake-PS and RaptorLake-S PCI IDs (already in HDaudio +and SOF drivers), add comments and regroup by skew. + +Signed-off-by: Pierre-Louis Bossart +Reviewed-by: Kai Vehmanen +Reviewed-by: Ranjani Sridharan +Link: https://lore.kernel.org/r/20220406190418.245044-1-pierre-louis.bossart@linux.intel.com +Signed-off-by: Takashi Iwai + +[ mikhailnov: +copied from https://github.com/torvalds/linux/blob/d52eee988597ac2a2c5d17d842946616d7d41070/sound/hda/intel-dsp-config.c ] +--- + sound/hda/intel-dsp-config.c | 22 ++++++++++++++++++++++ + 1 file changed, 22 insertions(+) + +diff --git a/sound/hda/intel-dsp-config.c b/sound/hda/intel-dsp-config.c +index 036ba4889..3257dc8a3 100644 +--- a/sound/hda/intel-dsp-config.c ++++ b/sound/hda/intel-dsp-config.c +@@ -368,18 +368,40 @@ static const struct config_entry config_table[] = { + + /* Alder Lake */ + #if IS_ENABLED(CONFIG_SND_SOC_SOF_ALDERLAKE) ++ /* Alderlake-S */ + { + .flags = FLAG_SOF | FLAG_SOF_ONLY_IF_DMIC_OR_SOUNDWIRE, + .device = 0x7ad0, + }, ++ /* RaptorLake-S */ ++ { ++ .flags = FLAG_SOF | FLAG_SOF_ONLY_IF_DMIC_OR_SOUNDWIRE, ++ .device = 0x7a50, ++ }, ++ /* Alderlake-P */ + { + .flags = FLAG_SOF | FLAG_SOF_ONLY_IF_DMIC_OR_SOUNDWIRE, + .device = 0x51c8, + }, ++ { ++ .flags = FLAG_SOF | FLAG_SOF_ONLY_IF_DMIC_OR_SOUNDWIRE, ++ .device = 0x51cd, ++ }, ++ /* Alderlake-PS */ ++ { ++ .flags = FLAG_SOF | FLAG_SOF_ONLY_IF_DMIC_OR_SOUNDWIRE, ++ .device = 0x51c9, ++ }, ++ /* Alderlake-M */ + { + .flags = FLAG_SOF | FLAG_SOF_ONLY_IF_DMIC_OR_SOUNDWIRE, + .device = 0x51cc, + }, ++ /* Alderlake-N */ ++ { ++ .flags = FLAG_SOF | FLAG_SOF_ONLY_IF_DMIC_OR_SOUNDWIRE, ++ .device = 0x54c8, ++ }, + #endif + + }; +-- +2.35.2 + diff --git a/0435-ASoC-Intel-soc-acpi-Add-entry-for-sof_es8336-in-ADL-.patch b/0435-ASoC-Intel-soc-acpi-Add-entry-for-sof_es8336-in-ADL-.patch new file mode 100644 index 0000000..36e7a9a --- /dev/null +++ b/0435-ASoC-Intel-soc-acpi-Add-entry-for-sof_es8336-in-ADL-.patch @@ -0,0 +1,68 @@ +From 6de8fe7791362d1db4c0bfcb0629ac192ae63af0 Mon Sep 17 00:00:00 2001 +From: Muralidhar Reddy +Date: Mon, 25 Jul 2022 14:49:01 -0500 +Subject: [PATCH 435/435] ASoC: Intel: soc-acpi: Add entry for sof_es8336 in + ADL match table + +Adding support for ES83x6 codec in ADL match table + +Reviewed-by: Bard Liao +Signed-off-by: Muralidhar Reddy +Signed-off-by: Pierre-Louis Bossart +Link: https://lore.kernel.org/r/20220725194909.145418-3-pierre-louis.bossart@linux.intel.com +Signed-off-by: Mark Brown +--- + sound/hda/intel-dsp-config.c | 5 +++++ + sound/soc/intel/common/soc-acpi-intel-adl-match.c | 13 +++++++++++++ + 2 files changed, 18 insertions(+) + +diff --git a/sound/hda/intel-dsp-config.c b/sound/hda/intel-dsp-config.c +index 3257dc8a3..08390a029 100644 +--- a/sound/hda/intel-dsp-config.c ++++ b/sound/hda/intel-dsp-config.c +@@ -379,6 +379,11 @@ static const struct config_entry config_table[] = { + .device = 0x7a50, + }, + /* Alderlake-P */ ++ { ++ .flags = FLAG_SOF, ++ .device = 0x51c8, ++ .codec_hid = &essx_83x6, ++ }, + { + .flags = FLAG_SOF | FLAG_SOF_ONLY_IF_DMIC_OR_SOUNDWIRE, + .device = 0x51c8, +diff --git a/sound/soc/intel/common/soc-acpi-intel-adl-match.c b/sound/soc/intel/common/soc-acpi-intel-adl-match.c +index ca5a34471..8d76dc6f3 100644 +--- a/sound/soc/intel/common/soc-acpi-intel-adl-match.c ++++ b/sound/soc/intel/common/soc-acpi-intel-adl-match.c +@@ -8,6 +8,11 @@ + #include + #include + ++static const struct snd_soc_acpi_codecs essx_83x6 = { ++ .num_codecs = 3, ++ .codecs = { "ESSX8316", "ESSX8326", "ESSX8336"}, ++}; ++ + static const struct snd_soc_acpi_endpoint single_endpoint = { + .num = 0, + .aggregated = 0, +@@ -352,6 +357,14 @@ struct snd_soc_acpi_mach snd_soc_acpi_intel_adl_sdw_machines[] = { + .sof_fw_filename = "sof-adl.ri", + .sof_tplg_filename = "sof-adl-sdw-max98373-rt5682.tplg", + }, ++ { ++ .comp_ids = &essx_83x6, ++ .drv_name = "sof-essx8336", ++ .sof_tplg_filename = "sof-adl-es83x6", /* the tplg suffix is added at run time */ ++ .tplg_quirk_mask = SND_SOC_ACPI_TPLG_INTEL_SSP_NUMBER | ++ SND_SOC_ACPI_TPLG_INTEL_SSP_MSB | ++ SND_SOC_ACPI_TPLG_INTEL_DMIC_NUMBER, ++ }, + {}, + }; + EXPORT_SYMBOL_GPL(snd_soc_acpi_intel_adl_sdw_machines); +-- +2.35.2 + diff --git a/0436-ALSA-intel-nhlt-add-helper-to-detect-SSP-link-mask.patch b/0436-ALSA-intel-nhlt-add-helper-to-detect-SSP-link-mask.patch new file mode 100644 index 0000000..c748d4c --- /dev/null +++ b/0436-ALSA-intel-nhlt-add-helper-to-detect-SSP-link-mask.patch @@ -0,0 +1,125 @@ +From 048c23cfceace501f667ed8ff9da4c5978a47550 Mon Sep 17 00:00:00 2001 +From: Pierre-Louis Bossart +Date: Tue, 8 Mar 2022 13:25:54 -0600 +Subject: [PATCH] ALSA: intel-nhlt: add helper to detect SSP link mask +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +The NHLT information can be used to figure out which SSPs are enabled +in a platform. + +The 'SSP' link type is too broad for machine drivers, since it can +cover the Bluetooth sideband and the analog audio codec connections, +so this helper exposes a parameter to filter with the device +type (DEVICE_I2S refers to analog audio codec in NHLT parlance). + +The helper returns a mask, since more than one SSP may be used for +analog audio, e.g. the NHLT spec describes the use of SSP0 for +amplifiers and SSP1 for headset codec. Note that if more than one bit +is set, it's impossible to determine which SSP is connected to what +external component. Additional platform-specific information based on +e.g. DMI quirks would still be required in the machine driver to +configure the relevant dailinks. + +Signed-off-by: Pierre-Louis Bossart +Reviewed-by: Bard Liao +Reviewed-by: Péter Ujfalusi +Acked-by: Takashi Iwai +Link: https://lore.kernel.org/r/20220308192610.392950-5-pierre-louis.bossart@linux.intel.com +Signed-off-by: Mark Brown +--- + include/sound/intel-nhlt.h | 22 +++++++++++++++------- + sound/hda/intel-nhlt.c | 22 ++++++++++++++++++++++ + 2 files changed, 37 insertions(+), 7 deletions(-) + +diff --git a/include/sound/intel-nhlt.h b/include/sound/intel-nhlt.h +index 089a760d3..6fb2d5e37 100644 +--- a/include/sound/intel-nhlt.h ++++ b/include/sound/intel-nhlt.h +@@ -18,6 +18,13 @@ enum nhlt_link_type { + NHLT_LINK_INVALID + }; + ++enum nhlt_device_type { ++ NHLT_DEVICE_BT = 0, ++ NHLT_DEVICE_DMIC = 1, ++ NHLT_DEVICE_I2S = 4, ++ NHLT_DEVICE_INVALID ++}; ++ + #if IS_ENABLED(CONFIG_ACPI) && IS_ENABLED(CONFIG_SND_INTEL_NHLT) + + struct wav_fmt { +@@ -41,13 +48,6 @@ struct wav_fmt_ext { + u8 sub_fmt[16]; + } __packed; + +-enum nhlt_device_type { +- NHLT_DEVICE_BT = 0, +- NHLT_DEVICE_DMIC = 1, +- NHLT_DEVICE_I2S = 4, +- NHLT_DEVICE_INVALID +-}; +- + struct nhlt_specific_cfg { + u32 size; + u8 caps[]; +@@ -133,6 +133,9 @@ void intel_nhlt_free(struct nhlt_acpi_table *addr); + int intel_nhlt_get_dmic_geo(struct device *dev, struct nhlt_acpi_table *nhlt); + + bool intel_nhlt_has_endpoint_type(struct nhlt_acpi_table *nhlt, u8 link_type); ++ ++int intel_nhlt_ssp_endpoint_mask(struct nhlt_acpi_table *nhlt, u8 device_type); ++ + struct nhlt_specific_cfg * + intel_nhlt_get_endpoint_blob(struct device *dev, struct nhlt_acpi_table *nhlt, + u32 bus_id, u8 link_type, u8 vbps, u8 bps, +@@ -163,6 +166,11 @@ static inline bool intel_nhlt_has_endpoint_type(struct nhlt_acpi_table *nhlt, + return false; + } + ++static inline int intel_nhlt_ssp_endpoint_mask(struct nhlt_acpi_table *nhlt, u8 device_type) ++{ ++ return 0; ++} ++ + static inline struct nhlt_specific_cfg * + intel_nhlt_get_endpoint_blob(struct device *dev, struct nhlt_acpi_table *nhlt, + u32 bus_id, u8 link_type, u8 vbps, u8 bps, +diff --git a/sound/hda/intel-nhlt.c b/sound/hda/intel-nhlt.c +index 128476aa7..4063da378 100644 +--- a/sound/hda/intel-nhlt.c ++++ b/sound/hda/intel-nhlt.c +@@ -130,6 +130,28 @@ bool intel_nhlt_has_endpoint_type(struct nhlt_acpi_table *nhlt, u8 link_type) + } + EXPORT_SYMBOL(intel_nhlt_has_endpoint_type); + ++int intel_nhlt_ssp_endpoint_mask(struct nhlt_acpi_table *nhlt, u8 device_type) ++{ ++ struct nhlt_endpoint *epnt; ++ int ssp_mask = 0; ++ int i; ++ ++ if (!nhlt || (device_type != NHLT_DEVICE_BT && device_type != NHLT_DEVICE_I2S)) ++ return 0; ++ ++ epnt = (struct nhlt_endpoint *)nhlt->desc; ++ for (i = 0; i < nhlt->endpoint_count; i++) { ++ if (epnt->linktype == NHLT_LINK_SSP && epnt->device_type == device_type) { ++ /* for SSP the virtual bus id is the SSP port */ ++ ssp_mask |= BIT(epnt->virtual_bus_id); ++ } ++ epnt = (struct nhlt_endpoint *)((u8 *)epnt + epnt->length); ++ } ++ ++ return ssp_mask; ++} ++EXPORT_SYMBOL(intel_nhlt_ssp_endpoint_mask); ++ + static struct nhlt_specific_cfg * + nhlt_get_specific_cfg(struct device *dev, struct nhlt_fmt *fmt, u8 num_ch, + u32 rate, u8 vbps, u8 bps) +-- +2.35.2 + diff --git a/kernel-arm64.config b/kernel-arm64.config index f8f7a92..4e12707 100644 --- a/kernel-arm64.config +++ b/kernel-arm64.config @@ -1,15 +1,15 @@ # # Automatically generated file; DO NOT EDIT. -# Linux/arm64 5.15.53 Kernel Configuration +# Linux/arm64 5.15.65 Kernel Configuration # CONFIG_CC_VERSION_TEXT="gcc (GCC) 11.2.0 20210728 (ROSA)" CONFIG_CC_IS_GCC=y CONFIG_GCC_VERSION=110200 CONFIG_CLANG_VERSION=0 CONFIG_AS_IS_GNU=y -CONFIG_AS_VERSION=23700 +CONFIG_AS_VERSION=23800 CONFIG_LD_IS_BFD=y -CONFIG_LD_VERSION=23700 +CONFIG_LD_VERSION=23800 CONFIG_LLD_VERSION=0 CONFIG_CC_CAN_LINK=y CONFIG_CC_CAN_LINK_STATIC=y @@ -367,6 +367,7 @@ CONFIG_ARM64_ERRATUM_1286807=y CONFIG_ARM64_ERRATUM_1463225=y CONFIG_ARM64_ERRATUM_1542419=y CONFIG_ARM64_ERRATUM_1508412=y +CONFIG_ARM64_ERRATUM_2441009=y CONFIG_CAVIUM_ERRATUM_22375=y CONFIG_CAVIUM_ERRATUM_23144=y CONFIG_CAVIUM_ERRATUM_23154=y @@ -705,6 +706,7 @@ CONFIG_HAVE_KRETPROBES=y CONFIG_HAVE_FUNCTION_ERROR_INJECTION=y CONFIG_HAVE_NMI=y CONFIG_TRACE_IRQFLAGS_SUPPORT=y +CONFIG_TRACE_IRQFLAGS_NMI_SUPPORT=y CONFIG_HAVE_ARCH_TRACEHOOK=y CONFIG_HAVE_DMA_CONTIGUOUS=y CONFIG_GENERIC_SMP_IDLE_THREAD=y @@ -12156,7 +12158,6 @@ CONFIG_CRYPTO_CRC32C=y CONFIG_CRYPTO_CRC32=m CONFIG_CRYPTO_XXHASH=y CONFIG_CRYPTO_BLAKE2B=y -CONFIG_CRYPTO_BLAKE2S=m CONFIG_CRYPTO_CRCT10DIF=y CONFIG_CRYPTO_GHASH=y CONFIG_CRYPTO_POLY1305=m diff --git a/kernel-i686.config b/kernel-i686.config index 3c1ffaf..3047d55 100644 --- a/kernel-i686.config +++ b/kernel-i686.config @@ -1,15 +1,15 @@ # # Automatically generated file; DO NOT EDIT. -# Linux/x86 5.15.53 Kernel Configuration +# Linux/x86 5.15.65 Kernel Configuration # CONFIG_CC_VERSION_TEXT="gcc (GCC) 11.2.0 20210728 (ROSA)" CONFIG_CC_IS_GCC=y CONFIG_GCC_VERSION=110200 CONFIG_CLANG_VERSION=0 CONFIG_AS_IS_GNU=y -CONFIG_AS_VERSION=23700 +CONFIG_AS_VERSION=23800 CONFIG_LD_IS_BFD=y -CONFIG_LD_VERSION=23700 +CONFIG_LD_VERSION=23800 CONFIG_LLD_VERSION=0 CONFIG_CC_CAN_LINK=y CONFIG_CC_CAN_LINK_STATIC=y @@ -325,7 +325,6 @@ CONFIG_SMP=y CONFIG_X86_FEATURE_NAMES=y CONFIG_X86_MPPARSE=y # CONFIG_GOLDFISH is not set -CONFIG_RETPOLINE=y CONFIG_X86_CPU_RESCTRL=y CONFIG_X86_BIGSMP=y CONFIG_X86_EXTENDED_PLATFORM=y @@ -499,6 +498,11 @@ CONFIG_HOTPLUG_CPU=y CONFIG_MODIFY_LDT_SYSCALL=y # end of Processor type and features +CONFIG_CC_HAS_RETURN_THUNK=y +CONFIG_SPECULATION_MITIGATIONS=y +CONFIG_PAGE_TABLE_ISOLATION=y +CONFIG_RETPOLINE=y +# CONFIG_RETHUNK is not set CONFIG_ARCH_MHP_MEMMAP_ON_MEMORY_ENABLE=y CONFIG_USE_PERCPU_NUMA_NODE_ID=y @@ -740,6 +744,7 @@ CONFIG_HAVE_KPROBES_ON_FTRACE=y CONFIG_HAVE_FUNCTION_ERROR_INJECTION=y CONFIG_HAVE_NMI=y CONFIG_TRACE_IRQFLAGS_SUPPORT=y +CONFIG_TRACE_IRQFLAGS_NMI_SUPPORT=y CONFIG_HAVE_ARCH_TRACEHOOK=y CONFIG_HAVE_DMA_CONTIGUOUS=y CONFIG_GENERIC_SMP_IDLE_THREAD=y @@ -7184,6 +7189,7 @@ CONFIG_SND_SOC_INTEL_SKL_HDA_DSP_GENERIC_MACH=m CONFIG_SND_SOC_INTEL_SOF_RT5682_MACH=m CONFIG_SND_SOC_INTEL_SOF_CS42L42_MACH=m CONFIG_SND_SOC_INTEL_SOF_PCM512x_MACH=m +CONFIG_SND_SOC_INTEL_SOF_ES8336_MACH=m CONFIG_SND_SOC_INTEL_CML_LP_DA7219_MAX98357A_MACH=m CONFIG_SND_SOC_INTEL_SOF_CML_RT1011_RT5682_MACH=m CONFIG_SND_SOC_INTEL_SOF_DA7219_MAX98373_MACH=m @@ -10336,7 +10342,6 @@ CONFIG_SECURITY=y CONFIG_SECURITY_WRITABLE_HOOKS=y CONFIG_SECURITYFS=y CONFIG_SECURITY_NETWORK=y -CONFIG_PAGE_TABLE_ISOLATION=y CONFIG_SECURITY_INFINIBAND=y CONFIG_SECURITY_NETWORK_XFRM=y CONFIG_SECURITY_PATH=y @@ -10516,7 +10521,6 @@ CONFIG_CRYPTO_CRC32=m CONFIG_CRYPTO_CRC32_PCLMUL=m CONFIG_CRYPTO_XXHASH=y CONFIG_CRYPTO_BLAKE2B=y -CONFIG_CRYPTO_BLAKE2S=m CONFIG_CRYPTO_CRCT10DIF=y CONFIG_CRYPTO_GHASH=y CONFIG_CRYPTO_POLY1305=m @@ -11084,7 +11088,6 @@ CONFIG_STRICT_DEVMEM=y # # x86 Debugging # -CONFIG_TRACE_IRQFLAGS_NMI_SUPPORT=y # CONFIG_X86_VERBOSE_BOOTUP is not set CONFIG_EARLY_PRINTK=y # CONFIG_EARLY_PRINTK_DBGP is not set diff --git a/kernel-x86_64.config b/kernel-x86_64.config index cb91282..26ec835 100644 --- a/kernel-x86_64.config +++ b/kernel-x86_64.config @@ -1,15 +1,15 @@ # # Automatically generated file; DO NOT EDIT. -# Linux/x86 5.15.53 Kernel Configuration +# Linux/x86 5.15.65 Kernel Configuration # CONFIG_CC_VERSION_TEXT="gcc (GCC) 11.2.0 20210728 (ROSA)" CONFIG_CC_IS_GCC=y CONFIG_GCC_VERSION=110200 CONFIG_CLANG_VERSION=0 CONFIG_AS_IS_GNU=y -CONFIG_AS_VERSION=23700 +CONFIG_AS_VERSION=23800 CONFIG_LD_IS_BFD=y -CONFIG_LD_VERSION=23700 +CONFIG_LD_VERSION=23800 CONFIG_LLD_VERSION=0 CONFIG_CC_CAN_LINK=y CONFIG_CC_CAN_LINK_STATIC=y @@ -340,7 +340,6 @@ CONFIG_X86_FEATURE_NAMES=y CONFIG_X86_X2APIC=y CONFIG_X86_MPPARSE=y # CONFIG_GOLDFISH is not set -CONFIG_RETPOLINE=y CONFIG_X86_CPU_RESCTRL=y CONFIG_X86_EXTENDED_PLATFORM=y CONFIG_X86_NUMACHIP=y @@ -512,6 +511,14 @@ CONFIG_HAVE_LIVEPATCH=y # CONFIG_LIVEPATCH is not set # end of Processor type and features +CONFIG_CC_HAS_RETURN_THUNK=y +CONFIG_SPECULATION_MITIGATIONS=y +CONFIG_PAGE_TABLE_ISOLATION=y +CONFIG_RETPOLINE=y +CONFIG_RETHUNK=y +CONFIG_CPU_UNRET_ENTRY=y +CONFIG_CPU_IBPB_ENTRY=y +CONFIG_CPU_IBRS_ENTRY=y CONFIG_ARCH_HAS_ADD_PAGES=y CONFIG_ARCH_MHP_MEMMAP_ON_MEMORY_ENABLE=y CONFIG_USE_PERCPU_NUMA_NODE_ID=y @@ -742,6 +749,7 @@ CONFIG_HAVE_KPROBES_ON_FTRACE=y CONFIG_HAVE_FUNCTION_ERROR_INJECTION=y CONFIG_HAVE_NMI=y CONFIG_TRACE_IRQFLAGS_SUPPORT=y +CONFIG_TRACE_IRQFLAGS_NMI_SUPPORT=y CONFIG_HAVE_ARCH_TRACEHOOK=y CONFIG_HAVE_DMA_CONTIGUOUS=y CONFIG_GENERIC_SMP_IDLE_THREAD=y @@ -6998,6 +7006,7 @@ CONFIG_SND_SOC_INTEL_SKL_HDA_DSP_GENERIC_MACH=m CONFIG_SND_SOC_INTEL_SOF_RT5682_MACH=m CONFIG_SND_SOC_INTEL_SOF_CS42L42_MACH=m CONFIG_SND_SOC_INTEL_SOF_PCM512x_MACH=m +CONFIG_SND_SOC_INTEL_SOF_ES8336_MACH=m CONFIG_SND_SOC_INTEL_CML_LP_DA7219_MAX98357A_MACH=m CONFIG_SND_SOC_INTEL_SOF_CML_RT1011_RT5682_MACH=m CONFIG_SND_SOC_INTEL_SOF_DA7219_MAX98373_MACH=m @@ -10178,7 +10187,6 @@ CONFIG_SECURITY=y CONFIG_SECURITY_WRITABLE_HOOKS=y CONFIG_SECURITYFS=y CONFIG_SECURITY_NETWORK=y -CONFIG_PAGE_TABLE_ISOLATION=y CONFIG_SECURITY_NETWORK_XFRM=y CONFIG_SECURITY_PATH=y CONFIG_INTEL_TXT=y @@ -10361,8 +10369,7 @@ CONFIG_CRYPTO_CRC32=m CONFIG_CRYPTO_CRC32_PCLMUL=m CONFIG_CRYPTO_XXHASH=y CONFIG_CRYPTO_BLAKE2B=y -CONFIG_CRYPTO_BLAKE2S=m -CONFIG_CRYPTO_BLAKE2S_X86=m +CONFIG_CRYPTO_BLAKE2S_X86=y CONFIG_CRYPTO_CRCT10DIF=y CONFIG_CRYPTO_CRCT10DIF_PCLMUL=m CONFIG_CRYPTO_GHASH=y @@ -10972,7 +10979,6 @@ CONFIG_STRICT_DEVMEM=y # # x86 Debugging # -CONFIG_TRACE_IRQFLAGS_NMI_SUPPORT=y # CONFIG_X86_VERBOSE_BOOTUP is not set CONFIG_EARLY_PRINTK=y # CONFIG_EARLY_PRINTK_DBGP is not set diff --git a/kernel.spec b/kernel.spec index 1e92218..4999e3d 100644 --- a/kernel.spec +++ b/kernel.spec @@ -349,17 +349,53 @@ Patch307: le9pf.diff Patch308: 0001-Revert-kallsyms-unexport-kallsyms_lookup_name-and-ka.patch # Support sound on notebook Aquarius NS685U R11 (https://linux-hardware.org/?probe=339dc3db60) -# sound/soc/intel/boards/sof_es8336.c is backported from 5.18 by Vasily Vinogradov +# First 2 patches are from Aquarius. +# The next ones are cherry-picked commits from v5.16+, all commits except 19aed2d6cd from: +# https://github.com/torvalds/linux/commits/0066f1b0e/sound/soc/intel/boards/sof_es8336.c # Also needed to make sound work: # 1) alsa-ucm-conf (SRPM alsa-lib) (ucm2/Intel/sof-essx8336/HiFi.conf) also has to be patched # https://abf.io/import/alsa-lib/commit/0cc7a15f10ef20dbedba94c14ef614a8c64c1882 # 2) firmware sof-cml-es8336.tplg is added into alsa-sof-firmware # https://abf.io/import/alsa-sof-firmware/commit/6fa57e82492d3ddede7af7b78aeeb5a0c230db4b -# 3) echo "options snd_soc_sof_es8336 quirk=0x40" > /etc/modprobe.d/sof-essx8336.conf -# TODO: automate this quirk by adding into sof_es8336_quirk_table in sound/soc/intel/boards/sof_es8336.c -Patch0401: 0401-ASoC-Intel-add-machine-driver-for-SOF-ES8336.patch -Patch0402: 0402-ASoC-es8316-Add-power-management.patch -Patch0403: 0403-ASoC-es8316-Use-increased-GPIO-debounce-time.patch +Patch0400: 0400-ASoC-es8316-Add-power-management.patch +Patch0401: 0401-ASoC-es8316-Use-increased-GPIO-debounce-time.patch +Patch0402: 0402-ASoC-Intel-add-machine-driver-for-SOF-ES8336.patch +Patch0403: 0403-ASoC-Intel-sof_es8336-add-quirk-for-Huawei-D15-2021.patch +Patch0404: 0404-ASoC-Intel-sof_es8336-make-gpio-optional.patch +Patch0405: 0405-ASoC-Intel-sof_es8336-get-codec-device-with-ACPI-ins.patch +Patch0406: 0406-ASoC-Intel-Revert-ASoC-Intel-sof_es8336-add-quirk-fo.patch +Patch0407: 0407-ASoC-Intel-sof_es8336-use-NHLT-information-to-set-dm.patch +Patch0408: 0408-ASoC-Intel-sof_es8336-log-all-quirks.patch +Patch0409: 0409-ASoC-Intel-sof_es8336-move-comment-to-the-right-plac.patch +Patch0410: 0410-ASoC-Intel-sof_es8336-add-support-for-JD-inverted-qu.patch +Patch0411: 0411-ASoC-Intel-sof_es8336-extend-machine-driver-to-suppo.patch +Patch0412: 0412-ASoC-Intel-sof_es8336-add-cfg-dmics-component-for-UC.patch +Patch0413: 0413-ASoC-Intel-sof_es8336-simplify-speaker-gpio-naming.patch +Patch0414: 0414-ASoC-Intel-sof_es8336-support-a-separate-gpio-to-con.patch +Patch0415: 0415-ASoC-Intel-sof_es8336-add-a-quirk-for-headset-at-mic.patch +Patch0416: 0416-ASoC-Intel-sof_es8336-Add-a-quirk-for-Huawei-Mateboo.patch +Patch0417: 0417-ASoC-Intel-sof_es8336-Fix-GPIO-quirks-set-via-module.patch +Patch0418: 0418-ASoC-Intel-sof_es8336-ignore-GpioInt-when-looking-fo.patch +Patch0419: 0419-ASoC-Intel-sof_es8336-add-support-for-HDMI_In-captur.patch +Patch0420: 0420-ASoC-Intel-sof_es8336-reset-the-num_links-during-pro.patch +Patch0421: 0421-ASoC-Intel-sof_es8336-remove-hard-coded-SSP-selectio.patch +Patch0422: 0422-ASoC-Intel-fix-sof_es8336-probe.patch +Patch0423: 0423-sound-backport-firmware-matches.patch +# TODO: upstreamize quirks and fixes in alsa ucm2 +Patch0424: 0424-ASoC-Intel-sof_es8336-Add-a-quirk-for-Aquarius-NS685.patch +Patch0425: 0425-ASoC-Intel-sof_es8336-Add-more-quirks-for-Russian-ha.patch +# Additional backports to make previous patches work/compile +Patch0426: 0426-ASoC-SOF-Intel-hda-report-SSP-link-mask-to-machine-d.patch +Patch0427: 0427-ASoC-Intel-soc-acpi-quirk-topology-filename-dynamica.patch +Patch0428: 0428-ASoC-soc-acpi-fix-kernel-doc-descriptor.patch +Patch0429: 0429-ASoC-soc-acpi-add-information-on-I2S-TDM-link-mask.patch +Patch0430: 0430-ALSA-hda-Fill-gaps-in-NHLT-endpoint-interface.patch +Patch0431: 0431-ASoC-SOF-avoid-casting-const-attribute-away.patch +Patch0432: 0432-ALSA-intel-dsp-config-add-more-ACPI-HIDs-for-ES83x6-.patch +Patch0433: 0433-ASoC-soc-acpi-add-comp_ids-field-for-machine-driver-.patch +Patch0434: 0434-ALSA-hda-intel-dsp-config-update-AlderLake-PCI-IDs.patch +Patch0435: 0435-ASoC-Intel-soc-acpi-Add-entry-for-sof_es8336-in-ADL-.patch +Patch0436: 0436-ALSA-intel-nhlt-add-helper-to-detect-SSP-link-mask.patch # Support SoC with Baikal-M (ARMv8) CPU # http://git.altlinux.org/gears/k/kernel-image-std-def.git