Setting Up X11

Would you like to take advantage of all the graphic features of the X Window System, but the complexities of hardware configuration leave you scratching your head? Greg explains how to get the best performance from your monitor without making it go up in smoke.

One of the best things about Linux is XFree86, the free windowing system built on top of X11R6. The current version, 3.1.1, runs on just about any hardware, so that there is very little reason why you shouldn't be running it.

Are you running XFree86? That's a different question. If you answer no, then this article may be for you.

Another great thing about Linux is that it runs on PCs, which have arguably the highest performance/price ratio of any computer family. (Yes, I know, people argue this point constantly.)

Unfortunately, there are hardly two PCs with the same hardware configuration; in the course of the PC's evolution, hundreds of different display boards have appeared, each with their own peculiar quirks. How come they can sell? Most people use DOS or a system derived from DOS, and the boards have the necessary driver software for DOS on the board. If you're running a real operating system, you don't want to use these drivers: they run in 16 bit mode, and they're slow. That's why XFree86 supplies its own drivers and incorporates them in the X server.

XFree86 drivers are a “good news, bad news” situation. First the bad news: setup can be more difficult. With Microsoft Windows, you install the board and the software that comes with it, and it works (well, you get a recognizable picture on the screen). With XFree86, things might not be as easy.

The good news is that the drivers are much faster and much more flexible. In particular, you can configure XFree86 to your exact combination of display board and monitor, if you know how, even though you need to tune it manually.

This may sound simple, or it may sound complex—and it is. Some people set up X in a few minutes, but others run into problems which make grown-ups cry. In this article, we'll look at:

  • How display boards and monitors work.

  • How to set up XFree86 to work with your hardware.

  • How to tune your hardware for maximum display performance.

  • How to fry your monitor.

I mean the last point seriously. Conventional wisdom says that you can't damage hardware with a programming mistake, but in this case, you can, and people do from time to time. When you've read the section on how monitors work, you'll understand, but please don't start tuning until you understand the dangers involved.

How TVs and Monitors Work

You don't have to be a computer expert to see the similarity between monitors and TVs; current monitor technology is derived from TV technology, and many display boards have modes which can use TVs instead of monitors. Those of us who were on the microcomputer scene 15 to 20 years ago will remember the joy of getting a computer display on a portable TV, a “glass tty” running at 300 or 1200 bps.

TVs and monitors display the picture by scanning lines across the screen. As in a book, the first line starts at the top left of the screen and goes to the top right. Each successive line starts slightly below the previous line. This continues until the screen is full. The lines don't have to be full; the picture is formed by altering the intensity of the electron beam as it scans the lines.

To perform this scan, the TV has two deflection units: one scans from left to right, and the other scans (much more slowly) from top to bottom. Not unexpectedly, these units are called the horizontal and vertical deflection units. You may also encounter the terms line and frame deflection.

The electron beam can move at only a finite speed. When the electron beam reaches the right hand side of the screen, it needs to be deflected back again. This part of the scan is called the horizontal retrace, and it is not used for displaying picture data. The actual time that the hardware requires for the retrace varies, but it is in the order of 5% to 10% of the total line scan time. Similarly, when the vertical deflection reaches the bottom of the screen, it performs a vertical retrace, which is also not used for display.

It's not enough to just deflect, of course; somehow you need to ensure that the scanning is synchronized with the incoming signal, so that the scan is at the top of the screen when the picture information for the top of the screen arrives. You've all seen what happens when this doesn't happen; the picture runs up and down the screen (incorrect vertical synchronization) or tears away from the left of the screen (incorrect horizontal synchronization). Synchronization is achieved by including synchronization pulses in the horizontal and vertical retrace periods. To ensure that they are recognized as synchronization pulses, they have different voltage levels from the picture data.

As if that wasn't enough, the video amplifier, the part of the TV which alters the intensity of the spot as it travels across the screen, needs time to ensure that the retrace is invisible, so there are brief pauses between the end of the line and the start of the sync pulse, and again between the end of the sync pulse and the beginning of the data. This process is called blanking, and the delays are called the front porch (before the sync pulse) and the back porch (after the sync pulse).

In a nutshell, that is how horizontal deflection works. Vertical deflection works in almost the same way, just slower, with one minor exception. This basic display mechanism was developed for TVs in the 1930s, when the term “high-tech” hadn't even been invented, and even today we're stuck with the low data rates that they decided upon in those days. Depending on the country, TVs display only 25 or 30 frames (pages of display) per second. This causes an unpleasant flicker in the display. This flicker is avoided with a trick called interlacing. Instead of displaying the frame in one vertical scan, the odd and even lines are displayed in two alternating half frames, which increases the apparent frame frequency to 50 or 60 Hz.