From patchwork Fri Feb 14 15:14:29 2025 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: 13975113 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 B58F1C02198 for ; Fri, 14 Feb 2025 15:27:12 +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:Cc:To:In-Reply-To:References :Message-Id:Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date: From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=R7hBuZFXrH73Nl/ObnLYXP2ri8z1FFmVnujkJfoZgKk=; b=iDZTkn+bIhkyplh2ACJibw5XLI r+2rYnUTIjaFxKentAvM83njI+KXmGbOW17tBukAdYpUPEvLeSccc7tVpi+V3vk7/FAoCE0UvWAsJ peanPENfS1fFa18cl8HCD6xxNNBrtXOorfHln1nHlEH1OYLAIhb6eDvRLfh6J/vNDRRkos0qm5HhY j58wo4EKqXSR7wiEG77/czuaY7zXFGxDic2eySfOt7g6aK5jcyTn0x36oKT0Ie13n/7gzXg85Iqj9 Qfigje3KHGwl1CBcZ0DCALNleWmm7n/Lx/+gpxLdS5Nz5hryTt5XHwLYNiKvEk4yUJkKiphQyBTkC Y2cNhGOw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tixax-0000000FJPN-3cfY; Fri, 14 Feb 2025 15:27:11 +0000 Received: from bali.collaboradmins.com ([2a01:4f8:201:9162::2]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tixPI-0000000FGhZ-1Dwc; Fri, 14 Feb 2025 15:15:09 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1739546106; bh=JlKd02FMr5+yn8vnMu4CtaugEG5YPJLOEvhxTZp5wBQ=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=e6S0uCEimvGI6HgMA73JSU5MOVMGZa/3wpyIYb1lmvNeTMQ2a+8bTZZSAWU1RNN9W lDiuBMZ4nGKLQ413R1OUJ3YrftqHerYyQJkX0poh3WW9FVnN2U5TwU/4mNsi+jzKF6 MoemyRcF03xqTkGPQC80Oe9mHTBZhNvUABNpmoRLwQ7CR7r9HBd9gJSjM7J88qtRaA 9grK+3Vlx2G5Hlt8Dm8OsdMLqrULtwW69o6mIanHi6qRie22gmGJI8ujDdrX7S2X2M a/RJOAq7hVXz/4cNIuA9sYX/JFJ+IaNXVmKffYAWhVS+7/kuZwDz+w5MCtiZ+vlkDi v5OfdBF/t/MYg== Received: from [192.168.0.47] (unknown [IPv6:2804:14c:1a9:53ee::1003]) (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 bali.collaboradmins.com (Postfix) with ESMTPSA id 1CCF917E0FBA; Fri, 14 Feb 2025 16:15:01 +0100 (CET) From: =?utf-8?b?TsOtY29sYXMgRi4gUi4gQS4gUHJhZG8=?= Date: Fri, 14 Feb 2025 12:14:29 -0300 Subject: [PATCH 1/3] ASoC: dt-bindings: mediatek,mt8188-mt6359: Add mediatek,accdet MIME-Version: 1.0 Message-Id: <20250214-mt8188-accdet-v1-1-6bbd5483855b@collabora.com> References: <20250214-mt8188-accdet-v1-0-6bbd5483855b@collabora.com> In-Reply-To: <20250214-mt8188-accdet-v1-0-6bbd5483855b@collabora.com> To: Liam Girdwood , Mark Brown , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Matthias Brugger , AngeloGioacchino Del Regno , Trevor Wu , Jaroslav Kysela , Takashi Iwai Cc: kernel@collabora.com, linux-sound@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, =?utf-8?b?TsOtY29sYXMgRi4gUi4gQS4gUHJhZG8=?= X-Mailer: b4 0.14.2 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20250214_071508_475188_5593136D X-CRM114-Status: UNSURE ( 8.47 ) X-CRM114-Notice: Please train this message. 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 Add a mediatek,accdet phandle property to allow getting a reference to the MT6359 ACCDET block, which is responsible for detecting jack insertion/removal. Signed-off-by: Nícolas F. R. A. Prado Reviewed-by: Rob Herring (Arm) --- Documentation/devicetree/bindings/sound/mediatek,mt8188-mt6359.yaml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Documentation/devicetree/bindings/sound/mediatek,mt8188-mt6359.yaml b/Documentation/devicetree/bindings/sound/mediatek,mt8188-mt6359.yaml index 362e729b51b43ec16716aee70ad736420def81f3..41d303e28e4dabd152140531ec0bf7375741b659 100644 --- a/Documentation/devicetree/bindings/sound/mediatek,mt8188-mt6359.yaml +++ b/Documentation/devicetree/bindings/sound/mediatek,mt8188-mt6359.yaml @@ -40,6 +40,12 @@ properties: hardware that provides additional audio functionalities if present. The AFE will link to ADSP when the phandle is provided. + mediatek,accdet: + $ref: /schemas/types.yaml#/definitions/phandle + description: + The phandle to the MT6359 accessory detection block, which detects audio + jack insertion and removal. + patternProperties: "^dai-link-[0-9]+$": type: object From patchwork Fri Feb 14 15:14:30 2025 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: 13975114 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 C8054C02198 for ; Fri, 14 Feb 2025 15:28:40 +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:Cc:To:In-Reply-To:References :Message-Id:Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date: From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=Hy/v/JU8BPIjcHWmK+Ogizxv2cgnNmOHVawTDT9QvGs=; b=NhSroZKochqGERWNkWPKECHStF JYfFM6mmONPt7rCJelIOhVlE8q51foQBVQYLPnBdSaX6KexQd2aQ22CrdCJF+yitJQZUnedVHy4X7 vOjPEzkmXSfPXIuyhRsTFCSFThykb2o2+D62oUcwTPC5KHhO3V7Xb04/cU8GPf9Vp/sbK4RFcfXDy lB3x+INISZ3NOnTvozxNHk75hzNvDMhFed6x6urCgzMaHfo2EF9p0ula+S3k8cSkNFnR2NcHYhr1H NscrNsfTBMbhonBmVZC139xEq58kgOxl6pdBSMYsRJ6ZsWTq3g25aMzlhvKSkgaa3FD7Sa6WsvLBo srQ1j05w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tixcN-0000000FJoG-3h1c; Fri, 14 Feb 2025 15:28:39 +0000 Received: from bali.collaboradmins.com ([2a01:4f8:201:9162::2]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tixPL-0000000FGi0-0kbF; Fri, 14 Feb 2025 15:15:12 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1739546109; bh=LrLIXtRuehdwykIBttWuiZuw5wRuaIW9+FNl6glcXx0=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=NVl3gfVdX0tAUHmBP+Ujt/sbBjxJhyiDXGHoqG64RegmsUc5nYqGcH5kQlVWquV8T um5om9ZCOmuH7BYvISmlO0DyBEH/BAfl1hMzCXyCNNH8IbFVzxWPMuY1PjvVz5KHpn rQ41DTxZbJ90M06ao+a20OwuWsI4luK3x4HyJqkw2pgQ4Tawd5QDvzQo8mUhKHxROt QN5rbMOeF4ljfHlPotsV3hDYwfn5WjdDHlHa6Eiu9S8+ldNakIhtojI3sn+WRMkKgZ H784A0aidpwU73e5rI7CbDujADRYf9UwX2idcoNvCrJ+RTNGNFbXJFvJuHbS8TYnM2 ZRsBBpTS4NMMA== Received: from [192.168.0.47] (unknown [IPv6:2804:14c:1a9:53ee::1003]) (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 bali.collaboradmins.com (Postfix) with ESMTPSA id 8426B17E0FDF; Fri, 14 Feb 2025 16:15:06 +0100 (CET) From: =?utf-8?b?TsOtY29sYXMgRi4gUi4gQS4gUHJhZG8=?= Date: Fri, 14 Feb 2025 12:14:30 -0300 Subject: [PATCH 2/3] ASoC: mediatek: common: Handle mediatek,accdet property MIME-Version: 1.0 Message-Id: <20250214-mt8188-accdet-v1-2-6bbd5483855b@collabora.com> References: <20250214-mt8188-accdet-v1-0-6bbd5483855b@collabora.com> In-Reply-To: <20250214-mt8188-accdet-v1-0-6bbd5483855b@collabora.com> To: Liam Girdwood , Mark Brown , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Matthias Brugger , AngeloGioacchino Del Regno , Trevor Wu , Jaroslav Kysela , Takashi Iwai Cc: kernel@collabora.com, linux-sound@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, =?utf-8?b?TsOtY29sYXMgRi4gUi4gQS4gUHJhZG8=?= X-Mailer: b4 0.14.2 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20250214_071511_364392_3FC9C03A X-CRM114-Status: GOOD ( 13.55 ) 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 Handle the optional mediatek,accdet property. When present, retrieve the sound component from its phandle, so the machine sound driver can use it to register the audio jack and initialize the MT6359 ACCDET for jack detection. Signed-off-by: Nícolas F. R. A. Prado --- sound/soc/mediatek/common/mtk-soc-card.h | 1 + sound/soc/mediatek/common/mtk-soundcard-driver.c | 15 ++++++++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/sound/soc/mediatek/common/mtk-soc-card.h b/sound/soc/mediatek/common/mtk-soc-card.h index 3f6e24dd22df13ddb3aef1625a77d2e29e46fccf..a1d2794ac1f717997fb47023d5951a9ac4897788 100644 --- a/sound/soc/mediatek/common/mtk-soc-card.h +++ b/sound/soc/mediatek/common/mtk-soc-card.h @@ -16,6 +16,7 @@ struct mtk_soc_card_data { const struct mtk_sof_priv *sof_priv; struct list_head sof_dai_link_list; struct mtk_platform_card_data *card_data; + struct snd_soc_component *accdet; void *mach_priv; }; diff --git a/sound/soc/mediatek/common/mtk-soundcard-driver.c b/sound/soc/mediatek/common/mtk-soundcard-driver.c index f4314dddc46075d554b4e3f3aae8bcb5498f8ab5..4e1c546a994f5e6b7068f70ac8dc2af7e87d141a 100644 --- a/sound/soc/mediatek/common/mtk-soundcard-driver.c +++ b/sound/soc/mediatek/common/mtk-soundcard-driver.c @@ -8,6 +8,7 @@ #include #include +#include #include #include "mtk-dsp-sof-common.h" @@ -192,7 +193,9 @@ EXPORT_SYMBOL_GPL(mtk_soundcard_common_capture_ops); int mtk_soundcard_common_probe(struct platform_device *pdev) { - struct device_node *platform_node, *adsp_node; + struct device_node *platform_node, *adsp_node, *accdet_node; + struct snd_soc_component *accdet_comp; + struct platform_device *accdet_pdev; const struct mtk_soundcard_pdata *pdata; struct mtk_soc_card_data *soc_card_data; struct snd_soc_dai_link *orig_dai_link, *dai_link; @@ -250,6 +253,16 @@ int mtk_soundcard_common_probe(struct platform_device *pdev) soc_card_data->card_data->jacks = jacks; + accdet_node = of_parse_phandle(pdev->dev.of_node, "mediatek,accdet", 0); + if (!IS_ERR(accdet_node)) { + accdet_pdev = of_find_device_by_node(accdet_node); + if (!IS_ERR(accdet_pdev)) { + accdet_comp = snd_soc_lookup_component(&accdet_pdev->dev, NULL); + if (!IS_ERR(accdet_comp)) + soc_card_data->accdet = accdet_comp; + } + } + platform_node = of_parse_phandle(pdev->dev.of_node, "mediatek,platform", 0); if (!platform_node) return dev_err_probe(&pdev->dev, -EINVAL, From patchwork Fri Feb 14 15:14:31 2025 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: 13975115 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 F187FC02198 for ; Fri, 14 Feb 2025 15:30:08 +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:Cc:To:In-Reply-To:References :Message-Id:Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date: From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=vYszs/DB4wFktP2QVNbwZIxZexG9SRiLd8NF1/clmJ8=; b=D+wqAzLKHxEl7QL/yU756gcqS2 iZT67762doD8enrLcS43lx29WIyiD2LoVr2Uhoo8JcYBRGkvoeNsasD9e+pxNmfl94zv0EvV3vKLL UmF9uorVNOYkvO2eeC2Vi9iFsJ/8ll1OyGt+SqEnws6J38Czk4sIuNaDEi5jDcBOqwVleMWw6q01I YnWsIUBgu93os9aQmv4M2ByXZgr5CPZ9n58iDCZj6UGLFf8ns4uBH5hSqeMv0Saiso+Up9xyjD/8z JhOlzhkmAoIZBerLlj+t3asTvCIy0gyWFXUwp18jcH3EJ+iIAW1ScAcLsPcZpMGNEkIhLbfvIXsO0 Y/d9k5Mw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tixdo-0000000FKB5-0TFa; Fri, 14 Feb 2025 15:30:08 +0000 Received: from bali.collaboradmins.com ([2a01:4f8:201:9162::2]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tixPP-0000000FGiW-3Twd; Fri, 14 Feb 2025 15:15:17 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1739546114; bh=gYGJtiW6FSC0FDX8qS6/krawDyDf5GHTiTmU7WJ3Af8=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=qX9YEGD0ml2gWVx35Ac2J306oISYovWOng1iOF0x/+LFzhhDxHVflwNrxOtJqod5W RMCqYmSg5FwP/N363m6hjsMHKn3yMO0lL7RyVtYm2YZOSt/GQ8gUziuvbgZuGg5Erm NrwHX6N1bHi5+qJ0uRK/6Y2CS/T6KY3Fj07xaoPI3TRG7kjNS2XXcnZNaMEMGOuXW8 /i4iSWsrDhPuH4dpv/X209rsVzmN2v6OUNJ3NT3fvN0JgtJ8LH0iFT+YcVmNppcc9n eIPZ0uhmSIuF8gDqD9Ixnmz9afwDvzM3Y8T4s85qqnziGgpntg+QIqxLzJJmiknQ9t NV5YO83cvkgtw== Received: from [192.168.0.47] (unknown [IPv6:2804:14c:1a9:53ee::1003]) (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 bali.collaboradmins.com (Postfix) with ESMTPSA id 36BB717E1558; Fri, 14 Feb 2025 16:15:10 +0100 (CET) From: =?utf-8?b?TsOtY29sYXMgRi4gUi4gQS4gUHJhZG8=?= Date: Fri, 14 Feb 2025 12:14:31 -0300 Subject: [PATCH 3/3] ASoC: mediatek: mt8188-mt6359: Add headset jack detect support MIME-Version: 1.0 Message-Id: <20250214-mt8188-accdet-v1-3-6bbd5483855b@collabora.com> References: <20250214-mt8188-accdet-v1-0-6bbd5483855b@collabora.com> In-Reply-To: <20250214-mt8188-accdet-v1-0-6bbd5483855b@collabora.com> To: Liam Girdwood , Mark Brown , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Matthias Brugger , AngeloGioacchino Del Regno , Trevor Wu , Jaroslav Kysela , Takashi Iwai Cc: kernel@collabora.com, linux-sound@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, =?utf-8?b?TsOtY29sYXMgRi4gUi4gQS4gUHJhZG8=?= , Zoran Zhan X-Mailer: b4 0.14.2 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20250214_071516_015018_3239070E X-CRM114-Status: GOOD ( 13.29 ) 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 Enable headset jack detection for MT8188 platforms using the MT6359 ACCDET block for it. Co-developed-by: Zoran Zhan Signed-off-by: Zoran Zhan Signed-off-by: Nícolas F. R. A. Prado --- sound/soc/mediatek/mt8188/mt8188-mt6359.c | 43 +++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/sound/soc/mediatek/mt8188/mt8188-mt6359.c b/sound/soc/mediatek/mt8188/mt8188-mt6359.c index 2d0d04e0232da07ba43a030b14853322427d55e7..4e19e6cfad1e1f42863b2e2f27131f880c5883bf 100644 --- a/sound/soc/mediatek/mt8188/mt8188-mt6359.c +++ b/sound/soc/mediatek/mt8188/mt8188-mt6359.c @@ -17,6 +17,7 @@ #include "mt8188-afe-common.h" #include "../../codecs/nau8825.h" #include "../../codecs/mt6359.h" +#include "../../codecs/mt6359-accdet.h" #include "../../codecs/rt5682.h" #include "../common/mtk-afe-platform-driver.h" #include "../common/mtk-soundcard-driver.h" @@ -266,6 +267,17 @@ static struct snd_soc_jack_pin nau8825_jack_pins[] = { }, }; +static struct snd_soc_jack_pin mt8188_headset_jack_pins[] = { + { + .pin = "Headphone", + .mask = SND_JACK_HEADPHONE, + }, + { + .pin = "Headset Mic", + .mask = SND_JACK_MICROPHONE, + }, +}; + static const struct snd_kcontrol_new mt8188_dumb_spk_controls[] = { SOC_DAPM_PIN_SWITCH("Ext Spk"), }; @@ -500,6 +512,35 @@ static int mt8188_mt6359_mtkaif_calibration(struct snd_soc_pcm_runtime *rtd) return 0; } +static int mt8188_mt6359_accdet_init(struct snd_soc_pcm_runtime *rtd) +{ + struct mtk_soc_card_data *soc_card_data = snd_soc_card_get_drvdata(rtd->card); + struct snd_soc_jack *jack = &soc_card_data->card_data->jacks[MT8188_JACK_HEADSET]; + int ret; + + if (!soc_card_data->accdet) + return 0; + + 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, mt8188_headset_jack_pins, + ARRAY_SIZE(mt8188_headset_jack_pins)); + if (ret) { + dev_err(rtd->dev, "Headset Jack create failed: %d\n", ret); + return ret; + } + + ret = mt6359_accdet_enable_jack_detect(soc_card_data->accdet, jack); + if (ret) { + dev_err(rtd->dev, "Headset Jack enable failed: %d\n", ret); + return ret; + } + + return 0; +} + static int mt8188_mt6359_init(struct snd_soc_pcm_runtime *rtd) { struct snd_soc_component *cmpnt_codec = @@ -512,6 +553,8 @@ static int mt8188_mt6359_init(struct snd_soc_pcm_runtime *rtd) /* mtkaif calibration */ mt8188_mt6359_mtkaif_calibration(rtd); + mt8188_mt6359_accdet_init(rtd); + return 0; }