summaryrefslogtreecommitdiffstats
path: root/meta-agl-bsp/meta-freescale-layer/recipes-graphics/wayland/weston-2.0.0/0001-libweston-Restore-EGL-support-for-the-fbdev-backend.patch
blob: 77bf2c5cb6b87f840dd7e2119b3bc691931f72f9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
From c43b64cad0fdc55594434a68faa25447b50ca7c5 Mon Sep 17 00:00:00 2001
From: Georgi Vlaev <georgi.vlaev@konsulko.com>
Date: Wed, 27 Sep 2017 14:00:50 +0300
Subject: [PATCH 1/5] libweston: Restore EGL support for the fbdev backend

In Weston 2.0, the EGL support was dropped from the fbdev-backend,
as that was not the correct way to initialize the EGL in first
place. However, the vendor support patches in Weston 1.11 still
require that functionality. Teporary restore the EGL support in
the fbdev-backend, until a separate vendor backend is available,
or switch to using etnaviv.

Signed-off-by: Georgi Vlaev <georgi.vlaev@konsulko.com>
---
 compositor/main.c            |  2 +
 libweston/compositor-fbdev.c | 99 +++++++++++++++++++++++++++++++++++++-------
 libweston/compositor-fbdev.h |  1 +
 3 files changed, 87 insertions(+), 15 deletions(-)

diff --git a/compositor/main.c b/compositor/main.c
index 72c3cd10..6c45a018 100644
--- a/compositor/main.c
+++ b/compositor/main.c
@@ -574,6 +574,7 @@ usage(int error_code)
 		"Options for fbdev-backend.so:\n\n"
 		"  --tty=TTY\t\tThe tty to use\n"
 		"  --device=DEVICE\tThe framebuffer device to use\n"
+		"  --use-gl\t\tUse the GL renderer\n"
 		"\n");
 #endif
 
@@ -1444,6 +1445,7 @@ load_fbdev_backend(struct weston_compositor *c,
 	const struct weston_option fbdev_options[] = {
 		{ WESTON_OPTION_INTEGER, "tty", 0, &config.tty },
 		{ WESTON_OPTION_STRING, "device", 0, &config.device },
+		{ WESTON_OPTION_BOOLEAN, "use-gl", 0, &config.use_gl },
 	};
 
 	parse_options(fbdev_options, ARRAY_LENGTH(fbdev_options), argc, argv);
diff --git a/libweston/compositor-fbdev.c b/libweston/compositor-fbdev.c
index 44f0cf51..4ca53b67 100644
--- a/libweston/compositor-fbdev.c
+++ b/libweston/compositor-fbdev.c
@@ -49,6 +49,7 @@
 #include "launcher-util.h"
 #include "pixman-renderer.h"
 #include "libinput-seat.h"
+#include "gl-renderer.h"
 #include "presentation-time-server-protocol.h"
 
 struct fbdev_backend {
@@ -58,6 +59,7 @@ struct fbdev_backend {
 
 	struct udev *udev;
 	struct udev_input input;
+	int use_pixman;
 	uint32_t output_transform;
 	struct wl_listener session_listener;
 };
@@ -94,6 +96,8 @@ struct fbdev_output {
 	uint8_t depth;
 };
 
+struct gl_renderer_interface *gl_renderer;
+
 static const char default_seat[] = "seat0";
 
 static inline struct fbdev_output *
@@ -117,8 +121,8 @@ fbdev_output_start_repaint_loop(struct weston_output *output)
 	weston_output_finish_frame(output, &ts, WP_PRESENTATION_FEEDBACK_INVALID);
 }
 
-static int
-fbdev_output_repaint(struct weston_output *base, pixman_region32_t *damage)
+static void
+fbdev_output_repaint_pixman(struct weston_output *base, pixman_region32_t *damage)
 {
 	struct fbdev_output *output = to_fbdev_output(base);
 	struct weston_compositor *ec = output->base.compositor;
@@ -140,6 +144,26 @@ fbdev_output_repaint(struct weston_output *base, pixman_region32_t *damage)
 	 * refresh rate is given in mHz and the interval in ms. */
 	wl_event_source_timer_update(output->finish_frame_timer,
 	                             1000000 / output->mode.refresh);
+}
+
+static int
+fbdev_output_repaint(struct weston_output *base, pixman_region32_t *damage)
+{
+	struct fbdev_output *output = to_fbdev_output(base);
+	struct fbdev_backend *backend = output->backend;
+	struct weston_compositor *ec = backend->compositor;
+
+	if (backend->use_pixman) {
+		fbdev_output_repaint_pixman(base,damage);
+	} else {
+		ec->renderer->repaint_output(base, damage);
+		/* Update the damage region. */
+		pixman_region32_subtract(&ec->primary_plane.damage,
+					&ec->primary_plane.damage, damage);
+
+		wl_event_source_timer_update(output->finish_frame_timer,
+					1000000 / output->mode.refresh);
+	}
 
 	return 0;
 }
@@ -440,16 +464,30 @@ fbdev_output_enable(struct weston_output *base)
 		return -1;
 	}
 
-	if (fbdev_frame_buffer_map(output, fb_fd) < 0) {
-		weston_log("Mapping frame buffer failed.\n");
-		return -1;
-	}
+	if (backend->use_pixman) {
+		if (fbdev_frame_buffer_map(output, fb_fd) < 0) {
+			weston_log("Mapping frame buffer failed.\n");
+			return -1;
+		}
+	} else
+		close(fb_fd);
 
 	output->base.start_repaint_loop = fbdev_output_start_repaint_loop;
 	output->base.repaint = fbdev_output_repaint;
 
-	if (pixman_renderer_output_create(&output->base) < 0)
-		goto out_hw_surface;
+	if (backend->use_pixman) {
+		if (pixman_renderer_output_create(&output->base) < 0)
+			goto out_hw_surface;
+	} else {
+		setenv("HYBRIS_EGLPLATFORM", "wayland", 1);
+		if (gl_renderer->output_window_create(&output->base,
+						(EGLNativeWindowType)NULL, NULL,
+						gl_renderer->opaque_attribs,
+						NULL, 0) < 0) {
+			weston_log("gl_renderer_output_create failed.\n");
+			goto out_hw_surface;
+		}
+	}
 
 	loop = wl_display_get_event_loop(backend->compositor->wl_display);
 	output->finish_frame_timer =
@@ -534,14 +572,19 @@ static void
 fbdev_output_destroy(struct weston_output *base)
 {
 	struct fbdev_output *output = to_fbdev_output(base);
+	struct fbdev_backend *backend = output->backend;
 
 	weston_log("Destroying fbdev output.\n");
 
 	/* Close the frame buffer. */
 	fbdev_output_disable(base);
 
-	if (base->renderer_state != NULL)
-		pixman_renderer_output_destroy(base);
+	if (backend->use_pixman) {
+		if (base->renderer_state != NULL)
+			pixman_renderer_output_destroy(base);
+	} else {
+		gl_renderer->output_destroy(base);
+	}
 
 	/* Remove the output. */
 	weston_output_destroy(&output->base);
@@ -610,9 +653,11 @@ fbdev_output_reenable(struct fbdev_backend *backend,
 	}
 
 	/* Map the device if it has the same details as before. */
-	if (fbdev_frame_buffer_map(output, fb_fd) < 0) {
-		weston_log("Mapping frame buffer failed.\n");
-		goto err;
+	if (backend->use_pixman) {
+		if (fbdev_frame_buffer_map(output, fb_fd) < 0) {
+			weston_log("Mapping frame buffer failed.\n");
+			goto err;
+		}
 	}
 
 	return 0;
@@ -628,9 +673,13 @@ static void
 fbdev_output_disable(struct weston_output *base)
 {
 	struct fbdev_output *output = to_fbdev_output(base);
+	struct fbdev_backend *backend = output->backend;
 
 	weston_log("Disabling fbdev output.\n");
 
+	 if (!backend->use_pixman)
+		return;
+
 	if (output->hw_surface != NULL) {
 		pixman_image_unref(output->hw_surface);
 		output->hw_surface = NULL;
@@ -744,11 +793,30 @@ fbdev_backend_create(struct weston_compositor *compositor,
 	backend->base.restore = fbdev_restore;
 
 	backend->prev_state = WESTON_COMPOSITOR_ACTIVE;
+	backend->use_pixman = !param->use_gl;
 
 	weston_setup_vt_switch_bindings(compositor);
 
-	if (pixman_renderer_init(compositor) < 0)
-		goto out_launcher;
+	if (backend->use_pixman) {
+		if (pixman_renderer_init(compositor) < 0)
+			goto out_launcher;
+	} else {
+		gl_renderer = weston_load_module("gl-renderer.so",
+						"gl_renderer_interface");
+		if (!gl_renderer) {
+			weston_log("could not load gl renderer\n");
+			goto out_launcher;
+		}
+
+		if (gl_renderer->display_create(compositor, NO_EGL_PLATFORM,
+					EGL_DEFAULT_DISPLAY,
+					NULL,
+					gl_renderer->opaque_attribs,
+					NULL, 0) < 0) {
+			weston_log("gl_renderer_create failed.\n");
+			goto out_launcher;
+		}
+	}
 
 	if (fbdev_output_create(backend, param->device) < 0)
 		goto out_launcher;
@@ -779,6 +847,7 @@ config_init_to_defaults(struct weston_fbdev_backend_config *config)
 	 * udev, rather than passing a device node in as a parameter. */
 	config->tty = 0; /* default to current tty */
 	config->device = "/dev/fb0"; /* default frame buffer */
+	config->use_gl = 0;
 }
 
 WL_EXPORT int
diff --git a/libweston/compositor-fbdev.h b/libweston/compositor-fbdev.h
index 8b7d900e..806712f9 100644
--- a/libweston/compositor-fbdev.h
+++ b/libweston/compositor-fbdev.h
@@ -43,6 +43,7 @@ struct weston_fbdev_backend_config {
 
 	int tty;
 	char *device;
+	int use_gl;
 
 	/** Callback used to configure input devices.
 	 *
-- 
2.11.0