Update waltham-transmitter patches to weston 5.0 & 6.0
[AGL/meta-agl.git] / meta-agl-profile-graphical / recipes-graphics / wayland / weston / 0002-compositor-add-output-type-to-weston_output.patch
1 From e31e63976aab7616319c10ad21c998c3b4c634e6 Mon Sep 17 00:00:00 2001
2 From: Veeresh Kadasani <external.vkadasani@jp.adit-jv.com>
3 Date: Tue, 30 Jul 2019 20:22:15 +0900
4 Subject: [PATCH 1/2] 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      | 12 +++++++++++-
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, 28 insertions(+), 6 deletions(-)
20
21 diff --git a/libweston/compositor-drm.c b/libweston/compositor-drm.c
22 index c110110..b83459a 100644
23 --- a/libweston/compositor-drm.c
24 +++ b/libweston/compositor-drm.c
25 @@ -923,6 +923,7 @@ 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->base.output_type == OUTPUT_DRM)
30                 if (output->crtc_id == crtc_id)
31                         return output;
32         }
33 @@ -939,6 +940,7 @@ drm_head_find_by_connector(struct drm_backend *backend, uint32_t connector_id)
34         wl_list_for_each(base,
35                          &backend->compositor->head_list, compositor_link) {
36                 head = to_drm_head(base);
37 +               if(base->output->output_type == OUTPUT_DRM)
38                 if (head->connector_id == connector_id)
39                         return head;
40         }
41 @@ -6159,6 +6161,7 @@ drm_output_enable(struct weston_output *base)
42  
43         assert(!output->virtual);
44  
45 +        output->base.output_type = OUTPUT_DRM;
46         resources = drmModeGetResources(b->drm.fd);
47         if (!resources) {
48                 weston_log("drmModeGetResources failed\n");
49 @@ -6628,6 +6631,7 @@ drm_backend_update_heads(struct drm_backend *b, struct udev_device *drm_device)
50         /* Remove connectors that have disappeared. */
51         wl_list_for_each_safe(base, next,
52                               &b->compositor->head_list, compositor_link) {
53 +                if (base->output->output_type == OUTPUT_DRM) {
54                 bool removed = true;
55  
56                 head = to_drm_head(base);
57 @@ -6646,6 +6650,7 @@ drm_backend_update_heads(struct drm_backend *b, struct udev_device *drm_device)
58                            head->base.name, head->connector_id);
59                 drm_head_destroy(head);
60         }
61 +       }
62  
63         drm_backend_update_unused_outputs(b, resources);
64  
65 @@ -6751,12 +6756,14 @@ session_notify(struct wl_listener *listener, void *data)
66                  * pending frame callbacks. */
67  
68                 wl_list_for_each(output, &compositor->output_list, base.link) {
69 +                       if(output->base.output_type == OUTPUT_DRM) {
70                         output->base.repaint_needed = false;
71                         if (output->cursor_plane)
72                                 drmModeSetCursor(b->drm.fd, output->crtc_id,
73                                                  0, 0, 0);
74                 }
75 -
76 +               }
77 +                if(output->base.output_type == OUTPUT_DRM) {
78                 output = container_of(compositor->output_list.next,
79                                       struct drm_output, base.link);
80  
81 @@ -6768,6 +6775,7 @@ session_notify(struct wl_listener *listener, void *data)
82                                         plane->plane_id,
83                                         output->crtc_id, 0, 0,
84                                         0, 0, 0, 0, 0, 0, 0, 0);
85 +                       }
86                 }
87         }
88  }
89 @@ -7094,6 +7102,7 @@ switch_to_gl_renderer(struct drm_backend *b)
90         }
91  
92         wl_list_for_each(output, &b->compositor->output_list, base.link)
93 +               if(output->base.output_type == OUTPUT_DRM)
94                 pixman_renderer_output_destroy(&output->base);
95  
96         b->compositor->renderer->destroy(b->compositor);
97 @@ -7106,6 +7115,7 @@ switch_to_gl_renderer(struct drm_backend *b)
98         }
99  
100         wl_list_for_each(output, &b->compositor->output_list, base.link)
101 +               if(output->base.output_type == OUTPUT_DRM)
102                 drm_output_init_egl(output, b);
103  
104         b->use_pixman = 0;
105 diff --git a/libweston/compositor-fbdev.c b/libweston/compositor-fbdev.c
106 index 6031be5..97002e6 100644
107 --- a/libweston/compositor-fbdev.c
108 +++ b/libweston/compositor-fbdev.c
109 @@ -526,7 +526,7 @@ fbdev_output_enable(struct weston_output *base)
110         struct fbdev_head *head;
111         int fb_fd;
112         struct wl_event_loop *loop;
113 -
114 +        output->base.output_type = OUTPUT_FBDEV;
115         head = fbdev_output_get_head(output);
116  
117         /* Create the frame buffer. */
118 diff --git a/libweston/compositor-headless.c b/libweston/compositor-headless.c
119 index 5a0e46c..20b78b2 100644
120 --- a/libweston/compositor-headless.c
121 +++ b/libweston/compositor-headless.c
122 @@ -160,7 +160,7 @@ headless_output_enable(struct weston_output *base)
123         loop = wl_display_get_event_loop(b->compositor->wl_display);
124         output->finish_frame_timer =
125                 wl_event_loop_add_timer(loop, finish_frame_handler, output);
126 -
127 +        output->base.output_type = OUTPUT_HEADLESS;
128         if (b->use_pixman) {
129                 output->image_buf = malloc(output->base.current_mode->width *
130                                            output->base.current_mode->height * 4);
131 diff --git a/libweston/compositor-rdp.c b/libweston/compositor-rdp.c
132 index 871a0a3..b3064dd 100644
133 --- a/libweston/compositor-rdp.c
134 +++ b/libweston/compositor-rdp.c
135 @@ -554,7 +554,7 @@ rdp_output_enable(struct weston_output *base)
136         struct rdp_output *output = to_rdp_output(base);
137         struct rdp_backend *b = to_rdp_backend(base->compositor);
138         struct wl_event_loop *loop;
139 -
140 +        output->base.output_type = OUTPUT_RDP;
141         output->shadow_surface = pixman_image_create_bits(PIXMAN_x8r8g8b8,
142                                                           output->base.current_mode->width,
143                                                           output->base.current_mode->height,
144 diff --git a/libweston/compositor-wayland.c b/libweston/compositor-wayland.c
145 index e1485ca..75140b2 100644
146 --- a/libweston/compositor-wayland.c
147 +++ b/libweston/compositor-wayland.c
148 @@ -1221,7 +1221,7 @@ wayland_output_enable(struct weston_output *base)
149         struct wayland_backend *b = to_wayland_backend(base->compositor);
150         enum mode_status mode_status;
151         int ret = 0;
152 -
153 +        output->base.output_type = OUTPUT_WAYLAND;
154         weston_log("Creating %dx%d wayland output at (%d, %d)\n",
155                    output->base.current_mode->width,
156                    output->base.current_mode->height,
157 diff --git a/libweston/compositor-x11.c b/libweston/compositor-x11.c
158 index 922e3c8..8c20626 100644
159 --- a/libweston/compositor-x11.c
160 +++ b/libweston/compositor-x11.c
161 @@ -934,7 +934,7 @@ x11_output_enable(struct weston_output *base)
162                 XCB_EVENT_MASK_STRUCTURE_NOTIFY,
163                 0
164         };
165 -
166 +        output->base.output_type = OUTPUT_X11;
167         if (!b->no_input)
168                 values[0] |=
169                         XCB_EVENT_MASK_KEY_PRESS |
170 diff --git a/libweston/compositor.h b/libweston/compositor.h
171 index a5223c2..040917b 100644
172 --- a/libweston/compositor.h
173 +++ b/libweston/compositor.h
174 @@ -169,6 +169,17 @@ enum dpms_enum {
175         WESTON_DPMS_OFF
176  };
177  
178 +/* bit compatible with drm definitions. */
179 +enum output_type {
180 +       OUTPUT_DRM,
181 +       OUTPUT_FBDEV,
182 +       OUTPUT_HEADLESS,
183 +       OUTPUT_RDP,
184 +       OUTPUT_WAYLAND,
185 +       OUTPUT_X11,
186 +       OUTPUT_WALTHAM
187 +};
188 +
189  /** Represents a monitor
190   *
191   * This object represents a monitor (hardware backends like DRM) or a window
192 @@ -202,6 +213,7 @@ struct weston_head {
193  struct weston_output {
194         uint32_t id;
195         char *name;
196 +        enum output_type output_type;
197  
198         /** Matches the lifetime from the user perspective */
199         struct wl_signal user_destroy_signal;
200 -- 
201 2.7.4
202