Gentoo Archives: gentoo-commits

From: Jan Psota <jasiupsota@×××××.com>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/user/bleeding-edge:master commit in: x11-drivers/ati-drivers/files/, x11-drivers/ati-drivers/
Date: Sun, 29 Nov 2015 23:12:56
Message-Id: 1448837710.489e5fb07071045b3fc3d4314a1f0dfa25fa2a5f.jasiupsota@gentoo
1 commit: 489e5fb07071045b3fc3d4314a1f0dfa25fa2a5f
2 Author: layman <layman <AT> localhost>
3 AuthorDate: Sun Nov 29 22:55:10 2015 +0000
4 Commit: Jan Psota <jasiupsota <AT> gmail <DOT> com>
5 CommitDate: Sun Nov 29 22:55:10 2015 +0000
6 URL: https://gitweb.gentoo.org/repo/user/bleeding-edge.git/commit/?id=489e5fb0
7
8 x11-drivers/ati-drivers-15.11 from byg 566846 - thanks to Rion!
9
10 x11-drivers/ati-drivers/Manifest | 2 +
11 x11-drivers/ati-drivers/ati-drivers-15.11.ebuild | 636 +++++++++++++++++++++
12 .../files/15.11-remove-gpl-symbols.patch | 48 ++
13 x11-drivers/ati-drivers/files/15.9-kcl_str.patch | 14 +
14 x11-drivers/ati-drivers/files/15.9-mtrr.patch | 27 +
15 x11-drivers/ati-drivers/files/15.9-preempt.patch | 103 ++++
16 .../files/15.9-remove-gpl-symbols.patch | 74 +++
17 .../ati-drivers/files/15.9-sep_printf.patch | 11 +
18 ...ivers-12.9-KCL_AGP_FindCapsRegisters-stub.patch | 27 +
19 .../ati-drivers-13.8-beta-include-seq_file.patch | 13 +
20 .../ati-drivers-x32_something_something.patch | 13 +
21 .../files/ati-powermode-opt-path-3.patch | 40 ++
22 x11-drivers/ati-drivers/files/atieventsd.init | 20 +
23 x11-drivers/ati-drivers/files/atieventsd.service | 9 +
24 .../ati-drivers/files/const-notifier-block.patch | 25 +
25 .../files/fgl_glxgears-do-not-include-glATI.patch | 11 +
26 x11-drivers/ati-drivers/files/switchlibGL | 61 ++
27 17 files changed, 1134 insertions(+)
28
29 diff --git a/x11-drivers/ati-drivers/Manifest b/x11-drivers/ati-drivers/Manifest
30 new file mode 100644
31 index 0000000..edc7694
32 --- /dev/null
33 +++ b/x11-drivers/ati-drivers/Manifest
34 @@ -0,0 +1,2 @@
35 +DIST radeon-crimson-15.11-15.30.1025.zip 185334292 SHA256 5e3aeb28d2c25a4682a6ff8b9611c0c4a6b55c11e264515fa3963d58b8f10ba6 SHA512 12f81bf8c4dc96ff60830da6f84a585be033105a9bedd83672f8a3bddf906c4ead44239b0bf7ebf1da5c5b6e8f5516f2f1cdee8947173fbe8e527300f97d547b WHIRLPOOL c58dc438e5addf0bdae8b159b5afd1af18e6e547c7d81f436b5927fb69fd8d79449f31159bcd8ca75a2e95603bd3920fba12c053cd1a7bd6574bf99d2a2e99a9
36 +DIST xvba-sdk-0.74-404001.tar.gz 583847 SHA256 731a2c489f2fb5d7318c1976061b26c1057a696f46d09dcf55fbada97fed17eb SHA512 aa1dd52b59eeeabd026d8b76e3b75eaf02587ef286438ba28884afeef5a5efaf50283b5ee4f5b81b12cf79cb4ec77c9a235a886b29fb7cdf850c9779f4b07b35 WHIRLPOOL 69917b746d353a884512e97b9d9a9b89e6f51add3119e69ddd119d51c0c3f2820b93a449fe42bd76d671dc505f92bf25b7f2c5868b33768fc68a19596e460951
37
38 diff --git a/x11-drivers/ati-drivers/ati-drivers-15.11.ebuild b/x11-drivers/ati-drivers/ati-drivers-15.11.ebuild
39 new file mode 100644
40 index 0000000..17406f7
41 --- /dev/null
42 +++ b/x11-drivers/ati-drivers/ati-drivers-15.11.ebuild
43 @@ -0,0 +1,636 @@
44 +# Copyright 1999-2015 Gentoo Foundation
45 +# Distributed under the terms of the GNU General Public License v2
46 +# $Id$
47 +
48 +EAPI=5
49 +
50 +MULTILIB_COMPAT=( abi_x86_{32,64} )
51 +inherit eutils multilib-build linux-info linux-mod systemd toolchain-funcs versionator pax-utils
52 +
53 +DESCRIPTION="Ati precompiled drivers for Radeon Evergreen (HD5000 Series) and newer chipsets"
54 +HOMEPAGE="http://www.amd.com"
55 +BUILD_VER=15.30.1025
56 +RUN="${WORKDIR}/fglrx-${BUILD_VER}/amd-driver-installer-${BUILD_VER}-x86.x86_64.run"
57 +SLOT="1"
58 +# Uses javascript for download YESSSS
59 +#DRIVERS_URI="http://www2.ati.com/drivers/linux/amd-catalyst-13.12-linux-x86.x86_64.zip"
60 +#DRV_VER="amd-catalyst-${PV}-linux-installer-15.201.1151-x86.x86_64.zip"
61 +DRV_VER="radeon-crimson-${PV}-${BUILD_VER}.zip"
62 +DRIVERS_URI="mirror://gentoo/${DRV_VER}"
63 +SDK_VER="xvba-sdk-0.74-404001.tar.gz"
64 +XVBA_SDK_URI="http://developer.amd.com/wordpress/media/2012/10/${SDK_VER}"
65 +SRC_URI="${DRIVERS_URI} ${XVBA_SDK_URI}"
66 +FOLDER_PREFIX="common/"
67 +IUSE="debug +modules qt4 static-libs pax_kernel gdm-hack"
68 +
69 +LICENSE="AMD GPL-2 QPL-1.0"
70 +KEYWORDS="-* ~amd64 ~x86"
71 +
72 +RESTRICT="bindist test fetch"
73 +
74 +RDEPEND="
75 + <=x11-base/xorg-server-1.17.49[-minimal]
76 + >=app-eselect/eselect-opengl-1.0.7
77 + app-eselect/eselect-opencl
78 + sys-power/acpid
79 + x11-apps/xauth
80 + !x11-libs/xvba-video
81 + virtual/glu[${MULTILIB_USEDEP}]
82 + x11-libs/libX11[${MULTILIB_USEDEP}]
83 + x11-libs/libXext[${MULTILIB_USEDEP}]
84 + x11-libs/libXinerama[${MULTILIB_USEDEP}]
85 + x11-libs/libXrandr[${MULTILIB_USEDEP}]
86 + x11-libs/libXrender[${MULTILIB_USEDEP}]
87 + qt4? (
88 + x11-libs/libICE
89 + x11-libs/libSM
90 + x11-libs/libXcursor
91 + x11-libs/libXfixes
92 + x11-libs/libXxf86vm
93 + dev-qt/qtcore:4
94 + dev-qt/qtgui:4[accessibility]
95 + )
96 + gdm-hack? (
97 + x11-base/xorg-server:=
98 + )
99 +"
100 +if [[ legacy != ${SLOT} ]]; then
101 + RDEPEND="${RDEPEND}
102 + !x11-drivers/ati-drivers:legacy"
103 +else
104 + RDEPEND="${RDEPEND}
105 + !x11-drivers/ati-drivers:1"
106 +fi
107 +
108 +DEPEND="${RDEPEND}
109 + x11-proto/inputproto
110 + x11-proto/xf86miscproto
111 + x11-proto/xf86vidmodeproto
112 + x11-proto/xineramaproto
113 + x11-libs/libXtst
114 + sys-apps/findutils
115 + app-misc/pax-utils
116 + app-arch/unzip
117 +"
118 +
119 +EMULTILIB_PKG="true"
120 +
121 +S="${WORKDIR}"
122 +
123 +# QA Silencing
124 +QA_TEXTRELS="
125 + usr/lib*/opengl/ati/lib/libGL.so.1.2
126 + usr/lib*/libatiadlxx.so
127 + usr/lib*/xorg/modules/glesx.so
128 + usr/lib*/libaticaldd.so
129 + usr/lib*/dri/fglrx_dri.so
130 +"
131 +
132 +QA_EXECSTACK="
133 + opt/bin/atiode
134 + opt/bin/amdcccle
135 + usr/lib*/opengl/ati/lib/libGL.so.1.2
136 + usr/lib*/dri/fglrx_dri.so
137 +"
138 +
139 +QA_WX_LOAD="
140 + usr/lib*/opengl/ati/lib/libGL.so.1.2
141 + usr/lib*/dri/fglrx_dri.so
142 +"
143 +
144 +QA_PRESTRIPPED="
145 + usr/lib\(32\|64\)\?/libXvBAW.so.1.0
146 + usr/lib\(32\|64\)\?/opengl/ati/lib/libGL.so.1.2
147 + usr/lib\(32\|64\)\?/opengl/ati/extensions/libglx.so
148 + usr/lib\(32\|64\)\?/xorg/modules/glesx.so
149 + usr/lib\(32\|64\)\?/libAMDXvBA.so.1.0
150 + usr/lib\(32\|64\)\?/libaticaldd.so
151 + usr/lib\(32\|64\)\?/dri/fglrx_dri.so
152 + usr/lib\(32\|64\)\?/OpenCL/vendors/amd/libOpenCL.so.1
153 + usr/lib\(32\|64\)\?/OpenCL/vendors/amd/libamdocl\(32\|64\).so
154 +"
155 +
156 +QA_SONAME="
157 + usr/lib\(32\|64\)\?/libatiadlxx.so
158 + usr/lib\(32\|64\)\?/libaticalcl.so
159 + usr/lib\(32\|64\)\?/libaticaldd.so
160 + usr/lib\(32\|64\)\?/libaticalrt.so
161 + usr/lib\(32\|64\)\?/libamdocl\(32\|64\)\?.so
162 + usr/lib\(32\|64\)\?/libamdhsasc\(32\|64\)\?.so
163 +"
164 +
165 +QA_DT_HASH="
166 + opt/bin/amdcccle
167 + opt/bin/aticonfig
168 + opt/bin/atiodcli
169 + opt/bin/atiode
170 + opt/bin/clinfo
171 + opt/bin/fglrxinfo
172 + opt/sbin/atieventsd
173 + opt/sbin/amdnotifyui
174 + usr/lib\(32\|64\)\?/libaticalcl.so
175 + usr/lib\(32\|64\)\?/libaticalrt.so
176 + usr/lib\(32\|64\)\?/libatiuki.so.1.0
177 + usr/lib\(32\|64\)\?/libatiadlxx.so
178 + usr/lib\(32\|64\)\?/libfglrx_dm.so.1.0
179 + usr/lib\(32\|64\)\?/libXvBAW.so.1.0
180 + usr/lib\(32\|64\)\?/libAMDXvBA.so.1.0
181 + usr/lib\(32\|64\)\?/xorg/modules/amdxmm.so
182 + usr/lib\(32\|64\)\?/xorg/modules/glesx.so
183 + usr/lib\(32\|64\)\?/xorg/modules/linux/libfglrxdrm.so
184 + usr/lib\(32\|64\)\?/xorg/modules/drivers/fglrx_drv.so
185 + usr/lib\(32\|64\)\?/libaticaldd.so
186 + usr/lib\(32\|64\)\?/dri/fglrx_dri.so
187 + usr/lib\(32\|64\)\?/opengl/ati/extensions/libglx.so
188 + usr/lib\(32\|64\)\?/opengl/ati/extensions/fglrx-libglx.so
189 + usr/lib\(32\|64\)\?/opengl/ati/lib/fglrx-libGL.so.1.2
190 + usr/lib\(32\|64\)\?/opengl/ati/lib/libGL.so.1.2
191 + usr/lib\(32\|64\)\?/OpenCL/vendors/amd/libamdocl\(32\|64\)\?.so
192 + usr/lib\(32\|64\)\?/OpenCL/vendors/amd/libOpenCL.so.1
193 +"
194 +
195 +pkg_nofetch() {
196 + einfo "The driver packages"
197 + einfo ${A}
198 + einfo "need to be downloaded manually from"
199 + einfo "http://support.amd.com/en-us/download/desktop?os=Linux+x86"
200 + einfo "and ${XVBA_SDK_URI}"
201 +}
202 +
203 +pkg_pretend() {
204 + local CONFIG_CHECK="~MTRR ~!DRM ACPI PCI_MSI \
205 + !LOCKDEP !PAX_KERNEXEC_PLUGIN_METHOD_OR"
206 + use amd64 && CONFIG_CHECK+=" COMPAT"
207 +
208 + local ERROR_MTRR="CONFIG_MTRR required for direct rendering."
209 + local ERROR_DRM="CONFIG_DRM must be disabled or compiled as a
210 + module and not loaded for direct rendering to work."
211 + local ERROR_LOCKDEP="CONFIG_LOCKDEP (lock tracking) exports
212 + the symbol lock_acquire as GPL-only. This prevents ${P} from
213 + compiling with an error like this:
214 + FATAL: modpost: GPL-incompatible module fglrx.ko uses GPL-only symbol 'lock_acquire'"
215 + local ERROR_PAX_KERNEXEC_PLUGIN_METHOD_OR="This config option will cause
216 + kernel to reject loading the fglrx module with
217 + \"ERROR: could not insert 'fglrx': Exec format error.\"
218 + You may want to try CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_BTS instead."
219 + local ERROR_BKL="CONFIG_BKL must be enabled for kernels 2.6.37-2.6.38."
220 +
221 + # workaround until bug 365543 is solved
222 + if use modules; then
223 + linux-info_pkg_setup
224 + require_configured_kernel
225 + kernel_is ge 2 6 37 && kernel_is le 2 6 38 && CONFIG_CHECK+=" BKL"
226 + check_extra_config
227 + if ! linux_chkconfig_present AGP && \
228 + ! linux_chkconfig_present PCIEPORTBUS; then
229 + ewarn "You don't have AGP and/or PCIe support enabled in the kernel"
230 + ewarn "Direct rendering will not work."
231 + fi
232 + fi
233 +
234 + if ! has XT ${PAX_MARKINGS} && use pax_kernel; then
235 + ewarn "You have disabled xattr pax markings for portage."
236 + ewarn "This will likely cause programs using ati-drivers provided"
237 + ewarn "libraries to be killed kernel."
238 + fi
239 +}
240 +
241 +pkg_setup() {
242 + if use modules; then
243 + MODULE_PATH="${S}/${FOLDER_PREFIX}/lib/modules/fglrx/build_mod/2.6.x"
244 + MODULE_NAMES="fglrx(video:${MODULE_PATH})"
245 + BUILD_TARGETS="kmod_build"
246 + linux-mod_pkg_setup
247 + BUILD_PARAMS="GCC_VER_MAJ=$(gcc-major-version) KVER=${KV_FULL} KDIR=${KV_OUT_DIR}"
248 + BUILD_PARAMS="${BUILD_PARAMS} CFLAGS_MODULE+=\"-DMODULE -DATI -DFGL\""
249 + if grep -q arch_compat_alloc_user_space ${KV_DIR}/arch/x86/include/asm/compat.h ; then
250 + BUILD_PARAMS="${BUILD_PARAMS} \
251 + CFLAGS_MODULE+=-DCOMPAT_ALLOC_USER_SPACE=arch_compat_alloc_user_space"
252 + else
253 + BUILD_PARAMS="${BUILD_PARAMS} \
254 + CFLAGS_MODULE+=-DCOMPAT_ALLOC_USER_SPACE=compat_alloc_user_space"
255 + fi
256 + fi
257 + # Define module dir.
258 + MODULE_DIR="${S}/${FOLDER_PREFIX}/lib/modules/fglrx/build_mod"
259 + # get the xorg-server version and set BASE_DIR for that
260 + BASE_DIR="${S}/xpic"
261 +
262 + # amd64/x86
263 + if use amd64 ; then
264 + MY_BASE_DIR="${BASE_DIR}_64a"
265 + PKG_LIBDIR=lib64
266 + ARCH_DIR="${S}/arch/x86_64"
267 + else
268 + MY_BASE_DIR="${BASE_DIR}"
269 + PKG_LIBDIR=lib
270 + ARCH_DIR="${S}/arch/x86"
271 + fi
272 +
273 + elog
274 + elog "Please note that this driver only supports graphic cards based on"
275 + elog "Evergreen chipset and newer."
276 + elog "This includes the AMD Radeon HD 5400+ series at this moment."
277 + elog
278 + elog "If your card is older then use ${CATEGORY}/xf86-video-ati"
279 + elog "For migration informations please refer to:"
280 + elog "https://www.gentoo.org/proj/en/desktop/x/x11/ati-migration-guide.xml"
281 + einfo
282 +}
283 +
284 +src_unpack() {
285 + local DRIVERS_DISTFILE XVBA_SDK_DISTFILE
286 + DRIVERS_DISTFILE=${DRIVERS_URI##*/}
287 + XVBA_SDK_DISTFILE=${XVBA_SDK_URI##*/}
288 +
289 + if [[ ${DRIVERS_DISTFILE} =~ .*\.tar\.gz ]]; then
290 + unpack ${DRIVERS_DISTFILE}
291 + mkdir -p common
292 + mv etc lib usr common || die "Assumed to find etc lib and usr for common"
293 + else
294 + #please note, RUN may be insanely assigned at top near SRC_URI
295 + if [[ ${DRIVERS_DISTFILE} =~ .*\.zip ]]; then
296 + unpack ${DRIVERS_DISTFILE}
297 + [[ -z "$RUN" ]] && RUN="${S}/${DRIVERS_DISTFILE/%.zip/.run}"
298 + else
299 + RUN="${DISTDIR}/${DRIVERS_DISTFILE}"
300 + fi
301 + sh "${RUN}" --extract "${S}" 2>&1 > /dev/null || die
302 + fi
303 +
304 + mkdir xvba_sdk
305 + cd xvba_sdk
306 + unpack ${XVBA_SDK_DISTFILE}
307 +
308 + mkdir -p "${WORKDIR}/extra" || die "mkdir extra failed"
309 + cd "${WORKDIR}/extra"
310 + tar -xf "../${FOLDER_PREFIX}usr/src/ati/fglrx_sample_source.tgz"
311 +}
312 +
313 +src_prepare() {
314 + if use modules; then
315 + if use debug; then
316 + sed -i '/^#define DRM_DEBUG_CODE/s/0/1/' \
317 + "${MODULE_DIR}/firegl_public.c" \
318 + || die "Failed to enable debug output."
319 + fi
320 + fi
321 +
322 + # These are the userspace utilities that we also have source for.
323 + # We rebuild these later.
324 + rm \
325 + "${ARCH_DIR}"/usr/X11R6/bin/fgl_glxgears \
326 + || die "bin rm failed"
327 +
328 + # in this version amdcccle isn't static, thus we depend on qt4
329 + use qt4 || rm "${ARCH_DIR}"/usr/X11R6/bin/amdcccle
330 +
331 + # ACPI fixups
332 + sed -i \
333 + -e "s:/var/lib/xdm/authdir/authfiles/:/var/run/xauth/:" \
334 + -e "s:/var/lib/gdm/:/var/gdm/:" \
335 + "${S}/${FOLDER_PREFIX}etc/ati/authatieventsd.sh" \
336 + || die "ACPI fixups failed."
337 +
338 + # Since "who" is in coreutils, we're using that one instead of "finger".
339 + sed -i -e 's:finger:who:' \
340 + "${S}/${FOLDER_PREFIX}usr/share/doc/fglrx/examples/etc/acpi/ati-powermode.sh" \
341 + || die "Replacing 'finger' with 'who' failed."
342 + # Adjust paths in the script from /usr/X11R6/bin/ to /opt/bin/ and
343 + # add function to detect default state.
344 + epatch "${FILESDIR}"/ati-powermode-opt-path-3.patch
345 +
346 + # see http://ati.cchtml.com/show_bug.cgi?id=495
347 + #epatch "${FILESDIR}"/ati-drivers-old_rsp.patch
348 + # first hunk applied upstream second (x32 related) was not
349 + epatch "${FILESDIR}"/ati-drivers-x32_something_something.patch
350 +
351 + # compile fix for AGP-less kernel, bug #435322
352 + epatch "${FILESDIR}"/ati-drivers-12.9-KCL_AGP_FindCapsRegisters-stub.patch
353 +
354 + epatch "${FILESDIR}/ati-drivers-13.8-beta-include-seq_file.patch"
355 +
356 + # Fix #483400
357 + epatch "${FILESDIR}/fgl_glxgears-do-not-include-glATI.patch"
358 +
359 + # Compile fix, https://bugs.gentoo.org/show_bug.cgi?id=454870
360 + use pax_kernel && epatch "${FILESDIR}/const-notifier-block.patch"
361 +
362 + # Compile fix, #526602
363 + # epatch "${FILESDIR}/use-kernel_fpu_begin.patch"
364 +
365 + # Fix #542320
366 + epatch "${FILESDIR}/15.9-preempt.patch"
367 +
368 + # Compile fixes, #548118
369 + epatch "${FILESDIR}/15.11-remove-gpl-symbols.patch"
370 + epatch "${FILESDIR}/15.9-kcl_str.patch"
371 + epatch "${FILESDIR}/15.9-sep_printf.patch"
372 + epatch "${FILESDIR}/15.9-mtrr.patch"
373 +
374 + epatch_user
375 +
376 + cd "${MODULE_DIR}"
377 +
378 + # bugged fglrx build system, this file should be copied by hand
379 + cp ${ARCH_DIR}/lib/modules/fglrx/build_mod/libfglrx_ip.a 2.6.x
380 +
381 + convert_to_m 2.6.x/Makefile || die "convert_to_m failed"
382 +
383 + # When built with ati's make.sh it defines a bunch of macros if
384 + # certain .config values are set, falling back to less reliable
385 + # detection methods if linux/autoconf.h is not available. We
386 + # simply use the linux/autoconf.h settings directly, bypassing the
387 + # detection script.
388 + sed -i -e 's/__SMP__/CONFIG_SMP/' *.c *h || die "SMP sed failed"
389 + sed -i -e 's/ifdef MODVERSIONS/ifdef CONFIG_MODVERSIONS/' *.c *.h \
390 + || die "MODVERSIONS sed failed"
391 +}
392 +
393 +src_compile() {
394 + use modules && linux-mod_src_compile
395 +
396 + ebegin "Building fgl_glxgears"
397 + cd "${S}"/extra/fgl_glxgears
398 + # These extra libs/utils either have an Imakefile that does not
399 + # work very well without tweaking or a Makefile ignoring CFLAGS
400 + # and the like. We bypass those.
401 + # The -DUSE_GLU is needed to compile using nvidia headers
402 + # according to a comment in ati-drivers-extra-8.33.6.ebuild.
403 + "$(tc-getCC)" -o fgl_glxgears ${CFLAGS} ${LDFLAGS} -DUSE_GLU \
404 + -I"${S}"/${FOLDER_PREFIX}usr/include fgl_glxgears.c \
405 + -lGL -lGLU -lX11 -lm || die "fgl_glxgears build failed"
406 + eend $?
407 +}
408 +
409 +src_install() {
410 + use modules && linux-mod_src_install
411 +
412 + # We can do two things here, and neither of them is very nice.
413 +
414 + # For direct rendering libGL has to be able to load one or more
415 + # dri modules (files ending in _dri.so, like fglrx_dri.so).
416 + # Gentoo's mesa looks for these files in the location specified by
417 + # LIBGL_DRIVERS_PATH or LIBGL_DRIVERS_DIR, then in the hardcoded
418 + # location /usr/$(get_libdir)/dri. Ati's libGL does the same
419 + # thing, but the hardcoded location is /usr/X11R6/lib/modules/dri
420 + # on x86 and amd64 32bit, /usr/X11R6/lib64/modules/dri on amd64
421 + # 64bit. So we can either put the .so files in that (unusual,
422 + # compared to "normal" mesa libGL) location or set
423 + # LIBGL_DRIVERS_PATH. We currently do the latter. See also bug
424 + # 101539.
425 +
426 + # The problem with this approach is that LIBGL_DRIVERS_PATH
427 + # *overrides* the default hardcoded location, it does not extend
428 + # it. So if ati-drivers is merged but a non-ati libGL is selected
429 + # and its hardcoded path does not match our LIBGL_DRIVERS_PATH
430 + # (because it changed in a newer mesa or because it was compiled
431 + # for a different set of multilib abis than we are) stuff breaks.
432 +
433 + # We create one file per ABI to work with "native" multilib, see
434 + # below.
435 +
436 + echo "COLON_SEPARATED=LIBGL_DRIVERS_PATH" > "${T}/03ati-colon-sep"
437 + doenvd "${T}/03ati-colon-sep" || die
438 +
439 + # All libraries that we have a 32 bit and 64 bit version of on
440 + # amd64 are installed in src_install-libs. Everything else
441 + # (including libraries only available in native 64bit on amd64)
442 + # goes in here.
443 + multilib_foreach_abi src_install-libs
444 +
445 + # This is sorted by the order the files occur in the source tree.
446 +
447 + # X modules.
448 + exeinto /usr/$(get_libdir)/xorg/modules/drivers
449 + doexe "${MY_BASE_DIR}"/usr/X11R6/${PKG_LIBDIR}/modules/drivers/fglrx_drv.so
450 + exeinto /usr/$(get_libdir)/xorg/modules/linux
451 + doexe "${MY_BASE_DIR}"/usr/X11R6/${PKG_LIBDIR}/modules/linux/libfglrxdrm.so
452 + exeinto /usr/$(get_libdir)/xorg/modules
453 + doexe "${MY_BASE_DIR}"/usr/X11R6/${PKG_LIBDIR}/modules/{glesx.so,amdxmm.so}
454 +
455 + #516816
456 + if use gdm-hack; then
457 + sed -i 's#/proc/%i/fd/0#/etc/ati/xvrn#g' \
458 + "${D}/usr/$(get_libdir)/xorg/modules/drivers/fglrx_drv.so" || \
459 + die "Applying gdm-hack failed"
460 + fi
461 +
462 + # Arch-specific files.
463 + # (s)bin.
464 + into /opt
465 + dosbin "${ARCH_DIR}"/usr/sbin/atieventsd
466 + use qt4 && dosbin "${ARCH_DIR}"/usr/sbin/amdnotifyui
467 + dobin "${ARCH_DIR}"/usr/bin/clinfo
468 + # We cleaned out the compilable stuff in src_unpack
469 + dobin "${ARCH_DIR}"/usr/X11R6/bin/*
470 +
471 + # Common files.
472 + # etc.
473 + insinto /etc/ati
474 + exeinto /etc/ati
475 + # Everything except for the authatieventsd.sh script.
476 + doins ${FOLDER_PREFIX}etc/ati/{logo*,control,signature,amdpcsdb.default}
477 + doexe ${FOLDER_PREFIX}etc/ati/authatieventsd.sh
478 +
479 + # include.
480 + insinto /usr
481 + doins -r ${FOLDER_PREFIX}usr/include
482 + insinto /usr/include/X11/extensions
483 +
484 + # Just the atigetsysteminfo.sh script.
485 + into /usr
486 + dosbin ${FOLDER_PREFIX}usr/sbin/*
487 +
488 + # data files for the control panel.
489 + if use qt4 ; then
490 + insinto /usr/share
491 + doins -r ${FOLDER_PREFIX}usr/share/ati
492 + insinto /usr/share/pixmaps
493 + doins ${FOLDER_PREFIX}usr/share/icons/ccc_large.xpm
494 + make_desktop_entry amdcccle 'AMD Catalyst Control Center' \
495 + ccc_large System
496 + fi
497 +
498 + # doc.
499 + dohtml -r ${FOLDER_PREFIX}usr/share/doc/fglrx
500 +
501 + doman ${FOLDER_PREFIX}usr/share/man/man8/atieventsd.8
502 +
503 + pushd ${FOLDER_PREFIX}usr/share/doc/fglrx/examples/etc/acpi > /dev/null
504 +
505 + exeinto /etc/acpi
506 + doexe ati-powermode.sh
507 + insinto /etc/acpi/events
508 + doins events/*
509 +
510 + popd > /dev/null
511 +
512 + # Done with the "source" tree. Install tools we rebuilt:
513 + dobin extra/fgl_glxgears/fgl_glxgears
514 + newdoc extra/fgl_glxgears/README README.fgl_glxgears
515 +
516 + # Gentoo-specific stuff:
517 + newinitd "${FILESDIR}"/atieventsd.init atieventsd
518 + echo 'ATIEVENTSDOPTS=""' > "${T}"/atieventsd.conf
519 + newconfd "${T}"/atieventsd.conf atieventsd
520 + systemd_dounit "${FILESDIR}/atieventsd.service"
521 +
522 + # PowerXpress stuff
523 + exeinto /usr/$(get_libdir)/fglrx
524 + doexe "${FILESDIR}"/switchlibGL || die "doexe switchlibGL failed"
525 + cp "${FILESDIR}"/switchlibGL "${T}"/switchlibglx
526 + doexe "${T}"/switchlibglx || die "doexe switchlibglx failed"
527 +
528 + #516816
529 + use gdm-hack && Xorg -version > "${D}/etc/ati/xvrn" 2>&1
530 +}
531 +
532 +src_install-libs() {
533 + if [[ "${ABI}" == "amd64" ]]; then
534 + local EX_BASE_DIR="${BASE_DIR}_64a"
535 + local pkglibdir=lib64
536 + local MY_ARCH_DIR="${S}/arch/x86_64"
537 + local oclsuffix=64
538 + else
539 + local EX_BASE_DIR="${BASE_DIR}"
540 + local pkglibdir=lib
541 + local MY_ARCH_DIR="${S}/arch/x86"
542 + local oclsuffix=32
543 + fi
544 + einfo "ati tree '${pkglibdir}' -> '$(get_libdir)' on system"
545 +
546 + local ATI_ROOT=/usr/$(get_libdir)/opengl/ati
547 + # To make sure we do not miss a spot when these change.
548 + local libmajor=1 libminor=2
549 + local libver=${libmajor}.${libminor}
550 +
551 + # The GLX libraries
552 + # (yes, this really is "lib" even on amd64/multilib --marienz)
553 + exeinto ${ATI_ROOT}/lib
554 + newexe "${MY_ARCH_DIR}"/usr/X11R6/${pkglibdir}/fglrx/fglrx-libGL.so.${libver} \
555 + libGL.so.${libver}
556 + dosym libGL.so.${libver} ${ATI_ROOT}/lib/libGL.so.${libmajor}
557 + dosym libGL.so.${libver} ${ATI_ROOT}/lib/libGL.so
558 +
559 + if multilib_is_native_abi; then
560 + exeinto ${ATI_ROOT}/extensions
561 + doexe "${EX_BASE_DIR}"/usr/X11R6/${pkglibdir}/modules/extensions/fglrx/fglrx-libglx.so
562 + mv "${D}"/${ATI_ROOT}/extensions/{fglrx-,}libglx.so
563 +
564 + #516816
565 + if use gdm-hack; then
566 + sed -i 's#/proc/%i/fd/0#/etc/ati/xvrn#g' \
567 + "${D}/${ATI_ROOT}/extensions/libglx.so" \
568 + || die "Applying gdm-hack failed"
569 + fi
570 + fi
571 +
572 + # other libs
573 + exeinto /usr/$(get_libdir)
574 + # Everything except for the libGL.so installed some row above
575 + doexe $(find "${MY_ARCH_DIR}"/usr/X11R6/${pkglibdir} \
576 + -maxdepth 1 -type f -name '*.so*' -not -name '*libGL.so*')
577 + insinto /usr/$(get_libdir)
578 + doins $(find "${MY_ARCH_DIR}"/usr/X11R6/${pkglibdir} \
579 + -maxdepth 1 -type f -not -name '*.so*')
580 +
581 + # DRI modules, installed into the path used by recent versions of mesa.
582 + exeinto /usr/$(get_libdir)/dri
583 + doexe "${MY_ARCH_DIR}"/usr/X11R6/${pkglibdir}/modules/dri/fglrx_dri.so
584 +
585 + # AMD Cal and OpenCL libraries
586 + exeinto /usr/$(get_libdir)/OpenCL/vendors/amd
587 + doexe "${MY_ARCH_DIR}"/usr/${pkglibdir}/libamdocl*.so*
588 + doexe "${MY_ARCH_DIR}"/usr/${pkglibdir}/libOpenCL*.so*
589 + dosym libOpenCL.so.${libmajor} /usr/$(get_libdir)/OpenCL/vendors/amd/libOpenCL.so
590 + exeinto /usr/$(get_libdir)
591 + doexe "${MY_ARCH_DIR}"/usr/${pkglibdir}/libati*.so*
592 +
593 + # OpenCL vendor files
594 + insinto /etc/OpenCL/vendors/
595 + cat > "${T}"/amdocl${oclsuffix}.icd <<-EOF
596 + /usr/$(get_libdir)/OpenCL/vendors/amd/libamdocl${oclsuffix}.so
597 + EOF
598 + doins "${T}"/amdocl${oclsuffix}.icd
599 +
600 + local envname="${T}"/04ati-dri-path
601 + if [[ -n ${ABI} ]]; then
602 + envname="${envname}-${ABI}"
603 + fi
604 + echo "LIBGL_DRIVERS_PATH=/usr/$(get_libdir)/dri" > "${envname}"
605 + doenvd "${envname}"
606 +
607 + # Silence the QA notice by creating missing soname symlinks
608 + for so in $(find "${D}"/usr/$(get_libdir) -maxdepth 1 -name *.so.[0-9].[0-9])
609 + do
610 + local soname=${so##*/}
611 + local soname_one=${soname%.[0-9]}
612 + local soname_zero=${soname_one%.[0-9]}
613 + dosym ${soname} /usr/$(get_libdir)/${soname_one}
614 + dosym ${soname_one} /usr/$(get_libdir)/${soname_zero}
615 + done
616 +
617 + # See https://bugs.gentoo.org/show_bug.cgi?id=443466
618 + dodir /etc/revdep-rebuild/
619 + echo "SEARCH_DIRS_MASK=\"/opt/bin/clinfo\"" > "${ED}/etc/revdep-rebuild/62-ati-drivers"
620 +
621 + #remove static libs if not wanted
622 + use static-libs || rm -rf "${D}"/usr/$(get_libdir)/libfglrx_dm.a
623 +
624 + #install xvba sdk headers
625 + doheader xvba_sdk/include/amdxvba.h
626 +
627 + # VA-API internal wrapper
628 + dosym /usr/$(get_libdir)/libXvBAW.so.1.0 /usr/$(get_libdir)/va/drivers/fglrx_drv_video.so
629 +
630 + if use pax_kernel; then
631 + pax-mark m "${D}"/usr/lib*/opengl/ati/lib/libGL.so.1.2 || die "pax-mark failed"
632 + fi
633 +}
634 +
635 +pkg_postinst() {
636 + elog "To switch to AMD OpenGL, run \"eselect opengl set ati\""
637 + elog "To change your xorg.conf you can use the bundled \"aticonfig\""
638 + elog
639 + elog "If you experience unexplained segmentation faults and kernel crashes"
640 + elog "with this driver and multi-threaded applications such as wine,"
641 + elog "set UseFastTLS in xorg.conf to either 0 or 1, but not 2."
642 + elog
643 + elog "Fully rebooting the system after an ${PN} update is recommended"
644 + elog "Stopping Xorg, reloading fglrx kernel module and restart Xorg"
645 + elog "might not work"
646 + elog
647 +
648 + use modules && linux-mod_pkg_postinst
649 + "${ROOT}"/usr/bin/eselect opengl set --use-old ati
650 + "${ROOT}"/usr/bin/eselect opencl set --use-old amd
651 +
652 + if has_version "x11-drivers/xf86-video-intel[sna]"; then
653 + ewarn "It is reported that xf86-video-intel built with USE=\"sna\""
654 + ewarn "causes the X server to crash on systems that use hybrid"
655 + ewarn "AMD/Intel graphics. If you experience this crash, downgrade"
656 + ewarn "to xf86-video-intel-2.20.2 or earlier or try disabling sna"
657 + ewarn "for xf86-video-intel."
658 + ewarn "For details, see https://bugs.gentoo.org/show_bug.cgi?id=430000"
659 + fi
660 +
661 + if use pax_kernel; then
662 + ewarn "Please run \"revdep-pax -s libGL.so.1 -me\" after installation and"
663 + ewarn "after you have run \"eselect opengl set ati\". Executacle"
664 + ewarn "revdep-pax is part of package sys-apps/elfix."
665 + fi
666 +}
667 +
668 +pkg_preinst() {
669 + use modules && linux-mod_pkg_preinst
670 +}
671 +
672 +pkg_prerm() {
673 + "${ROOT}"/usr/bin/eselect opengl set --use-old xorg-x11
674 +}
675 +
676 +pkg_postrm() {
677 + use modules && linux-mod_pkg_postrm
678 + "${ROOT}"/usr/bin/eselect opengl set --use-old xorg-x11
679 +}
680
681 diff --git a/x11-drivers/ati-drivers/files/15.11-remove-gpl-symbols.patch b/x11-drivers/ati-drivers/files/15.11-remove-gpl-symbols.patch
682 new file mode 100644
683 index 0000000..5cea796
684 --- /dev/null
685 +++ b/x11-drivers/ati-drivers/files/15.11-remove-gpl-symbols.patch
686 @@ -0,0 +1,48 @@
687 +--- a/common/lib/modules/fglrx/build_mod/firegl_public.c 2015-09-18 23:57:02.000000000 -0400
688 ++++ b/common/lib/modules/fglrx/build_mod/firegl_public.c 2015-09-18 23:57:11.000000000 -0400
689 +@@ -136,7 +136,6 @@
690 + #include <asm/mman.h>
691 + #include <asm/uaccess.h>
692 + #include <asm/processor.h>
693 +-#include <asm/tlbflush.h> // for flush_tlb_page
694 + #include <asm/cpufeature.h>
695 + #ifdef CONFIG_MTRR
696 + #include <asm/mtrr.h>
697 +@@ -251,6 +250,26 @@
698 + #define WRITE_CR4(x) write_cr4(x)
699 + #endif
700 +
701 ++#define __flush_tlb_one(addr) asm volatile("invlpg (%0)" ::"r" (addr) : "memory")
702 ++#define __flush_tlb() native_write_cr3(native_read_cr3())
703 ++
704 ++static inline void __flush_tlb_all(void)
705 ++{
706 ++ if (cpu_has_pge)
707 ++ {
708 ++ unsigned long flags, cr4;
709 ++ raw_local_irq_save(flags);
710 ++ cr4 = native_read_cr4();
711 ++ native_write_cr4(cr4 & ~X86_CR4_PGE);
712 ++ native_write_cr4(cr4);
713 ++ raw_local_irq_restore(flags);
714 ++ }
715 ++ else
716 ++ {
717 ++ __flush_tlb();
718 ++ }
719 ++}
720 ++
721 + // ============================================================
722 + /* globals */
723 +
724 +--- a/common/lib/modules/fglrx/build_mod/kcl_acpi.c 2015-09-19 00:43:35.000000000 -0400
725 ++++ b/common/lib/modules/fglrx/build_mod/kcl_acpi.c 2015-09-19 00:43:48.000000000 -0400
726 +@@ -868,7 +868,7 @@ void ATI_API_CALL KCL_ACPI_No_Hotplug(vo
727 + #elif LINUX_VERSION_CODE >= KERNEL_VERSION(3,17,0)
728 + if(pdev)
729 + {
730 +-#if (UTS_UBUNTU_RELEASE_ABI < 0 && LINUX_VERSION_CODE < KERNEL_VERSION(4,1,3)) || (UTS_UBUNTU_RELEASE_ABI >= 0 && UTS_UBUNTU_RELEASE_ABI < 26 && LINUX_VERSION_CODE <= KERNEL_VERSION(3,19,8))
731 ++#if 0 && (UTS_UBUNTU_RELEASE_ABI < 0 && LINUX_VERSION_CODE < KERNEL_VERSION(4,1,3)) || (UTS_UBUNTU_RELEASE_ABI >= 0 && UTS_UBUNTU_RELEASE_ABI < 26 && LINUX_VERSION_CODE <= KERNEL_VERSION(3,19,8))
732 + pci_ignore_hotplug(pdev);
733 + #else
734 + pdev->ignore_hotplug = 1;
735
736 diff --git a/x11-drivers/ati-drivers/files/15.9-kcl_str.patch b/x11-drivers/ati-drivers/files/15.9-kcl_str.patch
737 new file mode 100644
738 index 0000000..20c3bc8
739 --- /dev/null
740 +++ b/x11-drivers/ati-drivers/files/15.9-kcl_str.patch
741 @@ -0,0 +1,14 @@
742 +--- a/common/lib/modules/fglrx/build_mod/kcl_str.c 2015-09-13 13:47:30.000000000 -0400
743 ++++ b/common/lib/modules/fglrx/build_mod/kcl_str.c 2015-09-13 13:49:42.000000000 -0400
744 +@@ -169,7 +169,11 @@ int ATI_API_CALL KCL_STR_Strnicmp(const
745 + const char* s2,
746 + KCL_TYPE_SizeSigned count)
747 + {
748 ++#if LINUX_VERSION_CODE < KERNEL_VERSION(4,0,0)
749 + return strnicmp(s1, s2, count);
750 ++#else
751 ++ return strncasecmp(s1, s2, count);
752 ++#endif
753 + }
754 +
755 + /** \brief Locate character in string
756
757 diff --git a/x11-drivers/ati-drivers/files/15.9-mtrr.patch b/x11-drivers/ati-drivers/files/15.9-mtrr.patch
758 new file mode 100644
759 index 0000000..bdf70b4
760 --- /dev/null
761 +++ b/x11-drivers/ati-drivers/files/15.9-mtrr.patch
762 @@ -0,0 +1,27 @@
763 +--- a/common/lib/modules/fglrx/build_mod/firegl_public.c 2015-09-19 23:43:22.000000000 -0400
764 ++++ b/common/lib/modules/fglrx/build_mod/firegl_public.c 2015-09-19 23:52:07.000000000 -0400
765 +@@ -3442,7 +3442,11 @@ int ATI_API_CALL KCL_MEM_MTRR_Support(vo
766 + int ATI_API_CALL KCL_MEM_MTRR_AddRegionWc(unsigned long base, unsigned long size)
767 + {
768 + #ifdef CONFIG_MTRR
769 ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,3,0)
770 ++ return arch_phys_wc_add(base, size);
771 ++#else
772 + return mtrr_add(base, size, MTRR_TYPE_WRCOMB, 1);
773 ++#endif
774 + #else /* !CONFIG_MTRR */
775 + return -EPERM;
776 + #endif /* !CONFIG_MTRR */
777 +@@ -3451,7 +3455,12 @@ int ATI_API_CALL KCL_MEM_MTRR_AddRegionW
778 + int ATI_API_CALL KCL_MEM_MTRR_DeleteRegion(int reg, unsigned long base, unsigned long size)
779 + {
780 + #ifdef CONFIG_MTRR
781 ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,3,0)
782 ++ arch_phys_wc_del(reg);
783 ++ return reg;
784 ++#else
785 + return mtrr_del(reg, base, size);
786 ++#endif
787 + #else /* !CONFIG_MTRR */
788 + return -EPERM;
789 + #endif /* !CONFIG_MTRR */
790
791 diff --git a/x11-drivers/ati-drivers/files/15.9-preempt.patch b/x11-drivers/ati-drivers/files/15.9-preempt.patch
792 new file mode 100644
793 index 0000000..c659883
794 --- /dev/null
795 +++ b/x11-drivers/ati-drivers/files/15.9-preempt.patch
796 @@ -0,0 +1,103 @@
797 +--- a/common/lib/modules/fglrx/build_mod/firegl_public.c 2015-08-30 17:36:02.000000000 -0400
798 ++++ b/common/lib/modules/fglrx/build_mod/firegl_public.c 2015-08-30 17:39:36.000000000 -0400
799 +@@ -21,6 +21,8 @@
800 + !!! since it requires changes to linux/init/main.c.
801 + #endif /* !MODULE */
802 +
803 ++#include <linux/preempt.h>
804 ++
805 + // ============================================================
806 + #include <linux/version.h>
807 +
808 +@@ -4997,7 +4999,9 @@ static unsigned int kas_spin_unlock(kas_
809 + unsigned long ATI_API_CALL KAS_GetExecutionLevel(void)
810 + {
811 + unsigned long ret;
812 ++ preempt_disable();
813 + ret = kas_GetExecutionLevel();
814 ++ preempt_enable();
815 + return ret;
816 + }
817 +
818 +@@ -5022,8 +5026,10 @@ unsigned int ATI_API_CALL KAS_Ih_Execute
819 + KCL_DEBUG5(FN_FIREGL_KAS,"0x%08X, 0x%08X\n", ih_routine, ih_context);
820 +
821 + //Prevent simultaneous entry on some SMP systems.
822 ++ preempt_disable();
823 + if (test_and_set_bit(0, (void *)&(kasContext.in_interrupts[smp_processor_id()])))
824 + {
825 ++ preempt_enable();
826 + KCL_DEBUG1(FN_FIREGL_KAS, "The processor is handling the interrupt\n");
827 + return IRQ_NONE;
828 + }
829 +@@ -5036,9 +5042,9 @@ unsigned int ATI_API_CALL KAS_Ih_Execute
830 +
831 + kasSetExecutionLevel(orig_level);
832 + spin_unlock(&kasContext.lock_ih);
833 +-
834 + clear_bit(0, (void *)&(kasContext.in_interrupts[smp_processor_id()]));
835 + KCL_DEBUG5(FN_FIREGL_KAS,"%d\n", ret);
836 ++ preempt_enable();
837 +
838 + return ret;
839 + }
840 +@@ -5256,6 +5262,7 @@ unsigned int ATI_API_CALL KAS_Spinlock_A
841 +
842 + KCL_DEBUG5(FN_FIREGL_KAS,"0x%08X\n", hSpinLock);
843 +
844 ++ preempt_disable();
845 + spin_lock_info.routine_type = spinlock_obj->routine_type;
846 + spin_lock_info.plock = &(spinlock_obj->lock);
847 +
848 +@@ -5263,6 +5270,7 @@ unsigned int ATI_API_CALL KAS_Spinlock_A
849 +
850 + spinlock_obj->acquire_type = spin_lock_info.acquire_type;
851 + spinlock_obj->flags = spin_lock_info.flags;
852 ++ preempt_enable();
853 +
854 + KCL_DEBUG5(FN_FIREGL_KAS,"%d\n", ret);
855 + return ret;
856 +@@ -6034,6 +6042,8 @@ unsigned int ATI_API_CALL KAS_Interlocke
857 +
858 + KCL_DEBUG5(FN_FIREGL_KAS,"0x%08X, 0x%08X, 0x%08X\n", hListHead, hListEntry, phPrevEntry);
859 +
860 ++ preempt_disable();
861 ++
862 + /* Protect the operation with spinlock */
863 + spin_lock_info.routine_type = listhead_obj->routine_type;
864 + spin_lock_info.plock = &(listhead_obj->lock);
865 +@@ -6041,6 +6051,7 @@ unsigned int ATI_API_CALL KAS_Interlocke
866 + if (!kas_spin_lock(&spin_lock_info))
867 + {
868 + KCL_DEBUG_ERROR("Unable to grab list spinlock\n");
869 ++ preempt_enable();
870 + return 0; /* No spinlock - no operation */
871 + }
872 +
873 +@@ -6065,6 +6076,7 @@ unsigned int ATI_API_CALL KAS_Interlocke
874 + spin_unlock_info.flags = spin_lock_info.flags;
875 +
876 + ret = kas_spin_unlock(&spin_unlock_info);
877 ++ preempt_enable();
878 + KCL_DEBUG5(FN_FIREGL_KAS,"%d", ret);
879 + return ret;
880 + }
881 +@@ -6153,8 +6165,10 @@ unsigned int ATI_API_CALL KAS_Interlocke
882 + spin_lock_info.routine_type = listhead_obj->routine_type;
883 + spin_lock_info.plock = &(listhead_obj->lock);
884 +
885 ++ preempt_disable();
886 + if (!kas_spin_lock(&spin_lock_info))
887 + {
888 ++ preempt_enable();
889 + KCL_DEBUG_ERROR("Unable to grab list spinlock");
890 + return 0; /* No spinlock - no operation */
891 + }
892 +@@ -6178,6 +6192,7 @@ unsigned int ATI_API_CALL KAS_Interlocke
893 + spin_unlock_info.flags = spin_lock_info.flags;
894 +
895 + ret = kas_spin_unlock(&spin_unlock_info);
896 ++ preempt_enable();
897 + KCL_DEBUG5(FN_FIREGL_KAS,"%d", ret);
898 + return ret;
899 + }
900
901 diff --git a/x11-drivers/ati-drivers/files/15.9-remove-gpl-symbols.patch b/x11-drivers/ati-drivers/files/15.9-remove-gpl-symbols.patch
902 new file mode 100644
903 index 0000000..51fc6c2
904 --- /dev/null
905 +++ b/x11-drivers/ati-drivers/files/15.9-remove-gpl-symbols.patch
906 @@ -0,0 +1,74 @@
907 +--- a/common/lib/modules/fglrx/build_mod/firegl_public.c 2015-09-18 23:57:02.000000000 -0400
908 ++++ b/common/lib/modules/fglrx/build_mod/firegl_public.c 2015-09-18 23:57:11.000000000 -0400
909 +@@ -136,7 +136,6 @@
910 + #include <asm/mman.h>
911 + #include <asm/uaccess.h>
912 + #include <asm/processor.h>
913 +-#include <asm/tlbflush.h> // for flush_tlb_page
914 + #include <asm/cpufeature.h>
915 + #ifdef CONFIG_MTRR
916 + #include <asm/mtrr.h>
917 +@@ -251,6 +250,26 @@
918 + #define WRITE_CR4(x) write_cr4(x)
919 + #endif
920 +
921 ++#define __flush_tlb_one(addr) asm volatile("invlpg (%0)" ::"r" (addr) : "memory")
922 ++#define __flush_tlb() native_write_cr3(native_read_cr3())
923 ++
924 ++static inline void __flush_tlb_all(void)
925 ++{
926 ++ if (cpu_has_pge)
927 ++ {
928 ++ unsigned long flags, cr4;
929 ++ raw_local_irq_save(flags);
930 ++ cr4 = native_read_cr4();
931 ++ native_write_cr4(cr4 & ~X86_CR4_PGE);
932 ++ native_write_cr4(cr4);
933 ++ raw_local_irq_restore(flags);
934 ++ }
935 ++ else
936 ++ {
937 ++ __flush_tlb();
938 ++ }
939 ++}
940 ++
941 + // ============================================================
942 + /* globals */
943 +
944 +@@ -6479,7 +6498,12 @@ static int KCL_fpu_save_init(struct task
945 + void ATI_API_CALL KCL_fpu_begin(void)
946 + {
947 + #if defined(CONFIG_X86_64) || LINUX_VERSION_CODE >= KERNEL_VERSION(3,17,0)
948 ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,2,0)
949 ++ preempt_disable();
950 ++ __kernel_fpu_begin();
951 ++#else
952 + kernel_fpu_begin();
953 ++#endif
954 + #else
955 + #ifdef TS_USEDFPU
956 + struct thread_info *cur_thread = current_thread_info();
957 +@@ -6525,7 +6549,12 @@ void ATI_API_CALL KCL_fpu_begin(void)
958 + */
959 + void ATI_API_CALL KCL_fpu_end(void)
960 + {
961 ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,2,0)
962 ++ __kernel_fpu_end();
963 ++ preempt_enable();
964 ++#else
965 + kernel_fpu_end();
966 ++#endif
967 + }
968 +
969 + /** Create new directory entry under "/proc/...."
970 +--- a/common/lib/modules/fglrx/build_mod/kcl_acpi.c 2015-09-19 00:43:35.000000000 -0400
971 ++++ b/common/lib/modules/fglrx/build_mod/kcl_acpi.c 2015-09-19 00:43:48.000000000 -0400
972 +@@ -868,7 +868,7 @@ void ATI_API_CALL KCL_ACPI_No_Hotplug(vo
973 + #elif LINUX_VERSION_CODE >= KERNEL_VERSION(3,17,0)
974 + if(pdev)
975 + {
976 +-#if (UTS_UBUNTU_RELEASE_ABI < 0 && LINUX_VERSION_CODE < KERNEL_VERSION(4,1,3)) || (UTS_UBUNTU_RELEASE_ABI >= 0 && UTS_UBUNTU_RELEASE_ABI < 26 && LINUX_VERSION_CODE <= KERNEL_VERSION(3,19,8))
977 ++#if 0 && (UTS_UBUNTU_RELEASE_ABI < 0 && LINUX_VERSION_CODE < KERNEL_VERSION(4,1,3)) || (UTS_UBUNTU_RELEASE_ABI >= 0 && UTS_UBUNTU_RELEASE_ABI < 26 && LINUX_VERSION_CODE <= KERNEL_VERSION(3,19,8))
978 + pci_ignore_hotplug(pdev);
979 + #else
980 + pdev->ignore_hotplug = 1;
981
982 diff --git a/x11-drivers/ati-drivers/files/15.9-sep_printf.patch b/x11-drivers/ati-drivers/files/15.9-sep_printf.patch
983 new file mode 100644
984 index 0000000..3e4e8d6
985 --- /dev/null
986 +++ b/x11-drivers/ati-drivers/files/15.9-sep_printf.patch
987 @@ -0,0 +1,11 @@
988 +--- a/common/lib/modules/fglrx/build_mod/firegl_public.c 2015-09-14 15:14:36.000000000 -0400
989 ++++ b/common/lib/modules/fglrx/build_mod/firegl_public.c 2015-09-14 16:18:58.000000000 -0400
990 +@@ -649,6 +649,8 @@ static int firegl_major_proc_read(struct
991 + *eof = 1;
992 +
993 + len = snprintf(buf, request, "%d\n", major);
994 ++#elif LINUX_VERSION_CODE >= KERNEL_VERSION(4,3,0)
995 ++ seq_printf(m, "%d\n", major);
996 + #else
997 + len = seq_printf(m, "%d\n", major);
998 + #endif
999
1000 diff --git a/x11-drivers/ati-drivers/files/ati-drivers-12.9-KCL_AGP_FindCapsRegisters-stub.patch b/x11-drivers/ati-drivers/files/ati-drivers-12.9-KCL_AGP_FindCapsRegisters-stub.patch
1001 new file mode 100644
1002 index 0000000..0ea461b
1003 --- /dev/null
1004 +++ b/x11-drivers/ati-drivers/files/ati-drivers-12.9-KCL_AGP_FindCapsRegisters-stub.patch
1005 @@ -0,0 +1,27 @@
1006 +From: Vasiliy Yeremeyev <vayerx@×××××.com>
1007 +Date: Sun, 4 Nov 2012 23:59:36 +0400
1008 +Subject: [PATCH] KCL_AGP_FindCapsRegisters stub for AGP-less systems
1009 +
1010 +---
1011 + common/lib/modules/fglrx/build_mod/kcl_agp.c | 5 +++++
1012 + 1 file changed, 5 insertions(+)
1013 +
1014 +diff --git a/common/lib/modules/fglrx/build_mod/kcl_agp.c b/common/lib/modules/fglrx/build_mod/kcl_agp.c
1015 +index b9c0655..cb1902b 100644
1016 +--- a/common/lib/modules/fglrx/build_mod/kcl_agp.c
1017 ++++ b/common/lib/modules/fglrx/build_mod/kcl_agp.c
1018 +@@ -479,6 +479,11 @@ int ATI_API_CALL KCL_AGP_Enable(unsigned long mode)
1019 + return -EINVAL;
1020 + }
1021 +
1022 ++int ATI_API_CALL KCL_AGP_FindCapsRegisters(KCL_PCI_DevHandle dev)
1023 ++{
1024 ++ return -EINVAL;
1025 ++}
1026 ++
1027 + int ATI_API_CALL KCL_AGP_ReadCapsRegisters(KCL_PCI_DevHandle dev, unsigned int *caps)
1028 + {
1029 + return -EINVAL;
1030 +--
1031 +1.7.12
1032 +
1033
1034 diff --git a/x11-drivers/ati-drivers/files/ati-drivers-13.8-beta-include-seq_file.patch b/x11-drivers/ati-drivers/files/ati-drivers-13.8-beta-include-seq_file.patch
1035 new file mode 100644
1036 index 0000000..fb1ba17
1037 --- /dev/null
1038 +++ b/x11-drivers/ati-drivers/files/ati-drivers-13.8-beta-include-seq_file.patch
1039 @@ -0,0 +1,13 @@
1040 +diff --git a/common/lib/modules/fglrx/build_mod/firegl_public.c b/common/lib/modules/fglrx/build_mod/firegl_public.c
1041 +index 22561c5..fdfe65e 100755
1042 +--- a/common/lib/modules/fglrx/build_mod/firegl_public.c
1043 ++++ b/common/lib/modules/fglrx/build_mod/firegl_public.c
1044 +@@ -520,6 +520,8 @@ static int func##_wrap(char *buf, char **start, kcl_off_t offset, \
1045 + }
1046 +
1047 + #else
1048 ++#include <linux/seq_file.h>
1049 ++
1050 + #define READ_PROC_WRAP(func) \
1051 + static int func##_wrap(struct seq_file *m, void* data) \
1052 + { \
1053
1054 diff --git a/x11-drivers/ati-drivers/files/ati-drivers-x32_something_something.patch b/x11-drivers/ati-drivers/files/ati-drivers-x32_something_something.patch
1055 new file mode 100644
1056 index 0000000..d37c119
1057 --- /dev/null
1058 +++ b/x11-drivers/ati-drivers/files/ati-drivers-x32_something_something.patch
1059 @@ -0,0 +1,13 @@
1060 +--- a/common/lib/modules/fglrx/build_mod/kcl_ioctl.c 2012-05-26 19:11:03.402987821 +0200
1061 ++++ b/common/lib/modules/fglrx/build_mod/kcl_ioctl.c 2012-05-26 19:13:00.273986422 +0200
1062 +@@ -217,6 +217,10 @@
1063 + * \param size [in] Number of bytes to allocate
1064 + * \return Pointer to allocated memory
1065 + */
1066 ++#ifndef CONFIG_X86_X32
1067 ++DEFINE_PER_CPU(unsigned long, old_rsp);
1068 ++#endif
1069 ++
1070 + void* ATI_API_CALL KCL_IOCTL_AllocUserSpace32(long size)
1071 + {
1072 + void __user *ret = COMPAT_ALLOC_USER_SPACE(size);
1073
1074 diff --git a/x11-drivers/ati-drivers/files/ati-powermode-opt-path-3.patch b/x11-drivers/ati-drivers/files/ati-powermode-opt-path-3.patch
1075 new file mode 100644
1076 index 0000000..278c191
1077 --- /dev/null
1078 +++ b/x11-drivers/ati-drivers/files/ati-powermode-opt-path-3.patch
1079 @@ -0,0 +1,40 @@
1080 +--- a/common/usr/share/doc/fglrx/examples/etc/acpi/ati-powermode.sh 2012-08-17 22:39:05.077984979 +0800
1081 ++++ b/common/usr/share/doc/fglrx/examples/etc/acpi/ati-powermode.sh 2012-08-17 22:41:15.919976149 +0800
1082 +@@ -4,6 +4,8 @@
1083 + # Control script for ACPI lid state and AC adapter state
1084 + #
1085 +
1086 ++aticonfig='/opt/bin/aticonfig'
1087 ++
1088 + getXuser() {
1089 + user=`who| grep -m1 ":$displaynum " | awk '{print $1}'`
1090 + if [ x"$user" = x"" ]; then
1091 +@@ -47,7 +49,7 @@
1092 + done
1093 +
1094 + #If PPLIB is enabled
1095 +-su $user -c '/usr/bin/aticonfig --pplib-cmd="get version"' | grep PPLIB
1096 ++su $user -c "$aticonfig --pplib-cmd='get version'" | grep PPLIB
1097 + if [ $? = 0 ]; then
1098 + echo "Has PPLIB"
1099 + has_pplib=1
1100 +@@ -61,15 +63,15 @@
1101 + if [ ${lid_closed} -eq 1 -o ${on_dc} -eq 1 ]; then
1102 + echo "Low power"
1103 + if [ ${has_pplib} -eq 1 ]; then
1104 +- su $user -c '/usr/bin/aticonfig --pplib-cmd="notify psrc dc"'
1105 ++ su $user -c "$aticonfig --pplib-cmd='notify psrc dc'"
1106 + else
1107 +- su $user -c "/usr/bin/aticonfig --set-powerstate=1 --effective=now"
1108 ++ su $user -c "$aticonfig --set-powerstate=1 --effective=now"
1109 + fi
1110 + else
1111 + echo "high power"
1112 + if [ ${has_pplib} -eq 1 ]; then
1113 +- su $user -c '/usr/bin/aticonfig --pplib-cmd="notify psrc ac"'
1114 ++ su $user -c "$aticonfig --pplib-cmd='notify psrc ac'"
1115 + else
1116 +- su $user -c "/usr/bin/aticonfig --set-powerstate=3 --effective=now"
1117 ++ su $user -c "$aticonfig --set-powerstate=3 --effective=now"
1118 + fi
1119 + fi
1120
1121 diff --git a/x11-drivers/ati-drivers/files/atieventsd.init b/x11-drivers/ati-drivers/files/atieventsd.init
1122 new file mode 100644
1123 index 0000000..aa7d028
1124 --- /dev/null
1125 +++ b/x11-drivers/ati-drivers/files/atieventsd.init
1126 @@ -0,0 +1,20 @@
1127 +#!/sbin/runscript
1128 +# Copyright 1999-2006 Gentoo Foundation
1129 +# Distributed under the terms of the GNU General Public License v2
1130 +# $Id$
1131 +
1132 +depend() {
1133 + need acpid
1134 +}
1135 +
1136 +start() {
1137 + ebegin "Starting ${SVCNAME}"
1138 + start-stop-daemon --start --exec /opt/sbin/atieventsd -- ${ATIEVENTSDOPTS}
1139 + eend $?
1140 +}
1141 +
1142 +stop() {
1143 + ebegin "Stopping ${SVCNAME}"
1144 + start-stop-daemon --stop --quiet --exec /opt/sbin/atieventsd
1145 + eend $?
1146 +}
1147 \ No newline at end of file
1148
1149 diff --git a/x11-drivers/ati-drivers/files/atieventsd.service b/x11-drivers/ati-drivers/files/atieventsd.service
1150 new file mode 100644
1151 index 0000000..72df6c4
1152 --- /dev/null
1153 +++ b/x11-drivers/ati-drivers/files/atieventsd.service
1154 @@ -0,0 +1,9 @@
1155 +[Unit]
1156 +Description=Catalyst event Daemon
1157 +Requires=acpid.socket
1158 +
1159 +[Service]
1160 +ExecStart=/opt/sbin/atieventsd --nodaemon
1161 +
1162 +[Install]
1163 +WantedBy=multi-user.target
1164
1165 diff --git a/x11-drivers/ati-drivers/files/const-notifier-block.patch b/x11-drivers/ati-drivers/files/const-notifier-block.patch
1166 new file mode 100644
1167 index 0000000..ba1fdb2
1168 --- /dev/null
1169 +++ b/x11-drivers/ati-drivers/files/const-notifier-block.patch
1170 @@ -0,0 +1,25 @@
1171 +diff -Nur common/lib/modules/fglrx/build_mod/kcl_acpi.c common-r1/lib/modules/fglrx/build_mod/kcl_acpi.c
1172 +--- common/lib/modules/fglrx/build_mod/kcl_acpi.c 2013-01-29 17:03:51.000000000 +0200
1173 ++++ common-r1/lib/modules/fglrx/build_mod/kcl_acpi.c 2013-02-15 20:33:10.611838616 +0200
1174 +@@ -15,6 +15,9 @@
1175 + ****************************************************************************/
1176 +
1177 + #include <linux/version.h>
1178 ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,7,0)
1179 ++#include <linux/notifier.h>
1180 ++#endif
1181 + #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,33)
1182 + #include <generated/autoconf.h>
1183 + #else
1184 +@@ -145,7 +148,11 @@
1185 + return NOTIFY_OK;
1186 + }
1187 +
1188 ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,7,0)
1189 ++static notifier_block_no_const firegl_acpi_lid_notifier = {
1190 ++#else
1191 + static struct notifier_block firegl_acpi_lid_notifier = {
1192 ++#endif
1193 + .notifier_call = firegl_acpi_lid_event,
1194 + };
1195 + #endif
1196
1197 diff --git a/x11-drivers/ati-drivers/files/fgl_glxgears-do-not-include-glATI.patch b/x11-drivers/ati-drivers/files/fgl_glxgears-do-not-include-glATI.patch
1198 new file mode 100644
1199 index 0000000..d46e027
1200 --- /dev/null
1201 +++ b/x11-drivers/ati-drivers/files/fgl_glxgears-do-not-include-glATI.patch
1202 @@ -0,0 +1,11 @@
1203 +diff -Nur extra/fgl_glxgears/fgl_glxgears.c extra-r1/fgl_glxgears/fgl_glxgears.c
1204 +--- extra/fgl_glxgears/fgl_glxgears.c 2012-08-29 09:59:03.000000000 +0300
1205 ++++ extra-r1/fgl_glxgears/fgl_glxgears.c 2013-09-07 09:26:11.034723135 +0300
1206 +@@ -78,7 +78,6 @@
1207 + #endif // _WIN32
1208 +
1209 + #define INT_PTR ptrdiff_t
1210 +-#include <GL/glATI.h>
1211 +
1212 + #ifdef _WIN32
1213 + #include <GL/wglATI.h>
1214
1215 diff --git a/x11-drivers/ati-drivers/files/switchlibGL b/x11-drivers/ati-drivers/files/switchlibGL
1216 new file mode 100644
1217 index 0000000..a6aa4fc
1218 --- /dev/null
1219 +++ b/x11-drivers/ati-drivers/files/switchlibGL
1220 @@ -0,0 +1,61 @@
1221 +#!/bin/bash
1222 +# switchlibGL
1223 +#
1224 +# Copyright (c) 2011 Advanced Micro Devices, Inc.
1225 +#
1226 +# Purpose:
1227 +# For switch between AMD and Intel graphic driver library.
1228 +#
1229 +# Usage:
1230 +# switchlibGL amd|intel|query
1231 +# amd: switches to the AMD version of libGL.
1232 +# intel: switches to the open-source version of libGL .
1233 +# query: checks, which version is currently active and prints either "amd"
1234 +# or "intel" or "unknown" on the standard output.
1235 +# must be root to execute this script
1236 +
1237 +ARCH=`uname -m`
1238 +E_ERR=1
1239 +
1240 +# Check if root
1241 +if [ "`whoami`" != "root" ]; then
1242 + echo "Must be root to run this script." 1>&2
1243 + exit $E_ERR
1244 +fi
1245 +
1246 +# One parameter
1247 +if [ $# -ne 1 ]; then
1248 + echo "Usage: `basename $0` amd|intel|query " 1>&2
1249 + echo "Please choose one parameter " 1>&2
1250 + exit $E_ERR
1251 +fi
1252 +
1253 +current=$(eselect opengl show)
1254 +# Switch to right mode
1255 +case "$1" in
1256 + "amd" )
1257 + if [ $current != ati ] ; then
1258 + eselect opengl set ati || return 1
1259 + fi
1260 + ;;
1261 + "intel" )
1262 + if [ $current != xorg-x11 ] ; then
1263 + eselect opengl set xorg-x11 || return 1
1264 + fi
1265 + ;;
1266 + "query" )
1267 + case "$current" in
1268 + "ati" )
1269 + echo "amd"
1270 + ;;
1271 + "xorg-x11" )
1272 + echo "intel"
1273 + ;;
1274 + esac
1275 + ;;
1276 + * ) echo "Usage: `basename $0` amd|intel|query" 1>&2; exit $E_ERR;;
1277 + # other than amd|intel|query parameter report an error
1278 +esac
1279 +
1280 +# A zero return value from the script upon exit indicates success.
1281 +exit 0