public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ASoC: mediatek: mt8195: add sof be ops to check audio active
@ 2022-12-09  3:10 YC Hung
  2022-12-09 18:27 ` Curtis Malainey
  2022-12-14 13:32 ` Mark Brown
  0 siblings, 2 replies; 4+ messages in thread
From: YC Hung @ 2022-12-09  3:10 UTC (permalink / raw)
  Cc: yc.hung, Liam Girdwood, Mark Brown, Jaroslav Kysela, Takashi Iwai,
	Matthias Brugger, Tzung-Bi Shih, AngeloGioacchino Del Regno,
	Trevor Wu, Nicolas F . R . A . Prado, Jiaxin Yu, alsa-devel,
	linux-arm-kernel, linux-mediatek, linux-kernel, Curtis Malainey,
	whalechang

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 <yc.hung@mediatek.com>
---
 sound/soc/mediatek/mt8195/mt8195-mt6359.c | 30 +++++++++++++++++++++++
 1 file changed, 30 insertions(+)

diff --git a/sound/soc/mediatek/mt8195/mt8195-mt6359.c b/sound/soc/mediatek/mt8195/mt8195-mt6359.c
index 61be66f47723..4682748d82be 100644
--- a/sound/soc/mediatek/mt8195/mt8195-mt6359.c
+++ b/sound/soc/mediatek/mt8195/mt8195-mt6359.c
@@ -633,6 +633,32 @@ static const struct snd_soc_ops mt8195_rt1011_etdm_ops = {
 	.hw_params = mt8195_rt1011_etdm_hw_params,
 };
 
+static int mt8195_sof_be_hw_params(struct snd_pcm_substream *substream,
+				   struct snd_pcm_hw_params *params)
+{
+	struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream);
+	struct snd_soc_component *cmpnt_afe = NULL;
+	struct snd_soc_pcm_runtime *runtime;
+
+	/* find afe component */
+	for_each_card_rtds(rtd->card, runtime) {
+		cmpnt_afe = snd_soc_rtdcom_lookup(runtime, AFE_PCM_NAME);
+		if (cmpnt_afe)
+			break;
+	}
+
+	if (cmpnt_afe && !pm_runtime_active(cmpnt_afe->dev)) {
+		dev_err(rtd->dev, "afe pm runtime is not active!!\n");
+		return -EINVAL;
+	}
+
+	return 0;
+}
+
+static const struct snd_soc_ops mt8195_sof_be_ops = {
+	.hw_params = mt8195_sof_be_hw_params,
+};
+
 static int mt8195_rt1011_init(struct snd_soc_pcm_runtime *rtd)
 {
 	struct snd_soc_card *card = rtd->card;
@@ -1272,24 +1298,28 @@ static struct snd_soc_dai_link mt8195_mt6359_dai_links[] = {
 		.name = "AFE_SOF_DL2",
 		.no_pcm = 1,
 		.dpcm_playback = 1,
+		.ops = &mt8195_sof_be_ops,
 		SND_SOC_DAILINK_REG(AFE_SOF_DL2),
 	},
 	[DAI_LINK_SOF_DL3_BE] = {
 		.name = "AFE_SOF_DL3",
 		.no_pcm = 1,
 		.dpcm_playback = 1,
+		.ops = &mt8195_sof_be_ops,
 		SND_SOC_DAILINK_REG(AFE_SOF_DL3),
 	},
 	[DAI_LINK_SOF_UL4_BE] = {
 		.name = "AFE_SOF_UL4",
 		.no_pcm = 1,
 		.dpcm_capture = 1,
+		.ops = &mt8195_sof_be_ops,
 		SND_SOC_DAILINK_REG(AFE_SOF_UL4),
 	},
 	[DAI_LINK_SOF_UL5_BE] = {
 		.name = "AFE_SOF_UL5",
 		.no_pcm = 1,
 		.dpcm_capture = 1,
+		.ops = &mt8195_sof_be_ops,
 		SND_SOC_DAILINK_REG(AFE_SOF_UL5),
 	},
 };
-- 
2.18.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] ASoC: mediatek: mt8195: add sof be ops to check audio active
  2022-12-09  3:10 [PATCH] ASoC: mediatek: mt8195: add sof be ops to check audio active YC Hung
@ 2022-12-09 18:27 ` Curtis Malainey
  2022-12-12  8:50   ` AngeloGioacchino Del Regno
  2022-12-14 13:32 ` Mark Brown
  1 sibling, 1 reply; 4+ messages in thread
From: Curtis Malainey @ 2022-12-09 18:27 UTC (permalink / raw)
  To: YC Hung
  Cc: Liam Girdwood, Mark Brown, Jaroslav Kysela, Takashi Iwai,
	Matthias Brugger, Tzung-Bi Shih, AngeloGioacchino Del Regno,
	Trevor Wu, Nicolas F . R . A . Prado, Jiaxin Yu, alsa-devel,
	linux-arm-kernel, linux-mediatek, linux-kernel, Curtis Malainey,
	whalechang

On Thu, Dec 8, 2022 at 7:11 PM YC Hung <yc.hung@mediatek.com> wrote:
>
> 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 <yc.hung@mediatek.com>

Acked-by: Curtis Malainey <cujomalainey@chromium.org>

> ---
>  sound/soc/mediatek/mt8195/mt8195-mt6359.c | 30 +++++++++++++++++++++++
>  1 file changed, 30 insertions(+)
>
> diff --git a/sound/soc/mediatek/mt8195/mt8195-mt6359.c b/sound/soc/mediatek/mt8195/mt8195-mt6359.c
> index 61be66f47723..4682748d82be 100644
> --- a/sound/soc/mediatek/mt8195/mt8195-mt6359.c
> +++ b/sound/soc/mediatek/mt8195/mt8195-mt6359.c
> @@ -633,6 +633,32 @@ static const struct snd_soc_ops mt8195_rt1011_etdm_ops = {
>         .hw_params = mt8195_rt1011_etdm_hw_params,
>  };
>
> +static int mt8195_sof_be_hw_params(struct snd_pcm_substream *substream,
> +                                  struct snd_pcm_hw_params *params)
> +{
> +       struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream);
> +       struct snd_soc_component *cmpnt_afe = NULL;
> +       struct snd_soc_pcm_runtime *runtime;
> +
> +       /* find afe component */
> +       for_each_card_rtds(rtd->card, runtime) {
> +               cmpnt_afe = snd_soc_rtdcom_lookup(runtime, AFE_PCM_NAME);
> +               if (cmpnt_afe)
> +                       break;
> +       }
> +
> +       if (cmpnt_afe && !pm_runtime_active(cmpnt_afe->dev)) {
> +               dev_err(rtd->dev, "afe pm runtime is not active!!\n");
> +               return -EINVAL;
> +       }
> +
> +       return 0;
> +}
> +
> +static const struct snd_soc_ops mt8195_sof_be_ops = {
> +       .hw_params = mt8195_sof_be_hw_params,
> +};
> +
>  static int mt8195_rt1011_init(struct snd_soc_pcm_runtime *rtd)
>  {
>         struct snd_soc_card *card = rtd->card;
> @@ -1272,24 +1298,28 @@ static struct snd_soc_dai_link mt8195_mt6359_dai_links[] = {
>                 .name = "AFE_SOF_DL2",
>                 .no_pcm = 1,
>                 .dpcm_playback = 1,
> +               .ops = &mt8195_sof_be_ops,
>                 SND_SOC_DAILINK_REG(AFE_SOF_DL2),
>         },
>         [DAI_LINK_SOF_DL3_BE] = {
>                 .name = "AFE_SOF_DL3",
>                 .no_pcm = 1,
>                 .dpcm_playback = 1,
> +               .ops = &mt8195_sof_be_ops,
>                 SND_SOC_DAILINK_REG(AFE_SOF_DL3),
>         },
>         [DAI_LINK_SOF_UL4_BE] = {
>                 .name = "AFE_SOF_UL4",
>                 .no_pcm = 1,
>                 .dpcm_capture = 1,
> +               .ops = &mt8195_sof_be_ops,
>                 SND_SOC_DAILINK_REG(AFE_SOF_UL4),
>         },
>         [DAI_LINK_SOF_UL5_BE] = {
>                 .name = "AFE_SOF_UL5",
>                 .no_pcm = 1,
>                 .dpcm_capture = 1,
> +               .ops = &mt8195_sof_be_ops,
>                 SND_SOC_DAILINK_REG(AFE_SOF_UL5),
>         },
>  };
> --
> 2.18.0
>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] ASoC: mediatek: mt8195: add sof be ops to check audio active
  2022-12-09 18:27 ` Curtis Malainey
@ 2022-12-12  8:50   ` AngeloGioacchino Del Regno
  0 siblings, 0 replies; 4+ messages in thread
From: AngeloGioacchino Del Regno @ 2022-12-12  8:50 UTC (permalink / raw)
  To: Curtis Malainey, YC Hung
  Cc: Liam Girdwood, Mark Brown, Jaroslav Kysela, Takashi Iwai,
	Matthias Brugger, Tzung-Bi Shih, Trevor Wu,
	Nicolas F . R . A . Prado, Jiaxin Yu, alsa-devel,
	linux-arm-kernel, linux-mediatek, linux-kernel, Curtis Malainey,
	whalechang

Il 09/12/22 19:27, Curtis Malainey ha scritto:
> On Thu, Dec 8, 2022 at 7:11 PM YC Hung <yc.hung@mediatek.com> wrote:
>>
>> 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 <yc.hung@mediatek.com>
> 
> Acked-by: Curtis Malainey <cujomalainey@chromium.org>
> 

Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] ASoC: mediatek: mt8195: add sof be ops to check audio active
  2022-12-09  3:10 [PATCH] ASoC: mediatek: mt8195: add sof be ops to check audio active YC Hung
  2022-12-09 18:27 ` Curtis Malainey
@ 2022-12-14 13:32 ` Mark Brown
  1 sibling, 0 replies; 4+ messages in thread
From: Mark Brown @ 2022-12-14 13:32 UTC (permalink / raw)
  To: YC Hung
  Cc: Liam Girdwood, Jaroslav Kysela, Takashi Iwai, Matthias Brugger,
	Tzung-Bi Shih, AngeloGioacchino Del Regno, Trevor Wu,
	Nicolas F . R . A . Prado, Jiaxin Yu, alsa-devel,
	linux-arm-kernel, linux-mediatek, linux-kernel, Curtis Malainey,
	whalechang

On Fri, 09 Dec 2022 11:10:53 +0800, YC Hung wrote:
> 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.
> 
> [...]

Applied to

   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next

Thanks!

[1/1] ASoC: mediatek: mt8195: add sof be ops to check audio active
      commit: 83f1b7f39af73b01edf098fe3141404670703281

All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying
to this mail.

Thanks,
Mark

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-12-14 13:33 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-12-09  3:10 [PATCH] ASoC: mediatek: mt8195: add sof be ops to check audio active YC Hung
2022-12-09 18:27 ` Curtis Malainey
2022-12-12  8:50   ` AngeloGioacchino Del Regno
2022-12-14 13:32 ` Mark Brown

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox