From nobody Thu Nov 14 04:44:10 2024 Received: from madrid.collaboradmins.com (madrid.collaboradmins.com [46.235.227.194]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C737512E1EA; Tue, 9 Apr 2024 11:33:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=46.235.227.194 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712662416; cv=none; b=gTu/Bg8HHYQVQTNe7bd0fRSFnnYa2Ajgwjrm4vMWpHiQNaRMLi4A+3SHEBe0XvXYs1TPeC5DL8X5cy/K6joJMDZ5T0uAW+N/LE+3LAEMy0ogZQzOcfAlVGyE9qgtfcPBel1Mw+jiOzMeasoTZ95K04CuGVpvmzNt7UWmcG//I4o= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712662416; c=relaxed/simple; bh=G/DuFDqnI1SUE8CT6Ts6k0MPSX/alAT/PmcBUch4tLM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=FnDw60cZ0MwTz217ftd+UJgC8ommF4h5DZy6fY7a0r2oSWGqbcc/wdxsGohnc3fJboVtrx1acm8YrUm3ezpaHWlXNe3t0TCohRCqIffmE8mSYPTWkpuwGNkrakSw/nifDmBmMYO+jefrRkuD6Pk3Tpln7UTgGJUE3T3U1kcNnCI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=collabora.com; spf=pass smtp.mailfrom=collabora.com; dkim=pass (2048-bit key) header.d=collabora.com header.i=@collabora.com header.b=ERjXqIDZ; arc=none smtp.client-ip=46.235.227.194 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=collabora.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=collabora.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=collabora.com header.i=@collabora.com header.b="ERjXqIDZ" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1712662412; bh=G/DuFDqnI1SUE8CT6Ts6k0MPSX/alAT/PmcBUch4tLM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ERjXqIDZKTky1IpsxIG4YbwTpsEQ91Fwreq3RDfWsQCiVwpjFoGRGu07tdDZqUI46 yrCPfPctlLubrpmfhZx+oEgx5YFlKztzG0Lrv4Nowq4Ay4DkoJskkupBFlDAsJSjRw WhiXara9J2UIcZ6wwRPvR7D2No8AtMfGwn0JD3DTLS1b+GgTs3H1r+N1/5KOZO9rl3 xNerHo38KF2yALY3rc6OE8brqYfRvi7DzG2FG9mvsuwq2NGwNkbRrUEbY0ble/wyF8 yXDid1GTXZw9RrZE7KRwD+6cCkZbARMQViB8QLs+KFG6R+OLzI98uupvgHgH5QeB33 xZYrlTDrMxalQ== 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 AE21B37820F8; Tue, 9 Apr 2024 11:33:30 +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 v4 01/18] ASoC: mediatek: Add common machine soundcard driver probe mechanism Date: Tue, 9 Apr 2024 13:32:53 +0200 Message-ID: <20240409113310.303261-2-angelogioacchino.delregno@collabora.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240409113310.303261-1-angelogioacchino.delregno@collabora.com> References: <20240409113310.303261-1-angelogioacchino.delregno@collabora.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Add a common machine soundcard driver probe function that supports both DSP and AFE-direct usecases and also provides a hook for legacy machine soundcard driver probe mechanisms. Note that the hook is there because, even for legacy probe, a lot of the actual code can still be commonized, hence still reducing duplication for the legacy devicetree retrocompatibility cases. This common probe function deprecates all of the inconsistent previous probe mechanisms and aims to settle all of the MediaTek card drivers on consistent and common devicetree properties describing wanted DAIs, device specific DAI configuration and DAI links to codecs found on each device/board. Signed-off-by: AngeloGioacchino Del Regno Reviewed-by: Alexandre Mergnat --- sound/soc/mediatek/common/mtk-soc-card.h | 7 +- .../mediatek/common/mtk-soundcard-driver.c | 148 ++++++++++++++++++ .../mediatek/common/mtk-soundcard-driver.h | 18 +++ 3 files changed, 172 insertions(+), 1 deletion(-) diff --git a/sound/soc/mediatek/common/mtk-soc-card.h b/sound/soc/mediatek/= common/mtk-soc-card.h index eeda79370049..d92dc36d4577 100644 --- a/sound/soc/mediatek/common/mtk-soc-card.h +++ b/sound/soc/mediatek/common/mtk-soc-card.h @@ -9,9 +9,14 @@ #ifndef _MTK_SOC_CARD_H_ #define _MTK_SOC_CARD_H_ =20 +struct mtk_platform_card_data; +struct mtk_sof_priv; + struct mtk_soc_card_data { + struct mtk_sof_priv *sof_priv; + struct list_head sof_dai_link_list; + struct mtk_platform_card_data *card_data; void *mach_priv; - void *sof_priv; }; =20 #endif diff --git a/sound/soc/mediatek/common/mtk-soundcard-driver.c b/sound/soc/m= ediatek/common/mtk-soundcard-driver.c index 000a086a8cf4..b1db17e392d5 100644 --- a/sound/soc/mediatek/common/mtk-soundcard-driver.c +++ b/sound/soc/mediatek/common/mtk-soundcard-driver.c @@ -10,6 +10,8 @@ #include #include =20 +#include "mtk-dsp-sof-common.h" +#include "mtk-soc-card.h" #include "mtk-soundcard-driver.h" =20 static int set_card_codec_info(struct snd_soc_card *card, @@ -136,3 +138,149 @@ void clean_card_reference(struct snd_soc_card *card) snd_soc_of_put_dai_link_codecs(dai_link); } EXPORT_SYMBOL_GPL(clean_card_reference); + +int mtk_soundcard_common_probe(struct platform_device *pdev) +{ + struct device_node *platform_node, *adsp_node; + const struct mtk_soundcard_pdata *pdata; + struct mtk_soc_card_data *soc_card_data; + struct snd_soc_dai_link *orig_dai_link, *dai_link; + struct snd_soc_jack *jacks; + struct snd_soc_card *card; + int i, orig_num_links, ret; + bool needs_legacy_probe; + + pdata =3D device_get_match_data(&pdev->dev); + if (!pdata) + return -EINVAL; + + card =3D pdata->card_data->card; + card->dev =3D &pdev->dev; + orig_dai_link =3D card->dai_link; + orig_num_links =3D card->num_links; + + ret =3D snd_soc_of_parse_card_name(card, "model"); + if (ret) + return ret; + + if (!card->name) { + if (!pdata->card_name) + return -EINVAL; + + card->name =3D pdata->card_name; + } + + needs_legacy_probe =3D !of_property_read_bool(pdev->dev.of_node, "audio-r= outing"); + if (needs_legacy_probe) { + /* + * If we have no .soc_probe() callback there's no way of using + * any legacy probe mechanism, as that cannot not be generic. + */ + if (!pdata->soc_probe) + return -EINVAL; + + dev_info_once(&pdev->dev, "audio-routing not found: using legacy probe\n= "); + } else { + ret =3D snd_soc_of_parse_audio_routing(card, "audio-routing"); + if (ret) + return ret; + } + + soc_card_data =3D devm_kzalloc(&pdev->dev, sizeof(*soc_card_data), GFP_KE= RNEL); + if (!soc_card_data) + return -ENOMEM; + + soc_card_data->card_data =3D pdata->card_data; + + jacks =3D devm_kcalloc(card->dev, soc_card_data->card_data->num_jacks, + sizeof(*jacks), GFP_KERNEL); + if (!jacks) + return -ENOMEM; + + soc_card_data->card_data->jacks =3D jacks; + + platform_node =3D of_parse_phandle(pdev->dev.of_node, "mediatek,platform"= , 0); + if (!platform_node) + return dev_err_probe(&pdev->dev, -EINVAL, + "Property mediatek,platform missing or invalid\n"); + + /* Check if this SoC has an Audio DSP */ + if (pdata->sof_priv) + adsp_node =3D of_parse_phandle(pdev->dev.of_node, "mediatek,adsp", 0); + else + adsp_node =3D NULL; + + if (adsp_node) { + if (of_property_read_bool(pdev->dev.of_node, "mediatek,dai-link")) { + ret =3D mtk_sof_dailink_parse_of(card, pdev->dev.of_node, + "mediatek,dai-link", + card->dai_link, card->num_links); + if (ret) { + of_node_put(adsp_node); + of_node_put(platform_node); + return dev_err_probe(&pdev->dev, ret, + "Cannot parse mediatek,dai-link\n"); + } + } + + soc_card_data->sof_priv =3D pdata->sof_priv; + card->probe =3D mtk_sof_card_probe; + card->late_probe =3D mtk_sof_card_late_probe; + if (!card->topology_shortname_created) { + snprintf(card->topology_shortname, 32, "sof-%s", card->name); + card->topology_shortname_created =3D true; + } + card->name =3D card->topology_shortname; + } + + /* + * Regardless of whether the ADSP is wanted and/or present in a machine + * specific device tree or not and regardless of whether any AFE_SOF + * link is present, we have to make sure that the platforms->of_node + * is not NULL, and set to either ADSP (adsp_node) or AFE (platform_node). + */ + for_each_card_prelinks(card, i, dai_link) { + if (adsp_node && !strncmp(dai_link->name, "AFE_SOF", strlen("AFE_SOF"))) + dai_link->platforms->of_node =3D adsp_node; + else if (!dai_link->platforms->name && !dai_link->platforms->of_node) + dai_link->platforms->of_node =3D platform_node; + } + + if (!needs_legacy_probe) { + ret =3D parse_dai_link_info(card); + if (ret) + goto err_restore_dais; + } else { + if (adsp_node) + of_node_put(adsp_node); + of_node_put(platform_node); + } + + if (pdata->soc_probe) { + ret =3D pdata->soc_probe(soc_card_data, needs_legacy_probe); + if (ret) { + if (!needs_legacy_probe) + clean_card_reference(card); + goto err_restore_dais; + } + } + snd_soc_card_set_drvdata(card, soc_card_data); + + ret =3D devm_snd_soc_register_card(&pdev->dev, card); + + if (!needs_legacy_probe) + clean_card_reference(card); + + if (ret) { + dev_err_probe(&pdev->dev, ret, "Cannot register card\n"); + goto err_restore_dais; + } + + return 0; + +err_restore_dais: + card->dai_link =3D orig_dai_link; + card->num_links =3D orig_num_links; + return ret; +} +EXPORT_SYMBOL_GPL(mtk_soundcard_common_probe); diff --git a/sound/soc/mediatek/common/mtk-soundcard-driver.h b/sound/soc/m= ediatek/common/mtk-soundcard-driver.h index d92cac1d7b72..44320efff5f8 100644 --- a/sound/soc/mediatek/common/mtk-soundcard-driver.h +++ b/sound/soc/mediatek/common/mtk-soundcard-driver.h @@ -9,6 +9,24 @@ #ifndef _MTK_SOUNDCARD_DRIVER_H_ #define _MTK_SOUNDCARD_DRIVER_H_ =20 +struct mtk_sof_priv; +struct mtk_soc_card_data; + +struct mtk_platform_card_data { + struct snd_soc_card *card; + struct snd_soc_jack *jacks; + u8 num_jacks; + u8 flags; +}; + +struct mtk_soundcard_pdata { + const char *card_name; + struct mtk_platform_card_data *card_data; + struct mtk_sof_priv *sof_priv; + int (*soc_probe)(struct mtk_soc_card_data *card_data, bool legacy); +}; + int parse_dai_link_info(struct snd_soc_card *card); void clean_card_reference(struct snd_soc_card *card); +int mtk_soundcard_common_probe(struct platform_device *pdev); #endif --=20 2.44.0 From nobody Thu Nov 14 04:44:10 2024 Received: from madrid.collaboradmins.com (madrid.collaboradmins.com [46.235.227.194]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D4E9512EBD3; Tue, 9 Apr 2024 11:33:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=46.235.227.194 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712662418; cv=none; b=Ny4btDhH98PL17zyGtSkBqjd8jHQ4tcxiYFUjjtOS70/IrY1pnWokme3DTNGB0cQb/ug38GIpdvvgIcZApEkGmJ9XWNmg5mjsQOvY1HuSPkDTklnSCvIxm8R4+iqpdHRxxxRlpJEHJFH8CTPrYV3ATHT/08ADIvbmPpWiznpMec= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712662418; c=relaxed/simple; bh=j6MGyfhFtjGyDqUgU4egNnPSUCHahfCyH58URzE5d6k=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Kg9/KygHfCSLXVzuvdEL5arxubJGurZQWuNDJ87+AVN00MKer2yJwHIsOhD2dog9caVParN/UGxvQaSnyiDHDMVp7AtEh4pN4Fz3Xl7Z0hOsSZseYP+2i7FRQIijPReFu2wHs3vy/EPHzfzRhw6QMslxfQkf38YR3CHuC9jQzoc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=collabora.com; spf=pass smtp.mailfrom=collabora.com; dkim=pass (2048-bit key) header.d=collabora.com header.i=@collabora.com header.b=kbSkjq0b; arc=none smtp.client-ip=46.235.227.194 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=collabora.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=collabora.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=collabora.com header.i=@collabora.com header.b="kbSkjq0b" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1712662415; bh=j6MGyfhFtjGyDqUgU4egNnPSUCHahfCyH58URzE5d6k=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kbSkjq0bhHZ5/2D711Bg0hWWYj1YYClylI1MCY1k1iVQVw6wpbUlcq4jfw796f3Zs 1JaIZX+URjEZ/xbquS1ik7EyPxDxHUaJfv+rYNl+hpU2Rz+Xob38ThKDCul7U0Cdnq mikYM7sQiOKUls8v9T1QPTTHNgtTpMk6qgqGIVvey8YIALgOIOn7q4a3JzY62P8zNX PoHlAHdqhIACtfTIvaNM5KgmM1/PZXCt3bJMQu8108UIQxn1bVKvx23OciNCpuVM3c OxbU4kS/X7UVic1716QtVxBpk4rzP+j2vi1/a448iAUswZcJ+dsRcfE0KQXHQnlPGg X7vPGlGvMYo5w== 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 148C13782111; Tue, 9 Apr 2024 11:33:33 +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 v4 02/18] ASoC: mediatek: common: Constify struct mtk_sof_priv Date: Tue, 9 Apr 2024 13:32:54 +0200 Message-ID: <20240409113310.303261-3-angelogioacchino.delregno@collabora.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240409113310.303261-1-angelogioacchino.delregno@collabora.com> References: <20240409113310.303261-1-angelogioacchino.delregno@collabora.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Apart from a dai_link_list variable, the mtk_sof_priv currently holds data that never gets modified during runtime. Constify the mtk_sof_priv structure and move the SOF dai_link_list as sof_dai_link_list in struct mtk_soc_card_data, which is a structure that already holds the card's machine specific, runtime modified data. This allows to safely pass the mtk_sof_priv structure as platform data for the commonized card probe mechanism. Signed-off-by: AngeloGioacchino Del Regno Reviewed-by: Alexandre Mergnat --- sound/soc/mediatek/common/mtk-dsp-sof-common.c | 15 +++++++-------- sound/soc/mediatek/common/mtk-dsp-sof-common.h | 1 - sound/soc/mediatek/common/mtk-soc-card.h | 2 +- sound/soc/mediatek/common/mtk-soundcard-driver.h | 2 +- 4 files changed, 9 insertions(+), 11 deletions(-) diff --git a/sound/soc/mediatek/common/mtk-dsp-sof-common.c b/sound/soc/med= iatek/common/mtk-dsp-sof-common.c index 7ec8965a70c0..bca758dca2c9 100644 --- a/sound/soc/mediatek/common/mtk-dsp-sof-common.c +++ b/sound/soc/mediatek/common/mtk-dsp-sof-common.c @@ -15,7 +15,7 @@ int mtk_sof_dai_link_fixup(struct snd_soc_pcm_runtime *rt= d, { struct snd_soc_card *card =3D rtd->card; struct mtk_soc_card_data *soc_card_data =3D snd_soc_card_get_drvdata(card= ); - struct mtk_sof_priv *sof_priv =3D soc_card_data->sof_priv; + const struct mtk_sof_priv *sof_priv =3D soc_card_data->sof_priv; int i, j, ret =3D 0; =20 for (i =3D 0; i < sof_priv->num_streams; i++) { @@ -55,7 +55,6 @@ int mtk_sof_card_probe(struct snd_soc_card *card) int i; struct snd_soc_dai_link *dai_link; struct mtk_soc_card_data *soc_card_data =3D snd_soc_card_get_drvdata(card= ); - struct mtk_sof_priv *sof_priv =3D soc_card_data->sof_priv; =20 /* Set stream_name to help sof bind widgets */ for_each_card_prelinks(card, i, dai_link) { @@ -63,7 +62,7 @@ int mtk_sof_card_probe(struct snd_soc_card *card) dai_link->stream_name =3D dai_link->name; } =20 - INIT_LIST_HEAD(&sof_priv->dai_link_list); + INIT_LIST_HEAD(&soc_card_data->sof_dai_link_list); =20 return 0; } @@ -73,7 +72,7 @@ static struct snd_soc_pcm_runtime *mtk_sof_find_tplg_be(s= truct snd_soc_pcm_runti { struct snd_soc_card *card =3D rtd->card; struct mtk_soc_card_data *soc_card_data =3D snd_soc_card_get_drvdata(card= ); - struct mtk_sof_priv *sof_priv =3D soc_card_data->sof_priv; + const struct mtk_sof_priv *sof_priv =3D soc_card_data->sof_priv; struct snd_soc_pcm_runtime *fe; struct snd_soc_pcm_runtime *be; struct snd_soc_dpcm *dpcm; @@ -113,7 +112,7 @@ static int mtk_sof_check_tplg_be_dai_link_fixup(struct = snd_soc_pcm_runtime *rtd, { struct snd_soc_card *card =3D rtd->card; struct mtk_soc_card_data *soc_card_data =3D snd_soc_card_get_drvdata(card= ); - struct mtk_sof_priv *sof_priv =3D soc_card_data->sof_priv; + const struct mtk_sof_priv *sof_priv =3D soc_card_data->sof_priv; struct snd_soc_pcm_runtime *sof_be; struct mtk_dai_link *dai_link; int ret =3D 0; @@ -125,7 +124,7 @@ static int mtk_sof_check_tplg_be_dai_link_fixup(struct = snd_soc_pcm_runtime *rtd, else if (sof_be->dai_link->be_hw_params_fixup) ret =3D sof_be->dai_link->be_hw_params_fixup(sof_be, params); } else { - list_for_each_entry(dai_link, &sof_priv->dai_link_list, list) { + list_for_each_entry(dai_link, &soc_card_data->sof_dai_link_list, list) { if (strcmp(dai_link->name, rtd->dai_link->name) =3D=3D 0) { if (dai_link->be_hw_params_fixup) ret =3D dai_link->be_hw_params_fixup(rtd, params); @@ -144,7 +143,7 @@ int mtk_sof_card_late_probe(struct snd_soc_card *card) struct snd_soc_component *sof_comp =3D NULL; struct mtk_soc_card_data *soc_card_data =3D snd_soc_card_get_drvdata(card); - struct mtk_sof_priv *sof_priv =3D soc_card_data->sof_priv; + const struct mtk_sof_priv *sof_priv =3D soc_card_data->sof_priv; struct snd_soc_dai_link *dai_link; struct mtk_dai_link *mtk_dai_link; int i; @@ -173,7 +172,7 @@ int mtk_sof_card_late_probe(struct snd_soc_card *card) mtk_dai_link->be_hw_params_fixup =3D dai_link->be_hw_params_fixup; mtk_dai_link->name =3D dai_link->name; =20 - list_add(&mtk_dai_link->list, &sof_priv->dai_link_list); + list_add(&mtk_dai_link->list, &soc_card_data->sof_dai_link_list); } =20 if (dai_link->no_pcm) diff --git a/sound/soc/mediatek/common/mtk-dsp-sof-common.h b/sound/soc/med= iatek/common/mtk-dsp-sof-common.h index 4bc5e1c0c8ed..8784ee471132 100644 --- a/sound/soc/mediatek/common/mtk-dsp-sof-common.h +++ b/sound/soc/mediatek/common/mtk-dsp-sof-common.h @@ -30,7 +30,6 @@ struct mtk_sof_priv { int num_streams; int (*sof_dai_link_fixup)(struct snd_soc_pcm_runtime *rtd, struct snd_pcm_hw_params *params); - struct list_head dai_link_list; }; =20 int mtk_sof_dai_link_fixup(struct snd_soc_pcm_runtime *rtd, diff --git a/sound/soc/mediatek/common/mtk-soc-card.h b/sound/soc/mediatek/= common/mtk-soc-card.h index d92dc36d4577..3f6e24dd22df 100644 --- a/sound/soc/mediatek/common/mtk-soc-card.h +++ b/sound/soc/mediatek/common/mtk-soc-card.h @@ -13,7 +13,7 @@ struct mtk_platform_card_data; struct mtk_sof_priv; =20 struct mtk_soc_card_data { - struct mtk_sof_priv *sof_priv; + const struct mtk_sof_priv *sof_priv; struct list_head sof_dai_link_list; struct mtk_platform_card_data *card_data; void *mach_priv; diff --git a/sound/soc/mediatek/common/mtk-soundcard-driver.h b/sound/soc/m= ediatek/common/mtk-soundcard-driver.h index 44320efff5f8..4fd2ffb7e486 100644 --- a/sound/soc/mediatek/common/mtk-soundcard-driver.h +++ b/sound/soc/mediatek/common/mtk-soundcard-driver.h @@ -22,7 +22,7 @@ struct mtk_platform_card_data { struct mtk_soundcard_pdata { const char *card_name; struct mtk_platform_card_data *card_data; - struct mtk_sof_priv *sof_priv; + const struct mtk_sof_priv *sof_priv; int (*soc_probe)(struct mtk_soc_card_data *card_data, bool legacy); }; =20 --=20 2.44.0 From nobody Thu Nov 14 04:44:10 2024 Received: from madrid.collaboradmins.com (madrid.collaboradmins.com [46.235.227.194]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5030312F378; Tue, 9 Apr 2024 11:33:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=46.235.227.194 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712662421; cv=none; b=mbuuZyZ6hUHgG0YR0PJTj94fnVZ2ddIiWRlJx9D4migJ+1M6Lh/s9zo1b00UH/omPJXFyCoYDS14kO4Rk+jyusunmnu+jcwT8kBelaJ2rrrj9FSqYFhlgDYxKA6Se4F59hBko0sUV/wAtSL3nJVT4o1P3bMlRcimbnXh71UnYEc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712662421; c=relaxed/simple; bh=B+vp4Uw62xZRdn2O7lnJ5cXiKQOHqoydOc/koaWZkvc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ZPgmE7vIGDpP49pu8ITadPipfuFE2JyzQC2r4elpSt2LDe71wY+BVi4ucC90a1m2Ela48V6zXTNQJhSSo3BswJBjEJKzwz6YFuiDq5+tUf1JdcxRHGNTA9oVTAFw7MCjhcg7yz7O/LhIjTlYVQ11vA0ElBlCTYtjQNPioj+Mc8c= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=collabora.com; spf=pass smtp.mailfrom=collabora.com; dkim=pass (2048-bit key) header.d=collabora.com header.i=@collabora.com header.b=sq1qAra0; arc=none smtp.client-ip=46.235.227.194 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=collabora.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=collabora.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=collabora.com header.i=@collabora.com header.b="sq1qAra0" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1712662417; bh=B+vp4Uw62xZRdn2O7lnJ5cXiKQOHqoydOc/koaWZkvc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=sq1qAra0qY+JzH0Ep4m6ugHAjxfaRIafn8WWO7NSRovFbsFSljY+uzHgqyl07ylF1 q+UR3v545aysfGM4L+ncMPL0lnT4XA/bFNgn8urTDEoiTOGuM1cBZnTgEPQK3ZCxdn bmUGSTTkV64Z35SOk2In1Ycbni3+Zhx5uJbuVW8VM3norRs9nfYg3r0eiVlrMBaani i7NA5cuhm3kgOTzLqIYSpfTHc2DRM4tm4G0wLDM8DtbrSSbXiDtNTzEjMpdh+6LigQ PdiXlUDUX/zp7kudYxe9CICS4Q2bGRUH/G2orI5jIR4CE6WOJ2vpNZsVVmu7vdeext m5y2Z/mUPyIDA== 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 6E658378212C; Tue, 9 Apr 2024 11:33:35 +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 v4 03/18] ASoC: mediatek: mt8188: Migrate to mtk_soundcard_common_probe Date: Tue, 9 Apr 2024 13:32:55 +0200 Message-ID: <20240409113310.303261-4-angelogioacchino.delregno@collabora.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240409113310.303261-1-angelogioacchino.delregno@collabora.com> References: <20240409113310.303261-1-angelogioacchino.delregno@collabora.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Add mtk_soundcard_pdata platform data for the MediaTek common sound card probe mechanism, including a driver/soc-specific probe extension (used for bits that cannot be commonized hence specific to this driver), and change the probe function to mtk_soundcard_common_probe. Signed-off-by: AngeloGioacchino Del Regno Reviewed-by: Alexandre Mergnat --- sound/soc/mediatek/mt8188/mt8188-mt6359.c | 203 +++++++--------------- 1 file changed, 64 insertions(+), 139 deletions(-) diff --git a/sound/soc/mediatek/mt8188/mt8188-mt6359.c b/sound/soc/mediatek= /mt8188/mt8188-mt6359.c index a391066ab204..f629fc6bbb53 100644 --- a/sound/soc/mediatek/mt8188/mt8188-mt6359.c +++ b/sound/soc/mediatek/mt8188/mt8188-mt6359.c @@ -236,11 +236,11 @@ static const struct sof_conn_stream g_sof_conn_stream= s[] =3D { }, }; =20 -struct mt8188_mt6359_priv { - struct snd_soc_jack dp_jack; - struct snd_soc_jack hdmi_jack; - struct snd_soc_jack headset_jack; - void *private_data; +enum mt8188_jacks { + MT8188_JACK_HEADSET, + MT8188_JACK_DP, + MT8188_JACK_HDMI, + MT8188_JACK_MAX, }; =20 static struct snd_soc_jack_pin mt8188_hdmi_jack_pins[] =3D { @@ -268,11 +268,6 @@ static struct snd_soc_jack_pin nau8825_jack_pins[] =3D= { }, }; =20 -struct mt8188_card_data { - const char *name; - unsigned long quirk; -}; - static const struct snd_kcontrol_new mt8188_dumb_spk_controls[] =3D { SOC_DAPM_PIN_SWITCH("Ext Spk"), }; @@ -590,12 +585,12 @@ static int mt8188_dptx_hw_params_fixup(struct snd_soc= _pcm_runtime *rtd, static int mt8188_hdmi_codec_init(struct snd_soc_pcm_runtime *rtd) { struct mtk_soc_card_data *soc_card_data =3D snd_soc_card_get_drvdata(rtd-= >card); - struct mt8188_mt6359_priv *priv =3D soc_card_data->mach_priv; + struct snd_soc_jack *jack =3D &soc_card_data->card_data->jacks[MT8188_JAC= K_HDMI]; struct snd_soc_component *component =3D snd_soc_rtd_to_codec(rtd, 0)->com= ponent; int ret =3D 0; =20 ret =3D snd_soc_card_jack_new_pins(rtd->card, "HDMI Jack", - SND_JACK_LINEOUT, &priv->hdmi_jack, + SND_JACK_LINEOUT, jack, mt8188_hdmi_jack_pins, ARRAY_SIZE(mt8188_hdmi_jack_pins)); if (ret) { @@ -603,7 +598,7 @@ static int mt8188_hdmi_codec_init(struct snd_soc_pcm_ru= ntime *rtd) return ret; } =20 - ret =3D snd_soc_component_set_jack(component, &priv->hdmi_jack, NULL); + ret =3D snd_soc_component_set_jack(component, jack, NULL); if (ret) { dev_err(rtd->dev, "%s, set jack failed on %s (ret=3D%d)\n", __func__, component->name, ret); @@ -616,19 +611,19 @@ static int mt8188_hdmi_codec_init(struct snd_soc_pcm_= runtime *rtd) static int mt8188_dptx_codec_init(struct snd_soc_pcm_runtime *rtd) { struct mtk_soc_card_data *soc_card_data =3D snd_soc_card_get_drvdata(rtd-= >card); - struct mt8188_mt6359_priv *priv =3D soc_card_data->mach_priv; + struct snd_soc_jack *jack =3D &soc_card_data->card_data->jacks[MT8188_JAC= K_DP]; struct snd_soc_component *component =3D snd_soc_rtd_to_codec(rtd, 0)->com= ponent; int ret =3D 0; =20 ret =3D snd_soc_card_jack_new_pins(rtd->card, "DP Jack", SND_JACK_LINEOUT, - &priv->dp_jack, mt8188_dp_jack_pins, + jack, mt8188_dp_jack_pins, ARRAY_SIZE(mt8188_dp_jack_pins)); if (ret) { dev_err(rtd->dev, "%s, new jack failed: %d\n", __func__, ret); return ret; } =20 - ret =3D snd_soc_component_set_jack(component, &priv->dp_jack, NULL); + ret =3D snd_soc_component_set_jack(component, jack, NULL); if (ret) { dev_err(rtd->dev, "%s, set jack failed on %s (ret=3D%d)\n", __func__, component->name, ret); @@ -736,10 +731,9 @@ static int mt8188_max98390_codec_init(struct snd_soc_p= cm_runtime *rtd) static int mt8188_headset_codec_init(struct snd_soc_pcm_runtime *rtd) { struct snd_soc_card *card =3D rtd->card; - struct mtk_soc_card_data *soc_card_data =3D snd_soc_card_get_drvdata(card= ); - struct mt8188_mt6359_priv *priv =3D soc_card_data->mach_priv; + struct mtk_soc_card_data *soc_card_data =3D snd_soc_card_get_drvdata(rtd-= >card); + struct snd_soc_jack *jack =3D &soc_card_data->card_data->jacks[MT8188_JAC= K_HEADSET]; struct snd_soc_component *component =3D snd_soc_rtd_to_codec(rtd, 0)->com= ponent; - struct snd_soc_jack *jack =3D &priv->headset_jack; int ret; =20 ret =3D snd_soc_dapm_new_controls(&card->dapm, mt8188_nau8825_widgets, @@ -1224,11 +1218,10 @@ static struct snd_soc_dai_link mt8188_mt6359_dai_li= nks[] =3D { static void mt8188_fixup_controls(struct snd_soc_card *card) { struct mtk_soc_card_data *soc_card_data =3D snd_soc_card_get_drvdata(card= ); - struct mt8188_mt6359_priv *priv =3D soc_card_data->mach_priv; - struct mt8188_card_data *card_data =3D (struct mt8188_card_data *)priv->p= rivate_data; + struct mtk_platform_card_data *card_data =3D soc_card_data->card_data; struct snd_kcontrol *kctl; =20 - if (card_data->quirk & (NAU8825_HS_PRESENT | RT5682S_HS_PRESENT | ES8326_= HS_PRESENT)) { + if (card_data->flags & (NAU8825_HS_PRESENT | RT5682S_HS_PRESENT | ES8326_= HS_PRESENT)) { struct snd_soc_dapm_widget *w, *next_w; =20 for_each_card_widgets_safe(card, w, next_w) { @@ -1259,14 +1252,10 @@ static struct snd_soc_card mt8188_mt6359_soc_card = =3D { .fixup_controls =3D mt8188_fixup_controls, }; =20 -static int mt8188_mt6359_dev_probe(struct platform_device *pdev) +static int mt8188_mt6359_soc_card_probe(struct mtk_soc_card_data *soc_card= _data, bool legacy) { - struct snd_soc_card *card =3D &mt8188_mt6359_soc_card; - struct device_node *platform_node; - struct device_node *adsp_node; - struct mtk_soc_card_data *soc_card_data; - struct mt8188_mt6359_priv *priv; - struct mt8188_card_data *card_data; + struct mtk_platform_card_data *card_data =3D soc_card_data->card_data; + struct snd_soc_card *card =3D soc_card_data->card_data->card; struct snd_soc_dai_link *dai_link; bool init_mt6359 =3D false; bool init_es8326 =3D false; @@ -1274,91 +1263,12 @@ static int mt8188_mt6359_dev_probe(struct platform_= device *pdev) bool init_rt5682s =3D false; bool init_max98390 =3D false; bool init_dumb =3D false; - int ret, i; - - card_data =3D (struct mt8188_card_data *)of_device_get_match_data(&pdev->= dev); - card->dev =3D &pdev->dev; - - ret =3D snd_soc_of_parse_card_name(card, "model"); - if (ret) - return dev_err_probe(&pdev->dev, ret, "%s new card name parsing error\n", - __func__); - - if (!card->name) - card->name =3D card_data->name; - - if (of_property_read_bool(pdev->dev.of_node, "audio-routing")) { - ret =3D snd_soc_of_parse_audio_routing(card, "audio-routing"); - if (ret) - return ret; - } - - priv =3D devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL); - if (!priv) - return -ENOMEM; - - soc_card_data =3D devm_kzalloc(&pdev->dev, sizeof(*card_data), GFP_KERNEL= ); - if (!soc_card_data) - return -ENOMEM; - - soc_card_data->mach_priv =3D priv; - - adsp_node =3D of_parse_phandle(pdev->dev.of_node, "mediatek,adsp", 0); - if (adsp_node) { - struct mtk_sof_priv *sof_priv; - - sof_priv =3D devm_kzalloc(&pdev->dev, sizeof(*sof_priv), GFP_KERNEL); - if (!sof_priv) { - ret =3D -ENOMEM; - goto err_adsp_node; - } - sof_priv->conn_streams =3D g_sof_conn_streams; - sof_priv->num_streams =3D ARRAY_SIZE(g_sof_conn_streams); - soc_card_data->sof_priv =3D sof_priv; - card->probe =3D mtk_sof_card_probe; - card->late_probe =3D mtk_sof_card_late_probe; - if (!card->topology_shortname_created) { - snprintf(card->topology_shortname, 32, "sof-%s", card->name); - card->topology_shortname_created =3D true; - } - card->name =3D card->topology_shortname; - } - - if (of_property_read_bool(pdev->dev.of_node, "mediatek,dai-link")) { - ret =3D mtk_sof_dailink_parse_of(card, pdev->dev.of_node, - "mediatek,dai-link", - mt8188_mt6359_dai_links, - ARRAY_SIZE(mt8188_mt6359_dai_links)); - if (ret) { - dev_err_probe(&pdev->dev, ret, "Parse dai-link fail\n"); - goto err_adsp_node; - } - } else { - if (!adsp_node) - card->num_links =3D DAI_LINK_REGULAR_NUM; - } - - platform_node =3D of_parse_phandle(pdev->dev.of_node, - "mediatek,platform", 0); - if (!platform_node) { - ret =3D dev_err_probe(&pdev->dev, -EINVAL, - "Property 'platform' missing or invalid\n"); - goto err_adsp_node; - - } + int i; =20 - ret =3D parse_dai_link_info(card); - if (ret) - goto err; + if (legacy) + return -EINVAL; =20 for_each_card_prelinks(card, i, dai_link) { - if (!dai_link->platforms->name) { - if (!strncmp(dai_link->name, "AFE_SOF", strlen("AFE_SOF")) && adsp_node) - dai_link->platforms->of_node =3D adsp_node; - else - dai_link->platforms->of_node =3D platform_node; - } - if (strcmp(dai_link->name, "DPTX_BE") =3D=3D 0) { if (strcmp(dai_link->codecs->dai_name, "snd-soc-dummy-dai")) dai_link->init =3D mt8188_dptx_codec_init; @@ -1381,7 +1291,7 @@ static int mt8188_mt6359_dev_probe(struct platform_de= vice *pdev) * mt8188_max98390_ops. Two amps is I2S mode, * SOC and codec don't require TDM settings. */ - if (!(card_data->quirk & MAX98390_TWO_AMP)) { + if (!(card_data->flags & MAX98390_TWO_AMP)) { dai_link->ops =3D &mt8188_max98390_ops; } if (!init_max98390) { @@ -1420,40 +1330,55 @@ static int mt8188_mt6359_dev_probe(struct platform_= device *pdev) } } =20 - priv->private_data =3D card_data; - snd_soc_card_set_drvdata(card, soc_card_data); - - ret =3D devm_snd_soc_register_card(&pdev->dev, card); - if (ret) - dev_err_probe(&pdev->dev, ret, "%s snd_soc_register_card fail\n", - __func__); -err: - of_node_put(platform_node); - clean_card_reference(card); - -err_adsp_node: - of_node_put(adsp_node); - - return ret; + return 0; } =20 -static struct mt8188_card_data mt8188_evb_card =3D { - .name =3D "mt8188_mt6359", +static const struct mtk_sof_priv mt8188_sof_priv =3D { + .conn_streams =3D g_sof_conn_streams, + .num_streams =3D ARRAY_SIZE(g_sof_conn_streams), +}; + +static const struct mtk_soundcard_pdata mt8188_evb_card =3D { + .card_name =3D "mt8188_mt6359", + .card_data =3D &(struct mtk_platform_card_data) { + .card =3D &mt8188_mt6359_soc_card, + .num_jacks =3D MT8188_JACK_MAX, + }, + .sof_priv =3D &mt8188_sof_priv, + .soc_probe =3D mt8188_mt6359_soc_card_probe, }; =20 -static struct mt8188_card_data mt8188_nau8825_card =3D { - .name =3D "mt8188_nau8825", - .quirk =3D NAU8825_HS_PRESENT, +static const struct mtk_soundcard_pdata mt8188_nau8825_card =3D { + .card_name =3D "mt8188_nau8825", + .card_data =3D &(struct mtk_platform_card_data) { + .card =3D &mt8188_mt6359_soc_card, + .num_jacks =3D MT8188_JACK_MAX, + .flags =3D NAU8825_HS_PRESENT + }, + .sof_priv =3D &mt8188_sof_priv, + .soc_probe =3D mt8188_mt6359_soc_card_probe, }; =20 -static struct mt8188_card_data mt8188_rt5682s_card =3D { - .name =3D "mt8188_rt5682s", - .quirk =3D RT5682S_HS_PRESENT | MAX98390_TWO_AMP, +static const struct mtk_soundcard_pdata mt8188_rt5682s_card =3D { + .card_name =3D "mt8188_rt5682s", + .card_data =3D &(struct mtk_platform_card_data) { + .card =3D &mt8188_mt6359_soc_card, + .num_jacks =3D MT8188_JACK_MAX, + .flags =3D RT5682S_HS_PRESENT | MAX98390_TWO_AMP + }, + .sof_priv =3D &mt8188_sof_priv, + .soc_probe =3D mt8188_mt6359_soc_card_probe, }; =20 -static struct mt8188_card_data mt8188_es8326_card =3D { - .name =3D "mt8188_es8326", - .quirk =3D ES8326_HS_PRESENT | MAX98390_TWO_AMP, +static const struct mtk_soundcard_pdata mt8188_es8326_card =3D { + .card_name =3D "mt8188_es8326", + .card_data =3D &(struct mtk_platform_card_data) { + .card =3D &mt8188_mt6359_soc_card, + .num_jacks =3D MT8188_JACK_MAX, + .flags =3D ES8326_HS_PRESENT | MAX98390_TWO_AMP + }, + .sof_priv =3D &mt8188_sof_priv, + .soc_probe =3D mt8188_mt6359_soc_card_probe, }; =20 static const struct of_device_id mt8188_mt6359_dt_match[] =3D { @@ -1471,7 +1396,7 @@ static struct platform_driver mt8188_mt6359_driver = =3D { .of_match_table =3D mt8188_mt6359_dt_match, .pm =3D &snd_soc_pm_ops, }, - .probe =3D mt8188_mt6359_dev_probe, + .probe =3D mtk_soundcard_common_probe, }; =20 module_platform_driver(mt8188_mt6359_driver); --=20 2.44.0 From nobody Thu Nov 14 04:44:10 2024 Received: from madrid.collaboradmins.com (madrid.collaboradmins.com [46.235.227.194]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AAB8B12F589; Tue, 9 Apr 2024 11:33:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=46.235.227.194 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712662423; cv=none; b=ZjFrx78cuQn/2btavsIupFJzGOLsoa0IyMm0X1vEqgYuTelSwEsp+G01eE9csJmN6A2DLNgQtbJghosADRfX3aUMvrPuOtiODnxwmRFKvi4lbX+n+GHNaBJi5rKFGlOT2KxTdz3grmFDNaSR3cvqxzfan/AKmH6aFReqU+GmJWk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712662423; c=relaxed/simple; bh=TIZvwWDeJ4aqoDbvqKNZ4ihhFX6tlxaL4ndXBGXYyoQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=pJucDPaY0Y869EdQDomVCTQw/BHu+3oxfc30/4tYjEndzspl09krSN/N9BHNo5ya/rUVpPGj7CfWuEeYIJi5RtElmy39TEWFNJG759KOIXvr63qTvTmNaVmzthF0wDBvzzkwQs6Kc7On0pWSf8ChbmLW9pRa4A6aPXub5oK0mMs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=collabora.com; spf=pass smtp.mailfrom=collabora.com; dkim=pass (2048-bit key) header.d=collabora.com header.i=@collabora.com header.b=v+kOWH3U; arc=none smtp.client-ip=46.235.227.194 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=collabora.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=collabora.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=collabora.com header.i=@collabora.com header.b="v+kOWH3U" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1712662420; bh=TIZvwWDeJ4aqoDbvqKNZ4ihhFX6tlxaL4ndXBGXYyoQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=v+kOWH3UgkAvSQa4x4NveHCA/Wqfs9FR7AnglALc/HYC8caSkYcWV7Ym8aK1VDTWp kOhz+LoQXJ45uV8IBK5oj0e3D61yffLlGNcHxIoRRnUD5/PriWIaxa15Q8haH9cMiC mIxV2LtqnTuQiObOMfgvVSp2gNqCKiiOcOeX3ZwcJiEXJOIgoFzn80NmlRr4+M8jHz M1XFvuomRTs9Vt74fK1ibjVj+/OqoFhUBnrFrdl8mYj41JB/fQ71PJSKRoIvSBxPH+ q4QhoQqlH1nPbYFQaM2NoULG8XPc1tKo5fXKK28GPIiARWZMIt5YXuSXM+qhzI+TBF MPNlwfXYam8Nw== 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 C7CD83782127; Tue, 9 Apr 2024 11:33:37 +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 v4 04/18] ASoC: mediatek: mt8195: Migrate to mtk_soundcard_common_probe Date: Tue, 9 Apr 2024 13:32:56 +0200 Message-ID: <20240409113310.303261-5-angelogioacchino.delregno@collabora.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240409113310.303261-1-angelogioacchino.delregno@collabora.com> References: <20240409113310.303261-1-angelogioacchino.delregno@collabora.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Add mtk_soundcard_pdata platform data for the MediaTek common sound card probe mechanism, including a driver/soc-specific probe extension (used for bits that cannot be commonized hence specific to this driver), and change the probe function to mtk_soundcard_common_probe. This is also adding the possibility of specifying the links and routing with the audio-routing property and (x)-dai-link nodes in device trees to stop hardcoding machine specific links in the card driver assupported by the common probe function, but support for legacy device trees is retained with a legacy_probe function, which is used only in case the new properties are not found. Signed-off-by: AngeloGioacchino Del Regno --- sound/soc/mediatek/mt8195/mt8195-mt6359.c | 292 ++++++++++++---------- 1 file changed, 159 insertions(+), 133 deletions(-) diff --git a/sound/soc/mediatek/mt8195/mt8195-mt6359.c b/sound/soc/mediatek= /mt8195/mt8195-mt6359.c index 53fd8a897b9d..f694618e7635 100644 --- a/sound/soc/mediatek/mt8195/mt8195-mt6359.c +++ b/sound/soc/mediatek/mt8195/mt8195-mt6359.c @@ -22,6 +22,7 @@ #include "../common/mtk-afe-platform-driver.h" #include "../common/mtk-dsp-sof-common.h" #include "../common/mtk-soc-card.h" +#include "../common/mtk-soundcard-driver.h" #include "mt8195-afe-clk.h" #include "mt8195-afe-common.h" =20 @@ -29,6 +30,13 @@ #define RT1019_SPEAKER_AMP_PRESENT BIT(1) #define MAX98390_SPEAKER_AMP_PRESENT BIT(2) =20 +#define DUMB_CODEC_INIT BIT(0) +#define MT6359_CODEC_INIT BIT(1) +#define RT1011_CODEC_INIT BIT(2) +#define RT1019_CODEC_INIT BIT(3) +#define MAX98390_CODEC_INIT BIT(4) +#define RT5682_CODEC_INIT BIT(5) + #define RT1011_CODEC_DAI "rt1011-aif" #define RT1011_DEV0_NAME "rt1011.2-0038" #define RT1011_DEV1_NAME "rt1011.2-0039" @@ -51,18 +59,17 @@ #define SOF_DMA_UL4 "SOF_DMA_UL4" #define SOF_DMA_UL5 "SOF_DMA_UL5" =20 -struct mt8195_card_data { - const char *name; - unsigned long quirk; -}; - struct mt8195_mt6359_priv { - struct snd_soc_jack headset_jack; - struct snd_soc_jack dp_jack; - struct snd_soc_jack hdmi_jack; struct clk *i2so1_mclk; }; =20 +enum mt8195_jacks { + MT8195_JACK_HEADSET, + MT8195_JACK_DP, + MT8195_JACK_HDMI, + MT8195_JACK_MAX, +}; + /* Headset jack detection DAPM pins */ static struct snd_soc_jack_pin mt8195_jack_pins[] =3D { { @@ -382,33 +389,31 @@ static const struct snd_soc_ops mt8195_dptx_ops =3D { static int mt8195_dptx_codec_init(struct snd_soc_pcm_runtime *rtd) { struct mtk_soc_card_data *soc_card_data =3D snd_soc_card_get_drvdata(rtd-= >card); - struct mt8195_mt6359_priv *priv =3D soc_card_data->mach_priv; + struct snd_soc_jack *jack =3D &soc_card_data->card_data->jacks[MT8195_JAC= K_DP]; struct snd_soc_component *cmpnt_codec =3D snd_soc_rtd_to_codec(rtd, 0)->component; int ret; =20 - ret =3D snd_soc_card_jack_new(rtd->card, "DP Jack", SND_JACK_LINEOUT, - &priv->dp_jack); + ret =3D snd_soc_card_jack_new(rtd->card, "DP Jack", SND_JACK_LINEOUT, jac= k); if (ret) return ret; =20 - return snd_soc_component_set_jack(cmpnt_codec, &priv->dp_jack, NULL); + return snd_soc_component_set_jack(cmpnt_codec, jack, NULL); } =20 static int mt8195_hdmi_codec_init(struct snd_soc_pcm_runtime *rtd) { struct mtk_soc_card_data *soc_card_data =3D snd_soc_card_get_drvdata(rtd-= >card); - struct mt8195_mt6359_priv *priv =3D soc_card_data->mach_priv; + struct snd_soc_jack *jack =3D &soc_card_data->card_data->jacks[MT8195_JAC= K_HDMI]; struct snd_soc_component *cmpnt_codec =3D snd_soc_rtd_to_codec(rtd, 0)->component; int ret; =20 - ret =3D snd_soc_card_jack_new(rtd->card, "HDMI Jack", SND_JACK_LINEOUT, - &priv->hdmi_jack); + ret =3D snd_soc_card_jack_new(rtd->card, "HDMI Jack", SND_JACK_LINEOUT, j= ack); if (ret) return ret; =20 - return snd_soc_component_set_jack(cmpnt_codec, &priv->hdmi_jack, NULL); + return snd_soc_component_set_jack(cmpnt_codec, jack, NULL); } =20 static int mt8195_dptx_hw_params_fixup(struct snd_soc_pcm_runtime *rtd, @@ -566,7 +571,7 @@ static int mt8195_rt5682_init(struct snd_soc_pcm_runtim= e *rtd) snd_soc_rtd_to_codec(rtd, 0)->component; struct mtk_soc_card_data *soc_card_data =3D snd_soc_card_get_drvdata(rtd-= >card); struct mt8195_mt6359_priv *priv =3D soc_card_data->mach_priv; - struct snd_soc_jack *jack =3D &priv->headset_jack; + struct snd_soc_jack *jack =3D &soc_card_data->card_data->jacks[MT8195_JAC= K_HEADSET]; struct snd_soc_component *cmpnt_afe =3D snd_soc_rtdcom_lookup(rtd, AFE_PCM_NAME); struct mtk_base_afe *afe =3D snd_soc_component_get_drvdata(cmpnt_afe); @@ -687,7 +692,7 @@ static int mt8195_rt1011_init(struct snd_soc_pcm_runtim= e *rtd) return ret; } =20 -static int mt8195_rt1019_init(struct snd_soc_pcm_runtime *rtd) +static int mt8195_dumb_amp_init(struct snd_soc_pcm_runtime *rtd) { struct snd_soc_card *card =3D rtd->card; int ret; @@ -707,6 +712,18 @@ static int mt8195_rt1019_init(struct snd_soc_pcm_runti= me *rtd) return ret; } =20 + return 0; +} + +static int mt8195_rt1019_init(struct snd_soc_pcm_runtime *rtd) +{ + struct snd_soc_card *card =3D rtd->card; + int ret; + + ret =3D mt8195_dumb_amp_init(rtd); + if (ret) + return ret; + ret =3D snd_soc_dapm_add_routes(&card->dapm, mt8195_rt1019_routes, ARRAY_SIZE(mt8195_rt1019_routes)); if (ret) @@ -1371,108 +1388,31 @@ static int mt8195_dai_link_fixup(struct snd_soc_pc= m_runtime *rtd, return ret; } =20 -static int mt8195_mt6359_dev_probe(struct platform_device *pdev) +static int mt8195_mt6359_legacy_probe(struct mtk_soc_card_data *soc_card_d= ata) { - struct snd_soc_card *card =3D &mt8195_mt6359_soc_card; + struct mtk_platform_card_data *card_data =3D soc_card_data->card_data; + struct snd_soc_card *card =3D card_data->card; + struct device_node *codec_node, *dp_node, *hdmi_node; struct snd_soc_dai_link *dai_link; - struct mtk_soc_card_data *soc_card_data; - struct mt8195_mt6359_priv *mach_priv; - struct device_node *platform_node, *adsp_node, *codec_node, *dp_node, *hd= mi_node; - struct mt8195_card_data *card_data; - int is5682s =3D 0; - int init6359 =3D 0; - int sof_on =3D 0; - int ret, i; - - card_data =3D (struct mt8195_card_data *)of_device_get_match_data(&pdev->= dev); - card->dev =3D &pdev->dev; - - ret =3D snd_soc_of_parse_card_name(card, "model"); - if (ret) { - dev_err(&pdev->dev, "%s new card name parsing error %d\n", - __func__, ret); - return ret; - } - - if (!card->name) - card->name =3D card_data->name; + struct device *dev =3D card->dev; + bool is5682s, init6359 =3D false; + int i; =20 if (strstr(card->name, "_5682s")) { codec_node =3D of_find_compatible_node(NULL, NULL, "realtek,rt5682s"); - is5682s =3D 1; - } else - codec_node =3D of_find_compatible_node(NULL, NULL, "realtek,rt5682i"); - - soc_card_data =3D devm_kzalloc(&pdev->dev, sizeof(*card_data), GFP_KERNEL= ); - if (!soc_card_data) - return -ENOMEM; - - mach_priv =3D devm_kzalloc(&pdev->dev, sizeof(*mach_priv), GFP_KERNEL); - if (!mach_priv) - return -ENOMEM; - - soc_card_data->mach_priv =3D mach_priv; - - adsp_node =3D of_parse_phandle(pdev->dev.of_node, "mediatek,adsp", 0); - if (adsp_node) { - struct mtk_sof_priv *sof_priv; - - sof_priv =3D devm_kzalloc(&pdev->dev, sizeof(*sof_priv), GFP_KERNEL); - if (!sof_priv) { - ret =3D -ENOMEM; - goto err_kzalloc; - } - sof_priv->conn_streams =3D g_sof_conn_streams; - sof_priv->num_streams =3D ARRAY_SIZE(g_sof_conn_streams); - sof_priv->sof_dai_link_fixup =3D mt8195_dai_link_fixup; - soc_card_data->sof_priv =3D sof_priv; - card->probe =3D mtk_sof_card_probe; - card->late_probe =3D mtk_sof_card_late_probe; - if (!card->topology_shortname_created) { - snprintf(card->topology_shortname, 32, "sof-%s", card->name); - card->topology_shortname_created =3D true; - } - card->name =3D card->topology_shortname; - sof_on =3D 1; - } - - if (of_property_read_bool(pdev->dev.of_node, "mediatek,dai-link")) { - ret =3D mtk_sof_dailink_parse_of(card, pdev->dev.of_node, - "mediatek,dai-link", - mt8195_mt6359_dai_links, - ARRAY_SIZE(mt8195_mt6359_dai_links)); - if (ret) { - dev_dbg(&pdev->dev, "Parse dai-link fail\n"); - goto err_parse_of; - } + is5682s =3D true; } else { - if (!sof_on) - card->num_links =3D DAI_LINK_REGULAR_NUM; - } - - platform_node =3D of_parse_phandle(pdev->dev.of_node, - "mediatek,platform", 0); - if (!platform_node) { - dev_dbg(&pdev->dev, "Property 'platform' missing or invalid\n"); - ret =3D -EINVAL; - goto err_platform_node; + codec_node =3D of_find_compatible_node(NULL, NULL, "realtek,rt5682i"); + is5682s =3D false; } =20 - dp_node =3D of_parse_phandle(pdev->dev.of_node, "mediatek,dptx-codec", 0); - hdmi_node =3D of_parse_phandle(pdev->dev.of_node, - "mediatek,hdmi-codec", 0); + dp_node =3D of_parse_phandle(dev->of_node, "mediatek,dptx-codec", 0); + hdmi_node =3D of_parse_phandle(dev->of_node, "mediatek,hdmi-codec", 0); =20 for_each_card_prelinks(card, i, dai_link) { - if (!dai_link->platforms->name) { - if (!strncmp(dai_link->name, "AFE_SOF", strlen("AFE_SOF")) && sof_on) - dai_link->platforms->of_node =3D adsp_node; - else - dai_link->platforms->of_node =3D platform_node; - } - if (strcmp(dai_link->name, "DPTX_BE") =3D=3D 0) { if (!dp_node) { - dev_dbg(&pdev->dev, "No property 'dptx-codec'\n"); + dev_dbg(dev, "No property 'dptx-codec'\n"); } else { dai_link->codecs->of_node =3D dp_node; dai_link->codecs->name =3D NULL; @@ -1481,7 +1421,7 @@ static int mt8195_mt6359_dev_probe(struct platform_de= vice *pdev) } } else if (strcmp(dai_link->name, "ETDM3_OUT_BE") =3D=3D 0) { if (!hdmi_node) { - dev_dbg(&pdev->dev, "No property 'hdmi-codec'\n"); + dev_dbg(dev, "No property 'hdmi-codec'\n"); } else { dai_link->codecs->of_node =3D hdmi_node; dai_link->codecs->name =3D NULL; @@ -1490,7 +1430,7 @@ static int mt8195_mt6359_dev_probe(struct platform_de= vice *pdev) } } else if (strcmp(dai_link->name, "ETDM1_OUT_BE") =3D=3D 0) { if (!codec_node) { - dev_err(&pdev->dev, "Codec not found!\n"); + dev_err(dev, "Codec not found!\n"); } else { dai_link->codecs->of_node =3D codec_node; dai_link->codecs->name =3D NULL; @@ -1501,7 +1441,7 @@ static int mt8195_mt6359_dev_probe(struct platform_de= vice *pdev) } } else if (strcmp(dai_link->name, "ETDM2_IN_BE") =3D=3D 0) { if (!codec_node) { - dev_err(&pdev->dev, "Codec not found!\n"); + dev_err(dev, "Codec not found!\n"); } else { dai_link->codecs->of_node =3D codec_node; dai_link->codecs->name =3D NULL; @@ -1514,10 +1454,10 @@ static int mt8195_mt6359_dev_probe(struct platform_= device *pdev) strcmp(dai_link->name, "UL_SRC2_BE") =3D=3D 0) { if (!init6359) { dai_link->init =3D mt8195_mt6359_init; - init6359 =3D 1; + init6359 =3D true; } } else if (strcmp(dai_link->name, "ETDM2_OUT_BE") =3D=3D 0) { - switch (card_data->quirk) { + switch (card_data->flags) { case RT1011_SPEAKER_AMP_PRESENT: dai_link->codecs =3D rt1011_comps; dai_link->num_codecs =3D ARRAY_SIZE(rt1011_comps); @@ -1545,33 +1485,119 @@ static int mt8195_mt6359_dev_probe(struct platform= _device *pdev) } } =20 - snd_soc_card_set_drvdata(card, soc_card_data); + return 0; +} =20 - ret =3D devm_snd_soc_register_card(&pdev->dev, card); +static int mt8195_mt6359_soc_card_probe(struct mtk_soc_card_data *soc_card= _data, bool legacy) +{ + struct mtk_platform_card_data *card_data =3D soc_card_data->card_data; + struct snd_soc_card *card =3D card_data->card; + struct mt8195_mt6359_priv *mach_priv; + struct snd_soc_dai_link *dai_link; + u8 codec_init =3D 0; + int i; =20 - of_node_put(platform_node); - of_node_put(dp_node); - of_node_put(hdmi_node); -err_kzalloc: -err_parse_of: -err_platform_node: - of_node_put(adsp_node); - return ret; + mach_priv =3D devm_kzalloc(card->dev, sizeof(*mach_priv), GFP_KERNEL); + if (!mach_priv) + return -ENOMEM; + + soc_card_data->mach_priv =3D mach_priv; + + if (legacy) + return mt8195_mt6359_legacy_probe(soc_card_data); + + for_each_card_prelinks(card, i, dai_link) { + if (strcmp(dai_link->name, "DPTX_BE") =3D=3D 0) { + if (strcmp(dai_link->codecs->dai_name, "snd-soc-dummy-dai")) + dai_link->init =3D mt8195_dptx_codec_init; + } else if (strcmp(dai_link->name, "ETDM3_OUT_BE") =3D=3D 0) { + if (strcmp(dai_link->codecs->dai_name, "snd-soc-dummy-dai")) + dai_link->init =3D mt8195_hdmi_codec_init; + } else if (strcmp(dai_link->name, "DL_SRC_BE") =3D=3D 0 || + strcmp(dai_link->name, "UL_SRC1_BE") =3D=3D 0 || + strcmp(dai_link->name, "UL_SRC2_BE") =3D=3D 0) { + if (!(codec_init & MT6359_CODEC_INIT)) { + dai_link->init =3D mt8195_mt6359_init; + codec_init |=3D MT6359_CODEC_INIT; + } + } else if (strcmp(dai_link->name, "ETDM1_OUT_BE") =3D=3D 0 || + strcmp(dai_link->name, "ETDM2_OUT_BE") =3D=3D 0 || + strcmp(dai_link->name, "ETDM1_IN_BE") =3D=3D 0 || + strcmp(dai_link->name, "ETDM2_IN_BE") =3D=3D 0) { + if (!strcmp(dai_link->codecs->dai_name, MAX98390_CODEC_DAI)) { + if (!(codec_init & MAX98390_CODEC_INIT)) { + dai_link->init =3D mt8195_max98390_init; + codec_init |=3D MAX98390_CODEC_INIT; + } + } else if (!strcmp(dai_link->codecs->dai_name, RT1011_CODEC_DAI)) { + dai_link->ops =3D &mt8195_rt1011_etdm_ops; + if (!(codec_init & RT1011_CODEC_INIT)) { + dai_link->init =3D mt8195_rt1011_init; + codec_init |=3D RT1011_CODEC_INIT; + } + } else if (!strcmp(dai_link->codecs->dai_name, RT1019_CODEC_DAI)) { + if (!(codec_init & RT1019_CODEC_INIT)) { + dai_link->init =3D mt8195_rt1019_init; + codec_init |=3D RT1019_CODEC_INIT; + } + } else if (!strcmp(dai_link->codecs->dai_name, RT5682_CODEC_DAI) || + !strcmp(dai_link->codecs->dai_name, RT5682S_CODEC_DAI)) { + dai_link->ops =3D &mt8195_rt5682_etdm_ops; + if (!(codec_init & RT5682_CODEC_INIT)) { + dai_link->init =3D mt8195_rt5682_init; + codec_init |=3D RT5682_CODEC_INIT; + } + } else { + if (strcmp(dai_link->codecs->dai_name, "snd-soc-dummy-dai")) { + if (!(codec_init & DUMB_CODEC_INIT)) { + dai_link->init =3D mt8195_dumb_amp_init; + codec_init |=3D DUMB_CODEC_INIT; + } + } + } + } + } + + return 0; } =20 -static struct mt8195_card_data mt8195_mt6359_rt1019_rt5682_card =3D { - .name =3D "mt8195_r1019_5682", - .quirk =3D RT1019_SPEAKER_AMP_PRESENT, +static const struct mtk_sof_priv mt8195_sof_priv =3D { + .conn_streams =3D g_sof_conn_streams, + .num_streams =3D ARRAY_SIZE(g_sof_conn_streams), + .sof_dai_link_fixup =3D mt8195_dai_link_fixup }; =20 -static struct mt8195_card_data mt8195_mt6359_rt1011_rt5682_card =3D { - .name =3D "mt8195_r1011_5682", - .quirk =3D RT1011_SPEAKER_AMP_PRESENT, +static const struct mtk_soundcard_pdata mt8195_mt6359_rt1019_rt5682_card = =3D { + .card_name =3D "mt8195_r1019_5682", + .card_data =3D &(struct mtk_platform_card_data) { + .card =3D &mt8195_mt6359_soc_card, + .num_jacks =3D MT8195_JACK_MAX, + .flags =3D RT1019_SPEAKER_AMP_PRESENT + }, + .sof_priv =3D &mt8195_sof_priv, + .soc_probe =3D mt8195_mt6359_soc_card_probe }; =20 -static struct mt8195_card_data mt8195_mt6359_max98390_rt5682_card =3D { - .name =3D "mt8195_m98390_r5682", - .quirk =3D MAX98390_SPEAKER_AMP_PRESENT, +static const struct mtk_soundcard_pdata mt8195_mt6359_rt1011_rt5682_card = =3D { + .card_name =3D "mt8195_r1011_5682", + .card_data =3D &(struct mtk_platform_card_data) { + .card =3D &mt8195_mt6359_soc_card, + .num_jacks =3D MT8195_JACK_MAX, + .flags =3D RT1011_SPEAKER_AMP_PRESENT + }, + .sof_priv =3D &mt8195_sof_priv, + .soc_probe =3D mt8195_mt6359_soc_card_probe +}; + +static const struct mtk_soundcard_pdata mt8195_mt6359_max98390_rt5682_card= =3D { + .card_name =3D "mt8195_m98390_r5682", + .card_data =3D &(struct mtk_platform_card_data) { + .card =3D &mt8195_mt6359_soc_card, + .num_jacks =3D MT8195_JACK_MAX, + .flags =3D MAX98390_SPEAKER_AMP_PRESENT + }, + .sof_priv =3D &mt8195_sof_priv, + .soc_probe =3D mt8195_mt6359_soc_card_probe }; =20 static const struct of_device_id mt8195_mt6359_dt_match[] =3D { @@ -1597,7 +1623,7 @@ static struct platform_driver mt8195_mt6359_driver = =3D { .of_match_table =3D mt8195_mt6359_dt_match, .pm =3D &snd_soc_pm_ops, }, - .probe =3D mt8195_mt6359_dev_probe, + .probe =3D mtk_soundcard_common_probe, }; =20 module_platform_driver(mt8195_mt6359_driver); --=20 2.44.0 From nobody Thu Nov 14 04:44:10 2024 Received: from madrid.collaboradmins.com (madrid.collaboradmins.com [46.235.227.194]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0B32012F394; Tue, 9 Apr 2024 11:33:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=46.235.227.194 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712662425; cv=none; b=HlIb/GS2Wq3LC0s+oqnQi33ZzZELlUw9GHtxCaHSie7JF79BUhjDSP53cnKENYFFK8tLj7dbGxyyo7Hn2hAfXo9lLlC2qxV9rN40AYU5AYpEr1DYswvRyA6KmyrjuBoGCx4RxD+SbiBCSu94A0iooPIGF5hFl4YiCq97mdUKLUI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712662425; c=relaxed/simple; bh=5l6ixT/QJSwR/7ij5ouRmnGQrpg9lKNtekqp8cQZN/E=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=TNqwyhv4kJjle5X+3SAseS6v8WmOJ4NYhc0knAPXljIfkTuWKa2U5zmrVCI7XwXQk+w9xImDS+o4M6nJrSeis/ucQhVnde2P7sSPj8fE5n4Z3AAO1XUiRhWAdtR+2Pa0IXYoy38yeNURlUeJscajDGpJJDZF45FPt+5AZ5ZCLls= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=collabora.com; spf=pass smtp.mailfrom=collabora.com; dkim=pass (2048-bit key) header.d=collabora.com header.i=@collabora.com header.b=fLp2KXbH; arc=none smtp.client-ip=46.235.227.194 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=collabora.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=collabora.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=collabora.com header.i=@collabora.com header.b="fLp2KXbH" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1712662422; bh=5l6ixT/QJSwR/7ij5ouRmnGQrpg9lKNtekqp8cQZN/E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fLp2KXbHF6vumyXVCtoYQlUTBj+R6nX6K/oBbABxND601NoXmxRmBTfSl05PXqFvE DPaFY5HsbXeLNG74mmHxfpG0Ji9h6AH2mCWwRNWA4VcFyqf7DoDAIDblb0+9RaOEu3 a9nlqBsUagjsr64m6IHZBot/6ngTkT0WNNsdhgXKCAeHKAxEqWvKISI5YKlBzmeQdx kUcDUR1KfWXkkmrTQ+QlNjiBn0cCWZ0zN5V0hfV27gPhXMjGLB0G0WWCB9WiNQ0Qo9 a3w27XDHMfJ+nikgv7iv/XJTJhueLaJzf+bFQuEVFimgfdrIchFrd+HxI+laoidPHp efqjAZfY8Ws0w== 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 28DBB378212D; Tue, 9 Apr 2024 11:33:40 +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 v4 05/18] ASoC: mediatek: mt8192: Migrate to mtk_soundcard_common_probe Date: Tue, 9 Apr 2024 13:32:57 +0200 Message-ID: <20240409113310.303261-6-angelogioacchino.delregno@collabora.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240409113310.303261-1-angelogioacchino.delregno@collabora.com> References: <20240409113310.303261-1-angelogioacchino.delregno@collabora.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Add mtk_soundcard_pdata platform data for the MediaTek common sound card probe mechanism, including a driver/soc-specific probe extension (used for bits that cannot be commonized hence specific to this driver), and change the probe function to mtk_soundcard_common_probe. This is also adding the possibility of specifying the links and routing with the audio-routing property and (x)-dai-link nodes in device trees to stop hardcoding machine specific links in the card driver assupported by the common probe function, but support for legacy device trees is retained with a legacy_probe function, which is used only in case the new properties are not found. Signed-off-by: AngeloGioacchino Del Regno Reviewed-by: Alexandre Mergnat --- .../mt8192/mt8192-mt6359-rt1015-rt5682.c | 164 ++++++++++-------- 1 file changed, 91 insertions(+), 73 deletions(-) diff --git a/sound/soc/mediatek/mt8192/mt8192-mt6359-rt1015-rt5682.c b/soun= d/soc/mediatek/mt8192/mt8192-mt6359-rt1015-rt5682.c index bfcb2c486c39..645bc1aa67c7 100644 --- a/sound/soc/mediatek/mt8192/mt8192-mt6359-rt1015-rt5682.c +++ b/sound/soc/mediatek/mt8192/mt8192-mt6359-rt1015-rt5682.c @@ -20,6 +20,8 @@ #include "../../codecs/rt1015.h" #include "../../codecs/rt5682.h" #include "../common/mtk-afe-platform-driver.h" +#include "../common/mtk-soc-card.h" +#include "../common/mtk-soundcard-driver.h" #include "mt8192-afe-common.h" #include "mt8192-afe-clk.h" #include "mt8192-afe-gpio.h" @@ -38,9 +40,10 @@ #define RT1015P_RT5682_OF_NAME "mediatek,mt8192_mt6359_rt1015p_rt5682" #define RT1015P_RT5682S_OF_NAME "mediatek,mt8192_mt6359_rt1015p_rt5682s" =20 -struct mt8192_mt6359_priv { - struct snd_soc_jack headset_jack; - struct snd_soc_jack hdmi_jack; +enum mt8192_jacks { + MT8192_JACK_HEADSET, + MT8192_JACK_HDMI, + MT8192_JACK_MAX, }; =20 /* Headset jack detection DAPM pins */ @@ -323,13 +326,13 @@ static int mt8192_mt6359_init(struct snd_soc_pcm_runt= ime *rtd) =20 static int mt8192_rt5682_init(struct snd_soc_pcm_runtime *rtd) { + struct mtk_soc_card_data *soc_card_data =3D snd_soc_card_get_drvdata(rtd-= >card); + struct snd_soc_jack *jack =3D &soc_card_data->card_data->jacks[MT8192_JAC= K_HEADSET]; struct snd_soc_component *cmpnt_afe =3D snd_soc_rtdcom_lookup(rtd, AFE_PCM_NAME); struct mtk_base_afe *afe =3D snd_soc_component_get_drvdata(cmpnt_afe); struct snd_soc_component *cmpnt_codec =3D snd_soc_rtd_to_codec(rtd, 0)->component; - struct mt8192_mt6359_priv *priv =3D snd_soc_card_get_drvdata(rtd->card); - struct snd_soc_jack *jack =3D &priv->headset_jack; int ret; =20 ret =3D mt8192_dai_i2s_set_share(afe, "I2S8", "I2S9"); @@ -359,19 +362,19 @@ static int mt8192_rt5682_init(struct snd_soc_pcm_runt= ime *rtd) =20 static int mt8192_mt6359_hdmi_init(struct snd_soc_pcm_runtime *rtd) { + struct mtk_soc_card_data *soc_card_data =3D snd_soc_card_get_drvdata(rtd-= >card); + struct snd_soc_jack *jack =3D &soc_card_data->card_data->jacks[MT8192_JAC= K_HDMI]; struct snd_soc_component *cmpnt_codec =3D snd_soc_rtd_to_codec(rtd, 0)->component; - struct mt8192_mt6359_priv *priv =3D snd_soc_card_get_drvdata(rtd->card); int ret; =20 - ret =3D snd_soc_card_jack_new(rtd->card, "HDMI Jack", SND_JACK_LINEOUT, - &priv->hdmi_jack); + ret =3D snd_soc_card_jack_new(rtd->card, "HDMI Jack", SND_JACK_LINEOUT, j= ack); if (ret) { dev_err(rtd->dev, "HDMI Jack creation failed: %d\n", ret); return ret; } =20 - return snd_soc_component_set_jack(cmpnt_codec, &priv->hdmi_jack, NULL); + return snd_soc_component_set_jack(cmpnt_codec, jack, NULL); } =20 static int mt8192_i2s_hw_params_fixup(struct snd_soc_pcm_runtime *rtd, @@ -1136,71 +1139,53 @@ static int mt8192_mt6359_card_set_be_link(struct sn= d_soc_card *card, return 0; } =20 -static int mt8192_mt6359_dev_probe(struct platform_device *pdev) +static int mt8192_mt6359_legacy_probe(struct mtk_soc_card_data *soc_card_d= ata) { - struct snd_soc_card *card; - struct device_node *platform_node, *hdmi_codec, *headset_codec, *speaker_= codec; - int ret, i; + struct mtk_platform_card_data *card_data =3D soc_card_data->card_data; + struct snd_soc_card *card =3D card_data->card; + struct device *dev =3D card->dev; + struct device_node *hdmi_codec, *headset_codec, *speaker_codec; struct snd_soc_dai_link *dai_link; - struct mt8192_mt6359_priv *priv; - - card =3D (struct snd_soc_card *)of_device_get_match_data(&pdev->dev); - if (!card) - return -EINVAL; - card->dev =3D &pdev->dev; - - if (of_device_is_compatible(pdev->dev.of_node, RT1015P_RT5682_OF_NAME)) - card->name =3D RT1015P_RT5682_CARD_NAME; - else if (of_device_is_compatible(pdev->dev.of_node, RT1015P_RT5682S_OF_NA= ME)) - card->name =3D RT1015P_RT5682S_CARD_NAME; - else - dev_dbg(&pdev->dev, "No need to set card name\n"); + int ret, i; =20 - hdmi_codec =3D of_parse_phandle(pdev->dev.of_node, "mediatek,hdmi-codec",= 0); + hdmi_codec =3D of_parse_phandle(dev->of_node, "mediatek,hdmi-codec", 0); if (!hdmi_codec) - dev_dbg(&pdev->dev, "The machine has no hdmi-codec\n"); + dev_dbg(dev, "The machine has no hdmi-codec\n"); =20 - platform_node =3D of_parse_phandle(pdev->dev.of_node, "mediatek,platform"= , 0); - if (!platform_node) { - ret =3D -EINVAL; - dev_err_probe(&pdev->dev, ret, "Property 'platform' missing or invalid\n= "); - goto err_platform_node; - } - - speaker_codec =3D of_get_child_by_name(pdev->dev.of_node, "speaker-codecs= "); + speaker_codec =3D of_get_child_by_name(dev->of_node, "speaker-codecs"); if (!speaker_codec) { ret =3D -EINVAL; - dev_err_probe(&pdev->dev, ret, "Property 'speaker-codecs' missing or inv= alid\n"); + dev_err_probe(dev, ret, "Property 'speaker-codecs' missing or invalid\n"= ); goto err_speaker_codec; } =20 - headset_codec =3D of_get_child_by_name(pdev->dev.of_node, "headset-codec"= ); + headset_codec =3D of_get_child_by_name(dev->of_node, "headset-codec"); if (!headset_codec) { ret =3D -EINVAL; - dev_err_probe(&pdev->dev, ret, "Property 'headset-codec' missing or inva= lid\n"); + dev_err_probe(dev, ret, "Property 'headset-codec' missing or invalid\n"); goto err_headset_codec; } =20 for_each_card_prelinks(card, i, dai_link) { ret =3D mt8192_mt6359_card_set_be_link(card, dai_link, speaker_codec, "I= 2S3"); if (ret) { - dev_err_probe(&pdev->dev, ret, "%s set speaker_codec fail\n", + dev_err_probe(dev, ret, "%s set speaker_codec fail\n", dai_link->name); - goto err_probe; + break; } =20 ret =3D mt8192_mt6359_card_set_be_link(card, dai_link, headset_codec, "I= 2S8"); if (ret) { - dev_err_probe(&pdev->dev, ret, "%s set headset_codec fail\n", + dev_err_probe(dev, ret, "%s set headset_codec fail\n", dai_link->name); - goto err_probe; + break; } =20 ret =3D mt8192_mt6359_card_set_be_link(card, dai_link, headset_codec, "I= 2S9"); if (ret) { - dev_err_probe(&pdev->dev, ret, "%s set headset_codec fail\n", + dev_err_probe(dev, ret, "%s set headset_codec fail\n", dai_link->name); - goto err_probe; + break; } =20 if (hdmi_codec && strcmp(dai_link->name, "TDM") =3D=3D 0) { @@ -1211,52 +1196,85 @@ static int mt8192_mt6359_dev_probe(struct platform_= device *pdev) if (dai_link->num_codecs && dai_link->codecs[0].dai_name && strcmp(dai_link->codecs[0].dai_name, RT1015_CODEC_DAI) =3D=3D 0) dai_link->ops =3D &mt8192_rt1015_i2s_ops; - - if (!dai_link->platforms->name) - dai_link->platforms->of_node =3D platform_node; - } - - priv =3D devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL); - if (!priv) { - ret =3D -ENOMEM; - goto err_probe; - } - snd_soc_card_set_drvdata(card, priv); - - ret =3D mt8192_afe_gpio_init(&pdev->dev); - if (ret) { - dev_err_probe(&pdev->dev, ret, "%s init gpio error\n", __func__); - goto err_probe; } =20 - ret =3D devm_snd_soc_register_card(&pdev->dev, card); - if (ret) - dev_err_probe(&pdev->dev, ret, "%s snd_soc_register_card fail\n", __func= __); - -err_probe: of_node_put(headset_codec); err_headset_codec: of_node_put(speaker_codec); err_speaker_codec: - of_node_put(platform_node); -err_platform_node: - of_node_put(hdmi_codec); + if (hdmi_codec) + of_node_put(hdmi_codec); + return ret; } =20 +static int mt8192_mt6359_soc_card_probe(struct mtk_soc_card_data *soc_card= _data, bool legacy) +{ + struct mtk_platform_card_data *card_data =3D soc_card_data->card_data; + struct snd_soc_card *card =3D card_data->card; + int ret; + + if (legacy) { + ret =3D mt8192_mt6359_legacy_probe(soc_card_data); + if (ret) + return ret; + } else { + struct snd_soc_dai_link *dai_link; + int i; + + for_each_card_prelinks(card, i, dai_link) + if (dai_link->num_codecs && dai_link->codecs[0].dai_name && + strcmp(dai_link->codecs[0].dai_name, RT1015_CODEC_DAI) =3D=3D 0) + dai_link->ops =3D &mt8192_rt1015_i2s_ops; + } + + ret =3D mt8192_afe_gpio_init(card->dev); + if (ret) + return dev_err_probe(card->dev, ret, "%s init gpio error\n", __func__); + + return 0; +} + +static const struct mtk_soundcard_pdata mt8192_mt6359_rt1015_rt5682_pdata = =3D { + .card_name =3D RT1015_RT5682_CARD_NAME, + .card_data =3D &(struct mtk_platform_card_data) { + .card =3D &mt8192_mt6359_rt1015_rt5682_card, + .num_jacks =3D MT8192_JACK_MAX, + }, + .soc_probe =3D mt8192_mt6359_soc_card_probe +}; + +static const struct mtk_soundcard_pdata mt8192_mt6359_rt1015p_rt5682_pdata= =3D { + .card_name =3D RT1015P_RT5682_CARD_NAME, + .card_data =3D &(struct mtk_platform_card_data) { + .card =3D &mt8192_mt6359_rt1015p_rt5682x_card, + .num_jacks =3D MT8192_JACK_MAX, + }, + .soc_probe =3D mt8192_mt6359_soc_card_probe +}; + +static const struct mtk_soundcard_pdata mt8192_mt6359_rt1015p_rt5682s_pdat= a =3D { + .card_name =3D RT1015P_RT5682S_CARD_NAME, + .card_data =3D &(struct mtk_platform_card_data) { + .card =3D &mt8192_mt6359_rt1015p_rt5682x_card, + .num_jacks =3D MT8192_JACK_MAX, + }, + .soc_probe =3D mt8192_mt6359_soc_card_probe +}; + #ifdef CONFIG_OF static const struct of_device_id mt8192_mt6359_dt_match[] =3D { { .compatible =3D RT1015_RT5682_OF_NAME, - .data =3D &mt8192_mt6359_rt1015_rt5682_card, + .data =3D &mt8192_mt6359_rt1015_rt5682_pdata, }, { .compatible =3D RT1015P_RT5682_OF_NAME, - .data =3D &mt8192_mt6359_rt1015p_rt5682x_card, + .data =3D &mt8192_mt6359_rt1015p_rt5682_pdata, }, { .compatible =3D RT1015P_RT5682S_OF_NAME, - .data =3D &mt8192_mt6359_rt1015p_rt5682x_card, + .data =3D &mt8192_mt6359_rt1015p_rt5682s_pdata, }, {} }; @@ -1276,7 +1294,7 @@ static struct platform_driver mt8192_mt6359_driver = =3D { #endif .pm =3D &mt8192_mt6359_pm_ops, }, - .probe =3D mt8192_mt6359_dev_probe, + .probe =3D mtk_soundcard_common_probe, }; =20 module_platform_driver(mt8192_mt6359_driver); --=20 2.44.0 From nobody Thu Nov 14 04:44:10 2024 Received: from madrid.collaboradmins.com (madrid.collaboradmins.com [46.235.227.194]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 81C0912FB3E; Tue, 9 Apr 2024 11:33:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=46.235.227.194 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712662428; cv=none; b=CMM1fJo+LNkfZ1DnGfBSTy+QWv0keMHFZjMj7SSHyAlIE1R9utx6D5Y5UNB6yq6wFgYWgBNohLZwVsGATr1FThYtwSION4qStWLOAeV2tBz7PlLrnnkYi46/wIfoAOicxoiLPSufIMb0cllmIQ7JPiflVZD2lOmTbESXPkgwnIg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712662428; c=relaxed/simple; bh=bN6L38ZdV4Cry6UWtn4L+ZSKaNSwvVl8TeIvJNWAOFQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=rV8nhfcar31ZI4nRV4i7p8Wtaq9cqFIKrAL4Wm55guUEC/b4NglivxYQYCFnISHy6JpcgQQ3gPJq9u3JeOBqX4/dmTKh3/iihspM1ecpEuH9S8Q7irLdH3WVAIHxc7TQUKtd+4mhXfV0vKjQc71muMDPMXtRTD7WTwAr8ybxHhI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=collabora.com; spf=pass smtp.mailfrom=collabora.com; dkim=pass (2048-bit key) header.d=collabora.com header.i=@collabora.com header.b=kvcI+v3T; arc=none smtp.client-ip=46.235.227.194 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=collabora.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=collabora.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=collabora.com header.i=@collabora.com header.b="kvcI+v3T" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1712662424; bh=bN6L38ZdV4Cry6UWtn4L+ZSKaNSwvVl8TeIvJNWAOFQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kvcI+v3TabD5kUn/ss5PAPC0+WH+83eGLhx6lZJvb7RsIvJ5RnLlcOCHH2YHfV3sI aIyjriSC+J3J1o4UBHU/5VPbUyxX7cxUZyRIMrpEB9tfLT8LkaKp7FdCfrJpGGCuXK rLw6a2Mi0CzpIhaAlhSk6hwU7OUGd0G6lmN967D0+6ue/F2EvhYor6CgdEFJtMAMsk QgHkhH2Q9ZlMykJtB+KP/EGNlZBxdOXIGtvhmh2jhuyw7uzaHb3oaxHJ91nDlo1JFt gfIV0QX1NapfDisVPV/of8aR92ZqNhY8z2NKnRbikrL/5LNxPacEAcgg4GbCsUWRZ9 VqlkD0+44MdSQ== 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 7D75E3782132; Tue, 9 Apr 2024 11:33:42 +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 v4 06/18] ASoC: mediatek: mt8186: Migrate to mtk_soundcard_common_probe Date: Tue, 9 Apr 2024 13:32:58 +0200 Message-ID: <20240409113310.303261-7-angelogioacchino.delregno@collabora.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240409113310.303261-1-angelogioacchino.delregno@collabora.com> References: <20240409113310.303261-1-angelogioacchino.delregno@collabora.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Add mtk_soundcard_pdata platform data for the MediaTek common sound card probe mechanism, including a driver/soc-specific probe extension (used for bits that cannot be commonized hence specific to this driver), and change the probe function to mtk_soundcard_common_probe. This is also adding the possibility of specifying the links and routing with the audio-routing property and (x)-dai-link nodes in device trees to stop hardcoding machine specific links in the card driver assupported by the common probe function, but support for legacy device trees is retained with a legacy_probe function, which is used only in case the new properties are not found. Signed-off-by: AngeloGioacchino Del Regno Reviewed-by: Alexandre Mergnat --- .../mt8186/mt8186-mt6366-rt1019-rt5682s.c | 220 ++++++++---------- 1 file changed, 96 insertions(+), 124 deletions(-) diff --git a/sound/soc/mediatek/mt8186/mt8186-mt6366-rt1019-rt5682s.c b/sou= nd/soc/mediatek/mt8186/mt8186-mt6366-rt1019-rt5682s.c index f78197c8e582..f8856a100b27 100644 --- a/sound/soc/mediatek/mt8186/mt8186-mt6366-rt1019-rt5682s.c +++ b/sound/soc/mediatek/mt8186/mt8186-mt6366-rt1019-rt5682s.c @@ -21,6 +21,7 @@ #include "../common/mtk-afe-platform-driver.h" #include "../common/mtk-dsp-sof-common.h" #include "../common/mtk-soc-card.h" +#include "../common/mtk-soundcard-driver.h" #include "mt8186-afe-common.h" #include "mt8186-afe-clk.h" #include "mt8186-afe-gpio.h" @@ -38,11 +39,16 @@ #define SOF_DMA_UL2 "SOF_DMA_UL2" =20 struct mt8186_mt6366_rt1019_rt5682s_priv { - struct snd_soc_jack headset_jack, hdmi_jack; struct gpio_desc *dmic_sel; int dmic_switch; }; =20 +enum mt8186_jacks { + MT8186_JACK_HEADSET, + MT8186_JACK_HDMI, + MT8186_JACK_MAX, +}; + /* Headset jack detection DAPM pins */ static struct snd_soc_jack_pin mt8186_jack_pins[] =3D { { @@ -165,8 +171,7 @@ static int mt8186_rt5682s_init(struct snd_soc_pcm_runti= me *rtd) struct mtk_base_afe *afe =3D snd_soc_component_get_drvdata(cmpnt_afe); struct mtk_soc_card_data *soc_card_data =3D snd_soc_card_get_drvdata(rtd->card); - struct mt8186_mt6366_rt1019_rt5682s_priv *priv =3D soc_card_data->mach_pr= iv; - struct snd_soc_jack *jack =3D &priv->headset_jack; + struct snd_soc_jack *jack =3D &soc_card_data->card_data->jacks[MT8186_JAC= K_HEADSET]; struct snd_soc_component *cmpnt_codec =3D snd_soc_rtd_to_codec(rtd, 0)->component; int ret; @@ -257,7 +262,7 @@ static int mt8186_mt6366_rt1019_rt5682s_hdmi_init(struc= t snd_soc_pcm_runtime *rt snd_soc_rtd_to_codec(rtd, 0)->component; struct mtk_soc_card_data *soc_card_data =3D snd_soc_card_get_drvdata(rtd->card); - struct mt8186_mt6366_rt1019_rt5682s_priv *priv =3D soc_card_data->mach_pr= iv; + struct snd_soc_jack *jack =3D &soc_card_data->card_data->jacks[MT8186_JAC= K_HDMI]; int ret; =20 ret =3D mt8186_dai_i2s_set_share(afe, "I2S2", "I2S3"); @@ -266,13 +271,13 @@ static int mt8186_mt6366_rt1019_rt5682s_hdmi_init(str= uct snd_soc_pcm_runtime *rt return ret; } =20 - ret =3D snd_soc_card_jack_new(rtd->card, "HDMI Jack", SND_JACK_LINEOUT, &= priv->hdmi_jack); + ret =3D snd_soc_card_jack_new(rtd->card, "HDMI Jack", SND_JACK_LINEOUT, j= ack); if (ret) { dev_err(rtd->dev, "HDMI Jack creation failed: %d\n", ret); return ret; } =20 - return snd_soc_component_set_jack(cmpnt_codec, &priv->hdmi_jack, NULL); + return snd_soc_component_set_jack(cmpnt_codec, jack, NULL); } =20 static int mt8186_hw_params_fixup(struct snd_soc_pcm_runtime *rtd, @@ -1134,166 +1139,133 @@ static struct snd_soc_card mt8186_mt6366_rt5650_s= oc_card =3D { .num_configs =3D ARRAY_SIZE(mt8186_mt6366_rt1019_rt5682s_codec_conf), }; =20 -static int mt8186_mt6366_rt1019_rt5682s_dev_probe(struct platform_device *= pdev) +static int mt8186_mt6366_legacy_probe(struct mtk_soc_card_data *soc_card_d= ata) { - struct snd_soc_card *card; + struct mtk_platform_card_data *card_data =3D soc_card_data->card_data; + struct snd_soc_card *card =3D card_data->card; + struct device *dev =3D card->dev; struct snd_soc_dai_link *dai_link; - struct mtk_soc_card_data *soc_card_data; - struct mt8186_mt6366_rt1019_rt5682s_priv *mach_priv; - struct device_node *platform_node, *headset_codec, *playback_codec, *adsp= _node; - int sof_on =3D 0; + struct device_node *headset_codec, *playback_codec; int ret, i; =20 - card =3D (struct snd_soc_card *)device_get_match_data(&pdev->dev); - if (!card) - return -EINVAL; - card->dev =3D &pdev->dev; - - soc_card_data =3D devm_kzalloc(&pdev->dev, sizeof(*soc_card_data), GFP_KE= RNEL); - if (!soc_card_data) - return -ENOMEM; - mach_priv =3D devm_kzalloc(&pdev->dev, sizeof(*mach_priv), GFP_KERNEL); - if (!mach_priv) - return -ENOMEM; - - soc_card_data->mach_priv =3D mach_priv; - - mach_priv->dmic_sel =3D devm_gpiod_get_optional(&pdev->dev, - "dmic", GPIOD_OUT_LOW); - if (IS_ERR(mach_priv->dmic_sel)) { - dev_err(&pdev->dev, "DMIC gpio failed err=3D%ld\n", - PTR_ERR(mach_priv->dmic_sel)); - return PTR_ERR(mach_priv->dmic_sel); - } - - adsp_node =3D of_parse_phandle(pdev->dev.of_node, "mediatek,adsp", 0); - if (adsp_node) { - struct mtk_sof_priv *sof_priv; + playback_codec =3D of_get_child_by_name(dev->of_node, "playback-codecs"); + if (!playback_codec) + return dev_err_probe(dev, -EINVAL, + "Property 'playback-codecs' missing or invalid\n"); =20 - sof_priv =3D devm_kzalloc(&pdev->dev, sizeof(*sof_priv), GFP_KERNEL); - if (!sof_priv) { - ret =3D -ENOMEM; - goto err_adsp_node; - } - sof_priv->conn_streams =3D g_sof_conn_streams; - sof_priv->num_streams =3D ARRAY_SIZE(g_sof_conn_streams); - sof_priv->sof_dai_link_fixup =3D mt8186_sof_dai_link_fixup; - soc_card_data->sof_priv =3D sof_priv; - card->probe =3D mtk_sof_card_probe; - card->late_probe =3D mtk_sof_card_late_probe; - if (!card->topology_shortname_created) { - snprintf(card->topology_shortname, 32, "sof-%s", card->name); - card->topology_shortname_created =3D true; - } - card->name =3D card->topology_shortname; - sof_on =3D 1; - } else { - dev_dbg(&pdev->dev, "Probe without adsp\n"); - } - - if (of_property_read_bool(pdev->dev.of_node, "mediatek,dai-link")) { - ret =3D mtk_sof_dailink_parse_of(card, pdev->dev.of_node, - "mediatek,dai-link", - mt8186_mt6366_rt1019_rt5682s_dai_links, - ARRAY_SIZE(mt8186_mt6366_rt1019_rt5682s_dai_links)); - if (ret) { - dev_dbg(&pdev->dev, "Parse dai-link fail\n"); - goto err_adsp_node; - } - } else { - if (!sof_on) - card->num_links =3D ARRAY_SIZE(mt8186_mt6366_rt1019_rt5682s_dai_links) - - ARRAY_SIZE(g_sof_conn_streams); - } - - platform_node =3D of_parse_phandle(pdev->dev.of_node, "mediatek,platform"= , 0); - if (!platform_node) { - ret =3D -EINVAL; - dev_err_probe(&pdev->dev, ret, "Property 'platform' missing or invalid\n= "); - goto err_platform_node; - } - - playback_codec =3D of_get_child_by_name(pdev->dev.of_node, "playback-code= cs"); - if (!playback_codec) { - ret =3D -EINVAL; - dev_err_probe(&pdev->dev, ret, "Property 'playback-codecs' missing or in= valid\n"); - goto err_playback_codec; - } - - headset_codec =3D of_get_child_by_name(pdev->dev.of_node, "headset-codec"= ); + headset_codec =3D of_get_child_by_name(dev->of_node, "headset-codec"); if (!headset_codec) { - ret =3D -EINVAL; - dev_err_probe(&pdev->dev, ret, "Property 'headset-codec' missing or inva= lid\n"); - goto err_headset_codec; + of_node_put(playback_codec); + return dev_err_probe(dev, -EINVAL, + "Property 'headset-codec' missing or invalid\n"); } =20 for_each_card_prelinks(card, i, dai_link) { ret =3D mt8186_mt6366_card_set_be_link(card, dai_link, playback_codec, "= I2S3"); if (ret) { - dev_err_probe(&pdev->dev, ret, "%s set playback_codec fail\n", + dev_err_probe(dev, ret, "%s set playback_codec fail\n", dai_link->name); - goto err_probe; + break; } =20 ret =3D mt8186_mt6366_card_set_be_link(card, dai_link, headset_codec, "I= 2S0"); if (ret) { - dev_err_probe(&pdev->dev, ret, "%s set headset_codec fail\n", + dev_err_probe(dev, ret, "%s set headset_codec fail\n", dai_link->name); - goto err_probe; + break; } =20 ret =3D mt8186_mt6366_card_set_be_link(card, dai_link, headset_codec, "I= 2S1"); if (ret) { - dev_err_probe(&pdev->dev, ret, "%s set headset_codec fail\n", + dev_err_probe(dev, ret, "%s set headset_codec fail\n", dai_link->name); - goto err_probe; + break; } + } + of_node_put(headset_codec); + of_node_put(playback_codec); =20 - if (!strncmp(dai_link->name, "AFE_SOF", strlen("AFE_SOF")) && sof_on) - dai_link->platforms->of_node =3D adsp_node; + return ret; +} =20 - if (!dai_link->platforms->name && !dai_link->platforms->of_node) - dai_link->platforms->of_node =3D platform_node; - } +static int mt8186_mt6366_soc_card_probe(struct mtk_soc_card_data *soc_card= _data, bool legacy) +{ + struct mtk_platform_card_data *card_data =3D soc_card_data->card_data; + struct snd_soc_card *card =3D card_data->card; + struct mt8186_mt6366_rt1019_rt5682s_priv *mach_priv; + int ret; =20 - snd_soc_card_set_drvdata(card, soc_card_data); + mach_priv =3D devm_kzalloc(card->dev, sizeof(*mach_priv), GFP_KERNEL); + if (!mach_priv) + return -ENOMEM; =20 - ret =3D mt8186_afe_gpio_init(&pdev->dev); - if (ret) { - dev_err_probe(&pdev->dev, ret, "%s init gpio error\n", __func__); - goto err_probe; + soc_card_data->mach_priv =3D mach_priv; + + mach_priv->dmic_sel =3D devm_gpiod_get_optional(card->dev, + "dmic", GPIOD_OUT_LOW); + if (IS_ERR(mach_priv->dmic_sel)) + return dev_err_probe(card->dev, PTR_ERR(mach_priv->dmic_sel), + "DMIC gpio failed\n"); + + if (legacy) { + ret =3D mt8186_mt6366_legacy_probe(soc_card_data); + if (ret) + return ret; } =20 - ret =3D devm_snd_soc_register_card(&pdev->dev, card); + ret =3D mt8186_afe_gpio_init(card->dev); if (ret) - dev_err_probe(&pdev->dev, ret, "%s snd_soc_register_card fail\n", __func= __); + return dev_err_probe(card->dev, ret, "init AFE gpio error\n"); =20 -err_probe: - of_node_put(headset_codec); -err_headset_codec: - of_node_put(playback_codec); -err_playback_codec: - of_node_put(platform_node); -err_platform_node: -err_adsp_node: - of_node_put(adsp_node); - - return ret; + return 0; } =20 +static const struct mtk_sof_priv mt8186_sof_priv =3D { + .conn_streams =3D g_sof_conn_streams, + .num_streams =3D ARRAY_SIZE(g_sof_conn_streams), + .sof_dai_link_fixup =3D mt8186_sof_dai_link_fixup +}; + +static const struct mtk_soundcard_pdata mt8186_mt6366_rt1019_rt5682s_pdata= =3D { + .card_data =3D &(struct mtk_platform_card_data) { + .card =3D &mt8186_mt6366_rt1019_rt5682s_soc_card, + .num_jacks =3D MT8186_JACK_MAX, + }, + .sof_priv =3D &mt8186_sof_priv, + .soc_probe =3D mt8186_mt6366_soc_card_probe +}; + +static const struct mtk_soundcard_pdata mt8186_mt6366_rt5682s_max98360_pda= ta =3D { + .card_data =3D &(struct mtk_platform_card_data) { + .card =3D &mt8186_mt6366_rt5682s_max98360_soc_card, + .num_jacks =3D MT8186_JACK_MAX, + }, + .sof_priv =3D &mt8186_sof_priv, + .soc_probe =3D mt8186_mt6366_soc_card_probe +}; + +static const struct mtk_soundcard_pdata mt8186_mt6366_rt5650_pdata =3D { + .card_data =3D &(struct mtk_platform_card_data) { + .card =3D &mt8186_mt6366_rt5650_soc_card, + .num_jacks =3D MT8186_JACK_MAX, + }, + .sof_priv =3D &mt8186_sof_priv, + .soc_probe =3D mt8186_mt6366_soc_card_probe +}; + #if IS_ENABLED(CONFIG_OF) static const struct of_device_id mt8186_mt6366_rt1019_rt5682s_dt_match[] = =3D { { .compatible =3D "mediatek,mt8186-mt6366-rt1019-rt5682s-sound", - .data =3D &mt8186_mt6366_rt1019_rt5682s_soc_card, + .data =3D &mt8186_mt6366_rt1019_rt5682s_pdata, }, { .compatible =3D "mediatek,mt8186-mt6366-rt5682s-max98360-sound", - .data =3D &mt8186_mt6366_rt5682s_max98360_soc_card, + .data =3D &mt8186_mt6366_rt5682s_max98360_pdata, }, { .compatible =3D "mediatek,mt8186-mt6366-rt5650-sound", - .data =3D &mt8186_mt6366_rt5650_soc_card, + .data =3D &mt8186_mt6366_rt5650_pdata, }, {} }; @@ -1308,7 +1280,7 @@ static struct platform_driver mt8186_mt6366_rt1019_rt= 5682s_driver =3D { #endif .pm =3D &snd_soc_pm_ops, }, - .probe =3D mt8186_mt6366_rt1019_rt5682s_dev_probe, + .probe =3D mtk_soundcard_common_probe, }; =20 module_platform_driver(mt8186_mt6366_rt1019_rt5682s_driver); --=20 2.44.0 From nobody Thu Nov 14 04:44:10 2024 Received: from madrid.collaboradmins.com (madrid.collaboradmins.com [46.235.227.194]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BD15F12FF84; Tue, 9 Apr 2024 11:33:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=46.235.227.194 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712662430; cv=none; b=Jk1cd5a+TLQWkrRKuG6IRL90/h4NvgTImRzpi1mlYPHsrNJm0v1P/41kpWJRr/LZwwG2NhD3laSKOSHj+811Mp8WWTka5wQG4c9YUZNULVZESvT9hooE01RBi0sini4BfnrW0ra2puUxEIsO67B0pMOnSOvFnqWeHNAJqiJ+Q7g= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712662430; c=relaxed/simple; bh=8dO/knddMZmgChwWbJp/fcjiVO5qSxhidYiSZvCNm60=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=nCAs0ZUVEUssoSzuYKNL7tK2HoXYWwTlwu6aZBHjrAy+iZJTM6awMhS2RpwfQL6zstW05DQmLJcjxinqaDNq5byBs9CWuA87OYil9MKVMjS3+Q2fG/IOX2D3q29E9wjTCNvZDVbE9zkPqyhf8G+YtBXtVKlJKWkA0myyMzFrXMM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=collabora.com; spf=pass smtp.mailfrom=collabora.com; dkim=pass (2048-bit key) header.d=collabora.com header.i=@collabora.com header.b=nOSTlDqJ; arc=none smtp.client-ip=46.235.227.194 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=collabora.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=collabora.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=collabora.com header.i=@collabora.com header.b="nOSTlDqJ" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1712662427; bh=8dO/knddMZmgChwWbJp/fcjiVO5qSxhidYiSZvCNm60=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nOSTlDqJRR/aEs8kZfV08cvdT6yX5D4bfTCXDDGrL5wTboLxsbsE2qlExEd0rH46Y yQd7NEzFb2wHyh1nbPaYgj7PFz7cuWuP0iTajpmVY+Irg6ufFkhwchSoX4DCcswWnm gop1k4z/dDZqzj8MZw54I54DbvSRlVOGebBWcOP7Wqv9zILoLiRDe1oGtU0GA4uPpq od61LTva846zQlaTqfeYWu4fxbvkvnmJi5CWtMeZuX4vgareFfng2SG3D2sU386dqe wWnbynZBdhbEM9AlTJljHVuWsJQeNDB599qwii2M8FBdOK/Ds4bsY3U4xTH+dfT9hU WlHszIVEAvNRw== 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 DA6543782133; Tue, 9 Apr 2024 11:33:44 +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 v4 07/18] ASoC: mediatek: Add common snd_soc_ops .startup() callback Date: Tue, 9 Apr 2024 13:32:59 +0200 Message-ID: <20240409113310.303261-8-angelogioacchino.delregno@collabora.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240409113310.303261-1-angelogioacchino.delregno@collabora.com> References: <20240409113310.303261-1-angelogioacchino.delregno@collabora.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" MediaTek platforms are typically setting PCM rate and channels constraints for playback, capture and HDMI/DisplayPort playback: commonize the startup callback by adding the PCM constraints data to the mtk_platform_card_data structure and by reusing the common mtk_soundcard_startup() function for all of them by getting back the parameters from the aforementioned struct. Signed-off-by: AngeloGioacchino Del Regno Reviewed-by: Alexandre Mergnat --- .../mediatek/common/mtk-soundcard-driver.c | 51 +++++++++++++++++++ .../mediatek/common/mtk-soundcard-driver.h | 24 +++++++++ 2 files changed, 75 insertions(+) diff --git a/sound/soc/mediatek/common/mtk-soundcard-driver.c b/sound/soc/m= ediatek/common/mtk-soundcard-driver.c index b1db17e392d5..d344630f7851 100644 --- a/sound/soc/mediatek/common/mtk-soundcard-driver.c +++ b/sound/soc/mediatek/common/mtk-soundcard-driver.c @@ -139,6 +139,57 @@ void clean_card_reference(struct snd_soc_card *card) } EXPORT_SYMBOL_GPL(clean_card_reference); =20 +int mtk_soundcard_startup(struct snd_pcm_substream *substream, + enum mtk_pcm_constraint_type ctype) +{ + struct snd_soc_pcm_runtime *rtd =3D snd_soc_substream_to_rtd(substream); + struct mtk_soc_card_data *soc_card =3D snd_soc_card_get_drvdata(rtd->card= ); + const struct mtk_pcm_constraints_data *mpc =3D &soc_card->card_data->pcm_= constraints[ctype]; + int ret; + + if (unlikely(!mpc)) + return -EINVAL; + + ret =3D snd_pcm_hw_constraint_list(substream->runtime, 0, + SNDRV_PCM_HW_PARAM_RATE, + &mpc->rates); + if (ret < 0) { + dev_err(rtd->dev, "hw_constraint_list rate failed\n"); + return ret; + } + + ret =3D snd_pcm_hw_constraint_list(substream->runtime, 0, + SNDRV_PCM_HW_PARAM_CHANNELS, + &mpc->channels); + if (ret < 0) { + dev_err(rtd->dev, "hw_constraint_list channel failed\n"); + return ret; + } + + return 0; +} +EXPORT_SYMBOL_GPL(mtk_soundcard_startup); + +static int mtk_soundcard_playback_startup(struct snd_pcm_substream *substr= eam) +{ + return mtk_soundcard_startup(substream, MTK_CONSTRAINT_PLAYBACK); +} + +const struct snd_soc_ops mtk_soundcard_common_playback_ops =3D { + .startup =3D mtk_soundcard_playback_startup, +}; +EXPORT_SYMBOL_GPL(mtk_soundcard_common_playback_ops); + +static int mtk_soundcard_capture_startup(struct snd_pcm_substream *substre= am) +{ + return mtk_soundcard_startup(substream, MTK_CONSTRAINT_CAPTURE); +} + +const struct snd_soc_ops mtk_soundcard_common_capture_ops =3D { + .startup =3D mtk_soundcard_capture_startup, +}; +EXPORT_SYMBOL_GPL(mtk_soundcard_common_capture_ops); + int mtk_soundcard_common_probe(struct platform_device *pdev) { struct device_node *platform_node, *adsp_node; diff --git a/sound/soc/mediatek/common/mtk-soundcard-driver.h b/sound/soc/m= ediatek/common/mtk-soundcard-driver.h index 4fd2ffb7e486..c38e2ac09ad3 100644 --- a/sound/soc/mediatek/common/mtk-soundcard-driver.h +++ b/sound/soc/mediatek/common/mtk-soundcard-driver.h @@ -11,11 +11,26 @@ =20 struct mtk_sof_priv; struct mtk_soc_card_data; +struct snd_pcm_hw_constraint_list; + +enum mtk_pcm_constraint_type { + MTK_CONSTRAINT_PLAYBACK, + MTK_CONSTRAINT_CAPTURE, + MTK_CONSTRAINT_HDMIDP, + MTK_CONSTRAINT_MAX +}; + +struct mtk_pcm_constraints_data { + const struct snd_pcm_hw_constraint_list channels; + const struct snd_pcm_hw_constraint_list rates; +}; =20 struct mtk_platform_card_data { struct snd_soc_card *card; struct snd_soc_jack *jacks; + const struct mtk_pcm_constraints_data *pcm_constraints; u8 num_jacks; + u8 num_pcm_constraints; u8 flags; }; =20 @@ -23,9 +38,18 @@ struct mtk_soundcard_pdata { const char *card_name; struct mtk_platform_card_data *card_data; const struct mtk_sof_priv *sof_priv; + int (*soc_probe)(struct mtk_soc_card_data *card_data, bool legacy); }; =20 +/* Common playback/capture card startup ops */ +extern const struct snd_soc_ops mtk_soundcard_common_playback_ops; +extern const struct snd_soc_ops mtk_soundcard_common_capture_ops; + +/* Exported for custom/extended soundcard startup ops */ +int mtk_soundcard_startup(struct snd_pcm_substream *substream, + enum mtk_pcm_constraint_type ctype); + int parse_dai_link_info(struct snd_soc_card *card); void clean_card_reference(struct snd_soc_card *card); int mtk_soundcard_common_probe(struct platform_device *pdev); --=20 2.44.0 From nobody Thu Nov 14 04:44:10 2024 Received: from madrid.collaboradmins.com (madrid.collaboradmins.com [46.235.227.194]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2BE311304BE; Tue, 9 Apr 2024 11:33:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=46.235.227.194 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712662433; cv=none; b=iGLWoBKTqZn6jRQ+/5CnmqWY06ZUcvFRTTsycdmQJu0dsoeeL+CBFDaVMS58xqnkzhyX2Jhi0SZEmkrLscJRwk+yQ1QRXpEVahH6MIIyA9VmaLmKDVbpggenKgIhEtyDXDGdCl/pefFnyMj6CoUOelfcYVdPk1PV77gXozcGdo4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712662433; c=relaxed/simple; bh=J1cLn1ZkiMj/nqWHv8FW9Fb4kGxB9xQ83ourhgps8rk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=HRdHShf4UQJLrewfdW6Ny4Do0kJf5CO4omn2U0AqJ4+lmof+q+k1VoU3ZEoa5UKaQmXYe9JXHT4bg9lDBbw14dumykiRXpyESKf9TmT4vCKD8rdX/V4dRG+V8baaOJD9Qe+8gJtruSOGOpiq2yMhWlVzs/9XxBnUi7z9T1EgNsU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=collabora.com; spf=pass smtp.mailfrom=collabora.com; dkim=pass (2048-bit key) header.d=collabora.com header.i=@collabora.com header.b=rYzwI5P9; arc=none smtp.client-ip=46.235.227.194 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=collabora.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=collabora.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=collabora.com header.i=@collabora.com header.b="rYzwI5P9" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1712662429; bh=J1cLn1ZkiMj/nqWHv8FW9Fb4kGxB9xQ83ourhgps8rk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rYzwI5P9+jOqns6yXqXHmtiNODflnjzuEzogAc6Ec+W/3GRgeJsJDyQajhbNMdtco /e0NlutwZP/4p6u/XbO92bYfkhGbo6DVwvDoSrPP+/wbao4GoUrfSXGDE1HXcYVPSg 4RHaE8TWXWkyFdN8q5ZllqDDjRKbmidv/3qUeuSjdhKrClDntccjOlPhCjGwUegAvI OGfwaTGZLKjtBvjwJHaGoBLvjzYVej6nbZVEkxzzr07OTE5v7que8tNmKn+P4LrKH2 62dZUFtOOB3QGZApr+SGLAolbpmRSvO3t63JOjtsYW6Cod7m/pJ5F7BX/WZ+vrmlM3 2F98oulQsmvAg== 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 41CBD37820F8; Tue, 9 Apr 2024 11:33:47 +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 v4 08/18] ASoC: mediatek: mt8195: Migrate to the common mtk_soundcard_startup Date: Tue, 9 Apr 2024 13:33:00 +0200 Message-ID: <20240409113310.303261-9-angelogioacchino.delregno@collabora.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240409113310.303261-1-angelogioacchino.delregno@collabora.com> References: <20240409113310.303261-1-angelogioacchino.delregno@collabora.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Add a const mtk_pcm_constraints_data struct array with all of the (again, constant) constraints for all of the supported usecases, remove the duplicated functions and call mtk_soundcard_startup() instead in all of the .startup() callbacks. Signed-off-by: AngeloGioacchino Del Regno Reviewed-by: Alexandre Mergnat --- sound/soc/mediatek/mt8195/mt8195-mt6359.c | 195 ++++++---------------- 1 file changed, 53 insertions(+), 142 deletions(-) diff --git a/sound/soc/mediatek/mt8195/mt8195-mt6359.c b/sound/soc/mediatek= /mt8195/mt8195-mt6359.c index f694618e7635..d143ce3406fe 100644 --- a/sound/soc/mediatek/mt8195/mt8195-mt6359.c +++ b/sound/soc/mediatek/mt8195/mt8195-mt6359.c @@ -328,44 +328,7 @@ static int mt8195_mt6359_init(struct snd_soc_pcm_runti= me *rtd) =20 static int mt8195_hdmitx_dptx_startup(struct snd_pcm_substream *substream) { - static const unsigned int rates[] =3D { - 48000 - }; - static const unsigned int channels[] =3D { - 2, 4, 6, 8 - }; - static const struct snd_pcm_hw_constraint_list constraints_rates =3D { - .count =3D ARRAY_SIZE(rates), - .list =3D rates, - .mask =3D 0, - }; - static const struct snd_pcm_hw_constraint_list constraints_channels =3D { - .count =3D ARRAY_SIZE(channels), - .list =3D channels, - .mask =3D 0, - }; - - struct snd_soc_pcm_runtime *rtd =3D snd_soc_substream_to_rtd(substream); - struct snd_pcm_runtime *runtime =3D substream->runtime; - int ret; - - ret =3D snd_pcm_hw_constraint_list(runtime, 0, - SNDRV_PCM_HW_PARAM_RATE, - &constraints_rates); - if (ret < 0) { - dev_err(rtd->dev, "hw_constraint_list rate failed\n"); - return ret; - } - - ret =3D snd_pcm_hw_constraint_list(runtime, 0, - SNDRV_PCM_HW_PARAM_CHANNELS, - &constraints_channels); - if (ret < 0) { - dev_err(rtd->dev, "hw_constraint_list channel failed\n"); - return ret; - } - - return 0; + return mtk_soundcard_startup(substream, MTK_CONSTRAINT_HDMIDP); } =20 static const struct snd_soc_ops mt8195_hdmitx_dptx_playback_ops =3D { @@ -428,98 +391,6 @@ static int mt8195_dptx_hw_params_fixup(struct snd_soc_= pcm_runtime *rtd, return 0; } =20 -static int mt8195_playback_startup(struct snd_pcm_substream *substream) -{ - static const unsigned int rates[] =3D { - 48000 - }; - static const unsigned int channels[] =3D { - 2 - }; - static const struct snd_pcm_hw_constraint_list constraints_rates =3D { - .count =3D ARRAY_SIZE(rates), - .list =3D rates, - .mask =3D 0, - }; - static const struct snd_pcm_hw_constraint_list constraints_channels =3D { - .count =3D ARRAY_SIZE(channels), - .list =3D channels, - .mask =3D 0, - }; - - struct snd_soc_pcm_runtime *rtd =3D snd_soc_substream_to_rtd(substream); - struct snd_pcm_runtime *runtime =3D substream->runtime; - int ret; - - ret =3D snd_pcm_hw_constraint_list(runtime, 0, - SNDRV_PCM_HW_PARAM_RATE, - &constraints_rates); - if (ret < 0) { - dev_err(rtd->dev, "hw_constraint_list rate failed\n"); - return ret; - } - - ret =3D snd_pcm_hw_constraint_list(runtime, 0, - SNDRV_PCM_HW_PARAM_CHANNELS, - &constraints_channels); - if (ret < 0) { - dev_err(rtd->dev, "hw_constraint_list channel failed\n"); - return ret; - } - - return 0; -} - -static const struct snd_soc_ops mt8195_playback_ops =3D { - .startup =3D mt8195_playback_startup, -}; - -static int mt8195_capture_startup(struct snd_pcm_substream *substream) -{ - static const unsigned int rates[] =3D { - 48000 - }; - static const unsigned int channels[] =3D { - 1, 2 - }; - static const struct snd_pcm_hw_constraint_list constraints_rates =3D { - .count =3D ARRAY_SIZE(rates), - .list =3D rates, - .mask =3D 0, - }; - static const struct snd_pcm_hw_constraint_list constraints_channels =3D { - .count =3D ARRAY_SIZE(channels), - .list =3D channels, - .mask =3D 0, - }; - - struct snd_soc_pcm_runtime *rtd =3D snd_soc_substream_to_rtd(substream); - struct snd_pcm_runtime *runtime =3D substream->runtime; - int ret; - - ret =3D snd_pcm_hw_constraint_list(runtime, 0, - SNDRV_PCM_HW_PARAM_RATE, - &constraints_rates); - if (ret < 0) { - dev_err(rtd->dev, "hw_constraint_list rate failed\n"); - return ret; - } - - ret =3D snd_pcm_hw_constraint_list(runtime, 0, - SNDRV_PCM_HW_PARAM_CHANNELS, - &constraints_channels); - if (ret < 0) { - dev_err(rtd->dev, "hw_constraint_list channel failed\n"); - return ret; - } - - return 0; -} - -static const struct snd_soc_ops mt8195_capture_ops =3D { - .startup =3D mt8195_capture_startup, -}; - static int mt8195_rt5682_etdm_hw_params(struct snd_pcm_substream *substrea= m, struct snd_pcm_hw_params *params) { @@ -1042,7 +913,7 @@ static struct snd_soc_dai_link mt8195_mt6359_dai_links= [] =3D { }, .dynamic =3D 1, .dpcm_playback =3D 1, - .ops =3D &mt8195_playback_ops, + .ops =3D &mtk_soundcard_common_playback_ops, SND_SOC_DAILINK_REG(DL2_FE), }, [DAI_LINK_DL3_FE] =3D { @@ -1054,7 +925,7 @@ static struct snd_soc_dai_link mt8195_mt6359_dai_links= [] =3D { }, .dynamic =3D 1, .dpcm_playback =3D 1, - .ops =3D &mt8195_playback_ops, + .ops =3D &mtk_soundcard_common_playback_ops, SND_SOC_DAILINK_REG(DL3_FE), }, [DAI_LINK_DL6_FE] =3D { @@ -1066,7 +937,7 @@ static struct snd_soc_dai_link mt8195_mt6359_dai_links= [] =3D { }, .dynamic =3D 1, .dpcm_playback =3D 1, - .ops =3D &mt8195_playback_ops, + .ops =3D &mtk_soundcard_common_playback_ops, SND_SOC_DAILINK_REG(DL6_FE), }, [DAI_LINK_DL7_FE] =3D { @@ -1089,7 +960,7 @@ static struct snd_soc_dai_link mt8195_mt6359_dai_links= [] =3D { }, .dynamic =3D 1, .dpcm_playback =3D 1, - .ops =3D &mt8195_playback_ops, + .ops =3D &mtk_soundcard_common_playback_ops, SND_SOC_DAILINK_REG(DL8_FE), }, [DAI_LINK_DL10_FE] =3D { @@ -1113,7 +984,7 @@ static struct snd_soc_dai_link mt8195_mt6359_dai_links= [] =3D { }, .dynamic =3D 1, .dpcm_playback =3D 1, - .ops =3D &mt8195_playback_ops, + .ops =3D &mtk_soundcard_common_playback_ops, SND_SOC_DAILINK_REG(DL11_FE), }, [DAI_LINK_UL1_FE] =3D { @@ -1136,7 +1007,7 @@ static struct snd_soc_dai_link mt8195_mt6359_dai_link= s[] =3D { }, .dynamic =3D 1, .dpcm_capture =3D 1, - .ops =3D &mt8195_capture_ops, + .ops =3D &mtk_soundcard_common_capture_ops, SND_SOC_DAILINK_REG(UL2_FE), }, [DAI_LINK_UL3_FE] =3D { @@ -1148,7 +1019,7 @@ static struct snd_soc_dai_link mt8195_mt6359_dai_link= s[] =3D { }, .dynamic =3D 1, .dpcm_capture =3D 1, - .ops =3D &mt8195_capture_ops, + .ops =3D &mtk_soundcard_common_capture_ops, SND_SOC_DAILINK_REG(UL3_FE), }, [DAI_LINK_UL4_FE] =3D { @@ -1160,7 +1031,7 @@ static struct snd_soc_dai_link mt8195_mt6359_dai_link= s[] =3D { }, .dynamic =3D 1, .dpcm_capture =3D 1, - .ops =3D &mt8195_capture_ops, + .ops =3D &mtk_soundcard_common_capture_ops, SND_SOC_DAILINK_REG(UL4_FE), }, [DAI_LINK_UL5_FE] =3D { @@ -1172,7 +1043,7 @@ static struct snd_soc_dai_link mt8195_mt6359_dai_link= s[] =3D { }, .dynamic =3D 1, .dpcm_capture =3D 1, - .ops =3D &mt8195_capture_ops, + .ops =3D &mtk_soundcard_common_capture_ops, SND_SOC_DAILINK_REG(UL5_FE), }, [DAI_LINK_UL6_FE] =3D { @@ -1195,7 +1066,7 @@ static struct snd_soc_dai_link mt8195_mt6359_dai_link= s[] =3D { }, .dynamic =3D 1, .dpcm_capture =3D 1, - .ops =3D &mt8195_capture_ops, + .ops =3D &mtk_soundcard_common_capture_ops, SND_SOC_DAILINK_REG(UL8_FE), }, [DAI_LINK_UL9_FE] =3D { @@ -1207,7 +1078,7 @@ static struct snd_soc_dai_link mt8195_mt6359_dai_link= s[] =3D { }, .dynamic =3D 1, .dpcm_capture =3D 1, - .ops =3D &mt8195_capture_ops, + .ops =3D &mtk_soundcard_common_capture_ops, SND_SOC_DAILINK_REG(UL9_FE), }, [DAI_LINK_UL10_FE] =3D { @@ -1219,7 +1090,7 @@ static struct snd_soc_dai_link mt8195_mt6359_dai_link= s[] =3D { }, .dynamic =3D 1, .dpcm_capture =3D 1, - .ops =3D &mt8195_capture_ops, + .ops =3D &mtk_soundcard_common_capture_ops, SND_SOC_DAILINK_REG(UL10_FE), }, /* BE */ @@ -1561,6 +1432,40 @@ static int mt8195_mt6359_soc_card_probe(struct mtk_s= oc_card_data *soc_card_data, return 0; } =20 +static const unsigned int mt8195_pcm_playback_channels[] =3D { 2 }; +static const unsigned int mt8195_pcm_capture_channels[] =3D { 1, 2 }; +static const unsigned int mt8195_pcm_hdmidp_channels[] =3D { 2, 4, 6, 8 }; +static const unsigned int mt8195_pcm_rates[] =3D { 48000 }; + +static const struct snd_pcm_hw_constraint_list mt8195_rate_constraint =3D { + .list =3D mt8195_pcm_rates, + .count =3D ARRAY_SIZE(mt8195_pcm_rates) +}; + +static const struct mtk_pcm_constraints_data mt8195_pcm_constraints[MTK_CO= NSTRAINT_HDMIDP + 1] =3D { + [MTK_CONSTRAINT_PLAYBACK] =3D { + .channels =3D { + .list =3D mt8195_pcm_playback_channels, + .count =3D ARRAY_SIZE(mt8195_pcm_playback_channels) + }, + .rates =3D mt8195_rate_constraint, + }, + [MTK_CONSTRAINT_CAPTURE] =3D { + .channels =3D { + .list =3D mt8195_pcm_capture_channels, + .count =3D ARRAY_SIZE(mt8195_pcm_capture_channels) + }, + .rates =3D mt8195_rate_constraint, + }, + [MTK_CONSTRAINT_HDMIDP] =3D { + .channels =3D { + .list =3D mt8195_pcm_hdmidp_channels, + .count =3D ARRAY_SIZE(mt8195_pcm_hdmidp_channels) + }, + .rates =3D mt8195_rate_constraint, + }, +}; + static const struct mtk_sof_priv mt8195_sof_priv =3D { .conn_streams =3D g_sof_conn_streams, .num_streams =3D ARRAY_SIZE(g_sof_conn_streams), @@ -1572,6 +1477,8 @@ static const struct mtk_soundcard_pdata mt8195_mt6359= _rt1019_rt5682_card =3D { .card_data =3D &(struct mtk_platform_card_data) { .card =3D &mt8195_mt6359_soc_card, .num_jacks =3D MT8195_JACK_MAX, + .pcm_constraints =3D mt8195_pcm_constraints, + .num_pcm_constraints =3D ARRAY_SIZE(mt8195_pcm_constraints), .flags =3D RT1019_SPEAKER_AMP_PRESENT }, .sof_priv =3D &mt8195_sof_priv, @@ -1583,6 +1490,8 @@ static const struct mtk_soundcard_pdata mt8195_mt6359= _rt1011_rt5682_card =3D { .card_data =3D &(struct mtk_platform_card_data) { .card =3D &mt8195_mt6359_soc_card, .num_jacks =3D MT8195_JACK_MAX, + .pcm_constraints =3D mt8195_pcm_constraints, + .num_pcm_constraints =3D ARRAY_SIZE(mt8195_pcm_constraints), .flags =3D RT1011_SPEAKER_AMP_PRESENT }, .sof_priv =3D &mt8195_sof_priv, @@ -1594,6 +1503,8 @@ static const struct mtk_soundcard_pdata mt8195_mt6359= _max98390_rt5682_card =3D { .card_data =3D &(struct mtk_platform_card_data) { .card =3D &mt8195_mt6359_soc_card, .num_jacks =3D MT8195_JACK_MAX, + .pcm_constraints =3D mt8195_pcm_constraints, + .num_pcm_constraints =3D ARRAY_SIZE(mt8195_pcm_constraints), .flags =3D MAX98390_SPEAKER_AMP_PRESENT }, .sof_priv =3D &mt8195_sof_priv, --=20 2.44.0 From nobody Thu Nov 14 04:44:10 2024 Received: from madrid.collaboradmins.com (madrid.collaboradmins.com [46.235.227.194]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 57D77130A7E; Tue, 9 Apr 2024 11:33:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=46.235.227.194 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712662435; cv=none; b=MLq6wNaEXkfi1+x29aPOwQCXP7GqLpC1MxPEK/bJ5w5CEWvZDhzZPWgodDm+33JO67RbSKACYf9YXlR2YNAl9hGdRIaLUY0T4Xe6ygKvsEH+ETtp7jHptZk9Yhj12LGDkgige4gSSFGxrAn0AIrI9EPQBWma5NXBQyzBKiYfWPw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712662435; c=relaxed/simple; bh=7dwcW721xQhnjT05thzylbyuJsM5PYC/qaTz/86b5ls=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=t8dLC/l5IgOHLpoDz8xd6JofEI3bu5npPWDzy+bUEzttH2oP2NZ+0AJ/1R7dUuAX933bKm4ogZaqDX48zhpnqu5N18KrqmG3Un8fqeYGCSHIfRFOxZKbjZZPJWCyAhQphqThuopiAUPakVuqI+nGVAfjuhbH1jtZsaObiCceWAA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=collabora.com; spf=pass smtp.mailfrom=collabora.com; dkim=pass (2048-bit key) header.d=collabora.com header.i=@collabora.com header.b=POa3k99V; arc=none smtp.client-ip=46.235.227.194 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=collabora.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=collabora.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=collabora.com header.i=@collabora.com header.b="POa3k99V" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1712662431; bh=7dwcW721xQhnjT05thzylbyuJsM5PYC/qaTz/86b5ls=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=POa3k99Vn7p8AZTqcrRL6QFEMTQVzOZu9r9uE5ahyTAU3R1IXGc+9csBeN5fgRm7K FGc8jUNFJM8jMLoUHJpSX7ulgiZ1LTcIb6HS/oaqADJnO02OzkMmB3gt1kSWLyeJou UcYxaXohxgZ42tvTwrK5vsymeuy5RupCCR879doMB5cPBFmKl5z42iZTlL9V/2Iufp luXC+hWDGwwskckVLCGVJnTdO5SG039wM1M0NxZQM4PXUgASJ65DXWJsir8YQR2iga o4QpDWZcjZqjmDE8sIW00S1QUuNK36WFART/PBZkojJx4mYG3SwwpGM0sSF7ENJ02/ qxpZxpi39teSA== 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 9C2AE37820FD; Tue, 9 Apr 2024 11:33:49 +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 v4 09/18] ASoC: mediatek: mt8192: Migrate to the common mtk_soundcard_startup Date: Tue, 9 Apr 2024 13:33:01 +0200 Message-ID: <20240409113310.303261-10-angelogioacchino.delregno@collabora.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240409113310.303261-1-angelogioacchino.delregno@collabora.com> References: <20240409113310.303261-1-angelogioacchino.delregno@collabora.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Add a const mtk_pcm_constraints_data struct array with all of the (again, constant) constraints for all of the supported usecases, remove the duplicated functions and call mtk_soundcard_startup() instead in all of the .startup() callbacks. Signed-off-by: AngeloGioacchino Del Regno Reviewed-by: Alexandre Mergnat --- .../mt8192/mt8192-mt6359-rt1015-rt5682.c | 139 ++++++------------ 1 file changed, 41 insertions(+), 98 deletions(-) diff --git a/sound/soc/mediatek/mt8192/mt8192-mt6359-rt1015-rt5682.c b/soun= d/soc/mediatek/mt8192/mt8192-mt6359-rt1015-rt5682.c index 645bc1aa67c7..5fb34a4834d2 100644 --- a/sound/soc/mediatek/mt8192/mt8192-mt6359-rt1015-rt5682.c +++ b/sound/soc/mediatek/mt8192/mt8192-mt6359-rt1015-rt5682.c @@ -389,100 +389,6 @@ static int mt8192_i2s_hw_params_fixup(struct snd_soc_= pcm_runtime *rtd, return 0; } =20 -static int -mt8192_mt6359_cap1_startup(struct snd_pcm_substream *substream) -{ - static const unsigned int channels[] =3D { - 1, 2, 4 - }; - static const struct snd_pcm_hw_constraint_list constraints_channels =3D { - .count =3D ARRAY_SIZE(channels), - .list =3D channels, - .mask =3D 0, - }; - static const unsigned int rates[] =3D { - 8000, 16000, 32000, 48000, 96000, 192000 - }; - static const struct snd_pcm_hw_constraint_list constraints_rates =3D { - .count =3D ARRAY_SIZE(rates), - .list =3D rates, - .mask =3D 0, - }; - - struct snd_soc_pcm_runtime *rtd =3D snd_soc_substream_to_rtd(substream); - struct snd_pcm_runtime *runtime =3D substream->runtime; - int ret; - - ret =3D snd_pcm_hw_constraint_list(runtime, 0, - SNDRV_PCM_HW_PARAM_CHANNELS, - &constraints_channels); - if (ret < 0) { - dev_err(rtd->dev, "hw_constraint_list channels failed\n"); - return ret; - } - - ret =3D snd_pcm_hw_constraint_list(runtime, 0, - SNDRV_PCM_HW_PARAM_RATE, - &constraints_rates); - if (ret < 0) { - dev_err(rtd->dev, "hw_constraint_list rate failed\n"); - return ret; - } - - return 0; -} - -static const struct snd_soc_ops mt8192_mt6359_capture1_ops =3D { - .startup =3D mt8192_mt6359_cap1_startup, -}; - -static int -mt8192_mt6359_rt5682_startup(struct snd_pcm_substream *substream) -{ - static const unsigned int channels[] =3D { - 1, 2 - }; - static const struct snd_pcm_hw_constraint_list constraints_channels =3D { - .count =3D ARRAY_SIZE(channels), - .list =3D channels, - .mask =3D 0, - }; - static const unsigned int rates[] =3D { - 48000 - }; - static const struct snd_pcm_hw_constraint_list constraints_rates =3D { - .count =3D ARRAY_SIZE(rates), - .list =3D rates, - .mask =3D 0, - }; - - struct snd_soc_pcm_runtime *rtd =3D snd_soc_substream_to_rtd(substream); - struct snd_pcm_runtime *runtime =3D substream->runtime; - int ret; - - ret =3D snd_pcm_hw_constraint_list(runtime, 0, - SNDRV_PCM_HW_PARAM_CHANNELS, - &constraints_channels); - if (ret < 0) { - dev_err(rtd->dev, "hw_constraint_list channels failed\n"); - return ret; - } - - ret =3D snd_pcm_hw_constraint_list(runtime, 0, - SNDRV_PCM_HW_PARAM_RATE, - &constraints_rates); - if (ret < 0) { - dev_err(rtd->dev, "hw_constraint_list rate failed\n"); - return ret; - } - - return 0; -} - -static const struct snd_soc_ops mt8192_mt6359_rt5682_ops =3D { - .startup =3D mt8192_mt6359_rt5682_startup, -}; - /* FE */ SND_SOC_DAILINK_DEFS(playback1, DAILINK_COMP_ARRAY(COMP_CPU("DL1")), @@ -720,7 +626,7 @@ static struct snd_soc_dai_link mt8192_mt6359_dai_links[= ] =3D { SND_SOC_DPCM_TRIGGER_PRE}, .dynamic =3D 1, .dpcm_playback =3D 1, - .ops =3D &mt8192_mt6359_rt5682_ops, + .ops =3D &mtk_soundcard_common_playback_ops, SND_SOC_DAILINK_REG(playback3), }, { @@ -784,7 +690,7 @@ static struct snd_soc_dai_link mt8192_mt6359_dai_links[= ] =3D { SND_SOC_DPCM_TRIGGER_PRE}, .dynamic =3D 1, .dpcm_capture =3D 1, - .ops =3D &mt8192_mt6359_capture1_ops, + .ops =3D &mtk_soundcard_common_capture_ops, SND_SOC_DAILINK_REG(capture1), }, { @@ -794,7 +700,7 @@ static struct snd_soc_dai_link mt8192_mt6359_dai_links[= ] =3D { SND_SOC_DPCM_TRIGGER_PRE}, .dynamic =3D 1, .dpcm_capture =3D 1, - .ops =3D &mt8192_mt6359_rt5682_ops, + .ops =3D &mtk_soundcard_common_playback_ops, SND_SOC_DAILINK_REG(capture2), }, { @@ -1146,7 +1052,7 @@ static int mt8192_mt6359_legacy_probe(struct mtk_soc_= card_data *soc_card_data) struct device *dev =3D card->dev; struct device_node *hdmi_codec, *headset_codec, *speaker_codec; struct snd_soc_dai_link *dai_link; - int ret, i; + int i, ret =3D 0; =20 hdmi_codec =3D of_parse_phandle(dev->of_node, "mediatek,hdmi-codec", 0); if (!hdmi_codec) @@ -1235,11 +1141,44 @@ static int mt8192_mt6359_soc_card_probe(struct mtk_= soc_card_data *soc_card_data, return 0; } =20 +static const unsigned int mt8192_pcm_playback_channels[] =3D { 1, 2 }; +static const unsigned int mt8192_pcm_playback_rates[] =3D { 48000 }; + +static const unsigned int mt8192_pcm_capture_channels[] =3D { 1, 2, 4 }; +static const unsigned int mt8192_pcm_capture_rates[] =3D { + 8000, 16000, 32000, 48000, 96000, 192000 +}; + +static const struct mtk_pcm_constraints_data mt8192_pcm_constraints[MTK_CO= NSTRAINT_CAPTURE + 1] =3D { + [MTK_CONSTRAINT_PLAYBACK] =3D { + .channels =3D { + .list =3D mt8192_pcm_playback_channels, + .count =3D ARRAY_SIZE(mt8192_pcm_playback_channels) + }, + .rates =3D { + .list =3D mt8192_pcm_playback_rates, + .count =3D ARRAY_SIZE(mt8192_pcm_playback_rates) + } + }, + [MTK_CONSTRAINT_CAPTURE] =3D { + .channels =3D { + .list =3D mt8192_pcm_capture_channels, + .count =3D ARRAY_SIZE(mt8192_pcm_capture_channels) + }, + .rates =3D { + .list =3D mt8192_pcm_capture_rates, + .count =3D ARRAY_SIZE(mt8192_pcm_capture_rates) + } + } +}; + static const struct mtk_soundcard_pdata mt8192_mt6359_rt1015_rt5682_pdata = =3D { .card_name =3D RT1015_RT5682_CARD_NAME, .card_data =3D &(struct mtk_platform_card_data) { .card =3D &mt8192_mt6359_rt1015_rt5682_card, .num_jacks =3D MT8192_JACK_MAX, + .pcm_constraints =3D mt8192_pcm_constraints, + .num_pcm_constraints =3D ARRAY_SIZE(mt8192_pcm_constraints), }, .soc_probe =3D mt8192_mt6359_soc_card_probe }; @@ -1249,6 +1188,8 @@ static const struct mtk_soundcard_pdata mt8192_mt6359= _rt1015p_rt5682_pdata =3D { .card_data =3D &(struct mtk_platform_card_data) { .card =3D &mt8192_mt6359_rt1015p_rt5682x_card, .num_jacks =3D MT8192_JACK_MAX, + .pcm_constraints =3D mt8192_pcm_constraints, + .num_pcm_constraints =3D ARRAY_SIZE(mt8192_pcm_constraints), }, .soc_probe =3D mt8192_mt6359_soc_card_probe }; @@ -1258,6 +1199,8 @@ static const struct mtk_soundcard_pdata mt8192_mt6359= _rt1015p_rt5682s_pdata =3D { .card_data =3D &(struct mtk_platform_card_data) { .card =3D &mt8192_mt6359_rt1015p_rt5682x_card, .num_jacks =3D MT8192_JACK_MAX, + .pcm_constraints =3D mt8192_pcm_constraints, + .num_pcm_constraints =3D ARRAY_SIZE(mt8192_pcm_constraints), }, .soc_probe =3D mt8192_mt6359_soc_card_probe }; --=20 2.44.0 From nobody Thu Nov 14 04:44:10 2024 Received: from madrid.collaboradmins.com (madrid.collaboradmins.com [46.235.227.194]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 72FE8130AFC; Tue, 9 Apr 2024 11:33:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=46.235.227.194 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712662437; cv=none; b=NZnqheuwYVyvrUrZhK+sDMJcHkl0hsbMiuB/RMDWBt6/GD52S6zzttJE1VfpuFNdr2M54CNU1CQ7vYMXpAeDs2tYOaLy/Mx0WxMap6BXV78C6A/bTTgyBRxEFvnp/dPLN8pzKBes6HM2I4zqZ/5XX0mFivbIueEv3lFhe9V5IUs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712662437; c=relaxed/simple; bh=6lf3kyW4xSkggiUziJSrRhwyGxMWUnzQ+GAvBOJm5OE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=VozFAnckRztzrEG8D/MBDSMERD3QCJOZWkcg0tVo4Fq90/seHAihUoDt3oVj1QzBmecjdUNudAKqEV8XuSdSD9Vy/KtgELo3owBzOY+vzgcrk4yz/ElX64snPmZIsVIKIoerERmZHU6Em8m/SFMb03uO667gdZFNFWu3ERjIHm4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=collabora.com; spf=pass smtp.mailfrom=collabora.com; dkim=pass (2048-bit key) header.d=collabora.com header.i=@collabora.com header.b=rN06Xrz3; arc=none smtp.client-ip=46.235.227.194 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=collabora.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=collabora.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=collabora.com header.i=@collabora.com header.b="rN06Xrz3" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1712662434; bh=6lf3kyW4xSkggiUziJSrRhwyGxMWUnzQ+GAvBOJm5OE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rN06Xrz3E+mhP2xWUAMrD9fy38p12l4SRTdIApvD4yHM1hOa9BZk677FwY+v1BbX5 kVY+XwAbLLerN/CiFYRLr3fUE3LUH8OSYSBo9TtqPodmFPK7rPCtQq9B2sMVqL66hP L7lV5laPk9Xc2sLhs96njZQGz2TpCiOVbP9PiTy3wC9ebK17JhY6KKNHcYZoVBl6lf RyAZsJqF6QWuHQEp2AhDqdIvz/DOjM7Is5H4m2/Y9Om18UO0vmUX++p0GBZGrRza6n JGHLSWzaRt18SUoLQLFEsRhtpSBEP2Yl7Za6GMqpRz4fi5Zd7K3kwdirtU8F3Os9/F 7nEIgGiYokaHw== 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 0104D37820F5; Tue, 9 Apr 2024 11:33:51 +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 v4 10/18] ASoC: mediatek: mt8186-rt1019: Migrate to the common mtk_soundcard_startup Date: Tue, 9 Apr 2024 13:33:02 +0200 Message-ID: <20240409113310.303261-11-angelogioacchino.delregno@collabora.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240409113310.303261-1-angelogioacchino.delregno@collabora.com> References: <20240409113310.303261-1-angelogioacchino.delregno@collabora.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Add a const mtk_pcm_constraints_data struct array with all of the (again, constant) constraints for all of the supported usecases, remove the duplicated functions and call mtk_soundcard_startup() instead in all of the .startup() callbacks. Signed-off-by: AngeloGioacchino Del Regno --- sound/soc/mediatek/mt8186/mt8186-afe-pcm.c | 19 ++- sound/soc/mediatek/mt8186/mt8186-dai-adda.c | 2 +- .../mt8186/mt8186-mt6366-rt1019-rt5682s.c | 132 +++++------------- 3 files changed, 52 insertions(+), 101 deletions(-) diff --git a/sound/soc/mediatek/mt8186/mt8186-afe-pcm.c b/sound/soc/mediate= k/mt8186/mt8186-afe-pcm.c index bfcfc68ac64d..dbe5afa0e9ee 100644 --- a/sound/soc/mediatek/mt8186/mt8186-afe-pcm.c +++ b/sound/soc/mediatek/mt8186/mt8186-afe-pcm.c @@ -2729,7 +2729,7 @@ static int mt8186_afe_runtime_resume(struct device *d= ev) struct mtk_base_afe *afe =3D dev_get_drvdata(dev); struct mt8186_afe_private *afe_priv =3D afe->platform_priv; int ret; - +pr_err("mt8186 afe runtime_resume\n"); ret =3D mt8186_afe_enable_clock(afe); if (ret) return ret; @@ -2739,7 +2739,7 @@ static int mt8186_afe_runtime_resume(struct device *d= ev) return ret; =20 if (!afe->regmap || afe_priv->pm_runtime_bypass_reg_ctl) - goto skip_regmap; + return 0; =20 regcache_cache_only(afe->regmap, false); regcache_sync(afe->regmap); @@ -2758,13 +2758,20 @@ static int mt8186_afe_runtime_resume(struct device = *dev) /* enable AFE */ regmap_update_bits(afe->regmap, AFE_DAC_CON0, AUDIO_AFE_ON_MASK_SFT, BIT(= 0)); =20 -skip_regmap: return 0; } =20 static int mt8186_afe_component_probe(struct snd_soc_component *component) { - mtk_afe_add_sub_dai_control(component); + struct mtk_base_afe *afe =3D snd_soc_component_get_drvdata(component); + int ret; + + snd_soc_component_init_regmap(component, afe->regmap); + + ret =3D mtk_afe_add_sub_dai_control(component); + if (ret) + return ret; + mt8186_add_misc_control(component); =20 return 0; @@ -2929,6 +2936,10 @@ static int mt8186_afe_pcm_dev_probe(struct platform_= device *pdev) goto err_pm_disable; } =20 + ret =3D regmap_reinit_cache(afe->regmap, &mt8186_afe_regmap_config); + if (ret) + return dev_err_probe(dev, ret, "regmap_reinit_cache fail\n"); + /* others */ afe->mtk_afe_hardware =3D &mt8186_afe_hardware; afe->memif_fs =3D mt8186_memif_fs; diff --git a/sound/soc/mediatek/mt8186/mt8186-dai-adda.c b/sound/soc/mediat= ek/mt8186/mt8186-dai-adda.c index dbd157d1a1ea..b87b04928678 100644 --- a/sound/soc/mediatek/mt8186/mt8186-dai-adda.c +++ b/sound/soc/mediatek/mt8186/mt8186-dai-adda.c @@ -413,7 +413,7 @@ static const struct snd_soc_dapm_widget mtk_dai_adda_wi= dgets[] =3D { SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD), =20 SND_SOC_DAPM_SUPPLY_S("AUD_PAD_TOP", SUPPLY_SEQ_ADDA_AUD_PAD_TOP, - AFE_AUD_PAD_TOP, RG_RX_FIFO_ON_SFT, 0, + SND_SOC_NOPM, 0, 0, mtk_adda_pad_top_event, SND_SOC_DAPM_PRE_PMU), SND_SOC_DAPM_SUPPLY_S("ADDA_MTKAIF_CFG", SUPPLY_SEQ_ADDA_MTKAIF_CFG, diff --git a/sound/soc/mediatek/mt8186/mt8186-mt6366-rt1019-rt5682s.c b/sou= nd/soc/mediatek/mt8186/mt8186-mt6366-rt1019-rt5682s.c index f8856a100b27..95dcf06a91cb 100644 --- a/sound/soc/mediatek/mt8186/mt8186-mt6366-rt1019-rt5682s.c +++ b/sound/soc/mediatek/mt8186/mt8186-mt6366-rt1019-rt5682s.c @@ -332,98 +332,6 @@ static int mt8186_sof_dai_link_fixup(struct snd_soc_pc= m_runtime *rtd, return ret; } =20 -static int mt8186_mt6366_rt1019_rt5682s_playback_startup(struct snd_pcm_su= bstream *substream) -{ - static const unsigned int rates[] =3D { - 48000 - }; - static const unsigned int channels[] =3D { - 2 - }; - static const struct snd_pcm_hw_constraint_list constraints_rates =3D { - .count =3D ARRAY_SIZE(rates), - .list =3D rates, - .mask =3D 0, - }; - static const struct snd_pcm_hw_constraint_list constraints_channels =3D { - .count =3D ARRAY_SIZE(channels), - .list =3D channels, - .mask =3D 0, - }; - - struct snd_soc_pcm_runtime *rtd =3D snd_soc_substream_to_rtd(substream); - struct snd_pcm_runtime *runtime =3D substream->runtime; - int ret; - - ret =3D snd_pcm_hw_constraint_list(runtime, 0, - SNDRV_PCM_HW_PARAM_RATE, - &constraints_rates); - if (ret < 0) { - dev_err(rtd->dev, "hw_constraint_list rate failed\n"); - return ret; - } - - ret =3D snd_pcm_hw_constraint_list(runtime, 0, - SNDRV_PCM_HW_PARAM_CHANNELS, - &constraints_channels); - if (ret < 0) { - dev_err(rtd->dev, "hw_constraint_list channel failed\n"); - return ret; - } - - return 0; -} - -static const struct snd_soc_ops mt8186_mt6366_rt1019_rt5682s_playback_ops = =3D { - .startup =3D mt8186_mt6366_rt1019_rt5682s_playback_startup, -}; - -static int mt8186_mt6366_rt1019_rt5682s_capture_startup(struct snd_pcm_sub= stream *substream) -{ - static const unsigned int rates[] =3D { - 48000 - }; - static const unsigned int channels[] =3D { - 1, 2 - }; - static const struct snd_pcm_hw_constraint_list constraints_rates =3D { - .count =3D ARRAY_SIZE(rates), - .list =3D rates, - .mask =3D 0, - }; - static const struct snd_pcm_hw_constraint_list constraints_channels =3D { - .count =3D ARRAY_SIZE(channels), - .list =3D channels, - .mask =3D 0, - }; - - struct snd_soc_pcm_runtime *rtd =3D snd_soc_substream_to_rtd(substream); - struct snd_pcm_runtime *runtime =3D substream->runtime; - int ret; - - ret =3D snd_pcm_hw_constraint_list(runtime, 0, - SNDRV_PCM_HW_PARAM_RATE, - &constraints_rates); - if (ret < 0) { - dev_err(rtd->dev, "hw_constraint_list rate failed\n"); - return ret; - } - - ret =3D snd_pcm_hw_constraint_list(runtime, 0, - SNDRV_PCM_HW_PARAM_CHANNELS, - &constraints_channels); - if (ret < 0) { - dev_err(rtd->dev, "hw_constraint_list channel failed\n"); - return ret; - } - - return 0; -} - -static const struct snd_soc_ops mt8186_mt6366_rt1019_rt5682s_capture_ops = =3D { - .startup =3D mt8186_mt6366_rt1019_rt5682s_capture_startup, -}; - /* FE */ SND_SOC_DAILINK_DEFS(playback1, DAILINK_COMP_ARRAY(COMP_CPU("DL1")), @@ -644,7 +552,7 @@ static struct snd_soc_dai_link mt8186_mt6366_rt1019_rt5= 682s_dai_links[] =3D { .dpcm_merged_format =3D 1, .dpcm_merged_chan =3D 1, .dpcm_merged_rate =3D 1, - .ops =3D &mt8186_mt6366_rt1019_rt5682s_playback_ops, + .ops =3D &mtk_soundcard_common_playback_ops, SND_SOC_DAILINK_REG(playback1), }, { @@ -678,7 +586,7 @@ static struct snd_soc_dai_link mt8186_mt6366_rt1019_rt5= 682s_dai_links[] =3D { .dpcm_merged_format =3D 1, .dpcm_merged_chan =3D 1, .dpcm_merged_rate =3D 1, - .ops =3D &mt8186_mt6366_rt1019_rt5682s_playback_ops, + .ops =3D &mtk_soundcard_common_playback_ops, SND_SOC_DAILINK_REG(playback3), }, { @@ -745,7 +653,7 @@ static struct snd_soc_dai_link mt8186_mt6366_rt1019_rt5= 682s_dai_links[] =3D { .dpcm_merged_format =3D 1, .dpcm_merged_chan =3D 1, .dpcm_merged_rate =3D 1, - .ops =3D &mt8186_mt6366_rt1019_rt5682s_capture_ops, + .ops =3D &mtk_soundcard_common_capture_ops, SND_SOC_DAILINK_REG(capture2), }, { @@ -767,7 +675,7 @@ static struct snd_soc_dai_link mt8186_mt6366_rt1019_rt5= 682s_dai_links[] =3D { .dpcm_merged_format =3D 1, .dpcm_merged_chan =3D 1, .dpcm_merged_rate =3D 1, - .ops =3D &mt8186_mt6366_rt1019_rt5682s_capture_ops, + .ops =3D &mtk_soundcard_common_capture_ops, SND_SOC_DAILINK_REG(capture4), }, { @@ -1220,6 +1128,32 @@ static int mt8186_mt6366_soc_card_probe(struct mtk_s= oc_card_data *soc_card_data, return 0; } =20 +static const unsigned int mt8186_pcm_playback_channels[] =3D { 2 }; +static const unsigned int mt8186_pcm_capture_channels[] =3D { 1, 2 }; +static const unsigned int mt8186_pcm_rates[] =3D { 48000 }; + +static const struct snd_pcm_hw_constraint_list mt8186_rate_constraint =3D { + .list =3D mt8186_pcm_rates, + .count =3D ARRAY_SIZE(mt8186_pcm_rates) +}; + +static const struct mtk_pcm_constraints_data mt8186_pcm_constraints[MTK_CO= NSTRAINT_CAPTURE + 1] =3D { + [MTK_CONSTRAINT_PLAYBACK] =3D { + .channels =3D { + .list =3D mt8186_pcm_playback_channels, + .count =3D ARRAY_SIZE(mt8186_pcm_playback_channels) + }, + .rates =3D mt8186_rate_constraint, + }, + [MTK_CONSTRAINT_CAPTURE] =3D { + .channels =3D { + .list =3D mt8186_pcm_capture_channels, + .count =3D ARRAY_SIZE(mt8186_pcm_capture_channels) + }, + .rates =3D mt8186_rate_constraint, + } +}; + static const struct mtk_sof_priv mt8186_sof_priv =3D { .conn_streams =3D g_sof_conn_streams, .num_streams =3D ARRAY_SIZE(g_sof_conn_streams), @@ -1230,6 +1164,8 @@ static const struct mtk_soundcard_pdata mt8186_mt6366= _rt1019_rt5682s_pdata =3D { .card_data =3D &(struct mtk_platform_card_data) { .card =3D &mt8186_mt6366_rt1019_rt5682s_soc_card, .num_jacks =3D MT8186_JACK_MAX, + .pcm_constraints =3D mt8186_pcm_constraints, + .num_pcm_constraints =3D ARRAY_SIZE(mt8186_pcm_constraints), }, .sof_priv =3D &mt8186_sof_priv, .soc_probe =3D mt8186_mt6366_soc_card_probe @@ -1239,6 +1175,8 @@ static const struct mtk_soundcard_pdata mt8186_mt6366= _rt5682s_max98360_pdata =3D { .card_data =3D &(struct mtk_platform_card_data) { .card =3D &mt8186_mt6366_rt5682s_max98360_soc_card, .num_jacks =3D MT8186_JACK_MAX, + .pcm_constraints =3D mt8186_pcm_constraints, + .num_pcm_constraints =3D ARRAY_SIZE(mt8186_pcm_constraints), }, .sof_priv =3D &mt8186_sof_priv, .soc_probe =3D mt8186_mt6366_soc_card_probe @@ -1248,6 +1186,8 @@ static const struct mtk_soundcard_pdata mt8186_mt6366= _rt5650_pdata =3D { .card_data =3D &(struct mtk_platform_card_data) { .card =3D &mt8186_mt6366_rt5650_soc_card, .num_jacks =3D MT8186_JACK_MAX, + .pcm_constraints =3D mt8186_pcm_constraints, + .num_pcm_constraints =3D ARRAY_SIZE(mt8186_pcm_constraints), }, .sof_priv =3D &mt8186_sof_priv, .soc_probe =3D mt8186_mt6366_soc_card_probe --=20 2.44.0 From nobody Thu Nov 14 04:44:10 2024 Received: from madrid.collaboradmins.com (madrid.collaboradmins.com [46.235.227.194]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DF271131BD6; Tue, 9 Apr 2024 11:33:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=46.235.227.194 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712662439; cv=none; b=gvdwDzu1tniYVsbtsBAaWBxKgMVFB1WyXpb5wHIMRQa3UPJfr5Z1eENlknv14K8bZcWjmz+g17KRIq3900DEYiAcn98lI2Waat2MauacZQ7q9oryZU+v3skCitFBYVYqyimzkITaKzQxIlp5ktDl09pWU0HPoRjTG+qJxgFITuQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712662439; c=relaxed/simple; bh=ClgWR4mgcTFs9Nig5y7IuRN0DOliEM0btt6YY0gL/ck=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=FhCoN62MxtSCBTPQSo1POQKkOLzrf+ItDdr/nxN5kXlnFUe8rUpLtwzGhhwQS4QzOVNohuinHZGD02PNkBVv/QjT/F2s5aNYqQdOgMPmbTPU/10TTcbsHRddAWRdZ8ZpcW4HhHz5csydzwD+LiIGCjOmcYMVlOMpRjEhMhq5d8c= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=collabora.com; spf=pass smtp.mailfrom=collabora.com; dkim=pass (2048-bit key) header.d=collabora.com header.i=@collabora.com header.b=1UxKrCwZ; arc=none smtp.client-ip=46.235.227.194 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=collabora.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=collabora.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=collabora.com header.i=@collabora.com header.b="1UxKrCwZ" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1712662436; bh=ClgWR4mgcTFs9Nig5y7IuRN0DOliEM0btt6YY0gL/ck=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=1UxKrCwZGfiST8d6KpGhuEB/Zlp/tAykO+Moio6Qm3s5OQYTSOv4a/ysFlL2dosFk KXgWRlU2V5ll1DWKZrEbFrev4cjH9ZbAzFotBNA6jWLfq1ypemKOAyfpUobXoGhXPc +ZbauqgXqZkgLvqAb9bQfY2v7418TZEHyDR+V8U+wL/kGpzL825PQooD48GcqBAUlp PRAXOzUxoBXUJP0xR1gAr00lkgVgY4gJRTYoI5i+qkKIQLhBaCsDnlP4nSDvYNJZq4 JH3BKG6P9m6tpmPtRSoOk3BhYPuUSoueS09F2059J50/sQWlQoq1sz8lLsESC9JT8K V8C6wWCllhY9Q== 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 50E72378212D; Tue, 9 Apr 2024 11:33:54 +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 v4 11/18] ASoC: mediatek: Add common mtk_afe_component_probe callback Date: Tue, 9 Apr 2024 13:33:03 +0200 Message-ID: <20240409113310.303261-12-angelogioacchino.delregno@collabora.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240409113310.303261-1-angelogioacchino.delregno@collabora.com> References: <20240409113310.303261-1-angelogioacchino.delregno@collabora.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Multiple MediaTek AFE PCM component drivers are using their own .probe() callback, but most of those are simply duplicated functions as they are doing exactly the same thing over and over. Add a common probe callback for this component to reduce duplication. Signed-off-by: AngeloGioacchino Del Regno Reviewed-by: Alexandre Mergnat --- .../mediatek/common/mtk-afe-platform-driver.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/sound/soc/mediatek/common/mtk-afe-platform-driver.c b/sound/so= c/mediatek/common/mtk-afe-platform-driver.c index 32edcb6d5219..9b72b2a7ae91 100644 --- a/sound/soc/mediatek/common/mtk-afe-platform-driver.c +++ b/sound/soc/mediatek/common/mtk-afe-platform-driver.c @@ -126,10 +126,28 @@ int mtk_afe_pcm_new(struct snd_soc_component *compone= nt, } EXPORT_SYMBOL_GPL(mtk_afe_pcm_new); =20 +static int mtk_afe_component_probe(struct snd_soc_component *component) +{ + struct mtk_base_afe *afe =3D snd_soc_component_get_drvdata(component); + int ret; + + snd_soc_component_init_regmap(component, afe->regmap); + + /* If the list was never initialized there are no sub-DAIs */ + if (afe->sub_dais.next && afe->sub_dais.prev) { + ret =3D mtk_afe_add_sub_dai_control(component); + if (ret) + return ret; + } + + return 0; +} + const struct snd_soc_component_driver mtk_afe_pcm_platform =3D { .name =3D AFE_PCM_NAME, .pointer =3D mtk_afe_pcm_pointer, .pcm_construct =3D mtk_afe_pcm_new, + .probe =3D mtk_afe_component_probe, }; EXPORT_SYMBOL_GPL(mtk_afe_pcm_platform); =20 --=20 2.44.0 From nobody Thu Nov 14 04:44:10 2024 Received: from madrid.collaboradmins.com (madrid.collaboradmins.com [46.235.227.194]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 642D813248E; Tue, 9 Apr 2024 11:34:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=46.235.227.194 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712662442; cv=none; b=JGX9mFmKkYJZ/TGtXai/+iN5GiRiRiSY39SypyXX+1MT6nTOd00SnPgi0V3LJ5LYWicnkqg2gUCiLIds9WOJm/0xkQxyIhmJBDAS/5yOxOCFVo8o3vC9SYAhKB9fqcjeJvl50IMW9AM9HlvK+FVJ1H3OFZtbeabbmkA7s3zLec4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712662442; c=relaxed/simple; bh=0HO5qRG7yEUzOGGRdhqoIYa/lL7AlbvV2yD89QdBpT4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=DNfmmfAnPdz54s996x2rE1JU0eR7tkFmzrXUWrPdcXYstNVv2APoS2pA5/rYQL0uO246c/ay6DACylHwlGXlRkX2kQdCK+pf/8/s+kOyIG6m7S0nb7NWHfUpqwplK93I1t6JO0689606EDvy3FP+yjLAJb3GeUZFe8wWzUQ5/Lw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=collabora.com; spf=pass smtp.mailfrom=collabora.com; dkim=pass (2048-bit key) header.d=collabora.com header.i=@collabora.com header.b=2LxECNbS; arc=none smtp.client-ip=46.235.227.194 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=collabora.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=collabora.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=collabora.com header.i=@collabora.com header.b="2LxECNbS" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1712662438; bh=0HO5qRG7yEUzOGGRdhqoIYa/lL7AlbvV2yD89QdBpT4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=2LxECNbStsShBe9BxdU7ykmyjzb6y4Dubr6mxyzyi696LuIFVRZ/bDA6heNJ8UcaN 43QKkLN9ze/sW/XnNnwqkLYNgk9uF30JlU/X/QkzKDNjDi4OXyDh4aNWht5faLo34E HhCAJmBAaS8oF4S4OgXAl9IZlwjmFrxcgXzayVKeq92FR/sgQ8zQ5IePSSUhqdyRv9 16xHQtv6Nb0I+u5JS9slYWgbjiqFXWVelC1R/nodBszN41ZEzs3JdBvR4boBF0RmmD 26I04dw6GJLGBovSo72yWjRjcIzjpV9e849v6OPG41Vn1yb+pBTTKEmL3p5A6HMrbq D8HxYVSjRF5DQ== 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 98F7A3782111; Tue, 9 Apr 2024 11:33:56 +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 v4 12/18] ASoC: mediatek: Use common mtk_afe_pcm_platform with common probe cb Date: Tue, 9 Apr 2024 13:33:04 +0200 Message-ID: <20240409113310.303261-13-angelogioacchino.delregno@collabora.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240409113310.303261-1-angelogioacchino.delregno@collabora.com> References: <20240409113310.303261-1-angelogioacchino.delregno@collabora.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Since the mtk-afe-platform-driver generic mtk_afe_pcm_platform now has a common .probe() callback, there is no reason to keep duplicating this function over and over in the SoC specific AFE-PCM drivers: switch over to register with the common bits instead. Note that MT8186 was left out of this because it is registering some extra sinegen controls in the AFE-PCM probe callback and needs extra cleanups to be able to use the common bits. Signed-off-by: AngeloGioacchino Del Regno Reviewed-by: Alexandre Mergnat --- sound/soc/mediatek/mt6797/mt6797-afe-pcm.c | 14 +----------- sound/soc/mediatek/mt7986/mt7986-afe-pcm.c | 14 +----------- sound/soc/mediatek/mt8183/mt8183-afe-pcm.c | 14 +----------- sound/soc/mediatek/mt8188/mt8188-afe-pcm.c | 21 +----------------- sound/soc/mediatek/mt8192/mt8192-afe-pcm.c | 25 ++-------------------- sound/soc/mediatek/mt8195/mt8195-afe-pcm.c | 21 +----------------- 6 files changed, 7 insertions(+), 102 deletions(-) diff --git a/sound/soc/mediatek/mt6797/mt6797-afe-pcm.c b/sound/soc/mediate= k/mt6797/mt6797-afe-pcm.c index da7267c684b1..c1dee119e93a 100644 --- a/sound/soc/mediatek/mt6797/mt6797-afe-pcm.c +++ b/sound/soc/mediatek/mt6797/mt6797-afe-pcm.c @@ -704,18 +704,6 @@ static int mt6797_afe_runtime_resume(struct device *de= v) return 0; } =20 -static int mt6797_afe_component_probe(struct snd_soc_component *component) -{ - return mtk_afe_add_sub_dai_control(component); -} - -static const struct snd_soc_component_driver mt6797_afe_component =3D { - .name =3D AFE_PCM_NAME, - .probe =3D mt6797_afe_component_probe, - .pointer =3D mtk_afe_pcm_pointer, - .pcm_construct =3D mtk_afe_pcm_new, -}; - static int mt6797_dai_memif_register(struct mtk_base_afe *afe) { struct mtk_base_afe_dai *dai; @@ -852,7 +840,7 @@ static int mt6797_afe_pcm_dev_probe(struct platform_dev= ice *pdev) pm_runtime_get_sync(&pdev->dev); =20 /* register component */ - ret =3D devm_snd_soc_register_component(dev, &mt6797_afe_component, + ret =3D devm_snd_soc_register_component(dev, &mtk_afe_pcm_platform, NULL, 0); if (ret) { dev_warn(dev, "err_platform\n"); diff --git a/sound/soc/mediatek/mt7986/mt7986-afe-pcm.c b/sound/soc/mediate= k/mt7986/mt7986-afe-pcm.c index d497e1129889..c1c486e275b9 100644 --- a/sound/soc/mediatek/mt7986/mt7986-afe-pcm.c +++ b/sound/soc/mediatek/mt7986/mt7986-afe-pcm.c @@ -429,18 +429,6 @@ static int mt7986_afe_runtime_resume(struct device *de= v) return 0; } =20 -static int mt7986_afe_component_probe(struct snd_soc_component *component) -{ - return mtk_afe_add_sub_dai_control(component); -} - -static const struct snd_soc_component_driver mt7986_afe_component =3D { - .name =3D AFE_PCM_NAME, - .probe =3D mt7986_afe_component_probe, - .pointer =3D mtk_afe_pcm_pointer, - .pcm_construct =3D mtk_afe_pcm_new, -}; - static int mt7986_dai_memif_register(struct mtk_base_afe *afe) { struct mtk_base_afe_dai *dai; @@ -573,7 +561,7 @@ static int mt7986_afe_pcm_dev_probe(struct platform_dev= ice *pdev) =20 /* register component */ ret =3D devm_snd_soc_register_component(&pdev->dev, - &mt7986_afe_component, + &mtk_afe_pcm_platform, NULL, 0); if (ret) return dev_err_probe(dev, ret, "Cannot register AFE component\n"); diff --git a/sound/soc/mediatek/mt8183/mt8183-afe-pcm.c b/sound/soc/mediate= k/mt8183/mt8183-afe-pcm.c index 9e432ed9124b..25348fdf75fa 100644 --- a/sound/soc/mediatek/mt8183/mt8183-afe-pcm.c +++ b/sound/soc/mediatek/mt8183/mt8183-afe-pcm.c @@ -1042,18 +1042,6 @@ static int mt8183_afe_runtime_resume(struct device *= dev) return 0; } =20 -static int mt8183_afe_component_probe(struct snd_soc_component *component) -{ - return mtk_afe_add_sub_dai_control(component); -} - -static const struct snd_soc_component_driver mt8183_afe_component =3D { - .name =3D AFE_PCM_NAME, - .probe =3D mt8183_afe_component_probe, - .pointer =3D mtk_afe_pcm_pointer, - .pcm_construct =3D mtk_afe_pcm_new, -}; - static int mt8183_dai_memif_register(struct mtk_base_afe *afe) { struct mtk_base_afe_dai *dai; @@ -1232,7 +1220,7 @@ static int mt8183_afe_pcm_dev_probe(struct platform_d= evice *pdev) =20 /* register component */ ret =3D devm_snd_soc_register_component(&pdev->dev, - &mt8183_afe_component, + &mtk_afe_pcm_platform, NULL, 0); if (ret) { dev_warn(dev, "err_platform\n"); diff --git a/sound/soc/mediatek/mt8188/mt8188-afe-pcm.c b/sound/soc/mediate= k/mt8188/mt8188-afe-pcm.c index 46d6a5540403..9647fe133dc8 100644 --- a/sound/soc/mediatek/mt8188/mt8188-afe-pcm.c +++ b/sound/soc/mediatek/mt8188/mt8188-afe-pcm.c @@ -3030,25 +3030,6 @@ static int mt8188_afe_runtime_resume(struct device *= dev) return 0; } =20 -static int mt8188_afe_component_probe(struct snd_soc_component *component) -{ - struct mtk_base_afe *afe =3D snd_soc_component_get_drvdata(component); - int ret; - - snd_soc_component_init_regmap(component, afe->regmap); - - ret =3D mtk_afe_add_sub_dai_control(component); - - return ret; -} - -static const struct snd_soc_component_driver mt8188_afe_component =3D { - .name =3D AFE_PCM_NAME, - .pointer =3D mtk_afe_pcm_pointer, - .pcm_construct =3D mtk_afe_pcm_new, - .probe =3D mt8188_afe_component_probe, -}; - static int init_memif_priv_data(struct mtk_base_afe *afe) { struct mt8188_afe_private *afe_priv =3D afe->platform_priv; @@ -3350,7 +3331,7 @@ static int mt8188_afe_pcm_dev_probe(struct platform_d= evice *pdev) } =20 /* register component */ - ret =3D devm_snd_soc_register_component(dev, &mt8188_afe_component, + ret =3D devm_snd_soc_register_component(dev, &mtk_afe_pcm_platform, afe->dai_drivers, afe->num_dai_drivers); if (ret) { dev_warn(dev, "err_platform\n"); diff --git a/sound/soc/mediatek/mt8192/mt8192-afe-pcm.c b/sound/soc/mediate= k/mt8192/mt8192-afe-pcm.c index aed22baef9fb..424c5c68f78a 100644 --- a/sound/soc/mediatek/mt8192/mt8192-afe-pcm.c +++ b/sound/soc/mediatek/mt8192/mt8192-afe-pcm.c @@ -2125,22 +2125,6 @@ static int mt8192_afe_runtime_resume(struct device *= dev) return 0; } =20 -static int mt8192_afe_component_probe(struct snd_soc_component *component) -{ - return mtk_afe_add_sub_dai_control(component); -} - -static const struct snd_soc_component_driver mt8192_afe_component =3D { - .name =3D AFE_PCM_NAME, - .probe =3D mt8192_afe_component_probe, - .pointer =3D mtk_afe_pcm_pointer, - .pcm_construct =3D mtk_afe_pcm_new, -}; - -static const struct snd_soc_component_driver mt8192_afe_pcm_component =3D { - .name =3D "mt8192-afe-pcm-dai", -}; - static int mt8192_dai_memif_register(struct mtk_base_afe *afe) { struct mtk_base_afe_dai *dai; @@ -2302,16 +2286,11 @@ static int mt8192_afe_pcm_dev_probe(struct platform= _device *pdev) =20 /* register platform */ ret =3D devm_snd_soc_register_component(&pdev->dev, - &mt8192_afe_component, NULL, 0); - if (ret) - return dev_err_probe(dev, ret, "Couldn't register AFE component\n"); - - ret =3D devm_snd_soc_register_component(&pdev->dev, - &mt8192_afe_pcm_component, + &mtk_afe_pcm_platform, afe->dai_drivers, afe->num_dai_drivers); if (ret) - return dev_err_probe(dev, ret, "Couldn't register AFE-PCM component\n"); + return dev_err_probe(dev, ret, "Couldn't register AFE component\n"); =20 return 0; } diff --git a/sound/soc/mediatek/mt8195/mt8195-afe-pcm.c b/sound/soc/mediate= k/mt8195/mt8195-afe-pcm.c index 620d7ade1992..64af9bf363fd 100644 --- a/sound/soc/mediatek/mt8195/mt8195-afe-pcm.c +++ b/sound/soc/mediatek/mt8195/mt8195-afe-pcm.c @@ -2944,25 +2944,6 @@ static int mt8195_afe_runtime_resume(struct device *= dev) return 0; } =20 -static int mt8195_afe_component_probe(struct snd_soc_component *component) -{ - struct mtk_base_afe *afe =3D snd_soc_component_get_drvdata(component); - int ret =3D 0; - - snd_soc_component_init_regmap(component, afe->regmap); - - ret =3D mtk_afe_add_sub_dai_control(component); - - return ret; -} - -static const struct snd_soc_component_driver mt8195_afe_component =3D { - .name =3D AFE_PCM_NAME, - .pointer =3D mtk_afe_pcm_pointer, - .pcm_construct =3D mtk_afe_pcm_new, - .probe =3D mt8195_afe_component_probe, -}; - static int init_memif_priv_data(struct mtk_base_afe *afe) { struct mt8195_afe_private *afe_priv =3D afe->platform_priv; @@ -3164,7 +3145,7 @@ static int mt8195_afe_pcm_dev_probe(struct platform_d= evice *pdev) } =20 /* register component */ - ret =3D devm_snd_soc_register_component(dev, &mt8195_afe_component, + ret =3D devm_snd_soc_register_component(dev, &mtk_afe_pcm_platform, afe->dai_drivers, afe->num_dai_drivers); if (ret) { dev_warn(dev, "err_platform\n"); --=20 2.44.0 From nobody Thu Nov 14 04:44:10 2024 Received: from madrid.collaboradmins.com (madrid.collaboradmins.com [46.235.227.194]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D1446131BD6; Tue, 9 Apr 2024 11:34:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=46.235.227.194 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712662446; cv=none; b=ABRj1cyv+/kpqsdH5BqhRxSANimf4M/lbHt/90WcF+uR9rCE2ttZZwZQei3KVa9bBoRmXbyfn+1vIg5xG2CvkrdqqSBL70bhAdGRO/83d1kHV8wVqFmTBp09LEVSo/jOargd1jMtrKIIAYD66UIcXleE/IUlynDnOwGlC+C0Ov0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712662446; c=relaxed/simple; bh=YH84rIjBo+VVW/ZOSDstCD2uJpZtV5dcxUJlUIzC76Q=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=FGnObPEmbAPTcCVxT7gwWAYJ4aV3d87Bxjiv/Q+na+mnqRTH8zVxG/ZNzx0Hh22RFF78A0wBIFfxLl/8Kjw+lkvmEpeEdIJoNN4pzmw+9M5468hJwZ43rajbXRm7yI0qMuksUSgQ5xZ7uBjWmoLqir+hSCS9ROUyfZUL8fA2wso= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=collabora.com; spf=pass smtp.mailfrom=collabora.com; dkim=pass (2048-bit key) header.d=collabora.com header.i=@collabora.com header.b=5VTaOGZj; arc=none smtp.client-ip=46.235.227.194 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=collabora.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=collabora.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=collabora.com header.i=@collabora.com header.b="5VTaOGZj" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1712662441; bh=YH84rIjBo+VVW/ZOSDstCD2uJpZtV5dcxUJlUIzC76Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=5VTaOGZjuM/u3S6srLOqQ1TOxK58J+XhsivcmRGFEyfkF1ZrcYoVkAft+XQSDOHSw qsqfxNnAT1Xitf7PnQrrsNNvjjo1XmtnW7yyBPaWKqsIzVejyxj0VWlBl/4Og5GxGx 9xbTknJ8Wi0Qs1v9/fkcOyIKoLVgGzFW9ZkQSUhnjTG7O1X0q1KfEKOdMBWIzjZI2v dMhM/8o+Z4g/6ZNgkj3mfY98hplp0mKXeC6zONxJTGL69lofflhFfn5ObBq3tQmr7s 8WUxazHdptagiVKGA7GG3PlIrXlvgdZR5WKreiIcMCsjON7I3ry8SumRc1/X3534W3 R23xDEpCZ0INQ== 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 F33FB37820FD; Tue, 9 Apr 2024 11:33:58 +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 v4 13/18] ASoC: mediatek: mt8186: Unify mt8186-mt6366 machine drivers Date: Tue, 9 Apr 2024 13:33:05 +0200 Message-ID: <20240409113310.303261-14-angelogioacchino.delregno@collabora.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240409113310.303261-1-angelogioacchino.delregno@collabora.com> References: <20240409113310.303261-1-angelogioacchino.delregno@collabora.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Copy the few differences from mt8186-mt6166-da7219-max98357 in the mt8186-mt6366-rt1019-rt5682s driver to greatly reduce code duplication; since now the driver is meant to support MT8186 with the MT6366 PMIC codec and various combinations of I2S codecs, rename the driver to mt8186-mt6366 for consistency with MT8195 and MT8188, and rename the configuration option to SND_SOC_MT8186_MT6366. Since right now there is no machine using the da7219-max98357 yet, the snd_soc_dapm_route array was omitted as it's now possible to specify the audio routing in device trees instead. While at it, also add the missing sentinel comment to the last entry of the of_device_id array. Signed-off-by: AngeloGioacchino Del Regno --- sound/soc/mediatek/Kconfig | 24 +- sound/soc/mediatek/mt8186/Makefile | 3 +- .../mt8186/mt8186-mt6366-da7219-max98357.c | 1189 ----------------- ...t6366-rt1019-rt5682s.c =3D> mt8186-mt6366.c} | 228 +++- 4 files changed, 202 insertions(+), 1242 deletions(-) delete mode 100644 sound/soc/mediatek/mt8186/mt8186-mt6366-da7219-max98357= .c rename sound/soc/mediatek/mt8186/{mt8186-mt6366-rt1019-rt5682s.c =3D> mt81= 86-mt6366.c} (83%) diff --git a/sound/soc/mediatek/Kconfig b/sound/soc/mediatek/Kconfig index 296b434caf81..5a8476e1ecca 100644 --- a/sound/soc/mediatek/Kconfig +++ b/sound/soc/mediatek/Kconfig @@ -185,27 +185,11 @@ config SND_SOC_MT8186 Select Y if you have such device. If unsure select "N". =20 -config SND_SOC_MT8186_MT6366_DA7219_MAX98357 - tristate "ASoC Audio driver for MT8186 with DA7219 MAX98357A codec" +config SND_SOC_MT8186_MT6366 + tristate "ASoC Audio driver for MT8186 with MT6366 and I2S codecs" depends on I2C && GPIOLIB depends on SND_SOC_MT8186 && MTK_PMIC_WRAP - select SND_SOC_MT6358 - select SND_SOC_MAX98357A select SND_SOC_DA7219 - select SND_SOC_BT_SCO - select SND_SOC_DMIC - select SND_SOC_HDMI_CODEC - help - This adds ASoC driver for Mediatek MT8186 boards - with the MT6366(MT6358) DA7219 MAX98357A codecs. - Select Y if you have such device. - If unsure select "N". - -config SND_SOC_MT8186_MT6366_RT1019_RT5682S - tristate "ASoC Audio driver for MT8186 with RT1019 RT5682S MAX98357A/MAX9= 8360 codec" - depends on I2C && GPIOLIB - depends on SND_SOC_MT8186 && MTK_PMIC_WRAP - select SND_SOC_MAX98357A select SND_SOC_MT6358 select SND_SOC_MAX98357A select SND_SOC_RT1015P @@ -215,8 +199,8 @@ config SND_SOC_MT8186_MT6366_RT1019_RT5682S select SND_SOC_DMIC select SND_SOC_HDMI_CODEC help - This adds ASoC driver for Mediatek MT8186 boards - with the MT6366(MT6358) RT1019 RT5682S codecs. + This adds the ASoC machine driver for Mediatek MT8186 boards + with the MT6366(MT6358) and other I2S audio codecs. Select Y if you have such device. If unsure select "N". =20 diff --git a/sound/soc/mediatek/mt8186/Makefile b/sound/soc/mediatek/mt8186= /Makefile index 49b0026628a0..fa2f0efce815 100644 --- a/sound/soc/mediatek/mt8186/Makefile +++ b/sound/soc/mediatek/mt8186/Makefile @@ -18,5 +18,4 @@ snd-soc-mt8186-afe-objs :=3D \ mt8186-mt6366-common.o =20 obj-$(CONFIG_SND_SOC_MT8186) +=3D snd-soc-mt8186-afe.o -obj-$(CONFIG_SND_SOC_MT8186_MT6366_DA7219_MAX98357) +=3D mt8186-mt6366-da7= 219-max98357.o -obj-$(CONFIG_SND_SOC_MT8186_MT6366_RT1019_RT5682S) +=3D mt8186-mt6366-rt10= 19-rt5682s.o +obj-$(CONFIG_SND_SOC_MT8186_MT6366) +=3D mt8186-mt6366.o diff --git a/sound/soc/mediatek/mt8186/mt8186-mt6366-da7219-max98357.c b/so= und/soc/mediatek/mt8186/mt8186-mt6366-da7219-max98357.c deleted file mode 100644 index d86dc45be30c..000000000000 --- a/sound/soc/mediatek/mt8186/mt8186-mt6366-da7219-max98357.c +++ /dev/null @@ -1,1189 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0 -// -// mt8186-mt6366-da7219-max98357.c -// -- MT8186-MT6366-DA7219-MAX98357 ALSA SoC machine driver -// -// Copyright (c) 2022 MediaTek Inc. -// Author: Jiaxin Yu -// - -#include -#include -#include -#include -#include -#include - -#include "../../codecs/da7219.h" -#include "../../codecs/mt6358.h" -#include "../common/mtk-afe-platform-driver.h" -#include "../common/mtk-dsp-sof-common.h" -#include "../common/mtk-soc-card.h" -#include "mt8186-afe-common.h" -#include "mt8186-afe-clk.h" -#include "mt8186-afe-gpio.h" -#include "mt8186-mt6366-common.h" - -#define DA7219_CODEC_DAI "da7219-hifi" -#define DA7219_DEV_NAME "da7219.5-001a" - -#define SOF_DMA_DL1 "SOF_DMA_DL1" -#define SOF_DMA_DL2 "SOF_DMA_DL2" -#define SOF_DMA_UL1 "SOF_DMA_UL1" -#define SOF_DMA_UL2 "SOF_DMA_UL2" - -struct mt8186_mt6366_da7219_max98357_priv { - struct snd_soc_jack headset_jack, hdmi_jack; -}; - -/* Headset jack detection DAPM pins */ -static struct snd_soc_jack_pin mt8186_jack_pins[] =3D { - { - .pin =3D "Headphones", - .mask =3D SND_JACK_HEADPHONE, - }, - { - .pin =3D "Headset Mic", - .mask =3D SND_JACK_MICROPHONE, - }, - { - .pin =3D "Line Out", - .mask =3D SND_JACK_LINEOUT, - }, -}; - -static struct snd_soc_codec_conf mt8186_mt6366_da7219_max98357_codec_conf[= ] =3D { - { - .dlc =3D COMP_CODEC_CONF("mt6358-sound"), - .name_prefix =3D "Mt6366", - }, - { - .dlc =3D COMP_CODEC_CONF("bt-sco"), - .name_prefix =3D "Mt8186 bt", - }, - { - .dlc =3D COMP_CODEC_CONF("hdmi-audio-codec"), - .name_prefix =3D "Mt8186 hdmi", - }, -}; - -static int mt8186_da7219_init(struct snd_soc_pcm_runtime *rtd) -{ - struct snd_soc_component *cmpnt_afe =3D - snd_soc_rtdcom_lookup(rtd, AFE_PCM_NAME); - struct mtk_base_afe *afe =3D snd_soc_component_get_drvdata(cmpnt_afe); - struct mtk_soc_card_data *soc_card_data =3D - snd_soc_card_get_drvdata(rtd->card); - struct mt8186_mt6366_da7219_max98357_priv *priv =3D soc_card_data->mach_p= riv; - struct snd_soc_jack *jack =3D &priv->headset_jack; - struct snd_soc_component *cmpnt_codec =3D - snd_soc_rtd_to_codec(rtd, 0)->component; - int ret; - - ret =3D mt8186_dai_i2s_set_share(afe, "I2S1", "I2S0"); - if (ret) { - dev_err(rtd->dev, "Failed to set up shared clocks\n"); - return ret; - } - - /* Enable Headset and 4 Buttons Jack detection */ - ret =3D 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 | SND_JACK_LINEOUT, - jack, mt8186_jack_pins, - ARRAY_SIZE(mt8186_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_VOLUMEUP); - snd_jack_set_key(jack->jack, SND_JACK_BTN_2, KEY_VOLUMEDOWN); - snd_jack_set_key(jack->jack, SND_JACK_BTN_3, KEY_VOICECOMMAND); - - snd_soc_component_set_jack(cmpnt_codec, &priv->headset_jack, NULL); - - return 0; -} - -static int mt8186_da7219_i2s_hw_params(struct snd_pcm_substream *substream, - struct snd_pcm_hw_params *params) -{ - struct snd_soc_pcm_runtime *rtd =3D snd_soc_substream_to_rtd(substream); - struct snd_soc_dai *codec_dai; - unsigned int rate =3D params_rate(params); - unsigned int mclk_fs_ratio =3D 256; - unsigned int mclk_fs =3D rate * mclk_fs_ratio; - unsigned int freq; - int ret, j; - - ret =3D snd_soc_dai_set_sysclk(snd_soc_rtd_to_cpu(rtd, 0), 0, - mclk_fs, SND_SOC_CLOCK_OUT); - if (ret < 0) { - dev_err(rtd->dev, "failed to set cpu dai sysclk: %d\n", ret); - return ret; - } - - for_each_rtd_codec_dais(rtd, j, codec_dai) { - if (!strcmp(codec_dai->component->name, DA7219_DEV_NAME)) { - ret =3D snd_soc_dai_set_sysclk(codec_dai, - DA7219_CLKSRC_MCLK, - mclk_fs, - SND_SOC_CLOCK_IN); - if (ret < 0) { - dev_err(rtd->dev, "failed to set sysclk: %d\n", - ret); - return ret; - } - - if ((rate % 8000) =3D=3D 0) - freq =3D DA7219_PLL_FREQ_OUT_98304; - else - freq =3D DA7219_PLL_FREQ_OUT_90316; - - ret =3D snd_soc_dai_set_pll(codec_dai, 0, - DA7219_SYSCLK_PLL_SRM, - 0, freq); - if (ret) { - dev_err(rtd->dev, "failed to start PLL: %d\n", - ret); - return ret; - } - } - } - - return 0; -} - -static int mt8186_da7219_i2s_hw_free(struct snd_pcm_substream *substream) -{ - struct snd_soc_pcm_runtime *rtd =3D snd_soc_substream_to_rtd(substream); - struct snd_soc_dai *codec_dai; - int ret =3D 0, j; - - for_each_rtd_codec_dais(rtd, j, codec_dai) { - if (!strcmp(codec_dai->component->name, DA7219_DEV_NAME)) { - ret =3D snd_soc_dai_set_pll(codec_dai, - 0, DA7219_SYSCLK_MCLK, 0, 0); - if (ret < 0) { - dev_err(rtd->dev, "failed to stop PLL: %d\n", - ret); - return ret; - } - } - } - - return 0; -} - -static const struct snd_soc_ops mt8186_da7219_i2s_ops =3D { - .hw_params =3D mt8186_da7219_i2s_hw_params, - .hw_free =3D mt8186_da7219_i2s_hw_free, -}; - -static int mt8186_mt6366_da7219_max98357_hdmi_init(struct snd_soc_pcm_runt= ime *rtd) -{ - struct snd_soc_component *cmpnt_afe =3D - snd_soc_rtdcom_lookup(rtd, AFE_PCM_NAME); - struct mtk_base_afe *afe =3D snd_soc_component_get_drvdata(cmpnt_afe); - struct snd_soc_component *cmpnt_codec =3D - snd_soc_rtd_to_codec(rtd, 0)->component; - struct mtk_soc_card_data *soc_card_data =3D - snd_soc_card_get_drvdata(rtd->card); - struct mt8186_mt6366_da7219_max98357_priv *priv =3D soc_card_data->mach_p= riv; - int ret; - - ret =3D mt8186_dai_i2s_set_share(afe, "I2S2", "I2S3"); - if (ret) { - dev_err(rtd->dev, "Failed to set up shared clocks\n"); - return ret; - } - - ret =3D snd_soc_card_jack_new(rtd->card, "HDMI Jack", SND_JACK_LINEOUT, &= priv->hdmi_jack); - if (ret) { - dev_err(rtd->dev, "HDMI Jack creation failed: %d\n", ret); - return ret; - } - - return snd_soc_component_set_jack(cmpnt_codec, &priv->hdmi_jack, NULL); -} - -static int mt8186_hw_params_fixup(struct snd_soc_pcm_runtime *rtd, - struct snd_pcm_hw_params *params, - snd_pcm_format_t fmt) -{ - struct snd_interval *channels =3D hw_param_interval(params, - SNDRV_PCM_HW_PARAM_CHANNELS); - - dev_dbg(rtd->dev, "%s(), fix format to %d\n", __func__, fmt); - - /* fix BE i2s channel to 2 channel */ - channels->min =3D 2; - channels->max =3D 2; - - /* clean param mask first */ - snd_mask_reset_range(hw_param_mask(params, SNDRV_PCM_HW_PARAM_FORMAT), - 0, (__force unsigned int)SNDRV_PCM_FORMAT_LAST); - - params_set_format(params, fmt); - - return 0; -} - -static int mt8186_i2s_hw_params_fixup(struct snd_soc_pcm_runtime *rtd, - struct snd_pcm_hw_params *params) -{ - return mt8186_hw_params_fixup(rtd, params, SNDRV_PCM_FORMAT_S32_LE); -} - -static int mt8186_anx7625_i2s_hw_params_fixup(struct snd_soc_pcm_runtime *= rtd, - struct snd_pcm_hw_params *params) -{ - return mt8186_hw_params_fixup(rtd, params, SNDRV_PCM_FORMAT_S24_LE); -} - -/* fixup the BE DAI link to match any values from topology */ -static int mt8186_sof_dai_link_fixup(struct snd_soc_pcm_runtime *rtd, - struct snd_pcm_hw_params *params) -{ - int ret; - - ret =3D mtk_sof_dai_link_fixup(rtd, params); - - if (!strcmp(rtd->dai_link->name, "I2S0") || - !strcmp(rtd->dai_link->name, "I2S1") || - !strcmp(rtd->dai_link->name, "I2S2")) - mt8186_i2s_hw_params_fixup(rtd, params); - else if (!strcmp(rtd->dai_link->name, "I2S3")) - mt8186_anx7625_i2s_hw_params_fixup(rtd, params); - - return ret; -} - -static int mt8186_mt6366_da7219_max98357_playback_startup(struct snd_pcm_s= ubstream *substream) -{ - static const unsigned int rates[] =3D { - 48000 - }; - static const unsigned int channels[] =3D { - 2 - }; - static const struct snd_pcm_hw_constraint_list constraints_rates =3D { - .count =3D ARRAY_SIZE(rates), - .list =3D rates, - .mask =3D 0, - }; - static const struct snd_pcm_hw_constraint_list constraints_channels =3D { - .count =3D ARRAY_SIZE(channels), - .list =3D channels, - .mask =3D 0, - }; - - struct snd_soc_pcm_runtime *rtd =3D snd_soc_substream_to_rtd(substream); - struct snd_pcm_runtime *runtime =3D substream->runtime; - int ret; - - ret =3D snd_pcm_hw_constraint_list(runtime, 0, - SNDRV_PCM_HW_PARAM_RATE, - &constraints_rates); - if (ret < 0) { - dev_err(rtd->dev, "hw_constraint_list rate failed\n"); - return ret; - } - - ret =3D snd_pcm_hw_constraint_list(runtime, 0, - SNDRV_PCM_HW_PARAM_CHANNELS, - &constraints_channels); - if (ret < 0) { - dev_err(rtd->dev, "hw_constraint_list channel failed\n"); - return ret; - } - - return 0; -} - -static const struct snd_soc_ops mt8186_mt6366_da7219_max98357_playback_ops= =3D { - .startup =3D mt8186_mt6366_da7219_max98357_playback_startup, -}; - -static int mt8186_mt6366_da7219_max98357_capture_startup(struct snd_pcm_su= bstream *substream) -{ - static const unsigned int rates[] =3D { - 48000 - }; - static const unsigned int channels[] =3D { - 1, 2 - }; - static const struct snd_pcm_hw_constraint_list constraints_rates =3D { - .count =3D ARRAY_SIZE(rates), - .list =3D rates, - .mask =3D 0, - }; - static const struct snd_pcm_hw_constraint_list constraints_channels =3D { - .count =3D ARRAY_SIZE(channels), - .list =3D channels, - .mask =3D 0, - }; - - struct snd_soc_pcm_runtime *rtd =3D snd_soc_substream_to_rtd(substream); - struct snd_pcm_runtime *runtime =3D substream->runtime; - int ret; - - ret =3D snd_pcm_hw_constraint_list(runtime, 0, - SNDRV_PCM_HW_PARAM_RATE, - &constraints_rates); - if (ret < 0) { - dev_err(rtd->dev, "hw_constraint_list rate failed\n"); - return ret; - } - - ret =3D snd_pcm_hw_constraint_list(runtime, 0, - SNDRV_PCM_HW_PARAM_CHANNELS, - &constraints_channels); - if (ret < 0) { - dev_err(rtd->dev, "hw_constraint_list channel failed\n"); - return ret; - } - - return 0; -} - -static const struct snd_soc_ops mt8186_mt6366_da7219_max98357_capture_ops = =3D { - .startup =3D mt8186_mt6366_da7219_max98357_capture_startup, -}; - -/* FE */ -SND_SOC_DAILINK_DEFS(playback1, - DAILINK_COMP_ARRAY(COMP_CPU("DL1")), - DAILINK_COMP_ARRAY(COMP_DUMMY()), - DAILINK_COMP_ARRAY(COMP_EMPTY())); - -SND_SOC_DAILINK_DEFS(playback12, - DAILINK_COMP_ARRAY(COMP_CPU("DL12")), - DAILINK_COMP_ARRAY(COMP_DUMMY()), - DAILINK_COMP_ARRAY(COMP_EMPTY())); - -SND_SOC_DAILINK_DEFS(playback2, - DAILINK_COMP_ARRAY(COMP_CPU("DL2")), - DAILINK_COMP_ARRAY(COMP_DUMMY()), - DAILINK_COMP_ARRAY(COMP_EMPTY())); - -SND_SOC_DAILINK_DEFS(playback3, - DAILINK_COMP_ARRAY(COMP_CPU("DL3")), - DAILINK_COMP_ARRAY(COMP_DUMMY()), - DAILINK_COMP_ARRAY(COMP_EMPTY())); - -SND_SOC_DAILINK_DEFS(playback4, - DAILINK_COMP_ARRAY(COMP_CPU("DL4")), - DAILINK_COMP_ARRAY(COMP_DUMMY()), - DAILINK_COMP_ARRAY(COMP_EMPTY())); - -SND_SOC_DAILINK_DEFS(playback5, - DAILINK_COMP_ARRAY(COMP_CPU("DL5")), - DAILINK_COMP_ARRAY(COMP_DUMMY()), - DAILINK_COMP_ARRAY(COMP_EMPTY())); - -SND_SOC_DAILINK_DEFS(playback6, - DAILINK_COMP_ARRAY(COMP_CPU("DL6")), - DAILINK_COMP_ARRAY(COMP_DUMMY()), - DAILINK_COMP_ARRAY(COMP_EMPTY())); - -SND_SOC_DAILINK_DEFS(playback7, - DAILINK_COMP_ARRAY(COMP_CPU("DL7")), - DAILINK_COMP_ARRAY(COMP_DUMMY()), - DAILINK_COMP_ARRAY(COMP_EMPTY())); - -SND_SOC_DAILINK_DEFS(playback8, - DAILINK_COMP_ARRAY(COMP_CPU("DL8")), - DAILINK_COMP_ARRAY(COMP_DUMMY()), - DAILINK_COMP_ARRAY(COMP_EMPTY())); - -SND_SOC_DAILINK_DEFS(capture1, - DAILINK_COMP_ARRAY(COMP_CPU("UL1")), - DAILINK_COMP_ARRAY(COMP_DUMMY()), - DAILINK_COMP_ARRAY(COMP_EMPTY())); - -SND_SOC_DAILINK_DEFS(capture2, - DAILINK_COMP_ARRAY(COMP_CPU("UL2")), - DAILINK_COMP_ARRAY(COMP_DUMMY()), - DAILINK_COMP_ARRAY(COMP_EMPTY())); - -SND_SOC_DAILINK_DEFS(capture3, - DAILINK_COMP_ARRAY(COMP_CPU("UL3")), - DAILINK_COMP_ARRAY(COMP_DUMMY()), - DAILINK_COMP_ARRAY(COMP_EMPTY())); - -SND_SOC_DAILINK_DEFS(capture4, - DAILINK_COMP_ARRAY(COMP_CPU("UL4")), - DAILINK_COMP_ARRAY(COMP_DUMMY()), - DAILINK_COMP_ARRAY(COMP_EMPTY())); - -SND_SOC_DAILINK_DEFS(capture5, - DAILINK_COMP_ARRAY(COMP_CPU("UL5")), - DAILINK_COMP_ARRAY(COMP_DUMMY()), - DAILINK_COMP_ARRAY(COMP_EMPTY())); - -SND_SOC_DAILINK_DEFS(capture6, - DAILINK_COMP_ARRAY(COMP_CPU("UL6")), - DAILINK_COMP_ARRAY(COMP_DUMMY()), - DAILINK_COMP_ARRAY(COMP_EMPTY())); - -SND_SOC_DAILINK_DEFS(capture7, - DAILINK_COMP_ARRAY(COMP_CPU("UL7")), - DAILINK_COMP_ARRAY(COMP_DUMMY()), - DAILINK_COMP_ARRAY(COMP_EMPTY())); - -/* hostless */ -SND_SOC_DAILINK_DEFS(hostless_lpbk, - DAILINK_COMP_ARRAY(COMP_CPU("Hostless LPBK DAI")), - DAILINK_COMP_ARRAY(COMP_DUMMY()), - DAILINK_COMP_ARRAY(COMP_EMPTY())); -SND_SOC_DAILINK_DEFS(hostless_fm, - DAILINK_COMP_ARRAY(COMP_CPU("Hostless FM DAI")), - DAILINK_COMP_ARRAY(COMP_DUMMY()), - DAILINK_COMP_ARRAY(COMP_EMPTY())); -SND_SOC_DAILINK_DEFS(hostless_src1, - DAILINK_COMP_ARRAY(COMP_CPU("Hostless_SRC_1_DAI")), - DAILINK_COMP_ARRAY(COMP_DUMMY()), - DAILINK_COMP_ARRAY(COMP_EMPTY())); -SND_SOC_DAILINK_DEFS(hostless_src_bargein, - DAILINK_COMP_ARRAY(COMP_CPU("Hostless_SRC_Bargein_DAI")), - DAILINK_COMP_ARRAY(COMP_DUMMY()), - DAILINK_COMP_ARRAY(COMP_EMPTY())); - -/* BE */ -SND_SOC_DAILINK_DEFS(adda, - DAILINK_COMP_ARRAY(COMP_CPU("ADDA")), - DAILINK_COMP_ARRAY(COMP_CODEC("mt6358-sound", - "mt6358-snd-codec-aif1"), - COMP_CODEC("dmic-codec", - "dmic-hifi")), - DAILINK_COMP_ARRAY(COMP_EMPTY())); -SND_SOC_DAILINK_DEFS(i2s0, - DAILINK_COMP_ARRAY(COMP_CPU("I2S0")), - DAILINK_COMP_ARRAY(COMP_EMPTY()), - DAILINK_COMP_ARRAY(COMP_EMPTY())); -SND_SOC_DAILINK_DEFS(i2s1, - DAILINK_COMP_ARRAY(COMP_CPU("I2S1")), - DAILINK_COMP_ARRAY(COMP_EMPTY()), - DAILINK_COMP_ARRAY(COMP_EMPTY())); -SND_SOC_DAILINK_DEFS(i2s2, - DAILINK_COMP_ARRAY(COMP_CPU("I2S2")), - DAILINK_COMP_ARRAY(COMP_DUMMY()), - DAILINK_COMP_ARRAY(COMP_EMPTY())); -SND_SOC_DAILINK_DEFS(i2s3, - DAILINK_COMP_ARRAY(COMP_CPU("I2S3")), - DAILINK_COMP_ARRAY(COMP_EMPTY()), - DAILINK_COMP_ARRAY(COMP_EMPTY())); -SND_SOC_DAILINK_DEFS(hw_gain1, - DAILINK_COMP_ARRAY(COMP_CPU("HW Gain 1")), - DAILINK_COMP_ARRAY(COMP_DUMMY()), - DAILINK_COMP_ARRAY(COMP_EMPTY())); -SND_SOC_DAILINK_DEFS(hw_gain2, - DAILINK_COMP_ARRAY(COMP_CPU("HW Gain 2")), - DAILINK_COMP_ARRAY(COMP_DUMMY()), - DAILINK_COMP_ARRAY(COMP_EMPTY())); -SND_SOC_DAILINK_DEFS(hw_src1, - DAILINK_COMP_ARRAY(COMP_CPU("HW_SRC_1")), - DAILINK_COMP_ARRAY(COMP_DUMMY()), - DAILINK_COMP_ARRAY(COMP_EMPTY())); -SND_SOC_DAILINK_DEFS(hw_src2, - DAILINK_COMP_ARRAY(COMP_CPU("HW_SRC_2")), - DAILINK_COMP_ARRAY(COMP_DUMMY()), - DAILINK_COMP_ARRAY(COMP_EMPTY())); -SND_SOC_DAILINK_DEFS(connsys_i2s, - DAILINK_COMP_ARRAY(COMP_CPU("CONNSYS_I2S")), - DAILINK_COMP_ARRAY(COMP_DUMMY()), - DAILINK_COMP_ARRAY(COMP_EMPTY())); -SND_SOC_DAILINK_DEFS(pcm1, - DAILINK_COMP_ARRAY(COMP_CPU("PCM 1")), - DAILINK_COMP_ARRAY(COMP_CODEC("bt-sco", "bt-sco-pcm-wb")), - DAILINK_COMP_ARRAY(COMP_EMPTY())); -SND_SOC_DAILINK_DEFS(tdm_in, - DAILINK_COMP_ARRAY(COMP_CPU("TDM IN")), - DAILINK_COMP_ARRAY(COMP_DUMMY()), - DAILINK_COMP_ARRAY(COMP_EMPTY())); - -/* hostless */ -SND_SOC_DAILINK_DEFS(hostless_ul1, - DAILINK_COMP_ARRAY(COMP_CPU("Hostless_UL1 DAI")), - DAILINK_COMP_ARRAY(COMP_DUMMY()), - DAILINK_COMP_ARRAY(COMP_EMPTY())); -SND_SOC_DAILINK_DEFS(hostless_ul2, - DAILINK_COMP_ARRAY(COMP_CPU("Hostless_UL2 DAI")), - DAILINK_COMP_ARRAY(COMP_DUMMY()), - DAILINK_COMP_ARRAY(COMP_EMPTY())); -SND_SOC_DAILINK_DEFS(hostless_ul3, - DAILINK_COMP_ARRAY(COMP_CPU("Hostless_UL3 DAI")), - DAILINK_COMP_ARRAY(COMP_DUMMY()), - DAILINK_COMP_ARRAY(COMP_EMPTY())); -SND_SOC_DAILINK_DEFS(hostless_ul5, - DAILINK_COMP_ARRAY(COMP_CPU("Hostless_UL5 DAI")), - DAILINK_COMP_ARRAY(COMP_DUMMY()), - DAILINK_COMP_ARRAY(COMP_EMPTY())); -SND_SOC_DAILINK_DEFS(hostless_ul6, - DAILINK_COMP_ARRAY(COMP_CPU("Hostless_UL6 DAI")), - DAILINK_COMP_ARRAY(COMP_DUMMY()), - DAILINK_COMP_ARRAY(COMP_EMPTY())); -SND_SOC_DAILINK_DEFS(hostless_hw_gain_aaudio, - DAILINK_COMP_ARRAY(COMP_CPU("Hostless HW Gain AAudio DAI")), - DAILINK_COMP_ARRAY(COMP_DUMMY()), - DAILINK_COMP_ARRAY(COMP_EMPTY())); -SND_SOC_DAILINK_DEFS(hostless_src_aaudio, - DAILINK_COMP_ARRAY(COMP_CPU("Hostless SRC AAudio DAI")), - DAILINK_COMP_ARRAY(COMP_DUMMY()), - DAILINK_COMP_ARRAY(COMP_EMPTY())); -SND_SOC_DAILINK_DEFS(AFE_SOF_DL1, - DAILINK_COMP_ARRAY(COMP_CPU("SOF_DL1")), - DAILINK_COMP_ARRAY(COMP_DUMMY()), - DAILINK_COMP_ARRAY(COMP_EMPTY())); - -SND_SOC_DAILINK_DEFS(AFE_SOF_DL2, - DAILINK_COMP_ARRAY(COMP_CPU("SOF_DL2")), - DAILINK_COMP_ARRAY(COMP_DUMMY()), - DAILINK_COMP_ARRAY(COMP_EMPTY())); - -SND_SOC_DAILINK_DEFS(AFE_SOF_UL1, - DAILINK_COMP_ARRAY(COMP_CPU("SOF_UL1")), - DAILINK_COMP_ARRAY(COMP_DUMMY()), - DAILINK_COMP_ARRAY(COMP_EMPTY())); - -SND_SOC_DAILINK_DEFS(AFE_SOF_UL2, - DAILINK_COMP_ARRAY(COMP_CPU("SOF_UL2")), - DAILINK_COMP_ARRAY(COMP_DUMMY()), - DAILINK_COMP_ARRAY(COMP_EMPTY())); - -static const struct sof_conn_stream g_sof_conn_streams[] =3D { - { "I2S1", "AFE_SOF_DL1", SOF_DMA_DL1, SNDRV_PCM_STREAM_PLAYBACK}, - { "I2S3", "AFE_SOF_DL2", SOF_DMA_DL2, SNDRV_PCM_STREAM_PLAYBACK}, - { "Primary Codec", "AFE_SOF_UL1", SOF_DMA_UL1, SNDRV_PCM_STREAM_CAPTURE}, - { "I2S0", "AFE_SOF_UL2", SOF_DMA_UL2, SNDRV_PCM_STREAM_CAPTURE}, -}; - -static struct snd_soc_dai_link mt8186_mt6366_da7219_max98357_dai_links[] = =3D { - /* Front End DAI links */ - { - .name =3D "Playback_1", - .stream_name =3D "Playback_1", - .trigger =3D {SND_SOC_DPCM_TRIGGER_PRE, - SND_SOC_DPCM_TRIGGER_PRE}, - .dynamic =3D 1, - .dpcm_playback =3D 1, - .dpcm_merged_format =3D 1, - .dpcm_merged_chan =3D 1, - .dpcm_merged_rate =3D 1, - .ops =3D &mt8186_mt6366_da7219_max98357_playback_ops, - SND_SOC_DAILINK_REG(playback1), - }, - { - .name =3D "Playback_12", - .stream_name =3D "Playback_12", - .trigger =3D {SND_SOC_DPCM_TRIGGER_PRE, - SND_SOC_DPCM_TRIGGER_PRE}, - .dynamic =3D 1, - .dpcm_playback =3D 1, - SND_SOC_DAILINK_REG(playback12), - }, - { - .name =3D "Playback_2", - .stream_name =3D "Playback_2", - .trigger =3D {SND_SOC_DPCM_TRIGGER_PRE, - SND_SOC_DPCM_TRIGGER_PRE}, - .dynamic =3D 1, - .dpcm_playback =3D 1, - .dpcm_merged_format =3D 1, - .dpcm_merged_chan =3D 1, - .dpcm_merged_rate =3D 1, - SND_SOC_DAILINK_REG(playback2), - }, - { - .name =3D "Playback_3", - .stream_name =3D "Playback_3", - .trigger =3D {SND_SOC_DPCM_TRIGGER_PRE, - SND_SOC_DPCM_TRIGGER_PRE}, - .dynamic =3D 1, - .dpcm_playback =3D 1, - .dpcm_merged_format =3D 1, - .dpcm_merged_chan =3D 1, - .dpcm_merged_rate =3D 1, - .ops =3D &mt8186_mt6366_da7219_max98357_playback_ops, - SND_SOC_DAILINK_REG(playback3), - }, - { - .name =3D "Playback_4", - .stream_name =3D "Playback_4", - .trigger =3D {SND_SOC_DPCM_TRIGGER_PRE, - SND_SOC_DPCM_TRIGGER_PRE}, - .dynamic =3D 1, - .dpcm_playback =3D 1, - SND_SOC_DAILINK_REG(playback4), - }, - { - .name =3D "Playback_5", - .stream_name =3D "Playback_5", - .trigger =3D {SND_SOC_DPCM_TRIGGER_PRE, - SND_SOC_DPCM_TRIGGER_PRE}, - .dynamic =3D 1, - .dpcm_playback =3D 1, - SND_SOC_DAILINK_REG(playback5), - }, - { - .name =3D "Playback_6", - .stream_name =3D "Playback_6", - .trigger =3D {SND_SOC_DPCM_TRIGGER_PRE, - SND_SOC_DPCM_TRIGGER_PRE}, - .dynamic =3D 1, - .dpcm_playback =3D 1, - SND_SOC_DAILINK_REG(playback6), - }, - { - .name =3D "Playback_7", - .stream_name =3D "Playback_7", - .trigger =3D {SND_SOC_DPCM_TRIGGER_PRE, - SND_SOC_DPCM_TRIGGER_PRE}, - .dynamic =3D 1, - .dpcm_playback =3D 1, - SND_SOC_DAILINK_REG(playback7), - }, - { - .name =3D "Playback_8", - .stream_name =3D "Playback_8", - .trigger =3D {SND_SOC_DPCM_TRIGGER_PRE, - SND_SOC_DPCM_TRIGGER_PRE}, - .dynamic =3D 1, - .dpcm_playback =3D 1, - SND_SOC_DAILINK_REG(playback8), - }, - { - .name =3D "Capture_1", - .stream_name =3D "Capture_1", - .trigger =3D {SND_SOC_DPCM_TRIGGER_PRE, - SND_SOC_DPCM_TRIGGER_PRE}, - .dynamic =3D 1, - .dpcm_capture =3D 1, - SND_SOC_DAILINK_REG(capture1), - }, - { - .name =3D "Capture_2", - .stream_name =3D "Capture_2", - .trigger =3D {SND_SOC_DPCM_TRIGGER_PRE, - SND_SOC_DPCM_TRIGGER_PRE}, - .dynamic =3D 1, - .dpcm_capture =3D 1, - .dpcm_merged_format =3D 1, - .dpcm_merged_chan =3D 1, - .dpcm_merged_rate =3D 1, - .ops =3D &mt8186_mt6366_da7219_max98357_capture_ops, - SND_SOC_DAILINK_REG(capture2), - }, - { - .name =3D "Capture_3", - .stream_name =3D "Capture_3", - .trigger =3D {SND_SOC_DPCM_TRIGGER_PRE, - SND_SOC_DPCM_TRIGGER_PRE}, - .dynamic =3D 1, - .dpcm_capture =3D 1, - SND_SOC_DAILINK_REG(capture3), - }, - { - .name =3D "Capture_4", - .stream_name =3D "Capture_4", - .trigger =3D {SND_SOC_DPCM_TRIGGER_PRE, - SND_SOC_DPCM_TRIGGER_PRE}, - .dynamic =3D 1, - .dpcm_capture =3D 1, - .dpcm_merged_format =3D 1, - .dpcm_merged_chan =3D 1, - .dpcm_merged_rate =3D 1, - .ops =3D &mt8186_mt6366_da7219_max98357_capture_ops, - SND_SOC_DAILINK_REG(capture4), - }, - { - .name =3D "Capture_5", - .stream_name =3D "Capture_5", - .trigger =3D {SND_SOC_DPCM_TRIGGER_PRE, - SND_SOC_DPCM_TRIGGER_PRE}, - .dynamic =3D 1, - .dpcm_capture =3D 1, - SND_SOC_DAILINK_REG(capture5), - }, - { - .name =3D "Capture_6", - .stream_name =3D "Capture_6", - .trigger =3D {SND_SOC_DPCM_TRIGGER_PRE, - SND_SOC_DPCM_TRIGGER_PRE}, - .dynamic =3D 1, - .dpcm_capture =3D 1, - .dpcm_merged_format =3D 1, - .dpcm_merged_chan =3D 1, - .dpcm_merged_rate =3D 1, - SND_SOC_DAILINK_REG(capture6), - }, - { - .name =3D "Capture_7", - .stream_name =3D "Capture_7", - .trigger =3D {SND_SOC_DPCM_TRIGGER_PRE, - SND_SOC_DPCM_TRIGGER_PRE}, - .dynamic =3D 1, - .dpcm_capture =3D 1, - SND_SOC_DAILINK_REG(capture7), - }, - { - .name =3D "Hostless_LPBK", - .stream_name =3D "Hostless_LPBK", - .trigger =3D {SND_SOC_DPCM_TRIGGER_PRE, - SND_SOC_DPCM_TRIGGER_PRE}, - .dynamic =3D 1, - .dpcm_playback =3D 1, - .dpcm_capture =3D 1, - .ignore_suspend =3D 1, - SND_SOC_DAILINK_REG(hostless_lpbk), - }, - { - .name =3D "Hostless_FM", - .stream_name =3D "Hostless_FM", - .trigger =3D {SND_SOC_DPCM_TRIGGER_PRE, - SND_SOC_DPCM_TRIGGER_PRE}, - .dynamic =3D 1, - .dpcm_playback =3D 1, - .dpcm_capture =3D 1, - .ignore_suspend =3D 1, - SND_SOC_DAILINK_REG(hostless_fm), - }, - { - .name =3D "Hostless_SRC_1", - .stream_name =3D "Hostless_SRC_1", - .trigger =3D {SND_SOC_DPCM_TRIGGER_PRE, - SND_SOC_DPCM_TRIGGER_PRE}, - .dynamic =3D 1, - .dpcm_playback =3D 1, - .dpcm_capture =3D 1, - .ignore_suspend =3D 1, - SND_SOC_DAILINK_REG(hostless_src1), - }, - { - .name =3D "Hostless_SRC_Bargein", - .stream_name =3D "Hostless_SRC_Bargein", - .trigger =3D {SND_SOC_DPCM_TRIGGER_PRE, - SND_SOC_DPCM_TRIGGER_PRE}, - .dynamic =3D 1, - .dpcm_playback =3D 1, - .dpcm_capture =3D 1, - .ignore_suspend =3D 1, - SND_SOC_DAILINK_REG(hostless_src_bargein), - }, - { - .name =3D "Hostless_HW_Gain_AAudio", - .stream_name =3D "Hostless_HW_Gain_AAudio", - .trigger =3D {SND_SOC_DPCM_TRIGGER_PRE, - SND_SOC_DPCM_TRIGGER_PRE}, - .dynamic =3D 1, - .dpcm_capture =3D 1, - .ignore_suspend =3D 1, - SND_SOC_DAILINK_REG(hostless_hw_gain_aaudio), - }, - { - .name =3D "Hostless_SRC_AAudio", - .stream_name =3D "Hostless_SRC_AAudio", - .trigger =3D {SND_SOC_DPCM_TRIGGER_PRE, - SND_SOC_DPCM_TRIGGER_PRE}, - .dynamic =3D 1, - .dpcm_playback =3D 1, - .dpcm_capture =3D 1, - .ignore_suspend =3D 1, - SND_SOC_DAILINK_REG(hostless_src_aaudio), - }, - /* Back End DAI links */ - { - .name =3D "Primary Codec", - .no_pcm =3D 1, - .dpcm_playback =3D 1, - .dpcm_capture =3D 1, - .ignore_suspend =3D 1, - .init =3D mt8186_mt6366_init, - SND_SOC_DAILINK_REG(adda), - }, - { - .name =3D "I2S3", - .no_pcm =3D 1, - .dai_fmt =3D SND_SOC_DAIFMT_I2S | - SND_SOC_DAIFMT_IB_IF | - SND_SOC_DAIFMT_CBM_CFM, - .dpcm_playback =3D 1, - .ignore_suspend =3D 1, - .init =3D mt8186_mt6366_da7219_max98357_hdmi_init, - .be_hw_params_fixup =3D mt8186_anx7625_i2s_hw_params_fixup, - SND_SOC_DAILINK_REG(i2s3), - }, - { - .name =3D "I2S0", - .no_pcm =3D 1, - .dpcm_capture =3D 1, - .ignore_suspend =3D 1, - .be_hw_params_fixup =3D mt8186_i2s_hw_params_fixup, - .ops =3D &mt8186_da7219_i2s_ops, - SND_SOC_DAILINK_REG(i2s0), - }, - { - .name =3D "I2S1", - .no_pcm =3D 1, - .dpcm_playback =3D 1, - .ignore_suspend =3D 1, - .be_hw_params_fixup =3D mt8186_i2s_hw_params_fixup, - .init =3D mt8186_da7219_init, - .ops =3D &mt8186_da7219_i2s_ops, - SND_SOC_DAILINK_REG(i2s1), - }, - { - .name =3D "I2S2", - .no_pcm =3D 1, - .dpcm_capture =3D 1, - .ignore_suspend =3D 1, - .be_hw_params_fixup =3D mt8186_i2s_hw_params_fixup, - SND_SOC_DAILINK_REG(i2s2), - }, - { - .name =3D "HW Gain 1", - .no_pcm =3D 1, - .dpcm_playback =3D 1, - .dpcm_capture =3D 1, - .ignore_suspend =3D 1, - SND_SOC_DAILINK_REG(hw_gain1), - }, - { - .name =3D "HW Gain 2", - .no_pcm =3D 1, - .dpcm_playback =3D 1, - .dpcm_capture =3D 1, - .ignore_suspend =3D 1, - SND_SOC_DAILINK_REG(hw_gain2), - }, - { - .name =3D "HW_SRC_1", - .no_pcm =3D 1, - .dpcm_playback =3D 1, - .dpcm_capture =3D 1, - .ignore_suspend =3D 1, - SND_SOC_DAILINK_REG(hw_src1), - }, - { - .name =3D "HW_SRC_2", - .no_pcm =3D 1, - .dpcm_playback =3D 1, - .dpcm_capture =3D 1, - .ignore_suspend =3D 1, - SND_SOC_DAILINK_REG(hw_src2), - }, - { - .name =3D "CONNSYS_I2S", - .no_pcm =3D 1, - .dpcm_capture =3D 1, - .ignore_suspend =3D 1, - SND_SOC_DAILINK_REG(connsys_i2s), - }, - { - .name =3D "PCM 1", - .dai_fmt =3D SND_SOC_DAIFMT_I2S | - SND_SOC_DAIFMT_NB_IF, - .no_pcm =3D 1, - .dpcm_playback =3D 1, - .dpcm_capture =3D 1, - .ignore_suspend =3D 1, - SND_SOC_DAILINK_REG(pcm1), - }, - { - .name =3D "TDM IN", - .no_pcm =3D 1, - .dpcm_capture =3D 1, - .ignore_suspend =3D 1, - SND_SOC_DAILINK_REG(tdm_in), - }, - /* dummy BE for ul memif to record from dl memif */ - { - .name =3D "Hostless_UL1", - .no_pcm =3D 1, - .dpcm_capture =3D 1, - .ignore_suspend =3D 1, - SND_SOC_DAILINK_REG(hostless_ul1), - }, - { - .name =3D "Hostless_UL2", - .no_pcm =3D 1, - .dpcm_capture =3D 1, - .ignore_suspend =3D 1, - SND_SOC_DAILINK_REG(hostless_ul2), - }, - { - .name =3D "Hostless_UL3", - .no_pcm =3D 1, - .dpcm_capture =3D 1, - .ignore_suspend =3D 1, - SND_SOC_DAILINK_REG(hostless_ul3), - }, - { - .name =3D "Hostless_UL5", - .no_pcm =3D 1, - .dpcm_capture =3D 1, - .ignore_suspend =3D 1, - SND_SOC_DAILINK_REG(hostless_ul5), - }, - { - .name =3D "Hostless_UL6", - .no_pcm =3D 1, - .dpcm_capture =3D 1, - .ignore_suspend =3D 1, - SND_SOC_DAILINK_REG(hostless_ul6), - }, - /* SOF BE */ - { - .name =3D "AFE_SOF_DL1", - .no_pcm =3D 1, - .dpcm_playback =3D 1, - SND_SOC_DAILINK_REG(AFE_SOF_DL1), - }, - { - .name =3D "AFE_SOF_DL2", - .no_pcm =3D 1, - .dpcm_playback =3D 1, - SND_SOC_DAILINK_REG(AFE_SOF_DL2), - }, - { - .name =3D "AFE_SOF_UL1", - .no_pcm =3D 1, - .dpcm_capture =3D 1, - SND_SOC_DAILINK_REG(AFE_SOF_UL1), - }, - { - .name =3D "AFE_SOF_UL2", - .no_pcm =3D 1, - .dpcm_capture =3D 1, - SND_SOC_DAILINK_REG(AFE_SOF_UL2), - }, -}; - -static const struct snd_soc_dapm_widget -mt8186_mt6366_da7219_max98357_widgets[] =3D { - SND_SOC_DAPM_SPK("Speakers", NULL), - SND_SOC_DAPM_HP("Headphones", NULL), - SND_SOC_DAPM_MIC("Headset Mic", NULL), - SND_SOC_DAPM_LINE("Line Out", NULL), - SND_SOC_DAPM_OUTPUT("HDMI1"), - SND_SOC_DAPM_MIXER(SOF_DMA_DL1, SND_SOC_NOPM, 0, 0, NULL, 0), - SND_SOC_DAPM_MIXER(SOF_DMA_DL2, SND_SOC_NOPM, 0, 0, NULL, 0), - SND_SOC_DAPM_MIXER(SOF_DMA_UL1, SND_SOC_NOPM, 0, 0, NULL, 0), - SND_SOC_DAPM_MIXER(SOF_DMA_UL2, SND_SOC_NOPM, 0, 0, NULL, 0), -}; - -static const struct snd_soc_dapm_route -mt8186_mt6366_da7219_max98357_routes[] =3D { - /* SPK */ - { "Speakers", NULL, "Speaker"}, - /* Headset */ - { "Headphones", NULL, "HPL" }, - { "Headphones", NULL, "HPR" }, - { "MIC", NULL, "Headset Mic" }, - /* HDMI */ - { "HDMI1", NULL, "TX"}, - /* SOF Uplink */ - {SOF_DMA_UL1, NULL, "UL1_CH1"}, - {SOF_DMA_UL1, NULL, "UL1_CH2"}, - {SOF_DMA_UL2, NULL, "UL2_CH1"}, - {SOF_DMA_UL2, NULL, "UL2_CH2"}, - /* SOF Downlink */ - {"DSP_DL1_VIRT", NULL, SOF_DMA_DL1}, - {"DSP_DL2_VIRT", NULL, SOF_DMA_DL2}, -}; - -static const struct snd_kcontrol_new -mt8186_mt6366_da7219_max98357_controls[] =3D { - SOC_DAPM_PIN_SWITCH("Speakers"), - SOC_DAPM_PIN_SWITCH("Headphones"), - SOC_DAPM_PIN_SWITCH("Headset Mic"), - SOC_DAPM_PIN_SWITCH("Line Out"), - SOC_DAPM_PIN_SWITCH("HDMI1"), -}; - -static struct snd_soc_card mt8186_mt6366_da7219_max98357_soc_card =3D { - .name =3D "mt8186_da7219_max98357", - .owner =3D THIS_MODULE, - .dai_link =3D mt8186_mt6366_da7219_max98357_dai_links, - .num_links =3D ARRAY_SIZE(mt8186_mt6366_da7219_max98357_dai_links), - .controls =3D mt8186_mt6366_da7219_max98357_controls, - .num_controls =3D ARRAY_SIZE(mt8186_mt6366_da7219_max98357_controls), - .dapm_widgets =3D mt8186_mt6366_da7219_max98357_widgets, - .num_dapm_widgets =3D ARRAY_SIZE(mt8186_mt6366_da7219_max98357_widgets), - .dapm_routes =3D mt8186_mt6366_da7219_max98357_routes, - .num_dapm_routes =3D ARRAY_SIZE(mt8186_mt6366_da7219_max98357_routes), - .codec_conf =3D mt8186_mt6366_da7219_max98357_codec_conf, - .num_configs =3D ARRAY_SIZE(mt8186_mt6366_da7219_max98357_codec_conf), -}; - -static int mt8186_mt6366_da7219_max98357_dev_probe(struct platform_device = *pdev) -{ - struct snd_soc_card *card; - struct snd_soc_dai_link *dai_link; - struct mtk_soc_card_data *soc_card_data; - struct mt8186_mt6366_da7219_max98357_priv *mach_priv; - struct device_node *platform_node, *headset_codec, *playback_codec, *adsp= _node; - int sof_on =3D 0; - int ret, i; - - card =3D (struct snd_soc_card *)device_get_match_data(&pdev->dev); - if (!card) - return -EINVAL; - card->dev =3D &pdev->dev; - - soc_card_data =3D devm_kzalloc(&pdev->dev, sizeof(*soc_card_data), GFP_KE= RNEL); - if (!soc_card_data) - return -ENOMEM; - mach_priv =3D devm_kzalloc(&pdev->dev, sizeof(*mach_priv), GFP_KERNEL); - if (!mach_priv) - return -ENOMEM; - - soc_card_data->mach_priv =3D mach_priv; - - adsp_node =3D of_parse_phandle(pdev->dev.of_node, "mediatek,adsp", 0); - if (adsp_node) { - struct mtk_sof_priv *sof_priv; - - sof_priv =3D devm_kzalloc(&pdev->dev, sizeof(*sof_priv), GFP_KERNEL); - if (!sof_priv) { - ret =3D -ENOMEM; - goto err_adsp_node; - } - sof_priv->conn_streams =3D g_sof_conn_streams; - sof_priv->num_streams =3D ARRAY_SIZE(g_sof_conn_streams); - sof_priv->sof_dai_link_fixup =3D mt8186_sof_dai_link_fixup; - soc_card_data->sof_priv =3D sof_priv; - card->probe =3D mtk_sof_card_probe; - card->late_probe =3D mtk_sof_card_late_probe; - if (!card->topology_shortname_created) { - snprintf(card->topology_shortname, 32, "sof-%s", card->name); - card->topology_shortname_created =3D true; - } - card->name =3D card->topology_shortname; - sof_on =3D 1; - } else { - dev_dbg(&pdev->dev, "Probe without adsp\n"); - } - - if (of_property_read_bool(pdev->dev.of_node, "mediatek,dai-link")) { - ret =3D mtk_sof_dailink_parse_of(card, pdev->dev.of_node, - "mediatek,dai-link", - mt8186_mt6366_da7219_max98357_dai_links, - ARRAY_SIZE(mt8186_mt6366_da7219_max98357_dai_links)); - if (ret) { - dev_dbg(&pdev->dev, "Parse dai-link fail\n"); - goto err_adsp_node; - } - } else { - if (!sof_on) - card->num_links =3D ARRAY_SIZE(mt8186_mt6366_da7219_max98357_dai_links) - - ARRAY_SIZE(g_sof_conn_streams); - } - - platform_node =3D of_parse_phandle(pdev->dev.of_node, "mediatek,platform"= , 0); - if (!platform_node) { - ret =3D -EINVAL; - dev_err_probe(&pdev->dev, ret, "Property 'platform' missing or invalid\n= "); - goto err_platform_node; - } - - playback_codec =3D of_get_child_by_name(pdev->dev.of_node, "playback-code= cs"); - if (!playback_codec) { - ret =3D -EINVAL; - dev_err_probe(&pdev->dev, ret, "Property 'speaker-codecs' missing or inv= alid\n"); - goto err_playback_codec; - } - - headset_codec =3D of_get_child_by_name(pdev->dev.of_node, "headset-codec"= ); - if (!headset_codec) { - ret =3D -EINVAL; - dev_err_probe(&pdev->dev, ret, "Property 'headset-codec' missing or inva= lid\n"); - goto err_headset_codec; - } - - for_each_card_prelinks(card, i, dai_link) { - ret =3D mt8186_mt6366_card_set_be_link(card, dai_link, playback_codec, "= I2S3"); - if (ret) { - dev_err_probe(&pdev->dev, ret, "%s set speaker_codec fail\n", - dai_link->name); - goto err_probe; - } - - ret =3D mt8186_mt6366_card_set_be_link(card, dai_link, headset_codec, "I= 2S0"); - if (ret) { - dev_err_probe(&pdev->dev, ret, "%s set headset_codec fail\n", - dai_link->name); - goto err_probe; - } - - ret =3D mt8186_mt6366_card_set_be_link(card, dai_link, headset_codec, "I= 2S1"); - if (ret) { - dev_err_probe(&pdev->dev, ret, "%s set headset_codec fail\n", - dai_link->name); - goto err_probe; - } - - if (!strncmp(dai_link->name, "AFE_SOF", strlen("AFE_SOF")) && sof_on) - dai_link->platforms->of_node =3D adsp_node; - - if (!dai_link->platforms->name && !dai_link->platforms->of_node) - dai_link->platforms->of_node =3D platform_node; - } - - snd_soc_card_set_drvdata(card, soc_card_data); - - ret =3D mt8186_afe_gpio_init(&pdev->dev); - if (ret) { - dev_err_probe(&pdev->dev, ret, "%s init gpio error\n", __func__); - goto err_probe; - } - - ret =3D devm_snd_soc_register_card(&pdev->dev, card); - if (ret) - dev_err_probe(&pdev->dev, ret, "%s snd_soc_register_card fail\n", __func= __); - -err_probe: - of_node_put(headset_codec); -err_headset_codec: - of_node_put(playback_codec); -err_playback_codec: - of_node_put(platform_node); -err_platform_node: -err_adsp_node: - of_node_put(adsp_node); - - return ret; -} - -#if IS_ENABLED(CONFIG_OF) -static const struct of_device_id mt8186_mt6366_da7219_max98357_dt_match[] = =3D { - { .compatible =3D "mediatek,mt8186-mt6366-da7219-max98357-sound", - .data =3D &mt8186_mt6366_da7219_max98357_soc_card, - }, - {} -}; -MODULE_DEVICE_TABLE(of, mt8186_mt6366_da7219_max98357_dt_match); -#endif - -static struct platform_driver mt8186_mt6366_da7219_max98357_driver =3D { - .driver =3D { - .name =3D "mt8186_mt6366_da7219_max98357", -#if IS_ENABLED(CONFIG_OF) - .of_match_table =3D mt8186_mt6366_da7219_max98357_dt_match, -#endif - .pm =3D &snd_soc_pm_ops, - }, - .probe =3D mt8186_mt6366_da7219_max98357_dev_probe, -}; - -module_platform_driver(mt8186_mt6366_da7219_max98357_driver); - -/* Module information */ -MODULE_DESCRIPTION("MT8186-MT6366-DA7219-MAX98357 ALSA SoC machine driver"= ); -MODULE_AUTHOR("Jiaxin Yu "); -MODULE_LICENSE("GPL v2"); -MODULE_ALIAS("mt8186_mt6366_da7219_max98357 soc card"); diff --git a/sound/soc/mediatek/mt8186/mt8186-mt6366-rt1019-rt5682s.c b/sou= nd/soc/mediatek/mt8186/mt8186-mt6366.c similarity index 83% rename from sound/soc/mediatek/mt8186/mt8186-mt6366-rt1019-rt5682s.c rename to sound/soc/mediatek/mt8186/mt8186-mt6366.c index 95dcf06a91cb..2f1df9b76bff 100644 --- a/sound/soc/mediatek/mt8186/mt8186-mt6366-rt1019-rt5682s.c +++ b/sound/soc/mediatek/mt8186/mt8186-mt6366.c @@ -1,11 +1,14 @@ // SPDX-License-Identifier: GPL-2.0 // -// mt8186-mt6366-rt1019-rt5682s.c -// -- MT8186-MT6366-RT1019-RT5682S ALSA SoC machine driver +// mt8186-mt6366.c +// -- MT8186-MT6366 ALSA SoC machine driver // // Copyright (c) 2022 MediaTek Inc. // Author: Jiaxin Yu // +// Copyright (c) 2024 Collabora Ltd. +// AngeloGioacchino Del Regno +// =20 #include #include @@ -16,6 +19,7 @@ #include #include =20 +#include "../../codecs/da7219.h" #include "../../codecs/mt6358.h" #include "../../codecs/rt5682.h" #include "../common/mtk-afe-platform-driver.h" @@ -33,11 +37,16 @@ #define RT5682S_CODEC_DAI "rt5682s-aif1" #define RT5682S_DEV0_NAME "rt5682s.5-001a" =20 +#define DA7219_CODEC_DAI "da7219-hifi" +#define DA7219_DEV_NAME "da7219.5-001a" + #define SOF_DMA_DL1 "SOF_DMA_DL1" #define SOF_DMA_DL2 "SOF_DMA_DL2" #define SOF_DMA_UL1 "SOF_DMA_UL1" #define SOF_DMA_UL2 "SOF_DMA_UL2" =20 +#define DA7219_CODEC_PRESENT BIT(0) + struct mt8186_mt6366_rt1019_rt5682s_priv { struct gpio_desc *dmic_sel; int dmic_switch; @@ -164,7 +173,7 @@ static int primary_codec_init(struct snd_soc_pcm_runtim= e *rtd) return ret; } =20 -static int mt8186_rt5682s_init(struct snd_soc_pcm_runtime *rtd) +static int mt8186_headset_codec_init(struct snd_soc_pcm_runtime *rtd) { struct snd_soc_component *cmpnt_afe =3D snd_soc_rtdcom_lookup(rtd, AFE_PCM_NAME); @@ -174,6 +183,13 @@ static int mt8186_rt5682s_init(struct snd_soc_pcm_runt= ime *rtd) struct snd_soc_jack *jack =3D &soc_card_data->card_data->jacks[MT8186_JAC= K_HEADSET]; struct snd_soc_component *cmpnt_codec =3D snd_soc_rtd_to_codec(rtd, 0)->component; + const int hs_keys_rt5682[] =3D { + KEY_PLAYPAUSE, KEY_VOLUMEUP, KEY_VOLUMEDOWN, KEY_VOICECOMMAND + }; + const int hs_keys_da7219[] =3D { + KEY_PLAYPAUSE, KEY_VOICECOMMAND, KEY_VOLUMEUP, KEY_VOLUMEDOWN + }; + const int *hs_keys; int ret; int type; =20 @@ -194,15 +210,90 @@ static int mt8186_rt5682s_init(struct snd_soc_pcm_run= time *rtd) return ret; } =20 - 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); + if (soc_card_data->card_data->flags & DA7219_CODEC_PRESENT) + hs_keys =3D hs_keys_da7219; + else + hs_keys =3D hs_keys_rt5682; + + snd_jack_set_key(jack->jack, SND_JACK_BTN_0, hs_keys[0]); + snd_jack_set_key(jack->jack, SND_JACK_BTN_1, hs_keys[1]); + snd_jack_set_key(jack->jack, SND_JACK_BTN_2, hs_keys[2]); + snd_jack_set_key(jack->jack, SND_JACK_BTN_3, hs_keys[3]); =20 type =3D SND_JACK_HEADSET | SND_JACK_BTN_0 | SND_JACK_BTN_1 | SND_JACK_BT= N_2 | SND_JACK_BTN_3; return snd_soc_component_set_jack(cmpnt_codec, jack, (void *)&type); } =20 +static int mt8186_da7219_i2s_hw_params(struct snd_pcm_substream *substream, + struct snd_pcm_hw_params *params) +{ + struct snd_soc_pcm_runtime *rtd =3D snd_soc_substream_to_rtd(substream); + struct snd_soc_dai *cpu_dai =3D snd_soc_rtd_to_cpu(rtd, 0); + struct snd_soc_dai *codec_dai; + unsigned int rate =3D params_rate(params); + unsigned int mclk_fs_ratio =3D 256; + unsigned int mclk_fs =3D rate * mclk_fs_ratio; + unsigned int freq; + int ret, j; + + ret =3D snd_soc_dai_set_sysclk(cpu_dai, 0, mclk_fs, SND_SOC_CLOCK_OUT); + if (ret < 0) { + dev_err(rtd->dev, "failed to set cpu dai sysclk: %d\n", ret); + return ret; + } + + for_each_rtd_codec_dais(rtd, j, codec_dai) { + if (strcmp(codec_dai->component->name, DA7219_DEV_NAME)) + continue; + + ret =3D snd_soc_dai_set_sysclk(codec_dai, DA7219_CLKSRC_MCLK, + mclk_fs, SND_SOC_CLOCK_IN); + if (ret < 0) { + dev_err(rtd->dev, "failed to set sysclk: %d\n", ret); + return ret; + } + + if ((rate % 8000) =3D=3D 0) + freq =3D DA7219_PLL_FREQ_OUT_98304; + else + freq =3D DA7219_PLL_FREQ_OUT_90316; + + ret =3D snd_soc_dai_set_pll(codec_dai, 0, DA7219_SYSCLK_PLL_SRM, + 0, freq); + if (ret) { + dev_err(rtd->dev, "failed to start PLL: %d\n", ret); + return ret; + } + } + + return 0; +} + +static int mt8186_da7219_i2s_hw_free(struct snd_pcm_substream *substream) +{ + struct snd_soc_pcm_runtime *rtd =3D snd_soc_substream_to_rtd(substream); + struct snd_soc_dai *codec_dai; + int j, ret; + + for_each_rtd_codec_dais(rtd, j, codec_dai) { + if (strcmp(codec_dai->component->name, DA7219_DEV_NAME)) + continue; + + ret =3D snd_soc_dai_set_pll(codec_dai, 0, DA7219_SYSCLK_MCLK, 0, 0); + if (ret < 0) { + dev_err(rtd->dev, "failed to stop PLL: %d\n", ret); + return ret; + } + } + + return 0; +} + +static const struct snd_soc_ops mt8186_da7219_i2s_ops =3D { + .hw_params =3D mt8186_da7219_i2s_hw_params, + .hw_free =3D mt8186_da7219_i2s_hw_free, +}; + static int mt8186_rt5682s_i2s_hw_params(struct snd_pcm_substream *substrea= m, struct snd_pcm_hw_params *params) { @@ -302,14 +393,14 @@ static int mt8186_hw_params_fixup(struct snd_soc_pcm_= runtime *rtd, return 0; } =20 -static int mt8186_i2s_hw_params_fixup(struct snd_soc_pcm_runtime *rtd, - struct snd_pcm_hw_params *params) +static int mt8186_i2s_hw_params_24le_fixup(struct snd_soc_pcm_runtime *rtd, + struct snd_pcm_hw_params *params) { return mt8186_hw_params_fixup(rtd, params, SNDRV_PCM_FORMAT_S24_LE); } =20 -static int mt8186_it6505_i2s_hw_params_fixup(struct snd_soc_pcm_runtime *r= td, - struct snd_pcm_hw_params *params) +static int mt8186_i2s_hw_params_32le_fixup(struct snd_soc_pcm_runtime *rtd, + struct snd_pcm_hw_params *params) { return mt8186_hw_params_fixup(rtd, params, SNDRV_PCM_FORMAT_S32_LE); } @@ -318,16 +409,24 @@ static int mt8186_it6505_i2s_hw_params_fixup(struct s= nd_soc_pcm_runtime *rtd, static int mt8186_sof_dai_link_fixup(struct snd_soc_pcm_runtime *rtd, struct snd_pcm_hw_params *params) { + struct mtk_soc_card_data *soc_card_data =3D snd_soc_card_get_drvdata(rtd-= >card); int ret; =20 ret =3D mtk_sof_dai_link_fixup(rtd, params); =20 if (!strcmp(rtd->dai_link->name, "I2S0") || !strcmp(rtd->dai_link->name, "I2S1") || - !strcmp(rtd->dai_link->name, "I2S2")) - mt8186_i2s_hw_params_fixup(rtd, params); - else if (!strcmp(rtd->dai_link->name, "I2S3")) - mt8186_it6505_i2s_hw_params_fixup(rtd, params); + !strcmp(rtd->dai_link->name, "I2S2")) { + if (soc_card_data->card_data->flags & DA7219_CODEC_PRESENT) + mt8186_i2s_hw_params_32le_fixup(rtd, params); + else + mt8186_i2s_hw_params_24le_fixup(rtd, params); + } else if (!strcmp(rtd->dai_link->name, "I2S3")) { + if (soc_card_data->card_data->flags & DA7219_CODEC_PRESENT) + mt8186_i2s_hw_params_24le_fixup(rtd, params); + else + mt8186_i2s_hw_params_32le_fixup(rtd, params); + } =20 return ret; } @@ -792,7 +891,6 @@ static struct snd_soc_dai_link mt8186_mt6366_rt1019_rt5= 682s_dai_links[] =3D { .dpcm_playback =3D 1, .ignore_suspend =3D 1, .init =3D mt8186_mt6366_rt1019_rt5682s_hdmi_init, - .be_hw_params_fixup =3D mt8186_it6505_i2s_hw_params_fixup, SND_SOC_DAILINK_REG(i2s3), }, { @@ -800,7 +898,6 @@ static struct snd_soc_dai_link mt8186_mt6366_rt1019_rt5= 682s_dai_links[] =3D { .no_pcm =3D 1, .dpcm_capture =3D 1, .ignore_suspend =3D 1, - .be_hw_params_fixup =3D mt8186_i2s_hw_params_fixup, .ops =3D &mt8186_rt5682s_i2s_ops, SND_SOC_DAILINK_REG(i2s0), }, @@ -809,9 +906,7 @@ static struct snd_soc_dai_link mt8186_mt6366_rt1019_rt5= 682s_dai_links[] =3D { .no_pcm =3D 1, .dpcm_playback =3D 1, .ignore_suspend =3D 1, - .be_hw_params_fixup =3D mt8186_i2s_hw_params_fixup, - .init =3D mt8186_rt5682s_init, - .ops =3D &mt8186_rt5682s_i2s_ops, + .init =3D mt8186_headset_codec_init, SND_SOC_DAILINK_REG(i2s1), }, { @@ -819,7 +914,6 @@ static struct snd_soc_dai_link mt8186_mt6366_rt1019_rt5= 682s_dai_links[] =3D { .no_pcm =3D 1, .dpcm_capture =3D 1, .ignore_suspend =3D 1, - .be_hw_params_fixup =3D mt8186_i2s_hw_params_fixup, SND_SOC_DAILINK_REG(i2s2), }, { @@ -941,6 +1035,19 @@ static struct snd_soc_dai_link mt8186_mt6366_rt1019_r= t5682s_dai_links[] =3D { }, }; =20 +static const struct snd_soc_dapm_widget +mt8186_mt6366_da7219_max98357_widgets[] =3D { + SND_SOC_DAPM_SPK("Speakers", NULL), + SND_SOC_DAPM_HP("Headphones", NULL), + SND_SOC_DAPM_MIC("Headset Mic", NULL), + SND_SOC_DAPM_LINE("Line Out", NULL), + SND_SOC_DAPM_LINE("HDMI1", NULL), + SND_SOC_DAPM_MIXER(SOF_DMA_DL1, SND_SOC_NOPM, 0, 0, NULL, 0), + SND_SOC_DAPM_MIXER(SOF_DMA_DL2, SND_SOC_NOPM, 0, 0, NULL, 0), + SND_SOC_DAPM_MIXER(SOF_DMA_UL1, SND_SOC_NOPM, 0, 0, NULL, 0), + SND_SOC_DAPM_MIXER(SOF_DMA_UL2, SND_SOC_NOPM, 0, 0, NULL, 0), +}; + static const struct snd_soc_dapm_widget mt8186_mt6366_rt1019_rt5682s_widgets[] =3D { SND_SOC_DAPM_SPK("Speakers", NULL), @@ -994,6 +1101,14 @@ static const struct snd_soc_dapm_route mt8186_mt6366_= rt5650_routes[] =3D { {"DSP_DL2_VIRT", NULL, SOF_DMA_DL2}, }; =20 +static const struct snd_kcontrol_new mt8186_mt6366_da7219_max98357_control= s[] =3D { + SOC_DAPM_PIN_SWITCH("Speakers"), + SOC_DAPM_PIN_SWITCH("Headphones"), + SOC_DAPM_PIN_SWITCH("Headset Mic"), + SOC_DAPM_PIN_SWITCH("Line Out"), + SOC_DAPM_PIN_SWITCH("HDMI1"), +}; + static const struct snd_kcontrol_new mt8186_mt6366_rt1019_rt5682s_controls[] =3D { SOC_DAPM_PIN_SWITCH("Speakers"), @@ -1002,6 +1117,21 @@ mt8186_mt6366_rt1019_rt5682s_controls[] =3D { SOC_DAPM_PIN_SWITCH("HDMI1"), }; =20 +static struct snd_soc_card mt8186_mt6366_da7219_max98357_soc_card =3D { + .name =3D "mt8186_da7219_max98357", + .owner =3D THIS_MODULE, + .dai_link =3D mt8186_mt6366_rt1019_rt5682s_dai_links, + .num_links =3D ARRAY_SIZE(mt8186_mt6366_rt1019_rt5682s_dai_links), + .controls =3D mt8186_mt6366_da7219_max98357_controls, + .num_controls =3D ARRAY_SIZE(mt8186_mt6366_da7219_max98357_controls), + .dapm_widgets =3D mt8186_mt6366_da7219_max98357_widgets, + .num_dapm_widgets =3D ARRAY_SIZE(mt8186_mt6366_da7219_max98357_widgets), + .dapm_routes =3D mt8186_mt6366_rt1019_rt5682s_routes, + .num_dapm_routes =3D ARRAY_SIZE(mt8186_mt6366_rt1019_rt5682s_routes), + .codec_conf =3D mt8186_mt6366_rt1019_rt5682s_codec_conf, + .num_configs =3D ARRAY_SIZE(mt8186_mt6366_rt1019_rt5682s_codec_conf), +}; + static struct snd_soc_card mt8186_mt6366_rt1019_rt5682s_soc_card =3D { .name =3D "mt8186_rt1019_rt5682s", .owner =3D THIS_MODULE, @@ -1100,8 +1230,9 @@ static int mt8186_mt6366_soc_card_probe(struct mtk_so= c_card_data *soc_card_data, { struct mtk_platform_card_data *card_data =3D soc_card_data->card_data; struct snd_soc_card *card =3D card_data->card; + struct snd_soc_dai_link *dai_link; struct mt8186_mt6366_rt1019_rt5682s_priv *mach_priv; - int ret; + int i, ret; =20 mach_priv =3D devm_kzalloc(card->dev, sizeof(*mach_priv), GFP_KERNEL); if (!mach_priv) @@ -1115,6 +1246,25 @@ static int mt8186_mt6366_soc_card_probe(struct mtk_s= oc_card_data *soc_card_data, return dev_err_probe(card->dev, PTR_ERR(mach_priv->dmic_sel), "DMIC gpio failed\n"); =20 + for_each_card_prelinks(card, i, dai_link) { + if (strcmp(dai_link->name, "I2S0") =3D=3D 0 || + strcmp(dai_link->name, "I2S1") =3D=3D 0 || + strcmp(dai_link->name, "I2S2") =3D=3D 0) { + if (card_data->flags & DA7219_CODEC_PRESENT) { + dai_link->be_hw_params_fixup =3D mt8186_i2s_hw_params_32le_fixup; + dai_link->ops =3D &mt8186_da7219_i2s_ops; + } else { + dai_link->be_hw_params_fixup =3D mt8186_i2s_hw_params_24le_fixup; + dai_link->ops =3D &mt8186_rt5682s_i2s_ops; + } + } else if (strcmp(dai_link->name, "I2S3") =3D=3D 0) { + if (card_data->flags & DA7219_CODEC_PRESENT) + dai_link->be_hw_params_fixup =3D mt8186_i2s_hw_params_24le_fixup; + else + dai_link->be_hw_params_fixup =3D mt8186_i2s_hw_params_32le_fixup; + } + } + if (legacy) { ret =3D mt8186_mt6366_legacy_probe(soc_card_data); if (ret) @@ -1160,6 +1310,18 @@ static const struct mtk_sof_priv mt8186_sof_priv =3D= { .sof_dai_link_fixup =3D mt8186_sof_dai_link_fixup }; =20 +static const struct mtk_soundcard_pdata mt8186_mt6366_da7219_max98357_pdat= a =3D { + .card_data =3D &(struct mtk_platform_card_data) { + .card =3D &mt8186_mt6366_da7219_max98357_soc_card, + .num_jacks =3D MT8186_JACK_MAX, + .pcm_constraints =3D mt8186_pcm_constraints, + .num_pcm_constraints =3D ARRAY_SIZE(mt8186_pcm_constraints), + .flags =3D DA7219_CODEC_PRESENT, + }, + .sof_priv =3D &mt8186_sof_priv, + .soc_probe =3D mt8186_mt6366_soc_card_probe +}; + static const struct mtk_soundcard_pdata mt8186_mt6366_rt1019_rt5682s_pdata= =3D { .card_data =3D &(struct mtk_platform_card_data) { .card =3D &mt8186_mt6366_rt1019_rt5682s_soc_card, @@ -1194,7 +1356,7 @@ static const struct mtk_soundcard_pdata mt8186_mt6366= _rt5650_pdata =3D { }; =20 #if IS_ENABLED(CONFIG_OF) -static const struct of_device_id mt8186_mt6366_rt1019_rt5682s_dt_match[] = =3D { +static const struct of_device_id mt8186_mt6366_dt_match[] =3D { { .compatible =3D "mediatek,mt8186-mt6366-rt1019-rt5682s-sound", .data =3D &mt8186_mt6366_rt1019_rt5682s_pdata, @@ -1207,26 +1369,30 @@ static const struct of_device_id mt8186_mt6366_rt10= 19_rt5682s_dt_match[] =3D { .compatible =3D "mediatek,mt8186-mt6366-rt5650-sound", .data =3D &mt8186_mt6366_rt5650_pdata, }, - {} + { + .compatible =3D "mediatek,mt8186-mt6366-da7219-max98357-sound", + .data =3D &mt8186_mt6366_da7219_max98357_pdata, + }, + { /* sentinel */ } }; -MODULE_DEVICE_TABLE(of, mt8186_mt6366_rt1019_rt5682s_dt_match); +MODULE_DEVICE_TABLE(of, mt8186_mt6366_dt_match); #endif =20 -static struct platform_driver mt8186_mt6366_rt1019_rt5682s_driver =3D { +static struct platform_driver mt8186_mt6366_driver =3D { .driver =3D { - .name =3D "mt8186_mt6366_rt1019_rt5682s", + .name =3D "mt8186_mt6366", #if IS_ENABLED(CONFIG_OF) - .of_match_table =3D mt8186_mt6366_rt1019_rt5682s_dt_match, + .of_match_table =3D mt8186_mt6366_dt_match, #endif .pm =3D &snd_soc_pm_ops, }, .probe =3D mtk_soundcard_common_probe, }; =20 -module_platform_driver(mt8186_mt6366_rt1019_rt5682s_driver); +module_platform_driver(mt8186_mt6366_driver); =20 /* Module information */ -MODULE_DESCRIPTION("MT8186-MT6366-RT1019-RT5682S ALSA SoC machine driver"); +MODULE_DESCRIPTION("MT8186-MT6366 ALSA SoC machine driver"); MODULE_AUTHOR("Jiaxin Yu "); MODULE_LICENSE("GPL v2"); -MODULE_ALIAS("mt8186_mt6366_rt1019_rt5682s soc card"); +MODULE_ALIAS("mt8186_mt6366 soc card"); --=20 2.44.0 From nobody Thu Nov 14 04:44:10 2024 Received: from madrid.collaboradmins.com (madrid.collaboradmins.com [46.235.227.194]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 30852133286; Tue, 9 Apr 2024 11:34:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=46.235.227.194 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712662446; cv=none; b=Hr5ARKPvbNxJOOEntCtV6SQXk3SR2saFqywDergg/bnjCH5SynGReAHOxokDF8ar8e4n/JarAQ772DQBXYKPm2Rn/3r7dLbonNhSDoKR1/xP/yjLl/Gz3qgZMuR3YwTP3GTWiYDzRmJ7VbVm8RWos8hVRdMe8MjLHDQimEV9fvQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712662446; c=relaxed/simple; bh=l/YgE2jHDgEGiO5tZpMnwUUm+KuVZjmQoNRva6TC6eM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=uRfpGlSnNvvwH5RqobItiy0Ri7Kyhui5dbpxfQinD1eylJhRAvPMOsZm8j8kvVe6AYrY07ntjpaawZcxmlV7h5rvdkdCsLFnrO6umU0LRuj4QHPM21Q4NXtFM4kmnNFPuqgYdjWT/GnuwcL4LdlM2blfbl9sZf/0a0Usovd/46I= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=collabora.com; spf=pass smtp.mailfrom=collabora.com; dkim=pass (2048-bit key) header.d=collabora.com header.i=@collabora.com header.b=HjVtEb/a; arc=none smtp.client-ip=46.235.227.194 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=collabora.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=collabora.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=collabora.com header.i=@collabora.com header.b="HjVtEb/a" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1712662443; bh=l/YgE2jHDgEGiO5tZpMnwUUm+KuVZjmQoNRva6TC6eM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HjVtEb/agejdcAI18+BBEgvGU+Uzpv8NUoldIg8LLDMGeugmFpOijD5yzekO1L3t9 twmgZ27EGBt4uOS+w7vfDEg8NyevUB5Ang1mWt1plRZmD4YaFR2c3oGcS3c7HkOXfH f0RviRfotw9KpQk1Ore/6KDy5mTPT2C+lUnc1drIXz6xWKLIjjxCwgSgATJT9mDe2k glYbVds1VcUsx2nUNLDsOQZLsWpJjQ16TY8lecmqhaiFrP5KyNrbBcIem21ucvqr18 1QbEZFIhhsIF44FqZLmQ4kmfqkVvvTMBTKMHHbNIpuqjobnHVA6dU1C/27A4aq5whr Y5MiYrAt6CSOw== 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 5847D3782132; Tue, 9 Apr 2024 11:34:01 +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 v4 14/18] ASoC: dt-bindings: mt8195: Document audio-routing and dai-link subnode Date: Tue, 9 Apr 2024 13:33:06 +0200 Message-ID: <20240409113310.303261-15-angelogioacchino.delregno@collabora.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240409113310.303261-1-angelogioacchino.delregno@collabora.com> References: <20240409113310.303261-1-angelogioacchino.delregno@collabora.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Document the dai-link subnodes and the audio-routing property, allowing to describe machine specific audio hardware and links in device tree. While at it, also deprecate the old properties which were previously used with driver hardcoded configuration. Also, since describing machine specific audio hardware and links replaces the now deprecated old logic doing the same in a driver hardcoded fashion, it is not allowed to have both the old and new properties together. Reviewed-by: Rob Herring Signed-off-by: AngeloGioacchino Del Regno --- .../bindings/sound/mt8195-mt6359.yaml | 134 ++++++++++++++++++ 1 file changed, 134 insertions(+) diff --git a/Documentation/devicetree/bindings/sound/mt8195-mt6359.yaml b/D= ocumentation/devicetree/bindings/sound/mt8195-mt6359.yaml index c1ddbf672ca3..2af1d8ffbd8b 100644 --- a/Documentation/devicetree/bindings/sound/mt8195-mt6359.yaml +++ b/Documentation/devicetree/bindings/sound/mt8195-mt6359.yaml @@ -12,6 +12,9 @@ maintainers: description: This binding describes the MT8195 sound card. =20 +allOf: + - $ref: sound-card-common.yaml# + properties: compatible: enum: @@ -23,6 +26,33 @@ properties: $ref: /schemas/types.yaml#/definitions/string description: User specified audio sound card name =20 + audio-routing: + description: + A list of the connections between audio components. Each entry is a + pair of strings, the first being the connection's sink, the second + being the connection's source. + Valid names could be the input or output widgets of audio components, + power supplies, MicBias of codec and the software switch. + minItems: 2 + items: + enum: + # Sinks + - Ext Spk + - Headphone + - IN1P + - Left Spk + - Right Spk + + # Sources + - Headset Mic + - HPOL + - HPOR + - Left BE_OUT + - Left SPO + - Right BE_OUT + - Right SPO + - Speaker + mediatek,platform: $ref: /schemas/types.yaml#/definitions/phandle description: The phandle of MT8195 ASoC platform. @@ -30,10 +60,12 @@ properties: mediatek,dptx-codec: $ref: /schemas/types.yaml#/definitions/phandle description: The phandle of MT8195 Display Port Tx codec node. + deprecated: true =20 mediatek,hdmi-codec: $ref: /schemas/types.yaml#/definitions/phandle description: The phandle of MT8195 HDMI codec node. + deprecated: true =20 mediatek,adsp: $ref: /schemas/types.yaml#/definitions/phandle @@ -45,20 +77,122 @@ properties: A list of the desired dai-links in the sound card. Each entry is a name defined in the machine driver. =20 +patternProperties: + ".*-dai-link$": + type: object + additionalProperties: false + description: + Container for dai-link level properties and CODEC sub-nodes. + + properties: + link-name: + description: Indicates dai-link name and PCM stream name + enum: + - DPTX_BE + - ETDM1_IN_BE + - ETDM2_IN_BE + - ETDM1_OUT_BE + - ETDM2_OUT_BE + - ETDM3_OUT_BE + - PCM1_BE + + codec: + description: Holds subnode which indicates codec dai. + type: object + additionalProperties: false + properties: + sound-dai: + minItems: 1 + maxItems: 2 + required: + - sound-dai + + dai-format: + description: audio format + enum: [ i2s, right_j, left_j, dsp_a, dsp_b ] + + mediatek,clk-provider: + $ref: /schemas/types.yaml#/definitions/string + description: Indicates dai-link clock master. + enum: [ cpu, codec ] + + required: + - link-name + additionalProperties: false =20 required: - compatible - mediatek,platform =20 +# Disallow legacy properties if xxx-dai-link nodes are specified +if: + not: + patternProperties: + ".*-dai-link$": false +then: + properties: + mediatek,dptx-codec: false + mediatek,hdmi-codec: false + examples: - | =20 sound: mt8195-sound { compatible =3D "mediatek,mt8195_mt6359_rt1019_rt5682"; + model =3D "mt8195_r1019_5682"; mediatek,platform =3D <&afe>; pinctrl-names =3D "default"; pinctrl-0 =3D <&aud_pins_default>; + + audio-routing =3D + "Headphone", "HPOL", + "Headphone", "HPOR", + "IN1P", "Headset Mic", + "Ext Spk", "Speaker"; + + mm-dai-link { + link-name =3D "ETDM1_IN_BE"; + mediatek,clk-provider =3D "cpu"; + }; + + hs-playback-dai-link { + link-name =3D "ETDM1_OUT_BE"; + mediatek,clk-provider =3D "cpu"; + codec { + sound-dai =3D <&headset_codec>; + }; + }; + + hs-capture-dai-link { + link-name =3D "ETDM2_IN_BE"; + mediatek,clk-provider =3D "cpu"; + codec { + sound-dai =3D <&headset_codec>; + }; + }; + + spk-playback-dai-link { + link-name =3D "ETDM2_OUT_BE"; + mediatek,clk-provider =3D "cpu"; + codec { + sound-dai =3D <&spk_amplifier>; + }; + }; + + hdmi-dai-link { + link-name =3D "ETDM3_OUT_BE"; + codec { + sound-dai =3D <&hdmi_tx>; + }; + }; + + displayport-dai-link { + link-name =3D "DPTX_BE"; + codec { + sound-dai =3D <&dp_tx>; + }; + }; }; =20 ... --=20 2.44.0 From nobody Thu Nov 14 04:44:10 2024 Received: from madrid.collaboradmins.com (madrid.collaboradmins.com [46.235.227.194]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A444513441D; Tue, 9 Apr 2024 11:34:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=46.235.227.194 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712662449; cv=none; b=ByaQ1vsBHjEX49ZeMZwmnzzdTAsewffy/ZK76cFawvgFOzuQIDHQpZmlj3J6l65R2Oi4nzWDcTtNhP7WP1JhnuwdYvzFault5mtxMygvnee6nMSF6bDqkN1BBPZmUz4Hs4LI7WjYRXKX7sjT700ENm/ISiGBwKGyG+ZEJkROWqI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712662449; c=relaxed/simple; bh=6SqN9wWBxnCEthQ3e1Jy5DMt1UHcxaWeOQWQPNIAVhw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=RDfzk9CDV/O0UWf8wjRzZDm3r9rZCrtRtGv89aYjPmb9PJQn8J0yuTk4CREmn9oBJbAtGGpt/KW2NpPVYmeYj816k3QBjzXYtGVTz8RUossGk1EwnUZNXLofyY9OJD7lwh6t36yE/gC/1vu20GLuMtawwANCtEHHKx+jCbyFZU4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=collabora.com; spf=pass smtp.mailfrom=collabora.com; dkim=pass (2048-bit key) header.d=collabora.com header.i=@collabora.com header.b=4x8N+MmA; arc=none smtp.client-ip=46.235.227.194 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=collabora.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=collabora.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=collabora.com header.i=@collabora.com header.b="4x8N+MmA" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1712662445; bh=6SqN9wWBxnCEthQ3e1Jy5DMt1UHcxaWeOQWQPNIAVhw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=4x8N+MmAOwtwucfgJSxQR6oDDw4XDAWHS5cs9u95XsjwtWPDEh4ZHvc8wOT0IVT0I OxYNj3DG5CLxtzkEugDvcD2S+iNguTPv5PTwACBbjqgBegqqe8t2erLpbkulcTnaZN d/HWxiZYmrPEd5z+40C95nphZq9uy/vNNNSHeZ+HcDrjd1lEPQLBZ5yDV/nJofps+g GDFENdMKjw874sNxJD/0pTiL+aRPU9uxB8EFROOkoy8A/8AYhEN4dWKC+DyDpfRk00 KZs7BargTWGMJh9H5LQAtANTyifXYV04B1YL4RXgwf/VjbvlGzW5d9gGO6+ZSDIUDZ qxFAtfJ3aJjmQ== 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 AE89537820F8; Tue, 9 Apr 2024 11:34:03 +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 v4 15/18] ASoC: dt-bindings: mt8192: Document audio-routing and dai-link subnode Date: Tue, 9 Apr 2024 13:33:07 +0200 Message-ID: <20240409113310.303261-16-angelogioacchino.delregno@collabora.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240409113310.303261-1-angelogioacchino.delregno@collabora.com> References: <20240409113310.303261-1-angelogioacchino.delregno@collabora.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Document the dai-link subnodes and the audio-routing property, allowing to describe machine specific audio hardware and links in device tree. While at it, also deprecate the old properties which were previously used with the driver's partially hardcoded configuration. Also, since describing machine specific audio hardware and links replaces the now deprecated old logic doing the same in a driver hardcoded fashion, it is not allowed to have both the old and new properties together. Reviewed-by: Rob Herring Signed-off-by: AngeloGioacchino Del Regno --- .../sound/mt8192-mt6359-rt1015-rt5682.yaml | 139 ++++++++++++++++-- 1 file changed, 129 insertions(+), 10 deletions(-) diff --git a/Documentation/devicetree/bindings/sound/mt8192-mt6359-rt1015-r= t5682.yaml b/Documentation/devicetree/bindings/sound/mt8192-mt6359-rt1015-r= t5682.yaml index 7e50f5d65c8f..c4e68f31aaab 100644 --- a/Documentation/devicetree/bindings/sound/mt8192-mt6359-rt1015-rt5682.y= aml +++ b/Documentation/devicetree/bindings/sound/mt8192-mt6359-rt1015-rt5682.y= aml @@ -13,6 +13,9 @@ maintainers: description: This binding describes the MT8192 sound card. =20 +allOf: + - $ref: sound-card-common.yaml# + properties: compatible: enum: @@ -20,6 +23,31 @@ properties: - mediatek,mt8192_mt6359_rt1015p_rt5682 - mediatek,mt8192_mt6359_rt1015p_rt5682s =20 + audio-routing: + description: + A list of the connections between audio components. Each entry is a + pair of strings, the first being the connection's sink, the second + being the connection's source. + Valid names could be the input or output widgets of audio components, + power supplies, MicBias of codec and the software switch. + minItems: 2 + items: + enum: + # Sinks + - Speakers + - Headphone Jack + - IN1P + - Left Spk + - Right Spk + + # Sources + - Headset Mic + - HPOL + - HPOR + - Left SPO + - Right SPO + - Speaker + mediatek,platform: $ref: /schemas/types.yaml#/definitions/phandle description: The phandle of MT8192 ASoC platform. @@ -27,10 +55,12 @@ properties: mediatek,hdmi-codec: $ref: /schemas/types.yaml#/definitions/phandle description: The phandle of HDMI codec. + deprecated: true =20 headset-codec: type: object additionalProperties: false + deprecated: true =20 properties: sound-dai: @@ -41,6 +71,7 @@ properties: speaker-codecs: type: object additionalProperties: false + deprecated: true =20 properties: sound-dai: @@ -51,33 +82,121 @@ properties: required: - sound-dai =20 -additionalProperties: false +patternProperties: + ".*-dai-link$": + type: object + additionalProperties: false + + description: + Container for dai-link level properties and CODEC sub-nodes. + + properties: + link-name: + description: Indicates dai-link name and PCM stream name + enum: + - I2S0 + - I2S1 + - I2S2 + - I2S3 + - I2S4 + - I2S5 + - I2S6 + - I2S7 + - I2S8 + - I2S9 + - TDM + + codec: + description: Holds subnode which indicates codec dai. + type: object + additionalProperties: false + properties: + sound-dai: + minItems: 1 + maxItems: 2 + required: + - sound-dai + + dai-format: + description: audio format + enum: [ i2s, right_j, left_j, dsp_a, dsp_b ] + + mediatek,clk-provider: + $ref: /schemas/types.yaml#/definitions/string + description: Indicates dai-link clock master. + enum: [ cpu, codec ] + + required: + - link-name + +unevaluatedProperties: false =20 required: - compatible - mediatek,platform - - headset-codec - - speaker-codecs + +# Disallow legacy properties if xxx-dai-link nodes are specified +if: + not: + patternProperties: + ".*-dai-link$": false +then: + properties: + headset-codec: false + speaker-codecs: false + mediatek,hdmi-codec: false =20 examples: - | =20 sound: mt8192-sound { compatible =3D "mediatek,mt8192_mt6359_rt1015_rt5682"; - mediatek,platform =3D <&afe>; - mediatek,hdmi-codec =3D <&anx_bridge_dp>; + model =3D "mt8192_mt6359_rt1015_rt5682"; pinctrl-names =3D "aud_clk_mosi_off", "aud_clk_mosi_on"; pinctrl-0 =3D <&aud_clk_mosi_off>; pinctrl-1 =3D <&aud_clk_mosi_on>; + mediatek,platform =3D <&afe>; + + audio-routing =3D + "Headphone Jack", "HPOL", + "Headphone Jack", "HPOR", + "IN1P", "Headset Mic", + "Speakers", "Speaker"; + + spk-playback-dai-link { + link-name =3D "I2S3"; + dai-format =3D "i2s"; + mediatek,clk-provider =3D "cpu"; + codec { + sound-dai =3D <&rt1015p>; + }; + }; + + hs-playback-dai-link { + link-name =3D "I2S8"; + dai-format =3D "i2s"; + mediatek,clk-provider =3D "cpu"; + codec { + sound-dai =3D <&rt5682 0>; + }; + }; =20 - headset-codec { - sound-dai =3D <&rt5682>; + hs-capture-dai-link { + link-name =3D "I2S9"; + dai-format =3D "i2s"; + mediatek,clk-provider =3D "cpu"; + codec { + sound-dai =3D <&rt5682 0>; + }; }; =20 - speaker-codecs { - sound-dai =3D <&rt1015_l>, - <&rt1015_r>; + displayport-dai-link { + link-name =3D "TDM"; + dai-format =3D "dsp_a"; + codec { + sound-dai =3D <&anx_bridge_dp>; + }; }; }; =20 --=20 2.44.0 From nobody Thu Nov 14 04:44:10 2024 Received: from madrid.collaboradmins.com (madrid.collaboradmins.com [46.235.227.194]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BEC0D1350F1; Tue, 9 Apr 2024 11:34:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=46.235.227.194 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712662451; cv=none; b=CG16iuY68TsEEMXtg1176ots0KrmHoQwd3RLnw6DKQKWaiI4NYx4X47Mv3P7dnrAaSQvKXSew7oGTiIQZ7YQ3p4YAHu1BnFL1yQ/fyyd02BtwwxbXacE0JE5nQu0I5vw5hez8qwHy7YnDdkB198CHe+pnVe1IwUp0Q4tWIoLmn0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712662451; c=relaxed/simple; bh=0Xu+A6DQSApUl+bx7dqAi1yjwT+TMZd9+xG6pwiMVK4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=dqevj51JFw5Wzj9UR5PGgeLr19g82MJg83Y6yvc2vWaEEmMTs4FkufbU4Ij+gGc6IfiS/iM7oOUgkmyLIUWnoLGqErwJ7J+LBPMp1uEm6v35YT5nrKuSc0DjNxvrZjCj7nADcj2GOJIJSLp9hrGFTkZ89JZ3P6vMkyYR0b0NFoo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=collabora.com; spf=pass smtp.mailfrom=collabora.com; dkim=pass (2048-bit key) header.d=collabora.com header.i=@collabora.com header.b=AVQzVKzg; arc=none smtp.client-ip=46.235.227.194 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=collabora.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=collabora.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=collabora.com header.i=@collabora.com header.b="AVQzVKzg" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1712662448; bh=0Xu+A6DQSApUl+bx7dqAi1yjwT+TMZd9+xG6pwiMVK4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=AVQzVKzgmUNvyrYoAD47y6/ThPC1dMKqpH/E15dtsZNu5Y4Z2BXIovWQUtCbHtGyK ULt8O9UaOLignJje03hgZj0whg1pTzvYEFTVzqajDIrZ++vMKyxUyQ0reev0uRKNXJ mY66LM9QHnL4FD3Ca7AovKK7JyTOJF7s9Y527fsgLflRWoV5phZIZ5I8QfjlNoopci XtvaGaxgNi4/5xk/4I0Chu+wZFB4WF2uEk5eo0JFTZdPB4E/EW1DI9uWXwta4KaKOK W3/6obzVfQ8f2dngPafYHg++IG+kZO9xSNotnG6FZXVeUeIXidBVeh+ES6jcFtEPHx RHVw3JJ/ednbA== 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 1724D3782127; Tue, 9 Apr 2024 11:34:06 +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 v4 16/18] ASoC: dt-bindings: mt8186: Document audio-routing and dai-link subnode Date: Tue, 9 Apr 2024 13:33:08 +0200 Message-ID: <20240409113310.303261-17-angelogioacchino.delregno@collabora.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240409113310.303261-1-angelogioacchino.delregno@collabora.com> References: <20240409113310.303261-1-angelogioacchino.delregno@collabora.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Document the dai-link subnodes and the audio-routing property, allowing to describe machine specific audio hardware and links in device tree. While at it, also deprecate the old properties which were previously used with the driver's partially hardcoded configuration. Also, since describing machine specific audio hardware and links replaces the now deprecated old logic doing the same in a driver hardcoded fashion, it is not allowed to have both the old and new properties together. Reviewed-by: Rob Herring Signed-off-by: AngeloGioacchino Del Regno --- .../sound/mt8186-mt6366-da7219-max98357.yaml | 131 ++++++++++++++++-- .../sound/mt8186-mt6366-rt1019-rt5682s.yaml | 120 ++++++++++++++-- 2 files changed, 233 insertions(+), 18 deletions(-) diff --git a/Documentation/devicetree/bindings/sound/mt8186-mt6366-da7219-m= ax98357.yaml b/Documentation/devicetree/bindings/sound/mt8186-mt6366-da7219= -max98357.yaml index 9853c11a1330..cbc641ecbe94 100644 --- a/Documentation/devicetree/bindings/sound/mt8186-mt6366-da7219-max98357= .yaml +++ b/Documentation/devicetree/bindings/sound/mt8186-mt6366-da7219-max98357= .yaml @@ -12,17 +12,46 @@ maintainers: description: This binding describes the MT8186 sound card. =20 +allOf: + - $ref: sound-card-common.yaml# + properties: compatible: enum: - mediatek,mt8186-mt6366-da7219-max98357-sound =20 + audio-routing: + $ref: /schemas/types.yaml#/definitions/non-unique-string-array + description: + A list of the connections between audio components. Each entry is a + pair of strings, the first being the connection's sink, the second + being the connection's source. + Valid names could be the input or output widgets of audio components, + power supplies, MicBias of codec and the software switch. + minItems: 2 + items: + enum: + # Sinks + - HDMI1 + - Headphones + - Line Out + - MIC + - Speakers + + # Sources + - Headset Mic + - HPL + - HPR + - Speaker + - TX + mediatek,platform: $ref: /schemas/types.yaml#/definitions/phandle description: The phandle of MT8186 ASoC platform. =20 headset-codec: type: object + deprecated: true additionalProperties: false properties: sound-dai: @@ -32,6 +61,7 @@ properties: =20 playback-codecs: type: object + deprecated: true additionalProperties: false properties: sound-dai: @@ -53,32 +83,115 @@ properties: A list of the desired dai-links in the sound card. Each entry is a name defined in the machine driver. =20 -additionalProperties: false +patternProperties: + ".*-dai-link$": + type: object + additionalProperties: false + description: + Container for dai-link level properties and CODEC sub-nodes. + + properties: + link-name: + description: Indicates dai-link name and PCM stream name + items: + enum: + - I2S0 + - I2S1 + - I2S2 + - I2S3 + + codec: + description: Holds subnode which indicates codec dai. + type: object + additionalProperties: false + properties: + sound-dai: + minItems: 1 + maxItems: 2 + required: + - sound-dai + + dai-format: + description: audio format + items: + enum: + - i2s + - right_j + - left_j + - dsp_a + - dsp_b + + mediatek,clk-provider: + $ref: /schemas/types.yaml#/definitions/string + description: Indicates dai-link clock master. + items: + enum: + - cpu + - codec + + required: + - link-name + +unevaluatedProperties: false =20 required: - compatible - mediatek,platform - - headset-codec - - playback-codecs + +# Disallow legacy properties if xxx-dai-link nodes are specified +if: + not: + patternProperties: + ".*-dai-link$": false +then: + properties: + headset-codec: false + speaker-codecs: false =20 examples: - | =20 sound: mt8186-sound { compatible =3D "mediatek,mt8186-mt6366-da7219-max98357-sound"; - mediatek,platform =3D <&afe>; + model =3D "mt8186_da7219_m98357"; pinctrl-names =3D "aud_clk_mosi_off", "aud_clk_mosi_on"; pinctrl-0 =3D <&aud_clk_mosi_off>; pinctrl-1 =3D <&aud_clk_mosi_on>; + mediatek,platform =3D <&afe>; + + audio-routing =3D + "Headphones", "HPL", + "Headphones", "HPR", + "MIC", "Headset Mic", + "Speakers", "Speaker", + "HDMI1", "TX"; + + hs-playback-dai-link { + link-name =3D "I2S0"; + dai-format =3D "i2s"; + mediatek,clk-provider =3D "cpu"; + codec { + sound-dai =3D <&da7219>; + }; + }; =20 - headset-codec { - sound-dai =3D <&da7219>; + hs-capture-dai-link { + link-name =3D "I2S1"; + dai-format =3D "i2s"; + mediatek,clk-provider =3D "cpu"; + codec { + sound-dai =3D <&da7219>; + }; }; =20 - playback-codecs { - sound-dai =3D <&anx_bridge_dp>, - <&max98357a>; + spk-dp-playback-dai-link { + link-name =3D "I2S3"; + dai-format =3D "i2s"; + mediatek,clk-provider =3D "cpu"; + codec { + sound-dai =3D <&anx_bridge_dp>, <&max98357a>; + }; }; }; =20 diff --git a/Documentation/devicetree/bindings/sound/mt8186-mt6366-rt1019-r= t5682s.yaml b/Documentation/devicetree/bindings/sound/mt8186-mt6366-rt1019-= rt5682s.yaml index bdf7b0960533..ed93f18ef985 100644 --- a/Documentation/devicetree/bindings/sound/mt8186-mt6366-rt1019-rt5682s.= yaml +++ b/Documentation/devicetree/bindings/sound/mt8186-mt6366-rt1019-rt5682s.= yaml @@ -12,6 +12,9 @@ maintainers: description: This binding describes the MT8186 sound card. =20 +allOf: + - $ref: sound-card-common.yaml# + properties: compatible: enum: @@ -19,6 +22,34 @@ properties: - mediatek,mt8186-mt6366-rt5682s-max98360-sound - mediatek,mt8186-mt6366-rt5650-sound =20 + audio-routing: + $ref: /schemas/types.yaml#/definitions/non-unique-string-array + description: + A list of the connections between audio components. Each entry is a + pair of strings, the first being the connection's sink, the second + being the connection's source. + Valid names could be the input or output widgets of audio components, + power supplies, MicBias of codec and the software switch. + minItems: 2 + items: + enum: + # Sinks + - HDMI1 + - Headphone + - IN1P + - IN1N + - Line Out + - Speakers + + # Sources + - Headset Mic + - HPOL + - HPOR + - Speaker + - SPOL + - SPOR + - TX + mediatek,platform: $ref: /schemas/types.yaml#/definitions/phandle description: The phandle of MT8186 ASoC platform. @@ -32,6 +63,7 @@ properties: =20 headset-codec: type: object + deprecated: true additionalProperties: false properties: sound-dai: @@ -41,6 +73,7 @@ properties: =20 playback-codecs: type: object + deprecated: true additionalProperties: false properties: sound-dai: @@ -62,13 +95,56 @@ properties: A list of the desired dai-links in the sound card. Each entry is a name defined in the machine driver. =20 -additionalProperties: false +patternProperties: + ".*-dai-link$": + type: object + additionalProperties: false + description: + Container for dai-link level properties and CODEC sub-nodes. + + properties: + link-name: + description: Indicates dai-link name and PCM stream name + enum: [ I2S0, I2S1, I2S2, I2S3 ] + + codec: + description: Holds subnode which indicates codec dai. + type: object + additionalProperties: false + properties: + sound-dai: + minItems: 1 + maxItems: 2 + required: + - sound-dai + + dai-format: + description: audio format + enum: [ i2s, right_j, left_j, dsp_a, dsp_b ] + + mediatek,clk-provider: + $ref: /schemas/types.yaml#/definitions/string + description: Indicates dai-link clock master. + enum: [ cpu, codec ] + + required: + - link-name + +unevaluatedProperties: false =20 required: - compatible - mediatek,platform - - headset-codec - - playback-codecs + +# Disallow legacy properties if xxx-dai-link nodes are specified +if: + not: + patternProperties: + ".*-dai-link$": false +then: + properties: + headset-codec: false + speaker-codecs: false =20 examples: - | @@ -76,23 +152,49 @@ examples: =20 sound: mt8186-sound { compatible =3D "mediatek,mt8186-mt6366-rt1019-rt5682s-sound"; - mediatek,platform =3D <&afe>; + model =3D "mt8186_rt1019_rt5682s"; pinctrl-names =3D "aud_clk_mosi_off", "aud_clk_mosi_on", "aud_gpio_dmic_sec"; pinctrl-0 =3D <&aud_clk_mosi_off>; pinctrl-1 =3D <&aud_clk_mosi_on>; pinctrl-2 =3D <&aud_gpio_dmic_sec>; + mediatek,platform =3D <&afe>; =20 dmic-gpios =3D <&pio 23 GPIO_ACTIVE_HIGH>; =20 - headset-codec { - sound-dai =3D <&rt5682s>; + audio-routing =3D + "Headphone", "HPOL", + "Headphone", "HPOR", + "IN1P", "Headset Mic", + "Speakers", "Speaker", + "HDMI1", "TX"; + + hs-playback-dai-link { + link-name =3D "I2S0"; + dai-format =3D "i2s"; + mediatek,clk-provider =3D "cpu"; + codec { + sound-dai =3D <&rt5682s 0>; + }; + }; + + hs-capture-dai-link { + link-name =3D "I2S1"; + dai-format =3D "i2s"; + mediatek,clk-provider =3D "cpu"; + codec { + sound-dai =3D <&rt5682s 0>; + }; }; =20 - playback-codecs { - sound-dai =3D <&it6505dptx>, - <&rt1019p>; + spk-hdmi-playback-dai-link { + link-name =3D "I2S3"; + dai-format =3D "i2s"; + mediatek,clk-provider =3D "cpu"; + codec { + sound-dai =3D <&it6505dptx>, <&rt1019p>; + }; }; }; =20 --=20 2.44.0 From nobody Thu Nov 14 04:44:10 2024 Received: from madrid.collaboradmins.com (madrid.collaboradmins.com [46.235.227.194]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1ED82135A54; Tue, 9 Apr 2024 11:34:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=46.235.227.194 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712662453; cv=none; b=K9Iw6rq99/kx184nYgoBJD076ZJ8Mt1Zk4ixSMvOkPnzmy2wWsWWwU+UgK1IXao9lcBPjusQJSFQZfyEW++AzJKKVqwMrEwlOq4ttM6G+PjdDAk5zMzUtPmlrK7GD7QQMNfouf6CVbpxhuTOjfJw4Qa9Q+6WdEspcGz/dXbdUJk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712662453; c=relaxed/simple; bh=+JfrTVgrO4JkC6c7ui1/Sey7vbzN8l8IbPUAys7zK+A=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=GEvix65VBEraRnNZbFAeJBg+8h6Zdxvk7wflPVXaigCjZIXRxtbtTY3K3okF0X8o7UyLVgNPAtoRbwk7gDdbi9TzDv1FvJ15hf449v305dBl7jaUHSKNVIwukItPzCGx3AykXScWHjTHSb0yxsB3tTMwkmtKDpByIuC610G6Jj0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=collabora.com; spf=pass smtp.mailfrom=collabora.com; dkim=pass (2048-bit key) header.d=collabora.com header.i=@collabora.com header.b=ce2Cd4mC; arc=none smtp.client-ip=46.235.227.194 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=collabora.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=collabora.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=collabora.com header.i=@collabora.com header.b="ce2Cd4mC" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1712662450; bh=+JfrTVgrO4JkC6c7ui1/Sey7vbzN8l8IbPUAys7zK+A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ce2Cd4mCVU7Vhtoi0ILH3n35kwovkmajhigwTItpUOd+Msadx4h+NV3PnixFVviar wHMwoeoyixkvbBcwgBU4jwq4I9mBYgD2hTjw+pDvcAC80t0VdLfdG5KPgyIKVSxR1J aJZ8eukC2/FHA+gLkVlykHFcyWBj5NpwyJlR5lDzH+0okKqDX6NSonAf7Cyzhri+T4 OOIK9Xw32W5DIzJ4RUpndQAps8XE1ZeHx5l2QvillwcsDAhSN/3Y7JAJ3NwjumanGY lyCZG7iDbTMniTn3cq17jRuTiptI+EXUHOfj130bmtGb+kbl5cU11BlNpl/CC50taP uTMsfdK2FaYoA== 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 728E43782111; Tue, 9 Apr 2024 11:34:08 +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 v4 17/18] arm64: dts: mediatek: mt8195-cherry: Specify sound DAI links and routing Date: Tue, 9 Apr 2024 13:33:09 +0200 Message-ID: <20240409113310.303261-18-angelogioacchino.delregno@collabora.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240409113310.303261-1-angelogioacchino.delregno@collabora.com> References: <20240409113310.303261-1-angelogioacchino.delregno@collabora.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The drivers and bindings acquired support for specifying audio hardware and links in device tree: describe and link the sound related HW of this machine. Signed-off-by: AngeloGioacchino Del Regno --- .../boot/dts/mediatek/mt8195-cherry.dtsi | 45 +++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/arch/arm64/boot/dts/mediatek/mt8195-cherry.dtsi b/arch/arm64/b= oot/dts/mediatek/mt8195-cherry.dtsi index 4a11918da370..e35adff02469 100644 --- a/arch/arm64/boot/dts/mediatek/mt8195-cherry.dtsi +++ b/arch/arm64/boot/dts/mediatek/mt8195-cherry.dtsi @@ -240,6 +240,7 @@ adsp_device_mem: memory@60e80000 { spk_amplifier: rt1019p { compatible =3D "realtek,rt1019p"; label =3D "rt1019p"; + #sound-dai-cells =3D <0>; pinctrl-names =3D "default"; pinctrl-0 =3D <&rt1019p_pins_default>; sdb-gpios =3D <&pio 100 GPIO_ACTIVE_HIGH>; @@ -366,6 +367,7 @@ &disp_pwm0 { &dp_tx { status =3D "okay"; =20 + #sound-dai-cells =3D <0>; pinctrl-names =3D "default"; pinctrl-0 =3D <&dptx_pin>; =20 @@ -436,6 +438,7 @@ audio_codec: codec@1a { /* Realtek RT5682i or RT5682s, sharing the same configuration */ reg =3D <0x1a>; interrupts-extended =3D <&pio 89 IRQ_TYPE_EDGE_BOTH>; + #sound-dai-cells =3D <0>; realtek,jd-src =3D <1>; =20 AVDD-supply =3D <&mt6359_vio18_ldo_reg>; @@ -1162,6 +1165,48 @@ &sound { "AFE_SOF_DL2", "AFE_SOF_DL3", "AFE_SOF_UL4", "AFE_SOF_UL5"; pinctrl-names =3D "default"; pinctrl-0 =3D <&aud_pins_default>; + + audio-routing =3D + "Headphone", "HPOL", + "Headphone", "HPOR", + "IN1P", "Headset Mic", + "Ext Spk", "Speaker"; + + mm-dai-link { + link-name =3D "ETDM1_IN_BE"; + mediatek,clk-provider =3D "cpu"; + }; + + hs-playback-dai-link { + link-name =3D "ETDM1_OUT_BE"; + mediatek,clk-provider =3D "cpu"; + codec { + sound-dai =3D <&audio_codec>; + }; + }; + + hs-capture-dai-link { + link-name =3D "ETDM2_IN_BE"; + mediatek,clk-provider =3D "cpu"; + codec { + sound-dai =3D <&audio_codec>; + }; + }; + + spk-playback-dai-link { + link-name =3D "ETDM2_OUT_BE"; + mediatek,clk-provider =3D "cpu"; + codec { + sound-dai =3D <&spk_amplifier>; + }; + }; + + displayport-dai-link { + link-name =3D "DPTX_BE"; + codec { + sound-dai =3D <&dp_tx>; + }; + }; }; =20 &spi0 { --=20 2.44.0 From nobody Thu Nov 14 04:44:10 2024 Received: from madrid.collaboradmins.com (madrid.collaboradmins.com [46.235.227.194]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A48B713667A; Tue, 9 Apr 2024 11:34:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=46.235.227.194 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712662456; cv=none; b=jcBsydrfeC2kDPvd9E4rYwpwiHf3JMETmx4En9lBnpVYitJkpYZ1mFZ0cGpLsNhtbKO/SrfF1zAuTjlzyt/nsSNKbaXOhOHvPlm67NEsirEBLaLmK6RYvmmN3IMdV9trWTvldVXsVpS21FlNUxJ1OdGnwNcqT4p/wgib18j9EcM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712662456; c=relaxed/simple; bh=SRSwRgJbTBz/3750pVOWh9FKrFSoG2LU80QaUy5HTjg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=l+nOUVwHTtoklawQOat5aVNC8fmCVpHL8XBNVxEdQbyqB0eroizVQAdkN32kDPJZA8rVDYGSVfn1Jc03V2CnDQRNLPCqsWY7XJ+9rRFsP4a7mqlcBOX78rQhBkZduNeAyTo2G/nSG+VtpMekKMLgw0AQTW50SIK/9bSMCnQJx68= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=collabora.com; spf=pass smtp.mailfrom=collabora.com; dkim=pass (2048-bit key) header.d=collabora.com header.i=@collabora.com header.b=4IYpUbTT; arc=none smtp.client-ip=46.235.227.194 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=collabora.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=collabora.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=collabora.com header.i=@collabora.com header.b="4IYpUbTT" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1712662452; bh=SRSwRgJbTBz/3750pVOWh9FKrFSoG2LU80QaUy5HTjg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=4IYpUbTTh7MAruw1btaUKUdqHfQRm5G74zFUVOftI+T9TCdsW5jy+aLe+ovvx3Z5I 11UI3jSgbp9qKxd+LzBCt00w7WOAWyUP/p6OB6fymARuqX2oCBDDdepX2IMoVISL+l yu8bpU2L/u64hzPPpzZ0vIgXl62UkoB32ZOLbxYDRjgTb+eRUNCL50wab1sbQos2xG HJfl3ws6cRLa3pNEkCI0Pa2XtGASP4yD8EFCw4cm+utr45JPLDdRVZNKAKynh0A/hx ZmyW8i1MGMnAKvoLH4yDcvS0p2W6YZQ6e0aE3wR4ig2B/fdqYyzv7v8Kj0v2b8Ocb5 0WNMlXDLwfDJQ== 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 C7F1E378212C; Tue, 9 Apr 2024 11:34:10 +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 v4 18/18] arm64: dts: mediatek: mt8186-corsola: Specify sound DAI links and routing Date: Tue, 9 Apr 2024 13:33:10 +0200 Message-ID: <20240409113310.303261-19-angelogioacchino.delregno@collabora.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240409113310.303261-1-angelogioacchino.delregno@collabora.com> References: <20240409113310.303261-1-angelogioacchino.delregno@collabora.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The drivers and bindings acquired support for specifying audio hardware and links in device tree: describe and link the sound related HW of this machine. Signed-off-by: AngeloGioacchino Del Regno --- .../boot/dts/mediatek/mt8186-corsola.dtsi | 42 ++++++++++++++++--- 1 file changed, 37 insertions(+), 5 deletions(-) diff --git a/arch/arm64/boot/dts/mediatek/mt8186-corsola.dtsi b/arch/arm64/= boot/dts/mediatek/mt8186-corsola.dtsi index 1807e9d6cb0e..afdab5724eaa 100644 --- a/arch/arm64/boot/dts/mediatek/mt8186-corsola.dtsi +++ b/arch/arm64/boot/dts/mediatek/mt8186-corsola.dtsi @@ -42,7 +42,7 @@ backlight_lcd0: backlight-lcd0 { default-brightness-level =3D <576>; }; =20 - bt-sco-codec { + bt-sco { compatible =3D "linux,bt-sco"; #sound-dai-cells =3D <0>; }; @@ -223,12 +223,44 @@ sound: sound { mediatek,adsp =3D <&adsp>; mediatek,platform =3D <&afe>; =20 - playback-codecs { - sound-dai =3D <&it6505dptx>, <&rt1019p>; + audio-routing =3D + "Headphone", "HPOL", + "Headphone", "HPOR", + "IN1P", "Headset Mic", + "Speakers", "Speaker", + "HDMI1", "TX"; + + hs-playback-dai-link { + link-name =3D "I2S0"; + dai-format =3D "i2s"; + mediatek,clk-provider =3D "cpu"; + codec { + sound-dai =3D <&rt5682s 0>; + }; + }; + + hs-capture-dai-link { + link-name =3D "I2S1"; + dai-format =3D "i2s"; + mediatek,clk-provider =3D "cpu"; + codec { + sound-dai =3D <&rt5682s 0>; + }; }; =20 - headset-codec { - sound-dai =3D <&rt5682s 0>; + spk-share-dai-link { + link-name =3D "I2S2"; + mediatek,clk-provider =3D "cpu"; + }; + + spk-hdmi-playback-dai-link { + link-name =3D "I2S3"; + dai-format =3D "i2s"; + mediatek,clk-provider =3D "cpu"; + /* RT1019P and IT6505 connected to the same I2S line */ + codec { + sound-dai =3D <&it6505dptx>, <&rt1019p>; + }; }; }; =20 --=20 2.44.0