Gentoo Archives: gentoo-commits

From: Enrico Tagliavini <enrico.tagliavini@×××××.com>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/x11:master commit in: x11-drivers/ati-drivers/, x11-drivers/ati-drivers/files/
Date: Wed, 30 Mar 2011 09:51:33
Message-Id: 968cb8536aa08f020377845db7e00fbc4f2e8676.Enrico@gentoo
1 commit: 968cb8536aa08f020377845db7e00fbc4f2e8676
2 Author: Enrico Tagliavini <enrico.tagliavini <AT> gmail <DOT> com>
3 AuthorDate: Wed Mar 30 09:50:54 2011 +0000
4 Commit: Enrico Tagliavini <enrico.tagliavini <AT> gmail <DOT> com>
5 CommitDate: Wed Mar 30 09:50:54 2011 +0000
6 URL: http://git.overlays.gentoo.org/gitweb/?p=proj/x11.git;a=commit;h=968cb853
7
8 Create ati-drivers folder, and bump to version 11.3
9
10 ---
11 x11-drivers/ati-drivers/ati-drivers-11.3.ebuild | 574 ++++++++++++++++++++
12 .../ati-drivers/files/ati-drivers-2.6.38.patch | 60 ++
13 .../ati-drivers-fix_compilation-bug-297322.patch | 25 +
14 .../files/ati-powermode-opt-path-2.patch | 42 ++
15 x11-drivers/ati-drivers/files/atieventsd.init | 20 +
16 x11-drivers/ati-drivers/metadata.xml | 11 +
17 6 files changed, 732 insertions(+), 0 deletions(-)
18
19 diff --git a/x11-drivers/ati-drivers/ati-drivers-11.3.ebuild b/x11-drivers/ati-drivers/ati-drivers-11.3.ebuild
20 new file mode 100644
21 index 0000000..d2218ef
22 --- /dev/null
23 +++ b/x11-drivers/ati-drivers/ati-drivers-11.3.ebuild
24 @@ -0,0 +1,574 @@
25 +# Copyright 1999-2011 Gentoo Foundation
26 +# Distributed under the terms of the GNU General Public License v2
27 +# $Header: /var/cvsroot/gentoo-x86/x11-drivers/ati-drivers/ati-drivers-11.2.ebuild,v 1.5 2011/03/26 10:31:56 fauli Exp $
28 +
29 +EAPI="2"
30 +
31 +inherit eutils multilib linux-mod toolchain-funcs versionator
32 +
33 +DESCRIPTION="Ati precompiled drivers for r600 (HD Series) and newer chipsets"
34 +HOMEPAGE="http://www.ati.com"
35 +# 8.ble will be used for beta releases.
36 +if [[ $(get_major_version) -gt 8 ]]; then
37 + ATI_URL="https://a248.e.akamai.net/f/674/9206/0/www2.ati.com/drivers/linux/"
38 + SRC_URI="${ATI_URL}/ati-driver-installer-${PV/./-}-x86.x86_64.run"
39 + FOLDER_PREFIX="common/"
40 +else
41 + SRC_URI="https://launchpad.net/ubuntu/maverick/+source/fglrx-installer/2:${PV}-0ubuntu1/+files/fglrx-installer_${PV}.orig.tar.gz"
42 + FOLDER_PREFIX=""
43 +fi
44 +IUSE="debug +modules multilib qt4"
45 +
46 +LICENSE="AMD GPL-2 QPL-1.0 as-is"
47 +KEYWORDS="amd64 x86"
48 +SLOT="1"
49 +
50 +RDEPEND="
51 + <x11-base/xorg-server-1.9.99
52 + !x11-drivers/ati-drivers:0
53 + !x11-apps/ati-drivers-extra
54 + >=app-admin/eselect-opengl-1.0.7
55 + sys-power/acpid
56 + x11-apps/xauth
57 + x11-libs/libX11
58 + x11-libs/libXext
59 + x11-libs/libXinerama
60 + x11-libs/libXrandr
61 + x11-libs/libXrender
62 + multilib? ( app-emulation/emul-linux-x86-opengl )
63 + qt4? (
64 + x11-libs/libICE
65 + x11-libs/libSM
66 + x11-libs/libXcursor
67 + x11-libs/libXfixes
68 + x11-libs/libXxf86vm
69 + x11-libs/qt-core
70 + x11-libs/qt-gui
71 + )
72 +"
73 +
74 +DEPEND="${RDEPEND}
75 + app-portage/portage-utils
76 + x11-proto/inputproto
77 + x11-proto/xf86miscproto
78 + x11-proto/xf86vidmodeproto
79 + x11-proto/xineramaproto
80 + x11-libs/libXtst
81 +"
82 +
83 +EMULTILIB_PKG="true"
84 +
85 +S="${WORKDIR}"
86 +
87 +# QA Silencing
88 +QA_TEXTRELS="
89 + usr/lib*/opengl/ati/lib/libGL.so.1.2
90 + usr/lib*/libatiadlxx.so
91 + usr/lib*/xorg/modules/glesx.so
92 + usr/lib*/libaticaldd.so
93 + usr/lib*/dri/fglrx_dri.so
94 +"
95 +
96 +QA_EXECSTACK="
97 + opt/bin/atiode
98 + opt/bin/amdcccle
99 + usr/lib*/opengl/ati/lib/libGL.so.1.2
100 + usr/lib*/dri/fglrx_dri.so
101 +"
102 +
103 +QA_WX_LOAD="
104 + usr/lib*/opengl/ati/lib/libGL.so.1.2
105 + usr/lib*/dri/fglrx_dri.so
106 +"
107 +
108 +QA_PRESTRIPPED="
109 + usr/lib\(32\|64\)\?/libXvBAW.so.1.0
110 + usr/lib\(32\|64\)\?/opengl/ati/lib/libGL.so.1.2
111 + usr/lib\(32\|64\)\?/opengl/ati/extensions/libglx.so
112 + usr/lib\(32\|64\)\?/xorg/modules/glesx.so
113 + usr/lib\(32\|64\)\?/libAMDXvBA.so.1.0
114 + usr/lib\(32\|64\)\?/libaticaldd.so
115 + usr/lib\(32\|64\)\?/dri/fglrx_dri.so
116 +"
117 +
118 +QA_SONAME="
119 + usr/lib\(32\|64\)\?/libatiadlxx.so
120 + usr/lib\(32\|64\)\?/libaticalcl.so
121 + usr/lib\(32\|64\)\?/libaticaldd.so
122 + usr/lib\(32\|64\)\?/libaticalrt.so
123 +"
124 +
125 +QA_DT_HASH="
126 + opt/bin/amdcccle
127 + opt/bin/aticonfig
128 + opt/bin/atiodcli
129 + opt/bin/atiode
130 + opt/bin/fglrxinfo
131 + opt/sbin/atieventsd
132 + usr/lib\(32\|64\)\?/libaticalcl.so
133 + usr/lib\(32\|64\)\?/libaticalrt.so
134 + usr/lib\(32\|64\)\?/libatiuki.so.1.0
135 + usr/lib\(32\|64\)\?/libatiadlxx.so
136 + usr/lib\(32\|64\)\?/libfglrx_dm.so.1.0
137 + usr/lib\(32\|64\)\?/libXvBAW.so.1.0
138 + usr/lib\(32\|64\)\?/libAMDXvBA.so.1.0
139 + usr/lib\(32\|64\)\?/xorg/modules/amdxmm.so
140 + usr/lib\(32\|64\)\?/xorg/modules/glesx.so
141 + usr/lib\(32\|64\)\?/xorg/modules/linux/libfglrxdrm.so
142 + usr/lib\(32\|64\)\?/xorg/modules/drivers/fglrx_drv.so
143 + usr/lib\(32\|64\)\?/libaticaldd.so
144 + usr/lib\(32\|64\)\?/dri/fglrx_dri.so
145 + usr/lib\(32\|64\)\?/opengl/ati/extensions/libglx.so
146 + usr/lib\(32\|64\)\?/opengl/ati/lib/libGL.so.1.2
147 +"
148 +
149 +_check_kernel_config() {
150 + local failed=0
151 + local error=""
152 + if ! kernel_is 2 6; then
153 + eerror "You need a 2.6 linux kernel to compile against!"
154 + die "No 2.6 Kernel found"
155 + fi
156 +
157 + if ! linux_chkconfig_present MTRR; then
158 + ewarn "You don't have MTRR support enabled in the kernel."
159 + ewarn "Direct rendering will not work."
160 + fi
161 +
162 + if linux_chkconfig_builtin DRM; then
163 + ewarn "You have DRM support built in to the kernel"
164 + ewarn "Direct rendering will not work."
165 + fi
166 +
167 + if ! linux_chkconfig_present AGP && \
168 + ! linux_chkconfig_present PCIEPORTBUS; then
169 + ewarn "You don't have AGP and/or PCIe support enabled in the kernel"
170 + ewarn "Direct rendering will not work."
171 + fi
172 +
173 + if ! linux_chkconfig_present ACPI; then
174 + eerror "${P} requires the ACPI support in the kernel"
175 + eerror "Please enable it:"
176 + eerror " CONFIG_ACPI=y"
177 + eerror "in /usr/src/linux/.config or"
178 + eerror " Power management and ACPI options --->"
179 + eerror " [*] Power Management support"
180 + eerror "in the 'menuconfig'"
181 + error="${error} CONFIG_ACPI disabled"
182 + failed=1
183 + fi
184 +
185 + if ! linux_chkconfig_present MAGIC_SYSRQ; then
186 + eerror "${P} requires the magic SysRq keys in the kernel."
187 + eerror "Please enable it:"
188 + eerror " CONFIG_MAGIC_SYSRQ=y"
189 + eerror "in /usr/src/linux/.config or"
190 + eerror " Kernel hacking --->"
191 + eerror " [*] Magic SysRq key"
192 + eerror "in the 'menuconfig'"
193 + error="${error} CONFIG_MAGIC_SYSRQ disabled"
194 + failed=1
195 + fi
196 +
197 + if ! linux_chkconfig_present PCI_MSI; then
198 + eerror "${P} requires MSI in the kernel."
199 + eerror "Please enable it:"
200 + eerror " CONFIG_PCI_MSI=y"
201 + eerror "in /usr/src/linux/.config or"
202 + eerror " Bus options (PCI etc.) --->"
203 + eerror " [*] Message Signaled Interrupts (MSI and MSI-X)"
204 + eerror "in the kernel config."
205 + error="${error} CONFIG_PCI_MSI disabled"
206 + failed=1
207 + fi
208 +
209 + if linux_chkconfig_present LOCKDEP; then
210 + eerror "You've enabled LOCKDEP -- lock tracking -- in the kernel."
211 + eerror "Unfortunately, this option exports the symbol lock_acquire as GPL-only."
212 + eerror "This prevents ${P} from compiling with an error like this:"
213 + eerror "FATAL: modpost: GPL-incompatible module fglrx.ko uses GPL-only symbol 'lock_acquire'"
214 + eerror "Please make sure the following options have been unset:"
215 + eerror " Kernel hacking --->"
216 + eerror " [ ] Lock debugging: detect incorrect freeing of live locks"
217 + eerror " [ ] Lock debugging: prove locking correctness"
218 + eerror " [ ] Lock usage statistics"
219 + eerror "in 'menuconfig'"
220 + error="${error} LOCKDEP enabled"
221 + failed=1
222 + fi
223 +
224 + use amd64 && if ! linux_chkconfig_present COMPAT; then
225 + eerror "${P} requires COMPAT."
226 + eerror "Please enable the 32 bit emulation:"
227 + eerror "Executable file formats / Emulations --->"
228 + eerror " [*] IA32 Emulation"
229 + eerror "in the kernel config."
230 + eerror "if this doesn't enable CONFIG_COMPAT add"
231 + eerror " CONFIG_COMPAT=y"
232 + eerror "in /usr/src/linux/.config"
233 + error="${error} COMPAT disabled"
234 + failed=1
235 + fi
236 +
237 + kernel_is ge 2 6 37 && if ! linux_chkconfig_present BKL ; then
238 + eerror "${P} requires BKL."
239 + eerror "Please enable the Big Kernel Lock:"
240 + eerror "Kernel hacking --->"
241 + eerror " [*] Big Kernel Lock"
242 + eerror "in the kernel config."
243 + eerror "or add"
244 + eerror " CONFIG_BKL=y"
245 + eerror "in /usr/src/linux/.config"
246 + error="${error} BKL disabled"
247 + failed=1
248 + fi
249 +
250 + [ "x${failed}" != "x0" ] && die "${error}"
251 +}
252 +
253 +pkg_setup() {
254 + # Define module dir.
255 + MODULE_DIR="${S}/${FOLDER_PREFIX}/lib/modules/fglrx/build_mod"
256 + # get the xorg-server version and set BASE_DIR for that
257 + local ver_str=$(qatom `best_version x11-base/xorg-server` | cut -d ' ' -f 3)
258 + case ${ver_str} in
259 + 1\.9*) BASE_DIR="${S}/xpic" ;;
260 + 9999*) BASE_DIR="${S}/xpic"
261 + ewarn "Experimental xorg-server-${ver_str}"
262 + ewarn "Picking the last implementation" ;;
263 + 1\.8*|1\.7*) BASE_DIR="${S}/xpic" ;;
264 + *) die "xorg-server-${ver_str} not supported" ;;
265 + esac
266 +
267 + # amd64/x86
268 + if use amd64 ; then
269 + MY_BASE_DIR="${BASE_DIR}_64a"
270 + PKG_LIBDIR=lib64
271 + ARCH_DIR="${S}/arch/x86_64"
272 + else
273 + MY_BASE_DIR="${BASE_DIR}"
274 + PKG_LIBDIR=lib
275 + ARCH_DIR="${S}/arch/x86"
276 + fi
277 +
278 + if use modules; then
279 + MODULE_NAMES="fglrx(video:${S}/${FOLDER_PREFIX}/lib/modules/fglrx/build_mod/2.6.x)"
280 + BUILD_TARGETS="kmod_build"
281 + linux-mod_pkg_setup
282 + BUILD_PARAMS="GCC_VER_MAJ=$(gcc-major-version) KVER=${KV_FULL} KDIR=${KV_DIR}"
283 + BUILD_PARAMS="${BUILD_PARAMS} CFLAGS_MODULE+=\"-DMODULE -DATI -DFGL\""
284 + if grep -q arch_compat_alloc_user_space ${KV_DIR}/arch/x86/include/asm/compat.h ; then
285 + BUILD_PARAMS="${BUILD_PARAMS} CFLAGS_MODULE+=-DCOMPAT_ALLOC_USER_SPACE=arch_compat_alloc_user_space"
286 + else
287 + BUILD_PARAMS="${BUILD_PARAMS} CFLAGS_MODULE+=-DCOMPAT_ALLOC_USER_SPACE=compat_alloc_user_space"
288 + fi
289 + _check_kernel_config
290 + fi
291 +
292 + elog
293 + elog "Please note that this driver supports only graphic cards based on"
294 + elog "r600 chipset and newer."
295 + elog "This represent the ATI Radeon HD series at this moment."
296 + elog
297 + elog "If your card is older then usage of ${CATEGORY}/xf86-video-ati"
298 + elog "as replacement is highly recommended. Rather than staying with"
299 + elog "old versions of this driver."
300 + elog "For migration informations please reffer to:"
301 + elog "http://www.gentoo.org/proj/en/desktop/x/x11/ati-migration-guide.xml"
302 + einfo
303 +}
304 +
305 +src_unpack() {
306 + if [[ $(get_major_version) -gt 8 ]]; then
307 + # Switching to a standard way to extract the files since otherwise no signature file
308 + # would be created
309 + local src="${DISTDIR}/${A}"
310 + sh "${src}" --extract "${S}" 2&>1 /dev/null
311 + else
312 + unpack ${A}
313 + fi
314 +}
315 +
316 +src_prepare() {
317 + # All kernel options for prepare are ment to be in here
318 + if use modules; then
319 + # version patches
320 + # epatch "${FILESDIR}"/kernel/${PV}-*.patch
321 + if use debug; then
322 + sed -i '/^#define DRM_DEBUG_CODE/s/0/1/' \
323 + "${MODULE_DIR}/firegl_public.c" \
324 + || die "Failed to enable debug output."
325 + fi
326 + fi
327 +
328 + # Fix a known compilation error
329 + epatch "${FILESDIR}"/ati-drivers-fix_compilation-bug-297322.patch
330 +
331 + if kernel_is ge 2 6 38 ; then
332 + epatch "${FILESDIR}"/ati-drivers-2.6.38.patch || \
333 + die "epatch ati-drivers-2.6.38.patch failed"
334 + fi
335 +
336 + # These are the userspace utilities that we also have source for.
337 + # We rebuild these later.
338 + rm \
339 + "${ARCH_DIR}"/usr/X11R6/bin/fgl_glxgears \
340 + || die "bin rm failed"
341 +
342 + # in this version amdcccle isn't static, thus we depend on qt4
343 + use qt4 || rm "${ARCH_DIR}"/usr/X11R6/bin/amdcccle
344 +
345 + # ACPI fixups
346 + sed -i \
347 + -e "s:/var/lib/xdm/authdir/authfiles/:/var/run/xauth/:" \
348 + -e "s:/var/lib/gdm/:/var/gdm/:" \
349 + "${S}/${FOLDER_PREFIX}etc/ati/authatieventsd.sh" \
350 + || die "sed failed."
351 +
352 + # Since "who" is in coreutils, we're using that one instead of "finger".
353 + sed -i -e 's:finger:who:' \
354 + "${S}/${FOLDER_PREFIX}usr/share/doc/fglrx/examples/etc/acpi/ati-powermode.sh" \
355 + || die "Replacing 'finger' with 'who' failed."
356 + # Adjust paths in the script from /usr/X11R6/bin/ to /opt/bin/ and
357 + # add function to detect default state.
358 + epatch "${FILESDIR}"/ati-powermode-opt-path-2.patch || die "Failed to epatch powermode-opt-path-2.patch"
359 +
360 + cd "${MODULE_DIR}"
361 +
362 + # bugged fglrx build system, this file should be copied by hand
363 + cp ${ARCH_DIR}/lib/modules/fglrx/build_mod/libfglrx_ip.a 2.6.x
364 +
365 + convert_to_m 2.6.x/Makefile || die "convert_to_m failed"
366 +
367 + # When built with ati's make.sh it defines a bunch of macros if
368 + # certain .config values are set, falling back to less reliable
369 + # detection methods if linux/autoconf.h is not available. We
370 + # simply use the linux/autoconf.h settings directly, bypassing the
371 + # detection script.
372 + sed -i -e 's/__SMP__/CONFIG_SMP/' *.c *h || die "SMP sed failed"
373 + sed -i -e 's/ifdef MODVERSIONS/ifdef CONFIG_MODVERSIONS/' *.c *.h \
374 + || die "MODVERSIONS sed failed"
375 + cd "${S}"
376 +
377 + mkdir extra || die "mkdir failed"
378 + cd extra
379 + unpack ./../${FOLDER_PREFIX}usr/src/ati/fglrx_sample_source.tgz
380 +}
381 +
382 +src_compile() {
383 + use modules && linux-mod_src_compile
384 +
385 + ebegin "Building fgl_glxgears"
386 + cd "${S}"/extra/fgl_glxgears
387 + # These extra libs/utils either have an Imakefile that does not
388 + # work very well without tweaking or a Makefile ignoring CFLAGS
389 + # and the like. We bypass those.
390 +
391 + # The -DUSE_GLU is needed to compile using nvidia headers
392 + # according to a comment in ati-drivers-extra-8.33.6.ebuild.
393 + "$(tc-getCC)" -o fgl_glxgears ${CFLAGS} ${LDFLAGS} -DUSE_GLU \
394 + -I"${S}"/${FOLDER_PREFIX}usr/include fgl_glxgears.c \
395 + -lGL -lGLU -lX11 -lm || die "fgl_glxgears build failed"
396 + eend $?
397 +}
398 +
399 +src_install() {
400 + use modules && linux-mod_src_install
401 +
402 + # We can do two things here, and neither of them is very nice.
403 +
404 + # For direct rendering libGL has to be able to load one or more
405 + # dri modules (files ending in _dri.so, like fglrx_dri.so).
406 + # Gentoo's mesa looks for these files in the location specified by
407 + # LIBGL_DRIVERS_PATH or LIBGL_DRIVERS_DIR, then in the hardcoded
408 + # location /usr/$(get_libdir)/dri. Ati's libGL does the same
409 + # thing, but the hardcoded location is /usr/X11R6/lib/modules/dri
410 + # on x86 and amd64 32bit, /usr/X11R6/lib64/modules/dri on amd64
411 + # 64bit. So we can either put the .so files in that (unusual,
412 + # compared to "normal" mesa libGL) location or set
413 + # LIBGL_DRIVERS_PATH. We currently do the latter. See also bug
414 + # 101539.
415 +
416 + # The problem with this approach is that LIBGL_DRIVERS_PATH
417 + # *overrides* the default hardcoded location, it does not extend
418 + # it. So if ati-drivers is merged but a non-ati libGL is selected
419 + # and its hardcoded path does not match our LIBGL_DRIVERS_PATH
420 + # (because it changed in a newer mesa or because it was compiled
421 + # for a different set of multilib abis than we are) stuff breaks.
422 +
423 + # We create one file per ABI to work with "native" multilib, see
424 + # below.
425 +
426 + echo "COLON_SEPARATED=LIBGL_DRIVERS_PATH" > "${T}/03ati-colon-sep"
427 + doenvd "${T}/03ati-colon-sep" || die
428 +
429 + # All libraries that we have a 32 bit and 64 bit version of on
430 + # amd64 are installed in src_install-libs. Everything else
431 + # (including libraries only available in native 64bit on amd64)
432 + # goes in here.
433 +
434 + # There used to be some code here that tried to detect running
435 + # under a "native multilib" portage ((precursor of)
436 + # http://dev.gentoo.org/~kanaka/auto-multilib/). I removed that, it
437 + # should just work (only doing some duplicate work). --marienz
438 + if has_multilib_profile; then
439 + local OABI=${ABI}
440 + for ABI in $(get_install_abis); do
441 + src_install-libs
442 + done
443 + ABI=${OABI}
444 + unset OABI
445 + else
446 + src_install-libs
447 + fi
448 +
449 + # This is sorted by the order the files occur in the source tree.
450 +
451 + # X modules.
452 + exeinto /usr/$(get_libdir)/xorg/modules/drivers
453 + doexe "${MY_BASE_DIR}"/usr/X11R6/${PKG_LIBDIR}/modules/drivers/fglrx_drv.so || die
454 + exeinto /usr/$(get_libdir)/xorg/modules/linux
455 + doexe "${MY_BASE_DIR}"/usr/X11R6/${PKG_LIBDIR}/modules/linux/libfglrxdrm.so || die
456 + exeinto /usr/$(get_libdir)/xorg/modules
457 + doexe "${MY_BASE_DIR}"/usr/X11R6/${PKG_LIBDIR}/modules/{glesx.so,amdxmm.so} || die
458 +
459 + # Arch-specific files.
460 + # (s)bin.
461 + into /opt
462 + dosbin "${ARCH_DIR}"/usr/sbin/atieventsd || die
463 + # We cleaned out the compilable stuff in src_unpack
464 + dobin "${ARCH_DIR}"/usr/X11R6/bin/* || die
465 +
466 + # lib.
467 + exeinto /usr/$(get_libdir)
468 + # Everything except for the libGL.so installed in src_install-libs.
469 + doexe $(find "${ARCH_DIR}"/usr/X11R6/${PKG_LIBDIR} \
470 + -maxdepth 1 -type f -name '*.so*' -not -name 'libGL.so*')
471 + insinto /usr/$(get_libdir)
472 + doins $(find "${ARCH_DIR}"/usr/X11R6/${PKG_LIBDIR} \
473 + -maxdepth 1 -type f -not -name '*.so*')
474 +
475 + # Common files.
476 + # etc.
477 + insinto /etc/ati
478 + # Everything except for the authatieventsd.sh script.
479 + doins ${FOLDER_PREFIX}etc/ati/{logo*,control,atiogl.xml,signature,amdpcsdb.default}
480 + insopts -m0755
481 + doins ${FOLDER_PREFIX}etc/ati/authatieventsd.sh || die
482 +
483 + # include.
484 + insinto /usr
485 + doins -r ${FOLDER_PREFIX}usr/include || die
486 + insinto /usr/include/X11/extensions
487 +
488 + # Just the atigetsysteminfo.sh script.
489 + into /usr
490 + dosbin ${FOLDER_PREFIX}usr/sbin/* || die
491 +
492 + # data files for the control panel.
493 + if use qt4 ; then
494 + insinto /usr/share
495 + doins -r ${FOLDER_PREFIX}usr/share/ati || die
496 + insinto /usr/share/pixmaps
497 + doins ${FOLDER_PREFIX}usr/share/icons/ccc_large.xpm || die
498 + make_desktop_entry amdcccle 'ATI Catalyst Control Center' \
499 + ccc_large System
500 + fi
501 +
502 + # doc.
503 + dohtml -r ${FOLDER_PREFIX}usr/share/doc/fglrx || die
504 +
505 + doman ${FOLDER_PREFIX}usr/share/man/man8/atieventsd.8 || die
506 +
507 + pushd ${FOLDER_PREFIX}usr/share/doc/fglrx/examples/etc/acpi > /dev/null
508 +
509 + exeinto /etc/acpi
510 + doexe ati-powermode.sh || die
511 + insinto /etc/acpi/events
512 + doins events/* || die
513 +
514 + popd > /dev/null
515 +
516 + # Done with the "source" tree. Install tools we rebuilt:
517 + dobin extra/fgl_glxgears/fgl_glxgears || die
518 + newdoc extra/fgl_glxgears/README README.fgl_glxgears || die
519 +
520 + # Gentoo-specific stuff:
521 + newinitd "${FILESDIR}"/atieventsd.init atieventsd \
522 + || die "Failed to install atieventsd.init.d"
523 + echo 'ATIEVENTSDOPTS=""' > "${T}"/atieventsd.conf
524 + insopts -m0644
525 + newconfd "${T}"/atieventsd.conf atieventsd || die
526 +}
527 +
528 +src_install-libs() {
529 + if [[ "${ABI}" == "amd64" ]]; then
530 + local EX_BASE_DIR="${BASE_DIR}_64a"
531 + local pkglibdir=lib64
532 + local MY_ARCH_DIR="${S}/arch/x86_64"
533 + else
534 + local EX_BASE_DIR="${BASE_DIR}"
535 + local pkglibdir=lib
536 + local MY_ARCH_DIR="${S}/arch/x86"
537 + fi
538 + einfo "ati tree '${pkglibdir}' -> '$(get_libdir)' on system"
539 +
540 + local ATI_ROOT=/usr/$(get_libdir)/opengl/ati
541 + # To make sure we do not miss a spot when these change.
542 + local libmajor=1 libminor=2
543 + local libver=${libmajor}.${libminor}
544 +
545 + # The GLX libraries
546 + # (yes, this really is "lib" even on amd64/multilib --marienz)
547 + exeinto ${ATI_ROOT}/lib
548 + doexe "${MY_ARCH_DIR}"/usr/X11R6/${pkglibdir}/libGL.so.${libver} || die
549 + dosym libGL.so.${libver} ${ATI_ROOT}/lib/libGL.so.${libmajor} || die
550 + dosym libGL.so.${libver} ${ATI_ROOT}/lib/libGL.so || die
551 +
552 + exeinto ${ATI_ROOT}/extensions
553 + doexe "${EX_BASE_DIR}"/usr/X11R6/${pkglibdir}/modules/extensions/*.so || die
554 +
555 + # DRI modules, installed into the path used by recent versions of mesa.
556 + exeinto /usr/$(get_libdir)/dri
557 + doexe "${MY_ARCH_DIR}"/usr/X11R6/${pkglibdir}/modules/dri/fglrx_dri.so || die
558 +
559 + # AMD Cal libraries
560 + exeinto /usr/$(get_libdir)
561 + doexe "${MY_ARCH_DIR}"/usr/${pkglibdir}/libati*.so* || die
562 +
563 + local envname="${T}"/04ati-dri-path
564 + if [[ -n ${ABI} ]]; then
565 + envname="${envname}-${ABI}"
566 + fi
567 + echo "LIBGL_DRIVERS_PATH=/usr/$(get_libdir)/dri" > "${envname}"
568 + doenvd "${envname}" || die
569 +}
570 +
571 +pkg_postinst() {
572 + elog "To switch to ATI OpenGL, run \"eselect opengl set ati\""
573 + elog "To change your xorg.conf you can use the bundled \"aticonfig\""
574 + elog
575 + elog "If you experience unexplained segmentation faults and kernel crashes"
576 + elog "with this driver and multi-threaded applications such as wine,"
577 + elog "set UseFastTLS in xorg.conf to either 0 or 1, but not 2."
578 + elog
579 + elog "Fully rebooting the system after an ${PN} update is raccomended"
580 + elog "Stopping Xorg, reloading fglrx kernel module and restart Xorg"
581 + elog "might not work"
582 +
583 + use modules && linux-mod_pkg_postinst
584 + "${ROOT}"/usr/bin/eselect opengl set --use-old ati
585 +}
586 +
587 +pkg_preinst() {
588 + use modules && linux-mod_pkg_preinst
589 +}
590 +
591 +pkg_prerm() {
592 + "${ROOT}"/usr/bin/eselect opengl set --use-old xorg-x11
593 +}
594 +
595 +pkg_postrm() {
596 + use modules && linux-mod_pkg_postrm
597 + "${ROOT}"/usr/bin/eselect opengl set --use-old xorg-x11
598 +}
599
600 diff --git a/x11-drivers/ati-drivers/files/ati-drivers-2.6.38.patch b/x11-drivers/ati-drivers/files/ati-drivers-2.6.38.patch
601 new file mode 100644
602 index 0000000..0c3970e
603 --- /dev/null
604 +++ b/x11-drivers/ati-drivers/files/ati-drivers-2.6.38.patch
605 @@ -0,0 +1,60 @@
606 +--- cat11.1/common/lib/modules/fglrx/build_mod/firegl_public.c 2011-01-17 15:59:26.000000000 +0100
607 ++++ cat11.1/common/lib/modules/fglrx/build_mod/firegl_public.c 2011-02-01 18:39:08.902218444 +0100
608 +@@ -848,7 +848,12 @@
609 + * happen much less frequent then without this workaround.
610 + */
611 + if (state == PM_EVENT_SUSPEND)
612 +- acquire_console_sem();
613 ++
614 ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38)
615 ++ console_lock();
616 ++#else
617 ++ acquire_console_sem();
618 ++#endif
619 +
620 + if (firegl_cail_powerdown(privdev, state))
621 + ret = -EIO;
622 +@@ -870,8 +875,13 @@
623 + }
624 +
625 + if (state == PM_EVENT_SUSPEND)
626 +- release_console_sem();
627 +-
628 ++
629 ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38)
630 ++ console_unlock();
631 ++#else
632 ++ release_console_sem();
633 ++#endif
634 ++
635 + KCL_DEBUG_TRACEOUT(FN_FIREGL_ACPI, ret, NULL);
636 +
637 + return ret;
638 +@@ -894,7 +904,12 @@
639 + if (PMSG_EVENT(pdev->dev.power.power_state) == 0) return 0;
640 +
641 + if (PMSG_EVENT(pdev->dev.power.power_state) == PM_EVENT_SUSPEND)
642 +- acquire_console_sem();
643 ++
644 ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38)
645 ++ console_lock();
646 ++#else
647 ++ acquire_console_sem();
648 ++#endif
649 +
650 + #ifdef FIREGL_USWC_SUPPORT
651 + // Restore the PAT after resuming from S3 or S4.
652 +@@ -919,7 +934,12 @@
653 + firegl_cail_powerup(privdev);
654 +
655 + if (PMSG_EVENT(pdev->dev.power.power_state) == PM_EVENT_SUSPEND)
656 +- release_console_sem();
657 ++
658 ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38)
659 ++ console_unlock();
660 ++#else
661 ++ release_console_sem();
662 ++#endif
663 +
664 + PMSG_EVENT(pdev->dev.power.power_state) = 0;
665 + KCL_DEBUG_TRACEOUT(FN_FIREGL_ACPI, 0, NULL);
666
667 diff --git a/x11-drivers/ati-drivers/files/ati-drivers-fix_compilation-bug-297322.patch b/x11-drivers/ati-drivers/files/ati-drivers-fix_compilation-bug-297322.patch
668 new file mode 100644
669 index 0000000..e2af915
670 --- /dev/null
671 +++ b/x11-drivers/ati-drivers/files/ati-drivers-fix_compilation-bug-297322.patch
672 @@ -0,0 +1,25 @@
673 +--- common/lib/modules/fglrx/build_mod/firegl_public.c
674 ++++ common/lib/modules/fglrx/build_mod/firegl_public.c
675 +@@ -1441,7 +1441,9 @@
676 + todo !!!
677 + #endif
678 +
679 +-unsigned long ATI_API_CALL __ke__cmpxchg(volatile void *ptr, unsigned long old,
680 ++void __cmpxchg_wrong_size(void) {}
681 ++
682 ++unsigned long ATI_API_CALL __ke__cmpxchg(volatile unsigned long *ptr, unsigned long old,
683 + unsigned long new, int size)
684 + {
685 + #ifndef __HAVE_ARCH_CMPXCHG
686 +--- common/lib/modules/fglrx/build_mod/firegl_public.h
687 ++++ common/lib/modules/fglrx/build_mod/firegl_public.h
688 +@@ -441,7 +441,8 @@
689 + extern void ATI_API_CALL KCL_SIGNAL_BlockAll(int (*notifier)(void *priv), void *pPriv, __ke_sigset_t *pSigMask);
690 + extern void ATI_API_CALL KCL_SIGNAL_UnblockAll(void);
691 +
692 +-extern unsigned long ATI_API_CALL __ke__cmpxchg(volatile void *ptr, unsigned long old,
693 ++extern void __cmpxchg_wrong_size(void);
694 ++extern unsigned long ATI_API_CALL __ke__cmpxchg(volatile unsigned long *ptr, unsigned long old,
695 + unsigned long new, int size);
696 +
697 + #define __ke_cmpxchg(ptr,o,n) \
698
699 diff --git a/x11-drivers/ati-drivers/files/ati-powermode-opt-path-2.patch b/x11-drivers/ati-drivers/files/ati-powermode-opt-path-2.patch
700 new file mode 100644
701 index 0000000..f5a35a3
702 --- /dev/null
703 +++ b/x11-drivers/ati-drivers/files/ati-powermode-opt-path-2.patch
704 @@ -0,0 +1,42 @@
705 +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
706 +--- common.orig/usr/share/doc/fglrx/examples/etc/acpi/ati-powermode.sh 2006-07-28 04:22:36.000000000 +0100
707 ++++ common/usr/share/doc/fglrx/examples/etc/acpi/ati-powermode.sh 2006-08-04 12:19:42.000000000 +0100
708 +@@ -4,6 +4,8 @@
709 + # Control script for ACPI lid state and AC adapter state
710 + #
711 +
712 ++aticonfig='/opt/bin/aticonfig'
713 ++
714 + getXuser() {
715 + user=`finger| grep -m1 ":$displaynum " | awk '{print $1}'`
716 + if [ x"$user" = x"" ]; then
717 +@@ -47,7 +49,7 @@
718 + done
719 +
720 + #If PPLIB is enabled
721 +-su $user -c '/usr/bin/aticonfig --pplib-cmd="get version"' | grep PPLIB
722 ++su $user -c '$aticonfig --pplib-cmd="get version"' | grep PPLIB
723 + if [ $? = 0 ]; then
724 + echo "Has PPLIB"
725 + has_pplib=1
726 +@@ -61,15 +63,15 @@
727 + if [ ${lid_closed} -eq 1 -o ${on_dc} -eq 1 ]; then
728 + echo "Low power"
729 + if [ ${has_pplib} -eq 1 ]; then
730 +- su $user -c '/usr/bin/aticonfig --pplib-cmd="notify psrc dc"'
731 ++ su $user -c '$aticonfig --pplib-cmd="notify psrc dc"'
732 + else
733 +- su $user -c "/usr/bin/aticonfig --set-powerstate=1 --effective=now"
734 ++ su $user -c "$aticonfig --set-powerstate=1"
735 + fi
736 + else
737 + echo "high power"
738 + if [ ${has_pplib} -eq 1 ]; then
739 +- su $user -c '/usr/bin/aticonfig --pplib-cmd="notify psrc ac"'
740 ++ su $user -c '$aticonfig --pplib-cmd="notify psrc ac"'
741 + else
742 +- su $user -c "/usr/bin/aticonfig --set-powerstate=3 --effective=now"
743 ++ su $user -c "$aticonfig --set-powerstate=$($aticonfig --lsp | grep 'default state' | cut -c 3)"
744 + fi
745 + fi
746 +
747
748 diff --git a/x11-drivers/ati-drivers/files/atieventsd.init b/x11-drivers/ati-drivers/files/atieventsd.init
749 new file mode 100644
750 index 0000000..73139ce
751 --- /dev/null
752 +++ b/x11-drivers/ati-drivers/files/atieventsd.init
753 @@ -0,0 +1,20 @@
754 +#!/sbin/runscript
755 +# Copyright 1999-2006 Gentoo Foundation
756 +# Distributed under the terms of the GNU General Public License v2
757 +# $Header: /var/cvsroot/gentoo-x86/x11-drivers/ati-drivers/files/atieventsd.init,v 1.3 2007/05/18 23:58:01 marienz Exp $
758 +
759 +depend() {
760 + need acpid
761 +}
762 +
763 +start() {
764 + ebegin "Starting ${SVCNAME}"
765 + start-stop-daemon --start --exec /opt/sbin/atieventsd -- ${ATIEVENTSDOPTS}
766 + eend $?
767 +}
768 +
769 +stop() {
770 + ebegin "Stopping ${SVCNAME}"
771 + start-stop-daemon --stop --quiet --exec /opt/sbin/atieventsd
772 + eend $?
773 +}
774 \ No newline at end of file
775
776 diff --git a/x11-drivers/ati-drivers/metadata.xml b/x11-drivers/ati-drivers/metadata.xml
777 new file mode 100644
778 index 0000000..eee0c2c
779 --- /dev/null
780 +++ b/x11-drivers/ati-drivers/metadata.xml
781 @@ -0,0 +1,11 @@
782 +<?xml version="1.0" encoding="UTF-8"?>
783 +<!DOCTYPE pkgmetadata SYSTEM "http://www.gentoo.org/dtd/metadata.dtd">
784 +<pkgmetadata>
785 + <herd>x11</herd>
786 + <maintainer>
787 + <email>lu_zero@g.o</email>
788 + </maintainer>
789 + <use>
790 + <flag name='modules'>Build the kernel modules</flag>
791 + </use>
792 +</pkgmetadata>