====== My Perfect X11 Configuration ====== {{ :unix:screens.png |My physical setup}} I have a dual-head nVidia GeForce 7300 GT video card. Attached to the VGA-connector is my regular PC monitor, and attached to the DVI-connector is my HDTV. The PC monitor is for regular use, while the HDTV is really just for watching videos. This page details my final configuration, which took many hours of fiddling to achieve, and I don't want to forget should I need to do it again! ===== General PC Setup ===== * Ubuntu 8.10 Intrepid Ibex * Linux ikari.robmeerman.co.uk 2.6.27-9-generic #1 SMP Thu Nov 20 21:57:00 UTC 2008 i686 GNU/Linux * nVidia propriety drivers (nvidia-glx-*), installed by [[http://www.albertomilone.com/nvidia_scripts1.html|envy-ng]]((EnvyNG is available through Ubuntu's package-manager as ''envyng-core'')) ===== The Goal ===== 1 Artefact-free high-definition video playback on the HDTV 1 Artefact-free Compiz-Fusion window-management on the PC monitor ===== Strategy ===== There are at least 3 distinct ways to achieve multi-head output on an nVidia card, each with their pros and cons: ==== TwinView ==== * Pros - Works like Windows' multi-head: programmer's model of display is a single screen, all details are hidden. * Cons - If the screens have different refresh rates, only that of the primary screen is used for syncronising screen updates, i.e. the second screen will suffer tearing. * Show-stopper. The TV's refresh rate is 59.97Hz, the PC monitor's is 60.0Hz. Either my TV is primary (and gets all the desktop controls, such as menu bar) or it tears! ==== Xinerama ==== * Pros - Monitors are managed seperately by the system (programmer's model is multiple screens), so differing refresh-rates shouldn't be a problem. * Cons - Lowest-common-denominator for features. * Show-stopper. No GLX acceleration means no Compiz. - Full-screen will display on the primary screen, no matter where the window was. At least, it does for Flash which is a nuisance. ==== Seperate X Screens ==== * Pros - No-frills, everything should just work. - Refresh-rates and acceleration features managed per-display. * Cons - Really is two **seperate** desktops: no draggings windows between screens! I settled on seperate X screens, and just got used to having two desktops that cannot interact. The only real nuisance was with Firefox, which will run fine on your first desktop, but complain that Firefox is already running on the other! One workaround for this is to use profiles, so that Firefox prompts you at start up for which profile to load. I have a "default" and a "TV" profile. My "TV" profile is essentially blank, I just use to for YouTube and BBC iPlayer stuff I want to display full-screen on the TV. ===== Testing ===== At first I played the first 1000 frames from a video I had, fullscreen, and just watched it to see if there was any tearing on the TV. This was time-consuming and I was never sure if the cause was mplayer or X. I was happy to happen across [[http://myhd.sourceforge.net/juddertest.php|juddertest]], a small utility for performing such tests. It works by drawing black-and-white bars on the screen, and then scrolling them right-to-left. By watching the bars as they move you can spot tears very easily. {{ :unix:juddertest.png |Screenshot of JudderTest in action}} (Note that the blue-box is supposed to be some sort of on-screen display, but the fonts couldn't be loaded) One of the problems I have with juddertest's default settings is that it changes your display resolution before starting the test; somewhat defeating the point of it in my opinion. So I created two scripts, one per screen, with the resolutions I care about hard-coded into them: #!/bin/bash # HDTV XRES=1920 YRES=1080 ./judder 0 192 0 10 #!/bin/bash # PC Monitor XRES=1920 YRES=1200 ./judder 0 192 0 10 Note that my setting are "Scroll right-to-left", "Move 192 pixels per update", "Don't skip any updates" and "Draw 10 bars". Because 192 pixels * 10 bars = width of my screen, this effectively inverts the screen on each update. The display looks pretty horrible when it's flickering between black and white at 60Hz, but it shows up tearing immediately! If you see vertical bars flickering, but not moving, then you are tear free. If you see boxes then you are sufferring a tear. I played with ''nvidia-settings'' when trying to solve my tears. O, and your FPS should match your refresh rate, like so: frames drawn: 875 traces elapsed: 875 frames skipped: 0 frame ratio: 1.000000 seconds elapsed: 14.578704 approximate fps: 60.019052 ===== Display Settings (xorg.conf) ===== Mostly generated by ''nvidia-settings'', a tool nVidia supply to help you create/modify your display configuration file (''/etc/X11/xorg.conf''). You need to run ''nvidia-settings'' as root if you want it to over-write your ''xorg.conf'' file. I suggest gksudo nvidia-settings Once this file has been generated, you should remove all referenced to mice and keyboards - since Ubuntu 8.10 this is handled by the HAL((Hardware Abstraction Layer)). It doesn't hurt to put entried in your ''xorg.conf'', but it will probably confuse you because they'll be ignored. I also added the DPI of my TV, because ''/var/log/xorg.0.log'' had warnings about it being unable to work it out automatically. Section "ServerLayout" Identifier "Layout0" Screen 0 "Screen0" 0 0 Screen 1 "Screen1" RightOf "Screen0" EndSection Section "Files" EndSection Section "Module" Load "dbe" Load "extmod" Load "freetype" Load "glx" EndSection Section "ServerFlags" Option "NoXinerama" Option "RenderAccel" # 2009-01-05 Don't think this has any # effect outside a "Device" or "Screen" # section EndSection Section "Monitor" # HorizSync source: edid, VertRefresh source: edid Identifier "Monitor0" VendorName "Unknown" ModelName "DELL 2408WFP" HorizSync 30.0 - 83.0 VertRefresh 56.0 - 76.0 Option "DPMS" # I tend to switch between landscape and portrait modes often Option "RandRRotation" EndSection Section "Monitor" # HorizSync source: edid, VertRefresh source: edid Identifier "Monitor1" VendorName "Unknown" ModelName "PANASONIC-TV" HorizSync 15.0 - 68.0 VertRefresh 23.0 - 61.0 Option "DPMS" # Can't seem to detect this automatically Option "DPI" "52 x 52" EndSection Section "Device" Identifier "Device0" Driver "nvidia" VendorName "NVIDIA Corporation" BoardName "GeForce 7300 GT" BusID "PCI:1:0:0" Screen 0 EndSection Section "Device" Identifier "Device1" Driver "nvidia" VendorName "NVIDIA Corporation" BoardName "GeForce 7300 GT" BusID "PCI:1:0:0" Screen 1 EndSection Section "Screen" Identifier "Screen0" Device "Device0" Monitor "Monitor0" DefaultDepth 24 Option "metamodes" "CRT: 1920x1200_60 +0+0" SubSection "Display" Depth 24 EndSubSection EndSection Section "Screen" Identifier "Screen1" Device "Device1" Monitor "Monitor1" DefaultDepth 24 Option "metamodes" "DFP: 1920x1080_60 +0+0; DFP: nvidia-auto-select +0+0; DFP: 1920x1080 +0+0" SubSection "Display" Depth 24 EndSubSection EndSection ===== A seperate Window Manager per X-screen ===== I think that video plays smoother, and with less CPU overhead without Compiz, and so I decided I wanted to display Compiz on my TV. It turns out this is possible through X sessions! System -> Preferences -> Startup Applications: {{ :unix:session_preferences.png |Session Preferences}} These are the scripts/programs which are launched when you login to GDM((Gnome Desktop Manager)). - Find and untick "Window Manager" - Add a new entry: * Name: Compiz * Command: ''%%compiz --display=:0.0 --only-current-screen%%'' * Comment: Compiz, but only for CRT-0 - Add a new entry: * Name: MetaCity * Command: ''%%metacity --display=:0.1%%'' * Comment: MetaCity window manager, but only for DFP-0