platform/upstream/weston.git
6 years agocompositor-drm: Relax plane restrictions for atomic
Daniel Stone [Fri, 9 Dec 2016 18:23:22 +0000 (18:23 +0000)]
compositor-drm: Relax plane restrictions for atomic

Since we now incrementally test atomic state as we build it, we can
loosen restrictions on what we can do with planes, and let the kernel
tell us whether or not it's OK.

Signed-off-by: Daniel Stone <daniels@collabora.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
6 years agocompositor-drm: Allow scanout plane to be occluded by overlay
Daniel Stone [Wed, 11 Jul 2018 12:03:31 +0000 (13:03 +0100)]
compositor-drm: Allow scanout plane to be occluded by overlay

a0f8276fe814 ("compositor-drm: Disallow overlapping overlay planes") was
a little too pessimistic in rejecting occluded views. Whilst it
correctly prevented overlay planes from occluding each other, it also
prevented overlay planes from occluding the scanout plane.

This is undesirable: the primary/scanout plane is specified to stack
strictly below all overlay planes, so there is no need to reject a plane
from consideration for scanout due to being occluded by an overlay
plane.

Shift the check downwards so it only applies to overlay rather than
scanout planes.

Signed-off-by: Daniel Stone <daniels@collabora.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
6 years agocompositor-drm: Incrementally test plane states in mixed mode
Daniel Stone [Tue, 10 Jul 2018 17:40:12 +0000 (18:40 +0100)]
compositor-drm: Incrementally test plane states in mixed mode

In the plane-only mode, we try to place every view on a hardware plane,
and fail if we can't do this. This requires a full walk of the scene
graph to come up with a complete configuration in order to be able to
test.

In mixed mode, we know at least some visible views will fail to be
promoted to planes and must be composited via the renderer. In order to
still use some planes where possible, we use atomic modesetting's
test-only mode to incrementally test configurations.

We know that the renderer output will always be visible, and because it
is the renderer, that it will be occupying the scanout plane underneath
everything else. The actual renderer buffer doesn't materialise until
after assign_planes, because it cannot know what to render until then.

However, in order to test whether a configuration is valid, we need the
renderer buffer in the scanout plane. For testing, we fake this by
temporarily stealing the old buffer - if it seems sufficiently
compatible - and placing it in the state we construct. This is used to
test whether or not a renderer buffer will work with the addition of
overlay planes.

Doing this incremental testing will allow us to enable plane usage for
atomic by default, since we know ahead of time that our chosen plane
configuration will work.

Signed-off-by: Daniel Stone <daniels@collabora.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
6 years agocompositor-drm: Add planes-only mode to state proposal
Daniel Stone [Tue, 10 Jul 2018 17:19:37 +0000 (18:19 +0100)]
compositor-drm: Add planes-only mode to state proposal

Add a new mode, which attempts to construct a scene exclusively using
planes. This is a building block for incrementally testing and
constructing state: in the plane-only mode, we test the state exactly
once, when we have constructed a full set of planes and want to know if
it works or not.

When using the renderer, we need to incrementally test views one by one
to see if they will work on planes, falling back to the renderer if not.
This test is different, since the scanout plane will be occupied by the
renderer's buffer. Testing using the renderer or client buffers may have
completely different characteristics, so we need two passes: first,
constructing a state with only planes and testing if that succeeds,
falling back later to a mixed renderer/plane mode which tests
incrementally.

This implements the first mode, and preferentially attempts to use it.

Signed-off-by: Daniel Stone <daniels@collabora.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
6 years agocompositor-drm: Never lift solid surfaces to planes
Daniel Stone [Tue, 10 Jul 2018 17:08:12 +0000 (18:08 +0100)]
compositor-drm: Never lift solid surfaces to planes

This will never work, so don't even try to do it.

Signed-off-by: Daniel Stone <daniels@collabora.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
6 years agocompositor-drm: Add test-only mode to state application
Daniel Stone [Thu, 8 Dec 2016 17:27:17 +0000 (17:27 +0000)]
compositor-drm: Add test-only mode to state application

The atomic API can allow us to test state before we apply it, to see if
it will be valid. Use this when we construct a plane configuration, to
see if it has a chance of ever working. If not, we can fail
assign_planes early.

This will be used in later patches to incrementally build state by
proposing and testing potential configurations one at a time.

Signed-off-by: Daniel Stone <daniels@collabora.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
6 years agocompositor-drm: Return plane state from plane preparation
Daniel Stone [Fri, 9 Dec 2016 17:32:10 +0000 (17:32 +0000)]
compositor-drm: Return plane state from plane preparation

Return a pointer to the plane state, rather than returning its
underlying weston_plane. This eliminates any ambiguity between placing
client buffers on planes, and placing them through the renderer.

drm_output_propose_state is only concerned with preparing, testing, and
returning DRM state objects. Assigning views to weston_planes only
happens later, inside drm_assign_planes. This makes that split more
clear.

Signed-off-by: Daniel Stone <daniels@collabora.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
6 years agocompositor-drm: Add modes to drm_output_propose_state
Daniel Stone [Thu, 8 Dec 2016 17:19:09 +0000 (17:19 +0000)]
compositor-drm: Add modes to drm_output_propose_state

Add support for multiple modes to drm_output_propose_state. Currently we
intend to operate in three modes: planes-only (no renderer buffer,
client buffers in planes only), mixed-mode (promote client buffers to
planes where possible, falling back to the renderer where not), and
renderer-only (no plane usage at all).

We want to use the first (planes-only) mode where possible: it can avoid
us having to allocate buffers for the renderer, and it also gives us the
best chance of the optimal configuration, with no composition. In this
mode, we walk the scene looking at all views, trying to put them in
planes, and failing as soon as we find a view we cannot place in a
plane.

In the second mode, rather than failing, we assign those views which
cannot be on a plane to the renderer, and allow the renderer to
composite them.

In the third mode, planes are not usable, so everything but the cursor
goes to the renderer. We will use this when we cannot use the planes-only
mode (because some views cannot be placed in planes), but also cannot
use the 'mixed' mode because we have no renderer buffer yet. Since we
walk the scene graph from top to bottom, using atomic modesetting we
will determine if planes can be promoted in mixed mode by placing a
renderer buffer at the bottom of the scene, placing a cursor buffer if
applicable, then testing if we can add overlay planes to this mode.

Without a buffer from the renderer, we cannot do these tests, so we push
everything through the renderer and then switch to mixed mode on the
next repaint.

This patch implements the mixed and renderer-only modes (previously
differentiated only by the sprites_are_broken flag), with the
planes-only mode being left for a later patch.

Signed-off-by: Daniel Stone <daniels@collabora.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
6 years agocompositor-drm: Use sprites_are_broken for scanout plane
Daniel Stone [Tue, 10 Jul 2018 13:31:06 +0000 (14:31 +0100)]
compositor-drm: Use sprites_are_broken for scanout plane

When the sprites_are_broken variable is set, do not attempt to promote
client surfaces to the scanout plane.

We are currently assuming that every client buffer will be compatible
with the scanout plane, but that is not the case, particularly with more
exotic tiled/compressed buffers. Once we promote the client buffer to
scanout, there is no going back: if the repaint fails, we do not mark
this as failed and go back to repaint through composition.

This permanently removes the ability for scanout bypass when using the
non-atomic path. Future patches lift the restriction when using atomic
modesetting, as we can actually test and ensure that the view is
compatible with scanout.

Signed-off-by: Daniel Stone <daniels@collabora.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reported-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
6 years agocompositor-drm: Disallow overlapping overlay planes
Daniel Stone [Tue, 10 Jul 2018 10:44:25 +0000 (11:44 +0100)]
compositor-drm: Disallow overlapping overlay planes

The scanout plane strictly stacks under all overlay planes, and the
cursor plane above. However, the stacking of overlay planes with respect
to each other is undefined.

We can control the stacking order of overlay planes with the zpos
property, though this significantly complicates plane assignment. In the
meantime, simply disallow assigning a view to an overlay, when it
overlaps another view which is already on an overlay. This ensures
stacking order is irrelevant, since the planes never intersect each
other.

Signed-off-by: Daniel Stone <daniels@collabora.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
6 years agolibweston: Fix clear timing of output repainted flag
Tomohito Esaki [Tue, 10 Jul 2018 02:47:15 +0000 (11:47 +0900)]
libweston: Fix clear timing of output repainted flag

Since the repaint status of the flushed output may be reset if a output
repaint is failed, it is necessary to clear the repainted flag
immediately after output repaint flush/cancel.

Signed-off-by: Tomohito Esaki <etom@igel.co.jp>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
6 years agocompositor-drm: Ignore occluded views
Daniel Stone [Fri, 9 Dec 2016 18:03:31 +0000 (18:03 +0000)]
compositor-drm: Ignore occluded views

When trying to assign planes, keep track of the areas which are
already occluded, and ignore views which are completely occluded. This
allows us to build a state using planes only, when there are occluded
views which cannot go into a plane behind views which can.

Signed-off-by: Daniel Stone <daniels@collabora.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Tested-by: Emre Ucan <eucan@de.adit-jv.com>
6 years agocompositor-drm: Ignore views on other outputs
Daniel Stone [Tue, 29 Nov 2016 21:03:44 +0000 (21:03 +0000)]
compositor-drm: Ignore views on other outputs

When we come to assign_planes, try very hard to ignore views which are
only visible on other outputs, rather than forcibly moving them to the
primary plane, which causes damage all round and unnecessary repaints.

Signed-off-by: Daniel Stone <daniels@collabora.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Tested-by: Emre Ucan <eucan@de.adit-jv.com>
6 years agocompositor-drm: Split drm_assign_planes in two
Daniel Stone [Mon, 18 Dec 2017 13:41:09 +0000 (13:41 +0000)]
compositor-drm: Split drm_assign_planes in two

Move drm_assign_planes into two functions: one which proposes a plane
configuration, and another which applies that state to the Weston
internal structures. This will be used to try multiple configurations
and see which is supported.

Signed-off-by: Daniel Stone <daniels@collabora.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Tested-by: Emre Ucan <eucan@de.adit-jv.com>
6 years agocompositor-drm: Use GBM modifier API
Daniel Stone [Fri, 18 Nov 2016 18:02:08 +0000 (18:02 +0000)]
compositor-drm: Use GBM modifier API

Now that we collect information about which modifiers are supported for
KMS display, and are able to create KMS framebuffers with modifiers,
begin using the modifier-aware GBM API.

Client buffers from dmabuf already store multi-plane and modifier
information into drm_fb. Extend this to drm_fb_get_from_bo(), used for
wl_buffer, cursor, and gbm_surface buffers. wl_buffer buffers should by
convention not require modifiers. Cursor buffers must not require
modifiers, as they should be linear. Prior to this patch, GBM buffers
must have been single-planar, and able to used without explicitly naming
modifiers.

Using gbm_surface_create_with_modifiers allows us to pass the list of
modifiers acceptable to KMS for scanout to GBM, so it can allocate
multi-planar buffers or those which are otherwise only addressible with
modifiers. On platforms supporting and preferring modifiers for scanout,
this means that the gbm_bos we get from our scanout surface need to use
the extended API to query multiple planes, offsets, modifiers, etc.

Signed-off-by: Daniel Stone <daniels@collabora.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Tested-by: Emre Ucan <eucan@de.adit-jv.com>
6 years agocompositor-drm: Support plane IN_FORMATS
Sergi Granell [Thu, 12 Jan 2017 17:17:32 +0000 (17:17 +0000)]
compositor-drm: Support plane IN_FORMATS

The per-plane IN_FORMATS KMS property describes the format/modifier
combinations supported for display on this plane. Read and parse this
format, storing the data in each plane, so we can know which
combinations might work, and which combinations definitely will not
work.

Similarly to f11ec02cad40 ("compositor-drm: Extract overlay FB import to
helper"), we now use this when considering promoting a view to overlay
planes. If the framebuffer's modifier is definitely not supported by the
plane, we do not attempt to use that plane for that view.

This will also be used in a follow-patch, passing the list of modifiers
to GBM surface allocation to allow it to allocate more optimal buffers.

Signed-off-by: Sergi Granell <xerpi.g.12@gmail.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Tested-by: Emre Ucan <eucan@de.adit-jv.com>
6 years agocompositor-drm: Add modifiers to GBM dmabuf import
Daniel Stone [Fri, 18 Nov 2016 12:31:26 +0000 (12:31 +0000)]
compositor-drm: Add modifiers to GBM dmabuf import

Add support for the GBM_BO_IMPORT_FD_MODIFIER path, which allows us to
import multi-plane dmabufs, as well as format modifiers.

Signed-off-by: Daniel Stone <daniels@collabora.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Tested-by: Emre Ucan <eucan@de.adit-jv.com>
Fixes: https://gitlab.freedesktop.org/wayland/weston/issues/113

6 years agohelpers: Move static_assert definition to shared
Daniel Stone [Mon, 9 Jul 2018 12:05:59 +0000 (13:05 +0100)]
helpers: Move static_assert definition to shared

Collect the fallback definitions of static_assert() from desktop-shell
and the test shell, and move them to helpers.h. This allows code
throughout the tree to use static_assert() for build-time assertions,
where it is supported by the compiler.

As GCC goes out of its way to only add static_assert() when C11 has been
explicitly requested - which we don't do - make sure to use the more
widely available _Static_assert() if that is provided.

This will be used in future patches to ensure two array lengths don't go
out of sync.

Signed-off-by: Daniel Stone <daniels@collabora.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
6 years agocompositor-drm: Don't set fb->size for non-dumb buffers
Daniel Stone [Mon, 9 Jul 2018 12:51:51 +0000 (13:51 +0100)]
compositor-drm: Don't set fb->size for non-dumb buffers

When creating a drm_fb from client (wl_buffer/dmabuf), gbm_surface, or
client buffers, set fb->size to 0. The size member is only used for dumb
buffers, where we mmap the whole buffer, and need the size recorded to
later pass to munmap.

Determining the full size of multi-planar buffers is difficult, as
auxiliary planes are not guaranteed to have a (height*stride)
allocation, e.g. if they are subsampled or if they do not contain pixel
data at all but, e.g., compression information. Single-plane tiled
buffers also often pad the buffer allocation to a multiple of tile
height, making our existing calculation incorrect.

Though it does no harm to record incorrect information, it also does
no good as we never use it; remove it in order to avoid any confusion.

Signed-off-by: Daniel Stone <daniels@collabora.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
6 years agocompositor-drm: Avoid cast by using unsigned loop index
Daniel Stone [Mon, 9 Jul 2018 12:49:04 +0000 (13:49 +0100)]
compositor-drm: Avoid cast by using unsigned loop index

ARRAY_LENGTH returns a size_t; rather than casting its result to
int so we can compare to our signed index variable, just declare the
index as a compatible type in the first place.

Signed-off-by: Daniel Stone <daniels@collabora.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
6 years agocompositor-drm: Define DPMS property as an enum
Daniel Stone [Fri, 6 Jul 2018 10:36:49 +0000 (11:36 +0100)]
compositor-drm: Define DPMS property as an enum

The DPMS connector property is an enum property in KMS, which made our
property handling complain at startup as we weren't defining its enums.
Fix our definition so we parse the enum values.

The only user of the property is the legacy path, which can continue
using fixed values as those values are part of the KMS ABI. The atomic
path does not need any changes, since atomic uses routing and CRTC
active to determine the connector's power state, rather than a property.

Signed-off-by: Daniel Stone <daniels@collabora.com>
Fixes: https://gitlab.freedesktop.org/wayland/weston/issues/125
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
6 years agoman: Remove description of DRM specific mode-options from weston.ini.man
Ankit Nautiyal [Fri, 6 Jul 2018 10:48:39 +0000 (16:18 +0530)]
man: Remove description of DRM specific mode-options from weston.ini.man

The weston.ini.man describes the mode-formats that a user can specify
for selecting a video mode. The DRM specific examples are already
provided in weston-drm.man, so this inofrmation is redundant and can
be removed.

This patch removes the DRM specific mode option details from the
description of mode configuration in weston.ini.man.
A pointer to weston-drm.man is given, which has complete information
about the mode-format options supported by DRM backend.

Signed-off-by: Ankit Nautiyal <ankit.k.nautiyal@intel.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
6 years agocompositor-drm: Support modifiers for drm_fb
Daniel Stone [Thu, 8 Dec 2016 16:36:18 +0000 (16:36 +0000)]
compositor-drm: Support modifiers for drm_fb

Use the new drmModeAddFB2WithModifiers interface to import buffers with
modifiers.

Signed-off-by: Daniel Stone <daniels@collabora.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Tested-by: Emre Ucan <eucan@de.adit-jv.com>
6 years agocompositor-drm: Extract drm_fb_addfb into a helper
Daniel Stone [Thu, 17 Nov 2016 17:54:00 +0000 (17:54 +0000)]
compositor-drm: Extract drm_fb_addfb into a helper

We currently do the same thing in two places, and will soon have a
third.

Signed-off-by: Daniel Stone <daniels@collabora.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Tested-by: Emre Ucan <eucan@de.adit-jv.com>
6 years agocompositor-drm: Use plane FB-import helper for scanout
Daniel Stone [Thu, 17 Nov 2016 17:33:08 +0000 (17:33 +0000)]
compositor-drm: Use plane FB-import helper for scanout

Use the same codepath, which has the added advantage of being able to
import dmabufs.

Signed-off-by: Daniel Stone <daniels@collabora.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Tested-by: Emre Ucan <eucan@de.adit-jv.com>
6 years agocompositor-drm: Extract overlay FB import to helper
Daniel Stone [Thu, 17 Nov 2016 17:32:42 +0000 (17:32 +0000)]
compositor-drm: Extract overlay FB import to helper

... in order to be able to use it from scanout as well.

In doing this, the check for format compatibility is moved from after
selecting a plane to before selecting a plane. If different planes have
disjoint format support, this ensures that we don't reject the view from
all overlay consideration, just because the first plane we found didn't
support its format.

Signed-off-by: Daniel Stone <daniels@collabora.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Tested-by: Emre Ucan <eucan@de.adit-jv.com>
6 years agocompositor-drm: Use plane_state_coords_for_view for cursor
Daniel Stone [Wed, 16 Nov 2016 19:46:35 +0000 (19:46 +0000)]
compositor-drm: Use plane_state_coords_for_view for cursor

Use the new helper to populate the cursor state as well, with some
special-case handling to account for how we always upload a full-size
BO.

As this now fully takes care of buffer transformations, HiDPI client
cursors work, and we also clip the cursor plane completely to CRTC
bounds.

Signed-off-by: Daniel Stone <daniels@collabora.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reported-by: Derek Foreman <derekf@osg.samsung.com>
Tested-by: Emre Ucan <eucan@de.adit-jv.com>
Fixes: https://gitlab.freedesktop.org/wayland/weston/issues/118

6 years agocompositor-drm: Use plane_state_coords_for_view for scanout
Daniel Stone [Wed, 16 Nov 2016 19:40:29 +0000 (19:40 +0000)]
compositor-drm: Use plane_state_coords_for_view for scanout

Now that we have a helper to fill the plane state co-ordinates from a
view, use this for the scanout plane.

We now explicitly check that the view fills exactly the fullscreen area
and nothing else. We then use the new helper to fill out the plane state
values, and do further checks against the filled-in co-ordinates, i.e.
that we're not trying to show an offset into the buffer, or to scale the
image.

This now allows cases where the buffer -> surface -> view -> output
transform chain cancels each other out for scaling: previously, we would
never consider a buffer for scanout unless its scale matched the
output's. We now only look at the final result of the buffer -> output
transformation, to check that this does not result in translation or
scaling.

An audit of the error paths found some places where we would leave a
plane state hanging; this makes them all consistent.

Signed-off-by: Daniel Stone <daniels@collabora.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Tested-by: Emre Ucan <eucan@de.adit-jv.com>
6 years agocompositor-drm: Only check final co-ordinates for overlay scaling
Daniel Stone [Wed, 16 Nov 2016 19:35:03 +0000 (19:35 +0000)]
compositor-drm: Only check final co-ordinates for overlay scaling

When considering a view for placement into an overlay plane, we
previously checked that the buffer's transform and scale were identical
to the output's, and that there were no transformations applied.

We now use a more consistent set of checks through
drm_plane_state_coords_for_view. This checks the complete transformation
chain, allowing only translation and scaling; at the end, we check if
the total buffer -> surface -> view -> output chain requires scaling or
rotation, and disallow it if so.

This allows scaling in the cases where the transformation chain cancels
itself out to produce a 1:1 buffer -> output pixel scale.

An erroneously disallowed case is where buffer -> view -> output
rotations cancel each other out; we prevent a view from being on an
overlay plane if rotation is involved at all. Fixing this would require
a complete analysis of the overall transformation matrix.

Signed-off-by: Daniel Stone <daniels@collabora.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Tested-by: Emre Ucan <eucan@de.adit-jv.com>
6 years agocompositor-drm: Fully account for buffer transformation
Daniel Stone [Tue, 7 Feb 2017 18:48:19 +0000 (18:48 +0000)]
compositor-drm: Fully account for buffer transformation

In our new and improved helper to determine the src/dest values for a
buffer on a given plane, make sure we account for all buffer
transformations, including viewport clipping.

Rather than badly open-coding it ourselves, just use the helper which
does exactly this.

Signed-off-by: Daniel Stone <daniels@collabora.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reported-by: Tiago Gomes <tiago.gomes@codethink.co.uk>
Tested-by: Emre Ucan <eucan@de.adit-jv.com>
6 years agocompositor-drm: Extract buffer->plane co-ord translation
Daniel Stone [Wed, 16 Nov 2016 19:33:20 +0000 (19:33 +0000)]
compositor-drm: Extract buffer->plane co-ord translation

Pull this into a helper function, so we can use it everywhere.

Signed-off-by: Daniel Stone <daniels@collabora.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Tested-by: Emre Ucan <eucan@de.adit-jv.com>
6 years agocompositor-drm: Make alpha-to-opaque handling common
Daniel Stone [Thu, 8 Dec 2016 13:15:58 +0000 (13:15 +0000)]
compositor-drm: Make alpha-to-opaque handling common

Rather than a hardcoded ARGB8888 -> XRGB8888 translation inside a
GBM-specific helper, just determine whether or not the view is opaque,
and use the generic helpers to implement the format translation.

As a consequence of reordering the calls in
drm_output_prepare_overlay_view(), we move the GBM BO dereference into a
different failure path, before it gets captured by the plane state.

Signed-off-by: Daniel Stone <daniels@collabora.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Tested-by: Emre Ucan <eucan@de.adit-jv.com>
6 years agocompositor-drm: Remove unnecessary picked_scanout variable
Daniel Stone [Tue, 15 May 2018 16:09:53 +0000 (17:09 +0100)]
compositor-drm: Remove unnecessary picked_scanout variable

e2e80136334f fixed the same issue as df573031d0ba in a different way.
The latter commit (applied earlier in the upstream tree) adds a variable
to assign_planes to keep track of when we successfully assign a view to
the scanout plane, and doesn't call prepare_scanout_view if we have.

The former commit adds this checking inside prepare_scanout_view: if the
pending output state already has a framebuffer assigned to the scanout
plane, we drop out of prepare_scanout_view early. The picked_scanout
variable inside assign_planes can thus be removed.

Signed-off-by: Daniel Stone <daniels@collabora.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Tested-by: Emre Ucan <eucan@de.adit-jv.com>
6 years agocompositor-drm: Property accessor can be const
Daniel Stone [Thu, 5 Jul 2018 16:55:43 +0000 (17:55 +0100)]
compositor-drm: Property accessor can be const

Since it doesn't write to the parameter, we can make it const.

Signed-off-by: Daniel Stone <daniels@collabora.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
6 years agocompositor-drm: Add aspect-ratio parsing support
Ankit Nautiyal [Mon, 18 Mar 2097 18:54:57 +0000 (00:24 +0530)]
compositor-drm: Add aspect-ratio parsing support

The flag bits 19-22 of the connector modes, provide the aspect-ratio
information. This information can be stored in flags bits of the
weston mode structure, so that it can used for setting a mode with a
particular aspect-ratio.
Currently, DRM layer supports aspect-ratio with atomic-modesetting by
default. For legacy modeset path, the user-space needs to set the
drm client cap for aspect-ratio, if it wants aspect-ratio information
in modes.

This patch:
- preserves aspect-ratio flags from kernel video modes and
  accommodates it in wayland mode.
- uses aspect-ratio to pick the appropriate mode during modeset.
- changes the mode format in configuration file weston.ini to
  accommodate aspect-ratio information as:
  WIDTHxHEIGHT@REFRESH-RATE ASPECT-RATIO
  The aspect-ratio can take the following values :
  4:3, 16:9, 64:27, 256:135.

v2: As per recommendation from Pekka Paalanen, Quentin Glidic,
Daniel Stone, dropped the aspect-ratio info from wayland protocol,
thereby avoiding exposure of aspect-ratio to the client.

v3: As suggested by Pekka Paalanen, added aspect_ratio field to store
aspect-ratio information from the drm. Also added drm client
capability for aspect-ratio, as recommended by Daniel Vetter.

v4: Minor modifications and fixes as suggested by Pekka Paalanen.

v5: Rebased, fixed some styling issues, and added aspect-ratio
information while printing weston_modes.

v6: Moved the man pages changes to a different patch. Minor
reorganization of code as suggested by Pekka Paalanen.

Signed-off-by: Ankit Nautiyal <ankit.k.nautiyal@intel.com>
[Pekka: replace ARRAY_SIZE with ARRAY_LENGTH]
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
6 years agoman: add description for specifying modes with aspect-ratio in weston.ini
Ankit Nautiyal [Mon, 18 Mar 2097 18:54:56 +0000 (00:24 +0530)]
man: add description for specifying modes with aspect-ratio in weston.ini

This patch adds information about the new resolution-format that can
be specified by a user in weston.ini to select a CEA mode. CEA defines
timing of a video mode, which is considered as a standard for
HDMI certification and compliance testing. It defines each and every
parameter, of  a video mode, like h/vactive,h/vfront h/vback etc.,
including aspect-ratio information. The drm layer, specifies the
aspect-ratio information in user-mode flag bits 19-22. For the non-CEA
modes a value of 0 is given in the aspect-ratio flag bits. Each
CEA-mode is identified by a unique, Video Identification Code (VIC).
For example, VIC=4 is 1280x720@60 aspect-ratio 16:9.
This mode will be different than a non-CEA mode 1280x720@60 0:0.

The new mode-format helps to differentiate between the CEA and
non-CEA modes, by letting user specify aspect-ratio along with other
paremeters: mode=widthxheight@rr ratio.

This helps when certification testing is done, in tests like 7-27,
the HDMI analyzer applies a particular CEA mode, and expects the
applied mode to be with exactly same timings, including the
aspect-ratio and VIC field.

Signed-off-by: Ankit Nautiyal <ankit.k.nautiyal@intel.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
6 years agolibweston: fix output reflow on removal
Pekka Paalanen [Thu, 21 Jun 2018 11:26:18 +0000 (14:26 +0300)]
libweston: fix output reflow on removal

This is regression apparently introduced in
0de859ede4bad72b5d3b78e086632f02196d997f, which accidentally swapped the
sign of 'delta_width' in the original call site. If one removes an
output, the remaining outputs on the right are getting moved even
further to the right.

The outputs to the right should be moved to the left instead, to close
the gap left by the removed output.

Reported-by: Tomasz Olszak <olszak.tomasz@gmail.com>
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Ian Ray <ian.ray@ge.com>
6 years agodesktop-shell: fix output removal for background/panel
Pekka Paalanen [Thu, 21 Jun 2018 12:38:56 +0000 (15:38 +0300)]
desktop-shell: fix output removal for background/panel

When the compositor has multiple outputs (not clones) and one of them is
removed, the ones remaining to the right will be moved to close the gap.
Because reflowing the remaining outputs happens before removing the
wl_output global, we get the new output x,y before the removal. This
causes us to consider the remaining output immediately to the right of
the removed output to be a clone of the removed output whose x,y don't
get updated. That will then hit the two assertions this patch removes.

The reason the assertions were not actually hit is because of a
compositor bug which moved the remaining outputs in the wrong direction.
The next patch will fix the reflow, so we need this patch first to avoid
the asserts.

Remove the assertions and hand over the background and panel if the
"clone" does not already have them. If the clone already has them, we
destroy the unnecessary background and panel.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Marius Vlad <marius-cristian.vlad@nxp.com>
6 years agocompositor-drm: ignore case of {h,v}sync flags in modeline
Guido Günther [Tue, 26 Jun 2018 18:40:08 +0000 (20:40 +0200)]
compositor-drm: ignore case of {h,v}sync flags in modeline

Some modeline generators put out e.g. +HSync instead of +hsync. Accept
that too since it's not ambigous.

Signed-off-by: Guido Günther <agx@sigxcpu.org>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
6 years agomain: don't configure /dev/fb0 by default
nerdopolis [Fri, 29 Jun 2018 12:17:51 +0000 (08:17 -0400)]
main: don't configure /dev/fb0 by default

The framebuffer backend now detects the framebuffer device
dynamically. Don't assume that the framebuffer device is /dev/fb0

Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
6 years agocompositor-fbdev: detect the first fb device in the seat
nerdopolis [Fri, 29 Jun 2018 12:17:50 +0000 (08:17 -0400)]
compositor-fbdev: detect the first fb device in the seat

This adds a function to detect the first framebuffer device in the
current seat. Instead of hardcoding /dev/fb0, detect the device
with udev, favoring the boot_vga device, and falling back to the
first framebuffer device in the seat if there is none. This is very
similar to what compositor-drm does to find display devices

Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
6 years agocompositor-fbdev: set fb device info upon the first run.
nerdopolis [Fri, 29 Jun 2018 12:17:49 +0000 (08:17 -0400)]
compositor-fbdev: set fb device info upon the first run.

This attempts to wake up secondary framebuffer devices
(/dev/fb1 and up) as usually these devices start powered off, and
the FBIOPUT_VSCREENINFO ioctl turns it on. This was tested on a
qemu system with the options:

-vga none -device VGA,id=video0 -device secondary-vga,id=video1 \
-device secondary-vga,id=video2

Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
6 years agolauncher-logind: only get a VT on seat0, as only seat0 supports VTs
nerdopolis [Fri, 29 Jun 2018 12:17:48 +0000 (08:17 -0400)]
launcher-logind: only get a VT on seat0, as only seat0 supports VTs

As only seat0 supports TTYs, this changes the logind launcher where
it detects a TTY, only if the seat is seat0. This has only been
tested for logind

Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
6 years agocompositor-fbdev: support the --seat option, (and XDG_SEAT variable)
nerdopolis [Fri, 29 Jun 2018 12:17:47 +0000 (08:17 -0400)]
compositor-fbdev: support the --seat option, (and XDG_SEAT variable)

This allows the fbdev backend to run on, and use devices from the
specified seat, similar to the drm backend.

Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
6 years agolibweston: set the seat automatically based on the XDG_SEAT environment variable
nerdopolis [Fri, 29 Jun 2018 12:17:46 +0000 (08:17 -0400)]
libweston: set the seat automatically based on the XDG_SEAT environment variable

This will allow the seat to be set by the environment as pam_systemd typically
sets the XDG_SEAT variable

Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
6 years agoconfigure.ac: bump libdrm requirement to 2.4.68
Peter Hutterer [Sun, 10 Jun 2018 23:29:49 +0000 (09:29 +1000)]
configure.ac: bump libdrm requirement to 2.4.68

Had a stale libdrm sitting around which gave me errors, both fixed with the
.68 version.

libweston/pixel-formats.c:291:13: error: ‘DRM_FORMAT_NV24’ undeclared here
(not in a function); did you mean ‘DRM_FORMAT_NV21’?
   .format = DRM_FORMAT_NV24,
             ^~~~~~~~~~~~~~~
             DRM_FORMAT_NV21
libweston/pixel-formats.c:296:13: error: ‘DRM_FORMAT_NV42’ undeclared here
(not in a function); did you mean ‘DRM_FORMAT_NV12’?
   .format = DRM_FORMAT_NV42,
             ^~~~~~~~~~~~~~~
             DRM_FORMAT_NV12

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Acked-by: Daniel Stone <daniels@collabora.com>
Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
6 years agoweston: add force-on option for DRM
Pekka Paalanen [Wed, 23 May 2018 11:34:36 +0000 (14:34 +0300)]
weston: add force-on option for DRM

Add a new boolean output section key "force-on". When set to true, the
output will be enabled regardless of connector status. This is the
opposite of the mode=off setting.

Forcing connectors on is useful in special circumstances: avoid output
configuration changes due to hotplug e.g. with KVM switches, or hardware
with unreliable connector status readout for example.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Ian Ray <ian.ray@ge.com>
6 years agoweston: support clone mode on DRM-frontend
Pekka Paalanen [Fri, 3 Nov 2017 07:56:05 +0000 (09:56 +0200)]
weston: support clone mode on DRM-frontend

Add a new output section key "same-as" for configuring clone mode. An
output marked "same-as" another output will be configured identically to
the other output.

The current implementation supports only CRTC sharing for clone mode.
Independent CRTC clone mode cannot be supported until output layout
logic is moved from libweston into the frontend and libweston's damage
tracking issues stemming from overlapping outputs are solved.

Quite a lot of infrastructure is needed to properly configure clone
mode. The implemented logic allows easy addition of independent CRTC
clone mode once libweston supports it. The idea is that wet_layoutput is
the item to be laid out and all weston_outputs a wet_layoutput
contains show exactly the same area of the desktop.

The configuration logic attempts to automatically fall back to creating
more weston_outputs when all heads do not work under the same
weston_output. For now, the fallback path ends with an error message.

Enabling a weston_output is bit complicated, because one needs to first
collect all relevant heads, try to attach them all to the weston_output,
and then back up head by head until enabling the weston_output succeeds.
A new weston_output is created for the left-over heads and the process
is repeated.

CRTC-sharing clone mode is the most efficient clone mode, offering
synchronized scanout timings, but it is not always supported by
hardware.

v10:
- rebased trivial conflicts in man page
- switch to gitlab issue URL

v9:
- replace weston_compositor_set_heads_changed_cb() with
  weston_compositor_add_heads_changed_listener()
- remove workaround in simple_head_enable()

v6:
- Add man-page note about cms-colord.
- Don't create an output just to turn it off.

Fixes: https://gitlab.freedesktop.org/wayland/weston/issues/22

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Acked-by: Derek Foreman <derekf@osg.samsung.com>
Acked-by: Daniel Stone <daniels@collabora.com>
Reviewed-by: Ian Ray <ian.ray@ge.com>
6 years agoman: remove redundant word in weston.ini(5)
Matheus Santana [Fri, 22 Jun 2018 21:00:44 +0000 (18:00 -0300)]
man: remove redundant word in weston.ini(5)

Signed-off-by: Matheus Santana <embs@cin.ufpe.br>
Reviewed-by: Yong Bakos <ybakos@humanoriented.com>
Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
6 years agotests: Reshuffle IVI layout tests
Daniel Stone [Mon, 28 Nov 2016 15:54:06 +0000 (15:54 +0000)]
tests: Reshuffle IVI layout tests

Rename the IVI tests to be more consistent with the others, and invert
the naming of plugin/client to make it slightly more clear what's going
to happen. Handle the renaming by using wet_get_binary_path to rewrite
the local binaries.

As a side-effect, weston.ini ivi-shell-user-interface no longer needs to
be given as an absolute path.

Signed-off-by: Daniel Stone <daniels@collabora.com>
v2:

Call ivi-layout.ivi as ivi-layout-test-client.ivi to keep the same name
in both the file and the lookup, so that the module map does not need to
change the name.

Update code comments to reflect the new names.

Rename ivi_layout-test-plugin.c to ivi-layout-test-plugin.c.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Daniel Stone <daniels@collabora.com>
Reviewed-by: Emre Ucan <eucan@de.adit-jv.com>
Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
6 years agotests: remove WESTON_BUILD_DIR from env
Pekka Paalanen [Thu, 14 Jun 2018 13:25:39 +0000 (16:25 +0300)]
tests: remove WESTON_BUILD_DIR from env

There are no users left.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Daniel Stone <daniels@collabora.com>
Reviewed-by: Emre Ucan <eucan@de.adit-jv.com>
6 years agoshared: remove weston_config_get_libexec_dir()
Pekka Paalanen [Thu, 14 Jun 2018 13:20:32 +0000 (16:20 +0300)]
shared: remove weston_config_get_libexec_dir()

Now that WESTON_MODULE_MAP supersedes WESTON_BUILD_DIR for libexec
binaries, we don't need to check in WESTON_BUILD_DIR anymore.

There was only one user of weston_config_get_libexec_dir(), so remove
the whole function. There is no reason to export it.

Due to libshared.la being pulled into libweston, this probably was
libweston ABI unintended. Regardless, libweston major has already been
bumped.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Daniel Stone <daniels@collabora.com>
Reviewed-by: Emre Ucan <eucan@de.adit-jv.com>
Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
6 years agotests: Don't rely on build directory layout
Daniel Stone [Thu, 24 Nov 2016 20:45:45 +0000 (20:45 +0000)]
tests: Don't rely on build directory layout

Rather than having a hardcoded dependency on the build-directory layout,
use an explicit module-map environment variable, which rewrites requests
for modules and helper/libexec binaries to specific paths.

Pekka: This will help with migration to Meson where setting up the paths
according to autotools would be painful and unnecessary.

Emre: This should also help setting up the test suite after a
cross-compile.

Pekka: A caveat here is that this patch makes it slightly easier to load
external backends by abusing the module map. External backends are
specifically not supported in libweston.

Signed-off-by: Daniel Stone <daniels@collabora.com>
v2:

Fixed ivi_layout-test-plugin.c:wet_module_init().
Do not change the lookup name of ivi-layout.ivi.

Improved documentation of weston_module_path_from_env() and made it cope
with map strings that a) do not end with a semicolon, and b) have
multiple consecutive semicolons.

Let WESTON_MODULE_MAP be printed into the test log so that it is easier
to run tests manually.

Reviewed-by: Daniel Stone <daniels@collabora.com>
Reviewed-by: Emre Ucan <eucan@de.adit-jv.com>
Suggested by Emil: Use a variable for strlen(name).

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
6 years agoman: fix prefixes for weston.ini(5)
Peter Hutterer [Tue, 12 Jun 2018 23:11:48 +0000 (09:11 +1000)]
man: fix prefixes for weston.ini(5)

Replace a few hardcoded paths with the substitutes

https://gitlab.freedesktop.org/wayland/weston/issues/105

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
6 years agocompositor: print usage to stdout on success (not stderr) - this time really
Peter Hutterer [Tue, 12 Jun 2018 00:42:18 +0000 (10:42 +1000)]
compositor: print usage to stdout on success (not stderr) - this time really

Fix all the other printfs too.

https://gitlab.freedesktop.org/wayland/weston/issues/112

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
6 years agocompositor: print usage to stdout on success (not stderr)
Peter Hutterer [Sun, 10 Jun 2018 23:57:06 +0000 (09:57 +1000)]
compositor: print usage to stdout on success (not stderr)

Triggered by weston --help, the usage() output should not look like an error.

Note that there is only one caller of usage() at the moment, but let's handle
this here based on the status in case we add other cases.

https://gitlab.freedesktop.org/wayland/weston/issues/112

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
6 years agoweston-launch: always run through all groups
Peter Hutterer [Sun, 10 Jun 2018 23:57:04 +0000 (09:57 +1000)]
weston-launch: always run through all groups

If the user is in group 0, we'd exit the loop early with a failure. Make sure
we run through all groups.

https://gitlab.freedesktop.org/wayland/weston/issues/86

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
[Pekka: fix one whitespace]
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
6 years agodoc: Update for GitLab migration
Daniel Stone [Fri, 8 Jun 2018 23:51:06 +0000 (00:51 +0100)]
doc: Update for GitLab migration

Update issue report and build instruction URLs for moving to GitLab, and
for everything having been HTTPS-only for quite some time.

Signed-off-by: Daniel Stone <daniels@collabora.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
6 years agoclient: Fix segmentation fault in the case weston-nested
Yong Gan [Tue, 5 Sep 2017 00:00:30 +0000 (08:00 +0800)]
client: Fix segmentation fault in the case weston-nested

eglTerminate should be called before the display was disconnected.

Signed-off-by: Yong Gan <yong.gan@nxp.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
6 years agolibweston: Reset repaint schedule for all repainted outputs when repaint cancel
Tomohito Esaki [Tue, 5 Jun 2018 01:37:06 +0000 (10:37 +0900)]
libweston: Reset repaint schedule for all repainted outputs when repaint cancel

All outputs is canceled repaint when a output repaint is failed. At that
time, the output whose repaint is success is not scheduled because the
repaint status of that is still REPAINT_AWAITING_COMPLETION. Therefore,
we need to reset repaint schedule for all repainted outputs.

Signed-off-by: Tomohito Esaki <etom@igel.co.jp>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
6 years agolibweston: fix indentation
Tomohito Esaki [Tue, 5 Jun 2018 01:37:05 +0000 (10:37 +0900)]
libweston: fix indentation

Signed-off-by: Tomohito Esaki <etom@igel.co.jp>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
6 years agosimple-dmabuf-drm: Fallback DRM_FORMAT_MOD_LINEAR definition
Daniel Stone [Tue, 5 Jun 2018 22:01:51 +0000 (23:01 +0100)]
simple-dmabuf-drm: Fallback DRM_FORMAT_MOD_LINEAR definition

Just in case we're running on something quite old.

Signed-off-by: Daniel Stone <daniels@collabora.com>
6 years agoAdd .gitlab-ci.yml
Daniel Stone [Tue, 5 Jun 2018 21:20:40 +0000 (22:20 +0100)]
Add .gitlab-ci.yml

Add a GitLab CI configuration which tests building, 'make check', and
'make distcheck' of the tree inside a Debian Stretch container. The
choice of distribution base was arbitrary and may easily be changed.

As the version of wayland-protocols available is not sufficiently new,
we clone and build our own local version first. libwayland is new
enough, however we could potentially reuse the artifacts generated by
the Wayland CI job.

When commits are pushed to upstream, the commits will run this CI
pipeline to run these tests, and capture the result as an artifact
bundle, including the compiled binaries and full test suite logs.

Results can be seen at:
    https://gitlab.freedesktop.org/wayland/weston/pipelines/

Signed-off-by: Daniel Stone <daniels@collabora.com>
6 years agodoc: add example calibration-helper script
Pekka Paalanen [Tue, 13 Mar 2018 12:51:00 +0000 (14:51 +0200)]
doc: add example calibration-helper script

This is not to be installed, except maybe as a doc. It is just an
example of what one might do.  It also has not been tested, it's just
for giving an idea of what it should do.

It also contains untested speculation.

v2:
- use syspath instead of devpath
- add license blurb

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
6 years agoclients: add a new touchscreen calibrator
Louis-Francis Ratté-Boulianne [Wed, 29 Nov 2017 21:38:44 +0000 (16:38 -0500)]
clients: add a new touchscreen calibrator

The new calibrator uses weston_touch_calibration protocol extension and
provides the following features:

- chooses the physical touch device to be calibrated by DEVPATH or by
  the output/head name; device enumeration provided

- the compositor ensures the calibrator window is shown in the correct
  position and size

- no matter how wrong the old calibration is, the touch events will
  always arrive in the application

- the calibration is complete, not incremental; the received touch
  events are guaranteed to be unmodified

- computes a libinput style calibration matrix directly, not the
  WL_CALIBRATION format

- supports multiple touch devices: calibrate one device at a time, and
  show user feedback on touching a wrong device instead of recording bad
  data

- uses four touch point samples: three to compute the calibration, and
  one to verify the calibration is roughly correct

- consistent exit codes

- upload the new calibration into the server after successful
  and verified calibration

Due to using special touchscreen calibration protocol extension, this
application cannot be tested without touch input from the compositor.

Practically all of the above mentioned are unlike how the old
calibrator client worked.

Co-developed by Louis-Francis and Pekka.

v2:
- improve help() text
- rename wrong_touch_handler() to invalid_touch_handler()
- improve debug prints by adding sample number
- reorganize code into sample funcs vs. touch funcs
- add a state machine to properly process touch and related events

Signed-off-by: Louis-Francis Ratté-Boulianne <lfrb@collabora.com>
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
v1 Tested-by: Matt Hoosier <matt.hoosier@gmail.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
6 years agoweston: add touchscreen_calibrator option
Louis-Francis Ratté-Boulianne [Fri, 15 Dec 2017 07:02:56 +0000 (02:02 -0500)]
weston: add touchscreen_calibrator option

Add an option to enable the touchscreen calibrator interface. This is a
global on/off toggle, in lack of more fine-grained access restrictions.

As Weston should not hardcode system specifics, the actual permanent
saving of a new calibration is left for a user supplied script or a
program. Usually this script would write an appropriate udev rule to set
LIBINPUT_CALIBRATION_MATRIX for the touch device.

Co-developed by Louis-Francis and Pekka.

v2:
- use syspath instead of devpath

Signed-off-by: Louis-Francis Ratté-Boulianne <lfrb@collabora.com>
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
v1 Tested-by: Matt Hoosier <matt.hoosier@gmail.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
6 years agolibweston: implement touch calibration protocol
Louis-Francis Ratté-Boulianne [Wed, 29 Nov 2017 01:42:47 +0000 (20:42 -0500)]
libweston: implement touch calibration protocol

This implements a new global interface weston_touch_calibration, which
allows one client at a time to perform touchscreen calibration. This
also implements the calibrator window management.

A client asks to calibrate a specific physical touch device (not a
wl_seat which may have several physical touch devices aggregated).
Libweston grabs all touch devices and prevents normal touch event
handling during the calibation sequence.

API is added to enable this new global interface, but it not yet called
by anything. Since the implementation allows clients to grab touch devices
arbitrarily, it is not enabled by default. The compositor should take
measures to prevent unexpected access to the interface.

A client may upload a new calibration to the compositor. There is a
vfunc to allow the compositor to reject/accept it and save it to
persistent storage. The persistent storage could be a udev rule
setting LIBINPUT_CALIBRATION_MATRIX, so that all display server would
load the new calibration automatically.

Co-developed by Louis-Francis and Pekka.

v2:
- use struct weston_point2d_device_normalized
- use syspath instead of devpath
- wrong_touch was renamed to invalid_touch
- rename weston_touch_calibrator::cancelled to calibration_cancelled
- send invalid_touch on out-of-bounds touch-down
- cancel touch sequence and send invalid_touch on motion going
  out-of-bounds
- rename calcoord_from_double() to wire_uint_from_double()
- send bad_coordinates error in touch_calibrator_convert()
- conversion results in 0,0 if cancelled

Signed-off-by: Louis-Francis Ratté-Boulianne <lfrb@collabora.com>
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
v1 Tested-by: Matt Hoosier <matt.hoosier@gmail.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
6 years agoprotocol: add weston_touch_calibration
Pekka Paalanen [Wed, 22 Nov 2017 15:25:12 +0000 (17:25 +0200)]
protocol: add weston_touch_calibration

This is a Wayland protocol extension to allow the calibration of
touchscreens in Weston.

See: https://phabricator.freedesktop.org/T7868

v2:
- replace "server" with "compositor"
- rephrase error conditions to be simpler
- reword the matrix description in 'save' request
- rephrase when touch_device events are sent
- change device id to DEVPATH with "/sys" prefix
- qualify calibration units better
- replace wrong_touch event with a more generic invalid_touch
- fix error enum and add bad_coordinates
- convert while cancelled will not raise any errors

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
v1 Tested-by: Matt Hoosier <matt.hoosier@gmail.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
6 years agoinput: introduce touch event mode for calibrator
Louis-Francis Ratté-Boulianne [Wed, 29 Nov 2017 01:42:47 +0000 (20:42 -0500)]
input: introduce touch event mode for calibrator

In addition to the normal touch event processing mode, introduce a new
mode for calibrating a touchscreen input device.

In the calibration mode, normal touch event processing is skipped, and
the raw events are forwarded to the calibrator instead. The calibrator
is not yet implemented, so the calls will be added in a following patch.

To switch between modes, two functions are added, one for entering each
mode. The mode switch happens only when no touches are down on any touch
device, to avoid confusing touch grabs and clients. To realise this, the
state machine has four states: prepare and actual state for both normal
and calibrator modes.

At this point nothing will attempt to change the touch event mode.

The new calibrator mode is necessary, because when calibrating a
touchscreen, the touch events must be routed to the calibration client
directly. The touch coordinates are expected to be wrong, so they cannot
go through the normal focus surface picking. The calibrator code also
cannot use the normal touch grab interface, because it needs to be able
to distinguish between different physical touch input devices, even if
they are part of the same weston_seat. This requirement makes
calibration special enough to warrant the new mode, a sort of "super
grab".

Co-developed by Louis-Francis and Pekka.

Signed-off-by: Louis-Francis Ratté-Boulianne <lfrb@collabora.com>
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
v1 Tested-by: Matt Hoosier <matt.hoosier@gmail.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
6 years agoinput: do not forward unmatched touch-ups
Pekka Paalanen [Fri, 2 Mar 2018 12:20:59 +0000 (14:20 +0200)]
input: do not forward unmatched touch-ups

Commit a30e29af2e4d0ad6fc476ae7cc13c4cad5119217 introduced the code to
deal with a touchscreen with touches already down when Weston starts
using it. It fixed the touchpoint counting problem.

However, Weston still should not forward or process the unmatched
touch-ups either. Code inspection says it would confuse the
idle-inhibit counting, and it could probably confuse clients as well.
Hence, just drop unmatched touch-ups.

Enhance the warning message to allow identifying where the event came
from.

v2:
- use syspath instead of devpath

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
v1 Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
v1 Tested-by: Matt Hoosier <matt.hoosier@gmail.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
6 years agoinput: move touchpoint counting up
Louis-Francis Ratté-Boulianne [Wed, 29 Nov 2017 01:42:47 +0000 (20:42 -0500)]
input: move touchpoint counting up

The touchpoint counting is needed regardless of what we do with the
touch events, so move it out of process_touch_normal() into the caller
notify_touch_normalized().

This is pure refactoring.

Signed-off-by: Louis-Francis Ratté-Boulianne <lfrb@collabora.com>
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
v1 Tested-by: Matt Hoosier <matt.hoosier@gmail.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
6 years agolibweston: introduce notify_touch_normalized() and doc
Pekka Paalanen [Mon, 26 Feb 2018 14:18:29 +0000 (16:18 +0200)]
libweston: introduce notify_touch_normalized() and doc

notify_touch_normalized() is an extended form of notify_touch(), adding
normalized touch coordinates which are necessary for calibrating a
touchscreen.

It would be possible to invert the transformation and convert from
global coordinates to normalized device coordinates in input.c without
adding this API, but this way it is more robust against code changes.

Recovering normalized device coordinates is necessary because libinput
calibration matrix must be given in normalized units, and it would be
difficult to compute otherwise. Libinput API does not offer normalized
coordinates directly either, but those can be fetched by pretending the
output resolution is 1x1.

Anticipating touch calibration mode, the old notify_touch() is renamed
into a private process_touch_normal(), and the new
notify_touch_normalized() delegates to it.

Co-developed by Louis-Francis and Pekka.

v2:
- introduce struct weston_point2d_device_normalized
- rename notify_touch_cal() to notify_touch_normalized()
- remove WESTON_INVALID_TOUCH_COORDINATE

Cc: Louis-Francis Ratté-Boulianne <lfrb@collabora.com>
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
v1 Tested-by: Matt Hoosier <matt.hoosier@gmail.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
6 years agolibweston: notify_touch API to use weston_touch_device
Pekka Paalanen [Mon, 26 Feb 2018 12:43:00 +0000 (14:43 +0200)]
libweston: notify_touch API to use weston_touch_device

Relay touch input events into libweston core through the
weston_touch_device, so that the core can tell which individual physical
device they come from.

This is necessary for supporting touchscreen calibration, where one
needs to process a single physical device at a time instead of the
aggregate of all touch devices on the weston_seat.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
v1 Tested-by: Matt Hoosier <matt.hoosier@gmail.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
6 years agolibinput: move calibration printing into do_set_calibration()
Pekka Paalanen [Tue, 18 Apr 2017 09:11:53 +0000 (12:11 +0300)]
libinput: move calibration printing into do_set_calibration()

Move calibration printing here and call do_set_calibration() from
evdev_device_set_calibration() so that all matrix setting paths print
the same way.

Print the matrix values in a matrix style to help readability, and
mention the input device.

v2:
- use 'cal' instead of 'calb' as variable name

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
v1 Tested-by: Matt Hoosier <matt.hoosier@gmail.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
6 years agoinput: introduce weston_touch_device
Louis-Francis Ratté-Boulianne [Wed, 29 Nov 2017 01:42:47 +0000 (20:42 -0500)]
input: introduce weston_touch_device

Introduce weston_touch_device for libweston core to track individual
touchscreen input devices. A weston_seat/weston_touch may be an
aggregation of several physical touchscreen input devices. Separating
the physical devices will be required for implementing touchscreen
calibration. One can only calibrate one device at a time, and we want to
make sure to handle the right one.

Both backends that support touch devices are updated to create
weston_touch_devices. Wayland-backend provides touch devices that cannot
be calibrated, because we have no access to raw touch coordinates from
the device - calibration is the responsibility of the parent display
server. Libinput backend provides touch devices that can be calibrated,
hence implementing the set and get calibration hooks.

Backends need to maintain an output pointer in any case, so we have a
get_output() hook instead of having to maintain an identical field in
weston_touch_device. The same justification applies to
get_calibration_head_name.

Also update the test plugin to manage weston_touch_device objects.

Co-developed by Louis-Francis and Pekka.

v2:
- Consistently use 'cal' instead of 'calb' or 'matrix'.
- change devpath into syspath
- update copyrights

Signed-off-by: Louis-Francis Ratté-Boulianne <lfrb@collabora.com>
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
v1 Tested-by: Matt Hoosier <matt.hoosier@gmail.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
6 years agoweston-info: destroy wl_keyboard
Markus Ongyerth [Mon, 30 Apr 2018 09:35:50 +0000 (11:35 +0200)]
weston-info: destroy wl_keyboard

Fixes a memory leak by calling wl_keyboard_destroy on any keyboard
that was used to listen for events.

Signed-off-by: Markus Ongyerth <wl@ongy.net>
Acked-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
6 years agoweston-info: Add support for tablet-unstable-v2
Markus Ongyerth [Mon, 30 Apr 2018 09:35:49 +0000 (11:35 +0200)]
weston-info: Add support for tablet-unstable-v2

This now prints each tablet seat with at least one tablet/pad/tool
attached.
For each tablet seat, each tablet, pad and tool is printed with as much
detail about the device as the protocol provides.
Seat info is stored to be referenced, because the protocol requires to
request a tablet_seat for each wl_seat and it's not guaranteed that the
tablet_v2_manager is available when seats are advertised.

Signed-off-by: Markus Ongyerth <wl@ongy.net>
Acked-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
6 years agoFix a crash when unlocking or unconfining a pointer
Dima Ryazanov [Thu, 10 May 2018 07:53:38 +0000 (00:53 -0700)]
Fix a crash when unlocking or unconfining a pointer

In GNOME (but not in Weston), if a window loses focus, the client first receives
the focus event, then the unlock/unconfine event. This causes toytoolkit to
dereference a NULL window when unlocking or unconfining the pointer.

To repro:
- Run weston-confine
- Click the window
- Alt-Tab away from it

Result:

[1606837.869] wl_keyboard@19.modifiers(63944, 524352, 0, 0, 0)
[1606837.926] wl_keyboard@19.leave(63945, wl_surface@15)
[1606837.945] wl_pointer@18.leave(63946, wl_surface@15)
[1606837.956] wl_pointer@18.frame()
[1606837.961] zwp_confined_pointer_v1@26.unconfined()
Segmentation fault (core dumped)

To fix this, get the input from the window instead of the other way around.

Signed-off-by: Dima Ryazanov <dima@gmail.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
6 years agosimple-dmabuf-drm: support DRM_FORMAT_LINEAR for NV12 as well
Guido Günther [Mon, 28 May 2018 15:41:57 +0000 (17:41 +0200)]
simple-dmabuf-drm: support DRM_FORMAT_LINEAR for NV12 as well

This makes --import-format=NV12 testable on e.g. intel

We only set nv12_format_found to true if we found that format and at
least one understood modifier. Store modifier verbatim instead of using
a boolean flag. Last advertised and supported modifier currently wins.

The NV12 DRM_FORMAT_LINEAR image should be green in the upper left
corner and white in the lower right.

Signed-off-by: Guido Günther <agx@sigxcpu.org>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
6 years agolog: improve handling of use-before-init
Matt Hoosier [Fri, 4 May 2018 14:26:34 +0000 (09:26 -0500)]
log: improve handling of use-before-init

Rather than segfaulting by attempting to traverse an initially
null log handler pointer, explicitly print a message and abort.

Signed-off-by: Matt Hoosier <matt.hoosier@gmail.com>
Reviewed-by: Ian Ray <ian.ray@ge.com>
[Pekka: coding style fix]
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
6 years agosimple-dmabuf-drm: don't exit from create_display
Guido Günther [Tue, 20 Mar 2018 10:36:37 +0000 (11:36 +0100)]
simple-dmabuf-drm: don't exit from create_display

Only exit from main so control flow is in one place.

Signed-off-by: Guido Günther <agx@sigxcpu.org>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
6 years agosimple-dmabuf-drm: drop superfluous declaration
Guido Günther [Tue, 20 Mar 2018 10:36:36 +0000 (11:36 +0100)]
simple-dmabuf-drm: drop superfluous declaration

variable is defined in simple-dmabuf-drm.h

Signed-off-by: Guido Günther <agx@sigxcpu.org>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
6 years agosimple-dmabuf-drm: support etnaviv drm as well
Guido Günther [Tue, 20 Mar 2018 08:42:00 +0000 (09:42 +0100)]
simple-dmabuf-drm: support etnaviv drm as well

Reviewed-by: Derek Foreman <derekf@osg.samsung.com>
Signed-off-by: Guido Günther <agx@sigxcpu.org>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
6 years agosimple-dmabuf-drm: simplify fd_map_bo
Guido Günther [Tue, 20 Mar 2018 08:41:59 +0000 (09:41 +0100)]
simple-dmabuf-drm: simplify fd_map_bo

Signed-off-by: Guido Günther <agx@sigxcpu.org>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
6 years agosimple-dmabuf-drm: 0 is a valid fd (freedreno)
Guido Günther [Tue, 20 Mar 2018 08:41:58 +0000 (09:41 +0100)]
simple-dmabuf-drm: 0 is a valid fd (freedreno)

Reviewed-by: Eric Engestrom <eric.engestrom@imgtec.com>
Signed-off-by: Guido Günther <agx@sigxcpu.org>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
6 years agordp-compositor: fix compilation against FreeRDP 2.0.0 rc2
David Fort [Sun, 27 May 2018 21:56:43 +0000 (23:56 +0200)]
rdp-compositor: fix compilation against FreeRDP 2.0.0 rc2

The SURFACE_BITS_COMMAND struct has changed and some members have been moved in the
bmp field.

Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Tested-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
6 years agoxwm: dump properties of type WINDOW
Pekka Paalanen [Fri, 4 May 2018 10:53:55 +0000 (12:53 +0200)]
xwm: dump properties of type WINDOW

Very useful for TRANSIENT_FOR property debugging.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Signed-off-by: Fabien Lahoudere <fabien.lahoudere@collabora.com>
Reviewed-by: Ian Ray <ian.ray@ge.com>
6 years agoxwm: dump properties of type CARDINAL
Pekka Paalanen [Fri, 4 May 2018 10:53:54 +0000 (12:53 +0200)]
xwm: dump properties of type CARDINAL

Add code to dump CARDINAL arrays from properties. Useful for debugging.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Signed-off-by: Fabien Lahoudere <fabien.lahoudere@collabora.com>
Reviewed-by: Ian Ray <ian.ray@ge.com>
6 years agodesktop-shell: survive NULL output in shell_configure_fullscreen()
Pekka Paalanen [Wed, 2 May 2018 08:21:58 +0000 (10:21 +0200)]
desktop-shell: survive NULL output in shell_configure_fullscreen()

Running 'weston-simple-egl -f -b' (fullscreen, unthrottled) caused a
crash in shell_ensure_fullscreen_black_view() due to
shsurf->fullscreen_output being NULL. Also shell_configure_fullscreen()
could crash on that condition.

Fix shell_configure_fullscreen() to bail out with minimal work if there
is no fullscreen_output.

It is unclear if anything will cause a reconfiguration when an output is
plugged in.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Signed-off-by: Fabien Lahoudere <fabien.lahoudere@collabora.com>
Reviewed-by: Ian Ray <ian.ray@ge.com>
6 years agodesktop-shell: do not lower_fullscreen_layer(s, NULL)
Pekka Paalanen [Wed, 2 May 2018 08:21:57 +0000 (10:21 +0200)]
desktop-shell: do not lower_fullscreen_layer(s, NULL)

In activate, do not call lower_fullscreen_layer() at all if the output
is NULL. It should not do anything in that case, per the existing
comment.

This is a tentative crash fix for a case where there are no enabled
weston_outputs at all.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Signed-off-by: Fabien Lahoudere <fabien.lahoudere@collabora.com>
Reviewed-by: Ian Ray <ian.ray@ge.com>
6 years agodesktop-shell: handle NULL output in center_on_output()
Pekka Paalanen [Wed, 2 May 2018 08:21:56 +0000 (10:21 +0200)]
desktop-shell: handle NULL output in center_on_output()

This is a tentative crash fix for a case where there are no enabled
weston_outputs at all.

If no output is given, just put the surface at 0,0. At least it should
become mostly visible if an output is plugged in, if not centered.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Signed-off-by: Fabien Lahoudere <fabien.lahoudere@collabora.com>
Reviewed-by: Ian Ray <ian.ray@ge.com>
6 years agodesktop-shell: handle NULL output in get_output_work_area()
Pekka Paalanen [Wed, 2 May 2018 08:21:55 +0000 (10:21 +0200)]
desktop-shell: handle NULL output in get_output_work_area()

This is a tentative crash fix for a case where there are no
enabled weston_outputs at all.

Let get_output_work_area() return a zero area if the given output is
NULL. If there is no output, there is no area. Unfortunately we cannot
return "no position" but have to use 0,0 instead.

In send_configure_for_surface(), this causes a maximized surface to
receive width=0 and height=0 in the configure event, which means the
client is free to choose the size. There is no correct size to send for
maximizing for no output.

In constrain_position(), this has no effect. The interactive move of a
surface is restricted to not go below the panel, so even if a user
managed to move a surface without an output, it just prevents the
surface moving beyond y=0.

In weston_view_set_initial_position(), get_output_work_area() will not
be called with NULL output anyway.

In set_maximized_position(), this makes it behave as if the output was
at 0,0 which is the default position of the first output.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Signed-off-by: Fabien Lahoudere <fabien.lahoudere@collabora.com>
Reviewed-by: Ian Ray <ian.ray@ge.com>
6 years agomain: add setting for DRM/pixman shadow framebuffer
Pekka Paalanen [Mon, 23 Apr 2018 09:44:59 +0000 (11:44 +0200)]
main: add setting for DRM/pixman shadow framebuffer

Allows to control the Pixman-renderer shadow framebuffer usage from
weston.ini. It defaults to enabled, and whether it is a good idea to
disable or not depends on the platform and the workload.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Signed-off-by: Fabien Lahoudere <fabien.lahoudere@collabora.com>
Reviewed-by: Ian Ray <ian.ray@ge.com>
6 years agocompositor-drm: expose global shadow flag for pixman
Pekka Paalanen [Mon, 23 Apr 2018 09:44:58 +0000 (11:44 +0200)]
compositor-drm: expose global shadow flag for pixman

Allow global control of the pixman shadow buffers. The compositor can
choose whether all output use or do not use a shadow buffer with the
pixman renderer.

The option is added to the end of struct weston_drm_backend_config to
avoid bumping WESTON_DRM_BACKEND_CONFIG_VERSION.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Signed-off-by: Fabien Lahoudere <fabien.lahoudere@collabora.com>
Reviewed-by: Ian Ray <ian.ray@ge.com>
6 years agopixman: make shadow buffer optional
Pekka Paalanen [Mon, 23 Apr 2018 09:44:57 +0000 (11:44 +0200)]
pixman: make shadow buffer optional

Add a flag to pixman-renderer for initializing the output with a shadow
framebuffer. All backends were getting the shadow implcitly, so all
backends are modified to ask for the shadow explicitly.

Using a shadow buffer is usually beneficial, because read-modify-write
cycles (blending) into a scanout-capable buffer may be very slow. The
scanout framebuffer may also have reduced color depth, making blending
and read-back produce inferior results.

In some use cases though the shadow buffer might be just an extra copy
hurting more than it helps. Whether it helps or hurts depends on the
platform and the workload. Therefore let the backends control whether
pixman-renderer uses a shadow buffer for an output or not.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Signed-off-by: Fabien Lahoudere <fabien.lahoudere@collabora.com>
Reviewed-by: Ian Ray <ian.ray@ge.com>
6 years agopixman,drm: do not composite previous damage
Pekka Paalanen [Mon, 23 Apr 2018 09:44:56 +0000 (11:44 +0200)]
pixman,drm: do not composite previous damage

Pixman-renderer uses a single internal shadow buffer. It is enough to
composite the current damage into shadow, but the copy to hw buffer
needs to include the previous damage because of double-buffering in
DRM-backend.

This patch lets pixman-renderer do exactly that without compositing also
the previous damage on DRM-renderer.

Arguably weston_output should not have field previous_damage to begin
with, because it implies double-buffering, which e.g. EGL does not
guarantee. It would be better for each backend explicitly always provide
any extra damage that should be copied to hw.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Signed-off-by: Fabien Lahoudere <fabien.lahoudere@collabora.com>
Reviewed-by: Ian Ray <ian.ray@ge.com>
6 years agolibweston: fix output destroy signal list corruption
Pekka Paalanen [Tue, 22 May 2018 10:15:58 +0000 (13:15 +0300)]
libweston: fix output destroy signal list corruption

This issue was likely introduced by "libweston: add
weston_view_set_output()" which forgot to ensure the output destroy
listener is removed when weston_view is destroyed, leading to freed
memory being left into the list.

This was quite easy to trigger by opening and closing an application
window a few times, leading various memory corruption symptoms.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Ian Ray <ian.ray@ge.com>
6 years agodesktop-shell: fix output destroy signal list corruption
Pekka Paalanen [Tue, 22 May 2018 09:48:35 +0000 (12:48 +0300)]
desktop-shell: fix output destroy signal list corruption

This issue was introduced by "desktop-shell: detect stale shell surface
outputs" which forgot to remove the output destroy listener when
shell_surface is destroyed, leading to memory corruption.

This was fairly easy to trigger by opening and closing an application
window a few times.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Ian Ray <ian.ray@ge.com>
6 years agodesktop-shell: detect stale shell surface outputs
Semi Malinen [Wed, 2 May 2018 09:10:32 +0000 (11:10 +0200)]
desktop-shell: detect stale shell surface outputs

When displays are hot (un)plugged, it may happen that
a shell surface is left with a stale pointer to an output
that has already been freed. Add an output destroy listener
to catch such situations and set the output pointer to NULL.

Signed-off-by: Semi Malinen <semi.malinen@ge.com>
Signed-off-by: Fabien Lahoudere <fabien.lahoudere@collabora.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
6 years agolibweston: add weston_view_set_output()
Semi Malinen [Thu, 26 Apr 2018 09:08:10 +0000 (11:08 +0200)]
libweston: add weston_view_set_output()

Instead of desktop shell assigning view outputs directly,
use a new method, weston_view_set_output(). The method can
set up an output destroy listener to make sure that views
do not have stale output pointers.

Without this patch it is possible to end up in a scenario
where, e.g. configure_static_view() accesses memory that
has already been freed. The scenario can be provoked by
repeatedly plugging and unplugging a display. The faulty
memory accesses are reported by valgrind.

Signed-off-by: Semi Malinen <semi.malinen@ge.com>
Signed-off-by: Fabien Lahoudere <fabien.lahoudere@collabora.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>