linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/3] ASoC: es8316: Add support for inverted jack detect
@ 2019-03-29 21:50 Paul Cercueil
  2019-03-29 21:50 ` [PATCH 2/3] ASoC: Intel: bytcht_es8316: Add quirk " Paul Cercueil
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Paul Cercueil @ 2019-03-29 21:50 UTC (permalink / raw)
  To: Liam Girdwood, Mark Brown, Jie Yang, Pierre-Louis Bossart,
	Jaroslav Kysela, Takashi Iwai
  Cc: alsa-devel, linux-kernel, Paul Cercueil

On some devices (Teclast X98+ II tablet, maybe others), the jack
detection has been wired backwards, so when the ES8316 reports
headphones being present it means they are actually not plugged.

Use a quirk around this incorrect behaviour, which can be enabled
through the 'everest,jack-detect-inverted' boolean device property.

Signed-off-by: Paul Cercueil <paul@crapouillou.net>
---
 sound/soc/codecs/es8316.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/sound/soc/codecs/es8316.c b/sound/soc/codecs/es8316.c
index 6d4a323f786b..ec2770b3f77d 100644
--- a/sound/soc/codecs/es8316.c
+++ b/sound/soc/codecs/es8316.c
@@ -43,6 +43,7 @@ struct es8316_priv {
 	unsigned int sysclk;
 	unsigned int allowed_rates[NR_SUPPORTED_MCLK_LRCK_RATIOS];
 	struct snd_pcm_hw_constraint_list sysclk_constraints;
+	bool jd_inverted;
 };
 
 /*
@@ -577,6 +578,9 @@ static irqreturn_t es8316_irq(int irq, void *data)
 	if (!es8316->jack)
 		goto out;
 
+	if (es8316->jd_inverted)
+		flags ^= ES8316_GPIO_FLAG_HP_NOT_INSERTED;
+
 	dev_dbg(comp->dev, "gpio flags %#04x\n", flags);
 	if (flags & ES8316_GPIO_FLAG_HP_NOT_INSERTED) {
 		/* Jack removed, or spurious IRQ? */
@@ -592,6 +596,8 @@ static irqreturn_t es8316_irq(int irq, void *data)
 		/* Jack inserted, determine type */
 		es8316_enable_micbias_for_mic_gnd_short_detect(comp);
 		regmap_read(es8316->regmap, ES8316_GPIO_FLAG, &flags);
+		if (es8316->jd_inverted)
+			flags ^= ES8316_GPIO_FLAG_HP_NOT_INSERTED;
 		dev_dbg(comp->dev, "gpio flags %#04x\n", flags);
 		if (flags & ES8316_GPIO_FLAG_HP_NOT_INSERTED) {
 			/* Jack unplugged underneath us */
@@ -633,6 +639,14 @@ static void es8316_enable_jack_detect(struct snd_soc_component *component,
 {
 	struct es8316_priv *es8316 = snd_soc_component_get_drvdata(component);
 
+	/*
+	 * Init es8316->jd_inverted here and not in the probe, as we cannot
+	 * guarantee that the bytchr-es8316 driver, which might set this
+	 * property, will probe before us.
+	 */
+	es8316->jd_inverted = device_property_read_bool(component->dev,
+							"everest,jack-detect-inverted");
+
 	mutex_lock(&es8316->lock);
 
 	es8316->jack = jack;
-- 
2.11.0


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

* [PATCH 2/3] ASoC: Intel: bytcht_es8316: Add quirk for inverted jack detect
  2019-03-29 21:50 [PATCH 1/3] ASoC: es8316: Add support for inverted jack detect Paul Cercueil
@ 2019-03-29 21:50 ` Paul Cercueil
  2019-03-29 21:50 ` [PATCH 3/3] ASoC: Intel: bytcht_es8316: Add quirk for the Teclast X98+ II Paul Cercueil
  2019-04-01  8:52 ` Applied "ASoC: es8316: Add support for inverted jack detect" " Mark Brown
  2 siblings, 0 replies; 7+ messages in thread
From: Paul Cercueil @ 2019-03-29 21:50 UTC (permalink / raw)
  To: Liam Girdwood, Mark Brown, Jie Yang, Pierre-Louis Bossart,
	Jaroslav Kysela, Takashi Iwai
  Cc: alsa-devel, linux-kernel, Paul Cercueil

Add a quirk to support boards whose jack detection mechanism is
inverted.

It will set the 'everest,jack-detect-inverted' boolean device property
for the es8316 codec driver.

Signed-off-by: Paul Cercueil <paul@crapouillou.net>
---
 sound/soc/intel/boards/bytcht_es8316.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/sound/soc/intel/boards/bytcht_es8316.c b/sound/soc/intel/boards/bytcht_es8316.c
index d2a7e6ba11ae..e59ef61e1fd0 100644
--- a/sound/soc/intel/boards/bytcht_es8316.c
+++ b/sound/soc/intel/boards/bytcht_es8316.c
@@ -40,6 +40,9 @@
 #include "../atom/sst-atom-controls.h"
 #include "../common/sst-dsp.h"
 
+/* jd-inv + terminating entry */
+#define MAX_NO_PROPS 2
+
 struct byt_cht_es8316_private {
 	struct clk *mclk;
 	struct snd_soc_jack jack;
@@ -55,6 +58,7 @@ enum {
 #define BYT_CHT_ES8316_MAP(quirk)		((quirk) & GENMASK(3, 0))
 #define BYT_CHT_ES8316_SSP0			BIT(16)
 #define BYT_CHT_ES8316_MONO_SPEAKER		BIT(17)
+#define BYT_CHT_ES8316_JD_INVERTED		BIT(18)
 
 static int quirk;
 
@@ -72,6 +76,8 @@ static void log_quirks(struct device *dev)
 		dev_info(dev, "quirk SSP0 enabled");
 	if (quirk & BYT_CHT_ES8316_MONO_SPEAKER)
 		dev_info(dev, "quirk MONO_SPEAKER enabled\n");
+	if (quirk & BYT_CHT_ES8316_JD_INVERTED)
+		dev_info(dev, "quirk JD_INVERTED enabled\n");
 }
 
 static int byt_cht_es8316_speaker_power_event(struct snd_soc_dapm_widget *w,
@@ -438,12 +444,14 @@ static const struct acpi_gpio_mapping byt_cht_es8316_gpios[] = {
 static int snd_byt_cht_es8316_mc_probe(struct platform_device *pdev)
 {
 	static const char * const mic_name[] = { "in1", "in2" };
+	struct property_entry props[MAX_NO_PROPS] = {};
 	struct byt_cht_es8316_private *priv;
 	struct device *dev = &pdev->dev;
 	struct snd_soc_acpi_mach *mach;
 	const char *platform_name;
 	const char *i2c_name = NULL;
 	struct device *codec_dev;
+	unsigned int cnt = 0;
 	int dai_index = 0;
 	int i;
 	int ret = 0;
@@ -512,6 +520,15 @@ static int snd_byt_cht_es8316_mc_probe(struct platform_device *pdev)
 	if (!codec_dev)
 		return -EPROBE_DEFER;
 
+	if (quirk & BYT_CHT_ES8316_JD_INVERTED)
+		props[cnt++] = PROPERTY_ENTRY_BOOL("everest,jack-detect-inverted");
+
+	if (cnt) {
+		ret = device_add_properties(codec_dev, props);
+		if (ret)
+			return ret;
+	}
+
 	devm_acpi_dev_add_driver_gpios(codec_dev, byt_cht_es8316_gpios);
 	priv->speaker_en_gpio =
 		gpiod_get_index(codec_dev, "speaker-enable", 0,
-- 
2.11.0


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

* [PATCH 3/3] ASoC: Intel: bytcht_es8316: Add quirk for the Teclast X98+ II
  2019-03-29 21:50 [PATCH 1/3] ASoC: es8316: Add support for inverted jack detect Paul Cercueil
  2019-03-29 21:50 ` [PATCH 2/3] ASoC: Intel: bytcht_es8316: Add quirk " Paul Cercueil
@ 2019-03-29 21:50 ` Paul Cercueil
  2019-04-08  7:24   ` Applied "ASoC: Intel: bytcht_es8316: Add quirk for the Teclast X98+ II" to the asoc tree Mark Brown
  2019-04-01  8:52 ` Applied "ASoC: es8316: Add support for inverted jack detect" " Mark Brown
  2 siblings, 1 reply; 7+ messages in thread
From: Paul Cercueil @ 2019-03-29 21:50 UTC (permalink / raw)
  To: Liam Girdwood, Mark Brown, Jie Yang, Pierre-Louis Bossart,
	Jaroslav Kysela, Takashi Iwai
  Cc: alsa-devel, linux-kernel, Paul Cercueil

The Teclast X98+ II is a Cherrytrail tablet, which require two quirks:
- it has stereo speakers,
- its jack detection mechanism is inverted.

Signed-off-by: Paul Cercueil <paul@crapouillou.net>
---
 sound/soc/intel/boards/bytcht_es8316.c | 20 +++++++++++++++++++-
 1 file changed, 19 insertions(+), 1 deletion(-)

diff --git a/sound/soc/intel/boards/bytcht_es8316.c b/sound/soc/intel/boards/bytcht_es8316.c
index e59ef61e1fd0..4d0f8eb560d0 100644
--- a/sound/soc/intel/boards/bytcht_es8316.c
+++ b/sound/soc/intel/boards/bytcht_es8316.c
@@ -22,6 +22,7 @@
 #include <linux/acpi.h>
 #include <linux/clk.h>
 #include <linux/device.h>
+#include <linux/dmi.h>
 #include <linux/gpio/consumer.h>
 #include <linux/i2c.h>
 #include <linux/init.h>
@@ -441,11 +442,25 @@ static const struct acpi_gpio_mapping byt_cht_es8316_gpios[] = {
 	{ },
 };
 
+/* Please keep this list alphabetically sorted */
+static const struct dmi_system_id byt_cht_es8316_quirk_table[] = {
+	{	/* Teclast X98 Plus II */
+		.matches = {
+			DMI_MATCH(DMI_SYS_VENDOR, "TECLAST"),
+			DMI_MATCH(DMI_PRODUCT_NAME, "X98 Plus II"),
+		},
+		.driver_data = (void *)(BYT_CHT_ES8316_INTMIC_IN1_MAP
+					| BYT_CHT_ES8316_JD_INVERTED),
+	},
+	{}
+};
+
 static int snd_byt_cht_es8316_mc_probe(struct platform_device *pdev)
 {
 	static const char * const mic_name[] = { "in1", "in2" };
 	struct property_entry props[MAX_NO_PROPS] = {};
 	struct byt_cht_es8316_private *priv;
+	const struct dmi_system_id *dmi_id;
 	struct device *dev = &pdev->dev;
 	struct snd_soc_acpi_mach *mach;
 	const char *platform_name;
@@ -487,7 +502,10 @@ static int snd_byt_cht_es8316_mc_probe(struct platform_device *pdev)
 		return ret;
 
 	/* Check for BYTCR or other platform and setup quirks */
-	if (x86_match_cpu(baytrail_cpu_ids) &&
+	dmi_id = dmi_first_match(byt_cht_es8316_quirk_table);
+	if (dmi_id) {
+		quirk = (int)dmi_id->driver_data;
+	} else if (x86_match_cpu(baytrail_cpu_ids) &&
 	    mach->mach_params.acpi_ipc_irq_index == 0) {
 		/* On BYTCR default to SSP0, internal-mic-in2-map, mono-spk */
 		quirk = BYT_CHT_ES8316_SSP0 | BYT_CHT_ES8316_INTMIC_IN2_MAP |
-- 
2.11.0


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

* Applied "ASoC: es8316: Add support for inverted jack detect" to the asoc tree
  2019-03-29 21:50 [PATCH 1/3] ASoC: es8316: Add support for inverted jack detect Paul Cercueil
  2019-03-29 21:50 ` [PATCH 2/3] ASoC: Intel: bytcht_es8316: Add quirk " Paul Cercueil
  2019-03-29 21:50 ` [PATCH 3/3] ASoC: Intel: bytcht_es8316: Add quirk for the Teclast X98+ II Paul Cercueil
@ 2019-04-01  8:52 ` Mark Brown
  2019-04-01 17:57   ` Paul Cercueil
  2 siblings, 1 reply; 7+ messages in thread
From: Mark Brown @ 2019-04-01  8:52 UTC (permalink / raw)
  To: Paul Cercueil
  Cc: Mark Brown, Liam Girdwood, Mark Brown, Jie Yang,
	Pierre-Louis Bossart, Jaroslav Kysela, Takashi Iwai, alsa-devel,
	linux-kernel, alsa-devel

The patch

   ASoC: es8316: Add support for inverted jack detect

has been applied to the asoc tree at

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

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

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

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

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

Thanks,
Mark

From 0bbcedd6bb41b82b77115fc001441ff34e7c4ea7 Mon Sep 17 00:00:00 2001
From: Paul Cercueil <paul@crapouillou.net>
Date: Fri, 29 Mar 2019 22:50:43 +0100
Subject: [PATCH] ASoC: es8316: Add support for inverted jack detect

On some devices (Teclast X98+ II tablet, maybe others), the jack
detection has been wired backwards, so when the ES8316 reports
headphones being present it means they are actually not plugged.

Use a quirk around this incorrect behaviour, which can be enabled
through the 'everest,jack-detect-inverted' boolean device property.

Signed-off-by: Paul Cercueil <paul@crapouillou.net>
Signed-off-by: Mark Brown <broonie@kernel.org>
---
 sound/soc/codecs/es8316.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/sound/soc/codecs/es8316.c b/sound/soc/codecs/es8316.c
index 6d4a323f786b..ec2770b3f77d 100644
--- a/sound/soc/codecs/es8316.c
+++ b/sound/soc/codecs/es8316.c
@@ -43,6 +43,7 @@ struct es8316_priv {
 	unsigned int sysclk;
 	unsigned int allowed_rates[NR_SUPPORTED_MCLK_LRCK_RATIOS];
 	struct snd_pcm_hw_constraint_list sysclk_constraints;
+	bool jd_inverted;
 };
 
 /*
@@ -577,6 +578,9 @@ static irqreturn_t es8316_irq(int irq, void *data)
 	if (!es8316->jack)
 		goto out;
 
+	if (es8316->jd_inverted)
+		flags ^= ES8316_GPIO_FLAG_HP_NOT_INSERTED;
+
 	dev_dbg(comp->dev, "gpio flags %#04x\n", flags);
 	if (flags & ES8316_GPIO_FLAG_HP_NOT_INSERTED) {
 		/* Jack removed, or spurious IRQ? */
@@ -592,6 +596,8 @@ static irqreturn_t es8316_irq(int irq, void *data)
 		/* Jack inserted, determine type */
 		es8316_enable_micbias_for_mic_gnd_short_detect(comp);
 		regmap_read(es8316->regmap, ES8316_GPIO_FLAG, &flags);
+		if (es8316->jd_inverted)
+			flags ^= ES8316_GPIO_FLAG_HP_NOT_INSERTED;
 		dev_dbg(comp->dev, "gpio flags %#04x\n", flags);
 		if (flags & ES8316_GPIO_FLAG_HP_NOT_INSERTED) {
 			/* Jack unplugged underneath us */
@@ -633,6 +639,14 @@ static void es8316_enable_jack_detect(struct snd_soc_component *component,
 {
 	struct es8316_priv *es8316 = snd_soc_component_get_drvdata(component);
 
+	/*
+	 * Init es8316->jd_inverted here and not in the probe, as we cannot
+	 * guarantee that the bytchr-es8316 driver, which might set this
+	 * property, will probe before us.
+	 */
+	es8316->jd_inverted = device_property_read_bool(component->dev,
+							"everest,jack-detect-inverted");
+
 	mutex_lock(&es8316->lock);
 
 	es8316->jack = jack;
-- 
2.20.1


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

* Re: Applied "ASoC: es8316: Add support for inverted jack detect" to the asoc tree
  2019-04-01  8:52 ` Applied "ASoC: es8316: Add support for inverted jack detect" " Mark Brown
@ 2019-04-01 17:57   ` Paul Cercueil
  2019-04-02  4:55     ` Mark Brown
  0 siblings, 1 reply; 7+ messages in thread
From: Paul Cercueil @ 2019-04-01 17:57 UTC (permalink / raw)
  To: Mark Brown
  Cc: Liam Girdwood, Jie Yang, Pierre-Louis Bossart, Jaroslav Kysela,
	Takashi Iwai, alsa-devel, linux-kernel, alsa-devel

Hi Mark,

What about the other two patches? Should I make a new patchset with 
these?

Thanks,
-Paul


Le lun. 1 avril 2019 à 10:52, Mark Brown <broonie@kernel.org> a écrit 
:
> The patch
> 
>    ASoC: es8316: Add support for inverted jack detect
> 
> has been applied to the asoc tree at
> 
>    https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git
> 
> All being well this means that it will be integrated into the 
> linux-next
> tree (usually sometime in the next 24 hours) and sent to Linus during
> the next merge window (or sooner if it is a bug fix), however if
> problems are discovered then the patch may be dropped or reverted.
> 
> You may get further e-mails resulting from automated or manual testing
> and review of the tree, please engage with people reporting problems 
> and
> send followup patches addressing any issues that are reported if 
> needed.
> 
> If any updates are required or you are submitting further changes they
> should be sent as incremental updates against current git, existing
> patches will not be replaced.
> 
> Please add any relevant lists and maintainers to the CCs when replying
> to this mail.
> 
> Thanks,
> Mark
> 
> From 0bbcedd6bb41b82b77115fc001441ff34e7c4ea7 Mon Sep 17 00:00:00 2001
> From: Paul Cercueil <paul@crapouillou.net>
> Date: Fri, 29 Mar 2019 22:50:43 +0100
> Subject: [PATCH] ASoC: es8316: Add support for inverted jack detect
> 
> On some devices (Teclast X98+ II tablet, maybe others), the jack
> detection has been wired backwards, so when the ES8316 reports
> headphones being present it means they are actually not plugged.
> 
> Use a quirk around this incorrect behaviour, which can be enabled
> through the 'everest,jack-detect-inverted' boolean device property.
> 
> Signed-off-by: Paul Cercueil <paul@crapouillou.net>
> Signed-off-by: Mark Brown <broonie@kernel.org>
> ---
>  sound/soc/codecs/es8316.c | 14 ++++++++++++++
>  1 file changed, 14 insertions(+)
> 
> diff --git a/sound/soc/codecs/es8316.c b/sound/soc/codecs/es8316.c
> index 6d4a323f786b..ec2770b3f77d 100644
> --- a/sound/soc/codecs/es8316.c
> +++ b/sound/soc/codecs/es8316.c
> @@ -43,6 +43,7 @@ struct es8316_priv {
>  	unsigned int sysclk;
>  	unsigned int allowed_rates[NR_SUPPORTED_MCLK_LRCK_RATIOS];
>  	struct snd_pcm_hw_constraint_list sysclk_constraints;
> +	bool jd_inverted;
>  };
> 
>  /*
> @@ -577,6 +578,9 @@ static irqreturn_t es8316_irq(int irq, void *data)
>  	if (!es8316->jack)
>  		goto out;
> 
> +	if (es8316->jd_inverted)
> +		flags ^= ES8316_GPIO_FLAG_HP_NOT_INSERTED;
> +
>  	dev_dbg(comp->dev, "gpio flags %#04x\n", flags);
>  	if (flags & ES8316_GPIO_FLAG_HP_NOT_INSERTED) {
>  		/* Jack removed, or spurious IRQ? */
> @@ -592,6 +596,8 @@ static irqreturn_t es8316_irq(int irq, void *data)
>  		/* Jack inserted, determine type */
>  		es8316_enable_micbias_for_mic_gnd_short_detect(comp);
>  		regmap_read(es8316->regmap, ES8316_GPIO_FLAG, &flags);
> +		if (es8316->jd_inverted)
> +			flags ^= ES8316_GPIO_FLAG_HP_NOT_INSERTED;
>  		dev_dbg(comp->dev, "gpio flags %#04x\n", flags);
>  		if (flags & ES8316_GPIO_FLAG_HP_NOT_INSERTED) {
>  			/* Jack unplugged underneath us */
> @@ -633,6 +639,14 @@ static void es8316_enable_jack_detect(struct 
> snd_soc_component *component,
>  {
>  	struct es8316_priv *es8316 = 
> snd_soc_component_get_drvdata(component);
> 
> +	/*
> +	 * Init es8316->jd_inverted here and not in the probe, as we cannot
> +	 * guarantee that the bytchr-es8316 driver, which might set this
> +	 * property, will probe before us.
> +	 */
> +	es8316->jd_inverted = device_property_read_bool(component->dev,
> +							"everest,jack-detect-inverted");
> +
>  	mutex_lock(&es8316->lock);
> 
>  	es8316->jack = jack;
> --
> 2.20.1
> 



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

* Re: Applied "ASoC: es8316: Add support for inverted jack detect" to the asoc tree
  2019-04-01 17:57   ` Paul Cercueil
@ 2019-04-02  4:55     ` Mark Brown
  0 siblings, 0 replies; 7+ messages in thread
From: Mark Brown @ 2019-04-02  4:55 UTC (permalink / raw)
  To: Paul Cercueil
  Cc: Liam Girdwood, Jie Yang, Pierre-Louis Bossart, Jaroslav Kysela,
	Takashi Iwai, alsa-devel, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 454 bytes --]

On Mon, Apr 01, 2019 at 07:57:19PM +0200, Paul Cercueil wrote:

Please don't top post, reply in line with needed context.  This allows
readers to readily follow the flow of conversation and understand what
you are talking about and also helps ensure that everything in the
discussion is being addressed.

> What about the other two patches? Should I make a new patchset with these?

They're Intel board patches so the Intel people will hopefully review.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

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

* Applied "ASoC: Intel: bytcht_es8316: Add quirk for the Teclast X98+ II" to the asoc tree
  2019-03-29 21:50 ` [PATCH 3/3] ASoC: Intel: bytcht_es8316: Add quirk for the Teclast X98+ II Paul Cercueil
@ 2019-04-08  7:24   ` Mark Brown
  0 siblings, 0 replies; 7+ messages in thread
From: Mark Brown @ 2019-04-08  7:24 UTC (permalink / raw)
  To: Paul Cercueil
  Cc: Mark Brown, Liam Girdwood, Mark Brown, Jie Yang,
	Pierre-Louis Bossart, Jaroslav Kysela, Takashi Iwai, alsa-devel,
	linux-kernel, alsa-devel

The patch

   ASoC: Intel: bytcht_es8316: Add quirk for the Teclast X98+ II

has been applied to the asoc tree at

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

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

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

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

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

Thanks,
Mark

From a8d218f4fe8116395e4c4a13b63029ecf00d4035 Mon Sep 17 00:00:00 2001
From: Paul Cercueil <paul@crapouillou.net>
Date: Fri, 29 Mar 2019 22:50:45 +0100
Subject: [PATCH] ASoC: Intel: bytcht_es8316: Add quirk for the Teclast X98+ II

The Teclast X98+ II is a Cherrytrail tablet, which require two quirks:
- it has stereo speakers,
- its jack detection mechanism is inverted.

Signed-off-by: Paul Cercueil <paul@crapouillou.net>
Signed-off-by: Mark Brown <broonie@kernel.org>
---
 sound/soc/intel/boards/bytcht_es8316.c | 20 +++++++++++++++++++-
 1 file changed, 19 insertions(+), 1 deletion(-)

diff --git a/sound/soc/intel/boards/bytcht_es8316.c b/sound/soc/intel/boards/bytcht_es8316.c
index ccf552e92d53..38975827e276 100644
--- a/sound/soc/intel/boards/bytcht_es8316.c
+++ b/sound/soc/intel/boards/bytcht_es8316.c
@@ -22,6 +22,7 @@
 #include <linux/acpi.h>
 #include <linux/clk.h>
 #include <linux/device.h>
+#include <linux/dmi.h>
 #include <linux/gpio/consumer.h>
 #include <linux/i2c.h>
 #include <linux/init.h>
@@ -441,11 +442,25 @@ static const struct acpi_gpio_mapping byt_cht_es8316_gpios[] = {
 	{ },
 };
 
+/* Please keep this list alphabetically sorted */
+static const struct dmi_system_id byt_cht_es8316_quirk_table[] = {
+	{	/* Teclast X98 Plus II */
+		.matches = {
+			DMI_MATCH(DMI_SYS_VENDOR, "TECLAST"),
+			DMI_MATCH(DMI_PRODUCT_NAME, "X98 Plus II"),
+		},
+		.driver_data = (void *)(BYT_CHT_ES8316_INTMIC_IN1_MAP
+					| BYT_CHT_ES8316_JD_INVERTED),
+	},
+	{}
+};
+
 static int snd_byt_cht_es8316_mc_probe(struct platform_device *pdev)
 {
 	static const char * const mic_name[] = { "in1", "in2" };
 	struct property_entry props[MAX_NO_PROPS] = {};
 	struct byt_cht_es8316_private *priv;
+	const struct dmi_system_id *dmi_id;
 	struct device *dev = &pdev->dev;
 	struct snd_soc_acpi_mach *mach;
 	const char *platform_name;
@@ -488,7 +503,10 @@ static int snd_byt_cht_es8316_mc_probe(struct platform_device *pdev)
 		return ret;
 
 	/* Check for BYTCR or other platform and setup quirks */
-	if (x86_match_cpu(baytrail_cpu_ids) &&
+	dmi_id = dmi_first_match(byt_cht_es8316_quirk_table);
+	if (dmi_id) {
+		quirk = (int)dmi_id->driver_data;
+	} else if (x86_match_cpu(baytrail_cpu_ids) &&
 	    mach->mach_params.acpi_ipc_irq_index == 0) {
 		/* On BYTCR default to SSP0, internal-mic-in2-map, mono-spk */
 		quirk = BYT_CHT_ES8316_SSP0 | BYT_CHT_ES8316_INTMIC_IN2_MAP |
-- 
2.20.1


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

end of thread, other threads:[~2019-04-08  7:25 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-03-29 21:50 [PATCH 1/3] ASoC: es8316: Add support for inverted jack detect Paul Cercueil
2019-03-29 21:50 ` [PATCH 2/3] ASoC: Intel: bytcht_es8316: Add quirk " Paul Cercueil
2019-03-29 21:50 ` [PATCH 3/3] ASoC: Intel: bytcht_es8316: Add quirk for the Teclast X98+ II Paul Cercueil
2019-04-08  7:24   ` Applied "ASoC: Intel: bytcht_es8316: Add quirk for the Teclast X98+ II" to the asoc tree Mark Brown
2019-04-01  8:52 ` Applied "ASoC: es8316: Add support for inverted jack detect" " Mark Brown
2019-04-01 17:57   ` Paul Cercueil
2019-04-02  4:55     ` Mark Brown

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).