Snail/sbin/snail.nv_pwr_on

130 lines
2.8 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-04-07 19:57:45 +04:00
TRIES=8
2011-12-24 00:15:11 +04:00
2012-04-07 19:57:45 +04:00
lsmod | grep '^nouveau ' >/dev/null && modprobe -rf nouveau &>/dev/null
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
echo 'ON' > /proc/acpi/bbswitch \
&& modprobe nvidia \
&& exit 0
sleep 0.01
let tries--
echo "tries left: $tries"
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)
echo '\_SB.PCI0.P0P2.PEGP._PS0' > /proc/acpi/call \
&& modprobe nvidia \
&& exit 0
;;
1015PN)
echo '\_SB.PCI0.P0P4.DGPU.DON' > /proc/acpi/call \
&& modprobe nvidia \
&& exit 0
;;
1215N)
echo '\_SB.PCI0.P0P4.GFX0._PS0' > /proc/acpi/call \
&& modprobe nvidia \
&& exit 0
;;
K42Jc|K52Jc|N53Jf|N53Jg|N71Jv|N73Jf|P52Jc|PL80Jt|U30Jc|U33Jc|U35Jc|U36Jc|UL80Jt)
echo '\_SB.PCI0.PEG1.GFX0.DON' > /proc/acpi/call \
&& modprobe nvidia \
&& exit 0
;;
N53Sn|U41Sv|N53Sv)
echo '\_SB.PCI0.PEG0.GFX0.DON' > /proc/acpi/call \
&& modprobe nvidia \
&& exit 0
;;
N61Jv|N73Sv)
echo '\_SB.PCI0.PEGR.GFX0.DON' > /proc/acpi/call \
&& modprobe nvidia \
&& exit 0
;;
P31Jg)
echo '\_SB.PCI0.PEG1.GFX0._PS0' > /proc/acpi/call \
&& modprobe nvidia \
&& exit 0
;;
U43Jc)
echo '\_SB.PCI0.RP00.VGA._PS0' > /proc/acpi/call \
&& modprobe nvidia \
&& exit 0
;;
UL30Vt)
echo '\_SB.PCI0.P0P1.VGA._ON' > /proc/acpi/call \
&& modprobe nvidia \
&& exit 0
;;
E6420)
echo '\_SB.PCI0.PEG0.VID._ON' > /proc/acpi/call \
&& modprobe nvidia \
&& exit 0
;;
InspironN5110|XPSL702X)
echo '\_SB.PCI0.PEG0.PEGP._PS0' > /proc/acpi/call \
&& modprobe nvidia \
&& exit 0
;;
Vostro3300|Vostro3500)
echo '\_SB.PCI0.P0P1.PEGP._ON' > /proc/acpi/call \
&& modprobe nvidia \
&& exit 0
;;
XPS15)
echo '\_SB.PCI0.PEG0.PEGP._ON' > /proc/acpi/call \
&& modprobe nvidia \
&& exit 0
;;
ThinkPadT410)
echo '\_SB.PCI0.PEG.VID._ON' > /proc/acpi/call \
&& echo '\_SB.PCI0.PEG.VID._PS0' > /proc/acpi/call \
&& modprobe nvidia \
&& exit 0
;;
ThinkPadT420)
echo '\_SB.PCI0.PEG.VID._PS0' > /proc/acpi/call \
&& modprobe nvidia \
&& exit 0
;;
*) echo "Snail: unknown Notebook model: $model"; exit -1
;;
esac
2011-12-24 00:15:11 +04:00
2012-04-07 19:57:45 +04:00
sleep 0.01
let tries--
echo "tries left: $tries"
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
echo 'ON' > /sys/kernel/debug/vgaswitcheroo/switch \
&& modprobe nvidia \
&& exit 0
sleep 0.01
let tries--
echo "tries left: $tries"
done
fi
2012-04-07 19:57:45 +04:00
echo "Cann't power on nVidia chip"
2011-12-24 00:15:11 +04:00
exit -1