derekf pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=414d406b3b442216543cdaef112787696ae09898

commit 414d406b3b442216543cdaef112787696ae09898
Author: Derek Foreman <der...@osg.samsung.com>
Date:   Fri Jul 21 16:40:17 2017 -0500

    ecore_drm2: Ensure device we find can mode set
    
    Some systems have dri devices that can't mode set, and if they're first in
    the directory they'll get picked by our code and things fall apart later.
    
    So, open the potential device and ensure it has basic functionality before
    selecting it.
    
    This is a little inefficient as it gets the device via elput twice before
    it can be used - this will be addressed later as the changes are a little
    more invasive to optimize.
---
 src/lib/ecore_drm2/ecore_drm2_device.c | 32 +++++++++++++++++++++++++++++++-
 1 file changed, 31 insertions(+), 1 deletion(-)

diff --git a/src/lib/ecore_drm2/ecore_drm2_device.c 
b/src/lib/ecore_drm2/ecore_drm2_device.c
index 5552eebd47..446230edb9 100644
--- a/src/lib/ecore_drm2/ecore_drm2_device.c
+++ b/src/lib/ecore_drm2/ecore_drm2_device.c
@@ -71,13 +71,35 @@ _cb_device_change(void *data, int type EINA_UNUSED, void 
*event)
    return ECORE_CALLBACK_RENEW;
 }
 
+static Eina_Bool
+_drm2_device_modeset_capable(int fd)
+{
+   int ret = EINA_TRUE;
+   drmModeRes *res;
+
+   res = drmModeGetResources(fd);
+   if (!res)
+     return EINA_FALSE;
+
+   if (res->count_crtcs <= 0 ||
+       res->count_connectors <= 0 ||
+       res->count_encoders <= 0)
+     ret = EINA_FALSE;
+
+   drmModeFreeResources(res);
+
+   return ret;
+}
+
 static const char *
-_drm2_device_find(const char *seat)
+_drm2_device_find(Elput_Manager *em, const char *seat)
 {
    Eina_List *devs, *l;
    const char *dev, *ret = NULL;
    Eina_Bool found = EINA_FALSE;
    Eina_Bool platform = EINA_FALSE;
+   Eina_Bool modeset;
+   int fd;
 
    devs = eeze_udev_find_by_subsystem_sysname("drm", "card[0-9]*");
    if (!devs) return NULL;
@@ -97,6 +119,14 @@ _drm2_device_find(const char *seat)
         else if (strcmp(dseat, "seat0"))
           goto cont;
 
+        fd = elput_manager_open(em, dpath, -1);
+        if (fd < 0)
+          goto cont;
+        modeset = _drm2_device_modeset_capable(fd);
+        elput_manager_close(em, fd);
+        if (!modeset)
+          goto cont;
+
         dparent = eeze_udev_syspath_get_parent_filtered(dev, "pci", NULL);
         if (!dparent)
           {

-- 


Reply via email to