VGA Hardware: Difference between revisions
[unchecked revision] | [unchecked revision] |
(added ati info regarding Chain 4/Oddeven) |
(added some nvidia info, moved some stuff, added some extra notes) |
||
Line 18: | Line 18: | ||
== Overview == |
== Overview == |
||
The VGA can be divided in several parts. Historically, the predecessor of the VGA - the EGA - had several chips to perform each part in the system. On the VGA these have been merged into one chip (with the exception of the DAC). |
The VGA can be divided in several parts. Historically, the predecessor of the VGA - the EGA - had several chips to perform each part in the system. These chips could be configured to your liking using the I/O Bus. On the VGA these have been merged into one chip (with the exception of the DAC). |
||
The following diagram shows which units are responsible for which parts: |
The following diagram shows which units are responsible for which parts: |
||
Line 24: | Line 24: | ||
[[Image:VGA overview.gif|Overview of VGA Hardware]] |
[[Image:VGA overview.gif|Overview of VGA Hardware]] |
||
This diagram is however an simplification for the ease of programming, and should not be considered correct. |
|||
The I/O bus is used to configure each part of the VGA to your likings. |
|||
== The Graphics Controller == |
== The Graphics Controller == |
||
The Graphics Controller (Abbreviated to GC) is responsible for directing memory reads and writes to and from video memory. |
The Graphics Controller (Abbreviated to GC) is responsible for directing memory reads and writes to and from video memory. |
||
Apart from a few standard modes, the implementation of various control bits vary between implementations. However, the exact details can be probed by performing writes in the mode to check, then reading it out in planar mode. |
|||
⚫ | |||
⚫ | |||
These modes seem to be consistent among all VGA compatibles and emulators i've tested: |
|||
* Mode 3 (Text mode) (right now I can only set it by keeping a state dump of VGA registers of the old mode) |
|||
* Mode X (Planar 256 color mode) |
|||
I have yet to write code that enters the following standard modes on all hardware |
|||
* Mode 13h (Linear 256 color mode) - GC part seems ok, however, I cant get the sequencer to work properly (Video output is bogus) |
|||
* Mode 11h (Planar 16 color mode) - Not tried |
|||
* Mode 04h (4 color mode) - Not tried |
|||
=== Chain 4 Bit === |
=== Chain 4 Bit === |
||
Line 49: | Line 57: | ||
| {{Yes}} |
| {{Yes}} |
||
| {{Yes}} |
| {{Yes}} |
||
| |
| {{Yes}} |
||
|- |
|- |
||
! Chain 4 has effect on output |
! Chain 4 has effect on output |
||
Line 56: | Line 64: | ||
| {{No}} |
| {{No}} |
||
| {{No}} |
| {{No}} |
||
| |
| {{No}} |
||
|- |
|- |
||
! Plane Write Enable takes effect on writes |
! Plane Write Enable takes effect on writes |
||
Line 63: | Line 71: | ||
| {{No}} |
| {{No}} |
||
| {{Yes}} |
| {{Yes}} |
||
| |
| {{Yes}} |
||
|} |
|} |
||
In bochs + VPC Chain4 writes occur to this address: |
In bochs + VPC, as well as the hardware tested, Chain4 writes occur to this address: |
||
plane = addr & 0x0003; // lower bits |
plane = addr & 0x0003; // lower bits |
||
Line 87: | Line 95: | ||
write (plane2, offset); // write to the other plane |
write (plane2, offset); // write to the other plane |
||
This matches the NVidia card this, However my ATI card behaves slightly different (its pretty close though): |
|||
offset = addr & 0xfff'''f'''; // generate the offset |
offset = addr & 0xfff'''f'''; // generate the offset |
||
⚫ | |||
⚫ | |||
== Color Logic == |
== Color Logic == |
Revision as of 09:41, 20 December 2006
I'm working on the VGA Hardware page, doing it here so my chaos doesnt bloat the wiki as of yet. In the end I hope it will enable newbs to write video drivers without using BIOS, v8086 or anything - Combuster 05:46, 19 December 2006 (CST)
Since thorough documentation is scarce I can only try to reverse engineer behaviour on various systems. I check with Bochs, Qemu, VPC, and once in a while, both video cards in this computer (ati x300 and gf6). Ill try to list differences as good as possible. If somebody has a original IBM VGA, please let me know and i'll spam you :). Other test beds are of course also welcome although i do have a nice range of cards already at my disposal. - Combuster 07:58, 19 December 2006 (CST)
Things i'm currently going after:
- running probes on the GC mechanics (which seem to horribly differ between hosts. I sure hope nvidia and ati are mutually consistent)
- creating diagrams of hardware
The VGA is a complex piece of hardware. Even though its old, many modern graphics cards are compatible with it, including NVidia and ATI cards. This can make writing an VGA driver rather attractive. The amount of compatibility varies however, and do not ever assume a compatible card without proper hardware detection. Apart from real machines, several emulators and virtual machines provide VGA emulation, including Bochs, QEMU and Microsoft Virtual PC
Overview
The VGA can be divided in several parts. Historically, the predecessor of the VGA - the EGA - had several chips to perform each part in the system. These chips could be configured to your liking using the I/O Bus. On the VGA these have been merged into one chip (with the exception of the DAC).
The following diagram shows which units are responsible for which parts:
This diagram is however an simplification for the ease of programming, and should not be considered correct.
The Graphics Controller
The Graphics Controller (Abbreviated to GC) is responsible for directing memory reads and writes to and from video memory.
Apart from a few standard modes, the implementation of various control bits vary between implementations. However, the exact details can be probed by performing writes in the mode to check, then reading it out in planar mode.
These modes seem to be consistent among all VGA compatibles and emulators i've tested:
- Mode 3 (Text mode) (right now I can only set it by keeping a state dump of VGA registers of the old mode)
- Mode X (Planar 256 color mode)
I have yet to write code that enters the following standard modes on all hardware
- Mode 13h (Linear 256 color mode) - GC part seems ok, however, I cant get the sequencer to work properly (Video output is bogus)
- Mode 11h (Planar 16 color mode) - Not tried
- Mode 04h (4 color mode) - Not tried
Chain 4 Bit
Been testing the effect of Chain 4 on memory writes and output, and the results aren't consistent with one another. Chain 4 is located in the Sequencer which would mean setting/clearing it would have effect on video output. Furthermore i have been testing wether plane enable has effect in chain 4 writes.
Bochs | Qemu | Virtual PC | ATI Card (X300) | NVidia (GeForce 6 6150) | |
---|---|---|---|---|---|
Chain 4 has effect on writes | Yes | Yes | Yes | Yes | Yes |
Chain 4 has effect on output | Yes | No | No | No | No |
Plane Write Enable takes effect on writes | No | Yes | No | Yes | Yes |
In bochs + VPC, as well as the hardware tested, Chain4 writes occur to this address:
plane = addr & 0x0003; // lower bits offset = addr & 0xfffb; // rest of the bits. multiples of 4 wont get written
In qemu writes go here:
plane = addr & 0x0003; // lower bits offset = addr >> 2; // only the first 16k of each page gets written.
Odd/Even Disable Bit
Seems to be a Don't Care bit in bochs+qemu
VPC generates some form of echo:
plane1 = addr & 0x0001; // lowest bit plane2 = plane1 + 2; // pick the other odd/even plane offset = addr & 0xfffe; // generate the offset write (plane1, offset); // write to the plane write (plane2, offset); // write to the other plane
This matches the NVidia card this, However my ATI card behaves slightly different (its pretty close though):
offset = addr & 0xffff; // generate the offset
The Sequencer
The Sequencer is responsible to convert video memory to color indexes.
Color Logic
This block revolves around the Attribute Controller, Palette RAM and DAC, which are together responsible for generating a color signal out of an index generated by the Sequencer.
The CRT Controller
The Cathode Ray Tube Controller, or CRTC, is the unit to create a video signal from the data produced by the DAC. By programming this unit you can control the resolution of your monitor, as well as some hardware overlay and panning effects.
WARNING: Improperly changing CRTC settings can be harmful to the monitor attached to it