The timer was never removed anywhere. Remove it in disable() to match
what happens in enable().
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>
This is a more logical name for the function, matching the pattern used
in other backends and the hook names.
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>
If we pass the base->enabled test, then the renderer output is
guaranteed to be there, so we can just destroy it.
Destroying it before unmap makes the sequence match better the enable
path.
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>
Rename fbdev_frame_buffer_destroy() to fbdev_frame_buffer_unmap()
because that is what it does. Adding the destruction of hw_surface in it
makes it the perfect counterpart to fbdev_frame_buffer_map() which
simplifies the code.
fbdev_frame_buffer_map() can no longer call that, so just open-code the
munmap() there. It is an error path, we don't really care about
failures in an error path.
The error path of fbdev_output_enable() is converted to call
buffer_unmap() since that is exactly what it did.
fbdev_output_disable() became redundant, being identical to
fbdev_frame_buffer_unmap().
Invariant: output->hw_surface cannot be non-NULL without output->fb
being non-NULL. hw_surface wraps the mmapped memory so cannot exist
without the mmap.
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>
A few functions had argument 'output' which was not used at all. Remove
such unused arguments.
The coming migration to the head-based output API would have made it
awkward to come up with the output argument for these, but luckily they
are not actually needed.
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Sergi Granell <xerpi.g.12@gmail.com>
Acked-by Daniel Stone <daniels@collabora.com>
Change all backends to set the core backend pointer early.
This is necessary for libweston core to be able to access the backend
vfuncs before the backend init function returns. Particularly,
weston_output_init() will be needing to inspect the backend vfuncs to
see if the backend has been converted to a new API. Backends that create
outputs as part of their init would fail without setting the pointer
earlier.
For consistency, all backends are modified instead of just those that
could hit an issue.
Libweston core will take care of resetting the backend pointer to NULL
in case of error since "libweston: ensure backend is not loaded twice".
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>
'release' is a more appropriate name because the function does not free
the underlying memory. The main reason for this is that we need the name
weston_output_destroy() for new API that actually will free also the
underlying memory.
Since the function is only used in backends and external backends are
not a thing, this does not cause libweston major version bump, even
though it does change the ABI. There is no way external users could have
successfully used this function.
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>
Add 'name' argument to weston_output_init(). This is much more obvious
than the assert inside weston_output_init() to ensure the caller has set
a field in weston_output first.
Now weston_output_init() will strdup() the name itself, which means we
can drop a whole bunch of strdup()s in the backends. This matches
weston_output_destroy() which was already calling free() on the name.
All backends are slightly reordered to call weston_output_init() before
accessing any fields of weston_output, except the Wayland backend which
would make it a little awkward to do it in this patch. Mind, that
weston_output_init() still does not reset the struct to zero - it is
presumed the caller has done it, since weston_output is embedded in the
backend output structs.
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Ian Ray <ian.ray@ge.com>
Reviewed-by: David Fort <contact@hardening-consulting.com>
[Daniel: document name copying]
Acked-by Daniel Stone <daniels@collabora.com>
Initialize the list in weston_output_init() instead of doing it
separately in each backend.
One would expect weston_output_init() to initialize all weston_output
members, at least those that are not NULL.
We rely on the set_size() functions to be called only once, as is
assert()'d. If set_size() becomes callable multiple times, this patch
will force them to be fixed to properly manage the mode list instead of
losing all members.
compositor-wayland.c is strange in
wayland_output_create_for_parent_output(): it first called
wayland_output_set_size() that initialized the mode list with a single
mode manufactured from width and height and set that mode as current.
Then it continued to reset the mode list and adding the list of modes
from the parent output, leaving the current mode left to point to a mode
struct that is no longer in the mode list and with a broken 'link'
element. This patch changes things such that the manufactured mode is
left in the list, and the parent mode list is added. This is probably
not quite right either.
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Emre Ucan <eucan@de.adit-jv.com>
Reviewed-by: Ian Ray <ian.ray@ge.com>
Acked-by Daniel Stone <daniels@collabora.com>
Not referenced anywhere ever, has been there since the introduction of
fbdev-backend.
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Ian Ray <ian.ray@ge.com>
Fix the assumption that MAP_FAILED would be equal to NULL. It is not.
Set 'fb' explicitly to NULL on mmap failure so that comparisons to NULL
would produce the expected result.
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Daniel Stone <daniels@collabora.com>
Fixes the failure to start with fbdev-backend:
weston: /home/pq/git/weston/libweston/compositor.c:4733: weston_compositor_add_pending_output: Assertion `output->disable' failed.
The disable hook was completely unimplemented, and the regression was
caused by e952a01c3b
"libweston: move asserts to add_pending_output()".
It used to work because Weston never tried to explicitly disable the
fbdev output, but now it is hitting the assert.
Fix it by tentatively implementing a disable hook. It has not been
tested to work for explicit disabling, but it does solve the regression.
Fixes: https://bugs.freedesktop.org/show_bug.cgi?id=102208
Cc: bluescreen_avenger@verizon.net
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Armin Krezović <krezovic.armin@gmail.com>
Tested-by: n3rdopolis <bluescreen_avenger@verizon.net>
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>