Twinview Example
From Gentoo Linux Wiki
Dual-Head is where you have 2 monitors plugged into the same video card or 2 or more monitors plugged into more than one video card.
In this example, we assume 2 monitors plugged into a single video card which has 2 Monitor (DVI or VGA) outputs and possibly a S-VIDEO output (for TV's)
Contents |
[edit] Pre-requisites
To enable Dual Head displays (using both video connectors on your video card), you must configure your X server.
This assumes you have already installed the nVidia drivers, as described above. You may wish to refer to
- the Man pages for /etc/X11/xorg.conf'
- Gentoo nVidia Guide
- /usr/share/doc/nvidia-drivers-180.29/README.bz2 (replace the version with the appropriate version of your nVidia drivers)
Basically, you need to
- Identify the video card(s) (See #Device Section)
- Identify your monitors (See #Monitor Section)
- Identify how your group your monitors (See #Screen Section)
- Identify how you want your X system to use your monitors (See #ServerLayout Section)
You can have multiple 'setups' (ServerLayouts) and choose which one you want to use, at X startup time.
[edit] Assumptions
The following /etc/X11/xorg.conf file assumes
- A single nVidia Video card with 2 outputs (3 if you include S-VIDEO) - I state nVidia here as the configuration options include nVidia driver specific values. These values may differ for different manufacturers.
- an LCD monitor, named CMV
- a CRT monitor, named LG
Whilst the CRT monitor is capable of higher resolutions than the LCD, this example has both monitors at the same resolution.
[edit] What you get
The result of this /etc/X11/xorg.conf is
- The LCD monitor is primary, at resolution 1280x1024
- The CRT monitor is secondary, at resolution 1280x1024
- The LCD is positioned to the LEFT of the CRT monitor
- One large desktop, stretching over both monitors.
This gives us the ability to
- have a window span both monitors
- to easily drag windows between monitors
You cannot use applications in 'full screen mode', spanning both monitors, although, you can have windows spanning both monitors. For example, playing a movie with mplayer, in full screen mode, will play only on only one monitor, not stretched across both monitors, whereas, if you have it playing in windowed mode, it can span both monitors.
[edit] xorg.conf entries explained
[edit] Devices Section
This is where we identify the various video cards that are plugged into our machine. In this example, there is one.
- we give the video card a name "Device[0]" - you can call it whatever you like.
- tell X to use the 'nvidia' driver
- document the Vendor of the card (not used by the nVidia drivers, but it doesn't hurt)
- document the Board name (once again, not used by the nVidia drivers)
- Assign the primary display output plug on the card to be plug 0, using the 'Screen' option.
| Code: Devices Section |
Section "Device"
Identifier "Device[0]"
Driver "nvidia"
VendorName "Leadtek nVidia"
BoardName "geForce GTS 250"
# BusID "AGP:1:0:0"
Screen 0
EndSection
|
[edit] Monitors Section
In this example,
- as per the assumptions, we have 2 monitors
- both monitors are given a 'name', using 'Identifier'
- we document which is which, using the VendorName and ModelName
- both monitors can auto-configure their horizontal and vertical frequencies using DPMS as true - meaning we don't have to look up what the monitors frequency limits are, we let X figure it out.
| Code: Monitors Section |
Section "Monitor"
Identifier "Monitor[0]-CMV"
Option "VendorName" "CMV"
Option "ModelName" "CT-934D"
Option "DPMS" "true"
EndSection
Section "Monitor"
Identifier "Monitor[1]-LG"
Option "VendorName" "LG"
Option "ModelName" "Studioworks 900B"
Option "DPMS" "true"
EndSection
|
[edit] Screens Section
In this example,
- The nVidia logo is disabled (NoLogo)
- support switching video resolutions using the CTRL-ALT Keypad-plus and CTRL-ALT Keypad-minus keystrokes whereby we specify the various resolutions we are interested in.
- use nVidia driver options to tell it to do the desktop spanning ('TwinView')
- use nVidia driver options to tell the orientation of the monitors ('TwinViewOrientation')
- Set our full desktop to be the size of both monitors (2560 1024)
Note: we don't use the '/etc/X11/xorg.conf' options to establish the dual head, in this case.
| Code: Screen Section |
# Dual head, single desktop, spanning both
Section "Screen"
Identifier "Screen[0]-Dual-Head"
Monitor "Monitor[0]-CMV"
Device "Device[0]"
DefaultDepth 24
Option "NoLogo" "true"
Option "AddARGBGLXVisuals" "true"
Option "UseEvents" "false"
Option "RenderAccel" "true"
Option "HWcursor"
Option "TwinView"
Option "MetaModes" "1280x1024,1280x1024; 1280x1024; 1024x768,1024x768; 1024x768; 800x600,800x600; 800x600"
Option "TwinViewOrientation" "RightOf"
Option "SecondMonitorHorizSync" "UseEdidFreqs"
Option "SecondMonitorVertRefresh" "UseEdidFreqs"
SubSection "Display"
Viewport 0 0
Virtual 2560 1024
Depth 24
Modes "1280x1024"
EndSubSection
EndSection
|
[edit] ServerLayout Section
In this example,
- Identify this whole conifiguratoin as 'DualSingleDesktop'
- using the Screen which is configured as dual head
- using the keyboard and mouse
This represents a single X 'startup' configuration. You may have multiple of these to choose from in your /etc/X11/xorg.conf
| Code: ServerLayout Section |
# Dual head, single desktop, spanning both
Section "ServerLayout"
Identifier "DualSingleDesktop"
Screen 0 "Screen[0]-Dual-Head" 0 0
InputDevice "Keyboard0" "CoreKeyboard"
InputDevice "Mouse0" "CorePointer"
EndSection
|
[edit] The Other Sections
You may remove FontPath entries if they do not exist on your system
The 'ServerFlags' section identifies the default X configuration, in this case, the 'DualSingleDesktop'
| Code: Other Sections |
# Dual head, single desktop, spanning both
Section "Files"
FontPath "/usr/share/fonts/local/"
FontPath "/usr/share/fonts/misc/"
FontPath "/usr/share/fonts/75dpi/:unscaled"
FontPath "/usr/share/fonts/100dpi/:unscaled"
FontPath "/usr/share/fonts/Type1/"
FontPath "/usr/share/fonts/75dpi/"
FontPath "/usr/share/fonts/100dpi/"
FontPath "/usr/share/fonts/dejavu/"
FontPath "/usr/share/fonts/local/"
FontPath "/usr/share/fonts/mathematica-fonts/"
FontPath "/usr/share/fonts/ttf-bitstream-vera/"
EndSection
Section "Module"
SubSection "extmod"
Option "omit xfree86-dga" # don't initialise the DGA extension
EndSubSection
EndSection
Section "Extensions"
Option "Composite" "enable"
# Option "Xvideo" "true"
EndSection
Section "ServerFlags"
Option "DefaultServerLayout" "DualSingleDesktop"
Option "AutoAddDevices" "true"
Option "AutoEnableDevices" "true"
# Option "AllowEmptyInput" "false" # Till I figure out how to config my mouse and keybaord.
EndSection
Section "InputDevice"
Identifier "Keyboard0"
Driver "keyboard"
EndSection
Section "InputDevice"
Identifier "Mouse0"
Driver "mouse"
Option "Protocol"
Option "Device" "/dev/input/mice"
Option "Emulate3Buttons" "no"
Option "ZAxisMapping" "4 5"
EndSection
|
[edit] Using your S-VIDEO TV as a Display
This section focuses on using a TV plugged into the S-VIDEO port on your Video card.
There are multiple ways to utilise your TV.
- As a second monitor, positioned above, below, left or right of your main monitor
- As a your main monitor
- As a temporary replacement for your second monitor, when you want to watch media on your TV and still be able to use your primary montior for linux stuff.
This section assumes you already have your nVidia card working, possibly even with dual head, as described above.
What you can also do is to be able to retain use the dual head LCD/CRT monitors, only using the TV, when required.
So, using a combination of
- the nVidia docs /usr/share/doc/nvidia-drivers-180.29/README.bz2
- the guide at http://en.wikibooks.org/wiki/NVidia/TV-OUT
- the man pages for /etc/X11/xorg.conf
you have the following options.
- Run a script which uses mplayer to play the movie on your PC but displays it on the TV - leaving the PC useless till the movie ends, other than keyboard controls of the media player. Both monitors on your computer go black (no signal) whilst the TV is being used.
- Run a script which runs up a second X session with fluxbox window manager (or any x application or window manager, for that matter) on the LCD console with the TV as a second screen, which you can direct mplayer to play on. The original X session with the dual head config is still running, just not displayed - You can switch back to it using CTRL-ALT-F7 - but that turns off the TV.
The /etc/X11/xorg.conf, is setup as shown in the following sections.
NOTE: This setup is using x11-base/xorg-server 1.5.3-r5 with use flags of (hal input_devices_evdev input_devices_keyboard input_devices_mouse ipv6 nptl video_cards_fbdev video_cards_nvidia video_cards_vesa xorg)
Basically, the default, on boot up, is to start up in Dual Head mode (DualSingleDesktop), as configured in the "ServerFlags" section.
The second configuration, TV only (tv), which, if X is started with this, will display only on the TV.
A third configuration continues to use the Prime LCD as the prime display and the TV as a second one (DualHeadTv) - the one we use if we startup the fluxbox instance.
[edit] The xorg.conf file
The /etc/X11/xorg.conf file is as follows :-
| Code: /etc/X11/xorg.conf |
Section "Files"
FontPath "/usr/share/fonts/local/"
FontPath "/usr/share/fonts/misc/"
FontPath "/usr/share/fonts/75dpi/:unscaled"
FontPath "/usr/share/fonts/100dpi/:unscaled"
FontPath "/usr/share/fonts/Type1/"
FontPath "/usr/share/fonts/75dpi/"
FontPath "/usr/share/fonts/100dpi/"
FontPath "/usr/share/fonts/dejavu/"
FontPath "/usr/share/fonts/local/"
FontPath "/usr/share/fonts/mathematica-fonts/"
FontPath "/usr/share/fonts/ttf-bitstream-vera/"
EndSection
Section "Module"
SubSection "extmod"
Option "omit xfree86-dga" # don't initialise the DGA extension
EndSubSection
EndSection
Section "Extensions"
Option "Composite" "enable"
# Option "Xvideo" "true"
EndSection
Section "ServerLayout"
Identifier "DualSingleDesktop"
Screen 0 "Screen[0]-Dual-Head" 0 0
InputDevice "Keyboard0" "CoreKeyboard"
InputDevice "Mouse0" "CorePointer"
EndSection
Section "ServerLayout"
Identifier "tv"
Screen 0 "Screen[1]-TV" 0 0
InputDevice "Keyboard0" "CoreKeyboard"
InputDevice "Mouse0" "CorePointer"
EndSection
Section "ServerLayout"
Identifier "DualHeadTv"
Screen 0 "Screen[3]-TV" Absolute 0 0
Screen 1 "Screen[2]-CMV" RightOf "Screen[3]-TV"
InputDevice "Keyboard0" "CoreKeyboard"
InputDevice "Mouse0" "CorePointer"
EndSection
Section "ServerFlags"
Option "DefaultServerLayout" "DualSingleDesktop"
Option "AutoAddDevices" "true"
Option "AutoEnableDevices" "true"
# Option "AllowEmptyInput" "false" # Till I figure out how to config my mouse and keybaord.
EndSection
Section "InputDevice"
Identifier "Keyboard0"
Driver "keyboard"
EndSection
Section "InputDevice"
Identifier "Mouse0"
Driver "mouse"
Option "Protocol"
Option "Device" "/dev/input/mice"
Option "Emulate3Buttons" "no"
Option "ZAxisMapping" "4 5"
EndSection
# Dual head, single desktop, spanning both
Section "Screen"
Identifier "Screen[0]-Dual-Head"
Monitor "Monitor[0]-CMV"
Device "Device[0]"
DefaultDepth 24
Option "NoLogo" "true"
Option "AddARGBGLXVisuals" "true"
Option "UseEvents" "false"
Option "RenderAccel" "true"
Option "HWcursor"
Option "TwinView"
Option "MetaModes" "1280x1024,1280x1024; 1280x1024; 1024x768,1024x768; 1024x768; 800x600,800x600; 800x600"
Option "TwinViewOrientation" "RightOf"
Option "SecondMonitorHorizSync" "UseEdidFreqs"
Option "SecondMonitorVertRefresh" "UseEdidFreqs"
SubSection "Display"
Viewport 0 0
Virtual 2560 1024
Depth 24
Modes "1280x1024"
EndSubSection
EndSection
# TV Only, monitors go blank
Section "Screen"
Identifier "Screen[1]-TV"
Monitor "Monitor[2]-TV"
Device "Device[1]-TV"
DefaultDepth 24
SubSection "Display"
Viewport 0 0
Virtual 800 600
Depth 24
Modes "800x600"
EndSubSection
EndSection
# Dual head, 2 separate desktops, CMV and TV
Section "Screen" # work in progress.
Identifier "Screen[2]-CMV"
Device "Device[2]-Monitor-Only"
Monitor "Monitor[0]-CMV"
DefaultDepth 24
SubSection "Display"
Depth 24
Modes "1280x1024"
EndSubSection
EndSection
Section "Screen"
Identifier "Screen[3]-TV"
Device "Device[3]-TV-Only"
Monitor "Monitor[2]-TV"
DefaultDepth 24
SubSection "Display"
Depth 24
Modes "800x600"
EndSubSection
EndSection
Section "Screen"
Identifier "Screen[4]-LG"
Device "Device[2]-Monitor-Only"
Monitor "Monitor[1]-LG"
DefaultDepth 24
SubSection "Display"
Depth 24
Modes "1280x1024"
EndSubSection
EndSection
Section "Monitor"
Identifier "Monitor[0]-CMV"
Option "VendorName" "CMV"
Option "ModelName" "CT-934D"
Option "DPMS" "true"
EndSection
Section "Monitor"
Identifier "Monitor[1]-LG"
Option "VendorName" "LG"
Option "ModelName" "Studioworks 900B"
Option "DPMS" "true"
EndSection
Section "Monitor"
Identifier "Monitor[2]-TV"
Option "VendorName" "Mitsubishi"
Option "ModelName" "Diva"
HorizSync 30-60
VertRefresh 60
EndSection
Section "Device"
Identifier "Device[0]"
Driver "nvidia"
VendorName "Leadtek nVidia"
BoardName "geForce GTS 250"
# BusID "AGP:1:0:0"
Screen 0
EndSection
Section "Device"
Identifier "Device[1]-TV"
Driver "nvidia"
VendorName "Leadtek nVidia"
BoardName "geForce GTS 250"
# BusID "PCI:1:0:0"
Option "TVStandard" "PAL-B"
Option "TVOutFormat" "SVIDEO" # or "COMPOSITE"
Option "UseDisplayDevice" "TV-0"
EndSection
Section "Device"
Identifier "Device[2]-Monitor-Only"
Driver "nvidia"
VendorName "Leadtek nVidia"
BoardName "geForce GTS 250"
BusID "PCI:01:00:0"
Screen 1
EndSection
Section "Device"
Identifier "Device[3]-TV-Only"
Driver "nvidia"
VendorName "Leadtek nVidia"
BoardName "geForce GTS 250"
BusID "PCI:01:00:0"
Option "TVStandard" "PAL-B"
Option "TVOutFormat" "SVIDEO" # or "COMPOSITE"
Option "UseDisplayDevice" "TV"
Screen 0
EndSection
|
The BusID can be found by using lspci | grep -i nvidia.
The TVStandard and TVOutFormat values can be determined by referencing the nVidia documentation (/usr/share/doc/nvidia-drivers-180.29/README.bz2)
[edit] Using the Configurations
| Code: Script to play a movie on the TV |
#!/bin/bash
if [ "$1" = "nox" ]
then
shift
DISPLAY=":1.0" /usr/bin/mplayer -stop-xscreensaver -fs -vo vx "$@"
else
exec /usr/bin/xinit /usr/bin/xterm -ut -e \
/usr/bin/mplayer -stop-xscreensaver -fs -vo sdl "$@" -- /usr/X11R6/bin/X :1 -layout tv
fi
|
The above script takes 1 or 2 parameters. If the first parameter is 'nox', it assumes that X is already running in DualHeadTv layout and will start playing the second parameter using mplayer, on the second display. If there is only 1 parameter, it starts up the second instance of X that displays using the (tv) config and then starts playing the 2nd parameter using mplayer. In the second case, once the movie ends, the X instance quits and the normal Dual Head display returns.
| Code: Start FluxBox with TV Enabled |
#!/bin/bash /usr/bin/xinit /usr/bin/fluxbox -- /usr/X11R6/bin/X :1 -layout DualHeadTv & |
The above script which simply starts up fluxbox using the (DualHeadTV) configuration. Within this fluxbox, I can then run the first script with 'nox' and have the movies play on the TV.
Once you quit the FluxBox session, your original session will return. You can switch back and forth between your normal session using CTRL-ALT-F7 and CTRL-ALT-F8. If you switch back to your normal session, the TV will cease to display.