1 From 2cb25adac6b968104bbfb276c684506607dfbff4 Mon Sep 17 00:00:00 2001
2 From: Veeresh Kadasani <external.vkadasani@jp.adit-jv.com>
3 Date: Wed, 7 Aug 2019 21:05:11 +0900
4 Subject: [PATCH 1/1] 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 | 59 ++++++++++++++++++++++++++++++++++++++++++++++
11 libweston/compositor-drm.h | 7 ++++++
12 2 files changed, 66 insertions(+)
14 diff --git a/libweston/compositor-drm.c b/libweston/compositor-drm.c
15 index b83459a..98ad85c 100644
16 --- a/libweston/compositor-drm.c
17 +++ b/libweston/compositor-drm.c
18 @@ -5848,6 +5848,64 @@ drm_output_set_seat(struct weston_output *base,
23 +drm_get_dma_fd_from_view(struct weston_output *base,
24 + struct weston_view *ev, int *buf_stride)
26 + struct drm_backend *b = to_drm_backend(base->compositor);
27 + struct weston_buffer *buffer = ev->surface->buffer_ref.buffer;
29 + struct drm_fb *current;
30 + struct linux_dmabuf_buffer *dmabuf;
31 + bool is_opaque = weston_view_is_opaque(ev,&ev->transform.boundingbox);
36 + weston_log("buffer is NULL\n");
40 + if(dmabuf = linux_dmabuf_buffer_get(buffer->resource)) {
41 + current = drm_fb_get_from_dmabuf(dmabuf, b, is_opaque);
44 + fprintf(stderr, "failed to get drm_fb from dmabuf\n");
47 + *buf_stride=current->strides[0];
49 + else if(ev->surface->buffer_ref.buffer->legacy_buffer) {
50 + bo = gbm_bo_import(b->gbm, GBM_BO_IMPORT_WL_BUFFER,
51 + buffer->resource, GBM_BO_USE_SCANOUT);
53 + weston_log("failed to get gbm_bo\n");
56 + current = drm_fb_get_from_bo(bo, b, is_opaque, BUFFER_CLIENT);
59 + weston_log("failed to get drm_fb from bo\n");
62 + *buf_stride=current->strides[0];
65 + weston_log("Buffer is not supported\n");
69 + ret = drmPrimeHandleToFD(b->drm.fd, current->handles[0],
73 + weston_log("failed to create prime fd for front buffer\n");
81 drm_output_init_gamma_size(struct drm_output *output)
83 @@ -7396,6 +7454,7 @@ static const struct weston_drm_output_api api = {
85 drm_output_set_gbm_format,
87 + drm_get_dma_fd_from_view
90 static const struct weston_drm_virtual_output_api virt_api = {
91 diff --git a/libweston/compositor-drm.h b/libweston/compositor-drm.h
92 index 71a306f..a9379e4 100644
93 --- a/libweston/compositor-drm.h
94 +++ b/libweston/compositor-drm.h
95 @@ -78,6 +78,13 @@ struct weston_drm_output_api {
97 void (*set_seat)(struct weston_output *output,
100 + /** Get the dma fd from drm view.
102 + * The dma fd is got from weston_view.
103 + * Returns fd on success, -1 on failure.
105 + int (*get_dma_fd_from_view)(struct weston_output *output, struct weston_view *view, int *buf_stride);
108 static inline const struct weston_drm_output_api *