Skip to content

Commit 83f1b7f

Browse files
yaochunhungbroonie
authored andcommitted
ASoC: mediatek: mt8195: add sof be ops to check audio active
In MT8195 SOF design, both DSP and audio driver would access audio registers. Before DSP accesses audio registers, audio power and clock should be enabled. DSP will hang up if DSP access audio register but audio power and clock are disabled. Therefore, we add audio pm runtime active checking before accessing audio registers in SOF BE's callback hw_params function to avoid this situation. Signed-off-by: YC Hung <[email protected]> Reviewed-by: AngeloGioacchino Del Regno <[email protected]> Acked-by: Curtis Malainey <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Mark Brown <[email protected]>
1 parent e85b1f5 commit 83f1b7f

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

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

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -633,6 +633,32 @@ static const struct snd_soc_ops mt8195_rt1011_etdm_ops = {
633633
.hw_params = mt8195_rt1011_etdm_hw_params,
634634
};
635635

636+
static int mt8195_sof_be_hw_params(struct snd_pcm_substream *substream,
637+
struct snd_pcm_hw_params *params)
638+
{
639+
struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream);
640+
struct snd_soc_component *cmpnt_afe = NULL;
641+
struct snd_soc_pcm_runtime *runtime;
642+
643+
/* find afe component */
644+
for_each_card_rtds(rtd->card, runtime) {
645+
cmpnt_afe = snd_soc_rtdcom_lookup(runtime, AFE_PCM_NAME);
646+
if (cmpnt_afe)
647+
break;
648+
}
649+
650+
if (cmpnt_afe && !pm_runtime_active(cmpnt_afe->dev)) {
651+
dev_err(rtd->dev, "afe pm runtime is not active!!\n");
652+
return -EINVAL;
653+
}
654+
655+
return 0;
656+
}
657+
658+
static const struct snd_soc_ops mt8195_sof_be_ops = {
659+
.hw_params = mt8195_sof_be_hw_params,
660+
};
661+
636662
static int mt8195_rt1011_init(struct snd_soc_pcm_runtime *rtd)
637663
{
638664
struct snd_soc_card *card = rtd->card;
@@ -1272,24 +1298,28 @@ static struct snd_soc_dai_link mt8195_mt6359_dai_links[] = {
12721298
.name = "AFE_SOF_DL2",
12731299
.no_pcm = 1,
12741300
.dpcm_playback = 1,
1301+
.ops = &mt8195_sof_be_ops,
12751302
SND_SOC_DAILINK_REG(AFE_SOF_DL2),
12761303
},
12771304
[DAI_LINK_SOF_DL3_BE] = {
12781305
.name = "AFE_SOF_DL3",
12791306
.no_pcm = 1,
12801307
.dpcm_playback = 1,
1308+
.ops = &mt8195_sof_be_ops,
12811309
SND_SOC_DAILINK_REG(AFE_SOF_DL3),
12821310
},
12831311
[DAI_LINK_SOF_UL4_BE] = {
12841312
.name = "AFE_SOF_UL4",
12851313
.no_pcm = 1,
12861314
.dpcm_capture = 1,
1315+
.ops = &mt8195_sof_be_ops,
12871316
SND_SOC_DAILINK_REG(AFE_SOF_UL4),
12881317
},
12891318
[DAI_LINK_SOF_UL5_BE] = {
12901319
.name = "AFE_SOF_UL5",
12911320
.no_pcm = 1,
12921321
.dpcm_capture = 1,
1322+
.ops = &mt8195_sof_be_ops,
12931323
SND_SOC_DAILINK_REG(AFE_SOF_UL5),
12941324
},
12951325
};

0 commit comments

Comments
 (0)