home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #1 / NN_1993_1.iso / spool / comp / windows / x / 20909 < prev    next >
Encoding:
Internet Message Format  |  1993-01-08  |  51.3 KB

  1. Path: sparky!uunet!spool.mu.edu!sdd.hp.com!swrinde!gatech!rutgers!cbmvax!snark!esr
  2. From: esr@snark.thyrsus.com (Eric S. Raymond)
  3. Newsgroups: comp.windows.x
  4. Subject: Request for comments --- revised X386 video timing document
  5. Message-ID: <1k3k9M#2gW9Bz67Rfhr1SZ6hh9pYmqN=esr@snark.thyrsus.com>
  6. Date: 8 Jan 93 08:14:23 GMT
  7. Lines: 1126
  8.  
  9. I found the video timing tutorial(s) included with SGCS X rather impenetrable,
  10. so I fixed it.
  11.  
  12. I translated Chin Fang's original from the rather broken Chinese-English it was
  13. written in, folded in a lot of Bob Crosson's document, reorganized the lot for
  14. clarity, added some material of my own on curing various picture pathologies.
  15. David Wexelblat gave the result a close reading and contributed valuable
  16. corrections and feedback.  
  17.  
  18. It's dwex's intention to include this in the next Xfree release, and I think
  19. Mark Snitily is going to use it for SGCS as well.  I'm posting it here for
  20. public comment and criticism.
  21.  
  22. If you really understand this video-timing stuff, *please* read this.  If, as
  23. you read, corrections or additions occur to you, please email them to me
  24. for inclusion.  I am still a novice at this branch of the arcana, and I'm
  25. sure the document could be further improved.
  26.  
  27. ===============================================================================
  28.         The Hitchhiker's Guide to X386 Video Timing
  29.             (or, Tweaking Your Monitor Modes for Fun and Profit)
  30.  
  31. (from an original by Chin Fang <fangchin@leland.stanford.edu>;
  32.     portions derive from a how-to by Bob Crosson <crosson@cam.nist.gov>,
  33.     as revised and expanded by Eric S. Raymond <esr@snark.thyrsus.com>;
  34.  
  35. This is version 0.4, Jan 6th 1993.  Please direct comments, criticism,
  36. and suggestions for improvement to esr@snark.thyrsus.com.
  37.  
  38. Contents:
  39.  
  40. 1. Introduction
  41. 2. How Video Displays Work
  42. 3. Basic Things to Know about your Display and Adapter
  43. 4. Interpreting the Basic Specifications
  44. 5. Tradeoffs in Configuring your System
  45. 6. Memory Requirements
  46. 7. Computing Frame Sizes
  47. 8. Black Magic and Sync Pulses
  48. 9. Putting it All Together
  49. 10. Questions and Answers
  50. 11. Two More Example Calculations
  51. 12. Fixing Problems with the Image.
  52.  
  53. 1. Introduction
  54.  
  55. The X386 server allows users to configure their video subsystem and thus
  56. encourages best use of existing hardware.  This tutorial is intended to help
  57. you learn how to generate your own timing numbers to make optimum use of your
  58. video card and monitor.
  59.  
  60. We'll present a method for getting something that works, and then show you how
  61. you can experiment starting from that base to develop settings that optimize
  62. for your taste.
  63.  
  64. If you already have a mode that almost works (in particular, if one of
  65. predefined VESA modes gives you a stable display but one that's displaced
  66. right or left, or too small, or too large) you can go straight to the section
  67. on Fixing Problems.  This will enlighten you on ways to tweak the timing
  68. numbers to achieve particular effects.
  69.  
  70. X386 allows you to hot-key between different modes defined in Xconfig (see
  71. X386.man for details).  Use this capabilty to save yourself hassles!  When you
  72. want to test a new mode, give it a unique mode label and add it to the *end*
  73. your hot-key list.  Leave a known-good mode as the default to fall back on if
  74. the test mode doesn't work.  The Xconfig section at the end of the second
  75. Example Calculation provides a good example of how to record your experiments
  76. in a way that will help you quickly converge on a solution.
  77.  
  78. If you have ftp access, check out David Wexelblat's mode database (part of the
  79. XFree distribution) available on export.lcs.mit.edu in contrib/X386.modeDB.Z.
  80. If your monitor is in it, you can probably skip the rest of this document!
  81.  
  82. 2. How Video Displays Work
  83.  
  84. Knowing how the display works is essential to understanding what numbers to put
  85. in the various fields in the file Xconfig.  Those values are used in the lowest
  86. levels of controlling the display by the X386 server.
  87.  
  88. The display generates a picture from a series of dots.  The dots are arranged
  89. from left to right to form lines.  The lines are arranged from top to bottom to
  90. form the picture.  The dots emit light when they are struck by the electron
  91. beam inside the display.  To make the beam strike each dot for an equal amount
  92. of time, the beam is swept across the display in a constant pattern.
  93.  
  94. The pattern starts at the top left of the screen, goes across the screen to the
  95. right in a straight line, and stops temporarily on the right side of the
  96. screen.  Then the beam is swept back to the left side of the display, but down
  97. one line.  The new line is swept from left to right just as the first line was.
  98. This pattern is repeated until the bottom line on the display has been swept.
  99. Then the beam is moved from the bottom right corner of the display to the top
  100. left corner, and the pattern is started over again.
  101.  
  102. Starting the beam at the top left of the display is called the beginning of a
  103. frame.  The frame ends when the beam reaches the the top left corner again as
  104. it comes from the bottom right corner of the display.  A frame is made up of
  105. all of the lines the beam traced from the top of the display to the bottom.
  106.  
  107. If the electron beam were on all of the time it was sweeping through the frame,
  108. all of the dots on the display would be illuminated.  There would be no black
  109. border around the edges of the display.  At the edges of the display the
  110. picture would become distorted because the beam is hard to control there.  To
  111. reduce the distortion, the dots around the edges of the display are not
  112. illuminated by the beam even though the beam may be pointing at them.  The
  113. viewable area of the display is reduced this way.
  114.  
  115. Another important thing to understand is what becomes of the beam when no spot
  116. is being painted on the visible area.  The time the beam would have been
  117. illuminating the side borders of the display is used for sweeping the beam back
  118. from the right edge to the left and moving the beam down to the next line.  The
  119. time the beam would have been illuminating the top and bottom borders of the
  120. display is used for moving the beam from the bottom-right corner of the display
  121. to the top-left corner.
  122.  
  123. The adapter card generates the signals which cause the display to turn on the
  124. electron beam at each dot to generate a picture.  The card also controls when
  125. the display moves the beam from the right side to the left and down a line by
  126. generating a signal called the horizontal sync (for synchronization) pulse.
  127. One horizontal sync pulse occurs at the end of every line.  The adapter also
  128. generates a vertical sync pulse which signals the display to move the beam to
  129. the top-left corner of the display.  A vertical sync pulse is generated near
  130. the end of every frame.
  131.  
  132. The display requires that there be short time periods both before and after the
  133. horizontal and vertical sync pulses so that the position of the electron beam
  134. can stabilize.  If the beam can't stabilize, the picture will not be steady.
  135.  
  136. In a later section, we'll come back to these basics with definitions,
  137. formulas and examples to help you use them.
  138.  
  139. 3. Basic Things to Know about your Display and Adapter
  140.  
  141. There are some fundamental things you need to know before hacking an Xconfig
  142. entry.  These are:
  143.  
  144.     (1) your monitor's horizontal and vertical sync frequency options
  145.     (2) your video adapter's driving clock frequency, or "dot clock"
  146.     (3) your monitor's bandwidth
  147.  
  148. The monitor sync frequencies:
  149.  
  150. The horizontal sync frequency are just the number of times per second the
  151. monitor can write a horizontal scan line; it is the single most important
  152. statistic about your monitor.  The vertical sync frequency is the number of
  153. times per second the monitor can traverse its beam vertically.
  154.  
  155. Sync frequencies are usually listed on the specifications page of your monitor
  156. manual.  The vertical sync frequency number is typically calibrated in Hz
  157. (cycles per second), the horizontal one in KHz (kilocycles per second).  The
  158. usual ranges are between 50 and 80Hz vertical, and between 31 and 135KHz
  159. horizontal.
  160.  
  161. If you have a multisync monitor, these frequencies will be given as ranges.
  162. Some monitors, especially lower-end ones, have multiple fixed frequencies.
  163. These can be configured too, but your options will be severely limited by the
  164. built-in monitor characteristics.  Choose the highest frequency pair for best
  165. resolution.  And be careful --- trying to clock a fixed-frequency monitor at a
  166. higher speed than it's designed for can damage it.
  167.  
  168. The card driving clock frequency:
  169.  
  170. Your video adapter manual's spec page will usually give you the card's dot
  171. clock (that is, the total number of pixels per second it can write to the
  172. screen).  If you don't have this information, the X server will get it for
  173. you.  Even if your X locks up your monitor, it will emit a line of clock and
  174. other info to standard output.  If you redirect this to a file, it should be
  175. saved even if you have to reboot to get your console back.
  176.  
  177. If you're using SGCS X, the line will look something like the following
  178. example, collected from a Swan local-bus S3 adapter.  Xfree uses a slightly
  179. different multi-line format.
  180.  
  181. WGA: 86C911 (mem: 1024k clocks: 25 28 40 3 50 77 36 45 0 0 79 31 94 65 75 71)
  182. ---  ------       -----         --------------------------------------------
  183.  |     |            |                 Possible driving frequencies in MHz
  184.  |     |            +-- Size of on-board frame-buffer RAM
  185.  |     +-- Chip type
  186.  +-- Server type
  187.  
  188. Note: do this with your machine unloaded (if at all possible).  Because X is
  189. an application, its timing loops can collide with disk activity, rendering the
  190. numbers above inaccurate.  Do it several times and watch for the numbers to
  191. stabilize; if they don't, start killing processes until they do.  SVr4 users:
  192. the mousemgr process is particularly likely to mess you up. 
  193.  
  194. In order to avoid the clock-probe inaccuracy, you should clip out the clock
  195. timings and put them in your Xconfig as the value of the Clocks property ---
  196. this suppresses the timing loop and gives X an exact list of the clock values
  197. it can try.  Using the data from the example above:
  198.  
  199. wga
  200.     Clocks    25 28 40 3 50 77 36 45 0 0 79 31 94 65 75 71
  201.  
  202. On systems with a highly variable load, this may help you avoid mysterious X
  203. startup failures.  It's possible for X to come up, get its timings wrong due
  204. to system load, and then not be able to find a matching dot clock in its
  205. config database --- or find the wrong one!
  206.  
  207. The monitor's video bandwidth:
  208.  
  209. Finally, it's useful to know your monitor's video bandwidth, so you know
  210. approximately what the highest dot clock you can use is.  There's a lot of
  211. give here, though --- some monitors can run as much as 30% over their nominal
  212. bandwidth.
  213.  
  214. Knowing the bandwidth will enable you to make more intelligent choices between
  215. possible configurations.  It may affect your display's visual quality (esp.
  216. sharpness for fine details).
  217.  
  218. Your monitor's video bandwidth should be included on the manual's spec page.
  219. If it's not, look at the monitor's higest rated resolution.  As a rule of
  220. thumb, here's how to translate these into bandwidth estimates (and thus into
  221. rough upper bounds for the dot clock you can use):
  222.  
  223.     640x480            25
  224.     800x600            36
  225.     1024x768        65
  226.     1024x768 interlaced    45
  227.     1280x1024        110
  228.  
  229. BTW, there's nothing magic about this table; these numbers are just the lowest
  230. dot clocks per resolution in the standard X386 Modes database.  The bandwidth
  231. of your monitor may be higher than the minimum needed for its top resolution,
  232. so don't be afraid to try a dot clock a few MHz higher.
  233.  
  234. Also note that bandwidth is seldom an issue for dot clocks under 65MHz or so.
  235. With an SVGA and most hi-res monitors, you can't get anywhere near the limit
  236. of your monitor's video bandwidth.  The following are examples:
  237.  
  238.     Brand                Video Bandwidth
  239.     ----------            ---------------
  240.     NEC 4D                75Mhz
  241.     Nano 907a            50Mhz
  242.     Nano 9080i            60Mhz
  243.     Mitsubishi HL6615        110Mhz
  244.     Mitsubishi Diamond Scan        100Mhz
  245.     IDEK MF-5117            65Mhz
  246.     IOCOMM Thinksync-17 CM-7126    136Mhz
  247.     HP D1188A            100Mhz
  248.     Philips SC-17AS            110Mhz
  249.     Swan SW617            85Mhz
  250.  
  251. Even low-end monitors usually aren't terribly bandwidth-constrained for their
  252. rated resolutions.  The NEC Multisync II makes a good example --- it can't
  253. even display 800x600 per its spec.  It can only display 800x560.  For such low
  254. resolutions you don't need high dot clocks or a lot of bandwidth; probably the
  255. best you can do is 32Mhz or 36Mhz, both of them are still not too far from the
  256. monitor's rated video bandwidth of 30Mhz.
  257.  
  258. At these two driving frequencies, your screen image may not be as sharp as it
  259. should be, but definitely of tolerable quality. Of course it would be nicer if
  260. NEC Multisync II had a video bandwidth higher than, say, 36Mhz.  But this is
  261. not critical for common tasks like text editing, as long as the difference is
  262. not so significant as to cause severe image distortion (your eyes would tell
  263. you right away if this were so).
  264.  
  265. What these control:
  266.  
  267. The sync frequency ranges of your monitor, together with your video adapter's
  268. dot clock, determine the ultimate resolution that you can use.  But it's up to
  269. the driver to tap the potential of your hardware.  A superior hardware
  270. combination without an equally competent device driver is a waste of money.
  271. On the other hand, with a versatile device driver but less capable hardware,
  272. you can push the hardware's envelope a little.  This is the design philosophy
  273. of X386.
  274.  
  275. 4. Interpreting the Basic Specifications
  276.  
  277. This section explains what the specifications above mean, and some other
  278. things you'll need to know.  First, some definitions.  Next to each in parens
  279. is the variable name we'll use for it when doing calculations
  280.  
  281. horizontal sync frequency (HSF)
  282.     Horizontal scans per second (see above).
  283.  
  284. vertical sync frequency (VSF)
  285.     Vertical scans per second (see above).  Mainly important as the upper
  286. limit on your refresh rate.
  287.  
  288. dot clock  (DCF)
  289.     More formally, `driving clock frequency'; sometimes loosely called
  290. `bandwidth'.  The frequency of the crystal or VCO on your adaptor --- the
  291. maximum dots-per-second it can emit.
  292.  
  293. video bandwidth (VB)
  294.     The highest frequency at which your monitor's video signal can change.
  295. This constrains the highest dot clock you can use and the overall sharpness
  296. of fine details in the video image.
  297.  
  298. frame length (HFL, VFL)
  299.     Horizontal frame length (HFL) is the number of dot-clock ticks needed for
  300. your monitor's electron gun to scan one horizontal line, *including the
  301. inactive left and right borders*.  Vertical frame length (VFL) is the number
  302. of scan lines in the *entire* image, including the inactive top and bottom
  303. borders.
  304.  
  305. screen refresh rate (RR)
  306.    The number of times per second your screen is repainted.  Higher frequencies
  307. are better, as they reduce flicker.  60Hz is good, VESA-standard 72Hz is
  308. better.  Compute it as 
  309.  
  310.     RR = DCF / (HFL * VFL)
  311.  
  312. Note that the product in the denominator is *not* the same as the monitor's
  313. visible resolution, but typically somewhat larger.  We'll get to the details
  314. of this below.
  315.  
  316. About Bandwidth:
  317.  
  318. Monitor makers like to advertise high bandwidth because it constrains the
  319. sharpness of intensity and color changes on the screen.  A high bandwidth
  320. means smaller visible details.
  321.  
  322. Your monitor uses electronic signals to present an image to
  323. your eyes.  Such signals always come in in wave form once they are converted
  324. into analog form from digitized form.  They can be considered as combinations
  325. of many simpler wave forms each one of which has a fixed frequency, many of
  326. them are in the Mhz range, eg, 20Mhz, 40Mhz, or even 70Mhz.  Your monitor
  327. video bandwidth is, effectively, the highest-frequency analog signal it can
  328. handle without distortion.
  329.  
  330. For our purposes, bandwidth is mainly important as an approximate cutoff point
  331. for the highest dot clock you can use.
  332.  
  333. Sync Frequencies snd the Refresh Rate:
  334.  
  335. Each horizontal scan line on the display is just the visible portion of a
  336. frame-length scan.  At any instant there is actually only one dot active on
  337. the screen, but with a fast enough refresh rate your eye's persistence of
  338. vision enables you to "see" the whole image.
  339.  
  340. Here are some pictures to help:
  341.  
  342.                     _______________________
  343.                    |                       |     The horizontal frame length
  344.                    |->->->->->->->->->->-> |     is the time in dot clocks
  345.                    |                      )|     required for the
  346.                    |<-----<-----<-----<--- |     electron beam to trace
  347.                    |                       |     a pattern like this
  348.                    |                       |
  349.                    |                       |
  350.                    |                       |
  351.                    |_______________________|    
  352.  
  353.                     _______________________
  354.                    |        ^              |     The vertical frame length
  355.                    |       ^ |             |     is the time in dot clocks
  356.                    |       | v             |     required for the
  357.                    |       ^ |             |     electron beam to trace
  358.                    |       | |             |     a pattern like this
  359.                    |       ^ |             |
  360.                    |       | v             |
  361.                    |       ^ |             |
  362.                    |_______|_v_____________|    
  363.                 
  364. Remember that the actual raster scan is a very tight zigzag pattern; that is,
  365. the beam moves left <-> right and at the same time up <-> down.
  366.  
  367. Now we can see how the dot clock and frame size relates to refresh rate.  By
  368. definition, one hertz (hz) is one cycle per second.  So, if your horizontal
  369. frame length is HFL and your vertical frame length is VFL, then to cover the
  370. entire screen takes (HFL * VFL) ticks.  Since your card emits DCF ticks per
  371. second by definition, then obviously your monitor's electron gun(s) can sweep
  372. the screen from left to right and back and from bottom to top and back DCF /
  373. (HFL * VFL) times/sec.  This is your screen's refresh rate, because it's how
  374. many times your screen can be updated thus REFRESHED per second!
  375.  
  376. You need to understand this concept to design a configuration which trades off
  377. resolution against flicker in whatever way suits your needs.
  378.  
  379. 5. Tradeoffs in Configuring your System
  380.  
  381. Another way to look at the formula we derived above is
  382.  
  383.     DCF = RR * HFL * VFL
  384.  
  385. That is, your dot clock is fixed.  You can use those dots per second to buy 
  386. either refresh rate, horizontal resolution, or vertical resolution.  If one
  387. of those increases, one or both of the others must decrease.
  388.  
  389. Note, though, that your refresh rate cannot be greater than the maximum
  390. vertical sync frequency of your monitor.  Thus, for any given monitor at a
  391. given dot clock, there is a minimum product of frame lengths below which you
  392. can't force it.
  393.  
  394. In choosing your settings, remember: if you set RR too low, you will get
  395. mugged by screen flicker.
  396.  
  397. You probably do not want to pull your refresh rate below 60Hz.  This is the
  398. flicker rate of fluorescent lights; if you're sensitive to those, you need
  399. to hang with 72MHz, the VESA ergonomic standard.
  400.  
  401. Flicker is very eye-fatiguing, though human eyes are adaptable and peoples'
  402. tolerance for it varies widely.  If you face your monitor at a 90% viewing
  403. angle, are using a dark background and a good contrasting color for
  404. foreground, and stick with low to medium intensity, you *may* be comfortable
  405. at as little as 45Hz.
  406.  
  407. The acid test is this: open a xterm with pure white back-ground and black
  408. foreground using xterm -bg white -fg black and make it so large as to cover the
  409. entire viewable area.  Now turn your monitor's intensity to 3/4 of its maximum
  410. setting, and turn your face away from the monitor.  Try peeking at your monitor
  411. sideways (bringing the more sensitive peripheral-vision cells into play).  If
  412. you don't sense any flicker or if you feel the flickering is tolerable, then
  413. that refresh rate is fine with you.  Otherwise you better configure a higher
  414. refresh rate, because that semi-invisible flicker is going to fatigue your eyes
  415. like crazy and give you headaches, even if the screen looks OK to normal
  416. vision.
  417.  
  418. So let's say you've picked a minimum acceptable refresh rate.  In choosing
  419. your HFL and VFL, you'll have some room for maneuver.
  420.  
  421. 6. Memory Requirements
  422.  
  423. Available frame-buffer RAM may limit the resolution you can achieve on color or
  424. gray-scale displays.  It probably isn't a factor on displays that have only two
  425. colors, white and black with no shades of gray in between.
  426.  
  427. For 256-color displays, a byte of video memory is required for each visible
  428. dot to be shown.  This byte contains the information that determines what mix
  429. of red, green, and blue is generated for its dot.  To get the amount of memory
  430. required, multiply the number of visible dots per line by the number of
  431. visible lines.  For a display with a resolution of 800x600, this would be 800
  432. x 600 = 480,000, which is the number of visible dots on the display.  This is
  433. also, at one byte per dot, the number of bytes of video memory that are
  434. necessary on your adapter card.
  435.  
  436. Thus, your memory requirement will typically be (HR * VR)/1024 Kbytes of VRAM,
  437. rounded up.  In the example case, we'd need (936 * 702)/1024 = 642K.  So if
  438. you have one meg, you'll have extra for virtual-screen panning.
  439.                  
  440. However, if you only have 512K on board, then you can't use this resolution.
  441. Even if you have a good monitor, without enough video ram, you can't take
  442. advantage of your monitor's potential.  On the other hand, if your SVGA has one
  443. meg, but your monitor can display at most 800x600, then high resolution is
  444. beyond your reach anyway.
  445.  
  446. Don't worry if you have more memory than required; X386 will make use of it by
  447. allowing you to scroll your viewable area (see the Xconfig file documentation
  448. on the virtual screen size parameter).  Remember also that a card with 512K
  449. bytes of memory really doesn't have 512,000 bytes installed, it has 512 x 1024
  450. = 524,288 bytes.
  451.  
  452. If you're running SGCS X using an S3 card, and are willing to live with 16
  453. colors (4 bits per pixel), you can set depth 4 in Xconfig and effectively double
  454. the resolution your card can handle.  S3 cards, for example, normally do
  455. 1024x768x256.  You can make them do 1280x1024x16 with depth 4.
  456.  
  457. 7. Computing Frame Sizes
  458.  
  459. Warning: this method was developed for multisync monitors.  It will probably
  460. work with fixed-frequency monitors as well, but no guarantees!
  461.  
  462. Start by dividing DCF by your highest available HSF to get the number
  463. of horizontal sweeps per second available.
  464.  
  465. For example; suppose you have a Sigma Legend SVGA with a 65MHz dot clock, and
  466. your monitor has a 55KHz horizontal scan frequency.  The quantity (DCF / HSF)
  467. is then 1181.
  468.  
  469. Now for our first bit of black magic.  You need to round this figure to the
  470. nearest multiple of 8.  This has to do with the VGA hardware controller used by
  471. SVGA and S3 cards; it uses an 8-bit register, left-shifted 3 bits, for what's
  472. really an 11-bit quantity.  Other card types such as ATI 8514/A may not have
  473. this requirement, but we don't know and the correction can't hurt.  So round
  474. the usable horizontal scans per second figure to 1176.
  475.  
  476. This figure (DCF / HSF rounded to a multiple of 8) is the minimum HFL you can
  477. use.  You can get longer HFLs (and thus, possibly, more horizontal dots on the
  478. screen) by setting the sync pulse to produce a lower HSF.  But you'll pay with
  479. a slower and more visible flicker rate.
  480.  
  481. As a rule of thumb, 80% of the horizontal frame length is available for
  482. horizontal resolution, the visible part of the horizontal scan line (this
  483. allows, roughly, for borders and sweepback time -- that is, the time required
  484. for the beam to move from the right screen edge to the left edge of the next
  485. raster line).  In this example, that's 944 ticks.
  486.  
  487. Now, to get the normal 4:3 screen aspect ratio, set your vertical resolution
  488. to 3/4ths of the horizontal resolution you just calculated.   For this
  489. example, that's 708 ticks.  To get your actual VFL, multiply that by 1.05
  490. to get 743 ticks.
  491.  
  492. About that 4:3 --- a ratio of 4:3 for width to height of the displayed area
  493. approximates the Golden Section, (1 + sqrt(5))/2.  Human beings seem to be
  494. wired to find this kind of rectangle pleasant to look at; accordingly, video
  495. tubes and the standard resolutions such as 800x600, 640x480 and 1024x768 all
  496. approximate it.  Though it's psychologically magic, it's not technically
  497. magic; nothing prevents you from using a non-Golden-Section ratio if that
  498. will get the best use out of your screen real estate.
  499.  
  500. So, HFL=1176 and VFL=743.  Dividing 65MHz by the product of the two gives
  501. us a nice, healthy 74.4Hz refresh rate.  Excellent!  Better than VESA standard!
  502. And you got 944x708 to boot, more than the 800 by 600 you were probably
  503. expecting.  Not bad at all!
  504.  
  505. You can even improve the refresh rate further, to almost 76 Hz, by using the
  506. fact that monitors can often sync horizontally at 2khz or so higher than
  507. rated, and by lowering VFL somewhat (that is, taking less than 75% of 944 in
  508. the example above).  But before you try this "overdriving" maneuver, if you
  509. do, make *sure* that your monitor electron guns can sync up to 76 Hz vertical.
  510. (the popular NEC 4D, for instance, cannot.  It goes only up to 75 Hz VSF).
  511.  
  512. So far, most of this is simple arithematic and basic facts about raster
  513. displays.  Hardly any black magic at all!
  514.  
  515. 8. Black Magic and Sync Pulses
  516.  
  517. OK, now you've computed HFL/VFL numbers for your chosen dot clock, found the
  518. refresh rate acceptable, and checked that you have enough VRAM.  Now for the
  519. real black magic -- you need to know when and where to place synchronization
  520. pulses.
  521.  
  522. The sync pulses actually control the horizontal and vertical scan frequebcies
  523. of the monitor.  The HSF and VSF you've pulled off the spec sheet are nominal,
  524. approximate maximum sync frequencies.  The sync pulse in the signal from the
  525. adapter card tells the monitor how fast to actually run.
  526.  
  527. Recall the two pictures above?  Only part of the time required for
  528. raster-scanning a frame is used for displaying viewable image (ie. your
  529. resolution).
  530.  
  531. Horizontal Sync:
  532.  
  533. By previous definition, it takes HFL ticks to trace the a horizontal scan line.
  534. Let's call the visible tick count (your horizontal screen resolution) HR.  Then
  535. Obviously, HR < HFL by definition.  For concreteness, let's assume both start
  536. at the same instant as shown below:
  537.  
  538.                   |___ __ __ __ __ __ __ __ __ __ __ __ __
  539.                   |_ _ _ _ _ _ _ _ _ _ _ _                |
  540.                   |_______________________|_______________|_____ 
  541.                   0                       ^               ^     unit: ticks
  542.                                           |   ^       ^   |
  543.                                           HR  |       |  HFL
  544.                                           |   |<----->|   |
  545.                                           |<->|  HSP  |<->|
  546.                                            HGT1         HGT2
  547.  
  548.                   
  549. Now, we would like to place a sync pulse of length HSP as shown above, ie,
  550. between the end of clock ticks for display data and the end of clock ticks for
  551. the entire frame.  Why so?  because if we can achieve this, then your screen
  552. image won't shift to the right or to the left.  It will be where it supposed to
  553. be on the screen, covering squarely the monitor's viewable area.
  554.  
  555. Furthermore, we want about 30 ticks of "guard time" on either side of the sync
  556. pulse.  This is represented by HGT1 and HGT2.  In a typical configuration HGT1
  557. != HGT, but if you're building a configuration from scratch, you want to start
  558. your experimentation with them equal (that is, with the sync pulse centered).
  559.  
  560. The symptom of a misplaced sync pulse is that the image is displaced on the
  561. screen, with one border excessively wide and the other side of the image
  562. wrapped around the screen edge, producing a white edge line and a band of
  563. "ghost image" on that side.  A way-out-of-place vertical sync pulse can
  564. actually cause the image to roll like a TV with a mis-adjusted vertical hold
  565. (in fact, it's the same phenomenon at work).
  566.  
  567. If you're lucky, your monitor's sync pulse widths will be documented on its
  568. specification page.  If not, here's where the real black magic starts...
  569.  
  570. You'll have to do a little trial and error for this part.  But most of the
  571. time, we can safely assume that a sync pulse is about 3.5 to 4.0 microsecond
  572. in length.
  573.  
  574. For concretness again, let's take HSP to be 3.8 microseconds (which btw, is not
  575. a bad value to start with when experimenting).
  576.  
  577. Now, using the 65Mhz clock timing above, we know HSP is equivalent to 247 clock
  578. ticks (= 65x10**6 * 3.8 *10**(-6)) [recall M=10**6, micro=10**(-6)]
  579.  
  580. Vertical Sync:
  581.  
  582. Going back to the picture above, how do we place the 247 clock ticks as shown
  583. in the picture?
  584.  
  585. Using our example, HR is 944 and HFL is 1176.  The difference between the two
  586. is 1176-944=232 < 247!  Obviously we have to do some adjustment here.  What can
  587. we do?
  588.  
  589. The first thing is to raise 1176 to 1184, and lower 944 to 936.  Now the
  590. difference = 1184-936= 248. Hmm, closer.
  591.  
  592. Next, instead using 3.8, we use 3.5 for calculating HSP; then, we have
  593. 65*3.5=227.  Looks better.  But 248 is not much higher than 227.  It's normally
  594. necessary to have 30 or so clock ticks between HR and the start of SP, and the
  595. same for the end of SP and HFL.  AND they have to be multiple of eight!  Are we
  596. stuck?
  597.  
  598. No!  let's do this, 936%8==0, (936+32)%8==0 too.  But 936+32=968, 968+227=1195,
  599. 1195+32=1227.  Hmm.. this looks not too bad.  But it's not a multiple of 8, so
  600. lets round it up to 1232.
  601.  
  602. But now we have potential trouble, the sync pulse is no longer placed right in
  603. the middle between h and H any more.  Happily, using our calculator we find
  604. 1232-32=1200 is also a multiple of 8 and (1232-32)-968=232 corresponding using
  605. a sync pulse of 3.57 micro second long, still reasonable.
  606.  
  607. In addition, 936/1232~0.76 or 76%, still not far from 80%, so it should be all
  608. right.
  609.  
  610. Furthermore, using the current horizontal frame length, we basically ask our
  611. monitor to sync at 52.7khz(=65Mhz/1232) which is within its capability.  No
  612. problems.
  613.                 
  614. Using rules of thumb we mentioned before, 936*75%=702, This is our new vertical
  615. resolution.  702*1.05=737, our new vertical frame length.
  616.  
  617. Screen refresh rate = 65Mhz/(737*1232)=71.6 Hz.  This is still excellent.
  618.  
  619. Figuring the vertical sync pulse layout is similar:
  620.  
  621.                   |___ __ __ __ __ __ __ __ __ __ __ __ __
  622.                   |_ _ _ _ _ _ _ _ _ _ _ _                |
  623.                   |_______________________|_______________|_____ 
  624.                   0                      VR              VFL     unit: ticks
  625.                                           ^   ^       ^
  626.                                           |   |       |
  627.                                           |<->|<----->|
  628.                                            VGT    VSP
  629.                 
  630. We start the sync pulse just past the end of the vertical display data ticks.
  631. VGT is the vertical guard time required for the sync pulse.  Most monitors are
  632. comfortable with a VGT of 0 (no guard time) and we'll use that in this
  633. example.  A few need two or three ticks of guard time, and it usually doesn't
  634. hurt to add that.
  635.  
  636. Returning to the example: since by the defintion of frame length, a vertical
  637. tick is the time for tracing a complete HORIZONTAL frame, therefore in our
  638. example, it is 1232/65Mhz=18.95us.
  639.  
  640. Experience shows that a vertical sync pulse should be in the range of 50us and
  641. 300us.  As an example let's use 150us, which translates into 8 vertical clock
  642. ticks (150us/18.95us~8).
  643.  
  644. 9. Putting it All Together
  645.  
  646. The Xconfig file Table of Video Modes contains lines of numbers, with each line
  647. being a complete specification for one mode of X-server operation.  The fields
  648. are grouped into four sections, the name section, the clock frequency section,
  649. the horizontal section, and the vertical section.
  650.  
  651. The name section contains one field, the name of the video mode specified by
  652. the rest of the line.  This name is referred to on the "Modes" line of the
  653. Graphics Driver Setup section of the Xconfig file.  The name field may be
  654. omitted if the name of a previous line is the same as the current line.
  655.  
  656. The dot clock section contains only the dot clock (what we've called DCF) field
  657. of the video mode line.  The number in this field specifies what dot clock was
  658. used to generate the numbers in the following sections.
  659.  
  660. The horizontal section consists of four fields which specify how each
  661. horizontal line on the display is to be generated.  The first field of the
  662. section contains the number of dots per line which will be illuminated to form
  663. the picture (what we've called HR).  The second field of the section indicates
  664. at which dot the horizontal sync pulse will begin.  The third field indicates
  665. at which dot the horizontal sync pulse will end.  The fourth field specifies
  666. the toal horzontal frame length (HFL).
  667.  
  668. The vertical section also contains four fields.  The first field contains the
  669. number of visible lines which will appear on the display (VR).  The second
  670. field indicates the line number at which the vertical sync pulse will begin.
  671. The third field specifies the line number at which the vertical sync pulse will
  672. end.  The fourth field contains the total vertical frame length (VFL).
  673.  
  674. Example:
  675.  
  676.      #Modename    clock  horizontal timing  vertical timing
  677.  
  678.      "752x564"     40    752 784  944 1088  564 567 569 611
  679.                44.5  752 792  976 1240  564 567 570 600
  680.  
  681. (Note: stock X11R5 doesn't support fractional dot clocks.)
  682.  
  683. For Xconfig, all of the numbers just mentioned - the number of illuminated dots
  684. on the line, the number of dots separating the illuminated dots from the
  685. beginning of the sync pulse, the number of dots representing the duration of
  686. the pulse, and the number of dots after the end of the sync pulse - are added
  687. to produce the number of dots per line.  The number of horizontal dots must be
  688. evenly divisible by eight.
  689.  
  690. Example:
  691.  
  692.      horizontal numbers: 800 864 1024 1088
  693.  
  694.      The sample line has the number of illuminated dots
  695.      (800) followed by the number of the dot when the sync
  696.      pulse starts (864), followed by the number of the dot
  697.      when the sync pulse ends (1024), followed by the number
  698.      of the last dot on the horizontal line (1088).
  699.  
  700. Note again that all of the horizontal numbers (800, 864, 1024, and 1088) are
  701. divisible by eight!  This is not required of the vertical numbers.
  702.  
  703. The number of lines from the top of the display to the bottom form the frame.
  704. The basic timing signal for a frame is the line.  A number of lines will
  705. contain the picture.  After the last illuminated line has been displayed, a
  706. delay of a number of lines will occur before the vertical sync pulse is
  707. generated.  Then the sync pulse will last for a few lines, and finally the last
  708. lines in the frame, the delay required after the pulse, will be generated.  The
  709. numbers that specify this mode of operation are entered in a manner similar to
  710. the following example.
  711.  
  712. Example:
  713.  
  714.      vertical numbers: 600 603 609 630
  715.  
  716.      This example indicates that there are 600 visible lines
  717.      on the display, that the vertical sync pulse starts
  718.      with the 603rd line and ends with the 609th, and that
  719.      there are 630 total lines being used.
  720.  
  721. Note that the vertical numbers don't have to be divisible by eight!
  722.  
  723.    Let's return to the example we've been working.  According to the above, all
  724. we need to do from now on is to write our result into Xconfig as follows:
  725.  
  726. <name>   DCF     HR  SH1 SH2   HFL   VR  SV1 SV2 VFL
  727.  
  728. where SH1 is the start tick of the horizontal sync pulse and SH2 is its end
  729. tick; similarly, SV1 is the start tick of the vertical sync pulse and SV2 is
  730. its end tick.
  731.  
  732. #name    clock   horizontal timing   vertical timing    flag
  733. 936x702  65      936 968 1200 1232   702 702 710 737
  734.  
  735. No special flag necessary; this is a non-interlaced mode.  Now we are really
  736. done.
  737.  
  738. 10. Questions and Answers
  739.  
  740.    Q. The example you gave is not a standard screen size, can I use it?
  741.    A. Why not?  There is NO reason whatsover why you have to use 640x480,
  742. 800x600, or even 1024x768.  X386 driver lets you config your hardware with a
  743. lot of freedom.  It usually takes two to three minutes to come up the right
  744. one.  The important thing to shoot for is high refresh rate with reasonable
  745. viewing area. not high resolution at the price of eye-tearing flicker!
  746.  
  747.    Q. It this the *only* resolution given the 65Mhz dot clock and 55Khz HSF?
  748.    A. Absolutely not!  You are encouraged to follow the general procedure and
  749. do some trial-and-error to come up a setting that's really to your liking.
  750. Experimenting with this can be lots of fun.  Most settings may just give you
  751. nasty video hash, but nothing you do can actually damage a multi-sync monitor
  752. (unless you somehow force your card to clock it at way above its bandwidth ---
  753. if you stick reasonably close to the highest resolution the monitor is
  754. documented to support this can't happen).
  755.    Beware fixed-frequency monitors!  This kind ofhacking around *can* damage
  756. them.
  757.  
  758.    Q. You just mentioned two standard resolutions. In Xconfig, there are many
  759. standard resolutions available, can you tell me whether there's any point in
  760. tinkering with timings?
  761.    A. Absolutely!  Take, for example, the "standard" 640x480 listed in the
  762. current Xconfig.  It employes 25Mhz driving frequency, frame lengths are 800
  763. and 525 => refresh rate ~ 59.5Hz. Not too bad.  But 28Mhz is a commonly
  764. available driving frequency from many SVGA boards.  If we use it to drive
  765. 640x480, following the procedure we discussed above, you would get frame
  766. lengths like 812 and 505.  Now the refresh rate is raised to 68Hz, a
  767. quite significant improvement over the standard one.  
  768.  
  769.    Q. But how about interlace/non-interlace?
  770.    A. At a fixed dot clock, an interlaced display is going to flicker worse
  771. than a non-interlaced one, which is why the market has moved away from them.
  772. What you buy with the increased flicker is higher resolution with a slower
  773. dot clock.  If the DCF were fast enough (say 90MHz or up) even interlacing
  774. wouldn't produce flicker -- but at present speeds, interlaced monitors are
  775. a bad idea for X.
  776.  
  777.     Q. Can you summarize what we have discussed so far?
  778.     A. In a nutshell:
  779.  
  780.     (1) for any fixed driving frequency, raising max resolution
  781.         incurs the penalty of lowering refresh rate and thus
  782.         introducing more flicker.
  783.  
  784.     (2) if high resolution is desirable and your monitor 
  785.         supports it, try to get a SVGA card that provides
  786.         a matching dot clock or DCF. The higher, the
  787.         better!
  788.  
  789. 11. Two More Example Calculations
  790.  
  791. Here's another hypothetical:
  792.  
  793. An adapter card has a 40 MHz clock rate.  A display has a range of horizontal
  794. sync rates from 30 KHz to 37 KHz.  The minimum number of dots per line is
  795. 40,000,000/37,000 = 1,081.081, or approximately 1,081 dots per line.
  796.  
  797. We'll use this number of dots per line in the following calculations.  So each
  798. line on our display must have at least 1081 dots.  We round this up to 1088 to
  799. make it divisible evenly by eight.  Now let's assume that the horizontal sync
  800. pulse should be 3.8 microseconds long.  We need to find out how many dots it
  801. takes to make a 3.8 microsecond pulse.  We do this by first finding out how
  802. many microseconds are in one dot.  Since there are 40,000,000 dots per second,
  803. 1/40,000,000 is the number of seconds per dot.
  804.  
  805.      1/40,000,000 = .000000025 = .025 microseconds per dot
  806.  
  807.  
  808. Thus the number of dots for a 3.8 microsecond sync pulse is
  809.  
  810.      3.8 microseconds = D dots x .025 microseconds/dot
  811.  
  812.             or
  813.  
  814.      D dots = (3.8 microseconds) / (.025 microseconds/dot) = 152 dots
  815.  
  816. So we have 1088 dots per line, 800 of which are the illuminated ones, with 152
  817. for the sync pulse.  (Note that 152 is evenly divisible by eight.  If it
  818. weren't we would round it up until it was evenly divisible.)  This leaves us
  819. the task of calculating the time before and after the sync pulse that is
  820. necessary for the display.
  821.  
  822. The rule of thumb for this is that we need about 30 ticks of guard time.  In
  823. this particular case, allocating 32 dots is convenient, because all the other
  824. quantities are divisible by 8.  This results in the timing being 800 dots for
  825. the viewable area, 152 dots for the pulse, and 1088 - (800 + 152) = 136 dots
  826. to divide between the two other times.  Half of 136 is 68 dots, so 68 dots are
  827. placed between the illuminated dots and the sync pulse, and 68 dots are placed
  828. after the sync pulse.  The horizontal numbers in the Xconfig line then become
  829.  
  830.     800 (800+68) (800+68+152) (800+68+152+68)
  831.  
  832.             or
  833.  
  834.         800 868 1020 1088
  835.  
  836. Now we want to calculate the vertical numbers.  To begin, we must remember
  837. that the vertical numbers are not in terms of dots or microseconds per dot,
  838. but are expressed as numbers of lines!  So we have to calculate how much time
  839. it takes to display a single line.  That's easy, because we know each line is
  840. 1088 dots and each dot is .025 microsecond.  Each line is, therefore,
  841.  
  842.      (1088 dots/line) x (.025 microseconds/dot) =
  843.                     27.2 microseconds/line
  844.  
  845. Since we chose 800 visible dots per line, let's choose the number of lines to
  846. be such that the ratio of horizontal to vertical is 4 to 3.  Thus, 800 is 4 x
  847. 200, so the number of visible lines should be 3 x 200 = 600.  Our target
  848. resolution is 800x600.
  849.  
  850. We know that a vertical sync pulse should be in the range of 50 to 300
  851. microseconds.  If we chose 150 microseconds as a typical sync pulse, we find
  852. how many lines 150 microseconds is by dividing 150 by 27.2 microseconds per
  853. line.
  854.  
  855.      (150 microseconds/pulse) / (27.2 microseconds/line) =
  856.             5.51 lines/pulse
  857.  
  858. By rounding up (never down) to 6 lines/pulse we now have the vertical sync
  859. pulse width.
  860.  
  861. To guess at the total number of lines per frame (illuminated lines plus
  862. nonilluminated lines in the border) we assume (from "Videotiming...") that the
  863. total number of lines will be 5% more than the number of viewable lines.  So
  864. the total number of lines is
  865.  
  866.      (600 lines) x (1.05) = 630 total lines per frame
  867.  
  868. So now we must place the pulse in the time between the end of the illuminated
  869. lines and the end of the frame.  Since we have 630 total lines, 600
  870. illuminated lines, and 6 lines for the pulse, we have
  871.  
  872.         630 - 600 - 6 = 24 lines left
  873.  
  874. Some displays don't mind if the pulse begins immediately after the illuminated
  875. lines, but others might want a line or two between the last illuminated line
  876. and the beginning of the sync pulse.  Taking the latter course just to be
  877. safe, we add three lines between the last illuminated line and the beginning
  878. of the pulse.  The rest of the lines are added after the pulse ends.  So the
  879. vertical timing numbers become
  880.  
  881.          600 (600+3) (600+3+6) (600+3+6+21)
  882.  
  883.             or
  884.  
  885.  
  886.                600 603 609 630
  887.  
  888. Before we do anything else, we must check that the display can handle 630
  889. lines/frame at 27.2 microseconds/line.  We do this by calculating how many
  890. frames per second our configuration will generate, and comparing it to the
  891. display manual's entry for vertical sync rate.  For 630 lines/frame at 27.2
  892. micro- seconds/line, we have 630 x 27.2 = 17,136 microseconds/frame.  17,136
  893. microseconds/frame is 0.017136 seconds/frame, or 1/0.017892 frames/second.
  894.  
  895.     1 / (0.017136 seconds/frame) = 58.4 frames/second
  896.  
  897. If the manual says the vertical sync rate is 58.4 Hz, or 58.4 Hz is in the
  898. range of the display's vertical sync rate, we are fine.  If the display cannot
  899. handle this rate, we'll have to change the number of lines per frame by
  900. adjusting all of the timings proportionally.
  901.  
  902. Now we combine the horizontal and vertical timing numbers together with the
  903. resolution and clock values to produce a test configuration for Xconfig.  Our
  904. line becomes
  905.  
  906.      "800x600"  40  800 868 1020 1088  600 603 609 630
  907.  
  908. Now we have a configuration of X386 to try.  It may not work if any of our
  909. assumptions were grossly wrong, but in most cases it should at least give us a
  910. stable display.  Now it takes a little experimentation to produce something
  911. pleasing.
  912.  
  913. An actual calculation
  914.  
  915. My adapter card has a 40 MHz crystal on it so I started with a 40
  916. MHz clock rate.  My display's maximum horizontal sync rate is 37
  917. KHz, so the minimum dots per line are 40,000,000/37,000 = 1081.
  918. My display's vertical sync rate is the range from 50 Hz to 90 Hz.
  919.  
  920. My display's manual says that the largest horizontal sync pulse
  921. is 3.92 microseconds.  With 0.025 microseconds per dot, the pulse
  922. is
  923.  
  924.     (3.92 microseconds) / (.025 microseconds/dot) =
  925.                         156.8 dots
  926.  
  927. Rounding this up to the nearest number evenly divisible by eight
  928. gives 160 dots.
  929.  
  930. The manual also says that the time between the last illuminated
  931. dot and the beginning of the sync pulse must be at least 0.67
  932. microseconds.  The number of dots in 0.67 microseconds at a 40
  933. MHz clock rate - remember 40 MHz is .025 microseconds/dot - is
  934.  
  935.     D dots = (0.67 microseconds) / (.025 microseconds/dot) =
  936.                         26.8 dots
  937.  
  938. Since 26.8 is not evenly divisible by eight, round it up to 32
  939. dots.
  940.  
  941. My display's manual says the time after the sync pulse should be
  942. 3.56 microseconds or more.  In dots, 3.56 microseconds is
  943.  
  944.     D dots = (3.56 microseconds) / (.025 microseconds/dot) =
  945.                         142.4 dots
  946.  
  947. Round 142.4 up to 144, so that it's evenly divisible by eight.
  948.  
  949. So now for a horizontal line we have 800 illuminated dots, 32
  950. dots between the illuminated dots and the sync pulse, 152 dots
  951. for the sync pulse, and 144 dots after the sync pulse.
  952.  
  953.     800 + 32 + 160 + 144 = 1136
  954.  
  955. We now have a line that is 1136 dots long.  This is greater than
  956. the 1088 we previously calculated, but remember that 1088 was the
  957. MINIMUM number of dots that could be on a line.  So 1136 dots per
  958. line is okay for starters.
  959.  
  960. The numbers to enter on the Xconfig line so far are
  961.  
  962.     "800x?"  40  800 (800+32) (800+32+160) (800+32+160+144)...
  963.  
  964.                 or
  965.  
  966.     "800x?"  40  800 832 992 1136...
  967.  
  968.  
  969. A line of 1136 dots at .025 microsecond/dot means that a line
  970. represents 1136 x .025 = 28.4 microseconds.
  971.  
  972. Since we chose 800 dots/line horizontal resolution, we choose 600
  973. lines/frame as the vertical resolution.
  974.  
  975. My display's manual says that the vertical sync pulse must be at
  976. least 64 microseconds long.  In terms of lines, 64 microseconds
  977. is
  978.  
  979.     (64 microseconds/pulse) / (28.4 microseconds/line) =
  980.                     2.25 lines/pulse
  981.  
  982. We round 2.25 up to 3 lines for the vertical sync pulse.
  983.  
  984. The manual says the time between the last displayed line and the
  985. start of the sync pulse must be at least 318 microseconds, and
  986. the delay after the end of the pulse must be at least 630
  987. microseconds.  We calculate how many lines each of these time
  988. periods represents as follows.
  989.  
  990.     (318 microseconds) / (28.4 microseconds/line) =
  991.                     11.20 lines
  992.  
  993.     (630 microseconds) / (28.4 microseconds/line) =
  994.                     22.18 lines
  995.  
  996. We round each of the times up to become 12 lines before the sync
  997. pulse and 23 lines after the pulse.  This makes our vertical
  998. timing numbers
  999.  
  1000.     600 (600+12) (600+12+3) (600+12+3+23)
  1001.  
  1002.             or
  1003.  
  1004.         600 612 615 638
  1005.  
  1006. Checking the frame rate to see if it falls within the rate of the
  1007. display, we see that 638 lines/frame at 28.4 microseconds/line is
  1008. 18,119 microseconds/frame, which is 55.19 frames/second.  My
  1009. display can handle anything from 50 Hz to 90 Hz, so the timing is
  1010. all right.
  1011.  
  1012. Putting the resolution, clock, horizontal, vertical timing
  1013. numbers together on a video mode line in Xconfig results in
  1014.  
  1015.     "800x600"  40  800 832 992 1136  600 612 615 638
  1016.  
  1017. This was the first video mode I tried.  It turned out not to be
  1018. very satisfactory because there was too much flicker.  I tried
  1019. other timings both above and below this setting as shown in the
  1020. following example.  I finally settled on the "784x614" mode as a
  1021. compromise between flicker and resolution.
  1022.  
  1023. You'll notice that almost all of the clock frequencies are 40
  1024. MHz.  Through experimentation I found that higher frequencies
  1025. were beyond my adapter card's capabilities, and that lower
  1026. frequencies didn't provide the resolution I wanted.
  1027.  
  1028. Example:
  1029.  
  1030.      Timings I have tried:
  1031.  
  1032.      # the following line works but is right of center
  1033.      "752x564"    40  752  784  944 1088  564 567 569 611
  1034.      #          44.5  752 792  976 1240  564 567 570 600
  1035.      #
  1036.      # this line fixes the problem with the previous line
  1037.      #"752x564"    40  752  816  976 1088  564 567 569 611
  1038.      #
  1039.      # trying to increase the vertical display size, it works
  1040.      #"752x614"    40  752  816  976 1088  614 617 619 661
  1041.      #
  1042.      # trying to increase the horiz. display size, it works
  1043.      #"784x564"    40  784  816  976 1088  564 567 569 611
  1044.      #
  1045.      # the following works but is to the right of center
  1046.      #"784x614"    40  784  816  976 1088  614 617 619 661
  1047.      #
  1048.      # the following corrects the uncentered problem of the previous one
  1049.      "784x614"    40  784  848 1008 1088  614 617 619 661
  1050.      #
  1051.      # trying to increase the display size
  1052.      # the following works, the display is slightly off center to the left
  1053.      #"800x614"    40  800  864 1024 1088  614 617 619 661
  1054.      #
  1055.      # the following corrects the problem of the previous entry
  1056.      "800x614"    40  800  864 1024 1104  614 617 619 661
  1057.      #
  1058.      # increase the display size, it works
  1059.      "816x614"    40  816  880 1040 1120  614 617 619 661
  1060.      #
  1061.      # increase the display size, it works
  1062.      "800x620"    40  800  864 1024 1104  620 623 625 661
  1063.      #
  1064.      # increase the display size, it works
  1065.      "816x620"    40  816  880 1040 1120  620 623 625 661
  1066.      #
  1067.      # increase the display size, it works
  1068.      "832x630"    40  832  896 1056 1136  630 633 635 661
  1069.      #
  1070.      # change the display size, it works but flickers badly
  1071.      "848x618"    40  848  912 1072 1152  618 621 623 661
  1072.  
  1073. 12. Fixing Problems with the Image.
  1074.  
  1075. OK, so you've got your X configuration numbers.  You put them in Xconfig with
  1076. a test mode label.  You fire up X, hot-key to the new mode, ... and the image
  1077. doesn't look right.  What do you do?  Here's a list of common problems and how
  1078. to fix them.
  1079.  
  1080. You *move* the image by changing the sync pulse timing.  You *scale* it by
  1081. changing the frame length (you need to move the sync pulse to keep it in
  1082. the same relative position, otherwise scaling will move the image as well).
  1083. Here are some more specific recipes:
  1084.  
  1085. The horizontal and vertical positions are independent.  That is, moving the
  1086. image horizontally doesn't affect placement vertically, or vice-versa.
  1087. However, the same is not quite true of scaling.  While changing the horizontal
  1088. size does nothing to the vertical size or vice versa, the total change in both
  1089. may be limited.  In particular, if your image is too large in both dimensions
  1090. you will probably have to go to a higher dot clock to fix it.  Since this
  1091. raises the usable resolution, it is seldom a problem!
  1092.  
  1093. The image is displaced to the left or right
  1094.  
  1095.     To fix this, move the horizontal sync pulse.  That is, increment or
  1096. decrement (by a multiple of 8) the middle two numbers of the horizontal timing
  1097. section that define the leading and trailing edge of the horizontal sync pulse.
  1098.  
  1099.      If the image is shifted left (right border too large, you want to move
  1100. the image to the right) decrement the numbers.  If the image is shifted right
  1101. (left border too large, you want it to move left) increment the sync pulse.
  1102.  
  1103. The image is displaced up or down
  1104.  
  1105.     To fix this, move the vertical sync pulse.  That is, increment or
  1106. decrement the middle two numbers of the vertical timing section that define
  1107. the leading and trailing edge of the vertical sync pulse.
  1108.  
  1109.      If the image is shifted up (lower border too large, you want to move
  1110. the image down) decrement the numbers.  If the image is shifted down
  1111. (top border too large, you want it to move up) increment the numbers.
  1112.  
  1113. The image is too wide (too narrow) horizontally
  1114.  
  1115.      To fix this, increase (decrease) the horizontal frame length.  That is,
  1116. change the fourth number in the first timing section.  To avoid moving the
  1117. image, also move the sync pulse (second and third numbers) half as far,
  1118. to keep it in the same relative position.
  1119.  
  1120. The image is too deep (too shallow) vertically
  1121.  
  1122.     To fix this, decrease (increase) the vertical frame length.  That is,
  1123. change the fourth number in the second timing section.  To avoid moving the
  1124. image, also move the sync pulse (second and third numbers) half as far,
  1125. to keep it in the same relative position.
  1126.  
  1127. Any distortion that can't be handled by combining these techniques is probably
  1128. evidence of something more basically wrong, like a calculation mistake or a
  1129. faster dot clock than the monitor can handle.
  1130.  
  1131. Finally, remember that increasing either frame length will decrease your
  1132. refresh rate, and vice-versa.
  1133. -- 
  1134.                     Eric S. Raymond <esr@snark.thyrsus.com>
  1135.