ecore-drm2: Add API to check if vblank is supported
authorChristopher Michael <cp.michael@samsung.com>
Wed, 22 May 2019 11:35:45 +0000 (07:35 -0400)
committerJunsuChoi <jsuya.choi@samsung.com>
Thu, 30 May 2019 08:17:52 +0000 (17:17 +0900)
This patch adds a small API that we can use to check if the current
video driver supports the usage of drmWaitVBlank. This check is
required for certain drivers (like vbox) which do not support
drmWaitVBlank and thus are causing our animators in ecore_evas to
freeze. We can now use this API from within Ecore_Evas to disable
vsync'd animators and fall back to timer based ones.

@feature

src/lib/ecore_drm2/Ecore_Drm2.h
src/lib/ecore_drm2/ecore_drm2_device.c

index 843cfa6..5c43258 100644 (file)
@@ -1196,6 +1196,17 @@ EAPI Eina_Bool ecore_drm2_output_pending_get(Ecore_Drm2_Output *output);
  */
 EAPI Eina_Bool ecore_drm2_output_background_color_set(Ecore_Drm2_Output *output, uint64_t r, uint64_t g, uint64_t b, uint64_t a);
 
+/**
+ * Check if vblank is supported by the current video driver
+ *
+ * @param dev
+ *
+ * @return EINA_TRUE if vblank is supported, EINA_FALSE otherwise
+ *
+ * @ingroup Ecore_Drm2_Device_Group
+ * @since 1.23 */
+EAPI Eina_Bool ecore_drm2_vblank_supported(Ecore_Drm2_Device *dev);
+
 # endif
 
 #endif
index b95a5a7..c86df1a 100644 (file)
@@ -891,6 +891,23 @@ ecore_drm2_device_fd_get(Ecore_Drm2_Device *device)
    return device->fd;
 }
 
+EAPI Eina_Bool
+ecore_drm2_vblank_supported(Ecore_Drm2_Device *dev)
+{
+   drmVBlank tmp;
+   int ret = 0;
+
+   EINA_SAFETY_ON_NULL_RETURN_VAL(dev, EINA_FALSE);
+
+   memset(&tmp, 0, sizeof(drmVBlank));
+   tmp.request.type = DRM_VBLANK_RELATIVE;
+
+   ret = sym_drmWaitVBlank(dev->fd, &tmp);
+
+   if (ret != 0) return EINA_FALSE;
+   return EINA_TRUE;
+}
+
 /* prevent crashing with old apps compiled against these functions */
 EAPI void ecore_drm2_device_keyboard_cached_context_set(){};
 EAPI void ecore_drm2_device_keyboard_cached_keymap_set(){};