29.11.2010

Switchable graphics and power consumption

Update: The switch seems to work reliably for me now. I switched to the ATI card, restarted X, used it, switched back and restarted X again. The procedure worked without problems. If I find time I will probably write a small program to switch the graphics card similar to the one I wrote for screen rotation.

It is completed! Switchable graphics are supported by the Linux kernel!
The usage is pretty simple. You have 2 graphics cards installed in the system. Thus, You need drivers for both of them. For the tm2-1090eg this means You need to make sure that both the radeon and the intel module are loaded after You booted up Your laptop. If one of them does not appear in the output of lsmod, there's something wrong or You blacklisted is. How to cope with that is not covered in this guide.
Starting with some-kernel-version, there is a node in the sysfs, specifically in /sys/kernel/debug/, which is called vgaswitcheroo. This neat little thing gives us the possibility to switch the graphics adapter at runtime and also to turn off the idle one.
(As root) You can write different 3 values into the switch at /sys/kernel/debug/vgaswitcheroo/switch using:
Code:
$ echo <value> > /sys/kernel/debug/vgaswitcheroo/switch
The values are:
  1. OFF - This one is simple. It turns off the video adapter which is currently unused. It is of high value, though. I noticed that upon turning off my ATI card, the battery lifetime actually increased by a factor of 5! Before using this, I could use my laptop for about an hour before the batteries went dry and now I am able to hack on it for around 5 hours without a break. At the end of this article I will present an upstart script to automatically turn off the ATI card on startup (I can't think of a reason to use the ATI card on Linux. According to other people, the drivers don't work well and there is no need for 3D acceleration at all.).
  2. DDIS - Switch to the discrete graphics card (the ATI one). This requires a restart of the X server to take effect and the whole switching is buggy on my system. Every one or two switches, the system completely crashes and I need to hard-reboot my laptop. However, it may work for some people and may work for everyone in the near future, so I included it here as well.
  3. DIGD - Switch to the integrated graphics card (the Intel one). The same restrictions and errors apply as for the previous value.
You can also read the state of the switch:
Code:
$ cat /sys/kernel/debug/vgaswitcheroo/switch
So far so good. Now as I mentioned, the ATI card is practically useless unless You want to play games (and even then I heard it's not really making things look good). If You want to turn it off, You may copy the following script (name it ati-disable.conf and place it in /etc/init as root, of course).
Code:
# ati-disable - Disable ATI graphics card
#
# Disable the dedicated ATI graphics card to save power.

description "Disable ATI graphics card"
author "Frederik Möllers"

start on started gdm

script
    if [ -w /sys/kernel/debug/vgaswitcheroo/switch ]
    then
        echo "OFF" > /sys/kernel/debug/vgaswitcheroo/switch
    fi
end script
Upon reboot, Your ATI card should be turned off. You can check if it is by using the cat command from above.

That's it! You're done!

Keine Kommentare:

Kommentar veröffentlichen