All of lore.kernel.org
 help / color / mirror / Atom feed
From: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
To: alsa-devel@alsa-project.org
Cc: "Cezary Rojewski" <cezary.rojewski@intel.com>,
	tiwai@suse.de, "Péter Ujfalusi" <peter.ujfalusi@linux.intel.com>,
	"Huajun Li" <huajun.li@intel.com>,
	"Pierre-Louis Bossart" <pierre-louis.bossart@linux.intel.com>,
	"Nikolai Kostrigin" <nickel@altlinux.org>,
	broonie@kernel.org, "Mauro Carvalho Chehab" <mchehab@kernel.org>,
	"Bard Liao" <yung-chuan.liao@linux.intel.com>
Subject: [PATCH 14/20] ASoC: Intel: sof_es8336: use NHLT information to set dmic and SSP
Date: Tue,  8 Mar 2022 13:26:04 -0600	[thread overview]
Message-ID: <20220308192610.392950-15-pierre-louis.bossart@linux.intel.com> (raw)
In-Reply-To: <20220308192610.392950-1-pierre-louis.bossart@linux.intel.com>

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 <mchehab@kernel.org>
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Reviewed-by: Bard Liao <yung-chuan.liao@linux.intel.com>
Reviewed-by: Péter Ujfalusi <peter.ujfalusi@linux.intel.com>
---
 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 3376bd360a03..1a8680470577 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.30.2


  parent reply	other threads:[~2022-03-08 19:31 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-08 19:25 [PATCH 00/20] ALSA/ASoC/SOF/Intel: improve support for ES8336-based platforms Pierre-Louis Bossart
2022-03-08 19:25 ` [PATCH 01/20] ASoC: soc-acpi: fix kernel-doc descriptor Pierre-Louis Bossart
2022-03-08 19:25 ` [PATCH 02/20] ASoC: soc-acpi: add information on I2S/TDM link mask Pierre-Louis Bossart
2022-03-08 19:25 ` [PATCH 03/20] ASoC: SOF: Intel: hda: retrieve DMIC number for I2S boards Pierre-Louis Bossart
2022-03-09 16:49   ` Cezary Rojewski
2022-03-09 17:10     ` Pierre-Louis Bossart
2022-03-08 19:25 ` [PATCH 04/20] ALSA: intel-nhlt: add helper to detect SSP link mask Pierre-Louis Bossart
2022-03-09 10:03   ` Takashi Iwai
2022-03-09 17:01   ` Cezary Rojewski
2022-03-09 17:24     ` Pierre-Louis Bossart
2022-03-08 19:25 ` [PATCH 05/20] ASoC: SOF: Intel: hda: report SSP link mask to machine driver Pierre-Louis Bossart
2022-03-09 16:59   ` Cezary Rojewski
2022-03-09 17:16     ` Pierre-Louis Bossart
2022-03-08 19:25 ` [PATCH 06/20] ASoC: Intel: soc-acpi: quirk topology filename dynamically Pierre-Louis Bossart
2022-03-08 19:25 ` [PATCH 07/20] ALSA: intel-dsp-config: add more ACPI HIDs for ES83x6 devices Pierre-Louis Bossart
2022-03-09 10:04   ` Takashi Iwai
2022-03-08 19:25 ` [PATCH 08/20] ASoC: Intel: soc-acpi: " Pierre-Louis Bossart
2022-03-08 19:25 ` [PATCH 09/20] ALSA: intel-dspconfig: add ES8336 support for CNL Pierre-Louis Bossart
2022-03-09 10:04   ` Takashi Iwai
2022-03-08 19:26 ` [PATCH 10/20] ASoC: Intel: soc-acpi: add ESSX8336 support on Cannon Lake machines Pierre-Louis Bossart
2022-03-08 19:26 ` [PATCH 11/20] ASoC: Intel: sof_es8336: make gpio optional Pierre-Louis Bossart
2022-03-08 19:26 ` [PATCH 12/20] ASoC: Intel: sof_es8336: get codec device with ACPI instead of bus search Pierre-Louis Bossart
2022-03-08 19:26 ` [PATCH 13/20] ASoC: Intel: Revert "ASoC: Intel: sof_es8336: add quirk for Huawei D15 2021" Pierre-Louis Bossart
2022-03-08 19:26 ` Pierre-Louis Bossart [this message]
2022-03-08 19:26 ` [PATCH 15/20] ASoC: Intel: sof_es8336: log all quirks Pierre-Louis Bossart
2022-03-08 19:26 ` [PATCH 16/20] ASoC: Intel: sof_es8336: move comment to the right place Pierre-Louis Bossart
2022-03-08 19:26 ` [PATCH 17/20] ASoC: Intel: sof_es8336: add support for JD inverted quirk Pierre-Louis Bossart
2022-03-08 19:26 ` [PATCH 18/20] ASoC: Intel: sof_es8336: extend machine driver to support ES8326 codec Pierre-Louis Bossart
2022-03-08 19:26 ` [PATCH 19/20] ASoC: Intel: sof_es8336: add cfg-dmics component for UCM support Pierre-Louis Bossart
2022-03-08 19:26 ` [PATCH 20/20] ASoC: Intel: bytcht_es8316: move comment to the right place Pierre-Louis Bossart
2022-03-10 11:35 ` [PATCH 00/20] ALSA/ASoC/SOF/Intel: improve support for ES8336-based platforms Mark Brown

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220308192610.392950-15-pierre-louis.bossart@linux.intel.com \
    --to=pierre-louis.bossart@linux.intel.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=broonie@kernel.org \
    --cc=cezary.rojewski@intel.com \
    --cc=huajun.li@intel.com \
    --cc=mchehab@kernel.org \
    --cc=nickel@altlinux.org \
    --cc=peter.ujfalusi@linux.intel.com \
    --cc=tiwai@suse.de \
    --cc=yung-chuan.liao@linux.intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.