summaryrefslogtreecommitdiff
path: root/x11-drivers/ati-userspace/files
diff options
context:
space:
mode:
authorBlackNoxis <steven.darklight@gmail.com>2014-02-15 23:24:26 +0200
committerBlackNoxis <steven.darklight@gmail.com>2014-02-15 23:24:26 +0200
commit7224c1253228e5c29c78cb3f0f26ce34770f2356 (patch)
tree1684924656132935256e034f35f92abee6623265 /x11-drivers/ati-userspace/files
Added ebuilds for kogaion desktop
Diffstat (limited to 'x11-drivers/ati-userspace/files')
-rw-r--r--x11-drivers/ati-userspace/files/amd-drivers-3.2.7.1.patch19
-rw-r--r--x11-drivers/ati-userspace/files/ati-drivers-12.2-redefine-WARN.patch42
-rw-r--r--x11-drivers/ati-userspace/files/ati-drivers-12.9-KCL_AGP_FindCapsRegisters-stub.patch27
-rw-r--r--x11-drivers/ati-userspace/files/ati-drivers-2.6.33.patch140
-rw-r--r--x11-drivers/ati-userspace/files/ati-drivers-2.6.34.patch10
-rw-r--r--x11-drivers/ati-userspace/files/ati-drivers-2.6.35-and-newer.patch11
-rw-r--r--x11-drivers/ati-userspace/files/ati-drivers-2.6.36.patch26
-rw-r--r--x11-drivers/ati-userspace/files/ati-drivers-2.6.37.patch11
-rw-r--r--x11-drivers/ati-userspace/files/ati-drivers-2.6.38.patch59
-rw-r--r--x11-drivers/ati-userspace/files/ati-drivers-CVE-2010-3081-fix.patch60
-rw-r--r--x11-drivers/ati-userspace/files/ati-drivers-do_mmap.patch50
-rw-r--r--x11-drivers/ati-userspace/files/ati-drivers-fix_compilation-bug-297322.patch25
-rw-r--r--x11-drivers/ati-userspace/files/ati-drivers-kernel-3.8-acpihandle.patch15
-rw-r--r--x11-drivers/ati-userspace/files/ati-drivers-old_rsp.patch24
-rw-r--r--x11-drivers/ati-userspace/files/ati-drivers-vm-reserverd.patch12
-rw-r--r--x11-drivers/ati-userspace/files/ati-drivers-x32_something_something.patch13
-rw-r--r--x11-drivers/ati-userspace/files/ati-drivers-xen.patch62
-rw-r--r--x11-drivers/ati-userspace/files/ati-powermode-opt-path-2.patch42
-rw-r--r--x11-drivers/ati-userspace/files/ati-powermode-opt-path-3.patch40
-rw-r--r--x11-drivers/ati-userspace/files/atieventsd.init20
-rw-r--r--x11-drivers/ati-userspace/files/const-notifier-block.patch25
-rw-r--r--x11-drivers/ati-userspace/files/kernel/2.6.31-fglrx_find_task_by_vpid.patch19
-rw-r--r--x11-drivers/ati-userspace/files/kernel/2.6.32-9.11-fix_compilation.patch37
-rw-r--r--x11-drivers/ati-userspace/files/switchlibGL61
24 files changed, 850 insertions, 0 deletions
diff --git a/x11-drivers/ati-userspace/files/amd-drivers-3.2.7.1.patch b/x11-drivers/ati-userspace/files/amd-drivers-3.2.7.1.patch
new file mode 100644
index 00000000..104c8788
--- /dev/null
+++ b/x11-drivers/ati-userspace/files/amd-drivers-3.2.7.1.patch
@@ -0,0 +1,19 @@
+--- a/common/lib/modules/fglrx/build_mod/firegl_public.c
++++ b/common/lib/modules/fglrx/build_mod/firegl_public.c
+@@ -5797,10 +5797,16 @@ void ATI_API_CALL KCL_fpu_begin(void)
+ #ifdef CONFIG_X86_64
+ kernel_fpu_begin();
+ #else
++#ifndef TS_USEDFPU
++ preempt_disable();
++ if (__thread_has_fpu(current))
++ __save_init_fpu(current);
++#else
+ struct thread_info *cur_task = current_thread_info();
+ preempt_disable();
+ if (cur_task->status & TS_USEDFPU)
+ __save_init_fpu(cur_task->task);
++#endif
+ else
+ clts();
+ #endif
diff --git a/x11-drivers/ati-userspace/files/ati-drivers-12.2-redefine-WARN.patch b/x11-drivers/ati-userspace/files/ati-drivers-12.2-redefine-WARN.patch
new file mode 100644
index 00000000..f4fab432
--- /dev/null
+++ b/x11-drivers/ati-userspace/files/ati-drivers-12.2-redefine-WARN.patch
@@ -0,0 +1,42 @@
+--- common/lib/modules/fglrx/build_mod/kcl_debug.h.orig 2012-03-08 19:30:38.195025328 +0100
++++ common/lib/modules/fglrx/build_mod/kcl_debug.h 2012-03-08 19:31:24.976024507 +0100
+@@ -85,8 +85,8 @@
+ #ifdef ERROR
+ #undef ERROR
+ #endif
+-#ifdef WARN
+-#undef WARN
++#ifdef AMD_WARN
++#undef AMD_WARN
+ #endif
+ #ifdef INFO
+ #undef INFO
+@@ -122,7 +122,7 @@
+ {
+ SPECIAL = 0,
+ ERROR ,
+- WARN ,
++ AMD_WARN ,
+ INFO ,
+ INFOEX,
+ TRACE,
+@@ -160,7 +160,7 @@
+ }log_map;
+
+
+-#define DEFAULT_LOG_LEVEL ((U08)(___BIT(INFO) | ___BIT(INFOEX) |___BIT(ERROR) |___BIT(WARN) | ___BIT(TRACE)| ___BIT(SPECIAL) ))
++#define DEFAULT_LOG_LEVEL ((U08)(___BIT(INFO) | ___BIT(INFOEX) |___BIT(ERROR) |___BIT(AMD_WARN) | ___BIT(TRACE)| ___BIT(SPECIAL) ))
+ #define INFO_LOG_LEVEL ((U08)(___BIT(INFO) | ___BIT(INFOEX)))
+ extern const log_map module_log_map[];
+ extern const module_map module_type_map[];
+--- common/lib/modules/fglrx/build_mod/kcl_debug.c.orig 2012-03-08 19:36:18.244019310 +0100
++++ common/lib/modules/fglrx/build_mod/kcl_debug.c 2012-03-08 19:36:36.197018973 +0100
+@@ -69,7 +69,7 @@
+ {
+ {SPECIAL , 'S'},
+ {ERROR , 'E'},
+- {WARN , 'W'},
++ {AMD_WARN , 'W'},
+ {INFO , 'I'},
+ {INFOEX , 'X'},
+ {TRACE , 'T'},
diff --git a/x11-drivers/ati-userspace/files/ati-drivers-12.9-KCL_AGP_FindCapsRegisters-stub.patch b/x11-drivers/ati-userspace/files/ati-drivers-12.9-KCL_AGP_FindCapsRegisters-stub.patch
new file mode 100644
index 00000000..0ea461b8
--- /dev/null
+++ b/x11-drivers/ati-userspace/files/ati-drivers-12.9-KCL_AGP_FindCapsRegisters-stub.patch
@@ -0,0 +1,27 @@
+From: Vasiliy Yeremeyev <vayerx@gmail.com>
+Date: Sun, 4 Nov 2012 23:59:36 +0400
+Subject: [PATCH] KCL_AGP_FindCapsRegisters stub for AGP-less systems
+
+---
+ common/lib/modules/fglrx/build_mod/kcl_agp.c | 5 +++++
+ 1 file changed, 5 insertions(+)
+
+diff --git a/common/lib/modules/fglrx/build_mod/kcl_agp.c b/common/lib/modules/fglrx/build_mod/kcl_agp.c
+index b9c0655..cb1902b 100644
+--- a/common/lib/modules/fglrx/build_mod/kcl_agp.c
++++ b/common/lib/modules/fglrx/build_mod/kcl_agp.c
+@@ -479,6 +479,11 @@ int ATI_API_CALL KCL_AGP_Enable(unsigned long mode)
+ return -EINVAL;
+ }
+
++int ATI_API_CALL KCL_AGP_FindCapsRegisters(KCL_PCI_DevHandle dev)
++{
++ return -EINVAL;
++}
++
+ int ATI_API_CALL KCL_AGP_ReadCapsRegisters(KCL_PCI_DevHandle dev, unsigned int *caps)
+ {
+ return -EINVAL;
+--
+1.7.12
+
diff --git a/x11-drivers/ati-userspace/files/ati-drivers-2.6.33.patch b/x11-drivers/ati-userspace/files/ati-drivers-2.6.33.patch
new file mode 100644
index 00000000..85f9aff7
--- /dev/null
+++ b/x11-drivers/ati-userspace/files/ati-drivers-2.6.33.patch
@@ -0,0 +1,140 @@
+--- work.orig/common/lib/modules/fglrx/build_mod/drmP.h
++++ work/common/lib/modules/fglrx/build_mod/drmP.h
+@@ -42,7 +42,11 @@
+ * 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)
++#include <generated/autoconf.h>
++#else
+ #include <linux/autoconf.h>
++#endif
+ #include <linux/module.h>
+ #include <linux/kernel.h>
+ #include <linux/miscdevice.h>
+--- work.orig/common/lib/modules/fglrx/build_mod/firegl_public.c
++++ work/common/lib/modules/fglrx/build_mod/firegl_public.c
+@@ -28,7 +28,11 @@
+ #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)
++#include <generated/autoconf.h>
++#else
+ #include <linux/autoconf.h>
++#endif
+
+ #if !defined(CONFIG_X86)
+ #if !defined(CONFIG_X86_PC)
+@@ -163,8 +167,12 @@
+
+ // 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)
++#include <generated/utsrelease.h>
++#else
+ #include <linux/utsrelease.h>
+ #endif
++#endif
+
+ #if defined(__i386__)
+ #ifndef do_div
+--- work.orig/common/lib/modules/fglrx/build_mod/kcl_acpi.c
++++ work/common/lib/modules/fglrx/build_mod/kcl_acpi.c
+@@ -15,7 +15,11 @@
+ ****************************************************************************/
+
+ #include <linux/version.h>
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,33)
++#include <generated/autoconf.h>
++#else
+ #include <linux/autoconf.h>
++#endif
+ #include <linux/acpi.h>
+
+ #include "kcl_config.h"
+--- work.orig/common/lib/modules/fglrx/build_mod/kcl_agp.c
++++ work/common/lib/modules/fglrx/build_mod/kcl_agp.c
+@@ -31,7 +31,11 @@
+ */
+
+ #include <linux/version.h>
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,33)
++#include <generated/autoconf.h>
++#else
+ #include <linux/autoconf.h>
++#endif
+ #include <linux/pci.h>
+ #include <linux/agp_backend.h>
+ #include <linux/string.h>
+--- work.orig/common/lib/modules/fglrx/build_mod/kcl_io.c
++++ work/common/lib/modules/fglrx/build_mod/kcl_io.c
+@@ -37,7 +37,11 @@
+ */
+
+ #include <linux/version.h>
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,33)
++#include <generated/autoconf.h>
++#else
+ #include <linux/autoconf.h>
++#endif
+ #include <linux/poll.h>
+ #include <linux/signal.h>
+ #include <asm/io.h>
+--- work.orig/common/lib/modules/fglrx/build_mod/kcl_osconfig.h
++++ work/common/lib/modules/fglrx/build_mod/kcl_osconfig.h
+@@ -20,7 +20,11 @@
+ #define KCL_OSCONFIG_H
+
+ #include <linux/version.h>
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,33)
++#include <generated/autoconf.h>
++#else
+ #include <linux/autoconf.h>
++#endif
+
+ // Choose modern way to call 32-on-64 IOCTLs if configured in the kernel
+ #if defined(CONFIG_COMPAT) && LINUX_VERSION_CODE > KERNEL_VERSION(2,6,9)
+--- work.orig/common/lib/modules/fglrx/build_mod/kcl_pci.c
++++ work/common/lib/modules/fglrx/build_mod/kcl_pci.c
+@@ -31,7 +31,11 @@
+ */
+
+ #include <linux/version.h>
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,33)
++#include <generated/autoconf.h>
++#else
+ #include <linux/autoconf.h>
++#endif
+ #include <linux/pci.h>
+
+ #include "kcl_config.h"
+--- work.orig/common/lib/modules/fglrx/build_mod/kcl_str.c
++++ work/common/lib/modules/fglrx/build_mod/kcl_str.c
+@@ -30,7 +30,12 @@
+ *
+ */
+
++#include <linux/version.h>
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,33)
++#include <generated/autoconf.h>
++#else
+ #include <linux/autoconf.h>
++#endif
+ #include <linux/string.h>
+ #include <linux/module.h>
+
+--- work.orig/common/lib/modules/fglrx/build_mod/kcl_wait.c
++++ work/common/lib/modules/fglrx/build_mod/kcl_wait.c
+@@ -31,7 +31,11 @@
+ */
+
+ #include <linux/version.h>
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,33)
++#include <generated/autoconf.h>
++#else
+ #include <linux/autoconf.h>
++#endif
+ #include <linux/wait.h>
+ #include <linux/highmem.h>
+ #include <linux/sched.h>
diff --git a/x11-drivers/ati-userspace/files/ati-drivers-2.6.34.patch b/x11-drivers/ati-userspace/files/ati-drivers-2.6.34.patch
new file mode 100644
index 00000000..1993d134
--- /dev/null
+++ b/x11-drivers/ati-userspace/files/ati-drivers-2.6.34.patch
@@ -0,0 +1,10 @@
+--- work.orig/common/lib/modules/fglrx/build_mod/kcl_wait.c 2010-04-13 20:02:46.494496561 +0200
++++ work/common/lib/modules/fglrx/build_mod/kcl_wait.c 2010-04-13 19:52:00.054563389 +0200
+@@ -39,6 +39,7 @@
+ #include <linux/wait.h>
+ #include <linux/highmem.h>
+ #include <linux/sched.h>
++#include <linux/slab.h>
+
+ #include "kcl_config.h"
+ #include "kcl_wait.h"
diff --git a/x11-drivers/ati-userspace/files/ati-drivers-2.6.35-and-newer.patch b/x11-drivers/ati-userspace/files/ati-drivers-2.6.35-and-newer.patch
new file mode 100644
index 00000000..e1703f34
--- /dev/null
+++ b/x11-drivers/ati-userspace/files/ati-drivers-2.6.35-and-newer.patch
@@ -0,0 +1,11 @@
+--- work.orig/common/lib/modules/fglrx/build_mod/kcl_ioctl.c 2010-09-19 11:45:04.922760268 +0200
++++ work/common/lib/modules/fglrx/build_mod/kcl_ioctl.c 2010-09-19 12:04:29.092812959 +0200
+@@ -193,7 +193,7 @@ void ATI_API_CALL KCL_IOCTL_UnregisterCo
+ */
+ void* ATI_API_CALL KCL_IOCTL_AllocUserSpace32(long size)
+ {
+- return compat_alloc_user_space(size);
++ return arch_compat_alloc_user_space(size);
+ }
+
+ #endif // __x86_64__
diff --git a/x11-drivers/ati-userspace/files/ati-drivers-2.6.36.patch b/x11-drivers/ati-userspace/files/ati-drivers-2.6.36.patch
new file mode 100644
index 00000000..5f8f5845
--- /dev/null
+++ b/x11-drivers/ati-userspace/files/ati-drivers-2.6.36.patch
@@ -0,0 +1,26 @@
+--- work.orig/common/lib/modules/fglrx/build_mod/firegl_public.c 2010-08-20 21:51:48.000000000 +0200
++++ work/common/lib/modules/fglrx/build_mod/firegl_public.c 2010-08-20 23:46:37.000000000 +0200
+@@ -320,7 +320,11 @@
+ return firegl_release((KCL_IO_FILE_Handle)filp);
+ }
+
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,36)
++int ip_firegl_ioctl(struct file* filp, unsigned int cmd, unsigned long arg)
++#else
+ int ip_firegl_ioctl(struct inode* inode, struct file* filp, unsigned int cmd, unsigned long arg)
++#endif
+ {
+ return firegl_ioctl((KCL_IO_FILE_Handle)filp, cmd, arg);
+ }
+@@ -407,7 +411,11 @@
+ #endif
+ open: ip_firegl_open,
+ release: ip_firegl_release,
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,36)
++ unlocked_ioctl: ip_firegl_ioctl,
++#else
+ ioctl: ip_firegl_ioctl,
++#endif
+ mmap: ip_firegl_mmap,
+
+ write: ip_firegl_write,
diff --git a/x11-drivers/ati-userspace/files/ati-drivers-2.6.37.patch b/x11-drivers/ati-userspace/files/ati-drivers-2.6.37.patch
new file mode 100644
index 00000000..75522b41
--- /dev/null
+++ b/x11-drivers/ati-userspace/files/ati-drivers-2.6.37.patch
@@ -0,0 +1,11 @@
+--- work.orig/common/lib/modules/fglrx/build_mod/firegl_public.c 2010-08-20 21:51:48.000000000 +0200
++++ work/common/lib/modules/fglrx/build_mod/firegl_public.c 2010-08-20 23:46:37.000000000 +0200
+@@ -5094,7 +5094,7 @@
+ unsigned int ATI_API_CALL KAS_Mutex_Initialize(void* hMutex)
+ {
+ kasMutex_t* mutex_obj = (kasMutex_t*)hMutex;
+- init_MUTEX(&(mutex_obj->mutex));
++ sema_init(&(mutex_obj->mutex),1);
+ return 1;
+ }
+
diff --git a/x11-drivers/ati-userspace/files/ati-drivers-2.6.38.patch b/x11-drivers/ati-userspace/files/ati-drivers-2.6.38.patch
new file mode 100644
index 00000000..1ecafece
--- /dev/null
+++ b/x11-drivers/ati-userspace/files/ati-drivers-2.6.38.patch
@@ -0,0 +1,59 @@
+Description: Add Linux 2.6.38 support
+ The following commit renamed acquire_console_sem to console_lock and
+ release_console_sem to console_unlock on the Linux kernel:
+ http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commitdiff;h=ac751efa6a0d70f2c9daef5c7e3a92270f5c2dff
+Author: Miguel Colon <debian.micove@gmail.com>
+Forwarded: no
+Last-Update: 2011-02-01
+
+--- fglrx-driver-11-1.orig/common/lib/modules/fglrx/build_mod/firegl_public.c
++++ fglrx-driver-11-1/common/lib/modules/fglrx/build_mod/firegl_public.c
+@@ -850,7 +850,12 @@ static int fglrx_pci_suspend(struct pci_
+ * happen much less frequent then without this workaround.
+ */
+ if (state == PM_EVENT_SUSPEND)
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38)
++ console_lock();
++#else
+ acquire_console_sem();
++#endif
++
+
+ if (firegl_cail_powerdown(privdev, state))
+ ret = -EIO;
+@@ -872,7 +877,11 @@ static int fglrx_pci_suspend(struct pci_
+ }
+
+ if (state == PM_EVENT_SUSPEND)
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38)
++ console_unlock();
++#else
+ release_console_sem();
++#endif
+
+ KCL_DEBUG_TRACEOUT(FN_FIREGL_ACPI, ret, NULL);
+
+@@ -896,7 +905,11 @@ static int fglrx_pci_resume(struct pci_d
+ if (PMSG_EVENT(pdev->dev.power.power_state) == 0) return 0;
+
+ if (PMSG_EVENT(pdev->dev.power.power_state) == PM_EVENT_SUSPEND)
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38)
++ console_lock();
++#else
+ acquire_console_sem();
++#endif
+
+ #ifdef FIREGL_USWC_SUPPORT
+ // Restore the PAT after resuming from S3 or S4.
+@@ -921,7 +934,11 @@ static int fglrx_pci_resume(struct pci_d
+ firegl_cail_powerup(privdev);
+
+ if (PMSG_EVENT(pdev->dev.power.power_state) == PM_EVENT_SUSPEND)
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38)
++ console_unlock();
++#else
+ release_console_sem();
++#endif
+
+ PMSG_EVENT(pdev->dev.power.power_state) = 0;
+ KCL_DEBUG_TRACEOUT(FN_FIREGL_ACPI, 0, NULL);
diff --git a/x11-drivers/ati-userspace/files/ati-drivers-CVE-2010-3081-fix.patch b/x11-drivers/ati-userspace/files/ati-drivers-CVE-2010-3081-fix.patch
new file mode 100644
index 00000000..5a71da10
--- /dev/null
+++ b/x11-drivers/ati-userspace/files/ati-drivers-CVE-2010-3081-fix.patch
@@ -0,0 +1,60 @@
+/****************************************************************************
+ * *
+ * Copyright 1999-2005 ATI Technologies Inc., Markham, Ontario, CANADA. *
+ * All Rights Reserved. *
+ * *
+ * Your use and or redistribution of this software in source and \ or *
+ * binary form, with or without modification, is subject to: (i) your *
+ * ongoing acceptance of and compliance with the terms and conditions of *
+ * the ATI Technologies Inc. software End User License Agreement; and (ii) *
+ * your inclusion of this notice in any version of this software that you *
+ * use or redistribute. A copy of the ATI Technologies Inc. software End *
+ * User License Agreement is included with this software and is also *
+ * available by contacting ATI Technologies Inc. at http://www.ati.com *
+ * *
+ ****************************************************************************/
+
+--- common/lib/modules/fglrx/build_mod/kcl_ioctl.c.orig 2010-09-01 16:05:31.000000000 +0200
++++ common/lib/modules/fglrx/build_mod/kcl_ioctl.c 2010-09-23 01:41:46.711844303 +0200
+@@ -35,6 +35,9 @@
+
+ #ifdef __x86_64__
+ # include "asm/compat.h"
++# if ARCH_COMPAT_ALLOC_USER_SPACE
++# include "linux/compat.h"
++# endif
+ # if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,22)
+ # if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,12)
+ # include "linux/ioctl32.h"
+@@ -193,7 +196,20 @@
+ */
+ void* ATI_API_CALL KCL_IOCTL_AllocUserSpace32(long size)
+ {
+- return compat_alloc_user_space(size);
++ void __user *ptr;
++
++ /* If size would occupy more than half of the entire compat space... */
++ if (unlikely(size > (((compat_uptr_t)~0) >> 1)))
++ return NULL;
++#if ARCH_COMPAT_ALLOC_USER_SPACE
++ ptr = arch_compat_alloc_user_space(size);
++#else
++ ptr = compat_alloc_user_space(size);
++#endif
++ if (unlikely(!access_ok(VERIFY_WRITE, ptr, size)))
++ return NULL;
++
++ return ptr;
+ }
+
+ #endif // __x86_64__
+--- common/lib/modules/fglrx/build_mod/2.6.x/Makefile.orig 2010-09-01 16:05:31.000000000 +0200
++++ common/lib/modules/fglrx/build_mod/2.6.x/Makefile 2010-09-23 01:47:46.533415019 +0200
+@@ -66,6 +66,7 @@
+ -DFGL_GART_RESERVED_SLOT \
+ -DFGL_LINUX253P1_VMA_API \
+ -DPAGE_ATTR_FIX=$(PAGE_ATTR_FIX) \
++ -DARCH_COMPAT_ALLOC_USER_SPACE=$(ARCH_COMPAT_ALLOC_USER_SPACE) \
+
+ ifeq ($(KERNELRELEASE),)
+ # on first call from remote location we get into this path
diff --git a/x11-drivers/ati-userspace/files/ati-drivers-do_mmap.patch b/x11-drivers/ati-userspace/files/ati-drivers-do_mmap.patch
new file mode 100644
index 00000000..04248eb7
--- /dev/null
+++ b/x11-drivers/ati-userspace/files/ati-drivers-do_mmap.patch
@@ -0,0 +1,50 @@
+--- a/common/lib/modules/fglrx/build_mod/firegl_public.c 2012-06-15 18:30:13.483762070 +0200
++++ b/common/lib/modules/fglrx/build_mod/firegl_public.c 2012-06-17 17:47:36.543041869 +0200
+@@ -2106,6 +2106,12 @@
+ }
+ }
+
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 5, 0)
++# define NO_DO_MMAP
++# define do_mmap(a,b,c,d,e,f) vm_mmap(a, b, c, d, e, f)
++# define do_munmap(a,b,c) vm_munmap(b, c)
++#endif
++
+ unsigned long ATI_API_CALL KCL_MEM_AllocLinearAddrInterval(
+ KCL_IO_FILE_Handle file,
+ unsigned long addr,
+@@ -2117,10 +2123,13 @@
+
+ flags = MAP_SHARED;
+ prot = PROT_READ|PROT_WRITE;
+-
++#ifdef NO_DO_MMAP
++ vaddr = (void *) vm_mmap(file, 0, len, prot, flags, pgoff);
++#else
+ down_write(&current->mm->mmap_sem);
+ vaddr = (void *) do_mmap(file, 0, len, prot, flags, pgoff);
+ up_write(&current->mm->mmap_sem);
++#endif
+ if (IS_ERR(vaddr))
+ return 0;
+ else
+@@ -2131,7 +2140,9 @@
+ {
+ int retcode = 0;
+
++#ifndef NO_DO_MMAP
+ down_write(&current->mm->mmap_sem);
++#endif
+ #ifdef FGL_LINUX_RHEL_MUNMAP_API
+ retcode = do_munmap(current->mm,
+ addr,
+@@ -2142,7 +2153,9 @@
+ addr,
+ len);
+ #endif
++#ifndef NO_DO_MMAP
+ up_write(&current->mm->mmap_sem);
++#endif
+ return retcode;
+ }
+
diff --git a/x11-drivers/ati-userspace/files/ati-drivers-fix_compilation-bug-297322.patch b/x11-drivers/ati-userspace/files/ati-drivers-fix_compilation-bug-297322.patch
new file mode 100644
index 00000000..e2af915a
--- /dev/null
+++ b/x11-drivers/ati-userspace/files/ati-drivers-fix_compilation-bug-297322.patch
@@ -0,0 +1,25 @@
+--- common/lib/modules/fglrx/build_mod/firegl_public.c
++++ common/lib/modules/fglrx/build_mod/firegl_public.c
+@@ -1441,7 +1441,9 @@
+ todo !!!
+ #endif
+
+-unsigned long ATI_API_CALL __ke__cmpxchg(volatile void *ptr, unsigned long old,
++void __cmpxchg_wrong_size(void) {}
++
++unsigned long ATI_API_CALL __ke__cmpxchg(volatile unsigned long *ptr, unsigned long old,
+ unsigned long new, int size)
+ {
+ #ifndef __HAVE_ARCH_CMPXCHG
+--- common/lib/modules/fglrx/build_mod/firegl_public.h
++++ common/lib/modules/fglrx/build_mod/firegl_public.h
+@@ -441,7 +441,8 @@
+ extern void ATI_API_CALL KCL_SIGNAL_BlockAll(int (*notifier)(void *priv), void *pPriv, __ke_sigset_t *pSigMask);
+ extern void ATI_API_CALL KCL_SIGNAL_UnblockAll(void);
+
+-extern unsigned long ATI_API_CALL __ke__cmpxchg(volatile void *ptr, unsigned long old,
++extern void __cmpxchg_wrong_size(void);
++extern unsigned long ATI_API_CALL __ke__cmpxchg(volatile unsigned long *ptr, unsigned long old,
+ unsigned long new, int size);
+
+ #define __ke_cmpxchg(ptr,o,n) \
diff --git a/x11-drivers/ati-userspace/files/ati-drivers-kernel-3.8-acpihandle.patch b/x11-drivers/ati-userspace/files/ati-drivers-kernel-3.8-acpihandle.patch
new file mode 100644
index 00000000..bdff4fb7
--- /dev/null
+++ b/x11-drivers/ati-userspace/files/ati-drivers-kernel-3.8-acpihandle.patch
@@ -0,0 +1,15 @@
+--- common/lib/modules/fglrx/build_mod/kcl_acpi.c 2012-07-04 21:43:47.000000000 +0200
++++ common/lib/modules/fglrx/build_mod/kcl_acpi.c.new 2012-12-23 11:25:38.000000000 +0100
+@@ -775,11 +775,7 @@
+ unsigned int ATI_API_CALL KCL_ACPI_GetHandles(kcl_match_info_t *pInfo)
+ {
+ #if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,12)
+- #if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,19)
+- pInfo->video_handle = pInfo->pcidev->dev.archdata.acpi_handle;
+- #else
+- pInfo->video_handle = pInfo->pcidev->dev.firmware_data;
+- #endif
++ pInfo->video_handle = DEVICE_ACPI_HANDLE(&pInfo->pcidev->dev);
+ if ( pInfo->video_handle &&
+ (KCL_ACPI_videoDevice(pInfo->video_handle) != KCL_ACPI_OK) )
+ {
diff --git a/x11-drivers/ati-userspace/files/ati-drivers-old_rsp.patch b/x11-drivers/ati-userspace/files/ati-drivers-old_rsp.patch
new file mode 100644
index 00000000..0456bd6b
--- /dev/null
+++ b/x11-drivers/ati-userspace/files/ati-drivers-old_rsp.patch
@@ -0,0 +1,24 @@
+--- a/common/lib/modules/fglrx/build_mod/firegl_public.c 2012-05-26 18:33:25.044695179 +0200
++++ b/common/lib/modules/fglrx/build_mod/firegl_public.c 2012-05-26 18:28:39.692699095 +0200
+@@ -4154,7 +4154,7 @@
+ {
+ unsigned int p;
+ KCL_DEBUG5(FN_FIREGL_KAS, "%d\n", level_init);
+- for_each_cpu_mask(p, cpu_possible_map)
++ for_each_possible_cpu(p)
+ {
+ KCL_DEBUG1(FN_FIREGL_KAS,"Setting initial execution level for CPU # %d\n", p);
+ preempt_disable();
+--- a/common/lib/modules/fglrx/build_mod/kcl_ioctl.c 2012-05-26 19:11:03.402987821 +0200
++++ b/common/lib/modules/fglrx/build_mod/kcl_ioctl.c 2012-05-26 19:13:00.273986422 +0200
+@@ -217,6 +217,10 @@
+ * \param size [in] Number of bytes to allocate
+ * \return Pointer to allocated memory
+ */
++#ifndef CONFIG_X86_X32
++DEFINE_PER_CPU(unsigned long, old_rsp);
++#endif
++
+ void* ATI_API_CALL KCL_IOCTL_AllocUserSpace32(long size)
+ {
+ void __user *ret = COMPAT_ALLOC_USER_SPACE(size); \ No newline at end of file
diff --git a/x11-drivers/ati-userspace/files/ati-drivers-vm-reserverd.patch b/x11-drivers/ati-userspace/files/ati-drivers-vm-reserverd.patch
new file mode 100644
index 00000000..08045a65
--- /dev/null
+++ b/x11-drivers/ati-userspace/files/ati-drivers-vm-reserverd.patch
@@ -0,0 +1,12 @@
+--- common/lib/modules/fglrx/build_mod/firegl_public.c 2012-10-18 00:29:21.778369464 +0200
++++ common/lib/modules/fglrx/build_mod/firegl_public.c.new 2012-10-18 00:30:39.647416026 +0200
+@@ -222,6 +222,10 @@
+ #define preempt_enable()
+ #endif
+
++#ifndef VM_RESERVED
++#define VM_RESERVED (VM_DONTEXPAND | VM_DONTDUMP)
++#endif
++
+ // ============================================================
+ /* globals */
diff --git a/x11-drivers/ati-userspace/files/ati-drivers-x32_something_something.patch b/x11-drivers/ati-userspace/files/ati-drivers-x32_something_something.patch
new file mode 100644
index 00000000..d37c1191
--- /dev/null
+++ b/x11-drivers/ati-userspace/files/ati-drivers-x32_something_something.patch
@@ -0,0 +1,13 @@
+--- a/common/lib/modules/fglrx/build_mod/kcl_ioctl.c 2012-05-26 19:11:03.402987821 +0200
++++ b/common/lib/modules/fglrx/build_mod/kcl_ioctl.c 2012-05-26 19:13:00.273986422 +0200
+@@ -217,6 +217,10 @@
+ * \param size [in] Number of bytes to allocate
+ * \return Pointer to allocated memory
+ */
++#ifndef CONFIG_X86_X32
++DEFINE_PER_CPU(unsigned long, old_rsp);
++#endif
++
+ void* ATI_API_CALL KCL_IOCTL_AllocUserSpace32(long size)
+ {
+ void __user *ret = COMPAT_ALLOC_USER_SPACE(size);
diff --git a/x11-drivers/ati-userspace/files/ati-drivers-xen.patch b/x11-drivers/ati-userspace/files/ati-drivers-xen.patch
new file mode 100644
index 00000000..a1b88df7
--- /dev/null
+++ b/x11-drivers/ati-userspace/files/ati-drivers-xen.patch
@@ -0,0 +1,62 @@
+--- common/lib/modules/fglrx/build_mod/firegl_public.c 2008-12-09 15:17:27.000000000 +0000
++++ common/lib/modules/fglrx/build_mod/firegl_public.c 2008-12-09 15:12:34.000000000 +0000
+@@ -31,6 +31,9 @@
+ #include <linux/autoconf.h>
+
+ #if !defined(CONFIG_X86_PC)
++#if !defined(CONFIG_X86_PC_XEN)
++#if !defined(CONFIG_X86_XEN)
++#if !defined(CONFIG_X86_64_XEN)
+ #if !defined(CONFIG_X86_64)
+ #if !defined(CONFIG_X86_VOYAGER)
+ #if !defined(CONFIG_X86_NUMAQ)
+@@ -47,6 +50,9 @@
+ #endif
+ #endif
+ #endif
++#endif
++#endif
++#endif
+
+ /* The dirty-page-tracking patch included in NLD 9 SMP kernels defines
+ * a static inline function that uses a GPL-only symbol in a header
+--- common/lib/modules/fglrx/build_mod/firegl_public.h 2008-12-09 15:17:27.000000000 +0000
++++ common/lib/modules/fglrx/build_mod/firegl_public.h 2008-12-09 15:15:45.000000000 +0000
+@@ -30,9 +30,13 @@
+ #endif
+
+ #if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,9)
+-
++#ifdef CONFIG_XEN
++#define REMAP_PAGE_RANGE_FN io_remap_pfn_range
++#define REMAP_PAGE_RANGE_STR "io_remap_pfn_range"
++#else
+ #define REMAP_PAGE_RANGE_FN remap_pfn_range
+ #define REMAP_PAGE_RANGE_STR "remap_pfn_range"
++#endif
+ #define REMAP_PAGE_RANGE_OFF(offset) ((offset) >> PAGE_SHIFT)
+
+ #else /* LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,9) */
+@@ -43,13 +47,21 @@
+
+ #endif /* LINUX_VERSION_CODE > KERNEL_VERSION(2,6,9) */
+
++#ifdef CONFIG_XEN
++#define REMAP_PAGE_RANGE(vma,offset) \
++ REMAP_PAGE_RANGE_FN((vma), \
++ (vma)->vm_start, \
++ REMAP_PAGE_RANGE_OFF(offset), \
++ (vma)->vm_end - (vma)->vm_start, \
++ (vma)->vm_page_prot)
++#else
+ #define REMAP_PAGE_RANGE(vma,offset) \
+ REMAP_PAGE_RANGE_FN(FGL_VMA_API_PASS \
+ (vma)->vm_start, \
+ REMAP_PAGE_RANGE_OFF(offset), \
+ (vma)->vm_end - (vma)->vm_start, \
+ (vma)->vm_page_prot)
+-
++#endif
+
+ /* Page table macros */
+
diff --git a/x11-drivers/ati-userspace/files/ati-powermode-opt-path-2.patch b/x11-drivers/ati-userspace/files/ati-powermode-opt-path-2.patch
new file mode 100644
index 00000000..f5a35a30
--- /dev/null
+++ b/x11-drivers/ati-userspace/files/ati-powermode-opt-path-2.patch
@@ -0,0 +1,42 @@
+diff -ur common.orig/usr/share/doc/fglrx/examples/etc/acpi/ati-powermode.sh common/usr/share/doc/fglrx/examples/etc/acpi/ati-powermode.sh
+--- common.orig/usr/share/doc/fglrx/examples/etc/acpi/ati-powermode.sh 2006-07-28 04:22:36.000000000 +0100
++++ common/usr/share/doc/fglrx/examples/etc/acpi/ati-powermode.sh 2006-08-04 12:19:42.000000000 +0100
+@@ -4,6 +4,8 @@
+ # Control script for ACPI lid state and AC adapter state
+ #
+
++aticonfig='/opt/bin/aticonfig'
++
+ getXuser() {
+ user=`finger| grep -m1 ":$displaynum " | awk '{print $1}'`
+ if [ x"$user" = x"" ]; then
+@@ -47,7 +49,7 @@
+ done
+
+ #If PPLIB is enabled
+-su $user -c '/usr/bin/aticonfig --pplib-cmd="get version"' | grep PPLIB
++su $user -c '$aticonfig --pplib-cmd="get version"' | grep PPLIB
+ if [ $? = 0 ]; then
+ echo "Has PPLIB"
+ has_pplib=1
+@@ -61,15 +63,15 @@
+ if [ ${lid_closed} -eq 1 -o ${on_dc} -eq 1 ]; then
+ echo "Low power"
+ if [ ${has_pplib} -eq 1 ]; then
+- su $user -c '/usr/bin/aticonfig --pplib-cmd="notify psrc dc"'
++ su $user -c '$aticonfig --pplib-cmd="notify psrc dc"'
+ else
+- su $user -c "/usr/bin/aticonfig --set-powerstate=1 --effective=now"
++ su $user -c "$aticonfig --set-powerstate=1"
+ fi
+ else
+ echo "high power"
+ if [ ${has_pplib} -eq 1 ]; then
+- su $user -c '/usr/bin/aticonfig --pplib-cmd="notify psrc ac"'
++ su $user -c '$aticonfig --pplib-cmd="notify psrc ac"'
+ else
+- su $user -c "/usr/bin/aticonfig --set-powerstate=3 --effective=now"
++ su $user -c "$aticonfig --set-powerstate=$($aticonfig --lsp | grep 'default state' | cut -c 3)"
+ fi
+ fi
+
diff --git a/x11-drivers/ati-userspace/files/ati-powermode-opt-path-3.patch b/x11-drivers/ati-userspace/files/ati-powermode-opt-path-3.patch
new file mode 100644
index 00000000..106e67ee
--- /dev/null
+++ b/x11-drivers/ati-userspace/files/ati-powermode-opt-path-3.patch
@@ -0,0 +1,40 @@
+--- a/common/usr/share/doc/fglrx/examples/etc/acpi/ati-powermode.sh 2012-08-17 22:39:05.077984979 +0800
++++ b/common/usr/share/doc/fglrx/examples/etc/acpi/ati-powermode.sh 2012-08-17 22:41:15.919976149 +0800
+@@ -4,6 +4,8 @@
+ # Control script for ACPI lid state and AC adapter state
+ #
+
++aticonfig='/opt/bin/aticonfig'
++
+ getXuser() {
+ user=`who| grep -m1 ":$displaynum " | awk '{print $1}'`
+ if [ x"$user" = x"" ]; then
+@@ -47,7 +49,7 @@
+ done
+
+ #If PPLIB is enabled
+-su $user -c '/usr/bin/aticonfig --pplib-cmd="get version"' | grep PPLIB
++su $user -c '$aticonfig --pplib-cmd="get version"' | grep PPLIB
+ if [ $? = 0 ]; then
+ echo "Has PPLIB"
+ has_pplib=1
+@@ -61,15 +63,15 @@
+ if [ ${lid_closed} -eq 1 -o ${on_dc} -eq 1 ]; then
+ echo "Low power"
+ if [ ${has_pplib} -eq 1 ]; then
+- su $user -c '/usr/bin/aticonfig --pplib-cmd="notify psrc dc"'
++ su $user -c '$aticonfig --pplib-cmd="notify psrc dc"'
+ else
+- su $user -c "/usr/bin/aticonfig --set-powerstate=1 --effective=now"
++ su $user -c "$aticonfig --set-powerstate=1 --effective=now"
+ fi
+ else
+ echo "high power"
+ if [ ${has_pplib} -eq 1 ]; then
+- su $user -c '/usr/bin/aticonfig --pplib-cmd="notify psrc ac"'
++ su $user -c '$aticonfig --pplib-cmd="notify psrc ac"'
+ else
+- su $user -c "/usr/bin/aticonfig --set-powerstate=3 --effective=now"
++ su $user -c "$aticonfig --set-powerstate=3 --effective=now"
+ fi
+ fi
diff --git a/x11-drivers/ati-userspace/files/atieventsd.init b/x11-drivers/ati-userspace/files/atieventsd.init
new file mode 100644
index 00000000..73139ce3
--- /dev/null
+++ b/x11-drivers/ati-userspace/files/atieventsd.init
@@ -0,0 +1,20 @@
+#!/sbin/runscript
+# Copyright 1999-2006 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Header: /var/cvsroot/gentoo-x86/x11-drivers/ati-drivers/files/atieventsd.init,v 1.3 2007/05/18 23:58:01 marienz Exp $
+
+depend() {
+ need acpid
+}
+
+start() {
+ ebegin "Starting ${SVCNAME}"
+ start-stop-daemon --start --exec /opt/sbin/atieventsd -- ${ATIEVENTSDOPTS}
+ eend $?
+}
+
+stop() {
+ ebegin "Stopping ${SVCNAME}"
+ start-stop-daemon --stop --quiet --exec /opt/sbin/atieventsd
+ eend $?
+} \ No newline at end of file
diff --git a/x11-drivers/ati-userspace/files/const-notifier-block.patch b/x11-drivers/ati-userspace/files/const-notifier-block.patch
new file mode 100644
index 00000000..ba1fdb2b
--- /dev/null
+++ b/x11-drivers/ati-userspace/files/const-notifier-block.patch
@@ -0,0 +1,25 @@
+diff -Nur common/lib/modules/fglrx/build_mod/kcl_acpi.c common-r1/lib/modules/fglrx/build_mod/kcl_acpi.c
+--- common/lib/modules/fglrx/build_mod/kcl_acpi.c 2013-01-29 17:03:51.000000000 +0200
++++ common-r1/lib/modules/fglrx/build_mod/kcl_acpi.c 2013-02-15 20:33:10.611838616 +0200
+@@ -15,6 +15,9 @@
+ ****************************************************************************/
+
+ #include <linux/version.h>
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,7,0)
++#include <linux/notifier.h>
++#endif
+ #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,33)
+ #include <generated/autoconf.h>
+ #else
+@@ -145,7 +148,11 @@
+ return NOTIFY_OK;
+ }
+
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,7,0)
++static notifier_block_no_const firegl_acpi_lid_notifier = {
++#else
+ static struct notifier_block firegl_acpi_lid_notifier = {
++#endif
+ .notifier_call = firegl_acpi_lid_event,
+ };
+ #endif
diff --git a/x11-drivers/ati-userspace/files/kernel/2.6.31-fglrx_find_task_by_vpid.patch b/x11-drivers/ati-userspace/files/kernel/2.6.31-fglrx_find_task_by_vpid.patch
new file mode 100644
index 00000000..1d4e030b
--- /dev/null
+++ b/x11-drivers/ati-userspace/files/kernel/2.6.31-fglrx_find_task_by_vpid.patch
@@ -0,0 +1,19 @@
+--- common/lib/modules/fglrx/build_mod/firegl_public.c.orig 2009-09-10 20:14:10.302938534 +0200
++++ common/lib/modules/fglrx/build_mod/firegl_public.c 2009-09-10 20:16:21.828943780 +0200
+@@ -183,6 +183,7 @@
+ #include <linux/string.h>
+ #include <linux/gfp.h>
+ #include <linux/swap.h>
++#include <linux/pid.h>
+
+ #include "firegl_public.h"
+ #include "kcl_osconfig.h"
+@@ -1315,7 +1316,7 @@
+ #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,26)
+ p = find_task_by_pid( pid );
+ #else
+- p = find_task_by_vpid( pid );
++ p = pid_task( pid, PIDTYPE_PID );
+ #endif
+ if (p)
+ {
diff --git a/x11-drivers/ati-userspace/files/kernel/2.6.32-9.11-fix_compilation.patch b/x11-drivers/ati-userspace/files/kernel/2.6.32-9.11-fix_compilation.patch
new file mode 100644
index 00000000..38519d76
--- /dev/null
+++ b/x11-drivers/ati-userspace/files/kernel/2.6.32-9.11-fix_compilation.patch
@@ -0,0 +1,37 @@
+--- work/common/lib/modules/fglrx/build_mod/firegl_public.c
++++ work.new/common/lib/modules/fglrx/build_mod/firegl_public.c
+@@ -1441,7 +1441,9 @@
+ todo !!!
+ #endif
+
+-unsigned long ATI_API_CALL __ke__cmpxchg(volatile void *ptr, unsigned long old,
++void __cmpxchg_wrong_size(void) {}
++
++unsigned long ATI_API_CALL __ke__cmpxchg(volatile unsigned long *ptr, unsigned long old,
+ unsigned long new, int size)
+ {
+ #ifndef __HAVE_ARCH_CMPXCHG
+--- work/common/lib/modules/fglrx/build_mod/firegl_public.h
++++ work.new/common/lib/modules/fglrx/build_mod/firegl_public.h
+@@ -441,7 +441,8 @@
+ extern void ATI_API_CALL KCL_SIGNAL_BlockAll(int (*notifier)(void *priv), void *pPriv, __ke_sigset_t *pSigMask);
+ extern void ATI_API_CALL KCL_SIGNAL_UnblockAll(void);
+
+-extern unsigned long ATI_API_CALL __ke__cmpxchg(volatile void *ptr, unsigned long old,
++extern void __cmpxchg_wrong_size(void);
++extern unsigned long ATI_API_CALL __ke__cmpxchg(volatile unsigned long *ptr, unsigned long old,
+ unsigned long new, int size);
+
+ #define __ke_cmpxchg(ptr,o,n) \
+--- work/common/lib/modules/fglrx/build_mod/kcl_io.c
++++ work.new/common/lib/modules/fglrx/build_mod/kcl_io.c
+@@ -37,8 +37,9 @@
+ */
+
+ #include <linux/version.h>
+ #include <linux/autoconf.h>
+ #include <linux/poll.h>
++#include <linux/signal.h>
+ #include <asm/io.h>
+
+ #include "kcl_config.h"
diff --git a/x11-drivers/ati-userspace/files/switchlibGL b/x11-drivers/ati-userspace/files/switchlibGL
new file mode 100644
index 00000000..a6aa4fce
--- /dev/null
+++ b/x11-drivers/ati-userspace/files/switchlibGL
@@ -0,0 +1,61 @@
+#!/bin/bash
+# switchlibGL
+#
+# Copyright (c) 2011 Advanced Micro Devices, Inc.
+#
+# Purpose:
+# For switch between AMD and Intel graphic driver library.
+#
+# Usage:
+# switchlibGL amd|intel|query
+# amd: switches to the AMD version of libGL.
+# intel: switches to the open-source version of libGL .
+# query: checks, which version is currently active and prints either "amd"
+# or "intel" or "unknown" on the standard output.
+# must be root to execute this script
+
+ARCH=`uname -m`
+E_ERR=1
+
+# Check if root
+if [ "`whoami`" != "root" ]; then
+ echo "Must be root to run this script." 1>&2
+ exit $E_ERR
+fi
+
+# One parameter
+if [ $# -ne 1 ]; then
+ echo "Usage: `basename $0` amd|intel|query " 1>&2
+ echo "Please choose one parameter " 1>&2
+ exit $E_ERR
+fi
+
+current=$(eselect opengl show)
+# Switch to right mode
+case "$1" in
+ "amd" )
+ if [ $current != ati ] ; then
+ eselect opengl set ati || return 1
+ fi
+ ;;
+ "intel" )
+ if [ $current != xorg-x11 ] ; then
+ eselect opengl set xorg-x11 || return 1
+ fi
+ ;;
+ "query" )
+ case "$current" in
+ "ati" )
+ echo "amd"
+ ;;
+ "xorg-x11" )
+ echo "intel"
+ ;;
+ esac
+ ;;
+ * ) echo "Usage: `basename $0` amd|intel|query" 1>&2; exit $E_ERR;;
+ # other than amd|intel|query parameter report an error
+esac
+
+# A zero return value from the script upon exit indicates success.
+exit 0