Skip to contentSkip to conversation

Expose ALSA control for jack

PATCH In review Dylan Van Assche 3 participants 5 messages Mar 25, 2023

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

v3 cover Expose ALSA control for jack

Qualcomm SDM845 features a headphone jack via a Qualcomm WCD9340 codec which has jack detection through the wcd-mbhc-v2 driver.

ALSA features 2 ways to expose jack detection from the kernel to userspace either as an input device or through an ALSA control. The wcd-mbhc-v2 driver only supports the first option which is insufficient for userspace programs e.g. PulseAudio [1]. 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.

[1] https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/issues/1377

Changes in v3:

- Improved cover letter
- Added Tested-by from
https://lore.kernel.org/alsa-devel/[email protected]/
- Properly added maintainers for sending this patch

Kind regards,
Dylan Van Assche

Dylan Van Assche (1):
sound: soc: codecs: wcd-mbhc-v2: expose ALSA control for jack

 sound/soc/codecs/wcd-mbhc-v2.c | 4 ++++
 1 file changed, 4 insertions(+)
Signature · 1 line
2.39.2
#1 lore raw

PATCH v3 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.39.2
maintainer
#2 lore raw

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

sound/soc/codecs/wcd-mbhc-v2.c static int wcd_mbhc_initialise(struct wcd_mbhc *mbhc) · line 731

Quoted 7 lines · Dylan Van Assche
sound/soc/codecs/wcd-mbhc-v2.c +4 -0
 	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);
+

No, drivers should not be open coding userspace reporting - there is no reason for this device to be special, or for this device to duplicate what machine drivers and the core are doing. Any configuration should be done by the machine driver, the ASoC core jack handling already creates userspace controls when asked.

#3 lore raw

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

In reply to 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,
Signature · 1 line
2.39.2
maintainer
#4 lore raw
In reply to Dylan Van Assche
Quoted 2 lines · Dylan Van Assche

Qualcomm SDM845 features a headphone jack via a Qualcomm WCD9340 codec which has jack detection through the wcd-mbhc-v2 driver.

Please submit patches using subject lines reflecting the style for the subsystem, this makes it easier for people to identify relevant patches. Look at what existing commits in the area you're changing are doing and make sure your subject lines visually resemble what they're doing. There's no need to resubmit to fix this alone.

Please don't send cover letters for single patches, if there is anything that needs saying put it in the changelog of the patch or after the --- if it's administrative stuff. This reduces mail volume and ensures that any important information is recorded in the changelog rather than being lost.