Page 1 of 1

Video and Audio device driver interface

Posted: Mon Jun 30, 2008 3:34 am
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)

Re: Video and Audio device driver interface

Posted: Mon Jun 30, 2008 3:59 am
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.

Re: Video and Audio device driver interface

Posted: Mon Jun 30, 2008 4:38 am
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?

Re: Video and Audio device driver interface

Posted: Mon Jun 30, 2008 4:49 am
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.

Re: Video and Audio device driver interface

Posted: Mon Jun 30, 2008 5:01 am
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?

Re: Video and Audio device driver interface

Posted: Mon Jun 30, 2008 5:07 am
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.

Re: Video and Audio device driver interface

Posted: Mon Jun 30, 2008 5:20 am
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?

Re: Video and Audio device driver interface

Posted: Mon Jun 30, 2008 5:24 am
by JackScott
http://en.wikipedia.org/wiki/Device_driver#Design. The two sections after that are also worth reading.

Re: Video and Audio device driver interface

Posted: Mon Jun 30, 2008 5:26 am
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:

Re: Video and Audio device driver interface

Posted: Mon Jun 30, 2008 5:40 am
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?

Re: Video and Audio device driver interface

Posted: Mon Jun 30, 2008 5:59 am
by Combuster
Somebody restrain me :evil:

Re: Video and Audio device driver interface

Posted: Mon Jun 30, 2008 6:08 am
by JackScott
Let slip the dogs of war?

Re: Video and Audio device driver interface

Posted: Mon Jun 30, 2008 6:42 am
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