drm: bochs: add power management support
authorGerd Hoffmann <kraxel@redhat.com>
Mon, 14 Apr 2014 09:34:49 +0000 (11:34 +0200)
committerDave Airlie <airlied@redhat.com>
Fri, 18 Apr 2014 03:31:49 +0000 (13:31 +1000)
bochs kms driver lacks power management support, thus
the vga display doesn't work any more after S3 resume.

Fix this by adding suspend and resume functions.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
drivers/gpu/drm/bochs/bochs.h
drivers/gpu/drm/bochs/bochs_drv.c

index 741965c001a687e42f20ca40160e4bd52d383e9b..460820551b09950c07f8ce20206c9328a54af74a 100644 (file)
@@ -1,5 +1,6 @@
 #include <linux/io.h>
 #include <linux/fb.h>
+#include <linux/console.h>
 
 #include <drm/drmP.h>
 #include <drm/drm_crtc.h>
index 395bba261c9a6d3da0a3d525dac25559e0d7f78f..9c13df29fd20ea2306f3d4b57369d9ce971566ec 100644 (file)
@@ -94,6 +94,49 @@ static struct drm_driver bochs_driver = {
        .dumb_destroy           = drm_gem_dumb_destroy,
 };
 
+/* ---------------------------------------------------------------------- */
+/* pm interface                                                           */
+
+static int bochs_pm_suspend(struct device *dev)
+{
+       struct pci_dev *pdev = to_pci_dev(dev);
+       struct drm_device *drm_dev = pci_get_drvdata(pdev);
+       struct bochs_device *bochs = drm_dev->dev_private;
+
+       drm_kms_helper_poll_disable(drm_dev);
+
+       if (bochs->fb.initialized) {
+               console_lock();
+               fb_set_suspend(bochs->fb.helper.fbdev, 1);
+               console_unlock();
+       }
+
+       return 0;
+}
+
+static int bochs_pm_resume(struct device *dev)
+{
+       struct pci_dev *pdev = to_pci_dev(dev);
+       struct drm_device *drm_dev = pci_get_drvdata(pdev);
+       struct bochs_device *bochs = drm_dev->dev_private;
+
+       drm_helper_resume_force_mode(drm_dev);
+
+       if (bochs->fb.initialized) {
+               console_lock();
+               fb_set_suspend(bochs->fb.helper.fbdev, 0);
+               console_unlock();
+       }
+
+       drm_kms_helper_poll_enable(drm_dev);
+       return 0;
+}
+
+static const struct dev_pm_ops bochs_pm_ops = {
+       SET_SYSTEM_SLEEP_PM_OPS(bochs_pm_suspend,
+                               bochs_pm_resume)
+};
+
 /* ---------------------------------------------------------------------- */
 /* pci interface                                                          */
 
@@ -155,6 +198,7 @@ static struct pci_driver bochs_pci_driver = {
        .id_table =     bochs_pci_tbl,
        .probe =        bochs_pci_probe,
        .remove =       bochs_pci_remove,
+       .driver.pm =    &bochs_pm_ops,
 };
 
 /* ---------------------------------------------------------------------- */