[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20240313110147.1267793-15-angelogioacchino.delregno@collabora.com>
Date: Wed, 13 Mar 2024 12:01:39 +0100
From: AngeloGioacchino Del Regno <angelogioacchino.delregno@...labora.com>
To: broonie@...nel.org
Cc: wenst@...omium.org,
lgirdwood@...il.com,
robh@...nel.org,
krzysztof.kozlowski+dt@...aro.org,
conor+dt@...nel.org,
matthias.bgg@...il.com,
perex@...ex.cz,
tiwai@...e.com,
trevor.wu@...iatek.com,
maso.huang@...iatek.com,
xiazhengqiao@...qin.corp-partner.google.com,
arnd@...db.de,
kuninori.morimoto.gx@...esas.com,
shraash@...gle.com,
amergnat@...libre.com,
nicolas.ferre@...rochip.com,
u.kleine-koenig@...gutronix.de,
dianders@...omium.org,
frank.li@...o.com,
allen-kh.cheng@...iatek.com,
eugen.hristev@...labora.com,
claudiu.beznea@...on.dev,
jarkko.nikula@...mer.com,
jiaxin.yu@...iatek.com,
alpernebiyasak@...il.com,
ckeepax@...nsource.cirrus.com,
zhourui@...qin.corp-partner.google.com,
nfraprado@...labora.com,
alsa-devel@...a-project.org,
shane.chien@...iatek.com,
linux-sound@...r.kernel.org,
devicetree@...r.kernel.org,
linux-kernel@...r.kernel.org,
linux-arm-kernel@...ts.infradead.org,
linux-mediatek@...ts.infradead.org,
kernel@...labora.com,
AngeloGioacchino Del Regno <angelogioacchino.delregno@...labora.com>
Subject: [PATCH v3 14/22] ASoC: mediatek: mt8186-rt1019: Migrate to the common mtk_soundcard_startup
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 <angelogioacchino.delregno@...labora.com>
---
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/mediatek/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 *dev)
struct mtk_base_afe *afe = dev_get_drvdata(dev);
struct mt8186_afe_private *afe_priv = afe->platform_priv;
int ret;
-
+pr_err("mt8186 afe runtime_resume\n");
ret = mt8186_afe_enable_clock(afe);
if (ret)
return ret;
@@ -2739,7 +2739,7 @@ static int mt8186_afe_runtime_resume(struct device *dev)
return ret;
if (!afe->regmap || afe_priv->pm_runtime_bypass_reg_ctl)
- goto skip_regmap;
+ return 0;
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));
-skip_regmap:
return 0;
}
static int mt8186_afe_component_probe(struct snd_soc_component *component)
{
- mtk_afe_add_sub_dai_control(component);
+ struct mtk_base_afe *afe = snd_soc_component_get_drvdata(component);
+ int ret;
+
+ snd_soc_component_init_regmap(component, afe->regmap);
+
+ ret = mtk_afe_add_sub_dai_control(component);
+ if (ret)
+ return ret;
+
mt8186_add_misc_control(component);
return 0;
@@ -2929,6 +2936,10 @@ static int mt8186_afe_pcm_dev_probe(struct platform_device *pdev)
goto err_pm_disable;
}
+ ret = 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 = &mt8186_afe_hardware;
afe->memif_fs = mt8186_memif_fs;
diff --git a/sound/soc/mediatek/mt8186/mt8186-dai-adda.c b/sound/soc/mediatek/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_widgets[] = {
SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
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/sound/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_pcm_runtime *rtd,
return ret;
}
-static int mt8186_mt6366_rt1019_rt5682s_playback_startup(struct snd_pcm_substream *substream)
-{
- static const unsigned int rates[] = {
- 48000
- };
- static const unsigned int channels[] = {
- 2
- };
- static const struct snd_pcm_hw_constraint_list constraints_rates = {
- .count = ARRAY_SIZE(rates),
- .list = rates,
- .mask = 0,
- };
- static const struct snd_pcm_hw_constraint_list constraints_channels = {
- .count = ARRAY_SIZE(channels),
- .list = channels,
- .mask = 0,
- };
-
- struct snd_soc_pcm_runtime *rtd = snd_soc_substream_to_rtd(substream);
- struct snd_pcm_runtime *runtime = substream->runtime;
- int ret;
-
- ret = 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 = 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 = {
- .startup = mt8186_mt6366_rt1019_rt5682s_playback_startup,
-};
-
-static int mt8186_mt6366_rt1019_rt5682s_capture_startup(struct snd_pcm_substream *substream)
-{
- static const unsigned int rates[] = {
- 48000
- };
- static const unsigned int channels[] = {
- 1, 2
- };
- static const struct snd_pcm_hw_constraint_list constraints_rates = {
- .count = ARRAY_SIZE(rates),
- .list = rates,
- .mask = 0,
- };
- static const struct snd_pcm_hw_constraint_list constraints_channels = {
- .count = ARRAY_SIZE(channels),
- .list = channels,
- .mask = 0,
- };
-
- struct snd_soc_pcm_runtime *rtd = snd_soc_substream_to_rtd(substream);
- struct snd_pcm_runtime *runtime = substream->runtime;
- int ret;
-
- ret = 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 = 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 = {
- .startup = 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_rt5682s_dai_links[] = {
.dpcm_merged_format = 1,
.dpcm_merged_chan = 1,
.dpcm_merged_rate = 1,
- .ops = &mt8186_mt6366_rt1019_rt5682s_playback_ops,
+ .ops = &mtk_soundcard_common_playback_ops,
SND_SOC_DAILINK_REG(playback1),
},
{
@@ -678,7 +586,7 @@ static struct snd_soc_dai_link mt8186_mt6366_rt1019_rt5682s_dai_links[] = {
.dpcm_merged_format = 1,
.dpcm_merged_chan = 1,
.dpcm_merged_rate = 1,
- .ops = &mt8186_mt6366_rt1019_rt5682s_playback_ops,
+ .ops = &mtk_soundcard_common_playback_ops,
SND_SOC_DAILINK_REG(playback3),
},
{
@@ -745,7 +653,7 @@ static struct snd_soc_dai_link mt8186_mt6366_rt1019_rt5682s_dai_links[] = {
.dpcm_merged_format = 1,
.dpcm_merged_chan = 1,
.dpcm_merged_rate = 1,
- .ops = &mt8186_mt6366_rt1019_rt5682s_capture_ops,
+ .ops = &mtk_soundcard_common_capture_ops,
SND_SOC_DAILINK_REG(capture2),
},
{
@@ -767,7 +675,7 @@ static struct snd_soc_dai_link mt8186_mt6366_rt1019_rt5682s_dai_links[] = {
.dpcm_merged_format = 1,
.dpcm_merged_chan = 1,
.dpcm_merged_rate = 1,
- .ops = &mt8186_mt6366_rt1019_rt5682s_capture_ops,
+ .ops = &mtk_soundcard_common_capture_ops,
SND_SOC_DAILINK_REG(capture4),
},
{
@@ -1220,6 +1128,32 @@ static int mt8186_mt6366_soc_card_probe(struct mtk_soc_card_data *soc_card_data,
return 0;
}
+static const unsigned int mt8186_pcm_playback_channels[] = { 2 };
+static const unsigned int mt8186_pcm_capture_channels[] = { 1, 2 };
+static const unsigned int mt8186_pcm_rates[] = { 48000 };
+
+static const struct snd_pcm_hw_constraint_list mt8186_rate_constraint = {
+ .list = mt8186_pcm_rates,
+ .count = ARRAY_SIZE(mt8186_pcm_rates)
+};
+
+static const struct mtk_pcm_constraints_data mt8186_pcm_constraints[MTK_CONSTRAINT_CAPTURE + 1] = {
+ [MTK_CONSTRAINT_PLAYBACK] = {
+ .channels = {
+ .list = mt8186_pcm_playback_channels,
+ .count = ARRAY_SIZE(mt8186_pcm_playback_channels)
+ },
+ .rates = mt8186_rate_constraint,
+ },
+ [MTK_CONSTRAINT_CAPTURE] = {
+ .channels = {
+ .list = mt8186_pcm_capture_channels,
+ .count = ARRAY_SIZE(mt8186_pcm_capture_channels)
+ },
+ .rates = mt8186_rate_constraint,
+ }
+};
+
static const struct mtk_sof_priv mt8186_sof_priv = {
.conn_streams = g_sof_conn_streams,
.num_streams = ARRAY_SIZE(g_sof_conn_streams),
@@ -1230,6 +1164,8 @@ static const struct mtk_soundcard_pdata mt8186_mt6366_rt1019_rt5682s_pdata = {
.card_data = &(struct mtk_platform_card_data) {
.card = &mt8186_mt6366_rt1019_rt5682s_soc_card,
.num_jacks = MT8186_JACK_MAX,
+ .pcm_constraints = mt8186_pcm_constraints,
+ .num_pcm_constraints = ARRAY_SIZE(mt8186_pcm_constraints),
},
.sof_priv = &mt8186_sof_priv,
.soc_probe = mt8186_mt6366_soc_card_probe
@@ -1239,6 +1175,8 @@ static const struct mtk_soundcard_pdata mt8186_mt6366_rt5682s_max98360_pdata = {
.card_data = &(struct mtk_platform_card_data) {
.card = &mt8186_mt6366_rt5682s_max98360_soc_card,
.num_jacks = MT8186_JACK_MAX,
+ .pcm_constraints = mt8186_pcm_constraints,
+ .num_pcm_constraints = ARRAY_SIZE(mt8186_pcm_constraints),
},
.sof_priv = &mt8186_sof_priv,
.soc_probe = mt8186_mt6366_soc_card_probe
@@ -1248,6 +1186,8 @@ static const struct mtk_soundcard_pdata mt8186_mt6366_rt5650_pdata = {
.card_data = &(struct mtk_platform_card_data) {
.card = &mt8186_mt6366_rt5650_soc_card,
.num_jacks = MT8186_JACK_MAX,
+ .pcm_constraints = mt8186_pcm_constraints,
+ .num_pcm_constraints = ARRAY_SIZE(mt8186_pcm_constraints),
},
.sof_priv = &mt8186_sof_priv,
.soc_probe = mt8186_mt6366_soc_card_probe
--
2.44.0
Powered by blists - more mailing lists