devilhorns pushed a commit to branch master.

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

commit 8a3441dfe9f2c59586498b41cc87fc26288b7d06
Author: Chris Michael <cp.mich...@samsung.com>
Date:   Mon May 11 12:37:24 2015 -0400

    ecore-drm: Add API function to test if an output can go on a given crtc
    
    Summary: This adds a new API function to test if a given
    Ecore_Drm_Output can be used on a given crtc. This is needed for DRM
    RandR support
    
    @feature
    
    Signed-off-by: Chris Michael <cp.mich...@samsung.com>
---
 src/lib/ecore_drm/Ecore_Drm.h        | 16 +++++++++
 src/lib/ecore_drm/ecore_drm_output.c | 64 ++++++++++++++++++++++++++++++++++++
 2 files changed, 80 insertions(+)

diff --git a/src/lib/ecore_drm/Ecore_Drm.h b/src/lib/ecore_drm/Ecore_Drm.h
index 481da42..f468b56 100644
--- a/src/lib/ecore_drm/Ecore_Drm.h
+++ b/src/lib/ecore_drm/Ecore_Drm.h
@@ -906,6 +906,22 @@ EAPI void ecore_drm_output_crtc_size_get(Ecore_Drm_Output 
*output, int *width, i
  */
 EAPI Ecore_Drm_Output *ecore_drm_device_output_name_find(Ecore_Drm_Device 
*dev, const char *name);
 
+/**
+ * Get if an Ecore_Drm_Output can be used on a given crtc
+ *
+ * This function will loop the possible crtcs of an encoder to determine if
+ * a given output can be assigned to a given crtc
+ *
+ * @param output The Ecore_Drm_Output to test if can be used on crtc
+ * @param crtc The crtc to test an Ecore_Drm_Output against
+ *
+ * @return EINA_TRUE if the output can be assigned to given crtc, EINA_FALSE 
otherwise
+ *
+ * @ingroup Ecore_Drm_Output_Group
+ * @since 1.15
+ */
+EAPI Eina_Bool ecore_drm_output_possible_crtc_get(Ecore_Drm_Output *output, 
unsigned int crtc);
+
 # ifdef __cplusplus
 }
 # endif
diff --git a/src/lib/ecore_drm/ecore_drm_output.c 
b/src/lib/ecore_drm/ecore_drm_output.c
index 2596538..a76a8ec 100644
--- a/src/lib/ecore_drm/ecore_drm_output.c
+++ b/src/lib/ecore_drm/ecore_drm_output.c
@@ -1291,3 +1291,67 @@ ecore_drm_output_crtc_size_get(Ecore_Drm_Output *output, 
int *width, int *height
    if (width) *width = output->crtc->width;
    if (height) *height = output->crtc->height;
 }
+
+EAPI Eina_Bool
+ecore_drm_output_possible_crtc_get(Ecore_Drm_Output *output, unsigned int crtc)
+{
+   Ecore_Drm_Device *dev;
+   drmModeRes *res;
+   drmModeConnector *conn;
+   drmModeEncoder *enc;
+   int i, j;
+   unsigned int p;
+   Eina_Bool ret = EINA_FALSE;
+
+   EINA_SAFETY_ON_NULL_RETURN_VAL(output, EINA_FALSE);
+   EINA_SAFETY_ON_NULL_RETURN_VAL(output->dev, EINA_FALSE);
+
+   dev = output->dev;
+   EINA_SAFETY_ON_TRUE_RETURN_VAL(dev->drm.fd < 0, EINA_FALSE);
+
+   /* get the resources */
+   if (!(res = drmModeGetResources(dev->drm.fd)))
+     {
+        ERR("Could not get resources for drm card: %m");
+        return EINA_FALSE;
+     }
+
+   for (i = 0; i < res->count_connectors; i++)
+     {
+        /* get the connector */
+        if (!(conn = drmModeGetConnector(dev->drm.fd, res->connectors[i])))
+          continue;
+
+        for (j = 0; j < conn->count_encoders; j++)
+          {
+             /* get the encoder on this connector */
+             if (!(enc = drmModeGetEncoder(dev->drm.fd, conn->encoders[j])))
+               {
+                  WRN("Failed to get encoder: %m");
+                  continue;
+               }
+
+             /* get the encoder for given crtc */
+             if (enc->crtc_id != crtc) goto next;
+
+             p = enc->possible_crtcs;
+
+             /* Does the CRTC match the list of possible CRTCs from the 
encoder? */
+             if (p & (1 << output->crtc_id))
+               ret = EINA_TRUE;
+
+next:
+             drmModeFreeEncoder(enc);
+             if (ret) break;
+          }
+
+        /* free the connector */
+        drmModeFreeConnector(conn);
+        if (ret) break;
+     }
+
+   /* free resources */
+   drmModeFreeResources(res);
+
+   return ret;
+}

-- 


Reply via email to