Pekka Paalanen | e8de35c | 2012-11-07 12:25:14 +0200 | [diff] [blame] | 1 | /* |
| 2 | * Copyright © 2008-2011 Kristian Høgsberg |
| 3 | * Copyright © 2011 Intel Corporation |
Pekka Paalanen | e31e053 | 2013-05-22 18:03:07 +0300 | [diff] [blame] | 4 | * Copyright © 2012-2013 Raspberry Pi Foundation |
Pekka Paalanen | e8de35c | 2012-11-07 12:25:14 +0200 | [diff] [blame] | 5 | * |
| 6 | * Permission to use, copy, modify, distribute, and sell this software and |
| 7 | * its documentation for any purpose is hereby granted without fee, provided |
| 8 | * that the above copyright notice appear in all copies and that both that |
| 9 | * copyright notice and this permission notice appear in supporting |
| 10 | * documentation, and that the name of the copyright holders not be used in |
| 11 | * advertising or publicity pertaining to distribution of the software |
| 12 | * without specific, written prior permission. The copyright holders make |
| 13 | * no representations about the suitability of this software for any |
| 14 | * purpose. It is provided "as is" without express or implied warranty. |
| 15 | * |
| 16 | * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS |
| 17 | * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND |
| 18 | * FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY |
| 19 | * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER |
| 20 | * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF |
| 21 | * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN |
| 22 | * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
| 23 | */ |
| 24 | |
Daniel Stone | c228e23 | 2013-05-22 18:03:19 +0300 | [diff] [blame^] | 25 | #include "config.h" |
Pekka Paalanen | e8de35c | 2012-11-07 12:25:14 +0200 | [diff] [blame] | 26 | |
| 27 | #include <errno.h> |
| 28 | #include <stdlib.h> |
| 29 | #include <stdio.h> |
| 30 | #include <string.h> |
| 31 | #include <math.h> |
| 32 | #include <sys/types.h> |
| 33 | #include <fcntl.h> |
| 34 | #include <unistd.h> |
| 35 | |
| 36 | #include <libudev.h> |
| 37 | |
Pekka Paalanen | e8de35c | 2012-11-07 12:25:14 +0200 | [diff] [blame] | 38 | #ifdef HAVE_BCM_HOST |
| 39 | # include <bcm_host.h> |
| 40 | #else |
| 41 | # include "rpi-bcm-stubs.h" |
| 42 | #endif |
| 43 | |
| 44 | #include "compositor.h" |
Pekka Paalanen | e31e053 | 2013-05-22 18:03:07 +0300 | [diff] [blame] | 45 | #include "rpi-renderer.h" |
Pekka Paalanen | e8de35c | 2012-11-07 12:25:14 +0200 | [diff] [blame] | 46 | #include "evdev.h" |
| 47 | |
Pekka Paalanen | 7fb46fb | 2012-11-07 12:25:15 +0200 | [diff] [blame] | 48 | #if 0 |
| 49 | #define DBG(...) \ |
| 50 | weston_log(__VA_ARGS__) |
| 51 | #else |
| 52 | #define DBG(...) do {} while (0) |
| 53 | #endif |
| 54 | |
Pekka Paalanen | e8de35c | 2012-11-07 12:25:14 +0200 | [diff] [blame] | 55 | struct rpi_compositor; |
Pekka Paalanen | 7fb46fb | 2012-11-07 12:25:15 +0200 | [diff] [blame] | 56 | struct rpi_output; |
| 57 | |
Pekka Paalanen | 7fb46fb | 2012-11-07 12:25:15 +0200 | [diff] [blame] | 58 | struct rpi_flippipe { |
| 59 | int readfd; |
| 60 | int writefd; |
| 61 | struct wl_event_source *source; |
| 62 | }; |
Pekka Paalanen | e8de35c | 2012-11-07 12:25:14 +0200 | [diff] [blame] | 63 | |
| 64 | struct rpi_output { |
| 65 | struct rpi_compositor *compositor; |
| 66 | struct weston_output base; |
Pekka Paalanen | 7fb46fb | 2012-11-07 12:25:15 +0200 | [diff] [blame] | 67 | int single_buffer; |
Pekka Paalanen | e8de35c | 2012-11-07 12:25:14 +0200 | [diff] [blame] | 68 | |
| 69 | struct weston_mode mode; |
Pekka Paalanen | 7fb46fb | 2012-11-07 12:25:15 +0200 | [diff] [blame] | 70 | struct rpi_flippipe flippipe; |
Pekka Paalanen | e8de35c | 2012-11-07 12:25:14 +0200 | [diff] [blame] | 71 | |
| 72 | DISPMANX_DISPLAY_HANDLE_T display; |
Pekka Paalanen | e8de35c | 2012-11-07 12:25:14 +0200 | [diff] [blame] | 73 | }; |
| 74 | |
| 75 | struct rpi_seat { |
| 76 | struct weston_seat base; |
| 77 | struct wl_list devices_list; |
| 78 | |
| 79 | struct udev_monitor *udev_monitor; |
| 80 | struct wl_event_source *udev_monitor_source; |
| 81 | char *seat_id; |
| 82 | }; |
| 83 | |
| 84 | struct rpi_compositor { |
| 85 | struct weston_compositor base; |
| 86 | uint32_t prev_state; |
| 87 | |
| 88 | struct udev *udev; |
| 89 | struct tty *tty; |
Pekka Paalanen | 7fb46fb | 2012-11-07 12:25:15 +0200 | [diff] [blame] | 90 | |
Pekka Paalanen | 7fb46fb | 2012-11-07 12:25:15 +0200 | [diff] [blame] | 91 | int single_buffer; |
Pekka Paalanen | e8de35c | 2012-11-07 12:25:14 +0200 | [diff] [blame] | 92 | }; |
| 93 | |
| 94 | static inline struct rpi_output * |
| 95 | to_rpi_output(struct weston_output *base) |
| 96 | { |
| 97 | return container_of(base, struct rpi_output, base); |
| 98 | } |
| 99 | |
| 100 | static inline struct rpi_seat * |
| 101 | to_rpi_seat(struct weston_seat *base) |
| 102 | { |
| 103 | return container_of(base, struct rpi_seat, base); |
| 104 | } |
| 105 | |
| 106 | static inline struct rpi_compositor * |
| 107 | to_rpi_compositor(struct weston_compositor *base) |
| 108 | { |
| 109 | return container_of(base, struct rpi_compositor, base); |
| 110 | } |
| 111 | |
Jonas Ådahl | e5a1225 | 2013-04-05 23:07:11 +0200 | [diff] [blame] | 112 | static uint64_t |
| 113 | rpi_get_current_time(void) |
| 114 | { |
| 115 | struct timeval tv; |
| 116 | |
| 117 | /* XXX: use CLOCK_MONOTONIC instead? */ |
| 118 | gettimeofday(&tv, NULL); |
| 119 | return (uint64_t)tv.tv_sec * 1000 + tv.tv_usec / 1000; |
| 120 | } |
| 121 | |
Pekka Paalanen | 7fb46fb | 2012-11-07 12:25:15 +0200 | [diff] [blame] | 122 | static void |
| 123 | rpi_flippipe_update_complete(DISPMANX_UPDATE_HANDLE_T update, void *data) |
| 124 | { |
| 125 | /* This function runs in a different thread. */ |
| 126 | struct rpi_flippipe *flippipe = data; |
Pekka Paalanen | 7fb46fb | 2012-11-07 12:25:15 +0200 | [diff] [blame] | 127 | uint64_t time; |
| 128 | ssize_t ret; |
| 129 | |
| 130 | /* manufacture flip completion timestamp */ |
Jonas Ådahl | e5a1225 | 2013-04-05 23:07:11 +0200 | [diff] [blame] | 131 | time = rpi_get_current_time(); |
Pekka Paalanen | 7fb46fb | 2012-11-07 12:25:15 +0200 | [diff] [blame] | 132 | |
| 133 | ret = write(flippipe->writefd, &time, sizeof time); |
| 134 | if (ret != sizeof time) |
| 135 | weston_log("ERROR: %s failed to write, ret %zd, errno %d\n", |
| 136 | __func__, ret, errno); |
| 137 | } |
| 138 | |
| 139 | static int |
| 140 | rpi_dispmanx_update_submit(DISPMANX_UPDATE_HANDLE_T update, |
| 141 | struct rpi_output *output) |
| 142 | { |
| 143 | /* |
| 144 | * The callback registered here will eventually be called |
| 145 | * in a different thread context. Therefore we cannot call |
| 146 | * the usual functions from rpi_flippipe_update_complete(). |
| 147 | * Instead, we have a pipe for passing the message from the |
| 148 | * thread, waking up the Weston main event loop, calling |
| 149 | * rpi_flippipe_handler(), and then ending up in |
| 150 | * rpi_output_update_complete() in the main thread context, |
| 151 | * where we can do the frame finishing work. |
| 152 | */ |
| 153 | return vc_dispmanx_update_submit(update, rpi_flippipe_update_complete, |
| 154 | &output->flippipe); |
| 155 | } |
| 156 | |
| 157 | static void |
| 158 | rpi_output_update_complete(struct rpi_output *output, uint64_t time); |
| 159 | |
| 160 | static int |
| 161 | rpi_flippipe_handler(int fd, uint32_t mask, void *data) |
Pekka Paalanen | e8de35c | 2012-11-07 12:25:14 +0200 | [diff] [blame] | 162 | { |
| 163 | struct rpi_output *output = data; |
Pekka Paalanen | 7fb46fb | 2012-11-07 12:25:15 +0200 | [diff] [blame] | 164 | ssize_t ret; |
| 165 | uint64_t time; |
Pekka Paalanen | e8de35c | 2012-11-07 12:25:14 +0200 | [diff] [blame] | 166 | |
Pekka Paalanen | 7fb46fb | 2012-11-07 12:25:15 +0200 | [diff] [blame] | 167 | if (mask != WL_EVENT_READABLE) |
| 168 | weston_log("ERROR: unexpected mask 0x%x in %s\n", |
| 169 | mask, __func__); |
| 170 | |
| 171 | ret = read(fd, &time, sizeof time); |
| 172 | if (ret != sizeof time) { |
| 173 | weston_log("ERROR: %s failed to read, ret %zd, errno %d\n", |
| 174 | __func__, ret, errno); |
| 175 | } |
| 176 | |
| 177 | rpi_output_update_complete(output, time); |
| 178 | |
Pekka Paalanen | e8de35c | 2012-11-07 12:25:14 +0200 | [diff] [blame] | 179 | return 1; |
| 180 | } |
| 181 | |
Pekka Paalanen | 7fb46fb | 2012-11-07 12:25:15 +0200 | [diff] [blame] | 182 | static int |
| 183 | rpi_flippipe_init(struct rpi_flippipe *flippipe, struct rpi_output *output) |
| 184 | { |
| 185 | struct wl_event_loop *loop; |
| 186 | int fd[2]; |
| 187 | |
| 188 | if (pipe2(fd, O_CLOEXEC) == -1) |
| 189 | return -1; |
| 190 | |
| 191 | flippipe->readfd = fd[0]; |
| 192 | flippipe->writefd = fd[1]; |
| 193 | |
| 194 | loop = wl_display_get_event_loop(output->compositor->base.wl_display); |
| 195 | flippipe->source = wl_event_loop_add_fd(loop, flippipe->readfd, |
| 196 | WL_EVENT_READABLE, |
| 197 | rpi_flippipe_handler, output); |
| 198 | |
| 199 | if (!flippipe->source) { |
| 200 | close(flippipe->readfd); |
| 201 | close(flippipe->writefd); |
| 202 | return -1; |
| 203 | } |
| 204 | |
| 205 | return 0; |
| 206 | } |
| 207 | |
| 208 | static void |
| 209 | rpi_flippipe_release(struct rpi_flippipe *flippipe) |
| 210 | { |
| 211 | wl_event_source_remove(flippipe->source); |
| 212 | close(flippipe->readfd); |
| 213 | close(flippipe->writefd); |
| 214 | } |
| 215 | |
Pekka Paalanen | e8de35c | 2012-11-07 12:25:14 +0200 | [diff] [blame] | 216 | static void |
Jonas Ådahl | e5a1225 | 2013-04-05 23:07:11 +0200 | [diff] [blame] | 217 | rpi_output_start_repaint_loop(struct weston_output *output) |
| 218 | { |
| 219 | uint64_t time; |
| 220 | |
| 221 | time = rpi_get_current_time(); |
| 222 | weston_output_finish_frame(output, time); |
| 223 | } |
| 224 | |
| 225 | static void |
Pekka Paalanen | e8de35c | 2012-11-07 12:25:14 +0200 | [diff] [blame] | 226 | rpi_output_repaint(struct weston_output *base, pixman_region32_t *damage) |
| 227 | { |
| 228 | struct rpi_output *output = to_rpi_output(base); |
| 229 | struct rpi_compositor *compositor = output->compositor; |
Ander Conselvan de Oliveira | 0a88772 | 2012-11-22 15:57:00 +0200 | [diff] [blame] | 230 | struct weston_plane *primary_plane = &compositor->base.primary_plane; |
Pekka Paalanen | 7fb46fb | 2012-11-07 12:25:15 +0200 | [diff] [blame] | 231 | DISPMANX_UPDATE_HANDLE_T update; |
Pekka Paalanen | e8de35c | 2012-11-07 12:25:14 +0200 | [diff] [blame] | 232 | |
Pekka Paalanen | e31e053 | 2013-05-22 18:03:07 +0300 | [diff] [blame] | 233 | DBG("frame update start\n"); |
Pekka Paalanen | 7fb46fb | 2012-11-07 12:25:15 +0200 | [diff] [blame] | 234 | |
Pekka Paalanen | e31e053 | 2013-05-22 18:03:07 +0300 | [diff] [blame] | 235 | /* Update priority higher than in rpi-renderer's |
| 236 | * output destroy function, see rpi_output_destroy(). |
| 237 | */ |
| 238 | update = vc_dispmanx_update_start(1); |
Pekka Paalanen | 7fb46fb | 2012-11-07 12:25:15 +0200 | [diff] [blame] | 239 | |
Pekka Paalanen | e31e053 | 2013-05-22 18:03:07 +0300 | [diff] [blame] | 240 | rpi_renderer_set_update_handle(&output->base, update); |
Pekka Paalanen | e8de35c | 2012-11-07 12:25:14 +0200 | [diff] [blame] | 241 | compositor->base.renderer->repaint_output(&output->base, damage); |
| 242 | |
Ander Conselvan de Oliveira | 0a88772 | 2012-11-22 15:57:00 +0200 | [diff] [blame] | 243 | pixman_region32_subtract(&primary_plane->damage, |
| 244 | &primary_plane->damage, damage); |
| 245 | |
Pekka Paalanen | e31e053 | 2013-05-22 18:03:07 +0300 | [diff] [blame] | 246 | /* schedule callback to rpi_output_update_complete() */ |
| 247 | rpi_dispmanx_update_submit(update, output); |
| 248 | DBG("frame update submitted\n"); |
Pekka Paalanen | 7fb46fb | 2012-11-07 12:25:15 +0200 | [diff] [blame] | 249 | } |
| 250 | |
| 251 | static void |
| 252 | rpi_output_update_complete(struct rpi_output *output, uint64_t time) |
| 253 | { |
Pekka Paalanen | e31e053 | 2013-05-22 18:03:07 +0300 | [diff] [blame] | 254 | DBG("frame update complete(%" PRIu64 ")\n", time); |
Pekka Paalanen | e31e053 | 2013-05-22 18:03:07 +0300 | [diff] [blame] | 255 | rpi_renderer_finish_frame(&output->base); |
Pekka Paalanen | 7fb46fb | 2012-11-07 12:25:15 +0200 | [diff] [blame] | 256 | weston_output_finish_frame(&output->base, time); |
Pekka Paalanen | e8de35c | 2012-11-07 12:25:14 +0200 | [diff] [blame] | 257 | } |
| 258 | |
| 259 | static void |
| 260 | rpi_output_destroy(struct weston_output *base) |
| 261 | { |
| 262 | struct rpi_output *output = to_rpi_output(base); |
Pekka Paalanen | e8de35c | 2012-11-07 12:25:14 +0200 | [diff] [blame] | 263 | |
Pekka Paalanen | 7fb46fb | 2012-11-07 12:25:15 +0200 | [diff] [blame] | 264 | DBG("%s\n", __func__); |
| 265 | |
Pekka Paalanen | e31e053 | 2013-05-22 18:03:07 +0300 | [diff] [blame] | 266 | rpi_renderer_output_destroy(base); |
Pekka Paalanen | e8de35c | 2012-11-07 12:25:14 +0200 | [diff] [blame] | 267 | |
Pekka Paalanen | e31e053 | 2013-05-22 18:03:07 +0300 | [diff] [blame] | 268 | /* rpi_renderer_output_destroy() will schedule a removal of |
| 269 | * all Dispmanx Elements, and wait for the update to complete. |
| 270 | * Assuming updates are sequential, the wait should guarantee, |
| 271 | * that any pending rpi_flippipe_update_complete() callbacks |
| 272 | * have happened already. Therefore we can destroy the flippipe |
| 273 | * now. |
| 274 | */ |
| 275 | rpi_flippipe_release(&output->flippipe); |
| 276 | |
Pekka Paalanen | e8de35c | 2012-11-07 12:25:14 +0200 | [diff] [blame] | 277 | wl_list_remove(&output->base.link); |
| 278 | weston_output_destroy(&output->base); |
| 279 | |
Pekka Paalanen | e8de35c | 2012-11-07 12:25:14 +0200 | [diff] [blame] | 280 | vc_dispmanx_display_close(output->display); |
| 281 | |
| 282 | free(output); |
| 283 | } |
| 284 | |
Pekka Paalanen | e31e053 | 2013-05-22 18:03:07 +0300 | [diff] [blame] | 285 | static const char *transform_names[] = { |
| 286 | [WL_OUTPUT_TRANSFORM_NORMAL] = "normal", |
| 287 | [WL_OUTPUT_TRANSFORM_90] = "90", |
| 288 | [WL_OUTPUT_TRANSFORM_180] = "180", |
| 289 | [WL_OUTPUT_TRANSFORM_270] = "270", |
| 290 | [WL_OUTPUT_TRANSFORM_FLIPPED] = "flipped", |
| 291 | [WL_OUTPUT_TRANSFORM_FLIPPED_90] = "flipped-90", |
| 292 | [WL_OUTPUT_TRANSFORM_FLIPPED_180] = "flipped-180", |
| 293 | [WL_OUTPUT_TRANSFORM_FLIPPED_270] = "flipped-270", |
| 294 | }; |
| 295 | |
Pekka Paalanen | e8de35c | 2012-11-07 12:25:14 +0200 | [diff] [blame] | 296 | static int |
Pekka Paalanen | e31e053 | 2013-05-22 18:03:07 +0300 | [diff] [blame] | 297 | str2transform(const char *name) |
| 298 | { |
| 299 | unsigned i; |
| 300 | |
| 301 | for (i = 0; i < ARRAY_LENGTH(transform_names); i++) |
| 302 | if (strcmp(name, transform_names[i]) == 0) |
| 303 | return i; |
| 304 | |
| 305 | return -1; |
| 306 | } |
| 307 | |
| 308 | static const char * |
| 309 | transform2str(uint32_t output_transform) |
| 310 | { |
| 311 | if (output_transform >= ARRAY_LENGTH(transform_names)) |
| 312 | return "<illegal value>"; |
| 313 | |
| 314 | return transform_names[output_transform]; |
| 315 | } |
| 316 | |
| 317 | static int |
| 318 | rpi_output_create(struct rpi_compositor *compositor, uint32_t transform) |
Pekka Paalanen | e8de35c | 2012-11-07 12:25:14 +0200 | [diff] [blame] | 319 | { |
| 320 | struct rpi_output *output; |
| 321 | DISPMANX_MODEINFO_T modeinfo; |
Pekka Paalanen | e8de35c | 2012-11-07 12:25:14 +0200 | [diff] [blame] | 322 | int ret; |
| 323 | float mm_width, mm_height; |
Pekka Paalanen | e8de35c | 2012-11-07 12:25:14 +0200 | [diff] [blame] | 324 | |
| 325 | output = calloc(1, sizeof *output); |
| 326 | if (!output) |
| 327 | return -1; |
| 328 | |
| 329 | output->compositor = compositor; |
Pekka Paalanen | 7fb46fb | 2012-11-07 12:25:15 +0200 | [diff] [blame] | 330 | output->single_buffer = compositor->single_buffer; |
Pekka Paalanen | 7fb46fb | 2012-11-07 12:25:15 +0200 | [diff] [blame] | 331 | |
| 332 | if (rpi_flippipe_init(&output->flippipe, output) < 0) { |
| 333 | weston_log("Creating message pipe failed.\n"); |
| 334 | goto out_free; |
| 335 | } |
Pekka Paalanen | e8de35c | 2012-11-07 12:25:14 +0200 | [diff] [blame] | 336 | |
| 337 | output->display = vc_dispmanx_display_open(DISPMANX_ID_HDMI); |
| 338 | if (!output->display) { |
Pekka Paalanen | 7fb46fb | 2012-11-07 12:25:15 +0200 | [diff] [blame] | 339 | weston_log("Failed to open dispmanx HDMI display.\n"); |
| 340 | goto out_pipe; |
Pekka Paalanen | e8de35c | 2012-11-07 12:25:14 +0200 | [diff] [blame] | 341 | } |
| 342 | |
| 343 | ret = vc_dispmanx_display_get_info(output->display, &modeinfo); |
| 344 | if (ret < 0) { |
| 345 | weston_log("Failed to get display mode information.\n"); |
| 346 | goto out_dmx_close; |
| 347 | } |
| 348 | |
Jonas Ådahl | e5a1225 | 2013-04-05 23:07:11 +0200 | [diff] [blame] | 349 | output->base.start_repaint_loop = rpi_output_start_repaint_loop; |
Pekka Paalanen | e8de35c | 2012-11-07 12:25:14 +0200 | [diff] [blame] | 350 | output->base.repaint = rpi_output_repaint; |
| 351 | output->base.destroy = rpi_output_destroy; |
Pekka Paalanen | e31e053 | 2013-05-22 18:03:07 +0300 | [diff] [blame] | 352 | output->base.assign_planes = NULL; |
Pekka Paalanen | e8de35c | 2012-11-07 12:25:14 +0200 | [diff] [blame] | 353 | output->base.set_backlight = NULL; |
| 354 | output->base.set_dpms = NULL; |
| 355 | output->base.switch_mode = NULL; |
| 356 | |
| 357 | /* XXX: use tvservice to get information from and control the |
| 358 | * HDMI and SDTV outputs. See: |
| 359 | * /opt/vc/include/interface/vmcs_host/vc_tvservice.h |
| 360 | */ |
| 361 | |
| 362 | /* only one static mode in list */ |
| 363 | output->mode.flags = |
| 364 | WL_OUTPUT_MODE_CURRENT | WL_OUTPUT_MODE_PREFERRED; |
| 365 | output->mode.width = modeinfo.width; |
| 366 | output->mode.height = modeinfo.height; |
| 367 | output->mode.refresh = 60000; |
| 368 | wl_list_init(&output->base.mode_list); |
| 369 | wl_list_insert(&output->base.mode_list, &output->mode.link); |
| 370 | |
| 371 | output->base.current = &output->mode; |
| 372 | output->base.origin = &output->mode; |
| 373 | output->base.subpixel = WL_OUTPUT_SUBPIXEL_UNKNOWN; |
| 374 | output->base.make = "unknown"; |
| 375 | output->base.model = "unknown"; |
| 376 | |
| 377 | /* guess 96 dpi */ |
| 378 | mm_width = modeinfo.width * (25.4f / 96.0f); |
| 379 | mm_height = modeinfo.height * (25.4f / 96.0f); |
| 380 | |
| 381 | weston_output_init(&output->base, &compositor->base, |
| 382 | 0, 0, round(mm_width), round(mm_height), |
Pekka Paalanen | e31e053 | 2013-05-22 18:03:07 +0300 | [diff] [blame] | 383 | transform, 1); |
John Kåre Alsaker | 9465927 | 2012-11-13 19:10:18 +0100 | [diff] [blame] | 384 | |
Pekka Paalanen | e31e053 | 2013-05-22 18:03:07 +0300 | [diff] [blame] | 385 | if (rpi_renderer_output_create(&output->base, output->display) < 0) |
John Kåre Alsaker | 9465927 | 2012-11-13 19:10:18 +0100 | [diff] [blame] | 386 | goto out_output; |
| 387 | |
Pekka Paalanen | e8de35c | 2012-11-07 12:25:14 +0200 | [diff] [blame] | 388 | wl_list_insert(compositor->base.output_list.prev, &output->base.link); |
| 389 | |
Pekka Paalanen | e8de35c | 2012-11-07 12:25:14 +0200 | [diff] [blame] | 390 | weston_log("Raspberry Pi HDMI output %dx%d px\n", |
| 391 | output->mode.width, output->mode.height); |
| 392 | weston_log_continue(STAMP_SPACE "guessing %d Hz and 96 dpi\n", |
| 393 | output->mode.refresh / 1000); |
Pekka Paalanen | e31e053 | 2013-05-22 18:03:07 +0300 | [diff] [blame] | 394 | weston_log_continue(STAMP_SPACE "orientation: %s\n", |
| 395 | transform2str(output->base.transform)); |
| 396 | |
| 397 | if (!strncmp(transform2str(output->base.transform), "flipped", 7)) |
| 398 | weston_log("warning: flipped output transforms may not work\n"); |
Pekka Paalanen | e8de35c | 2012-11-07 12:25:14 +0200 | [diff] [blame] | 399 | |
| 400 | return 0; |
| 401 | |
John Kåre Alsaker | 9465927 | 2012-11-13 19:10:18 +0100 | [diff] [blame] | 402 | out_output: |
| 403 | weston_output_destroy(&output->base); |
Pekka Paalanen | e8de35c | 2012-11-07 12:25:14 +0200 | [diff] [blame] | 404 | |
| 405 | out_dmx_close: |
| 406 | vc_dispmanx_display_close(output->display); |
| 407 | |
Pekka Paalanen | 7fb46fb | 2012-11-07 12:25:15 +0200 | [diff] [blame] | 408 | out_pipe: |
| 409 | rpi_flippipe_release(&output->flippipe); |
| 410 | |
Pekka Paalanen | e8de35c | 2012-11-07 12:25:14 +0200 | [diff] [blame] | 411 | out_free: |
| 412 | free(output); |
| 413 | return -1; |
| 414 | } |
| 415 | |
| 416 | static void |
| 417 | rpi_led_update(struct weston_seat *seat_base, enum weston_led leds) |
| 418 | { |
| 419 | struct rpi_seat *seat = to_rpi_seat(seat_base); |
| 420 | struct evdev_device *device; |
| 421 | |
| 422 | wl_list_for_each(device, &seat->devices_list, link) |
| 423 | evdev_led_update(device, leds); |
| 424 | } |
| 425 | |
| 426 | static const char default_seat[] = "seat0"; |
| 427 | |
| 428 | static void |
| 429 | device_added(struct udev_device *udev_device, struct rpi_seat *master) |
| 430 | { |
| 431 | struct evdev_device *device; |
| 432 | const char *devnode; |
| 433 | const char *device_seat; |
| 434 | int fd; |
| 435 | |
| 436 | device_seat = udev_device_get_property_value(udev_device, "ID_SEAT"); |
| 437 | if (!device_seat) |
| 438 | device_seat = default_seat; |
| 439 | |
| 440 | if (strcmp(device_seat, master->seat_id)) |
| 441 | return; |
| 442 | |
| 443 | devnode = udev_device_get_devnode(udev_device); |
| 444 | |
| 445 | /* Use non-blocking mode so that we can loop on read on |
| 446 | * evdev_device_data() until all events on the fd are |
| 447 | * read. mtdev_get() also expects this. */ |
| 448 | fd = open(devnode, O_RDWR | O_NONBLOCK | O_CLOEXEC); |
| 449 | if (fd < 0) { |
| 450 | weston_log("opening input device '%s' failed.\n", devnode); |
| 451 | return; |
| 452 | } |
| 453 | |
| 454 | device = evdev_device_create(&master->base, devnode, fd); |
| 455 | if (!device) { |
| 456 | close(fd); |
| 457 | weston_log("not using input device '%s'.\n", devnode); |
| 458 | return; |
| 459 | } |
| 460 | |
| 461 | wl_list_insert(master->devices_list.prev, &device->link); |
| 462 | } |
| 463 | |
| 464 | static void |
| 465 | evdev_add_devices(struct udev *udev, struct weston_seat *seat_base) |
| 466 | { |
| 467 | struct rpi_seat *seat = to_rpi_seat(seat_base); |
| 468 | struct udev_enumerate *e; |
| 469 | struct udev_list_entry *entry; |
| 470 | struct udev_device *device; |
| 471 | const char *path, *sysname; |
| 472 | |
| 473 | e = udev_enumerate_new(udev); |
| 474 | udev_enumerate_add_match_subsystem(e, "input"); |
| 475 | udev_enumerate_scan_devices(e); |
| 476 | udev_list_entry_foreach(entry, udev_enumerate_get_list_entry(e)) { |
| 477 | path = udev_list_entry_get_name(entry); |
| 478 | device = udev_device_new_from_syspath(udev, path); |
| 479 | |
| 480 | sysname = udev_device_get_sysname(device); |
| 481 | if (strncmp("event", sysname, 5) != 0) { |
| 482 | udev_device_unref(device); |
| 483 | continue; |
| 484 | } |
| 485 | |
| 486 | device_added(device, seat); |
| 487 | |
| 488 | udev_device_unref(device); |
| 489 | } |
| 490 | udev_enumerate_unref(e); |
| 491 | |
| 492 | evdev_notify_keyboard_focus(&seat->base, &seat->devices_list); |
| 493 | |
| 494 | if (wl_list_empty(&seat->devices_list)) { |
| 495 | weston_log( |
| 496 | "warning: no input devices on entering Weston. " |
| 497 | "Possible causes:\n" |
| 498 | "\t- no permissions to read /dev/input/event*\n" |
| 499 | "\t- seats misconfigured " |
| 500 | "(Weston backend option 'seat', " |
| 501 | "udev device property ID_SEAT)\n"); |
| 502 | } |
| 503 | } |
| 504 | |
| 505 | static int |
| 506 | evdev_udev_handler(int fd, uint32_t mask, void *data) |
| 507 | { |
| 508 | struct rpi_seat *seat = data; |
| 509 | struct udev_device *udev_device; |
| 510 | struct evdev_device *device, *next; |
| 511 | const char *action; |
| 512 | const char *devnode; |
| 513 | |
| 514 | udev_device = udev_monitor_receive_device(seat->udev_monitor); |
| 515 | if (!udev_device) |
| 516 | return 1; |
| 517 | |
| 518 | action = udev_device_get_action(udev_device); |
| 519 | if (!action) |
| 520 | goto out; |
| 521 | |
| 522 | if (strncmp("event", udev_device_get_sysname(udev_device), 5) != 0) |
| 523 | goto out; |
| 524 | |
| 525 | if (!strcmp(action, "add")) { |
| 526 | device_added(udev_device, seat); |
| 527 | } |
| 528 | else if (!strcmp(action, "remove")) { |
| 529 | devnode = udev_device_get_devnode(udev_device); |
| 530 | wl_list_for_each_safe(device, next, &seat->devices_list, link) |
| 531 | if (!strcmp(device->devnode, devnode)) { |
| 532 | weston_log("input device %s, %s removed\n", |
| 533 | device->devname, device->devnode); |
| 534 | evdev_device_destroy(device); |
| 535 | break; |
| 536 | } |
| 537 | } |
| 538 | |
| 539 | out: |
| 540 | udev_device_unref(udev_device); |
| 541 | |
| 542 | return 0; |
| 543 | } |
| 544 | |
| 545 | static int |
| 546 | evdev_enable_udev_monitor(struct udev *udev, struct weston_seat *seat_base) |
| 547 | { |
| 548 | struct rpi_seat *master = to_rpi_seat(seat_base); |
| 549 | struct wl_event_loop *loop; |
| 550 | struct weston_compositor *c = master->base.compositor; |
| 551 | int fd; |
| 552 | |
| 553 | master->udev_monitor = udev_monitor_new_from_netlink(udev, "udev"); |
| 554 | if (!master->udev_monitor) { |
| 555 | weston_log("udev: failed to create the udev monitor\n"); |
| 556 | return 0; |
| 557 | } |
| 558 | |
| 559 | udev_monitor_filter_add_match_subsystem_devtype(master->udev_monitor, |
| 560 | "input", NULL); |
| 561 | |
| 562 | if (udev_monitor_enable_receiving(master->udev_monitor)) { |
| 563 | weston_log("udev: failed to bind the udev monitor\n"); |
| 564 | udev_monitor_unref(master->udev_monitor); |
| 565 | return 0; |
| 566 | } |
| 567 | |
| 568 | loop = wl_display_get_event_loop(c->wl_display); |
| 569 | fd = udev_monitor_get_fd(master->udev_monitor); |
| 570 | master->udev_monitor_source = |
| 571 | wl_event_loop_add_fd(loop, fd, WL_EVENT_READABLE, |
| 572 | evdev_udev_handler, master); |
| 573 | if (!master->udev_monitor_source) { |
| 574 | udev_monitor_unref(master->udev_monitor); |
| 575 | return 0; |
| 576 | } |
| 577 | |
| 578 | return 1; |
| 579 | } |
| 580 | |
| 581 | static void |
| 582 | evdev_disable_udev_monitor(struct weston_seat *seat_base) |
| 583 | { |
| 584 | struct rpi_seat *seat = to_rpi_seat(seat_base); |
| 585 | |
| 586 | if (!seat->udev_monitor) |
| 587 | return; |
| 588 | |
| 589 | udev_monitor_unref(seat->udev_monitor); |
| 590 | seat->udev_monitor = NULL; |
| 591 | wl_event_source_remove(seat->udev_monitor_source); |
| 592 | seat->udev_monitor_source = NULL; |
| 593 | } |
| 594 | |
| 595 | static void |
| 596 | evdev_input_create(struct weston_compositor *c, struct udev *udev, |
| 597 | const char *seat_id) |
| 598 | { |
| 599 | struct rpi_seat *seat; |
| 600 | |
| 601 | seat = malloc(sizeof *seat); |
| 602 | if (seat == NULL) |
| 603 | return; |
| 604 | |
| 605 | memset(seat, 0, sizeof *seat); |
Rob Bradford | 9af5f9e | 2013-05-31 18:09:50 +0100 | [diff] [blame] | 606 | weston_seat_init(&seat->base, c, "default"); |
Pekka Paalanen | e8de35c | 2012-11-07 12:25:14 +0200 | [diff] [blame] | 607 | seat->base.led_update = rpi_led_update; |
| 608 | |
| 609 | wl_list_init(&seat->devices_list); |
| 610 | seat->seat_id = strdup(seat_id); |
| 611 | if (!evdev_enable_udev_monitor(udev, &seat->base)) { |
| 612 | free(seat->seat_id); |
| 613 | free(seat); |
| 614 | return; |
| 615 | } |
| 616 | |
| 617 | evdev_add_devices(udev, &seat->base); |
| 618 | } |
| 619 | |
| 620 | static void |
| 621 | evdev_remove_devices(struct weston_seat *seat_base) |
| 622 | { |
| 623 | struct rpi_seat *seat = to_rpi_seat(seat_base); |
| 624 | struct evdev_device *device, *next; |
| 625 | |
| 626 | wl_list_for_each_safe(device, next, &seat->devices_list, link) |
| 627 | evdev_device_destroy(device); |
| 628 | |
Kristian Høgsberg | e314875 | 2013-05-06 23:19:49 -0400 | [diff] [blame] | 629 | if (seat->base.keyboard) |
Pekka Paalanen | e8de35c | 2012-11-07 12:25:14 +0200 | [diff] [blame] | 630 | notify_keyboard_focus_out(&seat->base); |
| 631 | } |
| 632 | |
| 633 | static void |
| 634 | evdev_input_destroy(struct weston_seat *seat_base) |
| 635 | { |
| 636 | struct rpi_seat *seat = to_rpi_seat(seat_base); |
| 637 | |
| 638 | evdev_remove_devices(seat_base); |
| 639 | evdev_disable_udev_monitor(&seat->base); |
| 640 | |
| 641 | weston_seat_release(seat_base); |
| 642 | free(seat->seat_id); |
| 643 | free(seat); |
| 644 | } |
| 645 | |
Pekka Paalanen | e8de35c | 2012-11-07 12:25:14 +0200 | [diff] [blame] | 646 | static void |
| 647 | rpi_compositor_destroy(struct weston_compositor *base) |
| 648 | { |
| 649 | struct rpi_compositor *compositor = to_rpi_compositor(base); |
| 650 | struct weston_seat *seat, *next; |
| 651 | |
| 652 | wl_list_for_each_safe(seat, next, &compositor->base.seat_list, link) |
| 653 | evdev_input_destroy(seat); |
| 654 | |
| 655 | /* destroys outputs, too */ |
| 656 | weston_compositor_shutdown(&compositor->base); |
| 657 | |
Vasily Khoruzhick | 52cfd61 | 2013-01-08 19:09:01 +0300 | [diff] [blame] | 658 | compositor->base.renderer->destroy(&compositor->base); |
Pekka Paalanen | e8de35c | 2012-11-07 12:25:14 +0200 | [diff] [blame] | 659 | tty_destroy(compositor->tty); |
| 660 | |
| 661 | bcm_host_deinit(); |
| 662 | free(compositor); |
| 663 | } |
| 664 | |
| 665 | static void |
| 666 | vt_func(struct weston_compositor *base, int event) |
| 667 | { |
| 668 | struct rpi_compositor *compositor = to_rpi_compositor(base); |
| 669 | struct weston_seat *seat; |
| 670 | struct weston_output *output; |
| 671 | |
| 672 | switch (event) { |
| 673 | case TTY_ENTER_VT: |
| 674 | weston_log("entering VT\n"); |
| 675 | compositor->base.focus = 1; |
| 676 | compositor->base.state = compositor->prev_state; |
| 677 | weston_compositor_damage_all(&compositor->base); |
| 678 | wl_list_for_each(seat, &compositor->base.seat_list, link) { |
| 679 | evdev_add_devices(compositor->udev, seat); |
| 680 | evdev_enable_udev_monitor(compositor->udev, seat); |
| 681 | } |
| 682 | break; |
| 683 | case TTY_LEAVE_VT: |
| 684 | weston_log("leaving VT\n"); |
| 685 | wl_list_for_each(seat, &compositor->base.seat_list, link) { |
| 686 | evdev_disable_udev_monitor(seat); |
| 687 | evdev_remove_devices(seat); |
| 688 | } |
| 689 | |
| 690 | compositor->base.focus = 0; |
| 691 | compositor->prev_state = compositor->base.state; |
Philipp Brüschweiler | 57edf7f | 2013-03-29 13:01:56 +0100 | [diff] [blame] | 692 | weston_compositor_offscreen(&compositor->base); |
Pekka Paalanen | e8de35c | 2012-11-07 12:25:14 +0200 | [diff] [blame] | 693 | |
| 694 | /* If we have a repaint scheduled (either from a |
| 695 | * pending pageflip or the idle handler), make sure we |
| 696 | * cancel that so we don't try to pageflip when we're |
Philipp Brüschweiler | 57edf7f | 2013-03-29 13:01:56 +0100 | [diff] [blame] | 697 | * vt switched away. The OFFSCREEN state will prevent |
Pekka Paalanen | e8de35c | 2012-11-07 12:25:14 +0200 | [diff] [blame] | 698 | * further attemps at repainting. When we switch |
| 699 | * back, we schedule a repaint, which will process |
| 700 | * pending frame callbacks. */ |
| 701 | |
| 702 | wl_list_for_each(output, |
| 703 | &compositor->base.output_list, link) { |
| 704 | output->repaint_needed = 0; |
| 705 | } |
| 706 | |
| 707 | break; |
| 708 | }; |
| 709 | } |
| 710 | |
| 711 | static void |
| 712 | rpi_restore(struct weston_compositor *base) |
| 713 | { |
| 714 | struct rpi_compositor *compositor = to_rpi_compositor(base); |
| 715 | |
| 716 | tty_reset(compositor->tty); |
| 717 | } |
| 718 | |
| 719 | static void |
Kristian Høgsberg | e314875 | 2013-05-06 23:19:49 -0400 | [diff] [blame] | 720 | switch_vt_binding(struct weston_seat *seat, uint32_t time, uint32_t key, void *data) |
Pekka Paalanen | e8de35c | 2012-11-07 12:25:14 +0200 | [diff] [blame] | 721 | { |
| 722 | struct rpi_compositor *ec = data; |
| 723 | |
| 724 | tty_activate_vt(ec->tty, key - KEY_F1 + 1); |
| 725 | } |
| 726 | |
Pekka Paalanen | 7fb46fb | 2012-11-07 12:25:15 +0200 | [diff] [blame] | 727 | struct rpi_parameters { |
| 728 | int tty; |
Pekka Paalanen | e31e053 | 2013-05-22 18:03:07 +0300 | [diff] [blame] | 729 | struct rpi_renderer_parameters renderer; |
| 730 | uint32_t output_transform; |
Pekka Paalanen | 7fb46fb | 2012-11-07 12:25:15 +0200 | [diff] [blame] | 731 | }; |
| 732 | |
Pekka Paalanen | e8de35c | 2012-11-07 12:25:14 +0200 | [diff] [blame] | 733 | static struct weston_compositor * |
Kristian Høgsberg | 4172f66 | 2013-02-20 15:27:49 -0500 | [diff] [blame] | 734 | rpi_compositor_create(struct wl_display *display, int *argc, char *argv[], |
Kristian Høgsberg | 14e438c | 2013-05-26 21:48:14 -0400 | [diff] [blame] | 735 | struct weston_config *config, |
| 736 | struct rpi_parameters *param) |
Pekka Paalanen | e8de35c | 2012-11-07 12:25:14 +0200 | [diff] [blame] | 737 | { |
| 738 | struct rpi_compositor *compositor; |
Pekka Paalanen | e8de35c | 2012-11-07 12:25:14 +0200 | [diff] [blame] | 739 | const char *seat = default_seat; |
| 740 | uint32_t key; |
| 741 | |
| 742 | weston_log("initializing Raspberry Pi backend\n"); |
| 743 | |
| 744 | compositor = calloc(1, sizeof *compositor); |
| 745 | if (compositor == NULL) |
| 746 | return NULL; |
| 747 | |
| 748 | if (weston_compositor_init(&compositor->base, display, argc, argv, |
Kristian Høgsberg | 14e438c | 2013-05-26 21:48:14 -0400 | [diff] [blame] | 749 | config) < 0) |
Pekka Paalanen | e8de35c | 2012-11-07 12:25:14 +0200 | [diff] [blame] | 750 | goto out_free; |
| 751 | |
| 752 | compositor->udev = udev_new(); |
| 753 | if (compositor->udev == NULL) { |
| 754 | weston_log("Failed to initialize udev context.\n"); |
| 755 | goto out_compositor; |
| 756 | } |
| 757 | |
Pekka Paalanen | 7fb46fb | 2012-11-07 12:25:15 +0200 | [diff] [blame] | 758 | compositor->tty = tty_create(&compositor->base, vt_func, param->tty); |
Pekka Paalanen | e8de35c | 2012-11-07 12:25:14 +0200 | [diff] [blame] | 759 | if (!compositor->tty) { |
| 760 | weston_log("Failed to initialize tty.\n"); |
| 761 | goto out_udev; |
| 762 | } |
| 763 | |
| 764 | compositor->base.destroy = rpi_compositor_destroy; |
| 765 | compositor->base.restore = rpi_restore; |
| 766 | |
| 767 | compositor->base.focus = 1; |
| 768 | compositor->prev_state = WESTON_COMPOSITOR_ACTIVE; |
Pekka Paalanen | e31e053 | 2013-05-22 18:03:07 +0300 | [diff] [blame] | 769 | compositor->single_buffer = param->renderer.single_buffer; |
Pekka Paalanen | 7fb46fb | 2012-11-07 12:25:15 +0200 | [diff] [blame] | 770 | |
Pekka Paalanen | 7fb46fb | 2012-11-07 12:25:15 +0200 | [diff] [blame] | 771 | weston_log("Dispmanx planes are %s buffered.\n", |
| 772 | compositor->single_buffer ? "single" : "double"); |
Pekka Paalanen | e8de35c | 2012-11-07 12:25:14 +0200 | [diff] [blame] | 773 | |
| 774 | for (key = KEY_F1; key < KEY_F9; key++) |
| 775 | weston_compositor_add_key_binding(&compositor->base, key, |
| 776 | MODIFIER_CTRL | MODIFIER_ALT, |
| 777 | switch_vt_binding, compositor); |
| 778 | |
Pekka Paalanen | 7fb46fb | 2012-11-07 12:25:15 +0200 | [diff] [blame] | 779 | /* |
| 780 | * bcm_host_init() creates threads. |
| 781 | * Therefore we must have all signal handlers set and signals blocked |
| 782 | * before calling it. Otherwise the signals may end in the bcm |
| 783 | * threads and cause the default behaviour there. For instance, |
| 784 | * SIGUSR1 used for VT switching caused Weston to terminate there. |
| 785 | */ |
Pekka Paalanen | e8de35c | 2012-11-07 12:25:14 +0200 | [diff] [blame] | 786 | bcm_host_init(); |
| 787 | |
Pekka Paalanen | e31e053 | 2013-05-22 18:03:07 +0300 | [diff] [blame] | 788 | if (rpi_renderer_create(&compositor->base, ¶m->renderer) < 0) |
Pekka Paalanen | e8de35c | 2012-11-07 12:25:14 +0200 | [diff] [blame] | 789 | goto out_tty; |
| 790 | |
Pekka Paalanen | e31e053 | 2013-05-22 18:03:07 +0300 | [diff] [blame] | 791 | if (rpi_output_create(compositor, param->output_transform) < 0) |
| 792 | goto out_renderer; |
Pekka Paalanen | e8de35c | 2012-11-07 12:25:14 +0200 | [diff] [blame] | 793 | |
Pekka Paalanen | e8de35c | 2012-11-07 12:25:14 +0200 | [diff] [blame] | 794 | evdev_input_create(&compositor->base, compositor->udev, seat); |
| 795 | |
| 796 | return &compositor->base; |
| 797 | |
Pekka Paalanen | e31e053 | 2013-05-22 18:03:07 +0300 | [diff] [blame] | 798 | out_renderer: |
Vasily Khoruzhick | 52cfd61 | 2013-01-08 19:09:01 +0300 | [diff] [blame] | 799 | compositor->base.renderer->destroy(&compositor->base); |
Pekka Paalanen | e8de35c | 2012-11-07 12:25:14 +0200 | [diff] [blame] | 800 | |
| 801 | out_tty: |
| 802 | tty_destroy(compositor->tty); |
| 803 | |
| 804 | out_udev: |
| 805 | udev_unref(compositor->udev); |
| 806 | |
| 807 | out_compositor: |
| 808 | weston_compositor_shutdown(&compositor->base); |
| 809 | |
| 810 | out_free: |
| 811 | bcm_host_deinit(); |
| 812 | free(compositor); |
| 813 | |
| 814 | return NULL; |
| 815 | } |
| 816 | |
| 817 | WL_EXPORT struct weston_compositor * |
Kristian Høgsberg | 4172f66 | 2013-02-20 15:27:49 -0500 | [diff] [blame] | 818 | backend_init(struct wl_display *display, int *argc, char *argv[], |
Kristian Høgsberg | 14e438c | 2013-05-26 21:48:14 -0400 | [diff] [blame] | 819 | struct weston_config *config) |
Pekka Paalanen | e8de35c | 2012-11-07 12:25:14 +0200 | [diff] [blame] | 820 | { |
Pekka Paalanen | e31e053 | 2013-05-22 18:03:07 +0300 | [diff] [blame] | 821 | const char *transform = "normal"; |
| 822 | int ret; |
| 823 | |
Pekka Paalanen | 7fb46fb | 2012-11-07 12:25:15 +0200 | [diff] [blame] | 824 | struct rpi_parameters param = { |
| 825 | .tty = 0, /* default to current tty */ |
Pekka Paalanen | e31e053 | 2013-05-22 18:03:07 +0300 | [diff] [blame] | 826 | .renderer.single_buffer = 0, |
| 827 | .output_transform = WL_OUTPUT_TRANSFORM_NORMAL, |
Pekka Paalanen | 7fb46fb | 2012-11-07 12:25:15 +0200 | [diff] [blame] | 828 | }; |
Pekka Paalanen | e8de35c | 2012-11-07 12:25:14 +0200 | [diff] [blame] | 829 | |
| 830 | const struct weston_option rpi_options[] = { |
Pekka Paalanen | 7fb46fb | 2012-11-07 12:25:15 +0200 | [diff] [blame] | 831 | { WESTON_OPTION_INTEGER, "tty", 0, ¶m.tty }, |
Pekka Paalanen | 7fb46fb | 2012-11-07 12:25:15 +0200 | [diff] [blame] | 832 | { WESTON_OPTION_BOOLEAN, "single-buffer", 0, |
Pekka Paalanen | e31e053 | 2013-05-22 18:03:07 +0300 | [diff] [blame] | 833 | ¶m.renderer.single_buffer }, |
| 834 | { WESTON_OPTION_STRING, "transform", 0, &transform }, |
Pekka Paalanen | e8de35c | 2012-11-07 12:25:14 +0200 | [diff] [blame] | 835 | }; |
| 836 | |
| 837 | parse_options(rpi_options, ARRAY_LENGTH(rpi_options), argc, argv); |
| 838 | |
Pekka Paalanen | e31e053 | 2013-05-22 18:03:07 +0300 | [diff] [blame] | 839 | ret = str2transform(transform); |
| 840 | if (ret < 0) |
| 841 | weston_log("invalid transform \"%s\"\n", transform); |
| 842 | else |
| 843 | param.output_transform = ret; |
| 844 | |
Kristian Høgsberg | 14e438c | 2013-05-26 21:48:14 -0400 | [diff] [blame] | 845 | return rpi_compositor_create(display, argc, argv, config, ¶m); |
Pekka Paalanen | e8de35c | 2012-11-07 12:25:14 +0200 | [diff] [blame] | 846 | } |