[Mesa-dev] [PATCH 05/10] st/egl: use loader util lib

Emil Velikov emil.l.velikov at gmail.com
Sat Jan 11 08:54:46 PST 2014


Signed-off-by: Emil Velikov <emil.l.velikov at gmail.com>
---
 src/gallium/state_trackers/egl/Makefile.am      |  1 +
 src/gallium/state_trackers/egl/SConscript       |  3 ++
 src/gallium/state_trackers/egl/drm/native_drm.c | 44 ++-----------------------
 3 files changed, 6 insertions(+), 42 deletions(-)

diff --git a/src/gallium/state_trackers/egl/Makefile.am b/src/gallium/state_trackers/egl/Makefile.am
index 459fabc..bad14fe 100644
--- a/src/gallium/state_trackers/egl/Makefile.am
+++ b/src/gallium/state_trackers/egl/Makefile.am
@@ -63,6 +63,7 @@ endif
 
 if HAVE_EGL_PLATFORM_DRM
 libegl_la_SOURCES += $(drm_FILES)
+libegl_la_LIBADD = $(top_builddir)/src/loader/libloader.la
 AM_CFLAGS += \
 	$(LIBDRM_CFLAGS)
 AM_CPPFLAGS += \
diff --git a/src/gallium/state_trackers/egl/SConscript b/src/gallium/state_trackers/egl/SConscript
index 2a5db64..066a7fd 100644
--- a/src/gallium/state_trackers/egl/SConscript
+++ b/src/gallium/state_trackers/egl/SConscript
@@ -37,6 +37,9 @@ else:
             '#/src/gbm/main',
             '#/src/gallium/state_trackers/gbm',
         ])
+        env.Prepend(LIBS = [
+            libloader
+        ])
         sources.append(env.ParseSourceList('Makefile.sources', 'drm_FILES'))
 
 st_egl = env.ConvenienceLibrary(
diff --git a/src/gallium/state_trackers/egl/drm/native_drm.c b/src/gallium/state_trackers/egl/drm/native_drm.c
index c82bbe4..edaba43 100644
--- a/src/gallium/state_trackers/egl/drm/native_drm.c
+++ b/src/gallium/state_trackers/egl/drm/native_drm.c
@@ -30,15 +30,12 @@
 
 #include "util/u_memory.h"
 #include "egllog.h"
+#include "loader.h"
 
 #include "native_drm.h"
 
 #include "gbm_gallium_drmint.h"
 
-#ifdef HAVE_LIBUDEV
-#include <libudev.h>
-#endif
-
 static boolean
 drm_display_is_format_supported(struct native_display *ndpy,
                                 enum pipe_format fmt, boolean is_color)
@@ -151,43 +148,6 @@ static struct native_display_buffer drm_display_buffer = {
    drm_display_export_native_buffer
 };
 
-static char *
-drm_get_device_name(int fd)
-{
-   char *device_name = NULL;
-#ifdef HAVE_LIBUDEV
-   struct udev *udev;
-   struct udev_device *device;
-   struct stat buf;
-   const char *tmp;
-
-   udev = udev_new();
-   if (fstat(fd, &buf) < 0) {
-      _eglLog(_EGL_WARNING, "failed to stat fd %d", fd);
-      goto outudev;
-   }
-
-   device = udev_device_new_from_devnum(udev, 'c', buf.st_rdev);
-   if (device == NULL) {
-      _eglLog(_EGL_WARNING,
-              "could not create udev device for fd %d", fd);
-      goto outdevice;
-   }
-
-   tmp = udev_device_get_devnode(device);
-   if (!tmp)
-      goto outdevice;
-   device_name = strdup(tmp);
-
-outdevice:
-   udev_device_unref(device);
-outudev:
-   udev_unref(udev);
-
-#endif
-   return device_name;
-}
-
 #ifdef HAVE_WAYLAND_BACKEND
 
 static int
@@ -230,7 +190,7 @@ drm_create_display(struct gbm_gallium_drm_device *gbmdrm, int own_gbm,
    drmdpy->gbmdrm = gbmdrm;
    drmdpy->own_gbm = own_gbm;
    drmdpy->fd = gbmdrm->base.base.fd;
-   drmdpy->device_name = drm_get_device_name(drmdpy->fd);
+   drmdpy->device_name = loader_get_device_name_for_fd(drmdpy->fd);
 
    gbmdrm->lookup_egl_image = (struct pipe_resource *(*)(void *, void *))
       event_handler->lookup_egl_image;
-- 
1.8.5.1



More information about the mesa-dev mailing list