2010-06-11 20:56:24 +04:00
|
|
|
/*
|
Change remaining GPLv2 headers to MIT
The files in question are copyright Benjamin Franzke (who agrees),
Intel Corporation, Red Hat and myself. On behalf of Red Hat,
Richard Fontana says:
"Therefore, to the extent that Red Hat, Inc. has any copyright
interest in the files you cited as of this date (compositor-drm.c,
compositor.c, compositor.h, screenshooter.c in
http://cgit.freedesktop.org/wayland/wayland-demos/tree/compositor),
Red Hat hereby elects to apply the CC0 1.0 Universal Public Domain
Dedication to such copyrighted material. See:
http://creativecommons.org/publicdomain/zero/1.0/legalcode .
Thanks,
Richard E. Fontana
Open Source Licensing and Patent Counsel
Red Hat, Inc."
2011-09-15 23:43:14 +04:00
|
|
|
* Copyright © 2008-2011 Kristian Høgsberg
|
|
|
|
* Copyright © 2011 Intel Corporation
|
2010-06-11 20:56:24 +04:00
|
|
|
*
|
Change remaining GPLv2 headers to MIT
The files in question are copyright Benjamin Franzke (who agrees),
Intel Corporation, Red Hat and myself. On behalf of Red Hat,
Richard Fontana says:
"Therefore, to the extent that Red Hat, Inc. has any copyright
interest in the files you cited as of this date (compositor-drm.c,
compositor.c, compositor.h, screenshooter.c in
http://cgit.freedesktop.org/wayland/wayland-demos/tree/compositor),
Red Hat hereby elects to apply the CC0 1.0 Universal Public Domain
Dedication to such copyrighted material. See:
http://creativecommons.org/publicdomain/zero/1.0/legalcode .
Thanks,
Richard E. Fontana
Open Source Licensing and Patent Counsel
Red Hat, Inc."
2011-09-15 23:43:14 +04:00
|
|
|
* Permission to use, copy, modify, distribute, and sell this software and
|
|
|
|
* its documentation for any purpose is hereby granted without fee, provided
|
|
|
|
* that the above copyright notice appear in all copies and that both that
|
|
|
|
* copyright notice and this permission notice appear in supporting
|
|
|
|
* documentation, and that the name of the copyright holders not be used in
|
|
|
|
* advertising or publicity pertaining to distribution of the software
|
|
|
|
* without specific, written prior permission. The copyright holders make
|
|
|
|
* no representations about the suitability of this software for any
|
|
|
|
* purpose. It is provided "as is" without express or implied warranty.
|
2010-06-11 20:56:24 +04:00
|
|
|
*
|
Change remaining GPLv2 headers to MIT
The files in question are copyright Benjamin Franzke (who agrees),
Intel Corporation, Red Hat and myself. On behalf of Red Hat,
Richard Fontana says:
"Therefore, to the extent that Red Hat, Inc. has any copyright
interest in the files you cited as of this date (compositor-drm.c,
compositor.c, compositor.h, screenshooter.c in
http://cgit.freedesktop.org/wayland/wayland-demos/tree/compositor),
Red Hat hereby elects to apply the CC0 1.0 Universal Public Domain
Dedication to such copyrighted material. See:
http://creativecommons.org/publicdomain/zero/1.0/legalcode .
Thanks,
Richard E. Fontana
Open Source Licensing and Patent Counsel
Red Hat, Inc."
2011-09-15 23:43:14 +04:00
|
|
|
* THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
|
|
|
|
* SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
|
|
|
* FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
|
|
|
* SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
|
|
|
|
* RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
|
|
|
|
* CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
|
|
|
|
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
2010-06-11 20:56:24 +04:00
|
|
|
*/
|
|
|
|
|
2011-04-12 19:34:32 +04:00
|
|
|
#define _GNU_SOURCE
|
|
|
|
|
2012-02-23 18:45:49 +04:00
|
|
|
#include <errno.h>
|
2010-06-11 20:56:24 +04:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <fcntl.h>
|
|
|
|
#include <unistd.h>
|
2012-04-10 08:11:50 +04:00
|
|
|
#include <linux/input.h>
|
2012-06-26 18:09:14 +04:00
|
|
|
#include <assert.h>
|
2010-06-11 20:56:24 +04:00
|
|
|
|
2011-03-02 13:56:04 +03:00
|
|
|
#include <xf86drm.h>
|
|
|
|
#include <xf86drmMode.h>
|
2012-02-23 18:45:49 +04:00
|
|
|
#include <drm_fourcc.h>
|
2011-03-02 13:56:04 +03:00
|
|
|
|
2011-04-30 11:32:11 +04:00
|
|
|
#include <gbm.h>
|
2012-02-29 21:53:50 +04:00
|
|
|
#include <libbacklight.h>
|
2012-08-03 21:30:30 +04:00
|
|
|
#include <libudev.h>
|
2011-04-30 11:32:11 +04:00
|
|
|
|
2010-06-11 20:56:24 +04:00
|
|
|
#include "compositor.h"
|
2011-12-19 03:14:03 +04:00
|
|
|
#include "evdev.h"
|
2012-01-30 17:04:04 +04:00
|
|
|
#include "launcher-util.h"
|
2010-06-11 20:56:24 +04:00
|
|
|
|
2012-06-28 19:28:15 +04:00
|
|
|
static int option_current_mode = 0;
|
2012-07-31 05:51:08 +04:00
|
|
|
static char *output_name;
|
|
|
|
static char *output_mode;
|
|
|
|
static struct wl_list configured_output_list;
|
|
|
|
|
|
|
|
enum output_config {
|
|
|
|
OUTPUT_CONFIG_INVALID = 0,
|
|
|
|
OUTPUT_CONFIG_OFF,
|
|
|
|
OUTPUT_CONFIG_PREFERRED,
|
|
|
|
OUTPUT_CONFIG_CURRENT,
|
2012-08-01 01:30:41 +04:00
|
|
|
OUTPUT_CONFIG_MODE,
|
|
|
|
OUTPUT_CONFIG_MODELINE
|
2012-07-31 05:51:08 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
struct drm_configured_output {
|
|
|
|
char *name;
|
|
|
|
char *mode;
|
|
|
|
int32_t width, height;
|
2012-08-01 01:30:41 +04:00
|
|
|
drmModeModeInfo crtc_mode;
|
2012-07-31 05:51:08 +04:00
|
|
|
enum output_config config;
|
|
|
|
struct wl_list link;
|
|
|
|
};
|
2012-06-28 19:28:15 +04:00
|
|
|
|
2010-06-14 19:54:00 +04:00
|
|
|
struct drm_compositor {
|
Rename wayland-compositor to weston
This rename addresses a few problems around the split between core
Wayland and the wayland-demos repository.
1) Initially, we had one big repository with protocol code, sample
compositor and sample clients. We split that repository to make it
possible to implement the protocol without pulling in the sample/demo
code. At this point, the compositor is more than just a "demo" and
wayland-demos doesn't send the right message. The sample compositor
is a useful, self-contained project in it's own right, and we want to
move away from the "demos" label.
2) Another problem is that the wayland-demos compositor is often
called "the wayland compsitor", but it's really just one possible
compositor. Existing X11 compositors are expected to add Wayland
support and then gradually phase out/modularize the X11 support, for
example. Conversely, it's hard to talk about the wayland-demos
compositor specifically as opposed to, eg, the wayland protocol or a
wayland compositor in general.
We are also renaming the repo to weston, and the compositor
subdirectory to src/, to emphasize that the main "output" is the
compositor.
2012-01-03 19:29:47 +04:00
|
|
|
struct weston_compositor base;
|
2010-06-14 19:54:00 +04:00
|
|
|
|
|
|
|
struct udev *udev;
|
|
|
|
struct wl_event_source *drm_source;
|
|
|
|
|
2011-03-15 17:08:41 +03:00
|
|
|
struct udev_monitor *udev_monitor;
|
|
|
|
struct wl_event_source *udev_drm_source;
|
|
|
|
|
2011-03-02 13:14:59 +03:00
|
|
|
struct {
|
2012-03-11 23:05:21 +04:00
|
|
|
int id;
|
2011-03-02 13:14:59 +03:00
|
|
|
int fd;
|
|
|
|
} drm;
|
2011-04-30 11:32:11 +04:00
|
|
|
struct gbm_device *gbm;
|
2012-02-23 18:45:49 +04:00
|
|
|
uint32_t *crtcs;
|
|
|
|
int num_crtcs;
|
2011-02-10 03:01:42 +03:00
|
|
|
uint32_t crtc_allocator;
|
2011-03-15 17:08:41 +03:00
|
|
|
uint32_t connector_allocator;
|
2011-01-14 22:59:13 +03:00
|
|
|
struct tty *tty;
|
2011-12-02 15:07:27 +04:00
|
|
|
|
2012-03-29 06:53:49 +04:00
|
|
|
struct gbm_surface *dummy_surface;
|
|
|
|
EGLSurface dummy_egl_surface;
|
|
|
|
|
2012-08-09 23:18:28 +04:00
|
|
|
/* we need these parameters in order to not fail drmModeAddFB2()
|
|
|
|
* due to out of bounds dimensions, and then mistakenly set
|
|
|
|
* sprites_are_broken:
|
|
|
|
*/
|
2012-08-10 01:19:23 +04:00
|
|
|
int32_t min_width, max_width;
|
|
|
|
int32_t min_height, max_height;
|
2012-08-09 23:18:28 +04:00
|
|
|
|
2012-02-23 18:45:49 +04:00
|
|
|
struct wl_list sprite_list;
|
2012-03-06 04:57:35 +04:00
|
|
|
int sprites_are_broken;
|
2012-02-23 18:45:49 +04:00
|
|
|
|
2012-08-09 22:24:45 +04:00
|
|
|
int cursors_are_broken;
|
|
|
|
|
2011-12-02 15:07:27 +04:00
|
|
|
uint32_t prev_state;
|
2010-06-14 19:54:00 +04:00
|
|
|
};
|
|
|
|
|
2011-06-21 19:16:58 +04:00
|
|
|
struct drm_mode {
|
Rename wayland-compositor to weston
This rename addresses a few problems around the split between core
Wayland and the wayland-demos repository.
1) Initially, we had one big repository with protocol code, sample
compositor and sample clients. We split that repository to make it
possible to implement the protocol without pulling in the sample/demo
code. At this point, the compositor is more than just a "demo" and
wayland-demos doesn't send the right message. The sample compositor
is a useful, self-contained project in it's own right, and we want to
move away from the "demos" label.
2) Another problem is that the wayland-demos compositor is often
called "the wayland compsitor", but it's really just one possible
compositor. Existing X11 compositors are expected to add Wayland
support and then gradually phase out/modularize the X11 support, for
example. Conversely, it's hard to talk about the wayland-demos
compositor specifically as opposed to, eg, the wayland protocol or a
wayland compositor in general.
We are also renaming the repo to weston, and the compositor
subdirectory to src/, to emphasize that the main "output" is the
compositor.
2012-01-03 19:29:47 +04:00
|
|
|
struct weston_mode base;
|
2011-06-21 19:16:58 +04:00
|
|
|
drmModeModeInfo mode_info;
|
|
|
|
};
|
|
|
|
|
2012-05-02 17:42:21 +04:00
|
|
|
struct drm_output;
|
|
|
|
|
|
|
|
struct drm_fb {
|
|
|
|
struct gbm_bo *bo;
|
|
|
|
struct drm_output *output;
|
|
|
|
uint32_t fb_id;
|
|
|
|
int is_client_buffer;
|
|
|
|
struct wl_buffer *buffer;
|
|
|
|
struct wl_listener buffer_destroy_listener;
|
|
|
|
};
|
|
|
|
|
2010-06-14 19:54:00 +04:00
|
|
|
struct drm_output {
|
Rename wayland-compositor to weston
This rename addresses a few problems around the split between core
Wayland and the wayland-demos repository.
1) Initially, we had one big repository with protocol code, sample
compositor and sample clients. We split that repository to make it
possible to implement the protocol without pulling in the sample/demo
code. At this point, the compositor is more than just a "demo" and
wayland-demos doesn't send the right message. The sample compositor
is a useful, self-contained project in it's own right, and we want to
move away from the "demos" label.
2) Another problem is that the wayland-demos compositor is often
called "the wayland compsitor", but it's really just one possible
compositor. Existing X11 compositors are expected to add Wayland
support and then gradually phase out/modularize the X11 support, for
example. Conversely, it's hard to talk about the wayland-demos
compositor specifically as opposed to, eg, the wayland protocol or a
wayland compositor in general.
We are also renaming the repo to weston, and the compositor
subdirectory to src/, to emphasize that the main "output" is the
compositor.
2012-01-03 19:29:47 +04:00
|
|
|
struct weston_output base;
|
2010-06-14 19:54:00 +04:00
|
|
|
|
2012-07-27 01:57:15 +04:00
|
|
|
char *name;
|
2010-06-14 19:54:00 +04:00
|
|
|
uint32_t crtc_id;
|
2012-08-09 05:27:37 +04:00
|
|
|
int pipe;
|
2010-06-14 19:54:00 +04:00
|
|
|
uint32_t connector_id;
|
2011-08-30 00:52:23 +04:00
|
|
|
drmModeCrtcPtr original_crtc;
|
2012-03-12 02:27:41 +04:00
|
|
|
|
2012-06-26 18:09:13 +04:00
|
|
|
int vblank_pending;
|
|
|
|
int page_flip_pending;
|
|
|
|
|
2012-03-12 02:27:41 +04:00
|
|
|
struct gbm_surface *surface;
|
2012-05-03 19:39:35 +04:00
|
|
|
struct gbm_bo *cursor_bo[2];
|
2012-08-03 19:30:18 +04:00
|
|
|
struct weston_plane cursor_plane;
|
|
|
|
struct weston_plane fb_plane;
|
2012-08-03 19:50:05 +04:00
|
|
|
struct weston_surface *cursor_surface;
|
|
|
|
int current_cursor;
|
2012-03-12 02:27:41 +04:00
|
|
|
EGLSurface egl_surface;
|
2012-05-02 17:42:21 +04:00
|
|
|
struct drm_fb *current, *next;
|
2012-02-29 21:53:50 +04:00
|
|
|
struct backlight *backlight;
|
2010-06-14 19:54:00 +04:00
|
|
|
};
|
|
|
|
|
2012-02-23 18:45:49 +04:00
|
|
|
/*
|
|
|
|
* An output has a primary display plane plus zero or more sprites for
|
|
|
|
* blending display contents.
|
|
|
|
*/
|
|
|
|
struct drm_sprite {
|
|
|
|
struct wl_list link;
|
|
|
|
|
|
|
|
uint32_t fb_id;
|
|
|
|
uint32_t pending_fb_id;
|
|
|
|
struct weston_surface *surface;
|
|
|
|
struct weston_surface *pending_surface;
|
2012-08-03 19:30:18 +04:00
|
|
|
struct weston_plane plane;
|
2012-02-23 18:45:49 +04:00
|
|
|
|
2012-06-26 18:09:13 +04:00
|
|
|
struct drm_output *output;
|
|
|
|
|
2012-02-23 18:45:49 +04:00
|
|
|
struct drm_compositor *compositor;
|
|
|
|
|
|
|
|
struct wl_listener destroy_listener;
|
|
|
|
struct wl_listener pending_destroy_listener;
|
|
|
|
|
|
|
|
uint32_t possible_crtcs;
|
|
|
|
uint32_t plane_id;
|
|
|
|
uint32_t count_formats;
|
|
|
|
|
|
|
|
int32_t src_x, src_y;
|
|
|
|
uint32_t src_w, src_h;
|
|
|
|
uint32_t dest_x, dest_y;
|
|
|
|
uint32_t dest_w, dest_h;
|
|
|
|
|
|
|
|
uint32_t formats[];
|
|
|
|
};
|
|
|
|
|
2012-08-03 21:30:30 +04:00
|
|
|
struct drm_seat {
|
|
|
|
struct weston_seat base;
|
|
|
|
struct wl_list devices_list;
|
|
|
|
struct udev_monitor *udev_monitor;
|
|
|
|
struct wl_event_source *udev_monitor_source;
|
|
|
|
char *seat_id;
|
|
|
|
};
|
|
|
|
|
2012-08-03 19:50:05 +04:00
|
|
|
static void
|
|
|
|
drm_output_set_cursor(struct drm_output *output);
|
|
|
|
static void
|
|
|
|
drm_disable_unused_sprites(struct weston_output *output_base);
|
|
|
|
|
2012-02-23 18:45:49 +04:00
|
|
|
static int
|
|
|
|
drm_sprite_crtc_supported(struct weston_output *output_base, uint32_t supported)
|
|
|
|
{
|
|
|
|
struct weston_compositor *ec = output_base->compositor;
|
|
|
|
struct drm_compositor *c =(struct drm_compositor *) ec;
|
|
|
|
struct drm_output *output = (struct drm_output *) output_base;
|
|
|
|
int crtc;
|
|
|
|
|
|
|
|
for (crtc = 0; crtc < c->num_crtcs; crtc++) {
|
|
|
|
if (c->crtcs[crtc] != output->crtc_id)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if (supported & (1 << crtc))
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2012-05-02 17:42:21 +04:00
|
|
|
static void
|
|
|
|
drm_fb_destroy_callback(struct gbm_bo *bo, void *data)
|
|
|
|
{
|
|
|
|
struct drm_fb *fb = data;
|
|
|
|
struct gbm_device *gbm = gbm_bo_get_device(bo);
|
|
|
|
|
|
|
|
if (fb->fb_id)
|
|
|
|
drmModeRmFB(gbm_device_get_fd(gbm), fb->fb_id);
|
|
|
|
|
|
|
|
if (fb->buffer) {
|
|
|
|
weston_buffer_post_release(fb->buffer);
|
|
|
|
wl_list_remove(&fb->buffer_destroy_listener.link);
|
|
|
|
}
|
|
|
|
|
|
|
|
free(data);
|
|
|
|
}
|
|
|
|
|
|
|
|
static struct drm_fb *
|
|
|
|
drm_fb_get_from_bo(struct gbm_bo *bo, struct drm_output *output)
|
|
|
|
{
|
|
|
|
struct drm_fb *fb = gbm_bo_get_user_data(bo);
|
|
|
|
struct drm_compositor *compositor =
|
|
|
|
(struct drm_compositor *) output->base.compositor;
|
|
|
|
uint32_t width, height, stride, handle;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
if (fb)
|
|
|
|
return fb;
|
|
|
|
|
|
|
|
fb = malloc(sizeof *fb);
|
|
|
|
|
|
|
|
fb->bo = bo;
|
|
|
|
fb->output = output;
|
|
|
|
fb->is_client_buffer = 0;
|
|
|
|
fb->buffer = NULL;
|
|
|
|
|
|
|
|
width = gbm_bo_get_width(bo);
|
|
|
|
height = gbm_bo_get_height(bo);
|
2012-07-17 00:44:16 +04:00
|
|
|
stride = gbm_bo_get_stride(bo);
|
2012-05-02 17:42:21 +04:00
|
|
|
handle = gbm_bo_get_handle(bo).u32;
|
|
|
|
|
|
|
|
ret = drmModeAddFB(compositor->drm.fd, width, height, 24, 32,
|
|
|
|
stride, handle, &fb->fb_id);
|
|
|
|
if (ret) {
|
2012-06-07 20:01:59 +04:00
|
|
|
weston_log("failed to create kms fb: %m\n");
|
2012-05-02 17:42:21 +04:00
|
|
|
free(fb);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
gbm_bo_set_user_data(bo, fb, drm_fb_destroy_callback);
|
|
|
|
|
|
|
|
return fb;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
fb_handle_buffer_destroy(struct wl_listener *listener, void *data)
|
|
|
|
{
|
|
|
|
struct drm_fb *fb = container_of(listener, struct drm_fb,
|
|
|
|
buffer_destroy_listener);
|
|
|
|
|
|
|
|
fb->buffer = NULL;
|
|
|
|
|
|
|
|
if (fb == fb->output->next ||
|
|
|
|
(fb == fb->output->current && !fb->output->next))
|
2012-06-20 08:35:59 +04:00
|
|
|
weston_output_schedule_repaint(&fb->output->base);
|
2012-05-02 17:42:21 +04:00
|
|
|
}
|
|
|
|
|
2012-08-03 19:30:18 +04:00
|
|
|
static struct weston_plane *
|
2012-07-14 08:31:32 +04:00
|
|
|
drm_output_prepare_scanout_surface(struct weston_output *_output,
|
|
|
|
struct weston_surface *es)
|
2012-01-26 08:59:42 +04:00
|
|
|
{
|
2012-07-14 08:31:32 +04:00
|
|
|
struct drm_output *output = (struct drm_output *) _output;
|
2012-01-26 08:59:42 +04:00
|
|
|
struct drm_compositor *c =
|
|
|
|
(struct drm_compositor *) output->base.compositor;
|
2012-05-02 17:42:21 +04:00
|
|
|
struct gbm_bo *bo;
|
2012-01-26 08:59:42 +04:00
|
|
|
|
2012-02-17 19:45:16 +04:00
|
|
|
if (es->geometry.x != output->base.x ||
|
2012-01-25 18:22:05 +04:00
|
|
|
es->geometry.y != output->base.y ||
|
2012-01-25 17:55:43 +04:00
|
|
|
es->geometry.width != output->base.current->width ||
|
|
|
|
es->geometry.height != output->base.current->height ||
|
2012-01-25 16:33:33 +04:00
|
|
|
es->transform.enabled ||
|
2012-07-14 06:54:43 +04:00
|
|
|
es->buffer == NULL)
|
2012-08-03 19:30:18 +04:00
|
|
|
return NULL;
|
2012-01-26 08:59:42 +04:00
|
|
|
|
2012-07-14 06:54:43 +04:00
|
|
|
bo = gbm_bo_import(c->gbm, GBM_BO_IMPORT_WL_BUFFER,
|
|
|
|
es->buffer, GBM_BO_USE_SCANOUT);
|
2012-05-02 17:42:21 +04:00
|
|
|
|
2012-05-02 17:42:22 +04:00
|
|
|
/* Need to verify output->region contained in surface opaque
|
|
|
|
* region. Or maybe just that format doesn't have alpha.
|
|
|
|
* For now, scanout only if format is XRGB8888. */
|
|
|
|
if (gbm_bo_get_format(bo) != GBM_FORMAT_XRGB8888) {
|
|
|
|
gbm_bo_destroy(bo);
|
2012-08-03 19:30:18 +04:00
|
|
|
return NULL;
|
2012-05-02 17:42:22 +04:00
|
|
|
}
|
|
|
|
|
2012-05-02 17:42:21 +04:00
|
|
|
output->next = drm_fb_get_from_bo(bo, output);
|
|
|
|
if (!output->next) {
|
|
|
|
gbm_bo_destroy(bo);
|
2012-08-03 19:30:18 +04:00
|
|
|
return NULL;
|
2012-05-02 17:42:21 +04:00
|
|
|
}
|
2012-01-26 08:59:42 +04:00
|
|
|
|
2012-05-02 17:42:21 +04:00
|
|
|
output->next->is_client_buffer = 1;
|
|
|
|
output->next->buffer = es->buffer;
|
|
|
|
output->next->buffer->busy_count++;
|
|
|
|
output->next->buffer_destroy_listener.notify = fb_handle_buffer_destroy;
|
2012-01-26 08:59:42 +04:00
|
|
|
|
2012-05-02 17:42:21 +04:00
|
|
|
wl_signal_add(&output->next->buffer->resource.destroy_signal,
|
|
|
|
&output->next->buffer_destroy_listener);
|
2012-01-26 08:59:42 +04:00
|
|
|
|
2012-08-03 19:30:18 +04:00
|
|
|
return &output->fb_plane;
|
2012-01-26 08:59:42 +04:00
|
|
|
}
|
|
|
|
|
2012-03-12 02:27:41 +04:00
|
|
|
static void
|
|
|
|
drm_output_render(struct drm_output *output, pixman_region32_t *damage)
|
|
|
|
{
|
|
|
|
struct drm_compositor *compositor =
|
|
|
|
(struct drm_compositor *) output->base.compositor;
|
|
|
|
struct weston_surface *surface;
|
2012-05-02 17:42:21 +04:00
|
|
|
struct gbm_bo *bo;
|
2012-03-12 02:27:41 +04:00
|
|
|
|
2012-06-18 23:13:51 +04:00
|
|
|
if (!eglMakeCurrent(compositor->base.egl_display, output->egl_surface,
|
|
|
|
output->egl_surface,
|
|
|
|
compositor->base.egl_context)) {
|
2012-06-07 20:01:59 +04:00
|
|
|
weston_log("failed to make current\n");
|
2012-03-12 02:27:41 +04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
wl_list_for_each_reverse(surface, &compositor->base.surface_list, link)
|
2012-08-03 19:30:18 +04:00
|
|
|
if (surface->plane == &compositor->base.primary_plane)
|
2012-07-14 08:31:32 +04:00
|
|
|
weston_surface_draw(surface, &output->base, damage);
|
2012-03-12 02:27:41 +04:00
|
|
|
|
2012-06-20 08:13:18 +04:00
|
|
|
wl_signal_emit(&output->base.frame_signal, output);
|
2012-04-20 23:37:33 +04:00
|
|
|
|
2012-06-18 23:13:51 +04:00
|
|
|
eglSwapBuffers(compositor->base.egl_display, output->egl_surface);
|
2012-05-02 17:42:21 +04:00
|
|
|
bo = gbm_surface_lock_front_buffer(output->surface);
|
|
|
|
if (!bo) {
|
2012-06-07 20:01:59 +04:00
|
|
|
weston_log("failed to lock front buffer: %m\n");
|
2012-03-12 02:27:41 +04:00
|
|
|
return;
|
|
|
|
}
|
2012-05-02 17:42:21 +04:00
|
|
|
|
|
|
|
output->next = drm_fb_get_from_bo(bo, output);
|
|
|
|
if (!output->next) {
|
2012-06-07 20:01:59 +04:00
|
|
|
weston_log("failed to get drm_fb for bo\n");
|
2012-05-02 17:42:21 +04:00
|
|
|
gbm_surface_release_buffer(output->surface, bo);
|
|
|
|
return;
|
|
|
|
}
|
2012-03-12 02:27:41 +04:00
|
|
|
}
|
|
|
|
|
2012-01-26 08:47:45 +04:00
|
|
|
static void
|
2012-02-29 07:31:58 +04:00
|
|
|
drm_output_repaint(struct weston_output *output_base,
|
|
|
|
pixman_region32_t *damage)
|
2011-03-11 18:39:20 +03:00
|
|
|
{
|
|
|
|
struct drm_output *output = (struct drm_output *) output_base;
|
2012-01-26 08:47:45 +04:00
|
|
|
struct drm_compositor *compositor =
|
|
|
|
(struct drm_compositor *) output->base.compositor;
|
2012-02-23 18:45:49 +04:00
|
|
|
struct drm_sprite *s;
|
2012-03-12 02:27:41 +04:00
|
|
|
struct drm_mode *mode;
|
2012-02-23 18:45:49 +04:00
|
|
|
int ret = 0;
|
2011-03-11 18:39:20 +03:00
|
|
|
|
2012-05-02 17:42:21 +04:00
|
|
|
if (!output->next)
|
2012-03-12 02:27:41 +04:00
|
|
|
drm_output_render(output, damage);
|
2012-05-02 17:42:21 +04:00
|
|
|
if (!output->next)
|
2012-03-12 02:27:41 +04:00
|
|
|
return;
|
2010-06-14 19:54:00 +04:00
|
|
|
|
2012-03-12 02:27:41 +04:00
|
|
|
mode = container_of(output->base.current, struct drm_mode, base);
|
2012-05-02 17:42:21 +04:00
|
|
|
if (!output->current) {
|
2012-03-12 02:27:41 +04:00
|
|
|
ret = drmModeSetCrtc(compositor->drm.fd, output->crtc_id,
|
2012-05-02 17:42:21 +04:00
|
|
|
output->next->fb_id, 0, 0,
|
2012-03-12 02:27:41 +04:00
|
|
|
&output->connector_id, 1,
|
|
|
|
&mode->mode_info);
|
|
|
|
if (ret) {
|
2012-06-07 20:01:59 +04:00
|
|
|
weston_log("set mode failed: %m\n");
|
2012-03-12 02:27:41 +04:00
|
|
|
return;
|
|
|
|
}
|
2011-04-10 18:49:52 +04:00
|
|
|
}
|
|
|
|
|
2012-01-26 08:47:45 +04:00
|
|
|
if (drmModePageFlip(compositor->drm.fd, output->crtc_id,
|
2012-05-02 17:42:21 +04:00
|
|
|
output->next->fb_id,
|
2012-01-18 20:47:41 +04:00
|
|
|
DRM_MODE_PAGE_FLIP_EVENT, output) < 0) {
|
2012-06-07 20:01:59 +04:00
|
|
|
weston_log("queueing pageflip failed: %m\n");
|
2012-01-26 08:47:45 +04:00
|
|
|
return;
|
2012-01-18 20:47:41 +04:00
|
|
|
}
|
2011-03-11 18:39:20 +03:00
|
|
|
|
2012-06-26 18:09:13 +04:00
|
|
|
output->page_flip_pending = 1;
|
|
|
|
|
2012-08-03 19:50:05 +04:00
|
|
|
drm_output_set_cursor(output);
|
|
|
|
|
2012-02-23 18:45:49 +04:00
|
|
|
/*
|
|
|
|
* Now, update all the sprite surfaces
|
|
|
|
*/
|
|
|
|
wl_list_for_each(s, &compositor->sprite_list, link) {
|
|
|
|
uint32_t flags = 0;
|
|
|
|
drmVBlank vbl = {
|
|
|
|
.request.type = DRM_VBLANK_RELATIVE | DRM_VBLANK_EVENT,
|
|
|
|
.request.sequence = 1,
|
|
|
|
};
|
|
|
|
|
|
|
|
if (!drm_sprite_crtc_supported(output_base, s->possible_crtcs))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
ret = drmModeSetPlane(compositor->drm.fd, s->plane_id,
|
|
|
|
output->crtc_id, s->pending_fb_id, flags,
|
|
|
|
s->dest_x, s->dest_y,
|
|
|
|
s->dest_w, s->dest_h,
|
|
|
|
s->src_x, s->src_y,
|
|
|
|
s->src_w, s->src_h);
|
|
|
|
if (ret)
|
2012-06-07 20:01:59 +04:00
|
|
|
weston_log("setplane failed: %d: %s\n",
|
2012-02-23 18:45:49 +04:00
|
|
|
ret, strerror(errno));
|
|
|
|
|
2012-08-09 05:27:37 +04:00
|
|
|
if (output->pipe > 0)
|
|
|
|
vbl.request.type |= DRM_VBLANK_SECONDARY;
|
|
|
|
|
2012-02-23 18:45:49 +04:00
|
|
|
/*
|
|
|
|
* Queue a vblank signal so we know when the surface
|
|
|
|
* becomes active on the display or has been replaced.
|
|
|
|
*/
|
|
|
|
vbl.request.signal = (unsigned long)s;
|
|
|
|
ret = drmWaitVBlank(compositor->drm.fd, &vbl);
|
|
|
|
if (ret) {
|
2012-06-07 20:01:59 +04:00
|
|
|
weston_log("vblank event request failed: %d: %s\n",
|
2012-02-23 18:45:49 +04:00
|
|
|
ret, strerror(errno));
|
|
|
|
}
|
2012-06-26 18:09:13 +04:00
|
|
|
|
|
|
|
s->output = output;
|
|
|
|
output->vblank_pending = 1;
|
2012-02-23 18:45:49 +04:00
|
|
|
}
|
|
|
|
|
2012-08-03 19:50:05 +04:00
|
|
|
drm_disable_unused_sprites(&output->base);
|
|
|
|
|
2012-01-26 08:47:45 +04:00
|
|
|
return;
|
2010-06-11 20:56:24 +04:00
|
|
|
}
|
|
|
|
|
2012-02-23 18:45:49 +04:00
|
|
|
static void
|
|
|
|
vblank_handler(int fd, unsigned int frame, unsigned int sec, unsigned int usec,
|
|
|
|
void *data)
|
|
|
|
{
|
|
|
|
struct drm_sprite *s = (struct drm_sprite *)data;
|
|
|
|
struct drm_compositor *c = s->compositor;
|
2012-06-26 18:09:13 +04:00
|
|
|
struct drm_output *output = s->output;
|
|
|
|
uint32_t msecs;
|
|
|
|
|
|
|
|
output->vblank_pending = 0;
|
2012-02-23 18:45:49 +04:00
|
|
|
|
|
|
|
if (s->surface) {
|
|
|
|
weston_buffer_post_release(s->surface->buffer);
|
|
|
|
wl_list_remove(&s->destroy_listener.link);
|
|
|
|
s->surface = NULL;
|
|
|
|
drmModeRmFB(c->drm.fd, s->fb_id);
|
|
|
|
s->fb_id = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (s->pending_surface) {
|
|
|
|
wl_list_remove(&s->pending_destroy_listener.link);
|
2012-04-12 07:18:23 +04:00
|
|
|
wl_signal_add(&s->pending_surface->buffer->resource.destroy_signal,
|
|
|
|
&s->destroy_listener);
|
2012-02-23 18:45:49 +04:00
|
|
|
s->surface = s->pending_surface;
|
|
|
|
s->pending_surface = NULL;
|
|
|
|
s->fb_id = s->pending_fb_id;
|
|
|
|
s->pending_fb_id = 0;
|
|
|
|
}
|
2012-06-26 18:09:13 +04:00
|
|
|
|
|
|
|
if (!output->page_flip_pending) {
|
|
|
|
msecs = sec * 1000 + usec / 1000;
|
|
|
|
weston_output_finish_frame(&output->base, msecs);
|
|
|
|
}
|
2012-02-23 18:45:49 +04:00
|
|
|
}
|
|
|
|
|
2010-06-11 20:56:24 +04:00
|
|
|
static void
|
|
|
|
page_flip_handler(int fd, unsigned int frame,
|
|
|
|
unsigned int sec, unsigned int usec, void *data)
|
|
|
|
{
|
2011-04-10 18:49:52 +04:00
|
|
|
struct drm_output *output = (struct drm_output *) data;
|
2010-06-11 20:56:24 +04:00
|
|
|
uint32_t msecs;
|
|
|
|
|
2012-06-26 18:09:13 +04:00
|
|
|
output->page_flip_pending = 0;
|
|
|
|
|
2012-05-02 17:42:21 +04:00
|
|
|
if (output->current) {
|
|
|
|
if (output->current->is_client_buffer)
|
|
|
|
gbm_bo_destroy(output->current->bo);
|
|
|
|
else
|
|
|
|
gbm_surface_release_buffer(output->surface,
|
|
|
|
output->current->bo);
|
2011-04-10 18:49:52 +04:00
|
|
|
}
|
|
|
|
|
2012-05-02 17:42:21 +04:00
|
|
|
output->current = output->next;
|
|
|
|
output->next = NULL;
|
2012-03-12 02:27:41 +04:00
|
|
|
|
2012-06-26 18:09:13 +04:00
|
|
|
if (!output->vblank_pending) {
|
|
|
|
msecs = sec * 1000 + usec / 1000;
|
|
|
|
weston_output_finish_frame(&output->base, msecs);
|
|
|
|
}
|
2011-04-10 18:49:52 +04:00
|
|
|
}
|
|
|
|
|
2012-02-23 18:45:49 +04:00
|
|
|
static int
|
|
|
|
drm_surface_format_supported(struct drm_sprite *s, uint32_t format)
|
|
|
|
{
|
2012-03-30 19:52:39 +04:00
|
|
|
uint32_t i;
|
2012-02-23 18:45:49 +04:00
|
|
|
|
|
|
|
for (i = 0; i < s->count_formats; i++)
|
|
|
|
if (s->formats[i] == format)
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
drm_surface_transform_supported(struct weston_surface *es)
|
|
|
|
{
|
2012-07-13 23:25:07 +04:00
|
|
|
struct weston_matrix *matrix = &es->transform.matrix;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
if (!es->transform.enabled)
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
for (i = 0; i < 16; i++) {
|
|
|
|
switch (i) {
|
|
|
|
case 10:
|
|
|
|
case 15:
|
|
|
|
if (matrix->d[i] != 1.0)
|
|
|
|
return 0;
|
|
|
|
break;
|
|
|
|
case 0:
|
|
|
|
case 5:
|
|
|
|
case 12:
|
|
|
|
case 13:
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
if (matrix->d[i] != 0.0)
|
|
|
|
return 0;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2012-02-23 18:45:49 +04:00
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
drm_disable_unused_sprites(struct weston_output *output_base)
|
|
|
|
{
|
|
|
|
struct weston_compositor *ec = output_base->compositor;
|
|
|
|
struct drm_compositor *c =(struct drm_compositor *) ec;
|
|
|
|
struct drm_output *output = (struct drm_output *) output_base;
|
|
|
|
struct drm_sprite *s;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
wl_list_for_each(s, &c->sprite_list, link) {
|
|
|
|
if (s->pending_fb_id)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
ret = drmModeSetPlane(c->drm.fd, s->plane_id,
|
|
|
|
output->crtc_id, 0, 0,
|
|
|
|
0, 0, 0, 0, 0, 0, 0, 0);
|
|
|
|
if (ret)
|
2012-06-07 20:01:59 +04:00
|
|
|
weston_log("failed to disable plane: %d: %s\n",
|
2012-02-23 18:45:49 +04:00
|
|
|
ret, strerror(errno));
|
|
|
|
drmModeRmFB(c->drm.fd, s->fb_id);
|
2012-06-26 18:09:14 +04:00
|
|
|
|
|
|
|
if (s->surface) {
|
|
|
|
s->surface = NULL;
|
|
|
|
wl_list_remove(&s->destroy_listener.link);
|
|
|
|
}
|
|
|
|
|
|
|
|
assert(!s->pending_surface);
|
2012-02-23 18:45:49 +04:00
|
|
|
s->fb_id = 0;
|
|
|
|
s->pending_fb_id = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* This function must take care to damage any previously assigned surface
|
|
|
|
* if the sprite ends up binding to a different surface than in the
|
|
|
|
* previous frame.
|
|
|
|
*/
|
2012-08-03 19:30:18 +04:00
|
|
|
static struct weston_plane *
|
2012-02-23 18:45:49 +04:00
|
|
|
drm_output_prepare_overlay_surface(struct weston_output *output_base,
|
2012-07-14 08:31:32 +04:00
|
|
|
struct weston_surface *es)
|
2012-02-23 18:45:49 +04:00
|
|
|
{
|
|
|
|
struct weston_compositor *ec = output_base->compositor;
|
|
|
|
struct drm_compositor *c =(struct drm_compositor *) ec;
|
|
|
|
struct drm_sprite *s;
|
|
|
|
int found = 0;
|
|
|
|
EGLint handle, stride;
|
|
|
|
struct gbm_bo *bo;
|
|
|
|
uint32_t fb_id = 0;
|
|
|
|
uint32_t handles[4], pitches[4], offsets[4];
|
|
|
|
int ret = 0;
|
|
|
|
pixman_region32_t dest_rect, src_rect;
|
|
|
|
pixman_box32_t *box;
|
|
|
|
uint32_t format;
|
2012-07-13 23:25:07 +04:00
|
|
|
wl_fixed_t sx1, sy1, sx2, sy2;
|
2012-08-10 01:19:23 +04:00
|
|
|
int32_t width, height;
|
2012-02-23 18:45:49 +04:00
|
|
|
|
2012-03-06 04:57:35 +04:00
|
|
|
if (c->sprites_are_broken)
|
2012-08-03 19:30:18 +04:00
|
|
|
return NULL;
|
2012-03-06 04:57:35 +04:00
|
|
|
|
2012-06-26 18:09:12 +04:00
|
|
|
if (es->output_mask != (1u << output_base->id))
|
2012-08-03 19:30:18 +04:00
|
|
|
return NULL;
|
2012-06-26 18:09:12 +04:00
|
|
|
|
2012-07-14 06:54:43 +04:00
|
|
|
if (es->buffer == NULL)
|
2012-08-03 19:30:18 +04:00
|
|
|
return NULL;
|
2012-02-23 18:45:49 +04:00
|
|
|
|
2012-08-09 23:18:27 +04:00
|
|
|
if (wl_buffer_is_shm(es->buffer))
|
|
|
|
return NULL;
|
|
|
|
|
2012-02-23 18:45:49 +04:00
|
|
|
if (!drm_surface_transform_supported(es))
|
2012-08-03 19:30:18 +04:00
|
|
|
return NULL;
|
2012-02-23 18:45:49 +04:00
|
|
|
|
|
|
|
wl_list_for_each(s, &c->sprite_list, link) {
|
|
|
|
if (!drm_sprite_crtc_supported(output_base, s->possible_crtcs))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if (!s->pending_fb_id) {
|
|
|
|
found = 1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* No sprites available */
|
|
|
|
if (!found)
|
2012-08-03 19:30:18 +04:00
|
|
|
return NULL;
|
2012-02-23 18:45:49 +04:00
|
|
|
|
2012-08-09 23:18:28 +04:00
|
|
|
width = es->geometry.width;
|
|
|
|
height = es->geometry.height;
|
|
|
|
|
|
|
|
/* If geometry is out of bounds, don't even bother trying because
|
|
|
|
* we know the AddFB2() call will fail:
|
|
|
|
*/
|
|
|
|
if (c->min_width > width || width > c->max_width ||
|
|
|
|
c->min_height > height || height > c->max_height)
|
2012-08-10 01:19:23 +04:00
|
|
|
return NULL;
|
2012-08-09 23:18:28 +04:00
|
|
|
|
2012-07-14 06:54:43 +04:00
|
|
|
bo = gbm_bo_import(c->gbm, GBM_BO_IMPORT_WL_BUFFER,
|
|
|
|
es->buffer, GBM_BO_USE_SCANOUT);
|
|
|
|
if (!bo)
|
2012-08-03 19:30:18 +04:00
|
|
|
return NULL;
|
2012-07-14 06:54:43 +04:00
|
|
|
|
2012-02-23 18:45:49 +04:00
|
|
|
format = gbm_bo_get_format(bo);
|
|
|
|
handle = gbm_bo_get_handle(bo).s32;
|
2012-07-17 00:44:16 +04:00
|
|
|
stride = gbm_bo_get_stride(bo);
|
2012-02-23 18:45:49 +04:00
|
|
|
|
|
|
|
gbm_bo_destroy(bo);
|
|
|
|
|
|
|
|
if (!drm_surface_format_supported(s, format))
|
2012-08-03 19:30:18 +04:00
|
|
|
return NULL;
|
2012-02-23 18:45:49 +04:00
|
|
|
|
|
|
|
if (!handle)
|
2012-08-03 19:30:18 +04:00
|
|
|
return NULL;
|
2012-02-23 18:45:49 +04:00
|
|
|
|
|
|
|
handles[0] = handle;
|
|
|
|
pitches[0] = stride;
|
|
|
|
offsets[0] = 0;
|
|
|
|
|
2012-08-09 23:18:28 +04:00
|
|
|
ret = drmModeAddFB2(c->drm.fd, width, height,
|
2012-02-23 18:45:49 +04:00
|
|
|
format, handles, pitches, offsets,
|
|
|
|
&fb_id, 0);
|
|
|
|
if (ret) {
|
2012-06-07 20:01:59 +04:00
|
|
|
weston_log("addfb2 failed: %d\n", ret);
|
2012-03-06 04:57:35 +04:00
|
|
|
c->sprites_are_broken = 1;
|
2012-08-03 19:30:18 +04:00
|
|
|
return NULL;
|
2012-02-23 18:45:49 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
s->pending_fb_id = fb_id;
|
|
|
|
s->pending_surface = es;
|
|
|
|
es->buffer->busy_count++;
|
|
|
|
|
2012-08-03 19:30:18 +04:00
|
|
|
box = pixman_region32_extents(&es->transform.boundingbox);
|
|
|
|
s->plane.x = box->x1;
|
|
|
|
s->plane.y = box->y1;
|
|
|
|
|
2012-02-23 18:45:49 +04:00
|
|
|
/*
|
|
|
|
* Calculate the source & dest rects properly based on actual
|
|
|
|
* postion (note the caller has called weston_surface_update_transform()
|
|
|
|
* for us already).
|
|
|
|
*/
|
|
|
|
pixman_region32_init(&dest_rect);
|
|
|
|
pixman_region32_intersect(&dest_rect, &es->transform.boundingbox,
|
|
|
|
&output_base->region);
|
|
|
|
pixman_region32_translate(&dest_rect, -output_base->x, -output_base->y);
|
|
|
|
box = pixman_region32_extents(&dest_rect);
|
|
|
|
s->dest_x = box->x1;
|
|
|
|
s->dest_y = box->y1;
|
|
|
|
s->dest_w = box->x2 - box->x1;
|
|
|
|
s->dest_h = box->y2 - box->y1;
|
|
|
|
pixman_region32_fini(&dest_rect);
|
|
|
|
|
|
|
|
pixman_region32_init(&src_rect);
|
|
|
|
pixman_region32_intersect(&src_rect, &es->transform.boundingbox,
|
|
|
|
&output_base->region);
|
|
|
|
box = pixman_region32_extents(&src_rect);
|
2012-07-13 23:25:07 +04:00
|
|
|
|
|
|
|
weston_surface_from_global_fixed(es,
|
|
|
|
wl_fixed_from_int(box->x1),
|
|
|
|
wl_fixed_from_int(box->y1),
|
|
|
|
&sx1, &sy1);
|
|
|
|
weston_surface_from_global_fixed(es,
|
|
|
|
wl_fixed_from_int(box->x2),
|
|
|
|
wl_fixed_from_int(box->y2),
|
|
|
|
&sx2, &sy2);
|
|
|
|
|
|
|
|
if (sx1 < 0)
|
|
|
|
sx1 = 0;
|
|
|
|
if (sy1 < 0)
|
|
|
|
sy1 = 0;
|
|
|
|
if (sx2 > wl_fixed_from_int(es->geometry.width))
|
|
|
|
sx2 = wl_fixed_from_int(es->geometry.width);
|
|
|
|
if (sy2 > wl_fixed_from_int(es->geometry.height))
|
|
|
|
sy2 = wl_fixed_from_int(es->geometry.height);
|
|
|
|
|
|
|
|
s->src_x = sx1 << 8;
|
|
|
|
s->src_y = sy1 << 8;
|
|
|
|
s->src_w = (sx2 - sx1) << 8;
|
|
|
|
s->src_h = (sy2 - sy1) << 8;
|
2012-02-23 18:45:49 +04:00
|
|
|
pixman_region32_fini(&src_rect);
|
|
|
|
|
2012-04-12 07:18:23 +04:00
|
|
|
wl_signal_add(&es->buffer->resource.destroy_signal,
|
|
|
|
&s->pending_destroy_listener);
|
2012-07-13 23:25:07 +04:00
|
|
|
|
2012-08-03 19:30:18 +04:00
|
|
|
return &s->plane;
|
2012-02-23 18:45:49 +04:00
|
|
|
}
|
|
|
|
|
2012-08-03 19:30:18 +04:00
|
|
|
static struct weston_plane *
|
2012-08-03 19:50:05 +04:00
|
|
|
drm_output_prepare_cursor_surface(struct weston_output *output_base,
|
|
|
|
struct weston_surface *es)
|
2012-02-24 08:03:14 +04:00
|
|
|
{
|
2012-08-10 01:19:23 +04:00
|
|
|
struct drm_compositor *c =
|
|
|
|
(struct drm_compositor *) output_base->compositor;
|
2012-07-14 09:06:28 +04:00
|
|
|
struct drm_output *output = (struct drm_output *) output_base;
|
2012-08-03 19:50:05 +04:00
|
|
|
|
|
|
|
if (output->cursor_surface)
|
|
|
|
return NULL;
|
|
|
|
if (es->output_mask != (1u << output_base->id))
|
|
|
|
return NULL;
|
2012-08-09 22:24:45 +04:00
|
|
|
if (c->cursors_are_broken)
|
2012-08-10 01:19:23 +04:00
|
|
|
return NULL;
|
2012-08-03 19:50:05 +04:00
|
|
|
if (es->buffer == NULL || !wl_buffer_is_shm(es->buffer) ||
|
|
|
|
es->geometry.width > 64 || es->geometry.height > 64)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
output->cursor_surface = es;
|
|
|
|
|
|
|
|
return &output->cursor_plane;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
drm_output_set_cursor(struct drm_output *output)
|
|
|
|
{
|
|
|
|
struct weston_surface *es = output->cursor_surface;
|
2012-07-14 09:06:28 +04:00
|
|
|
struct drm_compositor *c =
|
|
|
|
(struct drm_compositor *) output->base.compositor;
|
|
|
|
EGLint handle, stride;
|
|
|
|
struct gbm_bo *bo;
|
|
|
|
uint32_t buf[64 * 64];
|
|
|
|
unsigned char *s;
|
2012-07-18 20:08:37 +04:00
|
|
|
int i, x, y;
|
2012-07-14 09:06:28 +04:00
|
|
|
|
2012-08-03 23:45:23 +04:00
|
|
|
output->cursor_surface = NULL;
|
2012-08-03 19:50:05 +04:00
|
|
|
if (es == NULL) {
|
|
|
|
drmModeSetCursor(c->drm.fd, output->crtc_id, 0, 0, 0);
|
|
|
|
return;
|
|
|
|
}
|
2012-02-24 08:03:14 +04:00
|
|
|
|
2012-08-03 19:50:05 +04:00
|
|
|
if (es->buffer && pixman_region32_not_empty(&output->cursor_plane.damage)) {
|
|
|
|
pixman_region32_fini(&output->cursor_plane.damage);
|
|
|
|
pixman_region32_init(&output->cursor_plane.damage);
|
2012-07-18 20:09:58 +04:00
|
|
|
output->current_cursor ^= 1;
|
|
|
|
bo = output->cursor_bo[output->current_cursor];
|
|
|
|
memset(buf, 0, sizeof buf);
|
|
|
|
stride = wl_shm_buffer_get_stride(es->buffer);
|
|
|
|
s = wl_shm_buffer_get_data(es->buffer);
|
|
|
|
for (i = 0; i < es->geometry.height; i++)
|
|
|
|
memcpy(buf + i * 64, s + i * stride,
|
|
|
|
es->geometry.width * 4);
|
|
|
|
|
|
|
|
if (gbm_bo_write(bo, buf, sizeof buf) < 0)
|
2012-08-06 15:57:05 +04:00
|
|
|
weston_log("failed update cursor: %m\n");
|
2012-02-24 08:03:14 +04:00
|
|
|
|
2012-07-18 20:09:58 +04:00
|
|
|
handle = gbm_bo_get_handle(bo).s32;
|
|
|
|
if (drmModeSetCursor(c->drm.fd,
|
2012-08-09 22:24:45 +04:00
|
|
|
output->crtc_id, handle, 64, 64)) {
|
2012-08-06 15:57:05 +04:00
|
|
|
weston_log("failed to set cursor: %m\n");
|
2012-08-09 22:24:45 +04:00
|
|
|
c->cursors_are_broken = 1;
|
|
|
|
}
|
2012-07-14 09:06:28 +04:00
|
|
|
}
|
2012-02-24 08:03:14 +04:00
|
|
|
|
2012-07-18 20:08:37 +04:00
|
|
|
x = es->geometry.x - output->base.x;
|
|
|
|
y = es->geometry.y - output->base.y;
|
2012-08-03 19:30:18 +04:00
|
|
|
if (output->cursor_plane.x != x || output->cursor_plane.y != y) {
|
2012-08-09 22:24:45 +04:00
|
|
|
if (drmModeMoveCursor(c->drm.fd, output->crtc_id, x, y)) {
|
2012-07-18 20:08:37 +04:00
|
|
|
weston_log("failed to move cursor: %m\n");
|
2012-08-09 22:24:45 +04:00
|
|
|
c->cursors_are_broken = 1;
|
|
|
|
}
|
|
|
|
|
2012-08-03 19:30:18 +04:00
|
|
|
output->cursor_plane.x = x;
|
|
|
|
output->cursor_plane.y = y;
|
2012-07-14 09:06:28 +04:00
|
|
|
}
|
2012-02-24 08:03:14 +04:00
|
|
|
}
|
|
|
|
|
2012-02-23 18:45:49 +04:00
|
|
|
static void
|
|
|
|
drm_assign_planes(struct weston_output *output)
|
|
|
|
{
|
2012-07-14 09:06:28 +04:00
|
|
|
struct drm_compositor *c =
|
|
|
|
(struct drm_compositor *) output->compositor;
|
2012-05-03 19:39:35 +04:00
|
|
|
struct weston_surface *es, *next;
|
2012-02-23 18:45:49 +04:00
|
|
|
pixman_region32_t overlap, surface_overlap;
|
2012-08-03 19:30:18 +04:00
|
|
|
struct weston_plane *primary, *next_plane;
|
2012-02-23 18:45:49 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Find a surface for each sprite in the output using some heuristics:
|
|
|
|
* 1) size
|
|
|
|
* 2) frequency of update
|
|
|
|
* 3) opacity (though some hw might support alpha blending)
|
|
|
|
* 4) clipping (this can be fixed with color keys)
|
|
|
|
*
|
|
|
|
* The idea is to save on blitting since this should save power.
|
|
|
|
* If we can get a large video surface on the sprite for example,
|
|
|
|
* the main display surface may not need to update at all, and
|
|
|
|
* the client buffer can be used directly for the sprite surface
|
|
|
|
* as we do for flipping full screen surfaces.
|
|
|
|
*/
|
|
|
|
pixman_region32_init(&overlap);
|
2012-08-03 19:30:18 +04:00
|
|
|
primary = &c->base.primary_plane;
|
2012-07-14 09:06:28 +04:00
|
|
|
wl_list_for_each_safe(es, next, &c->base.surface_list, link) {
|
2012-02-23 18:45:49 +04:00
|
|
|
pixman_region32_init(&surface_overlap);
|
|
|
|
pixman_region32_intersect(&surface_overlap, &overlap,
|
|
|
|
&es->transform.boundingbox);
|
|
|
|
|
2012-08-03 19:30:18 +04:00
|
|
|
next_plane = NULL;
|
2012-07-14 08:31:32 +04:00
|
|
|
if (pixman_region32_not_empty(&surface_overlap))
|
2012-08-03 19:30:18 +04:00
|
|
|
next_plane = primary;
|
|
|
|
if (next_plane == NULL)
|
2012-08-03 19:50:05 +04:00
|
|
|
next_plane = drm_output_prepare_cursor_surface(output, es);
|
2012-08-03 19:30:18 +04:00
|
|
|
if (next_plane == NULL)
|
|
|
|
next_plane = drm_output_prepare_scanout_surface(output, es);
|
|
|
|
if (next_plane == NULL)
|
|
|
|
next_plane = drm_output_prepare_overlay_surface(output, es);
|
|
|
|
if (next_plane == NULL)
|
|
|
|
next_plane = primary;
|
|
|
|
weston_surface_move_to_plane(es, next_plane);
|
|
|
|
if (next_plane == primary)
|
2012-02-23 18:45:49 +04:00
|
|
|
pixman_region32_union(&overlap, &overlap,
|
|
|
|
&es->transform.boundingbox);
|
2012-07-14 08:31:32 +04:00
|
|
|
|
2012-02-23 18:45:49 +04:00
|
|
|
pixman_region32_fini(&surface_overlap);
|
|
|
|
}
|
|
|
|
pixman_region32_fini(&overlap);
|
|
|
|
}
|
|
|
|
|
2011-08-30 00:52:23 +04:00
|
|
|
static void
|
Rename wayland-compositor to weston
This rename addresses a few problems around the split between core
Wayland and the wayland-demos repository.
1) Initially, we had one big repository with protocol code, sample
compositor and sample clients. We split that repository to make it
possible to implement the protocol without pulling in the sample/demo
code. At this point, the compositor is more than just a "demo" and
wayland-demos doesn't send the right message. The sample compositor
is a useful, self-contained project in it's own right, and we want to
move away from the "demos" label.
2) Another problem is that the wayland-demos compositor is often
called "the wayland compsitor", but it's really just one possible
compositor. Existing X11 compositors are expected to add Wayland
support and then gradually phase out/modularize the X11 support, for
example. Conversely, it's hard to talk about the wayland-demos
compositor specifically as opposed to, eg, the wayland protocol or a
wayland compositor in general.
We are also renaming the repo to weston, and the compositor
subdirectory to src/, to emphasize that the main "output" is the
compositor.
2012-01-03 19:29:47 +04:00
|
|
|
drm_output_destroy(struct weston_output *output_base)
|
2011-08-30 00:52:23 +04:00
|
|
|
{
|
|
|
|
struct drm_output *output = (struct drm_output *) output_base;
|
|
|
|
struct drm_compositor *c =
|
2011-08-30 13:38:26 +04:00
|
|
|
(struct drm_compositor *) output->base.compositor;
|
2011-08-30 00:52:23 +04:00
|
|
|
drmModeCrtcPtr origcrtc = output->original_crtc;
|
|
|
|
|
2012-02-29 21:53:50 +04:00
|
|
|
if (output->backlight)
|
|
|
|
backlight_destroy(output->backlight);
|
|
|
|
|
2011-08-30 00:52:23 +04:00
|
|
|
/* Turn off hardware cursor */
|
2012-07-14 09:06:28 +04:00
|
|
|
drmModeSetCursor(c->drm.fd, output->crtc_id, 0, 0, 0);
|
2011-08-30 00:52:23 +04:00
|
|
|
|
|
|
|
/* Restore original CRTC state */
|
|
|
|
drmModeSetCrtc(c->drm.fd, origcrtc->crtc_id, origcrtc->buffer_id,
|
2011-08-30 13:38:26 +04:00
|
|
|
origcrtc->x, origcrtc->y,
|
|
|
|
&output->connector_id, 1, &origcrtc->mode);
|
2011-08-30 00:52:23 +04:00
|
|
|
drmModeFreeCrtc(origcrtc);
|
|
|
|
|
2011-08-30 13:44:56 +04:00
|
|
|
c->crtc_allocator &= ~(1 << output->crtc_id);
|
|
|
|
c->connector_allocator &= ~(1 << output->connector_id);
|
|
|
|
|
2012-06-18 23:13:51 +04:00
|
|
|
eglDestroySurface(c->base.egl_display, output->egl_surface);
|
2012-03-12 02:27:41 +04:00
|
|
|
gbm_surface_destroy(output->surface);
|
|
|
|
|
2012-08-03 19:30:18 +04:00
|
|
|
weston_plane_release(&output->fb_plane);
|
|
|
|
weston_plane_release(&output->cursor_plane);
|
|
|
|
|
Rename wayland-compositor to weston
This rename addresses a few problems around the split between core
Wayland and the wayland-demos repository.
1) Initially, we had one big repository with protocol code, sample
compositor and sample clients. We split that repository to make it
possible to implement the protocol without pulling in the sample/demo
code. At this point, the compositor is more than just a "demo" and
wayland-demos doesn't send the right message. The sample compositor
is a useful, self-contained project in it's own right, and we want to
move away from the "demos" label.
2) Another problem is that the wayland-demos compositor is often
called "the wayland compsitor", but it's really just one possible
compositor. Existing X11 compositors are expected to add Wayland
support and then gradually phase out/modularize the X11 support, for
example. Conversely, it's hard to talk about the wayland-demos
compositor specifically as opposed to, eg, the wayland protocol or a
wayland compositor in general.
We are also renaming the repo to weston, and the compositor
subdirectory to src/, to emphasize that the main "output" is the
compositor.
2012-01-03 19:29:47 +04:00
|
|
|
weston_output_destroy(&output->base);
|
2011-08-30 13:44:56 +04:00
|
|
|
wl_list_remove(&output->base.link);
|
|
|
|
|
2012-07-27 07:03:57 +04:00
|
|
|
free(output->name);
|
2011-08-30 00:52:23 +04:00
|
|
|
free(output);
|
|
|
|
}
|
|
|
|
|
2012-04-17 13:20:48 +04:00
|
|
|
static struct drm_mode *
|
|
|
|
choose_mode (struct drm_output *output, struct weston_mode *target_mode)
|
|
|
|
{
|
|
|
|
struct drm_mode *tmp_mode = NULL, *mode;
|
|
|
|
|
|
|
|
if (output->base.current->width == target_mode->width &&
|
|
|
|
output->base.current->height == target_mode->height &&
|
|
|
|
(output->base.current->refresh == target_mode->refresh ||
|
|
|
|
target_mode->refresh == 0))
|
|
|
|
return (struct drm_mode *)output->base.current;
|
|
|
|
|
|
|
|
wl_list_for_each(mode, &output->base.mode_list, base.link) {
|
|
|
|
if (mode->mode_info.hdisplay == target_mode->width &&
|
|
|
|
mode->mode_info.vdisplay == target_mode->height) {
|
|
|
|
if (mode->mode_info.vrefresh == target_mode->refresh ||
|
|
|
|
target_mode->refresh == 0) {
|
|
|
|
return mode;
|
|
|
|
} else if (!tmp_mode)
|
|
|
|
tmp_mode = mode;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return tmp_mode;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
drm_output_switch_mode(struct weston_output *output_base, struct weston_mode *mode)
|
|
|
|
{
|
|
|
|
struct drm_output *output;
|
|
|
|
struct drm_mode *drm_mode;
|
|
|
|
int ret;
|
|
|
|
struct drm_compositor *ec;
|
|
|
|
struct gbm_surface *surface;
|
|
|
|
EGLSurface egl_surface;
|
|
|
|
|
|
|
|
if (output_base == NULL) {
|
2012-06-07 20:01:59 +04:00
|
|
|
weston_log("output is NULL.\n");
|
2012-04-17 13:20:48 +04:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (mode == NULL) {
|
2012-06-07 20:01:59 +04:00
|
|
|
weston_log("mode is NULL.\n");
|
2012-04-17 13:20:48 +04:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
ec = (struct drm_compositor *)output_base->compositor;
|
|
|
|
output = (struct drm_output *)output_base;
|
|
|
|
drm_mode = choose_mode (output, mode);
|
|
|
|
|
|
|
|
if (!drm_mode) {
|
2012-06-07 20:01:59 +04:00
|
|
|
weston_log("%s, invalid resolution:%dx%d\n", __func__, mode->width, mode->height);
|
2012-04-17 13:20:48 +04:00
|
|
|
return -1;
|
|
|
|
} else if (&drm_mode->base == output->base.current) {
|
|
|
|
return 0;
|
|
|
|
} else if (drm_mode->base.width == output->base.current->width &&
|
|
|
|
drm_mode->base.height == output->base.current->height) {
|
|
|
|
/* only change refresh value */
|
|
|
|
ret = drmModeSetCrtc(ec->drm.fd,
|
|
|
|
output->crtc_id,
|
2012-05-02 17:42:21 +04:00
|
|
|
output->current->fb_id, 0, 0,
|
2012-04-17 13:20:48 +04:00
|
|
|
&output->connector_id, 1, &drm_mode->mode_info);
|
|
|
|
|
|
|
|
if (ret) {
|
2012-06-07 20:01:59 +04:00
|
|
|
weston_log("failed to set mode (%dx%d) %u Hz\n",
|
2012-04-17 13:20:48 +04:00
|
|
|
drm_mode->base.width,
|
|
|
|
drm_mode->base.height,
|
2012-05-10 20:23:53 +04:00
|
|
|
drm_mode->base.refresh / 1000);
|
2012-04-17 13:20:48 +04:00
|
|
|
ret = -1;
|
|
|
|
} else {
|
|
|
|
output->base.current->flags = 0;
|
|
|
|
output->base.current = &drm_mode->base;
|
|
|
|
drm_mode->base.flags =
|
|
|
|
WL_OUTPUT_MODE_CURRENT | WL_OUTPUT_MODE_PREFERRED;
|
|
|
|
ret = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
drm_mode->base.flags =
|
|
|
|
WL_OUTPUT_MODE_CURRENT | WL_OUTPUT_MODE_PREFERRED;
|
|
|
|
|
|
|
|
surface = gbm_surface_create(ec->gbm,
|
|
|
|
drm_mode->base.width,
|
|
|
|
drm_mode->base.height,
|
|
|
|
GBM_FORMAT_XRGB8888,
|
|
|
|
GBM_BO_USE_SCANOUT |
|
|
|
|
GBM_BO_USE_RENDERING);
|
|
|
|
if (!surface) {
|
2012-06-07 20:01:59 +04:00
|
|
|
weston_log("failed to create gbm surface\n");
|
2012-04-17 13:20:48 +04:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
egl_surface =
|
2012-06-18 23:13:51 +04:00
|
|
|
eglCreateWindowSurface(ec->base.egl_display,
|
|
|
|
ec->base.egl_config,
|
2012-04-17 13:20:48 +04:00
|
|
|
surface, NULL);
|
|
|
|
|
|
|
|
if (egl_surface == EGL_NO_SURFACE) {
|
2012-06-07 20:01:59 +04:00
|
|
|
weston_log("failed to create egl surface\n");
|
2012-04-17 13:20:48 +04:00
|
|
|
goto err;
|
|
|
|
}
|
|
|
|
|
|
|
|
ret = drmModeSetCrtc(ec->drm.fd,
|
|
|
|
output->crtc_id,
|
2012-05-02 17:42:21 +04:00
|
|
|
output->current->fb_id, 0, 0,
|
2012-04-17 13:20:48 +04:00
|
|
|
&output->connector_id, 1, &drm_mode->mode_info);
|
|
|
|
if (ret) {
|
2012-06-07 20:01:59 +04:00
|
|
|
weston_log("failed to set mode\n");
|
2012-04-17 13:20:48 +04:00
|
|
|
goto err;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* reset rendering stuff. */
|
2012-05-02 17:42:21 +04:00
|
|
|
if (output->current) {
|
|
|
|
if (output->current->is_client_buffer)
|
|
|
|
gbm_bo_destroy(output->current->bo);
|
|
|
|
else
|
|
|
|
gbm_surface_release_buffer(output->surface,
|
|
|
|
output->current->bo);
|
|
|
|
}
|
|
|
|
output->current = NULL;
|
|
|
|
|
|
|
|
if (output->next) {
|
|
|
|
if (output->next->is_client_buffer)
|
|
|
|
gbm_bo_destroy(output->next->bo);
|
|
|
|
else
|
|
|
|
gbm_surface_release_buffer(output->surface,
|
|
|
|
output->next->bo);
|
|
|
|
}
|
|
|
|
output->next = NULL;
|
2012-04-17 13:20:48 +04:00
|
|
|
|
2012-06-18 23:13:51 +04:00
|
|
|
eglDestroySurface(ec->base.egl_display, output->egl_surface);
|
2012-04-17 13:20:48 +04:00
|
|
|
gbm_surface_destroy(output->surface);
|
|
|
|
output->egl_surface = egl_surface;
|
|
|
|
output->surface = surface;
|
|
|
|
|
|
|
|
/*update output*/
|
|
|
|
output->base.current = &drm_mode->base;
|
|
|
|
output->base.dirty = 1;
|
|
|
|
weston_output_move(&output->base, output->base.x, output->base.y);
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
err:
|
2012-06-18 23:13:51 +04:00
|
|
|
eglDestroySurface(ec->base.egl_display, egl_surface);
|
2012-04-17 13:20:48 +04:00
|
|
|
gbm_surface_destroy(surface);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2011-04-22 20:27:57 +04:00
|
|
|
static int
|
2010-06-11 20:56:24 +04:00
|
|
|
on_drm_input(int fd, uint32_t mask, void *data)
|
|
|
|
{
|
|
|
|
drmEventContext evctx;
|
|
|
|
|
|
|
|
memset(&evctx, 0, sizeof evctx);
|
|
|
|
evctx.version = DRM_EVENT_CONTEXT_VERSION;
|
|
|
|
evctx.page_flip_handler = page_flip_handler;
|
2012-02-23 18:45:49 +04:00
|
|
|
evctx.vblank_handler = vblank_handler;
|
2010-06-11 20:56:24 +04:00
|
|
|
drmHandleEvent(fd, &evctx);
|
2011-04-22 20:27:57 +04:00
|
|
|
|
|
|
|
return 1;
|
2010-06-11 20:56:24 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2010-06-14 19:54:00 +04:00
|
|
|
init_egl(struct drm_compositor *ec, struct udev_device *device)
|
2010-06-11 20:56:24 +04:00
|
|
|
{
|
2012-03-12 02:27:41 +04:00
|
|
|
EGLint major, minor, n;
|
2012-03-29 06:53:49 +04:00
|
|
|
const char *filename, *sysnum;
|
2010-08-09 22:43:33 +04:00
|
|
|
int fd;
|
2010-07-29 07:47:54 +04:00
|
|
|
static const EGLint context_attribs[] = {
|
|
|
|
EGL_CONTEXT_CLIENT_VERSION, 2,
|
|
|
|
EGL_NONE
|
|
|
|
};
|
2010-06-11 20:56:24 +04:00
|
|
|
|
2012-03-12 02:27:41 +04:00
|
|
|
static const EGLint config_attribs[] = {
|
|
|
|
EGL_SURFACE_TYPE, EGL_WINDOW_BIT,
|
|
|
|
EGL_RED_SIZE, 1,
|
|
|
|
EGL_GREEN_SIZE, 1,
|
|
|
|
EGL_BLUE_SIZE, 1,
|
|
|
|
EGL_ALPHA_SIZE, 0,
|
|
|
|
EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
|
|
|
|
EGL_NONE
|
|
|
|
};
|
|
|
|
|
2012-05-10 20:28:35 +04:00
|
|
|
sysnum = udev_device_get_sysnum(device);
|
|
|
|
if (sysnum)
|
|
|
|
ec->drm.id = atoi(sysnum);
|
|
|
|
if (!sysnum || ec->drm.id < 0) {
|
2012-06-07 20:01:59 +04:00
|
|
|
weston_log("cannot get device sysnum\n");
|
2012-05-10 20:28:35 +04:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2010-08-09 22:43:33 +04:00
|
|
|
filename = udev_device_get_devnode(device);
|
2011-11-05 21:46:01 +04:00
|
|
|
fd = open(filename, O_RDWR | O_CLOEXEC);
|
2010-08-09 22:43:33 +04:00
|
|
|
if (fd < 0) {
|
2010-06-11 20:56:24 +04:00
|
|
|
/* Probably permissions error */
|
2012-06-07 20:01:59 +04:00
|
|
|
weston_log("couldn't open %s, skipping\n",
|
2010-06-11 20:56:24 +04:00
|
|
|
udev_device_get_devnode(device));
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2012-06-09 00:45:33 +04:00
|
|
|
weston_log("using %s\n", filename);
|
|
|
|
|
2011-03-02 13:14:59 +03:00
|
|
|
ec->drm.fd = fd;
|
2011-04-30 11:32:11 +04:00
|
|
|
ec->gbm = gbm_create_device(ec->drm.fd);
|
2012-06-18 23:13:51 +04:00
|
|
|
ec->base.egl_display = eglGetDisplay(ec->gbm);
|
|
|
|
if (ec->base.egl_display == NULL) {
|
2012-06-07 20:01:59 +04:00
|
|
|
weston_log("failed to create display\n");
|
2010-06-11 20:56:24 +04:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2012-06-18 23:13:51 +04:00
|
|
|
if (!eglInitialize(ec->base.egl_display, &major, &minor)) {
|
2012-06-07 20:01:59 +04:00
|
|
|
weston_log("failed to initialize display\n");
|
2010-06-11 20:56:24 +04:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2010-11-23 05:24:39 +03:00
|
|
|
if (!eglBindAPI(EGL_OPENGL_ES_API)) {
|
2012-06-07 20:01:59 +04:00
|
|
|
weston_log("failed to bind api EGL_OPENGL_ES_API\n");
|
2010-11-23 05:24:39 +03:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2012-06-18 23:13:51 +04:00
|
|
|
if (!eglChooseConfig(ec->base.egl_display, config_attribs,
|
|
|
|
&ec->base.egl_config, 1, &n) || n != 1) {
|
2012-06-07 20:01:59 +04:00
|
|
|
weston_log("failed to choose config: %d\n", n);
|
2012-03-12 02:27:41 +04:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2012-06-18 23:13:51 +04:00
|
|
|
ec->base.egl_context =
|
|
|
|
eglCreateContext(ec->base.egl_display, ec->base.egl_config,
|
|
|
|
EGL_NO_CONTEXT, context_attribs);
|
|
|
|
if (ec->base.egl_context == NULL) {
|
2012-06-07 20:01:59 +04:00
|
|
|
weston_log("failed to create context\n");
|
2010-06-11 20:56:24 +04:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2012-03-29 06:53:49 +04:00
|
|
|
ec->dummy_surface = gbm_surface_create(ec->gbm, 10, 10,
|
|
|
|
GBM_FORMAT_XRGB8888,
|
|
|
|
GBM_BO_USE_RENDERING);
|
|
|
|
if (!ec->dummy_surface) {
|
2012-06-07 20:01:59 +04:00
|
|
|
weston_log("failed to create dummy gbm surface\n");
|
2012-03-29 06:53:49 +04:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
ec->dummy_egl_surface =
|
2012-06-18 23:13:51 +04:00
|
|
|
eglCreateWindowSurface(ec->base.egl_display,
|
|
|
|
ec->base.egl_config,
|
|
|
|
ec->dummy_surface,
|
|
|
|
NULL);
|
2012-03-29 06:53:49 +04:00
|
|
|
if (ec->dummy_egl_surface == EGL_NO_SURFACE) {
|
2012-06-07 20:01:59 +04:00
|
|
|
weston_log("failed to create egl surface\n");
|
2012-03-29 06:53:49 +04:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2012-06-18 23:13:51 +04:00
|
|
|
if (!eglMakeCurrent(ec->base.egl_display, ec->dummy_egl_surface,
|
|
|
|
ec->dummy_egl_surface, ec->base.egl_context)) {
|
2012-06-07 20:01:59 +04:00
|
|
|
weston_log("failed to make context current\n");
|
2010-06-11 20:56:24 +04:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2012-08-09 17:45:00 +04:00
|
|
|
static struct drm_mode *
|
2011-06-21 19:16:58 +04:00
|
|
|
drm_output_add_mode(struct drm_output *output, drmModeModeInfo *info)
|
|
|
|
{
|
|
|
|
struct drm_mode *mode;
|
2012-05-10 20:23:53 +04:00
|
|
|
uint64_t refresh;
|
2011-06-21 19:16:58 +04:00
|
|
|
|
|
|
|
mode = malloc(sizeof *mode);
|
|
|
|
if (mode == NULL)
|
2012-08-09 17:45:00 +04:00
|
|
|
return NULL;
|
2011-06-21 19:16:58 +04:00
|
|
|
|
|
|
|
mode->base.flags = 0;
|
|
|
|
mode->base.width = info->hdisplay;
|
|
|
|
mode->base.height = info->vdisplay;
|
2012-05-10 20:23:53 +04:00
|
|
|
|
|
|
|
/* Calculate higher precision (mHz) refresh rate */
|
|
|
|
refresh = (info->clock * 1000000LL / info->htotal +
|
|
|
|
info->vtotal / 2) / info->vtotal;
|
|
|
|
|
|
|
|
if (info->flags & DRM_MODE_FLAG_INTERLACE)
|
|
|
|
refresh *= 2;
|
|
|
|
if (info->flags & DRM_MODE_FLAG_DBLSCAN)
|
|
|
|
refresh /= 2;
|
|
|
|
if (info->vscan > 1)
|
|
|
|
refresh /= info->vscan;
|
|
|
|
|
|
|
|
mode->base.refresh = refresh;
|
2011-06-21 19:16:58 +04:00
|
|
|
mode->mode_info = *info;
|
2012-06-28 19:28:15 +04:00
|
|
|
|
|
|
|
if (info->type & DRM_MODE_TYPE_PREFERRED)
|
|
|
|
mode->base.flags |= WL_OUTPUT_MODE_PREFERRED;
|
|
|
|
|
2011-06-21 19:16:58 +04:00
|
|
|
wl_list_insert(output->base.mode_list.prev, &mode->base.link);
|
|
|
|
|
2012-08-09 17:45:00 +04:00
|
|
|
return mode;
|
2011-06-21 19:16:58 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
drm_subpixel_to_wayland(int drm_value)
|
|
|
|
{
|
|
|
|
switch (drm_value) {
|
|
|
|
default:
|
|
|
|
case DRM_MODE_SUBPIXEL_UNKNOWN:
|
|
|
|
return WL_OUTPUT_SUBPIXEL_UNKNOWN;
|
|
|
|
case DRM_MODE_SUBPIXEL_NONE:
|
|
|
|
return WL_OUTPUT_SUBPIXEL_NONE;
|
|
|
|
case DRM_MODE_SUBPIXEL_HORIZONTAL_RGB:
|
|
|
|
return WL_OUTPUT_SUBPIXEL_HORIZONTAL_RGB;
|
|
|
|
case DRM_MODE_SUBPIXEL_HORIZONTAL_BGR:
|
|
|
|
return WL_OUTPUT_SUBPIXEL_HORIZONTAL_BGR;
|
|
|
|
case DRM_MODE_SUBPIXEL_VERTICAL_RGB:
|
|
|
|
return WL_OUTPUT_SUBPIXEL_VERTICAL_RGB;
|
|
|
|
case DRM_MODE_SUBPIXEL_VERTICAL_BGR:
|
|
|
|
return WL_OUTPUT_SUBPIXEL_VERTICAL_BGR;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-02-23 18:45:49 +04:00
|
|
|
static void
|
2012-04-12 07:18:23 +04:00
|
|
|
sprite_handle_buffer_destroy(struct wl_listener *listener, void *data)
|
2012-02-23 18:45:49 +04:00
|
|
|
{
|
|
|
|
struct drm_sprite *sprite =
|
|
|
|
container_of(listener, struct drm_sprite,
|
|
|
|
destroy_listener);
|
2012-06-26 18:09:15 +04:00
|
|
|
struct drm_compositor *compositor = sprite->compositor;
|
2012-02-23 18:45:49 +04:00
|
|
|
|
|
|
|
sprite->surface = NULL;
|
2012-06-26 18:09:15 +04:00
|
|
|
drmModeRmFB(compositor->drm.fd, sprite->fb_id);
|
|
|
|
sprite->fb_id = 0;
|
2012-02-23 18:45:49 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2012-04-12 07:18:23 +04:00
|
|
|
sprite_handle_pending_buffer_destroy(struct wl_listener *listener, void *data)
|
2012-02-23 18:45:49 +04:00
|
|
|
{
|
|
|
|
struct drm_sprite *sprite =
|
|
|
|
container_of(listener, struct drm_sprite,
|
|
|
|
pending_destroy_listener);
|
2012-06-26 18:09:15 +04:00
|
|
|
struct drm_compositor *compositor = sprite->compositor;
|
2012-02-23 18:45:49 +04:00
|
|
|
|
|
|
|
sprite->pending_surface = NULL;
|
2012-06-26 18:09:15 +04:00
|
|
|
drmModeRmFB(compositor->drm.fd, sprite->pending_fb_id);
|
|
|
|
sprite->pending_fb_id = 0;
|
2012-02-23 18:45:49 +04:00
|
|
|
}
|
|
|
|
|
2012-03-13 02:40:09 +04:00
|
|
|
/* returns a value between 0-255 range, where higher is brighter */
|
2012-02-29 21:53:50 +04:00
|
|
|
static uint32_t
|
|
|
|
drm_get_backlight(struct drm_output *output)
|
|
|
|
{
|
|
|
|
long brightness, max_brightness, norm;
|
|
|
|
|
|
|
|
brightness = backlight_get_brightness(output->backlight);
|
|
|
|
max_brightness = backlight_get_max_brightness(output->backlight);
|
|
|
|
|
2012-03-13 02:40:09 +04:00
|
|
|
/* convert it on a scale of 0 to 255 */
|
|
|
|
norm = (brightness * 255)/(max_brightness);
|
2012-02-29 21:53:50 +04:00
|
|
|
|
|
|
|
return (uint32_t) norm;
|
|
|
|
}
|
|
|
|
|
2012-03-13 02:40:09 +04:00
|
|
|
/* values accepted are between 0-255 range */
|
2012-02-29 21:53:50 +04:00
|
|
|
static void
|
|
|
|
drm_set_backlight(struct weston_output *output_base, uint32_t value)
|
|
|
|
{
|
|
|
|
struct drm_output *output = (struct drm_output *) output_base;
|
|
|
|
long max_brightness, new_brightness;
|
|
|
|
|
|
|
|
if (!output->backlight)
|
|
|
|
return;
|
|
|
|
|
2012-03-30 19:52:39 +04:00
|
|
|
if (value > 255)
|
2012-02-29 21:53:50 +04:00
|
|
|
return;
|
|
|
|
|
|
|
|
max_brightness = backlight_get_max_brightness(output->backlight);
|
|
|
|
|
|
|
|
/* get denormalized value */
|
2012-03-13 02:40:09 +04:00
|
|
|
new_brightness = (value * max_brightness) / 255;
|
2012-02-29 21:53:50 +04:00
|
|
|
|
|
|
|
backlight_set_brightness(output->backlight, new_brightness);
|
|
|
|
}
|
|
|
|
|
|
|
|
static drmModePropertyPtr
|
|
|
|
drm_get_prop(int fd, drmModeConnectorPtr connector, const char *name)
|
|
|
|
{
|
|
|
|
drmModePropertyPtr props;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; i < connector->count_props; i++) {
|
|
|
|
props = drmModeGetProperty(fd, connector->props[i]);
|
|
|
|
if (!props)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if (!strcmp(props->name, name))
|
|
|
|
return props;
|
|
|
|
|
|
|
|
drmModeFreeProperty(props);
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
drm_set_dpms(struct weston_output *output_base, enum dpms_enum level)
|
|
|
|
{
|
|
|
|
struct drm_output *output = (struct drm_output *) output_base;
|
|
|
|
struct weston_compositor *ec = output_base->compositor;
|
|
|
|
struct drm_compositor *c = (struct drm_compositor *) ec;
|
|
|
|
drmModeConnectorPtr connector;
|
|
|
|
drmModePropertyPtr prop;
|
|
|
|
|
|
|
|
connector = drmModeGetConnector(c->drm.fd, output->connector_id);
|
|
|
|
if (!connector)
|
|
|
|
return;
|
|
|
|
|
|
|
|
prop = drm_get_prop(c->drm.fd, connector, "DPMS");
|
|
|
|
if (!prop) {
|
|
|
|
drmModeFreeConnector(connector);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
drmModeConnectorSetProperty(c->drm.fd, connector->connector_id,
|
|
|
|
prop->prop_id, level);
|
|
|
|
drmModeFreeProperty(prop);
|
|
|
|
drmModeFreeConnector(connector);
|
|
|
|
}
|
|
|
|
|
2012-07-27 01:57:15 +04:00
|
|
|
static const char *connector_type_names[] = {
|
|
|
|
"None",
|
|
|
|
"VGA",
|
|
|
|
"DVI",
|
|
|
|
"DVI",
|
|
|
|
"DVI",
|
|
|
|
"Composite",
|
|
|
|
"TV",
|
|
|
|
"LVDS",
|
|
|
|
"CTV",
|
|
|
|
"DIN",
|
|
|
|
"DP",
|
|
|
|
"HDMI",
|
|
|
|
"HDMI",
|
|
|
|
"TV",
|
|
|
|
"eDP",
|
|
|
|
};
|
|
|
|
|
2012-07-27 06:44:55 +04:00
|
|
|
static int
|
|
|
|
find_crtc_for_connector(struct drm_compositor *ec,
|
|
|
|
drmModeRes *resources, drmModeConnector *connector)
|
|
|
|
{
|
|
|
|
drmModeEncoder *encoder;
|
|
|
|
uint32_t possible_crtcs;
|
|
|
|
int i, j;
|
|
|
|
|
|
|
|
for (j = 0; j < connector->count_encoders; j++) {
|
|
|
|
encoder = drmModeGetEncoder(ec->drm.fd, connector->encoders[j]);
|
|
|
|
if (encoder == NULL) {
|
|
|
|
weston_log("Failed to get encoder.\n");
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
possible_crtcs = encoder->possible_crtcs;
|
|
|
|
drmModeFreeEncoder(encoder);
|
|
|
|
|
|
|
|
for (i = 0; i < resources->count_crtcs; i++) {
|
|
|
|
if (possible_crtcs & (1 << i) &&
|
|
|
|
!(ec->crtc_allocator & (1 << resources->crtcs[i])))
|
|
|
|
return i;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2010-06-11 20:56:24 +04:00
|
|
|
static int
|
2010-06-14 19:54:00 +04:00
|
|
|
create_output_for_connector(struct drm_compositor *ec,
|
2010-06-11 20:56:24 +04:00
|
|
|
drmModeRes *resources,
|
2011-03-11 18:39:20 +03:00
|
|
|
drmModeConnector *connector,
|
2012-02-29 21:53:50 +04:00
|
|
|
int x, int y, struct udev_device *drm_device)
|
2010-06-11 20:56:24 +04:00
|
|
|
{
|
2010-06-14 19:54:00 +04:00
|
|
|
struct drm_output *output;
|
2012-08-09 17:45:00 +04:00
|
|
|
struct drm_mode *drm_mode, *next, *preferred, *current, *configured;
|
|
|
|
struct weston_mode *m;
|
2012-07-31 05:51:08 +04:00
|
|
|
struct drm_configured_output *o = NULL, *temp;
|
2010-06-11 20:56:24 +04:00
|
|
|
drmModeEncoder *encoder;
|
2012-06-28 19:28:15 +04:00
|
|
|
drmModeModeInfo crtc_mode;
|
|
|
|
drmModeCrtc *crtc;
|
2012-08-09 17:45:00 +04:00
|
|
|
int i;
|
2012-07-27 01:57:15 +04:00
|
|
|
char name[32];
|
|
|
|
const char *type_name;
|
2010-06-11 20:56:24 +04:00
|
|
|
|
2012-07-27 06:44:55 +04:00
|
|
|
i = find_crtc_for_connector(ec, resources, connector);
|
|
|
|
if (i < 0) {
|
|
|
|
weston_log("No usable crtc/encoder pair for connector.\n");
|
2010-06-11 20:56:24 +04:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2011-06-21 19:16:58 +04:00
|
|
|
output = malloc(sizeof *output);
|
2012-07-27 06:44:55 +04:00
|
|
|
if (output == NULL)
|
2011-06-21 19:16:58 +04:00
|
|
|
return -1;
|
|
|
|
|
2010-06-14 19:54:00 +04:00
|
|
|
memset(output, 0, sizeof *output);
|
2011-06-21 19:16:58 +04:00
|
|
|
output->base.subpixel = drm_subpixel_to_wayland(connector->subpixel);
|
|
|
|
output->base.make = "unknown";
|
|
|
|
output->base.model = "unknown";
|
|
|
|
wl_list_init(&output->base.mode_list);
|
2010-06-14 19:54:00 +04:00
|
|
|
|
2012-07-27 01:57:15 +04:00
|
|
|
if (connector->connector_type < ARRAY_LENGTH(connector_type_names))
|
|
|
|
type_name = connector_type_names[connector->connector_type];
|
|
|
|
else
|
|
|
|
type_name = "UNKNOWN";
|
|
|
|
snprintf(name, 32, "%s%d", type_name, connector->connector_type_id);
|
|
|
|
output->name = strdup(name);
|
|
|
|
|
2010-06-11 20:56:24 +04:00
|
|
|
output->crtc_id = resources->crtcs[i];
|
2012-08-09 05:27:37 +04:00
|
|
|
output->pipe = i;
|
2011-03-15 17:08:41 +03:00
|
|
|
ec->crtc_allocator |= (1 << output->crtc_id);
|
2010-06-11 20:56:24 +04:00
|
|
|
output->connector_id = connector->connector_id;
|
2011-03-15 17:08:41 +03:00
|
|
|
ec->connector_allocator |= (1 << output->connector_id);
|
2011-06-21 19:16:58 +04:00
|
|
|
|
2011-08-30 00:52:23 +04:00
|
|
|
output->original_crtc = drmModeGetCrtc(ec->drm.fd, output->crtc_id);
|
2011-12-08 20:05:45 +04:00
|
|
|
|
2012-06-28 19:28:15 +04:00
|
|
|
/* Get the current mode on the crtc that's currently driving
|
|
|
|
* this connector. */
|
|
|
|
encoder = drmModeGetEncoder(ec->drm.fd, connector->encoder_id);
|
2012-07-31 02:09:46 +04:00
|
|
|
memset(&crtc_mode, 0, sizeof crtc_mode);
|
|
|
|
if (encoder != NULL) {
|
|
|
|
crtc = drmModeGetCrtc(ec->drm.fd, encoder->crtc_id);
|
|
|
|
drmModeFreeEncoder(encoder);
|
|
|
|
if (crtc == NULL)
|
|
|
|
goto err_free;
|
|
|
|
if (crtc->mode_valid)
|
|
|
|
crtc_mode = crtc->mode;
|
|
|
|
drmModeFreeCrtc(crtc);
|
|
|
|
}
|
2012-06-28 19:28:15 +04:00
|
|
|
|
2011-12-08 20:05:45 +04:00
|
|
|
for (i = 0; i < connector->count_modes; i++) {
|
2012-08-09 17:45:00 +04:00
|
|
|
drm_mode = drm_output_add_mode(output, &connector->modes[i]);
|
|
|
|
if (!drm_mode)
|
2011-12-08 20:05:45 +04:00
|
|
|
goto err_free;
|
|
|
|
}
|
2011-08-30 00:52:23 +04:00
|
|
|
|
2012-06-28 19:28:15 +04:00
|
|
|
preferred = NULL;
|
|
|
|
current = NULL;
|
2012-07-31 05:51:08 +04:00
|
|
|
configured = NULL;
|
|
|
|
|
|
|
|
wl_list_for_each(temp, &configured_output_list, link) {
|
|
|
|
if (strcmp(temp->name, output->name) == 0) {
|
|
|
|
weston_log("%s mode \"%s\" in config\n",
|
|
|
|
temp->name, temp->mode);
|
|
|
|
o = temp;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-08-09 17:45:01 +04:00
|
|
|
if (o && o->config == OUTPUT_CONFIG_OFF) {
|
2012-07-31 05:51:08 +04:00
|
|
|
weston_log("Disabling output %s\n", o->name);
|
|
|
|
|
|
|
|
drmModeSetCrtc(ec->drm.fd, output->crtc_id,
|
|
|
|
0, 0, 0, 0, 0, NULL);
|
|
|
|
goto err_free;
|
|
|
|
}
|
|
|
|
|
2012-06-28 19:28:15 +04:00
|
|
|
wl_list_for_each(drm_mode, &output->base.mode_list, base.link) {
|
2012-07-31 05:51:08 +04:00
|
|
|
if (o && o->width == drm_mode->base.width &&
|
2012-08-01 01:30:41 +04:00
|
|
|
o->height == drm_mode->base.height &&
|
|
|
|
o->config == OUTPUT_CONFIG_MODE)
|
2012-08-09 17:45:00 +04:00
|
|
|
configured = drm_mode;
|
2012-07-31 02:09:46 +04:00
|
|
|
if (!memcmp(&crtc_mode, &drm_mode->mode_info, sizeof crtc_mode))
|
2012-08-09 17:45:00 +04:00
|
|
|
current = drm_mode;
|
2012-06-28 19:28:15 +04:00
|
|
|
if (drm_mode->base.flags & WL_OUTPUT_MODE_PREFERRED)
|
2012-08-09 17:45:00 +04:00
|
|
|
preferred = drm_mode;
|
2012-06-28 19:28:15 +04:00
|
|
|
}
|
|
|
|
|
2012-08-01 01:30:41 +04:00
|
|
|
if (o && o->config == OUTPUT_CONFIG_MODELINE) {
|
2012-08-09 17:45:00 +04:00
|
|
|
configured = drm_output_add_mode(output, &o->crtc_mode);
|
|
|
|
if (!configured)
|
2012-08-01 01:30:41 +04:00
|
|
|
goto err_free;
|
|
|
|
current = configured;
|
|
|
|
}
|
|
|
|
|
2012-07-31 02:09:46 +04:00
|
|
|
if (current == NULL && crtc_mode.clock != 0) {
|
2012-08-09 17:45:00 +04:00
|
|
|
current = drm_output_add_mode(output, &crtc_mode);
|
|
|
|
if (!current)
|
2011-12-08 20:05:45 +04:00
|
|
|
goto err_free;
|
|
|
|
}
|
2011-06-21 19:16:58 +04:00
|
|
|
|
2012-07-31 05:51:08 +04:00
|
|
|
if (o && o->config == OUTPUT_CONFIG_CURRENT)
|
|
|
|
configured = current;
|
|
|
|
|
2012-07-31 02:09:46 +04:00
|
|
|
if (option_current_mode && current)
|
2012-08-09 17:45:00 +04:00
|
|
|
output->base.current = ¤t->base;
|
2012-07-31 05:51:08 +04:00
|
|
|
else if (configured)
|
2012-08-09 17:45:00 +04:00
|
|
|
output->base.current = &configured->base;
|
2012-07-31 02:09:46 +04:00
|
|
|
else if (preferred)
|
2012-08-09 17:45:00 +04:00
|
|
|
output->base.current = &preferred->base;
|
2012-07-31 02:09:46 +04:00
|
|
|
else if (current)
|
2012-08-09 17:45:00 +04:00
|
|
|
output->base.current = ¤t->base;
|
2012-07-31 02:09:46 +04:00
|
|
|
|
|
|
|
if (output->base.current == NULL) {
|
|
|
|
weston_log("no available modes for %s\n", output->name);
|
|
|
|
goto err_free;
|
2012-06-28 19:28:15 +04:00
|
|
|
}
|
2011-06-21 19:16:58 +04:00
|
|
|
|
2012-07-31 02:09:46 +04:00
|
|
|
output->base.current->flags |= WL_OUTPUT_MODE_CURRENT;
|
|
|
|
|
2012-03-12 02:27:41 +04:00
|
|
|
output->surface = gbm_surface_create(ec->gbm,
|
|
|
|
output->base.current->width,
|
|
|
|
output->base.current->height,
|
|
|
|
GBM_FORMAT_XRGB8888,
|
|
|
|
GBM_BO_USE_SCANOUT |
|
|
|
|
GBM_BO_USE_RENDERING);
|
|
|
|
if (!output->surface) {
|
2012-06-07 20:01:59 +04:00
|
|
|
weston_log("failed to create gbm surface\n");
|
2012-03-12 02:27:41 +04:00
|
|
|
goto err_free;
|
2010-06-11 20:56:24 +04:00
|
|
|
}
|
|
|
|
|
2012-03-12 02:27:41 +04:00
|
|
|
output->egl_surface =
|
2012-06-18 23:13:51 +04:00
|
|
|
eglCreateWindowSurface(ec->base.egl_display,
|
|
|
|
ec->base.egl_config,
|
|
|
|
output->surface,
|
|
|
|
NULL);
|
2012-03-12 02:27:41 +04:00
|
|
|
if (output->egl_surface == EGL_NO_SURFACE) {
|
2012-06-07 20:01:59 +04:00
|
|
|
weston_log("failed to create egl surface\n");
|
2012-03-12 02:27:41 +04:00
|
|
|
goto err_surface;
|
2010-06-11 20:56:24 +04:00
|
|
|
}
|
|
|
|
|
2012-05-03 19:39:35 +04:00
|
|
|
output->cursor_bo[0] =
|
|
|
|
gbm_bo_create(ec->gbm, 64, 64, GBM_FORMAT_ARGB8888,
|
|
|
|
GBM_BO_USE_CURSOR_64X64 | GBM_BO_USE_WRITE);
|
|
|
|
output->cursor_bo[1] =
|
|
|
|
gbm_bo_create(ec->gbm, 64, 64, GBM_FORMAT_ARGB8888,
|
|
|
|
GBM_BO_USE_CURSOR_64X64 | GBM_BO_USE_WRITE);
|
|
|
|
|
2012-02-29 21:53:50 +04:00
|
|
|
output->backlight = backlight_init(drm_device,
|
|
|
|
connector->connector_type);
|
|
|
|
if (output->backlight) {
|
|
|
|
output->base.set_backlight = drm_set_backlight;
|
|
|
|
output->base.backlight_current = drm_get_backlight(output);
|
|
|
|
}
|
|
|
|
|
Rename wayland-compositor to weston
This rename addresses a few problems around the split between core
Wayland and the wayland-demos repository.
1) Initially, we had one big repository with protocol code, sample
compositor and sample clients. We split that repository to make it
possible to implement the protocol without pulling in the sample/demo
code. At this point, the compositor is more than just a "demo" and
wayland-demos doesn't send the right message. The sample compositor
is a useful, self-contained project in it's own right, and we want to
move away from the "demos" label.
2) Another problem is that the wayland-demos compositor is often
called "the wayland compsitor", but it's really just one possible
compositor. Existing X11 compositors are expected to add Wayland
support and then gradually phase out/modularize the X11 support, for
example. Conversely, it's hard to talk about the wayland-demos
compositor specifically as opposed to, eg, the wayland protocol or a
wayland compositor in general.
We are also renaming the repo to weston, and the compositor
subdirectory to src/, to emphasize that the main "output" is the
compositor.
2012-01-03 19:29:47 +04:00
|
|
|
weston_output_init(&output->base, &ec->base, x, y,
|
2012-08-10 17:57:56 +04:00
|
|
|
connector->mmWidth, connector->mmHeight);
|
2011-10-24 21:26:32 +04:00
|
|
|
|
|
|
|
wl_list_insert(ec->base.output_list.prev, &output->base.link);
|
|
|
|
|
2012-04-17 13:20:49 +04:00
|
|
|
output->base.origin = output->base.current;
|
2012-01-26 08:32:28 +04:00
|
|
|
output->base.repaint = drm_output_repaint;
|
2011-08-30 00:52:23 +04:00
|
|
|
output->base.destroy = drm_output_destroy;
|
2012-02-23 18:45:49 +04:00
|
|
|
output->base.assign_planes = drm_assign_planes;
|
2012-02-29 21:53:50 +04:00
|
|
|
output->base.set_dpms = drm_set_dpms;
|
2012-04-17 13:20:48 +04:00
|
|
|
output->base.switch_mode = drm_output_switch_mode;
|
2011-03-11 18:39:20 +03:00
|
|
|
|
2012-08-03 19:30:18 +04:00
|
|
|
weston_plane_init(&output->cursor_plane, 0, 0);
|
|
|
|
weston_plane_init(&output->fb_plane, 0, 0);
|
|
|
|
|
2012-07-27 01:57:15 +04:00
|
|
|
weston_log("Output %s, (connector %d, crtc %d)\n",
|
|
|
|
output->name, output->connector_id, output->crtc_id);
|
2012-06-28 19:28:15 +04:00
|
|
|
wl_list_for_each(m, &output->base.mode_list, link)
|
|
|
|
weston_log_continue(" mode %dx%d@%.1f%s%s%s\n",
|
|
|
|
m->width, m->height, m->refresh / 1000.0,
|
|
|
|
m->flags & WL_OUTPUT_MODE_PREFERRED ?
|
|
|
|
", preferred" : "",
|
|
|
|
m->flags & WL_OUTPUT_MODE_CURRENT ?
|
|
|
|
", current" : "",
|
|
|
|
connector->count_modes == 0 ?
|
|
|
|
", built-in" : "");
|
2012-06-09 00:45:33 +04:00
|
|
|
|
2010-06-11 20:56:24 +04:00
|
|
|
return 0;
|
2011-12-08 20:05:45 +04:00
|
|
|
|
2012-03-12 02:27:41 +04:00
|
|
|
err_surface:
|
|
|
|
gbm_surface_destroy(output->surface);
|
2011-12-08 20:05:45 +04:00
|
|
|
err_free:
|
|
|
|
wl_list_for_each_safe(drm_mode, next, &output->base.mode_list,
|
|
|
|
base.link) {
|
|
|
|
wl_list_remove(&drm_mode->base.link);
|
|
|
|
free(drm_mode);
|
|
|
|
}
|
|
|
|
|
|
|
|
drmModeFreeCrtc(output->original_crtc);
|
|
|
|
ec->crtc_allocator &= ~(1 << output->crtc_id);
|
|
|
|
ec->connector_allocator &= ~(1 << output->connector_id);
|
2012-07-27 07:03:57 +04:00
|
|
|
free(output->name);
|
2011-12-08 20:05:45 +04:00
|
|
|
free(output);
|
2012-03-12 02:27:41 +04:00
|
|
|
|
2011-12-08 20:05:45 +04:00
|
|
|
return -1;
|
2010-06-11 20:56:24 +04:00
|
|
|
}
|
|
|
|
|
2012-02-23 18:45:49 +04:00
|
|
|
static void
|
|
|
|
create_sprites(struct drm_compositor *ec)
|
|
|
|
{
|
|
|
|
struct drm_sprite *sprite;
|
|
|
|
drmModePlaneRes *plane_res;
|
|
|
|
drmModePlane *plane;
|
2012-03-30 19:52:39 +04:00
|
|
|
uint32_t i;
|
2012-02-23 18:45:49 +04:00
|
|
|
|
|
|
|
plane_res = drmModeGetPlaneResources(ec->drm.fd);
|
|
|
|
if (!plane_res) {
|
2012-06-07 20:01:59 +04:00
|
|
|
weston_log("failed to get plane resources: %s\n",
|
2012-02-23 18:45:49 +04:00
|
|
|
strerror(errno));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0; i < plane_res->count_planes; i++) {
|
|
|
|
plane = drmModeGetPlane(ec->drm.fd, plane_res->planes[i]);
|
|
|
|
if (!plane)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
sprite = malloc(sizeof(*sprite) + ((sizeof(uint32_t)) *
|
|
|
|
plane->count_formats));
|
|
|
|
if (!sprite) {
|
2012-06-07 20:01:59 +04:00
|
|
|
weston_log("%s: out of memory\n",
|
2012-02-23 18:45:49 +04:00
|
|
|
__func__);
|
|
|
|
free(plane);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
memset(sprite, 0, sizeof *sprite);
|
|
|
|
|
|
|
|
sprite->possible_crtcs = plane->possible_crtcs;
|
|
|
|
sprite->plane_id = plane->plane_id;
|
|
|
|
sprite->surface = NULL;
|
|
|
|
sprite->pending_surface = NULL;
|
|
|
|
sprite->fb_id = 0;
|
|
|
|
sprite->pending_fb_id = 0;
|
2012-04-12 07:18:23 +04:00
|
|
|
sprite->destroy_listener.notify = sprite_handle_buffer_destroy;
|
|
|
|
sprite->pending_destroy_listener.notify =
|
2012-02-23 18:45:49 +04:00
|
|
|
sprite_handle_pending_buffer_destroy;
|
|
|
|
sprite->compositor = ec;
|
|
|
|
sprite->count_formats = plane->count_formats;
|
|
|
|
memcpy(sprite->formats, plane->formats,
|
2012-03-12 04:48:44 +04:00
|
|
|
plane->count_formats * sizeof(plane->formats[0]));
|
2012-02-23 18:45:49 +04:00
|
|
|
drmModeFreePlane(plane);
|
2012-08-03 19:30:18 +04:00
|
|
|
weston_plane_init(&sprite->plane, 0, 0);
|
2012-02-23 18:45:49 +04:00
|
|
|
|
|
|
|
wl_list_insert(&ec->sprite_list, &sprite->link);
|
|
|
|
}
|
|
|
|
|
|
|
|
free(plane_res->planes);
|
|
|
|
free(plane_res);
|
|
|
|
}
|
|
|
|
|
2012-02-24 06:45:32 +04:00
|
|
|
static void
|
|
|
|
destroy_sprites(struct drm_compositor *compositor)
|
|
|
|
{
|
|
|
|
struct drm_sprite *sprite, *next;
|
|
|
|
struct drm_output *output;
|
|
|
|
|
|
|
|
output = container_of(compositor->base.output_list.next,
|
|
|
|
struct drm_output, base.link);
|
|
|
|
|
|
|
|
wl_list_for_each_safe(sprite, next, &compositor->sprite_list, link) {
|
|
|
|
drmModeSetPlane(compositor->drm.fd,
|
|
|
|
sprite->plane_id,
|
|
|
|
output->crtc_id, 0, 0,
|
|
|
|
0, 0, 0, 0, 0, 0, 0, 0);
|
|
|
|
drmModeRmFB(compositor->drm.fd, sprite->fb_id);
|
2012-08-03 19:30:18 +04:00
|
|
|
weston_plane_release(&sprite->plane);
|
2012-02-24 06:45:32 +04:00
|
|
|
free(sprite);
|
|
|
|
}
|
|
|
|
}
|
2012-02-23 18:45:49 +04:00
|
|
|
|
2010-06-11 20:56:24 +04:00
|
|
|
static int
|
2012-03-30 19:52:39 +04:00
|
|
|
create_outputs(struct drm_compositor *ec, uint32_t option_connector,
|
2012-02-29 21:53:50 +04:00
|
|
|
struct udev_device *drm_device)
|
2010-06-11 20:56:24 +04:00
|
|
|
{
|
|
|
|
drmModeConnector *connector;
|
|
|
|
drmModeRes *resources;
|
|
|
|
int i;
|
2011-03-11 18:39:20 +03:00
|
|
|
int x = 0, y = 0;
|
2010-06-11 20:56:24 +04:00
|
|
|
|
2011-03-02 13:14:59 +03:00
|
|
|
resources = drmModeGetResources(ec->drm.fd);
|
2010-06-11 20:56:24 +04:00
|
|
|
if (!resources) {
|
2012-06-07 20:01:59 +04:00
|
|
|
weston_log("drmModeGetResources failed\n");
|
2010-06-11 20:56:24 +04:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2012-02-23 18:45:49 +04:00
|
|
|
ec->crtcs = calloc(resources->count_crtcs, sizeof(uint32_t));
|
2012-03-07 23:55:21 +04:00
|
|
|
if (!ec->crtcs) {
|
|
|
|
drmModeFreeResources(resources);
|
2012-02-23 18:45:49 +04:00
|
|
|
return -1;
|
2012-03-07 23:55:21 +04:00
|
|
|
}
|
2012-02-23 18:45:49 +04:00
|
|
|
|
2012-08-09 23:18:28 +04:00
|
|
|
ec->min_width = resources->min_width;
|
|
|
|
ec->max_width = resources->max_width;
|
|
|
|
ec->min_height = resources->min_height;
|
|
|
|
ec->max_height = resources->max_height;
|
|
|
|
|
2012-02-23 18:45:49 +04:00
|
|
|
ec->num_crtcs = resources->count_crtcs;
|
|
|
|
memcpy(ec->crtcs, resources->crtcs, sizeof(uint32_t) * ec->num_crtcs);
|
|
|
|
|
2010-06-11 20:56:24 +04:00
|
|
|
for (i = 0; i < resources->count_connectors; i++) {
|
2011-08-30 13:38:26 +04:00
|
|
|
connector = drmModeGetConnector(ec->drm.fd,
|
|
|
|
resources->connectors[i]);
|
2010-06-11 20:56:24 +04:00
|
|
|
if (connector == NULL)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if (connector->connection == DRM_MODE_CONNECTED &&
|
|
|
|
(option_connector == 0 ||
|
2011-08-02 15:03:54 +04:00
|
|
|
connector->connector_id == option_connector)) {
|
2011-03-11 18:39:20 +03:00
|
|
|
if (create_output_for_connector(ec, resources,
|
2012-02-29 21:53:50 +04:00
|
|
|
connector, x, y,
|
|
|
|
drm_device) < 0) {
|
2011-10-07 10:20:53 +04:00
|
|
|
drmModeFreeConnector(connector);
|
|
|
|
continue;
|
|
|
|
}
|
2010-06-11 20:56:24 +04:00
|
|
|
|
2011-08-02 15:03:54 +04:00
|
|
|
x += container_of(ec->base.output_list.prev,
|
Rename wayland-compositor to weston
This rename addresses a few problems around the split between core
Wayland and the wayland-demos repository.
1) Initially, we had one big repository with protocol code, sample
compositor and sample clients. We split that repository to make it
possible to implement the protocol without pulling in the sample/demo
code. At this point, the compositor is more than just a "demo" and
wayland-demos doesn't send the right message. The sample compositor
is a useful, self-contained project in it's own right, and we want to
move away from the "demos" label.
2) Another problem is that the wayland-demos compositor is often
called "the wayland compsitor", but it's really just one possible
compositor. Existing X11 compositors are expected to add Wayland
support and then gradually phase out/modularize the X11 support, for
example. Conversely, it's hard to talk about the wayland-demos
compositor specifically as opposed to, eg, the wayland protocol or a
wayland compositor in general.
We are also renaming the repo to weston, and the compositor
subdirectory to src/, to emphasize that the main "output" is the
compositor.
2012-01-03 19:29:47 +04:00
|
|
|
struct weston_output,
|
2011-08-02 15:03:54 +04:00
|
|
|
link)->current->width;
|
|
|
|
}
|
2011-03-11 18:39:20 +03:00
|
|
|
|
2010-06-11 20:56:24 +04:00
|
|
|
drmModeFreeConnector(connector);
|
|
|
|
}
|
|
|
|
|
2010-06-14 19:54:00 +04:00
|
|
|
if (wl_list_empty(&ec->base.output_list)) {
|
2012-06-07 20:01:59 +04:00
|
|
|
weston_log("No currently active connector found.\n");
|
2012-03-07 23:55:21 +04:00
|
|
|
drmModeFreeResources(resources);
|
2010-06-11 20:56:24 +04:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
drmModeFreeResources(resources);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2011-03-15 17:08:41 +03:00
|
|
|
static void
|
2012-02-29 21:53:50 +04:00
|
|
|
update_outputs(struct drm_compositor *ec, struct udev_device *drm_device)
|
2011-03-15 17:08:41 +03:00
|
|
|
{
|
|
|
|
drmModeConnector *connector;
|
|
|
|
drmModeRes *resources;
|
|
|
|
struct drm_output *output, *next;
|
|
|
|
int x = 0, y = 0;
|
|
|
|
int x_offset = 0, y_offset = 0;
|
|
|
|
uint32_t connected = 0, disconnects = 0;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
resources = drmModeGetResources(ec->drm.fd);
|
|
|
|
if (!resources) {
|
2012-06-07 20:01:59 +04:00
|
|
|
weston_log("drmModeGetResources failed\n");
|
2011-03-15 17:08:41 +03:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* collect new connects */
|
|
|
|
for (i = 0; i < resources->count_connectors; i++) {
|
2011-08-30 13:38:26 +04:00
|
|
|
int connector_id = resources->connectors[i];
|
|
|
|
|
|
|
|
connector = drmModeGetConnector(ec->drm.fd, connector_id);
|
2011-12-08 20:05:43 +04:00
|
|
|
if (connector == NULL)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if (connector->connection != DRM_MODE_CONNECTED) {
|
|
|
|
drmModeFreeConnector(connector);
|
2011-03-15 17:08:41 +03:00
|
|
|
continue;
|
2011-12-08 20:05:43 +04:00
|
|
|
}
|
2011-03-15 17:08:41 +03:00
|
|
|
|
2011-08-30 13:38:26 +04:00
|
|
|
connected |= (1 << connector_id);
|
|
|
|
|
|
|
|
if (!(ec->connector_allocator & (1 << connector_id))) {
|
Rename wayland-compositor to weston
This rename addresses a few problems around the split between core
Wayland and the wayland-demos repository.
1) Initially, we had one big repository with protocol code, sample
compositor and sample clients. We split that repository to make it
possible to implement the protocol without pulling in the sample/demo
code. At this point, the compositor is more than just a "demo" and
wayland-demos doesn't send the right message. The sample compositor
is a useful, self-contained project in it's own right, and we want to
move away from the "demos" label.
2) Another problem is that the wayland-demos compositor is often
called "the wayland compsitor", but it's really just one possible
compositor. Existing X11 compositors are expected to add Wayland
support and then gradually phase out/modularize the X11 support, for
example. Conversely, it's hard to talk about the wayland-demos
compositor specifically as opposed to, eg, the wayland protocol or a
wayland compositor in general.
We are also renaming the repo to weston, and the compositor
subdirectory to src/, to emphasize that the main "output" is the
compositor.
2012-01-03 19:29:47 +04:00
|
|
|
struct weston_output *last =
|
2011-03-15 17:08:41 +03:00
|
|
|
container_of(ec->base.output_list.prev,
|
Rename wayland-compositor to weston
This rename addresses a few problems around the split between core
Wayland and the wayland-demos repository.
1) Initially, we had one big repository with protocol code, sample
compositor and sample clients. We split that repository to make it
possible to implement the protocol without pulling in the sample/demo
code. At this point, the compositor is more than just a "demo" and
wayland-demos doesn't send the right message. The sample compositor
is a useful, self-contained project in it's own right, and we want to
move away from the "demos" label.
2) Another problem is that the wayland-demos compositor is often
called "the wayland compsitor", but it's really just one possible
compositor. Existing X11 compositors are expected to add Wayland
support and then gradually phase out/modularize the X11 support, for
example. Conversely, it's hard to talk about the wayland-demos
compositor specifically as opposed to, eg, the wayland protocol or a
wayland compositor in general.
We are also renaming the repo to weston, and the compositor
subdirectory to src/, to emphasize that the main "output" is the
compositor.
2012-01-03 19:29:47 +04:00
|
|
|
struct weston_output, link);
|
2011-03-15 17:08:41 +03:00
|
|
|
|
|
|
|
/* XXX: not yet needed, we die with 0 outputs */
|
|
|
|
if (!wl_list_empty(&ec->base.output_list))
|
2011-08-30 13:38:26 +04:00
|
|
|
x = last->x + last->current->width;
|
2011-03-15 17:08:41 +03:00
|
|
|
else
|
|
|
|
x = 0;
|
|
|
|
y = 0;
|
|
|
|
create_output_for_connector(ec, resources,
|
2012-02-29 21:53:50 +04:00
|
|
|
connector, x, y,
|
|
|
|
drm_device);
|
2012-06-07 20:01:59 +04:00
|
|
|
weston_log("connector %d connected\n", connector_id);
|
2011-08-30 13:38:26 +04:00
|
|
|
|
2011-03-15 17:08:41 +03:00
|
|
|
}
|
|
|
|
drmModeFreeConnector(connector);
|
|
|
|
}
|
|
|
|
drmModeFreeResources(resources);
|
|
|
|
|
|
|
|
disconnects = ec->connector_allocator & ~connected;
|
|
|
|
if (disconnects) {
|
|
|
|
wl_list_for_each_safe(output, next, &ec->base.output_list,
|
|
|
|
base.link) {
|
|
|
|
if (x_offset != 0 || y_offset != 0) {
|
Rename wayland-compositor to weston
This rename addresses a few problems around the split between core
Wayland and the wayland-demos repository.
1) Initially, we had one big repository with protocol code, sample
compositor and sample clients. We split that repository to make it
possible to implement the protocol without pulling in the sample/demo
code. At this point, the compositor is more than just a "demo" and
wayland-demos doesn't send the right message. The sample compositor
is a useful, self-contained project in it's own right, and we want to
move away from the "demos" label.
2) Another problem is that the wayland-demos compositor is often
called "the wayland compsitor", but it's really just one possible
compositor. Existing X11 compositors are expected to add Wayland
support and then gradually phase out/modularize the X11 support, for
example. Conversely, it's hard to talk about the wayland-demos
compositor specifically as opposed to, eg, the wayland protocol or a
wayland compositor in general.
We are also renaming the repo to weston, and the compositor
subdirectory to src/, to emphasize that the main "output" is the
compositor.
2012-01-03 19:29:47 +04:00
|
|
|
weston_output_move(&output->base,
|
2011-03-15 17:08:41 +03:00
|
|
|
output->base.x - x_offset,
|
|
|
|
output->base.y - y_offset);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (disconnects & (1 << output->connector_id)) {
|
|
|
|
disconnects &= ~(1 << output->connector_id);
|
2012-06-07 20:01:59 +04:00
|
|
|
weston_log("connector %d disconnected\n",
|
2011-03-15 17:08:41 +03:00
|
|
|
output->connector_id);
|
2011-06-21 19:16:58 +04:00
|
|
|
x_offset += output->base.current->width;
|
2011-08-30 13:44:56 +04:00
|
|
|
drm_output_destroy(&output->base);
|
2011-03-15 17:08:41 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* FIXME: handle zero outputs, without terminating */
|
|
|
|
if (ec->connector_allocator == 0)
|
|
|
|
wl_display_terminate(ec->base.wl_display);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2012-03-11 23:05:21 +04:00
|
|
|
udev_event_is_hotplug(struct drm_compositor *ec, struct udev_device *device)
|
2011-03-15 17:08:41 +03:00
|
|
|
{
|
2012-03-11 23:05:21 +04:00
|
|
|
const char *sysnum;
|
2012-03-11 23:05:22 +04:00
|
|
|
const char *val;
|
2012-03-11 23:05:21 +04:00
|
|
|
|
|
|
|
sysnum = udev_device_get_sysnum(device);
|
|
|
|
if (!sysnum || atoi(sysnum) != ec->drm.id)
|
|
|
|
return 0;
|
2011-08-30 13:38:26 +04:00
|
|
|
|
2012-03-11 23:05:22 +04:00
|
|
|
val = udev_device_get_property_value(device, "HOTPLUG");
|
|
|
|
if (!val)
|
2011-03-15 17:08:41 +03:00
|
|
|
return 0;
|
|
|
|
|
2012-03-11 23:05:22 +04:00
|
|
|
return strcmp(val, "1") == 0;
|
2011-03-15 17:08:41 +03:00
|
|
|
}
|
|
|
|
|
2011-04-22 20:27:57 +04:00
|
|
|
static int
|
2011-03-15 17:08:41 +03:00
|
|
|
udev_drm_event(int fd, uint32_t mask, void *data)
|
|
|
|
{
|
|
|
|
struct drm_compositor *ec = data;
|
|
|
|
struct udev_device *event;
|
|
|
|
|
|
|
|
event = udev_monitor_receive_device(ec->udev_monitor);
|
2011-08-30 13:38:26 +04:00
|
|
|
|
2012-03-11 23:05:21 +04:00
|
|
|
if (udev_event_is_hotplug(ec, event))
|
2012-02-29 21:53:50 +04:00
|
|
|
update_outputs(ec, event);
|
2011-03-15 17:08:41 +03:00
|
|
|
|
|
|
|
udev_device_unref(event);
|
2011-04-22 20:27:57 +04:00
|
|
|
|
|
|
|
return 1;
|
2011-03-15 17:08:41 +03:00
|
|
|
}
|
|
|
|
|
2012-07-31 22:32:01 +04:00
|
|
|
static void
|
|
|
|
drm_restore(struct weston_compositor *ec)
|
|
|
|
{
|
|
|
|
struct drm_compositor *d = (struct drm_compositor *) ec;
|
|
|
|
|
|
|
|
if (weston_launcher_drm_set_master(&d->base, d->drm.fd, 0) < 0)
|
|
|
|
weston_log("failed to drop master: %m\n");
|
|
|
|
tty_reset(d->tty);
|
|
|
|
}
|
|
|
|
|
2012-08-03 21:30:30 +04:00
|
|
|
static const char default_seat[] = "seat0";
|
|
|
|
|
|
|
|
static void
|
|
|
|
device_added(struct udev_device *udev_device, struct drm_seat *master)
|
|
|
|
{
|
|
|
|
struct weston_compositor *c;
|
2012-08-06 15:57:08 +04:00
|
|
|
struct evdev_device *device;
|
2012-08-03 21:30:30 +04:00
|
|
|
const char *devnode;
|
|
|
|
const char *device_seat;
|
|
|
|
int fd;
|
|
|
|
|
|
|
|
device_seat = udev_device_get_property_value(udev_device, "ID_SEAT");
|
|
|
|
if (!device_seat)
|
|
|
|
device_seat = default_seat;
|
|
|
|
|
|
|
|
if (strcmp(device_seat, master->seat_id))
|
|
|
|
return;
|
|
|
|
|
|
|
|
c = master->base.compositor;
|
|
|
|
devnode = udev_device_get_devnode(udev_device);
|
|
|
|
|
|
|
|
/* Use non-blocking mode so that we can loop on read on
|
2012-08-06 15:57:08 +04:00
|
|
|
* evdev_device_data() until all events on the fd are
|
2012-08-03 21:30:30 +04:00
|
|
|
* read. mtdev_get() also expects this. */
|
|
|
|
fd = weston_launcher_open(c, devnode, O_RDWR | O_NONBLOCK);
|
|
|
|
if (fd < 0) {
|
|
|
|
weston_log("opening input device '%s' failed.\n", devnode);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-08-06 15:57:08 +04:00
|
|
|
device = evdev_device_create(&master->base, devnode, fd);
|
2012-08-03 21:30:30 +04:00
|
|
|
if (!device) {
|
|
|
|
close(fd);
|
|
|
|
weston_log("not using input device '%s'.\n", devnode);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
wl_list_insert(master->devices_list.prev, &device->link);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
evdev_add_devices(struct udev *udev, struct weston_seat *seat_base)
|
|
|
|
{
|
|
|
|
struct drm_seat *seat = (struct drm_seat *) seat_base;
|
|
|
|
struct udev_enumerate *e;
|
|
|
|
struct udev_list_entry *entry;
|
|
|
|
struct udev_device *device;
|
|
|
|
const char *path, *sysname;
|
|
|
|
|
|
|
|
e = udev_enumerate_new(udev);
|
|
|
|
udev_enumerate_add_match_subsystem(e, "input");
|
|
|
|
udev_enumerate_scan_devices(e);
|
|
|
|
udev_list_entry_foreach(entry, udev_enumerate_get_list_entry(e)) {
|
|
|
|
path = udev_list_entry_get_name(entry);
|
|
|
|
device = udev_device_new_from_syspath(udev, path);
|
|
|
|
|
|
|
|
sysname = udev_device_get_sysname(device);
|
|
|
|
if (strncmp("event", sysname, 5) != 0) {
|
|
|
|
udev_device_unref(device);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
device_added(device, seat);
|
|
|
|
|
|
|
|
udev_device_unref(device);
|
|
|
|
}
|
|
|
|
udev_enumerate_unref(e);
|
|
|
|
|
|
|
|
evdev_notify_keyboard_focus(&seat->base, &seat->devices_list);
|
|
|
|
|
|
|
|
if (wl_list_empty(&seat->devices_list)) {
|
|
|
|
weston_log(
|
|
|
|
"warning: no input devices on entering Weston. "
|
|
|
|
"Possible causes:\n"
|
|
|
|
"\t- no permissions to read /dev/input/event*\n"
|
|
|
|
"\t- seats misconfigured "
|
|
|
|
"(Weston backend option 'seat', "
|
|
|
|
"udev device property ID_SEAT)\n");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
evdev_udev_handler(int fd, uint32_t mask, void *data)
|
|
|
|
{
|
2012-08-03 15:39:08 +04:00
|
|
|
struct drm_seat *seat = data;
|
2012-08-03 21:30:30 +04:00
|
|
|
struct udev_device *udev_device;
|
2012-08-06 15:57:08 +04:00
|
|
|
struct evdev_device *device, *next;
|
2012-08-03 21:30:30 +04:00
|
|
|
const char *action;
|
|
|
|
const char *devnode;
|
|
|
|
|
2012-08-03 15:39:08 +04:00
|
|
|
udev_device = udev_monitor_receive_device(seat->udev_monitor);
|
2012-08-03 21:30:30 +04:00
|
|
|
if (!udev_device)
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
action = udev_device_get_action(udev_device);
|
2012-08-03 15:39:08 +04:00
|
|
|
if (!action)
|
|
|
|
goto out;
|
2012-08-03 21:30:30 +04:00
|
|
|
|
2012-08-03 15:39:08 +04:00
|
|
|
if (strncmp("event", udev_device_get_sysname(udev_device), 5) != 0)
|
|
|
|
goto out;
|
|
|
|
|
|
|
|
if (!strcmp(action, "add")) {
|
|
|
|
device_added(udev_device, seat);
|
2012-08-03 21:30:30 +04:00
|
|
|
}
|
2012-08-03 15:39:08 +04:00
|
|
|
else if (!strcmp(action, "remove")) {
|
|
|
|
devnode = udev_device_get_devnode(udev_device);
|
|
|
|
wl_list_for_each_safe(device, next, &seat->devices_list, link)
|
|
|
|
if (!strcmp(device->devnode, devnode)) {
|
2012-08-03 15:39:09 +04:00
|
|
|
weston_log("input device %s, %s removed\n",
|
|
|
|
device->devname, device->devnode);
|
2012-08-06 15:57:08 +04:00
|
|
|
evdev_device_destroy(device);
|
2012-08-03 15:39:08 +04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
out:
|
2012-08-03 21:30:30 +04:00
|
|
|
udev_device_unref(udev_device);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
evdev_enable_udev_monitor(struct udev *udev, struct weston_seat *seat_base)
|
|
|
|
{
|
|
|
|
struct drm_seat *master = (struct drm_seat *) seat_base;
|
|
|
|
struct wl_event_loop *loop;
|
|
|
|
struct weston_compositor *c = master->base.compositor;
|
|
|
|
int fd;
|
|
|
|
|
|
|
|
master->udev_monitor = udev_monitor_new_from_netlink(udev, "udev");
|
|
|
|
if (!master->udev_monitor) {
|
|
|
|
weston_log("udev: failed to create the udev monitor\n");
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
udev_monitor_filter_add_match_subsystem_devtype(master->udev_monitor,
|
|
|
|
"input", NULL);
|
|
|
|
|
|
|
|
if (udev_monitor_enable_receiving(master->udev_monitor)) {
|
|
|
|
weston_log("udev: failed to bind the udev monitor\n");
|
|
|
|
udev_monitor_unref(master->udev_monitor);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
loop = wl_display_get_event_loop(c->wl_display);
|
|
|
|
fd = udev_monitor_get_fd(master->udev_monitor);
|
|
|
|
master->udev_monitor_source =
|
|
|
|
wl_event_loop_add_fd(loop, fd, WL_EVENT_READABLE,
|
|
|
|
evdev_udev_handler, master);
|
|
|
|
if (!master->udev_monitor_source) {
|
|
|
|
udev_monitor_unref(master->udev_monitor);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
evdev_disable_udev_monitor(struct weston_seat *seat_base)
|
|
|
|
{
|
|
|
|
struct drm_seat *seat = (struct drm_seat *) seat_base;
|
|
|
|
|
|
|
|
if (!seat->udev_monitor)
|
|
|
|
return;
|
|
|
|
|
|
|
|
udev_monitor_unref(seat->udev_monitor);
|
|
|
|
seat->udev_monitor = NULL;
|
|
|
|
wl_event_source_remove(seat->udev_monitor_source);
|
|
|
|
seat->udev_monitor_source = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
drm_led_update(struct weston_seat *seat_base, enum weston_led leds)
|
|
|
|
{
|
|
|
|
struct drm_seat *seat = (struct drm_seat *) seat_base;
|
2012-08-06 15:57:08 +04:00
|
|
|
struct evdev_device *device;
|
2012-08-03 21:30:30 +04:00
|
|
|
|
2012-08-06 15:57:07 +04:00
|
|
|
wl_list_for_each(device, &seat->devices_list, link)
|
|
|
|
evdev_led_update(device, leds);
|
2012-08-03 21:30:30 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
evdev_input_create(struct weston_compositor *c, struct udev *udev,
|
|
|
|
const char *seat_id)
|
|
|
|
{
|
|
|
|
struct drm_seat *seat;
|
|
|
|
|
|
|
|
seat = malloc(sizeof *seat);
|
|
|
|
if (seat == NULL)
|
|
|
|
return;
|
|
|
|
|
|
|
|
memset(seat, 0, sizeof *seat);
|
|
|
|
weston_seat_init(&seat->base, c);
|
|
|
|
seat->base.led_update = drm_led_update;
|
|
|
|
|
|
|
|
wl_list_init(&seat->devices_list);
|
|
|
|
seat->seat_id = strdup(seat_id);
|
|
|
|
if (!evdev_enable_udev_monitor(udev, &seat->base)) {
|
|
|
|
free(seat->seat_id);
|
|
|
|
free(seat);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
evdev_add_devices(udev, &seat->base);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
evdev_remove_devices(struct weston_seat *seat_base)
|
|
|
|
{
|
|
|
|
struct drm_seat *seat = (struct drm_seat *) seat_base;
|
2012-08-06 15:57:08 +04:00
|
|
|
struct evdev_device *device, *next;
|
2012-08-03 21:30:30 +04:00
|
|
|
|
|
|
|
wl_list_for_each_safe(device, next, &seat->devices_list, link)
|
2012-08-06 15:57:08 +04:00
|
|
|
evdev_device_destroy(device);
|
2012-08-03 21:30:30 +04:00
|
|
|
|
2012-08-03 15:39:11 +04:00
|
|
|
if (seat->base.seat.keyboard)
|
|
|
|
notify_keyboard_focus_out(&seat->base.seat);
|
2012-08-03 21:30:30 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
evdev_input_destroy(struct weston_seat *seat_base)
|
|
|
|
{
|
|
|
|
struct drm_seat *seat = (struct drm_seat *) seat_base;
|
|
|
|
|
|
|
|
evdev_remove_devices(seat_base);
|
|
|
|
evdev_disable_udev_monitor(&seat->base);
|
|
|
|
|
|
|
|
weston_seat_release(seat_base);
|
|
|
|
free(seat->seat_id);
|
|
|
|
free(seat);
|
|
|
|
}
|
|
|
|
|
2012-08-01 08:29:56 +04:00
|
|
|
static void
|
|
|
|
drm_free_configured_output(struct drm_configured_output *output)
|
|
|
|
{
|
|
|
|
free(output->name);
|
|
|
|
free(output->mode);
|
|
|
|
free(output);
|
|
|
|
}
|
|
|
|
|
2010-12-02 00:52:15 +03:00
|
|
|
static void
|
Rename wayland-compositor to weston
This rename addresses a few problems around the split between core
Wayland and the wayland-demos repository.
1) Initially, we had one big repository with protocol code, sample
compositor and sample clients. We split that repository to make it
possible to implement the protocol without pulling in the sample/demo
code. At this point, the compositor is more than just a "demo" and
wayland-demos doesn't send the right message. The sample compositor
is a useful, self-contained project in it's own right, and we want to
move away from the "demos" label.
2) Another problem is that the wayland-demos compositor is often
called "the wayland compsitor", but it's really just one possible
compositor. Existing X11 compositors are expected to add Wayland
support and then gradually phase out/modularize the X11 support, for
example. Conversely, it's hard to talk about the wayland-demos
compositor specifically as opposed to, eg, the wayland protocol or a
wayland compositor in general.
We are also renaming the repo to weston, and the compositor
subdirectory to src/, to emphasize that the main "output" is the
compositor.
2012-01-03 19:29:47 +04:00
|
|
|
drm_destroy(struct weston_compositor *ec)
|
2010-12-02 00:52:15 +03:00
|
|
|
{
|
|
|
|
struct drm_compositor *d = (struct drm_compositor *) ec;
|
2012-05-16 21:45:18 +04:00
|
|
|
struct weston_seat *seat, *next;
|
2012-07-31 05:51:08 +04:00
|
|
|
struct drm_configured_output *o, *n;
|
2010-12-02 00:52:15 +03:00
|
|
|
|
2012-05-16 21:45:18 +04:00
|
|
|
wl_list_for_each_safe(seat, next, &ec->seat_list, link)
|
|
|
|
evdev_input_destroy(seat);
|
2012-07-31 05:51:08 +04:00
|
|
|
wl_list_for_each_safe(o, n, &configured_output_list, link)
|
2012-08-01 08:29:56 +04:00
|
|
|
drm_free_configured_output(o);
|
2012-03-29 00:36:09 +04:00
|
|
|
|
|
|
|
wl_event_source_remove(d->udev_drm_source);
|
|
|
|
wl_event_source_remove(d->drm_source);
|
|
|
|
|
Rename wayland-compositor to weston
This rename addresses a few problems around the split between core
Wayland and the wayland-demos repository.
1) Initially, we had one big repository with protocol code, sample
compositor and sample clients. We split that repository to make it
possible to implement the protocol without pulling in the sample/demo
code. At this point, the compositor is more than just a "demo" and
wayland-demos doesn't send the right message. The sample compositor
is a useful, self-contained project in it's own right, and we want to
move away from the "demos" label.
2) Another problem is that the wayland-demos compositor is often
called "the wayland compsitor", but it's really just one possible
compositor. Existing X11 compositors are expected to add Wayland
support and then gradually phase out/modularize the X11 support, for
example. Conversely, it's hard to talk about the wayland-demos
compositor specifically as opposed to, eg, the wayland protocol or a
wayland compositor in general.
We are also renaming the repo to weston, and the compositor
subdirectory to src/, to emphasize that the main "output" is the
compositor.
2012-01-03 19:29:47 +04:00
|
|
|
weston_compositor_shutdown(ec);
|
2012-03-29 00:36:09 +04:00
|
|
|
|
2012-04-30 14:31:28 +04:00
|
|
|
/* Work around crash in egl_dri2.c's dri2_make_current() */
|
2012-06-18 23:13:51 +04:00
|
|
|
eglMakeCurrent(ec->egl_display, EGL_NO_SURFACE, EGL_NO_SURFACE,
|
2012-04-30 14:31:28 +04:00
|
|
|
EGL_NO_CONTEXT);
|
2012-06-18 23:13:51 +04:00
|
|
|
eglTerminate(ec->egl_display);
|
2012-04-30 14:31:28 +04:00
|
|
|
eglReleaseThread();
|
|
|
|
|
2011-08-30 00:52:23 +04:00
|
|
|
gbm_device_destroy(d->gbm);
|
2012-02-24 06:45:32 +04:00
|
|
|
destroy_sprites(d);
|
2012-01-30 17:04:04 +04:00
|
|
|
if (weston_launcher_drm_set_master(&d->base, d->drm.fd, 0) < 0)
|
2012-06-07 20:01:59 +04:00
|
|
|
weston_log("failed to drop master: %m\n");
|
2011-01-14 22:59:13 +03:00
|
|
|
tty_destroy(d->tty);
|
2010-12-02 00:52:15 +03:00
|
|
|
|
2011-01-14 22:59:13 +03:00
|
|
|
free(d);
|
2010-12-02 00:52:15 +03:00
|
|
|
}
|
|
|
|
|
2012-01-18 20:48:46 +04:00
|
|
|
static void
|
|
|
|
drm_compositor_set_modes(struct drm_compositor *compositor)
|
|
|
|
{
|
|
|
|
struct drm_output *output;
|
|
|
|
struct drm_mode *drm_mode;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
wl_list_for_each(output, &compositor->base.output_list, base.link) {
|
|
|
|
drm_mode = (struct drm_mode *) output->base.current;
|
|
|
|
ret = drmModeSetCrtc(compositor->drm.fd, output->crtc_id,
|
2012-05-02 17:42:21 +04:00
|
|
|
output->current->fb_id, 0, 0,
|
2012-01-18 20:48:46 +04:00
|
|
|
&output->connector_id, 1,
|
|
|
|
&drm_mode->mode_info);
|
|
|
|
if (ret < 0) {
|
2012-06-07 20:01:59 +04:00
|
|
|
weston_log(
|
2012-03-12 02:27:41 +04:00
|
|
|
"failed to set mode %dx%d for output at %d,%d: %m\n",
|
2012-01-18 20:48:46 +04:00
|
|
|
drm_mode->base.width, drm_mode->base.height,
|
|
|
|
output->base.x, output->base.y);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-05-06 23:15:37 +04:00
|
|
|
static void
|
Rename wayland-compositor to weston
This rename addresses a few problems around the split between core
Wayland and the wayland-demos repository.
1) Initially, we had one big repository with protocol code, sample
compositor and sample clients. We split that repository to make it
possible to implement the protocol without pulling in the sample/demo
code. At this point, the compositor is more than just a "demo" and
wayland-demos doesn't send the right message. The sample compositor
is a useful, self-contained project in it's own right, and we want to
move away from the "demos" label.
2) Another problem is that the wayland-demos compositor is often
called "the wayland compsitor", but it's really just one possible
compositor. Existing X11 compositors are expected to add Wayland
support and then gradually phase out/modularize the X11 support, for
example. Conversely, it's hard to talk about the wayland-demos
compositor specifically as opposed to, eg, the wayland protocol or a
wayland compositor in general.
We are also renaming the repo to weston, and the compositor
subdirectory to src/, to emphasize that the main "output" is the
compositor.
2012-01-03 19:29:47 +04:00
|
|
|
vt_func(struct weston_compositor *compositor, int event)
|
2011-05-06 23:15:37 +04:00
|
|
|
{
|
|
|
|
struct drm_compositor *ec = (struct drm_compositor *) compositor;
|
2012-05-16 21:45:18 +04:00
|
|
|
struct weston_seat *seat;
|
2012-02-24 06:45:32 +04:00
|
|
|
struct drm_sprite *sprite;
|
2012-07-14 09:06:28 +04:00
|
|
|
struct drm_output *output;
|
2011-05-06 23:15:37 +04:00
|
|
|
|
|
|
|
switch (event) {
|
|
|
|
case TTY_ENTER_VT:
|
2012-08-03 15:39:10 +04:00
|
|
|
weston_log("entering VT\n");
|
2011-05-06 23:15:37 +04:00
|
|
|
compositor->focus = 1;
|
2012-01-30 17:04:04 +04:00
|
|
|
if (weston_launcher_drm_set_master(&ec->base, ec->drm.fd, 1)) {
|
2012-06-07 20:01:59 +04:00
|
|
|
weston_log("failed to set master: %m\n");
|
2012-01-16 19:52:52 +04:00
|
|
|
wl_display_terminate(compositor->wl_display);
|
|
|
|
}
|
2011-12-02 15:07:27 +04:00
|
|
|
compositor->state = ec->prev_state;
|
2012-01-18 20:48:46 +04:00
|
|
|
drm_compositor_set_modes(ec);
|
Rename wayland-compositor to weston
This rename addresses a few problems around the split between core
Wayland and the wayland-demos repository.
1) Initially, we had one big repository with protocol code, sample
compositor and sample clients. We split that repository to make it
possible to implement the protocol without pulling in the sample/demo
code. At this point, the compositor is more than just a "demo" and
wayland-demos doesn't send the right message. The sample compositor
is a useful, self-contained project in it's own right, and we want to
move away from the "demos" label.
2) Another problem is that the wayland-demos compositor is often
called "the wayland compsitor", but it's really just one possible
compositor. Existing X11 compositors are expected to add Wayland
support and then gradually phase out/modularize the X11 support, for
example. Conversely, it's hard to talk about the wayland-demos
compositor specifically as opposed to, eg, the wayland protocol or a
wayland compositor in general.
We are also renaming the repo to weston, and the compositor
subdirectory to src/, to emphasize that the main "output" is the
compositor.
2012-01-03 19:29:47 +04:00
|
|
|
weston_compositor_damage_all(compositor);
|
2012-05-16 21:45:18 +04:00
|
|
|
wl_list_for_each(seat, &compositor->seat_list, link) {
|
|
|
|
evdev_add_devices(ec->udev, seat);
|
|
|
|
evdev_enable_udev_monitor(ec->udev, seat);
|
2012-04-09 20:14:58 +04:00
|
|
|
}
|
2011-05-06 23:15:37 +04:00
|
|
|
break;
|
|
|
|
case TTY_LEAVE_VT:
|
2012-08-03 15:39:10 +04:00
|
|
|
weston_log("leaving VT\n");
|
2012-05-16 21:45:18 +04:00
|
|
|
wl_list_for_each(seat, &compositor->seat_list, link) {
|
|
|
|
evdev_disable_udev_monitor(seat);
|
|
|
|
evdev_remove_devices(seat);
|
2012-04-10 08:08:45 +04:00
|
|
|
}
|
|
|
|
|
2011-05-06 23:15:37 +04:00
|
|
|
compositor->focus = 0;
|
2011-12-02 15:07:27 +04:00
|
|
|
ec->prev_state = compositor->state;
|
Rename wayland-compositor to weston
This rename addresses a few problems around the split between core
Wayland and the wayland-demos repository.
1) Initially, we had one big repository with protocol code, sample
compositor and sample clients. We split that repository to make it
possible to implement the protocol without pulling in the sample/demo
code. At this point, the compositor is more than just a "demo" and
wayland-demos doesn't send the right message. The sample compositor
is a useful, self-contained project in it's own right, and we want to
move away from the "demos" label.
2) Another problem is that the wayland-demos compositor is often
called "the wayland compsitor", but it's really just one possible
compositor. Existing X11 compositors are expected to add Wayland
support and then gradually phase out/modularize the X11 support, for
example. Conversely, it's hard to talk about the wayland-demos
compositor specifically as opposed to, eg, the wayland protocol or a
wayland compositor in general.
We are also renaming the repo to weston, and the compositor
subdirectory to src/, to emphasize that the main "output" is the
compositor.
2012-01-03 19:29:47 +04:00
|
|
|
compositor->state = WESTON_COMPOSITOR_SLEEPING;
|
2011-05-06 23:38:28 +04:00
|
|
|
|
2012-01-18 20:50:31 +04:00
|
|
|
/* If we have a repaint scheduled (either from a
|
|
|
|
* pending pageflip or the idle handler), make sure we
|
|
|
|
* cancel that so we don't try to pageflip when we're
|
|
|
|
* vt switched away. The SLEEPING state will prevent
|
|
|
|
* further attemps at repainting. When we switch
|
|
|
|
* back, we schedule a repaint, which will process
|
|
|
|
* pending frame callbacks. */
|
|
|
|
|
2012-07-14 09:06:28 +04:00
|
|
|
wl_list_for_each(output, &ec->base.output_list, base.link) {
|
|
|
|
output->base.repaint_needed = 0;
|
|
|
|
drmModeSetCursor(ec->drm.fd, output->crtc_id, 0, 0, 0);
|
2012-01-18 20:50:31 +04:00
|
|
|
}
|
|
|
|
|
2012-07-14 09:06:28 +04:00
|
|
|
output = container_of(ec->base.output_list.next,
|
|
|
|
struct drm_output, base.link);
|
2012-02-24 06:45:32 +04:00
|
|
|
|
|
|
|
wl_list_for_each(sprite, &ec->sprite_list, link)
|
|
|
|
drmModeSetPlane(ec->drm.fd,
|
|
|
|
sprite->plane_id,
|
2012-07-14 09:06:28 +04:00
|
|
|
output->crtc_id, 0, 0,
|
2012-02-24 06:45:32 +04:00
|
|
|
0, 0, 0, 0, 0, 0, 0, 0);
|
|
|
|
|
2012-01-30 17:04:04 +04:00
|
|
|
if (weston_launcher_drm_set_master(&ec->base, ec->drm.fd, 0) < 0)
|
2012-06-07 20:01:59 +04:00
|
|
|
weston_log("failed to drop master: %m\n");
|
2012-01-16 19:52:52 +04:00
|
|
|
|
2011-05-06 23:15:37 +04:00
|
|
|
break;
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2012-04-10 08:11:50 +04:00
|
|
|
static void
|
2012-05-30 19:31:58 +04:00
|
|
|
switch_vt_binding(struct wl_seat *seat, uint32_t time, uint32_t key, void *data)
|
2012-04-10 08:11:50 +04:00
|
|
|
{
|
|
|
|
struct drm_compositor *ec = data;
|
|
|
|
|
2012-05-30 19:31:58 +04:00
|
|
|
tty_activate_vt(ec->tty, key - KEY_F1 + 1);
|
2012-04-10 08:11:50 +04:00
|
|
|
}
|
|
|
|
|
Rename wayland-compositor to weston
This rename addresses a few problems around the split between core
Wayland and the wayland-demos repository.
1) Initially, we had one big repository with protocol code, sample
compositor and sample clients. We split that repository to make it
possible to implement the protocol without pulling in the sample/demo
code. At this point, the compositor is more than just a "demo" and
wayland-demos doesn't send the right message. The sample compositor
is a useful, self-contained project in it's own right, and we want to
move away from the "demos" label.
2) Another problem is that the wayland-demos compositor is often
called "the wayland compsitor", but it's really just one possible
compositor. Existing X11 compositors are expected to add Wayland
support and then gradually phase out/modularize the X11 support, for
example. Conversely, it's hard to talk about the wayland-demos
compositor specifically as opposed to, eg, the wayland protocol or a
wayland compositor in general.
We are also renaming the repo to weston, and the compositor
subdirectory to src/, to emphasize that the main "output" is the
compositor.
2012-01-03 19:29:47 +04:00
|
|
|
static struct weston_compositor *
|
2011-07-16 05:28:38 +04:00
|
|
|
drm_compositor_create(struct wl_display *display,
|
2012-06-01 19:11:10 +04:00
|
|
|
int connector, const char *seat, int tty,
|
2012-06-01 19:14:02 +04:00
|
|
|
int argc, char *argv[], const char *config_file)
|
2010-06-11 20:56:24 +04:00
|
|
|
{
|
2010-06-14 19:54:00 +04:00
|
|
|
struct drm_compositor *ec;
|
2010-06-11 20:56:24 +04:00
|
|
|
struct udev_enumerate *e;
|
2011-08-30 13:38:26 +04:00
|
|
|
struct udev_list_entry *entry;
|
2011-07-16 05:28:38 +04:00
|
|
|
struct udev_device *device, *drm_device;
|
|
|
|
const char *path, *device_seat;
|
2010-06-11 20:56:24 +04:00
|
|
|
struct wl_event_loop *loop;
|
2012-06-22 17:04:37 +04:00
|
|
|
struct weston_seat *weston_seat, *next;
|
2012-04-10 08:11:50 +04:00
|
|
|
uint32_t key;
|
2010-06-11 20:56:24 +04:00
|
|
|
|
2012-06-09 00:45:33 +04:00
|
|
|
weston_log("initializing drm backend\n");
|
|
|
|
|
2010-06-14 19:54:00 +04:00
|
|
|
ec = malloc(sizeof *ec);
|
|
|
|
if (ec == NULL)
|
|
|
|
return NULL;
|
|
|
|
memset(ec, 0, sizeof *ec);
|
2012-06-22 17:04:36 +04:00
|
|
|
|
|
|
|
if (weston_compositor_init(&ec->base, display, argc, argv,
|
2012-06-22 17:04:37 +04:00
|
|
|
config_file) < 0) {
|
|
|
|
weston_log("weston_compositor_init failed\n");
|
|
|
|
goto err_base;
|
|
|
|
}
|
2012-06-22 17:04:36 +04:00
|
|
|
|
2010-06-11 20:56:24 +04:00
|
|
|
ec->udev = udev_new();
|
|
|
|
if (ec->udev == NULL) {
|
2012-06-07 20:01:59 +04:00
|
|
|
weston_log("failed to initialize udev context\n");
|
2012-06-22 17:04:37 +04:00
|
|
|
goto err_compositor;
|
2010-06-11 20:56:24 +04:00
|
|
|
}
|
|
|
|
|
2012-01-15 23:29:09 +04:00
|
|
|
ec->base.wl_display = display;
|
|
|
|
ec->tty = tty_create(&ec->base, vt_func, tty);
|
|
|
|
if (!ec->tty) {
|
2012-06-07 20:01:59 +04:00
|
|
|
weston_log("failed to initialize tty\n");
|
2012-06-22 17:04:37 +04:00
|
|
|
goto err_udev;
|
2012-01-15 23:29:09 +04:00
|
|
|
}
|
|
|
|
|
2010-06-11 20:56:24 +04:00
|
|
|
e = udev_enumerate_new(ec->udev);
|
2010-06-14 19:54:00 +04:00
|
|
|
udev_enumerate_add_match_subsystem(e, "drm");
|
2011-10-07 10:23:22 +04:00
|
|
|
udev_enumerate_add_match_sysname(e, "card[0-9]*");
|
2011-07-16 05:28:38 +04:00
|
|
|
|
2011-08-30 13:38:26 +04:00
|
|
|
udev_enumerate_scan_devices(e);
|
2011-07-16 05:28:38 +04:00
|
|
|
drm_device = NULL;
|
2011-08-30 13:38:26 +04:00
|
|
|
udev_list_entry_foreach(entry, udev_enumerate_get_list_entry(e)) {
|
2010-06-11 20:56:24 +04:00
|
|
|
path = udev_list_entry_get_name(entry);
|
|
|
|
device = udev_device_new_from_syspath(ec->udev, path);
|
2011-08-30 13:38:26 +04:00
|
|
|
device_seat =
|
2011-07-16 05:28:38 +04:00
|
|
|
udev_device_get_property_value(device, "ID_SEAT");
|
|
|
|
if (!device_seat)
|
|
|
|
device_seat = default_seat;
|
|
|
|
if (strcmp(device_seat, seat) == 0) {
|
|
|
|
drm_device = device;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
udev_device_unref(device);
|
2010-06-11 20:56:24 +04:00
|
|
|
}
|
2011-07-16 05:28:38 +04:00
|
|
|
|
|
|
|
if (drm_device == NULL) {
|
2012-06-07 20:01:59 +04:00
|
|
|
weston_log("no drm device found\n");
|
2012-06-22 17:04:37 +04:00
|
|
|
goto err_udev_enum;
|
2010-06-14 19:54:00 +04:00
|
|
|
}
|
2010-06-11 20:56:24 +04:00
|
|
|
|
2011-07-16 05:28:38 +04:00
|
|
|
if (init_egl(ec, drm_device) < 0) {
|
2012-06-07 20:01:59 +04:00
|
|
|
weston_log("failed to initialize egl\n");
|
2012-06-22 17:04:37 +04:00
|
|
|
goto err_udev_dev;
|
2010-06-11 20:56:24 +04:00
|
|
|
}
|
2011-01-15 00:20:21 +03:00
|
|
|
|
|
|
|
ec->base.destroy = drm_destroy;
|
2012-07-31 22:32:01 +04:00
|
|
|
ec->base.restore = drm_restore;
|
2011-04-20 13:02:58 +04:00
|
|
|
|
2011-01-15 00:20:21 +03:00
|
|
|
ec->base.focus = 1;
|
|
|
|
|
Rename wayland-compositor to weston
This rename addresses a few problems around the split between core
Wayland and the wayland-demos repository.
1) Initially, we had one big repository with protocol code, sample
compositor and sample clients. We split that repository to make it
possible to implement the protocol without pulling in the sample/demo
code. At this point, the compositor is more than just a "demo" and
wayland-demos doesn't send the right message. The sample compositor
is a useful, self-contained project in it's own right, and we want to
move away from the "demos" label.
2) Another problem is that the wayland-demos compositor is often
called "the wayland compsitor", but it's really just one possible
compositor. Existing X11 compositors are expected to add Wayland
support and then gradually phase out/modularize the X11 support, for
example. Conversely, it's hard to talk about the wayland-demos
compositor specifically as opposed to, eg, the wayland protocol or a
wayland compositor in general.
We are also renaming the repo to weston, and the compositor
subdirectory to src/, to emphasize that the main "output" is the
compositor.
2012-01-03 19:29:47 +04:00
|
|
|
ec->prev_state = WESTON_COMPOSITOR_ACTIVE;
|
2011-12-02 15:07:27 +04:00
|
|
|
|
2012-06-22 17:04:36 +04:00
|
|
|
if (weston_compositor_init_gl(&ec->base) < 0)
|
2012-06-22 17:04:37 +04:00
|
|
|
goto err_egl;
|
2011-04-30 00:14:54 +04:00
|
|
|
|
2012-04-10 08:11:50 +04:00
|
|
|
for (key = KEY_F1; key < KEY_F9; key++)
|
2012-05-30 19:31:58 +04:00
|
|
|
weston_compositor_add_key_binding(&ec->base, key,
|
|
|
|
MODIFIER_CTRL | MODIFIER_ALT,
|
|
|
|
switch_vt_binding, ec);
|
2012-04-10 08:11:50 +04:00
|
|
|
|
2012-02-23 18:45:49 +04:00
|
|
|
wl_list_init(&ec->sprite_list);
|
|
|
|
create_sprites(ec);
|
|
|
|
|
2012-02-29 21:53:50 +04:00
|
|
|
if (create_outputs(ec, connector, drm_device) < 0) {
|
2012-06-07 20:01:59 +04:00
|
|
|
weston_log("failed to create output for %s\n", path);
|
2012-06-22 17:04:37 +04:00
|
|
|
goto err_sprite;
|
2010-06-14 19:54:00 +04:00
|
|
|
}
|
|
|
|
|
2011-10-07 10:27:26 +04:00
|
|
|
path = NULL;
|
|
|
|
|
2011-12-19 03:14:03 +04:00
|
|
|
evdev_input_create(&ec->base, ec->udev, seat);
|
2010-06-11 20:56:24 +04:00
|
|
|
|
2010-06-14 19:54:00 +04:00
|
|
|
loop = wl_display_get_event_loop(ec->base.wl_display);
|
|
|
|
ec->drm_source =
|
2011-03-02 13:14:59 +03:00
|
|
|
wl_event_loop_add_fd(loop, ec->drm.fd,
|
2010-06-14 19:54:00 +04:00
|
|
|
WL_EVENT_READABLE, on_drm_input, ec);
|
2010-06-11 20:56:24 +04:00
|
|
|
|
2011-03-15 17:08:41 +03:00
|
|
|
ec->udev_monitor = udev_monitor_new_from_netlink(ec->udev, "udev");
|
|
|
|
if (ec->udev_monitor == NULL) {
|
2012-06-07 20:01:59 +04:00
|
|
|
weston_log("failed to intialize udev monitor\n");
|
2012-06-22 17:04:37 +04:00
|
|
|
goto err_drm_source;
|
2011-03-15 17:08:41 +03:00
|
|
|
}
|
|
|
|
udev_monitor_filter_add_match_subsystem_devtype(ec->udev_monitor,
|
|
|
|
"drm", NULL);
|
|
|
|
ec->udev_drm_source =
|
2011-08-30 13:38:26 +04:00
|
|
|
wl_event_loop_add_fd(loop,
|
|
|
|
udev_monitor_get_fd(ec->udev_monitor),
|
2011-03-15 17:08:41 +03:00
|
|
|
WL_EVENT_READABLE, udev_drm_event, ec);
|
|
|
|
|
|
|
|
if (udev_monitor_enable_receiving(ec->udev_monitor) < 0) {
|
2012-06-07 20:01:59 +04:00
|
|
|
weston_log("failed to enable udev-monitor receiving\n");
|
2012-06-22 17:04:37 +04:00
|
|
|
goto err_udev_monitor;
|
2011-03-15 17:08:41 +03:00
|
|
|
}
|
|
|
|
|
2012-06-22 17:04:37 +04:00
|
|
|
udev_device_unref(drm_device);
|
|
|
|
udev_enumerate_unref(e);
|
|
|
|
|
2010-06-14 19:54:00 +04:00
|
|
|
return &ec->base;
|
2012-06-22 17:04:37 +04:00
|
|
|
|
|
|
|
err_udev_monitor:
|
|
|
|
wl_event_source_remove(ec->udev_drm_source);
|
|
|
|
udev_monitor_unref(ec->udev_monitor);
|
|
|
|
err_drm_source:
|
|
|
|
wl_event_source_remove(ec->drm_source);
|
|
|
|
wl_list_for_each_safe(weston_seat, next, &ec->base.seat_list, link)
|
|
|
|
evdev_input_destroy(weston_seat);
|
|
|
|
err_sprite:
|
|
|
|
destroy_sprites(ec);
|
|
|
|
err_egl:
|
|
|
|
eglMakeCurrent(ec->base.egl_display, EGL_NO_SURFACE, EGL_NO_SURFACE,
|
|
|
|
EGL_NO_CONTEXT);
|
|
|
|
eglTerminate(ec->base.egl_display);
|
|
|
|
eglReleaseThread();
|
|
|
|
gbm_device_destroy(ec->gbm);
|
|
|
|
err_udev_dev:
|
|
|
|
udev_device_unref(drm_device);
|
|
|
|
err_udev_enum:
|
|
|
|
udev_enumerate_unref(e);
|
|
|
|
tty_destroy(ec->tty);
|
|
|
|
err_udev:
|
|
|
|
udev_unref(ec->udev);
|
|
|
|
err_compositor:
|
|
|
|
weston_compositor_shutdown(&ec->base);
|
|
|
|
err_base:
|
|
|
|
free(ec);
|
|
|
|
return NULL;
|
2010-06-11 20:56:24 +04:00
|
|
|
}
|
2011-05-03 06:09:20 +04:00
|
|
|
|
2012-08-01 01:30:41 +04:00
|
|
|
static int
|
|
|
|
set_sync_flags(drmModeModeInfo *mode, char *hsync, char *vsync)
|
|
|
|
{
|
|
|
|
mode->flags = 0;
|
|
|
|
|
|
|
|
if (strcmp(hsync, "+hsync") == 0)
|
|
|
|
mode->flags |= DRM_MODE_FLAG_PHSYNC;
|
|
|
|
else if (strcmp(hsync, "-hsync") == 0)
|
|
|
|
mode->flags |= DRM_MODE_FLAG_NHSYNC;
|
|
|
|
else
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
if (strcmp(vsync, "+vsync") == 0)
|
|
|
|
mode->flags |= DRM_MODE_FLAG_PVSYNC;
|
|
|
|
else if (strcmp(vsync, "-vsync") == 0)
|
|
|
|
mode->flags |= DRM_MODE_FLAG_NVSYNC;
|
|
|
|
else
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
check_for_modeline(struct drm_configured_output *output)
|
|
|
|
{
|
|
|
|
drmModeModeInfo mode;
|
|
|
|
char hsync[16];
|
|
|
|
char vsync[16];
|
|
|
|
char mode_name[16];
|
|
|
|
float fclock;
|
|
|
|
|
|
|
|
mode.type = DRM_MODE_TYPE_USERDEF;
|
|
|
|
mode.hskew = 0;
|
|
|
|
mode.vscan = 0;
|
|
|
|
mode.vrefresh = 0;
|
|
|
|
|
|
|
|
if (sscanf(output_mode, "%f %hd %hd %hd %hd %hd %hd %hd %hd %s %s",
|
|
|
|
&fclock, &mode.hdisplay,
|
|
|
|
&mode.hsync_start,
|
|
|
|
&mode.hsync_end, &mode.htotal,
|
|
|
|
&mode.vdisplay,
|
|
|
|
&mode.vsync_start,
|
|
|
|
&mode.vsync_end, &mode.vtotal,
|
|
|
|
hsync, vsync) == 11) {
|
|
|
|
if (set_sync_flags(&mode, hsync, vsync))
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
sprintf(mode_name, "%dx%d", mode.hdisplay, mode.vdisplay);
|
|
|
|
strcpy(mode.name, mode_name);
|
|
|
|
|
|
|
|
mode.clock = fclock * 1000;
|
|
|
|
} else
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
output->crtc_mode = mode;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2012-07-31 05:51:08 +04:00
|
|
|
static void
|
|
|
|
output_section_done(void *data)
|
|
|
|
{
|
|
|
|
struct drm_configured_output *output;
|
|
|
|
|
|
|
|
output = malloc(sizeof *output);
|
|
|
|
|
2012-08-01 06:18:28 +04:00
|
|
|
if (!output || !output_name || !output_mode) {
|
|
|
|
free(output_name);
|
|
|
|
output_name = NULL;
|
|
|
|
free(output_mode);
|
|
|
|
output_mode = NULL;
|
2012-07-31 05:51:08 +04:00
|
|
|
return;
|
2012-08-01 06:18:28 +04:00
|
|
|
}
|
2012-07-31 05:51:08 +04:00
|
|
|
|
|
|
|
output->config = OUTPUT_CONFIG_INVALID;
|
|
|
|
output->name = output_name;
|
|
|
|
output->mode = output_mode;
|
|
|
|
|
|
|
|
if (strcmp(output_mode, "off") == 0)
|
|
|
|
output->config = OUTPUT_CONFIG_OFF;
|
|
|
|
else if (strcmp(output_mode, "preferred") == 0)
|
|
|
|
output->config = OUTPUT_CONFIG_PREFERRED;
|
|
|
|
else if (strcmp(output_mode, "current") == 0)
|
|
|
|
output->config = OUTPUT_CONFIG_CURRENT;
|
|
|
|
else if (sscanf(output_mode, "%dx%d", &output->width, &output->height) == 2)
|
|
|
|
output->config = OUTPUT_CONFIG_MODE;
|
2012-08-01 01:30:41 +04:00
|
|
|
else if (check_for_modeline(output) == 0)
|
|
|
|
output->config = OUTPUT_CONFIG_MODELINE;
|
2012-07-31 05:51:08 +04:00
|
|
|
|
|
|
|
if (output->config != OUTPUT_CONFIG_INVALID)
|
|
|
|
wl_list_insert(&configured_output_list, &output->link);
|
|
|
|
else {
|
|
|
|
weston_log("Invalid mode \"%s\" for output %s\n",
|
|
|
|
output_mode, output_name);
|
2012-08-01 08:29:56 +04:00
|
|
|
drm_free_configured_output(output);
|
2012-07-31 05:51:08 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
Rename wayland-compositor to weston
This rename addresses a few problems around the split between core
Wayland and the wayland-demos repository.
1) Initially, we had one big repository with protocol code, sample
compositor and sample clients. We split that repository to make it
possible to implement the protocol without pulling in the sample/demo
code. At this point, the compositor is more than just a "demo" and
wayland-demos doesn't send the right message. The sample compositor
is a useful, self-contained project in it's own right, and we want to
move away from the "demos" label.
2) Another problem is that the wayland-demos compositor is often
called "the wayland compsitor", but it's really just one possible
compositor. Existing X11 compositors are expected to add Wayland
support and then gradually phase out/modularize the X11 support, for
example. Conversely, it's hard to talk about the wayland-demos
compositor specifically as opposed to, eg, the wayland protocol or a
wayland compositor in general.
We are also renaming the repo to weston, and the compositor
subdirectory to src/, to emphasize that the main "output" is the
compositor.
2012-01-03 19:29:47 +04:00
|
|
|
WL_EXPORT struct weston_compositor *
|
2012-06-01 19:14:02 +04:00
|
|
|
backend_init(struct wl_display *display, int argc, char *argv[],
|
|
|
|
const char *config_file)
|
2011-05-03 06:09:20 +04:00
|
|
|
{
|
2012-03-12 05:05:57 +04:00
|
|
|
int connector = 0, tty = 0;
|
|
|
|
const char *seat = default_seat;
|
|
|
|
|
|
|
|
const struct weston_option drm_options[] = {
|
|
|
|
{ WESTON_OPTION_INTEGER, "connector", 0, &connector },
|
|
|
|
{ WESTON_OPTION_STRING, "seat", 0, &seat },
|
|
|
|
{ WESTON_OPTION_INTEGER, "tty", 0, &tty },
|
2012-06-28 19:28:15 +04:00
|
|
|
{ WESTON_OPTION_BOOLEAN, "current-mode", 0, &option_current_mode },
|
2012-03-12 05:05:57 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
parse_options(drm_options, ARRAY_LENGTH(drm_options), argc, argv);
|
2011-05-03 06:09:20 +04:00
|
|
|
|
2012-07-31 05:51:08 +04:00
|
|
|
wl_list_init(&configured_output_list);
|
|
|
|
|
|
|
|
const struct config_key drm_config_keys[] = {
|
|
|
|
{ "name", CONFIG_KEY_STRING, &output_name },
|
|
|
|
{ "mode", CONFIG_KEY_STRING, &output_mode },
|
|
|
|
};
|
|
|
|
|
|
|
|
const struct config_section config_section[] = {
|
|
|
|
{ "output", drm_config_keys,
|
|
|
|
ARRAY_LENGTH(drm_config_keys), output_section_done },
|
|
|
|
};
|
|
|
|
|
|
|
|
parse_config_file(config_file, config_section,
|
|
|
|
ARRAY_LENGTH(config_section), NULL);
|
|
|
|
|
2012-06-01 19:14:02 +04:00
|
|
|
return drm_compositor_create(display, connector, seat, tty, argc, argv,
|
|
|
|
config_file);
|
2011-05-03 06:09:20 +04:00
|
|
|
}
|