home *** CD-ROM | disk | FTP | other *** search
/ Hackers Toolkit v2.0 / Hackers_Toolkit_v2.0.iso / HTML / archive / Unix / HOWTOs / XFREE86-.000 < prev   
Text File  |  1999-11-04  |  65KB  |  1,651 lines

  1.   XFree86 Video Timings HOWTO
  2.   Eric S. Raymond <esr@thyrsus.com>
  3.   v3.2, 20 February 1998
  4.  
  5.   How to compose a mode line for your card/monitor combination under
  6.   XFree86.  The XFree86 distribution now includes good facilities for
  7.   configuring most standard combinations; this document is mainly useful
  8.   if you are tuning a custom mode line for a high-performance monitor or
  9.   very unusual hardware.  It may also help you in using xvidtune to
  10.   tweak a standard mode that is not quite right for your monitor.
  11.   ______________________________________________________________________
  12.  
  13.   Table of Contents
  14.  
  15.  
  16.   1. Disclaimer
  17.  
  18.   2. Introduction
  19.  
  20.   3. How Video Displays Work
  21.  
  22.   4. Basic Things to Know about your Display and Adapter
  23.  
  24.      4.1 The monitor's video bandwidth:
  25.      4.2 What these control:
  26.  
  27.   5. Interpreting the Basic Specifications
  28.  
  29.      5.1 About Bandwidth:
  30.      5.2 Sync Frequencies and the Refresh Rate:
  31.  
  32.   6. Tradeoffs in Configuring your System
  33.  
  34.   7. Memory Requirements
  35.  
  36.   8. Computing Frame Sizes
  37.  
  38.   9. Black Magic and Sync Pulses
  39.  
  40.      9.1 Horizontal Sync:
  41.      9.2 Vertical Sync:
  42.  
  43.   10. Putting it All Together
  44.  
  45.   11. Overdriving Your Monitor
  46.  
  47.   12. Using Interlaced Modes
  48.  
  49.   13. Questions and Answers
  50.  
  51.   14. Fixing Problems with the Image.
  52.  
  53.      14.1 The image is displaced to the left or right
  54.      14.2 The image is displaced up or down
  55.      14.3 The image is too large both horizontally and vertically
  56.      14.4 The image is too wide (too narrow) horizontally
  57.      14.5 The image is too deep (too shallow) vertically
  58.  
  59.   15. Plotting Monitor Capabilities
  60.  
  61.   16. Credits
  62.  
  63.  
  64.  
  65.   ______________________________________________________________________
  66.  
  67.   1.  Disclaimer
  68.  
  69.  
  70.   You use the material herein SOLELY AT YOUR OWN RISK.  It is possible
  71.   to harm both your monitor and yourself when driving it outside the
  72.   manufacturer's specs. Read ``Overdriving Your Monitor'' for detailed
  73.   cautions. Any damages to you or your monitor caused by overdriving it
  74.   are your problem.
  75.  
  76.   The most up-to-date version of this HOWTO can be found at the Linux
  77.   Documentation Project <http://sunsite.unc.edu/LDP> web page.
  78.  
  79.   Please direct comments, criticism, and suggestions for improvement to
  80.   esr@snark.thyrsus.com. Please do not send email pleading for a magic
  81.   solution to your special monitor problem, as doing so will only burn
  82.   up my time and frustrate you -- everything I know about the subject is
  83.   already in here.
  84.  
  85.  
  86.   2.  Introduction
  87.  
  88.  
  89.   The XFree86 server allows users to configure their video subsystem and
  90.   thus encourages best use of existing hardware.  This tutorial is
  91.   intended to help you learn how to generate your own timing numbers to
  92.   make optimum use of your video card and monitor.
  93.  
  94.   We'll present a method for getting something that works, and then show
  95.   you how you can experiment starting from that base to develop settings
  96.   that optimize for your taste.
  97.  
  98.   Starting with XFree86 3.2, XFree86 provides an XF86Setup(1) program
  99.   that makes it easy to generate a working monitor mode interactively,
  100.   without messing with video timing number directly.  So you shouldn't
  101.   actually need to calculate a base monitor mode in most cases.
  102.   Unfortunately, XF86Setup(1) has some limitations; it only knows about
  103.   standard video modes up to 1280x1024.  If you have a very high-
  104.   performance monitor capable of 1600x1200 or more you will still have
  105.   to compute your base monitor mode yourself.
  106.  
  107.   Recent versions of XFree86 provide a tool called xvidtune(1) which you
  108.   will probably find quite useful for testing and tuning monitor modes.
  109.   It begins with a gruesome warning about the possible consequences of
  110.   mistakes with it.  If you pay careful attention to this document and
  111.   learn what is behind the pretty numbers in xvidtune's boxes, you will
  112.   become able to use xvidtune effectively and with confidence.
  113.  
  114.   If you already have a mode that almost works (in particular, if one of
  115.   predefined VESA modes gives you a stable display but one that's
  116.   displaced right or left, or too small, or too large) you can go
  117.   straight to the section on ``Fixing Problems with the Image''.  This
  118.   will enlighten you on ways to tweak the timing numbers to achieve
  119.   particular effects.
  120.  
  121.   If you have xvidtune(1), you'll be able to test new modes on the fly,
  122.   without modifying your X configuration files or even rebooting your X
  123.   server.  Otherwise, XFree86 allows you to hot-key between different
  124.   modes defined in Xconfig (see XFree86.man for details).  Use this
  125.   capabilty to save yourself hassles!  When you want to test a new mode,
  126.   give it a unique mode label and add it to the end of your hot-key
  127.   list.  Leave a known-good mode as the default to fall back on if the
  128.   test mode doesn't work.
  129.  
  130.  
  131.  
  132.  
  133.   3.  How Video Displays Work
  134.  
  135.  
  136.   Knowing how the display works is essential to understanding what
  137.   numbers to put in the various fields in the file Xconfig.  Those
  138.   values are used in the lowest levels of controlling the display by the
  139.   XFree86 server.
  140.  
  141.   The display generates a picture from a series of dots.  The dots are
  142.   arranged from left to right to form lines.  The lines are arranged
  143.   from top to bottom to form the picture.  The dots emit light when they
  144.   are struck by the electron beam inside the display.  To make the beam
  145.   strike each dot for an equal amount of time, the beam is swept across
  146.   the display in a constant pattern.
  147.  
  148.   The pattern starts at the top left of the screen, goes across the
  149.   screen to the right in a straight line, and stops temporarily on the
  150.   right side of the screen.  Then the beam is swept back to the left
  151.   side of the display, but down one line.  The new line is swept from
  152.   left to right just as the first line was.  This pattern is repeated
  153.   until the bottom line on the display has been swept.  Then the beam is
  154.   moved from the bottom right corner of the display to the top left
  155.   corner, and the pattern is started over again.
  156.  
  157.   There is one variation of this scheme known as interlacing: here only
  158.   every second line is swept during one half-frame and the others are
  159.   filled in in during a second half-frame.
  160.  
  161.   Starting the beam at the top left of the display is called the
  162.   beginning of a frame.  The frame ends when the beam reaches the the
  163.   top left corner again as it comes from the bottom right corner of the
  164.   display.  A frame is made up of all of the lines the beam traced from
  165.   the top of the display to the bottom.
  166.  
  167.   If the electron beam were on all of the time it was sweeping through
  168.   the frame, all of the dots on the display would be illuminated.  There
  169.   would be no black border around the edges of the display.  At the
  170.   edges of the display the picture would become distorted because the
  171.   beam is hard to control there.  To reduce the distortion, the dots
  172.   around the edges of the display are not illuminated by the beam even
  173.   though the beam may be pointing at them.  The viewable area of the
  174.   display is reduced this way.
  175.  
  176.   Another important thing to understand is what becomes of the beam when
  177.   no spot is being painted on the visible area.  The time the beam would
  178.   have been illuminating the side borders of the display is used for
  179.   sweeping the beam back from the right edge to the left and moving the
  180.   beam down to the next line.  The time the beam would have been
  181.   illuminating the top and bottom borders of the display is used for
  182.   moving the beam from the bottom-right corner of the display to the
  183.   top-left corner.
  184.  
  185.   The adapter card generates the signals which cause the display to turn
  186.   on the electron beam at each dot to generate a picture.  The card also
  187.   controls when the display moves the beam from the right side to the
  188.   left and down a line by generating a signal called the horizontal sync
  189.   (for synchronization) pulse.  One horizontal sync pulse occurs at the
  190.   end of every line.  The adapter also generates a vertical sync pulse
  191.   which signals the display to move the beam to the top-left corner of
  192.   the display.  A vertical sync pulse is generated near the end of every
  193.   frame.
  194.  
  195.   The display requires that there be short time periods both before and
  196.   after the horizontal and vertical sync pulses so that the position of
  197.   the electron beam can stabilize.  If the beam can't stabilize, the
  198.   picture will not be steady.
  199.   In a later section, we'll come back to these basics with definitions,
  200.   formulas and examples to help you use them.
  201.  
  202.  
  203.   4.  Basic Things to Know about your Display and Adapter
  204.  
  205.  
  206.   There are some fundamental things you need to know before hacking an
  207.   Xconfig entry.  These are:
  208.  
  209.  
  210.   o  your monitor's horizontal and vertical sync frequency options
  211.  
  212.   o  your video adapter's driving clock frequency, or "dot clock"
  213.  
  214.   o  your monitor's bandwidth
  215.  
  216.      The monitor sync frequencies:
  217.  
  218.   The horizontal sync frequency is just the number of times per second
  219.   the monitor can write a horizontal scan line; it is the single most
  220.   important statistic about your monitor.  The vertical sync frequency
  221.   is the number of times per second the monitor can traverse its beam
  222.   vertically.
  223.  
  224.   Sync frequencies are usually listed on the specifications page of your
  225.   monitor manual.  The vertical sync frequency number is typically
  226.   calibrated in Hz (cycles per second), the horizontal one in KHz
  227.   (kilocycles per second).  The usual ranges are between 50 and 150Hz
  228.   vertical, and between 31 and 135KHz horizontal.
  229.  
  230.   If you have a multisync monitor, these frequencies will be given as
  231.   ranges.  Some monitors, especially lower-end ones, have multiple fixed
  232.   frequencies.  These can be configured too, but your options will be
  233.   severely limited by the built-in monitor characteristics.  Choose the
  234.   highest frequency pair for best resolution.  And be careful --- trying
  235.   to clock a fixed-frequency monitor at a higher speed than it's
  236.   designed for can easily damage it.
  237.  
  238.   Earlier versions of this guide were pretty cavalier about overdriving
  239.   multisync monitors, pushing them past their nominal highest vertical
  240.   sync frequency in order to get better performance.  We have since had
  241.   more reasons pointed out to us for caution on this score; we'll cover
  242.   those under ``Overdriving Your Monitor'' below.
  243.  
  244.   The card driving clock frequency:
  245.  
  246.   Your video adapter manual's spec page will usually give you the card's
  247.   dot clock (that is, the total number of pixels per second it can write
  248.   to the screen).  If you don't have this information, the X server will
  249.   get it for you.  Even if your X locks up your monitor, it will emit a
  250.   line of clock and other info to standard output.  If you redirect this
  251.   to a file, it should be saved even if you have to reboot to get your
  252.   console back.  (Recent versions of the X servers allsupport a
  253.   --probeonly option that prints out this information and exits without
  254.   actually starting up X or changing the video mode.)
  255.  
  256.   Your X startup message should look something like one of the following
  257.   examples:
  258.  
  259.   If you're using XFree86:
  260.  
  261.  
  262.  
  263.  
  264.  
  265.   Xconfig: /usr/X11R6/lib/X11/Xconfig
  266.   (**) stands for supplied, (--) stands for probed/default values
  267.   (**) Mouse: type: MouseMan, device: /dev/ttyS1, baudrate: 9600
  268.   Warning: The directory "/usr/andrew/X11fonts" does not exist.
  269.            Entry deleted from font path.
  270.   (**) FontPath set to "/usr/lib/X11/fonts/misc/,/usr/lib/X11/fonts/75dpi/"
  271.   (--) S3: card type: 386/486 localbus
  272.   (--) S3: chipset:   924
  273.                       ---
  274.       Chipset -- this is the exact chip type; an early mask of the 86C911
  275.  
  276.   (--) S3: chipset driver: s3_generic
  277.   (--) S3: videoram:  1024k
  278.                       -----
  279.            Size of on-board frame-buffer RAM
  280.  
  281.   (**) S3: clocks:  25.00  28.00  40.00   3.00  50.00  77.00  36.00  45.00
  282.   (**) S3: clocks:   0.00   0.00  79.00  31.00  94.00  65.00  75.00  71.00
  283.                     ------------------------------------------------------
  284.                                 Possible driving frequencies in MHz
  285.  
  286.   (--) S3: Maximum allowed dot-clock: 110MHz
  287.                                       ------
  288.                                      Bandwidth
  289.   (**) S3: Mode "1024x768": mode clock =  79.000, clock used =  79.000
  290.   (--) S3: Virtual resolution set to 1024x768
  291.   (--) S3: Using a banksize of 64k, line width of 1024
  292.   (--) S3: Pixmap cache:
  293.   (--) S3: Using 2 128-pixel 4 64-pixel and 8 32-pixel slots
  294.   (--) S3: Using 8 pages of 768x255 for font caching
  295.  
  296.  
  297.  
  298.   If you're using SGCS or X/Inside X:
  299.  
  300.  
  301.   WGA: 86C911 (mem: 1024k clocks: 25 28 40 3 50 77 36 45 0 0 79 31 94 65 75 71)
  302.   ---  ------       -----         --------------------------------------------
  303.    |     |            |                 Possible driving frequencies in MHz
  304.    |     |            +-- Size of on-board frame-buffer RAM
  305.    |     +-- Chip type
  306.    +-- Server type
  307.  
  308.  
  309.  
  310.   Note: do this with your machine unloaded (if at all possible).
  311.   Because X is an application, its timing loops can collide with disk
  312.   activity, rendering the numbers above inaccurate.  Do it several times
  313.   and watch for the numbers to stabilize; if they don't, start killing
  314.   processes until they do.  SVr4 users: the mousemgr process is
  315.   particularly likely to mess you up.
  316.  
  317.   In order to avoid the clock-probe inaccuracy, you should clip out the
  318.   clock timings and put them in your Xconfig as the value of the Clocks
  319.   property --- this suppresses the timing loop and gives X an exact list
  320.   of the clock values it can try.  Using the data from the example
  321.   above:
  322.  
  323.  
  324.   wga
  325.           Clocks  25 28 40 3 50 77 36 45 0 0 79 31 94 65 75 71
  326.  
  327.  
  328.  
  329.   On systems with a highly variable load, this may help you avoid
  330.   mysterious X startup failures.  It's possible for X to come up, get
  331.   its timings wrong due to system load, and then not be able to find a
  332.   matching dot clock in its config database --- or find the wrong one!
  333.  
  334.  
  335.   4.1.  The monitor's video bandwidth:
  336.  
  337.  
  338.   If you're running XFree86, your server will probe your card and tell
  339.   you what your highest-available dot clock is.
  340.  
  341.   Otherwise, your highest available dot clock is approximately the
  342.   monitor's video bandwidth.  There's a lot of give here, though ---
  343.   some monitors can run as much as 30% over their nominal bandwidth.
  344.   The risks here have to do with exceeding the monitor's rated vertical-
  345.   sync frequency; we'll discuss them in detail below.
  346.  
  347.   Knowing the bandwidth will enable you to make more intelligent choices
  348.   between possible configurations.  It may affect your display's visual
  349.   quality (especially sharpness for fine details).
  350.  
  351.   Your monitor's video bandwidth should be included on the manual's spec
  352.   page.  If it's not, look at the monitor's higest rated resolution.  As
  353.   a rule of thumb, here's how to translate these into bandwidth
  354.   estimates (and thus into rough upper bounds for the dot clock you can
  355.   use):
  356.  
  357.  
  358.  
  359.                640x480                 25
  360.                800x600                 36
  361.                1024x768                65
  362.                1024x768 interlaced     45
  363.                1280x1024               110
  364.                1600x1200               185
  365.  
  366.  
  367.  
  368.  
  369.   BTW, there's nothing magic about this table; these numbers are just
  370.   the lowest dot clocks per resolution in the standard XFree86 Modes
  371.   database (except for the last, which I interpolated).  The bandwidth
  372.   of your monitor may actually be higher than the minimum needed for its
  373.   top resolution, so don't be afraid to try a dot clock a few MHz
  374.   higher.
  375.  
  376.   Also note that bandwidth is seldom an issue for dot clocks under 65MHz
  377.   or so.  With an SVGA card and most hi-res monitors, you can't get
  378.   anywhere near the limit of your monitor's video bandwidth.  The
  379.   following are examples:
  380.  
  381.  
  382.  
  383.                Brand                           Video Bandwidth
  384.                ----------                      ---------------
  385.                NEC 4D                          75Mhz
  386.                Nano 907a                       50Mhz
  387.                Nano 9080i                      60Mhz
  388.                Mitsubishi HL6615               110Mhz
  389.                Mitsubishi Diamond Scan         100Mhz
  390.                IDEK MF-5117                    65Mhz
  391.                IOCOMM Thinksync-17 CM-7126     136Mhz
  392.                HP D1188A                       100Mhz
  393.                Philips SC-17AS                 110Mhz
  394.                Swan SW617                      85Mhz
  395.                Viewsonic 21PS                  185Mhz
  396.  
  397.   Even low-end monitors usually aren't terribly bandwidth-constrained
  398.   for their rated resolutions.  The NEC Multisync II makes a good
  399.   example --- it can't even display 800x600 per its spec.  It can only
  400.   display 800x560.  For such low resolutions you don't need high dot
  401.   clocks or a lot of bandwidth; probably the best you can do is 32Mhz or
  402.   36Mhz, both of them are still not too far from the monitor's rated
  403.   video bandwidth of 30Mhz.
  404.  
  405.   At these two driving frequencies, your screen image may not be as
  406.   sharp as it should be, but definitely of tolerable quality. Of course
  407.   it would be nicer if NEC Multisync II had a video bandwidth higher
  408.   than, say, 36Mhz.  But this is not critical for common tasks like text
  409.   editing, as long as the difference is not so significant as to cause
  410.   severe image distortion (your eyes would tell you right away if this
  411.   were so).
  412.  
  413.  
  414.   4.2.  What these control:
  415.  
  416.  
  417.   The sync frequency ranges of your monitor, together with your video
  418.   adapter's dot clock, determine the ultimate resolution that you can
  419.   use.  But it's up to the driver to tap the potential of your hardware.
  420.   A superior hardware combination without an equally competent device
  421.   driver is a waste of money.  On the other hand, with a versatile
  422.   device driver but less capable hardware, you can push the hardware's
  423.   envelope a little.  This is the design philosophy of XFree86.
  424.  
  425.  
  426.   5.  Interpreting the Basic Specifications
  427.  
  428.  
  429.   This section explains what the specifications above mean, and some
  430.   other things you'll need to know.  First, some definitions.  Next to
  431.   each in parens is the variable name we'll use for it when doing
  432.   calculations
  433.  
  434.  
  435.      horizontal sync frequency (HSF)
  436.         Horizontal scans per second (see above).
  437.  
  438.  
  439.      vertical sync frequency (VSF)
  440.         Vertical scans per second (see above).  Mainly important as the
  441.         upper limit on your refresh rate.
  442.  
  443.  
  444.      dot clock (DCF)
  445.         More formally, `driving clock frequency'; The frequency of the
  446.         crystal or VCO on your adaptor --- the maximum dots-per-second
  447.         it can emit.
  448.  
  449.  
  450.      video bandwidth (VB)
  451.         The highest frequency you can feed into your monitor's video
  452.         input and still expect to see anything discernible. If your
  453.         adaptor produces an alternating on/off pattern, its lowest
  454.         frequency is half the DCF, so in theory bandwidth starts making
  455.         sense at DCF/2. For tolerately crisp display of fine details in
  456.         the video image, however, you don't want it much below your
  457.         highest DCF, and preferably higher.
  458.  
  459.  
  460.      frame length (HFL, VFL)
  461.         Horizontal frame length (HFL) is the number of dot-clock ticks
  462.         needed for your monitor's electron gun to scan one horizontal
  463.         line, including the inactive left and right borders.  Vertical
  464.         frame length (VFL) is the number of scan lines in the entire
  465.         image, including the inactive top and bottom borders.
  466.  
  467.  
  468.      screen refresh rate (RR)
  469.         The number of times per second your screen is repainted (this is
  470.         also called "frame rate").  Higher frequencies are better, as
  471.         they reduce flicker.  60Hz is good, VESA-standard 72Hz is
  472.         better.  Compute it as
  473.  
  474.  
  475.                   RR = DCF / (HFL * VFL)
  476.  
  477.  
  478.  
  479.  
  480.      Note that the product in the denominator is not the same as the
  481.      monitor's visible resolution, but typically somewhat larger.  We'll
  482.      get to the details of this below.
  483.  
  484.      The rates for which interlaced modes are usually specified (like
  485.      87Hz interlaced) are actually the half-frame rates: an entire
  486.      screen seems to have about that flicker frequency for typical
  487.      displays, but every single line is refreshed only half as often.
  488.  
  489.      For calculation purposes we reckon an interlaced display at its
  490.      full-frame (refresh) rate, i.e. 43.5Hz. The quality of an
  491.      interlaced mode is better than that of a non-interlaced mode with
  492.      the same full-frame rate, but definitely worse then the non-
  493.      interlaced one corresponding to the half-frame rate.
  494.  
  495.  
  496.   5.1.  About Bandwidth:
  497.  
  498.  
  499.   Monitor makers like to advertise high bandwidth because it constrains
  500.   the sharpness of intensity and color changes on the screen.  A high
  501.   bandwidth means smaller visible details.
  502.  
  503.   Your monitor uses electronic signals to present an image to your eyes.
  504.   Such signals always come in in wave form once they are converted into
  505.   analog form from digitized form.  They can be considered as
  506.   combinations of many simpler wave forms each one of which has a fixed
  507.   frequency, many of them are in the Mhz range, eg, 20Mhz, 40Mhz, or
  508.   even 70Mhz.  Your monitor video bandwidth is, effectively, the
  509.   highest-frequency analog signal it can handle without distortion.
  510.  
  511.   For our purposes, video bandwidth is mainly important as an
  512.   approximate cutoff point for the highest dot clock you can use.
  513.  
  514.  
  515.   5.2.  Sync Frequencies and the Refresh Rate:
  516.  
  517.  
  518.   Each horizontal scan line on the display is just the visible portion
  519.   of a frame-length scan.  At any instant there is actually only one dot
  520.   active on the screen, but with a fast enough refresh rate your eye's
  521.   persistence of vision enables you to "see" the whole image.
  522.  
  523.   Here are some pictures to help:
  524.  
  525.  
  526.  
  527.  
  528.  
  529.        _______________________
  530.       |                       |     The horizontal sync frequency
  531.       |->->->->->->->->->->-> |     is the number of times per
  532.       |                      )|     second that the monitor's
  533.       |<-----<-----<-----<--- |     electron beam can trace
  534.       |                       |     a pattern like this
  535.       |                       |
  536.       |                       |
  537.       |                       |
  538.       |_______________________|
  539.        _______________________
  540.       |        ^              |     The vertical sync frequency
  541.       |       ^ |             |     is the number of times per
  542.       |       | v             |     second that the monitor's
  543.       |       ^ |             |     electron beam can trace
  544.       |       | |             |     a pattern like this
  545.       |       ^ |             |
  546.       |       | v             |
  547.       |       ^ |             |
  548.       |_______|_v_____________|
  549.  
  550.  
  551.  
  552.   Remember that the actual raster scan is a very tight zigzag pattern;
  553.   that is, the beam moves left-right and at the same time up-down.
  554.  
  555.   Now we can see how the dot clock and frame size relates to refresh
  556.   rate.  By definition, one hertz (hz) is one cycle per second.  So, if
  557.   your horizontal frame length is HFL and your vertical frame length is
  558.   VFL, then to cover the entire screen takes (HFL * VFL) ticks.  Since
  559.   your card emits DCF ticks per second by definition, then obviously
  560.   your monitor's electron gun(s) can sweep the screen from left to right
  561.   and back and from bottom to top and back DCF / (HFL * VFL) times/sec.
  562.   This is your screen's refresh rate, because it's how many times your
  563.   screen can be updated (thus refreshed) per second!
  564.  
  565.   You need to understand this concept to design a configuration which
  566.   trades off resolution against flicker in whatever way suits your
  567.   needs.
  568.  
  569.   For those of you who handle visuals better than text, here is one:
  570.  
  571.  
  572.           RR                                      VB
  573.            |   min HSF                     max HSF |
  574.            |    |             R1        R2  |      |
  575.   max VSF -+----|------------/----------/---|------+----- max VSF
  576.            |    |:::::::::::/::::::::::/:::::\     |
  577.            |    \::::::::::/::::::::::/:::::::\    |
  578.            |     |::::::::/::::::::::/:::::::::|   |
  579.            |     |:::::::/::::::::::/::::::::::\   |
  580.            |     \::::::/::::::::::/::::::::::::\  |
  581.            |      \::::/::::::::::/::::::::::::::| |
  582.            |       |::/::::::::::/:::::::::::::::| |
  583.            |        \/::::::::::/:::::::::::::::::\|
  584.            |        /\:::::::::/:::::::::::::::::::|
  585.            |       /  \:::::::/::::::::::::::::::::|\
  586.            |      /    |:::::/:::::::::::::::::::::| |
  587.            |     /     \::::/::::::::::::::::::::::| \
  588.   min VSF -+----/-------\--/-----------------------|--\--- min VSF
  589.            |   /         \/                        |   \
  590.            +--/----------/\------------------------+----\- DCF
  591.              R1        R2  \                       |     \
  592.                             min HSF                |    max HSF
  593.                                                    VB
  594.  
  595.   This is a generic monitor mode diagram.  The x axis of the diagram
  596.   shows the clock rate (DCF), the y axis represents the refresh rate
  597.   (RR). The filled region of the diagram describes the monitor's
  598.   capabilities: every point within this region is a possible video mode.
  599.  
  600.   The lines labeled `R1' and `R2' represent a fixed resolutions (such as
  601.   640x480); they are meant to illustrate how one resolution can be
  602.   realized by many different combinations of dot clock and refresh rate.
  603.   The R2 line would represent a higher resolution than R1.
  604.  
  605.   The top and bottom boundaries of the permitted region are simply
  606.   horizontal lines representing the limiting values for the vertical
  607.   sync frequency. The video bandwidth is an upper limit to the clock
  608.   rate and hence is represented by a vertical line bounding the
  609.   capability region on the right.
  610.  
  611.   Under ``Plotting Monitor Capabilities'') you'll find a program that
  612.   will help you plot a diagram like this (but much nicer, with X
  613.   graphics) for your individual monitor.  That section also discusses
  614.   the interesting part; the derivation of the boundaries resulting from
  615.   the limits on the horizontal sync frequency.
  616.  
  617.  
  618.   6.  Tradeoffs in Configuring your System
  619.  
  620.  
  621.   Another way to look at the formula we derived above is
  622.  
  623.  
  624.  
  625.                DCF = RR * HFL * VFL
  626.  
  627.  
  628.  
  629.  
  630.   That is, your dot clock is fixed.  You can use those dots per second
  631.   to buy either refresh rate, horizontal resolution, or vertical resolu-
  632.   tion.  If one of those increases, one or both of the others must
  633.   decrease.
  634.  
  635.   Note, though, that your refresh rate cannot be greater than the
  636.   maximum vertical sync frequency of your monitor.  Thus, for any given
  637.   monitor at a given dot clock, there is a minimum product of frame
  638.   lengths below which you can't force it.
  639.  
  640.   In choosing your settings, remember: if you set RR too low, you will
  641.   get mugged by screen flicker.
  642.  
  643.   You probably do not want to pull your refresh rate below 60Hz.  This
  644.   is the flicker rate of fluorescent lights; if you're sensitive to
  645.   those, you need to hang with 72Hz, the VESA ergonomic standard.
  646.  
  647.   Flicker is very eye-fatiguing, though human eyes are adaptable and
  648.   peoples' tolerance for it varies widely.  If you face your monitor at
  649.   a 90% viewing angle, are using a dark background and a good
  650.   contrasting color for foreground, and stick with low to medium
  651.   intensity, you *may* be comfortable at as little as 45Hz.
  652.  
  653.   The acid test is this: open a xterm with pure white back-ground and
  654.   black foreground using xterm -bg white -fg black and make it so large
  655.   as to cover the entire viewable area.  Now turn your monitor's
  656.   intensity to 3/4 of its maximum setting, and turn your face away from
  657.   the monitor.  Try peeking at your monitor sideways (bringing the more
  658.   sensitive peripheral-vision cells into play).  If you don't sense any
  659.   flicker or if you feel the flickering is tolerable, then that refresh
  660.   rate is fine with you.  Otherwise you better configure a higher
  661.   refresh rate, because that semi-invisible flicker is going to fatigue
  662.   your eyes like crazy and give you headaches, even if the screen looks
  663.   OK to normal vision.
  664.  
  665.   For interlaced modes, the amount of flicker depends on more factors
  666.   such as the current vertical resolution and the actual screen
  667.   contents.  So just experiment.  You won't want to go much below about
  668.   85Hz half frame rate, though.
  669.  
  670.   So let's say you've picked a minimum acceptable refresh rate.  In
  671.   choosing your HFL and VFL, you'll have some room for maneuver.
  672.  
  673.  
  674.   7.  Memory Requirements
  675.  
  676.  
  677.   Available frame-buffer RAM may limit the resolution you can achieve on
  678.   color or gray-scale displays.  It probably isn't a factor on displays
  679.   that have only two colors, white and black with no shades of gray in
  680.   between.
  681.  
  682.   For 256-color displays, a byte of video memory is required for each
  683.   visible dot to be shown.  This byte contains the information that
  684.   determines what mix of red, green, and blue is generated for its dot.
  685.   To get the amount of memory required, multiply the number of visible
  686.   dots per line by the number of visible lines.  For a display with a
  687.   resolution of 800x600, this would be 800 x 600 = 480,000, which is the
  688.   number of visible dots on the display.  This is also, at one byte per
  689.   dot, the number of bytes of video memory that are necessary on your
  690.   adapter card.
  691.  
  692.   Thus, your memory requirement will typically be (HR * VR)/1024 Kbytes
  693.   of VRAM, rounded up.  If you have more memory than strictly required,
  694.   you'll have extra for virtual-screen panning.
  695.  
  696.   However, if you only have 512K on board, then you can't use this
  697.   resolution.  Even if you have a good monitor, without enough video
  698.   RAM, you can't take advantage of your monitor's potential.  On the
  699.   other hand, if your SVGA has one meg, but your monitor can display at
  700.   most 800x600, then high resolution is beyond your reach anyway (see
  701.   ``Using Interlaced Modes'' for a possible remedy).
  702.  
  703.   Don't worry if you have more memory than required; XFree86 will make
  704.   use of it by allowing you to scroll your viewable area (see the
  705.   Xconfig file documentation on the virtual screen size parameter).
  706.   Remember also that a card with 512K bytes of memory really doesn't
  707.   have 512,000 bytes installed, it has 512 x 1024 = 524,288 bytes.
  708.  
  709.   If you're running SGCS X (now called X/Inside) using an S3 card, and
  710.   are willing to live with 16 colors (4 bits per pixel), you can set
  711.   depth 4 in Xconfig and effectively double the resolution your card can
  712.   handle.  S3 cards, for example, normally do 1024x768x256.  You can
  713.   make them do 1280x1024x16 with depth 4.
  714.  
  715.  
  716.   8.  Computing Frame Sizes
  717.  
  718.  
  719.   Warning: this method was developed for multisync monitors.  It will
  720.   probably work with fixed-frequency monitors as well, but no
  721.   guarantees!
  722.  
  723.   Start by dividing DCF by your highest available HSF to get a
  724.   horizontal frame length.
  725.  
  726.  
  727.   For example; suppose you have a Sigma Legend SVGA with a 65MHz dot
  728.   clock, and your monitor has a 55KHz horizontal scan frequency.  The
  729.   quantity (DCF / HSF) is then 1181 (65MHz = 65000KHz; 65000/55 = 1181).
  730.  
  731.   Now for our first bit of black magic.  You need to round this figure
  732.   to the nearest multiple of 8.  This has to do with the VGA hardware
  733.   controller used by SVGA and S3 cards; it uses an 8-bit register, left-
  734.   shifted 3 bits, for what's really an 11-bit quantity.  Other card
  735.   types such as ATI 8514/A may not have this requirement, but we don't
  736.   know and the correction can't hurt.  So round the usable horizontal
  737.   frame length figure down to 1176.
  738.  
  739.   This figure (DCF / HSF rounded to a multiple of 8) is the minimum HFL
  740.   you can use.  You can get longer HFLs (and thus, possibly, more
  741.   horizontal dots on the screen) by setting the sync pulse to produce a
  742.   lower HSF.  But you'll pay with a slower and more visible flicker
  743.   rate.
  744.  
  745.   As a rule of thumb, 80% of the horizontal frame length is available
  746.   for horizontal resolution, the visible part of the horizontal scan
  747.   line (this allows, roughly, for borders and sweepback time -- that is,
  748.   the time required for the beam to move from the right screen edge to
  749.   the left edge of the next raster line).  In this example, that's 944
  750.   ticks.
  751.  
  752.   Now, to get the normal 4:3 screen aspect ratio, set your vertical
  753.   resolution to 3/4ths of the horizontal resolution you just calculated.
  754.   For this example, that's 708 ticks.  To get your actual VFL, multiply
  755.   that by 1.05 to get 743 ticks.
  756.  
  757.   The 4:3 is not technically magic; nothing prevents you from using a
  758.   non-Golden-Section ratio if that will get the best use out of your
  759.   screen real estate.  It does make figuring frame height and frame
  760.   width from the diagonal size convenient, you just multiply the
  761.   diagonal by by 0.8 to get width and 0.6 to get height.
  762.  
  763.   So, HFL=1176 and VFL=743.  Dividing 65MHz by the product of the two
  764.   gives us a nice, healthy 74.4Hz refresh rate.  Excellent!  Better than
  765.   VESA standard!  And you got 944x708 to boot, more than the 800 by 600
  766.   you were probably expecting.  Not bad at all!
  767.  
  768.   You can even improve the refresh rate further, to almost 76 Hz, by
  769.   using the fact that monitors can often sync horizontally at 2khz or so
  770.   higher than rated, and by lowering VFL somewhat (that is, taking less
  771.   than 75% of 944 in the example above).  But before you try this
  772.   "overdriving" maneuver, if you do, make sure that your monitor
  773.   electron guns can sync up to 76 Hz vertical.  (the popular NEC 4D, for
  774.   instance, cannot.  It goes only up to 75 Hz VSF).  (See ``Overdriving
  775.   Your Monitor'' for more general discussion of this issue. )
  776.  
  777.   So far, most of this is simple arithmetic and basic facts about raster
  778.   displays.  Hardly any black magic at all!
  779.  
  780.  
  781.   9.  Black Magic and Sync Pulses
  782.  
  783.  
  784.   OK, now you've computed HFL/VFL numbers for your chosen dot clock,
  785.   found the refresh rate acceptable, and checked that you have enough
  786.   VRAM.  Now for the real black magic -- you need to know when and where
  787.   to place synchronization pulses.
  788.  
  789.   The sync pulses actually control the horizontal and vertical scan
  790.   frequebcies of the monitor.  The HSF and VSF you've pulled off the
  791.   spec sheet are nominal, approximate maximum sync frequencies.  The
  792.   sync pulse in the signal from the adapter card tells the monitor how
  793.   fast to actually run.
  794.  
  795.   Recall the two pictures above?  Only part of the time required for
  796.   raster-scanning a frame is used for displaying viewable image (ie.
  797.   your resolution).
  798.  
  799.  
  800.   9.1.  Horizontal Sync:
  801.  
  802.  
  803.   By previous definition, it takes HFL ticks to trace the a horizontal
  804.   scan line.  Let's call the visible tick count (your horizontal screen
  805.   resolution) HR.  Then Obviously, HR < HFL by definition.  For
  806.   concreteness, let's assume both start at the same instant as shown
  807.   below:
  808.  
  809.  
  810.     |___ __ __ __ __ __ __ __ __ __ __ __ __
  811.     |_ _ _ _ _ _ _ _ _ _ _ _                |
  812.     |_______________________|_______________|_____
  813.     0                       ^               ^     unit: ticks
  814.                             |   ^       ^   |
  815.                             HR  |       |  HFL
  816.                             |   |<----->|   |
  817.                             |<->|  HSP  |<->|
  818.                             HGT1         HGT2
  819.  
  820.  
  821.  
  822.   Now, we would like to place a sync pulse of length HSP as shown above,
  823.   ie, between the end of clock ticks for display data and the end of
  824.   clock ticks for the entire frame.  Why so?  because if we can achieve
  825.   this, then your screen image won't shift to the right or to the left.
  826.   It will be where it supposed to be on the screen, covering squarely
  827.   the monitor's viewable area.
  828.  
  829.   Furthermore, we want about 30 ticks of "guard time" on either side of
  830.   the sync pulse.  This is represented by HGT1 and HGT2.  In a typical
  831.   configuration HGT1 != HGT2, but if you're building a configuration
  832.   from scratch, you want to start your experimentation with them equal
  833.   (that is, with the sync pulse centered).
  834.  
  835.   The symptom of a misplaced sync pulse is that the image is displaced
  836.   on the screen, with one border excessively wide and the other side of
  837.   the image wrapped around the screen edge, producing a white edge line
  838.   and a band of "ghost image" on that side.  A way-out-of-place vertical
  839.   sync pulse can actually cause the image to roll like a TV with a mis-
  840.   adjusted vertical hold (in fact, it's the same phenomenon at work).
  841.  
  842.   If you're lucky, your monitor's sync pulse widths will be documented
  843.   on its specification page.  If not, here's where the real black magic
  844.   starts...
  845.  
  846.   You'll have to do a little trial and error for this part.  But most of
  847.   the time, we can safely assume that a sync pulse is about 3.5 to 4.0
  848.   microsecond in length.
  849.  
  850.   For concretness again, let's take HSP to be 3.8 microseconds (which
  851.   btw, is not a bad value to start with when experimenting).
  852.  
  853.   Now, using the 65Mhz clock timing above, we know HSP is equivalent to
  854.   247 clock ticks (= 65 * 10**6 * 3.8 * 10^-6) [recall M=10^6,
  855.   micro=10^-6]
  856.  
  857.   Some makers like to quote their horizontal framing parameters as
  858.   timings rather than dot widths.  You may see the following terms:
  859.      active time (HAT)
  860.         Corresponds to HR, but in milliseconds.  HAT * DCF = HR.
  861.  
  862.      blanking time (HBT)
  863.         Corresponds to (HFL - HR), but in milliseconds.  HBT * DCF =
  864.         (HFL - HR).
  865.  
  866.      front porch (HFP)
  867.         This is just HGT1.
  868.  
  869.      sync time
  870.         This is just HSP.
  871.  
  872.      back porch (HBP)
  873.         This is just HGT2.
  874.  
  875.  
  876.   9.2.  Vertical Sync:
  877.  
  878.  
  879.   Going back to the picture above, how do we place the 247 clock ticks
  880.   as shown in the picture?
  881.  
  882.   Using our example, HR is 944 and HFL is 1176.  The difference between
  883.   the two is 1176 - 944=232 < 247!  Obviously we have to do some
  884.   adjustment here.  What can we do?
  885.  
  886.   The first thing is to raise 1176 to 1184, and lower 944 to 936.  Now
  887.   the difference = 1184-936= 248. Hmm, closer.
  888.  
  889.   Next, instead using 3.8, we use 3.5 for calculating HSP; then, we have
  890.   65*3.5=227.  Looks better.  But 248 is not much higher than 227.  It's
  891.   normally necessary to have 30 or so clock ticks between HR and the
  892.   start of SP, and the same for the end of SP and HFL.  AND they have to
  893.   be multiple of eight!  Are we stuck?
  894.  
  895.   No.  Let's do this, 936 % 8 = 0, (936 + 32) % 8 = 0 too.  But 936 + 32
  896.   = 968, 968 + 227 = 1195, 1195 + 32 = 1227.  Hmm.. this looks not too
  897.   bad.  But it's not a multiple of 8, so let's round it up to 1232.
  898.  
  899.   But now we have potential trouble, the sync pulse is no longer placed
  900.   right in the middle between h and H any more.  Happily, using our
  901.   calculator we find 1232 - 32 = 1200 is also a multiple of 8 and (1232
  902.   - 32) - 968 = 232 corresponding using a sync pulse of 3.57 micro
  903.   second long, still reasonable.
  904.  
  905.   In addition, 936/1232   0.76 or 76%, still not far from 80%, so it
  906.   should be all right.
  907.  
  908.   Furthermore, using the current horizontal frame length, we basically
  909.   ask our monitor to sync at 52.7khz (= 65Mhz/1232) which is within its
  910.   capability.  No problems.
  911.  
  912.   Using rules of thumb we mentioned before, 936*75%=702, This is our new
  913.   vertical resolution.  702 * 1.05 = 737, our new vertical frame length.
  914.  
  915.   Screen refresh rate = 65Mhz/(737*1232)=71.6 Hz.  This is still
  916.   excellent.
  917.  
  918.   Figuring the vertical sync pulse layout is similar:
  919.  
  920.  
  921.  
  922.  
  923.  
  924.  
  925.      |___ __ __ __ __ __ __ __ __ __ __ __ __
  926.      |_ _ _ _ _ _ _ _ _ _ _ _                |
  927.      |_______________________|_______________|_____
  928.      0                      VR              VFL     unit: ticks
  929.                              ^   ^       ^
  930.                              |   |       |
  931.                              |<->|<----->|
  932.                               VGT    VSP
  933.  
  934.  
  935.  
  936.   We start the sync pulse just past the end of the vertical display data
  937.   ticks.  VGT is the vertical guard time required for the sync pulse.
  938.   Most monitors are comfortable with a VGT of 0 (no guard time) and
  939.   we'll use that in this example.  A few need two or three ticks of
  940.   guard time, and it usually doesn't hurt to add that.
  941.  
  942.   Returning to the example: since by the defintion of frame length, a
  943.   vertical tick is the time for tracing a complete HORIZONTAL frame,
  944.   therefore in our example, it is 1232/65Mhz=18.95us.
  945.  
  946.   Experience shows that a vertical sync pulse should be in the range of
  947.   50us and 300us.  As an example let's use 150us, which translates into
  948.   8 vertical clock ticks (150us/18.95us 8).
  949.  
  950.   Some makers like to quote their vertical framing parameters as timings
  951.   rather than dot widths.  You may see the following terms:
  952.  
  953.  
  954.      active time (VAT)
  955.         Corresponds to VR, but in milliseconds.  VAT * VSF = VR.
  956.  
  957.      blanking time (VBT)
  958.         Corresponds to (VFL - VR), but in milliseconds.  VBT * VSF =
  959.         (VFL - VR).
  960.  
  961.      front porch (VFP)
  962.         This is just VGT.
  963.  
  964.      sync time
  965.         This is just VSP.
  966.  
  967.      back porch (VBP)
  968.         This is like a second guard time after the vertical sync pulse.
  969.         It is often zero.
  970.  
  971.  
  972.   10.  Putting it All Together
  973.  
  974.  
  975.   The Xconfig file Table of Video Modes contains lines of numbers, with
  976.   each line being a complete specification for one mode of X-server
  977.   operation.  The fields are grouped into four sections, the name
  978.   section, the clock frequency section, the horizontal section, and the
  979.   vertical section.
  980.  
  981.   The name section contains one field, the name of the video mode
  982.   specified by the rest of the line.  This name is referred to on the
  983.   "Modes" line of the Graphics Driver Setup section of the Xconfig file.
  984.   The name field may be omitted if the name of a previous line is the
  985.   same as the current line.
  986.  
  987.   The dot clock section contains only the dot clock (what we've called
  988.   DCF) field of the video mode line.  The number in this field specifies
  989.   what dot clock was used to generate the numbers in the following
  990.   sections.
  991.   The horizontal section consists of four fields which specify how each
  992.   horizontal line on the display is to be generated.  The first field of
  993.   the section contains the number of dots per line which will be
  994.   illuminated to form the picture (what we've called HR).  The second
  995.   field of the section (SH1) indicates at which dot the horizontal sync
  996.   pulse will begin.  The third field (SH2) indicates at which dot the
  997.   horizontal sync pulse will end.  The fourth field specifies the toal
  998.   horzontal frame length (HFL).
  999.  
  1000.   The vertical section also contains four fields.  The first field
  1001.   contains the number of visible lines which will appear on the display
  1002.   (VR).  The second field (SV1) indicates the line number at which the
  1003.   vertical sync pulse will begin.  The third field (SV2) specifies the
  1004.   line number at which the vertical sync pulse will end.  The fourth
  1005.   field contains the total vertical frame length (VFL).
  1006.  
  1007.   Example:
  1008.  
  1009.  
  1010.             #Modename    clock  horizontal timing  vertical timing
  1011.  
  1012.             "752x564"     40    752 784  944 1088  564 567 569 611
  1013.                           44.5  752 792  976 1240  564 567 570 600
  1014.  
  1015.  
  1016.  
  1017.  
  1018.   (Note: stock X11R5 doesn't support fractional dot clocks.)
  1019.  
  1020.   For Xconfig, all of the numbers just mentioned - the number of
  1021.   illuminated dots on the line, the number of dots separating the
  1022.   illuminated dots from the beginning of the sync pulse, the number of
  1023.   dots representing the duration of the pulse, and the number of dots
  1024.   after the end of the sync pulse - are added to produce the number of
  1025.   dots per line.  The number of horizontal dots must be evenly divisible
  1026.   by eight.
  1027.  
  1028.   Example horizontal numbers: 800 864 1024 1088
  1029.  
  1030.   This sample line has the number of illuminated dots (800) followed by
  1031.   the number of the dot when the sync pulse starts (864), followed by
  1032.   the number of the dot when the sync pulse ends (1024), followed by the
  1033.   number of the last dot on the horizontal line (1088).
  1034.  
  1035.   Note again that all of the horizontal numbers (800, 864, 1024, and
  1036.   1088) are divisible by eight!  This is not required of the vertical
  1037.   numbers.
  1038.  
  1039.   The number of lines from the top of the display to the bottom form the
  1040.   frame.  The basic timing signal for a frame is the line.  A number of
  1041.   lines will contain the picture.  After the last illuminated line has
  1042.   been displayed, a delay of a number of lines will occur before the
  1043.   vertical sync pulse is generated.  Then the sync pulse will last for a
  1044.   few lines, and finally the last lines in the frame, the delay required
  1045.   after the pulse, will be generated.  The numbers that specify this
  1046.   mode of operation are entered in a manner similar to the following
  1047.   example.
  1048.  
  1049.   Example vertical numbers: 600 603 609 630
  1050.  
  1051.   This example indicates that there are 600 visible lines on the
  1052.   display, that the vertical sync pulse starts with the 603rd line and
  1053.   ends with the 609th, and that there are 630 total lines being used.
  1054.  
  1055.   Note that the vertical numbers don't have to be divisible by eight!
  1056.  
  1057.   Let's return to the example we've been working.  According to the
  1058.   above, all we need to do from now on is to write our result into
  1059.   Xconfig as follows:
  1060.  
  1061.  
  1062.        <name>   DCF     HR  SH1 SH2   HFL   VR  SV1 SV2 VFL
  1063.  
  1064.  
  1065.  
  1066.  
  1067.   where SH1 is the start tick of the horizontal sync pulse and SH2 is
  1068.   its end tick; similarly, SV1 is the start tick of the vertical sync
  1069.   pulse and SV2 is its end tick.
  1070.  
  1071.  
  1072.        #name    clock   horizontal timing   vertical timing    flag
  1073.        936x702  65      936 968 1200 1232   702 702 710 737
  1074.  
  1075.  
  1076.  
  1077.  
  1078.   No special flag necessary; this is a non-interlaced mode.  Now we are
  1079.   really done.
  1080.  
  1081.  
  1082.   11.  Overdriving Your Monitor
  1083.  
  1084.  
  1085.   You should absolutely not try exceeding your monitor's scan rates if
  1086.   it's a fixed-frequency type.  You can smoke your hardware doing this!
  1087.   There are potentially subtler problems with overdriving a multisync
  1088.   monitor which you should be aware of.
  1089.  
  1090.   Having a pixel clock higher than the monitor's maximum bandwidth is
  1091.   rather harmless, in contrast.  (Note: the theoretical limit of
  1092.   discernable features is reached when the pixel clock reaches double
  1093.   the monitor's bandwidth.  This is a straightforward application of
  1094.   Nyquist's Theorem: consider the pixels as a spatially distributed
  1095.   series of samples of the drive signals and you'll see why.)
  1096.  
  1097.   It's exceeding the rated maximum sync frequencies that's problematic.
  1098.   Some modern monitors might have protection circuitry that shuts the
  1099.   monitor down at dangerous scan rates, but don't rely on it.  In
  1100.   particular there are older multisync monitors (like the Multisync II)
  1101.   which use just one horizontal transformer. These monitors will not
  1102.   have much protection against overdriving them.  While you necessarily
  1103.   have high voltage regulation circuitry (which can be absent in fixed
  1104.   frequency monitors), it will not necessarily cover every conceivable
  1105.   frequency range, especially in cheaper models. This not only implies
  1106.   more wear on the circuitry, it can also cause the screen phosphors to
  1107.   age faster, and cause more than the specified radiation (including X-
  1108.   rays) to be emitted from the monitor.
  1109.  
  1110.   Another importance of the bandwidth is that the monitor's input
  1111.   impedance is specified only for that range, and using higher
  1112.   frequencies can cause reflections probably causing minor screen
  1113.   interferences, and radio disturbance.
  1114.  
  1115.   However, the basic problematic magnitude in question here is the slew
  1116.   rate (the steepness of the video signals) of the video output drivers,
  1117.   and that is usually independent of the actual pixel frequency, but (if
  1118.   your board manufacturer cares about such problems) related to the
  1119.   maximum pixel frequency of the board.
  1120.  
  1121.   So be careful out there...
  1122.  
  1123.   12.  Using Interlaced Modes
  1124.  
  1125.  
  1126.   (This section is largely due to David Kastrup
  1127.   <dak@pool.informatik.rwth-aachen.de>)
  1128.  
  1129.   At a fixed dot clock, an interlaced display is going to have
  1130.   considerably less noticable flicker than a non-interlaced display, if
  1131.   the vertical circuitry of your monitor is able to support it stably.
  1132.   It is because of this that interlaced modes were invented in the first
  1133.   place.
  1134.  
  1135.   Interlaced modes got their bad repute because they are inferior to
  1136.   their non-interlaced companions at the same vertical scan frequency,
  1137.   VSF (which is what is usually given in advertisements). But they are
  1138.   definitely superior at the same horizontal scan rate, and that's where
  1139.   the decisive limits of your monitor/graphics card usually lie.
  1140.  
  1141.   At a fixed refresh rate (or half frame rate, or VSF) the interlaced
  1142.   display will flicker more: a 90Hz interlaced display will be inferior
  1143.   to a 90Hz non-interlaced display. It will, however, need only half the
  1144.   video bandwidth and half the horizontal scan rate. If you compared it
  1145.   to a non-interlaced mode with the same dot clock and the same scan
  1146.   rates, it would be vastly superior: 45Hz non-interlaced is
  1147.   intolerable. With 90Hz interlaced, I have worked for years with my
  1148.   Multisync 3D (at 1024x768) and am very satisfied. I'd guess you'd need
  1149.   at least a 70Hz non-interlaced display for similar comfort.
  1150.  
  1151.   You have to watch a few points, though: use interlaced modes only at
  1152.   high resolutions, so that the alternately lighted lines are close
  1153.   together. You might want to play with sync pulse widths and positions
  1154.   to get the most stable line positions. If alternating lines are bright
  1155.   and dark, interlace will jump at you. I have one application that
  1156.   chooses such a dot pattern for a menu background (XCept, no other
  1157.   application I know does that, fortunately). I switch to 800x600 for
  1158.   using XCept because it really hurts my eyes otherwise.
  1159.  
  1160.   For the same reason, use at least 100dpi fonts, or other fonts where
  1161.   horizontal beams are at least two lines thick (for high resolutions,
  1162.   nothing else will make sense anyhow).
  1163.  
  1164.   And of course, never use an interlaced mode when your hardware would
  1165.   support a non-interlaced one with similar refresh rate.
  1166.  
  1167.   If, however, you find that for some resolution you are pushing either
  1168.   monitor or graphics card to their upper limits, and getting
  1169.   dissatisfactorily flickery or outwashed (bandwidth exceeded) display,
  1170.   you might want to try tackling the same resolution using an interlaced
  1171.   mode. Of course this is useless if the VSF of your monitor is already
  1172.   close to its limits.
  1173.  
  1174.   Design of interlaced modes is easy: do it like a non-interlaced mode.
  1175.   Just two more considerations are necessary: you need an odd total
  1176.   number of vertical lines (the last number in your mode line), and when
  1177.   you specify the "interlace" flag, the actual vertical frame rate for
  1178.   your monitor doubles. Your monitor needs to support a 90Hz frame rate
  1179.   if the mode you specified looks like a 45Hz mode apart from the
  1180.   "Interlace" flag.
  1181.  
  1182.   As an example, here is my modeline for 1024x768 interlaced: my
  1183.   Multisync 3D will support up to 90Hz vertical and 38kHz horizontal.
  1184.  
  1185.  
  1186.  
  1187.        ModeLine "1024x768" 45 1024 1048 1208 1248 768 768 776 807 Interlace
  1188.  
  1189.   Both limits are pretty much exhausted with this mode. Specifying the
  1190.   same mode, just without the "Interlace" flag, still is almost at the
  1191.   limit of the monitor's horizontal capacity (and strictly speaking, a
  1192.   bit under the lower limit of vertical scan rate), but produces an
  1193.   intolerably flickery display.
  1194.  
  1195.   Basic design rules: if you have designed a mode at less than half of
  1196.   your monitor's vertical capacity, make the vertical total of lines odd
  1197.   and add the "Interlace" flag. The display's quality should vastly
  1198.   improve in most cases.
  1199.  
  1200.   If you have a non-interlaced mode otherwise exhausting your monitor's
  1201.   specs where the vertical scan rate lies about 30% or more under the
  1202.   maximum of your monitor, hand-designing an interlaced mode (probably
  1203.   with somewhat higher resolution) could deliver superior results, but I
  1204.   won't promise it.
  1205.  
  1206.  
  1207.   13.  Questions and Answers
  1208.  
  1209.  
  1210.   Q. The example you gave is not a standard screen size, can I use it?
  1211.  
  1212.   A. Why not?  There is NO reason whatsover why you have to use 640x480,
  1213.   800x600, or even 1024x768.  The XFree86 servers let you configure your
  1214.   hardware with a lot of freedom.  It usually takes two to three tries
  1215.   to come up the right one.  The important thing to shoot for is high
  1216.   refresh rate with reasonable viewing area. not high resolution at the
  1217.   price of eye-tearing flicker!
  1218.  
  1219.   Q. It this the only resolution given the 65Mhz dot clock and 55Khz
  1220.   HSF?
  1221.  
  1222.   A. Absolutely not!  You are encouraged to follow the general procedure
  1223.   and do some trial-and-error to come up a setting that's really to your
  1224.   liking.  Experimenting with this can be lots of fun.  Most settings
  1225.   may just give you nasty video hash, but in practice a modern multi-
  1226.   sync monitor is usually not damaged easily. Be sure though, that your
  1227.   monitor can support the frame rates of your mode before using it for
  1228.   longer times.
  1229.  
  1230.   Beware fixed-frequency monitors!  This kind of hacking around can
  1231.   damage them rather quickly. Be sure you use valid refresh rates for
  1232.   every experiment on them.
  1233.  
  1234.   Q. You just mentioned two standard resolutions. In Xconfig, there are
  1235.   many standard resolutions available, can you tell me whether there's
  1236.   any point in tinkering with timings?
  1237.  
  1238.   A. Absolutely!  Take, for example, the "standard" 640x480 listed in
  1239.   the current Xconfig.  It employes 25Mhz driving frequency, frame
  1240.   lengths are 800 and 525 => refresh rate   59.5Hz. Not too bad.  But
  1241.   28Mhz is a commonly available driving frequency from many SVGA boards.
  1242.   If we use it to drive 640x480, following the procedure we discussed
  1243.   above, you would get frame lengths like 812 (round down to 808) and
  1244.   505.  Now the refresh rate is raised to 68Hz, a quite significant
  1245.   improvement over the standard one.
  1246.  
  1247.   Q. Can you summarize what we have discussed so far?
  1248.  
  1249.   A. In a nutshell:
  1250.  
  1251.  
  1252.   1. for any fixed driving frequency, raising max resolution incurs the
  1253.      penalty of lowering refresh rate and thus introducing more flicker.
  1254.  
  1255.   2. if high resolution is desirable and your monitor supports it, try
  1256.      to get a SVGA card that provides a matching dot clock or DCF. The
  1257.      higher, the better!
  1258.  
  1259.  
  1260.   14.  Fixing Problems with the Image.
  1261.  
  1262.  
  1263.   OK, so you've got your X configuration numbers.  You put them in
  1264.   Xconfig with a test mode label.  You fire up X, hot-key to the new
  1265.   mode, ... and the image doesn't look right.  What do you do?  Here's a
  1266.   list of common video image distortions and how to fix them.
  1267.  
  1268.   (Fixing these minor distortions is where xvidtune(1) really shines.)
  1269.  
  1270.   You move the image by changing the sync pulse timing.  You scale it by
  1271.   changing the frame length (you need to move the sync pulse to keep it
  1272.   in the same relative position, otherwise scaling will move the image
  1273.   as well).  Here are some more specific recipes:
  1274.  
  1275.   The horizontal and vertical positions are independent.  That is,
  1276.   moving the image horizontally doesn't affect placement vertically, or
  1277.   vice-versa.  However, the same is not quite true of scaling.  While
  1278.   changing the horizontal size does nothing to the vertical size or vice
  1279.   versa, the total change in both may be limited.  In particular, if
  1280.   your image is too large in both dimensions you will probably have to
  1281.   go to a higher dot clock to fix it.  Since this raises the usable
  1282.   resolution, it is seldom a problem!
  1283.  
  1284.  
  1285.   14.1.  The image is displaced to the left or right
  1286.  
  1287.  
  1288.   To fix this, move the horizontal sync pulse.  That is, increment or
  1289.   decrement (by a multiple of 8) the middle two numbers of the
  1290.   horizontal timing section that define the leading and trailing edge of
  1291.   the horizontal sync pulse.
  1292.  
  1293.   If the image is shifted left (right border too large, you want to move
  1294.   the image to the right) decrement the numbers.  If the image is
  1295.   shifted right (left border too large, you want it to move left)
  1296.   increment the sync pulse.
  1297.  
  1298.  
  1299.   14.2.  The image is displaced up or down
  1300.  
  1301.  
  1302.   To fix this, move the vertical sync pulse.  That is, increment or
  1303.   decrement the middle two numbers of the vertical timing section that
  1304.   define the leading and trailing edge of the vertical sync pulse.
  1305.  
  1306.   If the image is shifted up (lower border too large, you want to move
  1307.   the image down) decrement the numbers.  If the image is shifted down
  1308.   (top border too large, you want it to move up) increment the numbers.
  1309.  
  1310.  
  1311.   14.3.  The image is too large both horizontally and vertically
  1312.  
  1313.  
  1314.   Switch to a higher card clock speed. If you have multiple modes in
  1315.   your clock file, possibly a lower-speed one is being activated by
  1316.   mistake.
  1317.  
  1318.  
  1319.  
  1320.  
  1321.   14.4.  The image is too wide (too narrow) horizontally
  1322.  
  1323.  
  1324.   To fix this, increase (decrease) the horizontal frame length.  That
  1325.   is, change the fourth number in the first timing section.  To avoid
  1326.   moving the image, also move the sync pulse (second and third numbers)
  1327.   half as far, to keep it in the same relative position.
  1328.  
  1329.  
  1330.   14.5.  The image is too deep (too shallow) vertically
  1331.  
  1332.  
  1333.   To fix this, increase (decrease) the vertical frame length.  That is,
  1334.   change the fourth number in the second timing section.  To avoid
  1335.   moving the image, also move the sync pulse (second and third numbers)
  1336.   half as far, to keep it in the same relative position.
  1337.  
  1338.   Any distortion that can't be handled by combining these techniques is
  1339.   probably evidence of something more basically wrong, like a
  1340.   calculation mistake or a faster dot clock than the monitor can handle.
  1341.  
  1342.   Finally, remember that increasing either frame length will decrease
  1343.   your refresh rate, and vice-versa.
  1344.  
  1345.  
  1346.   15.  Plotting Monitor Capabilities
  1347.  
  1348.  
  1349.   To plot a monitor mode diagram, you'll need the gnuplot package (a
  1350.   freeware plotting language for UNIX-like operating systems) and the
  1351.   tool modeplot, a shell/gnuplot script to plot the diagram from your
  1352.   monitor characteristics, entered as command-line options.
  1353.  
  1354.   Here is a copy of modeplot:
  1355.  
  1356.  
  1357.  
  1358.  
  1359.  
  1360.  
  1361.  
  1362.  
  1363.  
  1364.  
  1365.  
  1366.  
  1367.  
  1368.  
  1369.  
  1370.  
  1371.  
  1372.  
  1373.  
  1374.  
  1375.  
  1376.  
  1377.  
  1378.  
  1379.  
  1380.  
  1381.  
  1382.  
  1383.  
  1384.  
  1385.  
  1386.  
  1387.   #!/bin/sh
  1388.   #
  1389.   # modeplot -- generate X mode plot of available monitor modes
  1390.   #
  1391.   # Do `modeplot -?' to see the control options.
  1392.   #
  1393.   # ($Id: video-modes.sgml,v 1.5 1998/02/21 02:23:11 esr Exp $)
  1394.  
  1395.   # Monitor description. Bandwidth in MHz, horizontal frequencies in kHz
  1396.   # and vertical frequencies in Hz.
  1397.   TITLE="Viewsonic 21PS"
  1398.   BANDWIDTH=185
  1399.   MINHSF=31
  1400.   MAXHSF=85
  1401.   MINVSF=50
  1402.   MAXVSF=160
  1403.   ASPECT="4/3"
  1404.   vesa=72.5       # VESA-recommended minimum refresh rate
  1405.  
  1406.   while [ "$1" != "" ]
  1407.   do
  1408.           case $1 in
  1409.           -t) TITLE="$2"; shift;;
  1410.           -b) BANDWIDTH="$2"; shift;;
  1411.           -h) MINHSF="$2" MAXHSF="$3"; shift; shift;;
  1412.           -v) MINVSF="$2" MAXVSF="$3"; shift; shift;;
  1413.           -a) ASPECT="$2"; shift;;
  1414.           -g) GNUOPTS="$2"; shift;;
  1415.           -?) cat <<EOF
  1416.   modeplot control switches:
  1417.  
  1418.   -t "<description>"  name of monitor            defaults to "Viewsonic 21PS"
  1419.   -b <nn>                 bandwidth in MHz           defaults to 185
  1420.   -h <min> <max>          min & max HSF (kHz)        defaults to 31 85
  1421.   -v <min> <max>          min & max VSF (Hz)         defaults to 50 160
  1422.   -a <aspect ratio>       aspect ratio               defaults to 4/3
  1423.   -g "<options>"      pass options to gnuplot
  1424.  
  1425.   The -b, -h and -v options are required, -a, -t, -g optional.  You can
  1426.   use -g to pass a device type to gnuplot so that (for example) modeplot's
  1427.   output can be redirected to a printer.  See gnuplot(1) for  details.
  1428.  
  1429.   The modeplot tool was created by Eric S. Raymond <esr@thyrsus.com> based on
  1430.   analysis and scratch code by Martin Lottermoser <Martin.Lottermoser@mch.sni.de>
  1431.  
  1432.   This is modeplot $Revision: 1.5 $
  1433.   EOF
  1434.                   exit;;
  1435.           esac
  1436.           shift
  1437.   done
  1438.  
  1439.   gnuplot $GNUOPTS <<EOF
  1440.   set title "$TITLE Mode Plot"
  1441.  
  1442.   # Magic numbers.  Unfortunately, the plot is quite sensitive to changes in
  1443.   # these, and they may fail to represent reality on some monitors.  We need
  1444.   # to fix values to get even an approximation of the mode diagram.  These come
  1445.   # from looking at lots of values in the ModeDB database.
  1446.   F1 = 1.30       # multiplier to convert horizontal resolution to frame width
  1447.   F2 = 1.05       # multiplier to convert vertical resolution to frame height
  1448.  
  1449.   # Function definitions (multiplication by 1.0 forces real-number arithmetic)
  1450.   ac = (1.0*$ASPECT)*F1/F2
  1451.   refresh(hsync, dcf) = ac * (hsync**2)/(1.0*dcf)
  1452.   dotclock(hsync, rr) = ac * (hsync**2)/(1.0*rr)
  1453.   resolution(hv, dcf) = dcf * (10**6)/(hv * F1 * F2)
  1454.  
  1455.   # Put labels on the axes
  1456.   set xlabel 'DCF (MHz)'
  1457.   set ylabel 'RR (Hz)' 6  # Put it right over the Y axis
  1458.  
  1459.   # Generate diagram
  1460.   set grid
  1461.   set label "VB" at $BANDWIDTH+1, ($MAXVSF + $MINVSF) / 2 left
  1462.   set arrow from $BANDWIDTH, $MINVSF to $BANDWIDTH, $MAXVSF nohead
  1463.   set label "max VSF" at 1, $MAXVSF-1.5
  1464.   set arrow from 0, $MAXVSF to $BANDWIDTH, $MAXVSF nohead
  1465.   set label "min VSF" at 1, $MINVSF-1.5
  1466.   set arrow from 0, $MINVSF to $BANDWIDTH, $MINVSF nohead
  1467.   set label "min HSF" at dotclock($MINHSF, $MAXVSF+17), $MAXVSF + 17 right
  1468.   set label "max HSF" at dotclock($MAXHSF, $MAXVSF+17), $MAXVSF + 17 right
  1469.   set label "VESA $vesa" at 1, $vesa-1.5
  1470.   set arrow from 0, $vesa to $BANDWIDTH, $vesa nohead # style -1
  1471.   plot [dcf=0:1.1*$BANDWIDTH] [$MINVSF-10:$MAXVSF+20] \
  1472.     refresh($MINHSF, dcf) notitle with lines 1, \
  1473.     refresh($MAXHSF, dcf) notitle with lines 1, \
  1474.     resolution(640*480,   dcf) title "640x480  " with points 2, \
  1475.     resolution(800*600,   dcf) title "800x600  " with points 3, \
  1476.     resolution(1024*768,  dcf) title "1024x768 " with points 4, \
  1477.     resolution(1280*1024, dcf) title "1280x1024" with points 5, \
  1478.     resolution(1600*1280, dcf) title "1600x1200" with points 6
  1479.  
  1480.   pause 9999
  1481.   EOF
  1482.  
  1483.  
  1484.  
  1485.   Once you know you have modeplot and the gnuplot package in place,
  1486.   you'll need the following monitor characteristics:
  1487.  
  1488.  
  1489.   o  video bandwidth (VB)
  1490.  
  1491.   o  range of horizontal sync frequency (HSF)
  1492.  
  1493.   o  range of vertical sync frequency (VSF)
  1494.  
  1495.   The plot program needs to make some simplifying assumptions which are
  1496.   not necessarily correct.  This is the reason why the resulting diagram
  1497.   is only a rough description. These assumptions are:
  1498.  
  1499.  
  1500.   1. All resolutions have a single fixed aspect ratio AR = HR/VR.
  1501.      Standard resolutions have AR = 4/3 or AR = 5/4.  The modeplot
  1502.      programs assumes 4/3 by default, but you can override this.
  1503.  
  1504.   2. For the modes considered, horizontal and vertical frame lengths are
  1505.      fixed multiples of horizontal and vertical resolutions,
  1506.      respectively:
  1507.  
  1508.  
  1509.  
  1510.                HFL = F1 * HR
  1511.                VFL = F2 * VR
  1512.  
  1513.  
  1514.  
  1515.  
  1516.   As a rough guide, take F1 = 1.30 and F2 = 1.05 (see ``'' "Computing
  1517.   Frame Sizes").
  1518.  
  1519.   Now take a particular sync frequency, HSF.  Given the assumptions just
  1520.   presented, every value for the clock rate DCF already determines the
  1521.   refresh rate RR, i.e. for every value of HSF there is a function
  1522.   RR(DCF).  This can be derived as follows.
  1523.  
  1524.   The refresh rate is equal to the clock rate divided by the product of
  1525.   the frame sizes:
  1526.  
  1527.  
  1528.  
  1529.                RR = DCF / (HFL * VFL)          (*)
  1530.  
  1531.  
  1532.  
  1533.  
  1534.   On the other hand, the horizontal frame length is equal to the clock
  1535.   rate divided by the horizontal sync frequency:
  1536.  
  1537.  
  1538.  
  1539.                HFL = DCF / HSF                 (**)
  1540.  
  1541.  
  1542.  
  1543.  
  1544.   VFL can be reduced to HFL be means of the two assumptions above:
  1545.  
  1546.  
  1547.  
  1548.                VFL = F2 * VR
  1549.                    = F2 * (HR / AR)
  1550.                    = (F2/F1) * HFL / AR        (***)
  1551.  
  1552.  
  1553.  
  1554.  
  1555.   Inserting (**) and (***) into (*) we obtain:
  1556.  
  1557.  
  1558.  
  1559.                RR = DCF / ((F2/F1) * HFL**2 / AR)
  1560.                   = (F1/F2) * AR * DCF * (HSF/DCF)**2
  1561.                   = (F1/F2) * AR * HSF**2 / DCF
  1562.  
  1563.  
  1564.  
  1565.  
  1566.   For fixed HSF, F1, F2 and AR, this is a hyperbola in our diagram.
  1567.   Drawing two such curves for minimum and maximum horizontal sync
  1568.   frequencies we have obtained the two remaining boundaries of the
  1569.   permitted region.
  1570.  
  1571.   The straight lines crossing the capability region represent particular
  1572.   resolutions. This is based on (*) and the second assumption:
  1573.  
  1574.  
  1575.  
  1576.                RR = DCF / (HFL * VFL) = DCF / (F1 * HR * F2 * VR)
  1577.  
  1578.  
  1579.  
  1580.  
  1581.   By drawing such lines for all resolutions one is interested in, one
  1582.   can immediately read off the possible relations between resolution,
  1583.   clock rate and refresh rate of which the monitor is capable. Note that
  1584.   these lines do not depend on monitor properties, but they do depend on
  1585.   the second assumption.
  1586.  
  1587.   The modeplot tool provides you with an easy way to do this.  Do
  1588.   modeplot -? to see its control options. A typical invocation looks
  1589.   like this:
  1590.  
  1591.  
  1592.  
  1593.                modeplot -t "Swan SW617" -b 85 -v 50 90 -h 31 58
  1594.  
  1595.  
  1596.  
  1597.  
  1598.   The -b option specifies video bandwidth; -v and -h set horizontal and
  1599.   vertical sync frequency ranges.
  1600.  
  1601.   When reading the output of modeplot, always bear in mind that it gives
  1602.   only an approximate description. For example, it disregards
  1603.   limitations on HFL resulting from a minimum required sync pulse width,
  1604.   and it can only be accurate as far as the assumptions are.  It is
  1605.   therefore no substitute for a detailed calculation (involving some
  1606.   black magic) as presented in ``Putting it All Together''. However, it
  1607.   should give you a better feeling for what is possible and which
  1608.   tradeoffs are involved.
  1609.  
  1610.  
  1611.   16.  Credits
  1612.  
  1613.  
  1614.   The original ancestor of this document was by Chin Fang
  1615.   <fangchin@leland.stanford.edu>.
  1616.  
  1617.   Eric S. Raymond <esr@snark.thyrsus.com> reworked, reorganized, and
  1618.   massively rewrote Chin Fang's original in an attempt to understand it.
  1619.   In the process, he merged in most of a different how-to by Bob Crosson
  1620.   <crosson@cam.nist.gov>.
  1621.  
  1622.   The material on interlaced modes is largely by David Kastrup
  1623.   <dak@pool.informatik.rwth-aachen.de>
  1624.  
  1625.   Martin Lottermoser <Martin.Lottermoser@mch.sni.de> contributed the
  1626.   idea of using gnuplot to make mode diagrams and did the mathematical
  1627.   analysis behind modeplot.  The distributed modeplot was redesigned and
  1628.   generalized by ESR from Martin's original gnuplot code for one case.
  1629.  
  1630.  
  1631.  
  1632.  
  1633.  
  1634.  
  1635.  
  1636.  
  1637.  
  1638.  
  1639.  
  1640.  
  1641.  
  1642.  
  1643.  
  1644.  
  1645.  
  1646.  
  1647.  
  1648.  
  1649.  
  1650.  
  1651.