Skip to contentSkip to conversation

rt5651: Enable jack detection

PATCH In review Carlo Caione 2 participants 12 messages Oct 20, 2017 – Oct 26, 2017

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

v2 cover rt5651: Enable jack detection

From: Carlo Caione <[email protected]>

Patchset to support jack detection for the rt5651 codec on the JD* pins and enable it on the KIANO cherry-trail laptop.

Changelog:
v2:
- Added quirks for the KIANO laptop
- Extended support to JD1_2 and JD2 pins
- Reworked quirk logic in the codec driver
- Codec driver can now differentiate between headphone and headset (thank you Bard Liao)

Carlo Caione (5):
ASoC: rt5651: Enable jack detection on JD* pins
ASoC: intel: byt: Add headset jack
ASoC: intel: byt: Enable IN2 map quirk for a KIANO laptop
ASoC: rt5651: Rework quirk logic
ASoC: rt5651: Enable JD1_1 quirk for KIANO laptopt

 include/sound/rt5651.h                |   8 ++
 sound/soc/codecs/rt5651.c             | 215 +++++++++++++++++++++++++++++++++-
 sound/soc/codecs/rt5651.h             |   4 +
 sound/soc/intel/boards/bytcr_rt5651.c |  31 +++++
 4 files changed, 252 insertions(+), 6 deletions(-)
Signature · 1 line
2.14.2
#1 lore raw

PATCH v2 1/5 ASoC: rt5651: Enable jack detection on JD* pins

From: Carlo Caione <[email protected]>

Enable jack detection for the RT5651 codec on the JD* pins.

---
 include/sound/rt5651.h    |   8 +++
 sound/soc/codecs/rt5651.c | 168 +++++++++++++++++++++++++++++++++++++++++++++-
 sound/soc/codecs/rt5651.h |   4 ++
 3 files changed, 178 insertions(+), 2 deletions(-)
include/sound/rt5651.h +8 -0
index d35de758dfb5..18b79a761f10 100644
@@ -11,11 +11,19 @@
 #ifndef __LINUX_SND_RT5651_H
 #define __LINUX_SND_RT5651_H
 
+enum rt5651_jd_src {
+	RT5651_JD_NULL,
+	RT5651_JD1_1,
+	RT5651_JD1_2,
+	RT5651_JD2,
+};
+
 struct rt5651_platform_data {
 	/* IN2 can optionally be differential */
 	bool in2_diff;
 
 	bool dmic_en;
+	enum rt5651_jd_src jd_src;
 };
 
 #endif
sound/soc/codecs/rt5651.c +166 -2

222 lines not on this page · raw message

sound/soc/codecs/rt5651.h +4 -0
index 1bd33cfa6411..4f8b202121d7 100644
@@ -2062,6 +2062,8 @@ struct rt5651_priv {
 	struct snd_soc_codec *codec;
 	struct rt5651_platform_data pdata;
 	struct regmap *regmap;
+	struct snd_soc_jack *hp_jack;
+	struct delayed_work jack_detect_work;
 
 	int sysclk;
 	int sysclk_src;
@@ -2077,4 +2079,6 @@ struct rt5651_priv {
 	bool hp_mute;
 };
 
+int rt5651_set_jack_detect(struct snd_soc_codec *codec,
+			   struct snd_soc_jack *hp_jack);
 #endif /* __RT5651_H__ */
Signature · 1 line
2.14.2
maintainer
#2 lore raw

Applied "ASoC: rt5651: Enable jack detection on JD* pins" to the asoc tree

The patch

ASoC: rt5651: Enable jack detection on JD* pins

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

Quoted 1 line

From 80bbe4a30bc6b119df86c280c91cde2034309bf1 Mon Sep 17 00:00:00 2001

From: Carlo Caione <[email protected]>
Date: Fri, 20 Oct 2017 12:18:55 +0100
Subject: [PATCH] ASoC: rt5651: Enable jack detection on JD* pins

Enable jack detection for the RT5651 codec on the JD* pins.

---
 include/sound/rt5651.h    |   8 +++
 sound/soc/codecs/rt5651.c | 168 +++++++++++++++++++++++++++++++++++++++++++++-
 sound/soc/codecs/rt5651.h |   4 ++
 3 files changed, 178 insertions(+), 2 deletions(-)
include/sound/rt5651.h +8 -0
index d35de758dfb5..18b79a761f10 100644
@@ -11,11 +11,19 @@
 #ifndef __LINUX_SND_RT5651_H
 #define __LINUX_SND_RT5651_H
 
+enum rt5651_jd_src {
+	RT5651_JD_NULL,
+	RT5651_JD1_1,
+	RT5651_JD1_2,
+	RT5651_JD2,
+};
+
 struct rt5651_platform_data {
 	/* IN2 can optionally be differential */
 	bool in2_diff;
 
 	bool dmic_en;
+	enum rt5651_jd_src jd_src;
 };
 
 #endif
sound/soc/codecs/rt5651.c +166 -2

222 lines not on this page · raw message

sound/soc/codecs/rt5651.h +4 -0
index 1bd33cfa6411..4f8b202121d7 100644
@@ -2062,6 +2062,8 @@ struct rt5651_priv {
 	struct snd_soc_codec *codec;
 	struct rt5651_platform_data pdata;
 	struct regmap *regmap;
+	struct snd_soc_jack *hp_jack;
+	struct delayed_work jack_detect_work;
 
 	int sysclk;
 	int sysclk_src;
@@ -2077,4 +2079,6 @@ struct rt5651_priv {
 	bool hp_mute;
 };
 
+int rt5651_set_jack_detect(struct snd_soc_codec *codec,
+			   struct snd_soc_jack *hp_jack);
 #endif /* __RT5651_H__ */
Signature · 1 line
2.14.1
maintainer
#3 lore raw

Applied "ASoC: rt5651: Enable jack detection on JD* pins" to the asoc tree

In reply to Carlo Caione

The patch

ASoC: rt5651: Enable jack detection on JD* pins

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

Quoted 1 line

From 60d5a1a47b9a8381c08d2263b11ac9c757c87746 Mon Sep 17 00:00:00 2001

From: Carlo Caione <[email protected]>
Date: Fri, 20 Oct 2017 12:18:55 +0100
Subject: [PATCH] ASoC: rt5651: Enable jack detection on JD* pins

Enable jack detection for the RT5651 codec on the JD* pins.

---
 include/sound/rt5651.h    |   8 +++
 sound/soc/codecs/rt5651.c | 168 +++++++++++++++++++++++++++++++++++++++++++++-
 sound/soc/codecs/rt5651.h |   4 ++
 3 files changed, 178 insertions(+), 2 deletions(-)
include/sound/rt5651.h +8 -0
index d35de758dfb5..18b79a761f10 100644
@@ -11,11 +11,19 @@
 #ifndef __LINUX_SND_RT5651_H
 #define __LINUX_SND_RT5651_H
 
+enum rt5651_jd_src {
+	RT5651_JD_NULL,
+	RT5651_JD1_1,
+	RT5651_JD1_2,
+	RT5651_JD2,
+};
+
 struct rt5651_platform_data {
 	/* IN2 can optionally be differential */
 	bool in2_diff;
 
 	bool dmic_en;
+	enum rt5651_jd_src jd_src;
 };
 
 #endif
sound/soc/codecs/rt5651.c +166 -2

222 lines not on this page · raw message

sound/soc/codecs/rt5651.h +4 -0
index 1bd33cfa6411..4f8b202121d7 100644
@@ -2062,6 +2062,8 @@ struct rt5651_priv {
 	struct snd_soc_codec *codec;
 	struct rt5651_platform_data pdata;
 	struct regmap *regmap;
+	struct snd_soc_jack *hp_jack;
+	struct delayed_work jack_detect_work;
 
 	int sysclk;
 	int sysclk_src;
@@ -2077,4 +2079,6 @@ struct rt5651_priv {
 	bool hp_mute;
 };
 
+int rt5651_set_jack_detect(struct snd_soc_codec *codec,
+			   struct snd_soc_jack *hp_jack);
 #endif /* __RT5651_H__ */
Signature · 1 line
2.14.1
#4 lore raw

PATCH v2 2/5 ASoC: intel: byt: Add headset jack

In reply to Carlo Caione

From: Carlo Caione <[email protected]>

Introduce an headset jack in the machine driver and register it to the codec driver.

---
 sound/soc/intel/boards/bytcr_rt5651.c | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)
sound/soc/intel/boards/bytcr_rt5651.c +23 -0
index 1dad5c98c9ef..5aca55baccda 100644
@@ -47,6 +47,7 @@ enum {
 
 struct byt_rt5651_private {
 	struct clk *mclk;
+	struct snd_soc_jack jack;
 };
 
 static unsigned long byt_rt5651_quirk = BYT_RT5651_DMIC_MAP |
@@ -177,6 +178,17 @@ static const struct snd_kcontrol_new byt_rt5651_controls[] = {
 	SOC_DAPM_PIN_SWITCH("Speaker"),
 };
 
+static struct snd_soc_jack_pin bytcr_jack_pins[] = {
+	{
+		.pin	= "Headphone",
+		.mask	= SND_JACK_HEADPHONE,
+	},
+	{
+		.pin	= "Headset Mic",
+		.mask	= SND_JACK_MICROPHONE,
+	},
+};
+
 static int byt_rt5651_aif1_hw_params(struct snd_pcm_substream *substream,
 					struct snd_pcm_hw_params *params)
 {
@@ -244,6 +256,7 @@ static const struct dmi_system_id byt_rt5651_quirk_table[] = {
 static int byt_rt5651_init(struct snd_soc_pcm_runtime *runtime)
 {
 	struct snd_soc_card *card = runtime->card;
+	struct snd_soc_codec *codec = runtime->codec;
 	struct byt_rt5651_private *priv = snd_soc_card_get_drvdata(card);
 	const struct snd_soc_dapm_route *custom_map;
 	int num_routes;
@@ -301,6 +314,16 @@ static int byt_rt5651_init(struct snd_soc_pcm_runtime *runtime)
 			dev_err(card->dev, "unable to set MCLK rate\n");
 	}
 
+	ret = snd_soc_card_jack_new(runtime->card, "Headset",
+				    SND_JACK_HEADSET, &priv->jack,
+				    bytcr_jack_pins, ARRAY_SIZE(bytcr_jack_pins));
+	if (ret) {
+		dev_err(runtime->dev, "Headset jack creation failed %d\n", ret);
+		return ret;
+	}
+
+	rt5651_set_jack_detect(codec, &priv->jack);
+
 	return ret;
 }
 
Signature · 1 line
2.14.2
maintainer
#5 lore raw

Applied "ASoC: intel: byt: Add headset jack" to the asoc tree

The patch

ASoC: intel: byt: Add headset jack

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

Quoted 1 line

From d9f8f9b2f3e2b95875cd59ae5c3276e4662e7513 Mon Sep 17 00:00:00 2001

From: Carlo Caione <[email protected]>
Date: Fri, 20 Oct 2017 12:18:56 +0100
Subject: [PATCH] ASoC: intel: byt: Add headset jack

Introduce an headset jack in the machine driver and register it to the codec driver.

---
 sound/soc/intel/boards/bytcr_rt5651.c | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)
sound/soc/intel/boards/bytcr_rt5651.c +23 -0
index 51de1bbe8ecd..0df9067e4382 100644
@@ -47,6 +47,7 @@ enum {
 
 struct byt_rt5651_private {
 	struct clk *mclk;
+	struct snd_soc_jack jack;
 };
 
 static unsigned long byt_rt5651_quirk = BYT_RT5651_DMIC_MAP |
@@ -177,6 +178,17 @@ static const struct snd_kcontrol_new byt_rt5651_controls[] = {
 	SOC_DAPM_PIN_SWITCH("Speaker"),
 };
 
+static struct snd_soc_jack_pin bytcr_jack_pins[] = {
+	{
+		.pin	= "Headphone",
+		.mask	= SND_JACK_HEADPHONE,
+	},
+	{
+		.pin	= "Headset Mic",
+		.mask	= SND_JACK_MICROPHONE,
+	},
+};
+
 static int byt_rt5651_aif1_hw_params(struct snd_pcm_substream *substream,
 					struct snd_pcm_hw_params *params)
 {
@@ -244,6 +256,7 @@ static const struct dmi_system_id byt_rt5651_quirk_table[] = {
 static int byt_rt5651_init(struct snd_soc_pcm_runtime *runtime)
 {
 	struct snd_soc_card *card = runtime->card;
+	struct snd_soc_codec *codec = runtime->codec;
 	struct byt_rt5651_private *priv = snd_soc_card_get_drvdata(card);
 	const struct snd_soc_dapm_route *custom_map;
 	int num_routes;
@@ -301,6 +314,16 @@ static int byt_rt5651_init(struct snd_soc_pcm_runtime *runtime)
 			dev_err(card->dev, "unable to set MCLK rate\n");
 	}
 
+	ret = snd_soc_card_jack_new(runtime->card, "Headset",
+				    SND_JACK_HEADSET, &priv->jack,
+				    bytcr_jack_pins, ARRAY_SIZE(bytcr_jack_pins));
+	if (ret) {
+		dev_err(runtime->dev, "Headset jack creation failed %d\n", ret);
+		return ret;
+	}
+
+	rt5651_set_jack_detect(codec, &priv->jack);
+
 	return ret;
 }
 
Signature · 1 line
2.14.1
#6 lore raw

PATCH v2 3/5 ASoC: intel: byt: Enable IN2 map quirk for a KIANO laptop

In reply to Carlo Caione

From: Carlo Caione <[email protected]>

This cherry-trails laptop has the internal mic connected to the IN2 input pins. Enable the quirk to correctly map the routes.

---
 sound/soc/intel/boards/bytcr_rt5651.c | 8 ++++++++
 1 file changed, 8 insertions(+)
sound/soc/intel/boards/bytcr_rt5651.c +8 -0
index 5aca55baccda..c7494f88ab81 100644
@@ -250,6 +250,14 @@ static const struct dmi_system_id byt_rt5651_quirk_table[] = {
 		.driver_data = (void *)(BYT_RT5651_DMIC_MAP |
 					BYT_RT5651_DMIC_EN),
 	},
+	{
+		.callback = byt_rt5651_quirk_cb,
+		.matches = {
+			DMI_MATCH(DMI_SYS_VENDOR, "KIANO"),
+			DMI_MATCH(DMI_PRODUCT_NAME, "KIANO SlimNote 14.2"),
+		},
+		.driver_data = (void *)(BYT_RT5651_IN2_MAP),
+	},
 	{}
 };
 
Signature · 1 line
2.14.2
maintainer
#7 lore raw

Applied "ASoC: intel: byt: Enable IN2 map quirk for a KIANO laptop" to the asoc tree

The patch

ASoC: intel: byt: Enable IN2 map quirk for a KIANO laptop

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

Quoted 1 line

From 2fe30129b0a6a8ddf71c46c8fb4524cb89739bc0 Mon Sep 17 00:00:00 2001

From: Carlo Caione <[email protected]>
Date: Fri, 20 Oct 2017 12:18:57 +0100
Subject: [PATCH] ASoC: intel: byt: Enable IN2 map quirk for a KIANO laptop

This cherry-trails laptop has the internal mic connected to the IN2 input pins. Enable the quirk to correctly map the routes.

---
 sound/soc/intel/boards/bytcr_rt5651.c | 8 ++++++++
 1 file changed, 8 insertions(+)
sound/soc/intel/boards/bytcr_rt5651.c +8 -0
index 0df9067e4382..d955836c6870 100644
@@ -250,6 +250,14 @@ static const struct dmi_system_id byt_rt5651_quirk_table[] = {
 		.driver_data = (void *)(BYT_RT5651_DMIC_MAP |
 					BYT_RT5651_DMIC_EN),
 	},
+	{
+		.callback = byt_rt5651_quirk_cb,
+		.matches = {
+			DMI_MATCH(DMI_SYS_VENDOR, "KIANO"),
+			DMI_MATCH(DMI_PRODUCT_NAME, "KIANO SlimNote 14.2"),
+		},
+		.driver_data = (void *)(BYT_RT5651_IN2_MAP),
+	},
 	{}
 };
 
Signature · 1 line
2.14.1
#8 lore raw

PATCH v2 4/5 ASoC: rt5651: Rework quirk logic

In reply to Carlo Caione

From: Carlo Caione <[email protected]>

Rework a bit the quirk logic in the codec driver to simplify the DMI-based quirk assignment for non-DT platforms.

---
 sound/soc/codecs/rt5651.c | 39 +++++++++++++++++++++++++++++++++++----
 1 file changed, 35 insertions(+), 4 deletions(-)
sound/soc/codecs/rt5651.c +35 -4
index 91f254391452..f01d41101631 100644
@@ -19,6 +19,7 @@
 #include <linux/platform_device.h>
 #include <linux/spi/spi.h>
 #include <linux/acpi.h>
+#include <linux/dmi.h>
 #include <sound/core.h>
 #include <sound/pcm.h>
 #include <sound/pcm_params.h>
@@ -31,6 +32,10 @@
 #include "rl6231.h"
 #include "rt5651.h"
 
+#define RT5651_JD_MAP(quirk)	((quirk) & GENMASK(7, 0))
+#define RT5651_IN2_DIFF		BIT(16)
+#define RT5651_DMIC_EN		BIT(17)
+
 #define RT5651_DEVICE_ID_VALUE 0x6281
 
 #define RT5651_PR_RANGE_BASE (0xff + 1)
@@ -38,6 +43,8 @@
 
 #define RT5651_PR_BASE (RT5651_PR_RANGE_BASE + (0 * RT5651_PR_SPACING))
 
+static unsigned long rt5651_quirk;
+
 static const struct regmap_range_cfg rt5651_ranges[] = {
 	{ .name = "PR", .range_min = RT5651_PR_BASE,
 	  .range_max = RT5651_PR_BASE + 0xb4,
@@ -1739,16 +1746,36 @@ static const struct i2c_device_id rt5651_i2c_id[] = {
 };
 MODULE_DEVICE_TABLE(i2c, rt5651_i2c_id);
 
+static int rt5651_quirk_cb(const struct dmi_system_id *id)
+{
+	rt5651_quirk = (unsigned long) id->driver_data;
+	return 1;
+}
+
+static const struct dmi_system_id rt5651_quirk_table[] = {
+	{}
+};
+
 static int rt5651_parse_dt(struct rt5651_priv *rt5651, struct device_node *np)
 {
-	rt5651->pdata.in2_diff = of_property_read_bool(np,
-		"realtek,in2-differential");
-	rt5651->pdata.dmic_en = of_property_read_bool(np,
-		"realtek,dmic-en");
+	if (of_property_read_bool(np, "realtek,in2-differential"))
+		rt5651_quirk |= RT5651_IN2_DIFF;
+	if (of_property_read_bool(np, "realtek,dmic-en"))
+		rt5651_quirk |= RT5651_DMIC_EN;
 
 	return 0;
 }
 
+static void rt5651_set_pdata(struct rt5651_priv *rt5651)
+{
+	if (rt5651_quirk & RT5651_IN2_DIFF)
+		rt5651->pdata.in2_diff = true;
+	if (rt5651_quirk & RT5651_DMIC_EN)
+		rt5651->pdata.dmic_en = true;
+	if (RT5651_JD_MAP(rt5651_quirk))
+		rt5651->pdata.jd_src = RT5651_JD_MAP(rt5651_quirk);
+}
+
 static irqreturn_t rt5651_irq(int irq, void *data)
 {
 	struct rt5651_priv *rt5651 = data;
@@ -1854,6 +1881,10 @@ static int rt5651_i2c_probe(struct i2c_client *i2c,
 		rt5651->pdata = *pdata;
 	else if (i2c->dev.of_node)
 		rt5651_parse_dt(rt5651, i2c->dev.of_node);
+	else
+		dmi_check_system(rt5651_quirk_table);
+
+	rt5651_set_pdata(rt5651);
 
 	rt5651->regmap = devm_regmap_init_i2c(i2c, &rt5651_regmap);
 	if (IS_ERR(rt5651->regmap)) {
Signature · 1 line
2.14.2
maintainer
#9 lore raw

Applied "ASoC: rt5651: Rework quirk logic" to the asoc tree

The patch

ASoC: rt5651: Rework quirk logic

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

Quoted 1 line

From b4435130bc19cd54631588355b16326aeb760e34 Mon Sep 17 00:00:00 2001

From: Carlo Caione <[email protected]>
Date: Fri, 20 Oct 2017 12:18:58 +0100
Subject: [PATCH] ASoC: rt5651: Rework quirk logic

Rework a bit the quirk logic in the codec driver to simplify the DMI-based quirk assignment for non-DT platforms.

---
 sound/soc/codecs/rt5651.c | 39 +++++++++++++++++++++++++++++++++++----
 1 file changed, 35 insertions(+), 4 deletions(-)
sound/soc/codecs/rt5651.c +35 -4
index 91f254391452..f01d41101631 100644
@@ -19,6 +19,7 @@
 #include <linux/platform_device.h>
 #include <linux/spi/spi.h>
 #include <linux/acpi.h>
+#include <linux/dmi.h>
 #include <sound/core.h>
 #include <sound/pcm.h>
 #include <sound/pcm_params.h>
@@ -31,6 +32,10 @@
 #include "rl6231.h"
 #include "rt5651.h"
 
+#define RT5651_JD_MAP(quirk)	((quirk) & GENMASK(7, 0))
+#define RT5651_IN2_DIFF		BIT(16)
+#define RT5651_DMIC_EN		BIT(17)
+
 #define RT5651_DEVICE_ID_VALUE 0x6281
 
 #define RT5651_PR_RANGE_BASE (0xff + 1)
@@ -38,6 +43,8 @@
 
 #define RT5651_PR_BASE (RT5651_PR_RANGE_BASE + (0 * RT5651_PR_SPACING))
 
+static unsigned long rt5651_quirk;
+
 static const struct regmap_range_cfg rt5651_ranges[] = {
 	{ .name = "PR", .range_min = RT5651_PR_BASE,
 	  .range_max = RT5651_PR_BASE + 0xb4,
@@ -1739,16 +1746,36 @@ static const struct i2c_device_id rt5651_i2c_id[] = {
 };
 MODULE_DEVICE_TABLE(i2c, rt5651_i2c_id);
 
+static int rt5651_quirk_cb(const struct dmi_system_id *id)
+{
+	rt5651_quirk = (unsigned long) id->driver_data;
+	return 1;
+}
+
+static const struct dmi_system_id rt5651_quirk_table[] = {
+	{}
+};
+
 static int rt5651_parse_dt(struct rt5651_priv *rt5651, struct device_node *np)
 {
-	rt5651->pdata.in2_diff = of_property_read_bool(np,
-		"realtek,in2-differential");
-	rt5651->pdata.dmic_en = of_property_read_bool(np,
-		"realtek,dmic-en");
+	if (of_property_read_bool(np, "realtek,in2-differential"))
+		rt5651_quirk |= RT5651_IN2_DIFF;
+	if (of_property_read_bool(np, "realtek,dmic-en"))
+		rt5651_quirk |= RT5651_DMIC_EN;
 
 	return 0;
 }
 
+static void rt5651_set_pdata(struct rt5651_priv *rt5651)
+{
+	if (rt5651_quirk & RT5651_IN2_DIFF)
+		rt5651->pdata.in2_diff = true;
+	if (rt5651_quirk & RT5651_DMIC_EN)
+		rt5651->pdata.dmic_en = true;
+	if (RT5651_JD_MAP(rt5651_quirk))
+		rt5651->pdata.jd_src = RT5651_JD_MAP(rt5651_quirk);
+}
+
 static irqreturn_t rt5651_irq(int irq, void *data)
 {
 	struct rt5651_priv *rt5651 = data;
@@ -1854,6 +1881,10 @@ static int rt5651_i2c_probe(struct i2c_client *i2c,
 		rt5651->pdata = *pdata;
 	else if (i2c->dev.of_node)
 		rt5651_parse_dt(rt5651, i2c->dev.of_node);
+	else
+		dmi_check_system(rt5651_quirk_table);
+
+	rt5651_set_pdata(rt5651);
 
 	rt5651->regmap = devm_regmap_init_i2c(i2c, &rt5651_regmap);
 	if (IS_ERR(rt5651->regmap)) {
Signature · 1 line
2.14.1
#10 lore raw

PATCH v2 5/5 ASoC: rt5651: Enable JD1_1 quirk for KIANO laptopt

In reply to Carlo Caione

From: Carlo Caione <[email protected]>

The KIANO SlimNote 14.2 laptop uses the JD1_1 input pin for jack detection. Set the correct quirk in the codec driver.

---
 sound/soc/codecs/rt5651.c | 8 ++++++++
 1 file changed, 8 insertions(+)
sound/soc/codecs/rt5651.c +8 -0
index f01d41101631..831b297978a4 100644
@@ -1753,6 +1753,14 @@ static int rt5651_quirk_cb(const struct dmi_system_id *id)
 }
 
 static const struct dmi_system_id rt5651_quirk_table[] = {
+	{
+		.callback = rt5651_quirk_cb,
+		.matches = {
+			DMI_MATCH(DMI_SYS_VENDOR, "KIANO"),
+			DMI_MATCH(DMI_PRODUCT_NAME, "KIANO SlimNote 14.2"),
+		},
+		.driver_data = (unsigned long *) RT5651_JD1_1,
+	},
 	{}
 };
 
Signature · 1 line
2.14.2
maintainer
#11 lore raw

Applied "ASoC: rt5651: Enable JD1_1 quirk for KIANO laptopt" to the asoc tree

The patch

ASoC: rt5651: Enable JD1_1 quirk for KIANO laptopt

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

Quoted 1 line

From f85353fdd49fe0087438ef7d7475a832d16276c4 Mon Sep 17 00:00:00 2001

From: Carlo Caione <[email protected]>
Date: Fri, 20 Oct 2017 12:18:59 +0100
Subject: [PATCH] ASoC: rt5651: Enable JD1_1 quirk for KIANO laptopt

The KIANO SlimNote 14.2 laptop uses the JD1_1 input pin for jack detection. Set the correct quirk in the codec driver.

---
 sound/soc/codecs/rt5651.c | 8 ++++++++
 1 file changed, 8 insertions(+)
sound/soc/codecs/rt5651.c +8 -0
index f01d41101631..831b297978a4 100644
@@ -1753,6 +1753,14 @@ static int rt5651_quirk_cb(const struct dmi_system_id *id)
 }
 
 static const struct dmi_system_id rt5651_quirk_table[] = {
+	{
+		.callback = rt5651_quirk_cb,
+		.matches = {
+			DMI_MATCH(DMI_SYS_VENDOR, "KIANO"),
+			DMI_MATCH(DMI_PRODUCT_NAME, "KIANO SlimNote 14.2"),
+		},
+		.driver_data = (unsigned long *) RT5651_JD1_1,
+	},
 	{}
 };
 
Signature · 1 line
2.14.1