aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/ecore_drm2/ecore_drm2_device.c
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 14:20:24 -0400
commit541be05bf202778ece0cc08799586a873880f95a (patch)
treebcd165196ef01ed2d2feff3c3301791144af5d91 /src/lib/ecore_drm2/ecore_drm2_device.c
parentecore-drm2: Add private structures to support Atomic Modesetting (diff)
downloadefl-541be05bf202778ece0cc08799586a873880f95a.tar.gz
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>
Diffstat (limited to 'src/lib/ecore_drm2/ecore_drm2_device.c')
-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 @@
# define DRM_CAP_CURSOR_HEIGHT 0x9
#endif
+#ifdef HAVE_ATOMIC_DRM
+# include <sys/utsname.h>
+#endif
+
+Eina_Bool _ecore_drm2_use_atomic = EINA_FALSE;
+
static Eina_Bool
_cb_session_active(void *data, int type EINA_UNUSED, void *event)
{
@@ -143,6 +149,50 @@ out:
return ret;
}
+#ifdef HAVE_ATOMIC_DRM
+static Eina_Bool
+_ecore_drm2_atomic_usable(int fd)
+{
+ drmVersion *drmver;
+ Eina_Bool ret = EINA_FALSE;
+
+ drmver = drmGetVersion(fd);
+ if (!drmver) return EINA_FALSE;
+
+ /* detect driver */
+ if ((!strcmp(drmver->name, "i915")) &&
+ (!strcmp(drmver->desc, "Intel Graphics")))
+ {
+ FILE *fp;
+
+ /* detect kernel version
+ * NB: In order for atomic modesetting to work properly for Intel,
+ * we need to be using a kernel >= 4.8.0 */
+
+ fp = fopen("/proc/sys/kernel/osrelease", "rb");
+ if (fp)
+ {
+ char buff[512];
+ int maj = 0, min = 0;
+
+ if (fgets(buff, sizeof(buff), fp))
+ {
+ if (sscanf(buff, "%i.%i.%*s", &maj, &min) == 2)
+ {
+ if ((maj >= 4) && (min >= 8))
+ ret = EINA_TRUE;
+ }
+ }
+ fclose(fp);
+ }
+ }
+
+ drmFreeVersion(drmver);
+
+ return ret;
+}
+#endif
+
EAPI Ecore_Drm2_Device *
ecore_drm2_device_find(const char *seat, unsigned int tty)
{
@@ -191,6 +241,11 @@ ecore_drm2_device_open(Ecore_Drm2_Device *device)
DBG("Device Path: %s", device->path);
DBG("Device Fd: %d", device->fd);
+#ifdef HAVE_ATOMIC_DRM
+ /* check that this system can do atomic */
+ _ecore_drm2_use_atomic = _ecore_drm2_atomic_usable(device->fd);
+#endif
+
device->active_hdlr =
ecore_event_handler_add(ELPUT_EVENT_SESSION_ACTIVE,
_cb_session_active, device);
@@ -199,10 +254,6 @@ ecore_drm2_device_open(Ecore_Drm2_Device *device)
ecore_event_handler_add(ELPUT_EVENT_DEVICE_CHANGE,
_cb_device_change, device);
- /* NB: Not going to enable planes if we don't support atomic */
- /* if (drmSetClientCap(device->fd, DRM_CLIENT_CAP_UNIVERSAL_PLANES, 1) < 0) */
- /* ERR("Could not set Universal Plane support: %m"); */
-
return device->fd;
input_err: