Commit Graph

96 Commits

Author SHA1 Message Date
Michael Olbrich d70e712c2f drm: always check the repaint_status in update_complete
Initially finish_frame() was never called in drm_output_update_complete() for
'dpms_off_pending = true'. This is wrong for repaint_status ==
REPAINT_AWAITING_COMPLETION and that was fixed in
68d49d772c ("compositor-drm: run finish_frame when
dpms is turned off in update_complete").
However finish_frame() may now be called for repaint_status !=
REPAINT_AWAITING_COMPLETION, which is not allowed and results in a failed
assertion.

Fix this by checking dpms and repaint_status unconditionally.

Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
2020-08-19 07:35:14 +02:00
Marius Vlad 5130a8c21a backend-drm: Correctly tear down the DRM backend
It seem that we skipped to put back in TEXT mode the tty, in case a DRM
device node wasn't present at that time, or it isn't present at all. This
orders the destroy part correctly as to handle that case as well.

As a side effect, as the tty will still be set to GRAPHICS mode we will
require a manual change of the tty number, which might be not possible
on all systems. Properly putting back the tty to TEXT mode should avoid
that, and allows to re-use the same tty no in case the DRM device has
been created at a later point in time.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2020-08-18 12:59:50 +03:00
Stefan Agner 465ab2cd92 backend-drm: allow to disable GBM modifiers
Allow to disable GBM modifiers at runtime using the environment variable
WESTON_DISABLE_GBM_MODIFIERS.

This can be useful for debugging or when modifiers cause issues, e.g. in
case modifiers use higher memory bandwidth and hence impose a lower
resolution limit as it is the case with Intel Kaby Lake graphics.

Related to: https://gitlab.freedesktop.org/wayland/weston/-/issues/404
Signed-off-by: Stefan Agner <stefan@agner.ch>
2020-08-17 10:17:30 +00:00
Michael Olbrich 43ebb7e25a backend-drm: the GL renderer is a hard requirement for DRM virtual outputs
Building fails without it. So don't just warn about it but fail immediately.

Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
2020-08-17 10:12:54 +00:00
Michael Olbrich 27fb564a19 backend-drm: build DRM virtual support when the pipewire plugin is enabled
The pipewire plugin uses this API as well, not just the remoting plugin. So
enable it if either is enabled.

And disable pipewire in the no-gl-renderer CI build. The virtual outputs don't
work without it.

Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
2020-08-17 10:12:54 +00:00
Michael Olbrich 3097acc702 backend-drm: reorder plane checks to avoid unnecessary rendering
If a surface is not visible, then is does not matter if the view is on multiple
outputs. It will be skipped anyways when the output is rendered.

So check first if the surface is acually visible on the output before doing any
checks that might force rendering. This avoids unnecessary rendering.

Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
2020-08-17 09:53:38 +00:00
Alexandros Frantzis 53a71cb186 drm: Reset associated universal plane states when finalizing a crtc
When dissociating a universal plane from a crtc, we currently don't
reset the current state of the plane (plane->state_cur). When attempting
to use this plane in the future, we can run into invalid memory accesses
due to left over associations with potentially freed drm backend
objects. This commit resets the state of the scanout and cursor
universal planes associated with a crtc.

The following scenario exhibits the problem:

1. Start a (fullscreen) client that is suitable for and assigned to
   the scanout plane. The plane's state_cur->output value is set.
2. Unplug the monitor: the scanout plane is "released" but still
   maintains the state_cur->output association.
3. Replug the monitor: the plane is deemed unavailable due to an
   existing, albeit invalid, state_cur->output value. Note the memory
   errors trying to access the drm_output which was freed at step (2).

Signed-off-by: Alexandros Frantzis <alexandros.frantzis@collabora.com>
2020-08-17 09:44:45 +00:00
Alexandros Frantzis 9975134593 drm: Introduce drm_plane_reset_state() helper function
Introduce a helper function to reset the current state of a drm_plane.

Signed-off-by: Alexandros Frantzis <alexandros.frantzis@collabora.com>
2020-08-17 09:44:45 +00:00
Michael Olbrich 3ac911f69b drm: remove duplicate function declarations
These functions are all declared twice in the same file. Remove on of the two
declarations.

Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
2020-08-06 10:22:18 +02:00
Leandro Ribeiro ea4d13b3e3 drm-backend: remove log that advertises universal planes support
There's a log that advertises support for universal planes. That
can make users think there's something wrong with Weston or their
systems when universal planes are not supported, but that's not
the case. Remove this log from the code.

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
2020-07-28 11:13:53 -03:00
Scott Anderson 15c603caa6 drm: Fix leak of damage blob id
This moves the creation of the blob to be earlier, to when the damage is
calculated. It replaces the damage tracked inside of the plane state
with the blob id itself.

This should stop creating new blob ids for TEST_ONLY commits, and them
being leaked in general, as the blob ids are now freed with the plane
state.

The FB_DAMAGE_CLIPS property is now always set if it's supported, and
will be 0 in the case that we have no damage information, which
signifies full damage to the kernel.

Signed-off-by: Scott Anderson <scott.anderson@collabora.com>
2020-06-04 09:52:16 +00:00
Leandro Ribeiro e57d8ae818 drm-backend: add --continue-without-input command line option to DRM-backend
In the test suite we may want to run a DRM-backend test on a
non-default seat, which may not have a input device associated.
Weston's default behavior is to not open if input devices are
not found, as it may cause troubles. For instance, Weston can
open but if no input device is set than the user can not
interact or leave it.

Add flag --continue-without-input to DRM-backend so we can run
these types of tests with no input. Notice that this won't force
the compositor to skip opening a input device if it finds it on
the non-default seat.

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
2020-06-02 13:47:15 +00:00
Tomohito Esaki 51048463da drm: change timing to set color format for primary plane without universal plane
Without universal plane, the weston crashes with null pointer access in
set_gbm_format function because that function called before output
enable function. By changing timing to set color format for primary
plane in this case, this issue fixes.

Signed-off-by: Tomohito Esaki <etom@igel.co.jp>
2020-03-30 17:43:20 +09:00
Daniel Stone 61abf35ec4 pixman-renderer: Replace output-create flags with struct
pixman_renderer_output_create currently takes a flags enum bitmask for
its options. Switch this to using a structure, so we can introduce other
non-boolean options.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2020-03-20 15:25:24 +00:00
Daniel Stone db6e6e1ec5 gl-renderer: Replace window-create args with struct
gl_rendererer's output_window_create has a lot of arguments now. Add a
structure for the options to make it more clear what is what.
This is in preparation for adding bare-integer arguments which are ripe
for confusion when passing positional arguments.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2020-03-20 15:25:24 +00:00
Daniel Stone c890c384c8 gl-renderer: Replace display-create args with struct
gl_rendererer's output_create has a lot of arguments now. Add a
structure for the options to make it more clear what is what.
This is in preparation for adding bare-integer arguments which are ripe
for confusion when passing positional arguments.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2020-03-20 15:25:24 +00:00
Daniel Stone f9a6162595 drm: Get renderer buffer size from drm_fb
The renderer buffer size is usually the same size as the current mode,
so we were taking the dimensions from the currently-set mode. However,
using current_mode is quite confusing in places when it comes to scale,
and it also hampers our ability to do mode switches, as well as to
introduce a future option which will let the renderer use a smaller
buffer than the output and display scaled.

Simply take the dimensions of the renderer's output buffer from the
buffer itself.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2020-03-20 15:25:24 +00:00
Daniel Stone 98d75e1b23 drm: Remove unnecessary condition in drm_output_render reuse
This condition inside drm_output_render() checks if we can reuse the
existing renderer buffer for the primary plane; this occurs in
mixed-mode composition where a client buffer promoted to a plane has
changed, but the primary plane is unchanged.

We accomplish this by checking if there is no damage on the
primary/renderer plane, and then if there is already a renderer buffer
active on the primary plane: in that case, we can reuse the buffer we
already have.

There was a further condition checking if the width and height were
identical. This was designed to prevent against issues on mode changes.
However, runtime mode changes are already quite broken, and a mode
change will also cause damage on the full plane. We can simply remove
this condition.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2020-03-20 15:25:24 +00:00
Daniel Stone 7fa97e66eb drm: Remove trailing whitespace
Signed-off-by: Daniel Stone <daniels@collabora.com>
2020-03-20 15:25:24 +00:00
Lucas Stach 72e7a1ed48 backend-drm: Parse KMS panel orientation property, apply to weston_head
The KMS 'panel orientation' property allows the driver to statically
declare a fixed rotation of an output device. Now that weston_head has a
transform member, plumb the KMS property through to weston_head so the
compositor can make a smarter choice out of the box.

Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
[daniels: Extracted from one of Lucas's patches]
Signed-off-by: Daniel Stone <daniels@collabora.com>
2020-03-06 21:50:38 +00:00
Leandro Ribeiro 172afc2178 backend-drm: stop direct accessing core struct member
Commit "weston-log: add function to avoid direct
access to compositor members in non-core code" added the
function weston_compositor_add_log_scope mainly to allow
libweston users to avoid direct accessing core structs, as
weston_compositor.

Replace weston_log_context_add_log_scope usage by
weston_compositor_add_log_scope.

Signed-off-by: Leandro Ribeiro <leandrohr@riseup.net>
2020-01-29 09:55:24 +00:00
Scott Anderson 60b6572b35 Fix Wmaybe-uninitialized warnings
Just a couple of places which shouldn't be possible, so initialized and
added assertions to make sure.

Signed-off-by: Scott Anderson <scott.anderson@collabora.com>
2020-01-28 12:30:56 +00:00
Leandro Ribeiro f014964f6f weston-log: rename the confusing function name weston_compositor_log_scope_destroy()
There's a function named weston_compositor_log_scope_destroy()
but it doesn't take a struct weston_compositor argument.

Rename it to weston_log_scope_destroy(), as the argument is a
struct weston_log_scope.

Signed-off-by: Leandro Ribeiro <leandrohr@riseup.net>
2020-01-27 13:43:24 -03:00
Leandro Ribeiro 5976dbbbb5 weston-log: rename the confusing function name weston_compositor_add_log_scope()
There's a function named weston_compositor_add_log_scope()
but it doesn't take a struct weston_compositor argument.

Rename it to weston_log_ctx_add_log_scope(), as
the log_scope is being added to a log_context.

Also, bump libweston_major to 9.

Signed-off-by: Leandro Ribeiro <leandrohr@riseup.net>
2020-01-27 13:42:42 -03:00
Emmanuel Gil Peyrot 1b3ad0993b backend-drm: Make boolean fields actually bool
Continues what dd8219b3fb started, also in
the DRM backend.
2019-12-11 19:33:20 +00:00
Emmanuel Gil Peyrot b2f54d9f17 backend-drm: Remove unused variable
Its last usage was removed in 31838bf17e.
2019-12-11 19:33:20 +00:00
Stefan Agner 723c6a1266 backend-drm: Define potentially missing aspect-ratio bit definitions
The aspect ratio definitions for 64:27 and 256:135 have been added with
libdrm 2.4.95. However, Weston currently depends on libdrm 2.4.89 or
higher. Define the definitions in Weston to support libdrm older than
2.4.95.

Fixes: #332
Fixes: 6093772f45 ("backend-drm: Use aspect-ratio bit definitions from libdrm")
Signed-off-by: Stefan Agner <stefan@agner.ch>
2019-12-09 13:08:24 +00:00
Daniel Stone 6093772f45 backend-drm: Use aspect-ratio bit definitions from libdrm
When the aspect-ratio-aware mode support was added to Weston, it was
done before the libdrm support was finalised and merged. Between it
being added to Weston and being merged, it changed to no longer provide
the offset for the bitmask.

Instead of using the mask and a compatible enum, if we update our
libdrm dependency, we can use the flag definitions directly from libdrm.

In 94e4068ba1, the libdrm dependency was bumped to 2.4.83, which
enabled us to remove a bunch of error-prone ifdefs by making atomic and
modifier support mandatory.

We determined in the discussion of !311 that it was safe to push the
dependency as high as 2.4.91, as that was what was available in major
distributions.

Bumping to 2.4.86 allows us to safely remove the ifdef and go with
upstream flags, as that was added in mesa/drm@0d889201d1.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2019-11-27 17:52:16 +00:00
Leandro Ribeiro a2e80aca68 backend-drm: remove unnecessary ifdefs
Remove unnecessary ifdefs for DRM_MODE_CONNECTOR_DSI, DRM_MODE_CONNECTOR_DPI.
They are both provided by libdrm and were introduced long before 2.4.83 (the
lowest version we currently support).

Signed-off-by: Leandro Ribeiro <leandrohr@riseup.net>
2019-11-23 13:15:59 -03:00
Leandro Ribeiro 6196b201be backend-drm: remove unecessary ifdef checks
Since commit 28d26483 ("build: bump libdrm requirement to newer version
(2.4.83)"), all supported libdrm versions provide modifier formats,
atomic API and blob formats. Remove ifdef checks (HAVE_DRM_ADDFB2_MODIFIERS,
HAVE_DRM_ATOMIC, HAVE_DRM_FORMATS_BLOB) to improve the code and make it
simpler.

Signed-off-by: Leandro Ribeiro <leandrohr@riseup.net>
2019-11-23 09:57:52 +00:00
Marius Vlad 18462e8924 backend-drm: Further checks to skip plane assignment to HW planes
Mode change from mixed-mode to renderer-only means we should no longer
try to place views in HW planes (as we composite everything into the
primary plane) thus we should avoid that whenever that happens.

In the same time we need to be able to place in mixed-mode/renderer-only
mode the cursor view into the cursor plane (if one is available).

This patch adds a further check to skip plane assignment when disabling
overlay support (when we switch to renderer-only mode), when drivers do
not have atomic-modeset or it has been disabled intentionally.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2019-11-22 20:25:20 +02:00
Marius Vlad 48bc5efa7c backend-drm: Turn zpos duplicate check into an hard assert
This way we make sure we find out (if we have assigned invalid zpos
values) much faster.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2019-11-22 17:11:36 +02:00
Marius Vlad 788e80db77 backend-drm: Skip testing plane state if plane is not enabled
Adds a further assert() to make sure we're not checking against invalid
values. This was seen in the wild when the kernel rejects the commit for
overlay resulting in a check for invalid zpos values.

Fixes: #304

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2019-11-22 17:11:36 +02:00
Marius Vlad bd002b9884 backend-drm: Assign the primary plane the lowest zpos value
when switching to mixed-mode of compositing

This way we avoid an (incorrect) duplicate check of zpos values. Also,
this would be needed because the renderer needs have the lowest zpos value
available as we don't (yet) properly support underlays, the primary
plane serves as our renderer.

Adds also a check to see if we try to assign a view to a plane with
a lower zpos value than the one assigned to the primary when switching
to mixed-mode of compositing.

Fixes: #304

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2019-11-22 17:11:28 +02:00
Marius Vlad 81bada58db backend-drm: Add dmabuf scan-out check for DRM-backend
Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2019-11-21 14:07:54 +02:00
Marius Vlad ebd10e512e libweston: Add weston-direct-display server side implementation
Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2019-11-18 19:33:09 +02:00
Nicholas Niro 7aab746b3a backend-drm: Added support for legacy fd_import
This patch reenables the function drm_fb_get_from_dmabuf but with legacy
fd_import support for gbm/mesa < 17.1.
2019-11-12 13:01:02 -05:00
Nicholas Niro 56d1f4e7bc backend-drm: Fix for gbm modifiers when they are not available.
When the HAVE_GBM_MODIFIERS is unset, make the code drop back
to a single plane version like other places in the code.
2019-11-12 12:57:09 -05:00
Marius Vlad 28bb2da0ba backend-drm: Print whenever a view could not placed on the primary due to
invalid size

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2019-11-11 16:51:48 +00:00
Marius Vlad 555bfaf617 backend-drm: Print whenever a view will reach the renderer region
Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2019-11-11 16:51:48 +00:00
Marius Vlad 36f11a53e1 backend-drm: Move plane's availability in drm_output_try_view_on_plane()
It makes much more sense to be there. It adds some additional drm_debug()
statements to provide reason for failing to place the view in the HW
plane. Makes the reason for failing more accurate.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
Suggested-by: Daniel Stone <daniel.stone@collabora.com>
2019-11-11 16:51:48 +00:00
Marius Vlad eef694547d backend-drm: Pass the drm_fb to each prepare_overlay/scanout_view functions
Avoids the need to retrieve the DRM framebuffer in each function and
re-uses the one got before constructing the zpos candidate list.

Takes another reference for the scanout as to live the state, like
there's one for the overlay bit.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2019-11-11 16:51:48 +00:00
Marius Vlad 677e4598d9 backend-drm: Pass the plane to prepare_overlay_view
As we already have a potential plane available to use, pass it
over the _prepare_overlay_view instead of trying to find one
from the backend plane list.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
Suggested-by: Daniel Stone <daniel.stone@collabora.com>
2019-11-11 16:51:48 +00:00
Marius Vlad 80a62e5873 backend-drm: Allow for views to reach overlays/underlays planes
In this manner we will allow views to reach the overlay (or underlays)
even if the damage tracking will detect that the new view will
occlude the view underneath it.

Renames occluded_region to planes_region, and uses occluded_region
to represent the region where we add each view's visible-and-opaque region.
Sprinkle some comments about each region.

Re-uses the view's clipped region to determine visible-and-opaque region
which is accumulated (for both renderer and HW planes cases) into
occluded_region. The current view's clipped_region is then checked against
occluded_region.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
Suggested-by: Daniel Stone <daniel.stone@collabora.com>
2019-11-11 16:51:48 +00:00
Marius Vlad 26dcce06d7 backend-drm: Check pixel format before constructing the zpos candidate list
We can determine if the pixel format used by the clients buffer is
scan-out capable much sooner, so do it when constructing the zpos
candidate list. It also removes the checks in their respective
prepare_ functions.

Avoids the situation where we'd need to retrieve the DRM framebuffer each time
when checking the pixel format.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2019-11-11 16:51:48 +00:00
Marius Vlad 3b13f56a1d backend-drm: Place pixel format checks for the cursor plane in its own
function

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2019-11-11 16:51:48 +00:00
Marius Vlad 4eeb402553 backend-drm: Place pixel format checks for the overlay plane in its own
function

The idea is to place pixel the format checks in a common part and until
then, to make it available as a function so we can re-use easily.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2019-11-11 16:51:48 +00:00
Marius Vlad 2538aaccc7 backend-drm: Construct a zpos candidate list of planes
In order to better optimize view assignment to HW planes, we construct
an intermediary zpos candidate list which is used aggregate all suitable
planes for handling scan-out capable client buffers.

We go over it twice: once to construct it and once to pick-and-choose a
suitable plane based its highest zpos position.

In order to maintain the view order correctly we track current zpos
value being applied to the plane state and use it when trying to place
a view into a plane.

Pass the computed zpos value to be applied to the plane state.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
Suggested-by: Daniel Stone <daniel.stone@collabora.com>
2019-11-11 16:51:48 +00:00
Marius Vlad 47e3d1e481 libweston: Add a new helper to check if the view spawns the entire
output

Helpful to determine if the view can go through the scanout or not.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2019-11-11 16:51:48 +00:00
Marius Vlad 5f6bee49ed libweston: Add a new helper weston_view_has_valid_buffer
Helper to determine if the buffer attached to the view is valid.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2019-11-11 16:51:48 +00:00