Here is a very good write up on xorg.conf. Courtesy of Grenage’s Domain
Creating a custom xorg.conf
With the release of Ubuntu 9.10 (Karmic) xorg.conf was left largely redundant, at least, that was the theory. Something called EDID can be used for detecting a monitor’s display capabilities, but it doesn’t always work. This is usually down to monitor issues, or the video cable connected to it. If the EDID data cannot get through to the graphics adapter, then the graphics adapter knows nothing!
For some reason Intel cards seem to be particularly prone to dodgy display detection, and my examples here will reflect that.
To start off, if you’re unsure what your graphics card is:
grenage@ublt:~$ lspci | grep VGA00:02.0 VGA compatible controller: Intel Corporation Mobile 945GM/GMS, 943/940GML...
As you can see, we’ve got an Intel 945GM; that’ll do, Pig, that’ll do. If you are unsure what resolutions your adapter or monitor can support, you’re best off checking the manufacturer’s website for tech specs (or manual – how quaint). When it comes to monitors from the Pacific Rim, it’s not that unusual for the manufacter’s webby to have little information of use, hosted through a 56k modem. You could try:
grenage@ublt:~$ sudo apt-get install xresprobegrenage@ublt:~$ sudo ddcprobe
Unless something goes wrong, the output will be verbose; here’s a [very] cut-down result:
...memory: 8128kbmode: 1280x1024x256mode: 1280x1024x64kmode: 1280x1024x16m mode: 1024x768x256mode: 1024x768x64kmode: 1024x768x16mmode: 640x480x16m...id: 2095eisa: DCL2095serial: 000001a2 ...ctiming: 1680x1680@60ctiming: 1280x800@75ctiming: 1280x1280@75ctiming: 1280x960@75ctiming: 1680x1680@75 dtiming: 1680x1050@59monitorrange: 30-85, 56-76monitorname: DCLCDmonitorname: DCL20AT
Take the supported resolutions with a pinch of salt, I’ve never found them to be that accurate. The monitor frequency ranges are handy, assuming you get them; if you’re having a problem with EDID then there is a good chance you won’t. A last resort is use of cvt, it’ll give you a single horizontal and vertical frequency for a single resolution. The syntax is “cvt [horizontal resolution] [vertical resolution] [refresh rate]”:
grenage@ublt:~$ cvt 1680 1050 60 # 1680x1050 59.95 Hz (CVT 1.76MA) hsync: 65.29 kHz; pclk: 146.25 MHzModeline "1680x1050_60.00" 146.25 1680 1784 1960 2240 1050 1053 1059 1089 -hsync +vsync
That information would be used in the following format:
HorizSync 65.29VertRefresh 59.9
If you’ve dabbled with modelines before and are wondering what the difference is between cvt and gtf – not a lot. gtf generates industry-standard timings for use with a wide range of displays, and cvt generates VESA-standard timings. It’s best to make a backup of xorg.conf before you modfy it; I always do that *cough*:
grenage@ublt:~$ sudo cp /etc/X11/xorg.conf /etc/X11/xorg.old
Now we can clear out what’s there and enter a new config. I know it’s common for people to take example xorg.conf config files and copy/paste them as their own, but don’t. Unless your hardware is exactly the same, it’s easier to knock one up from scratch.
Section "Monitor" Identifier "Monitor0" VendorName "DCLLCD" ModelName "DCL20AT" HorizSync 24 - 82 VertRefresh 50 - 75EndSection Section "Device" Identifier "Device0" Driver "intel" VendorName "Intel 945GM"EndSection Section "Screen" Identifier "Screen0" Device "Device0" Monitor "Monitor0" DefaultDepth 24 SubSection "Display" Depth 24 Modes "1680x1050" EndSubSectionEndSection
You might notice that the monitor rates are difference from the dccprobe output, that’s because I am using the manufacturer’s listed specs. I only listed one resolution/mode because I only need one resolution, you can add as many as you like.
If you’re not using an Intel graphics adapter then you obviously won’t use “intel” as the driver. Alternatives include ati, sis, nv (nvidia) et cetera.
In theory that’s all we need, but it doesn’t work; curses. This is where modelines come in, and they can often make the difference. Modelines are easy to generate, again we use cvt again along with the desired resolution and refresh rate. This time we’re looking at the second line:
russellm@ublt:~$ cvt 1680 1050 60 # 1680x1050 59.95 Hz (CVT 1.76MA) hsync: 65.29 kHz; pclk: 146.25 MHz Modeline "1680x1050_60.00" 146.25 1680 1784 1960 2240 1050 1053 1059 1089 -hsync +vsync
Peachy; copy the last line in to the monitor section (or two lines if you want the comment) and try again:
Section "Monitor" Identifier "Monitor0" VendorName "DCLLCD" ModelName "DCL20AT" HorizSync 24 - 82 VertRefresh 50 - 75 Modeline "1680x1050_60.00" 147.14 1680 1784 1968 2256 1050 1051 1054 1087 -HSync +VsyncEndSection Section "Device" Identifier "Device0" Driver "intel" VendorName "Intel 945GM"EndSection Section "Screen" Identifier "Screen0" Device "Device0" Monitor "Monitor0" DefaultDepth 24 SubSection "Display" Depth 24 Modes "1680x1050" EndSubSectionEndSection
Success! You can have multiple modelines, allowing for multiple resolutions. Who said xorg config editing wasn’t fun?…
What if it goes wrong?
There is always the chance that something will go wrong; the screen frequencies might be off, an unsupported resolution might be refenced, or X might take offense at your choice of colour depth. If the monitor displays garbled images or errors, you will need to make use of either a live CD or a terminal. Ctrl-alt-F3 (F1-F7 are virtual terminals) should get you a text-based login prompt, and a live CD should get you a basic GUI. If you backed up your config earlier, you can quickly restore it:
grenage@ublt:~$ sudo rm /etc/X11/xorg.conf grenage@ublt:~$ sudo mv /etc/X11/xorg.old /etc/X11/xorg.conf
If you didn’t make a backup, you can try deleting the old config; most systems will just do fine without it, but if yours is not one of them, you can generate a new xorg.conf with:
sudo Xorg -configure
The Nvidia drivers often have issues using EDID information when a second monitor is attached; this can lead to problems such as the wrong resolution being used, or overscan (black borders). What we need to do is manually download the monitor’s EDID data using nvidia-settings (Nvidia X Server Settings); select the screen in question and click ‘Acquire EDID’. I recommend saving it in /etc/X11, but elsewhere will be fine. Now we modify xorg.conf:
Option "TwinView" "1" Option "TwinViewXineramaInfoOrder" "CRT-0" Option "metamodes" "CRT-0: 1440x900_75 +0+0, CRT-1: 1440x900_75 +1440+0" Option "CustomEDID" "CRT-1:/etc/X11/edid.bin"
If you’re not using TwinView (but still using an Nvidia card), you can try something like:
Option "UseDisplayDevice" "CRT-0" Option "CustomEDID" "CRT-0:/etc/X11/edid.bin"