From patchwork Fri Dec 8 07:09:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rui Zhou X-Patchwork-Id: 13484951 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 BC95BC46CA3 for ; Fri, 8 Dec 2023 07:09:49 +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: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=OQqe+M0SciQZs03dKyyk03FflXJC4UVH/RDIGAymDmI=; b=kKzeIH8EeZyTqGl+gkExGpTRpc SbRTc5Mw2eHbKK25m4kI3ArarCZXimWJBfTMrkrSbkhHsmWITu+vqcTtrmqz4H9Q7u2O+KYX4gBpJ 5DijgMgwdmcfAxQ4No6lO89TaRvkxm/e8KilPZs1h++o2jqXGEJH/m1k/y+yzQKVpLDMfXRLK2JgL 6SWyrXZ+5Jnj3QQgHyhFQFsU7lQkFul8BCziulx/Px0y2x8Pxh7MY6KTvPMyb7GKRQhFMi1DhcYMV 0gYCUBF89/m8WlBVY5nXZTu+s2jqeTR3drpt/xbC4YPuKfT95mmlcEwZi+soaClnuEArKlbjX+TlS 0LGzWpVg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1rBUzc-00Eveo-2H; Fri, 08 Dec 2023 07:09:48 +0000 Received: from mail-pf1-x42c.google.com ([2607:f8b0:4864:20::42c]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1rBUza-00EveH-0J for linux-mediatek@lists.infradead.org; Fri, 08 Dec 2023 07:09:47 +0000 Received: by mail-pf1-x42c.google.com with SMTP id d2e1a72fcca58-6ce9c8c45a7so1285288b3a.0 for ; Thu, 07 Dec 2023 23:09:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=huaqin-corp-partner-google-com.20230601.gappssmtp.com; s=20230601; t=1702019384; x=1702624184; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=OQqe+M0SciQZs03dKyyk03FflXJC4UVH/RDIGAymDmI=; b=D1VbP7FwRyWUnfBr9YUFs3QiKlHa+vJpqE23lXu6RIRpbWZye465sVCDXZAp3vr3eM QWYqGMGdRJNiVOsTUER7SFHTFDIn+2rfTscZiQwlqzbq90hkF6qbtZIRvAY+nXzEPjDF ibNh++3Ij9PkZ1xqHrJuOPK1HY+ZnuHVyaFZuSGd4iBhcawnLPgkdWOSeLvnq/+bc5uQ xJRHfgBsagS7c5ZJ9WmHhobHLNj2H/tMVYOecXk+G0nQEpeaVPprHErMP3LvPDyekiBV PNyP1eCHf76GCe34FnBmxpZS/y6KFLB07Nf3BE+9z2SvhAI1Uiv26qp9E/m5xa2SEBNu 9DRw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702019384; x=1702624184; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=OQqe+M0SciQZs03dKyyk03FflXJC4UVH/RDIGAymDmI=; b=nzMpK60QnzisHwj4Dtjj3Ef7dRc0CIiD9PjS8xlfKGv1EpjyiReEDH5oYr9/41qEWx UNU+ms1EaMWxHfb2OsE+vtMl81cDLR9xvw6yVfMnDW5MXLy7qGG53dL1beps+AyEF964 LvdT94hAJ/sHdguUoti+a5BcwBDU50lcsXCdVyMKy+0Ibd3MQuLPPes4jHSFaizrDmeA H9BWJn1/gDjds00EoRP6hNeTZaD8ef2mPXBtge/nTXhl+67z/SeN9z0cBmti32d3Tdwu iFeHiLoCgesoSPY8JO6tmPAdPcQxIiFKtfjV0+ooCHDC9YzJTWvfDZgc3gJvh2WGFcAG iSxA== X-Gm-Message-State: AOJu0YxdYzl/e2+q1dR9UAgMbhoe1xSVprdIu7VZXuFxdAC/BXfqYhx4 TWG1V3qLnKxLAZ+lGRLhBUbVKg== X-Google-Smtp-Source: AGHT+IHsHTSm2Bu/7jmLgk3YrcJqqwUg30HlW28b2vqp8SUhwfwdY33yw/3CJAX0OZ4ODyyP6JN7kg== X-Received: by 2002:a05:6a00:8019:b0:6ce:2731:5f7f with SMTP id eg25-20020a056a00801900b006ce27315f7fmr4201058pfb.62.1702019384623; Thu, 07 Dec 2023 23:09:44 -0800 (PST) Received: from localhost.localdomain ([101.78.151.194]) by smtp.gmail.com with ESMTPSA id b17-20020a056a000cd100b006ce4b40e7desm918061pfv.90.2023.12.07.23.09.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Dec 2023 23:09:44 -0800 (PST) From: Rui Zhou To: lgirdwood@gmail.com, broonie@kernel.org, robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, conor+dt@kernel.org, angelogioacchino.delregno@collabora.com, perex@perex.cz, trevor.wu@mediatek.com, allen-kh.cheng@mediatek.com, kuninori.morimoto.gx@renesas.com Cc: linux-mediatek@lists.infradead.org, Rui Zhou , Conor Dooley Subject: [v8 1/4] ASoC: dt-bindings: mt8188-mt6359: add es8326 support Date: Fri, 8 Dec 2023 15:09:30 +0800 Message-Id: <20231208070933.720324-2-zhourui@huaqin.corp-partner.google.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20231208070933.720324-1-zhourui@huaqin.corp-partner.google.com> References: <20231208070933.720324-1-zhourui@huaqin.corp-partner.google.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231207_230946_131483_CAFE7E76 X-CRM114-Status: UNSURE ( 6.77 ) 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 compatible string "mediatek,mt8188-es8326" to support new board with es8326 codec. Acked-by: Conor Dooley Reviewed-by: AngeloGioacchino Del Regno Signed-off-by: Rui Zhou --- .../devicetree/bindings/sound/mediatek,mt8188-mt6359.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/Documentation/devicetree/bindings/sound/mediatek,mt8188-mt6359.yaml b/Documentation/devicetree/bindings/sound/mediatek,mt8188-mt6359.yaml index 4c8c95057ef7..f94ad0715e32 100644 --- a/Documentation/devicetree/bindings/sound/mediatek,mt8188-mt6359.yaml +++ b/Documentation/devicetree/bindings/sound/mediatek,mt8188-mt6359.yaml @@ -15,6 +15,7 @@ allOf: properties: compatible: enum: + - mediatek,mt8188-es8326 - mediatek,mt8188-mt6359-evb - mediatek,mt8188-nau8825 - mediatek,mt8188-rt5682s From patchwork Fri Dec 8 07:09:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rui Zhou X-Patchwork-Id: 13484952 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 59C06C4167B for ; Fri, 8 Dec 2023 07:09:56 +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: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=Lpd6C9NI3pbwTLe6pctih7tPOV6DJdooeIM997kH/ks=; b=1eJ8K6oBRUh7Gq2KcSAu22Jx2d mjNr79eR6J/fSYXswXGBR2NGXr6u7Ndw1ZRK34ICW5FnoDU1wavwPwGkG6dKbJJ4l+2ISR+XvDGBA WNitBr4bnv9UNWJ9WtKIXe0tBb9mar+WSima+xZbo6W0s7eMRHaoqbOOlBv5U1NBA5L3dwkFG2sDv cYOYQAH7nj4HoekKv05/W/NCpYDu7oAXHdnJIWGAmFEnEUnCcF3SKdVZGDyzClWMFKdHs60JTsERU ukx7C6VS8F6yJ4oqnTsgLBORhIQpS0kpizOUzkJsifhO/lymXgUT2XeBEofQ0UFfyg66RYIRboVxO sVnkzg5Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1rBUzj-00EvgD-0c; Fri, 08 Dec 2023 07:09:55 +0000 Received: from mail-oo1-xc2d.google.com ([2607:f8b0:4864:20::c2d]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1rBUzf-00Evei-2H for linux-mediatek@lists.infradead.org; Fri, 08 Dec 2023 07:09:53 +0000 Received: by mail-oo1-xc2d.google.com with SMTP id 006d021491bc7-58e256505f7so803077eaf.3 for ; Thu, 07 Dec 2023 23:09:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=huaqin-corp-partner-google-com.20230601.gappssmtp.com; s=20230601; t=1702019388; x=1702624188; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Lpd6C9NI3pbwTLe6pctih7tPOV6DJdooeIM997kH/ks=; b=aSO5ZzNs2EPNGe1YDXs74NM2Jn9WrdMXdbvLVGCOAl88hQ1bW7qpmynwkj5fk05/Hh GaqCeif0TSmj++rWRSyiYbZGjqXQL5OCFCtiUE8ZCTq91q15MVAOPDDQCsykLqRVWWA/ gnCVYlRMrRKQg/ePwrHnLd9JeMQaOXYRe9cPn9ky1V3MA1/CyYQ3SNzO8XBsli4XSc6X 7kiOJRsIL7EzARWKEeuywU5uhnhjnJJlijbqo+e73xnIm3FKOinOlpJ/f5vNmrf/1VSe UQu5jE4nhhuJTCd2HvF7Lu4rjrIeBea4Bv0lWYo0tlVbLgE5Suejyi9WJUozyMsLk7no MdRg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702019388; x=1702624188; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Lpd6C9NI3pbwTLe6pctih7tPOV6DJdooeIM997kH/ks=; b=iqV+iTLrbQAleGsttJbdbi2jR9cU5IMuBhg06k7FG9jWoWMp805G3y0y/BnWaLfmLG FUiPDfxGHcvcc6EUrdEp3jHjuAzuIL5yTEV06+iMrxOTSRyqjJv0ETR97amkfV8Je+Qz M1PpK+kMPWdtknU2orKHDlN7uBBW162lEPV8nAcwdctgfhktYnbk6MUzrfuxSUT3nVrb q0Zb+aLWmU8CgN20bL3BgKQ9wN/5o8dFUd2+SZjHU5xQZJpmyZvX9V9iiWpWLXtmLdUV R+9pplUF8qi+U0Pwn4mB2ZtGyYPMtXpyBc06U7Sv1bnOsr6Tkf0Xm7CRPJe9xxttYfp4 9wSQ== X-Gm-Message-State: AOJu0YzzHOSfDTbl6ct9U5xHrExli4nXZ2319XQsFXa9jFuqzuXWhQ8C d7RrT4lgDeucJZMg17Y9kKK4bg== X-Google-Smtp-Source: AGHT+IFC54AX+aRqedQDrgfqtFE7wVI5+Pp1izCVsyhP4Hb2WWRnBhkK94PZ/vSG2aC53LEBwlnVog== X-Received: by 2002:a05:6358:91b:b0:170:a325:dd2b with SMTP id r27-20020a056358091b00b00170a325dd2bmr211976rwi.12.1702019387674; Thu, 07 Dec 2023 23:09:47 -0800 (PST) Received: from localhost.localdomain ([101.78.151.194]) by smtp.gmail.com with ESMTPSA id b17-20020a056a000cd100b006ce4b40e7desm918061pfv.90.2023.12.07.23.09.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Dec 2023 23:09:47 -0800 (PST) From: Rui Zhou To: lgirdwood@gmail.com, broonie@kernel.org, robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, conor+dt@kernel.org, angelogioacchino.delregno@collabora.com, perex@perex.cz, trevor.wu@mediatek.com, allen-kh.cheng@mediatek.com, kuninori.morimoto.gx@renesas.com Cc: linux-mediatek@lists.infradead.org, Rui Zhou Subject: [v8 2/4] ASoC: mediatek: mt8188-mt6359: commonize headset codec init/exit api Date: Fri, 8 Dec 2023 15:09:31 +0800 Message-Id: <20231208070933.720324-3-zhourui@huaqin.corp-partner.google.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20231208070933.720324-1-zhourui@huaqin.corp-partner.google.com> References: <20231208070933.720324-1-zhourui@huaqin.corp-partner.google.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231207_230951_745148_9B88CBCD X-CRM114-Status: UNSURE ( 9.67 ) 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 Reduce code duplication, unify the headset codec init/exit api. Reviewed-by: AngeloGioacchino Del Regno Signed-off-by: Rui Zhou --- sound/soc/mediatek/mt8188/mt8188-mt6359.c | 67 ++--------------------- 1 file changed, 6 insertions(+), 61 deletions(-) diff --git a/sound/soc/mediatek/mt8188/mt8188-mt6359.c b/sound/soc/mediatek/mt8188/mt8188-mt6359.c index 33d477cc2e54..b4606a28794c 100644 --- a/sound/soc/mediatek/mt8188/mt8188-mt6359.c +++ b/sound/soc/mediatek/mt8188/mt8188-mt6359.c @@ -726,7 +726,7 @@ static int mt8188_max98390_codec_init(struct snd_soc_pcm_runtime *rtd) return 0; } -static int mt8188_nau8825_codec_init(struct snd_soc_pcm_runtime *rtd) +static int mt8188_headset_codec_init(struct snd_soc_pcm_runtime *rtd) { struct snd_soc_card *card = rtd->card; struct mtk_soc_card_data *soc_card_data = snd_soc_card_get_drvdata(card); @@ -775,68 +775,13 @@ static int mt8188_nau8825_codec_init(struct snd_soc_pcm_runtime *rtd) return 0; }; -static int mt8188_rt5682s_codec_init(struct snd_soc_pcm_runtime *rtd) -{ - struct snd_soc_card *card = rtd->card; - struct mtk_soc_card_data *soc_card_data = snd_soc_card_get_drvdata(card); - struct mt8188_mt6359_priv *priv = soc_card_data->mach_priv; - struct snd_soc_component *component = snd_soc_rtd_to_codec(rtd, 0)->component; - struct snd_soc_jack *jack = &priv->headset_jack; - int ret; - - ret = snd_soc_dapm_new_controls(&card->dapm, mt8188_nau8825_widgets, - ARRAY_SIZE(mt8188_nau8825_widgets)); - if (ret) { - dev_err(rtd->dev, "unable to add rt5682s card widget, ret %d\n", ret); - return ret; - } - - ret = snd_soc_add_card_controls(card, mt8188_nau8825_controls, - ARRAY_SIZE(mt8188_nau8825_controls)); - if (ret) { - dev_err(rtd->dev, "unable to add rt5682s card controls, ret %d\n", ret); - return ret; - } - - 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, - nau8825_jack_pins, - ARRAY_SIZE(nau8825_jack_pins)); - if (ret) { - dev_err(rtd->dev, "Headset Jack creation failed: %d\n", ret); - return ret; - } - - snd_jack_set_key(jack->jack, SND_JACK_BTN_0, KEY_PLAYPAUSE); - snd_jack_set_key(jack->jack, SND_JACK_BTN_1, KEY_VOICECOMMAND); - snd_jack_set_key(jack->jack, SND_JACK_BTN_2, KEY_VOLUMEUP); - snd_jack_set_key(jack->jack, SND_JACK_BTN_3, KEY_VOLUMEDOWN); - ret = snd_soc_component_set_jack(component, jack, NULL); - - if (ret) { - dev_err(rtd->dev, "Headset Jack call-back failed: %d\n", ret); - return ret; - } - - return 0; -}; - -static void mt8188_nau8825_codec_exit(struct snd_soc_pcm_runtime *rtd) +static void mt8188_headset_codec_exit(struct snd_soc_pcm_runtime *rtd) { struct snd_soc_component *component = snd_soc_rtd_to_codec(rtd, 0)->component; snd_soc_component_set_jack(component, NULL, NULL); } -static void mt8188_rt5682s_codec_exit(struct snd_soc_pcm_runtime *rtd) -{ - struct snd_soc_component *component = snd_soc_rtd_to_codec(rtd, 0)->component; - - snd_soc_component_set_jack(component, NULL, NULL); -} static int mt8188_nau8825_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params) @@ -1407,15 +1352,15 @@ static int mt8188_mt6359_dev_probe(struct platform_device *pdev) } else if (!strcmp(dai_link->codecs->dai_name, NAU8825_CODEC_DAI)) { dai_link->ops = &mt8188_nau8825_ops; if (!init_nau8825) { - dai_link->init = mt8188_nau8825_codec_init; - dai_link->exit = mt8188_nau8825_codec_exit; + dai_link->init = mt8188_headset_codec_init; + dai_link->exit = mt8188_headset_codec_exit; init_nau8825 = true; } } else if (!strcmp(dai_link->codecs->dai_name, RT5682S_CODEC_DAI)) { dai_link->ops = &mt8188_rt5682s_i2s_ops; if (!init_rt5682s) { - dai_link->init = mt8188_rt5682s_codec_init; - dai_link->exit = mt8188_rt5682s_codec_exit; + dai_link->init = mt8188_headset_codec_init; + dai_link->exit = mt8188_headset_codec_exit; init_rt5682s = true; } } else { From patchwork Fri Dec 8 07:09:32 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rui Zhou X-Patchwork-Id: 13484953 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 AFAABC10F04 for ; Fri, 8 Dec 2023 07:09:56 +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: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=4kmdF+dOIN/jz7jd4rs5sOxenjApC06h574cv2snUaI=; b=trvtqe/Hc7Y1atZSPFyjVKbRlp b/E79Tg8/M72ksKzYFCr4PDyOAuR884l0wxDz1ETu129b/r2Ba1P9VY7qs4MMVp/IfOMth4B97hwH pDahepiNTqRvOGQLalQz/fUTxOM7sbZIJCeSaMK6OBSn/Xjn+547a185xUcUCkrBC8XUiC73SDO5Q 1HeLPfrNanxuEJRqAYiVe5lftarCK6XQkAGZWFABEMT64m9lEIWFtzTvhFKO3XvcEG3meOkBqlvmp k7pC/q8g7tbh5XQwqFIvn3csL/N8EG9qxJZGN8yv5xEW/aYC3LHhUVfYv115UKh9Vnozj2DjgrC24 4qlATOyQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1rBUzj-00EvgN-1i; Fri, 08 Dec 2023 07:09:55 +0000 Received: from mail-oi1-x236.google.com ([2607:f8b0:4864:20::236]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1rBUzg-00EvfO-0z for linux-mediatek@lists.infradead.org; Fri, 08 Dec 2023 07:09:53 +0000 Received: by mail-oi1-x236.google.com with SMTP id 5614622812f47-3b9ee9d15e7so28092b6e.2 for ; Thu, 07 Dec 2023 23:09:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=huaqin-corp-partner-google-com.20230601.gappssmtp.com; s=20230601; t=1702019390; x=1702624190; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=4kmdF+dOIN/jz7jd4rs5sOxenjApC06h574cv2snUaI=; b=wt6SFHH5cjrTRwgXOpgg9ILwtDJPj0gfyhDEwyAcFdXqd2jOXjsh2r/cYs5j36BoFg uTLzRYOV8mnVdRVoQp8/D5TQY/nzT7hWNiWbccq3EtF51IycA527XRHYQ/qmJpSNyiMs BzhEyfWHud2a4YJ33YKZP5xTUp8202EOg24MniH3xLp76kO/x+PDU4u54hK4Jjiaztrp 8kfKuVH/hiYMgn0g9gJoV/nJz5JhKC6aQvtw3RgyIZRHMWobjb/jG8pviYuc+Rs3k4m0 D1guMBCrEV0Wh4mGLXz8xegHceuTH3+kyvmTk08Ik3mCjlPf/SWWYoo6xB0p7WUa7f3L YExA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702019390; x=1702624190; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=4kmdF+dOIN/jz7jd4rs5sOxenjApC06h574cv2snUaI=; b=EJkhpcSuKPRrG6AaQmz8X12Di/5HPiaZyLhBshN6wbTFPWqo1ECzU3sp+GG7l0rWUr bIpMokbOuirXstxKf4n7nQFiaIyl6SrE2ifV3x7bwQSEUQfqImuGcczbNGtSGOGFJ4cj 7qhEfB0Wmet2mpejzILjooNhM0wqXlUg4VDQwbsgo8nAXCbj7W0ojLJ9Sr9fjQGnaNvi mpLHMEam++DwanMqJL5TSwVMeytz7LAEQa1owEvZOCbBDhBE3cLkxXXDCTLDEdTZuJyg m+wC3qvzzp+9If1F79jMH+HtnsujyODGLWUM6cwNjS7b69e/v6LMARp/877SdZaT269g mOVQ== X-Gm-Message-State: AOJu0YwbJYeQWEAkWbNsPkP76CsDSajDx4kmDf0tz/QrjfPUuRj1UNNB HwWy/hf/honcSC6tr/4ns94FbQ== X-Google-Smtp-Source: AGHT+IGfJUgwaSoo0EaaG4e12r5jBLEBcEqtObf7ny4kPxmVavumaWO3Qssm4BFj4Haox6E3l8B0eg== X-Received: by 2002:a05:6808:296:b0:3b9:b867:2eb6 with SMTP id z22-20020a056808029600b003b9b8672eb6mr3091575oic.7.1702019390654; Thu, 07 Dec 2023 23:09:50 -0800 (PST) Received: from localhost.localdomain ([101.78.151.194]) by smtp.gmail.com with ESMTPSA id b17-20020a056a000cd100b006ce4b40e7desm918061pfv.90.2023.12.07.23.09.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Dec 2023 23:09:50 -0800 (PST) From: Rui Zhou To: lgirdwood@gmail.com, broonie@kernel.org, robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, conor+dt@kernel.org, angelogioacchino.delregno@collabora.com, perex@perex.cz, trevor.wu@mediatek.com, allen-kh.cheng@mediatek.com, kuninori.morimoto.gx@renesas.com Cc: linux-mediatek@lists.infradead.org, Rui Zhou Subject: [v8 3/4] ASoC: mediatek: mt8188-mt6359: add es8326 support Date: Fri, 8 Dec 2023 15:09:32 +0800 Message-Id: <20231208070933.720324-4-zhourui@huaqin.corp-partner.google.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20231208070933.720324-1-zhourui@huaqin.corp-partner.google.com> References: <20231208070933.720324-1-zhourui@huaqin.corp-partner.google.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231207_230952_341676_162A18D3 X-CRM114-Status: GOOD ( 19.98 ) 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 To use ES8326 as the codec, add a new sound card named mt8186_es8326. Reviewed-by: Trevor Wu Signed-off-by: Rui Zhou --- sound/soc/mediatek/Kconfig | 1 + sound/soc/mediatek/mt8188/mt8188-mt6359.c | 51 ++++++++++++++++++++++- 2 files changed, 50 insertions(+), 2 deletions(-) diff --git a/sound/soc/mediatek/Kconfig b/sound/soc/mediatek/Kconfig index b93d455744ab..296b434caf81 100644 --- a/sound/soc/mediatek/Kconfig +++ b/sound/soc/mediatek/Kconfig @@ -252,6 +252,7 @@ config SND_SOC_MT8188_MT6359 select SND_SOC_NAU8315 select SND_SOC_NAU8825 select SND_SOC_RT5682S + select SND_SOC_ES8326 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 b4606a28794c..ddbdf9265640 100644 --- a/sound/soc/mediatek/mt8188/mt8188-mt6359.c +++ b/sound/soc/mediatek/mt8188/mt8188-mt6359.c @@ -34,6 +34,8 @@ #define NAU8825_HS_PRESENT BIT(0) #define RT5682S_HS_PRESENT BIT(1) +#define ES8326_HS_PRESENT BIT(2) +#define MAX98390_TWO_AMP BIT(3) /* * Maxim MAX98390 */ @@ -48,6 +50,11 @@ */ #define NAU8825_CODEC_DAI "nau8825-hifi" +/* + * ES8326 + */ +#define ES8326_CODEC_DAI "ES8326 HiFi" + #define SOF_DMA_DL2 "SOF_DMA_DL2" #define SOF_DMA_DL3 "SOF_DMA_DL3" #define SOF_DMA_UL4 "SOF_DMA_UL4" @@ -888,6 +895,30 @@ static const struct snd_soc_ops mt8188_sof_be_ops = { .hw_params = mt8188_sof_be_hw_params, }; +static int mt8188_es8326_hw_params(struct snd_pcm_substream *substream, + struct snd_pcm_hw_params *params) +{ + struct snd_soc_pcm_runtime *rtd = snd_soc_substream_to_rtd(substream); + struct snd_soc_dai *cpu_dai = snd_soc_rtd_to_cpu(rtd, 0); + struct snd_soc_dai *codec_dai = snd_soc_rtd_to_codec(rtd, 0); + unsigned int rate = params_rate(params); + int ret; + + /* Configure MCLK for codec */ + ret = snd_soc_dai_set_sysclk(codec_dai, 0, rate * 256, SND_SOC_CLOCK_IN); + if (ret < 0) { + dev_err(codec_dai->dev, "can't set MCLK %d\n", ret); + return ret; + } + + /* Configure MCLK for cpu */ + return snd_soc_dai_set_sysclk(cpu_dai, 0, rate * 256, SND_SOC_CLOCK_OUT); +} + +static const struct snd_soc_ops mt8188_es8326_ops = { + .hw_params = mt8188_es8326_hw_params, +}; + static struct snd_soc_dai_link mt8188_mt6359_dai_links[] = { /* FE */ [DAI_LINK_DL2_FE] = { @@ -1197,7 +1228,7 @@ static void mt8188_fixup_controls(struct snd_soc_card *card) struct mt8188_card_data *card_data = (struct mt8188_card_data *)priv->private_data; struct snd_kcontrol *kctl; - if (card_data->quirk & (NAU8825_HS_PRESENT | RT5682S_HS_PRESENT)) { + if (card_data->quirk & (NAU8825_HS_PRESENT | RT5682S_HS_PRESENT | ES8326_HS_PRESENT)) { struct snd_soc_dapm_widget *w, *next_w; for_each_card_widgets_safe(card, w, next_w) { @@ -1238,6 +1269,7 @@ static int mt8188_mt6359_dev_probe(struct platform_device *pdev) struct mt8188_card_data *card_data; struct snd_soc_dai_link *dai_link; bool init_mt6359 = false; + bool init_es8326 = false; bool init_nau8825 = false; bool init_rt5682s = false; bool init_max98390 = false; @@ -1344,7 +1376,9 @@ static int mt8188_mt6359_dev_probe(struct platform_device *pdev) strcmp(dai_link->name, "ETDM1_IN_BE") == 0 || strcmp(dai_link->name, "ETDM2_IN_BE") == 0) { if (!strcmp(dai_link->codecs->dai_name, MAX98390_CODEC_DAI)) { - dai_link->ops = &mt8188_max98390_ops; + if (!(card_data->quirk & MAX98390_TWO_AMP)) { + dai_link->ops = &mt8188_max98390_ops; + } if (!init_max98390) { dai_link->init = mt8188_max98390_codec_init; init_max98390 = true; @@ -1363,6 +1397,13 @@ static int mt8188_mt6359_dev_probe(struct platform_device *pdev) dai_link->exit = mt8188_headset_codec_exit; init_rt5682s = true; } + } else if (!strcmp(dai_link->codecs->dai_name, ES8326_CODEC_DAI)) { + dai_link->ops = &mt8188_es8326_ops; + if (!init_es8326) { + dai_link->init = mt8188_headset_codec_init; + dai_link->exit = mt8188_headset_codec_exit; + init_es8326 = true; + } } else { if (strcmp(dai_link->codecs->dai_name, "snd-soc-dummy-dai")) { if (!init_dumb) { @@ -1405,10 +1446,16 @@ static struct mt8188_card_data mt8188_rt5682s_card = { .quirk = RT5682S_HS_PRESENT, }; +static struct mt8188_card_data mt8188_es8326_card = { + .name = "mt8188_es8326", + .quirk = ES8326_HS_PRESENT | MAX98390_TWO_AMP, +}; + static const struct of_device_id mt8188_mt6359_dt_match[] = { { .compatible = "mediatek,mt8188-mt6359-evb", .data = &mt8188_evb_card, }, { .compatible = "mediatek,mt8188-nau8825", .data = &mt8188_nau8825_card, }, { .compatible = "mediatek,mt8188-rt5682s", .data = &mt8188_rt5682s_card, }, + { .compatible = "mediatek,mt8188-es8326", .data = &mt8188_es8326_card, }, { /* sentinel */ }, }; MODULE_DEVICE_TABLE(of, mt8188_mt6359_dt_match); From patchwork Fri Dec 8 07:09:33 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rui Zhou X-Patchwork-Id: 13484954 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 5FDCAC4167B for ; Fri, 8 Dec 2023 07:09:59 +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: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=nt4anNac6QQuI8NitQFKu/GxPNAvA4YY8I74D5v5vBE=; b=ZBz0CLpkIy4eRMdZuV7n3CORG7 gp53ncSdQ9E42+v63KyYmsSVmMsFFLjWKweJArmMSOH8Vw40UEyzBH9Rf0TQNDJQ4PJ4fw6isHZYT 3JPEiaQKpCdu/3woz9+TI/eULNriiD/hlJM98HEEDzIXVnevOGMNRKI7YaKlCGRFGGMwKd+K/HuGS GTsenK96+abqdcS7licbjly2vhDoSX0F3o+xGWAkiF2s0FmSj0FrCMrIkw/w80VgnP612SPI7gD66 payd3tfg/8Bq6S4LtG0Q+lEo3F4MKInZclwy4rwmmVnC4/EEp7KbKZTeGubG1CWxBZuBZTwQDfcex hHhuBUrQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1rBUzm-00Evi8-1C; Fri, 08 Dec 2023 07:09:58 +0000 Received: from mail-pf1-x42d.google.com ([2607:f8b0:4864:20::42d]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1rBUzk-00Evg9-1x for linux-mediatek@lists.infradead.org; Fri, 08 Dec 2023 07:09:57 +0000 Received: by mail-pf1-x42d.google.com with SMTP id d2e1a72fcca58-6ce7c1b07e1so1304035b3a.2 for ; Thu, 07 Dec 2023 23:09:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=huaqin-corp-partner-google-com.20230601.gappssmtp.com; s=20230601; t=1702019393; x=1702624193; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=nt4anNac6QQuI8NitQFKu/GxPNAvA4YY8I74D5v5vBE=; b=nIXwH/dtSTJ6ttd4X7p+rOeczKi36Uk4883/HDZcyihbqMAlnHgVe1n+opJGDQfS6V rsZXKnjqf0gQHriCGQJSTn+1dj+TZHC3JX0dr8ZC0K9mVus+neYPqW5C7vCoTxIPWQlO F2173PZJpUUz3iCWmKm7+Q83YwavUC/q5BuxtnCvzhUfGI46l9CdBZlgtc8/wUt5Q5jW lGJ5sMhikBM4CGs0UxQhzQKefaDgMO5R59lkGQxPByIn7k4hnKb7SeFoRpmmHnHkYQMb 6sJvC4vSktLHP/xXFkagUM21tB2ivxj/wmJwm5jRHhUbBdJmT7x6u/T1TTdHpi93R0R3 p7vQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702019393; x=1702624193; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=nt4anNac6QQuI8NitQFKu/GxPNAvA4YY8I74D5v5vBE=; b=Fu49Ddul99vo71d/BO5pReIlSgWqHmTqUMTfLQLEiIqYYJxtZhAz4YDxVZwVaZrMvl gKyeLNGVtJidh9FtnOsF0tVV8XW/GCrn42Gf80BzyF6rw55MUujBlBl3Qnr6WUEobCmo q19/Nqs5KUCxVpA3njcWhBnI9M1+YVOlEfBd5stOvPLVgnZ+3BXWRY0xDAofC2EKD4C0 8e8QpgDNMfpbW2ORZTzfb+rQLM2eBYG300onqzaHBFfFq/LeS7+u3NbG5nnD7nowLKib gOnW+f8uzFyZ/PQ3WCrS6OKwCSHSwX7UFulHN/kS+q7uzRWX0/0jT92E71jc8wt/yJd8 VjrA== X-Gm-Message-State: AOJu0YzG1wWzaL9UsETgjF5bCUJHH3dNFbUh00Qyrl/SPTrOGTwFxTuT 3HUhKUV+hF7Tt0Dx+J0nnyNrBQ== X-Google-Smtp-Source: AGHT+IHQjk5QlDFs0sFDS7yFpnRvxG3uEvorIsqqjx/R1zte7tBdywucB9vgYb8DBKT2N5sZNCaa/Q== X-Received: by 2002:a05:6a00:368a:b0:6ce:46dc:e4ab with SMTP id dw10-20020a056a00368a00b006ce46dce4abmr4756816pfb.2.1702019393702; Thu, 07 Dec 2023 23:09:53 -0800 (PST) Received: from localhost.localdomain ([101.78.151.194]) by smtp.gmail.com with ESMTPSA id b17-20020a056a000cd100b006ce4b40e7desm918061pfv.90.2023.12.07.23.09.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Dec 2023 23:09:53 -0800 (PST) From: Rui Zhou To: lgirdwood@gmail.com, broonie@kernel.org, robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, conor+dt@kernel.org, angelogioacchino.delregno@collabora.com, perex@perex.cz, trevor.wu@mediatek.com, allen-kh.cheng@mediatek.com, kuninori.morimoto.gx@renesas.com Cc: linux-mediatek@lists.infradead.org, Rui Zhou Subject: [v8 4/4] ASoC: mediatek: mt8188-mt6359: Enable dual amp for mt8188-rt5682s Date: Fri, 8 Dec 2023 15:09:33 +0800 Message-Id: <20231208070933.720324-5-zhourui@huaqin.corp-partner.google.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20231208070933.720324-1-zhourui@huaqin.corp-partner.google.com> References: <20231208070933.720324-1-zhourui@huaqin.corp-partner.google.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231207_230956_668878_4F5105C5 X-CRM114-Status: GOOD ( 10.59 ) 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 support for dual MAX98390 amplifiers on the mt8188-rt5682s board. Reviewed-by: Trevor Wu Reviewed-by: AngeloGioacchino Del Regno Signed-off-by: Rui Zhou --- sound/soc/mediatek/mt8188/mt8188-mt6359.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sound/soc/mediatek/mt8188/mt8188-mt6359.c b/sound/soc/mediatek/mt8188/mt8188-mt6359.c index ddbdf9265640..54ddf13d3f34 100644 --- a/sound/soc/mediatek/mt8188/mt8188-mt6359.c +++ b/sound/soc/mediatek/mt8188/mt8188-mt6359.c @@ -1443,7 +1443,7 @@ static struct mt8188_card_data mt8188_nau8825_card = { static struct mt8188_card_data mt8188_rt5682s_card = { .name = "mt8188_rt5682s", - .quirk = RT5682S_HS_PRESENT, + .quirk = RT5682S_HS_PRESENT | MAX98390_TWO_AMP, }; static struct mt8188_card_data mt8188_es8326_card = {