linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/6] ASoC: mediatek: Allow separate handling of headphone and headset mic jack
@ 2022-09-22 23:59 Nícolas F. R. A. Prado
  2022-09-22 23:59 ` [PATCH 1/6] ASoC: mediatek: mt8192-mt6359: Expose individual headset jack pins Nícolas F. R. A. Prado
                   ` (6 more replies)
  0 siblings, 7 replies; 14+ messages in thread
From: Nícolas F. R. A. Prado @ 2022-09-22 23:59 UTC (permalink / raw)
  To: Mark Brown
  Cc: AngeloGioacchino Del Regno, kernel, Nícolas F. R. A. Prado,
	Akihiko Odaki, Jaroslav Kysela, Jiaxin Yu, Liam Girdwood,
	Matthias Brugger, Miaoqian Lin, Takashi Iwai, Trevor Wu,
	Tzung-Bi Shih, alsa-devel, chunxu.li, linux-arm-kernel,
	linux-kernel, linux-mediatek


This series allows the headphone and headset mic jack status to be
handled separately by userspace on MT8192, MT8195 and MT8186.

Changes based on commit d0508b4f1604 ("ASoC: rk3399_gru_sound: Add DAPM
pins, kcontrols for jack detection"). Found while searching for an
alternative for JackSwitch [1].

[1] https://lore.kernel.org/all/b98a8a77-7652-1995-27ba-eb7b6d30202a@gmail.com/


Nícolas F. R. A. Prado (6):
  ASoC: mediatek: mt8192-mt6359: Expose individual headset jack pins
  ASoC: mediatek: mt8195: Expose individual headset jack pins
  ASoC: mediatek: mt8186-da7219: Add headset widgets with switches
  ASoC: mediatek: mt8186-da7219: Expose individual headset jack pins
  ASoC: mediatek: mt8186-rt5682: Add headset widgets with switches
  ASoC: mediatek: mt8186-rt5682: Expose individual headset jack pins

 .../mt8186/mt8186-mt6366-da7219-max98357.c    | 25 +++++++++++++++++--
 .../mt8186/mt8186-mt6366-rt1019-rt5682s.c     | 25 +++++++++++++++++--
 .../mt8192/mt8192-mt6359-rt1015-rt5682.c      | 17 +++++++++++--
 sound/soc/mediatek/mt8195/mt8195-mt6359.c     | 17 +++++++++++--
 4 files changed, 76 insertions(+), 8 deletions(-)

-- 
2.37.3


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* [PATCH 1/6] ASoC: mediatek: mt8192-mt6359: Expose individual headset jack pins
  2022-09-22 23:59 [PATCH 0/6] ASoC: mediatek: Allow separate handling of headphone and headset mic jack Nícolas F. R. A. Prado
@ 2022-09-22 23:59 ` Nícolas F. R. A. Prado
  2022-09-23  8:58   ` AngeloGioacchino Del Regno
  2022-09-22 23:59 ` [PATCH 2/6] ASoC: mediatek: mt8195: " Nícolas F. R. A. Prado
                   ` (5 subsequent siblings)
  6 siblings, 1 reply; 14+ messages in thread
From: Nícolas F. R. A. Prado @ 2022-09-22 23:59 UTC (permalink / raw)
  To: Mark Brown
  Cc: AngeloGioacchino Del Regno, kernel, Nícolas F. R. A. Prado,
	Akihiko Odaki, Jaroslav Kysela, Jiaxin Yu, Liam Girdwood,
	Matthias Brugger, Miaoqian Lin, Takashi Iwai, Tzung-Bi Shih,
	alsa-devel, linux-arm-kernel, linux-kernel, linux-mediatek

The rt5682 codec is able to distinguish between two event types:
headphone insertion/removal and headset microphone insertion/removal.
However, currently, the mt8192-mt6359 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.

Signed-off-by: Nícolas F. R. A. Prado <nfraprado@collabora.com>

---

 .../mt8192/mt8192-mt6359-rt1015-rt5682.c        | 17 +++++++++++++++--
 1 file changed, 15 insertions(+), 2 deletions(-)

diff --git a/sound/soc/mediatek/mt8192/mt8192-mt6359-rt1015-rt5682.c b/sound/soc/mediatek/mt8192/mt8192-mt6359-rt1015-rt5682.c
index 044d6ab71f0a..ff40ccd36f7e 100644
--- a/sound/soc/mediatek/mt8192/mt8192-mt6359-rt1015-rt5682.c
+++ b/sound/soc/mediatek/mt8192/mt8192-mt6359-rt1015-rt5682.c
@@ -41,6 +41,18 @@ struct mt8192_mt6359_priv {
 	struct snd_soc_jack hdmi_jack;
 };
 
+/* Headset jack detection DAPM pins */
+static struct snd_soc_jack_pin mt8192_jack_pins[] = {
+	{
+		.pin = "Headphone Jack",
+		.mask = SND_JACK_HEADPHONE,
+	},
+	{
+		.pin = "Headset Mic",
+		.mask = SND_JACK_MICROPHONE,
+	},
+};
+
 static int mt8192_rt1015_i2s_hw_params(struct snd_pcm_substream *substream,
 				       struct snd_pcm_hw_params *params)
 {
@@ -326,11 +338,12 @@ static int mt8192_rt5682_init(struct snd_soc_pcm_runtime *rtd)
 		return ret;
 	}
 
-	ret = snd_soc_card_jack_new(rtd->card, "Headset Jack",
+	ret = snd_soc_card_jack_new_pins(rtd->card, "Headset Jack",
 				    SND_JACK_HEADSET | SND_JACK_BTN_0 |
 				    SND_JACK_BTN_1 | SND_JACK_BTN_2 |
 				    SND_JACK_BTN_3,
-				    jack);
+				    jack, mt8192_jack_pins,
+				    ARRAY_SIZE(mt8192_jack_pins));
 	if (ret) {
 		dev_err(rtd->dev, "Headset Jack creation failed: %d\n", ret);
 		return ret;
-- 
2.37.3


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* [PATCH 2/6] ASoC: mediatek: mt8195: Expose individual headset jack pins
  2022-09-22 23:59 [PATCH 0/6] ASoC: mediatek: Allow separate handling of headphone and headset mic jack Nícolas F. R. A. Prado
  2022-09-22 23:59 ` [PATCH 1/6] ASoC: mediatek: mt8192-mt6359: Expose individual headset jack pins Nícolas F. R. A. Prado
@ 2022-09-22 23:59 ` Nícolas F. R. A. Prado
  2022-09-23  8:58   ` AngeloGioacchino Del Regno
  2022-09-22 23:59 ` [PATCH 3/6] ASoC: mediatek: mt8186-da7219: Add headset widgets with switches Nícolas F. R. A. Prado
                   ` (4 subsequent siblings)
  6 siblings, 1 reply; 14+ messages in thread
From: Nícolas F. R. A. Prado @ 2022-09-22 23:59 UTC (permalink / raw)
  To: Mark Brown
  Cc: AngeloGioacchino Del Regno, kernel, Nícolas F. R. A. Prado,
	Jaroslav Kysela, Liam Girdwood, Matthias Brugger, Takashi Iwai,
	Trevor Wu, Tzung-Bi Shih, alsa-devel, linux-arm-kernel,
	linux-kernel, linux-mediatek

The rt5682 codec is able to distinguish between two event types:
headphone insertion/removal and headset microphone insertion/removal.
However, currently, the mt8195 ASoC 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.

Signed-off-by: Nícolas F. R. A. Prado <nfraprado@collabora.com>

---

 sound/soc/mediatek/mt8195/mt8195-mt6359.c | 17 +++++++++++++++--
 1 file changed, 15 insertions(+), 2 deletions(-)

diff --git a/sound/soc/mediatek/mt8195/mt8195-mt6359.c b/sound/soc/mediatek/mt8195/mt8195-mt6359.c
index 961e769602d6..17d4c4108a9d 100644
--- a/sound/soc/mediatek/mt8195/mt8195-mt6359.c
+++ b/sound/soc/mediatek/mt8195/mt8195-mt6359.c
@@ -63,6 +63,18 @@ struct mt8195_mt6359_priv {
 	struct clk *i2so1_mclk;
 };
 
+/* Headset jack detection DAPM pins */
+static struct snd_soc_jack_pin mt8195_jack_pins[] = {
+	{
+		.pin = "Headphone",
+		.mask = SND_JACK_HEADPHONE,
+	},
+	{
+		.pin = "Headset Mic",
+		.mask = SND_JACK_MICROPHONE,
+	},
+};
+
 static const struct snd_soc_dapm_widget mt8195_mt6359_widgets[] = {
 	SND_SOC_DAPM_HP("Headphone", NULL),
 	SND_SOC_DAPM_MIC("Headset Mic", NULL),
@@ -563,11 +575,12 @@ static int mt8195_rt5682_init(struct snd_soc_pcm_runtime *rtd)
 
 	priv->i2so1_mclk = afe_priv->clk[MT8195_CLK_TOP_APLL12_DIV2];
 
-	ret = snd_soc_card_jack_new(rtd->card, "Headset Jack",
+	ret = snd_soc_card_jack_new_pins(rtd->card, "Headset Jack",
 				    SND_JACK_HEADSET | SND_JACK_BTN_0 |
 				    SND_JACK_BTN_1 | SND_JACK_BTN_2 |
 				    SND_JACK_BTN_3,
-				    jack);
+				    jack, mt8195_jack_pins,
+				    ARRAY_SIZE(mt8195_jack_pins));
 	if (ret) {
 		dev_err(rtd->dev, "Headset Jack creation failed: %d\n", ret);
 		return ret;
-- 
2.37.3


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* [PATCH 3/6] ASoC: mediatek: mt8186-da7219: Add headset widgets with switches
  2022-09-22 23:59 [PATCH 0/6] ASoC: mediatek: Allow separate handling of headphone and headset mic jack Nícolas F. R. A. Prado
  2022-09-22 23:59 ` [PATCH 1/6] ASoC: mediatek: mt8192-mt6359: Expose individual headset jack pins Nícolas F. R. A. Prado
  2022-09-22 23:59 ` [PATCH 2/6] ASoC: mediatek: mt8195: " Nícolas F. R. A. Prado
@ 2022-09-22 23:59 ` Nícolas F. R. A. Prado
  2022-09-23  8:58   ` AngeloGioacchino Del Regno
  2022-09-22 23:59 ` [PATCH 4/6] ASoC: mediatek: mt8186-da7219: Expose individual headset jack pins Nícolas F. R. A. Prado
                   ` (3 subsequent siblings)
  6 siblings, 1 reply; 14+ messages in thread
From: Nícolas F. R. A. Prado @ 2022-09-22 23:59 UTC (permalink / raw)
  To: Mark Brown
  Cc: AngeloGioacchino Del Regno, kernel, Nícolas F. R. A. Prado,
	Jaroslav Kysela, Jiaxin Yu, Liam Girdwood, Matthias Brugger,
	Takashi Iwai, alsa-devel, chunxu.li, linux-arm-kernel,
	linux-kernel, linux-mediatek

Add DAPM widgets for headphones and headset microphone, with matching
switches, to allow toggling these paths based on the jack connection
status.

Note that differently from others (mt8192, mt8195 and mt8186-rt5682),
the widget here is named "Headphones" (with an 's'), since "Headphone
Switch" was already registered by da7219.

Signed-off-by: Nícolas F. R. A. Prado <nfraprado@collabora.com>
---

 sound/soc/mediatek/mt8186/mt8186-mt6366-da7219-max98357.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/sound/soc/mediatek/mt8186/mt8186-mt6366-da7219-max98357.c b/sound/soc/mediatek/mt8186/mt8186-mt6366-da7219-max98357.c
index 6f93f9dd4623..8d428bc4a3b2 100644
--- a/sound/soc/mediatek/mt8186/mt8186-mt6366-da7219-max98357.c
+++ b/sound/soc/mediatek/mt8186/mt8186-mt6366-da7219-max98357.c
@@ -950,6 +950,8 @@ static struct snd_soc_dai_link mt8186_mt6366_da7219_max98357_dai_links[] = {
 static const struct snd_soc_dapm_widget
 mt8186_mt6366_da7219_max98357_widgets[] = {
 	SND_SOC_DAPM_SPK("Speakers", NULL),
+	SND_SOC_DAPM_HP("Headphones", NULL),
+	SND_SOC_DAPM_MIC("Headset Mic", NULL),
 	SND_SOC_DAPM_OUTPUT("HDMI1"),
 	SND_SOC_DAPM_MIXER(SOF_DMA_DL1, SND_SOC_NOPM, 0, 0, NULL, 0),
 	SND_SOC_DAPM_MIXER(SOF_DMA_DL2, SND_SOC_NOPM, 0, 0, NULL, 0),
@@ -961,6 +963,10 @@ static const struct snd_soc_dapm_route
 mt8186_mt6366_da7219_max98357_routes[] = {
 	/* SPK */
 	{ "Speakers", NULL, "Speaker"},
+	/* Headset */
+	{ "Headphones", NULL, "HPL" },
+	{ "Headphones", NULL, "HPR" },
+	{ "MIC", NULL, "Headset Mic" },
 	/* HDMI */
 	{ "HDMI1", NULL, "TX"},
 	/* SOF Uplink */
@@ -976,6 +982,8 @@ mt8186_mt6366_da7219_max98357_routes[] = {
 static const struct snd_kcontrol_new
 mt8186_mt6366_da7219_max98357_controls[] = {
 	SOC_DAPM_PIN_SWITCH("Speakers"),
+	SOC_DAPM_PIN_SWITCH("Headphones"),
+	SOC_DAPM_PIN_SWITCH("Headset Mic"),
 	SOC_DAPM_PIN_SWITCH("HDMI1"),
 };
 
-- 
2.37.3


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* [PATCH 4/6] ASoC: mediatek: mt8186-da7219: Expose individual headset jack pins
  2022-09-22 23:59 [PATCH 0/6] ASoC: mediatek: Allow separate handling of headphone and headset mic jack Nícolas F. R. A. Prado
                   ` (2 preceding siblings ...)
  2022-09-22 23:59 ` [PATCH 3/6] ASoC: mediatek: mt8186-da7219: Add headset widgets with switches Nícolas F. R. A. Prado
@ 2022-09-22 23:59 ` Nícolas F. R. A. Prado
  2022-09-23  8:58   ` AngeloGioacchino Del Regno
  2022-09-22 23:59 ` [PATCH 5/6] ASoC: mediatek: mt8186-rt5682: Add headset widgets with switches Nícolas F. R. A. Prado
                   ` (2 subsequent siblings)
  6 siblings, 1 reply; 14+ messages in thread
From: Nícolas F. R. A. Prado @ 2022-09-22 23:59 UTC (permalink / raw)
  To: Mark Brown
  Cc: AngeloGioacchino Del Regno, kernel, Nícolas F. R. A. Prado,
	Jaroslav Kysela, Jiaxin Yu, Liam Girdwood, Matthias Brugger,
	Takashi Iwai, alsa-devel, chunxu.li, linux-arm-kernel,
	linux-kernel, linux-mediatek

The da7219 codec is able to distinguish between two event types:
headphone insertion/removal and headset microphone insertion/removal.
However, currently, the mt8186-da7219 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.

Signed-off-by: Nícolas F. R. A. Prado <nfraprado@collabora.com>
---

 .../mt8186/mt8186-mt6366-da7219-max98357.c      | 17 +++++++++++++++--
 1 file changed, 15 insertions(+), 2 deletions(-)

diff --git a/sound/soc/mediatek/mt8186/mt8186-mt6366-da7219-max98357.c b/sound/soc/mediatek/mt8186/mt8186-mt6366-da7219-max98357.c
index 8d428bc4a3b2..cfca6bdee834 100644
--- a/sound/soc/mediatek/mt8186/mt8186-mt6366-da7219-max98357.c
+++ b/sound/soc/mediatek/mt8186/mt8186-mt6366-da7219-max98357.c
@@ -37,6 +37,18 @@ struct mt8186_mt6366_da7219_max98357_priv {
 	struct snd_soc_jack headset_jack, hdmi_jack;
 };
 
+/* Headset jack detection DAPM pins */
+static struct snd_soc_jack_pin mt8186_jack_pins[] = {
+	{
+		.pin = "Headphones",
+		.mask = SND_JACK_HEADPHONE,
+	},
+	{
+		.pin = "Headset Mic",
+		.mask = SND_JACK_MICROPHONE,
+	},
+};
+
 static struct snd_soc_codec_conf mt8186_mt6366_da7219_max98357_codec_conf[] = {
 	{
 		.dlc = COMP_CODEC_CONF("mt6358-sound"),
@@ -72,11 +84,12 @@ static int mt8186_da7219_init(struct snd_soc_pcm_runtime *rtd)
 	}
 
 	/* Enable Headset and 4 Buttons Jack detection */
-	ret = snd_soc_card_jack_new(rtd->card, "Headset Jack",
+	ret = snd_soc_card_jack_new_pins(rtd->card, "Headset Jack",
 				    SND_JACK_HEADSET | SND_JACK_BTN_0 |
 				    SND_JACK_BTN_1 | SND_JACK_BTN_2 |
 				    SND_JACK_BTN_3 | SND_JACK_LINEOUT,
-				    jack);
+				    jack, mt8186_jack_pins,
+				    ARRAY_SIZE(mt8186_jack_pins));
 	if (ret) {
 		dev_err(rtd->dev, "Headset Jack creation failed: %d\n", ret);
 		return ret;
-- 
2.37.3


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* [PATCH 5/6] ASoC: mediatek: mt8186-rt5682: Add headset widgets with switches
  2022-09-22 23:59 [PATCH 0/6] ASoC: mediatek: Allow separate handling of headphone and headset mic jack Nícolas F. R. A. Prado
                   ` (3 preceding siblings ...)
  2022-09-22 23:59 ` [PATCH 4/6] ASoC: mediatek: mt8186-da7219: Expose individual headset jack pins Nícolas F. R. A. Prado
@ 2022-09-22 23:59 ` Nícolas F. R. A. Prado
  2022-09-23  8:58   ` AngeloGioacchino Del Regno
  2022-09-22 23:59 ` [PATCH 6/6] ASoC: mediatek: mt8186-rt5682: Expose individual headset jack pins Nícolas F. R. A. Prado
  2022-09-23 17:07 ` [PATCH 0/6] ASoC: mediatek: Allow separate handling of headphone and headset mic jack Mark Brown
  6 siblings, 1 reply; 14+ messages in thread
From: Nícolas F. R. A. Prado @ 2022-09-22 23:59 UTC (permalink / raw)
  To: Mark Brown
  Cc: AngeloGioacchino Del Regno, kernel, Nícolas F. R. A. Prado,
	Jaroslav Kysela, Jiaxin Yu, Liam Girdwood, Matthias Brugger,
	Takashi Iwai, alsa-devel, chunxu.li, linux-arm-kernel,
	linux-kernel, linux-mediatek

Add DAPM widgets for headphones and headset microphone, with matching
switches, to allow toggling these paths based on the jack connection
status.

Signed-off-by: Nícolas F. R. A. Prado <nfraprado@collabora.com>
---

 sound/soc/mediatek/mt8186/mt8186-mt6366-rt1019-rt5682s.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/sound/soc/mediatek/mt8186/mt8186-mt6366-rt1019-rt5682s.c b/sound/soc/mediatek/mt8186/mt8186-mt6366-rt1019-rt5682s.c
index 247f20f594d9..4360871bfc44 100644
--- a/sound/soc/mediatek/mt8186/mt8186-mt6366-rt1019-rt5682s.c
+++ b/sound/soc/mediatek/mt8186/mt8186-mt6366-rt1019-rt5682s.c
@@ -926,6 +926,8 @@ static struct snd_soc_dai_link mt8186_mt6366_rt1019_rt5682s_dai_links[] = {
 static const struct snd_soc_dapm_widget
 mt8186_mt6366_rt1019_rt5682s_widgets[] = {
 	SND_SOC_DAPM_SPK("Speakers", NULL),
+	SND_SOC_DAPM_HP("Headphone", NULL),
+	SND_SOC_DAPM_MIC("Headset Mic", NULL),
 	SND_SOC_DAPM_OUTPUT("HDMI1"),
 	SND_SOC_DAPM_MIXER(SOF_DMA_DL1, SND_SOC_NOPM, 0, 0, NULL, 0),
 	SND_SOC_DAPM_MIXER(SOF_DMA_DL2, SND_SOC_NOPM, 0, 0, NULL, 0),
@@ -937,6 +939,10 @@ static const struct snd_soc_dapm_route
 mt8186_mt6366_rt1019_rt5682s_routes[] = {
 	/* SPK */
 	{ "Speakers", NULL, "Speaker" },
+	/* Headset */
+	{ "Headphone", NULL, "HPOL" },
+	{ "Headphone", NULL, "HPOR" },
+	{ "IN1P", NULL, "Headset Mic" },
 	/* HDMI */
 	{ "HDMI1", NULL, "TX" },
 	/* SOF Uplink */
@@ -952,6 +958,8 @@ mt8186_mt6366_rt1019_rt5682s_routes[] = {
 static const struct snd_kcontrol_new
 mt8186_mt6366_rt1019_rt5682s_controls[] = {
 	SOC_DAPM_PIN_SWITCH("Speakers"),
+	SOC_DAPM_PIN_SWITCH("Headphone"),
+	SOC_DAPM_PIN_SWITCH("Headset Mic"),
 	SOC_DAPM_PIN_SWITCH("HDMI1"),
 };
 
-- 
2.37.3


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* [PATCH 6/6] ASoC: mediatek: mt8186-rt5682: Expose individual headset jack pins
  2022-09-22 23:59 [PATCH 0/6] ASoC: mediatek: Allow separate handling of headphone and headset mic jack Nícolas F. R. A. Prado
                   ` (4 preceding siblings ...)
  2022-09-22 23:59 ` [PATCH 5/6] ASoC: mediatek: mt8186-rt5682: Add headset widgets with switches Nícolas F. R. A. Prado
@ 2022-09-22 23:59 ` Nícolas F. R. A. Prado
  2022-09-23  8:58   ` AngeloGioacchino Del Regno
  2022-09-23 17:07 ` [PATCH 0/6] ASoC: mediatek: Allow separate handling of headphone and headset mic jack Mark Brown
  6 siblings, 1 reply; 14+ messages in thread
From: Nícolas F. R. A. Prado @ 2022-09-22 23:59 UTC (permalink / raw)
  To: Mark Brown
  Cc: AngeloGioacchino Del Regno, kernel, Nícolas F. R. A. Prado,
	Jaroslav Kysela, Jiaxin Yu, Liam Girdwood, Matthias Brugger,
	Takashi Iwai, alsa-devel, chunxu.li, linux-arm-kernel,
	linux-kernel, linux-mediatek

The rt5682 codec is able to distinguish between two event types:
headphone insertion/removal and headset microphone insertion/removal.
However, currently, the mt8186-rt5682 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.

Signed-off-by: Nícolas F. R. A. Prado <nfraprado@collabora.com>
---

 .../mt8186/mt8186-mt6366-rt1019-rt5682s.c       | 17 +++++++++++++++--
 1 file changed, 15 insertions(+), 2 deletions(-)

diff --git a/sound/soc/mediatek/mt8186/mt8186-mt6366-rt1019-rt5682s.c b/sound/soc/mediatek/mt8186/mt8186-mt6366-rt1019-rt5682s.c
index 4360871bfc44..2414c5b77233 100644
--- a/sound/soc/mediatek/mt8186/mt8186-mt6366-rt1019-rt5682s.c
+++ b/sound/soc/mediatek/mt8186/mt8186-mt6366-rt1019-rt5682s.c
@@ -41,6 +41,18 @@ struct mt8186_mt6366_rt1019_rt5682s_priv {
 	struct snd_soc_jack headset_jack, hdmi_jack;
 };
 
+/* Headset jack detection DAPM pins */
+static struct snd_soc_jack_pin mt8186_jack_pins[] = {
+	{
+		.pin = "Headphone",
+		.mask = SND_JACK_HEADPHONE,
+	},
+	{
+		.pin = "Headset Mic",
+		.mask = SND_JACK_MICROPHONE,
+	},
+};
+
 static struct snd_soc_codec_conf mt8186_mt6366_rt1019_rt5682s_codec_conf[] = {
 	{
 		.dlc = COMP_CODEC_CONF("mt6358-sound"),
@@ -75,11 +87,12 @@ static int mt8186_rt5682s_init(struct snd_soc_pcm_runtime *rtd)
 		return ret;
 	}
 
-	ret = snd_soc_card_jack_new(rtd->card, "Headset Jack",
+	ret = snd_soc_card_jack_new_pins(rtd->card, "Headset Jack",
 				    SND_JACK_HEADSET | SND_JACK_BTN_0 |
 				    SND_JACK_BTN_1 | SND_JACK_BTN_2 |
 				    SND_JACK_BTN_3,
-				    jack);
+				    jack, mt8186_jack_pins,
+				    ARRAY_SIZE(mt8186_jack_pins));
 	if (ret) {
 		dev_err(rtd->dev, "Headset Jack creation failed: %d\n", ret);
 		return ret;
-- 
2.37.3


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH 6/6] ASoC: mediatek: mt8186-rt5682: Expose individual headset jack pins
  2022-09-22 23:59 ` [PATCH 6/6] ASoC: mediatek: mt8186-rt5682: Expose individual headset jack pins Nícolas F. R. A. Prado
@ 2022-09-23  8:58   ` AngeloGioacchino Del Regno
  0 siblings, 0 replies; 14+ messages in thread
From: AngeloGioacchino Del Regno @ 2022-09-23  8:58 UTC (permalink / raw)
  To: Nícolas F. R. A. Prado, Mark Brown
  Cc: kernel, Jaroslav Kysela, Jiaxin Yu, Liam Girdwood,
	Matthias Brugger, Takashi Iwai, alsa-devel, chunxu.li,
	linux-arm-kernel, linux-kernel, linux-mediatek

Il 23/09/22 01:59, Nícolas F. R. A. Prado ha scritto:
> The rt5682 codec is able to distinguish between two event types:
> headphone insertion/removal and headset microphone insertion/removal.
> However, currently, the mt8186-rt5682 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.
> 
> Signed-off-by: Nícolas F. R. A. Prado <nfraprado@collabora.com>

Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>



_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH 5/6] ASoC: mediatek: mt8186-rt5682: Add headset widgets with switches
  2022-09-22 23:59 ` [PATCH 5/6] ASoC: mediatek: mt8186-rt5682: Add headset widgets with switches Nícolas F. R. A. Prado
@ 2022-09-23  8:58   ` AngeloGioacchino Del Regno
  0 siblings, 0 replies; 14+ messages in thread
From: AngeloGioacchino Del Regno @ 2022-09-23  8:58 UTC (permalink / raw)
  To: Nícolas F. R. A. Prado, Mark Brown
  Cc: kernel, Jaroslav Kysela, Jiaxin Yu, Liam Girdwood,
	Matthias Brugger, Takashi Iwai, alsa-devel, chunxu.li,
	linux-arm-kernel, linux-kernel, linux-mediatek

Il 23/09/22 01:59, Nícolas F. R. A. Prado ha scritto:
> Add DAPM widgets for headphones and headset microphone, with matching
> switches, to allow toggling these paths based on the jack connection
> status.
> 
> Signed-off-by: Nícolas F. R. A. Prado <nfraprado@collabora.com>

Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>



_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH 3/6] ASoC: mediatek: mt8186-da7219: Add headset widgets with switches
  2022-09-22 23:59 ` [PATCH 3/6] ASoC: mediatek: mt8186-da7219: Add headset widgets with switches Nícolas F. R. A. Prado
@ 2022-09-23  8:58   ` AngeloGioacchino Del Regno
  0 siblings, 0 replies; 14+ messages in thread
From: AngeloGioacchino Del Regno @ 2022-09-23  8:58 UTC (permalink / raw)
  To: Nícolas F. R. A. Prado, Mark Brown
  Cc: kernel, Jaroslav Kysela, Jiaxin Yu, Liam Girdwood,
	Matthias Brugger, Takashi Iwai, alsa-devel, chunxu.li,
	linux-arm-kernel, linux-kernel, linux-mediatek

Il 23/09/22 01:59, Nícolas F. R. A. Prado ha scritto:
> Add DAPM widgets for headphones and headset microphone, with matching
> switches, to allow toggling these paths based on the jack connection
> status.
> 
> Note that differently from others (mt8192, mt8195 and mt8186-rt5682),
> the widget here is named "Headphones" (with an 's'), since "Headphone
> Switch" was already registered by da7219.
> 
> Signed-off-by: Nícolas F. R. A. Prado <nfraprado@collabora.com>

Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>



_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH 4/6] ASoC: mediatek: mt8186-da7219: Expose individual headset jack pins
  2022-09-22 23:59 ` [PATCH 4/6] ASoC: mediatek: mt8186-da7219: Expose individual headset jack pins Nícolas F. R. A. Prado
@ 2022-09-23  8:58   ` AngeloGioacchino Del Regno
  0 siblings, 0 replies; 14+ messages in thread
From: AngeloGioacchino Del Regno @ 2022-09-23  8:58 UTC (permalink / raw)
  To: Nícolas F. R. A. Prado, Mark Brown
  Cc: kernel, Jaroslav Kysela, Jiaxin Yu, Liam Girdwood,
	Matthias Brugger, Takashi Iwai, alsa-devel, chunxu.li,
	linux-arm-kernel, linux-kernel, linux-mediatek

Il 23/09/22 01:59, Nícolas F. R. A. Prado ha scritto:
> The da7219 codec is able to distinguish between two event types:
> headphone insertion/removal and headset microphone insertion/removal.
> However, currently, the mt8186-da7219 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.
> 
> Signed-off-by: Nícolas F. R. A. Prado <nfraprado@collabora.com>

Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>



_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH 1/6] ASoC: mediatek: mt8192-mt6359: Expose individual headset jack pins
  2022-09-22 23:59 ` [PATCH 1/6] ASoC: mediatek: mt8192-mt6359: Expose individual headset jack pins Nícolas F. R. A. Prado
@ 2022-09-23  8:58   ` AngeloGioacchino Del Regno
  0 siblings, 0 replies; 14+ messages in thread
From: AngeloGioacchino Del Regno @ 2022-09-23  8:58 UTC (permalink / raw)
  To: Nícolas F. R. A. Prado, Mark Brown
  Cc: kernel, Akihiko Odaki, Jaroslav Kysela, Jiaxin Yu, Liam Girdwood,
	Matthias Brugger, Miaoqian Lin, Takashi Iwai, Tzung-Bi Shih,
	alsa-devel, linux-arm-kernel, linux-kernel, linux-mediatek

Il 23/09/22 01:59, Nícolas F. R. A. Prado ha scritto:
> The rt5682 codec is able to distinguish between two event types:
> headphone insertion/removal and headset microphone insertion/removal.
> However, currently, the mt8192-mt6359 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.
> 
> Signed-off-by: Nícolas F. R. A. Prado <nfraprado@collabora.com>

Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>

[On MT8192 Asurada Spherion Chromebook]
Tested-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH 2/6] ASoC: mediatek: mt8195: Expose individual headset jack pins
  2022-09-22 23:59 ` [PATCH 2/6] ASoC: mediatek: mt8195: " Nícolas F. R. A. Prado
@ 2022-09-23  8:58   ` AngeloGioacchino Del Regno
  0 siblings, 0 replies; 14+ messages in thread
From: AngeloGioacchino Del Regno @ 2022-09-23  8:58 UTC (permalink / raw)
  To: Nícolas F. R. A. Prado, Mark Brown
  Cc: kernel, Jaroslav Kysela, Liam Girdwood, Matthias Brugger,
	Takashi Iwai, Trevor Wu, Tzung-Bi Shih, alsa-devel,
	linux-arm-kernel, linux-kernel, linux-mediatek

Il 23/09/22 01:59, Nícolas F. R. A. Prado ha scritto:
> The rt5682 codec is able to distinguish between two event types:
> headphone insertion/removal and headset microphone insertion/removal.
> However, currently, the mt8195 ASoC 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.
> 
> Signed-off-by: Nícolas F. R. A. Prado <nfraprado@collabora.com>
> 

Nit: for the title... ASoC: mediatek: mt8195-mt6359: ....

Apart from that,


Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>

[On MT8195 Cherry Tomato Chromebook]
Tested-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>



_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH 0/6] ASoC: mediatek: Allow separate handling of headphone and headset mic jack
  2022-09-22 23:59 [PATCH 0/6] ASoC: mediatek: Allow separate handling of headphone and headset mic jack Nícolas F. R. A. Prado
                   ` (5 preceding siblings ...)
  2022-09-22 23:59 ` [PATCH 6/6] ASoC: mediatek: mt8186-rt5682: Expose individual headset jack pins Nícolas F. R. A. Prado
@ 2022-09-23 17:07 ` Mark Brown
  6 siblings, 0 replies; 14+ messages in thread
From: Mark Brown @ 2022-09-23 17:07 UTC (permalink / raw)
  To: Nícolas F. R. A. Prado
  Cc: chunxu.li, Jiaxin Yu, alsa-devel, linux-kernel, linux-mediatek,
	Matthias Brugger, Miaoqian Lin, Trevor Wu, linux-arm-kernel,
	kernel, AngeloGioacchino Del Regno, Akihiko Odaki, Tzung-Bi Shih,
	Takashi Iwai, Jaroslav Kysela, Liam Girdwood

On Thu, 22 Sep 2022 19:59:45 -0400, Nícolas F. R. A. Prado wrote:
> This series allows the headphone and headset mic jack status to be
> handled separately by userspace on MT8192, MT8195 and MT8186.
> 
> Changes based on commit d0508b4f1604 ("ASoC: rk3399_gru_sound: Add DAPM
> pins, kcontrols for jack detection"). Found while searching for an
> alternative for JackSwitch [1].
> 
> [...]

Applied to

   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next

Thanks!

[1/6] ASoC: mediatek: mt8192-mt6359: Expose individual headset jack pins
      commit: 194ff8db03782d1dae41b7b42ea65da5748884c2
[2/6] ASoC: mediatek: mt8195: Expose individual headset jack pins
      commit: aa51e3c127a43cf4862db5f0081da281f1aa6429
[3/6] ASoC: mediatek: mt8186-da7219: Add headset widgets with switches
      commit: 13bee4a16ac5c5f0e3a5db868df991be57e74aa5
[4/6] ASoC: mediatek: mt8186-da7219: Expose individual headset jack pins
      commit: 8e986748680629a82398c65da0c5bda4c6a01b3d
[5/6] ASoC: mediatek: mt8186-rt5682: Add headset widgets with switches
      commit: d888e7afa03f06d8091ecdd43f87d5396dfbf907
[6/6] ASoC: mediatek: mt8186-rt5682: Expose individual headset jack pins
      commit: 42de42c22453064ffc9b72c259b2ab901dd766dc

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

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

end of thread, other threads:[~2022-09-23 17:08 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-22 23:59 [PATCH 0/6] ASoC: mediatek: Allow separate handling of headphone and headset mic jack Nícolas F. R. A. Prado
2022-09-22 23:59 ` [PATCH 1/6] ASoC: mediatek: mt8192-mt6359: Expose individual headset jack pins Nícolas F. R. A. Prado
2022-09-23  8:58   ` AngeloGioacchino Del Regno
2022-09-22 23:59 ` [PATCH 2/6] ASoC: mediatek: mt8195: " Nícolas F. R. A. Prado
2022-09-23  8:58   ` AngeloGioacchino Del Regno
2022-09-22 23:59 ` [PATCH 3/6] ASoC: mediatek: mt8186-da7219: Add headset widgets with switches Nícolas F. R. A. Prado
2022-09-23  8:58   ` AngeloGioacchino Del Regno
2022-09-22 23:59 ` [PATCH 4/6] ASoC: mediatek: mt8186-da7219: Expose individual headset jack pins Nícolas F. R. A. Prado
2022-09-23  8:58   ` AngeloGioacchino Del Regno
2022-09-22 23:59 ` [PATCH 5/6] ASoC: mediatek: mt8186-rt5682: Add headset widgets with switches Nícolas F. R. A. Prado
2022-09-23  8:58   ` AngeloGioacchino Del Regno
2022-09-22 23:59 ` [PATCH 6/6] ASoC: mediatek: mt8186-rt5682: Expose individual headset jack pins Nícolas F. R. A. Prado
2022-09-23  8:58   ` AngeloGioacchino Del Regno
2022-09-23 17:07 ` [PATCH 0/6] ASoC: mediatek: Allow separate handling of headphone and headset mic jack Mark Brown

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