[PATCH v2] drm/bridge: imx8mp-hdmi-pai: enable PM runtime

Shengjiu Wang posted 1 patch 1 week ago
drivers/gpu/drm/bridge/imx/imx8mp-hdmi-pai.c | 15 +++++++++++++++
1 file changed, 15 insertions(+)
[PATCH v2] drm/bridge: imx8mp-hdmi-pai: enable PM runtime
Posted by Shengjiu Wang 1 week ago
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 fix method is to reset the PAI interface
at the end of playback.

The reset can be handled by PM runtime, so enable PM runtime.

Fixes: 0205fae6327a ("drm/bridge: imx: add driver for HDMI TX Parallel Audio Interface")
Signed-off-by: Shengjiu Wang <shengjiu.wang@nxp.com>
---
Changes in v2:
- update commit message
- add fixes tag
- use pm_runtime_resume_and_get()

 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..cc221483ef0d 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_resume_and_get(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
Re: [PATCH v2] drm/bridge: imx8mp-hdmi-pai: enable PM runtime
Posted by Liu Ying 1 day, 23 hours ago
On Fri, Jan 30, 2026 at 04:09:10PM +0800, Shengjiu Wang wrote:
> 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 fix method is to reset the PAI interface
> at the end of playback.
> 
> The reset can be handled by PM runtime, so enable PM runtime.
> 
> Fixes: 0205fae6327a ("drm/bridge: imx: add driver for HDMI TX Parallel Audio Interface")
> Signed-off-by: Shengjiu Wang <shengjiu.wang@nxp.com>
> ---
> Changes in v2:
> - update commit message
> - add fixes tag
> - use pm_runtime_resume_and_get()
> 
>  drivers/gpu/drm/bridge/imx/imx8mp-hdmi-pai.c | 15 +++++++++++++++
>  1 file changed, 15 insertions(+)

Applied to misc/kernel.git (drm-misc-fixes).  Thanks!

-- 
Regards,
Liu Ying
Re: [PATCH v2] drm/bridge: imx8mp-hdmi-pai: enable PM runtime
Posted by Liu Ying 1 week ago
On Fri, Jan 30, 2026 at 04:09:10PM +0800, Shengjiu Wang wrote:
> 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 fix method is to reset the PAI interface
> at the end of playback.
> 
> The reset can be handled by PM runtime, so enable PM runtime.
> 
> Fixes: 0205fae6327a ("drm/bridge: imx: add driver for HDMI TX Parallel Audio Interface")
> Signed-off-by: Shengjiu Wang <shengjiu.wang@nxp.com>
> ---
> Changes in v2:
> - update commit message
> - add fixes tag
> - use pm_runtime_resume_and_get()

You also fixed subject and fixed error msg for devm_pm_runtime_enable().

Anyway,
Reviewed-by: Liu Ying <victor.liu@nxp.com>

Thanks!

> 
>  drivers/gpu/drm/bridge/imx/imx8mp-hdmi-pai.c | 15 +++++++++++++++
>  1 file changed, 15 insertions(+)

-- 
Regards,
Liu Ying