Mesa (master): egl/dri2: use drm macros to construct device name
Emil Velikov
evelikov at kemper.freedesktop.org
Sat Apr 5 13:08:54 UTC 2014
Module: Mesa
Branch: master
Commit: c973e440d5b4057d93b4ce1298da77c3449c9f33
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=c973e440d5b4057d93b4ce1298da77c3449c9f33
Author: Jonathan Gray <jsg at jsg.id.au>
Date: Thu Apr 3 16:22:26 2014 +1100
egl/dri2: use drm macros to construct device name
Don't hardcode /dev/dri/card0 but instead use the drm
macros which allows the correct /dev/drm0 device to be
opened on OpenBSD.
v2: use snprintf and fallback to /dev/dri/card0
v3: check for snprintf truncation
Signed-off-by: Jonathan Gray <jsg at jsg.id.au>
Cc: "10.1" <mesa-stable at lists.freedesktop.org>
Reviewed-by: Emil Velikov <emil.l.velikov at gmail.com>
Reviewed-by: Matt Turner <mattst88 at gmail.com>
---
src/egl/drivers/dri2/platform_drm.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/src/egl/drivers/dri2/platform_drm.c b/src/egl/drivers/dri2/platform_drm.c
index 2f7edb9..9a7633a 100644
--- a/src/egl/drivers/dri2/platform_drm.c
+++ b/src/egl/drivers/dri2/platform_drm.c
@@ -492,7 +492,12 @@ dri2_initialize_drm(_EGLDriver *drv, _EGLDisplay *disp)
gbm = disp->PlatformDisplay;
if (gbm == NULL) {
- fd = open("/dev/dri/card0", O_RDWR);
+ char buf[64];
+ int n = snprintf(buf, sizeof(buf), DRM_DEV_NAME, DRM_DIR_NAME, 0);
+ if (n != -1 && n < sizeof(buf))
+ fd = open(buf, O_RDWR);
+ if (fd < 0)
+ fd = open("/dev/dri/card0", O_RDWR);
dri2_dpy->own_device = 1;
gbm = gbm_create_device(fd);
if (gbm == NULL)
More information about the mesa-commit
mailing list