Skip to content

Commit 2355028

Browse files
wenliangwubroonie
authored andcommitted
ASoC: mediatek: mt8195: correct pcmif BE dai control flow
Originally, the conditions for preventing reentry are not correct. dai->component->active is not the state specifically for pcmif dai, so it is not a correct condition to indicate the status of pcmif dai. On the other hand, snd_soc_dai_stream_actvie() in prepare ops for both playback and capture possibly return true at the first entry when these two streams are opened at the same time. In the patch, I refer to the implementation in mt8192-dai-pcm.c. Clock and enabling bit for PCMIF are managed by DAPM, and the condition for prepare ops is replaced by the status of dai widget. Fixes: 1f95c01 ("ASoC: mediatek: mt8195: support pcm in platform driver") Signed-off-by: Trevor Wu <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Mark Brown <[email protected]>
1 parent cc5c978 commit 2355028

File tree

2 files changed

+22
-52
lines changed

2 files changed

+22
-52
lines changed

sound/soc/mediatek/mt8195/mt8195-dai-pcm.c

Lines changed: 21 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,15 @@ static const struct snd_soc_dapm_widget mtk_dai_pcm_widgets[] = {
8080
mtk_dai_pcm_o001_mix,
8181
ARRAY_SIZE(mtk_dai_pcm_o001_mix)),
8282

83+
SND_SOC_DAPM_SUPPLY("PCM_EN", PCM_INTF_CON1,
84+
PCM_INTF_CON1_PCM_EN_SHIFT, 0, NULL, 0),
85+
8386
SND_SOC_DAPM_INPUT("PCM1_INPUT"),
8487
SND_SOC_DAPM_OUTPUT("PCM1_OUTPUT"),
88+
89+
SND_SOC_DAPM_CLOCK_SUPPLY("aud_asrc11"),
90+
SND_SOC_DAPM_CLOCK_SUPPLY("aud_asrc12"),
91+
SND_SOC_DAPM_CLOCK_SUPPLY("aud_pcmif"),
8592
};
8693

8794
static const struct snd_soc_dapm_route mtk_dai_pcm_routes[] = {
@@ -97,22 +104,18 @@ static const struct snd_soc_dapm_route mtk_dai_pcm_routes[] = {
97104
{"PCM1 Playback", NULL, "O000"},
98105
{"PCM1 Playback", NULL, "O001"},
99106

107+
{"PCM1 Playback", NULL, "PCM_EN"},
108+
{"PCM1 Playback", NULL, "aud_asrc12"},
109+
{"PCM1 Playback", NULL, "aud_pcmif"},
110+
111+
{"PCM1 Capture", NULL, "PCM_EN"},
112+
{"PCM1 Capture", NULL, "aud_asrc11"},
113+
{"PCM1 Capture", NULL, "aud_pcmif"},
114+
100115
{"PCM1_OUTPUT", NULL, "PCM1 Playback"},
101116
{"PCM1 Capture", NULL, "PCM1_INPUT"},
102117
};
103118

104-
static void mtk_dai_pcm_enable(struct mtk_base_afe *afe)
105-
{
106-
regmap_update_bits(afe->regmap, PCM_INTF_CON1,
107-
PCM_INTF_CON1_PCM_EN, PCM_INTF_CON1_PCM_EN);
108-
}
109-
110-
static void mtk_dai_pcm_disable(struct mtk_base_afe *afe)
111-
{
112-
regmap_update_bits(afe->regmap, PCM_INTF_CON1,
113-
PCM_INTF_CON1_PCM_EN, 0x0);
114-
}
115-
116119
static int mtk_dai_pcm_configure(struct snd_pcm_substream *substream,
117120
struct snd_soc_dai *dai)
118121
{
@@ -207,54 +210,22 @@ static int mtk_dai_pcm_configure(struct snd_pcm_substream *substream,
207210
}
208211

209212
/* dai ops */
210-
static int mtk_dai_pcm_startup(struct snd_pcm_substream *substream,
211-
struct snd_soc_dai *dai)
212-
{
213-
struct mtk_base_afe *afe = snd_soc_dai_get_drvdata(dai);
214-
struct mt8195_afe_private *afe_priv = afe->platform_priv;
215-
216-
if (dai->component->active)
217-
return 0;
218-
219-
mt8195_afe_enable_clk(afe, afe_priv->clk[MT8195_CLK_AUD_ASRC11]);
220-
mt8195_afe_enable_clk(afe, afe_priv->clk[MT8195_CLK_AUD_ASRC12]);
221-
mt8195_afe_enable_clk(afe, afe_priv->clk[MT8195_CLK_AUD_PCMIF]);
222-
223-
return 0;
224-
}
225-
226-
static void mtk_dai_pcm_shutdown(struct snd_pcm_substream *substream,
227-
struct snd_soc_dai *dai)
228-
{
229-
struct mtk_base_afe *afe = snd_soc_dai_get_drvdata(dai);
230-
struct mt8195_afe_private *afe_priv = afe->platform_priv;
231-
232-
if (dai->component->active)
233-
return;
234-
235-
mtk_dai_pcm_disable(afe);
236-
237-
mt8195_afe_disable_clk(afe, afe_priv->clk[MT8195_CLK_AUD_PCMIF]);
238-
mt8195_afe_disable_clk(afe, afe_priv->clk[MT8195_CLK_AUD_ASRC12]);
239-
mt8195_afe_disable_clk(afe, afe_priv->clk[MT8195_CLK_AUD_ASRC11]);
240-
}
241-
242213
static int mtk_dai_pcm_prepare(struct snd_pcm_substream *substream,
243214
struct snd_soc_dai *dai)
244215
{
245-
struct mtk_base_afe *afe = snd_soc_dai_get_drvdata(dai);
246-
int ret = 0;
216+
int ret;
247217

248-
if (snd_soc_dai_stream_active(dai, SNDRV_PCM_STREAM_PLAYBACK) &&
249-
snd_soc_dai_stream_active(dai, SNDRV_PCM_STREAM_CAPTURE))
218+
dev_dbg(dai->dev, "%s(), id %d, stream %d, widget active p %d, c %d\n",
219+
__func__, dai->id, substream->stream,
220+
dai->playback_widget->active, dai->capture_widget->active);
221+
222+
if (dai->playback_widget->active || dai->capture_widget->active)
250223
return 0;
251224

252225
ret = mtk_dai_pcm_configure(substream, dai);
253226
if (ret)
254227
return ret;
255228

256-
mtk_dai_pcm_enable(afe);
257-
258229
return 0;
259230
}
260231

@@ -316,8 +287,6 @@ static int mtk_dai_pcm_set_fmt(struct snd_soc_dai *dai, unsigned int fmt)
316287
}
317288

318289
static const struct snd_soc_dai_ops mtk_dai_pcm_ops = {
319-
.startup = mtk_dai_pcm_startup,
320-
.shutdown = mtk_dai_pcm_shutdown,
321290
.prepare = mtk_dai_pcm_prepare,
322291
.set_fmt = mtk_dai_pcm_set_fmt,
323292
};

sound/soc/mediatek/mt8195/mt8195-reg.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2550,6 +2550,7 @@
25502550
#define PCM_INTF_CON1_PCM_FMT(x) (((x) & 0x3) << 1)
25512551
#define PCM_INTF_CON1_PCM_FMT_MASK (0x3 << 1)
25522552
#define PCM_INTF_CON1_PCM_EN BIT(0)
2553+
#define PCM_INTF_CON1_PCM_EN_SHIFT 0
25532554

25542555
/* PCM_INTF_CON2 */
25552556
#define PCM_INTF_CON2_CLK_DOMAIN_SEL(x) (((x) & 0x3) << 23)

0 commit comments

Comments
 (0)