Turning off discrete graphics for Acer Aspire 4750G

OPTIMUS on Linux has always been a pain in the ass for Linux users. It drains your battery power but you can't use it! Here is a way to turn it off on Linux, enjoy.

Install acpi_call

From github
git clone https://github.com/mkottman/acpi_call.git
cd acpi_call
make
sudo cp acpi_call.ko /lib/modules/`uname -r`/kernel/drivers/acpi
From AUR
If you are using Arch Linux, it's available at here

Add startup script
For 4750G, the acpi_call is "\_SB.PCI0.PEG0.PEGP._OFF".
Save the following script to 'discrete-off' and copy it to '/etc/rc.d' or '/etc/init.d' depend on your system.
#!/bin/bash

. /etc/rc.conf
. /etc/rc.d/functions

case "$1" in
start)
    if cat /proc/cmdline | grep 'powersave'; then
      if lsmod | grep -q acpi_call; then
        stat_busy "Stopping discrete graphics"
        echo '\_SB.PCI0.PEG0.PEGP._OFF' > /proc/acpi/call
        
        result=$(cat /proc/acpi/call)
        case "$result" in
          Error*)
            stat_fail
            ;;
          *)
            add_daemon discrete-off
            stat_done
            ;;
        esac
      else
        echo 'The acpi_call module is not loaded'
        exit 1
      fi
    fi
    ;;
stop)
    if cat /proc/cmdline | grep 'powersave' && lsmod | grep -q acpi_call; then
      stat_busy "Rusuming discrete grahpics"
      echo '\_SB.PCI0.PEG0.PEGP._ON' > /proc/acpi/call
      stat_done
    fi
    ;;
*)
    echo "Usage: /etc/rc.d/discrete-off {start|stop}"
    exit 1
    ;;
esac

exit 0

Now register the script to be start up at boot. For Arch Linux, add discrete-off to your '/etc/rc.conf' DAEMONS variable. For ubuntu, you should probably run 'sudo update-rc.d -f discrete-off defaults'.

Optional: Add GRUB entry
If you look at discrete-off script, you'll find that I use a keyword in /proc/cmdline to enable the script. If you don't like the check, simply remove it, else you have to add a new entry for your GRUB menu.lst. For my case:

# (0) Arch Linux
title  Arch Linux Powersave
root   (hd0,4)
kernel /boot/vmlinuz26-mainline root=/dev/sda5 ro vga=792 powersave
initrd /boot/kernel26-mainline.img

Remark

With NVIDIA card turned, my battery life grow from ~2 hr to ~3.5 hr!!! Thanks for the people who contributed to this!
For more information, checkout Linux Hybrid Graphics.

留言

這個網誌中的熱門文章

決定了!!!

P.S. I Love You

Tips: PPTP client on Openwrt