Difference between revisions of "Auto detect drivers for switchable graphics"
(→Script) |
(→Script) |
||
(10 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
== Auto detection and configuration for switchable graphics == | == Auto detection and configuration for switchable graphics == | ||
− | + | The purpose of this script is to allow a user to select either the integrated or discrete graphics chip in the BIOS and boot into Linux and have it work without any configuration. This scripts allows the user to switch between integrated Intel graphics using the xorg driver and discrete ATI graphics using the fglrx driver. This script was tested on a W500 running Debian Wheezy on Kernel 2.6.32-5 and Fglrx 11.2. At the time of writing this page, this is the quickest way to switch between integrated graphics and discrete graphics while using the binary ATI drivers. Switching under Linux requires a reboot and if one wishes to use binary drivers, switching is generally not possible without first uninstalling the binary drivers and reinstalling the open source drivers and viceversa. | |
− | |||
− | |||
− | |||
== Requirements == | == Requirements == | ||
− | The script only works to switch between and ATI video card with fglrx drivers and Intel Integrated graphics with xorg drivers. To select between the drivers, you simply select either 'Discrete' or 'Integrated' in the bios and then boot as normal. The fglrx and xorg drivers use different libraries and this is the reason they are not compatible with each other. The two specific libraries are: libGL.so.1.2 and libglx.so. The script requires copies of the libraries to be stores in /usr/lib/ and /usr/lib/xorg/modules/extensions/ respectively. | + | The script only works to switch between and ATI video card with fglrx drivers and Intel Integrated graphics with xorg drivers. To select between the drivers, you simply select either 'Discrete' or 'Integrated' in the bios and then boot as normal. The fglrx and xorg drivers use different libraries and this is the reason they are not compatible with each other. The two specific libraries are: libGL.so.1.2 and libglx.so. The script requires copies of the libraries to be stores in /usr/lib/ and /usr/lib/xorg/modules/extensions/ respectively. You must double check that the libraries are stored correctly as named below! I would first |
− | + | the original xorg libraries must be stored as: | |
− | + | /usr/lib/libGL.so.1.2.xorg | |
− | + | /usr/lib/xorg/modules/extensions/libglx.so.xorg | |
− | + | then the fglrx libraries must be stored as: | |
− | + | /usr/lib/libGL.so.1.2.fglrx | |
− | + | /usr/lib/xorg/modules/extensions/libglx.so.fglrx | |
In addition, xorg.conf files for each driver, intel and fglrx, must be stored as: | In addition, xorg.conf files for each driver, intel and fglrx, must be stored as: | ||
− | + | /etc/X11/xorg.conf.intel for integrated graphics | |
− | + | /etc/X11/xorg.conf.fglrx for discrete graphics | |
− | |||
== Initial Setup == | == Initial Setup == | ||
Line 30: | Line 26: | ||
The first step is select the integrated graphics chip in the bios and boot into Linux without fglrx installed. One then makes copies of the two libraries mentioned above. | The first step is select the integrated graphics chip in the bios and boot into Linux without fglrx installed. One then makes copies of the two libraries mentioned above. | ||
− | + | cp /usr/lib/libGL.so.1.2 /usr/lib/libGL.so.1.2.xorg | |
− | + | cp /usr/lib/xorg/modules/extensions/libglx.so /usr/lib/xorg/modules/extensions/libglx.so.xorg | |
The next step is to create a simple xorg.conf and save it in the same directory as xorg.conf as xorg.conf.intel. Simply is must contain: | The next step is to create a simple xorg.conf and save it in the same directory as xorg.conf as xorg.conf.intel. Simply is must contain: | ||
− | + | Section "Device" | |
− | + | Identifier "Anyname here will work" | |
− | + | Driver "intel" | |
− | + | EndSection | |
The next step is the same but with the ATI card selected in the BIOS and the fglrx drivers installed. | The next step is the same but with the ATI card selected in the BIOS and the fglrx drivers installed. | ||
− | + | cp /usr/lib/libGL.so.1.2 /usr/lib/libGL.so.1.2.fglrx | |
− | + | cp /usr/lib/xorg/modules/extensions/libglx.so /usr/lib/xorg/modules/extensions/libglx.so.fglrx | |
Next we need a copy of an xorg.conf for fglrx. You can simply generate one and make a copy using: | Next we need a copy of an xorg.conf for fglrx. You can simply generate one and make a copy using: | ||
− | + | aticonfig --initial | |
− | + | cp /etc/X11/xorg.conf /etc/X11/xorg.conf.fglrx | |
Now we are ready to setup the script. | Now we are ready to setup the script. | ||
Line 55: | Line 51: | ||
The script is below and can be saved as video_switch. | The script is below and can be saved as video_switch. | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | + | #!/bin/bash | |
+ | #check for intel integrated drivers | ||
+ | intel=`lspci | grep Integrated\ Graphics` | ||
+ | ATI=`lspci | grep ATI` | ||
+ | |||
+ | if [ "$intel" ] ; then | ||
+ | #setup drivers for intel Xorg driver | ||
+ | cp /etc/X11/xorg.conf.intel /etc/X11/xorg.conf | ||
+ | |||
+ | # switch libraries to fglrx libraries | ||
+ | # need to switch /usr/lib/libGL.so.1.2 and | ||
+ | # /usr/lib/xorg/modules/extensions/libglx.so | ||
+ | |||
+ | # I stored a copy of libGL.so.1.2 to libGL.so.1.2.xorg | ||
+ | # when xorg drivers were installed | ||
+ | # switch libraries to Xorg libraries | ||
+ | cp /usr/lib/libGL.so.1.2.xorg /usr/lib/libGL.so.1.2 | ||
+ | ln -s /usr/lib/libGL.so.1.2 libGL.so.1 | ||
+ | ln -s /usr/lib/libGL.so.1 libGL.so | ||
+ | |||
+ | cp /usr/lib/xorg/modules/extensions/libglx.so.xorg /usr/lib/xorg/modules/extensions/libglx.so | ||
+ | |||
+ | |||
+ | echo "Switched to Xorg Intel drivers" | ||
+ | |||
+ | fi | ||
+ | if [ "$ATI" ] ; then | ||
+ | #setup drivers for ATI fglrx driver | ||
+ | |||
+ | cp /etc/X11/xorg.conf.fglrx /etc/X11/xorg.conf | ||
+ | # switch libraries to fglrx libraries | ||
+ | # need to switch /usr/lib/libGL.so.1.2 and | ||
+ | # /usr/lib/xorg/modules/extensions/libglx.so | ||
+ | |||
+ | # I stored a copy of libGL.so.1.2 to libGL.so.1.2.fglrx | ||
+ | # when fglrx drivers were installed | ||
+ | cp /usr/lib/libGL.so.1.2.fglrx /usr/lib/libGL.so.1.2 | ||
+ | # link the other two libraries | ||
+ | ln -s /usr/lib/libGL.so.1.2 libGL.so.1 | ||
+ | ln -s /usr/lib/libGL.so.1 libGL.so | ||
+ | #same as before, stored a backup when fglrx was installed | ||
+ | cp /usr/lib/xorg/modules/extensions/libglx.so.fglrx /usr/lib/xorg/modules/extensions/libglx.so | ||
+ | |||
+ | echo "Switched to Discrete fglrx drivers" | ||
+ | |||
+ | echo "Switched to ATI fglrx drivers" | ||
+ | fi | ||
− | |||
− | |||
− | |||
We now set this as an init script to run during boot: | We now set this as an init script to run during boot: | ||
First copy the script | First copy the script | ||
− | + | cp video_switch /etc/init.d/ | |
Set it as executable: | Set it as executable: | ||
− | + | chmod +x /etc/init.d/video_switch | |
And set the script to run during boot | And set the script to run during boot | ||
− | + | update-rc.d video_switch defaults | |
Now you can select your graphics card in your bios and you are all ready to go! | Now you can select your graphics card in your bios and you are all ready to go! |
Latest revision as of 05:36, 26 February 2011
Contents
Auto detection and configuration for switchable graphics
The purpose of this script is to allow a user to select either the integrated or discrete graphics chip in the BIOS and boot into Linux and have it work without any configuration. This scripts allows the user to switch between integrated Intel graphics using the xorg driver and discrete ATI graphics using the fglrx driver. This script was tested on a W500 running Debian Wheezy on Kernel 2.6.32-5 and Fglrx 11.2. At the time of writing this page, this is the quickest way to switch between integrated graphics and discrete graphics while using the binary ATI drivers. Switching under Linux requires a reboot and if one wishes to use binary drivers, switching is generally not possible without first uninstalling the binary drivers and reinstalling the open source drivers and viceversa.
Requirements
The script only works to switch between and ATI video card with fglrx drivers and Intel Integrated graphics with xorg drivers. To select between the drivers, you simply select either 'Discrete' or 'Integrated' in the bios and then boot as normal. The fglrx and xorg drivers use different libraries and this is the reason they are not compatible with each other. The two specific libraries are: libGL.so.1.2 and libglx.so. The script requires copies of the libraries to be stores in /usr/lib/ and /usr/lib/xorg/modules/extensions/ respectively. You must double check that the libraries are stored correctly as named below! I would first
the original xorg libraries must be stored as:
/usr/lib/libGL.so.1.2.xorg /usr/lib/xorg/modules/extensions/libglx.so.xorg
then the fglrx libraries must be stored as:
/usr/lib/libGL.so.1.2.fglrx /usr/lib/xorg/modules/extensions/libglx.so.fglrx
In addition, xorg.conf files for each driver, intel and fglrx, must be stored as:
/etc/X11/xorg.conf.intel for integrated graphics /etc/X11/xorg.conf.fglrx for discrete graphics
Initial Setup
The first step is select the integrated graphics chip in the bios and boot into Linux without fglrx installed. One then makes copies of the two libraries mentioned above.
cp /usr/lib/libGL.so.1.2 /usr/lib/libGL.so.1.2.xorg cp /usr/lib/xorg/modules/extensions/libglx.so /usr/lib/xorg/modules/extensions/libglx.so.xorg
The next step is to create a simple xorg.conf and save it in the same directory as xorg.conf as xorg.conf.intel. Simply is must contain:
Section "Device" Identifier "Anyname here will work" Driver "intel" EndSection
The next step is the same but with the ATI card selected in the BIOS and the fglrx drivers installed.
cp /usr/lib/libGL.so.1.2 /usr/lib/libGL.so.1.2.fglrx cp /usr/lib/xorg/modules/extensions/libglx.so /usr/lib/xorg/modules/extensions/libglx.so.fglrx
Next we need a copy of an xorg.conf for fglrx. You can simply generate one and make a copy using:
aticonfig --initial cp /etc/X11/xorg.conf /etc/X11/xorg.conf.fglrx
Now we are ready to setup the script.
Script
The script is below and can be saved as video_switch.
#!/bin/bash #check for intel integrated drivers intel=`lspci | grep Integrated\ Graphics` ATI=`lspci | grep ATI` if [ "$intel" ] ; then #setup drivers for intel Xorg driver cp /etc/X11/xorg.conf.intel /etc/X11/xorg.conf # switch libraries to fglrx libraries # need to switch /usr/lib/libGL.so.1.2 and # /usr/lib/xorg/modules/extensions/libglx.so # I stored a copy of libGL.so.1.2 to libGL.so.1.2.xorg # when xorg drivers were installed # switch libraries to Xorg libraries cp /usr/lib/libGL.so.1.2.xorg /usr/lib/libGL.so.1.2 ln -s /usr/lib/libGL.so.1.2 libGL.so.1 ln -s /usr/lib/libGL.so.1 libGL.so cp /usr/lib/xorg/modules/extensions/libglx.so.xorg /usr/lib/xorg/modules/extensions/libglx.so echo "Switched to Xorg Intel drivers" fi if [ "$ATI" ] ; then #setup drivers for ATI fglrx driver cp /etc/X11/xorg.conf.fglrx /etc/X11/xorg.conf # switch libraries to fglrx libraries # need to switch /usr/lib/libGL.so.1.2 and # /usr/lib/xorg/modules/extensions/libglx.so # I stored a copy of libGL.so.1.2 to libGL.so.1.2.fglrx # when fglrx drivers were installed cp /usr/lib/libGL.so.1.2.fglrx /usr/lib/libGL.so.1.2 # link the other two libraries ln -s /usr/lib/libGL.so.1.2 libGL.so.1 ln -s /usr/lib/libGL.so.1 libGL.so #same as before, stored a backup when fglrx was installed cp /usr/lib/xorg/modules/extensions/libglx.so.fglrx /usr/lib/xorg/modules/extensions/libglx.so echo "Switched to Discrete fglrx drivers" echo "Switched to ATI fglrx drivers" fi
We now set this as an init script to run during boot:
First copy the script
cp video_switch /etc/init.d/
Set it as executable:
chmod +x /etc/init.d/video_switch
And set the script to run during boot
update-rc.d video_switch defaults
Now you can select your graphics card in your bios and you are all ready to go!
Sorry for the bad formatting, I just wanted to copy this somewhere and share it while it was still fresh in my head. I will come back to clean it up. --Cyberey66 05:52, 23 February 2011 (CET)