2013-02-02 16:02:32 +04:00
|
|
|
|
/*
|
|
|
|
|
* Copyright © 2008-2011 Kristian Høgsberg
|
|
|
|
|
* Copyright © 2011 Intel Corporation
|
|
|
|
|
* Copyright © 2012 Raspberry Pi Foundation
|
|
|
|
|
* Copyright © 2013 Philip Withnall
|
|
|
|
|
*
|
2015-06-12 01:35:43 +03:00
|
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining
|
|
|
|
|
* a copy of this software and associated documentation files (the
|
|
|
|
|
* "Software"), to deal in the Software without restriction, including
|
|
|
|
|
* without limitation the rights to use, copy, modify, merge, publish,
|
|
|
|
|
* distribute, sublicense, and/or sell copies of the Software, and to
|
|
|
|
|
* permit persons to whom the Software is furnished to do so, subject to
|
|
|
|
|
* the following conditions:
|
2013-02-02 16:02:32 +04:00
|
|
|
|
*
|
2015-06-12 01:35:43 +03:00
|
|
|
|
* The above copyright notice and this permission notice (including the
|
|
|
|
|
* next paragraph) shall be included in all copies or substantial
|
|
|
|
|
* portions of the Software.
|
|
|
|
|
*
|
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
|
|
|
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
|
|
|
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
|
|
|
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
|
|
|
|
|
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
|
|
|
|
|
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
|
|
|
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
|
|
|
* SOFTWARE.
|
2013-02-02 16:02:32 +04:00
|
|
|
|
*/
|
|
|
|
|
|
2013-05-22 19:03:19 +04:00
|
|
|
|
#include "config.h"
|
2013-02-02 16:02:32 +04:00
|
|
|
|
|
|
|
|
|
#include <errno.h>
|
|
|
|
|
#include <stdlib.h>
|
2016-07-19 14:16:27 +03:00
|
|
|
|
#include <stdint.h>
|
2013-02-02 16:02:32 +04:00
|
|
|
|
#include <stdio.h>
|
|
|
|
|
#include <string.h>
|
|
|
|
|
#include <math.h>
|
|
|
|
|
#include <sys/mman.h>
|
|
|
|
|
#include <sys/types.h>
|
|
|
|
|
#include <fcntl.h>
|
|
|
|
|
#include <unistd.h>
|
|
|
|
|
#include <linux/fb.h>
|
2013-02-19 01:35:26 +04:00
|
|
|
|
#include <linux/input.h>
|
2017-09-13 17:14:19 +03:00
|
|
|
|
#include <assert.h>
|
2013-02-02 16:02:32 +04:00
|
|
|
|
|
|
|
|
|
#include <libudev.h>
|
|
|
|
|
|
2015-06-16 01:37:08 +03:00
|
|
|
|
#include "shared/helpers.h"
|
2019-03-28 17:28:47 +03:00
|
|
|
|
#include <libweston/libweston.h>
|
2019-03-29 17:39:12 +03:00
|
|
|
|
#include <libweston/backend-fbdev.h>
|
2013-02-02 16:02:32 +04:00
|
|
|
|
#include "launcher-util.h"
|
|
|
|
|
#include "pixman-renderer.h"
|
2014-11-26 00:06:31 +03:00
|
|
|
|
#include "libinput-seat.h"
|
2016-02-18 17:53:27 +03:00
|
|
|
|
#include "presentation-time-server-protocol.h"
|
2013-02-02 16:02:32 +04:00
|
|
|
|
|
2014-10-11 19:27:30 +04:00
|
|
|
|
struct fbdev_backend {
|
|
|
|
|
struct weston_backend base;
|
|
|
|
|
struct weston_compositor *compositor;
|
2013-02-02 16:02:32 +04:00
|
|
|
|
uint32_t prev_state;
|
|
|
|
|
|
|
|
|
|
struct udev *udev;
|
2013-05-31 21:09:55 +04:00
|
|
|
|
struct udev_input input;
|
2016-04-28 00:56:42 +03:00
|
|
|
|
uint32_t output_transform;
|
2013-09-18 03:02:57 +04:00
|
|
|
|
struct wl_listener session_listener;
|
2013-02-02 16:02:32 +04:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct fbdev_screeninfo {
|
|
|
|
|
unsigned int x_resolution; /* pixels, visible area */
|
|
|
|
|
unsigned int y_resolution; /* pixels, visible area */
|
|
|
|
|
unsigned int width_mm; /* visible screen width in mm */
|
|
|
|
|
unsigned int height_mm; /* visible screen height in mm */
|
|
|
|
|
unsigned int bits_per_pixel;
|
|
|
|
|
|
|
|
|
|
size_t buffer_length; /* length of frame buffer memory in bytes */
|
|
|
|
|
size_t line_length; /* length of a line in bytes */
|
|
|
|
|
char id[16]; /* screen identifier */
|
|
|
|
|
|
|
|
|
|
pixman_format_code_t pixel_format; /* frame buffer pixel format */
|
|
|
|
|
unsigned int refresh_rate; /* Hertz */
|
|
|
|
|
};
|
|
|
|
|
|
2017-09-14 16:50:44 +03:00
|
|
|
|
struct fbdev_head {
|
|
|
|
|
struct weston_head base;
|
|
|
|
|
|
|
|
|
|
/* Frame buffer details. */
|
|
|
|
|
char *device;
|
|
|
|
|
struct fbdev_screeninfo fb_info;
|
|
|
|
|
};
|
|
|
|
|
|
2013-02-02 16:02:32 +04:00
|
|
|
|
struct fbdev_output {
|
2014-10-11 19:27:30 +04:00
|
|
|
|
struct fbdev_backend *backend;
|
2013-02-02 16:02:32 +04:00
|
|
|
|
struct weston_output base;
|
|
|
|
|
|
|
|
|
|
struct weston_mode mode;
|
|
|
|
|
struct wl_event_source *finish_frame_timer;
|
|
|
|
|
|
2017-09-14 16:50:44 +03:00
|
|
|
|
/* framebuffer mmap details */
|
|
|
|
|
size_t buffer_length;
|
|
|
|
|
void *fb;
|
2013-02-02 16:02:32 +04:00
|
|
|
|
|
|
|
|
|
/* pixman details. */
|
|
|
|
|
pixman_image_t *hw_surface;
|
|
|
|
|
};
|
|
|
|
|
|
2013-02-19 01:35:26 +04:00
|
|
|
|
static const char default_seat[] = "seat0";
|
|
|
|
|
|
2017-09-14 16:50:44 +03:00
|
|
|
|
static inline struct fbdev_head *
|
|
|
|
|
to_fbdev_head(struct weston_head *base)
|
|
|
|
|
{
|
|
|
|
|
return container_of(base, struct fbdev_head, base);
|
|
|
|
|
}
|
|
|
|
|
|
2013-02-02 16:02:32 +04:00
|
|
|
|
static inline struct fbdev_output *
|
|
|
|
|
to_fbdev_output(struct weston_output *base)
|
|
|
|
|
{
|
|
|
|
|
return container_of(base, struct fbdev_output, base);
|
|
|
|
|
}
|
|
|
|
|
|
2014-10-11 19:27:30 +04:00
|
|
|
|
static inline struct fbdev_backend *
|
|
|
|
|
to_fbdev_backend(struct weston_compositor *base)
|
2013-02-02 16:02:32 +04:00
|
|
|
|
{
|
2014-10-11 19:27:30 +04:00
|
|
|
|
return container_of(base->backend, struct fbdev_backend, base);
|
2013-02-02 16:02:32 +04:00
|
|
|
|
}
|
|
|
|
|
|
2017-09-14 16:50:44 +03:00
|
|
|
|
static struct fbdev_head *
|
|
|
|
|
fbdev_output_get_head(struct fbdev_output *output)
|
|
|
|
|
{
|
|
|
|
|
if (wl_list_length(&output->base.head_list) != 1)
|
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
|
|
return container_of(output->base.head_list.next,
|
|
|
|
|
struct fbdev_head, base.output_link);
|
|
|
|
|
}
|
|
|
|
|
|
2019-06-30 16:51:10 +03:00
|
|
|
|
static int
|
2013-04-06 01:07:11 +04:00
|
|
|
|
fbdev_output_start_repaint_loop(struct weston_output *output)
|
|
|
|
|
{
|
2014-09-24 06:08:45 +04:00
|
|
|
|
struct timespec ts;
|
2013-04-06 01:07:11 +04:00
|
|
|
|
|
2015-03-18 13:17:26 +03:00
|
|
|
|
weston_compositor_read_presentation_clock(output->compositor, &ts);
|
2016-02-18 17:53:27 +03:00
|
|
|
|
weston_output_finish_frame(output, &ts, WP_PRESENTATION_FEEDBACK_INVALID);
|
2019-06-30 16:51:10 +03:00
|
|
|
|
|
|
|
|
|
return 0;
|
2013-04-06 01:07:11 +04:00
|
|
|
|
}
|
|
|
|
|
|
2016-06-08 17:39:37 +03:00
|
|
|
|
static int
|
2017-03-01 14:34:10 +03:00
|
|
|
|
fbdev_output_repaint(struct weston_output *base, pixman_region32_t *damage,
|
|
|
|
|
void *repaint_data)
|
2013-02-02 16:02:32 +04:00
|
|
|
|
{
|
|
|
|
|
struct fbdev_output *output = to_fbdev_output(base);
|
|
|
|
|
struct weston_compositor *ec = output->base.compositor;
|
|
|
|
|
|
|
|
|
|
/* Repaint the damaged region onto the back buffer. */
|
2015-12-05 04:20:12 +03:00
|
|
|
|
pixman_renderer_output_set_buffer(base, output->hw_surface);
|
2013-02-02 16:02:32 +04:00
|
|
|
|
ec->renderer->repaint_output(base, damage);
|
|
|
|
|
|
|
|
|
|
/* Update the damage region. */
|
|
|
|
|
pixman_region32_subtract(&ec->primary_plane.damage,
|
|
|
|
|
&ec->primary_plane.damage, damage);
|
|
|
|
|
|
|
|
|
|
/* Schedule the end of the frame. We do not sync this to the frame
|
|
|
|
|
* buffer clock because users who want that should be using the DRM
|
|
|
|
|
* compositor. FBIO_WAITFORVSYNC blocks and FB_ACTIVATE_VBL requires
|
|
|
|
|
* panning, which is broken in most kernel drivers.
|
|
|
|
|
*
|
|
|
|
|
* Finish the frame synchronised to the specified refresh rate. The
|
|
|
|
|
* refresh rate is given in mHz and the interval in ms. */
|
|
|
|
|
wl_event_source_timer_update(output->finish_frame_timer,
|
|
|
|
|
1000000 / output->mode.refresh);
|
2013-10-22 19:11:26 +04:00
|
|
|
|
|
|
|
|
|
return 0;
|
2013-09-06 16:16:09 +04:00
|
|
|
|
}
|
|
|
|
|
|
2013-02-02 16:02:32 +04:00
|
|
|
|
static int
|
|
|
|
|
finish_frame_handler(void *data)
|
|
|
|
|
{
|
|
|
|
|
struct fbdev_output *output = data;
|
compositor: set presentation.presented flags
Change weston_output_finish_frame() signature so that backends are
required to set the flags, that will be reported on the Presentation
'presented' event. This is meant for output-wide feedback flags. Flags
that vary per wl_surface are subject for the following patch.
All start_repaint_loop functions use the special private flag
PRESENTATION_FEEDBACK_INVALID to mark, that this call of
weston_output_finish_frame() cannot trigger the 'presented' event. If it
does, we now hit an assert, and should then investigate why a fake update
triggered Presentation feedback.
DRM:
Page flip is always vsync'd, and always gets the completion timestamp
from the kernel which should correspond well to hardware. Completion is
triggered by the kernel/hardware.
Vblank handler is only used with the broken planes path, therefore do
not report VSYNC, because we cannot guarantee all the planes updated at
the same time. We cannot set the INVALID, because it would abort the
compositor if the broken planes path was ever used. This is a hack that
will get fixed with nuclear pageflip support in the future.
fbdev:
No vsync, update done by copy, no completion event from hardware, and
completion time is totally fake.
headless:
No real output to update.
RDP:
Guessing that maybe no vsync, fake time, and copy make sense (pixels
sent over network). Also no event that the pixels have been shown?
RPI:
Presumably Dispmanx updates are vsync'd. We get a completion event from
the driver, but need to read the clock ourselves, so the completion time
is somewhat unreliable. Zero-copy flag not implemented though it would
be theoretically possible with EGL clients (zero-copy is a per-surface
flag anyway, so in this patch).
Wayland:
No information how the host compositor is doing updates, so make a safe
guess without assuming vsync or hardware completion event. While we do
get some timestamp from the host compositor, it is not the completion
time. Would need to hook to the Presentation extension of the host
compositor to get more accurate flags.
X11:
No idea about vsync, completion event, or copying. Also the timestamp is
a fake.
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Mario Kleiner <mario.kleiner.de@gmail.com>
Tested-by: Mario Kleiner <mario.kleiner.de@gmail.com>
Acked-by: Mario Kleiner <mario.kleiner.de@gmail.com>
2014-12-17 17:20:40 +03:00
|
|
|
|
struct timespec ts;
|
2013-02-02 16:02:32 +04:00
|
|
|
|
|
2015-03-18 13:17:26 +03:00
|
|
|
|
weston_compositor_read_presentation_clock(output->base.compositor, &ts);
|
compositor: set presentation.presented flags
Change weston_output_finish_frame() signature so that backends are
required to set the flags, that will be reported on the Presentation
'presented' event. This is meant for output-wide feedback flags. Flags
that vary per wl_surface are subject for the following patch.
All start_repaint_loop functions use the special private flag
PRESENTATION_FEEDBACK_INVALID to mark, that this call of
weston_output_finish_frame() cannot trigger the 'presented' event. If it
does, we now hit an assert, and should then investigate why a fake update
triggered Presentation feedback.
DRM:
Page flip is always vsync'd, and always gets the completion timestamp
from the kernel which should correspond well to hardware. Completion is
triggered by the kernel/hardware.
Vblank handler is only used with the broken planes path, therefore do
not report VSYNC, because we cannot guarantee all the planes updated at
the same time. We cannot set the INVALID, because it would abort the
compositor if the broken planes path was ever used. This is a hack that
will get fixed with nuclear pageflip support in the future.
fbdev:
No vsync, update done by copy, no completion event from hardware, and
completion time is totally fake.
headless:
No real output to update.
RDP:
Guessing that maybe no vsync, fake time, and copy make sense (pixels
sent over network). Also no event that the pixels have been shown?
RPI:
Presumably Dispmanx updates are vsync'd. We get a completion event from
the driver, but need to read the clock ourselves, so the completion time
is somewhat unreliable. Zero-copy flag not implemented though it would
be theoretically possible with EGL clients (zero-copy is a per-surface
flag anyway, so in this patch).
Wayland:
No information how the host compositor is doing updates, so make a safe
guess without assuming vsync or hardware completion event. While we do
get some timestamp from the host compositor, it is not the completion
time. Would need to hook to the Presentation extension of the host
compositor to get more accurate flags.
X11:
No idea about vsync, completion event, or copying. Also the timestamp is
a fake.
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Mario Kleiner <mario.kleiner.de@gmail.com>
Tested-by: Mario Kleiner <mario.kleiner.de@gmail.com>
Acked-by: Mario Kleiner <mario.kleiner.de@gmail.com>
2014-12-17 17:20:40 +03:00
|
|
|
|
weston_output_finish_frame(&output->base, &ts, 0);
|
2013-02-02 16:02:32 +04:00
|
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static pixman_format_code_t
|
|
|
|
|
calculate_pixman_format(struct fb_var_screeninfo *vinfo,
|
|
|
|
|
struct fb_fix_screeninfo *finfo)
|
|
|
|
|
{
|
|
|
|
|
/* Calculate the pixman format supported by the frame buffer from the
|
|
|
|
|
* buffer's metadata. Return 0 if no known pixman format is supported
|
|
|
|
|
* (since this has depth 0 it's guaranteed to not conflict with any
|
|
|
|
|
* actual pixman format).
|
|
|
|
|
*
|
|
|
|
|
* Documentation on the vinfo and finfo structures:
|
|
|
|
|
* http://www.mjmwired.net/kernel/Documentation/fb/api.txt
|
|
|
|
|
*
|
|
|
|
|
* TODO: Try a bit harder to support other formats, including setting
|
|
|
|
|
* the preferred format in the hardware. */
|
|
|
|
|
int type;
|
|
|
|
|
|
|
|
|
|
weston_log("Calculating pixman format from:\n"
|
|
|
|
|
STAMP_SPACE " - type: %i (aux: %i)\n"
|
|
|
|
|
STAMP_SPACE " - visual: %i\n"
|
|
|
|
|
STAMP_SPACE " - bpp: %i (grayscale: %i)\n"
|
|
|
|
|
STAMP_SPACE " - red: offset: %i, length: %i, MSB: %i\n"
|
|
|
|
|
STAMP_SPACE " - green: offset: %i, length: %i, MSB: %i\n"
|
|
|
|
|
STAMP_SPACE " - blue: offset: %i, length: %i, MSB: %i\n"
|
|
|
|
|
STAMP_SPACE " - transp: offset: %i, length: %i, MSB: %i\n",
|
|
|
|
|
finfo->type, finfo->type_aux, finfo->visual,
|
|
|
|
|
vinfo->bits_per_pixel, vinfo->grayscale,
|
|
|
|
|
vinfo->red.offset, vinfo->red.length, vinfo->red.msb_right,
|
|
|
|
|
vinfo->green.offset, vinfo->green.length,
|
|
|
|
|
vinfo->green.msb_right,
|
|
|
|
|
vinfo->blue.offset, vinfo->blue.length,
|
|
|
|
|
vinfo->blue.msb_right,
|
|
|
|
|
vinfo->transp.offset, vinfo->transp.length,
|
|
|
|
|
vinfo->transp.msb_right);
|
|
|
|
|
|
|
|
|
|
/* We only handle packed formats at the moment. */
|
|
|
|
|
if (finfo->type != FB_TYPE_PACKED_PIXELS)
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
|
|
/* We only handle true-colour frame buffers at the moment. */
|
2013-09-03 18:47:43 +04:00
|
|
|
|
switch(finfo->visual) {
|
|
|
|
|
case FB_VISUAL_TRUECOLOR:
|
|
|
|
|
case FB_VISUAL_DIRECTCOLOR:
|
|
|
|
|
if (vinfo->grayscale != 0)
|
|
|
|
|
return 0;
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
2013-02-02 16:02:32 +04:00
|
|
|
|
|
|
|
|
|
/* We only support formats with MSBs on the left. */
|
|
|
|
|
if (vinfo->red.msb_right != 0 || vinfo->green.msb_right != 0 ||
|
|
|
|
|
vinfo->blue.msb_right != 0)
|
|
|
|
|
return 0;
|
|
|
|
|
|
2018-11-28 10:45:46 +03:00
|
|
|
|
/* Work out the format type from the offsets. We only support RGBA, ARGB
|
|
|
|
|
* and ABGR at the moment. */
|
2013-02-02 16:02:32 +04:00
|
|
|
|
type = PIXMAN_TYPE_OTHER;
|
|
|
|
|
|
|
|
|
|
if ((vinfo->transp.offset >= vinfo->red.offset ||
|
|
|
|
|
vinfo->transp.length == 0) &&
|
|
|
|
|
vinfo->red.offset >= vinfo->green.offset &&
|
|
|
|
|
vinfo->green.offset >= vinfo->blue.offset)
|
|
|
|
|
type = PIXMAN_TYPE_ARGB;
|
|
|
|
|
else if (vinfo->red.offset >= vinfo->green.offset &&
|
|
|
|
|
vinfo->green.offset >= vinfo->blue.offset &&
|
|
|
|
|
vinfo->blue.offset >= vinfo->transp.offset)
|
|
|
|
|
type = PIXMAN_TYPE_RGBA;
|
2018-11-28 10:45:46 +03:00
|
|
|
|
else if (vinfo->transp.offset >= vinfo->blue.offset &&
|
|
|
|
|
vinfo->blue.offset >= vinfo->green.offset &&
|
|
|
|
|
vinfo->green.offset >= vinfo->red.offset)
|
|
|
|
|
type = PIXMAN_TYPE_ABGR;
|
2013-02-02 16:02:32 +04:00
|
|
|
|
|
|
|
|
|
if (type == PIXMAN_TYPE_OTHER)
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
|
|
/* Build the format. */
|
|
|
|
|
return PIXMAN_FORMAT(vinfo->bits_per_pixel, type,
|
|
|
|
|
vinfo->transp.length,
|
|
|
|
|
vinfo->red.length,
|
|
|
|
|
vinfo->green.length,
|
|
|
|
|
vinfo->blue.length);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static int
|
|
|
|
|
calculate_refresh_rate(struct fb_var_screeninfo *vinfo)
|
|
|
|
|
{
|
|
|
|
|
uint64_t quot;
|
|
|
|
|
|
|
|
|
|
/* Calculate monitor refresh rate. Default is 60 Hz. Units are mHz. */
|
|
|
|
|
quot = (vinfo->upper_margin + vinfo->lower_margin + vinfo->yres);
|
|
|
|
|
quot *= (vinfo->left_margin + vinfo->right_margin + vinfo->xres);
|
|
|
|
|
quot *= vinfo->pixclock;
|
|
|
|
|
|
|
|
|
|
if (quot > 0) {
|
|
|
|
|
uint64_t refresh_rate;
|
|
|
|
|
|
|
|
|
|
refresh_rate = 1000000000000000LLU / quot;
|
|
|
|
|
if (refresh_rate > 200000)
|
|
|
|
|
refresh_rate = 200000; /* cap at 200 Hz */
|
|
|
|
|
|
2017-04-17 14:11:00 +03:00
|
|
|
|
if (refresh_rate >= 1000) /* at least 1 Hz */
|
|
|
|
|
return refresh_rate;
|
2013-02-02 16:02:32 +04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return 60 * 1000; /* default to 60 Hz */
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static int
|
2017-09-12 17:15:42 +03:00
|
|
|
|
fbdev_query_screen_info(int fd, struct fbdev_screeninfo *info)
|
2013-02-02 16:02:32 +04:00
|
|
|
|
{
|
|
|
|
|
struct fb_var_screeninfo varinfo;
|
|
|
|
|
struct fb_fix_screeninfo fixinfo;
|
|
|
|
|
|
|
|
|
|
/* Probe the device for screen information. */
|
|
|
|
|
if (ioctl(fd, FBIOGET_FSCREENINFO, &fixinfo) < 0 ||
|
|
|
|
|
ioctl(fd, FBIOGET_VSCREENINFO, &varinfo) < 0) {
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Store the pertinent data. */
|
|
|
|
|
info->x_resolution = varinfo.xres;
|
|
|
|
|
info->y_resolution = varinfo.yres;
|
|
|
|
|
info->width_mm = varinfo.width;
|
|
|
|
|
info->height_mm = varinfo.height;
|
|
|
|
|
info->bits_per_pixel = varinfo.bits_per_pixel;
|
|
|
|
|
|
|
|
|
|
info->buffer_length = fixinfo.smem_len;
|
|
|
|
|
info->line_length = fixinfo.line_length;
|
2015-09-02 21:45:20 +03:00
|
|
|
|
strncpy(info->id, fixinfo.id, sizeof(info->id));
|
2015-09-24 03:39:05 +03:00
|
|
|
|
info->id[sizeof(info->id)-1] = '\0';
|
2013-02-02 16:02:32 +04:00
|
|
|
|
|
|
|
|
|
info->pixel_format = calculate_pixman_format(&varinfo, &fixinfo);
|
|
|
|
|
info->refresh_rate = calculate_refresh_rate(&varinfo);
|
|
|
|
|
|
|
|
|
|
if (info->pixel_format == 0) {
|
|
|
|
|
weston_log("Frame buffer uses an unsupported format.\n");
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static int
|
2017-09-12 17:15:42 +03:00
|
|
|
|
fbdev_set_screen_info(int fd, struct fbdev_screeninfo *info)
|
2013-02-02 16:02:32 +04:00
|
|
|
|
{
|
|
|
|
|
struct fb_var_screeninfo varinfo;
|
|
|
|
|
|
|
|
|
|
/* Grab the current screen information. */
|
|
|
|
|
if (ioctl(fd, FBIOGET_VSCREENINFO, &varinfo) < 0) {
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Update the information. */
|
|
|
|
|
varinfo.xres = info->x_resolution;
|
|
|
|
|
varinfo.yres = info->y_resolution;
|
|
|
|
|
varinfo.width = info->width_mm;
|
|
|
|
|
varinfo.height = info->height_mm;
|
|
|
|
|
varinfo.bits_per_pixel = info->bits_per_pixel;
|
|
|
|
|
|
|
|
|
|
/* Try to set up an ARGB (x8r8g8b8) pixel format. */
|
|
|
|
|
varinfo.grayscale = 0;
|
|
|
|
|
varinfo.transp.offset = 24;
|
|
|
|
|
varinfo.transp.length = 0;
|
|
|
|
|
varinfo.transp.msb_right = 0;
|
|
|
|
|
varinfo.red.offset = 16;
|
|
|
|
|
varinfo.red.length = 8;
|
|
|
|
|
varinfo.red.msb_right = 0;
|
|
|
|
|
varinfo.green.offset = 8;
|
|
|
|
|
varinfo.green.length = 8;
|
|
|
|
|
varinfo.green.msb_right = 0;
|
|
|
|
|
varinfo.blue.offset = 0;
|
|
|
|
|
varinfo.blue.length = 8;
|
|
|
|
|
varinfo.blue.msb_right = 0;
|
|
|
|
|
|
|
|
|
|
/* Set the device's screen information. */
|
|
|
|
|
if (ioctl(fd, FBIOPUT_VSCREENINFO, &varinfo) < 0) {
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
2019-01-09 04:59:58 +03:00
|
|
|
|
static int
|
|
|
|
|
fbdev_wakeup_screen(int fd, struct fbdev_screeninfo *info)
|
|
|
|
|
{
|
|
|
|
|
struct fb_var_screeninfo varinfo;
|
|
|
|
|
|
|
|
|
|
/* Grab the current screen information. */
|
|
|
|
|
if (ioctl(fd, FBIOGET_VSCREENINFO, &varinfo) < 0) {
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* force the framebuffer to wake up */
|
|
|
|
|
varinfo.activate = FB_ACTIVATE_NOW | FB_ACTIVATE_FORCE;
|
|
|
|
|
|
|
|
|
|
/* Set the device's screen information. */
|
|
|
|
|
if (ioctl(fd, FBIOPUT_VSCREENINFO, &varinfo) < 0) {
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
2013-02-02 16:02:32 +04:00
|
|
|
|
/* Returns an FD for the frame buffer device. */
|
|
|
|
|
static int
|
2017-09-12 17:15:42 +03:00
|
|
|
|
fbdev_frame_buffer_open(const char *fb_dev,
|
|
|
|
|
struct fbdev_screeninfo *screen_info)
|
2013-02-02 16:02:32 +04:00
|
|
|
|
{
|
|
|
|
|
int fd = -1;
|
|
|
|
|
|
|
|
|
|
weston_log("Opening fbdev frame buffer.\n");
|
|
|
|
|
|
|
|
|
|
/* Open the frame buffer device. */
|
|
|
|
|
fd = open(fb_dev, O_RDWR | O_CLOEXEC);
|
|
|
|
|
if (fd < 0) {
|
|
|
|
|
weston_log("Failed to open frame buffer device ‘%s’: %s\n",
|
|
|
|
|
fb_dev, strerror(errno));
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Grab the screen info. */
|
2017-09-12 17:15:42 +03:00
|
|
|
|
if (fbdev_query_screen_info(fd, screen_info) < 0) {
|
2013-02-02 16:02:32 +04:00
|
|
|
|
weston_log("Failed to get frame buffer info: %s\n",
|
|
|
|
|
strerror(errno));
|
|
|
|
|
|
|
|
|
|
close(fd);
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
|
2018-06-29 15:17:49 +03:00
|
|
|
|
/* Attempt to wake up the framebuffer device, needed for secondary
|
|
|
|
|
* framebuffer devices */
|
2019-01-09 04:59:58 +03:00
|
|
|
|
if (fbdev_wakeup_screen(fd, screen_info) < 0) {
|
|
|
|
|
weston_log("Failed to activate framebuffer display. "
|
2018-06-29 15:17:49 +03:00
|
|
|
|
"Attempting to open output anyway.\n");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2013-02-02 16:02:32 +04:00
|
|
|
|
return fd;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Closes the FD on success or failure. */
|
|
|
|
|
static int
|
|
|
|
|
fbdev_frame_buffer_map(struct fbdev_output *output, int fd)
|
|
|
|
|
{
|
2017-09-14 16:50:44 +03:00
|
|
|
|
struct fbdev_head *head;
|
2013-02-02 16:02:32 +04:00
|
|
|
|
int retval = -1;
|
|
|
|
|
|
2017-09-14 16:50:44 +03:00
|
|
|
|
head = fbdev_output_get_head(output);
|
|
|
|
|
|
2013-02-02 16:02:32 +04:00
|
|
|
|
weston_log("Mapping fbdev frame buffer.\n");
|
|
|
|
|
|
|
|
|
|
/* Map the frame buffer. Write-only mode, since we don't want to read
|
|
|
|
|
* anything back (because it's slow). */
|
2017-09-14 16:50:44 +03:00
|
|
|
|
output->buffer_length = head->fb_info.buffer_length;
|
|
|
|
|
output->fb = mmap(NULL, output->buffer_length,
|
2013-02-02 16:02:32 +04:00
|
|
|
|
PROT_WRITE, MAP_SHARED, fd, 0);
|
|
|
|
|
if (output->fb == MAP_FAILED) {
|
|
|
|
|
weston_log("Failed to mmap frame buffer: %s\n",
|
|
|
|
|
strerror(errno));
|
2017-09-13 11:58:00 +03:00
|
|
|
|
output->fb = NULL;
|
2013-02-02 16:02:32 +04:00
|
|
|
|
goto out_close;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Create a pixman image to wrap the memory mapped frame buffer. */
|
|
|
|
|
output->hw_surface =
|
2017-09-14 16:50:44 +03:00
|
|
|
|
pixman_image_create_bits(head->fb_info.pixel_format,
|
|
|
|
|
head->fb_info.x_resolution,
|
|
|
|
|
head->fb_info.y_resolution,
|
2013-02-02 16:02:32 +04:00
|
|
|
|
output->fb,
|
2017-09-14 16:50:44 +03:00
|
|
|
|
head->fb_info.line_length);
|
2013-02-02 16:02:32 +04:00
|
|
|
|
if (output->hw_surface == NULL) {
|
|
|
|
|
weston_log("Failed to create surface for frame buffer.\n");
|
|
|
|
|
goto out_unmap;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Success! */
|
|
|
|
|
retval = 0;
|
|
|
|
|
|
|
|
|
|
out_unmap:
|
2017-09-13 17:14:19 +03:00
|
|
|
|
if (retval != 0 && output->fb != NULL) {
|
2017-09-14 16:50:44 +03:00
|
|
|
|
munmap(output->fb, output->buffer_length);
|
2017-09-13 17:14:19 +03:00
|
|
|
|
output->fb = NULL;
|
|
|
|
|
}
|
2013-02-02 16:02:32 +04:00
|
|
|
|
|
|
|
|
|
out_close:
|
|
|
|
|
if (fd >= 0)
|
|
|
|
|
close(fd);
|
|
|
|
|
|
|
|
|
|
return retval;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2017-09-13 17:14:19 +03:00
|
|
|
|
fbdev_frame_buffer_unmap(struct fbdev_output *output)
|
2013-02-02 16:02:32 +04:00
|
|
|
|
{
|
2017-09-13 17:14:19 +03:00
|
|
|
|
if (!output->fb) {
|
|
|
|
|
assert(!output->hw_surface);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
weston_log("Unmapping fbdev frame buffer.\n");
|
|
|
|
|
|
|
|
|
|
if (output->hw_surface)
|
|
|
|
|
pixman_image_unref(output->hw_surface);
|
|
|
|
|
output->hw_surface = NULL;
|
2013-02-02 16:02:32 +04:00
|
|
|
|
|
2017-09-14 16:50:44 +03:00
|
|
|
|
if (munmap(output->fb, output->buffer_length) < 0)
|
2013-02-02 16:02:32 +04:00
|
|
|
|
weston_log("Failed to munmap frame buffer: %s\n",
|
|
|
|
|
strerror(errno));
|
|
|
|
|
|
|
|
|
|
output->fb = NULL;
|
|
|
|
|
}
|
|
|
|
|
|
2017-09-14 16:50:44 +03:00
|
|
|
|
|
|
|
|
|
static int
|
|
|
|
|
fbdev_output_attach_head(struct weston_output *output_base,
|
|
|
|
|
struct weston_head *head_base)
|
|
|
|
|
{
|
|
|
|
|
struct fbdev_output *output = to_fbdev_output(output_base);
|
|
|
|
|
struct fbdev_head *head = to_fbdev_head(head_base);
|
|
|
|
|
|
|
|
|
|
/* Clones not supported. */
|
|
|
|
|
if (!wl_list_empty(&output->base.head_list))
|
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
|
|
/* only one static mode in list */
|
|
|
|
|
output->mode.flags = WL_OUTPUT_MODE_CURRENT | WL_OUTPUT_MODE_PREFERRED;
|
|
|
|
|
output->mode.width = head->fb_info.x_resolution;
|
|
|
|
|
output->mode.height = head->fb_info.y_resolution;
|
|
|
|
|
output->mode.refresh = head->fb_info.refresh_rate;
|
|
|
|
|
wl_list_init(&output->base.mode_list);
|
|
|
|
|
wl_list_insert(&output->base.mode_list, &output->mode.link);
|
|
|
|
|
output->base.current_mode = &output->mode;
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2013-02-02 16:02:32 +04:00
|
|
|
|
static void fbdev_output_destroy(struct weston_output *base);
|
|
|
|
|
|
2016-09-30 15:11:06 +03:00
|
|
|
|
static int
|
|
|
|
|
fbdev_output_enable(struct weston_output *base)
|
|
|
|
|
{
|
|
|
|
|
struct fbdev_output *output = to_fbdev_output(base);
|
|
|
|
|
struct fbdev_backend *backend = to_fbdev_backend(base->compositor);
|
2017-09-14 16:50:44 +03:00
|
|
|
|
struct fbdev_head *head;
|
2016-09-30 15:11:06 +03:00
|
|
|
|
int fb_fd;
|
|
|
|
|
struct wl_event_loop *loop;
|
|
|
|
|
|
2017-09-14 16:50:44 +03:00
|
|
|
|
head = fbdev_output_get_head(output);
|
|
|
|
|
|
2016-09-30 15:11:06 +03:00
|
|
|
|
/* Create the frame buffer. */
|
2017-09-14 16:50:44 +03:00
|
|
|
|
fb_fd = fbdev_frame_buffer_open(head->device, &head->fb_info);
|
2016-09-30 15:11:06 +03:00
|
|
|
|
if (fb_fd < 0) {
|
|
|
|
|
weston_log("Creating frame buffer failed.\n");
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (fbdev_frame_buffer_map(output, fb_fd) < 0) {
|
|
|
|
|
weston_log("Mapping frame buffer failed.\n");
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
output->base.start_repaint_loop = fbdev_output_start_repaint_loop;
|
|
|
|
|
output->base.repaint = fbdev_output_repaint;
|
|
|
|
|
|
2018-04-23 12:44:57 +03:00
|
|
|
|
if (pixman_renderer_output_create(&output->base,
|
|
|
|
|
PIXMAN_RENDERER_OUTPUT_USE_SHADOW) < 0)
|
2016-09-30 15:11:06 +03:00
|
|
|
|
goto out_hw_surface;
|
|
|
|
|
|
|
|
|
|
loop = wl_display_get_event_loop(backend->compositor->wl_display);
|
|
|
|
|
output->finish_frame_timer =
|
|
|
|
|
wl_event_loop_add_timer(loop, finish_frame_handler, output);
|
|
|
|
|
|
|
|
|
|
weston_log("fbdev output %d×%d px\n",
|
|
|
|
|
output->mode.width, output->mode.height);
|
|
|
|
|
weston_log_continue(STAMP_SPACE "guessing %d Hz and 96 dpi\n",
|
|
|
|
|
output->mode.refresh / 1000);
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
|
|
out_hw_surface:
|
2017-09-13 17:14:19 +03:00
|
|
|
|
fbdev_frame_buffer_unmap(output);
|
2016-09-30 15:11:06 +03:00
|
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
|
2017-08-15 10:35:09 +03:00
|
|
|
|
static int
|
2017-09-13 17:25:41 +03:00
|
|
|
|
fbdev_output_disable(struct weston_output *base)
|
2017-08-15 10:35:09 +03:00
|
|
|
|
{
|
2017-09-13 17:14:19 +03:00
|
|
|
|
struct fbdev_output *output = to_fbdev_output(base);
|
|
|
|
|
|
2017-08-15 10:35:09 +03:00
|
|
|
|
if (!base->enabled)
|
|
|
|
|
return 0;
|
|
|
|
|
|
2017-09-14 11:43:29 +03:00
|
|
|
|
wl_event_source_remove(output->finish_frame_timer);
|
|
|
|
|
output->finish_frame_timer = NULL;
|
|
|
|
|
|
2017-09-13 17:22:38 +03:00
|
|
|
|
pixman_renderer_output_destroy(&output->base);
|
2017-09-13 17:14:19 +03:00
|
|
|
|
fbdev_frame_buffer_unmap(output);
|
2017-08-15 10:35:09 +03:00
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2017-09-14 16:50:44 +03:00
|
|
|
|
static struct fbdev_head *
|
|
|
|
|
fbdev_head_create(struct fbdev_backend *backend, const char *device)
|
2013-02-02 16:02:32 +04:00
|
|
|
|
{
|
2017-09-14 16:50:44 +03:00
|
|
|
|
struct fbdev_head *head;
|
2013-02-02 16:02:32 +04:00
|
|
|
|
int fb_fd;
|
|
|
|
|
|
2017-09-14 16:50:44 +03:00
|
|
|
|
head = zalloc(sizeof *head);
|
|
|
|
|
if (!head)
|
|
|
|
|
return NULL;
|
2013-02-02 16:02:32 +04:00
|
|
|
|
|
2017-09-14 16:50:44 +03:00
|
|
|
|
head->device = strdup(device);
|
2013-02-02 16:02:32 +04:00
|
|
|
|
|
|
|
|
|
/* Create the frame buffer. */
|
2017-09-14 16:50:44 +03:00
|
|
|
|
fb_fd = fbdev_frame_buffer_open(head->device, &head->fb_info);
|
2013-02-02 16:02:32 +04:00
|
|
|
|
if (fb_fd < 0) {
|
2017-09-14 16:50:44 +03:00
|
|
|
|
weston_log("Creating frame buffer head failed.\n");
|
2013-02-02 16:02:32 +04:00
|
|
|
|
goto out_free;
|
|
|
|
|
}
|
2017-09-14 16:50:44 +03:00
|
|
|
|
close(fb_fd);
|
2016-06-08 17:39:37 +03:00
|
|
|
|
|
2017-09-14 16:50:44 +03:00
|
|
|
|
weston_head_init(&head->base, "fbdev");
|
|
|
|
|
weston_head_set_connection_status(&head->base, true);
|
|
|
|
|
weston_head_set_monitor_strings(&head->base, "unknown",
|
|
|
|
|
head->fb_info.id, NULL);
|
|
|
|
|
weston_head_set_subpixel(&head->base, WL_OUTPUT_SUBPIXEL_UNKNOWN);
|
|
|
|
|
weston_head_set_physical_size(&head->base, head->fb_info.width_mm,
|
|
|
|
|
head->fb_info.height_mm);
|
2017-04-03 13:18:13 +03:00
|
|
|
|
|
2017-09-14 16:50:44 +03:00
|
|
|
|
weston_compositor_add_head(backend->compositor, &head->base);
|
2016-09-30 15:11:06 +03:00
|
|
|
|
|
2017-09-14 16:50:44 +03:00
|
|
|
|
weston_log("Created head '%s' for device %s (%s)\n",
|
|
|
|
|
head->base.name, head->device, head->base.model);
|
2013-02-02 16:02:32 +04:00
|
|
|
|
|
2017-09-14 16:50:44 +03:00
|
|
|
|
return head;
|
2013-02-02 16:02:32 +04:00
|
|
|
|
|
2017-09-14 16:50:44 +03:00
|
|
|
|
out_free:
|
|
|
|
|
free(head->device);
|
|
|
|
|
free(head);
|
2013-02-02 16:02:32 +04:00
|
|
|
|
|
2017-09-14 16:50:44 +03:00
|
|
|
|
return NULL;
|
|
|
|
|
}
|
2013-09-06 16:16:09 +04:00
|
|
|
|
|
2017-09-14 16:50:44 +03:00
|
|
|
|
static void
|
|
|
|
|
fbdev_head_destroy(struct fbdev_head *head)
|
|
|
|
|
{
|
|
|
|
|
weston_head_release(&head->base);
|
|
|
|
|
free(head->device);
|
|
|
|
|
free(head);
|
|
|
|
|
}
|
2013-02-02 16:02:32 +04:00
|
|
|
|
|
2017-09-14 16:50:44 +03:00
|
|
|
|
static struct weston_output *
|
|
|
|
|
fbdev_output_create(struct weston_compositor *compositor,
|
|
|
|
|
const char *name)
|
|
|
|
|
{
|
|
|
|
|
struct fbdev_output *output;
|
2013-02-02 16:02:32 +04:00
|
|
|
|
|
2017-09-14 16:50:44 +03:00
|
|
|
|
weston_log("Creating fbdev output.\n");
|
2013-02-02 16:02:32 +04:00
|
|
|
|
|
2017-09-14 16:50:44 +03:00
|
|
|
|
output = zalloc(sizeof *output);
|
|
|
|
|
if (output == NULL)
|
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
|
|
output->backend = to_fbdev_backend(compositor);
|
|
|
|
|
|
|
|
|
|
weston_output_init(&output->base, compositor, name);
|
|
|
|
|
|
|
|
|
|
output->base.destroy = fbdev_output_destroy;
|
|
|
|
|
output->base.disable = fbdev_output_disable;
|
|
|
|
|
output->base.enable = fbdev_output_enable;
|
|
|
|
|
output->base.attach_head = fbdev_output_attach_head;
|
|
|
|
|
|
|
|
|
|
weston_compositor_add_pending_output(&output->base, compositor);
|
|
|
|
|
|
|
|
|
|
return &output->base;
|
2013-02-02 16:02:32 +04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
fbdev_output_destroy(struct weston_output *base)
|
|
|
|
|
{
|
|
|
|
|
struct fbdev_output *output = to_fbdev_output(base);
|
|
|
|
|
|
|
|
|
|
weston_log("Destroying fbdev output.\n");
|
|
|
|
|
|
2017-09-13 17:25:41 +03:00
|
|
|
|
fbdev_output_disable(base);
|
2013-02-02 16:02:32 +04:00
|
|
|
|
|
|
|
|
|
/* Remove the output. */
|
2017-08-16 12:07:14 +03:00
|
|
|
|
weston_output_release(&output->base);
|
2013-02-02 16:02:32 +04:00
|
|
|
|
|
|
|
|
|
free(output);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* strcmp()-style return values. */
|
|
|
|
|
static int
|
|
|
|
|
compare_screen_info (const struct fbdev_screeninfo *a,
|
|
|
|
|
const struct fbdev_screeninfo *b)
|
|
|
|
|
{
|
|
|
|
|
if (a->x_resolution == b->x_resolution &&
|
|
|
|
|
a->y_resolution == b->y_resolution &&
|
|
|
|
|
a->width_mm == b->width_mm &&
|
|
|
|
|
a->height_mm == b->height_mm &&
|
|
|
|
|
a->bits_per_pixel == b->bits_per_pixel &&
|
|
|
|
|
a->pixel_format == b->pixel_format &&
|
|
|
|
|
a->refresh_rate == b->refresh_rate)
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static int
|
2014-10-11 19:27:30 +04:00
|
|
|
|
fbdev_output_reenable(struct fbdev_backend *backend,
|
2013-02-02 16:02:32 +04:00
|
|
|
|
struct weston_output *base)
|
|
|
|
|
{
|
|
|
|
|
struct fbdev_output *output = to_fbdev_output(base);
|
2017-09-14 16:50:44 +03:00
|
|
|
|
struct fbdev_head *head;
|
2013-02-02 16:02:32 +04:00
|
|
|
|
struct fbdev_screeninfo new_screen_info;
|
|
|
|
|
int fb_fd;
|
|
|
|
|
|
2017-09-14 16:50:44 +03:00
|
|
|
|
head = fbdev_output_get_head(output);
|
|
|
|
|
|
2013-02-02 16:02:32 +04:00
|
|
|
|
weston_log("Re-enabling fbdev output.\n");
|
compositor-fbdev: make re-enable less drastic
Destroying the whole output in reenable would cause list walk
corruption: the loop over output_list in session_notify() is not using
wl_list_for_each_safe so output removal would break it.
Creating a new output is also problematic as it needs the compositor to
configure it, but that probably saved us from another list walk failure:
adding the new output to be list while walking the list, possibly
causing it to be destroyed and re-created ad infinitum.
Instead of a complete destroy/create cycle, just do our internal
disable/enable cycle. That will re-open the fbdev, re-read the
parameters, re-create hw_surface, and reinitialize the renderer output.
A problem with this is if fbdev_set_screen_info() fails. We do read the
new parameters, but we don't communicate them to libweston core or old
clients.
However, it is hard to care: to trigger this path, one needs to
VT-switch to another fbdev app which changes the fbdev parameters. That
is quite difficult as VT-switching has been broken for a good while for
fbdev-backend, at least with logind. Also fbdev_set_screen_info() would
have to fail before one should be able to tell something is wrong.
The real reason behind this patch, though, is the migration to the
head-based output API. Destroying and re-creating an output really does
not fit that design. Destroying and re-creating a head would be better,
but again not testable in the current state.
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Ian Ray <ian.ray@ge.com>
Acked-by: Daniel Stone <daniels@collabora.com>
Acked-by: Derek Foreman <derekf@osg.samsung.com>
2017-09-13 16:19:02 +03:00
|
|
|
|
assert(output->base.enabled);
|
2013-02-02 16:02:32 +04:00
|
|
|
|
|
|
|
|
|
/* Create the frame buffer. */
|
2017-09-14 16:50:44 +03:00
|
|
|
|
fb_fd = fbdev_frame_buffer_open(head->device, &new_screen_info);
|
2013-02-02 16:02:32 +04:00
|
|
|
|
if (fb_fd < 0) {
|
|
|
|
|
weston_log("Creating frame buffer failed.\n");
|
compositor-fbdev: make re-enable less drastic
Destroying the whole output in reenable would cause list walk
corruption: the loop over output_list in session_notify() is not using
wl_list_for_each_safe so output removal would break it.
Creating a new output is also problematic as it needs the compositor to
configure it, but that probably saved us from another list walk failure:
adding the new output to be list while walking the list, possibly
causing it to be destroyed and re-created ad infinitum.
Instead of a complete destroy/create cycle, just do our internal
disable/enable cycle. That will re-open the fbdev, re-read the
parameters, re-create hw_surface, and reinitialize the renderer output.
A problem with this is if fbdev_set_screen_info() fails. We do read the
new parameters, but we don't communicate them to libweston core or old
clients.
However, it is hard to care: to trigger this path, one needs to
VT-switch to another fbdev app which changes the fbdev parameters. That
is quite difficult as VT-switching has been broken for a good while for
fbdev-backend, at least with logind. Also fbdev_set_screen_info() would
have to fail before one should be able to tell something is wrong.
The real reason behind this patch, though, is the migration to the
head-based output API. Destroying and re-creating an output really does
not fit that design. Destroying and re-creating a head would be better,
but again not testable in the current state.
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Ian Ray <ian.ray@ge.com>
Acked-by: Daniel Stone <daniels@collabora.com>
Acked-by: Derek Foreman <derekf@osg.samsung.com>
2017-09-13 16:19:02 +03:00
|
|
|
|
return -1;
|
2013-02-02 16:02:32 +04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Check whether the frame buffer details have changed since we were
|
|
|
|
|
* disabled. */
|
2017-09-14 16:50:44 +03:00
|
|
|
|
if (compare_screen_info(&head->fb_info, &new_screen_info) != 0) {
|
2013-02-02 16:02:32 +04:00
|
|
|
|
/* Perform a mode-set to restore the old mode. */
|
2017-09-14 16:50:44 +03:00
|
|
|
|
if (fbdev_set_screen_info(fb_fd, &head->fb_info) < 0) {
|
2013-02-02 16:02:32 +04:00
|
|
|
|
weston_log("Failed to restore mode settings. "
|
|
|
|
|
"Attempting to re-open output anyway.\n");
|
|
|
|
|
}
|
|
|
|
|
|
2013-07-26 19:29:39 +04:00
|
|
|
|
close(fb_fd);
|
|
|
|
|
|
compositor-fbdev: make re-enable less drastic
Destroying the whole output in reenable would cause list walk
corruption: the loop over output_list in session_notify() is not using
wl_list_for_each_safe so output removal would break it.
Creating a new output is also problematic as it needs the compositor to
configure it, but that probably saved us from another list walk failure:
adding the new output to be list while walking the list, possibly
causing it to be destroyed and re-created ad infinitum.
Instead of a complete destroy/create cycle, just do our internal
disable/enable cycle. That will re-open the fbdev, re-read the
parameters, re-create hw_surface, and reinitialize the renderer output.
A problem with this is if fbdev_set_screen_info() fails. We do read the
new parameters, but we don't communicate them to libweston core or old
clients.
However, it is hard to care: to trigger this path, one needs to
VT-switch to another fbdev app which changes the fbdev parameters. That
is quite difficult as VT-switching has been broken for a good while for
fbdev-backend, at least with logind. Also fbdev_set_screen_info() would
have to fail before one should be able to tell something is wrong.
The real reason behind this patch, though, is the migration to the
head-based output API. Destroying and re-creating an output really does
not fit that design. Destroying and re-creating a head would be better,
but again not testable in the current state.
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Ian Ray <ian.ray@ge.com>
Acked-by: Daniel Stone <daniels@collabora.com>
Acked-by: Derek Foreman <derekf@osg.samsung.com>
2017-09-13 16:19:02 +03:00
|
|
|
|
/* Disable and enable the output so that resources depending on
|
2013-02-02 16:02:32 +04:00
|
|
|
|
* the frame buffer X/Y resolution (such as the shadow buffer)
|
|
|
|
|
* are re-initialised. */
|
compositor-fbdev: make re-enable less drastic
Destroying the whole output in reenable would cause list walk
corruption: the loop over output_list in session_notify() is not using
wl_list_for_each_safe so output removal would break it.
Creating a new output is also problematic as it needs the compositor to
configure it, but that probably saved us from another list walk failure:
adding the new output to be list while walking the list, possibly
causing it to be destroyed and re-created ad infinitum.
Instead of a complete destroy/create cycle, just do our internal
disable/enable cycle. That will re-open the fbdev, re-read the
parameters, re-create hw_surface, and reinitialize the renderer output.
A problem with this is if fbdev_set_screen_info() fails. We do read the
new parameters, but we don't communicate them to libweston core or old
clients.
However, it is hard to care: to trigger this path, one needs to
VT-switch to another fbdev app which changes the fbdev parameters. That
is quite difficult as VT-switching has been broken for a good while for
fbdev-backend, at least with logind. Also fbdev_set_screen_info() would
have to fail before one should be able to tell something is wrong.
The real reason behind this patch, though, is the migration to the
head-based output API. Destroying and re-creating an output really does
not fit that design. Destroying and re-creating a head would be better,
but again not testable in the current state.
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Ian Ray <ian.ray@ge.com>
Acked-by: Daniel Stone <daniels@collabora.com>
Acked-by: Derek Foreman <derekf@osg.samsung.com>
2017-09-13 16:19:02 +03:00
|
|
|
|
fbdev_output_disable(&output->base);
|
|
|
|
|
return fbdev_output_enable(&output->base);
|
2013-02-02 16:02:32 +04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Map the device if it has the same details as before. */
|
2016-06-08 17:39:37 +03:00
|
|
|
|
if (fbdev_frame_buffer_map(output, fb_fd) < 0) {
|
|
|
|
|
weston_log("Mapping frame buffer failed.\n");
|
compositor-fbdev: make re-enable less drastic
Destroying the whole output in reenable would cause list walk
corruption: the loop over output_list in session_notify() is not using
wl_list_for_each_safe so output removal would break it.
Creating a new output is also problematic as it needs the compositor to
configure it, but that probably saved us from another list walk failure:
adding the new output to be list while walking the list, possibly
causing it to be destroyed and re-created ad infinitum.
Instead of a complete destroy/create cycle, just do our internal
disable/enable cycle. That will re-open the fbdev, re-read the
parameters, re-create hw_surface, and reinitialize the renderer output.
A problem with this is if fbdev_set_screen_info() fails. We do read the
new parameters, but we don't communicate them to libweston core or old
clients.
However, it is hard to care: to trigger this path, one needs to
VT-switch to another fbdev app which changes the fbdev parameters. That
is quite difficult as VT-switching has been broken for a good while for
fbdev-backend, at least with logind. Also fbdev_set_screen_info() would
have to fail before one should be able to tell something is wrong.
The real reason behind this patch, though, is the migration to the
head-based output API. Destroying and re-creating an output really does
not fit that design. Destroying and re-creating a head would be better,
but again not testable in the current state.
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Ian Ray <ian.ray@ge.com>
Acked-by: Daniel Stone <daniels@collabora.com>
Acked-by: Derek Foreman <derekf@osg.samsung.com>
2017-09-13 16:19:02 +03:00
|
|
|
|
return -1;
|
2013-02-02 16:02:32 +04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2014-10-11 19:27:30 +04:00
|
|
|
|
fbdev_backend_destroy(struct weston_compositor *base)
|
2013-02-02 16:02:32 +04:00
|
|
|
|
{
|
2014-10-11 19:27:30 +04:00
|
|
|
|
struct fbdev_backend *backend = to_fbdev_backend(base);
|
2017-09-14 16:50:44 +03:00
|
|
|
|
struct weston_head *head, *next;
|
2013-02-02 16:02:32 +04:00
|
|
|
|
|
2014-10-11 19:27:30 +04:00
|
|
|
|
udev_input_destroy(&backend->input);
|
2013-02-02 16:02:32 +04:00
|
|
|
|
|
|
|
|
|
/* Destroy the output. */
|
2014-10-11 19:27:30 +04:00
|
|
|
|
weston_compositor_shutdown(base);
|
2013-02-02 16:02:32 +04:00
|
|
|
|
|
2017-09-14 16:50:44 +03:00
|
|
|
|
wl_list_for_each_safe(head, next, &base->head_list, compositor_link)
|
|
|
|
|
fbdev_head_destroy(to_fbdev_head(head));
|
|
|
|
|
|
2013-02-02 16:02:32 +04:00
|
|
|
|
/* Chain up. */
|
2014-10-11 19:27:30 +04:00
|
|
|
|
weston_launcher_destroy(base->launcher);
|
2013-02-02 16:02:32 +04:00
|
|
|
|
|
2017-09-13 16:49:02 +03:00
|
|
|
|
udev_unref(backend->udev);
|
|
|
|
|
|
2014-10-11 19:27:30 +04:00
|
|
|
|
free(backend);
|
2013-02-02 16:02:32 +04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2013-09-18 03:02:57 +04:00
|
|
|
|
session_notify(struct wl_listener *listener, void *data)
|
2013-02-02 16:02:32 +04:00
|
|
|
|
{
|
2015-08-19 13:52:47 +03:00
|
|
|
|
struct weston_compositor *compositor = data;
|
|
|
|
|
struct fbdev_backend *backend = to_fbdev_backend(compositor);
|
2013-02-02 16:02:32 +04:00
|
|
|
|
struct weston_output *output;
|
|
|
|
|
|
2014-10-11 19:27:30 +04:00
|
|
|
|
if (compositor->session_active) {
|
2013-02-02 16:02:32 +04:00
|
|
|
|
weston_log("entering VT\n");
|
2014-10-11 19:27:30 +04:00
|
|
|
|
compositor->state = backend->prev_state;
|
2013-02-02 16:02:32 +04:00
|
|
|
|
|
2014-10-11 19:27:30 +04:00
|
|
|
|
wl_list_for_each(output, &compositor->output_list, link) {
|
|
|
|
|
fbdev_output_reenable(backend, output);
|
2013-02-02 16:02:32 +04:00
|
|
|
|
}
|
|
|
|
|
|
2014-10-11 19:27:30 +04:00
|
|
|
|
weston_compositor_damage_all(compositor);
|
2013-02-02 16:02:32 +04:00
|
|
|
|
|
2014-10-11 19:27:30 +04:00
|
|
|
|
udev_input_enable(&backend->input);
|
2013-09-18 03:02:57 +04:00
|
|
|
|
} else {
|
2013-02-02 16:02:32 +04:00
|
|
|
|
weston_log("leaving VT\n");
|
2014-10-11 19:27:30 +04:00
|
|
|
|
udev_input_disable(&backend->input);
|
2013-02-02 16:02:32 +04:00
|
|
|
|
|
2014-10-11 19:27:30 +04:00
|
|
|
|
wl_list_for_each(output, &compositor->output_list, link) {
|
2017-09-13 17:14:19 +03:00
|
|
|
|
fbdev_frame_buffer_unmap(to_fbdev_output(output));
|
2013-02-02 16:02:32 +04:00
|
|
|
|
}
|
|
|
|
|
|
2014-10-11 19:27:30 +04:00
|
|
|
|
backend->prev_state = compositor->state;
|
|
|
|
|
weston_compositor_offscreen(compositor);
|
2013-02-02 16:02:32 +04:00
|
|
|
|
|
|
|
|
|
/* If we have a repaint scheduled (from the idle handler), make
|
|
|
|
|
* sure we cancel that so we don't try to pageflip when we're
|
2013-03-29 16:01:56 +04:00
|
|
|
|
* vt switched away. The OFFSCREEN state will prevent
|
2015-12-12 00:11:37 +03:00
|
|
|
|
* further attempts at repainting. When we switch
|
2013-02-02 16:02:32 +04:00
|
|
|
|
* back, we schedule a repaint, which will process
|
|
|
|
|
* pending frame callbacks. */
|
|
|
|
|
|
|
|
|
|
wl_list_for_each(output,
|
2014-10-11 19:27:30 +04:00
|
|
|
|
&compositor->output_list, link) {
|
2017-03-01 14:34:06 +03:00
|
|
|
|
output->repaint_needed = false;
|
2013-02-02 16:02:32 +04:00
|
|
|
|
}
|
2014-12-03 18:53:03 +03:00
|
|
|
|
}
|
2013-02-02 16:02:32 +04:00
|
|
|
|
}
|
|
|
|
|
|
2018-06-29 15:17:50 +03:00
|
|
|
|
static char *
|
|
|
|
|
find_framebuffer_device(struct fbdev_backend *b, const char *seat)
|
|
|
|
|
{
|
|
|
|
|
struct udev_enumerate *e;
|
|
|
|
|
struct udev_list_entry *entry;
|
|
|
|
|
const char *path, *device_seat, *id;
|
|
|
|
|
char *fb_device_path = NULL;
|
|
|
|
|
struct udev_device *device, *fb_device, *pci;
|
|
|
|
|
|
|
|
|
|
e = udev_enumerate_new(b->udev);
|
|
|
|
|
udev_enumerate_add_match_subsystem(e, "graphics");
|
|
|
|
|
udev_enumerate_add_match_sysname(e, "fb[0-9]*");
|
|
|
|
|
|
|
|
|
|
udev_enumerate_scan_devices(e);
|
|
|
|
|
fb_device = NULL;
|
|
|
|
|
udev_list_entry_foreach(entry, udev_enumerate_get_list_entry(e)) {
|
|
|
|
|
bool is_boot_vga = false;
|
|
|
|
|
|
|
|
|
|
path = udev_list_entry_get_name(entry);
|
|
|
|
|
device = udev_device_new_from_syspath(b->udev, path);
|
|
|
|
|
if (!device)
|
|
|
|
|
continue;
|
|
|
|
|
device_seat = udev_device_get_property_value(device, "ID_SEAT");
|
|
|
|
|
if (!device_seat)
|
|
|
|
|
device_seat = default_seat;
|
|
|
|
|
if (strcmp(device_seat, seat)) {
|
|
|
|
|
udev_device_unref(device);
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pci = udev_device_get_parent_with_subsystem_devtype(device,
|
|
|
|
|
"pci", NULL);
|
|
|
|
|
if (pci) {
|
|
|
|
|
id = udev_device_get_sysattr_value(pci, "boot_vga");
|
|
|
|
|
if (id && !strcmp(id, "1"))
|
|
|
|
|
is_boot_vga = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* If a framebuffer device was found, and this device isn't
|
|
|
|
|
* the boot-VGA device, don't use it. */
|
|
|
|
|
if (!is_boot_vga && fb_device) {
|
|
|
|
|
udev_device_unref(device);
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* There can only be one boot_vga device. Try to use it
|
|
|
|
|
* at all costs. */
|
|
|
|
|
if (is_boot_vga) {
|
|
|
|
|
if (fb_device)
|
|
|
|
|
udev_device_unref(fb_device);
|
|
|
|
|
fb_device = device;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Per the (!is_boot_vga && fb_device) test above, only
|
|
|
|
|
* trump existing saved devices with boot-VGA devices, so if
|
|
|
|
|
* the test ends up here, this must be the first device seen. */
|
|
|
|
|
assert(!fb_device);
|
|
|
|
|
fb_device = device;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
udev_enumerate_unref(e);
|
|
|
|
|
|
|
|
|
|
if (fb_device) {
|
|
|
|
|
fb_device_path = strdup(udev_device_get_devnode(fb_device));
|
|
|
|
|
udev_device_unref(fb_device);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return fb_device_path;
|
|
|
|
|
}
|
|
|
|
|
|
2014-10-11 19:27:30 +04:00
|
|
|
|
static struct fbdev_backend *
|
2016-06-03 14:56:18 +03:00
|
|
|
|
fbdev_backend_create(struct weston_compositor *compositor,
|
2016-04-28 00:56:42 +03:00
|
|
|
|
struct weston_fbdev_backend_config *param)
|
2013-02-02 16:02:32 +04:00
|
|
|
|
{
|
2014-10-11 19:27:30 +04:00
|
|
|
|
struct fbdev_backend *backend;
|
2013-05-31 21:09:57 +04:00
|
|
|
|
const char *seat_id = default_seat;
|
2018-06-29 15:17:47 +03:00
|
|
|
|
const char *session_seat;
|
|
|
|
|
|
|
|
|
|
session_seat = getenv("XDG_SEAT");
|
|
|
|
|
if (session_seat)
|
|
|
|
|
seat_id = session_seat;
|
|
|
|
|
if (param->seat_id)
|
|
|
|
|
seat_id = param->seat_id;
|
2013-02-02 16:02:32 +04:00
|
|
|
|
|
|
|
|
|
weston_log("initializing fbdev backend\n");
|
|
|
|
|
|
2014-10-11 19:27:30 +04:00
|
|
|
|
backend = zalloc(sizeof *backend);
|
|
|
|
|
if (backend == NULL)
|
2013-02-02 16:02:32 +04:00
|
|
|
|
return NULL;
|
|
|
|
|
|
2014-10-11 19:27:30 +04:00
|
|
|
|
backend->compositor = compositor;
|
2017-08-30 11:29:49 +03:00
|
|
|
|
compositor->backend = &backend->base;
|
2014-09-24 06:08:45 +04:00
|
|
|
|
if (weston_compositor_set_presentation_clock_software(
|
2014-10-11 19:27:30 +04:00
|
|
|
|
compositor) < 0)
|
2014-09-24 06:08:45 +04:00
|
|
|
|
goto out_compositor;
|
|
|
|
|
|
2014-10-11 19:27:30 +04:00
|
|
|
|
backend->udev = udev_new();
|
|
|
|
|
if (backend->udev == NULL) {
|
2013-02-02 16:02:32 +04:00
|
|
|
|
weston_log("Failed to initialize udev context.\n");
|
|
|
|
|
goto out_compositor;
|
|
|
|
|
}
|
|
|
|
|
|
2018-06-29 15:17:50 +03:00
|
|
|
|
if (!param->device)
|
|
|
|
|
param->device = find_framebuffer_device(backend, seat_id);
|
|
|
|
|
if (!param->device) {
|
|
|
|
|
weston_log("fatal: no framebuffer devices detected.\n");
|
|
|
|
|
goto out_udev;
|
|
|
|
|
}
|
|
|
|
|
|
2013-02-02 16:02:32 +04:00
|
|
|
|
/* Set up the TTY. */
|
2014-10-11 19:27:30 +04:00
|
|
|
|
backend->session_listener.notify = session_notify;
|
|
|
|
|
wl_signal_add(&compositor->session_signal,
|
|
|
|
|
&backend->session_listener);
|
|
|
|
|
compositor->launcher =
|
2018-06-29 15:17:47 +03:00
|
|
|
|
weston_launcher_connect(compositor, param->tty, seat_id, false);
|
2014-10-11 19:27:30 +04:00
|
|
|
|
if (!compositor->launcher) {
|
2017-10-31 11:19:48 +03:00
|
|
|
|
weston_log("fatal: fbdev backend should be run using "
|
|
|
|
|
"weston-launch binary, or your system should "
|
|
|
|
|
"provide the logind D-Bus API.\n");
|
2013-02-02 16:02:32 +04:00
|
|
|
|
goto out_udev;
|
|
|
|
|
}
|
|
|
|
|
|
2014-10-11 19:27:30 +04:00
|
|
|
|
backend->base.destroy = fbdev_backend_destroy;
|
2017-09-14 16:50:44 +03:00
|
|
|
|
backend->base.create_output = fbdev_output_create;
|
2013-02-02 16:02:32 +04:00
|
|
|
|
|
2014-10-11 19:27:30 +04:00
|
|
|
|
backend->prev_state = WESTON_COMPOSITOR_ACTIVE;
|
2013-02-02 16:02:32 +04:00
|
|
|
|
|
2016-01-12 13:21:47 +03:00
|
|
|
|
weston_setup_vt_switch_bindings(compositor);
|
|
|
|
|
|
2016-06-08 17:39:37 +03:00
|
|
|
|
if (pixman_renderer_init(compositor) < 0)
|
|
|
|
|
goto out_launcher;
|
2013-02-02 16:02:32 +04:00
|
|
|
|
|
2017-09-14 16:50:44 +03:00
|
|
|
|
if (!fbdev_head_create(backend, param->device))
|
2015-07-31 06:02:28 +03:00
|
|
|
|
goto out_launcher;
|
2013-02-02 16:02:32 +04:00
|
|
|
|
|
2018-06-29 15:17:50 +03:00
|
|
|
|
free(param->device);
|
|
|
|
|
|
2016-06-02 21:48:12 +03:00
|
|
|
|
udev_input_init(&backend->input, compositor, backend->udev,
|
|
|
|
|
seat_id, param->configure_device);
|
2013-02-02 16:02:32 +04:00
|
|
|
|
|
2014-10-11 19:27:30 +04:00
|
|
|
|
return backend;
|
2013-02-02 16:02:32 +04:00
|
|
|
|
|
2013-09-19 10:00:17 +04:00
|
|
|
|
out_launcher:
|
2018-06-29 15:17:50 +03:00
|
|
|
|
free(param->device);
|
2014-10-11 19:27:30 +04:00
|
|
|
|
weston_launcher_destroy(compositor->launcher);
|
2013-02-02 16:02:32 +04:00
|
|
|
|
|
|
|
|
|
out_udev:
|
2014-10-11 19:27:30 +04:00
|
|
|
|
udev_unref(backend->udev);
|
2013-02-02 16:02:32 +04:00
|
|
|
|
|
|
|
|
|
out_compositor:
|
2014-10-11 19:27:30 +04:00
|
|
|
|
weston_compositor_shutdown(compositor);
|
|
|
|
|
free(backend);
|
2013-02-02 16:02:32 +04:00
|
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
2016-04-28 00:56:42 +03:00
|
|
|
|
static void
|
|
|
|
|
config_init_to_defaults(struct weston_fbdev_backend_config *config)
|
|
|
|
|
{
|
|
|
|
|
config->tty = 0; /* default to current tty */
|
2018-06-29 15:17:50 +03:00
|
|
|
|
config->device = NULL;
|
2018-06-29 15:17:47 +03:00
|
|
|
|
config->seat_id = NULL;
|
2016-04-28 00:56:42 +03:00
|
|
|
|
}
|
|
|
|
|
|
2014-10-11 19:27:30 +04:00
|
|
|
|
WL_EXPORT int
|
2016-12-02 16:08:44 +03:00
|
|
|
|
weston_backend_init(struct weston_compositor *compositor,
|
|
|
|
|
struct weston_backend_config *config_base)
|
2013-02-02 16:02:32 +04:00
|
|
|
|
{
|
2014-10-11 19:27:30 +04:00
|
|
|
|
struct fbdev_backend *b;
|
2016-04-28 00:56:42 +03:00
|
|
|
|
struct weston_fbdev_backend_config config = {{ 0, }};
|
2013-02-02 16:02:32 +04:00
|
|
|
|
|
2016-04-28 00:56:42 +03:00
|
|
|
|
if (config_base == NULL ||
|
|
|
|
|
config_base->struct_version != WESTON_FBDEV_BACKEND_CONFIG_VERSION ||
|
|
|
|
|
config_base->struct_size > sizeof(struct weston_fbdev_backend_config)) {
|
|
|
|
|
weston_log("fbdev backend config structure is invalid\n");
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
2013-02-02 16:02:32 +04:00
|
|
|
|
|
2016-04-28 00:56:42 +03:00
|
|
|
|
config_init_to_defaults(&config);
|
|
|
|
|
memcpy(&config, config_base, config_base->struct_size);
|
2013-02-02 16:02:32 +04:00
|
|
|
|
|
2016-06-03 14:56:18 +03:00
|
|
|
|
b = fbdev_backend_create(compositor, &config);
|
2014-10-11 19:27:30 +04:00
|
|
|
|
if (b == NULL)
|
|
|
|
|
return -1;
|
|
|
|
|
return 0;
|
2013-02-02 16:02:32 +04:00
|
|
|
|
}
|