Skip to contentSkip to conversation

sound: soc: codecs: wcd-mbhc-v2: expose ALSA control for jack

PATCH Superseded Dylan Van Assche 3 participants 3 messages Oct 7, 2022 – Oct 9, 2022

Subsystems (4)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 sound: soc: codecs: wcd-mbhc-v2: expose ALSA control for jack

Jack detection is currently fully functional via the input interface together with multimedia buttons, but is not exposed as an ALSA control. Therefore, ALSA clients such as PulseAudio do not pick up the jack detection events as they only support one of the possible interface (ALSA control or input interface, but not both). Expose the jack events as an ALSA control and input interface to provide ALSA clients both interfaces.

---
 sound/soc/codecs/wcd-mbhc-v2.c | 4 ++++
 1 file changed, 4 insertions(+)
sound/soc/codecs/wcd-mbhc-v2.c +4 -0
index 1911750f7445..1b75f49b2858 100644
@@ -725,6 +725,10 @@ static int wcd_mbhc_initialise(struct wcd_mbhc *mbhc)
 
 	mutex_lock(&mbhc->lock);
 
+	ret = snd_jack_add_new_kctl(mbhc->jack->jack, "Headset Jack", WCD_MBHC_JACK_MASK);
+	if (ret)
+		dev_warn(component->dev, "failed creating Headset Jack kctl with err: %d\n", ret);
+
 	/* enable HS detection */
 	if (mbhc->mbhc_cb->hph_pull_up_control_v2)
 		mbhc->mbhc_cb->hph_pull_up_control_v2(component,
Signature · 1 line
2.37.3
Tested-by on v2 1/1
#1 lore raw

Can confirm that this is required for Pulseaudio to pick up the headphones properly. I tested this in my Xiaomi Poco F1 running postmarketOS (Phosh Mobile Desktop Environment). You can check the following pulseaudio issue for some more info.

Quoted 28 lines · Dylan Van Assche

Jack detection is currently fully functional via the input interface together with multimedia buttons, but is not exposed as an ALSA control. Therefore, ALSA clients such as PulseAudio do not pick up the jack detection events as they only support one of the possible interface (ALSA control or input interface, but not both). Expose the jack events as an ALSA control and input interface to provide ALSA clients both interfaces.

---
 sound/soc/codecs/wcd-mbhc-v2.c | 4 ++++
 1 file changed, 4 insertions(+)
sound/soc/codecs/wcd-mbhc-v2.c +4 -0
index 1911750f7445..1b75f49b2858 100644
@@ -725,6 +725,10 @@ static int wcd_mbhc_initialise(struct wcd_mbhc *mbhc)
 
 	mutex_lock(&mbhc->lock);
 
+	ret = snd_jack_add_new_kctl(mbhc->jack->jack, "Headset Jack", WCD_MBHC_JACK_MASK);
+	if (ret)
+		dev_warn(component->dev, "failed creating Headset Jack kctl with err: %d\n", ret);
+
 	/* enable HS detection */
 	if (mbhc->mbhc_cb->hph_pull_up_control_v2)
 		mbhc->mbhc_cb->hph_pull_up_control_v2(component,
Tested-by on v2 1/1
#2 lore raw
In reply to Dylan Van Assche

Tested on a OnePlus 6 running postmarketOS!

Quoted 9 lines · Dylan Van Assche

Jack detection is currently fully functional via the input interface together with multimedia buttons, but is not exposed as an ALSA control. Therefore, ALSA clients such as PulseAudio do not pick up the jack detection events as they only support one of the possible interface (ALSA control or input interface, but not both). Expose the jack events as an ALSA control and input interface to provide ALSA clients both interfaces.

Quoted 20 lines
---
  sound/soc/codecs/wcd-mbhc-v2.c | 4 ++++
  1 file changed, 4 insertions(+)
sound/soc/codecs/wcd-mbhc-v2.c +4 -1
index 1911750f7445..1b75f49b2858 100644
@@ -725,6 +725,10 @@ static int wcd_mbhc_initialise(struct wcd_mbhc *mbhc)
 
  	mutex_lock(&mbhc->lock);
 
+	ret = snd_jack_add_new_kctl(mbhc->jack->jack, "Headset Jack", WCD_MBHC_JACK_MASK);
+	if (ret)
+		dev_warn(component->dev, "failed creating Headset Jack kctl with err: %d\n", ret);
+
  	/* enable HS detection */
  	if (mbhc->mbhc_cb->hph_pull_up_control_v2)
  		mbhc->mbhc_cb->hph_pull_up_control_v2(component,
--
Quoted 2 lines

2.37.3

--
Kind Regards,
Caleb