Commit graph

347 commits

Author SHA1 Message Date
Pekka Paalanen 3728d7e99b backend-drm,pipewire,remoting: do not set monitor serial to "unknown"
If serial is unknown, it's best to leave it as NULL. All usage sites
already deal with it possibly being NULL.

This makes DRM-backend consistent with all other backend that leave
serial as NULL, allowing to move the initialization of these fields into
core.

Pipewire and remoting plugins are modified just for consistency.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2023-09-15 06:56:59 +00:00
Tomohito Esaki 1e781d9f88 drm-backend: Drop support libgbm older than 21.1.1
Since drm-backend requires libgbm 21.1.1 or later, there is no need to
support the old libgbm which does not support modifiers or fd import.

Signed-off-by: Tomohito Esaki <etom@igel.co.jp>
2023-08-09 21:45:42 +03:00
Marius Vlad 0713ea7ee6 backend-drm/meson.build: Require at least mesa 21.1.1
We seem to be using at least mesa 21.1.1 since Weston 10, but we never
explicitly asked for it.

Fixes: #790

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2023-08-02 15:42:19 +03:00
Philipp Zabel 1d59530e4b libweston: Set the presentation clock in the compositor
Let backends declare the presentation clocks they can use with a
new bitfield weston_backend::supported_presentation_clocks and set
presentation clock after loading the backend in the compositor.

Make weston_compositor_set_presentation_clock() internal and replace
weston_compositor_set_presentation_clock_software() with an exported
weston_compositor_backends_loaded(), which is called by the compositor
after the backend is loaded.

In the future, this can be extended to determine the subset of clocks
supported by all backends.

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
2023-08-02 11:51:56 +03:00
Marius Vlad 3e4aff6af4 backend-drm: Make DRM_CAP_ATOMIC_ASYNC_PAGE_FLIP inert
Until kernel mainline does merge the aysnc page flip ioctl, make the
whole bit look like it's unsupported. We can further switch it back when
it lands into the kernel.

Fixes: 9203d98f

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
Reported-by: Simon Ser <contact@emersion.fr>
2023-07-18 14:58:08 +03:00
Derek Foreman c4725f509f drm: allow views on more than one output to be on a plane
Now that planes are attached to paint nodes, we no have no reason to
prevent placing a view on a plane when it's on multiple monitors.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2023-07-11 07:26:43 -05:00
Derek Foreman ee7971e2cd libweston: have one primary_plane per output
The primary_plane is currently shared amongst all outputs, and is the last
barrier to having overlapping outputs.

Split it up and make it per output instead.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2023-07-11 07:26:43 -05:00
Derek Foreman 5f0eaeb083 drm: Don't stack sprite planes above primary on init
We don't need to do this, we can just leave them in the plane list until
they're used.

Also, doing so helps for when we want to move the primary_plane from
the compositor to the outputs in the future.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2023-07-11 07:26:43 -05:00
Derek Foreman 820346a372 libweston: Track damage on paint nodes instead of planes
Remove plane->damage and instead accumulate damage on paint
nodes.

This is a step towards allowing multiple overlapping outputs.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2023-07-11 07:26:43 -05:00
Derek Foreman fe2b5db01e libweston: Track plane in paint node instead of view
Tracking the view's plane in the paint node in this way is a step towards
inflicting plane damage from paint node update during the output repaint,
instead of manually doing weston_view_damage_below().

We remove view->plane entirely and do all access through pnodes.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2023-07-11 07:26:43 -05:00
Derek Foreman f07af89f9c libweston: Move output damage subtraction out of backends
Right now every backend clears output damage from the primary plane when
it repaints. Instead of having this same operation spread across all
the backends, just do it in the core instead.

In the future, we want to remove damage tracking from the primary plane
entirely, and this is a small step in that direction.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2023-07-11 07:26:43 -05:00
Derek Foreman a9986ef984 libweston,backends: assert if z_order_list contains pnodes for wrong output
We've just made this impossible, so we can now clean up all the TODO
locations.

I've only turned some of them into assert()s, because they're all mostly
in the same place.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2023-07-11 07:26:23 -05:00
marius vlad 3044d8ed72 backend-drm: Use resize_output to allow changing the fb
A video mode change would be needed to change the underlying renderer
framebuffer. All other backends make uses of this so let's do it for the
DRM-backend as well.

This would also be needed for the output capture to function properly as
we need call weston_output_update_capture_info() when a new mode set has
set. Otherwise we'd run into mismatched dimensions for the current mode
versus the dimensions set-up initially in weston_output_capture_source_info.

Signed-off-by: marius vlad <marius.vlad@collabora.com>
2023-07-04 11:41:29 +00:00
Philipp Zabel 90c11cf40e libweston: move weston_compositor_shutdown call out of backends
If we want to support multiple backends, the compositor must take care
to call this once, at the appropriate moment, so stop letting the
backends handle compositor shutdown themselves.

Move the weston_compositor_shutdown() calls from the backend::destroy
callbacks into weston_compositor_destroy() and the calls in the backend
creation error paths into weston_compositor_load_backend().

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
2023-06-27 12:09:47 +01:00
Philipp Zabel 6d699c3f54 libweston: add weston_backend::shutdown callback
Add a weston_backend::shutdown callback to split out the part of
weston_backend::destroy that needs to be done before compositor
shutdown.

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
2023-06-27 12:09:45 +01:00
Leandro Ribeiro f9ef4e64ea backend-drm: fix possible leak of struct drm_output
Before this patch, we would leak the drm_output if there was a pending
flip during shutdown.

Now we destroy the drm_output even if there's a pending flip (only
during shutdown, as we don't want to wait until flip completion to
destroy the output).

Also, it fixes a problem where weston_output_enable() is called right
after weston_output_enable() or weston_output_disable() and it could
fail to find available DRM objects (as they are only released after
the flip completion).

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
2023-06-27 10:57:12 +00:00
Daniel Stone be55909779 backend-drm: Don't leak writeback-format property blob
We were freeing the writeback-format blob on error, but not on success.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2023-06-19 21:32:47 +01:00
Daniel Stone 9aa68248a9 backend-drm: Use weston_compositor.shutting_down
We previously had our own local variable for this, but now we can just
use the one in weston_compositor.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2023-06-19 21:32:47 +01:00
Derek Foreman e8208d21d7 libweston: Use weston_coord in struct weston_output
Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2023-06-12 16:55:22 -05:00
Leandro Ribeiro 3226417573 drm: do not pull writeback task if KMS atomic API is not supported
Since 2d70bdfdcd "drm-backend: add support
to output capture writeback source", the DRM-backend was broken for KMS
devices that do not support the atomic API. This fixes that.

We don't support writeback screenshots without atomic modeset support.
So for such devices, we never update the output capture info
(weston_output_update_capture_info()) for the writeback source.

The function that we use to pull writeback tasks
(weston_output_pull_capture_task()) asserts that the capture providers
(renderers, DRM-backend) did not forget to update the capture info
(size/format) if something changed. But as we've never updated the
capture info for such devices, it is zeroed, leading to an assert hit.

With this patch we only pull the capture task for KMS devices that
support the atomic API.

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
2023-06-05 07:51:27 +00:00
Leandro Ribeiro 6d8e3c569c drm: drop disable_planes being false as a condition to support writeback
In 2d70bdfdcd "drm-backend: add support to
output capture writeback source" we've ensured that disable_planes
should be false in order to support writeback capture tasks.

But this was wrong; disable_planes is transient (it is true when
there's some sort of content recording happening), and we enable/disable
that during compositor's lifetime.

This is dangerous and may result in a crash. Imagine the following
sequence:

        1. screen recording starts, disable_planes is set to true.

        2. for whatever reason the output size changes, and we end up
        not updating capture info because we think that writeback is not
        supported by the device.

        3. screen recording stops, disable_planes is set to false.

        4. user tries to take a writeback screenshot, and the
        DRM-backend will pull a writeback capture task with
        weston_output_pull_capture_task().

        5. this function has an assert to ensure that the DRM-backend
        did not forget to update the capture info, and we hit that
        assert.

With this patch we drop disable_planes being false as a condition to
support writeback. So now we keep the capture info up-to-date even when
screen recording is happening, and we gracefully fail writeback tasks.

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
2023-06-05 07:51:27 +00:00
Pekka Paalanen 8ca6c24c8f backend-drm: drop HDR without libdisplay-info
Hardcode the ad hoc EDID parser to always claim that only SDR is
supported. Even though libdisplay-info is not yet asked for HDR
capabilities, it shall be the only way to see them.

To be nicer to experimenters, main.c adds a note that you really need
libdisplay-info if you want to play with HDR.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2023-04-28 16:18:22 +03:00
Pekka Paalanen d6a4c58f07 backend-drm: use libdisplay-info
Add libdisplay-info as a better alternative for parsing EDID. This way
we do not need to extend Weston's ad hoc parser for new things that
especially HDR support requires.

Eventually the ad hoc parser will be deleted and libdisplay-info becomes
a hard dependency for the drm-backend, reducing our maintenance burden.
Unlike the ad hoc code, libdisplay-info has automated CI testing.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2023-04-28 16:18:22 +03:00
Pekka Paalanen 902697d08e backend-drm: add drm_head_info_from_edid()
Move the ad hoc filling code into a separate function. Then we can
easily add an alternative implementation of the new function using
libdisplay-info without messing up the code any more than necessary.

Pure refactoring.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2023-04-28 13:58:53 +03:00
Pekka Paalanen d48d571f0a backend-drm: move struct drm_edid definition
Now that this is used only internally in modes.c, move it there. It will
not be used with libdisplay-info.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2023-04-28 13:58:53 +03:00
Pekka Paalanen dfdb1a71f8 backend-drm: let EDID parser return malloc'd strings
This will make adding libdisplay-info as another EDID parser easier,
because libdisplay-info always returns malloc'd strings.

To make things easier to extend as well, I introduce struct
drm_head_info. The libdisplay-info case will likely return more
information than this in the future.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2023-04-28 13:58:53 +03:00
Philipp Zabel 9e070c0840 backend-drm: obtain DRM backend from listener in session_notify()
The session_listener is embedded in the DRM backend structure.
Use this to obtain the DRM backend with container_of().

That way the DRM backend will not have to be found from the compositor.
This is trivial now, but in the multi-backend case would entail
iterating over all backends to find the correct one.

Signed-off-by: Philipp Zabel <philipp.zabel@gmail.com>
2023-04-19 13:36:45 +00:00
Michael Tretter bcacd9ec5a backend-drm: schedule connector disable for detached head
Currently, if a head is detached, the entire state of the device is invalidated
to make sure that the connector is disabled on the next atomic commit. Side
effect of the invalid state is that all planes are disabled on the next commit.
This includes planes that are used with a different head that is not part of the
next atomic commit. Disabling the planes of unrelated outputs causes a blanking
of these outputs until output is repainted and the plane is reenabled.

Store the detached heads in a list on the output and disable the connectors for
all heads in this list in the next atomic commit.

Signed-off-by: Michael Tretter <m.tretter@pengutronix.de>
2023-04-18 11:11:21 +02:00
Daniel Stone 27617ec937 drm: Fix type confusion in writeback_state
wl_array_for_each() returns a pointer to each storage location; as we're
storing a pointer to drm_fb, this means that we have a drm_fb **, not a
drm_fb *.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2023-04-04 11:30:52 +00:00
Leandro Ribeiro f95c2986dd drm: allow to skip composition if pending capture is writeback
We have an optimization to skip composition if there's no damage on the
primary plane and we already have a renderer buffer active. But we don't
allow this optimization if there's a pending capture task for the
output. For the renderer-based sources, that is really necessary, but
for the writeback source we should allow this optimization.

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
2023-03-31 10:36:31 +00:00
Andrew F. Davis 94afcbcdc3 backend-drm: Select plane based on current attached CRTC
When doing plane selection for an output CRTC check if the plane
already has a CRTC attached and if so prefer that plane only for
the corresponding CRTC.

This prevents changing a CRTC's primary plane when it is active
which is not allowed by the DRM framework.

Based-on-patch-by: Eric Ruei <e-ruei1@ti.com>
Signed-off-by: Andrew F. Davis <afd@ti.com>
2023-03-30 17:51:33 +01:00
Veeresh Kadasani c0f3cb87be backend-drm: Pass view alpha to plane state and commit
We map view alpha(0.0-1.0) to plane state's alpha
by using the max plane alpha value got from drm.

Signed-off-by: Hsuan-Yu Lin <hlin@jp.adit-jv.com>
Signed-off-by: Veeresh Kadasani <external.vkadasani@jp.adit-jv.com>
Signed-off-by: Vinh Nguyen Trong <Vinh.NguyenTrong@vn.bosch.com>
2023-03-30 17:29:57 +01:00
Veeresh Kadasani f35eccc6fa backend-drm: Add plane alpha DRM-property
This checks whether plane alpha is supported.
We get range of alpha value supported for plane
which is required for mapping view's alpha(0.0-1.0)
with drm plane alpha. No functional change.

Signed-off-by: Hsuan-Yu Lin <hlin@jp.adit-jv.com>
Signed-off-by: Veeresh Kadasani <external.vkadasani@jp.adit-jv.com>
Signed-off-by: Vinh Nguyen Trong <Vinh.NguyenTrong@vn.bosch.com>
2023-03-30 17:29:07 +01:00
Leandro Ribeiro 6517accf7e backend-drm: cosmetic changes to dmabuf_feedback_maybe_update()
Cosmetic changes that makes dmabuf_feedback_maybe_update() easier to
read.

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
2023-03-28 16:23:44 -03:00
Leandro Ribeiro c9b7c7085a backend-drm: add scanout tranche even for views eligible for direct scanout
We log the reasons why the fb of a certain view was not placed in an
overlay plane and use that for debug purposes. With these reasons we
also decide if the scanout tranche should be included on the dma-buf
feedback or not. For instance:

  1. If the reason is the incompatibility between the format/modifier
     pair of the fb and those supported by the KMS device, the scanout
     tranche is added and feedback is re-sent (so that the client can
     re-allocate with parameters that makes it eligible for direct
     scanout).

  2. If the reason is because we have no overlay planes available, the
     scanout tranche is useless. So the scanout tranche is removed and
     the feedback re-sent (so that clients can re-allocate with
     parameters optimal for the render device).

Also, when we detect that a view is eligible for direct scanout, we
don't even consider sending new feedback, as our interpretation of the
dma-buf feedback spec was that we should avoid bothering clients with
new feedback when they are already hitting direct scanout.

After some discussions and clarifications regarding the spec, we've
realized that Weston should start to also include the scanout tranche
even when the compositor is able to place client's content on overlay
planes. Basically, because this gives a chance for clients to
re-allocate with the proper parameters (not only format/modifier pair,
but also the target_device and the flags) from the scanout tranche. In
this patch we start doing this.

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
2023-03-28 16:23:44 -03:00
Leandro Ribeiro 0251c05212 backend-drm: remove scanout tranche when there are no planes available
It makes no sense to keep the scanout tranche on the dma-buf feedback if
there are no overlay planes available. So start to remove it.

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
2023-03-28 16:23:44 -03:00
Leandro Ribeiro 8fc9d68ffa backend-drm: change dmabuf_feedback_maybe_update() return type to void
As we are not using the returned value, so let's change to void.

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
2023-03-28 16:23:44 -03:00
Leandro Ribeiro 025ed4573c drm-backend: move aux function up to remove unnecessary declaration
Simple cosmetic change.

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
2023-03-22 09:37:37 -03:00
Leandro Ribeiro dc27a52216 drm-backend: address case in which writeback takes longer than atomic commit
In commit "drm-backend: add writeback connector screenshooter to
DRM-backend" we were failing the writeback screenshot when the DRM/KMS
driver would take longer than the atomic commit to finish. In this patch
we address such case.

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
2023-03-22 09:37:37 -03:00
Leandro Ribeiro 5b04895835 drm-backend: add writeback connector screenshooter to DRM-backend
In this patch, we add the writeback connector screenshooter to the
DRM-backend.

This will be useful to create plane composition tests that will run in
our CI, as VKMS already supports writeback connectors.

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
2023-03-22 09:37:37 -03:00
Leandro Ribeiro 2d70bdfdcd drm-backend: add support to output capture writeback source
With this change, we expose the DRM-backend writeback source through the
output capture interface, making it available to clients.

For now we'll always fail writeback screenshots requests, because we
still don't have the writeback screenshooter implementation on the
DRM-backend. We add that in the following commits.

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
2023-03-22 09:37:37 -03:00
Leandro Ribeiro 247d492d64 drm-backend: add supported formats for writeback connectors
In the following commits we add a writeback screenshooter. For that,
we'll need the formats supported by the writeback connectors. So include
the supported formats in struct drm_writeback.

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
2023-03-22 09:37:37 -03:00
Michael Olbrich d5e5428478 backend-drm: don't copy the fence fd when duplicating the plane state
The state does not own the fd. This is usually not a problem, because the
in_fence_fd of the state is assigned during drm_assign_planes() and then
immediately used in drm_repaint_flush(). It cannot be closed in-between.

However, in the fallback path in drm_output_start_repaint_loop(), the state is
duplicated. At this point in time, the in_fence_fd may be invalid because it was
replaced in a new commit of the corresponding surface.

The plane state was already committed to the kernel when it is copied, so the
fence is no longer needed. So just clear it.

Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
2023-03-22 11:41:56 +00:00
Michael Olbrich 0edcc9e5ba backend-drm: don't try to commit an empty state
With multiple DRM devices, the state for one device may be empty during
repaint_flush(). This can happen for example if an output of one device triggers
the repaint and there are no screens attached to the other device and therefore
no active outputs.

The atomic commit will actually fail because the commit contains the
DRM_MODE_PAGE_FLIP_EVENT flag but no CRTCs.

Avoid this by skipping the commit entirly. There is nothing to to anyways.

Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
2023-03-22 11:38:17 +00:00
Michael Tretter 3c6cfe6bf4 backend-drm: add additional-devices to support multi GPU
Add the --additional-devices parameter to Weston to add secondary drm devices
that will only be used as outputs, but not for rendering.

We can only fail the repaint for the entire backend, but not for single
devices. Thus, if one of the devices fail, we have to fail the repaint for the
entire backend.

Signed-off-by: Michael Tretter <m.tretter@pengutronix.de>
2023-03-03 08:08:46 +00:00
Michael Tretter 3f9f4277c3 backend-drm: import cursors on non gbm outputs
Additional devices don't have a gbm device. Therefore, we cannot create gbm bos
for the cursor.

If the output device differs from the gbm device, fall back to the allocation of
a dumb buffer for the cursor on the output device. Update the cursor sprite with
a memcpy to the already mapped dumb buffer that belongs to the current cursor.

Signed-off-by: Michael Tretter <m.tretter@pengutronix.de>
2023-03-03 08:08:46 +00:00
Michael Tretter 7887d3fb48 backend-drm: import GBM bo to scanout device if necessary
If the GBM bo was allocated on a different device than the device that is used
for the fb, we have to import the fd first and update the handle.

Use drmPrimeFDToHandle directly instead of using a gbm device for the scanout
device, since a gbm device would require a gbm implementation, which is often
not available for devices that only support scanout.

Signed-off-by: Michael Tretter <m.tretter@pengutronix.de>
2023-03-03 08:08:46 +00:00
Michael Tretter 575804c7e1 backend-drm: use linear buffers if gbm and kms device differ
If we are using multiple GPUs and are not able to use modifiers to ensure that
the formats are compatible, we have to use linear buffers for the transfer.

Signed-off-by: Michael Tretter <m.tretter@pengutronix.de>
2023-03-03 08:08:46 +00:00
Michael Tretter f05029127c backend-drm: allow to create multiple drm_fb for a weston_view
Weston uses a cached drm_fb when a view is shown multiple times. If the view is
shown on multiple outputs backed by different DRM devices, Weston returns the
cached drm_fb for the first device that was used for the import. This causes a
failure when adding the fb to the other device.

Use a list of all drm_fbs to cache the buf_fb per device, and check for the
device before reusing a drm_fb.

Signed-off-by: Michael Tretter <m.tretter@pengutronix.de>
2023-03-03 08:08:46 +00:00
Michael Tretter a8fb329335 backend-drm: create faked zpos for device instead of backend
The faked z position must be created for each device. Therefore, the device
itself must be passed to the function. If only the backend is passed, the faked
z position would be only created for the primary device.

Signed-off-by: Michael Tretter <m.tretter@pengutronix.de>
2023-03-03 08:08:46 +00:00