Update waltham-transmitter patches to weston 5.0 & 6.0
[AGL/meta-agl.git] / meta-agl-profile-graphical / recipes-graphics / wayland / weston / 0016-compositor-add-output-type-to-weston_output.patch
1 From 8ea60075d5310101bebedf09c94902e9d41432ac Mon Sep 17 00:00:00 2001
2 From: Veeresh Kadasani <external.vkadasani@jp.adit-jv.com>
3 Date: Mon, 29 Jul 2019 17:04:12 +0900
4 Subject: [PATCH 1/3] compositor: add output type to weston_output
5
6 This enables weston to use multiple types of backend
7 Each backends have own output structure for each functions
8 To avoid invalid member access, type identifier is needed
9
10 Signed-off-by: Veeresh Kadasani <external.vkadasani@jp.adit-jv.com>
11 ---
12  libweston/compositor-drm.c      | 78 +++++++++++++++++++++++------------------
13  libweston/compositor-fbdev.c    |  2 +-
14  libweston/compositor-headless.c |  2 +-
15  libweston/compositor-rdp.c      |  2 +-
16  libweston/compositor-wayland.c  |  2 +-
17  libweston/compositor-x11.c      |  2 +-
18  libweston/compositor.h          | 12 ++++++-
19  7 files changed, 60 insertions(+), 40 deletions(-)
20
21 diff --git a/libweston/compositor-drm.c b/libweston/compositor-drm.c
22 index 3891176..26a480c 100644
23 --- a/libweston/compositor-drm.c
24 +++ b/libweston/compositor-drm.c
25 @@ -843,8 +843,9 @@ drm_output_find_by_crtc(struct drm_backend *b, uint32_t crtc_id)
26         struct drm_output *output;
27  
28         wl_list_for_each(output, &b->compositor->output_list, base.link) {
29 -               if (output->crtc_id == crtc_id)
30 -                       return output;
31 +                if(output->base.output_type == OUTPUT_DRM)
32 +                       if (output->crtc_id == crtc_id)
33 +                               return output;
34         }
35  
36         return NULL;
37 @@ -859,7 +860,8 @@ drm_head_find_by_connector(struct drm_backend *backend, uint32_t connector_id)
38         wl_list_for_each(base,
39                          &backend->compositor->head_list, compositor_link) {
40                 head = to_drm_head(base);
41 -               if (head->connector_id == connector_id)
42 +               if(base->output->output_type == OUTPUT_DRM)
43 +                       if (head->connector_id == connector_id)
44                         return head;
45         }
46  
47 @@ -5728,6 +5730,7 @@ drm_output_enable(struct weston_output *base)
48         drmModeRes *resources;
49         int ret;
50  
51 +        output->base.output_type = OUTPUT_DRM;
52         resources = drmModeGetResources(b->drm.fd);
53         if (!resources) {
54                 weston_log("drmModeGetResources failed\n");
55 @@ -6188,23 +6191,25 @@ drm_backend_update_heads(struct drm_backend *b, struct udev_device *drm_device)
56         /* Remove connectors that have disappeared. */
57         wl_list_for_each_safe(base, next,
58                               &b->compositor->head_list, compositor_link) {
59 -               bool removed = true;
60 +                if (base->output->output_type == OUTPUT_DRM) {
61 +                       bool removed = true;
62  
63 -               head = to_drm_head(base);
64 +                       head = to_drm_head(base);
65  
66 -               for (i = 0; i < resources->count_connectors; i++) {
67 -                       if (resources->connectors[i] == head->connector_id) {
68 -                               removed = false;
69 -                               break;
70 -                       }
71 -               }
72 +                       for (i = 0; i < resources->count_connectors; i++) {
73 +                               if (resources->connectors[i] == head->connector_id) {
74 +                                       removed = false;
75 +                                       break;
76 +                               }
77 +                       }
78  
79 -               if (!removed)
80 -                       continue;
81 +                       if (!removed)
82 +                               continue;
83  
84 -               weston_log("DRM: head '%s' (connector %d) disappeared.\n",
85 -                          head->base.name, head->connector_id);
86 -               drm_head_destroy(head);
87 +                       weston_log("DRM: head '%s' (connector %d) disappeared.\n",
88 +                                  head->base.name, head->connector_id);
89 +                       drm_head_destroy(head);
90 +                }
91         }
92  
93         drm_backend_update_unused_outputs(b, resources);
94 @@ -6309,23 +6314,26 @@ session_notify(struct wl_listener *listener, void *data)
95                  * pending frame callbacks. */
96  
97                 wl_list_for_each(output, &compositor->output_list, base.link) {
98 -                       output->base.repaint_needed = false;
99 -                       if (output->cursor_plane)
100 -                               drmModeSetCursor(b->drm.fd, output->crtc_id,
101 -                                                0, 0, 0);
102 +                       if(output->base.output_type == OUTPUT_DRM) {
103 +                                output->base.repaint_needed = false;
104 +                                if (output->cursor_plane)
105 +                                        drmModeSetCursor(b->drm.fd, output->crtc_id,
106 +                                                        0, 0, 0);
107 +                        }
108                 }
109 -
110 -               output = container_of(compositor->output_list.next,
111 -                                     struct drm_output, base.link);
112 -
113 -               wl_list_for_each(plane, &b->plane_list, link) {
114 -                       if (plane->type != WDRM_PLANE_TYPE_OVERLAY)
115 -                               continue;
116 -
117 -                       drmModeSetPlane(b->drm.fd,
118 -                                       plane->plane_id,
119 -                                       output->crtc_id, 0, 0,
120 -                                       0, 0, 0, 0, 0, 0, 0, 0);
121 +                if(output->base.output_type == OUTPUT_DRM) {
122 +                       output = container_of(compositor->output_list.next,
123 +                                struct drm_output, base.link);
124 +
125 +                       wl_list_for_each(plane, &b->plane_list, link) {
126 +                                if (plane->type != WDRM_PLANE_TYPE_OVERLAY)
127 +                                        continue;
128 +
129 +                                drmModeSetPlane(b->drm.fd,
130 +                                                plane->plane_id,
131 +                                                output->crtc_id, 0, 0,
132 +                                                0, 0, 0, 0, 0, 0, 0, 0);
133 +                       }
134                 }
135         }
136  }
137 @@ -6649,7 +6657,8 @@ switch_to_gl_renderer(struct drm_backend *b)
138         }
139  
140         wl_list_for_each(output, &b->compositor->output_list, base.link)
141 -               pixman_renderer_output_destroy(&output->base);
142 +               if(output->base.output_type == OUTPUT_DRM)
143 +                        pixman_renderer_output_destroy(&output->base);
144  
145         b->compositor->renderer->destroy(b->compositor);
146  
147 @@ -6661,7 +6670,8 @@ switch_to_gl_renderer(struct drm_backend *b)
148         }
149  
150         wl_list_for_each(output, &b->compositor->output_list, base.link)
151 -               drm_output_init_egl(output, b);
152 +               if(output->base.output_type == OUTPUT_DRM)
153 +                       drm_output_init_egl(output, b);
154  
155         b->use_pixman = 0;
156  
157 diff --git a/libweston/compositor-fbdev.c b/libweston/compositor-fbdev.c
158 index a71b7bd..8edb50b 100644
159 --- a/libweston/compositor-fbdev.c
160 +++ b/libweston/compositor-fbdev.c
161 @@ -501,7 +501,7 @@ fbdev_output_enable(struct weston_output *base)
162         struct fbdev_head *head;
163         int fb_fd;
164         struct wl_event_loop *loop;
165 -
166 +        output->base.output_type = OUTPUT_FBDEV;
167         head = fbdev_output_get_head(output);
168  
169         /* Create the frame buffer. */
170 diff --git a/libweston/compositor-headless.c b/libweston/compositor-headless.c
171 index 61a5bd9..f633cd7 100644
172 --- a/libweston/compositor-headless.c
173 +++ b/libweston/compositor-headless.c
174 @@ -159,7 +159,7 @@ headless_output_enable(struct weston_output *base)
175         loop = wl_display_get_event_loop(b->compositor->wl_display);
176         output->finish_frame_timer =
177                 wl_event_loop_add_timer(loop, finish_frame_handler, output);
178 -
179 +        output->base.output_type = OUTPUT_HEADLESS;
180         if (b->use_pixman) {
181                 output->image_buf = malloc(output->base.current_mode->width *
182                                            output->base.current_mode->height * 4);
183 diff --git a/libweston/compositor-rdp.c b/libweston/compositor-rdp.c
184 index 134e729..429370c 100644
185 --- a/libweston/compositor-rdp.c
186 +++ b/libweston/compositor-rdp.c
187 @@ -554,7 +554,7 @@ rdp_output_enable(struct weston_output *base)
188         struct rdp_output *output = to_rdp_output(base);
189         struct rdp_backend *b = to_rdp_backend(base->compositor);
190         struct wl_event_loop *loop;
191 -
192 +        output->base.output_type = OUTPUT_RDP;
193         output->shadow_surface = pixman_image_create_bits(PIXMAN_x8r8g8b8,
194                                                           output->base.current_mode->width,
195                                                           output->base.current_mode->height,
196 diff --git a/libweston/compositor-wayland.c b/libweston/compositor-wayland.c
197 index e80ecc1..808fc8f 100644
198 --- a/libweston/compositor-wayland.c
199 +++ b/libweston/compositor-wayland.c
200 @@ -1221,7 +1221,7 @@ wayland_output_enable(struct weston_output *base)
201         struct wayland_backend *b = to_wayland_backend(base->compositor);
202         enum mode_status mode_status;
203         int ret = 0;
204 -
205 +        output->base.output_type = OUTPUT_WAYLAND;
206         weston_log("Creating %dx%d wayland output at (%d, %d)\n",
207                    output->base.current_mode->width,
208                    output->base.current_mode->height,
209 diff --git a/libweston/compositor-x11.c b/libweston/compositor-x11.c
210 index 4a9d068..afbaa73 100644
211 --- a/libweston/compositor-x11.c
212 +++ b/libweston/compositor-x11.c
213 @@ -933,7 +933,7 @@ x11_output_enable(struct weston_output *base)
214                 XCB_EVENT_MASK_STRUCTURE_NOTIFY,
215                 0
216         };
217 -
218 +        output->base.output_type = OUTPUT_X11;
219         if (!b->no_input)
220                 values[0] |=
221                         XCB_EVENT_MASK_KEY_PRESS |
222 diff --git a/libweston/compositor.h b/libweston/compositor.h
223 index 8b7a102..60feda3 100644
224 --- a/libweston/compositor.h
225 +++ b/libweston/compositor.h
226 @@ -169,6 +169,16 @@ enum dpms_enum {
227         WESTON_DPMS_OFF
228  };
229  
230 +/* bit compatible with drm definitions. */
231 +enum output_type {
232 +       OUTPUT_DRM,
233 +       OUTPUT_FBDEV,
234 +       OUTPUT_HEADLESS,
235 +       OUTPUT_RDP,
236 +       OUTPUT_WAYLAND,
237 +       OUTPUT_X11,
238 +       OUTPUT_WALTHAM
239 +};
240  /** Represents a monitor
241   *
242   * This object represents a monitor (hardware backends like DRM) or a window
243 @@ -201,7 +211,7 @@ struct weston_head {
244  struct weston_output {
245         uint32_t id;
246         char *name;
247 -
248 +        enum output_type output_type;
249         /** Matches the lifetime from the user perspective */
250         struct wl_signal user_destroy_signal;
251  
252 -- 
253 2.7.4
254