summaryrefslogtreecommitdiff
path: root/src/lib/ecore_drm2
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 /src/lib/ecore_drm2
parent57e826db69bc02ab6b779a5d65b278f0288bf718 (diff)
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.
Diffstat (limited to 'src/lib/ecore_drm2')
-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)
71 return ECORE_CALLBACK_RENEW; 71 return ECORE_CALLBACK_RENEW;
72} 72}
73 73
74static Eina_Bool
75_drm2_device_modeset_capable(int fd)
76{
77 int ret = EINA_TRUE;
78 drmModeRes *res;
79
80 res = drmModeGetResources(fd);
81 if (!res)
82 return EINA_FALSE;
83
84 if (res->count_crtcs <= 0 ||
85 res->count_connectors <= 0 ||
86 res->count_encoders <= 0)
87 ret = EINA_FALSE;
88
89 drmModeFreeResources(res);
90
91 return ret;
92}
93
74static const char * 94static const char *
75_drm2_device_find(const char *seat) 95_drm2_device_find(Elput_Manager *em, const char *seat)
76{ 96{
77 Eina_List *devs, *l; 97 Eina_List *devs, *l;
78 const char *dev, *ret = NULL; 98 const char *dev, *ret = NULL;
79 Eina_Bool found = EINA_FALSE; 99 Eina_Bool found = EINA_FALSE;
80 Eina_Bool platform = EINA_FALSE; 100 Eina_Bool platform = EINA_FALSE;
101 Eina_Bool modeset;
102 int fd;
81 103
82 devs = eeze_udev_find_by_subsystem_sysname("drm", "card[0-9]*"); 104 devs = eeze_udev_find_by_subsystem_sysname("drm", "card[0-9]*");
83 if (!devs) return NULL; 105 if (!devs) return NULL;
@@ -97,6 +119,14 @@ _drm2_device_find(const char *seat)
97 else if (strcmp(dseat, "seat0")) 119 else if (strcmp(dseat, "seat0"))
98 goto cont; 120 goto cont;
99 121
122 fd = elput_manager_open(em, dpath, -1);
123 if (fd < 0)
124 goto cont;
125 modeset = _drm2_device_modeset_capable(fd);
126 elput_manager_close(em, fd);
127 if (!modeset)
128 goto cont;
129
100 dparent = eeze_udev_syspath_get_parent_filtered(dev, "pci", NULL); 130 dparent = eeze_udev_syspath_get_parent_filtered(dev, "pci", NULL);
101 if (!dparent) 131 if (!dparent)
102 { 132 {