1 From c43b64cad0fdc55594434a68faa25447b50ca7c5 Mon Sep 17 00:00:00 2001
2 From: Georgi Vlaev <georgi.vlaev@konsulko.com>
3 Date: Wed, 27 Sep 2017 14:00:50 +0300
4 Subject: [PATCH 1/5] libweston: Restore EGL support for the fbdev backend
6 In Weston 2.0, the EGL support was dropped from the fbdev-backend,
7 as that was not the correct way to initialize the EGL in first
8 place. However, the vendor support patches in Weston 1.11 still
9 require that functionality. Teporary restore the EGL support in
10 the fbdev-backend, until a separate vendor backend is available,
11 or switch to using etnaviv.
13 Signed-off-by: Georgi Vlaev <georgi.vlaev@konsulko.com>
15 compositor/main.c | 2 +
16 libweston/compositor-fbdev.c | 99 +++++++++++++++++++++++++++++++++++++-------
17 libweston/compositor-fbdev.h | 1 +
18 3 files changed, 87 insertions(+), 15 deletions(-)
20 diff --git a/compositor/main.c b/compositor/main.c
21 index 72c3cd10..6c45a018 100644
22 --- a/compositor/main.c
23 +++ b/compositor/main.c
24 @@ -574,6 +574,7 @@ usage(int error_code)
25 "Options for fbdev-backend.so:\n\n"
26 " --tty=TTY\t\tThe tty to use\n"
27 " --device=DEVICE\tThe framebuffer device to use\n"
28 + " --use-gl\t\tUse the GL renderer\n"
32 @@ -1444,6 +1445,7 @@ load_fbdev_backend(struct weston_compositor *c,
33 const struct weston_option fbdev_options[] = {
34 { WESTON_OPTION_INTEGER, "tty", 0, &config.tty },
35 { WESTON_OPTION_STRING, "device", 0, &config.device },
36 + { WESTON_OPTION_BOOLEAN, "use-gl", 0, &config.use_gl },
39 parse_options(fbdev_options, ARRAY_LENGTH(fbdev_options), argc, argv);
40 diff --git a/libweston/compositor-fbdev.c b/libweston/compositor-fbdev.c
41 index 44f0cf51..4ca53b67 100644
42 --- a/libweston/compositor-fbdev.c
43 +++ b/libweston/compositor-fbdev.c
45 #include "launcher-util.h"
46 #include "pixman-renderer.h"
47 #include "libinput-seat.h"
48 +#include "gl-renderer.h"
49 #include "presentation-time-server-protocol.h"
51 struct fbdev_backend {
52 @@ -58,6 +59,7 @@ struct fbdev_backend {
55 struct udev_input input;
57 uint32_t output_transform;
58 struct wl_listener session_listener;
60 @@ -94,6 +96,8 @@ struct fbdev_output {
64 +struct gl_renderer_interface *gl_renderer;
66 static const char default_seat[] = "seat0";
68 static inline struct fbdev_output *
69 @@ -117,8 +121,8 @@ fbdev_output_start_repaint_loop(struct weston_output *output)
70 weston_output_finish_frame(output, &ts, WP_PRESENTATION_FEEDBACK_INVALID);
74 -fbdev_output_repaint(struct weston_output *base, pixman_region32_t *damage)
76 +fbdev_output_repaint_pixman(struct weston_output *base, pixman_region32_t *damage)
78 struct fbdev_output *output = to_fbdev_output(base);
79 struct weston_compositor *ec = output->base.compositor;
80 @@ -140,6 +144,26 @@ fbdev_output_repaint(struct weston_output *base, pixman_region32_t *damage)
81 * refresh rate is given in mHz and the interval in ms. */
82 wl_event_source_timer_update(output->finish_frame_timer,
83 1000000 / output->mode.refresh);
87 +fbdev_output_repaint(struct weston_output *base, pixman_region32_t *damage)
89 + struct fbdev_output *output = to_fbdev_output(base);
90 + struct fbdev_backend *backend = output->backend;
91 + struct weston_compositor *ec = backend->compositor;
93 + if (backend->use_pixman) {
94 + fbdev_output_repaint_pixman(base,damage);
96 + ec->renderer->repaint_output(base, damage);
97 + /* Update the damage region. */
98 + pixman_region32_subtract(&ec->primary_plane.damage,
99 + &ec->primary_plane.damage, damage);
101 + wl_event_source_timer_update(output->finish_frame_timer,
102 + 1000000 / output->mode.refresh);
107 @@ -440,16 +464,30 @@ fbdev_output_enable(struct weston_output *base)
111 - if (fbdev_frame_buffer_map(output, fb_fd) < 0) {
112 - weston_log("Mapping frame buffer failed.\n");
115 + if (backend->use_pixman) {
116 + if (fbdev_frame_buffer_map(output, fb_fd) < 0) {
117 + weston_log("Mapping frame buffer failed.\n");
123 output->base.start_repaint_loop = fbdev_output_start_repaint_loop;
124 output->base.repaint = fbdev_output_repaint;
126 - if (pixman_renderer_output_create(&output->base) < 0)
127 - goto out_hw_surface;
128 + if (backend->use_pixman) {
129 + if (pixman_renderer_output_create(&output->base) < 0)
130 + goto out_hw_surface;
132 + setenv("HYBRIS_EGLPLATFORM", "wayland", 1);
133 + if (gl_renderer->output_window_create(&output->base,
134 + (EGLNativeWindowType)NULL, NULL,
135 + gl_renderer->opaque_attribs,
137 + weston_log("gl_renderer_output_create failed.\n");
138 + goto out_hw_surface;
142 loop = wl_display_get_event_loop(backend->compositor->wl_display);
143 output->finish_frame_timer =
144 @@ -534,14 +572,19 @@ static void
145 fbdev_output_destroy(struct weston_output *base)
147 struct fbdev_output *output = to_fbdev_output(base);
148 + struct fbdev_backend *backend = output->backend;
150 weston_log("Destroying fbdev output.\n");
152 /* Close the frame buffer. */
153 fbdev_output_disable(base);
155 - if (base->renderer_state != NULL)
156 - pixman_renderer_output_destroy(base);
157 + if (backend->use_pixman) {
158 + if (base->renderer_state != NULL)
159 + pixman_renderer_output_destroy(base);
161 + gl_renderer->output_destroy(base);
164 /* Remove the output. */
165 weston_output_destroy(&output->base);
166 @@ -610,9 +653,11 @@ fbdev_output_reenable(struct fbdev_backend *backend,
169 /* Map the device if it has the same details as before. */
170 - if (fbdev_frame_buffer_map(output, fb_fd) < 0) {
171 - weston_log("Mapping frame buffer failed.\n");
173 + if (backend->use_pixman) {
174 + if (fbdev_frame_buffer_map(output, fb_fd) < 0) {
175 + weston_log("Mapping frame buffer failed.\n");
181 @@ -628,9 +673,13 @@ static void
182 fbdev_output_disable(struct weston_output *base)
184 struct fbdev_output *output = to_fbdev_output(base);
185 + struct fbdev_backend *backend = output->backend;
187 weston_log("Disabling fbdev output.\n");
189 + if (!backend->use_pixman)
192 if (output->hw_surface != NULL) {
193 pixman_image_unref(output->hw_surface);
194 output->hw_surface = NULL;
195 @@ -744,11 +793,30 @@ fbdev_backend_create(struct weston_compositor *compositor,
196 backend->base.restore = fbdev_restore;
198 backend->prev_state = WESTON_COMPOSITOR_ACTIVE;
199 + backend->use_pixman = !param->use_gl;
201 weston_setup_vt_switch_bindings(compositor);
203 - if (pixman_renderer_init(compositor) < 0)
205 + if (backend->use_pixman) {
206 + if (pixman_renderer_init(compositor) < 0)
209 + gl_renderer = weston_load_module("gl-renderer.so",
210 + "gl_renderer_interface");
211 + if (!gl_renderer) {
212 + weston_log("could not load gl renderer\n");
216 + if (gl_renderer->display_create(compositor, NO_EGL_PLATFORM,
217 + EGL_DEFAULT_DISPLAY,
219 + gl_renderer->opaque_attribs,
221 + weston_log("gl_renderer_create failed.\n");
226 if (fbdev_output_create(backend, param->device) < 0)
228 @@ -779,6 +847,7 @@ config_init_to_defaults(struct weston_fbdev_backend_config *config)
229 * udev, rather than passing a device node in as a parameter. */
230 config->tty = 0; /* default to current tty */
231 config->device = "/dev/fb0"; /* default frame buffer */
232 + config->use_gl = 0;
236 diff --git a/libweston/compositor-fbdev.h b/libweston/compositor-fbdev.h
237 index 8b7d900e..806712f9 100644
238 --- a/libweston/compositor-fbdev.h
239 +++ b/libweston/compositor-fbdev.h
240 @@ -43,6 +43,7 @@ struct weston_fbdev_backend_config {
246 /** Callback used to configure input devices.