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 1a5c0a6266e5f6e335a3bfa147ca8956d649bbab
Author: Christopher Michael <devilho...@comcast.net>
AuthorDate: Sat Aug 23 09:51:15 2025 -0500

    ecore_drm2: Add an API for mapping a framebuffer
    
    Small patch to add a new API for mapping a framebuffer. This will map
    either dumb buffers or gbm buffers
---
 src/lib/ecore_drm2/Ecore_Drm2.h    |  1 +
 src/lib/ecore_drm2/ecore_drm2_fb.c | 60 +++++++++++++++++++++++++-------------
 2 files changed, 41 insertions(+), 20 deletions(-)

diff --git a/src/lib/ecore_drm2/Ecore_Drm2.h b/src/lib/ecore_drm2/Ecore_Drm2.h
index 28244652b9..99f66d1837 100644
--- a/src/lib/ecore_drm2/Ecore_Drm2.h
+++ b/src/lib/ecore_drm2/Ecore_Drm2.h
@@ -141,6 +141,7 @@ EAPI void ecore_drm2_fb_dirty(Ecore_Drm2_Fb *fb, Eina_Rectangle *rects, unsigned
 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);
 
 # endif
 
diff --git a/src/lib/ecore_drm2/ecore_drm2_fb.c b/src/lib/ecore_drm2/ecore_drm2_fb.c
index acf015ee0e..16df8ccd10 100644
--- a/src/lib/ecore_drm2/ecore_drm2_fb.c
+++ b/src/lib/ecore_drm2/ecore_drm2_fb.c
@@ -16,23 +16,39 @@ _ecore_drm2_fb_add(Ecore_Drm2_Fb *fb)
 static Eina_Bool
 _ecore_drm2_fb_map(Ecore_Drm2_Fb *fb)
 {
-   struct drm_mode_map_dumb marg;
-   int ret;
-
-   memset(&marg, 0, sizeof(struct drm_mode_map_dumb));
-   marg.handle = fb->handles[0];
-   ret = sym_drmIoctl(fb->fd, DRM_IOCTL_MODE_MAP_DUMB, &marg);
-   if (ret)
+   if (!fb->bo)
      {
-	ERR("Could not map Framebuffer: %m");
-	return EINA_FALSE;
+        struct drm_mode_map_dumb marg;
+        int ret;
+
+        memset(&marg, 0, sizeof(struct drm_mode_map_dumb));
+        marg.handle = fb->handles[0];
+        ret = sym_drmIoctl(fb->fd, DRM_IOCTL_MODE_MAP_DUMB, &marg);
+        if (ret)
+          {
+             ERR("Could not map Framebuffer: %m");
+             return EINA_FALSE;
+          }
+
+        fb->mmap = mmap(NULL, fb->sizes[0], PROT_WRITE, MAP_SHARED, fb->fd, marg.offset);
+        if (fb->mmap == MAP_FAILED)
+          {
+             ERR("Could not map Framebuffer: %m");
+             return EINA_FALSE;
+          }
      }
-
-   fb->mmap = mmap(NULL, fb->sizes[0], PROT_WRITE, MAP_SHARED, fb->fd, marg.offset);
-   if (fb->mmap == MAP_FAILED)
+   else
      {
-	ERR("Could not map Framebuffer: %m");
-	return EINA_FALSE;
+        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);
+        if (!fb->mmap)
+          {
+             ERR("Could not map Framebuffer Bo: %m");
+             return EINA_FALSE;
+          }
      }
 
    return EINA_TRUE;
@@ -93,13 +109,10 @@ ecore_drm2_fb_create(Ecore_Drm2_Device *dev, int width, int height, int depth, i
 	  }
      }
 
-   if (!fb->bo)
+   if (!_ecore_drm2_fb_map(fb))
      {
-	if (!_ecore_drm2_fb_map(fb))
-	  {
-	     ERR("Could not map Framebuffer");
-	     goto map_err;
-	  }
+        ERR("Could not map Framebuffer");
+        goto map_err;
      }
 
    return fb;
@@ -173,3 +186,10 @@ ecore_drm2_fb_stride_get(Ecore_Drm2_Fb *fb)
    EINA_SAFETY_ON_NULL_RETURN_VAL(fb, 0);
    return fb->strides[0];
 }
+
+EAPI Eina_Bool
+ecore_drm2_fb_map(Ecore_Drm2_Fb *fb)
+{
+   EINA_SAFETY_ON_NULL_RETURN_VAL(fb, EINA_FALSE);
+   return _ecore_drm2_fb_map(fb);
+}

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

Reply via email to