[PATCH weston v2 7/8] compositor-drm: dmabuf GBM import
Pekka Paalanen
ppaalanen at gmail.com
Wed Jul 1 07:56:19 PDT 2015
From: Pekka Paalanen <pekka.paalanen at collabora.co.uk>
v2:
- add TODO note about multi-planar import and how we should do it
Signed-off-by: Pekka Paalanen <pekka.paalanen at collabora.co.uk>
Reviewed-by: Daniel Stone <daniels at collabora.com>
---
src/compositor-drm.c | 33 +++++++++++++++++++++++++++++----
1 file changed, 29 insertions(+), 4 deletions(-)
diff --git a/src/compositor-drm.c b/src/compositor-drm.c
index 59d869c..9788746 100644
--- a/src/compositor-drm.c
+++ b/src/compositor-drm.c
@@ -874,7 +874,9 @@ drm_output_prepare_overlay_view(struct drm_output *output,
struct weston_compositor *ec = output->base.compositor;
struct drm_compositor *c = (struct drm_compositor *)ec;
struct weston_buffer_viewport *viewport = &ev->surface->buffer_viewport;
+ struct wl_resource *buffer_resource;
struct drm_sprite *s;
+ struct linux_dmabuf_buffer *dmabuf;
int found = 0;
struct gbm_bo *bo;
pixman_region32_t dest_rect, src_rect;
@@ -899,11 +901,12 @@ drm_output_prepare_overlay_view(struct drm_output *output,
if (ev->surface->buffer_ref.buffer == NULL)
return NULL;
+ buffer_resource = ev->surface->buffer_ref.buffer->resource;
if (ev->alpha != 1.0f)
return NULL;
- if (wl_shm_buffer_get(ev->surface->buffer_ref.buffer->resource))
+ if (wl_shm_buffer_get(buffer_resource))
return NULL;
if (!drm_view_transform_supported(ev))
@@ -923,9 +926,31 @@ drm_output_prepare_overlay_view(struct drm_output *output,
if (!found)
return NULL;
- bo = gbm_bo_import(c->gbm, GBM_BO_IMPORT_WL_BUFFER,
- ev->surface->buffer_ref.buffer->resource,
- GBM_BO_USE_SCANOUT);
+ if ((dmabuf = linux_dmabuf_buffer_get(buffer_resource))) {
+ /* XXX: TODO:
+ *
+ * Use AddFB2 directly, do not go via GBM.
+ * Add support for multiplanar formats.
+ * Both require refactoring in the DRM-backend to
+ * support a mix of gbm_bos and drmfbs.
+ */
+ struct gbm_import_fd_data gbm_dmabuf = {
+ .fd = dmabuf->dmabuf_fd[0],
+ .width = dmabuf->width,
+ .height = dmabuf->height,
+ .stride = dmabuf->stride[0],
+ .format = dmabuf->format
+ };
+
+ if (dmabuf->n_planes != 1 || dmabuf->offset[0] != 0)
+ return NULL;
+
+ bo = gbm_bo_import(c->gbm, GBM_BO_IMPORT_FD, &gbm_dmabuf,
+ GBM_BO_USE_SCANOUT);
+ } else {
+ bo = gbm_bo_import(c->gbm, GBM_BO_IMPORT_WL_BUFFER,
+ buffer_resource, GBM_BO_USE_SCANOUT);
+ }
if (!bo)
return NULL;
--
2.3.6
More information about the wayland-devel
mailing list