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 17/20] ASoC: Intel: sof_es8336: add support for JD inverted quirk
Date: Tue,  8 Mar 2022 13:26:07 -0600	[thread overview]
Message-ID: <20220308192610.392950-18-pierre-louis.bossart@linux.intel.com> (raw)
In-Reply-To: <20220308192610.392950-1-pierre-louis.bossart@linux.intel.com>

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 <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 | 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 d7dff61c9ba8..932a80e62bc8 100644
--- a/sound/soc/intel/boards/sof_es8336.c
+++ b/sound/soc/intel/boards/sof_es8336.c
@@ -21,11 +21,15 @@
 #include <sound/soc-acpi.h>
 #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.30.2


  parent reply	other threads:[~2022-03-08 19:32 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 ` [PATCH 14/20] ASoC: Intel: sof_es8336: use NHLT information to set dmic and SSP Pierre-Louis Bossart
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 ` Pierre-Louis Bossart [this message]
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-18-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.