From patchwork Wed Mar 13 11:01:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AngeloGioacchino Del Regno X-Patchwork-Id: 780073 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 alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (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 572F2C54E58 for ; Wed, 13 Mar 2024 11:03:12 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 67D4514E7; Wed, 13 Mar 2024 12:03:00 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 67D4514E7 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1710327790; bh=Df+G1jujSAuxTjxGz/6YCYog9gmMwQR5emVptlMkfXY=; h=From:To:Cc:Subject:Date:List-Id:List-Archive:List-Help:List-Owner: List-Post:List-Subscribe:List-Unsubscribe:From; b=kRBA1DlaKWfG/KvzFA2K1gCJRLYE9a/WagZjWz46y/6dHzX2QRFShLINWFwgJrOT4 vtiCzqEyi0qwLWDzPGUKx1a6BOfGLCAU+1+n4bV6lw8HFsuZsmJU3FPRxnuwkkYTTL JcW/tj6SJzJzE7K1TcRHWf2Sryw/nPFB1TyfON/U= Received: by alsa1.perex.cz (Postfix, from userid 50401) id 067A8F805E1; Wed, 13 Mar 2024 12:02:28 +0100 (CET) Received: from mailman-core.alsa-project.org (mailman-core.alsa-project.org [10.254.200.10]) by alsa1.perex.cz (Postfix) with ESMTP id 84B5BF805E1; Wed, 13 Mar 2024 12:02:27 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 312BBF805BB; Wed, 13 Mar 2024 12:02:22 +0100 (CET) Received: from madrid.collaboradmins.com (madrid.collaboradmins.com [IPv6:2a00:1098:ed:100::25]) (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) by alsa1.perex.cz (Postfix) with ESMTPS id DB5E6F8014B for ; Wed, 13 Mar 2024 12:01:59 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz DB5E6F8014B Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key, unprotected) header.d=collabora.com header.i=@collabora.com header.a=rsa-sha256 header.s=mail header.b=yUVc4e7G DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1710327717; bh=Df+G1jujSAuxTjxGz/6YCYog9gmMwQR5emVptlMkfXY=; h=From:To:Cc:Subject:Date:From; b=yUVc4e7GxmrOg6JxeC26bSNUhQ8k0nC2G8vL9ADPy+DO5DPP+dBoQBwJ+ttxkXYWr aCkWjmIMZMfDp4SClGm/ChwXTQsqsNcWr+S45d16b8QBvI114i6/xcn3q55P8yyrgO oaYoh1C3tUv9UiL2Ls8/mna1Gfqi75KJkJPZt03O8wwGXejpXcX8huA6QSYnsbimLu IzFt5RDkarJf3dWrf9pcD3PJfDn/W7hOO+W3CgZFuHb7rztmpwzrnd6f/V3sLlymfl UOeA5p6nr6pdnl009XRAttvmRxy0Z133K0zT/1c4P3JRA72mdjRqbAywvK//o3z3e/ 09uXmIKpdEKHQ== Received: from IcarusMOD.eternityproject.eu (cola.collaboradmins.com [195.201.22.229]) (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: kholk11) by madrid.collaboradmins.com (Postfix) with ESMTPSA id 40E8F37810CD; Wed, 13 Mar 2024 11:01:55 +0000 (UTC) From: AngeloGioacchino Del Regno To: broonie@kernel.org Cc: wenst@chromium.org, lgirdwood@gmail.com, robh@kernel.org, krzysztof.kozlowski+dt@linaro.org, conor+dt@kernel.org, matthias.bgg@gmail.com, perex@perex.cz, tiwai@suse.com, trevor.wu@mediatek.com, maso.huang@mediatek.com, xiazhengqiao@huaqin.corp-partner.google.com, arnd@arndb.de, kuninori.morimoto.gx@renesas.com, shraash@google.com, amergnat@baylibre.com, nicolas.ferre@microchip.com, u.kleine-koenig@pengutronix.de, dianders@chromium.org, frank.li@vivo.com, allen-kh.cheng@mediatek.com, eugen.hristev@collabora.com, claudiu.beznea@tuxon.dev, jarkko.nikula@bitmer.com, jiaxin.yu@mediatek.com, alpernebiyasak@gmail.com, ckeepax@opensource.cirrus.com, zhourui@huaqin.corp-partner.google.com, nfraprado@collabora.com, alsa-devel@alsa-project.org, shane.chien@mediatek.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, kernel@collabora.com, AngeloGioacchino Del Regno Subject: [PATCH v3 00/22] SoC: Cleanup MediaTek soundcard machine drivers Date: Wed, 13 Mar 2024 12:01:25 +0100 Message-ID: <20240313110147.1267793-1-angelogioacchino.delregno@collabora.com> X-Mailer: git-send-email 2.44.0 MIME-Version: 1.0 Message-ID-Hash: DVQ7FWSN7TZCALXJL3EIPKTSRMSZPSHC X-Message-ID-Hash: DVQ7FWSN7TZCALXJL3EIPKTSRMSZPSHC X-MailFrom: angelogioacchino.delregno@collabora.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-alsa-devel.alsa-project.org-0; header-match-alsa-devel.alsa-project.org-1; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.9 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Changes in v3: - Added audio-routing names in enum in all yaml files - Added mention of disallowing old and new properties together in commit message of bindings patches - Fixed validation errors with sound-card-common.yaml inclusion due to missing model property in examples - Removed `else` enforcing headset-codec/speaker-codecs requirement if xxx-dai-link not present to avoid future commit noise as the deprecated statement will disallow deprecated properties as required Changes in v2: - Bindings: Changed link-name/codec/clk-provider to remove `items` and leave just the enum - Moved .*-dai-link pattern additionalProperties after `type: object` - Added ref to sound-card-common.yaml - Fixed dai-link-xxx -> xxx-dai-link typo in example comment This series performs a cleanup of most of the MediaTek AFE drivers and soundcard machine drivers, reducing code duplication and setting a base to be consistent with their devicetree bindings, as many of those are using different properties and nodes for no good reason. Summarizing: - Commonizes functions and ops where possible - Adds a common probe mechanism, increasing maintainability of soundcard drivers for older MediaTek SoCs - Migrates all drivers to support the new bindings - Obviously retains compatibility with old device trees - Reduces machine-specific parameters hardcoding in drivers - Can now set machine-specific params in device tree - Uses the `audio-routing` and `dai-link` nodes like some other non-MediaTek SoC sound drivers - Imposes consistency between MediaTek ASoC machine soundcard drivers bindings - Reduces code size and greatly reduces the amount of code that will be required for newer drivers (retaining compatibility with the old bindings was costly in terms of code size, otherwise this series would've removed ~1000 more lines, or something along that line). This series was (manually) tested on MT8173, MT8192, MT8195 and MT8186 Chromebooks. AngeloGioacchino Del Regno (22): ASoC: mediatek: mt8192-afe-pcm: Convert to devm_pm_runtime_enable() ASoC: mediatek: mt8192-afe-pcm: Simplify with dev_err_probe() ASoC: mediatek: Commonize ADDA rate transform functions and enums ASoC: mediatek: Assign dummy when codec not specified for a DAI link ASoC: mediatek: Add common machine soundcard driver probe mechanism ASoC: mediatek: common: Constify struct mtk_sof_priv ASoC: mediatek: mt8188: Migrate to mtk_soundcard_common_probe ASoC: mediatek: mt8195: Migrate to mtk_soundcard_common_probe ASoC: mediatek: mt8192: Migrate to mtk_soundcard_common_probe ASoC: mediatek: mt8186: Migrate to mtk_soundcard_common_probe ASoC: mediatek: Add common snd_soc_ops .startup() callback ASoC: mediatek: mt8195: Migrate to the common mtk_soundcard_startup ASoC: mediatek: mt8192: Migrate to the common mtk_soundcard_startup ASoC: mediatek: mt8186-rt1019: Migrate to the common mtk_soundcard_startup ASoC: mediatek: Add common mtk_afe_component_probe callback ASoC: mediatek: Use common mtk_afe_pcm_platform with common probe cb ASoC: mediatek: mt8186: Unify mt8186-mt6366 machine drivers ASoC: dt-bindings: mt8195: Document audio-routing and dai-link subnode ASoC: dt-bindings: mt8192: Document audio-routing and dai-link subnode ASoC: dt-bindings: mt8186: Document audio-routing and dai-link subnode arm64: dts: mediatek: mt8195-cherry: Specify sound DAI links and routing arm64: dts: mediatek: mt8186-corsola: Specify sound DAI links and routing .../sound/mt8186-mt6366-da7219-max98357.yaml | 131 +- .../sound/mt8186-mt6366-rt1019-rt5682s.yaml | 120 +- .../sound/mt8192-mt6359-rt1015-rt5682.yaml | 139 +- .../bindings/sound/mt8195-mt6359.yaml | 134 ++ .../boot/dts/mediatek/mt8186-corsola.dtsi | 42 +- .../boot/dts/mediatek/mt8195-cherry.dtsi | 45 + sound/soc/mediatek/Kconfig | 24 +- sound/soc/mediatek/common/Makefile | 2 + .../mediatek/common/mtk-afe-platform-driver.c | 18 + .../soc/mediatek/common/mtk-dai-adda-common.c | 70 + .../soc/mediatek/common/mtk-dai-adda-common.h | 45 + .../soc/mediatek/common/mtk-dsp-sof-common.c | 15 +- .../soc/mediatek/common/mtk-dsp-sof-common.h | 1 - sound/soc/mediatek/common/mtk-soc-card.h | 7 +- .../mediatek/common/mtk-soundcard-driver.c | 205 ++- .../mediatek/common/mtk-soundcard-driver.h | 42 + sound/soc/mediatek/mt6797/mt6797-afe-pcm.c | 14 +- sound/soc/mediatek/mt6797/mt6797-dai-adda.c | 85 +- sound/soc/mediatek/mt7986/mt7986-afe-pcm.c | 14 +- sound/soc/mediatek/mt8183/mt8183-afe-pcm.c | 14 +- sound/soc/mediatek/mt8183/mt8183-dai-adda.c | 90 +- sound/soc/mediatek/mt8186/Makefile | 3 +- sound/soc/mediatek/mt8186/mt8186-afe-pcm.c | 19 +- sound/soc/mediatek/mt8186/mt8186-dai-adda.c | 94 +- .../mt8186/mt8186-mt6366-da7219-max98357.c | 1189 ----------------- ...t6366-rt1019-rt5682s.c => mt8186-mt6366.c} | 578 ++++---- sound/soc/mediatek/mt8188/mt8188-afe-pcm.c | 21 +- sound/soc/mediatek/mt8188/mt8188-dai-adda.c | 89 +- sound/soc/mediatek/mt8188/mt8188-mt6359.c | 203 +-- sound/soc/mediatek/mt8192/mt8192-afe-pcm.c | 114 +- sound/soc/mediatek/mt8192/mt8192-dai-adda.c | 90 +- .../mt8192/mt8192-mt6359-rt1015-rt5682.c | 301 ++--- sound/soc/mediatek/mt8195/mt8195-afe-pcm.c | 21 +- sound/soc/mediatek/mt8195/mt8195-dai-adda.c | 90 +- sound/soc/mediatek/mt8195/mt8195-mt6359.c | 487 +++---- 35 files changed, 1781 insertions(+), 2775 deletions(-) create mode 100644 sound/soc/mediatek/common/mtk-dai-adda-common.c create mode 100644 sound/soc/mediatek/common/mtk-dai-adda-common.h delete mode 100644 sound/soc/mediatek/mt8186/mt8186-mt6366-da7219-max98357.c rename sound/soc/mediatek/mt8186/{mt8186-mt6366-rt1019-rt5682s.c => mt8186-mt6366.c} (72%)