mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: David Rau <David.Rau.opensource@dm.renesas.com>
To: broonie@kernel.org
Cc: support.opensource@diasemi.com, lgirdwood@gmail.com,
	perex@perex.cz, tiwai@suse.com, alsa-devel@alsa-project.org,
	linux-kernel@vger.kernel.org,
	David Rau <David.Rau.opensource@dm.renesas.com>
Subject: [PATCH] ASoC: da7219: Add Jack insertion detection polarity selection
Date: Thu,  4 May 2023 08:22:18 +0000	[thread overview]
Message-ID: <20230504082218.24059-1-David.Rau.opensource@dm.renesas.com> (raw)

Add the selection of DA7219 Jack insertion detection polarity
- Default polarity (Low)
- Inverted polarity (High)

Signed-off-by: David Rau <David.Rau.opensource@dm.renesas.com>
---
 sound/soc/codecs/Kconfig      | 24 +++++++++++++++++++++++-
 sound/soc/codecs/da7219-aad.c | 16 ++++++++++++++++
 2 files changed, 39 insertions(+), 1 deletion(-)

diff --git a/sound/soc/codecs/Kconfig b/sound/soc/codecs/Kconfig
index 79d2362ad055..96f934ad52e7 100644
--- a/sound/soc/codecs/Kconfig
+++ b/sound/soc/codecs/Kconfig
@@ -967,9 +967,31 @@ config SND_SOC_DA7218
 	depends on I2C
 
 config SND_SOC_DA7219
-	tristate
+	tristate "Dialog DA7219 CODEC"
 	depends on I2C
 
+if SND_SOC_DA7219
+
+choice
+	bool "DA7219 Jack insertion detection polarity selection"
+	default DA7219_DEFAULT_JACK_INSERTION_POLARITY if (SND_SOC_DA7219)
+
+config DA7219_DEFAULT_JACK_INSERTION_POLARITY
+    bool "Default polarity"
+	depends on SND_SOC_DA7219
+    help
+	  Select this option if your DA7219 codec with default Jack insertion detection polarity (Low).
+
+config DA7219_INVERTED_JACK_INSERTION_POLARITY
+    bool "Inverted polarity"
+	depends on SND_SOC_DA7219
+    help
+	  Select this option if your DA7219 codec with inverted Jack insertion detection polarity (High).
+
+endchoice
+
+endif # SND_SOC_DA7219
+
 config SND_SOC_DA732X
 	tristate
 	depends on I2C
diff --git a/sound/soc/codecs/da7219-aad.c b/sound/soc/codecs/da7219-aad.c
index 993a0d00bc48..9d16112cff6b 100644
--- a/sound/soc/codecs/da7219-aad.c
+++ b/sound/soc/codecs/da7219-aad.c
@@ -879,6 +879,18 @@ static void da7219_aad_handle_gnd_switch_time(struct snd_soc_component *componen
 	}
 }
 
+static void da7219_aad_handle_polarity(struct snd_soc_component *component)
+{
+	snd_soc_component_write(component, 0xF0, 0x8B);
+
+	if (IS_ENABLED(CONFIG_DA7219_DEFAULT_JACK_INSERTION_POLARITY))
+		snd_soc_component_write(component, 0x75, 0x80);
+	else if (IS_ENABLED(CONFIG_DA7219_INVERTED_JACK_INSERTION_POLARITY))
+		snd_soc_component_write(component, 0x75, 0x00);
+
+	snd_soc_component_write(component, 0xF0, 0x00);
+}
+
 /*
  * Suspend/Resume
  */
@@ -955,8 +967,12 @@ int da7219_aad_init(struct snd_soc_component *component)
 	snd_soc_component_update_bits(component, DA7219_ACCDET_CONFIG_1,
 			    DA7219_BUTTON_CONFIG_MASK, 0);
 
+	/* Handle the default ground switch delay time */
 	da7219_aad_handle_gnd_switch_time(component);
 
+	/* Handle the Jack insertion detection polarity */
+	da7219_aad_handle_polarity(component);
+
 	da7219_aad->aad_wq = create_singlethread_workqueue("da7219-aad");
 	if (!da7219_aad->aad_wq) {
 		dev_err(component->dev, "Failed to create aad workqueue\n");
-- 
2.17.1


             reply	other threads:[~2023-05-04  8:28 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-04  8:22 David Rau [this message]
2023-05-04 13:39 ` Mark Brown
2023-05-12  8:10 David Rau
2023-05-12 16:18 ` Krzysztof Kozlowski

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=20230504082218.24059-1-David.Rau.opensource@dm.renesas.com \
    --to=david.rau.opensource@dm.renesas.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=broonie@kernel.org \
    --cc=lgirdwood@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=perex@perex.cz \
    --cc=support.opensource@diasemi.com \
    --cc=tiwai@suse.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®