devilhorns pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=c126ce2e705f45f5992442c0c8bf0dfe5b4f6919

commit c126ce2e705f45f5992442c0c8bf0dfe5b4f6919
Author: Chris Michael <[email protected]>
Date:   Wed Jan 18 11:29:14 2017 -0500

    ecore-drm2: Add API function to set output rotation
    
    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 <[email protected]>
---
 src/lib/ecore_drm2/Ecore_Drm2.h         | 16 +++++++++++
 src/lib/ecore_drm2/ecore_drm2_outputs.c | 49 +++++++++++++++++++++++++++++++++
 2 files changed, 65 insertions(+)

diff --git a/src/lib/ecore_drm2/Ecore_Drm2.h b/src/lib/ecore_drm2/Ecore_Drm2.h
index a7834c4..87d7b40 100644
--- a/src/lib/ecore_drm2/Ecore_Drm2.h
+++ b/src/lib/ecore_drm2/Ecore_Drm2.h
@@ -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
diff --git a/src/lib/ecore_drm2/ecore_drm2_outputs.c 
b/src/lib/ecore_drm2/ecore_drm2_outputs.c
index 055b63d..a36c440 100644
--- a/src/lib/ecore_drm2/ecore_drm2_outputs.c
+++ b/src/lib/ecore_drm2/ecore_drm2_outputs.c
@@ -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;
+}

-- 


Reply via email to