Ian Romanick wrote:Tomas Carnecky wrote:
Why are the DRM() macros used in the linux kernel drivers? I'm sure this has been discussed many times, but I can't find anything about it. Any explanations or pointers to webpages (archives) where it's explained are welcome.
Each DRM driver contains a slightly customized copy of some functions. The customzations are based on driver-specific #defines. The DRM macro is used to convert the generic name (i.e., addmap) to a device-specific name (i.e., radeon_addmap). This also makes it so that you can load multiple DRM modules into your kernel at once. If every DRM module had a function called addmap, you could only have one at a time.
Thanks... but I personally prefer the fbdev approach. The fbdev core calls the appropriate functions (stored in a structure which is filled
by the device drivers).
That still doesn't solve the problem of assigning unique names to N similar-but-slightly-different functions. As a concrete example, look at DRM(setup) in drm_drv.h. Each driver has it's own set of __HAVE_* macros. Which ones are set will determine what code gets generated for DRM(setup). Using a C++ style method dispatch table would get rid of the DRM() macros when the functions are called, but they would still be used to declare the concrete instances. What would that buy (other than the additional overhead of calling through a function pointer)?
That said, I'll be the first to admit that the DRM() macros are a pain. It's just not clear to me that there's a clean way to get rid of them without either loss of functionality or more pain.
Another question.. what interface do the drivers present to the userspace. Is it only the ioctl interface defined in drm.h or do the device specific drivers have their own ioctl additions?
There are the device-independent ioctls in drm.h, and there are device-dependent ioctls in <driver name>_drm.h. So, radeon_drm.h contains ioctl information specific to the radeon DRM module.
-------------------------------------------------------
This SF.Net email is sponsored by: Oracle 10g
Get certified on the hottest thing ever to hit the market... Oracle 10g. Take an Oracle 10g class now, and we'll give you the exam FREE.
http://ads.osdn.com/?ad_id=3149&alloc_id=8166&op=click
--
_______________________________________________
Dri-devel mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/dri-devel