mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Akihiko Odaki <akihiko.odaki@gmail.com>
To: unlisted-recipients:; (no To-header on input)
Cc: "Liam Girdwood" <lgirdwood@gmail.com>,
	"Mark Brown" <broonie@kernel.org>,
	"Jaroslav Kysela" <perex@perex.cz>,
	"Takashi Iwai" <tiwai@suse.com>,
	"Matthias Brugger" <matthias.bgg@gmail.com>,
	alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org,
	"Nícolas F . R . A . Prado" <nfraprado@collabora.com>,
	"Akihiko Odaki" <akihiko.odaki@gmail.com>
Subject: [PATCH 2/2] ASoC: amd: acp3x-5682: Expose individual headset jack pins
Date: Sat, 24 Sep 2022 18:50:25 +0900	[thread overview]
Message-ID: <20220924095025.7778-2-akihiko.odaki@gmail.com> (raw)
In-Reply-To: <20220924095025.7778-1-akihiko.odaki@gmail.com>

The rt5682 codec is able to distinguish between two event types:
headphone insertion/removal and headset microphone insertion/removal.
However, currently, the acp3x-5682 driver exposes a single kcontrol
for the headset jack, so userspace isn't able to differentiate between
the two events.

Add a definition for the headset jack pins, so that a separate jack
kcontrol is created for each one, allowing userspace to track and handle
them individually.

This change is based on commit 194ff8db0378 ("ASoC: mediatek:
mt8192-mt6359: Expose individual headset jack pins").

Signed-off-by: Akihiko Odaki <akihiko.odaki@gmail.com>
---
 sound/soc/amd/acp3x-rt5682-max9836.c | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)

diff --git a/sound/soc/amd/acp3x-rt5682-max9836.c b/sound/soc/amd/acp3x-rt5682-max9836.c
index 0bdd9c26dd22..3679931a2285 100644
--- a/sound/soc/amd/acp3x-rt5682-max9836.c
+++ b/sound/soc/amd/acp3x-rt5682-max9836.c
@@ -39,6 +39,17 @@ enum {
 	EC,
 };
 
+static struct snd_soc_jack_pin acp3x_5682_jack_pins[] = {
+	{
+		.pin	= "Headphone Jack",
+		.mask	= SND_JACK_HEADPHONE,
+	},
+	{
+		.pin	= "Headset Mic",
+		.mask	= SND_JACK_MICROPHONE,
+	},
+};
+
 static int acp3x_5682_init(struct snd_soc_pcm_runtime *rtd)
 {
 	int ret;
@@ -86,11 +97,12 @@ static int acp3x_5682_init(struct snd_soc_pcm_runtime *rtd)
 	rt5682_dai_wclk = clk_get(component->dev, "rt5682-dai-wclk");
 	rt5682_dai_bclk = clk_get(component->dev, "rt5682-dai-bclk");
 
-	ret = snd_soc_card_jack_new(card, "Headset Jack",
+	ret = snd_soc_card_jack_new_pins(card, "Headset Jack",
 				SND_JACK_HEADSET |
 				SND_JACK_BTN_0 | SND_JACK_BTN_1 |
 				SND_JACK_BTN_2 | SND_JACK_BTN_3,
-				&pco_jack);
+				&pco_jack, acp3x_5682_jack_pins,
+				ARRAY_SIZE(acp3x_5682_jack_pins));
 	if (ret) {
 		dev_err(card->dev, "HP jack creation failed %d\n", ret);
 		return ret;
-- 
2.37.3


  reply	other threads:[~2022-09-24  9:50 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-24  9:50 [PATCH 1/2] ASoC: amd: acp3x-5682: Remove SND_JACK_LINEOUT Akihiko Odaki
2022-09-24  9:50 ` Akihiko Odaki [this message]
2022-09-26 13:27 ` Mark Brown

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=20220924095025.7778-2-akihiko.odaki@gmail.com \
    --to=akihiko.odaki@gmail.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=broonie@kernel.org \
    --cc=lgirdwood@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=matthias.bgg@gmail.com \
    --cc=nfraprado@collabora.com \
    --cc=perex@perex.cz \
    --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®