-   Slackware (
-   -   How-to switch between Graphics Processors using VGA Switcheroo (

Didier Spaier 11-15-2012 04:35 PM

How-to switch between Graphics Processors using VGA Switcheroo
Caveat emptor

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[02]\]'
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
The commands

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:

cat /sys/kernel/debug/vgaswitcheroo/switch
The output will look like this one:

1:DIS: :Pwr:0000:01:00.0

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:
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 kernels, but they are available in 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.

REFERENCES see note #4 after the Feature Matrix about MUXed and MUX-less.

Darth Vader 11-15-2012 05:40 PM

I would like to add that the best possible advice is to not enable the discrete graphics card for any reason, particularly if you use suspend and hibernate. Read: there is great stability issues.

Also, the power management support offered by the ATI and NVIDIA open source drivers are below critical and the risk of getting a heater ... err, fried laptop is very high.

If you still have dual graphics, use vga-switcheroo to deactivate discrete graphics card. Your laptop will work cooler and the battery will last longer.

But, you should remember to activate it again, before shutdown/reboot to make happy your BIOS.

Martinus2u 11-16-2012 12:52 PM

fwiw, my company laptop (lenovo) has Nvidia Optimus 3100. I haven't bothered with bumblebee. I switch to discrete graphics in the BIOS before booting Linux, and use the Nvidia binary driver. It seems to work well. Only once I had a panic after resuming, but that could have been due to any other reason.

I should add, I specifically use the installation for 3D graphics, otherwise I would switch to internal graphics in the BIOS and use the i915 driver. That configuration also works.

With a standard kernel I can see no way to get the Optimus configuration going.

All times are GMT -5. The time now is 12:01 PM.