1 From 6bed527fe0a4101ef214abaf2cd82609b6c510e4 Mon Sep 17 00:00:00 2001
2 From: Veeresh Kadasani <external.vkadasani@jp.adit-jv.com>
3 Date: Tue, 30 Jul 2019 20:25:34 +0900
4 Subject: [PATCH 2/2] compositor-drm: introduce drm_get_dmafd_from_view
6 This API enables to get dmafd from weston_view
8 Signed-off-by: Veeresh Kadasani <external.vkadasani@jp.adit-jv.com>
10 libweston/compositor-drm.c | 58 ++++++++++++++++++++++++++++++++++++++++++++++
11 libweston/compositor-drm.h | 7 ++++++
12 2 files changed, 65 insertions(+)
14 diff --git a/libweston/compositor-drm.c b/libweston/compositor-drm.c
15 index b83459a..5cabfb5 100644
16 --- a/libweston/compositor-drm.c
17 +++ b/libweston/compositor-drm.c
18 @@ -5849,6 +5849,64 @@ drm_output_set_seat(struct weston_output *base,
22 +drm_get_dma_fd_from_view(struct weston_output *base,
23 + struct weston_view *ev, int *buf_stride)
25 + struct drm_backend *b = to_drm_backend(base->compositor);
26 + struct weston_buffer *buffer = ev->surface->buffer_ref.buffer;
28 + struct drm_fb *current;
29 + struct linux_dmabuf_buffer *dmabuf;
30 + bool is_opaque = drm_view_is_opaque(ev);
35 + weston_log("buffer is NULL\n");
39 + if(dmabuf = linux_dmabuf_buffer_get(buffer->resource)) {
40 + current = drm_fb_get_from_dmabuf(dmabuf, b, is_opaque);
43 + fprintf(stderr, "failed to get drm_fb from dmabuf\n");
46 + *buf_stride=current->strides[0];
48 + else if(ev->surface->buffer_ref.buffer->legacy_buffer) {
49 + bo = gbm_bo_import(b->gbm, GBM_BO_IMPORT_WL_BUFFER,
50 + buffer->resource, GBM_BO_USE_SCANOUT);
52 + weston_log("failed to get gbm_bo\n");
55 + current = drm_fb_get_from_bo(bo, b, is_opaque, BUFFER_CLIENT);
58 + weston_log("failed to get drm_fb from bo\n");
61 + *buf_stride=current->strides[0];
64 + weston_log("Buffer is not supported\n");
68 + ret = drmPrimeHandleToFD(b->drm.fd, current->handles[0],
72 + weston_log("failed to create prime fd for front buffer\n");
80 drm_output_init_gamma_size(struct drm_output *output)
82 struct drm_backend *backend = to_drm_backend(output->base.compositor);
83 diff --git a/libweston/compositor-drm.h b/libweston/compositor-drm.h
84 index 71a306f..4f985d3 100644
85 --- a/libweston/compositor-drm.h
86 +++ b/libweston/compositor-drm.h
87 @@ -78,6 +78,13 @@ struct weston_drm_output_api {
89 void (*set_seat)(struct weston_output *output,
92 + /** Get the dma fd from drm view.
94 + * The dma fd is got from weston_view.
95 + * Returns fd on success, -1 on failure.
97 + int (*get_dma_fd_from_view)(struct weston_output *output, struct weston_view *view, int *buf_stride);
100 static inline const struct weston_drm_output_api *