aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/i915
diff options
context:
space:
mode:
authorDave Airlie <airlied@linux.ie>2010-02-01 00:38:10 -0500
committerDave Airlie <airlied@redhat.com>2010-03-01 01:20:37 -0500
commit6a9ee8af344e3bd7dbd61e67037096cdf7f83289 (patch)
tree07cdb493a790cf45bc473f2fc2ea1b9a166d5191 /drivers/gpu/drm/i915
parent9fd1de52945e06ed88a440c99ca92dab74b9b33c (diff)
vga_switcheroo: initial implementation (v15)
Many new laptops now come with 2 gpus, one to be used for low power modes and one for gaming/on-ac applications. These GPUs are typically wired to the laptop panel and VGA ports via a multiplexer unit which is controlled via ACPI methods. 4 combinations of systems typically exist - with 2 ACPI methods. Intel/ATI - Lenovo W500/T500 - use ATPX ACPI method ATI/ATI - some ASUS - use ATPX ACPI Method Intel/Nvidia - - use _DSM ACPI method Nvidia/Nvidia - - use _DSM ACPI method. TODO: This patch adds support for the ATPX method and initial bits for the _DSM methods that need to written by someone with access to the hardware. Add a proper non-debugfs interface - need to get some proper testing first. v2: add power up/down support for both devices on W500 puts i915/radeon into D3 and cuts power to radeon. v3: redo probing methods, no DMI list, drm devices call to register with switcheroo, it tries to find an ATPX method on any device and once there is two devices + ATPX it inits the switcher. v4: ATPX msg handling using buffers - should work on more machines v5: rearchitect after more mjg59 discussion - move ATPX handling to radeon driver. v6: add file headers + initial nouveau bits (to be filled out). v7: merge delayed switcher code. v8: avoid suspend/resume of gpu that is off v9: rearchitect - mjg59 is always right. - move all ATPX code to radeon, should allow simpler DSM also proper ATRM handling v10: add ATRM support for radeon BIOS, add mutex to lock vgasr_priv v11: fix bug in resuming Intel for 2nd time. v12: start fixing up nvidia code blindly. v13: blindly guess at finishing nvidia code v14: remove radeon audio hacks - fix up intel resume more like upstream v15: clean up printks + remove unnecessary igd/dis pointers mount debugfs /sys/kernel/debug/vgaswitcheroo/switch - should exist if ATPX detected + 2 cards. DIS - immediate change to discrete IGD - immediate change to IGD DDIS - delayed change to discrete DIGD - delayed change to IGD ON - turn on not in use OFF - turn off not in use Tested on W500 (Intel/ATI) and T500 (Intel/ATI) Signed-off-by: Dave Airlie <airlied@redhat.com>
Diffstat (limited to 'drivers/gpu/drm/i915')
-rw-r--r--drivers/gpu/drm/i915/i915_dma.c35
-rw-r--r--drivers/gpu/drm/i915/i915_drv.c4
-rw-r--r--drivers/gpu/drm/i915/i915_drv.h2
-rw-r--r--drivers/gpu/drm/i915/intel_fb.c2
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
1203static 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
1218static 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
1202static int i915_load_modeset_init(struct drm_device *dev, 1229static 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
204static int i915_suspend(struct drm_device *dev, pm_message_t state) 204int 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
258static int i915_resume(struct drm_device *dev) 258int 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;
736extern unsigned int i915_powersave; 736extern unsigned int i915_powersave;
737extern unsigned int i915_lvds_downclock; 737extern unsigned int i915_lvds_downclock;
738 738
739extern int i915_suspend(struct drm_device *dev, pm_message_t state);
740extern int i915_resume(struct drm_device *dev);
739extern void i915_save_display(struct drm_device *dev); 741extern void i915_save_display(struct drm_device *dev);
740extern void i915_restore_display(struct drm_device *dev); 742extern void i915_restore_display(struct drm_device *dev);
741extern int i915_master_create(struct drm_device *dev, struct drm_master *master); 743extern 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
240out_unpin: 242out_unpin: