From b69bf1a6acf5f1e3fe6d71f5cf1bf77d16fa8083 Mon Sep 17 00:00:00 2001 From: Christopher Michael Date: Wed, 17 Aug 2022 12:22:10 -0400 Subject: [PATCH] ecore_drm2: Add check for Atomic Modesetting support --- src/lib/ecore_drm2/ecore_drm2.c | 2 ++ src/lib/ecore_drm2/ecore_drm2_device.c | 29 ++++++++++++++++++++++++- src/lib/ecore_drm2/ecore_drm2_private.h | 4 ++++ 3 files changed, 34 insertions(+), 1 deletion(-) diff --git a/src/lib/ecore_drm2/ecore_drm2.c b/src/lib/ecore_drm2/ecore_drm2.c index 6d1096d2b7..2ae711fcc7 100644 --- a/src/lib/ecore_drm2/ecore_drm2.c +++ b/src/lib/ecore_drm2/ecore_drm2.c @@ -10,6 +10,7 @@ int _ecore_drm2_log_dom = -1; /* external drm function prototypes (for dlopen) */ void *(*sym_drmModeGetResources)(int fd) = NULL; void (*sym_drmModeFreeResources)(drmModeResPtr ptr) = NULL; +int (*sym_drmSetClientCap)(int fd, uint64_t capability, uint64_t value) = NULL; /* local static functions */ static Eina_Bool @@ -46,6 +47,7 @@ _ecore_drm2_link(void) /* TODO: Sym needed libdrm functions */ SYM(_drm_lib, drmModeGetResources); SYM(_drm_lib, drmModeFreeResources); + SYM(_drm_lib, drmSetClientCap); if (fail) { diff --git a/src/lib/ecore_drm2/ecore_drm2_device.c b/src/lib/ecore_drm2/ecore_drm2_device.c index 6396c92d5e..2fb0311e22 100644 --- a/src/lib/ecore_drm2/ecore_drm2_device.c +++ b/src/lib/ecore_drm2/ecore_drm2_device.c @@ -1,6 +1,25 @@ #include "ecore_drm2_private.h" +/* external variable for using atomic */ +Eina_Bool _ecore_drm2_atomic_use = EINA_FALSE; + /* local functions */ +static Eina_Bool +_ecore_drm2_device_atomic_capable_get(int fd) +{ + Eina_Bool ret = EINA_TRUE; + + if (sym_drmSetClientCap(fd, DRM_CLIENT_CAP_UNIVERSAL_PLANES, 1) < 0) + ret = EINA_FALSE; + else + { + if (sym_drmSetClientCap(fd, DRM_CLIENT_CAP_ATOMIC, 1) < 0) + ret = EINA_FALSE; + } + + return ret; +} + static Eina_Bool _ecore_drm2_device_modeset_capable_get(int fd) { @@ -124,7 +143,15 @@ ecore_drm2_device_open(const char *seat, unsigned int tty) goto open_err; } - /* TODO: elput_input_init, check atomic capable, etc */ + /* TODO: elput_input_init, etc */ + + /* NB: For now, we will ONLY support Atomic */ + _ecore_drm2_atomic_use = _ecore_drm2_device_atomic_capable_get(dev->fd); + if (!_ecore_drm2_atomic_use) + { + WRN("Could not enable Atomic Modesetting support"); + goto open_err; + } return dev; diff --git a/src/lib/ecore_drm2/ecore_drm2_private.h b/src/lib/ecore_drm2/ecore_drm2_private.h index 3f336e3070..06f53fb0d2 100644 --- a/src/lib/ecore_drm2/ecore_drm2_private.h +++ b/src/lib/ecore_drm2/ecore_drm2_private.h @@ -31,6 +31,9 @@ /* define necessary vars/macros for ecore_drm2 log domain */ extern int _ecore_drm2_log_dom; +/* define externval variable for atomic */ +extern Eina_Bool _ecore_drm2_atomic_use; + # ifdef ECORE_DRM2_DEFAULT_LOG_COLOR # undef ECORE_DRM2_DEFAULT_LOG_COLOR # endif @@ -72,5 +75,6 @@ struct _Ecore_Drm2_Device /* external drm function prototypes (for dlopen) */ extern void *(*sym_drmModeGetResources)(int fd); extern void (*sym_drmModeFreeResources)(drmModeResPtr ptr); +extern int (*sym_drmSetClientCap)(int fd, uint64_t capability, uint64_t value); #endif