Fglrx-hybrid-graphics

Acknowledgements
This article is largely inspired by Vga_switheroo and the post from gdbalbuzard, many many thanks to them!

Introduction
Since the release of ATI Catalyst 11.4, one with a laptop that has both a power-saving Intel integrated and a high-performance ATI discret graphic cards can switch between them under Linux. Here is how.

Emerge the latest ati-drivers
The first thing you would have to do is to get the latest ati-drivers

emerge -av ati-drivers

If you would like to have a graphical front end( literally, the Amd Catalyst Control Center ), you would have to add qt4 to the USE flag. emerge -pv ati-drivers x11-drivers/ati-drivers-11.7 USE="modules qt4 -debug (-multilib)"

For a complete guide on how to install the ati-drivers, refer to Gentoo Wiki Fglrx.

Hack the switchlibGL and switchlibglx File
The key to switching between hybrid graphics is that ATI provides two scripts, one is switchlibGL and the other one is switchlibglx. Unfortunately, they are not suitable for Gentoo. Thus a little bit hacking is necessary.

First, do make sure you have eselect-opengl installed( this is usually done as you follows the steps in installing the ati drivers): emerge -av eselect-opengl

Then, edit the /usr/lib/fglrx/switchlibGL and /usr/lib/fglrx/switchlibglx file: sudo vim /usr/lib/fglrx/switchlibGL /usr/lib/fglrx/switchlibglx delete ALL of the contents and fill them with the following script from gdbalbuzard.

Yes, both of them with the same script!

Now configure your xorg.conf: sudo aticonfig --initial If you already have an xorg.conf, you would probably have to remove it.

Now reboot your system and the xserver should work.

Switching between graphic cards
Switching cards with the following commands: Switch to discrete card: sudo aticonfig --px-dgpu Switch to integrated card: sudo aticonfig --px-igpu After switching, restarting the xserver is required!

You can view the current working card with: sudo aticonfig --px-list

Alternatively, you can use the Amd Catalyst Control Center to switch graphics. sudo amdcccle

Switch on the fly with hprofile
You should install hprofile first emerge -av hprofile Then in /etc/hprofile/profiles, create a folder named gpu mkdir /etc/hprofile/profiles/gpu cd /etc/hprofile/profiles/gpu

Then add following files:

Now we need to add the REAL scripts to do the switching for us:

As we finished those profile switching related scripts, we need to turn X server off and on:

Ok, all work is done. You can switch them with those commands: Switch to fglrx: sudo hprofile gpu.fglrx Switch to intel: sudo hprofile gpu.intel

Links

 * http://en.gentoo-wiki.com/wiki/Vga_switcheroo
 * http://en.gentoo-wiki.com/wiki/Fglrx
 * http://forums.gentoo.org/viewtopic-p-6748306.html?sid=97ce9a23f3a1d06f25a4942585fa9d0a#6748306