From patchwork Tue Mar 4 21:35:36 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: 14001444 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 51086C282D0 for ; Tue, 4 Mar 2025 21:39:13 +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=XA2dfnxHcYHg30TCiKmEfVSJuNwDEcHpOWhnk5spKUk=; b=mp7SE/PPbfseFU81RAXKR96lsY 1GChzf7wgDg27dAoQaq2fPn1ls2OPih/tbSgADq+apK7rRtKem29/abfpvYxYfcvu+SC3+cgRBTzN tUoi59C242/JWAItE9nymmkJ3zQo4G6MXIfxd0hrdYOjeKwx0Be33kCifw+ViKxjaGaUPDJLx7mQy 7gZ76Yub+2/NoYf0MKZhOVBEMBv+yOxTq8sZmQ4fWP0DYm5lo9uURiOLHGCVlxMU9CyeCDg9fgUzH EYNT8QrNzrErUjSmJodEIdttiWdqdjhrL6OwGSwsMabnxiloH2TAIM8BnqgLC0Gw6CZKPqAFxr+Cs BhjletTw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tpZyq-00000006JdS-1CYS; Tue, 04 Mar 2025 21:39:12 +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 1tpZvm-00000006JGK-1l08; Tue, 04 Mar 2025 21:36:03 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1741124161; bh=kqLKsRWONIOEmraC+9O8yD+AcyM64UYTSdcTa/53UAg=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=aaN9W9XfGNIt1pfsnGJgUbprevaTyBRiiNRgutPt2zycvlKQ/KPaayi8Myrs22Jn+ R4ror4lsY9r0Ltaz7FGHSSPXDDy5uz7zhqf0CadrMja1ty3qCaemnkaOSSJVik3WLZ i//zGlFXlE7qbgbBtItvMS45O8vOPeNVGor7+H0UNySSHTOAgN0onf6opzdRuErOZ0 a98Gz1LqB6PGiriskhE95CiPBjIVgq7bryqEVhMW1iQpQrQe/cIiM+c8AaD7nluRrv srSZJCP1t0WguFet+Y0XsskbE//Pzw/rXkBe712WEnXZrKJkOA5flJFbQoQCuP/203 sjVjrB37OMI2g== Received: from [192.168.0.47] (unknown [IPv6:2804:14c:1a9:53ee::1001]) (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 A918417E0B56; Tue, 4 Mar 2025 22:35:56 +0100 (CET) From: =?utf-8?b?TsOtY29sYXMgRi4gUi4gQS4gUHJhZG8=?= Date: Tue, 04 Mar 2025 18:35:36 -0300 Subject: [PATCH v2 1/3] ASoC: dt-bindings: mediatek,mt8188-mt6359: Add mediatek,accdet MIME-Version: 1.0 Message-Id: <20250304-mt8188-accdet-v2-1-27f496c4aede@collabora.com> References: <20250304-mt8188-accdet-v2-0-27f496c4aede@collabora.com> In-Reply-To: <20250304-mt8188-accdet-v2-0-27f496c4aede@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-20250304_133602_601259_9065656A X-CRM114-Status: GOOD ( 10.60 ) 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. Reviewed-by: AngeloGioacchino Del Regno Reviewed-by: Rob Herring (Arm) Signed-off-by: Nícolas F. R. A. Prado --- .../devicetree/bindings/sound/mediatek,mt8188-mt6359.yaml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Documentation/devicetree/bindings/sound/mediatek,mt8188-mt6359.yaml b/Documentation/devicetree/bindings/sound/mediatek,mt8188-mt6359.yaml index 8c77e7f68ad7b6f5b88b53cedccb291139a2eeea..76d5a437dc8f4ad1f31c21f84304bad326b0facd 100644 --- a/Documentation/devicetree/bindings/sound/mediatek,mt8188-mt6359.yaml +++ b/Documentation/devicetree/bindings/sound/mediatek,mt8188-mt6359.yaml @@ -40,6 +40,14 @@ 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. This property should only be present if the + accdet block is actually wired to the audio jack pins and to be used for + jack detection. + patternProperties: "^dai-link-[0-9]+$": type: object From patchwork Tue Mar 4 21:35:37 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: 14001641 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 98E74C021B8 for ; Tue, 4 Mar 2025 23:59:51 +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=6EPeksZy34hyGJ+FIUeDImaRetrIsVUOFg7F4ZA5JRU=; b=AT6+y/QZjjsR2Dw/S4vkMNEjvJ P6yyaIF58aj/tPVIYtf+SKClP8m4RNUEGt5Ti6Yl04Q6yQ7AkppNsLc8qc6jdSV311Uyf/2Uyj8Y/ aquFmV8IfqoCKkOX2FeZxbXosR3dPnkRbBy/GTk3YWqJM5nD5HmQxyTuHNXmSQhZ2C4q8aKXpsHeO s22y8vT4BLYn059HkFxiZaTp75/Cm/FqsXICYbfH2cGKGUxtnsGVDvAcv3uROcYZcmEFI8KCi3Cxw bCT3IOt6BxxmssZeWe5mkHkDS+d1VUGOtuO8MVOYj0oVvbuIRz23EbdbosIIerDnrTLxB9K5d/y0N LH3TgtQg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tpcAu-00000006ZlZ-2lR2; Tue, 04 Mar 2025 23:59:48 +0000 Received: from bali.collaboradmins.com ([148.251.105.195]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tpZvr-00000006JH0-0B18; Tue, 04 Mar 2025 21:36:08 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1741124165; bh=4t2C0qmVrIi7VnVoEP9H5R8wRYngP71UR0o3cUyGxgU=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=MDz0Q76TMWKkRWrrpRzxdHczLynV8ph1OAxaOKkmKJ4tpeaYridqAPIV5OYCtn/b4 3iZmjiJ0XU7JT4xC+gae3mji1D4vfWS9Zbk2FgUMCm5juiTLvfj5PUW+XV2QzJUyb3 sBFZA9sX86olBLl48TyjpfOwKoyOtfJXXMdeh5yuiS/3U4OQrUr0OuhV28dkg3TO+6 hY1UtOo6Bph37vjUM2TI2ktYiFNChu4GEcbzupHIx+gSY9cLhqJC/7OyBZJIL93YbO c39P0GQvC7jwAXuk5apibQaXcuBC8S1vXeJ9wjGPsG3Fy2s5G1fSdusm3swcXYW1rF 4dAxvQlWRotvw== Received: from [192.168.0.47] (unknown [IPv6:2804:14c:1a9:53ee::1001]) (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 93B0217E088C; Tue, 4 Mar 2025 22:36:01 +0100 (CET) From: =?utf-8?b?TsOtY29sYXMgRi4gUi4gQS4gUHJhZG8=?= Date: Tue, 04 Mar 2025 18:35:37 -0300 Subject: [PATCH v2 2/3] ASoC: mediatek: common: Handle mediatek,accdet property MIME-Version: 1.0 Message-Id: <20250304-mt8188-accdet-v2-2-27f496c4aede@collabora.com> References: <20250304-mt8188-accdet-v2-0-27f496c4aede@collabora.com> In-Reply-To: <20250304-mt8188-accdet-v2-0-27f496c4aede@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-20250304_133607_229991_87CC07BF X-CRM114-Status: GOOD ( 13.86 ) 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. Reviewed-by: AngeloGioacchino Del Regno 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 Tue Mar 4 21:35:38 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: 14001447 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 1BD13C021B8 for ; Tue, 4 Mar 2025 21:44:01 +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=9Q3d1nv6K7R4LwYAsiANt0YffDQzWhHDPpZz/QLdOJk=; b=ZCV/six1hu5AcunHO3uYzW7hdA eprwgiWtmblVOoAJrwsh1N2YHXpkmYrLqS2/PgB6qAS+O2EKF0W0HcF4OlRF5Uq0sa/YUbu4Aqfq3 sJxvR+BQmpM7SbU+WzUY82zxI5/Mo8pms7Ve7vFMLhaQHrUOqNR93Fkwie1AUP/JmS6KE7SsIouBo rV7wLo8ggbZFVkoRw5pE4Fm3ZK5oJoaPVLDVOcZFiRmb3MeZurp51ZyQ4d/Oq0VCi+rDWOzs5dJ/s k56o5pTGXechIilC94lSI+umUkaWPOsAvfjAP6+I0ni4vKYheStoGGsWvNX0islJYEWTlU8/xPfot bUzF/vYA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tpa3U-00000006K84-1FQf; Tue, 04 Mar 2025 21:44:00 +0000 Received: from bali.collaboradmins.com ([148.251.105.195]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tpZvv-00000006JI2-1a6D; Tue, 04 Mar 2025 21:36:12 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1741124169; bh=lfPOp8T4qiEf7llUQzd9pn2jZRzzyBoqvXgBW6abtNY=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=frOd5W/HW4h8YdTloOEWiu6R8JWebj5JId0BfN6oZeGwVVGSpiyErflTPYPLAd02v WtWkSh726xvr1X2BEWH2kJzUQbi+uyPcsUZV91kndbiu9ImiNE2WuvODnZLLX4cxss IImWYtML/CW8yKLOum+OEXD/DXXBGxKLhLx/BfPBanzcIxIMEfpMJWGN9y2EY3Ej+k Nc4XVrf4Iojuzhj0jSFsAtqxyL7xTytv4mWMxXLXVp6suav/KIrJORU3KwLvmFdGTE /XXCPUcW6KpnpByk2zJoavFr918BomP3ACwuNltI3u1eiYBtnWqvE+j9JMVj46unda J88pAtw1+VVzw== Received: from [192.168.0.47] (unknown [IPv6:2804:14c:1a9:53ee::1001]) (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 0110A17E0B56; Tue, 4 Mar 2025 22:36:05 +0100 (CET) From: =?utf-8?b?TsOtY29sYXMgRi4gUi4gQS4gUHJhZG8=?= Date: Tue, 04 Mar 2025 18:35:38 -0300 Subject: [PATCH v2 3/3] ASoC: mediatek: mt8188-mt6359: Add accdet headset jack detect support MIME-Version: 1.0 Message-Id: <20250304-mt8188-accdet-v2-3-27f496c4aede@collabora.com> References: <20250304-mt8188-accdet-v2-0-27f496c4aede@collabora.com> In-Reply-To: <20250304-mt8188-accdet-v2-0-27f496c4aede@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-20250304_133611_560310_1BEDCE81 X-CRM114-Status: GOOD ( 15.87 ) 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 that use the MT6359 ACCDET block for it, indicated by the mediatek,accdet property in DT. For those platforms, register a jack and initialize the ACCDET block to report jack events through it. Co-developed-by: Zoran Zhan Signed-off-by: Zoran Zhan Signed-off-by: Nícolas F. R. A. Prado Reviewed-by: AngeloGioacchino Del Regno --- sound/soc/mediatek/Kconfig | 1 + sound/soc/mediatek/mt8188/mt8188-mt6359.c | 43 +++++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+) diff --git a/sound/soc/mediatek/Kconfig b/sound/soc/mediatek/Kconfig index 3033e2d3fe16840631a465dd967da77f7a6ff43c..64155ea7965a1cc50593fef442ce90761836f328 100644 --- a/sound/soc/mediatek/Kconfig +++ b/sound/soc/mediatek/Kconfig @@ -237,6 +237,7 @@ config SND_SOC_MT8188_MT6359 select SND_SOC_NAU8825 select SND_SOC_RT5682S select SND_SOC_ES8326 + select SND_SOC_MT6359_ACCDET help This adds support for ASoC machine driver for MediaTek MT8188 boards with the MT6359 and other I2S audio codecs. diff --git a/sound/soc/mediatek/mt8188/mt8188-mt6359.c b/sound/soc/mediatek/mt8188/mt8188-mt6359.c index 420b1427b71dc1424a52f7ab6140c14659036733..20dc9470ba76b2a750e79a5ae3dafabd7c597f40 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" @@ -271,6 +272,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"), }; @@ -506,6 +518,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 = @@ -518,6 +559,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; }