I do not
own a laptop with hybrid graphics, so I can't check what I wrote below (a few months ago, in fact) for accuracy. For that reason I was reluctant to post this how-to on LQ. But as I see that some people still have problems using switcheroo, I eventually decided to release it.
The intended audience is people owning a laptop including hybrid graphics, i.e. integrated in the CPU (mostly Intel integrated) + discrete graphical processor (nVidia or ATI).
It is a "Request For Comments, Corrections and Enhancements" intended to feed a future "How to Switch Between Integrated vs Discrete Graphic Processor with Slackware" to be included In SlackDocs
Some laptops include two graphic processors: one integrated in the CPU (mostly provided by Intel) and one dedicated (ATI or nVidia)
Users should be able to choose which processor to use: the integrated one if they want less power consumption/increased battery life or the discrete one for better graphic performance.
In some models a BIOS set up allows to switch on/off each processor. Of course switching off a processor decreases power usage.
In some models a physical switch, called a multiplexer or MUX can be used to choose which processor to use.
To check that your laptop do have hybrid graphics type in a terminal:
lspci -vnn | grep '\''[030\]'
As many lines in the output, as many processors. So if you get only one, you can stop reading this
PS Please somebody owning this kind of laptop check that 'lspci' shows both cards even if one is switched off in the BIOS and give us feedback.
What is Switcheroo and what can it do for you?
Switcheroo, or more accurately VGA switcheroo, is a kernel driver written by Dave Airlie to allow Linux users to switch between graphic processors on a running system.
This driver is built-in kernels shipped in Slackware 13.37 and 14.
It allows users to do three things:
- get information about their graphical processors’ state (ON or OFF) and the power used by it
- switch each processor ON/OFF
- switch to integrated or dedicated processors, either immediately or delayed. Here "delayed" means: "at next Xsession" (after an X restart)
In the recent kernels (kernel version > 2.6.37) it allows to choose which processor will be used at next reboot, acting as a "software MUX" (this is a guess, to be checked if possible by users, see the MGID and MIDS commands below).
The delayed switching between GPU is useful if you plan to switch at next X restart whilst X is running, as in that case immediate switching would kill X.
Some typical use cases:
1) You don't want to play games but would like to save power to increase battery life => make sure the integrated processor is ON, switch to it if needed then switch OFF the dedicated GPU
2) You want to play games : make sure the discrete processor is ON, then switch to it.
How can I use Switcheroo?
First, you will need a hybrid graphic which allows switcheroo's usage (of course). You can check that with following command (typed as root):
grep switcheroo /var/log/messages
The output should be a line like this one:
Jul 4 12:44:00 darkstar kernel: [ 8.609135] VGA switcheroo: detected switching method \_SB_.PCI0.GFX0.ATPX handle
And, KMS (kernel mode setting) should be enabled for the ATI or nVidia card. Hopefully, this is done by default in Slackware.
You communicate with Switcherooo through its interface, which is the following pseudo file:
either by reading it with the 'cat' command or by writing to it with the 'echo' command. We will detail these commands later.
Please note that this file is owned by root: all commands should be typed as root.
First, we need to mount the debug file system, which is needed to populate the /sys/kernel/debug pseudo directory (otherwise it would stay empty).
You can do that on the fly with following command:
mount -t debugfs debugfs /sys/kernel/debug
To have it mounted at start-up, append following line to your /etc/fstab:
none /sys/kernel/debug debugfs defaults 0 0
1) Acronyms used in display and setting commands
IGD: Integrated Graphic Device (mostly Intel)
DIS: denotes DIScrete graphic device (nVidia or ATI)
OFF - power off the unused device
ON - power on the unused device
DIGD - delayed switch to integrated device (at next X startup)
DDIS - delayed switch to discrete device at next X startup)
IGD - immediate switch to integrated device
DIS - immediate switch to discrete device
MIGD - mux switch to integrated device (if I am right, at next reboot)
MDIS - mux switch to discrete device (if I am right, at next reboot)
WARNING. DO NOT TRY TO USE MGID OR MGIS COMMAND for a kernel version < 2.6.38 (as the kernels installed by default on Slackware 13.37).
I have one report that after doing that it is not possible to get a working screen anymore.
2) to query the state of the graphic processors:
The output will look like this one:
The '+' in the first line means that at the moment the active GPU is the Integrated Graphic Device.
2) Available commands
The general form of the commands is:
echo <switcheroo_command> > /sys/kernel/debug/vgaswitcheroo/switch
where <switcheroo_command> can be one of the following:
OFF ON DIGD DDIS IDG DIS MIGD MDIS
and the ">" sign after <switcheroo_command> should be typed litteraly.
The immediate switching commands (IDG / IDS) shouldn't be used under X, use the delayed ones instead (DIDG / DDIS)
Note. In Slackware 13.37, MIGD and MDIS commands are not available in the 18.104.22.168 kernels, but they are available in 22.214.171.124 provided in /testing
What if I own an Optimus laptop?
For the time being, you will need to use bumblebee, SlackBuilds for it are provided by jgeboski see here
. To know more see Nvidia Optimus
on The Slackware Documentation Project.
Last news about Optimus support at time of writing are in Phoronix
see note #4 after the Feature Matrix about MUXed and MUX-less.