Page 1 of 1

Why VGA needs IRQ?

Posted: Sun Feb 24, 2008 9:35 am
by Jef
I am wondering why VGA needs IRQ.
Where is used from the OS?

Posted: Sun Feb 24, 2008 9:50 am
by JamesM
It doesn't.

Posted: Sun Feb 24, 2008 10:51 am
by Osbios
The VGA IRQ is used for vsync.

Some background:
On old GFX Cards you can only access the video memory between screen refresh. If you write something to he video memory and the screen just gets refreshed at that same time the Processor (your code) will wait until the GFX car finished the refresh. To not lose any time by this you wait for the end of a refresh (IRQ) and then write the new image to the video memory.

Modern cars don't have this limit. But I think its still the same in VGA modus.

Today you can enable vsync in games to avoid that two images sharing the screen. Because the redrawing of the video memory is faster then the screen refresh. The image changes during the screen refresh.

It looks somehow like this: (Image 1 and 2)

111111111111111111
111111111111111111
111111111122222222
222222222222222222
222222222222222222
222222222222222222

Posted: Sun Feb 24, 2008 11:40 am
by jal
Osbios wrote:The VGA IRQ is used for vsync.
The VGA can be programmed to trigger an IRQ when reaching the vertical sync.
On old GFX Cards you can only access the video memory between screen refresh.
That's bull. Even on CGA this was possible (although causing horrible snowy artifacts).


JAL

Posted: Mon Feb 25, 2008 3:12 am
by AJ
OT: So, out of interest, can the (now seemingly redundant?) VGA IRQ be used as an additional timer, then - if you know you have a 60Hz refresh rate and weren't using the IRQ for anything else, say?

Cheers,
Adam

Posted: Mon Feb 25, 2008 3:53 am
by Brendan
Hi,

For modern video cards, most (all?) of them use bus mastering/DMA to transfer graphics data (and commands for the graphics accelerator) into the video card. In this case the IRQ is used for "transfer complete" and/or for "command queue empty".
AJ wrote:OT: So, out of interest, can the (now seemingly redundant?) VGA IRQ be used as an additional timer, then - if you know you have a 60Hz refresh rate and weren't using the IRQ for anything else, say?
Maybe, but can you think of something a "refresh rate dependant" timer can do that can't be done better by something designed to be used as a timer (PIT, RTC, HPET, local APIC timer)?


Cheers,

Brendan

Posted: Mon Feb 25, 2008 5:08 am
by Jef
So actually in modern OSs not needed/used.
Thats why in some BIOSs there is an option to assign or not an IRQ to VGA.

btw, how you change the refresh rate in PMode ?

Posted: Mon Feb 25, 2008 12:56 pm
by Osbios
Jef wrote:So actually in modern OSs not needed/used.
!-->
Brendan wrote:For modern video cards, most (all?) of them use bus mastering/DMA to transfer graphics data (and commands for the graphics accelerator) into the video card. In this case the IRQ is used for "transfer complete" and/or for "command queue empty".
And for vsync even if you don't use it all the time.
But you don't need the IRQ in a small hobby OS.

Jef wrote:btw, how you change the refresh rate in PMode ?
Changing the refresh rate is part of the GFX driver. I don't know how VGA handles it but you can change it if you use VESA. At last if the Card supports the last VESA standard what is not the case on some (or all?) ATI Chips.
Or you write drivers directly for the GFX Chip if you can get your hands on the docs.

Posted: Wed Feb 27, 2008 2:46 pm
by jal
Osbios wrote:Changing the refresh rate is part of the GFX driver. I don't know how VGA handles it but you can change it if you use VESA.
VGA has two refresh rates, 60Hz for 480 line modes and 70Hz for 400 line modes.


JAL

Posted: Wed Feb 27, 2008 5:17 pm
by Combuster
jal wrote:
Osbios wrote:Changing the refresh rate is part of the GFX driver. I don't know how VGA handles it but you can change it if you use VESA.
VGA has two refresh rates, 60Hz for 480 line modes and 70Hz for 400 line modes.
I'd rather say, two clock sources. One's 25MHz and the others 28MHz. Divide them by the amount of pixels in a frame (including the blank sections) and you get the refresh rate. That means that you can change the clock and get 640x480 at 67MHz. You can also change the resolution and get frequencies from 40 - 80Hz for different resolutions. The key to success is however that the H and V frequencies stay within tolerance limits of the monitor. For old fixed-frequency VGA monitors, that is indeed 60 or 70 Hz.

Posted: Thu Feb 28, 2008 5:48 am
by jal
Combuster wrote:
jal wrote:VGA has two refresh rates, 60Hz for 480 line modes and 70Hz for 400 line modes.
I'd rather say, two clock sources. One's 25MHz and the others 28MHz.
Yeah, that's the long (and more correct) version :).


JAL