From patchwork Thu Nov 16 09:35:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rui Zhou X-Patchwork-Id: 13457726 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 383A7C47071 for ; Thu, 16 Nov 2023 09:35:34 +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=g9xYChx5u7fhhBHstV0yAghSGQ O/tdQkN70Nz7E/kuC7PQBrglz/5uAOjSyJJZ8l30p8YkFzS9A95DWPY6PYVWGbHRPiV5iSgXq6fkd kLXaM4tFzXHtXObfFKV2xAD+CRP9gbfTQCLaUqwfbDY0pepjK4a7dbjJNlIsnBGZf6TYRVZ99pLOS LPf8FOGeMEVIbRtGwJ88QH2b8kmTQ5XJhGi+qa63PInqWvydYR5KkhclqqpPIAX9O2pH92upqHJL0 BfkfF04XdEuKPsDSenvnQ5PKYmY6dSttZjFOg2QYEBXSMNwUk6LzkTXoQunMlY5iN8JnZZ6L9CL3n +B9DPdOg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1r3Ymb-002z9r-00; Thu, 16 Nov 2023 09:35:33 +0000 Received: from mail-pg1-x531.google.com ([2607:f8b0:4864:20::531]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1r3YmX-002z7M-1A for linux-mediatek@lists.infradead.org; Thu, 16 Nov 2023 09:35:31 +0000 Received: by mail-pg1-x531.google.com with SMTP id 41be03b00d2f7-5ab94fc098cso420351a12.1 for ; Thu, 16 Nov 2023 01:35:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=huaqin-corp-partner-google-com.20230601.gappssmtp.com; s=20230601; t=1700127322; x=1700732122; 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=Y9+CjEvI2SNnyibNbusrxdnoyF3HHuO2SGAulVEYy6IW85iV6vQB1BG2AE0yeziReS P+PbZzmEwkD1qfUfvk3GgaGmWbJXnL535ANafedErfS/XyWe9+7hcBCsJC3mtpuj40Hk 6N7NytKB1m1sXk3swPTwYcQD0adXIsSFvnSFf1mvatCAeJsnBBfnaL7aaNOBlMY+O5vW CZ056sbmxroErPB4/vWPOqqvIjRV1e7xfxhi3zX+/knodVIye8MkLfOD3FeiJ2G1bR9j mCBgF/okEhWX8jSXmXyzm2cPn92ACvJOuxx2BGg8DeePly7lHURDcnQ4Sps6P38z9Cnm TdNQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700127322; x=1700732122; 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=InRp2TdVxdWtcMVARmG8zB4B0zjqWiMd7AxuxmxR8gEdlrNdB2scsGJyuKufMUZQTG 5TpaUYCnUlLwBxOXOtkLVZJ2EdyZ7SSHB0OgYhiaG43syc30Z/xVbJz8cGQPUbA3wW7z tEFNrISJ2iU3c50BwI+mtAoACsFcMVHMd/rRTRLm/e1XUqIZbI4OrKT3lH40w/ykYGYd pGayv/keNdE5Ow8zv8mKjD7ClUXrNFP3jp9H5TnCUdxP7ua7UkioF1xaVDrH/oGAJZPB ypqJlAHeghuF8A3h86QmBgS3o1hc415HNSFP8yLskg3tbmYvITHJFQWzhaubKDrx4YrC fhLQ== X-Gm-Message-State: AOJu0YxRJ5Sqzi34ulm352lPnClU+TwlhmObzo8x46RrY4l8IS7h6kyX daPKkHGLdqA5KH2dviSzR3R/Sw== X-Google-Smtp-Source: AGHT+IHn0vuFpmqTeZwYd/MNwbGBnfvbI4vmgww+bi0UMXJqY7MyI5ZeLDq5kWfWLtaUjlUPdcHlDA== X-Received: by 2002:a17:90b:3149:b0:27d:4901:b0b7 with SMTP id ip9-20020a17090b314900b0027d4901b0b7mr13989756pjb.30.1700127321792; Thu, 16 Nov 2023 01:35:21 -0800 (PST) Received: from localhost.localdomain ([101.78.151.194]) by smtp.gmail.com with ESMTPSA id o10-20020a17090aac0a00b00280fcbbe774sm1175214pjq.10.2023.11.16.01.35.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 Nov 2023 01:35:21 -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, allen-kh.cheng@mediatek.com, kuninori.morimoto.gx@renesas.com Cc: linux-sound@vger.kernel.org, linux-mediatek@lists.infradead.org, Rui Zhou , Conor Dooley Subject: [PATCH v7 1/4] ASoC: dt-bindings: mt8188-mt6359: add es8326 support Date: Thu, 16 Nov 2023 17:35:09 +0800 Message-Id: <20231116093512.4180240-2-zhourui@huaqin.corp-partner.google.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20231116093512.4180240-1-zhourui@huaqin.corp-partner.google.com> References: <20231116093512.4180240-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-20231116_013529_597855_08C3BEB9 X-CRM114-Status: UNSURE ( 7.31 ) 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 Thu Nov 16 09:35:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rui Zhou X-Patchwork-Id: 13457727 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 DBC41C54FB9 for ; Thu, 16 Nov 2023 09:35:36 +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=ZYD8dhWsAeFZclwVsR8FQpAtPI 0xtcq99x0SJyr87qoQFem3w9ErcHKrz0FKRlHy0Lgib4swpAgPcNV5JTNReeAxSM/nZLJQWxPkOoj jz7A0Aq0Be1Z+vq3ZkhUdZ3hhsn96PqJMCU0cpoUEzJzuo/nDB8VUNtIlfWDhBp4PadD3bSFFRHp6 2Yx67VTFnZjCatNpMuyrLrWJ1TR+Ms2K/6Wi0Fb1ilzXbiiOVMj3O3MGlerSbuRz8ryB/M1JQiemO jlx1sgZwdgFMXTn0F51XcAQVyGxCeSc9WlG0BjgvzuLdBrYhQjXZv1PE7lfl/ymqGd9pD7mCOmBq8 TJSQWTMg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1r3Ymd-002zBP-2I; Thu, 16 Nov 2023 09:35:35 +0000 Received: from mail-pg1-x535.google.com ([2607:f8b0:4864:20::535]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1r3Yma-002z7o-1O for linux-mediatek@lists.infradead.org; Thu, 16 Nov 2023 09:35:33 +0000 Received: by mail-pg1-x535.google.com with SMTP id 41be03b00d2f7-5bdf5a025c1so423645a12.0 for ; Thu, 16 Nov 2023 01:35:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=huaqin-corp-partner-google-com.20230601.gappssmtp.com; s=20230601; t=1700127325; x=1700732125; 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=scWDiSfBvD74CD1/zGospxbfHVnddFyZOkdFOX0+bGWDpPwJQZHGrdct1dKIKCq9Mq WIEUK6SxFniW1LhIjg51Lr43JqjwOySkRhqeyMV46PkN/X+GtjznASS5Ghk/7RQiHmBj pJB8hNo30pv/h4YzVVKkq5IugPwM67GQHCnH2rvkq/ZYsz1UdPLihdAS52AZyVmdyWE4 WCeHLZmdhFFf8db/1EApySXX5SZcU3FgvE4jzNPDKE9pN8YQaxMLRnBGOiRpNp/pgpxX xyhRp8ojxeG3JvJo9zKpDmpFrGsNZ5XS8zWOs2xu5waqejL1q61X+WveTvWqMzik5joq r88g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700127325; x=1700732125; 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=dlGlBnpFBMCaS4EDm/IqaNTOl0tn+7YwRQNUPGVcWpa7FluP5s3xd+bgjpLklBXbIi F88PbX6Ng9RGpNULJG0Di41g/h96xnW8SdKHXuE0SEK9UhDrndVI88hMiQG1grPM6WOe VLsEeKBsm/ek/YhJ6j80B4JYsuhlah2ii3dZWKcUxw7Wr2EXpnFl2DDTzfCP2J1XnNCZ e/+4hxouPXlyM9uNcqRSP3EZOL9dDnmUIYfjntCfhG/r7q02nFR0SirzFTVkbzZ0BRo8 VOmdM2Yot7jXPM6vQX1Ov5JaY4QPwmh4Wnc5Gy9NB0Oxk87WZcd4ijO6k+Sl4xDwajXj 46Aw== X-Gm-Message-State: AOJu0YzVU7CXolQ7sQulej1ffV0hDjdQMXuFuvXW9dYOQZ6PABnEc2R2 YSNmvi0YEaXkz3fbCEuw5OjSkw== X-Google-Smtp-Source: AGHT+IF2Ncdcg3VdUgyh/hUz1Ls+HI2d8tU/ped852Q4FNjsr/SOJgoNJlUsTHWSZgPySFwwSRrsOA== X-Received: by 2002:a17:90b:3808:b0:283:2805:7c7a with SMTP id mq8-20020a17090b380800b0028328057c7amr12732469pjb.43.1700127324939; Thu, 16 Nov 2023 01:35:24 -0800 (PST) Received: from localhost.localdomain ([101.78.151.194]) by smtp.gmail.com with ESMTPSA id o10-20020a17090aac0a00b00280fcbbe774sm1175214pjq.10.2023.11.16.01.35.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 Nov 2023 01:35:24 -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, allen-kh.cheng@mediatek.com, kuninori.morimoto.gx@renesas.com Cc: linux-sound@vger.kernel.org, linux-mediatek@lists.infradead.org, Rui Zhou Subject: [PATCH v7 2/4] ASoC: mediatek: mt8188-mt6359: commonize headset codec init/exit api Date: Thu, 16 Nov 2023 17:35:10 +0800 Message-Id: <20231116093512.4180240-3-zhourui@huaqin.corp-partner.google.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20231116093512.4180240-1-zhourui@huaqin.corp-partner.google.com> References: <20231116093512.4180240-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-20231116_013532_472458_734D1AEA X-CRM114-Status: GOOD ( 10.01 ) 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 Reviewed-by: Trevor Wu --- 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 Thu Nov 16 09:35:11 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rui Zhou X-Patchwork-Id: 13457728 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 47A14C5AD4C for ; Thu, 16 Nov 2023 09:35:37 +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=x+hGv37gCiC4Wt9k7p83b6rMFwUkB8NUy7FGC7+01Ao=; b=GuIZYadhQ9MFR404E4xgGxhW5P rRxwRFiR4SzMFMGKvnv3Va6pRUORwB5hUO5eNYlO1LpdOWPI1XMerHVaDzyAp+/hLWXFBS9LkU143 HD69MuGNPJwNY1mAOfOJhb8aMihniPkdNyAVWxUzWklsuSFN0KHOD0NjNxfkUrUy0z5itdZM/DZWB Y1Zibrq6cCF7l4H4WdoV334dZ4vSoesR4NOXTQCv9RUcBBlYC4BpkkAHPeQS4EtRqAFPeQUps6kYW rccOL+0NXtYqq9UIW7frtzvkbc2t7zhdHtnUckhetWMEe0TkwAlHcxUpGP8AiZ9EkBVKlN2vC5CJx oRMMSysQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1r3Yme-002zBd-02; Thu, 16 Nov 2023 09:35:36 +0000 Received: from mail-pj1-x102a.google.com ([2607:f8b0:4864:20::102a]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1r3Yma-002z8D-1O for linux-mediatek@lists.infradead.org; Thu, 16 Nov 2023 09:35:33 +0000 Received: by mail-pj1-x102a.google.com with SMTP id 98e67ed59e1d1-28035cf6a30so441651a91.3 for ; Thu, 16 Nov 2023 01:35:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=huaqin-corp-partner-google-com.20230601.gappssmtp.com; s=20230601; t=1700127328; x=1700732128; 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=x+hGv37gCiC4Wt9k7p83b6rMFwUkB8NUy7FGC7+01Ao=; b=yJFH6fb0uRir34UAwk6moO3/0Qv7P0Kj2UAG13VSiBZYH27o4Wx9/NjZoRdHk7LDmt /McyM5khTViufuNTTvKUILUQuomEJZ1EXDtstEU9jnxYYbJopTBqNn+KDvEXv3HEVA/C 9GL7WJex4gPvUwlUV/UnDwJQJTSOv/PZJjWrfjIFuYYl3VUggbujjLiLC52oGEmZgxb8 0Wxa5L5HTFXldEkMhrN1xR2Pq7+mS/RMjCiHzY1kCsNt5Xe0d8sDEs9nBqUki/LcJ651 zIYtiCVB2KmLJROSEsGoeJBHi0JSkRAEekLcxG+ecuCkC4c/xaveiUQTkXJPCRRBdVoM ofMQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700127328; x=1700732128; 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=x+hGv37gCiC4Wt9k7p83b6rMFwUkB8NUy7FGC7+01Ao=; b=jO+y0gRbUtb87ohttn6UrggXgg2WASPhCsCM6XcfnVz4RFFWmUHVTkMYmPryciK3sT nsJkwp73lGpFNuTTfXXfSIS21JyTv8L5RJzvo3//svGtTLPxxs28tYcWBEP1mWnzyuiB sOGEI+qAe5bjFNtiocvwErCODGhCBZ307sH29Hhsm0I8gqf7dx5FThpAU9M5RKSVVOBr oVkKeETSvLnOV2EzGZiwWPpLXF81yoNzoNORIxer8btxwnDH+er6qt+gC2pwNbyIUMI6 GY921bpqF5XfHTyo/ZXKRCDLlDJVFdIRqdaqYJo8KKtsC3FtBa2MT4IATuQuwB+OMDxi G+dw== X-Gm-Message-State: AOJu0YxWQPnlndS5+WyUB/JKqH2Xb2sf4gPxvpvrHGSmatfcpklgwZi+ wedYLo5Uu9SioX6NxDNg3p/UXQ== X-Google-Smtp-Source: AGHT+IENybR7kmU/GnU0pRVWMaavO1c74Bif8eg5BqsinfwIYbS3g6X9VRdIRjPnuafY4mAG0z1D6A== X-Received: by 2002:a17:90b:1a90:b0:27d:4278:ba53 with SMTP id ng16-20020a17090b1a9000b0027d4278ba53mr14164844pjb.47.1700127328374; Thu, 16 Nov 2023 01:35:28 -0800 (PST) Received: from localhost.localdomain ([101.78.151.194]) by smtp.gmail.com with ESMTPSA id o10-20020a17090aac0a00b00280fcbbe774sm1175214pjq.10.2023.11.16.01.35.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 Nov 2023 01:35:27 -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, allen-kh.cheng@mediatek.com, kuninori.morimoto.gx@renesas.com Cc: linux-sound@vger.kernel.org, linux-mediatek@lists.infradead.org, Rui Zhou Subject: [PATCH v7 3/4] ASoC: mediatek: mt8188-mt6359: add es8326 support Date: Thu, 16 Nov 2023 17:35:11 +0800 Message-Id: <20231116093512.4180240-4-zhourui@huaqin.corp-partner.google.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20231116093512.4180240-1-zhourui@huaqin.corp-partner.google.com> References: <20231116093512.4180240-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-20231116_013532_471309_3A84A7D7 X-CRM114-Status: GOOD ( 19.97 ) 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. Signed-off-by: Rui Zhou Reviewed-by: Trevor Wu --- sound/soc/mediatek/Kconfig | 1 + sound/soc/mediatek/mt8188/mt8188-mt6359.c | 49 ++++++++++++++++++++++- 2 files changed, 49 insertions(+), 1 deletion(-) 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..96c39f4e4b70 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] = { @@ -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 Thu Nov 16 09:35:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rui Zhou X-Patchwork-Id: 13457729 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 025B3C197A0 for ; Thu, 16 Nov 2023 09:35:39 +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=gm1vhROaHDruTkjEkYQ+e3YE5nLctFy09vafq9HP69k=; b=OE07+FiMzvyYrjccVBd63oogoE mLAuHqB/ap/lMKTVZTMeO+7Hi64oSe7AvB+4KX/eOWlTwQ5mWeGauPJ8xkLdePlV6oyc9LxXhsk0C nWZYZtbCh1tYem6wqHTfqI+W3gT2cRBs/fHCANpz8zMSeVfUG10ahEL7TASFOH2bxUG21NuMqiA50 gyP4mLbJkYXzg1RlLoov0b2tlqLZItEJHC3eE0owbPS9AeMy6MUlJtWcl0y88Xnje2E6x5qrNAkIY DZonBUqyfNhtG/quMelB3/SriuYo/B6Vt3sNsUuXgX7LGjnfhd311E0itb7lVKR5MvPeFAK8fuGVg zQdAyGPg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1r3Ymg-002zDM-2Y; Thu, 16 Nov 2023 09:35:38 +0000 Received: from mail-pj1-x102c.google.com ([2607:f8b0:4864:20::102c]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1r3Ymd-002z9I-0S for linux-mediatek@lists.infradead.org; Thu, 16 Nov 2023 09:35:36 +0000 Received: by mail-pj1-x102c.google.com with SMTP id 98e67ed59e1d1-28019b66ad5so442715a91.3 for ; Thu, 16 Nov 2023 01:35:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=huaqin-corp-partner-google-com.20230601.gappssmtp.com; s=20230601; t=1700127332; x=1700732132; 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=gm1vhROaHDruTkjEkYQ+e3YE5nLctFy09vafq9HP69k=; b=wpaYLfkRaxs4iC50UGZEj8N+dRqT169g4uGm5jU1kpt2PSyCBGFMrFd6ZAUSIHgCyK hVKgTFWfTSHXCoidMZWKCUxe/ZRCuWwXsdLckA4K5hYqomxGoeVOeFBuyz8hN7J9p4+W uMitHfO0m7ZEf+802TAuQYu3zzNLmQ1L+LPKHiQTKjM/N2o9zTCUtFcDhxyVNCiiJUhZ nlInKkxKbSLqXo/RPeFoLM6pSxq7dqx8q0EENABhOooMrEFy2QXHAWLdQFK18UYUqsAn Lcl3D+TW03iRok43rmycj8iETIdVZ2OcgI5B+o0g2ihZoKWIggAxW+MGRknUYiQRf++l wWnA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700127332; x=1700732132; 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=gm1vhROaHDruTkjEkYQ+e3YE5nLctFy09vafq9HP69k=; b=ICJO42DjH4hWilHp1zKA/5k6i1RrRxZPdGn6mfDhaSgtTMFplEMBXiTzN7M+tNgzM7 /sccXDnAxnrfoI3jVe+7A/RxR1tS6KGz6ftUlhaqzW/GzualnYCscjblVDanBmnZAP18 LJfzNpwg74KOTzI5GaPghY++xHE+VKf9EHfJnJjxHMz0zzk3oDVlQh6mGlMzLT+J4Tr6 dvsR4vH6iRcr4mi2ChJR7ZAsV7xL6g6JIqkxlzvL+OTcf4OxcwWy1XzkGnd5g+ht5WWe 3sU2JL3rnfQsKpEUBmA8Qqa25sNWQuA77gaosxgc5kemOPGjfUgkY/nASThrZVGa6zcF JxeQ== X-Gm-Message-State: AOJu0YxsPYhPaCAzZWQQyQ/s3PWGzYNiBFVSQNVp3D5w5hgBsqq1jzs3 ds25N3nlCaq/5vT8rpHo88/7Ig== X-Google-Smtp-Source: AGHT+IGG52IxZ72bRX48Su6eFunewmHAUv8tQuSJkhkYUETijVCXzx/LbhHhz8lhyxR3r0JnhWcSlg== X-Received: by 2002:a17:90b:1c0c:b0:27f:fce3:2266 with SMTP id oc12-20020a17090b1c0c00b0027ffce32266mr15213758pjb.24.1700127331753; Thu, 16 Nov 2023 01:35:31 -0800 (PST) Received: from localhost.localdomain ([101.78.151.194]) by smtp.gmail.com with ESMTPSA id o10-20020a17090aac0a00b00280fcbbe774sm1175214pjq.10.2023.11.16.01.35.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 Nov 2023 01:35:31 -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, allen-kh.cheng@mediatek.com, kuninori.morimoto.gx@renesas.com Cc: linux-sound@vger.kernel.org, linux-mediatek@lists.infradead.org, Rui Zhou Subject: [PATCH v7 4/4] ASoC: mediatek: mt8188-mt6359: Enable dual amp for mt8188-rt5682s Date: Thu, 16 Nov 2023 17:35:12 +0800 Message-Id: <20231116093512.4180240-5-zhourui@huaqin.corp-partner.google.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20231116093512.4180240-1-zhourui@huaqin.corp-partner.google.com> References: <20231116093512.4180240-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-20231116_013535_181722_141F9656 X-CRM114-Status: GOOD ( 10.92 ) 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: AngeloGioacchino Del Regno Signed-off-by: Rui Zhou Reviewed-by: Trevor Wu --- 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 96c39f4e4b70..be450292f351 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 = {