← Back to team overview

hybrid-graphics-linux team mailing list archive

Re: RadeonHD+IntelGMA switchable

 

On Tue, 13 Jul 2010, Andreas Demmer wrote:
What else have you patched in fglrx besides that it installs on a 2.6.34
kernel? Can I see your patches anywhere?


Patch attached. Note radeon_atpx_handler.c is simply from kernel's drivers/gpu/drm/radeon/radeon_atpx_handler.c copied to build_mod.


---
 Looking forward to reading yours.
   Ruslan N. Marchenko
diff -ru fglrx-install.0CL4xS/common/lib/modules/fglrx/build_mod/2.6.x/Makefile fglrx-install.my/common/lib/modules/fglrx/build_mod/2.6.x/Makefile
--- fglrx-install.0CL4xS/common/lib/modules/fglrx/build_mod/2.6.x/Makefile	2010-06-03 16:23:55.000000000 +0200
+++ fglrx-install.my/common/lib/modules/fglrx/build_mod/2.6.x/Makefile	2010-06-28 14:22:18.752405724 +0200
@@ -33,6 +33,7 @@
 
 fglrx-c-objs    += firegl_public.o      \
                    kcl_acpi.o           \
+		   radeon_atpx_handler.o\
                    kcl_agp.o            \
                    kcl_debug.o          \
                    kcl_ioctl.o          \
diff -ru fglrx-install.0CL4xS/common/lib/modules/fglrx/build_mod/drmP.h fglrx-install.my/common/lib/modules/fglrx/build_mod/drmP.h
--- fglrx-install.0CL4xS/common/lib/modules/fglrx/build_mod/drmP.h	2010-06-03 16:23:55.000000000 +0200
+++ fglrx-install.my/common/lib/modules/fglrx/build_mod/drmP.h	2010-06-28 10:32:21.213022579 +0200
@@ -42,7 +42,7 @@
  * can build the DRM (part of PI DRI). 4/21/2000 S + B */
 #include <asm/current.h>
 #endif /* __alpha__ */
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,33)
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,34)
 #include <generated/autoconf.h>
 #else
 #include <linux/autoconf.h>
diff -ru fglrx-install.0CL4xS/common/lib/modules/fglrx/build_mod/firegl_public.c fglrx-install.my/common/lib/modules/fglrx/build_mod/firegl_public.c
--- fglrx-install.0CL4xS/common/lib/modules/fglrx/build_mod/firegl_public.c	2010-06-03 16:23:55.000000000 +0200
+++ fglrx-install.my/common/lib/modules/fglrx/build_mod/firegl_public.c	2010-07-07 08:36:35.973712225 +0200
@@ -28,7 +28,7 @@
 #error Kernel versions older than 2.6.0 are no longer supported by this module.
 #endif 
 
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,33)
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,34)
 #include <generated/autoconf.h>
 #else
 #include <linux/autoconf.h>
@@ -167,7 +167,7 @@
 
 //  For 2.6.18 or higher, the UTS_RELEASE is defined in the linux/utsrelease.h. 
 #ifndef UTS_RELEASE 
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,33)
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,34)
 #include <generated/utsrelease.h>
 #else
 #include <linux/utsrelease.h>
@@ -800,11 +800,6 @@
 
 #ifdef FIREGL_POWER_MANAGEMENT
 
-static int fglrx_pci_probe(struct pci_dev *dev, const struct pci_device_id *id_table)
-{
-    return 0;
-}
-
 /* Starting from 2.6.14, kernel has new struct defined for pm_message_t,
    we have to handle this case separately.
    2.6.11/12/13 kernels have pm_message_t defined as int and older kernels
@@ -916,6 +911,53 @@
 
     return 0;
 }
+#if defined(CONFIG_VGA_SWITCHEROO)
+#include <linux/vga_switcheroo.h>
+// It is supposed to use single card anyway for fglrx
+// Don't know how it will be with onboard radeon + discrete radeon though
+static struct pci_dev *vga_switcheroo_pdev = NULL;
+void radeon_register_atpx_handler(void);
+void radeon_unregister_atpx_handler(void);
+static void fgl_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_INFO "[fglrx]: switched on\n");
+		fglrx_pci_resume(pdev);
+	} else {
+		printk(KERN_INFO "[fglrx]: switched off\n");
+		fglrx_pci_suspend(pdev, pmm);
+	}
+}
+// See drivers/gpu/drm/radeon/radeon_device.c
+static bool radeon_switcheroo_can_switch(struct pci_dev *pdev)
+{
+        struct drm_device *dev = pci_get_drvdata(pdev);
+        bool can_switch;
+	return (0 == 0);
+	printk(KERN_INFO "[fglrx]: dev_get_drvdata(pdev[%p]->dev[%p]) = %p\n",pdev,pdev->dev,dev);
+        spin_lock(&dev->count_lock);
+        can_switch = (dev->open_count == 0);
+        spin_unlock(&dev->count_lock);
+        return can_switch;
+}
+#endif // CONFIG_VGA_SWITCHEROO
+
+static int fglrx_pci_probe(struct pci_dev *dev, const struct pci_device_id *id_table)
+{
+	printk(KERN_INFO "[fglrx]: probed device: %x:%x(%x:%x)\n",dev->vendor,dev->device,dev->subsystem_vendor,dev->subsystem_device);
+#if defined(CONFIG_VGA_SWITCHEROO)
+		// Register only first device. ?!
+		if(vga_switcheroo_pdev == NULL) {
+			printk(KERN_INFO "[fglrx]: registering first device with vga_switcheroo\n");
+			radeon_register_atpx_handler();
+			vga_switcheroo_register_client(dev, fgl_switcheroo_set_state, radeon_switcheroo_can_switch);
+			vga_switcheroo_pdev = dev;
+		}
+#endif // VGASWITCHEROO
+    return 0;
+}
+
 
 static struct pci_driver fglrx_pci_driver = 
 {
@@ -927,6 +969,7 @@
     .resume         = fglrx_pci_resume,
 #endif /* CONFIG_PM */
 };
+
 #endif // FIREGL_POWER_MANAGEMENT
 
 
@@ -981,7 +1024,6 @@
             //The GART unit of All supported ASICs has 40-bit address range.
             pci_set_dma_mask(pdev, 0xfffffffffful); 
 #endif
-
             j++;
             if (j == num_of_devices)
             {
@@ -1193,6 +1235,15 @@
     cf_object_cleanup();
     adapter_chain_cleanup();    
 
+#if defined(CONFIG_VGA_SWITCHEROO)
+	radeon_unregister_atpx_handler();
+	if(vga_switcheroo_pdev != NULL) {
+		KCL_DEBUG_INFO("unregistering vga_switcheroo client\n");
+		vga_switcheroo_unregister_client(vga_switcheroo_pdev);
+		vga_switcheroo_pdev = NULL;
+	}
+#endif // VGASWITCHEROO:  Cleanup atpx hook
+
     return;
 }
 
diff -ru fglrx-install.0CL4xS/common/lib/modules/fglrx/build_mod/kcl_acpi.c fglrx-install.my/common/lib/modules/fglrx/build_mod/kcl_acpi.c
--- fglrx-install.0CL4xS/common/lib/modules/fglrx/build_mod/kcl_acpi.c	2010-06-03 16:23:55.000000000 +0200
+++ fglrx-install.my/common/lib/modules/fglrx/build_mod/kcl_acpi.c	2010-06-28 10:31:04.403022292 +0200
@@ -15,7 +15,7 @@
  ****************************************************************************/
 
 #include <linux/version.h>
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,33)
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,34)
 #include <generated/autoconf.h>
 #else
 #include <linux/autoconf.h>
diff -ru fglrx-install.0CL4xS/common/lib/modules/fglrx/build_mod/kcl_agp.c fglrx-install.my/common/lib/modules/fglrx/build_mod/kcl_agp.c
--- fglrx-install.0CL4xS/common/lib/modules/fglrx/build_mod/kcl_agp.c	2010-06-03 16:23:55.000000000 +0200
+++ fglrx-install.my/common/lib/modules/fglrx/build_mod/kcl_agp.c	2010-06-28 10:32:35.472401024 +0200
@@ -31,7 +31,7 @@
  */
 
 #include <linux/version.h>
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,33)
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,34)
 #include <generated/autoconf.h>
 #else
 #include <linux/autoconf.h>
diff -ru fglrx-install.0CL4xS/common/lib/modules/fglrx/build_mod/kcl_io.c fglrx-install.my/common/lib/modules/fglrx/build_mod/kcl_io.c
--- fglrx-install.0CL4xS/common/lib/modules/fglrx/build_mod/kcl_io.c	2010-06-03 16:23:55.000000000 +0200
+++ fglrx-install.my/common/lib/modules/fglrx/build_mod/kcl_io.c	2010-06-28 10:32:56.042400922 +0200
@@ -37,7 +37,7 @@
  */
 
 #include <linux/version.h>
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,33)
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,34)
 #include <generated/autoconf.h>
 #else
 #include <linux/autoconf.h>
diff -ru fglrx-install.0CL4xS/common/lib/modules/fglrx/build_mod/kcl_osconfig.h fglrx-install.my/common/lib/modules/fglrx/build_mod/kcl_osconfig.h
--- fglrx-install.0CL4xS/common/lib/modules/fglrx/build_mod/kcl_osconfig.h	2010-06-03 16:23:55.000000000 +0200
+++ fglrx-install.my/common/lib/modules/fglrx/build_mod/kcl_osconfig.h	2010-06-28 10:33:36.212401991 +0200
@@ -20,7 +20,7 @@
 #define KCL_OSCONFIG_H
 
 #include <linux/version.h>
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,33)
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,34)
 #include <generated/autoconf.h>
 #else
 #include <linux/autoconf.h>
diff -ru fglrx-install.0CL4xS/common/lib/modules/fglrx/build_mod/kcl_pci.c fglrx-install.my/common/lib/modules/fglrx/build_mod/kcl_pci.c
--- fglrx-install.0CL4xS/common/lib/modules/fglrx/build_mod/kcl_pci.c	2010-06-03 16:23:55.000000000 +0200
+++ fglrx-install.my/common/lib/modules/fglrx/build_mod/kcl_pci.c	2010-06-28 10:33:14.712400988 +0200
@@ -31,7 +31,7 @@
  */
 
 #include <linux/version.h>
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,33)
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,34)
 #include <generated/autoconf.h>
 #else
 #include <linux/autoconf.h>
diff -ru fglrx-install.0CL4xS/common/lib/modules/fglrx/build_mod/kcl_str.c fglrx-install.my/common/lib/modules/fglrx/build_mod/kcl_str.c
--- fglrx-install.0CL4xS/common/lib/modules/fglrx/build_mod/kcl_str.c	2010-06-03 16:23:55.000000000 +0200
+++ fglrx-install.my/common/lib/modules/fglrx/build_mod/kcl_str.c	2010-06-28 10:33:49.112401939 +0200
@@ -31,7 +31,7 @@
  */
 
 #include <linux/version.h>
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,33)
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,34)
 #include <generated/autoconf.h>
 #else
 #include <linux/autoconf.h>
diff -ru fglrx-install.0CL4xS/common/lib/modules/fglrx/build_mod/kcl_wait.c fglrx-install.my/common/lib/modules/fglrx/build_mod/kcl_wait.c
--- fglrx-install.0CL4xS/common/lib/modules/fglrx/build_mod/kcl_wait.c	2010-06-03 16:23:55.000000000 +0200
+++ fglrx-install.my/common/lib/modules/fglrx/build_mod/kcl_wait.c	2010-06-27 01:24:54.764525792 +0200
@@ -31,7 +31,7 @@
  */
 
 #include <linux/version.h>
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,33)
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,34)
 #include <generated/autoconf.h>
 #else
 #include <linux/autoconf.h>
@@ -40,6 +40,9 @@
 #include <linux/highmem.h>
 #include <linux/sched.h>
 
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,34)
+#include <linux/slab.h>
+#endif
 #include "kcl_config.h"
 #include "kcl_wait.h"
 
Only in fglrx-install.my/common/lib/modules/fglrx/build_mod/: radeon_atpx_handler.c

References