st/egl: use loader util lib
authorEmil Velikov <emil.l.velikov@gmail.com>
Sat, 11 Jan 2014 04:06:45 +0000 (04:06 +0000)
committerEmil Velikov <emil.l.velikov@gmail.com>
Sat, 18 Jan 2014 18:47:48 +0000 (18:47 +0000)
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Reviewed-by: Rob Clark <robdclark@gmail.com>
Reviewed-by: Kristian Høgsberg <krh@bitplanet.net>
src/gallium/state_trackers/egl/Makefile.am
src/gallium/state_trackers/egl/SConscript
src/gallium/state_trackers/egl/drm/native_drm.c

index 459fabc86927b646d90afba850466ffd99198021..bad14feb40fd37bb8d438e37d58ee7443b089aa0 100644 (file)
@@ -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 += \
index 2a5db64b9993c0bec8b48807c2be812f3549dfa1..066a7fd9a92cb9e2cc1f8961c23be21e8604f38b 100644 (file)
@@ -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(
index c82bbe4d7417a010bcc66653d8324cf5c2789458..edaba43271dbd8a2cc60655b595731f34e696ccd 100644 (file)
 
 #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;