From nobody Thu Nov 14 04:48:16 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 AE7F476044; Tue, 16 Apr 2024 07:14:22 +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=1713251664; cv=none; b=cCZ2IyZkuUTosPRa1JRV0suzEXKjtbSVbZOMSOTHsQd8oyqx3k2nBiivy91qC73rIBeNUrCAJEALaWXKkbKFL6tZMH1AgJKxPgpCAoGigN6yMUlY5aaJ6DuFp9yYg/SDOCTHEkLSLndXJZQDNdZzLBu+eTkJZ7Rnk7L7/ktfUXM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713251664; c=relaxed/simple; bh=jVhr77PiLNy9HfB30BEj+Z0f1ylyaSsDpPpIkaBWXzY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=aYGwcyR+F+3se9Cjmwp/3rJj2d9Zhy/NAZNupMcxWTQ8zq24H5V6KvkT+PfaPDopvYAljg5+FffvV1hrNwpVO2QRuXziUfi9IOeo2kPKJfaM4Kew+CS5hPiswx3X8AzQeO17R8vosAcr+IbRqhu7z4JBGCym4ag1rH67ZI80VjM= 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=1KQQX93X; 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="1KQQX93X" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1713251660; bh=jVhr77PiLNy9HfB30BEj+Z0f1ylyaSsDpPpIkaBWXzY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=1KQQX93XdQZmj7td+48wvCRrwAn+bwKbQHtZNAJ2Lov1oMtlqa0oNh8N+cuSVXbQ0 Nb1a6BnzkMNzCGL1o7+AINoBrsqwRnIvV+LI2A2DxsSruxrzDeYP4yGGzOErZWPamg XL73F9fPjklWlwSLYXsrQour09OdfNzDEc89ulnpC7SeYFp4F/MO5p2MghrY3pLOYo 0Fi//iFrRoJ++zA0xthqHwDFVmsPxbMro20NxkW2W/wES0AM1vfRxnPN+eUl9BTFDr u09nouLd6ssNqi07r+cxv7UHCcusZpA0nSqP4pnSLT5uk/XQiJMW5n23HqzmcqrHo2 np02iw8ABhdkw== 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 AAB15378210B; Tue, 16 Apr 2024 07:14:18 +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 v5 01/18] ASoC: mediatek: Add common machine soundcard driver probe mechanism Date: Tue, 16 Apr 2024 09:13:53 +0200 Message-ID: <20240416071410.75620-2-angelogioacchino.delregno@collabora.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240416071410.75620-1-angelogioacchino.delregno@collabora.com> References: <20240416071410.75620-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. Reviewed-by: Alexandre Mergnat Signed-off-by: AngeloGioacchino Del Regno --- 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:48:16 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 CEC9480611; Tue, 16 Apr 2024 07:14:24 +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=1713251666; cv=none; b=LrMqezH3KiJPO6TkFc44zhPue4digEIGtz06jhGAi77aWWBw8qKl+sTEQDS5+nlgAm5DdTaWcDNbHr2/EvpOYL+B6zS1Wstm2ZJjYxlzKWbj82mVENE/iWgg9c5/G7jbAWcj2/w3EpyqL99wEVTPfaXihWFgg9aNL9mk3yDQdFU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713251666; c=relaxed/simple; bh=sujJ+yH45hDcBjqKeWC7ARxj1AokpNPpDXwr5VjyZPU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Nfe9fFqFMzEPB8NZ4gNXkoqcdDnCAlWZxvZ5olIu7OyiddziFXcVV0TL1hAYXHdA5a9d5s1HSolgMsQ0bRbE7UBHk+nruu2j9OKLPC1CjhERvVYAlK81nqkw3JD5cmATzrqpgxwwXYIfllPPf268P6dlB/aTW/WPPhH/eYR5Ei0= 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=2IEdI4su; 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="2IEdI4su" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1713251663; bh=sujJ+yH45hDcBjqKeWC7ARxj1AokpNPpDXwr5VjyZPU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=2IEdI4suxMn1ims9sXpVJcEKFXWEBriNbbcqbkXyvaZFtPayxhpdn+PRp89Y9bymk 8R4RmOvuG+JqKaJMxrY2wHGWMZzVdQFs0wKUYVgXylQ3pjBo3su11IAJVPO75oCmhT hCTBQvq36qAjvpraT6HTdLtW/M5YIcEZoOXIpoK/CIt48EOETPx2DS0TQrdd3CJG63 +JM9WrQlsFVMWUGJKXt8+MwDOIthdu7JF4hJIDquoCziHHYFfukuU5DdnP/NpI1KCD tUokoRYUPPn6jtqyBq8lHmnrgEQl0bgThYFpa5Vm5tPcJxqzlBn27x7ojTSiZF53Au z7mEzLrlz8LVQ== 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 16680378211D; Tue, 16 Apr 2024 07:14:21 +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 v5 02/18] ASoC: mediatek: common: Constify struct mtk_sof_priv Date: Tue, 16 Apr 2024 09:13:54 +0200 Message-ID: <20240416071410.75620-3-angelogioacchino.delregno@collabora.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240416071410.75620-1-angelogioacchino.delregno@collabora.com> References: <20240416071410.75620-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. Reviewed-by: Alexandre Mergnat Signed-off-by: AngeloGioacchino Del Regno --- 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:48:16 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 4248775808; Tue, 16 Apr 2024 07:14:27 +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=1713251669; cv=none; b=Wo+ga5RVAxkwyoSK9KwAS54WsqWhsTkIwhJ0wiQemEJ7WxYtYt0V5OipQYO/5+GfOGhxr0Xu9O9OlSEoublZcbXrgEmiMxgu55F3ZYLRpgn4MeMMDYDCCq1QueNbvehrLKS1PBY80V4Gjwan+CS2gvs7uYlJUXdqzKcRF9Kodfg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713251669; c=relaxed/simple; bh=BB6XcCGlmcxZViVH9ZoV55JPlRV3RU8W/ckUxIBPpuY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=MTMqNuZ6qrwlnA9GnmaTXcNHaZQtLi5dPjRep7s5X5ZwhVUziZNlGhOKZhdckcGK1tV+wAxoSFtsr8AWMHUwfAozQtQmqJT2MXUMJWhcLjIXuH8zv1oCeIDhDKgu7J6ufvOs07HaSs02987EEdi0zA6f3jlzs7RnbqnD0SLJYQ8= 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=Rw9PHJ3n; 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="Rw9PHJ3n" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1713251665; bh=BB6XcCGlmcxZViVH9ZoV55JPlRV3RU8W/ckUxIBPpuY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Rw9PHJ3nE/q4pqibmhDb5ImZuz0A+BEbCw7wHBl5VMR+bOG4g/CsFPHUXSN1i92xS sLVcu4ir7kB+K/xQVCOrkJKL2KiL6DJKhj988C+DsilMgO37LOAY6E1gqKVqIBnOoY a+nk30/GsGiY1GBipTjdYejfB4atAsDXhmChD8/Rx6NCvhF7X+I3bjFWWLR3mguwWK aKLrSVca2cOOkicbjCkeZMg/7BQseQAA1p6iYR5BZmjvwVavH8mLOgPv24TulFev2+ WCTuZ/pz0OEdVPRMqcCZLLgQoyQCyCf+lvkFCqo/znqLZT/3wRarffSaJz6cYtZom7 oPQmG82FlkQbQ== 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 6B1433782134; Tue, 16 Apr 2024 07:14:23 +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 v5 03/18] ASoC: mediatek: mt8188: Migrate to mtk_soundcard_common_probe Date: Tue, 16 Apr 2024 09:13:55 +0200 Message-ID: <20240416071410.75620-4-angelogioacchino.delregno@collabora.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240416071410.75620-1-angelogioacchino.delregno@collabora.com> References: <20240416071410.75620-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. Reviewed-by: Alexandre Mergnat Signed-off-by: AngeloGioacchino Del Regno --- 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:48:16 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 9B94712F395; Tue, 16 Apr 2024 07:14:29 +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=1713251671; cv=none; b=en8Z1SQEW5zPdJ+jXSeuo2yA+z7N+KNgyImQm9dNFuqoiY1r2YdIOYGBXBuymqM9rG1A6AvhTWGt+Zx26SIUZcHIKXiLCPymzUsEpKbJYDC6CvJNyPFdCSjLT9ZWQ/gfJ5UJWQLwW1blu4Yugq38GPkl0Sdg8eIsK/VWlUow9tw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713251671; c=relaxed/simple; bh=TIZvwWDeJ4aqoDbvqKNZ4ihhFX6tlxaL4ndXBGXYyoQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=iva7mtDpxYmwuNEx9pTIVNOuW6BuLBB1GM8+LX1l8TGehVfCWe4TQkvxff/U7AI6pFvE25an6VS4/l5ZvYGSMoE3Jrr6O64tv1JB/OjqRhRHwCmTM9Ysx7tah3UNHQdwalY0CQd+GK8Ia7XkYcuiJwdHf4jHS3EttSXlIbUSwq0= 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=4xNmzsSw; 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="4xNmzsSw" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1713251668; bh=TIZvwWDeJ4aqoDbvqKNZ4ihhFX6tlxaL4ndXBGXYyoQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=4xNmzsSwqWQ0F/wFEwob9m1m907HkL8xmrZrECqjGKgiklAzcJGuq+2QMl403h9fu 1GsQCaLnZc536kxoEi6xWH8VA0ed108OtvI3bOMj9LOeZryycPw9RtklsUn/pjtg9Y f8cSa8nb2ABCzN7/S75RyXFT668669eCb+AIk+fd1Dw4yMzkrS+cbfdO7qsJUjwvlv 5LJXY+TmqJ1w1ghvQOxEtTcoM8QCGNNQSG3LokluBLxdryExOD1jjBfDq8tZLrGBtA WYaC/5cqtO63bAso1j1u7+tCVRAqwQlxG0JSn8ZzYc5/Y7hY783fV3EqCnd2bFt013 UZ4XYY3ju81hw== 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 CB1673782139; Tue, 16 Apr 2024 07:14:25 +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 v5 04/18] ASoC: mediatek: mt8195: Migrate to mtk_soundcard_common_probe Date: Tue, 16 Apr 2024 09:13:56 +0200 Message-ID: <20240416071410.75620-5-angelogioacchino.delregno@collabora.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240416071410.75620-1-angelogioacchino.delregno@collabora.com> References: <20240416071410.75620-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:48:16 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 F34B515575F; Tue, 16 Apr 2024 07:14:31 +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=1713251673; cv=none; b=WL6750Xe7uCdrDGaiO0HH92VgB4k1CyaCMX8btZvY57ZJts4kP8ybmP8hKUgV1mfYy/YbVox0l5vp54AvToEAOPk9cmn+HxSN+SMzhNFzojyFf12VwQrNIagueRV0FlCJfSs9gjXIKBccKaQ9LbyAUgq3r413UPbzgaPizFpNg0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713251673; c=relaxed/simple; bh=zjIts4SQTpsOns/jag7EsJB8dJKI7sT5Nc/h+yx72Ds=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=YRnHmu2jkbJX0LVK7xVKmAsmpJ9SwUFzUBZqpzsdwFntarernbpjoC0jAOyscTAQfHCjRHz6CLouRCCZSWgkYF9GbrpMd4hWuJiprhwTyDGsdgOS4nNiorRcBc6N0XKdzS5k4LMoHCZHblDiZWEAoD6szf8EErr6S8J6x3zGEJA= 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=m7jdpljO; 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="m7jdpljO" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1713251670; bh=zjIts4SQTpsOns/jag7EsJB8dJKI7sT5Nc/h+yx72Ds=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=m7jdpljOHCyOrilK4ROK/YgnxQTDb7XpgXHTYg8gN6ABu1EYMnc9koIpv+QjMdBKt nnqEW/8cc2S3Y/yyBpXUi5MVneQUpHbkIVNspA2ySzZzugjoVp6ZKKL1HDp0vFESue LoAP+JAZ6mHJx5EZgUuILuwaJoVGLW3v6RPxM5T31pZ3hKzeBxGC3oio3ZAnULkKc9 Dl0kVX+2YNzIGW8uvKAbeI2vhCrVEjtuF7al4h2EA6RvRD4NJr+vpZz3kYXZ43OUEM xUWbrzlwqALC4OsVlKTAwbtQkHZlph9ZoF2A2kongEuo6bmU0PK9dqqJQY7jAVWn8K DbNjcVBHLp5Qg== 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 34A2B37820F9; Tue, 16 Apr 2024 07:14:28 +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 v5 05/18] ASoC: mediatek: mt8192: Migrate to mtk_soundcard_common_probe Date: Tue, 16 Apr 2024 09:13:57 +0200 Message-ID: <20240416071410.75620-6-angelogioacchino.delregno@collabora.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240416071410.75620-1-angelogioacchino.delregno@collabora.com> References: <20240416071410.75620-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. Reviewed-by: Alexandre Mergnat Signed-off-by: AngeloGioacchino Del Regno --- .../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:48:16 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 1B78B158D61; Tue, 16 Apr 2024 07:14: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=1713251676; cv=none; b=U/4vJMoTvYzzsuZ/mw6R04OF4pPUtjebDy5Em3eCTs3LlevCi4drcf/U6ifHqIocJtYzzgPCTTQjhxx2XRJJhgTsa62TyoGM0VNOl6AAV2Nf611TUnLfjRJ7eRUEU8unT3VoCnN2KUqCkf3FpwhckjIMVdUyHU7thOT+LmlZ1ww= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713251676; c=relaxed/simple; bh=DH7vyulFVg1rDpurL/O6/TDCItfssmukTVTvmN6uB6s=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=oNj4R1hiY8pKTbBEWsVPp/y8Sg09rd8EXFcuOzOlRIYIqy4tE3t6HTSNGDrvxtfw3JB2aThOXQs5zBvpGennP2TCJm4YybhNZb0CRejVvO8kZalwpBxzJxYN7NppekFvFwNJ4Js6g5qbJ6S/jdQdNJpdxMYemSMokNdldeyRmHY= 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=BiwxkDLd; 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="BiwxkDLd" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1713251672; bh=DH7vyulFVg1rDpurL/O6/TDCItfssmukTVTvmN6uB6s=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BiwxkDLd7SURPReDm3xszdp6BBoJ4XEeemkIpH9HE2FxIBaqZJwcc2VpWR1/FIitx 2O03Ocyw8KtMcfVpjvFFijoxcjGlzt3oH6ukA3DZEHhTQaDbke3PfcTwWBSQAoNaUa qpDMDIS4p0l3o+9zGUZ5xLkLMNwHmQkX2Gy7x+UMFla0pIJDAaL2N/YwPqmLKeqFWn 3yJ2D4fPHjH0t3LF2tZB/tJxsY6zEDqAG1jKCyVJVBPefhtEaa+5Mj9e/Nn+f5jo04 bU0UEFh+uT08SUoaLSkyX5iaa/DLz1KVHylwJlZwsrdXXhv9WIxXoAv1hfQl3yP8eH hhHxxl39s9ekg== 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 912F4378210B; Tue, 16 Apr 2024 07:14: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 v5 06/18] ASoC: mediatek: mt8186: Migrate to mtk_soundcard_common_probe Date: Tue, 16 Apr 2024 09:13:58 +0200 Message-ID: <20240416071410.75620-7-angelogioacchino.delregno@collabora.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240416071410.75620-1-angelogioacchino.delregno@collabora.com> References: <20240416071410.75620-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. Reviewed-by: Alexandre Mergnat Signed-off-by: AngeloGioacchino Del Regno --- .../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:48:16 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 C76B9159905; Tue, 16 Apr 2024 07:14: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=1713251678; cv=none; b=Eak+afGUYVU5sojZG6/wD29VOS90MH5TA26GG01nVQ/k8km9fc6j/eAh6GTBq/QPWUy59TJ6kYWb54m3J/qeCEgRN67JPduxdei8jWwpXj3mTKZxMOq+PAMKjnPEDHv9xEb85aA1Oya7p50d2kESv5u6NUdxiwHwZe58J2CFXs4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713251678; c=relaxed/simple; bh=5LPAOufXMXvr0auuvISTAb5jHc1L/X607/iTKpJRiXY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=K29yzps4oTd4WKdLVxa9DT+dl666IIJJFhptLaUgejTabqZ5LrxK0dVlWUbIJYN3ZY3VhdhOlh308dKqm+eJibyKA0s6iEgmk2Crw7ttGk0nJZ6KB66Oz1Kzyi3DyC1TOkQc7uQ5zxWFaRav/9pLrnA6jIcMj8ZViDgnDZefIOw= 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=XWfg0f6y; 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="XWfg0f6y" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1713251675; bh=5LPAOufXMXvr0auuvISTAb5jHc1L/X607/iTKpJRiXY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XWfg0f6yz77Sb80ENd2o0niSD/3gYX5lZxtBTwwd2jI7ZC5+7HNVL/vwDICzsCjqb UwpuZJZ67Tcplo/5piJQ7HvYuGGSA8vKfi3Mk7ojAon23+drqLxmQ/zNm+QXQR9s8r GnkDQCrsd6SkhImMvxtUQ8QzWzv8CLZHl4G/CQFOj/q2+7RSKCLGzw9Iph+2fQa7E1 mC7/AdYEOPowKp4liHiDx/YfAMcPBFQsI2Vv+rSdw6rht5jtiSAD14/a7fIei6QL0Z zBL3f09qVtF7VUpQj/pciSV1g8A9WdLrpD3qpWxnDlTzh0rhzmfRR37maI7TmYezpp io3TZVh9ZGrKQ== 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 F024B378211D; Tue, 16 Apr 2024 07:14:32 +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 v5 07/18] ASoC: mediatek: Add common snd_soc_ops .startup() callback Date: Tue, 16 Apr 2024 09:13:59 +0200 Message-ID: <20240416071410.75620-8-angelogioacchino.delregno@collabora.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240416071410.75620-1-angelogioacchino.delregno@collabora.com> References: <20240416071410.75620-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. Reviewed-by: Alexandre Mergnat Signed-off-by: AngeloGioacchino Del Regno --- .../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..3bbf42c42805 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..f6c275b54025 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:48:16 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 E5A4215A4A2; Tue, 16 Apr 2024 07:14:38 +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=1713251680; cv=none; b=sMDWLduzXlPc1jBB6MAKaLDvK45G8niU4RFXX6xYcmfYcZWgxBviHsxI7GmHWxCrhM+vh6gWzd4CTXQke9kLM7TQ9zuABqHWo8eWEVRvkO8uaHij3PgePcVRRq88Iq67S60x8IX2LO0fUi70+2ITgZ55Y8TKB4sop9hzTagUSls= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713251680; c=relaxed/simple; bh=LyF7MVjxRuMpCPjEQh4Tk2NLhPg5JMMaQFoGRAX3xfI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ae8nDDK51fgd0uXNOCseuvvaP07TFwSgcbM54v5SnFT6ZzOCvRB2ot0oMwNAvjUEtpfLO/5a1VFjnCb6+qM5KG2I8kKtXOOtYy2WLGyRqZ+nRMUpIQpTzq41cWpnlZwgdY/kPu/jvQPXOuc5ZTQtlKeGwDyRjY80r1C1DqhE00o= 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=3/aFLAzb; 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="3/aFLAzb" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1713251677; bh=LyF7MVjxRuMpCPjEQh4Tk2NLhPg5JMMaQFoGRAX3xfI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=3/aFLAzbPtEIpDRoBSi4+v9X0Mz8bWSAgsTlVwIcOWBnpoTc2IND4OAHYMkmB5hOk zwTfIOLtkdf6WE3S/ulO3GlrX2PnJCcklIBzoZ9QQ+mUHqUenRcNUZdtAbfittY7iH Y+V96L7kkgT92oGKl2Cz8nj6oZSl2IK7WqyfWhoT99cjw5IHmlRpAGgQ+gar6Zt4Pk JonH/9GJaZKjV7cxgMfMKyiwbe8S6S7uKwMrNQAHNziAABoA88/yofcX0s+jM88PE/ 4t/LW+7hUIuCEAYEeBkIueGbN10TKsDky6+XtLhySNsF/x3Fl9cIsCjGqBHuuonvTq ZIkgT7wKYCM/Q== 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 6179B3782123; Tue, 16 Apr 2024 07:14: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 v5 08/18] ASoC: mediatek: mt8195: Migrate to the common mtk_soundcard_startup Date: Tue, 16 Apr 2024 09:14:00 +0200 Message-ID: <20240416071410.75620-9-angelogioacchino.delregno@collabora.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240416071410.75620-1-angelogioacchino.delregno@collabora.com> References: <20240416071410.75620-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. Reviewed-by: Alexandre Mergnat Signed-off-by: AngeloGioacchino Del Regno --- 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..62e4e34cffbb 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 &(const struct snd_pcm_hw_constraint_list) { + .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 &(const struct snd_pcm_hw_constraint_list) { + .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 &(const struct snd_pcm_hw_constraint_list) { + .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:48:16 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 795D382C8E; Tue, 16 Apr 2024 07:14: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=1713251684; cv=none; b=r+BlK8PNOsSvqDfiCOb+TG0pcmPyHordcGPXeyv1SR60U1suC06ODqHFqMqlhd9Alej4nlzzA/Ux/lrytudI2Coy98CO1yt4rWS0mYDjLq2Cj5kB6sP88Nnecv7dV2aCyrf46r1jzNv6bh6S3Moi7qGci99ZxWzXcJMDXhmKmFM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713251684; c=relaxed/simple; bh=dAqkdYAGV8dfv8IH73jURKP3uV28H1etOphrctT3v5I=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=EFuD63hOo2c94gY5v4rU742DhfGOeNH/qh3bC6dUTL3j7QQRkoMgCOgAvMo03l08NbIwEOgo7/2yhLit2crrFWeM4GRc4wLvshegOoTJXY8Ed8N2Ayezl6gi4bV7TImbfc2XCqCn/OWe4eVmVSGrvDzgYdRAYqFL5pWXjexLNiw= 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=BNbztLIC; 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="BNbztLIC" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1713251680; bh=dAqkdYAGV8dfv8IH73jURKP3uV28H1etOphrctT3v5I=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BNbztLICl5lpInrgUzfXqAi5xsofAQjoaWg6vSAsN/9fb8Y09Jv0jLpe9mXWA1FgN 4HsN1IALmwbtmWbRqos1X8eWfnQhhhbiSS/NX4flcMaOQBOopVo4umKY19JY+OhHky s1miwxSMLKMtat6byUG4nzpmNJ0FiGVZjZGQ58CRtjWL/RuD8ePYbSscaEIPrrxcRQ pAynfB5YDB4qmsk+DygK5sxdH32pQJNpd43t+VY1uUZ4TBxWtVa5/lHpla1Num088E 35iu5NXXUsHHzzFpEcL6/nUWDqf2iGtk3VprHHx+PLQcn5M6+AX8/StW4jFMtItYzw aH4dRhs4bDoLA== 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 BF1273782134; Tue, 16 Apr 2024 07:14: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 v5 09/18] ASoC: mediatek: mt8192: Migrate to the common mtk_soundcard_startup Date: Tue, 16 Apr 2024 09:14:01 +0200 Message-ID: <20240416071410.75620-10-angelogioacchino.delregno@collabora.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240416071410.75620-1-angelogioacchino.delregno@collabora.com> References: <20240416071410.75620-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. Reviewed-by: Alexandre Mergnat Signed-off-by: AngeloGioacchino Del Regno --- .../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..8b323fb19925 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 &(const struct snd_pcm_hw_constraint_list) { + .list =3D mt8192_pcm_playback_channels, + .count =3D ARRAY_SIZE(mt8192_pcm_playback_channels) + }, + .rates =3D &(const struct snd_pcm_hw_constraint_list) { + .list =3D mt8192_pcm_playback_rates, + .count =3D ARRAY_SIZE(mt8192_pcm_playback_rates) + } + }, + [MTK_CONSTRAINT_CAPTURE] =3D { + .channels =3D &(const struct snd_pcm_hw_constraint_list) { + .list =3D mt8192_pcm_capture_channels, + .count =3D ARRAY_SIZE(mt8192_pcm_capture_channels) + }, + .rates =3D &(const struct snd_pcm_hw_constraint_list) { + .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:48:16 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 B5E6915AACB; Tue, 16 Apr 2024 07:14: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=1713251685; cv=none; b=NBMl8y0DU66zZsYDAAg/vMVLKRZm9iC4sKN/agGqMDwj9KUGAl5vuPRyaqLhPFuAVTeYG/na+hYShDn2zAh2KQufzXEp1xjDmDdte77WNpD4e2/WkKVnljicWeDDnEAMYisEUUS0OPIfiK8/9jQCM7oYAB55g1q1vDEkgtzmS6I= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713251685; c=relaxed/simple; bh=9tLdQa1pwwBhUSykKr4mr5bn/tTz6nvsWgUVai9A2Co=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=QoPAhfUN5ZMS5HrgbayPsXRM6cU2TyBRFB2T9r9FaHQZec5SThPaMHjDgyTQQkrJhpqGtA/2l3iLS3yMp9LDsNnHTjBDEAhmO+l4z40oN67w7Jdk/I8FU/wAgLsEwvaQ4VsnZB67rZtb6ZC0EuoR0S4w2CcjBsGV38TpUWt5gYo= 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=wpXxXTQ+; 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="wpXxXTQ+" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1713251682; bh=9tLdQa1pwwBhUSykKr4mr5bn/tTz6nvsWgUVai9A2Co=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=wpXxXTQ+G+n0AhJh5kvieSzhRYGVK8a/Tewx/AzVVlbmzqXPlUxEbW2NDqal2QyuZ hjzBtfsnozHDbei22YEOMPMPx/eKO9+QGhNHdKEcYD8V4UDvIwLYN1QYcsc8BaT53q AhcFuR4ZwFajMPt/i9W9/yLmRaqQ5UiXwXHLRnKIXKqt3ok5kpkL/c5tsvHvdI32fT R0wG5i1CNlObhCVqY4kfkBm+2I8UILsYN/6TpDXR7fPG26eYfq+WY4bjBxeWrOdYE9 bre51Oic2KPLRHOW0VgAps/9ZQiRzzfek/Cayyst0Fz/9trnb8afho1j30CVi2RRu4 CFCDIywLX1uXA== 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 29FD137820F9; Tue, 16 Apr 2024 07:14: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 v5 10/18] ASoC: mediatek: mt8186-rt1019: Migrate to the common mtk_soundcard_startup Date: Tue, 16 Apr 2024 09:14:02 +0200 Message-ID: <20240416071410.75620-11-angelogioacchino.delregno@collabora.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240416071410.75620-1-angelogioacchino.delregno@collabora.com> References: <20240416071410.75620-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 --- .../mt8186/mt8186-mt6366-rt1019-rt5682s.c | 132 +++++------------- 1 file changed, 36 insertions(+), 96 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 f8856a100b27..28140ca0ebff 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 &(const struct snd_pcm_hw_constraint_list) { + .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 &(const struct snd_pcm_hw_constraint_list) { + .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:48:16 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 4F49F15ADB0; Tue, 16 Apr 2024 07:14: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=1713251687; cv=none; b=k8yAASfivgfFD7cMe8Y7lhkKBFOynM5r1+t6VTd5KQR70roWEyGJFTuDuDEVEHpK8ti9O71OuL4OPWLdf3mHqgZTQcZLWl+EWd78OM2SzHhxQMafeL/ZVWBhSReM7q6a8pBuuE54Bb3T/Xe5j2W9ZyLxYB+uw2+Hi1spwR3L3yw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713251687; c=relaxed/simple; bh=ZihqOvAsqLa0MvqNqKVldLZPj/NVl1J4njOx31ufWsU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=jVZhwB30+Tf+O+VypsM3noc3S2oH1N/hvLNNpJTXd8HFM4UECkh2adqZ0n/mt/Y+c04t/ZgQrq5RVGjDAat1Yxk0yDuTDANvtI8Ef61CgIWfQffNsXmxPcKT1UZR/Kdutin2VwZ2XkE7K1kXye243bb92cqgJQH7xqup7kEIFbY= 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=Rq4HZUZ3; 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="Rq4HZUZ3" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1713251684; bh=ZihqOvAsqLa0MvqNqKVldLZPj/NVl1J4njOx31ufWsU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Rq4HZUZ3E3NWylxpfqb3YWQ7uGToD4AoQLEpIj4QzP5CXUZnSVMksgV1kN6+p7hBU 7VBzx5dPCVVWSbuu0NiJ5GN3VWZppUrgskfOZLuej4mFvpl54zE7BSTcY4DyuxkJ3u tWg/HybegIjqli+sTup6etrGwZHiAhPYZ2gf1BGvgeJyNKMf3cHzcf/nQV3fszJKG0 +fC/tDbJK9sA8Ziz3l/da3HsXG9V85WnIQXfMPNKhsCrWeSR7G4J64S+4iJreCTsLA t5ovTOct7L+KbYRm25nKoBh/gk2ndsrfffhEdAOB6KYtZ+s5tnM3/p3IwGQ3bDd48S cBZHDv6OPJscQ== 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 8E96A3782123; Tue, 16 Apr 2024 07:14: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 v5 11/18] ASoC: mediatek: Add common mtk_afe_component_probe callback Date: Tue, 16 Apr 2024 09:14:03 +0200 Message-ID: <20240416071410.75620-12-angelogioacchino.delregno@collabora.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240416071410.75620-1-angelogioacchino.delregno@collabora.com> References: <20240416071410.75620-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. Reviewed-by: Alexandre Mergnat Signed-off-by: AngeloGioacchino Del Regno --- .../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:48:16 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 A686415B12F; Tue, 16 Apr 2024 07:14: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=1713251690; cv=none; b=DberyJLxnR2kfxKaumgwXm2FTG1LxfAFyRjYk4U0uZ7DDLKTz2u26+oGhEbkXrVFMtyTnf61xolutB/hnSPzOgtD9iKHKVkDQQNDR1/IzPAiudbQmcpPa7Z0RdEnn4N76yQH4D8zi4iF6qJUJ6QA1AVO7NalPEkmc3iWbSE07fo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713251690; c=relaxed/simple; bh=u3zwsWj3FznMZF6fne2Y0gfUvSivJy3RgPglHp05FEw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=gO8H6A/+hniybvTfLY2o1nql1x6igiJyixUEoC9Pq1oDhCQDJIJFUv2hZ018HZPTlRimqoMcjT04uK/XHGed1VEeVsHw6Uxj90YCbd45XZwIrJWJa2sgMQHJV6TJHH7Ky8a7vxbMzaqlpPtGch3TXPUqCCZSBkxDVCGHxgFT6eE= 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=Y2leWYBu; 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="Y2leWYBu" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1713251687; bh=u3zwsWj3FznMZF6fne2Y0gfUvSivJy3RgPglHp05FEw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Y2leWYBuNEq1AY1jsG3KjLCQUg4E/U6JNyFppUa/HaUwqjFQMU0XfdJIqjIplybOb wlhJtRy2kje2ZaylqpEFo7DaBiEYV4toREZZLHBvvUDuAVdJc9RydIJXUcok7QrajB HlWTU1hPifhcfB71Hz196Vr7Mf75fn7ARD6PLlJdMilbl2QklEBQt4Nfg+7V9lOi1k 0lgEcR3DcX2khoDL0UtDgYOWNqS9Pn+ItbqIaziLSZej24uKyh0H4cVIB3swfNw9oA W/EKoAd2uPuBfp5rDx6aPxouURmkFlwM8pAUO5U5lzPGWOw873dUhVb+iNSki9lVL0 RbU0V8cp2H09w== 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 EE6F2378213F; Tue, 16 Apr 2024 07:14: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 v5 12/18] ASoC: mediatek: Use common mtk_afe_pcm_platform with common probe cb Date: Tue, 16 Apr 2024 09:14:04 +0200 Message-ID: <20240416071410.75620-13-angelogioacchino.delregno@collabora.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240416071410.75620-1-angelogioacchino.delregno@collabora.com> References: <20240416071410.75620-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. Reviewed-by: Alexandre Mergnat Signed-off-by: AngeloGioacchino Del Regno --- 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:48:16 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 68BC915B56C; Tue, 16 Apr 2024 07:14: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=1713251696; cv=none; b=ajbq9gOCkygUN/KWL4Jy6XlfujVYOPbKr9JR4n+K8FWnNtC3YtcNfbFlgmKIyJVTbnTZ8WA3jxM091oSbCkgHMrxEIgAjLKV01HmzHFtmtBQOLniMzDkzFU97XfWJ3otNQ+pGSsBzfB+C1TibtaDAB0McvRs3rBQQuqb2JsBnno= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713251696; c=relaxed/simple; bh=axiFS/bDJRsfnBc3HMnxTtVMWKAiO75/NZOOS/K2xbo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ZfeBuwcjMdZ+CfitLavKXVI8IUgcOkW1KqSj5onW57haGG0Mz/+DV01dInvNHNoawQB0N0td13aDVz3ShfzOz/syNsXphPnVNR2CzYD1HoFrVcP45GWfilLRm6y3qZdc6rKNhz1jEYd5Cs5yroX8e+tGIagc3VBDs8+So9Nvj2A= 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=clXSjAeZ; 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="clXSjAeZ" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1713251689; bh=axiFS/bDJRsfnBc3HMnxTtVMWKAiO75/NZOOS/K2xbo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=clXSjAeZFVRgpo+0K8VFw/ixeac5CKKy9HCGv+SQvvdmJXlU+nNDQO4+G5isZ4nw+ n1lwC+njR3wamYiEAKq9jgYUnqO5HpIRcQMLQZkdYn7qzoQLuRcflqg1+yE2Fi/Ftp LTghVfK1FpN+wRwdd1swWfzjsNRHIIa11IBhdzs+ilsJIlygH8FhK+7uVurghrrCTT ydlBHgzR8NJUBLE5gBR9H83B06nRaHd0p1+ateYsjoO+lx1paxXtzuOMEA1fxOqDEO K9XotnQxj0o+GfpNOkRMssp+l3cBiMz+OWiEfs6R/CWriPGblynMeyWZEp0ScvdfUD wvg4W8IqH5VZg== 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 4D962378211D; Tue, 16 Apr 2024 07:14: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 v5 13/18] ASoC: mediatek: mt8186: Unify mt8186-mt6366 machine drivers Date: Tue, 16 Apr 2024 09:14:05 +0200 Message-ID: <20240416071410.75620-14-angelogioacchino.delregno@collabora.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240416071410.75620-1-angelogioacchino.delregno@collabora.com> References: <20240416071410.75620-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 28140ca0ebff..8fd31c52b077 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:48:16 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 68C1D15B56D; Tue, 16 Apr 2024 07:14: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=1713251694; cv=none; b=qIu/2xDFXPNaGGTCD/o/ORXMwUHhomQBUeuPvbsrmiT5pcpNye9B5clkyfiSjQ2q8e4I8YUnH9OUTaeRThNVgVOwC9KqujpU7aIf3tEEIjfEsp0T/GcHho3/zx09QFsAIms8m0C3Bo2yEYLTUcFU9kqUm0tc81Kftebs2n6/nJU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713251694; c=relaxed/simple; bh=l/YgE2jHDgEGiO5tZpMnwUUm+KuVZjmQoNRva6TC6eM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=WMT1TB7XfSJBj/+tBWjvgKiWp2F+0pMn9c2waCApVdxu/HF+GfrpMmdirT3YrVQCH0oBktd1VDG00nmydCU5ZzD8dBQBzgqN05sBTcxxaW2bW7KexESol5ch+LOuofe3B4XJ9tr+Og7jMArqd7QvsyAGcH72kISFwXGjAibZdR0= 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=fYTAnl9w; 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="fYTAnl9w" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1713251691; bh=l/YgE2jHDgEGiO5tZpMnwUUm+KuVZjmQoNRva6TC6eM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fYTAnl9wUuwE0R1aGy712w49sD5mzXirOnwJn5yVauxOU6KFy6Gz24C2YdlxEtwYI Kn8fJUyYWUBpSi09VisqJE+/5wl1GlIP3jbqJbzH5+hLmca2ODeSLom20TZMC7jdnz 2HWGvaZBYHLCZDmpMmxyyV1kkjLR3nBh3p4zG0YB0g2+UiNsO+MeTKUg6eUXMfkZUd SO+P1i//UHG5gT/rl8dy5lkmGFs3AoGtqNNDH1xyen6CK7tcRPRne8rS25cYLfeZae 8DU9hTs8SSnvyLIpAFJ55vnpNmP//g9LcRRO+cUb6SFooBaVHG5LeZOKoahqeo529r m3F/4ift/AqHw== 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 AF68A3782123; Tue, 16 Apr 2024 07:14: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 v5 14/18] ASoC: dt-bindings: mt8195: Document audio-routing and dai-link subnode Date: Tue, 16 Apr 2024 09:14:06 +0200 Message-ID: <20240416071410.75620-15-angelogioacchino.delregno@collabora.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240416071410.75620-1-angelogioacchino.delregno@collabora.com> References: <20240416071410.75620-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:48:16 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 C963A15B968; Tue, 16 Apr 2024 07:14: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=1713251697; cv=none; b=FxBuucpSoDQ/IVG9iQWjDP7QqS4y6Al+b+tU6MaKyyq3tqwv9zN1X61u5XablNBklTVtghEjz0aBWrPGIWRtXC/KW2edH4OGiBcr9StDwYp/z/rLUUkfprWAUfhbpV5l1Xh608/HNC8g7Ul0dGZuYF4UqMJswgC1jzxmikcNx5o= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713251697; c=relaxed/simple; bh=6SqN9wWBxnCEthQ3e1Jy5DMt1UHcxaWeOQWQPNIAVhw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ZKR59e5KYZtPm8XmmzEoMQ5ldiCQO7ZE8csYdG6s/aE7VUlCN+VAM3ezVhvISGNxPpcU8XxGJOfPrcUaonLWFS8xAZfofrfPiEyLJiaz5/w/Q9SAdy2fFFED7rP6fiMfvXe8T1uhd+h4v5gWg1v7Lkwl6Hh+8KrsLZx8ENl1jt8= 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=E4JXSJaJ; 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="E4JXSJaJ" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1713251694; bh=6SqN9wWBxnCEthQ3e1Jy5DMt1UHcxaWeOQWQPNIAVhw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=E4JXSJaJwGngvDelju68u5X7cw8l3GwdnPtw54YixTw0JrrOa7aLYg5IBVK2+A+vt n1mkPVQ8rtNODQH8XStw7EfbioZBwxWMebUW2AzG3q0URiPy+Ag2fuviBXyOOu2/JC nh2guHaPUDr1UvMAoVLEtyJEL2O/6Uf07LuepIJAjuUrsB/VfyW4bAJL96gB7xIaq4 aJX7mEajAKsqbPlYMPt5xayDkmBXagS0Bejst8CofHgdloGWZakS5nRGk4o0KKUpRd ERFNt4Fc/Ixd5jTAHjYvkenR7FGkPMyFb25aaVxAs2stI9PdM0h2cdO2HcfLhyuVke oaXt9tEREdYdw== 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 1806637820F9; Tue, 16 Apr 2024 07:14:52 +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 v5 15/18] ASoC: dt-bindings: mt8192: Document audio-routing and dai-link subnode Date: Tue, 16 Apr 2024 09:14:07 +0200 Message-ID: <20240416071410.75620-16-angelogioacchino.delregno@collabora.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240416071410.75620-1-angelogioacchino.delregno@collabora.com> References: <20240416071410.75620-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:48:16 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 35AC615CD4C; Tue, 16 Apr 2024 07:14: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=1713251699; cv=none; b=KR/DLoAjZm0RwMtIXAqryJ6Mq1ncXi8A0fEmHbMQJeGb3yyd4rMMfNcta9u5+jB/Bq7UiX3+WNBNQeZATqIqUtbiULhCJAkKep06P0drjVHwMvWoPLhWzI7easiEcjyLmOy/affBg8BMSJKv9EnFDSAg7i4opTMDLyxiL6BToBQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713251699; c=relaxed/simple; bh=0Xu+A6DQSApUl+bx7dqAi1yjwT+TMZd9+xG6pwiMVK4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=J6ioOo0EoGogxZutNvecRnTAMEo5vJNZBAiqCO6cMkEn5QfkBmRCfSxYIdeID34fPJhfatFnmlZshXh/H9lBhpQlAPDGVNAo97CwCuYv2fGONNwC16wvDjL1+6FZCpGKfnR5AJpGnUD4DdYXXDBcGcBVInJQ8BG4VbCa7puBqXM= 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=eQjwEv6Z; 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="eQjwEv6Z" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1713251696; bh=0Xu+A6DQSApUl+bx7dqAi1yjwT+TMZd9+xG6pwiMVK4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=eQjwEv6ZWzF9Ay/bg3H0wAkkjqZxasipdTIvYhVpZ/etz69slrDOawj+7rLe8leTi jhzD9FWjwOfwIW9vbN+3QZg+fY5Evgcy4u2QB53qzjh5ZsrPiNhy2pWUjj22RNYgAg iu4HJ2tfwWJ0AOOMApNLzKOeN3klv1Ovo9FZswp37jYEE+ua1uG7zjIaWGxtMQYlPX u5KvZVSK9sOg6yo7M9AeJrux48r7Mfm1g+F3jEYFMyg90ljJNnn+f9q0Iuu5jKCG4A Sfod7S2Ci1MsL2hX0QaguHQ5Ai2L7ItQUsJuAmkcjpj7P2uofiVw5QO6/C5sYHsNXs Sv/8uxymKcpEg== 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 71226378210B; Tue, 16 Apr 2024 07:14: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 v5 16/18] ASoC: dt-bindings: mt8186: Document audio-routing and dai-link subnode Date: Tue, 16 Apr 2024 09:14:08 +0200 Message-ID: <20240416071410.75620-17-angelogioacchino.delregno@collabora.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240416071410.75620-1-angelogioacchino.delregno@collabora.com> References: <20240416071410.75620-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:48:16 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 8200215CD76; Tue, 16 Apr 2024 07:15: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=1713251702; cv=none; b=fy+qpJoMmLRtBnjnHKAZO9wmR9TrTGgUXogc9FstfBQ5TFwaWFfnLolk6lZ/AdHS/4XVhcWEHzC0ehbhsYyLaVLWb1PWpVvHpkIxmC7shRfk3dSVIBZ8ipxtdjFeUD7/XwBcew/hcSrqUZCLhu793vc9jdBzYO9Wn3H234UyFmc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713251702; c=relaxed/simple; bh=+JfrTVgrO4JkC6c7ui1/Sey7vbzN8l8IbPUAys7zK+A=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=D+BQi+knaRtOrjJOO/IYPV7wyPnWyPmtuwnyReGoHAPFl6E2cgBzi26fdV9RFu0qRfK5K8A9kX4EH3YXYLGeh+3X50brHLCiQcq5YQ1hb6lBx/JKEtN6VcBBxIL54+faKyyYSLNGSKjLMFTFR9vm39nBzFl84FPkNQak9ImxeGk= 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=Z4m62yBD; 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="Z4m62yBD" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1713251699; bh=+JfrTVgrO4JkC6c7ui1/Sey7vbzN8l8IbPUAys7zK+A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Z4m62yBDtA+bF8qt+D4/JNUHrWxWKHTlqZlENRyUayMuEvVEh+oeWVdLagxjdo0ym Sp98TZT+64AGJ03y3vqFyZ+JTQpfn4JlqN2g7AtbRQm/D6Vn9o2vt2eEVcHJyDj6ur N09wMpYdwx9Gkshh3qAwkA6uNXKDc9hIcxnO7nrMK3fGo6LZAhiyC8xSM5Hmt334TD gsYmJ3W+/2cLU2GyQtyH0MtionLZYIGYJF43zfEg8MElyF/L7/4E+yzNKP/F0LlIne 0XSIx3hGmYq7scyzbTfAmWi/wS5khWaADryJmEfwoMOs2y9TtINtIwxfR3xx/epyDR hmZ75XFx7gWrA== 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 CFA6B3782134; Tue, 16 Apr 2024 07:14: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 v5 17/18] arm64: dts: mediatek: mt8195-cherry: Specify sound DAI links and routing Date: Tue, 16 Apr 2024 09:14:09 +0200 Message-ID: <20240416071410.75620-18-angelogioacchino.delregno@collabora.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240416071410.75620-1-angelogioacchino.delregno@collabora.com> References: <20240416071410.75620-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:48:16 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 B67EB15D5D2; Tue, 16 Apr 2024 07:15: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=1713251704; cv=none; b=MSl6us34VORnvHdnNcHQr8COekz1OemglwyolDrzn8bv5h7FsjQfqpYc5XISwlTPRsViI6RQVUIomFbc/4GyrVtVhI0ZkJ9cfoshYMY36ZhoUpqCjnyVp5Ly6AKmVvjGb48y+ksviJilxY8fFv5os4GYizuCihyBy7OxP5p02+s= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713251704; c=relaxed/simple; bh=SRSwRgJbTBz/3750pVOWh9FKrFSoG2LU80QaUy5HTjg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ei+0/nNxdyc0wGFGnFGAYEd9296hLLMmuSjYZSCDjPolOQSkUlWpZLNPhjizNVML0ad0DR5gKm0PenoGMttNrB50FokDgn9B97+W7NpUJ0zhRV8QDxFJA7mrsjxSBDpdvaqdfjA6Fs3fMLMDdN9eANjGPIS/nIlacTTcX7Ed8OY= 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=sAcjfMHW; 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="sAcjfMHW" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1713251701; bh=SRSwRgJbTBz/3750pVOWh9FKrFSoG2LU80QaUy5HTjg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=sAcjfMHWFXTPGeF/nm7OoyhAE4ooMwh1w5xzheHOVXvkUW4AFdfUJg8V/mmPbI+9D Ji/S2alaDeOTs0wan2CUJQgS1eHyP8NEEfJIsxJqNXHmxmvWzsKEI3TyxX9WbMzUwD yKepQZRko8plHDOSZIpzZP0ymKQ6ji9sbe6SZVUA5Ge/RxS/UdcQiYdd0ljr0DvXxq 6sJvGBCYYikzv4EyboGrj4oxRpXYYKEIjB9ZNKtVqBWVTtNgaVIda1eHs4OVt/qfKa cAX3a2OUF4R70gUw4jtJ6P+ynNosiF8LwqyyEldPqfWDWx1Y9FxOXxfmdtGLQ7dVyI KZeaRXxalpRvg== 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 30B26378213E; Tue, 16 Apr 2024 07:14:59 +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 v5 18/18] arm64: dts: mediatek: mt8186-corsola: Specify sound DAI links and routing Date: Tue, 16 Apr 2024 09:14:10 +0200 Message-ID: <20240416071410.75620-19-angelogioacchino.delregno@collabora.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240416071410.75620-1-angelogioacchino.delregno@collabora.com> References: <20240416071410.75620-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