Computing a Mode Line

Although you can live with the VESA standard video modes defined in the X server, you may sometimes have to add a ModeLine manually to get a video mode to work for a specific video card/monitor combination.

You specify a ModeLine on a single line with the following syntax:

ModeLine "name" CLK HRES HSS HSE HTOT VRES VSS VSE VTOT flags

You must fill in all arguments, except the last argument, which is an optional keyword that indicates the type of the mode. The flags field, for example, can be Interlace for an interlaced mode (alternate raster lines are drawn through the image each time) or DoubleScan (each scan line is doubled). Other flags indicate the polarity of the sync signal. The values can be +HSync, -HSync, +VSync, or -VSync, depending on the polarities you are specifying.

The arguments on the ModeLine have the following meanings:

• "name": The name of this mode, in double quotes. Usually, the resolution of the mode is used as its name. Thus, you'll see mode names such as "640 x 480" and "1024 x 768". These mode names are used in the Display subsection of the Screen section.

• CLK: The dot clock to be used for this mode. For a video card with a fixed set of dot clocks, the dot clock should be one of the values on the Clocks line in the Device section of the xorg.conf file.

• HRES HSS HSE HTOT: The horizontal timing parameters. HRES is the horizontal resolution in terms of the number of pixels visible on a raster line. As Figure 3-1 shows, the actual number of pixels on a raster line exceeds the number of visible pixels. HTOT is the total pixels on the line. HSS is where the horizontal-sync signal begins, and HSE is the pixel number where the horizontal-sync signal ends. The horizontal-sync signal moves the electron beam from one line to the next. For a 640 x 480 video mode, these four parameters might be 640 680 720 864. That sequence of numbers expresses that 864 pixels are on the raster lines but that only 640 are visible. The horizontal-sync signal begins at pixel 680 and ends at pixel 864.

• VRES VSS VSE VTOT: The vertical timing parameters. VRES is the vertical resolution in terms of the number of visible raster lines on the display screen. As Figure 3-1 shows, the actual number of raster lines exceeds the number of visible raster lines. VTOT is the total raster lines. VSS is the line number where the vertical-sync signal begins, and VSE is the line number where the vertical-sync signal ends. The vertical-sync signal moves the electron beam from the bottom of the screen to the beginning of the first line. For a 640 x 480 video mode, these four parameters might be 480 488 491 521.

From a monitor's manual, you can get two key parameters: the vertical refresh rate (in Hz) and the horizontal synchronization frequency (in kHz). The monitor's manual provides these two values as ranges of valid values. The vertical refresh rate is typically between 50 Hz and 90 Hz; the horizontal sync frequency can be anywhere from 30 kHz to 135 kHz. Following are two equations that define the relationship between the dot clock and some of the horizontal and vertical timing parameters on the ModeLine:

In these equations, RR is a screen refresh rate within the range of the vertical refresh rate of the monitor, and HSF is a horizontal-scan frequency the monitor supports. Remember to convert everything to a common unit (for example, make sure that all values are in Hz) when you apply these formulas.

To define a mode, you can start with a desired refresh rate (RR) such as 72 Hz. For a given dot clock, you then can compute the product HTOT * VTOT from the first equation. Next, plug in a value for HSF within the range of supported horizontal-scan frequencies for the monitor. Because the dot clock is already known, you can compute HTOT from the second equation. After you know HTOT, you can determine VTOT because you have already computed the product of HTOT * VTOT.

At this point, you know HTOT and VTOT. You have to select the arguments HSS, HSE, VSS, and VSE, which you need for the ModeLine. Unfortunately, figuring out these four parameters requires some trial and error. You can pick the HRES and VRES values first (HRES and VRES determine the resolution of the mode). Then, you have to select HSS and HSE to lie between HRES and HTOT and ensure that HSE > HSS. Similarly, VSS and VSE should be between VRES and VTOT; make sure that VSE > VSS.

If the display area looks small or not centered, you have to alter the values HSS, HSE, VSS, and VSE to tweak the display. One way to correct any minor display problems is to run the xvidtune utility that comes with X.Org X11. If your X display is working but the display does not look as good as you think it should (for example, if it does not fill the whole screen or is skewed to one side), type xvidtune in a terminal window. The program prints a few lines of information about the monitor on the terminal window. The xvidtune window and a dialog box appear. If the video chip does not allow modes to be tuned, xvid-tune exits with a message informing you so. Otherwise xvidtune displays a warning message (see Figure 3-6) that tells you about the possibility of damaging your monitor and video card if you use the xvidtune program improperly.

HRRNIHS HASHING IMRHING UHRMIHG URRNIHn UflRNIHG

JUL" INCORRECT IJEE OF THIS PROGRflrl CM DC PERHHHEHT DfiKRGE TO TOUR H0HIT0R RHD/OR VIDEO CURD. IF YOU HRE HOT SURE HHRT YOU ARE DOING, HIT CANCEL HOH. OTHERWISE, HIT OK ID COHTIHUE

THE SOFTHHRE IS PROVIDED "(IS IS", HITH00T HflRRHHTV 0T flMY KIND, EXPRESS OR DIPLIED, INCLUDING BUT NOT LIhlTED TO THE UHRRRNTIES OF HERCHRHTRBILITY, FITNESS FOR R PARTICULAR PURPOSE HHD NOHIHFRIHGEHE HT, IH NO EVENT SHOLL Kali* S. KEITHLEY [or his unployiir) OR The X.OrE Foundation EE LIABLE FOR RHY CLRItl, DAMAGES OR OTHER LIABILITY, WHETHER IH UN ACTIOH OF COHTRHCT, TORT OR OTHERWISE, ARISING fsnn, OUT OF [IH IN CAHNfiCTTAN UlTH THE: SOFI HHRE I IK THfi [ISF OR OTHFR DEALINGS IH THE SOFTHHRE.

Was this article helpful?

0 0
Make Money Writing

Make Money Writing

This Report Will Show You How To Make Money By Providing Writing Services To Other Internet Marketers. Learn how to make money by writing the right way. Grab your copy of this report now and learn. Why writing is a great way to earn money. How to compete with cheap writers, even if you charge a lot more money.

Get My Free Ebook


Post a comment