[LINUX] HOW-TO setup dual graphic cards in XBMC.

  Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Post Reply
alvess Offline
Junior Member
Posts: 6
Joined: Sep 2009
Reputation: 0
Location: Sweden
Big Grin  [LINUX] HOW-TO setup dual graphic cards in XBMC and switch between them with a remote
Post: #1
Change between two diffrent xorg.conf on XBMC [LIVE] Camelion 9.11 with a remote. Usefull for switching between a plasma, LCD or a beamer...
(This guide assume the user is "xbmc")

Connect to your XBMC computer with putty or similiar.
You can also open up a terminal session alt + F2.
All changes below is made by a terminal program or session.

1. Start irexec, needed for capturing remote commands and execute script:

Open rc.local

Code:
sudo nano /etc/rc.local

Add the following line before exit 0:

Code:
su -c '/usr/bin/irexec -d /home/xbmc/.lircrc' -l xbmc

2. Create config file for irexec (.lircrc):

Code:
sudo nano /home/xbmc/.lircrc

Add the following:

Code:
begin
remote = mceusb
prog = irexec
button = Clear
config = sudo sh /etc/X11/toggle.sh
repeat = 0
delay = 0
end

This will execute the script "toggle.sh" by pressing the "Clear" button on an MCE remote, change if needed.

3. Check if irexec starts (optional):

Reboot computer and put in this in the terminal:

Code:
ps -ef | grep irexec

If everyting works it should answer with:

xbmc 1554 1 0 14:00 ? 00:00:00 /usr/bin/irexec -d /home/xbmc/.lircrc
xbmc 2114 1646 0 14:16 pts/0 00:00:00 grep --color=auto irexec

4. Create two xorg.conf (one for each screen/setup):

First we need to know the PCI bus ID of the graphic cards.
(this is for nvidia cards, change to ati if needed)

Code:
lspci | grep -i nvidia

Output:

01:00.0 VGA compatible controller: nVidia Corporation G96 [GeForce 9500 GT] (rev a1)
02:00.0 VGA compatible controller: nVidia Corporation G96 [GeForce 9500 GT] (rev a1)

The first numbers tell us what we need to know.
- PCI:1:0:0 and PCI:2:0:0 this is the bus id's for each cards.

Create xorg0.conf

Code:
sudo nano /etc/X11/xorg0.conf

Add the text from your orginal xorg.conf or try mine.
Don't forget to change the BusID lines with our numbers.

Code:
# nvidia-xconfig: X configuration file generated by nvidia-xconfig
# nvidia-xconfig:  version 1.0  (buildmeister@builder63)  Mon Mar 23 15:33:27 PST 2009

Section "ServerLayout"
    Identifier     "Layout0"
    Screen       0 "Screen0"
    InputDevice    "Keyboard0" "CoreKeyboard"
    InputDevice    "Mouse0" "CorePointer"
EndSection

Section "Files"
EndSection

Section "Module"
    Load           "dbe"
    Load           "extmod"
    Load           "type1"
    Load           "freetype"
    Load           "glx"
EndSection

Section "InputDevice"
    # generated from default
    Identifier     "Mouse0"
    Driver         "mouse"
    Option         "Protocol" "auto"
    Option         "Device" "/dev/psaux"
    Option         "Emulate3Buttons" "no"
    Option         "ZAxisMapping" "4 5"
EndSection

Section "InputDevice"
    # generated from default
    Identifier     "Keyboard0"
    Driver         "kbd"
EndSection

Section "Monitor"
    Identifier     "Monitor0"
    VendorName     "Unknown"
    ModelName      "Unknown"
    HorizSync       28.0 - 33.0
    VertRefresh     43.0 - 72.0
    Option         "DPMS"
EndSection

Section "Monitor"
    Identifier     "Monitor1"
    VendorName     "Unknown"
    ModelName      "Unknown"
    HorizSync       28.0 - 33.0
    VertRefresh     43.0 - 72.0
    Option         "DPMS"
EndSection

Section "Device"
    Identifier    "Device0"
    Driver        "nvidia"
    VendorName    "NVIDIA Corporation"
    BusID         "PCI:1:0:0"
    Screen        0
EndSection
        
Section "Device"
    Identifier    "Device1"
    Driver        "nvidia"
    VendorName    "NVIDIA Corporation"
    BusID         "PCI:2:0:0"
    Screen        0
EndSection

Section "Screen"
    Identifier     "Screen0"
    Device         "Device0"
    Monitor        "Monitor0"
    DefaultDepth    24
    Option         "NoLogo" "True"
    SubSection     "Display"
        Depth       24
    EndSubSection
EndSection

Section "Screen"
    Identifier     "Screen1"
    Device         "Device1"
    Monitor        "Monitor1"
    DefaultDepth    24
    Option         "NoLogo" "True"
    SubSection     "Display"
        Depth       24
    EndSubSection
EndSection

Create the second file, xorg1.conf

Code:
sudo cp /etx/X11/xorg0.conf /etc/X11/xorg1.conf

5. Edit the files you just created, to make them use diffrent screens:

One should have "Screen0" the other "Screen1".

Code:
sudo nano /etc/X11/xorg1.conf

6. Make a script that change between the xorg0.conf and xorg1.conf:

Code:
sudo nano /etc/X11/toggle.sh

Add the following:

Code:
#!/bin/sh
# Shell script used to toggle between two xorg.conf files on XBMC [Live/Linux]
# namely $CONF_ONE and $CONF_TWO.
#
# To setup the script you need to change the value of two maybe three variables.
# Begin by changing $CONF_ONE and $CONF_TWO. They should contain the path to
# the two xorg.conf files you which to toggle between.
#
# The script will store information inside the $TOGGLE_CONF file (toggle.conf).

cd /etc/X11

# configuration (userdefined)
CONF_ONE="xorg0.conf"           # userdefined xorg.conf one
CONF_TWO="xorg1.conf"           # userdefined xorg.conf two

# constants
CONF="xorg.conf"                # path to the xorg.conf file used by X.org
TOGGLE_CONF="toggle.conf"       # path to this script's own configuration file
CONF_DEF=$CONF_ONE              # default xorg.conf that is used if no $TOGGLE_CONF file exists

# other vairables
FILE="" # store new the X.org config file name
LINE="" # used when readin this script's config file ($TOGGLE_CONF)

# set the given config file
setConfigFile() {
        FILE="$@" # get all args

        # set the new X.org config file
        echo "Setting $FILE as X.org's config"
        rm -f $CONF
        ln -s $FILE $CONF

        # save the name of the new config, so that we know which file to change
        # to the next time we toggle
        echo "Saving '$FILE' to $TOGGLE_CONF for later use"
        echo $FILE > $TOGGLE_CONF

        # in order for the changes to take effect, we need to restart X.org
        echo "Restarting XBMC"
        killall xbmc
        startx &
        sleep 2
        xbmc &

        exit
}

# read the script's config in order to know which X.org confing to toggle to
echo "Reading $TOGGLE_CONF"
if [ ! -f $TOGGLE_CONF ]; then
        echo "No $TOGGLE_CONF found, setting default X.org config"
        setConfigFile $CONF_DEF
else
        # read the script's config file
        while read LINE; do
                echo "Currently used X.org config: '$LINE'"

                # switch to the correct X.org config
                if [ $LINE != $CONF_ONE ]; then
                        setConfigFile $CONF_ONE
                else
                        setConfigFile $CONF_TWO
                fi
        done < $TOGGLE_CONF
fi

exit

7. Remove password from root:

Code:
sudo visudo

Add in the end of that file:

Code:
xbmc ALL=NOPASSWD: ALL


Thats it Wink

If you make small changes to the above it can also be usefull for:
-one graphic card with two resolution one for each vga/DVI port.

//alvess
(This post was last modified: 2010-09-05 17:26 by alvess.)
find quote
tequila Offline
Junior Member
Posts: 41
Joined: Nov 2009
Reputation: 0
Post: #2
thanks for this, hopefully I´ll be able to adapt that to a pov ion board Big Grin
find quote