stefan pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=31ad73efa96b6c4c2ab01366a0897e6fadad48e4

commit 31ad73efa96b6c4c2ab01366a0897e6fadad48e4
Author: Stefan Schmidt <[email protected]>
Date:   Fri Jun 27 16:21:32 2014 +0200

    evas/drm: Make use of ecore_drm for opening DRM device
    
    We use this functionality already from ecore_drm. The evas version does
    not even use udev to acquire the device which means we could not support
    hotplugging. The only missing feature was the capability check for
    DUMB_BUFFER which I added to ecore_drm now.
---
 src/Makefile_Evas.am                       |   2 +
 src/modules/evas/engines/drm/evas_drm.c    | 106 ++---------------------------
 src/modules/evas/engines/drm/evas_engine.c |   2 +-
 src/modules/evas/engines/drm/evas_engine.h |   2 +-
 4 files changed, 8 insertions(+), 104 deletions(-)

diff --git a/src/Makefile_Evas.am b/src/Makefile_Evas.am
index 9baf524..acc8593 100644
--- a/src/Makefile_Evas.am
+++ b/src/Makefile_Evas.am
@@ -1211,9 +1211,11 @@ modules_evas_engines_drm_module_la_CPPFLAGS = 
-I$(top_builddir)/src/lib/efl \
 -I$(top_srcdir)/src/lib/evas/include \
 -I$(top_srcdir)/src/lib/evas/cserve2 \
 @EVAS_CFLAGS@ \
+@ECORE_DRM_CFLAGS@ \
 @evas_engine_drm_cflags@
 modules_evas_engines_drm_module_la_LIBADD = \
 @USE_EVAS_LIBS@ \
+@ECORE_DRM_LIBS@ \
 @evas_engine_drm_libs@
 modules_evas_engines_drm_module_la_DEPENDENCIES = @USE_EVAS_INTERNAL_LIBS@
 modules_evas_engines_drm_module_la_LDFLAGS = -module @EFL_LTMODULE_FLAGS@
diff --git a/src/modules/evas/engines/drm/evas_drm.c 
b/src/modules/evas/engines/drm/evas_drm.c
index 764f77a..e5bd74d 100644
--- a/src/modules/evas/engines/drm/evas_drm.c
+++ b/src/modules/evas/engines/drm/evas_drm.c
@@ -2,90 +2,12 @@
 #include <linux/vt.h>
 #include <linux/kd.h>
 #include <sys/mman.h>
+#include <Ecore_Drm.h>
 
 /* NB: REALLY hate to store this here, but sigaction signal handlers cannot 
  * pass any 'user data' to the signal handlers :( */
 static Evas_Engine_Info_Drm *siginfo;
 
-static char *
-_evas_drm_card_driver_get(const char *dev)
-{
-   struct stat st;
-   int maj, min;
-   char *path, path_link[PATH_MAX + 1] = "";
-   char *drv;
-
-   if (stat(dev, &st) < 0) return NULL;
-
-   if (!S_ISCHR(st.st_mode)) return NULL;
-
-   maj = major(st.st_rdev);
-   min = minor(st.st_rdev);
-
-   asprintf(&path, "/sys/dev/char/%d:%d/device/driver", maj, min);
-   if (readlink(path, path_link, sizeof(path_link) - 1) < 0)
-     {
-        free(path);
-        return NULL;
-     }
-
-   free(path);
-
-   if (!(drv = strrchr(path_link, '/'))) return NULL;
-   return strdup(drv + strlen("/"));
-}
-
-static int 
-_evas_drm_card_open(int card)
-{
-   char dev[32], *driver;
-   int fd = -1;
-   uint64_t dumb;
-
-   sprintf(dev, DRM_DEV_NAME, DRM_DIR_NAME, card);
-
-   driver = _evas_drm_card_driver_get(dev);
-   DBG("Drm Device Driver: %s", driver);
-
-   if ((fd = drmOpen(driver, NULL)) < 0)
-     {
-        CRI("Could not open drm device %s: %m", dev);
-        return -1;
-     }
-
-   /* if ((fd = open(dev, (O_RDWR | O_CLOEXEC))) < 0) */
-   /*   { */
-   /*      CRI("Could not open drm device %s: %m", dev); */
-   /*      return -1; */
-   /*   } */
-
-   /* drmVersionPtr ver; */
-   /* if ((ver = drmGetVersion(fd))) */
-   /*   { */
-   /*      DBG("Drm Driver Name: %s", ver->name); */
-   /*      drmFreeVersion(ver); */
-   /*   } */
-
-   /* check for dumb buffer support
-    * 
-    * NB: This checks that we can at least support software rendering */
-   if ((drmGetCap(fd, DRM_CAP_DUMB_BUFFER, &dumb) < 0) || (!dumb))
-     {
-        CRI("Drm Device %s does not support software rendering", dev);
-
-        /* close the card */
-        close(fd);
-
-        /* return failure */
-        return -1;
-     }
-
-   DBG("Opened Drm Card %s: %d", dev, fd);
-
-   /* return opened card */
-   return fd;
-}
-
 static int 
 _evas_drm_tty_open(Evas_Engine_Info_Drm *info)
 {
@@ -386,26 +308,15 @@ _evas_drm_outbuf_planes_setup(Outbuf *ob, 
drmModePlaneResPtr pres)
    return EINA_TRUE;
 }
 
-Eina_Bool 
-evas_drm_init(Evas_Engine_Info_Drm *info, int card)
+Eina_Bool
+evas_drm_init(Evas_Engine_Info_Drm *info)
 {
+
    /* check for valid engine info */
    if (!info) return EINA_FALSE;
 
    setvbuf(stdout, NULL, _IONBF, 0);
 
-   /* check if we already opened the card */
-   if (info->info.fd < 0)
-     {
-        /* try to open the drm card */
-        if ((info->info.fd = _evas_drm_card_open(card)) < 0) 
-          return EINA_FALSE;
-
-        /* set flag to indicate that evas opened the card and we should 
-         * be the one to close it */
-        info->info.own_fd = EINA_TRUE;
-     }
-
    /* check if we already opened the tty */
    if (info->info.tty < 0)
      {
@@ -430,8 +341,6 @@ evas_drm_init(Evas_Engine_Info_Drm *info, int card)
         if ((info->info.tty >= 0) && (info->info.own_tty))
           close(info->info.tty);
 
-        /* FIXME: Close card also ?? */
-
         return EINA_FALSE;
      }
 
@@ -451,13 +360,6 @@ evas_drm_shutdown(Evas_Engine_Info_Drm *info)
         info->info.tty = -1;
      }
 
-   /* check if we already opened the card. if so, close it */
-   if ((info->info.fd >= 0) && (info->info.own_fd))
-     {
-        close(info->info.fd);
-        info->info.fd = -1;
-     }
-
    return EINA_TRUE;
 }
 
diff --git a/src/modules/evas/engines/drm/evas_engine.c 
b/src/modules/evas/engines/drm/evas_engine.c
index 8be1924..a868ac7 100644
--- a/src/modules/evas/engines/drm/evas_engine.c
+++ b/src/modules/evas/engines/drm/evas_engine.c
@@ -54,7 +54,7 @@ _output_setup(Evas_Engine_Info_Drm *info, int w, int h, int 
swap)
    if (info->info.fd < 0)
      {
         /* try to init drm (this includes openening the card & tty) */
-        if (!evas_drm_init(info, 0))
+        if (!evas_drm_init(info))
           {
              if (re->tb) evas_common_tilebuf_free(re->tb);
              free(re);
diff --git a/src/modules/evas/engines/drm/evas_engine.h 
b/src/modules/evas/engines/drm/evas_engine.h
index a7d3990..675c9e5 100644
--- a/src/modules/evas/engines/drm/evas_engine.h
+++ b/src/modules/evas/engines/drm/evas_engine.h
@@ -136,7 +136,7 @@ void evas_outbuf_update_region_push(Outbuf *ob, RGBA_Image 
*update, int x, int y
 void evas_outbuf_update_region_free(Outbuf *ob, RGBA_Image *update);
 void evas_outbuf_flush(Outbuf *ob);
 
-Eina_Bool evas_drm_init(Evas_Engine_Info_Drm *info, int card);
+Eina_Bool evas_drm_init(Evas_Engine_Info_Drm *info);
 Eina_Bool evas_drm_shutdown(Evas_Engine_Info_Drm *info);
 
 Eina_Bool evas_drm_outbuf_setup(Outbuf *ob);

-- 


Reply via email to