From patchwork Wed Aug 2 17:57:32 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alper Nebi Yasak X-Patchwork-Id: 130102 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9f41:0:b0:3e4:2afc:c1 with SMTP id v1csp682307vqx; Wed, 2 Aug 2023 12:35:20 -0700 (PDT) X-Google-Smtp-Source: APBJJlGjGXxWrJfDdT0EhR/UHyQD29i4QUdgaksHjgAn6K0ef96aQRGw/TjLT8R2wIDtRFrr/psT X-Received: by 2002:a2e:80c3:0:b0:2b7:2db:8ea4 with SMTP id r3-20020a2e80c3000000b002b702db8ea4mr6230809ljg.30.1691004920398; Wed, 02 Aug 2023 12:35:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691004920; cv=none; d=google.com; s=arc-20160816; b=WPqgi8ksTEYJ8QJzt/eCjGLkgCPVs/ynrh8tvWOS62bRz+kGOQuKQYSRTFFlFtLumA 7pLERrCu7kOFD8uW4fe1z4/LgSpSQfSXZNdTRaDXYbvmEzjl7fOv0gSLABZWKNVrJAdo UEPp2xMx1E26f8I4kM6/wkOjRD1QNmBzyQKdm52xkqzRraJ4MKMFtsDXrxQFepVuOMB3 iUcGDR2sN3B5LpUOxfnXx71Yk/apHKuEzuoxtPPua9grMLmVtbR8Nec5bqZww7JgaOcP +bc7JZyHBJJTy/lv686RJ5Lw+T4pGvVAxrWe9POrgn6atfrsK86LueZXCQ2qNUXKzPRZ ZzNw== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=ivMSWY5W5vVdPZxQIPJMmrp6wGH4fY48CYl1yy0Ej0E=; fh=GUNhzEJfka7aU6InG/mqeUgtNKAejFmk0vy+CY7S+VM=; b=myQUBKA6wKis9krtHBmBfm5BqOsYgI70gSdTdxfOrEZCA33BLi+RlCLOavYPIg3WLp 8JKu7V5hELpznXesmywEkpt2Oq29Qt4ZpOQMQ9xY3QojJV8StoMmW8m+vFka6VeV4w4C 8SPRCdVRgrEISEeLeZAEXJEiZD4LCxtqtl/gJ2AI1klorj6kO/Kcb161/YYh8dSSQYGi hxvt1WMyvyOFrLSAhzQAc0qXBs3oqydVt7h4wYZC3Y6TRs1VbjmU5VVREj/xKitAK3WF 5tTgdp9H2VIskHgVeHDh+lDBXn6+yvKlpoDqUzDmclFxe2kzMUrjKyZO3FNvpWn3OzEY GLpQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=MqN6xWER; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f5-20020a1709064dc500b009889cad765dsi12318206ejw.352.2023.08.02.12.34.56; Wed, 02 Aug 2023 12:35:20 -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=@gmail.com header.s=20221208 header.b=MqN6xWER; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234278AbjHBSAB (ORCPT + 99 others); Wed, 2 Aug 2023 14:00:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46752 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234046AbjHBR7f (ORCPT ); Wed, 2 Aug 2023 13:59:35 -0400 Received: from mail-wm1-x32e.google.com (mail-wm1-x32e.google.com [IPv6:2a00:1450:4864:20::32e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3990F35B5 for ; Wed, 2 Aug 2023 10:58:39 -0700 (PDT) Received: by mail-wm1-x32e.google.com with SMTP id 5b1f17b1804b1-3fc0aecf15bso1390055e9.1 for ; Wed, 02 Aug 2023 10:58:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1690999118; x=1691603918; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=ivMSWY5W5vVdPZxQIPJMmrp6wGH4fY48CYl1yy0Ej0E=; b=MqN6xWERzMdTN+8tcVQSYKf9fLJTD2JZeiFLCObyl03B60/xzXmwB02zYmsL/6x5bh OypDvc0pipYf79vcMZBq/krvgrlOWmGzv8CDKGkHLLK7TgJU4MVfnrvrDh2thBvBT1dd QkoovvMpj5cgJVQfpsnAXhS6tMxnLU+wwEHTjMLCX3OtsGSbWfFbxjftEWlabVbs5EUY aXBMEU+9yTyyFnJ/4at2Acvmhpbn5B/B0LUutW3a7+HLu8sBqpNyPmx1mb4Zg4z+wi6+ 1LcEYnMoL85zbG7A/QuYxq6WKO5Hj0q4Bbg+zKZFayu/C06IqhWqdqwCKyAN/n6clMZC myAg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690999118; x=1691603918; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ivMSWY5W5vVdPZxQIPJMmrp6wGH4fY48CYl1yy0Ej0E=; b=R1/KtXHANJqU9zHoF9HdwPKYCOKMfrNQ6xVaFPDrcyzlB9pwPdSVNB6isBmxGUQAdI uiuWAz+osQmLilTuonAjEjCRVokn2Ur7wP4MNQpmee+TSXo82AX/gSEKIJP8Hxvu8BvU xOZOOM0uRp+GZvZ0qStwtGG2GPVlnREFBhPFyR9sfZDZd0tW2MSl2q/3lqi9KdEehXUn X2CwmSGzkTeS5t2ixvyMmu/FkfFgT/nKi4nY+9Q2MDHsn4ZrHSsRz7uaFKGvj5BwjYkd S6GgjuKk9XVu6BObFk15Ui2befEnCr/aDzqC3Yhux9zJXcm4bZRP5p+0f3jJNSZy79Dz ct6w== X-Gm-Message-State: ABy/qLZMYKptqGT3ILTMdoyT45cshfy8zhHr1OltAHfInZodqOub6fHZ 20DAeLEq26IHQFQUsSeEeeE= X-Received: by 2002:a7b:cc12:0:b0:3fb:dd9c:72d2 with SMTP id f18-20020a7bcc12000000b003fbdd9c72d2mr5153102wmh.31.1690999117652; Wed, 02 Aug 2023 10:58:37 -0700 (PDT) Received: from ALPER-PC.. ([178.233.24.1]) by smtp.gmail.com with ESMTPSA id l23-20020a7bc457000000b003fe20db88ebsm2192439wmi.31.2023.08.02.10.58.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Aug 2023 10:58:37 -0700 (PDT) From: Alper Nebi Yasak To: alsa-devel@alsa-project.org Cc: Cezary Rojewski , Alper Nebi Yasak , Mark Brown , Liam Girdwood , Takashi Iwai , AngeloGioacchino Del Regno , Jaroslav Kysela , linux-kernel@vger.kernel.org, Akihiko Odaki , Pierre-Louis Bossart , Matthias Brugger , =?utf-8?q?N=C3=ADcolas_F_=2E_R_?= =?utf-8?q?=2E_A_=2E_Prado?= Subject: [PATCH 22/27] ASoC: qcom: sdm845: Map missing jack kcontrols Date: Wed, 2 Aug 2023 20:57:32 +0300 Message-Id: <20230802175737.263412-23-alpernebiyasak@gmail.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230802175737.263412-1-alpernebiyasak@gmail.com> References: <20230802175737.263412-1-alpernebiyasak@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham 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: INBOX X-GMAIL-THRID: 1773147175576749280 X-GMAIL-MSGID: 1773147175576749280 This driver does not properly map jack pins to kcontrols that PulseAudio and PipeWire need to handle jack detection events. The RT5663 codec used here can detect Headphone and Headset Mic connections. Expose each to userspace as a kcontrol. Signed-off-by: Alper Nebi Yasak --- sound/soc/qcom/sdm845.c | 32 ++++++++++++++++++++++++++------ 1 file changed, 26 insertions(+), 6 deletions(-) diff --git a/sound/soc/qcom/sdm845.c b/sound/soc/qcom/sdm845.c index 02612af714a8..29d23fe5dfa2 100644 --- a/sound/soc/qcom/sdm845.c +++ b/sound/soc/qcom/sdm845.c @@ -42,6 +42,17 @@ struct sdm845_snd_data { struct sdw_stream_runtime *sruntime[AFE_PORT_MAX]; }; +static struct snd_soc_jack_pin sdm845_jack_pins[] = { + { + .pin = "Headphone Jack", + .mask = SND_JACK_HEADPHONE, + }, + { + .pin = "Headset Mic", + .mask = SND_JACK_MICROPHONE, + }, +}; + static unsigned int tdm_slot_offset[8] = {0, 4, 8, 12, 16, 20, 24, 28}; static int sdm845_slim_snd_hw_params(struct snd_pcm_substream *substream, @@ -242,12 +253,14 @@ static int sdm845_dai_init(struct snd_soc_pcm_runtime *rtd) if (!pdata->jack_setup) { - rval = snd_soc_card_jack_new(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); + 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, + sdm845_jack_pins, + ARRAY_SIZE(sdm845_jack_pins)); if (rval < 0) { dev_err(card->dev, "Unable to add Headphone Jack\n"); @@ -539,6 +552,11 @@ static const struct snd_soc_dapm_widget sdm845_snd_widgets[] = { SND_SOC_DAPM_MIC("Int Mic", NULL), }; +static const struct snd_kcontrol_new sdm845_snd_controls[] = { + SOC_DAPM_PIN_SWITCH("Headphone Jack"), + SOC_DAPM_PIN_SWITCH("Headset Mic"), +}; + static void sdm845_add_ops(struct snd_soc_card *card) { struct snd_soc_dai_link *link; @@ -572,6 +590,8 @@ static int sdm845_snd_platform_probe(struct platform_device *pdev) card->driver_name = DRIVER_NAME; card->dapm_widgets = sdm845_snd_widgets; card->num_dapm_widgets = ARRAY_SIZE(sdm845_snd_widgets); + card->controls = sdm845_snd_controls; + card->num_controls = ARRAY_SIZE(sdm845_snd_controls); card->dev = dev; card->owner = THIS_MODULE; dev_set_drvdata(dev, card);