ecore-drm2: Add API function to set output rotation
authorChris Michael <cp.michael@samsung.com>
Wed, 18 Jan 2017 16:29:14 +0000 (11:29 -0500)
committerChris Michael <cp.michael@samsung.com>
Wed, 18 Jan 2017 16:29:14 +0000 (11:29 -0500)
This patch adds a new API function that can be called from
Enlightenment wl_drm module to enable output rotation.

NB: Only works if Atomic support is enabled as it rotates the hardware
plane directly...and we don't support planes without Atomic enabled.

@feature

Signed-off-by: Chris Michael <cp.michael@samsung.com>
src/lib/ecore_drm2/Ecore_Drm2.h
src/lib/ecore_drm2/ecore_drm2_outputs.c

index a7834c4..87d7b40 100644 (file)
@@ -758,6 +758,22 @@ EAPI void ecore_drm2_output_gamma_set(Ecore_Drm2_Output *output, uint16_t size,
 EAPI int ecore_drm2_output_supported_rotations_get(Ecore_Drm2_Output *output);
 
 /**
+ * Set a rotation on a given output
+ *
+ * @param output
+ * @param rotation
+ *
+ * @return EINA_TRUE on success, EINA_FALSE otherwise
+ *
+ * @note This function will only work if Atomic support
+ *       is enabled as it requires hardware plane support.
+ *
+ * @ingroup Ecore_Drm2_Output_Group
+ * @since 1.19
+ */
+EAPI Eina_Bool ecore_drm2_output_rotation_set(Ecore_Drm2_Output *output, int rotation);
+
+/**
  * @defgroup Ecore_Drm2_Fb_Group Drm framebuffer functions
  *
  * Functions that deal with setup of framebuffers
index 055b63d..a36c440 100644 (file)
@@ -1529,3 +1529,52 @@ ecore_drm2_output_supported_rotations_get(Ecore_Drm2_Output *output)
 
    return ret;
 }
+
+EAPI Eina_Bool
+ecore_drm2_output_rotation_set(Ecore_Drm2_Output *output, int rotation)
+{
+   Eina_Bool ret = EINA_FALSE;
+
+   EINA_SAFETY_ON_NULL_RETURN_VAL(output, EINA_FALSE);
+
+#ifdef HAVE_ATOMIC_DRM
+   if (_ecore_drm2_use_atomic)
+     {
+        Ecore_Drm2_Plane_State *pstate;
+        drmModeAtomicReq *req = NULL;
+        int res = 0;
+        uint32_t flags =
+          DRM_MODE_ATOMIC_NONBLOCK | DRM_MODE_PAGE_FLIP_EVENT |
+          DRM_MODE_ATOMIC_ALLOW_MODESET;
+
+        pstate = output->plane_state;
+        if ((pstate->supported_rotations & rotation) == 0)
+          {
+             WRN("Unsupported rotation");
+             return EINA_FALSE;
+          }
+
+        req = sym_drmModeAtomicAlloc();
+        if (!req) return EINA_FALSE;
+
+        sym_drmModeAtomicSetCursor(req, 0);
+
+        res = sym_drmModeAtomicAddProperty(req, pstate->obj_id,
+                                           pstate->rotation.id, rotation);
+        if (res < 0) goto err;
+
+        res = sym_drmModeAtomicCommit(output->fd, req, flags, output->user_data);
+        if (res < 0) goto err;
+        else
+          {
+             ret = EINA_TRUE;
+             pstate->rotation.value = rotation;
+          }
+
+err:
+        sym_drmModeAtomicFree(req);
+     }
+#endif
+
+   return ret;
+}