devilhorns pushed a commit to branch master.

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

commit a6b018a2a8283e9244182152cc9187db818b7b63
Author: Chris Michael <[email protected]>
Date:   Wed May 11 09:29:48 2016 -0400

    ecore-drm2: Add API function to set the mode of an output
    
    Signed-off-by: Chris Michael <[email protected]>
---
 src/lib/ecore_drm2/Ecore_Drm2.h         | 15 ++++++++++++
 src/lib/ecore_drm2/ecore_drm2_outputs.c | 43 +++++++++++++++++++++++++++++++++
 2 files changed, 58 insertions(+)

diff --git a/src/lib/ecore_drm2/Ecore_Drm2.h b/src/lib/ecore_drm2/Ecore_Drm2.h
index 508c0fd..df07a33 100644
--- a/src/lib/ecore_drm2/Ecore_Drm2.h
+++ b/src/lib/ecore_drm2/Ecore_Drm2.h
@@ -480,6 +480,21 @@ EAPI const Eina_List 
*ecore_drm2_output_modes_get(Ecore_Drm2_Output *output);
 EAPI void ecore_drm2_output_mode_info_get(Ecore_Drm2_Output_Mode *mode, int 
*w, int *h, unsigned int *refresh, unsigned int *flags);
 
 /**
+ * Set a given mode to be used on a given output
+ *
+ * @param output
+ * @param mode
+ * @param x
+ * @param y
+ *
+ * @return EINA_TRUE on success, EINA_FALSE otherwise
+ *
+ * @ingroup Ecore_Drm2_Output_Group
+ * @since 1.18
+ */
+EAPI Eina_Bool ecore_drm2_output_mode_set(Ecore_Drm2_Output *output, 
Ecore_Drm2_Output_Mode *mode, int x, int y);
+
+/**
  * @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 0f89fe7..4a4fe0b 100644
--- a/src/lib/ecore_drm2/ecore_drm2_outputs.c
+++ b/src/lib/ecore_drm2/ecore_drm2_outputs.c
@@ -989,3 +989,46 @@ ecore_drm2_output_mode_info_get(Ecore_Drm2_Output_Mode 
*mode, int *w, int *h, un
    if (refresh) *refresh = mode->refresh;
    if (flags) *flags = mode->flags;
 }
+
+EAPI Eina_Bool
+ecore_drm2_output_mode_set(Ecore_Drm2_Output *output, Ecore_Drm2_Output_Mode 
*mode, int x, int y)
+{
+   Eina_Bool ret = EINA_TRUE;
+   unsigned int buffer = 0;
+
+   EINA_SAFETY_ON_NULL_RETURN_VAL(output, EINA_FALSE);
+   EINA_SAFETY_ON_TRUE_RETURN_VAL((output->fd < 0), EINA_FALSE);
+
+   output->x = x;
+   output->y = y;
+   output->current_mode = mode;
+
+   if (mode)
+     {
+        if (output->current)
+          buffer = output->current->id;
+        else if (output->next)
+          buffer = output->next->id;
+        else
+          buffer = output->ocrtc->buffer_id;
+
+        if (drmModeSetCrtc(output->fd, output->crtc_id, buffer,
+                           x, y, &output->conn_id, 1, &mode->info) < 0)
+          {
+             ERR("Failed to set Mode %dx%d for Output %s: %m",
+                 mode->width, mode->height, output->name);
+             ret = EINA_FALSE;
+          }
+     }
+   else
+     {
+        if (drmModeSetCrtc(output->fd, output->crtc_id, 0,
+                           0, 0, 0, 0, NULL) < 0)
+          {
+             ERR("Failed to turn off Output %s: %m", output->name);
+             ret = EINA_FALSE;
+          }
+     }
+
+   return ret;
+}

-- 


Reply via email to