Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp260856rwb; Thu, 22 Sep 2022 17:49:35 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7TORmHStlGTKaHZXLvVzXTfLSc79UDxK4h/YDH03jzjGdeThuQY/X/UkWO3uuhG6GFgp6M X-Received: by 2002:a05:6402:348b:b0:450:28be:d6b0 with SMTP id v11-20020a056402348b00b0045028bed6b0mr6010904edc.386.1663894175245; Thu, 22 Sep 2022 17:49:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663894175; cv=none; d=google.com; s=arc-20160816; b=fKddpKVtKU3tJQkHkTR84Gk3SwTgM64vRPCXo42KLbeIs1+QbIV/T2EJcRWqFv4r8K Qw2MmAUjv3Eth4Tum6jcqZc5RgPXUAJNtdSZAhSKP55iUhc+koeF+aDKTspuJI7Z7uxJ apaMIjwC1O3KSLtJBqr71S7uO4iP2OeMQKJBMzGLOI3hof2g8LuBCMK2LXdEYOpZwRq8 XAaqGvzPr6nqoe1q4Qi3+dXezZ2Or4e+AaitsignfguTaYkQSJqal7xMYQRWYmWhqXPL iDPy0mKDgdv/IHX96b+1ONmX9Gx2/bx0MEpn/vZy0DJV8+KMpbeyLwwN0Fc+UWzIqhyj Fczw== 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=0MH37fWt1kKUncCdiiz6bIlRIc5bt+X1g89mXjaLpeY=; b=teepGVsw1cUQiVACd+gjIM0dnKBVuFcRPqEZ4ZVGyEFChQ2NoKHa8fsK/kZm2trw9p rtTtyZhrRjshZlPaAJNY2d2Wa+Pupdw1OS9bh5tXQLPv3rFXr6Nnv6upxUfWmLtvr63t Oj5fL984Qsf/IOoEp7SKUdQwJyYW5EQCzWNax0iYSwrs5H9fkpMo3vWtN7zROwiBdw9A gDYkvngyuMraHfCegh+ny6isw1y+q3YXvMVDBKHMEH4Pz/pJmVpwCfscGOsspxZCL+CE TVxfbKrpOhTNtBszSo279yFI/SaAQdSuV2Km6YaDylnOnwDqYvVG4bOKqa4+W0U1leDU Ay0Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=Q1O6wlvk; 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=NONE dis=NONE) header.from=collabora.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h24-20020a50cdd8000000b00447879e8221si6314180edj.247.2022.09.22.17.49.10; Thu, 22 Sep 2022 17:49:35 -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=@collabora.com header.s=mail header.b=Q1O6wlvk; 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=NONE dis=NONE) header.from=collabora.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229923AbiIWAAH (ORCPT + 99 others); Thu, 22 Sep 2022 20:00:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33140 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229774AbiIWAAE (ORCPT ); Thu, 22 Sep 2022 20:00:04 -0400 Received: from madras.collabora.co.uk (madras.collabora.co.uk [46.235.227.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F0E2B76975 for ; Thu, 22 Sep 2022 17:00:02 -0700 (PDT) Received: from notapiano.myfiosgateway.com (unknown [71.190.76.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: nfraprado) by madras.collabora.co.uk (Postfix) with ESMTPSA id 46FD46602234; Fri, 23 Sep 2022 01:00:00 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1663891201; bh=XLMVjc9kycY7cqA20QU1lEWGA1kBnlKNHm6oii/5Ggw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Q1O6wlvkTvjYSTOhOZ6sXzT27+FaY8dolxZ3Zo1LrAkHwjsbluUsR59dmCwxoRfJv dwcE/5BOq1WYgsRLV9MlutZ9fdbZ2BCKpS2z9VEw2n8Nly1UiPL+sateKf5zLWWy5O nyVFbNQ7P4w7AW0cwjk8wQat1eDEF1n2QNV1AeEk2EMYbD47G+rnFN3RQ1utRm3H7D voF9OnAC60YCu/1+dNca5MqTRoZEKpeY+V71SbR9TXYKwjc5Ykjqdzpvwtg4Qrjtxx d+F9OduTd3hdNEaRJKwE1GupsqqeXw6EbA8vtdx1V4DYomEjW9X5/gr6swkpciMAVe Gwnh/H2WyioNA== From: =?UTF-8?q?N=C3=ADcolas=20F=2E=20R=2E=20A=2E=20Prado?= To: Mark Brown Cc: AngeloGioacchino Del Regno , kernel@collabora.com, =?UTF-8?q?N=C3=ADcolas=20F=2E=20R=2E=20A=2E=20Prado?= , Jaroslav Kysela , Liam Girdwood , Matthias Brugger , Takashi Iwai , Trevor Wu , Tzung-Bi Shih , alsa-devel@alsa-project.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-mediatek@lists.infradead.org Subject: [PATCH 2/6] ASoC: mediatek: mt8195: Expose individual headset jack pins Date: Thu, 22 Sep 2022 19:59:47 -0400 Message-Id: <20220922235951.252532-3-nfraprado@collabora.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20220922235951.252532-1-nfraprado@collabora.com> References: <20220922235951.252532-1-nfraprado@collabora.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS 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 The rt5682 codec is able to distinguish between two event types: headphone insertion/removal and headset microphone insertion/removal. However, currently, the mt8195 ASoC driver exposes a single kcontrol for the headset jack, so userspace isn't able to differentiate between the two events. Add a definition for the headset jack pins, so that a separate jack kcontrol is created for each one, allowing userspace to track and handle them individually. Signed-off-by: NĂ­colas F. R. A. Prado --- sound/soc/mediatek/mt8195/mt8195-mt6359.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/sound/soc/mediatek/mt8195/mt8195-mt6359.c b/sound/soc/mediatek/mt8195/mt8195-mt6359.c index 961e769602d6..17d4c4108a9d 100644 --- a/sound/soc/mediatek/mt8195/mt8195-mt6359.c +++ b/sound/soc/mediatek/mt8195/mt8195-mt6359.c @@ -63,6 +63,18 @@ struct mt8195_mt6359_priv { struct clk *i2so1_mclk; }; +/* Headset jack detection DAPM pins */ +static struct snd_soc_jack_pin mt8195_jack_pins[] = { + { + .pin = "Headphone", + .mask = SND_JACK_HEADPHONE, + }, + { + .pin = "Headset Mic", + .mask = SND_JACK_MICROPHONE, + }, +}; + static const struct snd_soc_dapm_widget mt8195_mt6359_widgets[] = { SND_SOC_DAPM_HP("Headphone", NULL), SND_SOC_DAPM_MIC("Headset Mic", NULL), @@ -563,11 +575,12 @@ static int mt8195_rt5682_init(struct snd_soc_pcm_runtime *rtd) priv->i2so1_mclk = afe_priv->clk[MT8195_CLK_TOP_APLL12_DIV2]; - ret = snd_soc_card_jack_new(rtd->card, "Headset Jack", + ret = snd_soc_card_jack_new_pins(rtd->card, "Headset Jack", SND_JACK_HEADSET | SND_JACK_BTN_0 | SND_JACK_BTN_1 | SND_JACK_BTN_2 | SND_JACK_BTN_3, - jack); + jack, mt8195_jack_pins, + ARRAY_SIZE(mt8195_jack_pins)); if (ret) { dev_err(rtd->dev, "Headset Jack creation failed: %d\n", ret); return ret; -- 2.37.3