This is an automated email from the git hooks/post-receive script.

git pushed a commit to branch devs/devilhorns/apos
in repository efl.

View the commit online.

commit 62f4745cbfd404d096aefc9c97b5238e6897157e
Author: Christopher Michael <devilho...@comcast.net>
AuthorDate: Sat Aug 9 08:27:18 2025 -0500

    ecore_drm2: Rework _ecore_drm2_planes_find to be more generic and add
    a function to check if a plane is actually available for use
---
 src/lib/ecore_drm2/ecore_drm2_displays.c | 12 ++---
 src/lib/ecore_drm2/ecore_drm2_planes.c   | 78 +++++++++++++++-----------------
 src/lib/ecore_drm2/ecore_drm2_private.h  |  6 ++-
 3 files changed, 44 insertions(+), 52 deletions(-)

diff --git a/src/lib/ecore_drm2/ecore_drm2_displays.c b/src/lib/ecore_drm2/ecore_drm2_displays.c
index 9b2c05cb23..346abe3c10 100644
--- a/src/lib/ecore_drm2/ecore_drm2_displays.c
+++ b/src/lib/ecore_drm2/ecore_drm2_displays.c
@@ -355,8 +355,7 @@ _ecore_drm2_display_rotation_get(Ecore_Drm2_Display *disp)
    if (!plane)
      {
         /* try to find primary plane for this display */
-        plane = _ecore_drm2_planes_find(disp->dev, disp->crtc->id,
-                                        DRM_PLANE_TYPE_PRIMARY);
+        plane = _ecore_drm2_planes_find(disp, DRM_PLANE_TYPE_PRIMARY);
      }
 
    if (!plane) return;
@@ -577,8 +576,7 @@ _ecore_drm2_displays_planes_init(Ecore_Drm2_Display *disp)
    if (!disp->planes.primary)
      {
         disp->planes.primary =
-          _ecore_drm2_planes_find(disp->dev, disp->crtc->id,
-                                  DRM_PLANE_TYPE_PRIMARY);
+          _ecore_drm2_planes_find(disp, DRM_PLANE_TYPE_PRIMARY);
      }
 
    if (!disp->planes.overlay)
@@ -589,8 +587,7 @@ _ecore_drm2_displays_planes_init(Ecore_Drm2_Display *disp)
    if (!disp->planes.cursor)
      {
         disp->planes.cursor =
-          _ecore_drm2_planes_find(disp->dev, disp->crtc->id,
-                                  DRM_PLANE_TYPE_CURSOR);
+          _ecore_drm2_planes_find(disp, DRM_PLANE_TYPE_CURSOR);
      }
 
    disp->dev->hw_cursor = (disp->planes.cursor != NULL);
@@ -1117,8 +1114,7 @@ ecore_drm2_display_supported_rotations_get(Ecore_Drm2_Display *disp)
    if (!plane)
      {
         /* get the primary plane for this output */
-        plane = _ecore_drm2_planes_find(disp->dev, disp->crtc->id,
-                                        DRM_PLANE_TYPE_PRIMARY);
+        plane = _ecore_drm2_planes_find(disp, DRM_PLANE_TYPE_PRIMARY);
         if (!plane) return -1;
      }
 
diff --git a/src/lib/ecore_drm2/ecore_drm2_planes.c b/src/lib/ecore_drm2/ecore_drm2_planes.c
index 7966cc80aa..c0898cf810 100644
--- a/src/lib/ecore_drm2/ecore_drm2_planes.c
+++ b/src/lib/ecore_drm2/ecore_drm2_planes.c
@@ -273,6 +273,18 @@ _ecore_drm2_plane_create(Ecore_Drm2_Device *dev, drmModePlanePtr p, uint32_t ind
    return plane;
 }
 
+static Eina_Bool
+_ecore_drm2_planes_available(Ecore_Drm2_Plane *plane, Ecore_Drm2_Display *disp)
+{
+   if (!plane->state.current) return EINA_FALSE;
+
+   if (!plane->state.current->complete) return EINA_FALSE;
+
+   if (plane->state.current->cid.value != disp->crtc->id) return EINA_FALSE;
+
+   return !!(plane->possible_crtcs & (1 << disp->crtc->pipe));
+}
+
 Eina_Bool
 _ecore_drm2_planes_create(Ecore_Drm2_Device *dev)
 {
@@ -338,60 +350,42 @@ _ecore_drm2_planes_destroy(Ecore_Drm2_Device *dev)
 }
 
 Ecore_Drm2_Plane *
-_ecore_drm2_planes_find(Ecore_Drm2_Device *dev, unsigned int crtc_id, uint64_t type)
+_ecore_drm2_planes_find(Ecore_Drm2_Display *disp, uint64_t type)
 {
-   drmModeObjectPropertiesPtr oprops;
+   Ecore_Drm2_Device *dev;
+   Ecore_Drm2_Display *dsp;
    Ecore_Drm2_Plane *plane;
-   Eina_List *l;
-   unsigned int i = 0;
+   Eina_List *l, *ll;
 
+   dev = disp->dev;
    if (!dev) return NULL;
 
+   /* NB: may need to fix this to check that plane state has been filled */
    EINA_LIST_FOREACH(dev->planes, l, plane)
      {
-        Ecore_Drm2_Plane_State *pstate;
+        Eina_Bool found = EINA_FALSE;
 
-        pstate = plane->state.current;
-        if (pstate)
+        if (plane->state.current->type.value != type) continue;
+        if (!_ecore_drm2_planes_available(plane, disp)) continue;
+
+        EINA_LIST_FOREACH(dev->displays, ll, dsp)
           {
-             if (pstate->type.value != type) continue;
-             if (pstate->cid.value != crtc_id) continue;
-             return plane;
-          }
-        else
-          {
-             uint64_t cid = 0, ptype = 0;
-
-             /* We need to manually query plane properties here as
-              * plane->state.current may not be filled yet due to threading */
-             oprops =
-               sym_drmModeObjectGetProperties(plane->fd,
-                                              plane->drmPlane->plane_id,
-                                              DRM_MODE_OBJECT_PLANE);
-             if (!oprops) continue;
-
-             for (i = 0; i < oprops->count_props; i++)
+             if ((dsp->planes.cursor == plane) ||
+                 (dsp->planes.primary == plane))
                {
-                  drmModePropertyPtr prop;
-
-                  prop = sym_drmModeGetProperty(plane->fd, oprops->props[i]);
-                  if (!prop) continue;
-
-                  if (!strcmp(prop->name, "CRTC_ID"))
-                    cid = oprops->prop_values[i];
-                  else if (!strcmp(prop->name, "type"))
-                    ptype = oprops->prop_values[i];
-
-                  sym_drmModeFreeProperty(prop);
+                  found = EINA_TRUE;
+                  break;
                }
-
-             sym_drmModeFreeObjectProperties(oprops);
-
-             if (ptype != type) continue;
-             if (cid != crtc_id) continue;
-
-             return plane;
           }
+
+        if (found) continue;
+
+        if ((type == DRM_PLANE_TYPE_PRIMARY) && (plane->crtc_id != 0) &&
+            (plane->crtc_id != disp->crtc->id))
+          continue;
+
+        plane->possible_crtcs = (1 << disp->crtc->pipe);
+        return plane;
      }
 
    return NULL;
diff --git a/src/lib/ecore_drm2/ecore_drm2_private.h b/src/lib/ecore_drm2/ecore_drm2_private.h
index ef49426151..55ac1720a3 100644
--- a/src/lib/ecore_drm2/ecore_drm2_private.h
+++ b/src/lib/ecore_drm2/ecore_drm2_private.h
@@ -192,6 +192,7 @@ typedef struct _Ecore_Drm2_Plane_State
    uint32_t rotation_map[6];
    uint32_t supported_rotations;
 
+   Eina_Bool complete : 1;
    Eina_Bool in_use : 1;
 } Ecore_Drm2_Plane_State;
 
@@ -232,7 +233,8 @@ struct _Ecore_Drm2_Fb
 struct _Ecore_Drm2_Plane
 {
    int fd;
-   uint32_t id;
+   uint32_t id, crtc_id;
+   uint32_t possible_crtcs;
 
    drmModePlanePtr drmPlane;
 
@@ -394,7 +396,7 @@ void _ecore_drm2_displays_destroy(Ecore_Drm2_Device *dev);
 
 Eina_Bool _ecore_drm2_planes_create(Ecore_Drm2_Device *dev);
 void _ecore_drm2_planes_destroy(Ecore_Drm2_Device *dev);
-Ecore_Drm2_Plane *_ecore_drm2_planes_find(Ecore_Drm2_Device *dev, unsigned int crtc_id, uint64_t type);
+Ecore_Drm2_Plane *_ecore_drm2_planes_find(Ecore_Drm2_Display *disp, uint64_t type);
 
 /* external drm function prototypes (for dlopen) */
 extern int (*sym_drmIoctl)(int fd, unsigned long request, void *arg);

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.

Reply via email to