Skip to content

Commit bfe945c

Browse files
Shawn Guogregkh
authored andcommitted
imx-drm: imx-drm-core: add basic suspend/resume support
HDMI currently stops working after a system suspend/resume cycle. The cause is that the mode setting states in hardware gets lost and isn't restored across the suspend/resume cycle. The patch adds a very basic suspend/resume support to imx-drm driver, and calls drm_helper_resume_force_mode() in .resume hook to restore the mode setting states, so that HDMI can continue working after a system suspend/resume cycle. Since the suspend/resume hook can be called with drm_device pointer being NULL from driver data, we need a check on the pointer in the hooks. And to avoid using a stale pointer from driver data, it also clears driver data in .unload hook. Signed-off-by: Shawn Guo <shawn.guo@freescale.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent b46355f commit bfe945c

1 file changed

Lines changed: 33 additions & 0 deletions

File tree

‎drivers/staging/imx-drm/imx-drm-core.c‎

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,8 @@ static int imx_drm_driver_unload(struct drm_device *drm)
8787
drm_vblank_cleanup(drm);
8888
drm_mode_config_cleanup(drm);
8989

90+
platform_set_drvdata(drm->platformdev, NULL);
91+
9092
return 0;
9193
}
9294

@@ -648,6 +650,36 @@ static int imx_drm_platform_remove(struct platform_device *pdev)
648650
return 0;
649651
}
650652

653+
#ifdef CONFIG_PM_SLEEP
654+
static int imx_drm_suspend(struct device *dev)
655+
{
656+
struct drm_device *drm_dev = dev_get_drvdata(dev);
657+
658+
/* The drm_dev is NULL before .load hook is called */
659+
if (drm_dev == NULL)
660+
return 0;
661+
662+
drm_kms_helper_poll_disable(drm_dev);
663+
664+
return 0;
665+
}
666+
667+
static int imx_drm_resume(struct device *dev)
668+
{
669+
struct drm_device *drm_dev = dev_get_drvdata(dev);
670+
671+
if (drm_dev == NULL)
672+
return 0;
673+
674+
drm_helper_resume_force_mode(drm_dev);
675+
drm_kms_helper_poll_enable(drm_dev);
676+
677+
return 0;
678+
}
679+
#endif
680+
681+
static SIMPLE_DEV_PM_OPS(imx_drm_pm_ops, imx_drm_suspend, imx_drm_resume);
682+
651683
static const struct of_device_id imx_drm_dt_ids[] = {
652684
{ .compatible = "fsl,imx-display-subsystem", },
653685
{ /* sentinel */ },
@@ -660,6 +692,7 @@ static struct platform_driver imx_drm_pdrv = {
660692
.driver = {
661693
.owner = THIS_MODULE,
662694
.name = "imx-drm",
695+
.pm = &imx_drm_pm_ops,
663696
.of_match_table = imx_drm_dt_ids,
664697
},
665698
};

0 commit comments

Comments
 (0)