diff options
Diffstat (limited to 'drivers/gpu/drm/i915')
-rw-r--r-- | drivers/gpu/drm/i915/i915_dma.c | 35 | ||||
-rw-r--r-- | drivers/gpu/drm/i915/i915_drv.c | 4 | ||||
-rw-r--r-- | drivers/gpu/drm/i915/i915_drv.h | 2 | ||||
-rw-r--r-- | drivers/gpu/drm/i915/intel_fb.c | 2 |
4 files changed, 41 insertions, 2 deletions
diff --git a/drivers/gpu/drm/i915/i915_dma.c b/drivers/gpu/drm/i915/i915_dma.c index 2307f98349f7..42ca07f04a21 100644 --- a/drivers/gpu/drm/i915/i915_dma.c +++ b/drivers/gpu/drm/i915/i915_dma.c | |||
@@ -35,6 +35,7 @@ | |||
35 | #include "i915_drv.h" | 35 | #include "i915_drv.h" |
36 | #include "i915_trace.h" | 36 | #include "i915_trace.h" |
37 | #include <linux/vgaarb.h> | 37 | #include <linux/vgaarb.h> |
38 | #include <linux/vga_switcheroo.h> | ||
38 | 39 | ||
39 | /* Really want an OS-independent resettable timer. Would like to have | 40 | /* Really want an OS-independent resettable timer. Would like to have |
40 | * this loop run for (eg) 3 sec, but have the timer reset every time | 41 | * this loop run for (eg) 3 sec, but have the timer reset every time |
@@ -1199,6 +1200,32 @@ static unsigned int i915_vga_set_decode(void *cookie, bool state) | |||
1199 | return VGA_RSRC_NORMAL_IO | VGA_RSRC_NORMAL_MEM; | 1200 | return VGA_RSRC_NORMAL_IO | VGA_RSRC_NORMAL_MEM; |
1200 | } | 1201 | } |
1201 | 1202 | ||
1203 | static void i915_switcheroo_set_state(struct pci_dev *pdev, enum vga_switcheroo_state state) | ||
1204 | { | ||
1205 | struct drm_device *dev = pci_get_drvdata(pdev); | ||
1206 | pm_message_t pmm = { .event = PM_EVENT_SUSPEND }; | ||
1207 | if (state == VGA_SWITCHEROO_ON) { | ||
1208 | printk(KERN_INFO "i915: switched off\n"); | ||
1209 | /* i915 resume handler doesn't set to D0 */ | ||
1210 | pci_set_power_state(dev->pdev, PCI_D0); | ||
1211 | i915_resume(dev); | ||
1212 | } else { | ||
1213 | printk(KERN_ERR "i915: switched off\n"); | ||
1214 | i915_suspend(dev, pmm); | ||
1215 | } | ||
1216 | } | ||
1217 | |||
1218 | static bool i915_switcheroo_can_switch(struct pci_dev *pdev) | ||
1219 | { | ||
1220 | struct drm_device *dev = pci_get_drvdata(pdev); | ||
1221 | bool can_switch; | ||
1222 | |||
1223 | spin_lock(&dev->count_lock); | ||
1224 | can_switch = (dev->open_count == 0); | ||
1225 | spin_unlock(&dev->count_lock); | ||
1226 | return can_switch; | ||
1227 | } | ||
1228 | |||
1202 | static int i915_load_modeset_init(struct drm_device *dev, | 1229 | static int i915_load_modeset_init(struct drm_device *dev, |
1203 | unsigned long prealloc_start, | 1230 | unsigned long prealloc_start, |
1204 | unsigned long prealloc_size, | 1231 | unsigned long prealloc_size, |
@@ -1260,6 +1287,12 @@ static int i915_load_modeset_init(struct drm_device *dev, | |||
1260 | if (ret) | 1287 | if (ret) |
1261 | goto destroy_ringbuffer; | 1288 | goto destroy_ringbuffer; |
1262 | 1289 | ||
1290 | ret = vga_switcheroo_register_client(dev->pdev, | ||
1291 | i915_switcheroo_set_state, | ||
1292 | i915_switcheroo_can_switch); | ||
1293 | if (ret) | ||
1294 | goto destroy_ringbuffer; | ||
1295 | |||
1263 | intel_modeset_init(dev); | 1296 | intel_modeset_init(dev); |
1264 | 1297 | ||
1265 | ret = drm_irq_install(dev); | 1298 | ret = drm_irq_install(dev); |
@@ -1544,6 +1577,7 @@ int i915_driver_unload(struct drm_device *dev) | |||
1544 | dev_priv->child_dev_num = 0; | 1577 | dev_priv->child_dev_num = 0; |
1545 | } | 1578 | } |
1546 | drm_irq_uninstall(dev); | 1579 | drm_irq_uninstall(dev); |
1580 | vga_switcheroo_unregister_client(dev->pdev); | ||
1547 | vga_client_register(dev->pdev, NULL, NULL, NULL); | 1581 | vga_client_register(dev->pdev, NULL, NULL, NULL); |
1548 | } | 1582 | } |
1549 | 1583 | ||
@@ -1611,6 +1645,7 @@ void i915_driver_lastclose(struct drm_device * dev) | |||
1611 | 1645 | ||
1612 | if (!dev_priv || drm_core_check_feature(dev, DRIVER_MODESET)) { | 1646 | if (!dev_priv || drm_core_check_feature(dev, DRIVER_MODESET)) { |
1613 | drm_fb_helper_restore(); | 1647 | drm_fb_helper_restore(); |
1648 | vga_switcheroo_process_delayed_switch(); | ||
1614 | return; | 1649 | return; |
1615 | } | 1650 | } |
1616 | 1651 | ||
diff --git a/drivers/gpu/drm/i915/i915_drv.c b/drivers/gpu/drm/i915/i915_drv.c index cf4cb3e9a0c2..fd739efe73ce 100644 --- a/drivers/gpu/drm/i915/i915_drv.c +++ b/drivers/gpu/drm/i915/i915_drv.c | |||
@@ -201,7 +201,7 @@ static int i915_drm_freeze(struct drm_device *dev) | |||
201 | return 0; | 201 | return 0; |
202 | } | 202 | } |
203 | 203 | ||
204 | static int i915_suspend(struct drm_device *dev, pm_message_t state) | 204 | int i915_suspend(struct drm_device *dev, pm_message_t state) |
205 | { | 205 | { |
206 | int error; | 206 | int error; |
207 | 207 | ||
@@ -255,7 +255,7 @@ static int i915_drm_thaw(struct drm_device *dev) | |||
255 | return error; | 255 | return error; |
256 | } | 256 | } |
257 | 257 | ||
258 | static int i915_resume(struct drm_device *dev) | 258 | int i915_resume(struct drm_device *dev) |
259 | { | 259 | { |
260 | if (pci_enable_device(dev->pdev)) | 260 | if (pci_enable_device(dev->pdev)) |
261 | return -EIO; | 261 | return -EIO; |
diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h index b99b6a841d95..d77e56651352 100644 --- a/drivers/gpu/drm/i915/i915_drv.h +++ b/drivers/gpu/drm/i915/i915_drv.h | |||
@@ -736,6 +736,8 @@ extern unsigned int i915_fbpercrtc; | |||
736 | extern unsigned int i915_powersave; | 736 | extern unsigned int i915_powersave; |
737 | extern unsigned int i915_lvds_downclock; | 737 | extern unsigned int i915_lvds_downclock; |
738 | 738 | ||
739 | extern int i915_suspend(struct drm_device *dev, pm_message_t state); | ||
740 | extern int i915_resume(struct drm_device *dev); | ||
739 | extern void i915_save_display(struct drm_device *dev); | 741 | extern void i915_save_display(struct drm_device *dev); |
740 | extern void i915_restore_display(struct drm_device *dev); | 742 | extern void i915_restore_display(struct drm_device *dev); |
741 | extern int i915_master_create(struct drm_device *dev, struct drm_master *master); | 743 | extern int i915_master_create(struct drm_device *dev, struct drm_master *master); |
diff --git a/drivers/gpu/drm/i915/intel_fb.c b/drivers/gpu/drm/i915/intel_fb.c index aaabbcbe5905..8cd791dc5b29 100644 --- a/drivers/gpu/drm/i915/intel_fb.c +++ b/drivers/gpu/drm/i915/intel_fb.c | |||
@@ -35,6 +35,7 @@ | |||
35 | #include <linux/delay.h> | 35 | #include <linux/delay.h> |
36 | #include <linux/fb.h> | 36 | #include <linux/fb.h> |
37 | #include <linux/init.h> | 37 | #include <linux/init.h> |
38 | #include <linux/vga_switcheroo.h> | ||
38 | 39 | ||
39 | #include "drmP.h" | 40 | #include "drmP.h" |
40 | #include "drm.h" | 41 | #include "drm.h" |
@@ -235,6 +236,7 @@ static int intelfb_create(struct drm_device *dev, uint32_t fb_width, | |||
235 | obj_priv->gtt_offset, fbo); | 236 | obj_priv->gtt_offset, fbo); |
236 | 237 | ||
237 | mutex_unlock(&dev->struct_mutex); | 238 | mutex_unlock(&dev->struct_mutex); |
239 | vga_switcheroo_client_fb_set(dev->pdev, info); | ||
238 | return 0; | 240 | return 0; |
239 | 241 | ||
240 | out_unpin: | 242 | out_unpin: |