<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<TITLE>Video Mode Timings</TITLE>
</HEAD>
<BODY BGCOLOR="#efefef" TEXT="black" LINK="blue" VLINK="#551A8B" ALINK="red">

<A HREF="fbdev.html"><EM>The Linux/m68k Frame Buffer Device</EM></A>
 <b>:</b> <EM>Video Mode Timings</EM><BR>
<b>Previous:</b> <A HREF="fbdev5.html"><EM>The X Server</EM></A><BR>
<b>Next:</b> <A HREF="fbdev7.html"><EM>Converting XFree86 timing values into frame buffer device timings</EM></A>


<HR NOSHADE>
  <H2><A NAME="6"></A>6. Video Mode Timings</H2>
<p>A monitor draws an image on the screen by using an electron beam (3 electron
beams for color models, 1 electron beam for monochrome monitors). The front of
the screen is covered by a pattern of colored phosphors (pixels). If a phosphor
is hit by an electron, it emits a photon and thus becomes visible.</p>
<p>The electron beam draws horizontal lines (scanlines) from left to right, and
from the top to the bottom of the screen. By modifying the intensity of the
electron beam, pixels with various colors and intensities can be shown.</p>
<p>After each scanline the electron beam has to move back to the left side of the
screen and to the next line: this is called the horizontal retrace. After the
whole screen (frame) was painted, the beam moves back to the upper left corner:
this is called the vertical retrace. During both the horizontal and vertical
retrace, the electron beam is turned off (blanked).</p>
<p>The speed at which the electron beam paints the pixels is determined by the
dotclock in the graphics board. For a dotclock of e.g. 28.37516 MHz (millions
of cycles per second), each pixel is 35242 ps (picoseconds) long:</p>
<p>
<blockquote><code>
<pre>
    
</pre>
</code></blockquote>

1/(28.37516E6 Hz) = 35.242E-9 s</p>
<p>If the screen resolution is 640x480, it will take</p>
<p>
<blockquote><code>
<pre>
    640*35.242E-9 s = 22.555E-6 s
    
</pre>
</code></blockquote>
</p>
<p>to paint the 640 (xres) pixels on one scanline. But the horizontal retrace
also takes time (e.g. 272 `pixels'), so a full scanline takes</p>
<p>
<blockquote><code>
<pre>
    (640+272)*35.242E-9 s = 32.141E-6 s
    
</pre>
</code></blockquote>
</p>
<p>We'll say that the horizontal scanrate is about 31 kHz:</p>
<p>
<blockquote><code>
<pre>
    1/(32.141E-6 s) = 31.113E3 Hz
    
</pre>
</code></blockquote>
</p>
<p>A full screen counts 480 (yres) lines, but we have to consider the vertical
retrace too (e.g. 49 `pixels'). So a full screen will take</p>
<p>
<blockquote><code>
<pre>
    (480+49)*32.141E-6 s = 17.002E-3 s
    
</pre>
</code></blockquote>
</p>
<p>The vertical scanrate is about 59 Hz:</p>
<p>
<blockquote><code>
<pre>
    1/(17.002E-3 s) = 58.815 Hz
    
</pre>
</code></blockquote>
</p>
<p>This means the screen data is refreshed about 59 times per second. To have a
stable picture without visible flicker, VESA recommends a vertical scanrate of
at least 72 Hz. But the perceived flicker is very human dependent: some people
can use 50 Hz without any trouble, while I'll notice if it's less than 80 Hz.</p>
<p>Since the monitor doesn't know when a new scanline starts, the graphics board
will supply a synchronization pulse (horizontal sync or hsync) for each
scanline.  Similarly it supplies a synchronization pulse (vertical sync or
vsync) for each new frame. The position of the image on the screen is
influenced by the moments at which the synchronization pulses occur.</p>
<p>The following picture summarizes all timings. The horizontal retrace time is
the sum of the left margin, the right margin and the hsync length, while the
vertical retrace time is the sum of the upper margin, the lower margin and the
vsync length.</p>
<p>
<blockquote><code>
<pre>
  +----------+---------------------------------------------+----------+-------+
  |          |                x                            |          |       |
  |          |                |upper_margin                |          |       |
  |          |                x                            |          |       |
  +----------###############################################----------+-------+
  |          #                x                            #          |       |
  |          #                |                            #          |       |
  |          #                |                            #          |       |
  |          #                |                            #          |       |
  |   left   #                |                            #  right   | hsync |
  |  margin  #                |       xres                 #  margin  |  len  |
  |&lt;--------&gt;#&lt;---------------+---------------------------&gt;#&lt;--------&gt;|&lt;-----&gt;|
  |          #                |                            #          |       |
  |          #                |                            #          |       |
  |          #                |                            #          |       |
  |          #                |yres                        #          |       |
  |          #                |                            #          |       |
  |          #                |                            #          |       |
  |          #                |                            #          |       |
  |          #                |                            #          |       |
  |          #                |                            #          |       |
  |          #                |                            #          |       |
  |          #                |                            #          |       |
  |          #                |                            #          |       |
  |          #                x                            #          |       |
  +----------###############################################----------+-------+
  |          |                x                            |          |       |
  |          |                |lower_margin                |          |       |
  |          |                x                            |          |       |
  +----------+---------------------------------------------+----------+-------+
  |          |                x                            |          |       |
  |          |                |vsync_len                   |          |       |
  |          |                x                            |          |       |
  +----------+---------------------------------------------+----------+-------+
</pre>
</code></blockquote>
</p>
<p>The frame buffer device expects all horizontal timings in number of dotclocks
(in picoseconds, 1E-12 s), and vertical timings in number of scanlines.</p>


 <HR NOSHADE>
<A HREF="fbdev.html"><EM>The Linux/m68k Frame Buffer Device</EM></A>
 <b>:</b> <EM>Video Mode Timings</EM><BR>
<b>Previous:</b> <A HREF="fbdev5.html"><EM>The X Server</EM></A><BR>
<b>Next:</b> <A HREF="fbdev7.html"><EM>Converting XFree86 timing values into frame buffer device timings</EM></A>



</BODY>
</HTML>
