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