All of lore.kernel.org
 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; 10+ 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] 10+ messages in thread

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

Thread overview: 10+ 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-08  7:24     ` Mark Brown
2019-04-01  8:52 ` Applied "ASoC: es8316: Add support for inverted jack detect" " Mark Brown
2019-04-01  8:52   ` Mark Brown
2019-04-01 17:57   ` Paul Cercueil
2019-04-01 17:57     ` Paul Cercueil
2019-04-02  4:55     ` Mark Brown

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.