Skip to content

Commit b8ccd70

Browse files
kraxelairlied
authored andcommitted
drm: bochs: add power management support
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>
1 parent 2f1e800 commit b8ccd70

File tree

2 files changed

+45
-0
lines changed

2 files changed

+45
-0
lines changed

drivers/gpu/drm/bochs/bochs.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#include <linux/io.h>
22
#include <linux/fb.h>
3+
#include <linux/console.h>
34

45
#include <drm/drmP.h>
56
#include <drm/drm_crtc.h>

drivers/gpu/drm/bochs/bochs_drv.c

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,49 @@ static struct drm_driver bochs_driver = {
9494
.dumb_destroy = drm_gem_dumb_destroy,
9595
};
9696

97+
/* ---------------------------------------------------------------------- */
98+
/* pm interface */
99+
100+
static int bochs_pm_suspend(struct device *dev)
101+
{
102+
struct pci_dev *pdev = to_pci_dev(dev);
103+
struct drm_device *drm_dev = pci_get_drvdata(pdev);
104+
struct bochs_device *bochs = drm_dev->dev_private;
105+
106+
drm_kms_helper_poll_disable(drm_dev);
107+
108+
if (bochs->fb.initialized) {
109+
console_lock();
110+
fb_set_suspend(bochs->fb.helper.fbdev, 1);
111+
console_unlock();
112+
}
113+
114+
return 0;
115+
}
116+
117+
static int bochs_pm_resume(struct device *dev)
118+
{
119+
struct pci_dev *pdev = to_pci_dev(dev);
120+
struct drm_device *drm_dev = pci_get_drvdata(pdev);
121+
struct bochs_device *bochs = drm_dev->dev_private;
122+
123+
drm_helper_resume_force_mode(drm_dev);
124+
125+
if (bochs->fb.initialized) {
126+
console_lock();
127+
fb_set_suspend(bochs->fb.helper.fbdev, 0);
128+
console_unlock();
129+
}
130+
131+
drm_kms_helper_poll_enable(drm_dev);
132+
return 0;
133+
}
134+
135+
static const struct dev_pm_ops bochs_pm_ops = {
136+
SET_SYSTEM_SLEEP_PM_OPS(bochs_pm_suspend,
137+
bochs_pm_resume)
138+
};
139+
97140
/* ---------------------------------------------------------------------- */
98141
/* pci interface */
99142

@@ -155,6 +198,7 @@ static struct pci_driver bochs_pci_driver = {
155198
.id_table = bochs_pci_tbl,
156199
.probe = bochs_pci_probe,
157200
.remove = bochs_pci_remove,
201+
.driver.pm = &bochs_pm_ops,
158202
};
159203

160204
/* ---------------------------------------------------------------------- */

0 commit comments

Comments
 (0)