1 # Copyright 1999-2012 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 2 6 38; then
31 CONFIG_CHECK="~VGA_SWITCHEROO"
33 use video_cards_intel && MODULE_NAMES="${MODULE_NAMES} i915-jprobe(extra/${PN}:${S})"
41 exeinto /etc/pm/sleep.d
44 if kernel_is ge 2 6 38 ; then
45 sed -i "/915/d" ${PN}.conf-modprobe.d
48 sed -i '1ioptions asus-switcheroo ' ${PN}.conf-modprobe.d
50 if ( use video_cards_nvidia || use byo) ; then
51 sed -i "s:options.*oo:& dummy-client=1 \n:" ${PN}.conf-modprobe.d
54 if use video_cards_nvidia ; then
55 sed -i "s:/sbin/modprobe nouveau-jprobe:/bin/echo DIS > /sys/kernel/debug/vgaswitcheroo/switch:" ${PN}.conf-modprobe.d
56 sed -i "s:ouveau:vidia:g" ${PN}.conf-modprobe.d
60 sed -i "s:asus:byo:g" ${PN}.conf-modprobe.d
61 sed -i "s:options.*oo:& model=AsusUL30VT:" ${PN}.conf-modprobe.d
64 if use video_cards_nvidia ; then
65 sed -i '1iblacklist nvidia' ${PN}.conf-modprobe.d
67 insinto /etc/modprobe.d
68 newins ${PN}.conf-modprobe.d ${PN}.conf
70 newinitd "${FILESDIR}"/switcheroo-dir.rc switcheroo
73 newexe "${FILESDIR}"/switcheroo-to-nvidia.sh switcheroo-to-nvidia
76 doins "${FILESDIR}"/xorg.conf-nvidia
78 elif use video_cards_nouveau ; then
79 insinto /etc/modprobe.d
80 newins ${PN}.conf-modprobe.d ${PN}.conf
85 elog "If debugfs isn't automatically mounted for you,"
86 elog "add this to your /etc/fstab:"
88 elog "debugfs /sys/kernel/debug debugfs defaults 0 0"
90 elog "Remember to add asus_switcheroo or byo_switcheroo"
91 elog "to /etc/conf.d/modules, and edit your laptop model."
93 elog "To turn off the discrete card on boot, put"
95 elog 'if [ -f "/sys/kernel/debug/vgaswitcheroo/switch" ] ; then '
96 elog " /bin/echo OFF > /sys/kernel/debug/vgaswitcheroo/switch"
99 elog "in /etc/local.d/switcheroo.start"
101 if use video_cards_nvidia ; then
103 elog "This ebuild has installed a system for switching"
104 elog "to the nVidia card and driver. This system requires"
105 elog "that you use the supplied xorg.conf for nVidia"
106 elog "and no xorg.conf for the intel card. The switching"
107 elog "is handled by the command switcheroo-to-nvidia"
108 elog "and the switcheroo init.d script."
111 linux-mod_pkg_postinst