View previous topic :: View next topic |
Author |
Message |
Clark Kent n00b
Joined: 21 Sep 2006 Posts: 10
|
Posted: Wed Sep 27, 2006 6:54 pm Post subject: two drivers for the same piece of hardware? |
|
|
Hi guys,
I am wondering what happens if there are two drivers installed that are both compatable with the same piece of hardware. I am fairly new to linux and I've been trying to figure out how things work. As I understand it, the device driver registers the device numbers (major and minor) it wants to use. I assume that udev creates the corresponding device file in /dev only if the hardware is physically connected to my box. My question is what happens when there are two drivers that are capable of controlling the same piece of hardware. Do they get different device numbers and different device files? If this were the case then I guess the user program that requires the device would choose what device file it wants to use? But, as I understand it, many of the device numbers are standardized - so two device drivers may try to register the same major node if they want to control the same piece of hardware - so how is it decided what driver gets it? Also, I am wondering if there is a tool in linux that will tell me all the drivers installed and what devices they are support. Assuming it is possible to have more than one driver installed for the same piece of hardware, is there a way to specify the default driver to be used? Could somebody please set me straight.
Thanks for your help and time! |
|
Back to top |
|
|
kabage Guru
Joined: 31 Jan 2005 Posts: 340
|
Posted: Thu Sep 28, 2006 7:13 am Post subject: A lot of question |
|
|
Yes there can be many drivers but usually only one can be using the hardware at a given time
exampe arts vs alsa just from my experience arts can interrupt alsa and play over but
nothing can interrupt arts if it has control of the sound card. So I would say most of the time
it is first come first serve with a few exceptions on sound.
technically there is only one device for each hardware in /dev set up by udev
though there could be multiple links to the device like /dev/cdrom pointing to /dev/hdc
Most applications use one driver , again sound you might have a choice like arts or alsa or oss
so that is application dependent on if you have a choice.
Most applications other than sound don't really,
video cards there are linux vs commercial drivers but that is setup in xorg conf on which one you want
to use, I mean you can change the driver once your gui is started you have to shutdown and restart to
engage the new or alternate driver.
I'm sorry if I am making it worse, to summarize yes many drivers, typically first come first serve as
to which driver is engaged and only ONE device set up by udev or whatever per piece of hardware.
Edit: Regarding devices
lspci (in package pciutils)
or lshw are real good about listing devices
but I can think of nothing off hand that will show you what driver you should use. there is few things that will show you what
driver they are using after the fact, by the time you learn your hardware and which driver it uses will you get picture ,
you become very intimate with your hardware.
if you set yourself up like a liveCD there are a couple of good tools I can't remember off hand but basically will
set up all your devices on the fly, but the overhead is quite a bit. But it is more difficult to make a liveCD then just
download PCLinuxOs or Knoppix which never cease to amaze me how well they can identify and load drivers on the
fly. _________________ The solutions are easy. Its finding them that is hard. |
|
Back to top |
|
|
Clark Kent n00b
Joined: 21 Sep 2006 Posts: 10
|
Posted: Thu Sep 28, 2006 3:35 pm Post subject: |
|
|
Thanks for the response!
The lshw program you recomended works well, thanks! I still have a few questions.
If both drivers, arts and alsa, are controlling the sound card, and if there is only one special device file for the sound card, does the kernel let them both register the same major node (i think it's 14 for sound)?
In general, does the kernel allow more than one driver to register the same major node?
As I understand it, each device number is associated with its own set of functions (open, read, etc). There is a mechanism to have these functions point to the specific functions in the driver that implement them. So it seems impossible that two drivers can register the same device number - since they both need to have the "standard functions" (open,read,etc) point to their implementations. So I am still confused how two drivers can control the same hardware.
what do you mean by first come first serve? to register the device number? to execute the function being called by an application?
I am interested in any tool that will show me the names of the drivers that are installed after the fact! Could you let me know what tools those are? |
|
Back to top |
|
|
kabage Guru
Joined: 31 Jan 2005 Posts: 340
|
Posted: Thu Sep 28, 2006 5:30 pm Post subject: Hmmm |
|
|
lshw -X
should show you the drivers although, a little maybe cryptic
Code: | driver: ATI IXP MC97 controller |
here it lists my modem driver, however it doesn't tell you that is an Alsa driver
that looks like this in lsmod
of course is referenced in Gentoo like so in make.conf
Code: | ALSA_CARDS="atiixp atiixp-modem" |
I will use sound since that is the one that has several driver options,
pretty much alsa via udev sets up the devices but, any program
or other driver can send sound straight to the device with out even a
sound driver, like some test , I can't remember it is on alsa wiki
you send random character to the device should make a sound, something like that.
Random being the command but random doesn't ever use a sound driver, your just sending
characters straight to the output on the card to make a sound.
I believe this is how arts can play a sound and bypass alsa, but is still using the single device node created by alsa/udev.
Now I did say 1 device node per hardware, not quite true, like alsa oss , used to make
compatible oss sound nodes at /dev/snd or /dev/sound along I believe they were just links
though and did not have major and minor regestered, I guess if they did (well there is always an
exception right)
Maybe if you think in terms of usb that would help, though there is only one node for each port, what is driving the
usb port depends on what is plugged into it.
Which leads to what I mean about first come first serve, lets say you plug a usb mouse in, and we have 3 pretend drivers for
it, whatever driver grabs that first will send back a "busy" to any other driver trying to grab the mouse.
Now if you think laptop with usbmouse and touchpad, two drivers, two nodes, both controlling the cursor on the screen, I guess
that is good example of two pieces of hardware controlling the same "software" .
I can not think of a way for two drivers sharing the same device node at the same time, though like the sound example, other
drivers can "directly access" the raw hardware node, setup from another driver. So arts doesn't make any dev nodes just
borrows alsas.
Your not writing a virus are you?
Just playing hope that helps, I'm only a gp you might need a specialist. _________________ The solutions are easy. Its finding them that is hard. |
|
Back to top |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|