Commit graph

316 commits

Author SHA1 Message Date
Alexandros Frantzis 10d708d268 shared: Add timespec_to_proto helper function
Add helper function to convert from struct timespec values to tv_sec_hi,
tv_sec_lo, tv_nsec triplets used for sending high-resolution timestamp
data over the wayland protocol. Replace existing conversion code with
the helper function.

Signed-off-by: Alexandros Frantzis <alexandros.frantzis@collabora.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
2017-12-18 11:27:43 +02:00
Emil Velikov fbf165f5e8 libweston: drop return type from ::query_dmabuf_{formats, modifiers}
Nobody checks for the bool returned by these functions. At the same
time: a) the functions set the respective num_foo to zero on error and
b) callers honour that variable.

Just drop the return type - it's useless.

Note: this is an ABI break.

Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
2017-12-11 09:36:18 +00:00
Arnaud Vrac 340d25b76f gl-renderer: use correct pixel shader for NV12 format uploaded to RG texture
Signed-off-by: Arnaud Vrac <rawoul@gmail.com>
Fixes: 00a03d2f72 ("gl-renderer: add support of WL_SHM_FORMAT_NV12")
Reviewed-by: Daniel Stone <daniels@collabora.com>
2017-12-11 09:34:26 +00:00
Arnaud Vrac 49a8d9997b gl-renderer: fix pixel format used in texture uploads when using R/RG textures
In glTexImage2D / glTexSubImage2D calls, the only pixel formats allowed
for the GL_R8 and GL_RG internal formats are respectively GL_RED and
GL_RG [1].

Make sure we match this requirement, as some drivers will fail with the
current code.

[1] https://www.khronos.org/registry/OpenGL-Refpages/es3.0/html/glTexImage2D.xhtml, Table 2

Signed-off-by: Arnaud Vrac <rawoul@gmail.com>
Fixes: 00a03d2f72 ("gl-renderer: add support of WL_SHM_FORMAT_NV12")
Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
2017-12-11 09:34:26 +00:00
Quentin Glidic 85d55540cb input: Do not override keyboard focus on restore
If we start a special (grabbing) client when Weston is unfocused, it
would lose focus when coming back to Weston.

Signed-off-by: Quentin Glidic <sardemff7+git@sardemff7.net>
Reviewed-by: Daniel Stone <daniels@collabora.com>
2017-12-04 21:07:38 +00:00
Armin Krezović b9906aaead compositor-x11: Implement mode switching
Signed-off-by: Armin Krezović <krezovic.armin@gmail.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
2017-12-04 20:51:08 +00:00
Sergei Trofimovich 43c5a65b03 configure.ac: use AC_HEADER_MAJOR to detect major()/minor()
This change slightly updates c4d7f66c12
which added <sys/sysmacros.h> inclusion.

Autoconf has AC_HEADER_MAJOR to find out which header defines
reqiured macros:
    https://www.gnu.org/software/autoconf/manual/autoconf-2.69/html_node/Particular-Headers.html

This change should increase portability across other libcs.

Bug: https://bugs.gentoo.org/610652
Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>
Reviewed-by: Daniel Stone <daniels@collabora.com>
2017-12-04 19:38:14 +00:00
Emil Velikov bcfe397df2 gl-renderer: remove unneeded cast
The variable num is of EGLint type.

Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
2017-12-04 19:13:29 +00:00
Matt Hoosier df573031d0 compositor-drm: fix z-order inversion in plane assignment
As discussed in the following thread:

https://lists.freedesktop.org/archives/wayland-devel/2017-August/034755.html

the existing plane assignment in the DRM backend is vulnerable to
accidental masking of the intended fullscreen surface. This change
adds a simple stateful memory to the plane assignment algorithm
to prevent that.

Reviewed-by: Daniel Stone <daniels@collabora.com>
2017-12-04 19:11:46 +00:00
Daniel Stone b040974398 gl-renderer: Set pitch correctly for subsampled textures
zwp_linux_dmabuf_v1 allows clients to pass an explicit pitch for each
plane, but wl_shm only takes a single pitch parameter; the pitch for
secondary planes must be inferred.

Multi-plane sub-sampled textures have partial width/height, e.g.
YUV420/I420 has a full-size Y plane, followed by a half-width/height U
plane, and a half-width/height V plane.

GStreamer's waylandsink - the only user of wl_shm YUV formats - expects
the implementation to follow the example of Xv and implicitly divide the
pitch for secondary planes by the subsampling factor. gl-renderer was
not doing this, and instead just using the (larger) stride provided by
the client for all planes in the buffer.

Fix gl-renderer to divide pitch by the subsampling factor when uploading
from subsampled SHM buffers into GL textures, also dividing co-ordinates
when doing offset partial uploads.

Tested with:
  $ gst-launch-1.0 videotestsrc ! waylandsink

Signed-off-by: Daniel Stone <daniels@collabora.com>
Reported-by: Fabien Lahoudere <fabien.lahoudere@collabora.co.uk>
Tested-by: Fabien Lahoudere <fabien.lahoudere@collabora.co.uk>
Reviewed-by: Arnaud Vrac <avrac@freebox.fr>
Acked-by: Vincent ABRIOU <vincent.abriou@st.com>
Acked-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>
Acked-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Fixes: fdeefe4241 ("gl-renderer: add support of WL_SHM_FORMAT_YUV420")
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=103063
2017-12-01 16:36:38 +00:00
Pekka Paalanen a453f4d564 compositor-drm, compositor-fbdev: stop suggesting root
Stop suggesting to run Weston as root, it is only meant for debugging.
Instead, mention the two supported ways to run Weston on DRM and fbdev:
weston-launch helper and logind service.

Cc: "Ucan, Emre (ADITG/ESB)" <eucan@de.adit-jv.com>
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Quentin Glidic <sardemff7+git@sardemff7.net>
[Pekka: added forgotten "using" word.]
2017-11-28 10:24:12 +02:00
Pekka Paalanen 1a2adfedea weston-launch: improve help text for -u and -t
Explain that -u requires root and -t requires -u. Most importantly,
document in what format does -t expect the tty to be given.

It has been confusing, because Weston's --tty option takes an integer,
weston-launch takes a full device path.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Acked-by: Daniel Stone <daniels@collabora.com>
Reviewed-by: Quentin Glidic <sardemff7+git@sardemff7.net>
2017-11-28 09:18:08 +02:00
Pekka Paalanen 625f56f062 weston-launch: fix -t option parsing
Fix an issue introduced in:

 commit ab4999492c
 Author: Kristian Høgsberg <krh@bitplanet.net>
 Date:   Fri Jul 19 21:26:24 2013 -0700

     weston-launch: Drop sleep_fork option

where the option string accidentally became "t::". That causes

	$ weston-lauch -t /dev/tty4

to be parsed incorrectly, as if -t option had no argument and the tty
path gets passed to weston which errors out because of it.

This patch fixes the above to work as expected.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Acked-by: Daniel Stone <daniels@collabora.com>
Reviewed-by: Quentin Glidic <sardemff7+git@sardemff7.net>
2017-11-28 09:17:49 +02:00
Pekka Paalanen 5949e48d1d weston-launch: quit if -t without -u
setup_tty() function uses the tty argument for choosing the tty/VT only
if wl->new_user (the -u option) is given. If the tty option is given
without -u, it will only be used for misleading error messages.

To make it clear to the user that -t without -u does not work the way
one might think, let weston-launch exit with an error in that case.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Acked-by: Daniel Stone <daniels@collabora.com>
Reviewed-by: Quentin Glidic <sardemff7+git@sardemff7.net>
2017-11-28 09:17:35 +02:00
Alexandros Frantzis 409b01fd6d libweston: Use struct timespec for compositor time
Change weston_compositor_get_time to return the current compositor time
as a struct timespec. Also, use clock_gettime (with CLOCK_REALTIME) to
get the time, since it's equivalent to the currently used gettimeofday
call, but returns the data directly in a struct timespec.

This commit is part of a larger effort to transition the Weston codebase
to struct timespec.

Signed-off-by: Alexandros Frantzis <alexandros.frantzis@collabora.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
2017-11-27 11:42:07 +02:00
Alexandros Frantzis 7d2abcf6c8 libweston: Use struct timespec for touch motion events
Change code related to touch motion events to use struct timespec to
represent time.

This commit is part of a larger effort to transition the Weston codebase
to struct timespec.

Signed-off-by: Alexandros Frantzis <alexandros.frantzis@collabora.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
2017-11-27 11:42:07 +02:00
Alexandros Frantzis 27a51b83e5 libweston: Use struct timespec for touch up events
Change code related to touch up events to use struct timespec to represent
time.

This commit is part of a larger effort to transition the Weston codebase
to struct timespec.

Signed-off-by: Alexandros Frantzis <alexandros.frantzis@collabora.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
2017-11-27 11:42:07 +02:00
Alexandros Frantzis 9448deb073 libweston: Use struct timespec for touch down events
Change code related to touch down events to use struct timespec to
represent time.

This commit is part of a larger effort to transition the Weston codebase
to struct timespec.

Signed-off-by: Alexandros Frantzis <alexandros.frantzis@collabora.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
2017-11-27 11:42:07 +02:00
Alexandros Frantzis 47e79c860b libweston: Use struct timespec for key events
Change code related to key events to use struct timespec to represent
time.

This commit is part of a larger effort to transition the Weston codebase
to struct timespec.

Signed-off-by: Alexandros Frantzis <alexandros.frantzis@collabora.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
2017-11-27 11:42:07 +02:00
Alexandros Frantzis 80321942e7 libweston: Use struct timespec for axis events
Change code related to axis events to use struct timespec to represent
time.

This commit is part of a larger effort to transition the Weston codebase
to struct timespec.

Signed-off-by: Alexandros Frantzis <alexandros.frantzis@collabora.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
2017-11-27 11:42:07 +02:00
Alexandros Frantzis 215bedc88b libweston: Use struct timespec for button events
Change code related to button events to use struct timespec to represent
time.

This commit is part of a larger effort to transition the Weston codebase
to struct timespec.

Signed-off-by: Alexandros Frantzis <alexandros.frantzis@collabora.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
2017-11-27 11:42:07 +02:00
Alexandros Frantzis 84b31f8956 libweston: Use struct timespec for motion events
Change code related to motion events to use struct timespec to represent
time.

This commit is part of a larger effort to transition the Weston codebase
to struct timespec.

Signed-off-by: Alexandros Frantzis <alexandros.frantzis@collabora.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
2017-11-27 11:42:07 +02:00
Alexandros Frantzis e6ac2afa56 libweston: Use struct timespec for the output presentation timestamp
Store the output presentation timestamp as struct timespec.

This commit is part of a larger effort to transition the Weston codebase
to struct timespec.

Signed-off-by: Alexandros Frantzis <alexandros.frantzis@collabora.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
2017-11-27 11:42:07 +02:00
Alexandros Frantzis 8250a61de1 build,libweston: Use struct timespec for animations
Change code related to animations to use struct timespec to represent
time.

This commit is part of a larger effort to transition the Weston codebase
to struct timespec.

Signed-off-by: Alexandros Frantzis <alexandros.frantzis@collabora.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>

This bumps the libweston major version due to breakage in the animation
ABI. The commits following this one break more ABI in other parts.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
2017-11-27 11:41:17 +02:00
Reynaldo H. Verdejo Pinochet 71c4f70e08 buildsystem: add missing pkg-config stub for libweston uninstalled
-uninstalled.pc files are a pkg-config facility for working with
uninstalled libraries.

With pkg-config, foo-uninstalled.pc overrides foo.pc. foo-uninstalled.pc
should never be installed, and will be generated with references to the
build directory.

If you set up your environment so pkg-config looks for .pc files in your
build directories, you can use this to build and link against libraries
you haven't installed with "make install".

This can save time and space over installing with a prefix.

Signed-off-by: Reynaldo H. Verdejo Pinochet <reynaldo@osg.samsung.com>
Acked-by: Bryce Harrington <bryce@osg.samsung.com>
Reviewed-by: Derek Foreman <derekf@osg.samsung.com>
2017-11-10 12:50:41 -06:00
Pekka Paalanen 323d4b37a0 compositor-wayland: fix shm_buffer damage init
It appears that wayland_shm_buffer::damage is in the global coordinate
space. Therefore initializing it to width x height at 0,0 is not correct
for any output not positioned at 0,0. That is, all outputs after the
first one get it wrong.

Initialize it from the output region, which is in the global coordinate
space.

While at it, add a comment to note that damage is in global coordinate
space. As I can see, this was the last confusion about it.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Quentin Glidic <sardemff7+git@sardemff7.net>
Acked-by: Daniel Stone <daniels@collabora.com>
2017-10-24 12:51:35 +03:00
Armin Krezović 2b3c97d560 compositor-wayland: fix damage coordinates with pixman renderer
Damage coordinates are in global coordinate space, and they need to
be translated to local coordinate space so multiple outputs can work.

This path now matches the similar path in the X11 backend.

This patch fixes the appearance of multiple windows in the parent
compositor. Previously, all windows except the one with nested output
position 0,0 would have their damage for the parent wl_surface always
fall outside of the wl_surface, save the decorations which were handled
separately. If the parent compositor was Weston/GL, this would lead to
the output area remaining black as partial GL texture uploads would
practically never update the texture. If the parent compositor was
Weston/pixman, the parent windows would not update on screen unless
something else caused the area to be repainted.

[Pekka: adjusted commit message]
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Quentin Glidic <sardemff7+git@sardemff7.net>
Acked-by: Daniel Stone <daniels@collabora.com>
2017-10-24 12:51:35 +03:00
Pekka Paalanen 99c92e7e52 compositor-wayland: clarify wl_display_connect() error
Clarify the error message to explicitly say one was trying to connect to
a parent Wayland compositor. This hopefully is a good enough hint on
what using the wayland-backend is trying to do.

Add the command line display option value and WAYLAND_DISPLAY values for
good measure. WAYLAND_SOCKET is not shown as libwayland-client removes
it.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Quentin Glidic <sardemff7+git@sardemff7.net>
Acked-by: Daniel Stone <daniels@collabora.com>
2017-10-24 12:51:35 +03:00
Pekka Paalanen 441954325e compositor-wayland: windowed/fullscreen not on fullscreen-shell
The set_windowed and set_fullscreen functions are only useful on a
desktop shell, and never called on fullscreen-shell.

Remove the confusing dead code, and ensure we notice if these functions
get called in the wrong environment.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Quentin Glidic <sardemff7+git@sardemff7.net>
Acked-by: Daniel Stone <daniels@collabora.com>
2017-10-24 12:51:35 +03:00
Pekka Paalanen 7d2fc9291b compositor-wayland: allow to unset fullscreen
To be more symmetric with wayland_output_set_fullscreen(), implement the
xdg-shell path in wayland_output_set_windowed(). This should make it
possible to use the fullscreen key binding to toggle between a floating
window and fullscreen also under xdg-shell.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Quentin Glidic <sardemff7+git@sardemff7.net>
Acked-by: Daniel Stone <daniels@collabora.com>
2017-10-24 12:51:35 +03:00
Pekka Paalanen f132279455 compositor-wayland: actually free parent_output
I could not find anywhere where struct parent_output was freed, so
apparently we were leaking it.

Check against wayland_backend_register_output() and add the missing
clean-up: removal from the parent output list, and free().

registry_handle_global_remove() also needs fixing to use a safer loop,
because now we are actually removing the list item.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Quentin Glidic <sardemff7+git@sardemff7.net>
Acked-by: Daniel Stone <daniels@collabora.com>
2017-10-24 12:50:17 +03:00
Pekka Paalanen 4dab58343b compositor-wayland: fix mode_list corruption on --sprawl
The wayland-backend with --sprawl is one way to trigger
wayland_output_create_for_parent_output(), which intends to find a mode
from the parent mode list and use it. Calling wayland_output_set_size()
initialized an embedded struct weston_mode and inserts that into the
mode list. Then the assignment output->mode = *mode; corrupts the
mode_list by overwriting the link entry. This leads to an endless loop
in bind_output() in compositor.c.

Fix this by manually doing the setup that wayland_output_set_size() did
and do not call it.

As a side effect, it now relays the parent compositor's physical output
size to our own clients. It no longer smashes the refresh rate either.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Quentin Glidic <sardemff7+git@sardemff7.net>
Acked-by: Daniel Stone <daniels@collabora.com>
2017-10-23 10:29:42 +03:00
Pekka Paalanen afee695adc compositor-wayland: remove unused 'scale'
This member is only ever set and never read, therefore it is dead.

Delete dead code.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Quentin Glidic <sardemff7+git@sardemff7.net>
Acked-by: Daniel Stone <daniels@collabora.com>
2017-10-23 10:29:42 +03:00
Pekka Paalanen b07de934cc compositor-wayland: avoid recursive dispatch with wl_outputs
Calling wl_display_roundtrip() from within a Wayland event handler means
we will re-enter event dispatch, that is, it will lead to recursive
dispatch. Even if libwayland-client was safe, this would lead to
unexpected code paths: the first event handler function has not returned
when other event handler functions may get called. In this particular
case it maybe didn't hurt, but it's still a fragile pattern to use.

Replace the wl_display_roundtrip() with a manual sync callback to do the
work.

This does not break the wayland-backend initialization sequence, because
sprawl_across_outputs was set only after the roundtrip to ensure
wl_registry globals have been received so the code would not have been
hit anyway, and weston_backend_init() also has a second roundtrip that
ensures the per wl_output events have been received before continuing.

For wayland-backend output hotplug the change is insignificant because
it will only delay the output creation a bit, and the parent outputs are
not processed anywhere in between.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Quentin Glidic <sardemff7+git@sardemff7.net>
Acked-by: Daniel Stone <daniels@collabora.com>
2017-10-23 10:29:42 +03:00
Armin Krezović 71ebc05250 compositor-wayland: Don't use two different presentation methods for fs shell
This patch fixes the wayland backend to not use two different
presentation methods when running on fullscreen-shell.

See also: https://patchwork.freedesktop.org/patch/114534/

v2:

 - Add missing wayland_output_resize_surface() call
 - Start repaint loop after initial frame has been drawn

v3:

 - Redraw the initial frame if present for mode fails

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=93514
Signed-off-by: Armin Krezović <krezovic.armin@gmail.com>
Tested-by: nerdopolis <bluescreen_avenger@verizon.net>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
2017-10-13 15:22:54 +03:00
Sergi Granell b4e239f29f compositor-wayland: destroy the appropriate output instead of exiting when receiving an xdg_toplevel::close event
v2: Fix use after free spotted by Daniel Stone

Signed-off-by: Sergi Granell <xerpi.g.12@gmail.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
2017-10-13 14:12:38 +03:00
Sergi Granell cafc652cf6 compositor-wayland: use input region instead of opaque region to zxdg_shell_v6::set_window_geometry
The opaque region is a few pixels off due to the rounded corners
of the frame decorations, and, therefore, the input region
matches the window's geometry more closely.

Signed-off-by: Sergi Granell <xerpi.g.12@gmail.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
2017-10-13 13:56:48 +03:00
Daniel Stone be1090b523 compositor-drm: Allow disabling universal planes
Add a test environment variable to allow disabling universal planes.

Signed-off-by: Daniel Stone <daniels@collabora.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
2017-10-04 18:36:06 +01:00
Daniel Stone b138d7afb3 gl-renderer: Ignore INVALID modifier
If the user has passed an INVALID modifier, it's because there is no
applicable modifier, and the buffer layout should be determined by a
magic side-channel call (e.g. bo_get_tiling). If the modifier is
INVALID, don't try to pass it through to EGL, but just drop it.

On the other hand, if a modifier _is_ explicitly specified and we don't
have the modifiers extension, then refuse to import the buffer.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2017-10-04 18:36:06 +01:00
Pekka Paalanen cbe7fb0bb5 compositor-fbdev: fix finish_frame_timer leak
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>
2017-10-04 16:18:06 +03:00
Pekka Paalanen 82ffe79b18 compositor-fbdev: rename fbdev_output_disable_handler()
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>
2017-10-04 16:18:06 +03:00
Pekka Paalanen 61e5a2727a compositor-fbdev: always destroy renderer-output on disable
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>
2017-10-04 16:18:06 +03:00
Pekka Paalanen a51e71fbf0 compositor-fbdev: simplify FB destroy/unmap/disable
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>
2017-10-04 16:18:06 +03:00
Pekka Paalanen 82db6b79a3 compositor-fbdev: remove unused output arguments
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>
2017-10-04 16:18:06 +03:00
Pekka Paalanen 7da9a3802f libweston: set backend pointer earlier
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>
2017-10-04 16:18:06 +03:00
Pekka Paalanen d7e351189e libweston: ensure backend is not loaded twice
Check and ensure that a compositor can only load one backend
successfully. If a backend fails to load, it is theoretically possible
to try another backend. Once loading succeeds, only destroying the
compositor would allow "unloading" a backend.

If backend init fail, ensure the backend pointer remains NULL to avoid
calling into a half-loaded backend on e.g. compositor destruction.

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>
2017-10-04 16:18:06 +03:00
Pekka Paalanen ae6d35db14 libweston: rename weston_output_destroy() to weston_output_release()
'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>
2017-10-04 16:18:06 +03:00
Pekka Paalanen 01e0068868 libweston: send more wl_surface.enter/leave events
A client may have bound the same wl_output multiple times, for who knows
what reason. As the server cannot know which wl_output resource to use
for which wl_surface, send enter/leave events for all of them.

This is a protocol correctness fix.

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>
2017-10-04 16:18:06 +03:00
Pekka Paalanen a0bfedc1cf compositor-drm: set all properties in create_output_for_connector
Move the remaining scattered setup of the fixed properties into
create_output_for_connector(). All these are already known and they
cannot change.

This helps future refactoring.

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>
2017-10-04 16:18:06 +03:00
Pekka Paalanen 6f1866b3fa compositor-drm: set output make/model/serial once
This fixes a regression where monitor make and model would always be
advertised as "unknown" to Wayland clients. The EDID strings were parsed
at create_output_for_connector() time, but the fallback "unknown" values
were set in weston_drm_output_api::set_mode vfunc later. This made the
correct monitor info be shown in the log, but not sent to clients.

The purpose of the "unknown" assignments is to give fallback values in
case EDID is not providing them.

Fix all that by moving all setting of the make, model and serial into
create_output_for_connector(). These values cannot change afterwards
anyway. While at it, document find_and_parse_output_edid().

The ugly casts in create_output_for_connector() are required to silence
compositor warnings from ignoring const attribute. This is temporary,
and a future refactoring will get rid of the casts.

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>
2017-10-04 16:18:06 +03:00