From patchwork Mon Mar 27 17:36:27 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dylan Van Assche X-Patchwork-Id: 13189753 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 92079C6FD1D for ; Mon, 27 Mar 2023 17:38:22 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 745D83E8; Mon, 27 Mar 2023 19:37:29 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 745D83E8 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1679938699; bh=FtfzL+RBfnaAUPJa4KMvw/tXivxLL1QjoheWBdL9VHY=; h=To:Subject:Date:List-Id:List-Archive:List-Help:List-Owner: List-Post:List-Subscribe:List-Unsubscribe:From:Reply-To:Cc:From; b=WDDF3sRKvlC/KC57LwGMz53P49PId72rMsxNjqKsGlR9PvHzmfHLq+pAVqzcTH5FX SW/+nwhsIwu6WBZsFpKyg2kKwn9nyvjAleABlIko+AOEedHDcQH+n8MUNag9K6OD8U 2QmhjeA7iO0IRH6CuljBIevgoceqOmkWcvu/iWRc= Received: from mailman-core.alsa-project.org (mailman-core.alsa-project.org [10.254.200.10]) by alsa1.perex.cz (Postfix) with ESMTP id 05B02F800C9; Mon, 27 Mar 2023 19:37:06 +0200 (CEST) To: Jaroslav Kysela , Takashi Iwai Subject: [PATCH v4] sound: soc: qcom: sdm845: expose ALSA control for jack Date: Mon, 27 Mar 2023 19:36:27 +0200 X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-alsa-devel.alsa-project.org-0; header-match-alsa-devel.alsa-project.org-1; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.8 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-ID: <167993862458.26.3671334925039974134@mailman-core.alsa-project.org> X-Patchwork-Original-From: Dylan Van Assche via Alsa-devel From: Dylan Van Assche Reply-To: Dylan Van Assche Cc: Srinivas Kandagatla , Banajit Goswami , Liam Girdwood , Mark Brown , alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org, ~postmarketos/upstreaming@lists.sr.ht, phone-devel@vger.kernel.org, Dylan Van Assche Content-Disposition: inline Qualcomm SDM845 features a headphone jack via a Qualcomm WCD9340 codec which has jack detection through the wcd-mbhc-v2 driver. 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 [1] 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). Initialize the audio jack with snd_soc_card_jack_new_pins instead of snd_soc_card_jack_new to make the jack also available as an ALSA control. [1] https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/issues/1377 Signed-off-by: Dylan Van Assche --- Changes in v4: - Dropped cover letter because of a single patch. - Reworked as a patch to the SDM845 Machine driver as suggested by Mark Brown. Changes in v3: - Improved cover letter - Added Tested-by from https://lore.kernel.org/alsa-devel/20221007155716.10594-1-me@dylanvanassche.be/ - Properly added maintainers for sending this patch Kind regards, Dylan Van Assche sound/soc/qcom/sdm845.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/sound/soc/qcom/sdm845.c b/sound/soc/qcom/sdm845.c index 02612af714a8..95888c5079a0 100644 --- a/sound/soc/qcom/sdm845.c +++ b/sound/soc/qcom/sdm845.c @@ -44,6 +44,14 @@ struct sdm845_snd_data { static unsigned int tdm_slot_offset[8] = {0, 4, 8, 12, 16, 20, 24, 28}; +static struct snd_soc_jack_pin sdm845_jack_pins[] = { + { + .pin = "Headphone Jack", + .mask = (SND_JACK_HEADPHONE | SND_JACK_MICROPHONE | SND_JACK_HEADSET | + SND_JACK_MECHANICAL) + }, +}; + static int sdm845_slim_snd_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params) { @@ -242,12 +250,13 @@ static int sdm845_dai_init(struct snd_soc_pcm_runtime *rtd) if (!pdata->jack_setup) { - rval = snd_soc_card_jack_new(card, "Headset Jack", + rval = snd_soc_card_jack_new_pins(card, "Headset Jack", SND_JACK_HEADSET | SND_JACK_HEADPHONE | SND_JACK_BTN_0 | SND_JACK_BTN_1 | SND_JACK_BTN_2 | SND_JACK_BTN_3, - &pdata->jack); + &pdata->jack, sdm845_jack_pins, + ARRAY_SIZE(sdm845_jack_pins)); if (rval < 0) { dev_err(card->dev, "Unable to add Headphone Jack\n");