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 18cfd50d440265a2d6f84b320bcf2602cda72199
Author: Christopher Michael <devilho...@comcast.net>
AuthorDate: Wed Oct 9 14:39:08 2024 -0400

    ecore_drm2: Modify ecore_drm2_fb_create function to take an optional
    gbm bo
    
    Current usage in the evas gl_drm engine passes in a gbm bo when
    creating the framebuffer. As such, let's modify the
    ecore_drm2_fb_create API to take an optional bo
---
 src/lib/ecore_drm2/Ecore_Drm2.h         |  2 +-
 src/lib/ecore_drm2/ecore_drm2_fb.c      | 52 ++++++++++++++++++++++-----------
 src/lib/ecore_drm2/ecore_drm2_private.h |  2 +-
 src/lib/ecore_drm2/meson.build          |  2 +-
 4 files changed, 38 insertions(+), 20 deletions(-)

diff --git a/src/lib/ecore_drm2/Ecore_Drm2.h b/src/lib/ecore_drm2/Ecore_Drm2.h
index 71db469fed..3fdb4ea79e 100644
--- a/src/lib/ecore_drm2/Ecore_Drm2.h
+++ b/src/lib/ecore_drm2/Ecore_Drm2.h
@@ -125,7 +125,7 @@ EAPI void *ecore_drm2_display_user_data_get(Ecore_Drm2_Display *disp);
 EAPI Eina_Bool ecore_drm2_display_blanktime_get(Ecore_Drm2_Display *disp, int seq, long *sec, long *usec);
 
 /* Framebuffer API functions */
-EAPI Ecore_Drm2_Fb *ecore_drm2_fb_create(Ecore_Drm2_Device *dev, int width, int height, int depth, int bpp, unsigned int format);
+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);
 EAPI void ecore_drm2_fb_dirty(Ecore_Drm2_Fb *fb, Eina_Rectangle *rects, unsigned int count);
 EAPI void *ecore_drm2_fb_data_get(Ecore_Drm2_Fb *fb);
 EAPI unsigned int ecore_drm2_fb_size_get(Ecore_Drm2_Fb *fb);
diff --git a/src/lib/ecore_drm2/ecore_drm2_fb.c b/src/lib/ecore_drm2/ecore_drm2_fb.c
index c89e9d24ec..8b30e59dfd 100644
--- a/src/lib/ecore_drm2/ecore_drm2_fb.c
+++ b/src/lib/ecore_drm2/ecore_drm2_fb.c
@@ -1,4 +1,5 @@
 #include "ecore_drm2_private.h"
+#include <gbm.h>
 
 static Eina_Bool
 _ecore_drm2_fb_add(Ecore_Drm2_Fb *fb)
@@ -38,10 +39,9 @@ _ecore_drm2_fb_map(Ecore_Drm2_Fb *fb)
 }
 
 EAPI Ecore_Drm2_Fb *
-ecore_drm2_fb_create(Ecore_Drm2_Device *dev, int width, int height, int depth, int bpp, unsigned int format)
+ecore_drm2_fb_create(Ecore_Drm2_Device *dev, int width, int height, int depth, int bpp, unsigned int format, void *bo)
 {
    Ecore_Drm2_Fb *fb;
-   struct drm_mode_create_dumb carg;
    struct drm_mode_destroy_dumb darg;
    int ret;
 
@@ -56,18 +56,30 @@ ecore_drm2_fb_create(Ecore_Drm2_Device *dev, int width, int height, int depth, i
    fb->bpp = bpp;
    fb->depth = depth;
    fb->format = format;
+   fb->bo = bo;
 
-   memset(&carg, 0, sizeof(struct drm_mode_create_dumb));
-   carg.bpp = bpp;
-   carg.width = width;
-   carg.height = height;
+   if (!fb->bo)
+     {
+	struct drm_mode_create_dumb carg;
 
-   ret = sym_drmIoctl(dev->fd, DRM_IOCTL_MODE_CREATE_DUMB, &carg);
-   if (!ret) goto err;
+	memset(&carg, 0, sizeof(struct drm_mode_create_dumb));
+	carg.bpp = bpp;
+	carg.width = width;
+	carg.height = height;
 
-   fb->handles[0] = carg.handle;
-   fb->sizes[0] = carg.size;
-   fb->strides[0] = carg.pitch;
+	ret = sym_drmIoctl(dev->fd, DRM_IOCTL_MODE_CREATE_DUMB, &carg);
+	if (!ret) goto err;
+
+	fb->handles[0] = carg.handle;
+	fb->strides[0] = carg.pitch;
+	fb->sizes[0] = carg.size;
+     }
+   else
+     {
+	fb->handles[0] = gbm_bo_get_handle(fb->bo).u32;
+	fb->strides[0] = gbm_bo_get_stride(fb->bo);
+	fb->sizes[0] = fb->strides[0] * fb->h;
+     }
 
    if (!_ecore_drm2_fb_add(fb))
      {
@@ -81,10 +93,13 @@ ecore_drm2_fb_create(Ecore_Drm2_Device *dev, int width, int height, int depth, i
 	  }
      }
 
-   if (!_ecore_drm2_fb_map(fb))
+   if (!fb->bo)
      {
-	ERR("Could not map Framebuffer");
-	goto map_err;
+	if (!_ecore_drm2_fb_map(fb))
+	  {
+	     ERR("Could not map Framebuffer");
+	     goto map_err;
+	  }
      }
 
    return fb;
@@ -92,9 +107,12 @@ ecore_drm2_fb_create(Ecore_Drm2_Device *dev, int width, int height, int depth, i
 map_err:
    sym_drmModeRmFB(dev->fd, fb->id);
 add_err:
-   memset(&darg, 0, sizeof(struct drm_mode_destroy_dumb));
-   darg.handle = fb->handles[0];
-   sym_drmIoctl(dev->fd, DRM_IOCTL_MODE_DESTROY_DUMB, &darg);
+   if (!fb->bo)
+     {
+	memset(&darg, 0, sizeof(struct drm_mode_destroy_dumb));
+	darg.handle = fb->handles[0];
+	sym_drmIoctl(dev->fd, DRM_IOCTL_MODE_DESTROY_DUMB, &darg);
+     }
 err:
    free(fb);
    return NULL;
diff --git a/src/lib/ecore_drm2/ecore_drm2_private.h b/src/lib/ecore_drm2/ecore_drm2_private.h
index e976e2c507..daa9fcc52a 100644
--- a/src/lib/ecore_drm2/ecore_drm2_private.h
+++ b/src/lib/ecore_drm2/ecore_drm2_private.h
@@ -224,7 +224,7 @@ struct _Ecore_Drm2_Fb
    uint32_t id, handles[4];
    uint32_t strides[4], sizes[4];
 
-   void *mmap;
+   void *mmap, *bo;
 };
 
 struct _Ecore_Drm2_Plane
diff --git a/src/lib/ecore_drm2/meson.build b/src/lib/ecore_drm2/meson.build
index eecd058d08..cfc83892a5 100644
--- a/src/lib/ecore_drm2/meson.build
+++ b/src/lib/ecore_drm2/meson.build
@@ -1,4 +1,4 @@
-ecore_drm2_deps = [eeze, elput]
+ecore_drm2_deps = [eeze, elput, dependency('gbm')]
 ecore_drm2_pub_deps = [ecore]
 ecore_drm2_ext_deps = [dl, libdrm]
 

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

Reply via email to