From nobody Sat Sep 21 17:18:56 2024 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9EA60ECAAD8 for ; Fri, 23 Sep 2022 00:00:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230007AbiIWAAI (ORCPT ); Thu, 22 Sep 2022 20:00:08 -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: quoted-printable 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=C3=ADcolas F. R. A. Prado Reviewed-by: AngeloGioacchino Del Regno Tested-by: AngeloGioacchino Del Regno --- 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; }; =20 +/* Headset jack detection DAPM pins */ +static struct snd_soc_jack_pin mt8195_jack_pins[] =3D { + { + .pin =3D "Headphone", + .mask =3D SND_JACK_HEADPHONE, + }, + { + .pin =3D "Headset Mic", + .mask =3D SND_JACK_MICROPHONE, + }, +}; + static const struct snd_soc_dapm_widget mt8195_mt6359_widgets[] =3D { 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_runt= ime *rtd) =20 priv->i2so1_mclk =3D afe_priv->clk[MT8195_CLK_TOP_APLL12_DIV2]; =20 - ret =3D snd_soc_card_jack_new(rtd->card, "Headset Jack", + ret =3D 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; --=20 2.37.3