weston_8.0.%.bbappend: Remove unused patch
[AGL/meta-agl.git] / meta-agl-profile-graphical / recipes-graphics / wayland / weston / 0003-compositor-drm-introduce-drm_get_dmafd_from_view.patch
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
5
6 This API enables to get dmafd from weston_view
7
8 Signed-off-by: Veeresh Kadasani <external.vkadasani@jp.adit-jv.com>
9 ---
10  libweston/compositor-drm.c | 59 ++++++++++++++++++++++++++++++++++++++++++++++
11  libweston/compositor-drm.h |  7 ++++++
12  2 files changed, 66 insertions(+)
13
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,
19                                      seat ? seat : "");
20  }
21  
22 + static int
23 +drm_get_dma_fd_from_view(struct weston_output *base,
24 +                          struct weston_view *ev, int *buf_stride)
25 +{
26 +       struct drm_backend *b = to_drm_backend(base->compositor);
27 +       struct weston_buffer *buffer = ev->surface->buffer_ref.buffer;
28 +       struct gbm_bo *bo;
29 +       struct drm_fb *current;
30 +       struct linux_dmabuf_buffer *dmabuf;
31 +       bool is_opaque = weston_view_is_opaque(ev,&ev->transform.boundingbox);
32 +       uint32_t format;
33 +       int fd, ret;
34 +
35 +       if(!buffer) {
36 +               weston_log("buffer is NULL\n");
37 +               return -1;
38 +       }
39 +
40 +       if(dmabuf = linux_dmabuf_buffer_get(buffer->resource)) {
41 +               current = drm_fb_get_from_dmabuf(dmabuf, b, is_opaque);
42 +               if (!current)
43 +               {
44 +                       fprintf(stderr, "failed to get drm_fb from dmabuf\n");
45 +                       return -1;
46 +               }
47 +               *buf_stride=current->strides[0];
48 +       }
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);
52 +               if (!bo) {
53 +                       weston_log("failed to get gbm_bo\n");
54 +                       return -1;
55 +               }
56 +               current = drm_fb_get_from_bo(bo, b, is_opaque, BUFFER_CLIENT);
57 +
58 +               if (!current) {
59 +                       weston_log("failed to get drm_fb from bo\n");
60 +                       return -1;
61 +               }
62 +                *buf_stride=current->strides[0];
63 +       }
64 +       else {
65 +               weston_log("Buffer is not supported\n");
66 +               return -1;
67 +       }
68 +
69 +       ret = drmPrimeHandleToFD(b->drm.fd, current->handles[0],
70 +                                DRM_CLOEXEC, &fd);
71 +       free(current);
72 +       if (ret) {
73 +               weston_log("failed to create prime fd for front buffer\n");
74 +               return -1;
75 +       }
76 +
77 +       return fd;
78 +}
79 +
80  static int
81  drm_output_init_gamma_size(struct drm_output *output)
82  {
83 @@ -7396,6 +7454,7 @@ static const struct weston_drm_output_api api = {
84         drm_output_set_mode,
85         drm_output_set_gbm_format,
86         drm_output_set_seat,
87 +       drm_get_dma_fd_from_view
88  };
89  
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 {
96          */
97         void (*set_seat)(struct weston_output *output,
98                          const char *seat);
99 +
100 +       /** Get the dma fd from drm view.
101 +        *
102 +        *  The dma fd is got from weston_view.
103 +        *  Returns fd on success, -1 on failure.
104 +        */
105 +       int (*get_dma_fd_from_view)(struct weston_output *output, struct weston_view *view, int *buf_stride);
106  };
107  
108  static inline const struct weston_drm_output_api *
109 -- 
110 2.7.4
111