2023-03-25 14:25:20

by Dylan Van Assche

[permalink] [raw]
Subject: [PATCH v3 0/1] 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(+)

--
2.39.2


2023-03-25 14:27:03

by Dylan Van Assche

[permalink] [raw]
Subject: [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.

Signed-off-by: Dylan Van Assche <[email protected]>
Tested-by: Joel Selvaraj <[email protected]>
Tested-by: Caleb Connolly <[email protected]>
---
sound/soc/codecs/wcd-mbhc-v2.c | 4 ++++
1 file changed, 4 insertions(+)

diff --git a/sound/soc/codecs/wcd-mbhc-v2.c b/sound/soc/codecs/wcd-mbhc-v2.c
index 1911750f7445..1b75f49b2858 100644
--- a/sound/soc/codecs/wcd-mbhc-v2.c
+++ b/sound/soc/codecs/wcd-mbhc-v2.c
@@ -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,
--
2.39.2

2023-03-25 18:17:48

by Mark Brown

[permalink] [raw]
Subject: Re: [PATCH v3 0/1] Expose ALSA control for jack

On Sat, Mar 25, 2023 at 03:21:41PM +0100, Dylan Van Assche wrote:
> 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.


Attachments:
(No filename) (844.00 B)
signature.asc (499.00 B)
Download all attachments

2023-03-25 18:35:04

by Mark Brown

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

On Sat, Mar 25, 2023 at 03:21:42PM +0100, Dylan Van Assche wrote:

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


Attachments:
(No filename) (631.00 B)
signature.asc (499.00 B)
Download all attachments