# [Solved]How to make switchable graphics with Fglrx?

## kkspeed

Hello everyone, I have a laptop with an Intel graphic card embeded inside my i3-330m CPU and a Radeon Mobility HD 5650. 

I've done the VGA switcheroo stuffs with opensource driver, thanks to: http://en.gentoo-wiki.com/wiki/Vga_switcheroo

Now with the release of ATI Catalyst 11.4 or later, it is said that it has built-in support for switching graphic cards. Anyone knows how to do this?Last edited by kkspeed on Thu Aug 04, 2011 9:59 am; edited 2 times in total

----------

## audiodef

 *kkspeed wrote:*   

> VGA switheroo stuffs 
> 
> 

 

SwitherWHAT?   :Shocked: 

 :Razz:   :Razz:   :Razz: 

----------

## kkspeed

 *audiodef wrote:*   

>  *kkspeed wrote:*   VGA switheroo stuffs 
> 
>  
> 
> SwitherWHAT?  
> ...

 

Sorry, it's switcheroo... I mean I can switch graphics cards with the opensource driver now.

----------

## Ant P.

It probably means switching between two ATI cards. Switching between a binary blob and the open Intel driver probably won't work well even if it's supported. But it could be worse, at least you're not stuck with an nVidia optimus brick...

----------

## tclover

VGASWITCHEROO IS AVAILABLE ONLy FOR RADEON/i915(or i820? or i960?).

----------

## kkspeed

 *tclover wrote:*   

> VGASWITCHEROO IS AVAILABLE ONLy FOR RADEON/i915(or i820? or i960?).

 

Yep, but it is said that ATI Catalyst 11.4 or later supports PowerXpress, which can make switching graphics possible. I've got no idea how to do this, since if I run aticonfig to generate an xorg.conf and startx with embeded graphic card enabled, the X won't start and will give me a list of errors.

----------

## ad_meis

Ant P., what is the issue with NVdia Optimus?

I am planning to buy a thinkpad that comes with that card, is it bad? Could please give me some reference to get informed?

many thanks

m

----------

## gdbalbuzard

hello gentoo users,

I managed to use the switchable capabilities of the ati driver within gentoo (amd64). Below are some explanation. If someone want to update the gentoo wiki based on these explanation, correct my english errors or to extend what I did, I see no objection.

The explanation below worked on my laptop with the ati-drivers version 11.5 and 11.6 (I have not tested for older version).

preliminaries : I have one hp pavilion dv6-6080 laptop with a core i7-2630M processor and a ati radeon 6470M discrete graphic card.

lspci | grep -i vga

00:02.0 VGA compatible controller: Intel Corporation 2nd Generation Core Processor Family Integrated Graphics Controller (rev 09)

01:00.0 VGA compatible controller: ATI Technologies Inc NI Seymour [AMD Radeon HD 6470M] (rev ff)

The configuration is done in two step : 

step 1 : install the ati driver with emerge. In order to have switchable capabilities, you need to add two scripts that are not install by the ebuild. 

These two script are named switchlibGL  and switchlibglx and should be located in the /usr/lib64/fglrx/ folder. 

Some scripts are shipped with the ati-drivers but they do not work for gentoo so don't blame any gentoo developpers for them being absent. Basicly the purpose of this scripts is to manage symlinks between the libGL and libglx dynamic library. This is exactly (I guess) what eselect opengl set does. 

For the sake of simplicity I am using the same script for both switchlibGL and switchlibglx. Below is that script. As one can notice it is based on one AMD script (in fact the one you could find in the driver distro and I modify it in order to reflect the gentoo way of doing things) so I don't know if there is any legal issue in modifying the script and then using it.

```
#!/bin/bash

#  switchlibGL

#

#  Copyright (c) 2011 Advanced Micro Devices, Inc.

#

#  Purpose:

#    For switch between AMD and Intel graphic driver library.

#

#  Usage:

#  switchlibGL   amd|intel|query

#    amd:   switches to the AMD version of libGL.

#    intel: switches to the open-source version of libGL .

#    query: checks, which version is currently active and prints either "amd"

#    or "intel" or "unknown" on the standard output.

#    must be root to execute this script

ARCH=`uname -m`

E_ERR=1

# Check if root

if [ "`whoami`" != "root" ]; then

  echo "Must be root to run this script." 1>&2

  exit $E_ERR

fi

# One parameter

if [ $# -ne 1 ]; then

  echo "Usage: `basename $0` amd|intel|query " 1>&2

  echo "Please choose one parameter " 1>&2

  exit $E_ERR

fi

# Switch to right mode

case "$1" in

  "amd" )

        eselect opengl set ati

  ;;

  "intel" )

        eselect opengl set xorg-x11

  ;;

  "query" )

        current=`eselect opengl show`

        case "$current" in

          "ati" )

             echo "amd"

          ;;

          "xorg-x11" )

             echo "intel"

          ;;

        esac

  ;;

  * ) echo "Usage: `basename $0` amd|intel|query" 1>&2; exit $E_ERR;;

  # other than amd|intel|query parameter report an error

esac

#  A zero return value from the script upon exit indicates success.

exit 0
```

Step 2 : configure Xorg

I find out that Xorg was always using the integrated card instead of the discrete one. I guess this behavior is due to the fact that the integrated card come first in the list of device. So I created this basic xorg.conf file in /etc/X11/ 

```
Section "Device"

   Identifier "ATI"

   Driver "fglrx"

   Busid  "PCI:1:0:0:0"

EndSection
```

It tells Xorg to use the device located on the busid PCI:1:0:0:0 with the ati driver.

If you relaunch the Xorg server, you should now use the discrete graphic card instead of the integrated one. This ends the configuration.

Usage (ie how to switch between discrete and integrated graphic card):

In order to switch between the integrated and discrete card, you need to run the ati catalyst control center as user root. This free the tab switchable graphic. Select the graphic card you want and quit. The application should tell you, you need to reset your computer before the change to take effect but in my case I only need to logout (I am using the gnome desktop and GDM). You do not need to modify or delete the xorg.conf file. It seems the ati driver take of everything for you.

It could be a good idea that all users belonging to the group video be able to switch between graphic card but I do not know how to allow this. 

For hprofile user : it seems that the behavior of the driver is controlled by the file /etc/ati/amdpcsdb (at least). The difference between this file in ati mode (ie usint the ATI GPU) and intel mode is :

diff amdpcsdb_ati amdpcsdb_intel

```
 

34c34

< PX_ACTIVEGPU=SDISCRETEED

---

> PX_ACTIVEGPU=SINTEGRATED

35a36,37

> PX_GPUDOWN=R00010000

> PCICONFIG=R021060670700100000000003100000000C0000A000000000040050C600000000015000000000000000000000000000000000FEFF500000000000000003010000

44c46

< RebootTimeStamp=S0111/06/06 19:24:01

---

> RebootTimeStamp=S0111/06/06 06:29:08

```

So it could be a way of managing "on the fly" which graphic card is used. However I have not tested if this works or not.

troubleshooting :

I encountered some trouble with virtual console and framebuffer. it seems this is rather common with ati drivers.

Conclusion : I hope these explanations will be helpfull to the gentoo users. I think it is far from being perfect but it is a good starting point (at least it works on my laptop). Especially the scripts switchlibGL and switchlibglx could be rewritten and integrated in the ebuild or contibuted to ATI.

----------

## Ant P.

 *ad_meis wrote:*   

> Ant P., what is the issue with NVdia Optimus?
> 
> I am planning to buy a thinkpad that comes with that card, is it bad? Could please give me some reference to get informed?
> 
> many thanks
> ...

 

nVidia outright refuses to support it on Linux. You'll be buying a very expensive, very hot piece of silicon you aren't allowed to even use.

----------

## kkspeed

 *gdbalbuzard wrote:*   

> hello gentoo users,
> 
> I managed to use the switchable capabilities of the ati driver within gentoo (amd64). Below are some explanation. If someone want to update the gentoo wiki based on these explanation, correct my english errors or to extend what I did, I see no objection.
> 
> The explanation below worked on my laptop with the ati-drivers version 11.5 and 11.6 (I have not tested for older version).
> ...

 

Thank you very much! I managed to switch graphics and create hprofile shortcut. I've written a Wiki: http://en.gentoo-wiki.com/wiki/Fglrx-hybrid-graphics. Please help me improve it![/url]

----------

## Enrico Tagliavini

Hi there! I want to thanks both gdbalbuzard and kkspeed for this work. I've added it to ati-drivers-11.9 ebuild in X11 overlay. It will be in the main portage tree in a couple of days. Be aware i don't have the hardware to test on, so i've added the scripts without testing. If you want to test and report back here https://bugs.gentoo.org/show_bug.cgi?id=366397 your help is always welcome  :Very Happy: .

Also i think one of the two switchlib{GL,glx} scripts can just be an exit 0 and nothing more since i guess amdcccle|aticonfig calls them together. If someone with the hardware can test and confirm it works that way, many thanks  :Smile: .

Cheers

----------

## Climber

Hi,

I have a laptop with both ati and intel graphic cards and I want to try to use both graphic cards. Now in my make.conf I have

VIDEO_CARDS="intel"

have I to add radeon on this variable writing VIDEO_CARDS="intel radeon" before starting emerging ati-drivers?

Thank you

----------

## Enrico Tagliavini

radeon and ati-drivers shares nothing at all. ati-drivers is the propietary driver for AMD HD graphic cards, radeon is the open source one. You can add fglrx to VIDEO_CARDS if you want (it is not mandatory), but radeon is not needed. I suggest to you to not mix, and always enable one driver at a time to be sure to not use some piece from one and some piece from the other. You can have both installed at the same time and be sure to not mix them once you are used to them.

----------

## Climber

 *Enrico Tagliavini wrote:*   

> radeon and ati-drivers shares nothing at all. ati-drivers is the propietary driver for AMD HD graphic cards, radeon is the open source one. You can add fglrx to VIDEO_CARDS if you want (it is not mandatory), but radeon is not needed. I suggest to you to not mix, and always enable one driver at a time to be sure to not use some piece from one and some piece from the other. You can have both installed at the same time and be sure to not mix them once you are used to them.

 

Ok, now I have neither radeon neither ati. I'll install only ati-drivers and I will try to use the "vga-switch". Wish my good luck  :Smile: 

I will write you for any problem.

Excuse me: are you italian? Because I think could be easier to talk in italian (via PM)

Thank you

----------

## Enrico Tagliavini

Yes I'm Italian, but no PM please, let's talk here so we can help others with the same issue.

With "vga-switch" to you mean vga_switcheroo? If so, stop now. Vga_switcheroo works only with open source drivers (so radeon in the AMD case). As you can read in previous posts, ati-drivers has the switcher builtin. Be sure to use versione 11.10 or up of ati-drivers.

----------

## Climber

I want to configure my laptop to use both graphic cards using this guide: http://en.gentoo-wiki.com/wiki/Fglrx-hybrid-graphics with "vga-switch" I only meant a software/driver to change the working graphic card.

----------

## Enrico Tagliavini

Very well then  :Smile: . You don't need to replace the contenent of /usr/lib/fglrx/switchlibGL /usr/lib/fglrx/switchlibglx scripts couse i've included them in the version 11.9 and 11.10 of ati-drivers (i'm the co-mantainer of this gentoo package).

If you find some issue, or you have suggestions to improve the package feel free to share  :Smile: . Unluck i don't have the hardware to test this graphic switch support, so i've added this feature to the package blindly.

----------

## Climber

Hi, I have installed ati-drivers and I wrote

sudo aticonfig --initial

but the program returns

sudo aticonfig --initial

Password: 

Invalid MIT-MAGIC-COOKIE-1 keyUninitialised file found, configuring.

PowerXpress error: Cannot stat '/usr/lib64/fglrx/switchlibGL': No such file or directory

Failed to initialize libglx for discrete GPU

Using /etc/X11/xorg.conf

Saving back-up to /etc/X11/xorg.conf.original-0

Could someone help me?

----------

## Enrico Tagliavini

Please use ati-drivers-11.10, other versions don't have the switch vga capability

----------

## Climber

Ok, I emerged ati-drivers-11.10 and I run 

sudo aticonfig --initial

after xdm restarting X server doesn't start but sudo aticonfig --px-list said I was on ati gpu.

Using sudo aticonfig --px-dgpu and sudo aticonfig --px-igpu I can switch between both gpu.

So the driver works but X server doesn't start.

What can I do?

Thank you

----------

## Climber

Could some admin remove the "SOLVED" label because I still have a problem?

Thank you

----------

## bojojo2020

The new ati radeon cards (2011 and up) have mux-less connectors.  On MUX-less systems, the discrete card is solely for rendering, not display. That means the fglrx driver must communicate with the intel driver to drive vga/hdmi/lvds outputs. The fglrx 11.12 is only working with  <=x11-drivers/xf86-video-intel-2.15*

----------

## hirakendu

@ bojojo2020: many thanks for the hint about the xf86-video-intel package version.

@ Climber: you may need to specify the bus ID of the radeon device in the xorg.conf file. Also, you need an older xf86-video-intel as mentioned by bojojo2020.

Thanks to this thread in general, about running fglrx on radeon hybrid graphics. I managed to run fglrx on my Sony Vaio notebook that has the newer muxless Intel/Radeon hybrid graphics. I have put together this howto which may be useful for those with similar systems.

----------

## Climber

NOW WORKS!

Thank you so much for the help!

I emerged x11-drivers/ati-drivers-12.2 and followed the instructions on this link http://en.gentoo-wiki.com/wiki/Fglrx-hybrid-graphics to switch from integrated GPU to discrete GPU and now it works.

----------

## Gabriel_Blake

Could someone help me out ?  I have a laptop with hybrid graphics ( Intel + Radeon 5650 HD ). It's muxless as far as I know. I've managed to run the switcheroo approach, but no 3D acceleration :/

I can set the cards in my BIOS to "switchable" or "discrete". I can get fglrx to work on "discrete" and I can use the "intel" driver on "switchable" (without powering down the radeon card). However despite using all the manuals, I was unable to make the switching work. 

I've been trying for over a year! 

Here's my current Xorg log:

```
[   117.090] 

X.Org X Server 1.12.2

Release Date: 2012-05-29

[   117.091] X Protocol Version 11, Revision 0

[   117.091] Build Operating System: Linux 3.2.12-gentoo x86_64 Gentoo

[   117.091] Current Operating System: Linux blackstar 3.2.12-gentoo #17 SMP PREEMPT Sat Jun 9 14:20:02 CEST 2012 x86_64

[   117.091] Kernel command line: root=/dev/sda2 acpi_osi=Linux nomodeset

[   117.091] Build Date: 29 June 2012  11:22:48AM

[   117.092]  

[   117.092] Current version of pixman: 0.26.0

[   117.093]    Before reporting problems, check http://wiki.x.org

        to make sure that you have the latest version.

[   117.093] Markers: (--) probed, (**) from config file, (==) default setting,

        (++) from command line, (!!) notice, (II) informational,

        (WW) warning, (EE) error, (NI) not implemented, (??) unknown.

[   117.094] (==) Log file: "/var/log/Xorg.0.log", Time: Thu Jul  5 13:06:15 2012

[   117.094] (==) Using config file: "/etc/X11/xorg.conf"

[   117.094] (==) Using config directory: "/etc/X11/xorg.conf.d"

[   117.095] (==) Using system config directory "/usr/share/X11/xorg.conf.d"

[   117.095] (==) ServerLayout "aticonfig Layout"

[   117.095] (**) |-->Screen "aticonfig-Screen[0]-0" (0)

[   117.095] (**) |   |-->Monitor "aticonfig-Monitor[0]-0"

[   117.095] (**) |   |-->Device "aticonfig-Device[0]-0"

[   117.095] (==) Automatically adding devices

[   117.095] (==) Automatically enabling devices

[   117.096] (==) FontPath set to:

        /usr/share/fonts/misc/,

        /usr/share/fonts/TTF/,

        /usr/share/fonts/OTF/,

        /usr/share/fonts/Type1/,

        /usr/share/fonts/100dpi/,

        /usr/share/fonts/75dpi/

[   117.096] (==) ModulePath set to "/usr/lib64/xorg/modules"

[   117.096] (**) Extension "Composite" is enabled

[   117.096] (II) The server relies on udev to provide the list of input devices.

        If no devices become available, reconfigure udev or disable AutoAddDevices.

[   117.096] (II) Loader magic: 0x7d5ae0

[   117.096] (II) Module ABI versions:

[   117.096]    X.Org ANSI C Emulation: 0.4

[   117.096]    X.Org Video Driver: 12.0

[   117.096]    X.Org XInput driver : 16.0

[   117.096]    X.Org Server Extension : 6.0

[   117.097] (--) PCI:*(0:0:2:0) 8086:0046:1025:0365 rev 18, Mem @ 0xf0000000/4194304, 0xd0000000/268435456, I/O @ 0x00001800/8

[   117.097] (--) PCI: (0:2:0:0) 1002:68c1:1025:0365 rev 0, Mem @ 0xb0000000/268435456, 0xafee0000/131072, I/O @ 0x00002000/256, BIOS @ 0x????????/131072

[   117.097] (II) Open ACPI successful (/var/run/acpid.socket)

[   117.097] (II) "extmod" will be loaded by default.

[   117.097] (II) "dbe" will be loaded by default.

[   117.097] (II) "glx" will be loaded by default.

[   117.097] (II) "record" will be loaded by default.

[   117.097] (II) "dri" will be loaded by default.

[   117.097] (II) "dri2" will be loaded by default.

[   117.097] (II) LoadModule: "extmod"

[   117.098] (II) Loading /usr/lib64/xorg/modules/extensions/libextmod.so

[   117.098] (II) Module extmod: vendor="X.Org Foundation"

[   117.098]    compiled for 1.12.2, module version = 1.0.0

[   117.098]    Module class: X.Org Server Extension

[   117.098]    ABI class: X.Org Server Extension, version 6.0

[   117.098] (II) Loading extension MIT-SCREEN-SAVER

[   117.098] (II) Loading extension XFree86-VidModeExtension

[   117.098] (II) Loading extension XFree86-DGA

[   117.098] (II) Loading extension DPMS

[   117.098] (II) Loading extension XVideo

[   117.098] (II) Loading extension XVideo-MotionCompensation

[   117.098] (II) Loading extension X-Resource

[   117.098] (II) LoadModule: "dbe"

[   117.098] (II) Loading /usr/lib64/xorg/modules/extensions/libdbe.so

[   117.098] (II) Module dbe: vendor="X.Org Foundation"

[   117.098]    compiled for 1.12.2, module version = 1.0.0

[   117.098]    Module class: X.Org Server Extension

[   117.098]    ABI class: X.Org Server Extension, version 6.0

[   117.098] (II) Loading extension DOUBLE-BUFFER

[   117.098] (II) LoadModule: "glx"

[   117.098] (II) Loading /usr/lib64/xorg/modules/extensions/libglx.so

[   117.136] (II) Module glx: vendor="Advanced Micro Devices, Inc."

[   117.136]    compiled for 6.9.0, module version = 1.0.0

[   117.136] (II) Loading extension GLX

[   117.136] (II) LoadModule: "record"

[   117.136] (II) Loading /usr/lib64/xorg/modules/extensions/librecord.so

[   117.136] (II) Module record: vendor="X.Org Foundation"

[   117.136]    compiled for 1.12.2, module version = 1.13.0

[   117.136]    Module class: X.Org Server Extension

[   117.136]    ABI class: X.Org Server Extension, version 6.0

[   117.136] (II) Loading extension RECORD

[   117.136] (II) LoadModule: "dri"

[   117.155] (WW) Warning, couldn't open module dri

[   117.155] (II) UnloadModule: "dri"

[   117.155] (II) Unloading dri

[   117.155] (EE) Failed to load module "dri" (module does not exist, 0)

[   117.155] (II) LoadModule: "dri2"

[   117.155] (WW) Warning, couldn't open module dri2

[   117.155] (II) UnloadModule: "dri2"

[   117.155] (II) Unloading dri2

[   117.155] (EE) Failed to load module "dri2" (module does not exist, 0)

[   117.155] (II) LoadModule: "fglrx"

[   117.155] (II) Loading /usr/lib64/xorg/modules/drivers/fglrx_drv.so

[   117.187] (II) Module fglrx: vendor="FireGL - AMD Technologies Inc."

[   117.187]    compiled for 1.4.99.906, module version = 8.98.2

[   117.187]    Module class: X.Org Video Driver

[   117.188] (II) Loading sub module "fglrxdrm"

[   117.188] (II) LoadModule: "fglrxdrm"

[   117.188] (II) Loading /usr/lib64/xorg/modules/linux/libfglrxdrm.so

[   117.188] (II) Module fglrxdrm: vendor="FireGL - AMD Technologies Inc."

[   117.188]    compiled for 1.4.99.906, module version = 8.98.2

[   117.188] (II) AMD Proprietary Linux Driver Version Identifier:8.98.2

[   117.188] (II) AMD Proprietary Linux Driver Release Identifier: 8.98                                 

[   117.188] (II) AMD Proprietary Linux Driver Build Date: Jun 11 2012 11:57:59

[   117.188] (--) using VT number 7

[   117.190] (WW) Falling back to old probe method for fglrx

[   117.207] (II) Loading PCS database from /etc/ati/amdpcsdb

[   117.208] (--) Chipset Supported AMD Graphics Processor (0x68C1) found

[   117.209] (WW) fglrx: No matching Device section for instance (BusID PCI:0@2:0:1) found

[   117.209] (II) fglrx: intel VGA device detected, load intel driver.

[   117.209] (II) LoadModule: "intel"

[   117.209] (II) Loading /usr/lib64/xorg/modules/drivers/intel_drv.so

[   117.209] (II) Module intel: vendor="X.Org Foundation"

[   117.209]    compiled for 1.12.2, module version = 2.19.0

[   117.209]    Module class: X.Org Video Driver

[   117.209]    ABI class: X.Org Video Driver, version 12.0

[   117.212] ukiDynamicMajor: found major device number 249

[   117.212] ukiDynamicMajor: found major device number 249

[   117.212] ukiOpenByBusid: Searching for BusID PCI:2:0:0

[   117.212] ukiOpenDevice: node name is /dev/ati/card0

[   117.212] ukiOpenDevice: open result is 8, (OK)

[   117.212] ukiOpenByBusid: ukiOpenMinor returns 8

[   117.212] ukiOpenByBusid: ukiGetBusid reports PCI:2:0:0

[   117.213] (WW) PowerXpress feature is not supported on A+I Mux platform. Please uninstall fglrx driver.

[   117.213] (EE) No devices detected.

[   117.213] 

Fatal server error:

[   117.213] no screens found

[   117.213] 

Please consult the The X.Org Foundation support 

         at http://wiki.x.org

 for help. 

[   117.213] Please also check the log file at "/var/log/Xorg.0.log" for additional information.

[   117.213] 

```

What could be the problem ? What's the proper kernel config (kms,drm) ? Any help would be appreciated  :Smile: 

----------

