Skip to contentSkip to conversation

fb + vga switcher patches (THE CORRECT ONES)

PATCH In review Dave Airlie 2 participants 11 messages Feb 25, 2010 – Feb 26, 2010

Subsystems (8)
lore
Share & tools
lore

Dave Airlie

author maintainer
#0 lore raw

Oops send an old junk patch last time.

Here we go again, fb patch + vga switcher patch affects fb as well I'm happy to put this all via drm-2.6 tree any objections?

Dave.

author maintainer
#1 lore raw

PATCH 1/2 fb: for framebuffer handover don't exit the loop early.

From: Dave Airlie <[email protected]>

An offb machine has been seen in the fields which adds two offb nodes, so continue scanning the list after removing one.

---
 drivers/video/fbmem.c |    1 -
 1 files changed, 0 insertions(+), 1 deletions(-)
drivers/video/fbmem.c +0 -1
index 99bbd28..a15b44e 100644
@@ -1513,7 +1513,6 @@ register_framebuffer(struct fb_info *fb_info)
 				       fb_info->fix.id,
 				       registered_fb[i]->fix.id);
 				unregister_framebuffer(registered_fb[i]);
-				break;
 			}
 		}
 	}
Signature · 1 line
1.6.5.2
author maintainer
#2 lore raw

PATCH 2/2 vga_switcheroo: initial implementation (v8)

From: Dave Airlie <[email protected]>

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

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)

---
 drivers/gpu/drm/i915/i915_dma.c              |   32 ++
 drivers/gpu/drm/i915/i915_drv.c              |    4 +-
 drivers/gpu/drm/i915/i915_drv.h              |    2 +
 drivers/gpu/drm/i915/intel_fb.c              |    3 +
 drivers/gpu/drm/nouveau/nouveau_acpi.c       |   31 ++
 drivers/gpu/drm/nouveau/nouveau_drv.c        |    4 +-
 drivers/gpu/drm/nouveau/nouveau_drv.h        |    3 +
 drivers/gpu/drm/nouveau/nouveau_fbcon.c      |    3 +
 drivers/gpu/drm/nouveau/nouveau_state.c      |   27 ++
 drivers/gpu/drm/radeon/Makefile              |    3 +-
 drivers/gpu/drm/radeon/r600_audio.c          |    3 +
 drivers/gpu/drm/radeon/radeon.h              |    4 +
 drivers/gpu/drm/radeon/radeon_atpx_handler.c |  132 +++++++
 drivers/gpu/drm/radeon/radeon_bios.c         |   10 +-
 drivers/gpu/drm/radeon/radeon_device.c       |   41 +++
 drivers/gpu/drm/radeon/radeon_drv.c          |    4 +-
 drivers/gpu/drm/radeon/radeon_drv.h          |    3 +
 drivers/gpu/drm/radeon/radeon_fb.c           |    3 +
 drivers/gpu/drm/radeon/radeon_kms.c          |    3 +
 drivers/gpu/vga/Kconfig                      |   11 +
 drivers/gpu/vga/Makefile                     |    1 +
 drivers/gpu/vga/vga_switcheroo.c             |  472 ++++++++++++++++++++++++++
 drivers/video/console/fbcon.c                |   18 +
 include/linux/fb.h                           |    2 +
 include/linux/vga_switcheroo.h               |   65 ++++
 25 files changed, 872 insertions(+), 12 deletions(-)
 create mode 100644 drivers/gpu/drm/radeon/radeon_atpx_handler.c
 create mode 100644 drivers/gpu/vga/vga_switcheroo.c
 create mode 100644 include/linux/vga_switcheroo.h
drivers/gpu/drm/i915/i915_dma.c +32 -0
index 2307f98..fb91532 100644
@@ -35,6 +35,7 @@
 #include "i915_drv.h"
 #include "i915_trace.h"
 #include <linux/vgaarb.h>
+#include <linux/vga_switcheroo.h>
 
 /* Really want an OS-independent resettable timer.  Would like to have
  * this loop run for (eg) 3 sec, but have the timer reset every time
@@ -1199,6 +1200,30 @@ static unsigned int i915_vga_set_decode(void *cookie, bool state)
 		return VGA_RSRC_NORMAL_IO | VGA_RSRC_NORMAL_MEM;
 }
 
+static void i915_switcheroo_set_state(struct pci_dev *pdev, enum vga_switcheroo_state state)
+{
+	struct drm_device *dev = pci_get_drvdata(pdev);
+	pm_message_t pmm = { .event = PM_EVENT_SUSPEND };
+	if (state = VGA_SWITCHEROO_ON) {
+		printk(KERN_ERR "VGA switched i915 on\n");
+		i915_resume(dev);
+	} else {
+		printk(KERN_ERR "VGA switched i915 off\n");
+		i915_suspend(dev, pmm);
+	}
+}
+
+static bool i915_switcheroo_can_switch(struct pci_dev *pdev)
+{
+	struct drm_device *dev = pci_get_drvdata(pdev);
+	bool can_switch;
+
+	spin_lock(&dev->count_lock);
+	can_switch = (dev->open_count = 0);
+	spin_unlock(&dev->count_lock);
+	return can_switch;
+}
+
 static int i915_load_modeset_init(struct drm_device *dev,
 				  unsigned long prealloc_start,
 				  unsigned long prealloc_size,
@@ -1260,6 +1285,12 @@ static int i915_load_modeset_init(struct drm_device *dev,
 	if (ret)
 		goto destroy_ringbuffer;
 
+	ret = vga_switcheroo_register_client(dev->pdev,
+					     i915_switcheroo_set_state,
+					     i915_switcheroo_can_switch);
+	if (ret)
+		goto destroy_ringbuffer;
+
 	intel_modeset_init(dev);
 
 	ret = drm_irq_install(dev);
@@ -1611,6 +1642,7 @@ void i915_driver_lastclose(struct drm_device * dev)
 
 	if (!dev_priv || drm_core_check_feature(dev, DRIVER_MODESET)) {
 		drm_fb_helper_restore();
+		vga_switcheroo_process_delayed_switch();
 		return;
 	}
 
drivers/gpu/drm/i915/i915_drv.c +2 -2
index cf4cb3e..fd739ef 100644
@@ -201,7 +201,7 @@ static int i915_drm_freeze(struct drm_device *dev)
 	return 0;
 }
 
-static int i915_suspend(struct drm_device *dev, pm_message_t state)
+int i915_suspend(struct drm_device *dev, pm_message_t state)
 {
 	int error;
 
@@ -255,7 +255,7 @@ static int i915_drm_thaw(struct drm_device *dev)
 	return error;
 }
 
-static int i915_resume(struct drm_device *dev)
+int i915_resume(struct drm_device *dev)
 {
 	if (pci_enable_device(dev->pdev))
 		return -EIO;
drivers/gpu/drm/i915/i915_drv.h +2 -0
index b99b6a8..d77e566 100644
@@ -736,6 +736,8 @@ extern unsigned int i915_fbpercrtc;
 extern unsigned int i915_powersave;
 extern unsigned int i915_lvds_downclock;
 
+extern int i915_suspend(struct drm_device *dev, pm_message_t state);
+extern int i915_resume(struct drm_device *dev);
 extern void i915_save_display(struct drm_device *dev);
 extern void i915_restore_display(struct drm_device *dev);
 extern int i915_master_create(struct drm_device *dev, struct drm_master *master);
drivers/gpu/drm/i915/intel_fb.c +3 -0
index aaabbcb..6d370c2 100644
@@ -35,6 +35,7 @@
 #include <linux/delay.h>
 #include <linux/fb.h>
 #include <linux/init.h>
+#include <linux/vga_switcheroo.h>
 
 #include "drmP.h"
 #include "drm.h"
@@ -234,6 +235,8 @@ static int intelfb_create(struct drm_device *dev, uint32_t fb_width,
 			intel_fb->base.width, intel_fb->base.height,
 			obj_priv->gtt_offset, fbo);
 
+	vga_switcheroo_client_fb_set(dev->pdev, info);
+
 	mutex_unlock(&dev->struct_mutex);
 	return 0;
 
drivers/gpu/drm/nouveau/nouveau_acpi.c +31 -0
index 48227e7..7a6f0e5 100644
@@ -11,6 +11,8 @@
 #include "nouveau_drm.h"
 #include "nv50_display.h"
 
+#include <linux/vga_switcheroo.h>
+
 #define NOUVEAU_DSM_SUPPORTED 0x00
 #define NOUVEAU_DSM_SUPPORTED_FUNCTIONS 0x00
 
@@ -123,3 +125,32 @@ bool nouveau_dsm_probe(struct drm_device *dev)
 
 	return true;
 }
+
+static int nouveau_dsm_switchto(acpi_handle handle,
+				enum vga_switcheroo_client_id id)
+{
+	return 0;
+}
+
+static int nouveau_dsm_power_state(acpi_handle handle,
+				   enum vga_switcheroo_client_id id,
+				   enum vga_switcheroo_state state)
+{
+	return 0;
+}
+
+static struct vga_switcheroo_handler nouveau_dsm_handler = {
+	.method_id = VGA_SWITCHEROO_DSM,
+	.switchto = nouveau_dsm_switchto,
+	.power_state = nouveau_dsm_power_state,
+};
+
+void nouveau_register_dsm_handler(void)
+{
+	vga_switcheroo_register_handler(&nouveau_dsm_handler);
+}
+
+void nouveau_unregister_dsm_handler(void)
+{
+	vga_switcheroo_unregister_handler();
+}
drivers/gpu/drm/nouveau/nouveau_drv.c +2 -2
index da3b93b..e73476c 100644
@@ -135,7 +135,7 @@ nouveau_pci_remove(struct pci_dev *pdev)
 	drm_put_dev(dev);
 }
 
-static int
+int
 nouveau_pci_suspend(struct pci_dev *pdev, pm_message_t pm_state)
 {
 	struct drm_device *dev = pci_get_drvdata(pdev);
@@ -233,7 +233,7 @@ out_abort:
 	return ret;
 }
 
-static int
+int
 nouveau_pci_resume(struct pci_dev *pdev)
 {
 	struct drm_device *dev = pci_get_drvdata(pdev);
drivers/gpu/drm/nouveau/nouveau_drv.h +3 -0
index 1c15ef3..0517a93 100644
@@ -682,6 +682,9 @@ extern int nouveau_ignorelid;
 extern int nouveau_nofbaccel;
 extern int nouveau_noaccel;
 
+extern int nouveau_pci_suspend(struct pci_dev *pdev, pm_message_t pm_state);
+extern int nouveau_pci_resume(struct pci_dev *pdev);
+
 /* nouveau_state.c */
 extern void nouveau_preclose(struct drm_device *dev, struct drm_file *);
 extern int  nouveau_load(struct drm_device *, unsigned long flags);
drivers/gpu/drm/nouveau/nouveau_fbcon.c +3 -0
index ea879a2..f2c9d24 100644
@@ -36,6 +36,7 @@
 #include <linux/fb.h>
 #include <linux/init.h>
 #include <linux/screen_info.h>
+#include <linux/vga_switcheroo.h>
 
 #include "drmP.h"
 #include "drm.h"
@@ -369,6 +370,8 @@ nouveau_fbcon_create(struct drm_device *dev, uint32_t fb_width,
 						nouveau_fb->base.height,
 						nvbo->bo.offset, nvbo);
 
+	vga_switcheroo_client_fb_set(dev->pdev, info);
+
 	mutex_unlock(&dev->struct_mutex);
 	return 0;
 
drivers/gpu/drm/nouveau/nouveau_state.c +27 -0
index a4851af..330c763 100644
@@ -29,6 +29,7 @@
 #include "drm_sarea.h"
 #include "drm_crtc_helper.h"
 #include <linux/vgaarb.h>
+#include <linux/vga_switcheroo.h>
 
 #include "nouveau_drv.h"
 #include "nouveau_drm.h"
@@ -371,6 +372,30 @@ out_err:
 	return ret;
 }
 
+static void nouveau_switcheroo_set_state(struct pci_dev *pdev,
+					 enum vga_switcheroo_state state)
+{
+	pm_message_t pmm = { .event = PM_EVENT_SUSPEND };
+	if (state = VGA_SWITCHEROO_ON) {
+		printk(KERN_ERR "VGA switcheroo: switched nouveau on\n");
+		nouveau_pci_resume(pdev);
+	} else {
+		printk(KERN_ERR "VGA switcheroo: switched nouveau off\n");
+		nouveau_pci_suspend(pdev, pmm);
+	}
+}
+
+static bool nouveau_switcheroo_can_switch(struct pci_dev *pdev)
+{
+	struct drm_device *dev = pci_get_drvdata(pdev);
+	bool can_switch;
+
+	spin_lock(&dev->count_lock);
+	can_switch = (dev->open_count = 0);
+	spin_unlock(&dev->count_lock);
+	return can_switch;
+}
+
 int
 nouveau_card_init(struct drm_device *dev)
 {
@@ -384,6 +409,8 @@ nouveau_card_init(struct drm_device *dev)
 		return 0;
 
 	vga_client_register(dev->pdev, dev, NULL, nouveau_vga_set_decode);
+	vga_switcheroo_register_client(dev->pdev, nouveau_switcheroo_set_state,
+				       nouveau_switcheroo_can_switch);
 
 	/* Initialise internal driver API hooks */
 	ret = nouveau_init_engine_ptrs(dev);
drivers/gpu/drm/radeon/Makefile +2 -1
index 1cc7b93..8e62fe1 100644
@@ -54,7 +54,8 @@ radeon-y += radeon_device.o radeon_kms.o \
 	radeon_cs.o radeon_bios.o radeon_benchmark.o r100.o r300.o r420.o \
 	rs400.o rs600.o rs690.o rv515.o r520.o r600.o rv770.o radeon_test.o \
 	r200.o radeon_legacy_tv.o r600_cs.o r600_blit.o r600_blit_shaders.o \
-	r600_blit_kms.o radeon_pm.o atombios_dp.o r600_audio.o r600_hdmi.o
+	r600_blit_kms.o radeon_pm.o atombios_dp.o r600_audio.o r600_hdmi.o \
+	radeon_atpx_handler.o
 
 radeon-$(CONFIG_COMPAT) += radeon_ioc32.o
 
drivers/gpu/drm/radeon/r600_audio.c +3 -0
index 0dcb690..7def989 100644
@@ -163,6 +163,9 @@ int r600_audio_init(struct radeon_device *rdev)
 	rdev->audio_status_bits = 0;
 	rdev->audio_category_code = 0;
 
+	if (!radeon_audio)
+		return 0;
+
 	setup_timer(
 		&rdev->audio_timer,
 		r600_audio_update_hdmi,
drivers/gpu/drm/radeon/radeon.h +4 -0
index c0356bb..8d9132b 100644
@@ -838,6 +838,8 @@ struct radeon_device {
 	int			audio_bits_per_sample;
 	uint8_t			audio_status_bits;
 	uint8_t			audio_category_code;
+
+	bool powered_down;
 };
 
 int radeon_device_init(struct radeon_device *rdev,
@@ -1042,6 +1044,8 @@ extern void radeon_legacy_set_clock_gating(struct radeon_device *rdev, int enabl
 extern void radeon_atom_set_clock_gating(struct radeon_device *rdev, int enable);
 extern void radeon_ttm_placement_from_domain(struct radeon_bo *rbo, u32 domain);
 extern bool radeon_ttm_bo_is_radeon_bo(struct ttm_buffer_object *bo);
+extern int radeon_resume_kms(struct drm_device *dev);
+extern int radeon_suspend_kms(struct drm_device *dev, pm_message_t state);
 
 /* r100,rv100,rs100,rv200,rs200,r200,rv250,rs300,rv280 */
 struct r100_mc_save {
drivers/gpu/drm/radeon/radeon_atpx_handler.c new file +132 -0

132 lines not on this page · raw message

drivers/gpu/drm/radeon/radeon_bios.c +4 -6
index 9069217..a6f1da3 100644
@@ -50,6 +50,7 @@ static bool igp_read_bios_from_vram(struct radeon_device *rdev)
 	vram_base = drm_get_resource_start(rdev->ddev, 0);
 	bios = ioremap(vram_base, size);
 	if (!bios) {
+		DRM_ERROR("unable to ioremap %x %d\n", (unsigned int)vram_base, (unsigned int)size);
 		return false;
 	}
 
@@ -62,7 +63,7 @@ static bool igp_read_bios_from_vram(struct radeon_device *rdev)
 		iounmap(bios);
 		return false;
 	}
-	memcpy(rdev->bios, bios, size);
+	memcpy_fromio(rdev->bios, bios, size);
 	iounmap(bios);
 	return true;
 }
@@ -393,11 +394,8 @@ bool radeon_get_bios(struct radeon_device *rdev)
 	bool r;
 	uint16_t tmp;
 
-	if (rdev->flags & RADEON_IS_IGP) {
-		r = igp_read_bios_from_vram(rdev);
-		if (r = false)
-			r = radeon_read_bios(rdev);
-	} else
+	r = igp_read_bios_from_vram(rdev);
+	if (r = false)
 		r = radeon_read_bios(rdev);
 	if (r = false) {
 		r = radeon_read_disabled_bios(rdev);
drivers/gpu/drm/radeon/radeon_device.c +41 -0

71 lines not on this page · raw message

drivers/gpu/drm/radeon/radeon_drv.c +3 -1
index 8ba3de7..69017f2 100644
@@ -87,7 +87,7 @@ int radeon_testing = 0;
 int radeon_connector_table = 0;
 int radeon_tv = 1;
 int radeon_new_pll = 1;
-int radeon_audio = 1;
+int radeon_audio = 0;
 
 MODULE_PARM_DESC(no_wb, "Disable AGP writeback for scratch registers");
 module_param_named(no_wb, radeon_no_wb, int, 0444);
@@ -339,6 +339,7 @@ static int __init radeon_init(void)
 		driver = &kms_driver;
 		driver->driver_features |= DRIVER_MODESET;
 		driver->num_ioctls = radeon_max_kms_ioctl;
+		radeon_register_atpx_handler();
 	}
 	/* if the vga console setting is enabled still
 	 * let modprobe override it */
@@ -348,6 +349,7 @@ static int __init radeon_init(void)
 static void __exit radeon_exit(void)
 {
 	drm_exit(driver);
+	radeon_unregister_atpx_handler();
 }
 
 module_init(radeon_init);
drivers/gpu/drm/radeon/radeon_drv.h +3 -0
index c57ad60..7362371 100644
@@ -455,6 +455,9 @@ extern void r600_blit_swap(struct drm_device *dev,
 			   int sx, int sy, int dx, int dy,
 			   int w, int h, int src_pitch, int dst_pitch, int cpp);
 
+/* atpx handler */
+void radeon_register_atpx_handler(void);
+void radeon_unregister_atpx_handler(void);
 /* Flags for stats.boxes
  */
 #define RADEON_BOX_DMA_IDLE      0x1
drivers/gpu/drm/radeon/radeon_fb.c +3 -0
index d71e346..4e1e179 100644
@@ -39,6 +39,8 @@
 
 #include "drm_fb_helper.h"
 
+#include <linux/vga_switcheroo.h>
+
 struct radeon_fb_device {
 	struct drm_fb_helper helper;
 	struct radeon_framebuffer	*rfb;
@@ -290,6 +292,7 @@ int radeonfb_create(struct drm_device *dev,
 	rfbdev->rfb = rfb;
 	rfbdev->rdev = rdev;
 
+	vga_switcheroo_client_fb_set(rdev->ddev->pdev, info);
 	mutex_unlock(&rdev->ddev->struct_mutex);
 	return 0;
 
drivers/gpu/drm/radeon/radeon_kms.c +3 -0
index f23b056..5db7af6 100644
@@ -30,6 +30,8 @@
 #include "radeon.h"
 #include "radeon_drm.h"
 
+#include <linux/vga_switcheroo.h>
+
 int radeon_driver_unload_kms(struct drm_device *dev)
 {
 	struct radeon_device *rdev = dev->dev_private;
@@ -136,6 +138,7 @@ int radeon_driver_firstopen_kms(struct drm_device *dev)
 
 void radeon_driver_lastclose_kms(struct drm_device *dev)
 {
+	vga_switcheroo_process_delayed_switch();
 }
 
 int radeon_driver_open_kms(struct drm_device *dev, struct drm_file *file_priv)
drivers/gpu/vga/Kconfig +11 -0
index 790e675..66b4abc 100644
@@ -8,3 +8,14 @@ config VGA_ARB
 	  are accessed at same time they need some kind of coordination. Please
 	  see Documentation/vgaarbiter.txt for more details. Select this to
 	  enable VGA arbiter.
+
+config VGA_SWITCHEROO
+	bool "Laptop GPU switching support"
+	default y
+	depends on X86
+	depends on ACPI
+	help
+	  Many laptops released in 2008/9/10 have two gpus with a multiplxer
+	  to switch between them. This adds support for dynamic switching when
+          X isn't running and delayed switching until the next logoff.
+
drivers/gpu/vga/Makefile +1 -0
index 7cc8c1e..14ca30b 100644
@@ -1 +1,2 @@
 obj-$(CONFIG_VGA_ARB)  += vgaarb.o
+obj-$(CONFIG_VGA_SWITCHEROO) += vga_switcheroo.o
drivers/gpu/vga/vga_switcheroo.c new file +472 -0

472 lines not on this page · raw message

drivers/video/console/fbcon.c +18 -0
index 3681c6a..b0a3fa0 100644
@@ -3025,6 +3025,20 @@ static int fbcon_fb_unregistered(struct fb_info *info)
 	return 0;
 }
 
+static void fbcon_remap_all(int idx)
+{
+	int i;
+	for (i = first_fb_vc; i <= last_fb_vc; i++)
+		set_con2fb_map(i, idx, 0);
+
+	if (con_is_bound(&fb_con)) {
+		printk(KERN_INFO "fbcon: Remapping primary device, "
+		       "fb%i, to tty %i-%i\n", idx,
+		       first_fb_vc + 1, last_fb_vc + 1);
+		info_idx = idx;
+	}
+}
+
 #ifdef CONFIG_FRAMEBUFFER_CONSOLE_DETECT_PRIMARY
 static void fbcon_select_primary(struct fb_info *info)
 {
@@ -3225,6 +3239,10 @@ static int fbcon_event_notify(struct notifier_block *self,
 		caps = event->data;
 		fbcon_get_requirement(info, caps);
 		break;
+	case FB_EVENT_REMAP_ALL_CONSOLE:
+		idx = info->node;
+		fbcon_remap_all(idx);
+		break;
 	}
 done:
 	return ret;
include/linux/fb.h +2 -0
index 369767b..c10163b 100644
@@ -543,6 +543,8 @@ struct fb_cursor_user {
 #define FB_EVENT_GET_REQ                0x0D
 /*      Unbind from the console if possible */
 #define FB_EVENT_FB_UNBIND              0x0E
+/*      CONSOLE-SPECIFIC: remap all consoles to new fb - for vga switcheroo */
+#define FB_EVENT_REMAP_ALL_CONSOLE      0x0F
 
 struct fb_event {
 	struct fb_info *info;
include/linux/vga_switcheroo.h new file +65 -0

65 lines not on this page · raw message

Signature · 1 line
1.6.5.2
#3 lore raw

Re: [PATCH 2/2] vga_switcheroo: initial implementation (v8)

Oh, sorry, but I don't like such a hidden changes, touching not directly related things.

2010/2/25 Dave Airlie <[email protected]>:

drivers/gpu/drm/radeon/r600_audio.c int r600_audio_init(struct radeon_device *rdev) · line 168

Quoted 11 lines
drivers/gpu/drm/radeon/r600_audio.c +3 -0
index 0dcb690..7def989 100644
@@ -163,6 +163,9 @@ int r600_audio_init(struct radeon_device *rdev)
        rdev->audio_status_bits = 0;
        rdev->audio_category_code = 0;
 
+       if (!radeon_audio)
+               return 0;
+

Good catch but not for this patch. Plus we could handle audio on/off better.

Quoted 11 lines
drivers/gpu/drm/radeon/radeon_device.c +9 -0
(...)
+static void radeon_switcheroo_set_state(struct pci_dev *pdev, enum vga_switcheroo_state state)
+{
+       struct drm_device *dev = pci_get_drvdata(pdev);
+       struct radeon_device *rdev = dev->dev_private;
+       pm_message_t pmm = { .event = PM_EVENT_SUSPEND };
+       if (state = VGA_SWITCHEROO_ON) {
+               printk(KERN_ERR "VGA switched radeon on\n");
+               /* don't suspend or resume card normally */
+               rdev->powered_down = false;

drivers/gpu/drm/radeon/radeon_device.c void radeon_check_arguments(struct radeon_device *rdev) · line 635

Quoted 10 lines
drivers/gpu/drm/radeon/radeon_device.c +10 -0
+               radeon_resume_kms(dev);
+               r600_audio_init(rdev);
+       } else {
+               printk(KERN_ERR "VGA switched radeon off\n");
+               r600_audio_fini(rdev);
+               radeon_suspend_kms(dev, pmm);
+               /* don't suspend or resume card normally */
+               rdev->powered_down = true;
+       }
+}

Don't mess with r600_audio_* there. You call if for all chipsets which is not needed and break nice S&R layout, which is chipset specific.

I guess you needed that because you didn't work on branch containing my patch:
http://git.kernel.org/?p=linux/kernel/git/airlied/drm-2.6.git;a=commitdiff;h8fd2c6ff526e6a59edfa8e08f6f0724646784c4
(you commited it to drm-linus)

drivers/gpu/drm/radeon/radeon_drv.c int radeon_testing = 0; · line 90

Quoted 10 lines
drivers/gpu/drm/radeon/radeon_drv.c +1 -1
index 8ba3de7..69017f2 100644
@@ -87,7 +87,7 @@ int radeon_testing = 0;
  int radeon_connector_table = 0;
  int radeon_tv = 1;
  int radeon_new_pll = 1;
-int radeon_audio = 1;
+int radeon_audio = 0;

Why?! What for we disable this feature by default?! If you see some reason for that, explain it to others please. I can change my mind, but for now I don't like this. It makes audio an option from just working-out-of-box.

Signature · 1 line
Rafał
author maintainer
#4 lore raw

Re: [PATCH 2/2] vga_switcheroo: initial implementation (v8)

Oh I should probably have dropped all the audio bits, I didn't even see this reply
before I updated to v11.

The r600 audio code is a bit of disaster area hopefully we can clean it up, like the timer was firing after the device was suspended.

I'll repost with all that r600 audio ripped out and you can fix the mess.

Quoted 7 lines

Don't mess with r600_audio_* there. You call if for all chipsets which is not needed and break nice S&R layout, which is chipset specific.

I guess you needed that because you didn't work on branch containing my patch:
http://git.kernel.org/?p=linux/kernel/git/airlied/drm-2.6.git;a=commitdiff;h8fd2c6ff526e6a59edfa8e08f6f0724646784c4
(you commited it to drm-linus)

This patch is now based on Linus tree, but yeah the original version predates your
patches.

Quoted 8 lines

drivers/gpu/drm/radeon/radeon_drv.c int radeon_testing = 0; · line 90

Quoted 2 lines
drivers/gpu/drm/radeon/radeon_drv.c +1 -1
-int radeon_audio = 1;
+int radeon_audio = 0;

Why?! What for we disable this feature by default?! If you see some reason for that, explain it to others please. I can change my mind, but for now I don't like this. It makes audio an option from just working-out-of-box.

Oversights, the audio was just broken in the presence of suspend/resume when I wrote it.

Dave.

#5 lore raw

Re: [PATCH 2/2] vga_switcheroo: initial implementation (v8)

Quoted 8 lines · W dniu 26 lutego 2010 09:50 użytkownik Dave Airlie <[email protected]> napisał:

Oh I should probably have dropped all the audio bits, I didn't even see this reply
before I updated to v11.

The r600 audio code is a bit of disaster area hopefully we can clean it up, like the timer was firing after the device was suspended.

I'll repost with all that r600 audio ripped out and you can fix the mess.

I already did, 3 minutes ago ;)

Signature · 1 line
Rafał
#6 lore raw

Re: [PATCH 2/2] vga_switcheroo: initial implementation (v8)

In reply to Dave Airlie
Quoted 8 lines · W dniu 26 lutego 2010 09:50 użytkownik Dave Airlie <[email protected]> napisał:

Oh I should probably have dropped all the audio bits, I didn't even see this reply
before I updated to v11.

The r600 audio code is a bit of disaster area hopefully we can clean it up, like the timer was firing after the device was suspended.

I'll repost with all that r600 audio ripped out and you can fix the mess.

I already did, 3 minutes ago ;)

Signature · 13 lines
Rafał

------------------------------------------------------------------------------
Download Intel&#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
--
_______________________________________________
Dri-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/dri-devel
author maintainer
#7 lore raw

Re: [PATCH 2/2] vga_switcheroo: initial implementation (v8)

In reply to Rafał Miłecki

Oh I should probably have dropped all the audio bits, I didn't even see this reply
before I updated to v11.

The r600 audio code is a bit of disaster area hopefully we can clean it up, like the timer was firing after the device was suspended.

I'll repost with all that r600 audio ripped out and you can fix the mess.

Quoted 7 lines

Don't mess with r600_audio_* there. You call if for all chipsets which is not needed and break nice S&R layout, which is chipset specific.

I guess you needed that because you didn't work on branch containing my patch:
http://git.kernel.org/?p=linux/kernel/git/airlied/drm-2.6.git;a=commitdiff;h=38fd2c6ff526e6a59edfa8e08f6f0724646784c4
(you commited it to drm-linus)

This patch is now based on Linus tree, but yeah the original version predates your
patches.

Quoted 8 lines

drivers/gpu/drm/radeon/radeon_drv.c int radeon_testing = 0; · line 90

Quoted 2 lines
drivers/gpu/drm/radeon/radeon_drv.c +1 -1
-int radeon_audio = 1;
+int radeon_audio = 0;

Why?! What for we disable this feature by default?! If you see some reason for that, explain it to others please. I can change my mind, but for now I don't like this. It makes audio an option from just working-out-of-box.

Oversights, the audio was just broken in the presence of suspend/resume when I wrote it.

Dave.

------------------------------------------------------------------------------
Download Intel&#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs proactively, and fine-tune applications for parallel performance. See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
--

#8 lore raw

Re: [PATCH 2/2] vga_switcheroo: initial implementation (v8)

In reply to Dave Airlie

Oh, sorry, but I don't like such a hidden changes, touching not directly related things.

2010/2/25 Dave Airlie <[email protected]>:

drivers/gpu/drm/radeon/r600_audio.c int r600_audio_init(struct radeon_device *rdev) · line 168

Quoted 11 lines
drivers/gpu/drm/radeon/r600_audio.c +3 -0
index 0dcb690..7def989 100644
@@ -163,6 +163,9 @@ int r600_audio_init(struct radeon_device *rdev)
        rdev->audio_status_bits = 0;
        rdev->audio_category_code = 0;
 
+       if (!radeon_audio)
+               return 0;
+

Good catch but not for this patch. Plus we could handle audio on/off better.

Quoted 11 lines
drivers/gpu/drm/radeon/radeon_device.c +9 -0
(...)
+static void radeon_switcheroo_set_state(struct pci_dev *pdev, enum vga_switcheroo_state state)
+{
+       struct drm_device *dev = pci_get_drvdata(pdev);
+       struct radeon_device *rdev = dev->dev_private;
+       pm_message_t pmm = { .event = PM_EVENT_SUSPEND };
+       if (state == VGA_SWITCHEROO_ON) {
+               printk(KERN_ERR "VGA switched radeon on\n");
+               /* don't suspend or resume card normally */
+               rdev->powered_down = false;

drivers/gpu/drm/radeon/radeon_device.c void radeon_check_arguments(struct radeon_device *rdev) · line 635

Quoted 10 lines
drivers/gpu/drm/radeon/radeon_device.c +10 -0
+               radeon_resume_kms(dev);
+               r600_audio_init(rdev);
+       } else {
+               printk(KERN_ERR "VGA switched radeon off\n");
+               r600_audio_fini(rdev);
+               radeon_suspend_kms(dev, pmm);
+               /* don't suspend or resume card normally */
+               rdev->powered_down = true;
+       }
+}

Don't mess with r600_audio_* there. You call if for all chipsets which is not needed and break nice S&R layout, which is chipset specific.

I guess you needed that because you didn't work on branch containing my patch:
http://git.kernel.org/?p=linux/kernel/git/airlied/drm-2.6.git;a=commitdiff;h=38fd2c6ff526e6a59edfa8e08f6f0724646784c4
(you commited it to drm-linus)

drivers/gpu/drm/radeon/radeon_drv.c int radeon_testing = 0; · line 90

Quoted 10 lines
drivers/gpu/drm/radeon/radeon_drv.c +1 -1
index 8ba3de7..69017f2 100644
@@ -87,7 +87,7 @@ int radeon_testing = 0;
  int radeon_connector_table = 0;
  int radeon_tv = 1;
  int radeon_new_pll = 1;
-int radeon_audio = 1;
+int radeon_audio = 0;

Why?! What for we disable this feature by default?! If you see some reason for that, explain it to others please. I can change my mind, but for now I don't like this. It makes audio an option from just working-out-of-box.

Signature · 13 lines
Rafał

------------------------------------------------------------------------------
Download Intel&#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
--
_______________________________________________
Dri-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/dri-devel
author maintainer
#9 lore raw

PATCH 2/2 vga_switcheroo: initial implementation (v8)

In reply to Dave Airlie

From: Dave Airlie <[email protected]>

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

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)

---
 drivers/gpu/drm/i915/i915_dma.c              |   32 ++
 drivers/gpu/drm/i915/i915_drv.c              |    4 +-
 drivers/gpu/drm/i915/i915_drv.h              |    2 +
 drivers/gpu/drm/i915/intel_fb.c              |    3 +
 drivers/gpu/drm/nouveau/nouveau_acpi.c       |   31 ++
 drivers/gpu/drm/nouveau/nouveau_drv.c        |    4 +-
 drivers/gpu/drm/nouveau/nouveau_drv.h        |    3 +
 drivers/gpu/drm/nouveau/nouveau_fbcon.c      |    3 +
 drivers/gpu/drm/nouveau/nouveau_state.c      |   27 ++
 drivers/gpu/drm/radeon/Makefile              |    3 +-
 drivers/gpu/drm/radeon/r600_audio.c          |    3 +
 drivers/gpu/drm/radeon/radeon.h              |    4 +
 drivers/gpu/drm/radeon/radeon_atpx_handler.c |  132 +++++++
 drivers/gpu/drm/radeon/radeon_bios.c         |   10 +-
 drivers/gpu/drm/radeon/radeon_device.c       |   41 +++
 drivers/gpu/drm/radeon/radeon_drv.c          |    4 +-
 drivers/gpu/drm/radeon/radeon_drv.h          |    3 +
 drivers/gpu/drm/radeon/radeon_fb.c           |    3 +
 drivers/gpu/drm/radeon/radeon_kms.c          |    3 +
 drivers/gpu/vga/Kconfig                      |   11 +
 drivers/gpu/vga/Makefile                     |    1 +
 drivers/gpu/vga/vga_switcheroo.c             |  472 ++++++++++++++++++++++++++
 drivers/video/console/fbcon.c                |   18 +
 include/linux/fb.h                           |    2 +
 include/linux/vga_switcheroo.h               |   65 ++++
 25 files changed, 872 insertions(+), 12 deletions(-)
 create mode 100644 drivers/gpu/drm/radeon/radeon_atpx_handler.c
 create mode 100644 drivers/gpu/vga/vga_switcheroo.c
 create mode 100644 include/linux/vga_switcheroo.h
drivers/gpu/drm/i915/i915_dma.c +32 -0
index 2307f98..fb91532 100644
@@ -35,6 +35,7 @@
 #include "i915_drv.h"
 #include "i915_trace.h"
 #include <linux/vgaarb.h>
+#include <linux/vga_switcheroo.h>
 
 /* Really want an OS-independent resettable timer.  Would like to have
  * this loop run for (eg) 3 sec, but have the timer reset every time
@@ -1199,6 +1200,30 @@ static unsigned int i915_vga_set_decode(void *cookie, bool state)
 		return VGA_RSRC_NORMAL_IO | VGA_RSRC_NORMAL_MEM;
 }
 
+static void i915_switcheroo_set_state(struct pci_dev *pdev, enum vga_switcheroo_state state)
+{
+	struct drm_device *dev = pci_get_drvdata(pdev);
+	pm_message_t pmm = { .event = PM_EVENT_SUSPEND };
+	if (state == VGA_SWITCHEROO_ON) {
+		printk(KERN_ERR "VGA switched i915 on\n");
+		i915_resume(dev);
+	} else {
+		printk(KERN_ERR "VGA switched i915 off\n");
+		i915_suspend(dev, pmm);
+	}
+}
+
+static bool i915_switcheroo_can_switch(struct pci_dev *pdev)
+{
+	struct drm_device *dev = pci_get_drvdata(pdev);
+	bool can_switch;
+
+	spin_lock(&dev->count_lock);
+	can_switch = (dev->open_count == 0);
+	spin_unlock(&dev->count_lock);
+	return can_switch;
+}
+
 static int i915_load_modeset_init(struct drm_device *dev,
 				  unsigned long prealloc_start,
 				  unsigned long prealloc_size,
@@ -1260,6 +1285,12 @@ static int i915_load_modeset_init(struct drm_device *dev,
 	if (ret)
 		goto destroy_ringbuffer;
 
+	ret = vga_switcheroo_register_client(dev->pdev,
+					     i915_switcheroo_set_state,
+					     i915_switcheroo_can_switch);
+	if (ret)
+		goto destroy_ringbuffer;
+
 	intel_modeset_init(dev);
 
 	ret = drm_irq_install(dev);
@@ -1611,6 +1642,7 @@ void i915_driver_lastclose(struct drm_device * dev)
 
 	if (!dev_priv || drm_core_check_feature(dev, DRIVER_MODESET)) {
 		drm_fb_helper_restore();
+		vga_switcheroo_process_delayed_switch();
 		return;
 	}
 
drivers/gpu/drm/i915/i915_drv.c +2 -2
index cf4cb3e..fd739ef 100644
@@ -201,7 +201,7 @@ static int i915_drm_freeze(struct drm_device *dev)
 	return 0;
 }
 
-static int i915_suspend(struct drm_device *dev, pm_message_t state)
+int i915_suspend(struct drm_device *dev, pm_message_t state)
 {
 	int error;
 
@@ -255,7 +255,7 @@ static int i915_drm_thaw(struct drm_device *dev)
 	return error;
 }
 
-static int i915_resume(struct drm_device *dev)
+int i915_resume(struct drm_device *dev)
 {
 	if (pci_enable_device(dev->pdev))
 		return -EIO;
drivers/gpu/drm/i915/i915_drv.h +2 -0
index b99b6a8..d77e566 100644
@@ -736,6 +736,8 @@ extern unsigned int i915_fbpercrtc;
 extern unsigned int i915_powersave;
 extern unsigned int i915_lvds_downclock;
 
+extern int i915_suspend(struct drm_device *dev, pm_message_t state);
+extern int i915_resume(struct drm_device *dev);
 extern void i915_save_display(struct drm_device *dev);
 extern void i915_restore_display(struct drm_device *dev);
 extern int i915_master_create(struct drm_device *dev, struct drm_master *master);
drivers/gpu/drm/i915/intel_fb.c +3 -0
index aaabbcb..6d370c2 100644
@@ -35,6 +35,7 @@
 #include <linux/delay.h>
 #include <linux/fb.h>
 #include <linux/init.h>
+#include <linux/vga_switcheroo.h>
 
 #include "drmP.h"
 #include "drm.h"
@@ -234,6 +235,8 @@ static int intelfb_create(struct drm_device *dev, uint32_t fb_width,
 			intel_fb->base.width, intel_fb->base.height,
 			obj_priv->gtt_offset, fbo);
 
+	vga_switcheroo_client_fb_set(dev->pdev, info);
+
 	mutex_unlock(&dev->struct_mutex);
 	return 0;
 
drivers/gpu/drm/nouveau/nouveau_acpi.c +31 -0
index 48227e7..7a6f0e5 100644
@@ -11,6 +11,8 @@
 #include "nouveau_drm.h"
 #include "nv50_display.h"
 
+#include <linux/vga_switcheroo.h>
+
 #define NOUVEAU_DSM_SUPPORTED 0x00
 #define NOUVEAU_DSM_SUPPORTED_FUNCTIONS 0x00
 
@@ -123,3 +125,32 @@ bool nouveau_dsm_probe(struct drm_device *dev)
 
 	return true;
 }
+
+static int nouveau_dsm_switchto(acpi_handle handle,
+				enum vga_switcheroo_client_id id)
+{
+	return 0;
+}
+
+static int nouveau_dsm_power_state(acpi_handle handle,
+				   enum vga_switcheroo_client_id id,
+				   enum vga_switcheroo_state state)
+{
+	return 0;
+}
+
+static struct vga_switcheroo_handler nouveau_dsm_handler = {
+	.method_id = VGA_SWITCHEROO_DSM,
+	.switchto = nouveau_dsm_switchto,
+	.power_state = nouveau_dsm_power_state,
+};
+
+void nouveau_register_dsm_handler(void)
+{
+	vga_switcheroo_register_handler(&nouveau_dsm_handler);
+}
+
+void nouveau_unregister_dsm_handler(void)
+{
+	vga_switcheroo_unregister_handler();
+}
drivers/gpu/drm/nouveau/nouveau_drv.c +2 -2
index da3b93b..e73476c 100644
@@ -135,7 +135,7 @@ nouveau_pci_remove(struct pci_dev *pdev)
 	drm_put_dev(dev);
 }
 
-static int
+int
 nouveau_pci_suspend(struct pci_dev *pdev, pm_message_t pm_state)
 {
 	struct drm_device *dev = pci_get_drvdata(pdev);
@@ -233,7 +233,7 @@ out_abort:
 	return ret;
 }
 
-static int
+int
 nouveau_pci_resume(struct pci_dev *pdev)
 {
 	struct drm_device *dev = pci_get_drvdata(pdev);
drivers/gpu/drm/nouveau/nouveau_drv.h +3 -0
index 1c15ef3..0517a93 100644
@@ -682,6 +682,9 @@ extern int nouveau_ignorelid;
 extern int nouveau_nofbaccel;
 extern int nouveau_noaccel;
 
+extern int nouveau_pci_suspend(struct pci_dev *pdev, pm_message_t pm_state);
+extern int nouveau_pci_resume(struct pci_dev *pdev);
+
 /* nouveau_state.c */
 extern void nouveau_preclose(struct drm_device *dev, struct drm_file *);
 extern int  nouveau_load(struct drm_device *, unsigned long flags);
drivers/gpu/drm/nouveau/nouveau_fbcon.c +3 -0
index ea879a2..f2c9d24 100644
@@ -36,6 +36,7 @@
 #include <linux/fb.h>
 #include <linux/init.h>
 #include <linux/screen_info.h>
+#include <linux/vga_switcheroo.h>
 
 #include "drmP.h"
 #include "drm.h"
@@ -369,6 +370,8 @@ nouveau_fbcon_create(struct drm_device *dev, uint32_t fb_width,
 						nouveau_fb->base.height,
 						nvbo->bo.offset, nvbo);
 
+	vga_switcheroo_client_fb_set(dev->pdev, info);
+
 	mutex_unlock(&dev->struct_mutex);
 	return 0;
 
drivers/gpu/drm/nouveau/nouveau_state.c +27 -0
index a4851af..330c763 100644
@@ -29,6 +29,7 @@
 #include "drm_sarea.h"
 #include "drm_crtc_helper.h"
 #include <linux/vgaarb.h>
+#include <linux/vga_switcheroo.h>
 
 #include "nouveau_drv.h"
 #include "nouveau_drm.h"
@@ -371,6 +372,30 @@ out_err:
 	return ret;
 }
 
+static void nouveau_switcheroo_set_state(struct pci_dev *pdev,
+					 enum vga_switcheroo_state state)
+{
+	pm_message_t pmm = { .event = PM_EVENT_SUSPEND };
+	if (state == VGA_SWITCHEROO_ON) {
+		printk(KERN_ERR "VGA switcheroo: switched nouveau on\n");
+		nouveau_pci_resume(pdev);
+	} else {
+		printk(KERN_ERR "VGA switcheroo: switched nouveau off\n");
+		nouveau_pci_suspend(pdev, pmm);
+	}
+}
+
+static bool nouveau_switcheroo_can_switch(struct pci_dev *pdev)
+{
+	struct drm_device *dev = pci_get_drvdata(pdev);
+	bool can_switch;
+
+	spin_lock(&dev->count_lock);
+	can_switch = (dev->open_count == 0);
+	spin_unlock(&dev->count_lock);
+	return can_switch;
+}
+
 int
 nouveau_card_init(struct drm_device *dev)
 {
@@ -384,6 +409,8 @@ nouveau_card_init(struct drm_device *dev)
 		return 0;
 
 	vga_client_register(dev->pdev, dev, NULL, nouveau_vga_set_decode);
+	vga_switcheroo_register_client(dev->pdev, nouveau_switcheroo_set_state,
+				       nouveau_switcheroo_can_switch);
 
 	/* Initialise internal driver API hooks */
 	ret = nouveau_init_engine_ptrs(dev);
drivers/gpu/drm/radeon/Makefile +2 -1
index 1cc7b93..8e62fe1 100644
@@ -54,7 +54,8 @@ radeon-y += radeon_device.o radeon_kms.o \
 	radeon_cs.o radeon_bios.o radeon_benchmark.o r100.o r300.o r420.o \
 	rs400.o rs600.o rs690.o rv515.o r520.o r600.o rv770.o radeon_test.o \
 	r200.o radeon_legacy_tv.o r600_cs.o r600_blit.o r600_blit_shaders.o \
-	r600_blit_kms.o radeon_pm.o atombios_dp.o r600_audio.o r600_hdmi.o
+	r600_blit_kms.o radeon_pm.o atombios_dp.o r600_audio.o r600_hdmi.o \
+	radeon_atpx_handler.o
 
 radeon-$(CONFIG_COMPAT) += radeon_ioc32.o
 
drivers/gpu/drm/radeon/r600_audio.c +3 -0
index 0dcb690..7def989 100644
@@ -163,6 +163,9 @@ int r600_audio_init(struct radeon_device *rdev)
 	rdev->audio_status_bits = 0;
 	rdev->audio_category_code = 0;
 
+	if (!radeon_audio)
+		return 0;
+
 	setup_timer(
 		&rdev->audio_timer,
 		r600_audio_update_hdmi,
drivers/gpu/drm/radeon/radeon.h +4 -0
index c0356bb..8d9132b 100644
@@ -838,6 +838,8 @@ struct radeon_device {
 	int			audio_bits_per_sample;
 	uint8_t			audio_status_bits;
 	uint8_t			audio_category_code;
+
+	bool powered_down;
 };
 
 int radeon_device_init(struct radeon_device *rdev,
@@ -1042,6 +1044,8 @@ extern void radeon_legacy_set_clock_gating(struct radeon_device *rdev, int enabl
 extern void radeon_atom_set_clock_gating(struct radeon_device *rdev, int enable);
 extern void radeon_ttm_placement_from_domain(struct radeon_bo *rbo, u32 domain);
 extern bool radeon_ttm_bo_is_radeon_bo(struct ttm_buffer_object *bo);
+extern int radeon_resume_kms(struct drm_device *dev);
+extern int radeon_suspend_kms(struct drm_device *dev, pm_message_t state);
 
 /* r100,rv100,rs100,rv200,rs200,r200,rv250,rs300,rv280 */
 struct r100_mc_save {
drivers/gpu/drm/radeon/radeon_atpx_handler.c new file +132 -0

132 lines not on this page · raw message

drivers/gpu/drm/radeon/radeon_bios.c +4 -6
index 9069217..a6f1da3 100644
@@ -50,6 +50,7 @@ static bool igp_read_bios_from_vram(struct radeon_device *rdev)
 	vram_base = drm_get_resource_start(rdev->ddev, 0);
 	bios = ioremap(vram_base, size);
 	if (!bios) {
+		DRM_ERROR("unable to ioremap %x %d\n", (unsigned int)vram_base, (unsigned int)size);
 		return false;
 	}
 
@@ -62,7 +63,7 @@ static bool igp_read_bios_from_vram(struct radeon_device *rdev)
 		iounmap(bios);
 		return false;
 	}
-	memcpy(rdev->bios, bios, size);
+	memcpy_fromio(rdev->bios, bios, size);
 	iounmap(bios);
 	return true;
 }
@@ -393,11 +394,8 @@ bool radeon_get_bios(struct radeon_device *rdev)
 	bool r;
 	uint16_t tmp;
 
-	if (rdev->flags & RADEON_IS_IGP) {
-		r = igp_read_bios_from_vram(rdev);
-		if (r == false)
-			r = radeon_read_bios(rdev);
-	} else
+	r = igp_read_bios_from_vram(rdev);
+	if (r == false)
 		r = radeon_read_bios(rdev);
 	if (r == false) {
 		r = radeon_read_disabled_bios(rdev);
drivers/gpu/drm/radeon/radeon_device.c +41 -0

71 lines not on this page · raw message

drivers/gpu/drm/radeon/radeon_drv.c +3 -1
index 8ba3de7..69017f2 100644
@@ -87,7 +87,7 @@ int radeon_testing = 0;
 int radeon_connector_table = 0;
 int radeon_tv = 1;
 int radeon_new_pll = 1;
-int radeon_audio = 1;
+int radeon_audio = 0;
 
 MODULE_PARM_DESC(no_wb, "Disable AGP writeback for scratch registers");
 module_param_named(no_wb, radeon_no_wb, int, 0444);
@@ -339,6 +339,7 @@ static int __init radeon_init(void)
 		driver = &kms_driver;
 		driver->driver_features |= DRIVER_MODESET;
 		driver->num_ioctls = radeon_max_kms_ioctl;
+		radeon_register_atpx_handler();
 	}
 	/* if the vga console setting is enabled still
 	 * let modprobe override it */
@@ -348,6 +349,7 @@ static int __init radeon_init(void)
 static void __exit radeon_exit(void)
 {
 	drm_exit(driver);
+	radeon_unregister_atpx_handler();
 }
 
 module_init(radeon_init);
drivers/gpu/drm/radeon/radeon_drv.h +3 -0
index c57ad60..7362371 100644
@@ -455,6 +455,9 @@ extern void r600_blit_swap(struct drm_device *dev,
 			   int sx, int sy, int dx, int dy,
 			   int w, int h, int src_pitch, int dst_pitch, int cpp);
 
+/* atpx handler */
+void radeon_register_atpx_handler(void);
+void radeon_unregister_atpx_handler(void);
 /* Flags for stats.boxes
  */
 #define RADEON_BOX_DMA_IDLE      0x1
drivers/gpu/drm/radeon/radeon_fb.c +3 -0
index d71e346..4e1e179 100644
@@ -39,6 +39,8 @@
 
 #include "drm_fb_helper.h"
 
+#include <linux/vga_switcheroo.h>
+
 struct radeon_fb_device {
 	struct drm_fb_helper helper;
 	struct radeon_framebuffer	*rfb;
@@ -290,6 +292,7 @@ int radeonfb_create(struct drm_device *dev,
 	rfbdev->rfb = rfb;
 	rfbdev->rdev = rdev;
 
+	vga_switcheroo_client_fb_set(rdev->ddev->pdev, info);
 	mutex_unlock(&rdev->ddev->struct_mutex);
 	return 0;
 
drivers/gpu/drm/radeon/radeon_kms.c +3 -0
index f23b056..5db7af6 100644
@@ -30,6 +30,8 @@
 #include "radeon.h"
 #include "radeon_drm.h"
 
+#include <linux/vga_switcheroo.h>
+
 int radeon_driver_unload_kms(struct drm_device *dev)
 {
 	struct radeon_device *rdev = dev->dev_private;
@@ -136,6 +138,7 @@ int radeon_driver_firstopen_kms(struct drm_device *dev)
 
 void radeon_driver_lastclose_kms(struct drm_device *dev)
 {
+	vga_switcheroo_process_delayed_switch();
 }
 
 int radeon_driver_open_kms(struct drm_device *dev, struct drm_file *file_priv)
drivers/gpu/vga/Kconfig +11 -0
index 790e675..66b4abc 100644
@@ -8,3 +8,14 @@ config VGA_ARB
 	  are accessed at same time they need some kind of coordination. Please
 	  see Documentation/vgaarbiter.txt for more details. Select this to
 	  enable VGA arbiter.
+
+config VGA_SWITCHEROO
+	bool "Laptop GPU switching support"
+	default y
+	depends on X86
+	depends on ACPI
+	help
+	  Many laptops released in 2008/9/10 have two gpus with a multiplxer
+	  to switch between them. This adds support for dynamic switching when
+          X isn't running and delayed switching until the next logoff.
+
drivers/gpu/vga/Makefile +1 -0
index 7cc8c1e..14ca30b 100644
@@ -1 +1,2 @@
 obj-$(CONFIG_VGA_ARB)  += vgaarb.o
+obj-$(CONFIG_VGA_SWITCHEROO) += vga_switcheroo.o
drivers/gpu/vga/vga_switcheroo.c new file +472 -0

472 lines not on this page · raw message

drivers/video/console/fbcon.c +18 -0
index 3681c6a..b0a3fa0 100644
@@ -3025,6 +3025,20 @@ static int fbcon_fb_unregistered(struct fb_info *info)
 	return 0;
 }
 
+static void fbcon_remap_all(int idx)
+{
+	int i;
+	for (i = first_fb_vc; i <= last_fb_vc; i++)
+		set_con2fb_map(i, idx, 0);
+
+	if (con_is_bound(&fb_con)) {
+		printk(KERN_INFO "fbcon: Remapping primary device, "
+		       "fb%i, to tty %i-%i\n", idx,
+		       first_fb_vc + 1, last_fb_vc + 1);
+		info_idx = idx;
+	}
+}
+
 #ifdef CONFIG_FRAMEBUFFER_CONSOLE_DETECT_PRIMARY
 static void fbcon_select_primary(struct fb_info *info)
 {
@@ -3225,6 +3239,10 @@ static int fbcon_event_notify(struct notifier_block *self,
 		caps = event->data;
 		fbcon_get_requirement(info, caps);
 		break;
+	case FB_EVENT_REMAP_ALL_CONSOLE:
+		idx = info->node;
+		fbcon_remap_all(idx);
+		break;
 	}
 done:
 	return ret;
include/linux/fb.h +2 -0
index 369767b..c10163b 100644
@@ -543,6 +543,8 @@ struct fb_cursor_user {
 #define FB_EVENT_GET_REQ                0x0D
 /*      Unbind from the console if possible */
 #define FB_EVENT_FB_UNBIND              0x0E
+/*      CONSOLE-SPECIFIC: remap all consoles to new fb - for vga switcheroo */
+#define FB_EVENT_REMAP_ALL_CONSOLE      0x0F
 
 struct fb_event {
 	struct fb_info *info;
include/linux/vga_switcheroo.h new file +65 -0

65 lines not on this page · raw message

Signature · 10 lines
1.6.5.2


------------------------------------------------------------------------------
Download Intel&#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
--
author maintainer
#10 lore raw

PATCH 1/2 fb: for framebuffer handover don't exit the loop early.

In reply to Dave Airlie

From: Dave Airlie <[email protected]>

An offb machine has been seen in the fields which adds two offb nodes, so continue scanning the list after removing one.

---
 drivers/video/fbmem.c |    1 -
 1 files changed, 0 insertions(+), 1 deletions(-)
drivers/video/fbmem.c +0 -1
index 99bbd28..a15b44e 100644
@@ -1513,7 +1513,6 @@ register_framebuffer(struct fb_info *fb_info)
 				       fb_info->fix.id,
 				       registered_fb[i]->fix.id);
 				unregister_framebuffer(registered_fb[i]);
-				break;
 			}
 		}
 	}
Signature · 10 lines
1.6.5.2


------------------------------------------------------------------------------
Download Intel&#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
--