From patchwork Thu Sep 22 23:59:49 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?TsOtY29sYXMgRi4gUi4gQS4gUHJhZG8=?= X-Patchwork-Id: 12985961 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id CE1A6ECAAD8 for ; Fri, 23 Sep 2022 00:02:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: Content-Type:MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc: To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=tjXlq+UfHh9BRTH9qSENwd2hPgyXUVIwIE+7KdM09GA=; b=0zt8kmjGjzXzFn663zenAD6O8j K6Jfn6VcyuI1/+B7xpvvSwuBE9mDgC6pf8EmsRhNB6l9xQ0NuLuo14/3gjahalDGxHfPJUhgKpJmm mVvb8tZS4D7lLRzAhmn6DqkiVwAKIfaARMFtznuejqRMRzv39cbhVwon6iRiUfM/08KjL7tt7BxCN lWXEoXXU86atfcbs0GGzAqmdUYf7nDUYR81IyxOv1sE1du3JEgavibpK7Vro94vn5bx+cDy8R4EOr BNUyxGMvARoaTiD/6LA9eVn6IJgx+qlVPBdisk+m1sQg0tSC97srz6Udz626rHNNg0PszGFyWirDQ LlED82Pg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1obW9Q-000gWg-NA; Fri, 23 Sep 2022 00:02:40 +0000 Received: from madras.collabora.co.uk ([2a00:1098:0:82:1000:25:2eeb:e5ab]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1obW75-000fTU-7D; Fri, 23 Sep 2022 00:00:18 +0000 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 F21C96602238; Fri, 23 Sep 2022 01:00:03 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1663891205; bh=ISOW3z3UoH6ajFB2isdB1bDkL2oaj2boZn5kSY9GOek=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fXD++uf1S/DU/o3qgoQuzLEuPjsV/8hsGcGH6JPA8b0kISH6CZxN/3z2fpHs7EZSQ xxEF8xEIQdzaJAnQDGQ6YFRMteV0jGr+ITZ0pv0M5FSrDQz9mokez4g9pJnIlCe/fN f5x2amI/KWrPugmS0QoAP7NRckfVaWUfs4gKsWsXwbG0YOGbkwWOXB4IkmH5cpWtta ctaHvw2ONYX8+SjYLXxY876Ee5md+TzaxFAUb1A6JRblSvLusp/Ht7DBuuLsh9qi5P zrcosJqUwBx+2wdfVmmaJZ5m+wndV6Gsms+TmlclU4lZOzcbBbfznKezFNmxzbmFkI kxizSUPJb88dA== From: =?utf-8?b?TsOtY29sYXMgRi4gUi4gQS4gUHJhZG8=?= To: Mark Brown Cc: AngeloGioacchino Del Regno , kernel@collabora.com, =?utf-8?b?TsOtY29sYXMgRi4gUi4gQS4gUHJhZG8=?= , Jaroslav Kysela , Jiaxin Yu , Liam Girdwood , Matthias Brugger , Takashi Iwai , alsa-devel@alsa-project.org, "chunxu.li" , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-mediatek@lists.infradead.org Subject: [PATCH 4/6] ASoC: mediatek: mt8186-da7219: Expose individual headset jack pins Date: Thu, 22 Sep 2022 19:59:49 -0400 Message-Id: <20220922235951.252532-5-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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220922_170015_445369_9010770C X-CRM114-Status: GOOD ( 13.39 ) X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+linux-mediatek=archiver.kernel.org@lists.infradead.org The da7219 codec is able to distinguish between two event types: headphone insertion/removal and headset microphone insertion/removal. However, currently, the mt8186-da7219 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 Reviewed-by: AngeloGioacchino Del Regno --- .../mt8186/mt8186-mt6366-da7219-max98357.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/sound/soc/mediatek/mt8186/mt8186-mt6366-da7219-max98357.c b/sound/soc/mediatek/mt8186/mt8186-mt6366-da7219-max98357.c index 8d428bc4a3b2..cfca6bdee834 100644 --- a/sound/soc/mediatek/mt8186/mt8186-mt6366-da7219-max98357.c +++ b/sound/soc/mediatek/mt8186/mt8186-mt6366-da7219-max98357.c @@ -37,6 +37,18 @@ struct mt8186_mt6366_da7219_max98357_priv { struct snd_soc_jack headset_jack, hdmi_jack; }; +/* Headset jack detection DAPM pins */ +static struct snd_soc_jack_pin mt8186_jack_pins[] = { + { + .pin = "Headphones", + .mask = SND_JACK_HEADPHONE, + }, + { + .pin = "Headset Mic", + .mask = SND_JACK_MICROPHONE, + }, +}; + static struct snd_soc_codec_conf mt8186_mt6366_da7219_max98357_codec_conf[] = { { .dlc = COMP_CODEC_CONF("mt6358-sound"), @@ -72,11 +84,12 @@ static int mt8186_da7219_init(struct snd_soc_pcm_runtime *rtd) } /* Enable Headset and 4 Buttons Jack detection */ - 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 | SND_JACK_LINEOUT, - jack); + jack, mt8186_jack_pins, + ARRAY_SIZE(mt8186_jack_pins)); if (ret) { dev_err(rtd->dev, "Headset Jack creation failed: %d\n", ret); return ret;