home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 3: Developer Tools / Linux Cubed Series 3 - Developer Tools.iso / utils / console / svgatext.3 / svgatext / SVGATextMode-1.3 / doc / monitor-timings.howto < prev    next >
Encoding:
Text File  |  1995-06-19  |  15.2 KB  |  298 lines

  1.  
  2. Some general notes on monitor timings ("Monitor primer for the faint of heart")
  3. -------------------------------------
  4.  
  5. This story is about beams, split second control stuff, black (and white)
  6. magic, and Start-Trek-like techie mumbo jumbo. It is however NOT a science
  7. fiction story...
  8.  
  9.  
  10. All that fiddling with so-called "timings" might look a little dazzling to
  11. you at first. That is because it IS weird. But even weird things can become
  12. easy, once you understand them. Some more information might help you get
  13. started. The following explanation is FAR from complete, and probably
  14. oversimplified, but is might get some people going, and that's what it is
  15. intended for.
  16.  
  17. 1. introduction: a monitor
  18.  
  19. All picture-tube based monitors (=the heavy kind ;-) use the same principle:
  20. a beam of light (or three for colour screens) scans the entire screen region
  21. from left to right, and with every horizontal line, it moves a little bit
  22. from top to bottom. It illuminates the screen on those places where the
  23. driver (the graphic card in our case) tells it to. It does this so fast that
  24. the eye cannot actually "see" the beam passing by. They eye is fooled by the
  25. speed of the beam into believing that it sees an stable image on the screen.
  26.  
  27. Why do we need "timings"?
  28.  
  29. That beam of light has to "know" how fast it has to go from left to right,
  30. and how many times it has to do that before starting at the top again. It
  31. has to know when to move, and where to move to. So if you want it to move
  32. repeatedly from left to right, you'll have to tell it when it must return to
  33. the left again, to start another pass from left to right, just below the
  34. line it has just drawn (because in that time, it will have moved a little
  35. bit downwards, under control of the VERTICAL timing signals).
  36.  
  37. The same beam also has to know when to show a spot of light with a certain
  38. intensity, and when to shut up because it will soon travel quickly back to
  39. the left again, and you don't want to see THAT. What intensity it will have,
  40. is defined by the data in the memory on your graphic card. HOW that's done,
  41. is not your concern (at least not for THIS program).
  42.  
  43. In order to know WHEN it has to start on the left edge again, you need a
  44. SYNCHRONIZATION signal ("sync" for short). When the horizontal sync shows
  45. up, the beam has to move back to the left edge, so it can draw a new line.
  46. Ideally, the beam would return to the left in no time, so it can start
  47. drawing a new line right away. Alas, as with most things in nature, the
  48. faster you want to move something, the more energy you'll have to put in.
  49.  
  50. And you don't want to pay a MegaWatt power-bill just because your monitor is
  51. VERY fast at returning its beam to a new starting position, do you?
  52.  
  53. You will have to allow some time for the beam to hurry back to the left.
  54. Some appropriately call it "flyback" time. That is why you need "BLANKING"
  55. time. During that time, you cannot use the beam to show useful information.
  56. It must be allowed to "fly" back to the left, without you seeing it. i.e.:
  57. it must be "blanked away" during that time. The better the monitor,the
  58. faster the beam can be moved back.
  59.  
  60.  
  61. 2. The timing specification
  62.  
  63. And all those things are what you define in that 8-number string in the
  64. TextConfig file (or the XF86Config file for X-windows). Look at this example
  65. for out 100x37 text mode:
  66.  
  67.   "100x37"  50.00   800 848 880 1032    600 600 606 630   -hsync -vsync font 8x16
  68.                     -----------------------------------
  69.                  
  70. This section will deal with the underlined part in more detail than in the
  71. section explaining the entire line (somewhere before this one).
  72.  
  73. But first: the pixel clock. That is the second number in the entire
  74. description line (50.00). 50 MHz = 50 MegaHertz = 50 million clock pulses
  75. per second. A new pixel (dot) will be pulled out of the memory on your
  76. graphics card, and sent to the monitor beam every clock cycle. Your video
  77. card will essentially get a new dot and send it to the monitor 50 Million
  78. times per second.
  79.  
  80. There are 2 groups of timings, with almost exactly the same meaning: the
  81. first group of 4 is for the horizontal movement of the beam (left to right,
  82. the "horizontal timing parameters"), while the second group of 4 controls
  83. the vertical movement of the beam (top to bottom, the "vertical timing
  84. parameters").
  85.  
  86. The first group of numbers (horizontal parameters) are in units of pixel
  87. clocks: the clock in this case is 50 MHz, which means that each clock pulse
  88. lasts 20 billionths of a second (1 / 50 million).
  89.  
  90. The second group of numbers (vertical parameters) are in units of HORIZONTAL
  91. sync signals: this means that for each vertical counter increment, the
  92. HORIZONTAL counter will count an entire cycle from 1 to 1032 (in this case)
  93. clocks of 50 MHz. You'll need this knowledge to determine H- and
  94. V-frequencies.
  95.  
  96. But what do all the numbers mean ?
  97.  
  98. Let's look at the horizontal timings: 800 848 880 1032
  99.  
  100. The first number (800) tells the VGA chip (and the monitor) how many "active"
  101. pixels there are in each line. Those are the pixels you will be able to use,
  102. those will contain the graphics or text on the screen. 
  103.  
  104. The last of the four numbers says when the ENTIRE video line is finished,
  105. including syncs and blanking. In this case, the entire video line, including
  106. the time for the beam to travel back to the left, must be finished in 1032
  107. pixel clock periods. The time BETWEEN 800 and 1032 will be used by the
  108. monitor to hide the fact that he is busy sweeping the beam back.
  109.  
  110. The second number (848) tells the monitor WHEN it must START sweeping back
  111. the beam (= the start of the horizontal sync pulse). The third number (880)
  112. merely states the end of that sync pulse. Monitors need a certain time to be
  113. able to detect the presence of a sync pulse. Normally a minimum of around
  114. 1/2 micro-second (=25 clock pulses at 50 MHz) but that depends heavily on
  115. the monitor. That is why there are TWO numbers for the sync. The difference
  116. between the middle two numbers determines how long the sync pulse will be
  117. active, so the monitor can detect it. A small summary:
  118.  
  119.    800  =  number of pixel clocks for active (=visible) part of the line.
  120.    848  =  start of horizontal sync pulse
  121.    880  =  end of horizontal sync pulse
  122.    1032 =  end of entire line. This is when the NEXT line will begin.
  123.    
  124. At this point, we will be able to determine the horizontal frequency of the
  125. signal going to the monitor. Since there are 50 Million clock pulses per
  126. second, and since the entire line, including flyback, needs 1032 of those
  127. clock pulses, there will be 50,000,000 / 1032 = 48449 lines drawn per
  128. second. Bingo! We got the "horizontal refresh period" or the "horizontal
  129. frequency" of the signal going to the monitor: 48.449 kHz (kilo-Hertz = 1000
  130. Hz).
  131.  
  132. Of course, your monitor must be able to handle that. Can it sweep that beam
  133. almost 50000 times per second from side to side and back? Some can, some
  134. cannot. The more expensive your monitor is, the faster it will probably be
  135. able to do that (price is not the only criterion, of course...).
  136.  
  137. It is time to dive into your monitor manual and see what it can handle. Look
  138. up the "Technical Specifications" section, and look for something like
  139. "scanning frequency", or "vertical range" and "horizontal range" or
  140. whatever. Any numbers ending in "kHz" will probably relate to the horizontal
  141. range of the monitor. All VGA monitors can handle 30 kHz and up. Where "up"
  142. ends, depends on the monitor. Cheap SVGA monitors stop at 36 kHz, some at 39
  143. kHz, some at 48 kHz, some at 56 kHz, and some go on to 64 kHz. REALLY
  144. expensive things (I know at least ONE company who has them ;-) can even take
  145. upto 128 kHz. If you're into 29 inch 128 kHz monitors, and you have some
  146. bucks to spare, I can get you one...
  147.  
  148. If the 48 kHz is in the range of your monitor, then you'll be able to use
  149. that. Otherwise, lower the pixel clock until you come up with something it
  150. CAN handle.
  151.  
  152. BUT. There is also the vertical part of the story. It is almost identical to
  153. the horizontal part, except that this time we use the result of the
  154. horizontal calculations to determine vertical parameters. 
  155.  
  156. Since the configuration line states a total of 630 lines, including the
  157. VERTICAL flyback and sync time, we will get a VERTICAL frequency of 48449 /
  158. 630 = 76 Hertz. The VGA card (and the monitor) will draw a new screen 76
  159. times per second. The vertical "refresh" is 76 Hz. This is SO fast, that
  160. normal people will NOT see any flickering at all. Save those eyes!
  161.  
  162. If your monitor couldn't handle a horizontal frequency of 48 kHz, and you
  163. lowered the pixel clock to 40 Mhz, so it would only be 38.759 kHz, the
  164. vertical frequency would ALSO drop, because it depends on the horizontal
  165. one: 38759 / 630 = 61. Now we have 61 Hz instead of 76. Still acceptable to
  166. most of us (but not as good...).
  167.  
  168.  
  169. 3. blanking : what's that for?
  170.  
  171. "Blanking", or the unused area of the signal sent to the monitor, is used to
  172. allow the monitor beam to return to the left (horizontal blanking) or back
  173. to the top (vertical blanking).
  174.  
  175. If you would attempt to lose the blanking time completely (you could...),
  176. you would still get some sort of an image. BUT...
  177.  
  178. Any monitor NEEDS some blanking. It uses it to determine what it will show
  179. as "black" ("black-level clamping", in the techie mumbo-jumbo). The reason
  180. for that lies in the fact that the monitor cannot determine what voltage of
  181. the incoming video signal is meant to mean "black". The generally agreed
  182. remedy for this is to put some "black" data close to the sync signal, so the
  183. monitor can sense this, and use that as a reference for the rest of the
  184. video signal.
  185.  
  186. If you would decide to put real video in there, the monitor will say at the
  187. end of each line: "hey, the black level I sense here has changed to
  188. <anything that you are trying to display in that place>". And it will change
  189. it's interpretation of "black" to that new value. Anything BELOW that level
  190. will be made even blacker, and anything above that will be made whiter. If
  191. the blanking area was, say 70% white instead of black (0% white), then
  192. anything below 70% white would be shown "blacker than black", while anything
  193. above it would be shown 70% less white than intended. So full (100%) white
  194. would then show up as 30% white... And that's not what you intended. 
  195.  
  196. That is the reason for those black stripes on the screen (or even a
  197. completely black screen, worst case) if you define a blanking area that is
  198. too small.
  199.  
  200. There's still another reason for blanking. The hideous "flyback" mentionned
  201. earlier is not instantaneous, and the transition from a nice and slow linear
  202. move from left to right into a fast sweep back is not all that nice and
  203. sharp. Once the sync pulse is detected at the end of the screen, the beam
  204. starts to slow down, stops, and then moves faster and faster to the left.
  205. Once there, it slows down, and then starts moving to the right again. And
  206. after a certain while, it moves from left to right again in that very
  207. stable, linear movement, so that every pixel has the same width, and every
  208. line the same distance from the adjacent lines. The same goes for the
  209. vertical movement of the beam.
  210.  
  211. WHERE your monitor actually samples the "black" value, depends on the brand.
  212. All you know is that it's somewhere near the sync. 
  213.  
  214. If you define too little blanking, but still enough for that "black-level
  215. detection" to work all right, you will actually "see" (that is: you'll see
  216. the result of it) the beam slowing down and speeding up, because now it is
  217. not blanked away enough. The effect on the picture on screen will be that it
  218. is "compressed" on the edges.
  219.  
  220.  
  221. 4. sync: being in control
  222.  
  223. The sync pulses' first and most important use is to tell the monitor beam
  224. when to start "flying back", be it horizontally or vertically. That should
  225. be clear by now.
  226.  
  227. Another thing to note is that the sync "reference" is the FIRST edge of the
  228. sync (in most cases). The second one is just there (I am repeating myself
  229. here) to allow the monitor to "see" it. It will be the relative position of
  230. that FIRST edge that will determine the image position, and the amount of
  231. blanking before and after the sync. 
  232.  
  233. If the horizontal timing is defined as "800 848 880 1032", then the blank
  234. area BEFORE the sync (= at the right edge of the screen) will be 848-800
  235. pixels, and the blanking DURING and AFTER the flyback is 1032-848 pixels.
  236. How much blank pixels there are on the LEFT of the screen depends on how
  237. fast your monitor can sweep back. If your monitor would need 2 microseconds
  238. (= 100 clock pulses at 50 MHz) for flyback, then there are 132-848-100 black
  239. pixels on the LEFT side of the picture. The only catch is that you don't
  240. know how much time YOUR monitor needs for flyback... So some experimentation
  241. will be needed. 
  242.  
  243. Due to blanking, syncs have a more subtle influence on the picture. The
  244. relative position of the sync pulse in the blanked area of both horizontal
  245. and vertical timing parameters determines the position of the image on your
  246. monitor.
  247.  
  248. Any monitor always restarts drawing a new line (or a new picture) at exactly
  249. the same leftmost position. That should be independent of all other timings.
  250. After it has detected the sync signal, it needs a certain amount of
  251. "flyback" time, and then it starts at the same position on the left (for a
  252. horizontal sync) or at the top (vertical sync).
  253.  
  254. If you defined much "blank" space at the END of the line (=before the sync),
  255. and little blanking AFTER the sync, then the image will be positionned
  256. closer to the left, because after re-starting from that fixed position on
  257. the left, the picture data starts relatively "soon". If you leave too little
  258. room after the sync, the beam will still be busy "flying back" when the
  259. picture data is already restarting to show up. You'll see a "folding" effect
  260. on the left of the screen.
  261.  
  262. An example of this would be to define the following horizontal timings:
  263.  
  264.     "800 1000 1032 1032"
  265.     
  266. As you can see, the LENGTH of the horizontal sync is still 32 pixels, but it
  267. has moved to the extreme right in the timing definition. Try it out! Now
  268. there is lots of blank space BEFORE the sync (=at the right of the screen,
  269. before the beam is instructed to move back to the left by the "start sync"
  270. number), and no space at all AFTER the sync. Probably not enough time for
  271. the beam to travel back. You will wittness the famous folding effect! come
  272. and see!
  273.  
  274. The other extreme ("800 800 832 1032") will NOT always result in the same
  275. effect. Now you instruct the beam to start travelling back IMMEDIATELY after
  276. it has ended showing "active" video data. There will be virtually NO blank
  277. data at the rightmost edge of the screen, and MUCH of it at the left edge
  278. (=after the beam travelled back).
  279.  
  280. BUT since the beam cannot possibly know it will have to travel back so soon,
  281. until it is actually told to do so, there will be NO folding effect. It will
  282. only start to travell back at the start of the sync, and by then the blank
  283. area has JUST started...
  284.  
  285. Theoretically, yes. In practice, sometimes not. You might WANT to show data
  286. on the rightmost edge of your screen, but it could very well be that your
  287. monitor cannot reach out that far to the right. The beam might "bump into
  288. the right edge" way before the sync comes around to tell it to go back... So
  289. you WILL sometimes wittness something much like the folding effect, but then
  290. due to limitations in the monitor, not due to your akward timings specs.
  291.  
  292. Again: all this also applies to VERTICAL timings. In fact, you'll see a lot
  293. of vertical timing specs where the vertical sync comes right after the end
  294. of the active video data.
  295.  
  296. And that's all folks...
  297.  
  298.