summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Michael <cp.michael@samsung.com>2016-09-22 10:34:03 -0400
committerChris Michael <cp.michael@samsung.com>2016-09-22 13:33:56 -0400
commitad3ca31b01cab158e5b486a56dd17ba0de7ebf8a (patch)
treeb778319de06e0b822f86b2bc1000d9d76b1b6ec4
parent44a356a8488a736ae0ab524e20e71c4ed58fb580 (diff)
ecore-drm2: Add code to check if Atomic Modesettting is usable
This code will detect the drm driver name and check that the kernel itself is new enough to use Atomic Modesetting. This is needed as some drivers (i915) do not handle Atomic Modesetting propertly without a new enough kernel. Signed-off-by: Chris Michael <cp.michael@samsung.com>
-rw-r--r--src/lib/ecore_drm2/ecore_drm2_device.c59
1 files changed, 55 insertions, 4 deletions
diff --git a/src/lib/ecore_drm2/ecore_drm2_device.c b/src/lib/ecore_drm2/ecore_drm2_device.c
index 8f2e43cfde..1ee7871f5a 100644
--- a/src/lib/ecore_drm2/ecore_drm2_device.c
+++ b/src/lib/ecore_drm2/ecore_drm2_device.c
@@ -8,6 +8,12 @@
8# define DRM_CAP_CURSOR_HEIGHT 0x9 8# define DRM_CAP_CURSOR_HEIGHT 0x9
9#endif 9#endif
10 10
11#ifdef HAVE_ATOMIC_DRM
12# include <sys/utsname.h>
13#endif
14
15Eina_Bool _ecore_drm2_use_atomic = EINA_FALSE;
16
11static Eina_Bool 17static Eina_Bool
12_cb_session_active(void *data, int type EINA_UNUSED, void *event) 18_cb_session_active(void *data, int type EINA_UNUSED, void *event)
13{ 19{
@@ -143,6 +149,50 @@ out:
143 return ret; 149 return ret;
144} 150}
145 151
152#ifdef HAVE_ATOMIC_DRM
153static Eina_Bool
154_ecore_drm2_atomic_usable(int fd)
155{
156 drmVersion *drmver;
157 Eina_Bool ret = EINA_FALSE;
158
159 drmver = drmGetVersion(fd);
160 if (!drmver) return EINA_FALSE;
161
162 /* detect driver */
163 if ((!strcmp(drmver->name, "i915")) &&
164 (!strcmp(drmver->desc, "Intel Graphics")))
165 {
166 FILE *fp;
167
168 /* detect kernel version
169 * NB: In order for atomic modesetting to work properly for Intel,
170 * we need to be using a kernel >= 4.8.0 */
171
172 fp = fopen("/proc/sys/kernel/osrelease", "rb");
173 if (fp)
174 {
175 char buff[512];
176 int maj = 0, min = 0;
177
178 if (fgets(buff, sizeof(buff), fp))
179 {
180 if (sscanf(buff, "%i.%i.%*s", &maj, &min) == 2)
181 {
182 if ((maj >= 4) && (min >= 8))
183 ret = EINA_TRUE;
184 }
185 }
186 fclose(fp);
187 }
188 }
189
190 drmFreeVersion(drmver);
191
192 return ret;
193}
194#endif
195
146EAPI Ecore_Drm2_Device * 196EAPI Ecore_Drm2_Device *
147ecore_drm2_device_find(const char *seat, unsigned int tty) 197ecore_drm2_device_find(const char *seat, unsigned int tty)
148{ 198{
@@ -191,6 +241,11 @@ ecore_drm2_device_open(Ecore_Drm2_Device *device)
191 DBG("Device Path: %s", device->path); 241 DBG("Device Path: %s", device->path);
192 DBG("Device Fd: %d", device->fd); 242 DBG("Device Fd: %d", device->fd);
193 243
244#ifdef HAVE_ATOMIC_DRM
245 /* check that this system can do atomic */
246 _ecore_drm2_use_atomic = _ecore_drm2_atomic_usable(device->fd);
247#endif
248
194 device->active_hdlr = 249 device->active_hdlr =
195 ecore_event_handler_add(ELPUT_EVENT_SESSION_ACTIVE, 250 ecore_event_handler_add(ELPUT_EVENT_SESSION_ACTIVE,
196 _cb_session_active, device); 251 _cb_session_active, device);
@@ -199,10 +254,6 @@ ecore_drm2_device_open(Ecore_Drm2_Device *device)
199 ecore_event_handler_add(ELPUT_EVENT_DEVICE_CHANGE, 254 ecore_event_handler_add(ELPUT_EVENT_DEVICE_CHANGE,
200 _cb_device_change, device); 255 _cb_device_change, device);
201 256
202 /* NB: Not going to enable planes if we don't support atomic */
203 /* if (drmSetClientCap(device->fd, DRM_CLIENT_CAP_UNIVERSAL_PLANES, 1) < 0) */
204 /* ERR("Could not set Universal Plane support: %m"); */
205
206 return device->fd; 257 return device->fd;
207 258
208input_err: 259input_err: