mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] drm/bridge: imx: imx8mp-hdmi-pai: enable pm runtime
@ 2026-01-30  5:55 Shengjiu Wang
  2026-01-30  6:49 ` Liu Ying
  0 siblings, 1 reply; 5+ messages in thread
From: Shengjiu Wang @ 2026-01-30  5:55 UTC (permalink / raw)
  To: victor.liu, andrzej.hajda, neil.armstrong, rfoss,
	Laurent.pinchart, jonas, jernej.skrabec, maarten.lankhorst,
	mripard, tzimmermann, airlied, simona, shawnguo, s.hauer, kernel,
	festevam, dri-devel, imx, linux-arm-kernel, linux-kernel

There is an audio channel shift issue with multi channel case, first run
the channel order is correct, but second run the channel order is shifted.
The recovery method is to reset the pai interface.

The reset can be handled by pm runtime, so add the pm runtime function.

Signed-off-by: Shengjiu Wang <shengjiu.wang@nxp.com>
---
 drivers/gpu/drm/bridge/imx/imx8mp-hdmi-pai.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/drivers/gpu/drm/bridge/imx/imx8mp-hdmi-pai.c b/drivers/gpu/drm/bridge/imx/imx8mp-hdmi-pai.c
index 8d13a35b206a..1afc729da9b9 100644
--- a/drivers/gpu/drm/bridge/imx/imx8mp-hdmi-pai.c
+++ b/drivers/gpu/drm/bridge/imx/imx8mp-hdmi-pai.c
@@ -8,6 +8,7 @@
 #include <linux/module.h>
 #include <linux/of_platform.h>
 #include <linux/platform_device.h>
+#include <linux/pm_runtime.h>
 #include <linux/regmap.h>
 #include <drm/bridge/dw_hdmi.h>
 #include <sound/asoundef.h>
@@ -33,6 +34,7 @@
 
 struct imx8mp_hdmi_pai {
 	struct regmap	*regmap;
+	struct device	*dev;
 };
 
 static void imx8mp_hdmi_pai_enable(struct dw_hdmi *dw_hdmi, int channel,
@@ -43,6 +45,9 @@ static void imx8mp_hdmi_pai_enable(struct dw_hdmi *dw_hdmi, int channel,
 	struct imx8mp_hdmi_pai *hdmi_pai = pdata->priv_audio;
 	int val;
 
+	if (pm_runtime_get_sync(hdmi_pai->dev) < 0)
+		return;
+
 	/* PAI set control extended */
 	val =  WTMK_HIGH(3) | WTMK_LOW(3);
 	val |= NUM_CH(channel);
@@ -85,6 +90,8 @@ static void imx8mp_hdmi_pai_disable(struct dw_hdmi *dw_hdmi)
 
 	/* Stop PAI */
 	regmap_write(hdmi_pai->regmap, HTX_PAI_CTRL, 0);
+
+	pm_runtime_put_sync(hdmi_pai->dev);
 }
 
 static const struct regmap_config imx8mp_hdmi_pai_regmap_config = {
@@ -101,6 +108,7 @@ static int imx8mp_hdmi_pai_bind(struct device *dev, struct device *master, void
 	struct imx8mp_hdmi_pai *hdmi_pai;
 	struct resource *res;
 	void __iomem *base;
+	int ret;
 
 	hdmi_pai = devm_kzalloc(dev, sizeof(*hdmi_pai), GFP_KERNEL);
 	if (!hdmi_pai)
@@ -121,6 +129,13 @@ static int imx8mp_hdmi_pai_bind(struct device *dev, struct device *master, void
 	plat_data->disable_audio = imx8mp_hdmi_pai_disable;
 	plat_data->priv_audio = hdmi_pai;
 
+	hdmi_pai->dev = dev;
+	ret = devm_pm_runtime_enable(dev);
+	if (ret < 0) {
+		dev_err(dev, "failed to enable pm runtime: %d\n", ret);
+		return ret;
+	}
+
 	return 0;
 }
 
-- 
2.34.1


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

* Re: [PATCH] drm/bridge: imx: imx8mp-hdmi-pai: enable pm runtime
  2026-01-30  5:55 [PATCH] drm/bridge: imx: imx8mp-hdmi-pai: enable pm runtime Shengjiu Wang
@ 2026-01-30  6:49 ` Liu Ying
  2026-01-30  7:06   ` Shengjiu Wang
  0 siblings, 1 reply; 5+ messages in thread
From: Liu Ying @ 2026-01-30  6:49 UTC (permalink / raw)
  To: Shengjiu Wang, andrzej.hajda, neil.armstrong, rfoss,
	Laurent.pinchart, jonas, jernej.skrabec, maarten.lankhorst,
	mripard, tzimmermann, airlied, simona, shawnguo, s.hauer, kernel,
	festevam, dri-devel, imx, linux-arm-kernel, linux-kernel

Hi Shengjiu,

On Fri, Jan 30, 2026 at 01:55:08PM +0800, Shengjiu Wang wrote:
> There is an audio channel shift issue with multi channel case, first run
> the channel order is correct, but second run the channel order is shifted.

Nit: I'd rephrase "There is an audio channel shift issue with multi channel
case - the channel order is correct for the first run, but the channel order
is shifted for the second run.".

> The recovery method is to reset the pai interface.

s/pai/PAI/

Can the channel order shift issue be fully fixed instead of implementing
a "recovery method"?  I presume that this patch implements a recovery
mechanism.  If it can't, any chip ERRATA?

> 
> The reset can be handled by pm runtime, so add the pm runtime function.

Nit: s/pm/PM/

s/add the pm runtime function/enable PM runtime/

> 
> Signed-off-by: Shengjiu Wang <shengjiu.wang@nxp.com>
> ---
>  drivers/gpu/drm/bridge/imx/imx8mp-hdmi-pai.c | 15 +++++++++++++++
>  1 file changed, 15 insertions(+)

Subject prefix should be "drm/bridge: imx8mp-hdmi-pai:".
Refer to what previous commits for i.MX bridge drivers use.

> 
> diff --git a/drivers/gpu/drm/bridge/imx/imx8mp-hdmi-pai.c b/drivers/gpu/drm/bridge/imx/imx8mp-hdmi-pai.c
> index 8d13a35b206a..1afc729da9b9 100644
> --- a/drivers/gpu/drm/bridge/imx/imx8mp-hdmi-pai.c
> +++ b/drivers/gpu/drm/bridge/imx/imx8mp-hdmi-pai.c
> @@ -8,6 +8,7 @@
>  #include <linux/module.h>
>  #include <linux/of_platform.h>
>  #include <linux/platform_device.h>
> +#include <linux/pm_runtime.h>
>  #include <linux/regmap.h>
>  #include <drm/bridge/dw_hdmi.h>
>  #include <sound/asoundef.h>
> @@ -33,6 +34,7 @@
>  
>  struct imx8mp_hdmi_pai {
>  	struct regmap	*regmap;
> +	struct device	*dev;
>  };
>  
>  static void imx8mp_hdmi_pai_enable(struct dw_hdmi *dw_hdmi, int channel,
> @@ -43,6 +45,9 @@ static void imx8mp_hdmi_pai_enable(struct dw_hdmi *dw_hdmi, int channel,
>  	struct imx8mp_hdmi_pai *hdmi_pai = pdata->priv_audio;
>  	int val;
>  
> +	if (pm_runtime_get_sync(hdmi_pai->dev) < 0)

Use pm_runtime_resume_and_get instead.

-8<-
  `int pm_runtime_get_sync(struct device *dev);`
    - increment the device's usage counter, run pm_runtime_resume(dev) and
      return its result;
      note that it does not drop the device's usage counter on errors, so
      consider using pm_runtime_resume_and_get() instead of it, especially
      if its return value is checked by the caller, as this is likely to
      result in cleaner code.
-8<-

> +		return;
> +
>  	/* PAI set control extended */
>  	val =  WTMK_HIGH(3) | WTMK_LOW(3);
>  	val |= NUM_CH(channel);
> @@ -85,6 +90,8 @@ static void imx8mp_hdmi_pai_disable(struct dw_hdmi *dw_hdmi)
>  
>  	/* Stop PAI */
>  	regmap_write(hdmi_pai->regmap, HTX_PAI_CTRL, 0);
> +
> +	pm_runtime_put_sync(hdmi_pai->dev);
>  }
>  
>  static const struct regmap_config imx8mp_hdmi_pai_regmap_config = {
> @@ -101,6 +108,7 @@ static int imx8mp_hdmi_pai_bind(struct device *dev, struct device *master, void
>  	struct imx8mp_hdmi_pai *hdmi_pai;
>  	struct resource *res;
>  	void __iomem *base;
> +	int ret;
>  
>  	hdmi_pai = devm_kzalloc(dev, sizeof(*hdmi_pai), GFP_KERNEL);
>  	if (!hdmi_pai)
> @@ -121,6 +129,13 @@ static int imx8mp_hdmi_pai_bind(struct device *dev, struct device *master, void
>  	plat_data->disable_audio = imx8mp_hdmi_pai_disable;
>  	plat_data->priv_audio = hdmi_pai;
>  
> +	hdmi_pai->dev = dev;
> +	ret = devm_pm_runtime_enable(dev);
> +	if (ret < 0) {
> +		dev_err(dev, "failed to enable pm runtime: %d\n", ret);

s/pm/PM/

> +		return ret;
> +	}
> +
>  	return 0;
>  }
>  

-- 
Regards,
Liu Ying

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

* Re: [PATCH] drm/bridge: imx: imx8mp-hdmi-pai: enable pm runtime
  2026-01-30  6:49 ` Liu Ying
@ 2026-01-30  7:06   ` Shengjiu Wang
  2026-01-30  7:09     ` Liu Ying
  0 siblings, 1 reply; 5+ messages in thread
From: Shengjiu Wang @ 2026-01-30  7:06 UTC (permalink / raw)
  To: Liu Ying
  Cc: Shengjiu Wang, andrzej.hajda, neil.armstrong, rfoss,
	Laurent.pinchart, jonas, jernej.skrabec, maarten.lankhorst,
	mripard, tzimmermann, airlied, simona, shawnguo, s.hauer, kernel,
	festevam, dri-devel, imx, linux-arm-kernel, linux-kernel

On Fri, Jan 30, 2026 at 2:49 PM Liu Ying <victor.liu@nxp.com> wrote:
>
> Hi Shengjiu,
>
> On Fri, Jan 30, 2026 at 01:55:08PM +0800, Shengjiu Wang wrote:
> > There is an audio channel shift issue with multi channel case, first run
> > the channel order is correct, but second run the channel order is shifted.
>
> Nit: I'd rephrase "There is an audio channel shift issue with multi channel
> case - the channel order is correct for the first run, but the channel order
> is shifted for the second run.".

Ok. will update.
>
> > The recovery method is to reset the pai interface.
>
> s/pai/PAI/

Ok.

>
> Can the channel order shift issue be fully fixed instead of implementing
> a "recovery method"?  I presume that this patch implements a recovery
> mechanism.  If it can't, any chip ERRATA?

Yes, it can be fully fixed by this patch. I will remove the "recovery" for
confusion.

>
> >
> > The reset can be handled by pm runtime, so add the pm runtime function.
>
> Nit: s/pm/PM/
>
> s/add the pm runtime function/enable PM runtime/

Ok.
>
> >
> > Signed-off-by: Shengjiu Wang <shengjiu.wang@nxp.com>
> > ---
> >  drivers/gpu/drm/bridge/imx/imx8mp-hdmi-pai.c | 15 +++++++++++++++
> >  1 file changed, 15 insertions(+)
>
> Subject prefix should be "drm/bridge: imx8mp-hdmi-pai:".
> Refer to what previous commits for i.MX bridge drivers use.

Ok.
>
> >
> > diff --git a/drivers/gpu/drm/bridge/imx/imx8mp-hdmi-pai.c b/drivers/gpu/drm/bridge/imx/imx8mp-hdmi-pai.c
> > index 8d13a35b206a..1afc729da9b9 100644
> > --- a/drivers/gpu/drm/bridge/imx/imx8mp-hdmi-pai.c
> > +++ b/drivers/gpu/drm/bridge/imx/imx8mp-hdmi-pai.c
> > @@ -8,6 +8,7 @@
> >  #include <linux/module.h>
> >  #include <linux/of_platform.h>
> >  #include <linux/platform_device.h>
> > +#include <linux/pm_runtime.h>
> >  #include <linux/regmap.h>
> >  #include <drm/bridge/dw_hdmi.h>
> >  #include <sound/asoundef.h>
> > @@ -33,6 +34,7 @@
> >
> >  struct imx8mp_hdmi_pai {
> >       struct regmap   *regmap;
> > +     struct device   *dev;
> >  };
> >
> >  static void imx8mp_hdmi_pai_enable(struct dw_hdmi *dw_hdmi, int channel,
> > @@ -43,6 +45,9 @@ static void imx8mp_hdmi_pai_enable(struct dw_hdmi *dw_hdmi, int channel,
> >       struct imx8mp_hdmi_pai *hdmi_pai = pdata->priv_audio;
> >       int val;
> >
> > +     if (pm_runtime_get_sync(hdmi_pai->dev) < 0)
>
> Use pm_runtime_resume_and_get instead.

Ok.
>
> -8<-
>   `int pm_runtime_get_sync(struct device *dev);`
>     - increment the device's usage counter, run pm_runtime_resume(dev) and
>       return its result;
>       note that it does not drop the device's usage counter on errors, so
>       consider using pm_runtime_resume_and_get() instead of it, especially
>       if its return value is checked by the caller, as this is likely to
>       result in cleaner code.
> -8<-
>
> > +             return;
> > +
> >       /* PAI set control extended */
> >       val =  WTMK_HIGH(3) | WTMK_LOW(3);
> >       val |= NUM_CH(channel);
> > @@ -85,6 +90,8 @@ static void imx8mp_hdmi_pai_disable(struct dw_hdmi *dw_hdmi)
> >
> >       /* Stop PAI */
> >       regmap_write(hdmi_pai->regmap, HTX_PAI_CTRL, 0);
> > +
> > +     pm_runtime_put_sync(hdmi_pai->dev);
> >  }
> >
> >  static const struct regmap_config imx8mp_hdmi_pai_regmap_config = {
> > @@ -101,6 +108,7 @@ static int imx8mp_hdmi_pai_bind(struct device *dev, struct device *master, void
> >       struct imx8mp_hdmi_pai *hdmi_pai;
> >       struct resource *res;
> >       void __iomem *base;
> > +     int ret;
> >
> >       hdmi_pai = devm_kzalloc(dev, sizeof(*hdmi_pai), GFP_KERNEL);
> >       if (!hdmi_pai)
> > @@ -121,6 +129,13 @@ static int imx8mp_hdmi_pai_bind(struct device *dev, struct device *master, void
> >       plat_data->disable_audio = imx8mp_hdmi_pai_disable;
> >       plat_data->priv_audio = hdmi_pai;
> >
> > +     hdmi_pai->dev = dev;
> > +     ret = devm_pm_runtime_enable(dev);
> > +     if (ret < 0) {
> > +             dev_err(dev, "failed to enable pm runtime: %d\n", ret);
>
> s/pm/PM/

Ok. will update them.

best regards
Shengjiu Wang

>
> > +             return ret;
> > +     }
> > +
> >       return 0;
> >  }
> >
>
> --
> Regards,
> Liu Ying
>

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

* Re: [PATCH] drm/bridge: imx: imx8mp-hdmi-pai: enable pm runtime
  2026-01-30  7:06   ` Shengjiu Wang
@ 2026-01-30  7:09     ` Liu Ying
  2026-01-30  7:45       ` Shengjiu Wang
  0 siblings, 1 reply; 5+ messages in thread
From: Liu Ying @ 2026-01-30  7:09 UTC (permalink / raw)
  To: Shengjiu Wang
  Cc: Shengjiu Wang, andrzej.hajda, neil.armstrong, rfoss,
	Laurent.pinchart, jonas, jernej.skrabec, maarten.lankhorst,
	mripard, tzimmermann, airlied, simona, shawnguo, s.hauer, kernel,
	festevam, dri-devel, imx, linux-arm-kernel, linux-kernel



On Fri, Jan 30, 2026 at 03:06:19PM +0800, Shengjiu Wang wrote:
> On Fri, Jan 30, 2026 at 2:49 PM Liu Ying <victor.liu@nxp.com> wrote:
>>
>> Hi Shengjiu,
>>
>> On Fri, Jan 30, 2026 at 01:55:08PM +0800, Shengjiu Wang wrote:
>>> There is an audio channel shift issue with multi channel case, first run
>>> the channel order is correct, but second run the channel order is shifted.

[...]

>> Can the channel order shift issue be fully fixed instead of implementing
>> a "recovery method"?  I presume that this patch implements a recovery
>> mechanism.  If it can't, any chip ERRATA?
> 
> Yes, it can be fully fixed by this patch. I will remove the "recovery" for
> confusion.

Then, you need to add a Fixes tag.

-- 
Regards,
Liu Ying

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

* Re: [PATCH] drm/bridge: imx: imx8mp-hdmi-pai: enable pm runtime
  2026-01-30  7:09     ` Liu Ying
@ 2026-01-30  7:45       ` Shengjiu Wang
  0 siblings, 0 replies; 5+ messages in thread
From: Shengjiu Wang @ 2026-01-30  7:45 UTC (permalink / raw)
  To: Liu Ying
  Cc: Shengjiu Wang, andrzej.hajda, neil.armstrong, rfoss,
	Laurent.pinchart, jonas, jernej.skrabec, maarten.lankhorst,
	mripard, tzimmermann, airlied, simona, shawnguo, s.hauer, kernel,
	festevam, dri-devel, imx, linux-arm-kernel, linux-kernel

On Fri, Jan 30, 2026 at 3:08 PM Liu Ying <victor.liu@nxp.com> wrote:
>
>
>
> On Fri, Jan 30, 2026 at 03:06:19PM +0800, Shengjiu Wang wrote:
> > On Fri, Jan 30, 2026 at 2:49 PM Liu Ying <victor.liu@nxp.com> wrote:
> >>
> >> Hi Shengjiu,
> >>
> >> On Fri, Jan 30, 2026 at 01:55:08PM +0800, Shengjiu Wang wrote:
> >>> There is an audio channel shift issue with multi channel case, first run
> >>> the channel order is correct, but second run the channel order is shifted.
>
> [...]
>
> >> Can the channel order shift issue be fully fixed instead of implementing
> >> a "recovery method"?  I presume that this patch implements a recovery
> >> mechanism.  If it can't, any chip ERRATA?
> >
> > Yes, it can be fully fixed by this patch. I will remove the "recovery" for
> > confusion.
>
> Then, you need to add a Fixes tag.

yes.

best regards
Shengjiu Wang

>
> --
> Regards,
> Liu Ying

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

end of thread, other threads:[~2026-01-30  7:45 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-01-30  5:55 [PATCH] drm/bridge: imx: imx8mp-hdmi-pai: enable pm runtime Shengjiu Wang
2026-01-30  6:49 ` Liu Ying
2026-01-30  7:06   ` Shengjiu Wang
2026-01-30  7:09     ` Liu Ying
2026-01-30  7:45       ` Shengjiu Wang

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

all inboxes | Powered by JetHome®