Kristian Høgsberg | fc783d4 | 2010-06-11 12:56:24 -0400 | [diff] [blame] | 1 | /* |
Kristian Høgsberg | 96aa7da | 2011-09-15 15:43:14 -0400 | [diff] [blame] | 2 | * Copyright © 2008-2011 Kristian Høgsberg |
| 3 | * Copyright © 2011 Intel Corporation |
Kristian Høgsberg | fc783d4 | 2010-06-11 12:56:24 -0400 | [diff] [blame] | 4 | * |
Kristian Høgsberg | 96aa7da | 2011-09-15 15:43:14 -0400 | [diff] [blame] | 5 | * Permission to use, copy, modify, distribute, and sell this software and |
| 6 | * its documentation for any purpose is hereby granted without fee, provided |
| 7 | * that the above copyright notice appear in all copies and that both that |
| 8 | * copyright notice and this permission notice appear in supporting |
| 9 | * documentation, and that the name of the copyright holders not be used in |
| 10 | * advertising or publicity pertaining to distribution of the software |
| 11 | * without specific, written prior permission. The copyright holders make |
| 12 | * no representations about the suitability of this software for any |
| 13 | * purpose. It is provided "as is" without express or implied warranty. |
Kristian Høgsberg | fc783d4 | 2010-06-11 12:56:24 -0400 | [diff] [blame] | 14 | * |
Kristian Høgsberg | 96aa7da | 2011-09-15 15:43:14 -0400 | [diff] [blame] | 15 | * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS |
| 16 | * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND |
| 17 | * FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY |
| 18 | * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER |
| 19 | * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF |
| 20 | * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN |
| 21 | * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
Kristian Høgsberg | fc783d4 | 2010-06-11 12:56:24 -0400 | [diff] [blame] | 22 | */ |
| 23 | |
Kristian Høgsberg | 0b9334a | 2011-04-12 11:34:32 -0400 | [diff] [blame] | 24 | #define _GNU_SOURCE |
| 25 | |
Kristian Høgsberg | fc783d4 | 2010-06-11 12:56:24 -0400 | [diff] [blame] | 26 | #include <stdio.h> |
| 27 | #include <stdlib.h> |
| 28 | #include <string.h> |
| 29 | #include <fcntl.h> |
| 30 | #include <unistd.h> |
| 31 | |
Benjamin Franzke | c649a92 | 2011-03-02 11:56:04 +0100 | [diff] [blame] | 32 | #include <xf86drm.h> |
| 33 | #include <xf86drmMode.h> |
| 34 | |
Benjamin Franzke | 060cf80 | 2011-04-30 09:32:11 +0200 | [diff] [blame] | 35 | #include <gbm.h> |
| 36 | |
Kristian Høgsberg | fc783d4 | 2010-06-11 12:56:24 -0400 | [diff] [blame] | 37 | #include "compositor.h" |
| 38 | |
Kristian Høgsberg | ce5325d | 2010-06-14 11:54:00 -0400 | [diff] [blame] | 39 | struct drm_compositor { |
| 40 | struct wlsc_compositor base; |
| 41 | |
| 42 | struct udev *udev; |
| 43 | struct wl_event_source *drm_source; |
Kristian Høgsberg | ce5325d | 2010-06-14 11:54:00 -0400 | [diff] [blame] | 44 | |
Benjamin Franzke | 9c26ff3 | 2011-03-15 15:08:41 +0100 | [diff] [blame] | 45 | struct udev_monitor *udev_monitor; |
| 46 | struct wl_event_source *udev_drm_source; |
| 47 | |
Benjamin Franzke | 2af7f10 | 2011-03-02 11:14:59 +0100 | [diff] [blame] | 48 | struct { |
| 49 | int fd; |
| 50 | } drm; |
Benjamin Franzke | 060cf80 | 2011-04-30 09:32:11 +0200 | [diff] [blame] | 51 | struct gbm_device *gbm; |
Marty Jack | 13d9db2 | 2011-02-09 19:01:42 -0500 | [diff] [blame] | 52 | uint32_t crtc_allocator; |
Benjamin Franzke | 9c26ff3 | 2011-03-15 15:08:41 +0100 | [diff] [blame] | 53 | uint32_t connector_allocator; |
Kristian Høgsberg | e4762a6 | 2011-01-14 14:59:13 -0500 | [diff] [blame] | 54 | struct tty *tty; |
Kristian Høgsberg | ce5325d | 2010-06-14 11:54:00 -0400 | [diff] [blame] | 55 | }; |
| 56 | |
Kristian Høgsberg | 8f0ce05 | 2011-06-21 11:16:58 -0400 | [diff] [blame] | 57 | struct drm_mode { |
| 58 | struct wlsc_mode base; |
| 59 | drmModeModeInfo mode_info; |
| 60 | }; |
| 61 | |
Kristian Høgsberg | ce5325d | 2010-06-14 11:54:00 -0400 | [diff] [blame] | 62 | struct drm_output { |
| 63 | struct wlsc_output base; |
| 64 | |
Kristian Høgsberg | ce5325d | 2010-06-14 11:54:00 -0400 | [diff] [blame] | 65 | uint32_t crtc_id; |
| 66 | uint32_t connector_id; |
Matt Roper | 361d2ad | 2011-08-29 13:52:23 -0700 | [diff] [blame] | 67 | drmModeCrtcPtr original_crtc; |
Kristian Høgsberg | ce5325d | 2010-06-14 11:54:00 -0400 | [diff] [blame] | 68 | GLuint rbo[2]; |
| 69 | uint32_t fb_id[2]; |
| 70 | EGLImageKHR image[2]; |
Benjamin Franzke | 060cf80 | 2011-04-30 09:32:11 +0200 | [diff] [blame] | 71 | struct gbm_bo *bo[2]; |
Kristian Høgsberg | ce5325d | 2010-06-14 11:54:00 -0400 | [diff] [blame] | 72 | uint32_t current; |
Benjamin Franzke | 1178a3c | 2011-04-10 16:49:52 +0200 | [diff] [blame] | 73 | |
| 74 | uint32_t fs_surf_fb_id; |
| 75 | uint32_t pending_fs_surf_fb_id; |
Kristian Høgsberg | ce5325d | 2010-06-14 11:54:00 -0400 | [diff] [blame] | 76 | }; |
| 77 | |
Benjamin Franzke | eefc36c | 2011-03-11 16:39:20 +0100 | [diff] [blame] | 78 | static int |
| 79 | drm_output_prepare_render(struct wlsc_output *output_base) |
| 80 | { |
| 81 | struct drm_output *output = (struct drm_output *) output_base; |
| 82 | |
| 83 | glFramebufferRenderbuffer(GL_FRAMEBUFFER, |
| 84 | GL_COLOR_ATTACHMENT0, |
| 85 | GL_RENDERBUFFER, |
| 86 | output->rbo[output->current]); |
| 87 | |
| 88 | if (glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE) |
| 89 | return -1; |
| 90 | |
| 91 | return 0; |
| 92 | } |
| 93 | |
Benjamin Franzke | ec4d342 | 2011-03-14 12:07:26 +0100 | [diff] [blame] | 94 | static int |
| 95 | drm_output_present(struct wlsc_output *output_base) |
Kristian Høgsberg | ce5325d | 2010-06-14 11:54:00 -0400 | [diff] [blame] | 96 | { |
Benjamin Franzke | ec4d342 | 2011-03-14 12:07:26 +0100 | [diff] [blame] | 97 | struct drm_output *output = (struct drm_output *) output_base; |
| 98 | struct drm_compositor *c = |
| 99 | (struct drm_compositor *) output->base.compositor; |
Benjamin Franzke | 1178a3c | 2011-04-10 16:49:52 +0200 | [diff] [blame] | 100 | uint32_t fb_id = 0; |
Kristian Høgsberg | ce5325d | 2010-06-14 11:54:00 -0400 | [diff] [blame] | 101 | |
Benjamin Franzke | ec4d342 | 2011-03-14 12:07:26 +0100 | [diff] [blame] | 102 | if (drm_output_prepare_render(&output->base)) |
| 103 | return -1; |
| 104 | glFlush(); |
Kristian Høgsberg | ce5325d | 2010-06-14 11:54:00 -0400 | [diff] [blame] | 105 | |
Benjamin Franzke | ec4d342 | 2011-03-14 12:07:26 +0100 | [diff] [blame] | 106 | output->current ^= 1; |
Benjamin Franzke | eefc36c | 2011-03-11 16:39:20 +0100 | [diff] [blame] | 107 | |
Kristian Høgsberg | 191454e | 2011-10-20 17:51:45 -0400 | [diff] [blame^] | 108 | if (output->pending_fs_surf_fb_id != 0) { |
| 109 | fb_id = output->pending_fs_surf_fb_id; |
Benjamin Franzke | 1178a3c | 2011-04-10 16:49:52 +0200 | [diff] [blame] | 110 | } else { |
| 111 | fb_id = output->fb_id[output->current ^ 1]; |
| 112 | } |
| 113 | |
Benjamin Franzke | ec4d342 | 2011-03-14 12:07:26 +0100 | [diff] [blame] | 114 | drmModePageFlip(c->drm.fd, output->crtc_id, |
Benjamin Franzke | 1178a3c | 2011-04-10 16:49:52 +0200 | [diff] [blame] | 115 | fb_id, |
Benjamin Franzke | ec4d342 | 2011-03-14 12:07:26 +0100 | [diff] [blame] | 116 | DRM_MODE_PAGE_FLIP_EVENT, output); |
| 117 | |
| 118 | return 0; |
Kristian Høgsberg | fc783d4 | 2010-06-11 12:56:24 -0400 | [diff] [blame] | 119 | } |
| 120 | |
| 121 | static void |
| 122 | page_flip_handler(int fd, unsigned int frame, |
| 123 | unsigned int sec, unsigned int usec, void *data) |
| 124 | { |
Benjamin Franzke | 1178a3c | 2011-04-10 16:49:52 +0200 | [diff] [blame] | 125 | struct drm_output *output = (struct drm_output *) data; |
| 126 | struct drm_compositor *c = |
| 127 | (struct drm_compositor *) output->base.compositor; |
Kristian Høgsberg | fc783d4 | 2010-06-11 12:56:24 -0400 | [diff] [blame] | 128 | uint32_t msecs; |
| 129 | |
Kristian Høgsberg | 191454e | 2011-10-20 17:51:45 -0400 | [diff] [blame^] | 130 | if (output->fs_surf_fb_id) { |
| 131 | drmModeRmFB(c->drm.fd, output->fs_surf_fb_id); |
| 132 | output->fs_surf_fb_id = 0; |
Benjamin Franzke | 1178a3c | 2011-04-10 16:49:52 +0200 | [diff] [blame] | 133 | } |
| 134 | |
Kristian Høgsberg | 191454e | 2011-10-20 17:51:45 -0400 | [diff] [blame^] | 135 | if (output->pending_fs_surf_fb_id) { |
| 136 | output->fs_surf_fb_id = output->pending_fs_surf_fb_id; |
| 137 | output->pending_fs_surf_fb_id = 0; |
Benjamin Franzke | 1178a3c | 2011-04-10 16:49:52 +0200 | [diff] [blame] | 138 | } |
| 139 | |
Benjamin Franzke | ec4d342 | 2011-03-14 12:07:26 +0100 | [diff] [blame] | 140 | msecs = sec * 1000 + usec / 1000; |
Benjamin Franzke | 1178a3c | 2011-04-10 16:49:52 +0200 | [diff] [blame] | 141 | wlsc_output_finish_frame(&output->base, msecs); |
| 142 | } |
| 143 | |
| 144 | static int |
Benjamin Franzke | 66aa235 | 2011-04-20 17:06:13 +0200 | [diff] [blame] | 145 | drm_output_prepare_scanout_surface(struct wlsc_output *output_base, |
| 146 | struct wlsc_surface *es) |
Benjamin Franzke | 1178a3c | 2011-04-10 16:49:52 +0200 | [diff] [blame] | 147 | { |
| 148 | struct drm_output *output = (struct drm_output *) output_base; |
| 149 | struct drm_compositor *c = |
| 150 | (struct drm_compositor *) output->base.compositor; |
| 151 | EGLint handle, stride; |
| 152 | int ret; |
| 153 | uint32_t fb_id = 0; |
Benjamin Franzke | 060cf80 | 2011-04-30 09:32:11 +0200 | [diff] [blame] | 154 | struct gbm_bo *bo; |
Benjamin Franzke | 1178a3c | 2011-04-10 16:49:52 +0200 | [diff] [blame] | 155 | |
Kristian Høgsberg | 4d07a1c | 2011-05-06 14:03:12 -0400 | [diff] [blame] | 156 | if (es->x != output->base.x || |
| 157 | es->y != output->base.y || |
Kristian Høgsberg | 8f0ce05 | 2011-06-21 11:16:58 -0400 | [diff] [blame] | 158 | es->width != output->base.current->width || |
| 159 | es->height != output->base.current->height || |
Benjamin Franzke | 66aa235 | 2011-04-20 17:06:13 +0200 | [diff] [blame] | 160 | es->image == EGL_NO_IMAGE_KHR) |
| 161 | return -1; |
| 162 | |
Benjamin Franzke | 060cf80 | 2011-04-30 09:32:11 +0200 | [diff] [blame] | 163 | bo = gbm_bo_create_from_egl_image(c->gbm, |
| 164 | c->base.display, es->image, |
| 165 | es->width, es->height, |
| 166 | GBM_BO_USE_SCANOUT); |
| 167 | |
| 168 | handle = gbm_bo_get_handle(bo).s32; |
| 169 | stride = gbm_bo_get_pitch(bo); |
| 170 | |
| 171 | gbm_bo_destroy(bo); |
Benjamin Franzke | 1178a3c | 2011-04-10 16:49:52 +0200 | [diff] [blame] | 172 | |
Benjamin Franzke | 66aa235 | 2011-04-20 17:06:13 +0200 | [diff] [blame] | 173 | if (handle == 0) |
| 174 | return -1; |
| 175 | |
Benjamin Franzke | 1178a3c | 2011-04-10 16:49:52 +0200 | [diff] [blame] | 176 | ret = drmModeAddFB(c->drm.fd, |
Kristian Høgsberg | 8f0ce05 | 2011-06-21 11:16:58 -0400 | [diff] [blame] | 177 | output->base.current->width, |
| 178 | output->base.current->height, |
Benjamin Franzke | 66aa235 | 2011-04-20 17:06:13 +0200 | [diff] [blame] | 179 | 32, 32, stride, handle, &fb_id); |
| 180 | |
Benjamin Franzke | 1178a3c | 2011-04-10 16:49:52 +0200 | [diff] [blame] | 181 | if (ret) |
Benjamin Franzke | 66aa235 | 2011-04-20 17:06:13 +0200 | [diff] [blame] | 182 | return -1; |
Benjamin Franzke | 1178a3c | 2011-04-10 16:49:52 +0200 | [diff] [blame] | 183 | |
Kristian Høgsberg | 191454e | 2011-10-20 17:51:45 -0400 | [diff] [blame^] | 184 | output->pending_fs_surf_fb_id = fb_id; |
Benjamin Franzke | 1178a3c | 2011-04-10 16:49:52 +0200 | [diff] [blame] | 185 | |
Benjamin Franzke | 66aa235 | 2011-04-20 17:06:13 +0200 | [diff] [blame] | 186 | return 0; |
Kristian Høgsberg | fc783d4 | 2010-06-11 12:56:24 -0400 | [diff] [blame] | 187 | } |
| 188 | |
Benjamin Franzke | 431da9a | 2011-04-20 11:02:58 +0200 | [diff] [blame] | 189 | static int |
| 190 | drm_output_set_cursor(struct wlsc_output *output_base, |
Kristian Høgsberg | e4c40a4 | 2011-05-06 14:04:21 -0400 | [diff] [blame] | 191 | struct wlsc_input_device *eid) |
Benjamin Franzke | 431da9a | 2011-04-20 11:02:58 +0200 | [diff] [blame] | 192 | { |
| 193 | struct drm_output *output = (struct drm_output *) output_base; |
| 194 | struct drm_compositor *c = |
| 195 | (struct drm_compositor *) output->base.compositor; |
Benjamin Franzke | 431da9a | 2011-04-20 11:02:58 +0200 | [diff] [blame] | 196 | EGLint handle, stride; |
| 197 | int ret = -1; |
| 198 | pixman_region32_t cursor_region; |
Benjamin Franzke | 060cf80 | 2011-04-30 09:32:11 +0200 | [diff] [blame] | 199 | struct gbm_bo *bo; |
Benjamin Franzke | 431da9a | 2011-04-20 11:02:58 +0200 | [diff] [blame] | 200 | |
Kristian Høgsberg | e4c40a4 | 2011-05-06 14:04:21 -0400 | [diff] [blame] | 201 | if (eid == NULL) { |
| 202 | drmModeSetCursor(c->drm.fd, output->crtc_id, 0, 0, 0); |
| 203 | return 0; |
| 204 | } |
| 205 | |
Benjamin Franzke | 431da9a | 2011-04-20 11:02:58 +0200 | [diff] [blame] | 206 | pixman_region32_init_rect(&cursor_region, |
| 207 | eid->sprite->x, eid->sprite->y, |
| 208 | eid->sprite->width, eid->sprite->height); |
| 209 | |
| 210 | pixman_region32_intersect_rect(&cursor_region, &cursor_region, |
| 211 | output->base.x, output->base.y, |
Kristian Høgsberg | 8f0ce05 | 2011-06-21 11:16:58 -0400 | [diff] [blame] | 212 | output->base.current->width, |
| 213 | output->base.current->height); |
Benjamin Franzke | 431da9a | 2011-04-20 11:02:58 +0200 | [diff] [blame] | 214 | |
Benjamin Franzke | a8bdeae | 2011-06-28 22:56:43 +0200 | [diff] [blame] | 215 | if (!pixman_region32_not_empty(&cursor_region)) |
Benjamin Franzke | 431da9a | 2011-04-20 11:02:58 +0200 | [diff] [blame] | 216 | goto out; |
Benjamin Franzke | 431da9a | 2011-04-20 11:02:58 +0200 | [diff] [blame] | 217 | |
| 218 | if (eid->sprite->image == EGL_NO_IMAGE_KHR) |
| 219 | goto out; |
| 220 | |
| 221 | if (eid->sprite->width > 64 || eid->sprite->height > 64) |
| 222 | goto out; |
Benjamin Franzke | 117483d | 2011-08-30 11:38:26 +0200 | [diff] [blame] | 223 | |
Benjamin Franzke | 060cf80 | 2011-04-30 09:32:11 +0200 | [diff] [blame] | 224 | bo = gbm_bo_create_from_egl_image(c->gbm, |
| 225 | c->base.display, |
| 226 | eid->sprite->image, 64, 64, |
| 227 | GBM_BO_USE_CURSOR_64X64); |
| 228 | |
| 229 | handle = gbm_bo_get_handle(bo).s32; |
| 230 | stride = gbm_bo_get_pitch(bo); |
| 231 | |
| 232 | gbm_bo_destroy(bo); |
Benjamin Franzke | 431da9a | 2011-04-20 11:02:58 +0200 | [diff] [blame] | 233 | |
| 234 | if (stride != 64 * 4) { |
| 235 | fprintf(stderr, "info: cursor stride is != 64\n"); |
| 236 | goto out; |
| 237 | } |
| 238 | |
| 239 | ret = drmModeSetCursor(c->drm.fd, output->crtc_id, handle, 64, 64); |
| 240 | if (ret) { |
| 241 | fprintf(stderr, "failed to set cursor: %s\n", strerror(-ret)); |
| 242 | goto out; |
| 243 | } |
| 244 | |
| 245 | ret = drmModeMoveCursor(c->drm.fd, output->crtc_id, |
| 246 | eid->sprite->x - output->base.x, |
| 247 | eid->sprite->y - output->base.y); |
| 248 | if (ret) { |
| 249 | fprintf(stderr, "failed to move cursor: %s\n", strerror(-ret)); |
| 250 | goto out; |
| 251 | } |
| 252 | |
Benjamin Franzke | 431da9a | 2011-04-20 11:02:58 +0200 | [diff] [blame] | 253 | out: |
| 254 | pixman_region32_fini(&cursor_region); |
| 255 | if (ret) |
| 256 | drmModeSetCursor(c->drm.fd, output->crtc_id, 0, 0, 0); |
| 257 | return ret; |
| 258 | } |
| 259 | |
Matt Roper | 361d2ad | 2011-08-29 13:52:23 -0700 | [diff] [blame] | 260 | static void |
| 261 | drm_output_destroy(struct wlsc_output *output_base) |
| 262 | { |
| 263 | struct drm_output *output = (struct drm_output *) output_base; |
| 264 | struct drm_compositor *c = |
Benjamin Franzke | 117483d | 2011-08-30 11:38:26 +0200 | [diff] [blame] | 265 | (struct drm_compositor *) output->base.compositor; |
Matt Roper | 361d2ad | 2011-08-29 13:52:23 -0700 | [diff] [blame] | 266 | drmModeCrtcPtr origcrtc = output->original_crtc; |
| 267 | int i; |
| 268 | |
| 269 | /* Turn off hardware cursor */ |
Benjamin Franzke | 117483d | 2011-08-30 11:38:26 +0200 | [diff] [blame] | 270 | drm_output_set_cursor(&output->base, NULL); |
Matt Roper | 361d2ad | 2011-08-29 13:52:23 -0700 | [diff] [blame] | 271 | |
| 272 | /* Restore original CRTC state */ |
| 273 | drmModeSetCrtc(c->drm.fd, origcrtc->crtc_id, origcrtc->buffer_id, |
Benjamin Franzke | 117483d | 2011-08-30 11:38:26 +0200 | [diff] [blame] | 274 | origcrtc->x, origcrtc->y, |
| 275 | &output->connector_id, 1, &origcrtc->mode); |
Matt Roper | 361d2ad | 2011-08-29 13:52:23 -0700 | [diff] [blame] | 276 | drmModeFreeCrtc(origcrtc); |
| 277 | |
Benjamin Franzke | 48c4ea2 | 2011-08-30 11:44:56 +0200 | [diff] [blame] | 278 | glFramebufferRenderbuffer(GL_FRAMEBUFFER, |
| 279 | GL_COLOR_ATTACHMENT0, |
| 280 | GL_RENDERBUFFER, |
| 281 | 0); |
| 282 | |
| 283 | glBindRenderbuffer(GL_RENDERBUFFER, 0); |
| 284 | glDeleteRenderbuffers(2, output->rbo); |
| 285 | |
Matt Roper | 361d2ad | 2011-08-29 13:52:23 -0700 | [diff] [blame] | 286 | /* Destroy output buffers */ |
| 287 | for (i = 0; i < 2; i++) { |
| 288 | drmModeRmFB(c->drm.fd, output->fb_id[i]); |
| 289 | c->base.destroy_image(c->base.display, output->image[i]); |
| 290 | gbm_bo_destroy(output->bo[i]); |
| 291 | } |
| 292 | |
Benjamin Franzke | 48c4ea2 | 2011-08-30 11:44:56 +0200 | [diff] [blame] | 293 | c->crtc_allocator &= ~(1 << output->crtc_id); |
| 294 | c->connector_allocator &= ~(1 << output->connector_id); |
| 295 | |
| 296 | wlsc_output_destroy(&output->base); |
| 297 | wl_list_remove(&output->base.link); |
| 298 | |
Matt Roper | 361d2ad | 2011-08-29 13:52:23 -0700 | [diff] [blame] | 299 | free(output); |
| 300 | } |
| 301 | |
Kristian Høgsberg | b186847 | 2011-04-22 12:27:57 -0400 | [diff] [blame] | 302 | static int |
Kristian Høgsberg | fc783d4 | 2010-06-11 12:56:24 -0400 | [diff] [blame] | 303 | on_drm_input(int fd, uint32_t mask, void *data) |
| 304 | { |
| 305 | drmEventContext evctx; |
| 306 | |
| 307 | memset(&evctx, 0, sizeof evctx); |
| 308 | evctx.version = DRM_EVENT_CONTEXT_VERSION; |
| 309 | evctx.page_flip_handler = page_flip_handler; |
| 310 | drmHandleEvent(fd, &evctx); |
Kristian Høgsberg | b186847 | 2011-04-22 12:27:57 -0400 | [diff] [blame] | 311 | |
| 312 | return 1; |
Kristian Høgsberg | fc783d4 | 2010-06-11 12:56:24 -0400 | [diff] [blame] | 313 | } |
| 314 | |
| 315 | static int |
Kristian Høgsberg | ce5325d | 2010-06-14 11:54:00 -0400 | [diff] [blame] | 316 | init_egl(struct drm_compositor *ec, struct udev_device *device) |
Kristian Høgsberg | fc783d4 | 2010-06-11 12:56:24 -0400 | [diff] [blame] | 317 | { |
Kristian Høgsberg | 379b678 | 2010-07-28 22:52:28 -0400 | [diff] [blame] | 318 | EGLint major, minor; |
Kristian Høgsberg | 5fcd0aa | 2010-08-09 14:43:33 -0400 | [diff] [blame] | 319 | const char *extensions, *filename; |
| 320 | int fd; |
Kristian Høgsberg | 2c28aa5 | 2010-07-28 23:47:54 -0400 | [diff] [blame] | 321 | static const EGLint context_attribs[] = { |
| 322 | EGL_CONTEXT_CLIENT_VERSION, 2, |
| 323 | EGL_NONE |
| 324 | }; |
Kristian Høgsberg | fc783d4 | 2010-06-11 12:56:24 -0400 | [diff] [blame] | 325 | |
Kristian Høgsberg | 5fcd0aa | 2010-08-09 14:43:33 -0400 | [diff] [blame] | 326 | filename = udev_device_get_devnode(device); |
Kristian Høgsberg | 9cd7aca | 2011-04-11 13:19:16 -0400 | [diff] [blame] | 327 | fd = open(filename, O_RDWR, O_CLOEXEC); |
Kristian Høgsberg | 5fcd0aa | 2010-08-09 14:43:33 -0400 | [diff] [blame] | 328 | if (fd < 0) { |
Kristian Høgsberg | fc783d4 | 2010-06-11 12:56:24 -0400 | [diff] [blame] | 329 | /* Probably permissions error */ |
| 330 | fprintf(stderr, "couldn't open %s, skipping\n", |
| 331 | udev_device_get_devnode(device)); |
| 332 | return -1; |
| 333 | } |
| 334 | |
Benjamin Franzke | 2af7f10 | 2011-03-02 11:14:59 +0100 | [diff] [blame] | 335 | ec->drm.fd = fd; |
Benjamin Franzke | 060cf80 | 2011-04-30 09:32:11 +0200 | [diff] [blame] | 336 | ec->gbm = gbm_create_device(ec->drm.fd); |
| 337 | ec->base.display = eglGetDisplay(ec->gbm); |
Kristian Høgsberg | ce5325d | 2010-06-14 11:54:00 -0400 | [diff] [blame] | 338 | if (ec->base.display == NULL) { |
Kristian Høgsberg | fc783d4 | 2010-06-11 12:56:24 -0400 | [diff] [blame] | 339 | fprintf(stderr, "failed to create display\n"); |
| 340 | return -1; |
| 341 | } |
| 342 | |
Kristian Høgsberg | ce5325d | 2010-06-14 11:54:00 -0400 | [diff] [blame] | 343 | if (!eglInitialize(ec->base.display, &major, &minor)) { |
Kristian Høgsberg | fc783d4 | 2010-06-11 12:56:24 -0400 | [diff] [blame] | 344 | fprintf(stderr, "failed to initialize display\n"); |
| 345 | return -1; |
| 346 | } |
| 347 | |
Kristian Høgsberg | 379b678 | 2010-07-28 22:52:28 -0400 | [diff] [blame] | 348 | extensions = eglQueryString(ec->base.display, EGL_EXTENSIONS); |
| 349 | if (!strstr(extensions, "EGL_KHR_surfaceless_opengl")) { |
| 350 | fprintf(stderr, "EGL_KHR_surfaceless_opengl not available\n"); |
Kristian Høgsberg | fc783d4 | 2010-06-11 12:56:24 -0400 | [diff] [blame] | 351 | return -1; |
| 352 | } |
| 353 | |
Darxus | 55973f2 | 2010-11-22 21:24:39 -0500 | [diff] [blame] | 354 | if (!eglBindAPI(EGL_OPENGL_ES_API)) { |
| 355 | fprintf(stderr, "failed to bind api EGL_OPENGL_ES_API\n"); |
| 356 | return -1; |
| 357 | } |
| 358 | |
Kristian Høgsberg | 2c28aa5 | 2010-07-28 23:47:54 -0400 | [diff] [blame] | 359 | ec->base.context = eglCreateContext(ec->base.display, NULL, |
| 360 | EGL_NO_CONTEXT, context_attribs); |
Kristian Høgsberg | ce5325d | 2010-06-14 11:54:00 -0400 | [diff] [blame] | 361 | if (ec->base.context == NULL) { |
Kristian Høgsberg | fc783d4 | 2010-06-11 12:56:24 -0400 | [diff] [blame] | 362 | fprintf(stderr, "failed to create context\n"); |
| 363 | return -1; |
| 364 | } |
| 365 | |
Kristian Høgsberg | ce5325d | 2010-06-14 11:54:00 -0400 | [diff] [blame] | 366 | if (!eglMakeCurrent(ec->base.display, EGL_NO_SURFACE, |
| 367 | EGL_NO_SURFACE, ec->base.context)) { |
Kristian Høgsberg | fc783d4 | 2010-06-11 12:56:24 -0400 | [diff] [blame] | 368 | fprintf(stderr, "failed to make context current\n"); |
| 369 | return -1; |
| 370 | } |
| 371 | |
Kristian Høgsberg | fc783d4 | 2010-06-11 12:56:24 -0400 | [diff] [blame] | 372 | return 0; |
| 373 | } |
| 374 | |
| 375 | static drmModeModeInfo builtin_1024x768 = { |
| 376 | 63500, /* clock */ |
| 377 | 1024, 1072, 1176, 1328, 0, |
| 378 | 768, 771, 775, 798, 0, |
| 379 | 59920, |
| 380 | DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_PVSYNC, |
| 381 | 0, |
| 382 | "1024x768" |
| 383 | }; |
| 384 | |
Kristian Høgsberg | 8f0ce05 | 2011-06-21 11:16:58 -0400 | [diff] [blame] | 385 | |
| 386 | static int |
| 387 | drm_output_add_mode(struct drm_output *output, drmModeModeInfo *info) |
| 388 | { |
| 389 | struct drm_mode *mode; |
| 390 | |
| 391 | mode = malloc(sizeof *mode); |
| 392 | if (mode == NULL) |
| 393 | return -1; |
| 394 | |
| 395 | mode->base.flags = 0; |
| 396 | mode->base.width = info->hdisplay; |
| 397 | mode->base.height = info->vdisplay; |
| 398 | mode->base.refresh = info->vrefresh; |
| 399 | mode->mode_info = *info; |
| 400 | wl_list_insert(output->base.mode_list.prev, &mode->base.link); |
| 401 | |
| 402 | return 0; |
| 403 | } |
| 404 | |
| 405 | static int |
| 406 | drm_subpixel_to_wayland(int drm_value) |
| 407 | { |
| 408 | switch (drm_value) { |
| 409 | default: |
| 410 | case DRM_MODE_SUBPIXEL_UNKNOWN: |
| 411 | return WL_OUTPUT_SUBPIXEL_UNKNOWN; |
| 412 | case DRM_MODE_SUBPIXEL_NONE: |
| 413 | return WL_OUTPUT_SUBPIXEL_NONE; |
| 414 | case DRM_MODE_SUBPIXEL_HORIZONTAL_RGB: |
| 415 | return WL_OUTPUT_SUBPIXEL_HORIZONTAL_RGB; |
| 416 | case DRM_MODE_SUBPIXEL_HORIZONTAL_BGR: |
| 417 | return WL_OUTPUT_SUBPIXEL_HORIZONTAL_BGR; |
| 418 | case DRM_MODE_SUBPIXEL_VERTICAL_RGB: |
| 419 | return WL_OUTPUT_SUBPIXEL_VERTICAL_RGB; |
| 420 | case DRM_MODE_SUBPIXEL_VERTICAL_BGR: |
| 421 | return WL_OUTPUT_SUBPIXEL_VERTICAL_BGR; |
| 422 | } |
| 423 | } |
| 424 | |
Kristian Høgsberg | fc783d4 | 2010-06-11 12:56:24 -0400 | [diff] [blame] | 425 | static int |
Kristian Høgsberg | ce5325d | 2010-06-14 11:54:00 -0400 | [diff] [blame] | 426 | create_output_for_connector(struct drm_compositor *ec, |
Kristian Høgsberg | fc783d4 | 2010-06-11 12:56:24 -0400 | [diff] [blame] | 427 | drmModeRes *resources, |
Benjamin Franzke | eefc36c | 2011-03-11 16:39:20 +0100 | [diff] [blame] | 428 | drmModeConnector *connector, |
| 429 | int x, int y) |
Kristian Høgsberg | fc783d4 | 2010-06-11 12:56:24 -0400 | [diff] [blame] | 430 | { |
Kristian Høgsberg | ce5325d | 2010-06-14 11:54:00 -0400 | [diff] [blame] | 431 | struct drm_output *output; |
Kristian Høgsberg | 8f0ce05 | 2011-06-21 11:16:58 -0400 | [diff] [blame] | 432 | struct drm_mode *drm_mode; |
Kristian Høgsberg | fc783d4 | 2010-06-11 12:56:24 -0400 | [diff] [blame] | 433 | drmModeEncoder *encoder; |
Kristian Høgsberg | fc783d4 | 2010-06-11 12:56:24 -0400 | [diff] [blame] | 434 | int i, ret; |
Benjamin Franzke | 060cf80 | 2011-04-30 09:32:11 +0200 | [diff] [blame] | 435 | unsigned handle, stride; |
Kristian Høgsberg | fc783d4 | 2010-06-11 12:56:24 -0400 | [diff] [blame] | 436 | |
Benjamin Franzke | 2af7f10 | 2011-03-02 11:14:59 +0100 | [diff] [blame] | 437 | encoder = drmModeGetEncoder(ec->drm.fd, connector->encoders[0]); |
Kristian Høgsberg | fc783d4 | 2010-06-11 12:56:24 -0400 | [diff] [blame] | 438 | if (encoder == NULL) { |
| 439 | fprintf(stderr, "No encoder for connector.\n"); |
| 440 | return -1; |
| 441 | } |
| 442 | |
| 443 | for (i = 0; i < resources->count_crtcs; i++) { |
Marty Jack | 13d9db2 | 2011-02-09 19:01:42 -0500 | [diff] [blame] | 444 | if (encoder->possible_crtcs & (1 << i) && |
Benjamin Franzke | 9c26ff3 | 2011-03-15 15:08:41 +0100 | [diff] [blame] | 445 | !(ec->crtc_allocator & (1 << resources->crtcs[i]))) |
Kristian Høgsberg | fc783d4 | 2010-06-11 12:56:24 -0400 | [diff] [blame] | 446 | break; |
| 447 | } |
| 448 | if (i == resources->count_crtcs) { |
| 449 | fprintf(stderr, "No usable crtc for encoder.\n"); |
| 450 | return -1; |
| 451 | } |
| 452 | |
Kristian Høgsberg | 8f0ce05 | 2011-06-21 11:16:58 -0400 | [diff] [blame] | 453 | output = malloc(sizeof *output); |
| 454 | if (output == NULL) |
| 455 | return -1; |
| 456 | |
Kristian Høgsberg | ce5325d | 2010-06-14 11:54:00 -0400 | [diff] [blame] | 457 | memset(output, 0, sizeof *output); |
Kristian Høgsberg | 8f0ce05 | 2011-06-21 11:16:58 -0400 | [diff] [blame] | 458 | output->base.subpixel = drm_subpixel_to_wayland(connector->subpixel); |
| 459 | output->base.make = "unknown"; |
| 460 | output->base.model = "unknown"; |
| 461 | wl_list_init(&output->base.mode_list); |
Kristian Høgsberg | ce5325d | 2010-06-14 11:54:00 -0400 | [diff] [blame] | 462 | |
Kristian Høgsberg | fc783d4 | 2010-06-11 12:56:24 -0400 | [diff] [blame] | 463 | output->crtc_id = resources->crtcs[i]; |
Benjamin Franzke | 9c26ff3 | 2011-03-15 15:08:41 +0100 | [diff] [blame] | 464 | ec->crtc_allocator |= (1 << output->crtc_id); |
Kristian Høgsberg | fc783d4 | 2010-06-11 12:56:24 -0400 | [diff] [blame] | 465 | output->connector_id = connector->connector_id; |
Benjamin Franzke | 9c26ff3 | 2011-03-15 15:08:41 +0100 | [diff] [blame] | 466 | ec->connector_allocator |= (1 << output->connector_id); |
Kristian Høgsberg | 8f0ce05 | 2011-06-21 11:16:58 -0400 | [diff] [blame] | 467 | |
Matt Roper | 361d2ad | 2011-08-29 13:52:23 -0700 | [diff] [blame] | 468 | output->original_crtc = drmModeGetCrtc(ec->drm.fd, output->crtc_id); |
| 469 | |
Kristian Høgsberg | 8f0ce05 | 2011-06-21 11:16:58 -0400 | [diff] [blame] | 470 | for (i = 0; i < connector->count_modes; i++) |
| 471 | drm_output_add_mode(output, &connector->modes[i]); |
| 472 | if (connector->count_modes == 0) |
| 473 | drm_output_add_mode(output, &builtin_1024x768); |
| 474 | |
| 475 | drm_mode = container_of(output->base.mode_list.next, |
| 476 | struct drm_mode, base.link); |
| 477 | output->base.current = &drm_mode->base; |
| 478 | drm_mode->base.flags = |
| 479 | WL_OUTPUT_MODE_CURRENT | WL_OUTPUT_MODE_PREFERRED; |
| 480 | |
Benjamin Franzke | a16e002 | 2011-06-24 11:56:25 +0200 | [diff] [blame] | 481 | wlsc_output_init(&output->base, &ec->base, x, y, |
| 482 | connector->mmWidth, connector->mmHeight, 0); |
Kristian Høgsberg | 8f0ce05 | 2011-06-21 11:16:58 -0400 | [diff] [blame] | 483 | |
| 484 | wl_list_insert(ec->base.output_list.prev, &output->base.link); |
Kristian Høgsberg | fc783d4 | 2010-06-11 12:56:24 -0400 | [diff] [blame] | 485 | |
| 486 | drmModeFreeEncoder(encoder); |
| 487 | |
| 488 | glGenRenderbuffers(2, output->rbo); |
| 489 | for (i = 0; i < 2; i++) { |
| 490 | glBindRenderbuffer(GL_RENDERBUFFER, output->rbo[i]); |
| 491 | |
Benjamin Franzke | 060cf80 | 2011-04-30 09:32:11 +0200 | [diff] [blame] | 492 | output->bo[i] = |
| 493 | gbm_bo_create(ec->gbm, |
| 494 | output->base.current->width, |
| 495 | output->base.current->height, |
| 496 | GBM_BO_FORMAT_XRGB8888, |
Benjamin Franzke | 117483d | 2011-08-30 11:38:26 +0200 | [diff] [blame] | 497 | GBM_BO_USE_SCANOUT | |
| 498 | GBM_BO_USE_RENDERING); |
Benjamin Franzke | 060cf80 | 2011-04-30 09:32:11 +0200 | [diff] [blame] | 499 | output->image[i] = ec->base.create_image(ec->base.display, |
| 500 | NULL, |
| 501 | EGL_NATIVE_PIXMAP_KHR, |
| 502 | output->bo[i], NULL); |
| 503 | |
| 504 | |
Kristian Høgsberg | b5819dc | 2011-04-25 15:08:20 -0400 | [diff] [blame] | 505 | ec->base.image_target_renderbuffer_storage(GL_RENDERBUFFER, |
| 506 | output->image[i]); |
Benjamin Franzke | 060cf80 | 2011-04-30 09:32:11 +0200 | [diff] [blame] | 507 | stride = gbm_bo_get_pitch(output->bo[i]); |
| 508 | handle = gbm_bo_get_handle(output->bo[i]).u32; |
Kristian Høgsberg | fc783d4 | 2010-06-11 12:56:24 -0400 | [diff] [blame] | 509 | |
Benjamin Franzke | 2af7f10 | 2011-03-02 11:14:59 +0100 | [diff] [blame] | 510 | ret = drmModeAddFB(ec->drm.fd, |
Kristian Høgsberg | 8f0ce05 | 2011-06-21 11:16:58 -0400 | [diff] [blame] | 511 | output->base.current->width, |
| 512 | output->base.current->height, |
Kristian Høgsberg | fc783d4 | 2010-06-11 12:56:24 -0400 | [diff] [blame] | 513 | 32, 32, stride, handle, &output->fb_id[i]); |
| 514 | if (ret) { |
| 515 | fprintf(stderr, "failed to add fb %d: %m\n", i); |
| 516 | return -1; |
| 517 | } |
| 518 | } |
| 519 | |
| 520 | output->current = 0; |
| 521 | glFramebufferRenderbuffer(GL_FRAMEBUFFER, |
| 522 | GL_COLOR_ATTACHMENT0, |
| 523 | GL_RENDERBUFFER, |
| 524 | output->rbo[output->current]); |
Benjamin Franzke | 2af7f10 | 2011-03-02 11:14:59 +0100 | [diff] [blame] | 525 | ret = drmModeSetCrtc(ec->drm.fd, output->crtc_id, |
Kristian Høgsberg | fc783d4 | 2010-06-11 12:56:24 -0400 | [diff] [blame] | 526 | output->fb_id[output->current ^ 1], 0, 0, |
Kristian Høgsberg | 8f0ce05 | 2011-06-21 11:16:58 -0400 | [diff] [blame] | 527 | &output->connector_id, 1, |
| 528 | &drm_mode->mode_info); |
Kristian Høgsberg | fc783d4 | 2010-06-11 12:56:24 -0400 | [diff] [blame] | 529 | if (ret) { |
| 530 | fprintf(stderr, "failed to set mode: %m\n"); |
| 531 | return -1; |
| 532 | } |
| 533 | |
Benjamin Franzke | eefc36c | 2011-03-11 16:39:20 +0100 | [diff] [blame] | 534 | output->base.prepare_render = drm_output_prepare_render; |
Benjamin Franzke | ec4d342 | 2011-03-14 12:07:26 +0100 | [diff] [blame] | 535 | output->base.present = drm_output_present; |
Benjamin Franzke | 66aa235 | 2011-04-20 17:06:13 +0200 | [diff] [blame] | 536 | output->base.prepare_scanout_surface = |
| 537 | drm_output_prepare_scanout_surface; |
Benjamin Franzke | 431da9a | 2011-04-20 11:02:58 +0200 | [diff] [blame] | 538 | output->base.set_hardware_cursor = drm_output_set_cursor; |
Matt Roper | 361d2ad | 2011-08-29 13:52:23 -0700 | [diff] [blame] | 539 | output->base.destroy = drm_output_destroy; |
Benjamin Franzke | eefc36c | 2011-03-11 16:39:20 +0100 | [diff] [blame] | 540 | |
Kristian Høgsberg | fc783d4 | 2010-06-11 12:56:24 -0400 | [diff] [blame] | 541 | return 0; |
| 542 | } |
| 543 | |
| 544 | static int |
Kristian Høgsberg | 61a8251 | 2010-10-26 11:26:44 -0400 | [diff] [blame] | 545 | create_outputs(struct drm_compositor *ec, int option_connector) |
Kristian Høgsberg | fc783d4 | 2010-06-11 12:56:24 -0400 | [diff] [blame] | 546 | { |
| 547 | drmModeConnector *connector; |
| 548 | drmModeRes *resources; |
| 549 | int i; |
Benjamin Franzke | eefc36c | 2011-03-11 16:39:20 +0100 | [diff] [blame] | 550 | int x = 0, y = 0; |
Kristian Høgsberg | fc783d4 | 2010-06-11 12:56:24 -0400 | [diff] [blame] | 551 | |
Benjamin Franzke | 2af7f10 | 2011-03-02 11:14:59 +0100 | [diff] [blame] | 552 | resources = drmModeGetResources(ec->drm.fd); |
Kristian Høgsberg | fc783d4 | 2010-06-11 12:56:24 -0400 | [diff] [blame] | 553 | if (!resources) { |
| 554 | fprintf(stderr, "drmModeGetResources failed\n"); |
| 555 | return -1; |
| 556 | } |
| 557 | |
| 558 | for (i = 0; i < resources->count_connectors; i++) { |
Benjamin Franzke | 117483d | 2011-08-30 11:38:26 +0200 | [diff] [blame] | 559 | connector = drmModeGetConnector(ec->drm.fd, |
| 560 | resources->connectors[i]); |
Kristian Høgsberg | fc783d4 | 2010-06-11 12:56:24 -0400 | [diff] [blame] | 561 | if (connector == NULL) |
| 562 | continue; |
| 563 | |
| 564 | if (connector->connection == DRM_MODE_CONNECTED && |
| 565 | (option_connector == 0 || |
Benjamin Franzke | 9eaee35 | 2011-08-02 13:03:54 +0200 | [diff] [blame] | 566 | connector->connector_id == option_connector)) { |
Benjamin Franzke | eefc36c | 2011-03-11 16:39:20 +0100 | [diff] [blame] | 567 | if (create_output_for_connector(ec, resources, |
Benjamin Franzke | 439d986 | 2011-10-07 08:20:53 +0200 | [diff] [blame] | 568 | connector, x, y) < 0) { |
| 569 | drmModeFreeConnector(connector); |
| 570 | continue; |
| 571 | } |
Kristian Høgsberg | fc783d4 | 2010-06-11 12:56:24 -0400 | [diff] [blame] | 572 | |
Benjamin Franzke | 9eaee35 | 2011-08-02 13:03:54 +0200 | [diff] [blame] | 573 | x += container_of(ec->base.output_list.prev, |
| 574 | struct wlsc_output, |
| 575 | link)->current->width; |
| 576 | } |
Benjamin Franzke | eefc36c | 2011-03-11 16:39:20 +0100 | [diff] [blame] | 577 | |
Kristian Høgsberg | fc783d4 | 2010-06-11 12:56:24 -0400 | [diff] [blame] | 578 | drmModeFreeConnector(connector); |
| 579 | } |
| 580 | |
Kristian Høgsberg | ce5325d | 2010-06-14 11:54:00 -0400 | [diff] [blame] | 581 | if (wl_list_empty(&ec->base.output_list)) { |
Kristian Høgsberg | fc783d4 | 2010-06-11 12:56:24 -0400 | [diff] [blame] | 582 | fprintf(stderr, "No currently active connector found.\n"); |
| 583 | return -1; |
| 584 | } |
| 585 | |
| 586 | drmModeFreeResources(resources); |
| 587 | |
| 588 | return 0; |
| 589 | } |
| 590 | |
Benjamin Franzke | 9c26ff3 | 2011-03-15 15:08:41 +0100 | [diff] [blame] | 591 | static void |
| 592 | update_outputs(struct drm_compositor *ec) |
| 593 | { |
| 594 | drmModeConnector *connector; |
| 595 | drmModeRes *resources; |
| 596 | struct drm_output *output, *next; |
| 597 | int x = 0, y = 0; |
| 598 | int x_offset = 0, y_offset = 0; |
| 599 | uint32_t connected = 0, disconnects = 0; |
| 600 | int i; |
| 601 | |
| 602 | resources = drmModeGetResources(ec->drm.fd); |
| 603 | if (!resources) { |
| 604 | fprintf(stderr, "drmModeGetResources failed\n"); |
| 605 | return; |
| 606 | } |
| 607 | |
| 608 | /* collect new connects */ |
| 609 | for (i = 0; i < resources->count_connectors; i++) { |
Benjamin Franzke | 117483d | 2011-08-30 11:38:26 +0200 | [diff] [blame] | 610 | int connector_id = resources->connectors[i]; |
| 611 | |
| 612 | connector = drmModeGetConnector(ec->drm.fd, connector_id); |
Benjamin Franzke | 9c26ff3 | 2011-03-15 15:08:41 +0100 | [diff] [blame] | 613 | if (connector == NULL || |
| 614 | connector->connection != DRM_MODE_CONNECTED) |
| 615 | continue; |
| 616 | |
Benjamin Franzke | 117483d | 2011-08-30 11:38:26 +0200 | [diff] [blame] | 617 | connected |= (1 << connector_id); |
| 618 | |
| 619 | if (!(ec->connector_allocator & (1 << connector_id))) { |
| 620 | struct wlsc_output *last = |
Benjamin Franzke | 9c26ff3 | 2011-03-15 15:08:41 +0100 | [diff] [blame] | 621 | container_of(ec->base.output_list.prev, |
| 622 | struct wlsc_output, link); |
| 623 | |
| 624 | /* XXX: not yet needed, we die with 0 outputs */ |
| 625 | if (!wl_list_empty(&ec->base.output_list)) |
Benjamin Franzke | 117483d | 2011-08-30 11:38:26 +0200 | [diff] [blame] | 626 | x = last->x + last->current->width; |
Benjamin Franzke | 9c26ff3 | 2011-03-15 15:08:41 +0100 | [diff] [blame] | 627 | else |
| 628 | x = 0; |
| 629 | y = 0; |
| 630 | create_output_for_connector(ec, resources, |
| 631 | connector, x, y); |
Benjamin Franzke | 117483d | 2011-08-30 11:38:26 +0200 | [diff] [blame] | 632 | printf("connector %d connected\n", connector_id); |
| 633 | |
Benjamin Franzke | 9c26ff3 | 2011-03-15 15:08:41 +0100 | [diff] [blame] | 634 | } |
| 635 | drmModeFreeConnector(connector); |
| 636 | } |
| 637 | drmModeFreeResources(resources); |
| 638 | |
| 639 | disconnects = ec->connector_allocator & ~connected; |
| 640 | if (disconnects) { |
| 641 | wl_list_for_each_safe(output, next, &ec->base.output_list, |
| 642 | base.link) { |
| 643 | if (x_offset != 0 || y_offset != 0) { |
| 644 | wlsc_output_move(&output->base, |
| 645 | output->base.x - x_offset, |
| 646 | output->base.y - y_offset); |
| 647 | } |
| 648 | |
| 649 | if (disconnects & (1 << output->connector_id)) { |
| 650 | disconnects &= ~(1 << output->connector_id); |
| 651 | printf("connector %d disconnected\n", |
| 652 | output->connector_id); |
Kristian Høgsberg | 8f0ce05 | 2011-06-21 11:16:58 -0400 | [diff] [blame] | 653 | x_offset += output->base.current->width; |
Benjamin Franzke | 48c4ea2 | 2011-08-30 11:44:56 +0200 | [diff] [blame] | 654 | drm_output_destroy(&output->base); |
Benjamin Franzke | 9c26ff3 | 2011-03-15 15:08:41 +0100 | [diff] [blame] | 655 | } |
| 656 | } |
| 657 | } |
| 658 | |
| 659 | /* FIXME: handle zero outputs, without terminating */ |
| 660 | if (ec->connector_allocator == 0) |
| 661 | wl_display_terminate(ec->base.wl_display); |
| 662 | } |
| 663 | |
| 664 | static int |
| 665 | udev_event_is_hotplug(struct udev_device *device) |
| 666 | { |
| 667 | struct udev_list_entry *list, *hotplug_entry; |
Benjamin Franzke | 117483d | 2011-08-30 11:38:26 +0200 | [diff] [blame] | 668 | |
Benjamin Franzke | 9c26ff3 | 2011-03-15 15:08:41 +0100 | [diff] [blame] | 669 | list = udev_device_get_properties_list_entry(device); |
| 670 | |
| 671 | hotplug_entry = udev_list_entry_get_by_name(list, "HOTPLUG"); |
| 672 | if (hotplug_entry == NULL) |
| 673 | return 0; |
| 674 | |
| 675 | return strcmp(udev_list_entry_get_value(hotplug_entry), "1") == 0; |
| 676 | } |
| 677 | |
Kristian Høgsberg | b186847 | 2011-04-22 12:27:57 -0400 | [diff] [blame] | 678 | static int |
Benjamin Franzke | 9c26ff3 | 2011-03-15 15:08:41 +0100 | [diff] [blame] | 679 | udev_drm_event(int fd, uint32_t mask, void *data) |
| 680 | { |
| 681 | struct drm_compositor *ec = data; |
| 682 | struct udev_device *event; |
| 683 | |
| 684 | event = udev_monitor_receive_device(ec->udev_monitor); |
Benjamin Franzke | 117483d | 2011-08-30 11:38:26 +0200 | [diff] [blame] | 685 | |
Benjamin Franzke | 9c26ff3 | 2011-03-15 15:08:41 +0100 | [diff] [blame] | 686 | if (udev_event_is_hotplug(event)) |
| 687 | update_outputs(ec); |
| 688 | |
| 689 | udev_device_unref(event); |
Kristian Høgsberg | b186847 | 2011-04-22 12:27:57 -0400 | [diff] [blame] | 690 | |
| 691 | return 1; |
Benjamin Franzke | 9c26ff3 | 2011-03-15 15:08:41 +0100 | [diff] [blame] | 692 | } |
| 693 | |
Benjamin Franzke | 431da9a | 2011-04-20 11:02:58 +0200 | [diff] [blame] | 694 | static EGLImageKHR |
| 695 | drm_compositor_create_cursor_image(struct wlsc_compositor *ec, |
| 696 | int32_t width, int32_t height) |
| 697 | { |
Kristian Høgsberg | b5819dc | 2011-04-25 15:08:20 -0400 | [diff] [blame] | 698 | struct drm_compositor *c = (struct drm_compositor *) ec; |
Benjamin Franzke | 060cf80 | 2011-04-30 09:32:11 +0200 | [diff] [blame] | 699 | struct gbm_bo *bo; |
| 700 | EGLImageKHR image; |
Ander Conselvan de Oliveira | c483917 | 2011-08-16 14:25:15 +0300 | [diff] [blame] | 701 | uint32_t *pixels; |
| 702 | GLuint tex; |
Benjamin Franzke | 431da9a | 2011-04-20 11:02:58 +0200 | [diff] [blame] | 703 | |
| 704 | if (width > 64 || height > 64) |
| 705 | return EGL_NO_IMAGE_KHR; |
| 706 | |
Benjamin Franzke | 060cf80 | 2011-04-30 09:32:11 +0200 | [diff] [blame] | 707 | bo = gbm_bo_create(c->gbm, |
| 708 | /* width, height, */ 64, 64, |
| 709 | GBM_BO_FORMAT_ARGB8888, |
| 710 | GBM_BO_USE_CURSOR_64X64 | GBM_BO_USE_RENDERING); |
| 711 | |
| 712 | image = ec->create_image(c->base.display, NULL, |
| 713 | EGL_NATIVE_PIXMAP_KHR, bo, NULL); |
| 714 | gbm_bo_destroy(bo); |
| 715 | |
Ander Conselvan de Oliveira | c483917 | 2011-08-16 14:25:15 +0300 | [diff] [blame] | 716 | /* If the requested size is smaller than the allocated one, make the |
| 717 | * whole image transparent. */ |
| 718 | if (width != 64 || height != 64) { |
| 719 | pixels = calloc(64 * 64, sizeof *pixels); |
| 720 | |
| 721 | glGenTextures(1, &tex); |
| 722 | glBindTexture(GL_TEXTURE_2D, tex); |
Benjamin Franzke | 117483d | 2011-08-30 11:38:26 +0200 | [diff] [blame] | 723 | glTexParameteri(GL_TEXTURE_2D, |
| 724 | GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); |
| 725 | glTexParameteri(GL_TEXTURE_2D, |
| 726 | GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); |
| 727 | glTexParameteri(GL_TEXTURE_2D, |
| 728 | GL_TEXTURE_MIN_FILTER, GL_LINEAR); |
| 729 | glTexParameteri(GL_TEXTURE_2D, |
| 730 | GL_TEXTURE_MAG_FILTER, GL_LINEAR); |
Ander Conselvan de Oliveira | c483917 | 2011-08-16 14:25:15 +0300 | [diff] [blame] | 731 | |
| 732 | c->base.image_target_texture_2d(GL_TEXTURE_2D, image); |
Ander Conselvan de Oliveira | 90bc9e6 | 2011-08-17 14:50:17 +0300 | [diff] [blame] | 733 | glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 64, 64, |
Ander Conselvan de Oliveira | c483917 | 2011-08-16 14:25:15 +0300 | [diff] [blame] | 734 | GL_BGRA_EXT, GL_UNSIGNED_BYTE, pixels); |
| 735 | |
| 736 | glDeleteTextures(1, &tex); |
| 737 | free(pixels); |
| 738 | } |
| 739 | |
Benjamin Franzke | 060cf80 | 2011-04-30 09:32:11 +0200 | [diff] [blame] | 740 | return image; |
Benjamin Franzke | 431da9a | 2011-04-20 11:02:58 +0200 | [diff] [blame] | 741 | } |
| 742 | |
Kristian Høgsberg | caa6442 | 2010-12-01 16:52:15 -0500 | [diff] [blame] | 743 | static void |
| 744 | drm_destroy(struct wlsc_compositor *ec) |
| 745 | { |
| 746 | struct drm_compositor *d = (struct drm_compositor *) ec; |
| 747 | |
Matt Roper | 361d2ad | 2011-08-29 13:52:23 -0700 | [diff] [blame] | 748 | wlsc_compositor_shutdown(ec); |
| 749 | gbm_device_destroy(d->gbm); |
Kristian Høgsberg | e4762a6 | 2011-01-14 14:59:13 -0500 | [diff] [blame] | 750 | tty_destroy(d->tty); |
Kristian Høgsberg | caa6442 | 2010-12-01 16:52:15 -0500 | [diff] [blame] | 751 | |
Kristian Høgsberg | e4762a6 | 2011-01-14 14:59:13 -0500 | [diff] [blame] | 752 | free(d); |
Kristian Høgsberg | caa6442 | 2010-12-01 16:52:15 -0500 | [diff] [blame] | 753 | } |
| 754 | |
Kristian Høgsberg | 9396fc5 | 2011-05-06 15:15:37 -0400 | [diff] [blame] | 755 | static void |
| 756 | vt_func(struct wlsc_compositor *compositor, int event) |
| 757 | { |
| 758 | struct drm_compositor *ec = (struct drm_compositor *) compositor; |
Kristian Høgsberg | d8e181b | 2011-05-06 15:38:28 -0400 | [diff] [blame] | 759 | struct wlsc_output *output; |
Kristian Høgsberg | 9396fc5 | 2011-05-06 15:15:37 -0400 | [diff] [blame] | 760 | |
| 761 | switch (event) { |
| 762 | case TTY_ENTER_VT: |
| 763 | compositor->focus = 1; |
| 764 | drmSetMaster(ec->drm.fd); |
| 765 | compositor->state = WLSC_COMPOSITOR_ACTIVE; |
| 766 | wlsc_compositor_damage_all(compositor); |
| 767 | break; |
| 768 | case TTY_LEAVE_VT: |
| 769 | compositor->focus = 0; |
| 770 | compositor->state = WLSC_COMPOSITOR_SLEEPING; |
Kristian Høgsberg | d8e181b | 2011-05-06 15:38:28 -0400 | [diff] [blame] | 771 | |
| 772 | wl_list_for_each(output, &ec->base.output_list, link) |
| 773 | drm_output_set_cursor(output, NULL); |
| 774 | |
Matt Roper | 045037e | 2011-08-26 17:36:49 -0700 | [diff] [blame] | 775 | drmDropMaster(ec->drm.fd); |
Kristian Høgsberg | 9396fc5 | 2011-05-06 15:15:37 -0400 | [diff] [blame] | 776 | break; |
| 777 | }; |
| 778 | } |
| 779 | |
Kristian Høgsberg | 8d51f14 | 2011-07-15 21:28:38 -0400 | [diff] [blame] | 780 | static const char default_seat[] = "seat0"; |
| 781 | |
Kristian Høgsberg | 6c709a3 | 2011-05-06 14:52:41 -0400 | [diff] [blame] | 782 | static struct wlsc_compositor * |
Kristian Høgsberg | 8d51f14 | 2011-07-15 21:28:38 -0400 | [diff] [blame] | 783 | drm_compositor_create(struct wl_display *display, |
Tiago Vignatti | faee801 | 2011-09-01 15:58:17 -0400 | [diff] [blame] | 784 | int connector, const char *seat, int tty) |
Kristian Høgsberg | fc783d4 | 2010-06-11 12:56:24 -0400 | [diff] [blame] | 785 | { |
Kristian Høgsberg | ce5325d | 2010-06-14 11:54:00 -0400 | [diff] [blame] | 786 | struct drm_compositor *ec; |
Kristian Høgsberg | fc783d4 | 2010-06-11 12:56:24 -0400 | [diff] [blame] | 787 | struct udev_enumerate *e; |
Benjamin Franzke | 117483d | 2011-08-30 11:38:26 +0200 | [diff] [blame] | 788 | struct udev_list_entry *entry; |
Kristian Høgsberg | 8d51f14 | 2011-07-15 21:28:38 -0400 | [diff] [blame] | 789 | struct udev_device *device, *drm_device; |
| 790 | const char *path, *device_seat; |
Kristian Høgsberg | fc783d4 | 2010-06-11 12:56:24 -0400 | [diff] [blame] | 791 | struct wl_event_loop *loop; |
| 792 | |
Kristian Høgsberg | ce5325d | 2010-06-14 11:54:00 -0400 | [diff] [blame] | 793 | ec = malloc(sizeof *ec); |
| 794 | if (ec == NULL) |
| 795 | return NULL; |
| 796 | |
| 797 | memset(ec, 0, sizeof *ec); |
Kristian Høgsberg | fc783d4 | 2010-06-11 12:56:24 -0400 | [diff] [blame] | 798 | ec->udev = udev_new(); |
| 799 | if (ec->udev == NULL) { |
| 800 | fprintf(stderr, "failed to initialize udev context\n"); |
Kristian Høgsberg | ce5325d | 2010-06-14 11:54:00 -0400 | [diff] [blame] | 801 | return NULL; |
Kristian Høgsberg | fc783d4 | 2010-06-11 12:56:24 -0400 | [diff] [blame] | 802 | } |
| 803 | |
Kristian Høgsberg | fc783d4 | 2010-06-11 12:56:24 -0400 | [diff] [blame] | 804 | e = udev_enumerate_new(ec->udev); |
| 805 | udev_enumerate_add_match_subsystem(e, "drm"); |
Benjamin Franzke | a764ee5 | 2011-10-07 08:23:22 +0200 | [diff] [blame] | 806 | udev_enumerate_add_match_sysname(e, "card[0-9]*"); |
Kristian Høgsberg | 8d51f14 | 2011-07-15 21:28:38 -0400 | [diff] [blame] | 807 | |
Benjamin Franzke | 117483d | 2011-08-30 11:38:26 +0200 | [diff] [blame] | 808 | udev_enumerate_scan_devices(e); |
Kristian Høgsberg | 8d51f14 | 2011-07-15 21:28:38 -0400 | [diff] [blame] | 809 | drm_device = NULL; |
Benjamin Franzke | 117483d | 2011-08-30 11:38:26 +0200 | [diff] [blame] | 810 | udev_list_entry_foreach(entry, udev_enumerate_get_list_entry(e)) { |
Kristian Høgsberg | fc783d4 | 2010-06-11 12:56:24 -0400 | [diff] [blame] | 811 | path = udev_list_entry_get_name(entry); |
| 812 | device = udev_device_new_from_syspath(ec->udev, path); |
Benjamin Franzke | 117483d | 2011-08-30 11:38:26 +0200 | [diff] [blame] | 813 | device_seat = |
Kristian Høgsberg | 8d51f14 | 2011-07-15 21:28:38 -0400 | [diff] [blame] | 814 | udev_device_get_property_value(device, "ID_SEAT"); |
| 815 | if (!device_seat) |
| 816 | device_seat = default_seat; |
| 817 | if (strcmp(device_seat, seat) == 0) { |
| 818 | drm_device = device; |
| 819 | break; |
| 820 | } |
| 821 | udev_device_unref(device); |
Kristian Høgsberg | fc783d4 | 2010-06-11 12:56:24 -0400 | [diff] [blame] | 822 | } |
Kristian Høgsberg | 8d51f14 | 2011-07-15 21:28:38 -0400 | [diff] [blame] | 823 | |
Kristian Høgsberg | 8d51f14 | 2011-07-15 21:28:38 -0400 | [diff] [blame] | 824 | if (drm_device == NULL) { |
Kristian Høgsberg | ce5325d | 2010-06-14 11:54:00 -0400 | [diff] [blame] | 825 | fprintf(stderr, "no drm device found\n"); |
| 826 | return NULL; |
| 827 | } |
Kristian Høgsberg | fc783d4 | 2010-06-11 12:56:24 -0400 | [diff] [blame] | 828 | |
Kristian Høgsberg | 5fcd0aa | 2010-08-09 14:43:33 -0400 | [diff] [blame] | 829 | ec->base.wl_display = display; |
Kristian Høgsberg | 8d51f14 | 2011-07-15 21:28:38 -0400 | [diff] [blame] | 830 | if (init_egl(ec, drm_device) < 0) { |
Kristian Høgsberg | ce5325d | 2010-06-14 11:54:00 -0400 | [diff] [blame] | 831 | fprintf(stderr, "failed to initialize egl\n"); |
| 832 | return NULL; |
| 833 | } |
Kristian Høgsberg | 8525a50 | 2011-01-14 16:20:21 -0500 | [diff] [blame] | 834 | |
Kristian Høgsberg | 8d51f14 | 2011-07-15 21:28:38 -0400 | [diff] [blame] | 835 | udev_device_unref(drm_device); |
| 836 | |
Kristian Høgsberg | 8525a50 | 2011-01-14 16:20:21 -0500 | [diff] [blame] | 837 | ec->base.destroy = drm_destroy; |
Benjamin Franzke | 431da9a | 2011-04-20 11:02:58 +0200 | [diff] [blame] | 838 | ec->base.create_cursor_image = drm_compositor_create_cursor_image; |
| 839 | |
Kristian Høgsberg | 8525a50 | 2011-01-14 16:20:21 -0500 | [diff] [blame] | 840 | ec->base.focus = 1; |
| 841 | |
Benjamin Franzke | 5b2cb6f | 2011-02-18 16:54:55 +0100 | [diff] [blame] | 842 | glGenFramebuffers(1, &ec->base.fbo); |
| 843 | glBindFramebuffer(GL_FRAMEBUFFER, ec->base.fbo); |
| 844 | |
Benjamin Franzke | d59eb1c | 2011-04-29 22:14:54 +0200 | [diff] [blame] | 845 | /* Can't init base class until we have a current egl context */ |
| 846 | if (wlsc_compositor_init(&ec->base, display) < 0) |
| 847 | return NULL; |
| 848 | |
Kristian Høgsberg | 61a8251 | 2010-10-26 11:26:44 -0400 | [diff] [blame] | 849 | if (create_outputs(ec, connector) < 0) { |
Kristian Høgsberg | ce5325d | 2010-06-14 11:54:00 -0400 | [diff] [blame] | 850 | fprintf(stderr, "failed to create output for %s\n", path); |
| 851 | return NULL; |
| 852 | } |
| 853 | |
Benjamin Franzke | 02dee2c | 2011-10-07 08:27:26 +0200 | [diff] [blame] | 854 | udev_enumerate_unref(e); |
| 855 | path = NULL; |
| 856 | |
Kristian Høgsberg | 86ec8e8 | 2011-07-19 16:10:11 -0700 | [diff] [blame] | 857 | evdev_input_add_devices(&ec->base, ec->udev, seat); |
Kristian Høgsberg | ce5325d | 2010-06-14 11:54:00 -0400 | [diff] [blame] | 858 | |
| 859 | loop = wl_display_get_event_loop(ec->base.wl_display); |
| 860 | ec->drm_source = |
Benjamin Franzke | 2af7f10 | 2011-03-02 11:14:59 +0100 | [diff] [blame] | 861 | wl_event_loop_add_fd(loop, ec->drm.fd, |
Kristian Høgsberg | ce5325d | 2010-06-14 11:54:00 -0400 | [diff] [blame] | 862 | WL_EVENT_READABLE, on_drm_input, ec); |
Tiago Vignatti | faee801 | 2011-09-01 15:58:17 -0400 | [diff] [blame] | 863 | ec->tty = tty_create(&ec->base, vt_func, tty); |
Kristian Høgsberg | ce5325d | 2010-06-14 11:54:00 -0400 | [diff] [blame] | 864 | |
Benjamin Franzke | 9c26ff3 | 2011-03-15 15:08:41 +0100 | [diff] [blame] | 865 | ec->udev_monitor = udev_monitor_new_from_netlink(ec->udev, "udev"); |
| 866 | if (ec->udev_monitor == NULL) { |
| 867 | fprintf(stderr, "failed to intialize udev monitor\n"); |
| 868 | return NULL; |
| 869 | } |
| 870 | udev_monitor_filter_add_match_subsystem_devtype(ec->udev_monitor, |
| 871 | "drm", NULL); |
| 872 | ec->udev_drm_source = |
Benjamin Franzke | 117483d | 2011-08-30 11:38:26 +0200 | [diff] [blame] | 873 | wl_event_loop_add_fd(loop, |
| 874 | udev_monitor_get_fd(ec->udev_monitor), |
Benjamin Franzke | 9c26ff3 | 2011-03-15 15:08:41 +0100 | [diff] [blame] | 875 | WL_EVENT_READABLE, udev_drm_event, ec); |
| 876 | |
| 877 | if (udev_monitor_enable_receiving(ec->udev_monitor) < 0) { |
| 878 | fprintf(stderr, "failed to enable udev-monitor receiving\n"); |
| 879 | return NULL; |
| 880 | } |
| 881 | |
Kristian Høgsberg | ce5325d | 2010-06-14 11:54:00 -0400 | [diff] [blame] | 882 | return &ec->base; |
Kristian Høgsberg | fc783d4 | 2010-06-11 12:56:24 -0400 | [diff] [blame] | 883 | } |
Kristian Høgsberg | 1c56218 | 2011-05-02 22:09:20 -0400 | [diff] [blame] | 884 | |
| 885 | struct wlsc_compositor * |
Kristian Høgsberg | 6c709a3 | 2011-05-06 14:52:41 -0400 | [diff] [blame] | 886 | backend_init(struct wl_display *display, char *options); |
| 887 | |
| 888 | WL_EXPORT struct wlsc_compositor * |
Kristian Høgsberg | 1c56218 | 2011-05-02 22:09:20 -0400 | [diff] [blame] | 889 | backend_init(struct wl_display *display, char *options) |
| 890 | { |
Kristian Høgsberg | 8050bd2 | 2011-05-04 15:08:04 -0400 | [diff] [blame] | 891 | int connector = 0, i; |
Kristian Høgsberg | 8d51f14 | 2011-07-15 21:28:38 -0400 | [diff] [blame] | 892 | const char *seat; |
Kristian Høgsberg | 1c56218 | 2011-05-02 22:09:20 -0400 | [diff] [blame] | 893 | char *p, *value; |
Tiago Vignatti | faee801 | 2011-09-01 15:58:17 -0400 | [diff] [blame] | 894 | int tty = 1; |
Kristian Høgsberg | 1c56218 | 2011-05-02 22:09:20 -0400 | [diff] [blame] | 895 | |
Tiago Vignatti | faee801 | 2011-09-01 15:58:17 -0400 | [diff] [blame] | 896 | static char * const tokens[] = { "connector", "seat", "tty", NULL }; |
Benjamin Franzke | 117483d | 2011-08-30 11:38:26 +0200 | [diff] [blame] | 897 | |
Kristian Høgsberg | 1c56218 | 2011-05-02 22:09:20 -0400 | [diff] [blame] | 898 | p = options; |
Kristian Høgsberg | 8d51f14 | 2011-07-15 21:28:38 -0400 | [diff] [blame] | 899 | seat = default_seat; |
Kristian Høgsberg | 1c56218 | 2011-05-02 22:09:20 -0400 | [diff] [blame] | 900 | while (i = getsubopt(&p, tokens, &value), i != -1) { |
| 901 | switch (i) { |
| 902 | case 0: |
Kristian Høgsberg | 8050bd2 | 2011-05-04 15:08:04 -0400 | [diff] [blame] | 903 | connector = strtol(value, NULL, 0); |
Kristian Høgsberg | 1c56218 | 2011-05-02 22:09:20 -0400 | [diff] [blame] | 904 | break; |
Kristian Høgsberg | 8d51f14 | 2011-07-15 21:28:38 -0400 | [diff] [blame] | 905 | case 1: |
| 906 | seat = value; |
| 907 | break; |
Tiago Vignatti | faee801 | 2011-09-01 15:58:17 -0400 | [diff] [blame] | 908 | case 2: |
| 909 | tty = strtol(value, NULL, 0); |
| 910 | break; |
Kristian Høgsberg | 1c56218 | 2011-05-02 22:09:20 -0400 | [diff] [blame] | 911 | } |
| 912 | } |
| 913 | |
Tiago Vignatti | faee801 | 2011-09-01 15:58:17 -0400 | [diff] [blame] | 914 | return drm_compositor_create(display, connector, seat, tty); |
Kristian Høgsberg | 1c56218 | 2011-05-02 22:09:20 -0400 | [diff] [blame] | 915 | } |