[Mesa-dev] [PATCH v2] egl/dri2: use drm macros to construct device name

Jonathan Gray jsg at jsg.id.au
Sat Mar 22 21:53:09 PDT 2014


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
suggested by Emil Velikov.

Signed-off-by: Jonathan Gray <jsg at jsg.id.au>
---
 src/egl/drivers/dri2/platform_drm.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/src/egl/drivers/dri2/platform_drm.c b/src/egl/drivers/dri2/platform_drm.c
index 2f7edb9..964ac5a 100644
--- a/src/egl/drivers/dri2/platform_drm.c
+++ b/src/egl/drivers/dri2/platform_drm.c
@@ -492,7 +492,11 @@ dri2_initialize_drm(_EGLDriver *drv, _EGLDisplay *disp)
 
    gbm = disp->PlatformDisplay;
    if (gbm == NULL) {
-      fd = open("/dev/dri/card0", O_RDWR);
+      char buf[64];
+      if (snprintf(buf, sizeof(buf), DRM_DEV_NAME, DRM_DIR_NAME, 0) != -1)
+         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)
-- 
1.8.5.3



More information about the mesa-dev mailing list