Video and Audio device driver interface

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
Jeko
Member
Member
Posts: 500
Joined: Fri Mar 17, 2006 12:00 am
Location: Napoli, Italy

Video and Audio device driver interface

Post by Jeko »

I've written an interface for my drivers, but I don't know how to handle audio and video drivers...
I have some doubts, I liked to see how Linux handles them, but I can't find anything about it. How, for example, Linux talks with NVIDIA closed-source driver?

Video drivers must be implemented in kernel-mode or in user-mode? Maybe in user-mode they are faster because there isn't the necessity of system calls... But in user-mode how can they use privileged instructions like in and out?

Which functions video drivers must handle? (this is the less important question)
Rewriting virtual memory manager - Working on ELF support - Working on Device Drivers Handling

http://sourceforge.net/projects/jeko - Jeko Operating System
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:

Re: Video and Audio device driver interface

Post by Combuster »

Jeko wrote:I've written an interface for my drivers, but I don't know how to handle audio and video drivers...
I have some doubts, I liked to see how Linux handles them, but I can't find anything about it. How, for example, Linux talks with NVIDIA closed-source driver?
Accelerated Graphic Cards <- search first
Video drivers must be implemented in kernel-mode or in user-mode? Maybe in user-mode they are faster because there isn't the necessity of system calls... But in user-mode how can they use privileged instructions like in and out?
Practically all 3D hardware uses Memory Mapped I/O, which does everything on the much faster memory bus.
"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 ]
User avatar
Jeko
Member
Member
Posts: 500
Joined: Fri Mar 17, 2006 12:00 am
Location: Napoli, Italy

Re: Video and Audio device driver interface

Post by Jeko »

Combuster wrote:
Jeko wrote:I've written an interface for my drivers, but I don't know how to handle audio and video drivers...
I have some doubts, I liked to see how Linux handles them, but I can't find anything about it. How, for example, Linux talks with NVIDIA closed-source driver?
Accelerated Graphic Cards <- search first
I know this.
Combuster wrote:
Jeko wrote:Video drivers must be implemented in kernel-mode or in user-mode? Maybe in user-mode they are faster because there isn't the necessity of system calls... But in user-mode how can they use privileged instructions like in and out?
Practically all 3D hardware uses Memory Mapped I/O, which does everything on the much faster memory bus.
Ok. But this isn't an answer to my questions:
Video drivers must be implemented in kernel-mode or in user-mode? Are they faster in user-mode?
If they are in user-mode, how can they use privileged instructions?
Rewriting virtual memory manager - Working on ELF support - Working on Device Drivers Handling

http://sourceforge.net/projects/jeko - Jeko Operating System
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:

Re: Video and Audio device driver interface

Post by Combuster »

I know this.
Then WHY did you ask for what you already know?
Ok. But this isn't an answer to my questions
It is, you just have to realize your question is a bad one.
"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 ]
User avatar
Jeko
Member
Member
Posts: 500
Joined: Fri Mar 17, 2006 12:00 am
Location: Napoli, Italy

Re: Video and Audio device driver interface

Post by Jeko »

Combuster wrote:
Jeko wrote:I know this.
Then WHY did you ask for what you already know?
Because that wiki article doesn't explain how Linux handles video drivers or how he thinks video drivers must be handled.
Combuster wrote:
Jeko wrote:Ok. But this isn't an answer to my questions
It is, you just have to realize your question is a bad one.
Why my question is bad?
Rewriting virtual memory manager - Working on ELF support - Working on Device Drivers Handling

http://sourceforge.net/projects/jeko - Jeko Operating System
User avatar
JackScott
Member
Member
Posts: 1054
Joined: Thu Dec 21, 2006 3:03 am
Location: Hobart, Australia
Mastodon: https://aus.social/@jackscottau
Matrix: @JackScottAU:matrix.org
GitHub: https://github.com/JackScottAU
Contact:

Re: Video and Audio device driver interface

Post by JackScott »

Device driver design is something that I think is missing from the wiki. Notice that it's on the Wish List.
How to design the interface isn't on the AGP page for a good reason: it's not related at all to AGP. The drivers are a completely seperate issue.

Drivers in general can be implemented in either mode. Kernel allows them to access hardware directly. User mode, they will have to go through the kernel (making system calls, which then do the hardware call on the driver's behalf). Performance will be similar in both modes.

Your question is bad because it could have been resolved with an Internet search.
User avatar
Jeko
Member
Member
Posts: 500
Joined: Fri Mar 17, 2006 12:00 am
Location: Napoli, Italy

Re: Video and Audio device driver interface

Post by Jeko »

Yayyak wrote:Device driver design is something that I think is missing from the wiki. Notice that it's on the Wish List.
How to design the interface isn't on the AGP page for a good reason: it's not related at all to AGP. The drivers are a completely seperate issue.

Drivers in general can be implemented in either mode. Kernel allows them to access hardware directly. User mode, they will have to go through the kernel (making system calls, which then do the hardware call on the driver's behalf). Performance will be similar in both modes.

Your question is bad because it could have been resolved with an Internet search.
I've searched, but I can't find anything interesting. If you found something useful, could you give me the links?
Rewriting virtual memory manager - Working on ELF support - Working on Device Drivers Handling

http://sourceforge.net/projects/jeko - Jeko Operating System
User avatar
JackScott
Member
Member
Posts: 1054
Joined: Thu Dec 21, 2006 3:03 am
Location: Hobart, Australia
Mastodon: https://aus.social/@jackscottau
Matrix: @JackScottAU:matrix.org
GitHub: https://github.com/JackScottAU
Contact:

Re: Video and Audio device driver interface

Post by JackScott »

http://en.wikipedia.org/wiki/Device_driver#Design. The two sections after that are also worth reading.
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:

Re: Video and Audio device driver interface

Post by Combuster »

Jeko wrote:
Combuster wrote:
Jeko wrote:I know this.
Then WHY did you ask for what you already know?
Because that wiki article doesn't explain how Linux handles video drivers or how he thinks video drivers must be handled.
That is
a) not what you asked
b) Video drivers are not anything different than other drivers
c) You apparently did not investigate at all how video is handled under linux.

Why my question is bad?
d) http://www.catb.org/~esr/faqs/smart-questions.html
e) See point C
f) Your line of questioning:
Video drivers must be implemented in kernel-mode or in user-mode?
Must all people sit on a chair, or on a bench?
Are they faster in user-mode?
Is the bench always more comfortable
If they are in user-mode, how can they use privileged instructions?
I don't have a screwdriver, but I want one to paint this bench...

I've searched, but I can't find anything interesting. If you found something useful, could you give me the links?
I posted a link, but since you already know that but couldn't take a lesson from it, how do we know you haven't seen every other link you ask us to post? :roll:
"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 ]
User avatar
Jeko
Member
Member
Posts: 500
Joined: Fri Mar 17, 2006 12:00 am
Location: Napoli, Italy

Re: Video and Audio device driver interface

Post by Jeko »

Ok. Thank you.
I must read DRI, Mesa and XFree86 source code to understand how Linux handles video drivers.
However they are in user-mode, in fact OpenGL works in user-mode and Linux video drivers are for OpenGL.
http://en.wikipedia.org/wiki/Comparison ... _switching

Maybe I will implement XFree86 in my OS, also if I think it's really slow. Isn't it?
Rewriting virtual memory manager - Working on ELF support - Working on Device Drivers Handling

http://sourceforge.net/projects/jeko - Jeko Operating System
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:

Re: Video and Audio device driver interface

Post by Combuster »

Somebody restrain me :evil:
"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 ]
User avatar
JackScott
Member
Member
Posts: 1054
Joined: Thu Dec 21, 2006 3:03 am
Location: Hobart, Australia
Mastodon: https://aus.social/@jackscottau
Matrix: @JackScottAU:matrix.org
GitHub: https://github.com/JackScottAU
Contact:

Re: Video and Audio device driver interface

Post by JackScott »

Let slip the dogs of war?
User avatar
AJ
Member
Member
Posts: 2646
Joined: Sun Oct 22, 2006 7:01 am
Location: Devon, UK
Contact:

Re: Video and Audio device driver interface

Post by AJ »

Jeko,

Before you post anything else on this topic, I strongly suggest that you do some research first. Let me try to make a few things clear (that should already be obvious if you have followed the links handed to you earlier in this thread):

1) Until very recently, most accellerated graphics card specifications were closed source. This has recently changed with ATI/AMD starting to open up some of their specs. The accellerated graphics wiki article which has appropriate links has already been pointed out.
2) The fundamental point here is that this is your OS. There are systems out there where most graphics code runs in ring 3 and there are systems where it runs in ring 0. Which your OS does is entirely up to you.
3) Code runs equally quickly in ring 3 (user) and ring 0 (kernel). For ring 3 drivers, you may have the additional overhead of privilege switches for certain functions, depending on how you allocate memory mapped IO to the graphics driver process.
4) See the IO Bitmap related to your TSS for more information on port based IO.
5) The way linux talks to its drivers is highly publicised. You may like to search for the Linux Documentation Project for more information.

I hope this clears a few things up, but please now do some research and experimentation with the answers you have been given first.

Cheers,
Adam
Post Reply