alsa-devel.alsa-project.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] ASoC: nau8825: jack connection decision with different insertion logic
@ 2016-06-29  3:20 John Hsu
  2016-06-29  3:45 ` Anatol Pomozov
  0 siblings, 1 reply; 7+ messages in thread
From: John Hsu @ 2016-06-29  3:20 UTC (permalink / raw)
  To: broonie
  Cc: alsa-devel, anatol.pomozov, YHCHuang, John Hsu, lgirdwood, benzh,
	CTLIN0, mhkuo, yong.zhi

The original design only covers the jack insertion logic is active low.
Add more condition to cover no matter the logic is active low and high.

Signed-off-by: John Hsu <KCHSU0@nuvoton.com>
---
 sound/soc/codecs/nau8825.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/sound/soc/codecs/nau8825.c b/sound/soc/codecs/nau8825.c
index 3f30e6e..a2f0d03 100644
--- a/sound/soc/codecs/nau8825.c
+++ b/sound/soc/codecs/nau8825.c
@@ -1345,10 +1345,18 @@ EXPORT_SYMBOL_GPL(nau8825_enable_jack_detect);
 
 static bool nau8825_is_jack_inserted(struct regmap *regmap)
 {
-	int status;
+	int status, jkdet, res;
 
 	regmap_read(regmap, NAU8825_REG_I2C_DEVICE_ID, &status);
-	return !(status & NAU8825_GPIO2JD1);
+	regmap_read(regmap, NAU8825_REG_JACK_DET_CTRL, &jkdet);
+
+	/* return jack connection status according to jack insertion logic
+	 * active high or active low.
+	 */
+	res = !(status & NAU8825_GPIO2JD1) * !(jkdet & NAU8825_JACK_POLARITY) +
+		(status & NAU8825_GPIO2JD1) * (jkdet & NAU8825_JACK_POLARITY);
+
+	return res ? true : false;
 }
 
 static void nau8825_restart_jack_detection(struct regmap *regmap)
-- 
2.6.4

^ permalink raw reply related	[flat|nested] 7+ messages in thread
* [PATCH] ASoC: nau8825: jack connection decision with different insertion logic
@ 2016-07-06  2:09 John Hsu
  0 siblings, 0 replies; 7+ messages in thread
From: John Hsu @ 2016-07-06  2:09 UTC (permalink / raw)
  To: broonie
  Cc: alsa-devel, anatol.pomozov, YHCHuang, John Hsu, lgirdwood, benzh,
	CTLIN0, mhkuo, yong.zhi

The original design only covers the jack insertion logic is active low.
Add more condition to cover no matter the logic is active low and high.

Signed-off-by: John Hsu <KCHSU0@nuvoton.com>
---
 sound/soc/codecs/nau8825.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/sound/soc/codecs/nau8825.c b/sound/soc/codecs/nau8825.c
index 3f30e6e..a97418d 100644
--- a/sound/soc/codecs/nau8825.c
+++ b/sound/soc/codecs/nau8825.c
@@ -1345,10 +1345,17 @@ EXPORT_SYMBOL_GPL(nau8825_enable_jack_detect);
 
 static bool nau8825_is_jack_inserted(struct regmap *regmap)
 {
-	int status;
+	bool active_high, is_high;
+	int status, jkdet;
 
+	regmap_read(regmap, NAU8825_REG_JACK_DET_CTRL, &jkdet);
+	active_high = !!(jkdet & NAU8825_JACK_POLARITY);
 	regmap_read(regmap, NAU8825_REG_I2C_DEVICE_ID, &status);
-	return !(status & NAU8825_GPIO2JD1);
+	is_high = !!(status & NAU8825_GPIO2JD1);
+	/* return jack connection status according to jack insertion logic
+	 * active high or active low.
+	 */
+	return active_high == is_high;
 }
 
 static void nau8825_restart_jack_detection(struct regmap *regmap)
-- 
2.6.4

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

end of thread, other threads:[~2016-07-06  2:54 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-06-29  3:20 [PATCH] ASoC: nau8825: jack connection decision with different insertion logic John Hsu
2016-06-29  3:45 ` Anatol Pomozov
2016-06-30  7:51   ` John Hsu
2016-07-01 15:57     ` Mark Brown
2016-07-04  2:43       ` John Hsu
2016-07-06  2:54       ` Anatol Pomozov
  -- strict thread matches above, loose matches on Subject: below --
2016-07-06  2:09 John Hsu

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).