From nobody Thu Nov 14 04:56:18 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 0B0D14C3C3; Wed, 13 Mar 2024 11:02: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=1710327751; cv=none; b=EPr6s+272EvrZA0sPsNc0CnFEQktLSq1VABSlf0RP3HLASUnlZFY6PHzOpWKxmS79JNs7yWnSBJBerx/t0HlhnEnHhZQhaH9anzFvd/DZ736d/8LyU1dDOLyOC0KgZ6D4E9zlbtqOkgjITJY5pp2a8Zcm3ASl8X/oBIytJEwPEw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710327751; c=relaxed/simple; bh=7dwcW721xQhnjT05thzylbyuJsM5PYC/qaTz/86b5ls=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=uBf2HASosbAl1EzFJKW5YV8CemeeGydm3y16TbS6atCeK7WqPlektv5JBY+/dieyt2ipAAljEBRiGh6o76bNrGrhvDi/qkoTKWlyZ9U4Ul3nw79u31E5GhX6Ddgdetcu6CEAY2wSplkc/6glodJuCU78XdyytZ3M4dtwwzEF4Ho= 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=JGarrP1I; 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="JGarrP1I" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1710327748; bh=7dwcW721xQhnjT05thzylbyuJsM5PYC/qaTz/86b5ls=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JGarrP1IjP3HAKG506APsLsBnGggtC7f6yk1qgi7yomGArzJAzUfhYspb9V+/WYO5 vC9VFGJz+8KHjBJADBJtFyk3Q8QwzhU+a212XiBLRIKCEcCCcSDx5rbqMom3GJOX99 GBuI8alds8S5YRnqAu1WOH1hJy0Jx3CYwnj5kFLrE9BE9OIaUMAR7suQQR6r/xNo31 lzU7azNkswNke9/7CV9s+iI/5GivFhSQFqUThHUmBuCy6wQFAw4W/8iMnWEJmHvfOX tCy1MMTmBHHYh8YJknbfVOQSENRNGnQLwwRZuPiMCAcK8wyXDbZmlhO0tHa1JnheI0 dCuc/ju1vL21A== 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 4454B37820D0; Wed, 13 Mar 2024 11:02:26 +0000 (UTC) From: AngeloGioacchino Del Regno To: broonie@kernel.org Cc: wenst@chromium.org, lgirdwood@gmail.com, robh@kernel.org, krzysztof.kozlowski+dt@linaro.org, conor+dt@kernel.org, matthias.bgg@gmail.com, perex@perex.cz, tiwai@suse.com, trevor.wu@mediatek.com, maso.huang@mediatek.com, xiazhengqiao@huaqin.corp-partner.google.com, arnd@arndb.de, kuninori.morimoto.gx@renesas.com, shraash@google.com, amergnat@baylibre.com, nicolas.ferre@microchip.com, u.kleine-koenig@pengutronix.de, dianders@chromium.org, frank.li@vivo.com, allen-kh.cheng@mediatek.com, eugen.hristev@collabora.com, claudiu.beznea@tuxon.dev, jarkko.nikula@bitmer.com, jiaxin.yu@mediatek.com, alpernebiyasak@gmail.com, ckeepax@opensource.cirrus.com, zhourui@huaqin.corp-partner.google.com, nfraprado@collabora.com, alsa-devel@alsa-project.org, shane.chien@mediatek.com, linux-sound@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, kernel@collabora.com, AngeloGioacchino Del Regno Subject: [PATCH v3 13/22] ASoC: mediatek: mt8192: Migrate to the common mtk_soundcard_startup Date: Wed, 13 Mar 2024 12:01:38 +0100 Message-ID: <20240313110147.1267793-14-angelogioacchino.delregno@collabora.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240313110147.1267793-1-angelogioacchino.delregno@collabora.com> References: <20240313110147.1267793-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 --- .../mt8192/mt8192-mt6359-rt1015-rt5682.c | 139 ++++++------------ 1 file changed, 41 insertions(+), 98 deletions(-) diff --git a/sound/soc/mediatek/mt8192/mt8192-mt6359-rt1015-rt5682.c b/soun= d/soc/mediatek/mt8192/mt8192-mt6359-rt1015-rt5682.c index 645bc1aa67c7..5fb34a4834d2 100644 --- a/sound/soc/mediatek/mt8192/mt8192-mt6359-rt1015-rt5682.c +++ b/sound/soc/mediatek/mt8192/mt8192-mt6359-rt1015-rt5682.c @@ -389,100 +389,6 @@ static int mt8192_i2s_hw_params_fixup(struct snd_soc_= pcm_runtime *rtd, return 0; } =20 -static int -mt8192_mt6359_cap1_startup(struct snd_pcm_substream *substream) -{ - static const unsigned int channels[] =3D { - 1, 2, 4 - }; - static const struct snd_pcm_hw_constraint_list constraints_channels =3D { - .count =3D ARRAY_SIZE(channels), - .list =3D channels, - .mask =3D 0, - }; - static const unsigned int rates[] =3D { - 8000, 16000, 32000, 48000, 96000, 192000 - }; - static const struct snd_pcm_hw_constraint_list constraints_rates =3D { - .count =3D ARRAY_SIZE(rates), - .list =3D rates, - .mask =3D 0, - }; - - struct snd_soc_pcm_runtime *rtd =3D snd_soc_substream_to_rtd(substream); - struct snd_pcm_runtime *runtime =3D substream->runtime; - int ret; - - ret =3D snd_pcm_hw_constraint_list(runtime, 0, - SNDRV_PCM_HW_PARAM_CHANNELS, - &constraints_channels); - if (ret < 0) { - dev_err(rtd->dev, "hw_constraint_list channels failed\n"); - return ret; - } - - ret =3D snd_pcm_hw_constraint_list(runtime, 0, - SNDRV_PCM_HW_PARAM_RATE, - &constraints_rates); - if (ret < 0) { - dev_err(rtd->dev, "hw_constraint_list rate failed\n"); - return ret; - } - - return 0; -} - -static const struct snd_soc_ops mt8192_mt6359_capture1_ops =3D { - .startup =3D mt8192_mt6359_cap1_startup, -}; - -static int -mt8192_mt6359_rt5682_startup(struct snd_pcm_substream *substream) -{ - static const unsigned int channels[] =3D { - 1, 2 - }; - static const struct snd_pcm_hw_constraint_list constraints_channels =3D { - .count =3D ARRAY_SIZE(channels), - .list =3D channels, - .mask =3D 0, - }; - static const unsigned int rates[] =3D { - 48000 - }; - static const struct snd_pcm_hw_constraint_list constraints_rates =3D { - .count =3D ARRAY_SIZE(rates), - .list =3D rates, - .mask =3D 0, - }; - - struct snd_soc_pcm_runtime *rtd =3D snd_soc_substream_to_rtd(substream); - struct snd_pcm_runtime *runtime =3D substream->runtime; - int ret; - - ret =3D snd_pcm_hw_constraint_list(runtime, 0, - SNDRV_PCM_HW_PARAM_CHANNELS, - &constraints_channels); - if (ret < 0) { - dev_err(rtd->dev, "hw_constraint_list channels failed\n"); - return ret; - } - - ret =3D snd_pcm_hw_constraint_list(runtime, 0, - SNDRV_PCM_HW_PARAM_RATE, - &constraints_rates); - if (ret < 0) { - dev_err(rtd->dev, "hw_constraint_list rate failed\n"); - return ret; - } - - return 0; -} - -static const struct snd_soc_ops mt8192_mt6359_rt5682_ops =3D { - .startup =3D mt8192_mt6359_rt5682_startup, -}; - /* FE */ SND_SOC_DAILINK_DEFS(playback1, DAILINK_COMP_ARRAY(COMP_CPU("DL1")), @@ -720,7 +626,7 @@ static struct snd_soc_dai_link mt8192_mt6359_dai_links[= ] =3D { SND_SOC_DPCM_TRIGGER_PRE}, .dynamic =3D 1, .dpcm_playback =3D 1, - .ops =3D &mt8192_mt6359_rt5682_ops, + .ops =3D &mtk_soundcard_common_playback_ops, SND_SOC_DAILINK_REG(playback3), }, { @@ -784,7 +690,7 @@ static struct snd_soc_dai_link mt8192_mt6359_dai_links[= ] =3D { SND_SOC_DPCM_TRIGGER_PRE}, .dynamic =3D 1, .dpcm_capture =3D 1, - .ops =3D &mt8192_mt6359_capture1_ops, + .ops =3D &mtk_soundcard_common_capture_ops, SND_SOC_DAILINK_REG(capture1), }, { @@ -794,7 +700,7 @@ static struct snd_soc_dai_link mt8192_mt6359_dai_links[= ] =3D { SND_SOC_DPCM_TRIGGER_PRE}, .dynamic =3D 1, .dpcm_capture =3D 1, - .ops =3D &mt8192_mt6359_rt5682_ops, + .ops =3D &mtk_soundcard_common_playback_ops, SND_SOC_DAILINK_REG(capture2), }, { @@ -1146,7 +1052,7 @@ static int mt8192_mt6359_legacy_probe(struct mtk_soc_= card_data *soc_card_data) struct device *dev =3D card->dev; struct device_node *hdmi_codec, *headset_codec, *speaker_codec; struct snd_soc_dai_link *dai_link; - int ret, i; + int i, ret =3D 0; =20 hdmi_codec =3D of_parse_phandle(dev->of_node, "mediatek,hdmi-codec", 0); if (!hdmi_codec) @@ -1235,11 +1141,44 @@ static int mt8192_mt6359_soc_card_probe(struct mtk_= soc_card_data *soc_card_data, return 0; } =20 +static const unsigned int mt8192_pcm_playback_channels[] =3D { 1, 2 }; +static const unsigned int mt8192_pcm_playback_rates[] =3D { 48000 }; + +static const unsigned int mt8192_pcm_capture_channels[] =3D { 1, 2, 4 }; +static const unsigned int mt8192_pcm_capture_rates[] =3D { + 8000, 16000, 32000, 48000, 96000, 192000 +}; + +static const struct mtk_pcm_constraints_data mt8192_pcm_constraints[MTK_CO= NSTRAINT_CAPTURE + 1] =3D { + [MTK_CONSTRAINT_PLAYBACK] =3D { + .channels =3D { + .list =3D mt8192_pcm_playback_channels, + .count =3D ARRAY_SIZE(mt8192_pcm_playback_channels) + }, + .rates =3D { + .list =3D mt8192_pcm_playback_rates, + .count =3D ARRAY_SIZE(mt8192_pcm_playback_rates) + } + }, + [MTK_CONSTRAINT_CAPTURE] =3D { + .channels =3D { + .list =3D mt8192_pcm_capture_channels, + .count =3D ARRAY_SIZE(mt8192_pcm_capture_channels) + }, + .rates =3D { + .list =3D mt8192_pcm_capture_rates, + .count =3D ARRAY_SIZE(mt8192_pcm_capture_rates) + } + } +}; + static const struct mtk_soundcard_pdata mt8192_mt6359_rt1015_rt5682_pdata = =3D { .card_name =3D RT1015_RT5682_CARD_NAME, .card_data =3D &(struct mtk_platform_card_data) { .card =3D &mt8192_mt6359_rt1015_rt5682_card, .num_jacks =3D MT8192_JACK_MAX, + .pcm_constraints =3D mt8192_pcm_constraints, + .num_pcm_constraints =3D ARRAY_SIZE(mt8192_pcm_constraints), }, .soc_probe =3D mt8192_mt6359_soc_card_probe }; @@ -1249,6 +1188,8 @@ static const struct mtk_soundcard_pdata mt8192_mt6359= _rt1015p_rt5682_pdata =3D { .card_data =3D &(struct mtk_platform_card_data) { .card =3D &mt8192_mt6359_rt1015p_rt5682x_card, .num_jacks =3D MT8192_JACK_MAX, + .pcm_constraints =3D mt8192_pcm_constraints, + .num_pcm_constraints =3D ARRAY_SIZE(mt8192_pcm_constraints), }, .soc_probe =3D mt8192_mt6359_soc_card_probe }; @@ -1258,6 +1199,8 @@ static const struct mtk_soundcard_pdata mt8192_mt6359= _rt1015p_rt5682s_pdata =3D { .card_data =3D &(struct mtk_platform_card_data) { .card =3D &mt8192_mt6359_rt1015p_rt5682x_card, .num_jacks =3D MT8192_JACK_MAX, + .pcm_constraints =3D mt8192_pcm_constraints, + .num_pcm_constraints =3D ARRAY_SIZE(mt8192_pcm_constraints), }, .soc_probe =3D mt8192_mt6359_soc_card_probe }; --=20 2.44.0