Why VGA needs IRQ?

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
User avatar
Jef
Member
Member
Posts: 112
Joined: Tue Jan 08, 2008 7:25 am
Location: Greece
Contact:

Why VGA needs IRQ?

Post by Jef »

I am wondering why VGA needs IRQ.
Where is used from the OS?
Keep coding...
...the sky is the limit

AsteriOS project: http://www.mindfields.gr/main/index.php ... &Itemid=27
User avatar
JamesM
Member
Member
Posts: 2935
Joined: Tue Jul 10, 2007 5:27 am
Location: York, United Kingdom
Contact:

Post by JamesM »

It doesn't.
Osbios
Member
Member
Posts: 116
Joined: Fri Jun 10, 2005 11:00 pm

Post 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
jal
Member
Member
Posts: 1385
Joined: Wed Oct 31, 2007 9:09 am

Post 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
User avatar
AJ
Member
Member
Posts: 2646
Joined: Sun Oct 22, 2006 7:01 am
Location: Devon, UK
Contact:

Post 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
User avatar
Brendan
Member
Member
Posts: 8561
Joined: Sat Jan 15, 2005 12:00 am
Location: At his keyboard!
Contact:

Post 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
For all things; perfection is, and will always remain, impossible to achieve in practice. However; by striving for perfection we create things that are as perfect as practically possible. Let the pursuit of perfection be our guide.
User avatar
Jef
Member
Member
Posts: 112
Joined: Tue Jan 08, 2008 7:25 am
Location: Greece
Contact:

Post 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 ?
Keep coding...
...the sky is the limit

AsteriOS project: http://www.mindfields.gr/main/index.php ... &Itemid=27
Osbios
Member
Member
Posts: 116
Joined: Fri Jun 10, 2005 11:00 pm

Post 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.
jal
Member
Member
Posts: 1385
Joined: Wed Oct 31, 2007 9:09 am

Post 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
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Post 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.
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
jal
Member
Member
Posts: 1385
Joined: Wed Oct 31, 2007 9:09 am

Post 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
Post Reply