sysop @ mousehouse:
Programming of Modelines in XF86Config for Xwin under Linux
started on 01.09.1998 - updated 01.01.1999
Index
- Basics
- Monitor
- Video Card
- 1.2.1 RAM
- 1.2.2 Clocks
- ModeLine
- 2.1 An example. Standard-VGA.
- 2.2 Rules for hsync and vsync
- 2.3 Check whether example and rules fit together
- 2.4 Another example for self-study
- 3. A very special use of this knowledge
1 Basics
With a wrong modeline you can destroy your monitor and/or your VideoCard.
Therefor, do not program any modeline if you know not exactly what you are doing.
1.1 Monitor
How the monitor draws the screen picture
Monitor draws the picture line by line. First the first line.
Then he receives a horizontal synch pulse (hSync), with some pixels in length.
When he receives this, he runs back to the left edge of the screen.
Second line, and so forth.
At the lower edge of the screen, he receives a vertical synch pulse (vSync), with some
lines of length. Therefor, he runs up to the top and prepares to draw another first
line.
He does this quite often in one second. We should try to reach 70 times per second,
that is a framerate of 70 Hz, to protect our eyes.
Therefor, the videocard must send the entire picture, and the hsync at every end of a line,
and the vsync at the end of the screen.
Therefor, the sent lines are bigger than the viewable lines: about 25% more.
And there are more lines sent than displayed: about 5% more.
Example:
With a resolution of 800 x 600 pixels the sent picture has
1.25 * 800 x 1.05 * 600 = 1000 x 630 pixels.
To prevent the monitor from damage, the following specs must be kept:
- band width
- is the total number of sent pixels per second.
With our example and a frame rate of 70 Hz, these are 1000 * 630 * 70 = 44100000
Pixel per second,
which means a pixel frequency of 44,1 MHz (MegaHertz) and a pixel time of 22,676 nsec
(nanoSeconds).
- horizontal synch frequency:
- is the totasl number of sent lines per second.
Example: with a resolution of 600x800 pixels and a framerate of 70 Hz
there are 630 * 70 = 44100 lines sent per second,
which means a line frequency of 44,1 kHz and a line time of 22.676 usec (microSeconds).
Take care: If you do not understand the difference between MHz and kHz, and nsec and
usec, understand this first, before you read on.
1.2 VideoCard
1.2.1 RAM
The videocard holds the viewable picture in its memory (RAM).
8 bit are 1 byte, so we need at least:
- for monochrome (black&white or green&white or the like) 1 Bit per pixel.
- for 16 colors: 4 bit per pixel.
- for 256 colors: 8 bit per pixel = 1 byte per pixel.
- for 65536 colors: 2 byte per pixel.
- for 16.777.216 colors 3 byte per pixel.
Therefor, we need at least RAM:
- monochrom 320x200: 320 *200 * 1 = 64000 Bit = 8000 Byte = 7,8 kByte (1 k is 1024!)
- VGA mono 640x480: 640 * 480 * 1 = 307200 Bit = 38400 Byte = 37,5 kByte
- VGA 16colors 640x480: 640 * 480 * 4 = 1228800 Bit = 153600 Byte = 150 kByte
- SVGA 256 colors 800x600: 800 * 600 * 8 = 3840000 Bit = 480000 Byte = 468,75 kByte
- SVGA 16 colors 1024x786: 1024 * 768 * 4 = 3145728 Bit = 393216 Byte = 384 kByte
1.2.2 Clocks
Each videocard has quartz clocks that produce the pixel frequency. Most cards have more
than one quartz.
With SuperProbe we achieve these clocks (in MHz).
Standard-VGA-Card has the Clocks 25.2 MHz und 28.3 MHz.
Therefore, it can send 640x480 viewable = 800x504 total-Pixel
62,5 times oder 70,2 times per second.
2 ModeLine
2.1 An example. Standard VGA. Should run on every Card and every Monitor.
# 640x480 @ 60 Hz, 31.5 kHz hsync
Modeline "640x480" 25.175 640 664 760 800 480 491 493 525
This Modeline is part of XF86Config. It says to the Xwin server:
"This mode is named "640x480".
("HansUndFranz" or "VGAStandard" are acceptable, too).
Use the quartz clock of 25.175 MHz.
(So 1 pixel lasts 1 htick = 1 / ClockFrequency = 39,72 nsec.)
Draw 640 viewable pixels per line,
then send hsync, starting at 664 Ticks and stopping at 760 Ticks,
and stop sending a line at 800 Ticks.
(This makes 31,78 usec per line, line frequency therefor is 31.469 kHz. Look it up.
There are 480 viewable lines in total.
vsync starts at line 491 stops at line 493. Please draw in total 525 lines.
(Therefor, one frame lasts 0,0167 sec. Therefor, framerate is 59.94 Hz.) Look it up."
2.2 Rules
So, for one reason or the other, you want to create your own modelines. Let us view
some practical rules:
- Common
- total line length must be a product of 8.
- Rules for hsync
- hsync shall be 3,5 bis 4,0 usec. Start with 3,8 usec.
hsync shall have 30 Ticks distance to the left and to the right.
hsync shall have same distance to the left and to the right.
- Rules for vsync
- vsync shall be 50..300 usec. Start with 150 usec.
vsync shall have 0..3 vticks distance at the left.
2.3 Check example for rule fitting
One line is of total 800 pixel, that is 25 % more, and dividable by 8. - o.k.
hsync is 760 - 664 = 96 hTicks = 3,81 usec. - o.k.
hsync has left 24 and right 40 hTicks distance. - Fits not totally to rule, but works.
vsync is 2 vTicks = 63,56 usec. - o.k.
vsync has 491 - 480 = 11 vTicks distance. - o.k.
2.4 Calculate this by yourself
See if you can manage this example modeline, and if your monitor can manage the
specs.
# 640x480 @ 72 Hz, 36.5 kHz hsync
Modeline "640x480" 31.5 640 680 720 864 480 488 491 521
3. A very special use of all this
My computer owns videocard Diamond Stealth Video 2000, with accelerated S3-Chipsatz,
and is completely unknown to Xwin.
With Windows 3.1 it performs 1024x768x256.
The SVGA Server of Xwin cannot see the whole RAM on that card. He just sees 64 kByte, as
is standard of 640x460x16, and the VGA-Standard-Clocks.
I wanted more colors, but that did not work.
I treid out 800x600x1 (black&white) and 800x600x16, with the standard VGA settings. Must
have been a frame rate of 40. Sure was poison to my eyes.
S.u.S.E. (Germany) has built a S§-SVGA-Server who can manage this card. But my Linux
is quite old (1995), so most likely this won't work, and anyway, I do like to learn
how tomprogram my video card!
So I built this modeline on my own:
# 704x500, @ 69.5 Hz
Modeline "704x500" 28.3 704 734 764 880 500 503 505 525
and tweaked it with xvidtune to values appropiate for my monitor!
Back home
This page hosted by Get your own Free Home Page