Snail/sbin/snail.nv_pwr_off

129 lines
4.2 KiB
Plaintext
Raw Normal View History

2012-04-02 00:39:08 +04:00
#!/bin/bash
2011-12-24 00:15:11 +04:00
2012-05-15 14:40:19 +04:00
TRIES=8
2011-12-24 00:15:11 +04:00
2012-05-08 14:44:56 +04:00
lsmod | grep '^nouveau ' >/dev/null && rmmod -f nouveau &>/dev/null
2012-04-07 19:57:45 +04:00
2012-04-15 21:31:08 +04:00
# Trying bbswitch method
if [ -f /proc/acpi/bbswitch ]; then
let tries=$TRIES
while [ 0 -lt $tries ]; do
(! lsmod | grep '^nvidia ' &>/dev/null || rmmod nvidia &>/dev/null) \
2012-04-15 21:31:08 +04:00
&& echo 'OFF' > /proc/acpi/bbswitch \
&& exit 0
2012-05-13 13:33:39 +04:00
sleep 0.1
2012-04-15 21:31:08 +04:00
let tries--
2012-05-13 13:33:39 +04:00
# echo "tries left: $tries"
2012-04-15 21:31:08 +04:00
done
fi
2012-04-07 19:57:45 +04:00
# Trying acpi_call method
if [ -f /proc/acpi/call ]; then
model=`dmidecode $@ -s system-product-name`
tries=$TRIES
while [ 0 -lt $tries ]; do
2012-04-07 09:28:12 +04:00
case "$model" in
M11XR2)
(! lsmod | grep '^nvidia ' &>/dev/null || rmmod nvidia &>/dev/null) \
2012-04-07 09:28:12 +04:00
&& echo '\_SB.PCI0.P0P2.PEGP.NVOP 0 0x100 0x1A {255,255,255,255}' > /proc/acpi/call \
&& echo '\_SB.PCI0.P0P2.PEGP._PS3' > /proc/acpi/call \
&& exit 0
;;
1015PN)
(! lsmod | grep '^nvidia ' &>/dev/null || rmmod nvidia &>/dev/null) \
2012-04-07 09:28:12 +04:00
&& echo '\OSGS 0x03' > /proc/acpi/call \
&& exit 0
;;
1215N)
(! lsmod | grep '^nvidia ' &>/dev/null || rmmod nvidia &>/dev/null) \
2012-04-07 09:28:12 +04:00
&& echo '\_SB.PCI0.P0P4.GFX0._DSM {0xF8,0xD8,0x86,0xA4,0xDA,0x0B,0x1B,0x47,0xA7,0x2B,0x60,0x42,0xA6,0xB5,0xBE,0xE0} 0x100 0x1A {0x1,0x0,0x0,0x3}' > /proc/acpi/call \
&& echo '\_SB.PCI0.P0P4.GFX0._PS3' > /proc/acpi/call \
&& exit 0
;;
K42Jc|K52Jc|N53Jf|N53Jg|N71Jv|N73Jf|P52Jc|PL80Jt|U30Jc|U33Jc|U35Jc|U36Jc|UL80Jt)
(! lsmod | grep '^nvidia ' &>/dev/null || rmmod nvidia &>/dev/null) \
2012-04-07 09:28:12 +04:00
&& echo '\_SB.PCI0.PEG1.GFX0.DOFF' > /proc/acpi/call \
&& exit 0
;;
N61Jv|N73Sv)
(! lsmod | grep '^nvidia ' &>/dev/null || rmmod nvidia &>/dev/null) \
2012-04-07 09:28:12 +04:00
&& echo '\_SB.PCI0.PEGR.GFX0.DOFF' > /proc/acpi/call \
&& exit 0
;;
P31Jg)
(! lsmod | grep '^nvidia ' &>/dev/null || rmmod nvidia &>/dev/null) \
2012-04-07 09:28:12 +04:00
&& echo '\_SB.PCI0.PEG1.GFX0._PS3' > /proc/acpi/call \
&& exit 0
;;
U43Jc)
(! lsmod | grep '^nvidia ' &>/dev/null || rmmod nvidia &>/dev/null) \
2012-04-07 09:28:12 +04:00
&& echo '\_SB.PCI0.RP00.VGA._DSM {0xF8,0xD8,0x86,0xA4,0xDA,0x0B,0x1B,0x47,0xA7,0x2B,0x60,0x42,0xA6,0xB5,0xBE,0xE0} 0x100 0x1A {0x1,0x0,0x0,0x3}' > /proc/acpi/call \
&& echo '\_SB.PCI0.RP00.VGA._PS3' > /proc/acpi/call \
&& exit 0
;;
UL30Vt)
(! lsmod | grep '^nvidia ' &>/dev/null || rmmod nvidia &>/dev/null) \
2012-04-07 09:28:12 +04:00
&& echo '\_SB.PCI0.P0P1.VGA._OFF' > /proc/acpi/call \
&& exit 0
;;
E6420)
(! lsmod | grep '^nvidia ' &>/dev/null || rmmod nvidia &>/dev/null) \
2012-04-07 09:28:12 +04:00
&& echo '\_SB.PCI0.PEG0.VID._OFF' > /proc/acpi/call \
&& exit 0
;;
InspironN5110|XPSL702X)
(! lsmod | grep '^nvidia ' &>/dev/null || rmmod nvidia &>/dev/null) \
2012-04-07 09:28:12 +04:00
&& echo '\_SB.PCI0.PEG0.PEGP._DSM {0xF8,0xD8,0x86,0xA4,0xDA,0x0B,0x1B,0x47,0xA7,0x2B,0x60,0x42,0xA6,0xB5,0xBE,0xE0} 0x100 0x1A {0x1,0x0,0x0,0x3}' > /proc/acpi/call \
&& echo '\_SB.PCI0.PEG0.PEGP._PS3' > /proc/acpi/call \
&& exit 0
;;
Vostro3300|Vostro3500)
(! lsmod | grep '^nvidia ' &>/dev/null || rmmod nvidia &>/dev/null) \
2012-04-07 09:28:12 +04:00
&& echo '\_SB.PCI0.P0P1.PEGP._OFF' > /proc/acpi/call \
&& exit 0
;;
XPS15)
(! lsmod | grep '^nvidia ' &>/dev/null || rmmod nvidia &>/dev/null) \
2012-04-07 09:28:12 +04:00
&& echo '\_SB.PCI0.PEG0.PEGP._OFF' > /proc/acpi/call \
&& exit 0
;;
ThinkPadT410)
(! lsmod | grep '^nvidia ' &>/dev/null || rmmod nvidia &>/dev/null) \
2012-04-07 09:28:12 +04:00
&& echo '\_SB.PCI0.PEG.VID._PS3' > /proc/acpi/call \
&& echo '\_SB.PCI0.PEG.VID._OFF' > /proc/acpi/call \
&& exit 0
;;
ThinkPadT420)
(! lsmod | grep '^nvidia ' &>/dev/null || rmmod nvidia &>/dev/null) \
2012-04-07 09:28:12 +04:00
&& echo '\_SB.PCI0.PEG.VID._DSM {0xF8,0xD8,0x86,0xA4,0xDA,0x0B,0x1B,0x47,0xA7,0x2B,0x60,0x42,0xA6,0xB5,0xBE,0xE0} 0x100 0x1A {0x1,0x0,0x0,0x3}' > /proc/acpi/call \
&& echo '\_SB.PCI0.PEG.VID._PS3' > /proc/acpi/call \
&& exit 0
;;
*) echo "Snail: unknown Notebook model: $model"; exit -1
;;
esac
2011-12-24 00:15:11 +04:00
2012-05-13 13:33:39 +04:00
sleep 0.1
2012-04-07 19:57:45 +04:00
let tries--
2012-05-13 13:33:39 +04:00
# echo "tries left: $tries"
2012-04-07 19:57:45 +04:00
done
fi
2011-12-24 00:15:11 +04:00
# Trying vgaswitcheroo method
if [ -f /sys/kernel/debug/vgaswitcheroo/switch ]; then
let tries=$TRIES
while [ 0 -lt $tries ]; do
(! lsmod | grep '^nvidia ' &>/dev/null || rmmod nvidia &>/dev/null) \
&& echo 'OFF' > /sys/kernel/debug/vgaswitcheroo/switch \
&& exit 0
2012-05-13 13:33:39 +04:00
sleep 0.1
let tries--
echo "tries left: $tries"
done
fi
2012-04-07 19:57:45 +04:00
echo "Cann't power off nVidia chip"
2011-12-24 00:15:11 +04:00
exit -1