Skip to content

Commit a155b75

Browse files
committed
ASoC: mediatek: mt8195: repair pcmif BE dai
Merge series from Trevor Wu <[email protected]>: This series of patches repairs some problems for pcmif BE dai. The unexpected control flow is corrected, and the missing playback support of DPCM is added.
2 parents 85b57de + db5e1c2 commit a155b75

File tree

4 files changed

+24
-52
lines changed

4 files changed

+24
-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-mt6359-rt1011-rt5682.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1045,6 +1045,7 @@ static struct snd_soc_dai_link mt8195_mt6359_rt1011_rt5682_dai_links[] = {
10451045
.dai_fmt = SND_SOC_DAIFMT_I2S |
10461046
SND_SOC_DAIFMT_NB_NF |
10471047
SND_SOC_DAIFMT_CBS_CFS,
1048+
.dpcm_playback = 1,
10481049
.dpcm_capture = 1,
10491050
SND_SOC_DAILINK_REG(PCM1_BE),
10501051
},

sound/soc/mediatek/mt8195/mt8195-mt6359-rt1019-rt5682.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1191,6 +1191,7 @@ static struct snd_soc_dai_link mt8195_mt6359_rt1019_rt5682_dai_links[] = {
11911191
.dai_fmt = SND_SOC_DAIFMT_I2S |
11921192
SND_SOC_DAIFMT_NB_NF |
11931193
SND_SOC_DAIFMT_CBS_CFS,
1194+
.dpcm_playback = 1,
11941195
.dpcm_capture = 1,
11951196
SND_SOC_DAILINK_REG(PCM1_BE),
11961197
},

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)