Table of Contents

My Perfect X11 Configuration

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

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

Xinerama

Seperate X 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 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.

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 HAL2). 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:

Session Preferences

These are the scripts/programs which are launched when you login to GDM3).

  1. Find and untick “Window Manager”
  2. Add a new entry:
    • Name: Compiz
    • Command: compiz --display=:0.0 --only-current-screen
    • Comment: Compiz, but only for CRT-0
  3. Add a new entry:
    • Name: MetaCity
    • Command: metacity --display=:0.1
    • Comment: MetaCity window manager, but only for DFP-0
1)
EnvyNG is available through Ubuntu's package-manager as envyng-core
2)
Hardware Abstraction Layer
3)
Gnome Desktop Manager