Specifications.
[pintos-anon] / specs / freevga / vtiming.htm
1 <HTML>
2 <HEAD>
3    <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
4    <META NAME="Author" CONTENT="Joshua Neal">
5    <META NAME="Description" CONTENT="Pure VGA/SVGA hardware programming (registers, identification, and otherlow-level stuff.)">
6    <META NAME="KeyWords" CONTENT="VGA SVGA hardware video programming">
7    <TITLE>FreeVGA - Video Timing Information</TITLE>
8 </HEAD>
9 <BODY>
10
11 <CENTER><A HREF="home.htm">Home</A> <A HREF="#intro">Intro</A> <A HREF="#basics">Basics</A>
12 <A HREF="#measure">Measurements</A> <A HREF="#horiz">Horizontal</A> <A HREF="#vert">Vertical</A>
13 <A HREF="#considerations">Considerations</A> <A HREF="home.htm#background">Back</A>&nbsp;
14 <HR><B>Hardware Level VGA and SVGA Video Programming Information Page</B></CENTER>
15
16 <CENTER>Video Timing Information&nbsp;
17 <HR></CENTER>
18 <A NAME="intro"></A><B>Introduction</B>
19 <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; This page is written to give the
20 necessary background on video timing that is useful for video programming.&nbsp;
21 This is not a comprehensive reference on the subject, rather it just gives
22 the minimum information needed to know to perform mode setting and the
23 creation of custom video modes.&nbsp; It includes a small bit of information
24 about the messy side of video adapters, the electrical output and how that
25 is interpreted by the monitor.&nbsp; Much of this information pertains
26 both to monitors and other CRT devices such as television displays, and
27 is less applicable to LCD displays as they have different timing requirements.
28
29 <P><A NAME="basics"></A><B>Basic Description</B>
30 <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; The video hardware produces
31 a continuous signal on its output connector, except when it is in reset
32 mode, where the video outputs are held in a single state.&nbsp; The continuous
33 signal is required because the pixel information is only displayed for
34 a short period of time, and relies on the persistence of the phosphor glow
35 on the monitor as well as the ability of eyesight to perform automatic
36 averaging to appear to be a steady image.&nbsp; That signal is usually
37 output on multiple pins of the monitor connector, although it could also
38 be a TV compatible output.&nbsp; LCD displays use a similar technique,
39 although the timing is more advanced and depends on the specific type of
40 panel and its driver circuitry.&nbsp; The signal includes both the pixel
41 data that the monitor displays, as well as timing and "framing" information
42 that the video display uses to drive its internal circuitry.
43 <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; The image's pixels are "scanned"
44 on to the screen from left to right, top to bottom, and is broken up into
45 "dot periods" or pixels, which is controlled by the "dot clock" for the
46 mode, which is the basis for all the other video timings.&nbsp; Each horizontal
47 "scan line" of dot periods is called a horizontal refresh as it "refreshes"
48 the information on the display in a horizontal line.&nbsp; Many of these
49 scan lines (the amount depending on the video mode), scanning from top
50 to bottom, make up a vertical refresh, also known as a "frame".&nbsp; There
51 are many vertical refreshes per second, where a higher refresh rate produces
52 an image with less flicker.
53
54 <P><A NAME="measure"></A><B>Timing Measurements</B>
55 <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; One of the important pieces
56 of terminology to understand is how timing is measured.&nbsp; These include
57 terms such as megahertz, kilohertz, and hertz.&nbsp; The first three are
58 a measure of frequency which is based on the term hertz (abbreviated hz),
59 which can be replaced by the term "Cycles per second."&nbsp; In video timing,
60 hertz is used to describe the frequencies of the timing signals, such as
61 when saying that the vertical refresh frequency is 60 hertz (or 60hz).&nbsp;
62 This means that there are 60 cycles per second, which means that there
63 are 60 vertical refreshes per second.&nbsp; Another case where hertz is
64 used is when saying the horizontal refresh rate, such as when saying 31500
65 hz, which means that there are 31,500 horizontal refresh cycles per second.&nbsp;
66 One abbreviation frequently found is the term kilohertz (abbreviated Khz)
67 which means 1,000 cycles/per second.&nbsp; For example, 31.5 kilohertz
68 means 31.5 x 1000 hertz, or 31500 hz.&nbsp; This is used to save writing
69 a few zeros and is a bit more concise.&nbsp; Similarly the term megahertz
70 (abbreviated Mhz) is used, which means 1,000,000 cycles/per second.&nbsp;
71 For example, instead of saying that a certain mode uses a 25,000,000 hz
72 dot clock, or saying that it uses a 25,000 Khz clock, it can be concisely
73 be stated by saying that it uses a 25 Mhz dot clock.
74 <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Similarly, the periods of
75 time involved in video timing are very short as they are typically small
76 fractions of a second.&nbsp; The terms millisecond, microsecond, and nanosecond
77 are useful for expressing these small periods of time.&nbsp; The term millisecond
78 (abbreviated ms) means one thousandth of a second, or 0.001 seconds.&nbsp;
79 In one second, there are 1,000 milliseconds. This is used to describe things,
80 such as the length of time a vertical refresh takes, for example a 16.6
81 millisecond vertical refresh means 16.6 thousands of a second, or 0.0166
82 seconds.&nbsp; In one second, there are 1,000,000 microseconds.&nbsp; The
83 term microsecond (abbreviated us) is used to describe something in terms
84 of millionths of a second, or 0.000001 second.&nbsp; For example the length
85 of a horizontal refresh could be 31.7 microseconds, or 31.7 millionths
86 of a second, 0.0000317 second, or 0.0317 ms.&nbsp; The term nanosecond
87 (abbreviated ns) is used to describe one billionth of a second, or 0.000000001
88 seconds.&nbsp; There are 1,000,000,000 nanoseconds in one second.&nbsp;
89 One circumstance where this is used, is to describe the period of time
90 one dot period takes.&nbsp; For example, one dot period could be stated
91 as 40 nanoseconds, 0.04 us, 0.00004 ms, or 0.00000004 seconds.&nbsp; In
92 each case, the most concise term is used, to provide a shorter, more concise
93 description.
94 <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Because the unit hertz is
95 defined using a unit of time (second), the period of one cycle can be determined
96 by division.&nbsp; The simplest example is 1 hz, where the length of the
97 cycle, by definition would be 1 second. For other values, it can be calculated
98 according to the following formula:
99 <UL>
100 <LI>
101 Period (in seconds) = 1 / frequency (in hertz)</LI>
102 </UL>
103 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; For example, a 60 hertz vertical
104 refresh would last 1 / 60 second, which is approximately 0.0166 seconds,
105 or 16.6 ms.&nbsp; Similarly, a 31.5 Khz horizontal refresh would be 1 /
106 31500 second, which is approximately 0.000031 seconds, or 31.7 us.&nbsp;
107 A 25 Mhz dot clock would produce a dot period of 1 / 25000000 second, which
108 is 0.00000004 seconds, or 40 ns.&nbsp; If the period of a cycle is known,
109 then the frequency can be calculated as:
110 <UL>
111 <LI>
112 Frequency (in hertz) = 1 / Period (in seconds).</LI>
113 </UL>
114 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; For example, a 16.6 ms period
115 would equate to 1 / 0.0166, which produces a frequency of approximately
116 60 hz.&nbsp; Similarly a 31.7 us period would produce approximately a 31.5
117 Khz frequency, and a 40 ns period would produce a 25 Mhz frequency.
118
119 <P><A NAME="horiz"></A><B>Horizontal Timing</B>
120 <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; From a monitor's standpoint,
121 the timing is fairly simple.&nbsp; It detects the horizontal sync pulses
122 on the hsync line, then based on the polarity, frequency, and/or duration
123 of those pulses sets up its horizontal scan circuitry to scan across the
124 screen at the desired rate.&nbsp; During this period it continuously displays
125 the signal input on the analog RGB pins/connectors.&nbsp; It is important
126 to to know the horizontal sync frequency ranges of the monitor, as well
127 as the acceptable width of the sync pulse for those sync ranges.&nbsp;
128 If the width of the sync pulse is incorrect, it can make the displayed
129 information too large or too small, as well as possibly preventing the
130 monitor from synchronizing to the generated signal.&nbsp; The acceptable
131 range of sync pulse width and polarity for a given frequency should be
132 given in the specifications for the monitor; however, this is frequently
133 overlooked by the manufacturer.&nbsp; It is recommended to contact the
134 manufacturer, otherwise the result has to be determined by trial and error
135 which can be damaging to the monitor's circuitry.
136 <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; In addition to those that
137 control horizontal sync frequency and width, there are other horizontal
138 timing registers which tell the display generation hardware when to output
139 the active display, when to output the overscan, and when to perform blanking.&nbsp;
140 The active display is when pixel data from the frame buffer are being output
141 and displayed.&nbsp; This could also be overlaid by data from another source,
142 such as a TV or MPEG decoder, or a hardware cursor.&nbsp; The overscan
143 is the border to the left and right of the screen.&nbsp; This was more
144 important on older video hardware such as those monitors lacking horizontal
145 and vertical picture controls, and is provided for compatibility reasons
146 although current hardware typically reduces the need for this portion completely.&nbsp;
147 The blanking period is used during the retrace portion of the horizontal
148 display cycle which is the period in which the horizontal sweeps from the
149 right of the screen back to the left.&nbsp; Outputting non-zero intensities
150 during this period would end up being stretched, in reverse across the
151 end of the current scan line to the beginning of the next scan line which,
152 while interesting and possibly useful in a small number of circumstances.
153 would add a bit of blurring to the image.&nbsp; Blanking is signaled to
154 the monitor by sending zero intensities of the red, green, and blue components
155 on the analog lines.
156 <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; In the display generator,&nbsp;
157 horizontal timings are specified by the number of dot periods they take.&nbsp;
158 The dot period is controlled by selecting the desired dot clock frequency
159 by programming certain registers.
160
161 <P><A NAME="vert"></A><B>Vertical Timing</B>
162 <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Vertical timing is nearly
163 the same as the horizontal timing, except that it controls the vertical
164 movement of the display scan, spacing the scan lines the right width apart
165 so that they seem to form a rectangular image.&nbsp; The monitor detects
166 the vertical sync pulses on the vsync line, then based on the polarity,
167 frequency, and/or duration of those pulses sets up its vertical circuitry
168 to scan down the screen at the desired rate.&nbsp; It is necessary to know
169 the vertical sync frequency ranges for a given monitor, and the range of
170 acceptable vertical sync widths and polarities for those ranges.&nbsp;
171 The rage of vertical sync frequencies supported by the monitor are nearly
172 always given my the monitor's specifications, but like the horizontal sync
173 widths, the vertical sync widths are not commonly specified.&nbsp; Contact
174 the manufacturer, as attempting to guess the correct vertical sync width
175 can possibly cause the monitor to fail.
176 <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; As well as being programmed
177 with the vertical sync frequency and pulse width, the display generation
178 hardware has other registers which control when to output the active display,
179 when to output the overscan, and when to perform blanking. In vertical
180 terms, the active display is the scan lines which contain horizontal active
181 display periods.&nbsp; The overscan is the border on top and bottom of
182 the screen and, if present, consists of one or more entire scan lines in
183 which the active display period is replaced with the overscan color.&nbsp;
184 The blanking is used during the vertical retrace, and consists of one or
185 more (usually more) scan lines in which the active display and overscan
186 periods are replaced with blanking period, making the entire line effectively
187 blanking.&nbsp; This prevents intensity from overlaying the screen during
188 the vertical retrace where the monitor sweeps the vertical back to the
189 top of the screen.&nbsp; Non-zero intensities output during this period
190 would be written in a zig-zag pattern from the bottom to the top of the
191 screen.&nbsp; In the display generator, the vertical timings are specified
192 in terms of how many horizontal sync periods they take.
193 <BR>&nbsp;
194 <BR><A NAME="considerations"></A><B>Programming Considerations</B>
195 <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; For maximum flexibility,
196 video timings should be configurable by the end users to allow for the
197 specifications of their monitor.&nbsp; However, it is probably a wise idea
198 to maintain a table of monitors and their rated specifications, to allow
199 the users to select thieir monitor and determine whether or not the configured
200 video timings are within the rated specifications of their monitor and
201 warn the user about this.&nbsp; There is a distinct need for a comprehensive
202 and accurate software-usable database of monitor specifications in a platform
203 and video hardware independent form with sufficient information for a program
204 to both select timings for a particular video mode, as well as verify that
205 a given set of timings will function properly on the end-user's hardware.&nbsp;
206 This database should contain a human readable description of the monitor
207 make and model, as well as software parsable fields giving corresponding
208 ranges of horizontal and vertical frequencies and sync polarities for those
209 ranges if applicable, as well as a method of determining the acceptable
210 widths of horizontal and vertical sync pulses for a given frequency in
211 the corresponding rages.&nbsp; Framing information could be included in
212 this table in a frequency independent fashion, although this is something
213 that can be safely adjusted by the end user without risk of damage to the
214 monitor, thus it is preferrable to provide a method or interface for the
215 end-user to adjust these parameters to their preference.
216 <BR>&nbsp;
217
218 <P>Notice: All trademarks used or referred to on this page are the property
219 of their respective owners.
220 <BR>All pages are Copyright &copy; 1997, 1998, J. D. Neal, except where
221 noted. Permission for utilization and distribution is subject to the terms
222 of the <A HREF="license.htm">FreeVGA Project Copyright License</A>.
223 <BR>&nbsp;
224 <BR>&nbsp;
225 </BODY>
226 </HTML>