From nobody Sun Nov 10 05:57:21 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 64E154CB4A; Wed, 13 Mar 2024 11:02:32 +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=1710327754; cv=none; b=PacN07q/XdtpJDE3axG800uQ1f5nxHtYp9EPw+zVn9153wMitcHR7iIt6mljKS+7U2CLVZKQ7UDrxLRM/RuCNz1/roynpN1oVBwOpTg/F/w2vWhxmOoMd0QW2vwcHI4i5MwlF/Vl2OQE/37BsgEf+aaHbe96Rk00aD6sZlKK3oY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710327754; c=relaxed/simple; bh=lUeV2tKuXM18CPDYVVd//fD5s8BvB6xZr/GWUR7gNcc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=NR1ckqsRZMpFTxfWBx3Q4o8/kbNyFGFCdpOdSsT+Nto/m6dEOIpxxU9hnRPhRUP44uKTeMEFiLTTFc86IuTrTc9XmCHJZGdWQW4qDGq+AJ/hixNJX05RDHcKFEIyg2HRuzpPUSwTo2q+Xx3czu/0FYFhyOMmMp6Vl37iXBnYKak= 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=v9Pm7ddf; 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="v9Pm7ddf" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1710327750; bh=lUeV2tKuXM18CPDYVVd//fD5s8BvB6xZr/GWUR7gNcc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=v9Pm7ddfSyo6uotU4SXwM20WMrfkVyvbvkacMJqbTS4uussnSXdhaDDPjvmWzMjwg 2/lbi7x1bPBTybrAUtqNIkOtW+uGhIvZgqHSHjmqiJEoX2dpzYpvfderbRYS2P+wyX 1AmJwiB3GKNKmDH5JLuR1TIc3MnHBRxdNanZ02siXF05gQPYdXwC+gG6QQFw1N0i4s jIEWl6Bq5CEL1AvLUXCl0945mQbWKDF/N8zhMCxUfXRQWaWZ6V8Un1KTSw2pSnNy3D vHpMvyHKJf8NV9lFsYyktWFTOFXDNpIVtTxPdb732lYGPGuirOSwNtWyjoTOxrW+iA 5Kec35+0eJAhw== 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 A12C337820D4; Wed, 13 Mar 2024 11:02: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 v3 14/22] ASoC: mediatek: mt8186-rt1019: Migrate to the common mtk_soundcard_startup Date: Wed, 13 Mar 2024 12:01:39 +0100 Message-ID: <20240313110147.1267793-15-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 --- sound/soc/mediatek/mt8186/mt8186-afe-pcm.c | 19 ++- sound/soc/mediatek/mt8186/mt8186-dai-adda.c | 2 +- .../mt8186/mt8186-mt6366-rt1019-rt5682s.c | 132 +++++------------- 3 files changed, 52 insertions(+), 101 deletions(-) diff --git a/sound/soc/mediatek/mt8186/mt8186-afe-pcm.c b/sound/soc/mediate= k/mt8186/mt8186-afe-pcm.c index bfcfc68ac64d..dbe5afa0e9ee 100644 --- a/sound/soc/mediatek/mt8186/mt8186-afe-pcm.c +++ b/sound/soc/mediatek/mt8186/mt8186-afe-pcm.c @@ -2729,7 +2729,7 @@ static int mt8186_afe_runtime_resume(struct device *d= ev) struct mtk_base_afe *afe =3D dev_get_drvdata(dev); struct mt8186_afe_private *afe_priv =3D afe->platform_priv; int ret; - +pr_err("mt8186 afe runtime_resume\n"); ret =3D mt8186_afe_enable_clock(afe); if (ret) return ret; @@ -2739,7 +2739,7 @@ static int mt8186_afe_runtime_resume(struct device *d= ev) return ret; =20 if (!afe->regmap || afe_priv->pm_runtime_bypass_reg_ctl) - goto skip_regmap; + return 0; =20 regcache_cache_only(afe->regmap, false); regcache_sync(afe->regmap); @@ -2758,13 +2758,20 @@ static int mt8186_afe_runtime_resume(struct device = *dev) /* enable AFE */ regmap_update_bits(afe->regmap, AFE_DAC_CON0, AUDIO_AFE_ON_MASK_SFT, BIT(= 0)); =20 -skip_regmap: return 0; } =20 static int mt8186_afe_component_probe(struct snd_soc_component *component) { - mtk_afe_add_sub_dai_control(component); + struct mtk_base_afe *afe =3D snd_soc_component_get_drvdata(component); + int ret; + + snd_soc_component_init_regmap(component, afe->regmap); + + ret =3D mtk_afe_add_sub_dai_control(component); + if (ret) + return ret; + mt8186_add_misc_control(component); =20 return 0; @@ -2929,6 +2936,10 @@ static int mt8186_afe_pcm_dev_probe(struct platform_= device *pdev) goto err_pm_disable; } =20 + ret =3D regmap_reinit_cache(afe->regmap, &mt8186_afe_regmap_config); + if (ret) + return dev_err_probe(dev, ret, "regmap_reinit_cache fail\n"); + /* others */ afe->mtk_afe_hardware =3D &mt8186_afe_hardware; afe->memif_fs =3D mt8186_memif_fs; diff --git a/sound/soc/mediatek/mt8186/mt8186-dai-adda.c b/sound/soc/mediat= ek/mt8186/mt8186-dai-adda.c index dbd157d1a1ea..b87b04928678 100644 --- a/sound/soc/mediatek/mt8186/mt8186-dai-adda.c +++ b/sound/soc/mediatek/mt8186/mt8186-dai-adda.c @@ -413,7 +413,7 @@ static const struct snd_soc_dapm_widget mtk_dai_adda_wi= dgets[] =3D { SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD), =20 SND_SOC_DAPM_SUPPLY_S("AUD_PAD_TOP", SUPPLY_SEQ_ADDA_AUD_PAD_TOP, - AFE_AUD_PAD_TOP, RG_RX_FIFO_ON_SFT, 0, + SND_SOC_NOPM, 0, 0, mtk_adda_pad_top_event, SND_SOC_DAPM_PRE_PMU), SND_SOC_DAPM_SUPPLY_S("ADDA_MTKAIF_CFG", SUPPLY_SEQ_ADDA_MTKAIF_CFG, diff --git a/sound/soc/mediatek/mt8186/mt8186-mt6366-rt1019-rt5682s.c b/sou= nd/soc/mediatek/mt8186/mt8186-mt6366-rt1019-rt5682s.c index 66e15b883f54..3c972d7e1f94 100644 --- a/sound/soc/mediatek/mt8186/mt8186-mt6366-rt1019-rt5682s.c +++ b/sound/soc/mediatek/mt8186/mt8186-mt6366-rt1019-rt5682s.c @@ -332,98 +332,6 @@ static int mt8186_sof_dai_link_fixup(struct snd_soc_pc= m_runtime *rtd, return ret; } =20 -static int mt8186_mt6366_rt1019_rt5682s_playback_startup(struct snd_pcm_su= bstream *substream) -{ - static const unsigned int rates[] =3D { - 48000 - }; - static const unsigned int channels[] =3D { - 2 - }; - static const struct snd_pcm_hw_constraint_list constraints_rates =3D { - .count =3D ARRAY_SIZE(rates), - .list =3D rates, - .mask =3D 0, - }; - static const struct snd_pcm_hw_constraint_list constraints_channels =3D { - .count =3D ARRAY_SIZE(channels), - .list =3D channels, - .mask =3D 0, - }; - - struct snd_soc_pcm_runtime *rtd =3D snd_soc_substream_to_rtd(substream); - struct snd_pcm_runtime *runtime =3D substream->runtime; - int ret; - - ret =3D snd_pcm_hw_constraint_list(runtime, 0, - SNDRV_PCM_HW_PARAM_RATE, - &constraints_rates); - if (ret < 0) { - dev_err(rtd->dev, "hw_constraint_list rate failed\n"); - return ret; - } - - ret =3D snd_pcm_hw_constraint_list(runtime, 0, - SNDRV_PCM_HW_PARAM_CHANNELS, - &constraints_channels); - if (ret < 0) { - dev_err(rtd->dev, "hw_constraint_list channel failed\n"); - return ret; - } - - return 0; -} - -static const struct snd_soc_ops mt8186_mt6366_rt1019_rt5682s_playback_ops = =3D { - .startup =3D mt8186_mt6366_rt1019_rt5682s_playback_startup, -}; - -static int mt8186_mt6366_rt1019_rt5682s_capture_startup(struct snd_pcm_sub= stream *substream) -{ - static const unsigned int rates[] =3D { - 48000 - }; - static const unsigned int channels[] =3D { - 1, 2 - }; - static const struct snd_pcm_hw_constraint_list constraints_rates =3D { - .count =3D ARRAY_SIZE(rates), - .list =3D rates, - .mask =3D 0, - }; - static const struct snd_pcm_hw_constraint_list constraints_channels =3D { - .count =3D ARRAY_SIZE(channels), - .list =3D channels, - .mask =3D 0, - }; - - struct snd_soc_pcm_runtime *rtd =3D snd_soc_substream_to_rtd(substream); - struct snd_pcm_runtime *runtime =3D substream->runtime; - int ret; - - ret =3D snd_pcm_hw_constraint_list(runtime, 0, - SNDRV_PCM_HW_PARAM_RATE, - &constraints_rates); - if (ret < 0) { - dev_err(rtd->dev, "hw_constraint_list rate failed\n"); - return ret; - } - - ret =3D snd_pcm_hw_constraint_list(runtime, 0, - SNDRV_PCM_HW_PARAM_CHANNELS, - &constraints_channels); - if (ret < 0) { - dev_err(rtd->dev, "hw_constraint_list channel failed\n"); - return ret; - } - - return 0; -} - -static const struct snd_soc_ops mt8186_mt6366_rt1019_rt5682s_capture_ops = =3D { - .startup =3D mt8186_mt6366_rt1019_rt5682s_capture_startup, -}; - /* FE */ SND_SOC_DAILINK_DEFS(playback1, DAILINK_COMP_ARRAY(COMP_CPU("DL1")), @@ -644,7 +552,7 @@ static struct snd_soc_dai_link mt8186_mt6366_rt1019_rt5= 682s_dai_links[] =3D { .dpcm_merged_format =3D 1, .dpcm_merged_chan =3D 1, .dpcm_merged_rate =3D 1, - .ops =3D &mt8186_mt6366_rt1019_rt5682s_playback_ops, + .ops =3D &mtk_soundcard_common_playback_ops, SND_SOC_DAILINK_REG(playback1), }, { @@ -678,7 +586,7 @@ static struct snd_soc_dai_link mt8186_mt6366_rt1019_rt5= 682s_dai_links[] =3D { .dpcm_merged_format =3D 1, .dpcm_merged_chan =3D 1, .dpcm_merged_rate =3D 1, - .ops =3D &mt8186_mt6366_rt1019_rt5682s_playback_ops, + .ops =3D &mtk_soundcard_common_playback_ops, SND_SOC_DAILINK_REG(playback3), }, { @@ -745,7 +653,7 @@ static struct snd_soc_dai_link mt8186_mt6366_rt1019_rt5= 682s_dai_links[] =3D { .dpcm_merged_format =3D 1, .dpcm_merged_chan =3D 1, .dpcm_merged_rate =3D 1, - .ops =3D &mt8186_mt6366_rt1019_rt5682s_capture_ops, + .ops =3D &mtk_soundcard_common_capture_ops, SND_SOC_DAILINK_REG(capture2), }, { @@ -767,7 +675,7 @@ static struct snd_soc_dai_link mt8186_mt6366_rt1019_rt5= 682s_dai_links[] =3D { .dpcm_merged_format =3D 1, .dpcm_merged_chan =3D 1, .dpcm_merged_rate =3D 1, - .ops =3D &mt8186_mt6366_rt1019_rt5682s_capture_ops, + .ops =3D &mtk_soundcard_common_capture_ops, SND_SOC_DAILINK_REG(capture4), }, { @@ -1220,6 +1128,32 @@ static int mt8186_mt6366_soc_card_probe(struct mtk_s= oc_card_data *soc_card_data, return 0; } =20 +static const unsigned int mt8186_pcm_playback_channels[] =3D { 2 }; +static const unsigned int mt8186_pcm_capture_channels[] =3D { 1, 2 }; +static const unsigned int mt8186_pcm_rates[] =3D { 48000 }; + +static const struct snd_pcm_hw_constraint_list mt8186_rate_constraint =3D { + .list =3D mt8186_pcm_rates, + .count =3D ARRAY_SIZE(mt8186_pcm_rates) +}; + +static const struct mtk_pcm_constraints_data mt8186_pcm_constraints[MTK_CO= NSTRAINT_CAPTURE + 1] =3D { + [MTK_CONSTRAINT_PLAYBACK] =3D { + .channels =3D { + .list =3D mt8186_pcm_playback_channels, + .count =3D ARRAY_SIZE(mt8186_pcm_playback_channels) + }, + .rates =3D mt8186_rate_constraint, + }, + [MTK_CONSTRAINT_CAPTURE] =3D { + .channels =3D { + .list =3D mt8186_pcm_capture_channels, + .count =3D ARRAY_SIZE(mt8186_pcm_capture_channels) + }, + .rates =3D mt8186_rate_constraint, + } +}; + static const struct mtk_sof_priv mt8186_sof_priv =3D { .conn_streams =3D g_sof_conn_streams, .num_streams =3D ARRAY_SIZE(g_sof_conn_streams), @@ -1230,6 +1164,8 @@ static const struct mtk_soundcard_pdata mt8186_mt6366= _rt1019_rt5682s_pdata =3D { .card_data =3D &(struct mtk_platform_card_data) { .card =3D &mt8186_mt6366_rt1019_rt5682s_soc_card, .num_jacks =3D MT8186_JACK_MAX, + .pcm_constraints =3D mt8186_pcm_constraints, + .num_pcm_constraints =3D ARRAY_SIZE(mt8186_pcm_constraints), }, .sof_priv =3D &mt8186_sof_priv, .soc_probe =3D mt8186_mt6366_soc_card_probe @@ -1239,6 +1175,8 @@ static const struct mtk_soundcard_pdata mt8186_mt6366= _rt5682s_max98360_pdata =3D { .card_data =3D &(struct mtk_platform_card_data) { .card =3D &mt8186_mt6366_rt5682s_max98360_soc_card, .num_jacks =3D MT8186_JACK_MAX, + .pcm_constraints =3D mt8186_pcm_constraints, + .num_pcm_constraints =3D ARRAY_SIZE(mt8186_pcm_constraints), }, .sof_priv =3D &mt8186_sof_priv, .soc_probe =3D mt8186_mt6366_soc_card_probe @@ -1248,6 +1186,8 @@ static const struct mtk_soundcard_pdata mt8186_mt6366= _rt5650_pdata =3D { .card_data =3D &(struct mtk_platform_card_data) { .card =3D &mt8186_mt6366_rt5650_soc_card, .num_jacks =3D MT8186_JACK_MAX, + .pcm_constraints =3D mt8186_pcm_constraints, + .num_pcm_constraints =3D ARRAY_SIZE(mt8186_pcm_constraints), }, .sof_priv =3D &mt8186_sof_priv, .soc_probe =3D mt8186_mt6366_soc_card_probe --=20 2.44.0