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.
This commit is contained in:
Derek Foreman 2017-07-21 16:40:17 -05:00
parent 57e826db69
commit 414d406b3b
1 changed files with 31 additions and 1 deletions

View File

@ -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)
{