1 # Copyright 1999-2011 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
6 inherit linux-mod eutils
8 DESCRIPTION="Modules to turn off nVidia card for ASUS laptops"
9 HOMEPAGE="https://github.com/awilliam/asus-switcheroo"
12 DEPEND="sys-power/pm-utils"
16 IUSE="byo video_cards_intel video_cards_nouveau video_cards_nvidia"
17 REQUIRED_USE="video_cards_nouveau? ( !video_cards_nvidia )"
19 GITHUB_COMMIT="9231be9"
20 SRC_URI="http://www.github.com/awilliam/${PN}/tarball/${GITHUB_COMMIT} -> ${P}.tar.gz"
21 S="${WORKDIR}/awilliam-${PN}-${GITHUB_COMMIT}"
23 BUILD_TARGETS="default"
26 MODULE_NAMES="${PN}(extra/${PN}:${S})"
27 use byo && MODULE_NAMES="byo-switcheroo(extra/${PN}:${S})"
28 use video_cards_nouveau && MODULE_NAMES="${MODULE_NAMES} nouveau-jprobe(extra/${PN}:${S})"
30 if kernel_is ge 3 0 0; then
31 eerror "This package has only been tested with 2.6.x version kernels"
35 if kernel_is ge 2 6 38; then
36 CONFIG_CHECK="VGA_SWITCHEROO"
38 use video_cards_intel && MODULE_NAMES="${MODULE_NAMES} i915-jprobe(extra/${PN}:${S})"
46 exeinto /etc/pm/sleep.d
49 if kernel_is ge 2 6 38 ; then
50 sed -i "/915/d" ${PN}.conf-modprobe.d
53 sed -i '1ioptions asus-switcheroo ' ${PN}.conf-modprobe.d
55 if ( use video_cards_nvidia || use byo) ; then
56 sed -i "s:options.*oo:& dummy-client=1 \n:" ${PN}.conf-modprobe.d
59 if use video_cards_nvidia ; then
60 sed -i "s:/sbin/modprobe nouveau-jprobe:/bin/echo DIS > /sys/kernel/debug/vgaswitcheroo/switch:" ${PN}.conf-modprobe.d
61 sed -i "s:ouveau:vidia:g" ${PN}.conf-modprobe.d
65 sed -i "s:asus:byo:g" ${PN}.conf-modprobe.d
66 sed -i "s:options.*oo:& model=AsusUL30VT:" ${PN}.conf-modprobe.d
69 if use video_cards_nvidia ; then
70 sed -i '1iblacklist nvidia' ${PN}.conf-modprobe.d
72 insinto /etc/modprobe.d
73 newins ${PN}.conf-modprobe.d ${PN}.conf
75 newinitd "${FILESDIR}"/switcheroo-dir.rc switcheroo
78 newexe "${FILESDIR}"/switcheroo-to-nvidia.sh switcheroo-to-nvidia
81 doins "${FILESDIR}"/xorg.conf-nvidia
83 elif use video_cards_nouveau ; then
84 insinto /etc/modprobe.d
85 newins ${PN}.conf-modprobe.d ${PN}.conf
90 elog "If debugfs isn't automatically mounted for you,"
91 elog "add this to your /etc/fstab:"
93 elog "debugfs /sys/kernel/debug debugfs defaults 0 0"
95 elog "Remember to add asus_switcheroo or byo_switcheroo"
96 elog "to /etc/conf.d/modules, and edit your laptop model."
98 elog "To turn off the discrete card on boot, put"
100 elog 'if [ -f "/sys/kernel/debug/vgaswitcheroo/switch" ] ; then '
101 elog " /bin/echo OFF > /sys/kernel/debug/vgaswitcheroo/switch"
104 elog "in /etc/local.d/switcheroo.start"
106 if use video_cards_nvidia ; then
108 elog "This ebuild has installed a system for switching"
109 elog "to the nVidia card and driver. This system requires"
110 elog "that you use the supplied xorg.conf for nVidia"
111 elog "and no xorg.conf for the intel card. The switching"
112 elog "is handled by the command switcheroo-to-nvidia"
113 elog "and the switcheroo init.d script."
116 linux-mod_pkg_postinst