summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDerek Foreman <derekf@osg.samsung.com>2017-07-21 16:40:17 -0500
committerDerek Foreman <derekf@osg.samsung.com>2017-07-21 16:46:00 -0500
commit414d406b3b442216543cdaef112787696ae09898 (patch)
tree23643ba6614fede0de4c932a1e52b434dda2433e
parent57e826db69bc02ab6b779a5d65b278f0288bf718 (diff)
downloadefl-414d406b3b442216543cdaef112787696ae09898.tar.gz
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.
-rw-r--r--src/lib/ecore_drm2/ecore_drm2_device.c32
1 files changed, 31 insertions, 1 deletions
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)
{