I ran Weston on a Nexus 4 mobile phone, with a native GNU/Linux userland,
and the latest Android kernel for that device from LineageOS [1].
calculate_refresh_rate() returned 1 (mHz), which gets rounded to 0 Hz later
and results in nothing being drawn to the screen.
This patch makes sure, that there is at least a refresh rate of 1 Hz, because
it returns the default refresh rate of 60 Hz otherwise.
[1]: https://github.com/LineageOS/lge-kernel-mako
Signed-off-by: Oliver Smith <ollieparanoid@bitmessage.ch>
Reviewed-by: Quentin Glidic <sardemff7+git@sardemff7.net>
Implement new repaint_begin and repaint_flush hooks inside
weston_backend, allowing backends to gang together repaints which
trigger at the same time.
Signed-off-by: Daniel Stone <daniels@collabora.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
This prevents loading a backend as a simple module. This will avoid
messing up with backends when we will introduce libweston common
modules.
Signed-off-by: Quentin Glidic <sardemff7+git@sardemff7.net>
Reviewed-by: Daniel Stone <daniels@collabora.com>
This is a complete port of the fbdev backend that uses
the recently added output handling API for output
configuration.
It is required that the scale and transform values are
set using the previously added functionality.
After everything has been set, output needs to be
enabled manually using weston_output_enable().
v2:
- Use weston_compositor_add_pending_output().
- Bump weston_fbdev_backend_config version to 2.
Reviewed-by: Quentin Glidic <sardemff7+git@sardemff7.net>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Signed-off-by: Armin Krezović <krezovic.armin@gmail.com>
This clarifies what is supposed to be the libweston code.
v2: screen-share.c is already in compositor/ instead.
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Yong Bakos <ybakos@humanoriented.com>
Acked-by: Daniel Stone <daniels@collabora.com>
Reviewed-by: Quentin Glidic <sardemff7+git@sardemff7.net>
Tested-by: Quentin Glidic <sardemff7+git@sardemff7.net>
Tested-by: Benoit Gschwind <gschwind@gnu-log.net>
Acked-by: Benoit Gschwind <gschwind@gnu-log.net>
[Pekka: rebased]
EGL code was added to the fbdev backend in
4aa756dc7a in 2013, apparently for running
Weston on libhybris with Android hardware drivers.
This actually had nothing to do with the fbdev backend, really. Fbdev
was just a convenient platform to plug in the EGL init code and load
GL-renderer. Fbdev itself was not used at all in this case.
Fbdev should be forgotten and die, as we have better interfaces for
accelerated rendering and for controlling displays. It may be a bit too
harsh to remove the whole fbdev backend just yet, but let us at least
simplify it this much.
Fbdev+EGL has been the unholy union used by proprietary driver stacks of
hardware vendors in the non-PC world as a quick and dirty way to get
something out on the screen. In these cases it is actually the EGL
implementation that does everything internally, fbdev is not needed.
Fbdev was never meant for the sort anyway.
If anyone still needs this use case, I recommend sticking with a
outdated Weston to match your outdated platform. Or if you really
insist, write a new backend that does not pretend to use fbdev and just
initializes EGL and GL-renderer.
Cc: Adrian Negreanu <groleo@gmail.com>
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Quentin Glidic <sardemff7+git@sardemff7.net>
Reviewed-by: Derek Foreman <derekf@osg.samsung.com>
Backends do not have access to command line elements nor weston_config
anymore. They use the backend-specific config APIs now.
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Quentin Glidic <sardemff7+git@sardemff7.net>
Reviewed-by: Giulio Camuffo <giuliocamuffo@gmail.com>
Instead add callbacks to the drm and fbdev backends and pass that to
the input backens so that when a new device needs to be configured
that is called and the compositor can configure it.
Signed-off-by: Giulio Camuffo <giuliocamuffo@gmail.com>
Reviewed-by: Quentin Glidic <sardemff7+git@sardemff7.net>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Implement a "well" defined API to configure the fbdev backend.
Following and according to discussion about libweston API
The output transform configuration is moved into weston and added to the
fbdev configuration structure.
Signed-off-by: Benoit Gschwind <gschwind@gnu-log.net>
[Pekka: squashed two patches and rebased.]
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Ensuring that the pointer to the device path stays valid gets harder and
harder with migrating to the libweston-style config handling. Therefore,
make a copy of the string, private to struct fbdev_output.
Now the pointer passed in to fbdev_output_create() could be freed right
after the call returns.
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Quentin Glidic <sardemff7+git@sardemff7.net>
Reviewed-by: Benoit Gschwind <gschwind@gnu-log.net>
Remove the unstable presentation_timing.xml file, and use
presentation-time.xml from wayland-protocols instead to generate all the
Presentation extension bindings.
The following renames are done according to the XML changes:
- generated header includes
- enum constants and macros prefixed with WP_
- interface symbol names prefixed with wp_
- protocol API calls prefixed with wp_
Clients use wp_presentation_interface.name rather than hardcoding the
global interface name: presentation-shm, weston-info, presentation-test.
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Bryce Harrington <bryce@osg.samsung.com>
Reviewed-by: Jonas Ådahl <jadahl@gmail.com>
[Pekka: updated wayland-protocols dependency to 1.2]
Add a new boolean weston.ini option, "vt-switching" to enable or
disable Ctrl-Alt-Fn key combinations.
Signed-off-by: Bob Ham <bob.ham@collabora.com>
Reviewed-by: Derek Foreman <derekf@osg.samsung.com>
(Derek Foreman changed the prototype for switch_vt_binding to
have a weston_keyboard * instead of weston_seat *. The pointer
wasn't used, so this is just a warning fix.)
Currently the fbdev compositor has its own shadow buffer when rendering
with pixman, causing the following copies to occur:
[pixman shadow buffer] -> [fbdev shadow buffer] -> [fbdev hardware]
As the pixman render already does all output translation when
compositing the intermediate shadow buffer really isn't needed, so drop
it.
As a side-effect this fixes updating the fbdev hardware for outputs not
starting at 0x0.
Signed-off-by: Sjoerd Simons <sjoerd.simons@collabora.co.uk>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: David FORT <contact@hardening-consulting.com>
Reviewed-by: Derek Foreman <derekf@osg.samsung.com>
Tested-by: Derek Foreman <derekf@osg.samsung.com>
Add new configuration argument to the backend_init() function, which
will replace the current argc, argv, and config arguments.
After each backend is converted individually the unused parameters
will be removed.
Reviewed-by: Bryce Harrington <bryce@osg.samsung.com>
Really not sure why this was even here - it worked because
we were dividing by 1.
Signed-off-by: Derek Foreman <derekf@osg.samsung.com>
Reviewed-by: Bryce Harrington <bryce@osg.samsung.com>
This bug was introduced in 954f183e2f.
The session_notify() data was accidentally cast to fbdev_backend while
it is weston_compositor. This was possibly due to the code before the
mentioned commit casting data directly to fbdev_compositor without going
through the intended type first, which worked only because
weston_compositor was the first member in struct fbdev_compositor.
Fix the casts to be the right way around.
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=91654
Cc: nerdopolis1@verizon.net
Cc: Giulio Camuffo <giuliocamuffo@gmail.com>
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Derek Foreman <derekf@osg.samsung.com>
Normally we need to check if a seat's [device_type]_count is > 0 before
we can use the associated pointer. However, in a binding you're
guaranteed that the seat has a device of that type. If we pass in
that type instead of the seat, it's obvious we don't have to test it.
The bindings can still get the seat pointer via whatever->seat if they
need it.
This is preparation for a follow up patch that prevents direct access
to seat->device_type pointers, and this will save us a few tests at
that point.
Reviewed-by: Jonas Ådahl <jadahl@gmail.com>
Signed-off-by: Derek Foreman <derekf@osg.samsung.com>
This commit adds three new exported functions:
- weston_compositor_create() returns a new weston_compositor instance,
initializing it as the now removed weston_compositor_init() did.
- weston_compositor_exit(compositor) asks the compositor to tear
down by calling the compositor's exit vfunc which is set by the
libweston application.
- weston_compositor_destroy(compositor) is called by the libweston
application when tearing down the compositor. The compositor is destroyed
and the memory freed.
Reviewed-by: Jon A. Cruz <jonc@osg.samsung.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
This is a preliminary change for libweston, with no functional modifications.
Separate the backends and the core weston_compositor struct, by creating
the weston_compositor in the main(), and having the various backends extend
the weston_backend struct, an instance of which is returned by the backend
entry point.
This enable us to logically separate the compositor core from the backend,
allowing the core to be extended without messing with the backends.
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
To help reduce code duplication and also 'kitchen-sink' includes
the ARRAY_LENGTH macro was moved to a stand-alone file and
referenced from the sources consuming it. Other macros will be
added in subsequent passes.
Signed-off-by: Jon A. Cruz <jonc@osg.samsung.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Bryce Harrington <bryce@osg.samsung.com>
Currently we pass either a single format or no formats to the gl renderer
create and output_create functions. We extend this to any number of
formats so we can allow fallback formats if we don't get our first pick.
Reviewed-By: Bryce Harrington <bryce@osg.samsung.com>
Reviewed-By: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Signed-off-by: Derek Foreman <derekf@osg.samsung.com>
The compositor's output_created signal used to be sent in weston_output_init()
which the backend call before putting the output in the output_list.
This caused problems when creating a new view in a listener to that signal,
because weston_view_assign_output() doesn't yet know the new output exists.
To fix this add a new weston_composito_add_output() func which adds the
output in the list and later sends the signal, and make the backends call
that.
This means compositors don't need to call supports() manually and
create() will just return -1 in the failure case as before. This also
means we can deal with the case of eglGetProcAddress returning
non-NULL but not actually being available at runtime.
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Create a new function weston_compositor_read_presentation_clock() to
wrap the clock_gettime() call for the Presentation clock.
Reading the presentation clock is never supposed to fail, but if it
does, this will notify about it. I have not seen it fail yet, though.
This prepares for new testing features in the future that might allow
controlling the presentation clock. Right now it is just a convenience
function for clock_gettime().
All presentation clock readers are converted to call this new function
except rpi-backend's rpi_flippipe_update_complete(), because it gets its
clock id via a thread-safe mechanism. There shouldn't be anything really
thread-unsafe in weston_compositor_read_presentation_clock() at the
moment, but might be in the future, and weston core is not expected to
need to be thread-safe.
This is based on the original patch by
Cc: Derek Foreman <derekf@osg.samsung.com>
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-By: Derek Foreman <derekf@osg.samsung.com>
Reviewed-by: Bryce Harrington <bryce@osg.samsung.com>
The pixman-renderer is already performing transformations when compositing
into the shadow buffer, we just need to get the damage co-ordinates right
when copying from shadow to front.
Signed-off-by: Derek Foreman <derekf@osg.samsung.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Tested-by: Thilo Cestonaro <thilo@cestona.ro>
If you have devices configured in seats with udev then the output names
are tested with string compare. This fixes a potential crash on startup and
device insertion.
Signed-off-by: Derek Foreman <derekf@osg.samsung.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
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>
Logind sends us a notification whenever the Active attribute of our session
changes. However, due to the way compositor-drm.c relies on the master DRM
device to be synced with the session, we used to delay Active=true
handling until the DRM device was up, too. See:
commit aedc7732eb
Author: David Herrmann <dh.herrmann@gmail.com>
Date: Sat Nov 30 11:25:45 2013 +0100
logind: delay wakeup until DRM-device is resumed
However, the other compositor backends do not use DRM, so logind-util will
never get notified about any DRM device. Therefore, we have to forward the
Active=true change immediately.
This commit fixes logind-util to take sync_drm as argument. If it is true,
we do DRM-device synchronisation, otherwise we don't.
Fixes: https://bugs.freedesktop.org/show_bug.cgi?id=86889
Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
Reviewed-by: Bryce Harrington <bryce@osg.samsung.com>
Tested-by: nerdopolis <bluescreen_avenger@verizon.net>
calloc (and zalloc) set the allocated memory to 0, so there's really no
need to do it manually.
Signed-off-by: Bryce Harrington <bryce@osg.samsung.com>
Reviewed-by: Marek Chalupa <mchqwerty@gmail.com>
[Pekka: dropped the src/evdev.c hunk.]
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Add presentation clock setters that verify the given clock actually
works. Offer an automatic choice of a software fallback clock, when a
backend has to always use clock_gettime() to approximate the
presentation time.
The DRM backend already queried the DRM about the clock id, just let the
DRM backend set the presentation clock from that.
For all other backends which do not get a timestamp from the driver,
call the software clock setter to choose a suitable clock.
Report the chosen clock via presentation.clock_id event to clients.
In finish_frame(), upgrade the argument from uint32_t milliseconds to
struct timespec which can accurately hold the presentation clock values.
This will be needed when weston_output_finish_frame() starts to send out
presentation_feedback.presented events.
While at it, replace gettimeofday() calls with clock_gettime() using the
chosen presentation clock, so we manufacture presentation timestamps
from the presentation clock when the gfx drivers cannot give us a proper
timestamp.
Rpi patch is more verbose due to not having the compositor pointer
available in rpi_flippipe_update_complete(). Explicitly carry the clock
id with flippipe so it is available in the thread.
Changes in v4:
* rpi debug build fix
v4 Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
v3 Reviewed-by: Mario Kleiner <mario.kleiner.de@gmail.com>
While disable by default, passing --enable-libinput-backend to
./configure switches the input backend in weston's drm, fbdev and rpi
compositing backends to use libinput instead of udev-seat.c, evdev.c and
friends.
When enabled, weston now also depends on libinput >= 0.1.0.
Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
The gbm-format configuration option can now be specified per-output as
well as in the core config section. If it is not specified it will
default to the format specified in the core section. The
EGL_MESA_configless_context extension is required for this to work. If
this extension is available it will create a context without an
EGLConfig and then it will potentially use a different EGLConfig for
each output.
The gl-renderer interface has been changed so that it takes the EGL
attributes and visual ID in the create_output function as well as in
the create function.
Currently we destroy the renderer before the outputs are destroyed, but
that sometimes leads to an error since a reference to the renderer is
necessary in order to destroy a gl_renderer_output.
Since destroying the renderer is common among all backends, just move
that call into weston_compositor_shutdown() immediately after the
outputs being destroyed.
When destroying ouputs, they would sometimes be removed before the call
to weston_output_destory() and sometimes after, depending on the
backend. Now the output is remove withing that function so the behavior
is standard across all backends.
Also make sure backends destroy the renderers before shutting down the
compositor to avoid a double call to weston_binding_destroy().
This is a step towards making renderers switchable during runtime.