mirror of
https://gitlab.freedesktop.org/mesa/drm.git
synced 2026-01-04 15:40:25 +01:00
libdrm: drmNodeIsDRM: Add FreeBSD variant
FreeBSD devfs have on the gly generated major minor so we cannot use them to test if the device is a drm node. Instead get the devfs node name and test if it is in a subdirectory "drm/" or "dri/". Historycally DRM device on FreeBSD are created in /dev/drm/ and link are present in /dev/dri/ for compatibility reason. Signed-off-by: Emmanuel Vadot <manu@FreeBSD.org> Reviewed-by: Eric Engestrom <eric@engestrom.ch> Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
This commit is contained in:
parent
1f8ada8023
commit
1c8d2b73a6
1 changed files with 14 additions and 0 deletions
14
xf86drm.c
14
xf86drm.c
|
|
@ -59,6 +59,10 @@
|
|||
#endif
|
||||
#include <math.h>
|
||||
|
||||
#if defined(__FreeBSD__)
|
||||
#include <sys/param.h>
|
||||
#endif
|
||||
|
||||
#define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0]))
|
||||
|
||||
/* Not all systems have MAP_FAILED defined */
|
||||
|
|
@ -2777,6 +2781,16 @@ static bool drmNodeIsDRM(int maj, int min)
|
|||
snprintf(path, sizeof(path), "/sys/dev/char/%d:%d/device/drm",
|
||||
maj, min);
|
||||
return stat(path, &sbuf) == 0;
|
||||
#elif __FreeBSD__
|
||||
char name[SPECNAMELEN];
|
||||
|
||||
if (!devname_r(makedev(maj, min), S_IFCHR, name, sizeof(name)))
|
||||
return 0;
|
||||
/* Handle drm/ and dri/ as both are present in different FreeBSD version
|
||||
* FreeBSD on amd64/i386/powerpc external kernel modules create node in
|
||||
* in /dev/drm/ and links in /dev/dri while a WIP in kernel driver creates
|
||||
* only device nodes in /dev/dri/ */
|
||||
return (!strncmp(name, "drm/", 4) || !strncmp(name, "dri/", 4));
|
||||
#else
|
||||
return maj == DRM_MAJOR;
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue