What To Do When XOrg Picks The Wrong Values

You just installed a brand new copy of the OS on your brand new system, removed the system DVD and tried to boot for the first time. The system appeared to boot up OK (you saw GRUB loading) and a couple of systems started up (like udev), then the screen went blank and your display said (in broken Engrish, "VGA Mode Not Support"). What do you do?

Lucky you. XOrg has used the EDID values from your display (or the lack of EDID values, if you have a really old display) to pick a set of display parameters that your display doesn't support. You now have to repair this infelicity using a standalone rescue disk (isn't it great that you just installed a brand new, fresh copy of the OS and you're already resorting to booting from a rescue disk and hacking obscure display manager parameters -- no wonder Linux is such a hit with Joe User).

Our favorite standalone rescue disk is Knoppix (hint to XOrg programmers: if Klaus Knopper can figure out the proper display parameters for the display, maybe you could too, if you just tried a bit harder). So, begin by getting yourself a copy of KNOPPIX (the CD works perfectly fine):

     http://knopper.net/knoppix/index-en.html

And burn the ISO image onto a CD (or DVD, if you took that route).

Then, boot up the CD/DVD in the new machine and mount its root file system. Look around in the /media directory for the subdirectory that matches the partition where the root file system resides (Knoppix thoughtfully creates subdirectories in /media for all of the disk partitions that it finds at startup). In order to mount things, you will need to issue the "su" command in a shell window first. You'll need to do something like this:

     su
     mount /dev/sda3 /media/sda3

To edit the XOrg config file, locate the file (usually in /etc/X11/xorg.conf) and invoke the Kate editor (there's no EMACS, sorry) on it:

     cd /dev/sda3
     kate etc/X11/xorg.conf &

This will let you get at the offending display section of the file. A quick fix is to force the display resolution to one of the well-known VESA resolutions by putting the "Modes" line in the Display SubSection. You might also have some success with setting the HorizSync and VertRefresh parameters in the Monitor Section to the correct range for your monitor (although it does appear possible to use values that fall strictly within this range and still offend the monitor's sensibilities). Also, if EDID is not used to get the monitor's parameters, this could be the problem. Here's the basic idea:

/etc/X11/xorg.conf:

.

       .
  Section "Monitor"
      Identifier    "Monitor0"
      ModelName     "My LCD Panel 1024x768"
      HorizSync     31.5 - 48.0
      VertRefresh   56.0 - 65.0
      Option        "dpms"
  EndSection
       .
       .
       .
  Section "Screen"
      Identifier    "Screen0"
      Device        "Videocard0"
      Monitor       "Monitor0"
      DefaultDepth  24
      SubSection "Display"
          Viewport  0 0
          Depth     24
          Modes     "800x600" "640x480"
      EndSubSection

EndSection

If worst comes to worst, you may have to define your own ModeLine information and then use it in the Display subsection. To do this, you must figure out one or more modelines that can be used to set the various screen resolutions supported by your display. There should be a chart in the back of your display's manual that lists all of the supported modes (beware that some of the charts we've seen have the vertical and horizontal frequencies exchanged - a good clue is that the vertical frequency is usually the one that matches the number in the VESA name). First off, you should try to pick one of the standard modes from the list below. Also, it is best to try and pick the highest vertical refresh rate (in Hz) supported by your display:

     # 640x400 @ 85Hz (VGA VESA 85) hsync: 37.9kHz
     ModeLine "640x400"    31.5    640  672  736  832  400  401  404  445 \
       -hsync +vsync
     # 640x480 @ 60Hz (Industry standard) hsync: 31.5kHz
     ModeLine "640x480"    25.2    640  656  752  800  480  490  492  525 \
       -hsync -vsync
     # 640x480 @ 72Hz (VGA VESA 72) hsync: 37.9kHz
     ModeLine "640x480"    31.5    640  664  704  832  480  489  491  520 \
       -hsync -vsync
     # 640x480 @ 75Hz (VGA VESA 75) hsync: 37.5kHz
     ModeLine "640x480"    31.5    640  656  720  840  480  481  484  500 \
       -hsync -vsync
     # 640x480 @ 85Hz (VGA VESA 85) hsync: 43.3kHz
     ModeLine "640x480"    36.0    640  696  752  832  480  481  484  509 \
       -hsync -vsync
     # 720x400 @ 85Hz (VESA 85) hsync: 37.9kHz
     ModeLine "720x400"    35.5    720  756  828  936  400  401  404  446 \
       -hsync +vsync
     # 800x600 @ 56Hz (SVGA VESA 56) hsync: 35.2kHz
     ModeLine "800x600"    36.0    800  824  896 1024  600  601  603  625 \
       +hsync +vsync
     # 800x600 @ 60Hz (SVGA VESA 60) hsync: 37.9kHz
     ModeLine "800x600"    40.0    800  840  968 1056  600  601  605  628 \
       +hsync +vsync
     # 800x600 @ 72Hz (SVGA VESA 72) hsync: 48.1kHz
     ModeLine "800x600"    50.0    800  856  976 1040  600  637  643  666 \
       +hsync +vsync
     # 800x600 @ 75Hz (SVGA VESA 75) hsync: 46.9kHz
     ModeLine "800x600"    49.5    800  816  896 1056  600  601  604  625 \
       +hsync +vsync
     # 800x600 @ 85Hz (SVGA VESA 85) hsync: 53.7kHz
     ModeLine "800x600"    56.3    800  832  896 1048  600  601  604  631 \
       +hsync +vsync
     # 1024x768 @ 43Hz (industry standard) hsync: 35.5kHz
     ModeLine "1024x768"   44.9   1024 1032 1208 1264  768  768  776  817 \
       +hsync +vsync Interlace
     # 1024x768 @ 60Hz (XGA VESA 60) hsync: 48.4kHz
     ModeLine "1024x768"   65.0   1024 1048 1184 1344  768  771  777  806 \
       -hsync -vsync
     # 1024x768 @ 70Hz (VESA 70, HP1070) hsync: 56.5kHz
     ModeLine "1024x768"   75.0   1024 1048 1184 1328  768  771  777  806 \
       -hsync -vsync
     # 1024x768 @ 75Hz (XGA VESA 75) hsync: 60.0kHz
     ModeLine "1024x768"   78.8   1024 1040 1136 1312  768  769  772  800 \
       +hsync +vsync
     # 1024x768 @ 85Hz (XGA VESA 85) hsync: 68.7kHz
     ModeLine "1024x768"   94.5   1024 1072 1168 1376  768  769  772  808 \
       +hsync +vsync
     # 1152x864 @ 75Hz (SXGA VESA 75) hsync: 67.5kHz
     ModeLine "1152x864" 108.0    1152 1216 1344 1600  864  865  868  900 \
       +hsync +vsync
     # 1280x960 @ 60Hz (SXGA VESA 60) hsync: 60.0kHz
     ModeLine "1280x960"  108.0   1280 1376 1488 1800  960  961  964 1000 \
       +hsync +vsync
     # 1280x960 @ 85Hz (SXGA VESA 85) hsync: 85.9kHz
     ModeLine "1280x960"  148.5   1280 1344 1504 1728  960  961  964 1011 \
       +hsync +vsync

If you didn't find your display's resolution in this list, there are more standard modes listed at:

     http://m.domaindlx.com/LinuxHelp/resources/modelines.htm

Another way to determine the display's modeline is to use the modeline calculator at:

     http://xtiming.sourceforge.net/cgi-bin/xtiming.pl

Instead of determining the maximum refresh rate for your display, this will let you put in an arbitrary refresh rate and calculate the modeline from that. You can try a few until you arrive at one that seems likely to work with your display (again, a higher refresh rate is more desirable, since it provides a more flicker-free display but just getting the display to work is our goal here so beggars cannot be choosers).

Now, you can hack the Monitor section of the xorg.conf file in /etc/X11 and set the device identification fields to something useful (here we're using the recalcitrant Syntax LT27HV as an example):

     Identifier   "Syntax LT27HV LCD Display"
     VendorName   "Syntax"
     ModelName    "Olevia LT27HV"

Next, you should probably set the minimum and maximum horizontal and vertical sync frequencies from the chart of your display's capabilities:

     HorizSync    56-87
     VertRefresh  24-72

These values are not used to calculate any actual display settings but the values in the modelines are checked against these limits to ensure that you do not exceed your display's capabilities (and possibly destroy it).

Then, add the modelines to the Monitor section:

     # 640x480 @ 85Hz (VGA VESA 85) hsync: 43.3kHz
     ModeLine "640x480-85"  36.0  640 696 752 832  480 481 484 509  -hsync -vsync
     # 800x600 @ 85Hz (SVGA VESA 85) hsync: 53.7kHz
     ModeLine "800x600-85"  56.3  800 832 896 1048  600 601 604 631  +hsync +vsync
     # 1024x768 @ 85Hz (XGA VESA 85) hsync: 68.7kHz
     ModeLine "1024x768-85"  94.5  1024 1072 1168 1376  768 769 772 808 \
       +hsync +vsync
     # 1280x720 @ 60Hz (1280x720-60) vsync: 60.39Hz, hsync: 45.72kHz, clk: 74.25
     # This is the only true native mode for the LT27HV display.
     Modeline "1280x720-60" 74.25 1280 1312 1592 1624 720 735 742 757 \
       +hsync +vsync

For the Syntax Olevia models, you may want to add the following, as well:

     # Power saving mode
     Option       "DPMS"
     # We know everything about this display
     Option       "UseEDID" "false"
     # We know what the dot pitch is
     Option       "DPI" "96×96"
     # Make sure the video card always picks the CRT.  Or, if you have the
     # display plugged in on the DVI connection, use "DFP" instead of "CRT-0".
     Option       "UseDisplayDevice" "CRT-0"

Next, hack the Screen section to use the display that you just defined by setting the Display SubSection to point to it:

     # The color depth
     Depth        24
     # All of the supported modes that we defined in modelines.  The first is
     # the default mode chosen at startup.
     Modes        "1280x720-60"  "1024x768-85"  "800x600-85"  "640x480-85"

Providing the display driver respects the ModeLine parameters (some of the nVidia drivers don't), you should now be in business. Unmount the partition from Knoppix, shut Knoppix down and reboot to see if it really works.