Autore: Isaac Dunham Data: To: Jude Nelson CC: dng@lists.dyne.org Oggetto: Re: [Dng] What to do with udev? Some ideas...
On Wed, Dec 31, 2014 at 11:08:32PM -0500, Jude Nelson wrote: > On Wed, Dec 31, 2014 at 1:55 PM, Isaac Dunham <ibid.ag@???> wrote:
> > mesa uses udev to load the correct hardware driver.
> > There is a fallback available if you configure it with --enable-sysfs
> > or a similar flag. > I haven't read the mesa code yet, but it sounds like mesa uses udev to help
> it (1) insert the right kernel module, and (2) load the right firmware.
> udev gets its information from sysfs and/or its netlink socket, so I'd
> imagine mesa uses a similar technique with the --enable-sysfs option. Do
> you know if this is the case?
Not quite.
0: Before the display server starts, the hotplugger/system init scripts/root
loads the right kernel driver.
The kernel/hotplug helper/hotplug daemon loads the right firmware
(and creates a device).
1: Display server starts, probing for drivers (which are hardware-specific
libraries implementing the API X or Wayland wants in terms that the
kernel drivers can understand.)
2: Depending on the display server driver, either this driver or a user
program needing gl/egl/... loads and initializes Mesa.
3: In the course of initialization, Mesa probes for (OpenGL) drivers
(libraries which compile generic gl/egl/... commands into hardware-specific
commands).
If I'm understanding the code correctly,
* with udev:
the mesa loader passes udev an fd for a device, and udev returns the vendor
and chip pci ids
* with enable-sysfs:
the mesa loader looks up the major and minor for a device (fstat()),
then it generates a sysfs path based on the major and minor,
then it looks there for vendor and chip ids
Finally, the mesa loader compares the vendor and pci ids to a list it has,
and selects a driver (hardware-specific library) to dlopen().
udev might use the same method for looking ids up, or it might not.