From patchwork Wed Aug 2 17:57:31 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: 130061 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9f41:0:b0:3e4:2afc:c1 with SMTP id v1csp658367vqx; Wed, 2 Aug 2023 11:49:56 -0700 (PDT) X-Google-Smtp-Source: APBJJlGh5TBClXDWHwjrPqeT6YQCd6CbSQ9AaYZq7ewAr8a9CGz/OgkL2pHo+ZdfI90h0qZzmf2Q X-Received: by 2002:a17:907:77cd:b0:99b:ef1e:3836 with SMTP id kz13-20020a17090777cd00b0099bef1e3836mr6524887ejc.9.1691002196565; Wed, 02 Aug 2023 11:49:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691002196; cv=none; d=google.com; s=arc-20160816; b=BnZVAvemn4mLlTt5Rkn6wJSuSAZfRuFKY++uKT1ULQCkLBXNCfz5OSyOek6dHwJYlX 1U3lOpiLRVHUeQ/zdXfbkX51iFGcg3UmBUYa2+g+dIl0+XUyWbDsB/ssZeDH/SdPAQLt rqmpWd3aHIG9Nhy/o1SWCCqJ8lKuYO06IL2htpGmWsKa/aQ5OyjFoMzvf0tMRZHZM0Rj Uv3IwpCJALlaejILZmW+mskJOIhw90eP+w5+xIpeGAGDqo0OVUHnFxjjoQRykHlNvHIi aPDLW/djJxLFiE9Zq2TLZ5iYAXwy7xuykIJzswkqgNYL7buG3LcMsfzLxWXKpCukQkp4 Srmg== 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=2zh/WX6wdJak4IhHc3jkL9iRoK+aXWh9O/IfQG1cm3A=; fh=GUNhzEJfka7aU6InG/mqeUgtNKAejFmk0vy+CY7S+VM=; b=fQB36xzpL5IG88FxtdXDXd1hnIWss0Q5KJasv93DapgkY3vFRS14iq5lA2cGoGGVNa EIcDUfroETZbgUJWC3W8VwXe0kLRVSrsVgwcHzDeyaA0/pzAslv+WMq4uk4UlaHonW8X HIGoQjWyam+Rsu3KATFSY+82/ILozE0TIYTt6zh2qQ0rjWErpE4dycEsnOQwtXaJiL8I qHRkhZ+aatMqHTTSOsoMiRKNZlDB5sMI1wq+cIPrb9skRTeIFRinFOYGmwtmjBoMXuUp 4ysCOa1yNAyQOcQ0RgHx6pI83xf8Kh8GUevnb25AhTPF2E8zwd3THGU9Znz3qxffQFNT 9HPg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=FTZxpdE5; 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 cd21-20020a170906b35500b009945340230esi10860219ejb.174.2023.08.02.11.49.32; Wed, 02 Aug 2023 11:49:56 -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=FTZxpdE5; 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 S233986AbjHBSAJ (ORCPT + 99 others); Wed, 2 Aug 2023 14:00:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47022 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234195AbjHBR7h (ORCPT ); Wed, 2 Aug 2023 13:59:37 -0400 Received: from mail-wm1-x334.google.com (mail-wm1-x334.google.com [IPv6:2a00:1450:4864:20::334]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3E00A30E3 for ; Wed, 2 Aug 2023 10:58:38 -0700 (PDT) Received: by mail-wm1-x334.google.com with SMTP id 5b1f17b1804b1-3fbc59de0e2so1248345e9.3 for ; Wed, 02 Aug 2023 10:58:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1690999116; x=1691603916; 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=2zh/WX6wdJak4IhHc3jkL9iRoK+aXWh9O/IfQG1cm3A=; b=FTZxpdE5nx4Y6zQSk5bttaigS8VbRibjeKA3ZCREfPBwHaEibBv3iLD8k9qccZtT4e aZD09HP28KJsaWIUcrXrs3CEfvpd914hlqO0hNaxO+EcVsCXWA3vsRV4ehJWIiH1Wa0m 4wn57sn5rhYJtHRamKiJfDg/rbcpFgEruL5xAQ7YaHmSl9EWcj3T/Pi3Ruxn6R3agW0U m+zQSRysHJ6Kd21dByfuCnyzcfIkxTRth8K/1GH0i/4tP1L1mi7NreUMNxUpIAAYSQbp hIF7YEYJeeGSJu2iNQs7+/vSCrUJNyZEcw3URHIRTTdBEPpYg3W/+WNWflv31jJ54L80 39AA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690999116; x=1691603916; 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=2zh/WX6wdJak4IhHc3jkL9iRoK+aXWh9O/IfQG1cm3A=; b=VqG/Bq1HIolk4Emvm1IIJxllEIFlnkK6mwWEqEniEyaO8+Lor3nxg9cREEYHuzztD1 /xDo6zS5GwJCaHtbx2h4UyBKS7u5MxWzM9lkrRys1joTGEKUdbatfTKE7ILTSRmKItUB KVGauggwurP7gwD5iSHGGbUff9S85J5ltZUzVCspbbFgMkopDO2xrjm9fyiyxtaNryE/ KTnNpuX/uH8Dq0MAif/iioyqjdn6Fpk13hWjwBU00jLHCmxQJS8/TcBIqN2JqL1mtqAD pldkf8vELgfnhwbVQ//5QPi/JyDWVKUw6/7LYEY17bhXahz1lBdbKTd4b+iVsDVg4Pcs 3rCA== X-Gm-Message-State: ABy/qLbASzBWcZx+akVIcM40HodXz1g3ZAfFhJiBLP8uchVT3Ej+1N1F 2WDgwvDQl1lXUFOSc7H9/jg= X-Received: by 2002:a05:600c:20cb:b0:3f8:2777:15e with SMTP id y11-20020a05600c20cb00b003f82777015emr5232003wmm.31.1690999115687; Wed, 02 Aug 2023 10:58:35 -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.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Aug 2023 10:58:35 -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 21/27] ASoC: qcom: sc7280: Map missing jack kcontrols Date: Wed, 2 Aug 2023 20:57:31 +0300 Message-Id: <20230802175737.263412-22-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: 1773144319667957549 X-GMAIL-MSGID: 1773144319667957549 This driver does not properly map jack pins to kcontrols that PulseAudio and PipeWire need to handle jack detection events. The RT5682 and RT5682s codecs used here can detect Headphone and Headset Mic connections. Expose each to userspace as a kcontrol. Signed-off-by: Alper Nebi Yasak --- Should the SND_JACK_LINEOUT be removed from the jack_new_pins calls? Would SND_JACK_MECHANICAL be useful as a kcontrol as well? sound/soc/qcom/sc7280.c | 34 +++++++++++++++++++++++++++------- 1 file changed, 27 insertions(+), 7 deletions(-) diff --git a/sound/soc/qcom/sc7280.c b/sound/soc/qcom/sc7280.c index 787dd49e03f6..43010e4e2242 100644 --- a/sound/soc/qcom/sc7280.c +++ b/sound/soc/qcom/sc7280.c @@ -43,6 +43,17 @@ static void sc7280_jack_free(struct snd_jack *jack) snd_soc_component_set_jack(component, NULL, NULL); } +static struct snd_soc_jack_pin sc7280_jack_pins[] = { + { + .pin = "Headphone Jack", + .mask = SND_JACK_HEADPHONE, + }, + { + .pin = "Headset Mic", + .mask = SND_JACK_MICROPHONE, + }, +}; + static int sc7280_headset_init(struct snd_soc_pcm_runtime *rtd) { struct snd_soc_card *card = rtd->card; @@ -54,13 +65,15 @@ static int sc7280_headset_init(struct snd_soc_pcm_runtime *rtd) int rval, i; if (!pdata->jack_setup) { - rval = snd_soc_card_jack_new(card, "Headset Jack", - SND_JACK_HEADSET | SND_JACK_LINEOUT | - SND_JACK_MECHANICAL | - SND_JACK_BTN_0 | SND_JACK_BTN_1 | - SND_JACK_BTN_2 | SND_JACK_BTN_3 | - SND_JACK_BTN_4 | SND_JACK_BTN_5, - &pdata->hs_jack); + rval = snd_soc_card_jack_new_pins(card, "Headset Jack", + SND_JACK_HEADSET | SND_JACK_LINEOUT | + SND_JACK_MECHANICAL | + SND_JACK_BTN_0 | SND_JACK_BTN_1 | + SND_JACK_BTN_2 | SND_JACK_BTN_3 | + SND_JACK_BTN_4 | SND_JACK_BTN_5, + &pdata->hs_jack, + sc7280_jack_pins, + ARRAY_SIZE(sc7280_jack_pins)); if (rval < 0) { dev_err(card->dev, "Unable to add Headset Jack\n"); @@ -361,6 +374,11 @@ static const struct snd_soc_dapm_widget sc7280_snd_widgets[] = { SND_SOC_DAPM_MIC("Headset Mic", NULL), }; +static const struct snd_kcontrol_new sc7280_snd_controls[] = { + SOC_DAPM_PIN_SWITCH("Headphone Jack"), + SOC_DAPM_PIN_SWITCH("Headset Mic"), +}; + static int sc7280_snd_be_hw_params_fixup(struct snd_soc_pcm_runtime *rtd, struct snd_pcm_hw_params *params) { @@ -396,6 +414,8 @@ static int sc7280_snd_platform_probe(struct platform_device *pdev) card->dapm_widgets = sc7280_snd_widgets; card->num_dapm_widgets = ARRAY_SIZE(sc7280_snd_widgets); + card->controls = sc7280_snd_controls; + card->num_controls = ARRAY_SIZE(sc7280_snd_controls); ret = qcom_snd_parse_of(card); if (ret)