summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDerek Foreman <derekf@osg.samsung.com>2017-03-21 15:44:46 -0500
committerDerek Foreman <derekf@osg.samsung.com>2017-03-21 15:44:46 -0500
commit993ca7998a0efd0a941601c6e53ebe54feb6dcd7 (patch)
treecb14b34e1ffb9e5d42a0014b44b4da6351f30de5
parent1c52b46b9597b0aae3fef74a40dc7822d56213b6 (diff)
downloadefl-devs/derekf/import_dmabuf.tar.gz
ecore_drm2: Add ecore_drm2_fb_dmabuf_importdevs/derekf/import_dmabuf
Imports a set of dmabuf buffers as a single Ecore_Drm2_Fb
-rw-r--r--src/lib/ecore_drm2/Ecore_Drm2.h21
-rw-r--r--src/lib/ecore_drm2/ecore_drm2.c2
-rw-r--r--src/lib/ecore_drm2/ecore_drm2_fb.c26
-rw-r--r--src/lib/ecore_drm2/ecore_drm2_private.h1
4 files changed, 50 insertions, 0 deletions
diff --git a/src/lib/ecore_drm2/Ecore_Drm2.h b/src/lib/ecore_drm2/Ecore_Drm2.h
index 87d7b404b1..8a10104fea 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 e8c4d5b578..5713ba1a97 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 090c998d45..be75760765 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 879674ac1f..e82e8d50a1 100644
--- a/src/lib/ecore_drm2/ecore_drm2_private.h
+++ b/src/lib/ecore_drm2/ecore_drm2_private.h
@@ -838,5 +838,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