Skip to content

Commit b4dac01

Browse files
kraxelJiri Slaby
authored andcommitted
drm: cirrus: add power management support
commit 2f1e800 upstream. cirrus 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. Also make the mode_set function unblank the screen. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Signed-off-by: Dave Airlie <airlied@redhat.com> Signed-off-by: Jiri Slaby <jslaby@suse.cz>
1 parent 93cfde3 commit b4dac01

2 files changed

Lines changed: 45 additions & 0 deletions

File tree

‎drivers/gpu/drm/cirrus/cirrus_drv.c‎

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#include <linux/module.h>
1212
#include <linux/console.h>
1313
#include <drm/drmP.h>
14+
#include <drm/drm_crtc_helper.h>
1415

1516
#include "cirrus_drv.h"
1617

@@ -75,6 +76,41 @@ static void cirrus_pci_remove(struct pci_dev *pdev)
7576
drm_put_dev(dev);
7677
}
7778

79+
static int cirrus_pm_suspend(struct device *dev)
80+
{
81+
struct pci_dev *pdev = to_pci_dev(dev);
82+
struct drm_device *drm_dev = pci_get_drvdata(pdev);
83+
struct cirrus_device *cdev = drm_dev->dev_private;
84+
85+
drm_kms_helper_poll_disable(drm_dev);
86+
87+
if (cdev->mode_info.gfbdev) {
88+
console_lock();
89+
fb_set_suspend(cdev->mode_info.gfbdev->helper.fbdev, 1);
90+
console_unlock();
91+
}
92+
93+
return 0;
94+
}
95+
96+
static int cirrus_pm_resume(struct device *dev)
97+
{
98+
struct pci_dev *pdev = to_pci_dev(dev);
99+
struct drm_device *drm_dev = pci_get_drvdata(pdev);
100+
struct cirrus_device *cdev = drm_dev->dev_private;
101+
102+
drm_helper_resume_force_mode(drm_dev);
103+
104+
if (cdev->mode_info.gfbdev) {
105+
console_lock();
106+
fb_set_suspend(cdev->mode_info.gfbdev->helper.fbdev, 0);
107+
console_unlock();
108+
}
109+
110+
drm_kms_helper_poll_enable(drm_dev);
111+
return 0;
112+
}
113+
78114
static const struct file_operations cirrus_driver_fops = {
79115
.owner = THIS_MODULE,
80116
.open = drm_open,
@@ -104,11 +140,17 @@ static struct drm_driver driver = {
104140
.dumb_destroy = drm_gem_dumb_destroy,
105141
};
106142

143+
static const struct dev_pm_ops cirrus_pm_ops = {
144+
SET_SYSTEM_SLEEP_PM_OPS(cirrus_pm_suspend,
145+
cirrus_pm_resume)
146+
};
147+
107148
static struct pci_driver cirrus_pci_driver = {
108149
.name = DRIVER_NAME,
109150
.id_table = pciidlist,
110151
.probe = cirrus_pci_probe,
111152
.remove = cirrus_pci_remove,
153+
.driver.pm = &cirrus_pm_ops,
112154
};
113155

114156
static int __init cirrus_init(void)

‎drivers/gpu/drm/cirrus/cirrus_mode.c‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -308,6 +308,9 @@ static int cirrus_crtc_mode_set(struct drm_crtc *crtc,
308308

309309
WREG_HDR(hdr);
310310
cirrus_crtc_do_set_base(crtc, old_fb, x, y, 0);
311+
312+
/* Unblank (needed on S3 resume, vgabios doesn't do it then) */
313+
outb(0x20, 0x3c0);
311314
return 0;
312315
}
313316

0 commit comments

Comments
 (0)