devilhorns pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=61f40d58f7e87b2c937884cae4e2fd59f9a60882

commit 61f40d58f7e87b2c937884cae4e2fd59f9a60882
Author: Derek Foreman <der...@osg.samsung.com>
Date:   Tue Mar 21 15:44:46 2017 -0500

    ecore_drm2: Add ecore_drm2_fb_dmabuf_import
    
    Imports a set of dmabuf buffers as a single Ecore_Drm2_Fb
---
 src/lib/ecore_drm2/Ecore_Drm2.h         | 21 +++++++++++++++++++++
 src/lib/ecore_drm2/ecore_drm2.c         |  2 ++
 src/lib/ecore_drm2/ecore_drm2_fb.c      | 26 ++++++++++++++++++++++++++
 src/lib/ecore_drm2/ecore_drm2_private.h |  1 +
 4 files changed, 50 insertions(+)

diff --git a/src/lib/ecore_drm2/Ecore_Drm2.h b/src/lib/ecore_drm2/Ecore_Drm2.h
index 87d7b40..8a10104 100644
--- a/src/lib/ecore_drm2/Ecore_Drm2.h
+++ b/src/lib/ecore_drm2/Ecore_Drm2.h
@@ -964,6 +964,27 @@ EAPI void 
ecore_drm2_output_release_handler_set(Ecore_Drm2_Output *output, Ecore
  */
 EAPI void *ecore_drm2_fb_bo_get(Ecore_Drm2_Fb *fb);
 
+/**
+ * Import a dmabuf object as a Framebuffer
+ *
+ * @param fd
+ * @param width
+ * @param height
+ * @param depth
+ * @param bpp
+ * @param format
+ * @param stride
+ * @param dmabuf_fd
+ * @param dmabuf_fd_count
+ *
+ * @return A newly created framebuffer object, or NULL on failure
+ *
+ * @ingroup Ecore_Drm2_Fb_Group
+ * @since 1.20
+ *
+ */
+EAPI Ecore_Drm2_Fb *ecore_drm2_fb_dmabuf_import(int fd, int width, int height, 
int depth, int bpp, unsigned int format, unsigned int strides[4], int 
dmabuf_fd[4], int dmabuf_fd_count);
+
 # endif
 
 #endif
diff --git a/src/lib/ecore_drm2/ecore_drm2.c b/src/lib/ecore_drm2/ecore_drm2.c
index d3de6f3..7eec270 100644
--- a/src/lib/ecore_drm2/ecore_drm2.c
+++ b/src/lib/ecore_drm2/ecore_drm2.c
@@ -46,6 +46,7 @@ int (*sym_drmModeRmFB)(int fd, uint32_t bufferId) = NULL;
 int (*sym_drmModePageFlip)(int fd, uint32_t crtc_id, uint32_t fb_id, uint32_t 
flags, void *user_data) = NULL;
 int (*sym_drmModeDirtyFB)(int fd, uint32_t bufferId, drmModeClipPtr clips, 
uint32_t num_clips) = NULL;
 int (*sym_drmModeCrtcSetGamma)(int fd, uint32_t crtc_id, uint32_t size, 
uint16_t *red, uint16_t *green, uint16_t *blue) = NULL;
+int (*sym_drmPrimeFDToHandle)(int fd, int prime_fd, uint32_t *handle) = NULL;
 
 EAPI int ECORE_DRM2_EVENT_OUTPUT_CHANGED = -1;
 EAPI int ECORE_DRM2_EVENT_ACTIVATE = -1;
@@ -123,6 +124,7 @@ _ecore_drm2_link(void)
         SYM(drm_lib, drmModePageFlip);
         SYM(drm_lib, drmModeDirtyFB);
         SYM(drm_lib, drmModeCrtcSetGamma);
+        SYM(drm_lib, drmPrimeFDToHandle);
 
         if (fail)
           {
diff --git a/src/lib/ecore_drm2/ecore_drm2_fb.c 
b/src/lib/ecore_drm2/ecore_drm2_fb.c
index 090c998..be75760 100644
--- a/src/lib/ecore_drm2/ecore_drm2_fb.c
+++ b/src/lib/ecore_drm2/ecore_drm2_fb.c
@@ -522,3 +522,29 @@ ecore_drm2_fb_bo_get(Ecore_Drm2_Fb *fb)
    EINA_SAFETY_ON_NULL_RETURN_VAL(fb, NULL);
    return fb->gbm_bo;
 }
+
+EAPI Ecore_Drm2_Fb *
+ecore_drm2_fb_dmabuf_import(int fd, int width, int height, int depth, int bpp, 
unsigned int format, unsigned int strides[4], int dmabuf_fd[4], int 
dmabuf_fd_count)
+{
+   int i;
+   Ecore_Drm2_Fb *fb;
+
+   fb = calloc(1, sizeof(Ecore_Drm2_Fb));
+   if (!fb) return NULL;
+
+   for (i = 0; i < dmabuf_fd_count; i++)
+     if (sym_drmPrimeFDToHandle(fd, dmabuf_fd[i], &fb->handles[i])) goto fail;
+
+   fb->fd = fd;
+   fb->w = width;
+   fb->h = height;
+   fb->bpp = bpp;
+   fb->depth = depth;
+   fb->format = format;
+   memcpy(&fb->strides, strides, sizeof(fb->strides));
+   if (_fb2_create(fb)) return fb;
+
+fail:
+   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 2f89a3d..a9423df 100644
--- a/src/lib/ecore_drm2/ecore_drm2_private.h
+++ b/src/lib/ecore_drm2/ecore_drm2_private.h
@@ -836,5 +836,6 @@ extern int (*sym_drmModeRmFB)(int fd, uint32_t bufferId);
 extern int (*sym_drmModePageFlip)(int fd, uint32_t crtc_id, uint32_t fb_id, 
uint32_t flags, void *user_data);
 extern int (*sym_drmModeDirtyFB)(int fd, uint32_t bufferId, drmModeClipPtr 
clips, uint32_t num_clips);
 extern int (*sym_drmModeCrtcSetGamma)(int fd, uint32_t crtc_id, uint32_t size, 
uint16_t *red, uint16_t *green, uint16_t *blue);
+extern int (*sym_drmPrimeFDToHandle)(int fd, int prime_fd, uint32_t *handle);
 
 #endif

-- 


Reply via email to