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 a1eb6b98054908a05793a4cbe633d78af8ae28d7
Author: Christopher Michael <devilho...@comcast.net>
AuthorDate: Mon Aug 25 08:22:00 2025 -0500

    ecore_drm2: Add APIs for framebuffer destroy, unmap, and map get
    
    This patch adds new API functions for framebuffers. They include
    destroying a framebuffer, unmapping a framebuffer, and retrieving the
    framebuffers mapped data.
---
 src/lib/ecore_drm2/Ecore_Drm2.h         |  3 ++
 src/lib/ecore_drm2/ecore_drm2_fb.c      | 58 ++++++++++++++++++++++++++-------
 src/lib/ecore_drm2/ecore_drm2_private.h |  3 ++
 3 files changed, 52 insertions(+), 12 deletions(-)

diff --git a/src/lib/ecore_drm2/Ecore_Drm2.h b/src/lib/ecore_drm2/Ecore_Drm2.h
index 99f66d1837..c0466efa49 100644
--- a/src/lib/ecore_drm2/Ecore_Drm2.h
+++ b/src/lib/ecore_drm2/Ecore_Drm2.h
@@ -142,6 +142,9 @@ EAPI void *ecore_drm2_fb_data_get(Ecore_Drm2_Fb *fb, int *bpl);
 EAPI unsigned int ecore_drm2_fb_size_get(Ecore_Drm2_Fb *fb);
 EAPI unsigned int ecore_drm2_fb_stride_get(Ecore_Drm2_Fb *fb);
 EAPI Eina_Bool ecore_drm2_fb_map(Ecore_Drm2_Fb *fb);
+EAPI void ecore_drm2_fb_destroy(Ecore_Drm2_Fb *fb);
+EAPI void *ecore_drm2_fb_map_get(Ecore_Drm2_Fb *fb);
+EAPI void ecore_drm2_fb_unmap(Ecore_Drm2_Fb *fb);
 
 # endif
 
diff --git a/src/lib/ecore_drm2/ecore_drm2_fb.c b/src/lib/ecore_drm2/ecore_drm2_fb.c
index 55c23fda7d..c52752fc55 100644
--- a/src/lib/ecore_drm2/ecore_drm2_fb.c
+++ b/src/lib/ecore_drm2/ecore_drm2_fb.c
@@ -16,6 +16,8 @@ _ecore_drm2_fb_add(Ecore_Drm2_Fb *fb)
 static Eina_Bool
 _ecore_drm2_fb_map(Ecore_Drm2_Fb *fb)
 {
+   if (fb->mapped) return EINA_TRUE;
+
    if (!fb->bo)
      {
         struct drm_mode_map_dumb marg;
@@ -39,11 +41,9 @@ _ecore_drm2_fb_map(Ecore_Drm2_Fb *fb)
      }
    else
      {
-        void *map_data = NULL;
-
         fb->mmap =
           gbm_bo_map(fb->bo, 0, 0, fb->w, fb->h,
-                     GBM_BO_TRANSFER_READ_WRITE, NULL, &map_data);
+                     GBM_BO_TRANSFER_READ_WRITE, NULL, &fb->map_data);
         if (!fb->mmap)
           {
              ERR("Could not map Framebuffer Bo: %m");
@@ -51,9 +51,25 @@ _ecore_drm2_fb_map(Ecore_Drm2_Fb *fb)
           }
      }
 
+   fb->mapped = EINA_TRUE;
    return EINA_TRUE;
 }
 
+static void
+_ecore_drm2_fb_unmap(Ecore_Drm2_Fb *fb)
+{
+   if (!fb->mapped) return;
+
+   if (!fb->bo)
+     munmap(fb->mmap, fb->sizes[0]);
+   else
+     gbm_bo_unmap(fb->bo, fb->map_data);
+
+   fb->mmap = NULL;
+   fb->map_data = NULL;
+   fb->mapped = EINA_FALSE;
+}
+
 EAPI Ecore_Drm2_Fb *
 ecore_drm2_fb_create(Ecore_Drm2_Device *dev, int width, int height, int depth, int bpp, unsigned int format, void *bo)
 {
@@ -109,16 +125,8 @@ ecore_drm2_fb_create(Ecore_Drm2_Device *dev, int width, int height, int depth, i
 	  }
      }
 
-   if (!_ecore_drm2_fb_map(fb))
-     {
-        ERR("Could not map Framebuffer");
-        goto map_err;
-     }
-
    return fb;
 
-map_err:
-   sym_drmModeRmFB(dev->fd, fb->id);
 add_err:
    if (!fb->bo)
      {
@@ -170,7 +178,7 @@ ecore_drm2_fb_data_get(Ecore_Drm2_Fb *fb, int *bpl)
           *bpl = (fb->bpp * fb->w);
      }
 
-   return fb->mmap;
+   return ecore_drm2_fb_map_get(fb);
 }
 
 EAPI unsigned int
@@ -196,3 +204,29 @@ ecore_drm2_fb_map(Ecore_Drm2_Fb *fb)
    EINA_SAFETY_ON_NULL_RETURN_VAL(fb, EINA_FALSE);
    return _ecore_drm2_fb_map(fb);
 }
+
+EAPI void
+ecore_drm2_fb_destroy(Ecore_Drm2_Fb *fb)
+{
+   EINA_SAFETY_ON_NULL_RETURN(fb);
+   _ecore_drm2_fb_unmap(fb);
+   free(fb);
+}
+
+EAPI void *
+ecore_drm2_fb_map_get(Ecore_Drm2_Fb *fb)
+{
+   EINA_SAFETY_ON_NULL_RETURN_VAL(fb, NULL);
+
+   if (fb->bo)
+     return fb->map_data;
+   else
+     return fb->mmap;
+}
+
+EAPI void
+ecore_drm2_fb_unmap(Ecore_Drm2_Fb *fb)
+{
+   EINA_SAFETY_ON_NULL_RETURN(fb);
+   _ecore_drm2_fb_unmap(fb);
+}
diff --git a/src/lib/ecore_drm2/ecore_drm2_private.h b/src/lib/ecore_drm2/ecore_drm2_private.h
index 06e8cd2b5f..215554fcce 100644
--- a/src/lib/ecore_drm2/ecore_drm2_private.h
+++ b/src/lib/ecore_drm2/ecore_drm2_private.h
@@ -239,6 +239,9 @@ struct _Ecore_Drm2_Fb
    uint32_t strides[4], sizes[4];
 
    void *mmap, *bo;
+   void *map_data;
+
+   Eina_Bool mapped : 1;
 };
 
 struct _Ecore_Drm2_Plane

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

Reply via email to