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: 75595 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp1684836vqo; Mon, 27 Mar 2023 10:46:54 -0700 (PDT) X-Google-Smtp-Source: AKy350YthT37W0E2Hf+OHKAJ6zN+A3J2Zbzw2EoIZy/HikqNjjpLajbhB+b3dMsPG69rudK+Fvmb X-Received: by 2002:a17:90b:4c4a:b0:23b:bf03:397e with SMTP id np10-20020a17090b4c4a00b0023bbf03397emr14242994pjb.24.1679939213877; Mon, 27 Mar 2023 10:46:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1679939213; cv=none; d=google.com; s=arc-20160816; b=hKOy/0TTCf/QHBQ/gYpr29X5shw9rFyLAnT4Ns1ca65W/Wb1Z/eGrrlMKoZartVXqd 9Hu/U+rOAPbjrzmSKw6HldW5Knoka5bwAiAAPgXhZbqQcUu/lstnSkzuJ1Eo+CyIngNT dyy3S2JwYtPwCwmKz/h5jdSMi603Hv0gz3p1UCtulRCr5hoGFLg65zYMxXlobBiQTOi2 OM4r1sVJZdUvBaFyrE409V2jKV1xaCmCpiG15BOOIRLb+4IrY8kAfyT13cJi+y/t7o4K ZKZ6rfqABIRnNg6SA2CGssD8DgDvzP84QZxnTKHeuo9jpqwudMGgSd5e2fn7xJjqW5UN 50Mw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=erhiX1kWslYrQnsmeLq0Eijl2/NyUjXUqiUh7SiAOL4=; b=CNjJiN/H/Qg42WpdgdMjiER92KTz++JcxSmDNMDpflV4Km9Kt7zdC8SDlbsD6VAs3X fkKNQigGQIfHYVjLL+8dtnYnlOEuP6lloe+KsnxedqC5EnP870WxXCnLw0MbXuqRLm/F pLekzXRnVKw+gN1RY5OisMnzDIblAl3/UjlKIQANiDhRnypMPTzdUa67zONraA45nR23 OSoO30mSBpKkJtR6UVHTbtGXA9+czFSbrTnl5X7W9ujphZd+lkjExljDmEvsvftvkAR6 lJetpuh8kcF6B7oeSjjD1wH9HcMOosNdHtxRwrVgVj4+crh4bz3l/9vXL2bZa70LWng1 YMIg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@dylanvanassche.be header.s=MBO0001 header.b=Z+NCmJiR; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=dylanvanassche.be Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t20-20020a170902dcd400b00188fead2329si22277870pll.135.2023.03.27.10.46.41; Mon, 27 Mar 2023 10:46:53 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@dylanvanassche.be header.s=MBO0001 header.b=Z+NCmJiR; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=dylanvanassche.be Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232544AbjC0Rg6 (ORCPT + 99 others); Mon, 27 Mar 2023 13:36:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39152 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232439AbjC0Rg4 (ORCPT ); Mon, 27 Mar 2023 13:36:56 -0400 Received: from mout-p-202.mailbox.org (mout-p-202.mailbox.org [80.241.56.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 885701FD0; Mon, 27 Mar 2023 10:36:50 -0700 (PDT) Received: from smtp1.mailbox.org (smtp1.mailbox.org [IPv6:2001:67c:2050:b231:465::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-p-202.mailbox.org (Postfix) with ESMTPS id 4Plg3d2hKyz9sQY; Mon, 27 Mar 2023 19:36:45 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dylanvanassche.be; s=MBO0001; t=1679938606; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=erhiX1kWslYrQnsmeLq0Eijl2/NyUjXUqiUh7SiAOL4=; b=Z+NCmJiRBmaI4XZu26q+haVWgnaLtjwJk5782Ya5brwKjCkoB42NhqmmjRNoWgqglT7GEa C64Y5mBG9k8MZtgJXz6TjyuawegBFtwFbCGqCBHbHN4HWQXtwI98Ve7sXhymdqkjWV/B42 2CklB4ntdahmFFaQvzroxdbnEsaXCyu1GxbHylA2p5ModoeqNaTEdsPsgL1mUDbOUJqtGx KtxriXyIPhxp9BUlMqhS1s2w4W/l7rfAdf0JiVPzycLmOqgvyQHeYqdTxuS+wUkhB67h3S 9xGomaoDamqgfj6I8zTY/xDW11XitrRU2IwZae/KKyuX3Ik6rfm5LK+e93ZiJQ== From: Dylan Van Assche To: Jaroslav Kysela , Takashi Iwai 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 Subject: [PATCH v4] sound: soc: qcom: sdm845: expose ALSA control for jack Date: Mon, 27 Mar 2023 19:36:27 +0200 Message-Id: <20230327173627.361533-1-me@dylanvanassche.be> MIME-Version: 1.0 X-Rspamd-Queue-Id: 4Plg3d2hKyz9sQY X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1761543941122968612?= X-GMAIL-MSGID: =?utf-8?q?1761543941122968612?= 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");