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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
This is needed by drm_output_fini_egl() to be able to retrieve the
backend out of the drm_output on the shutdown path of the compositor.
Both the remoting plug-in and the pipewire plug-in are users of the
drm-virtual API and as such they would trigger a crash when shutting
down the compositor, as we're not setting up any backend whatsoever.
Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
Convert the bare x,y coordinates into struct weston_coord and update all
users.
We keep the surface position in wl_fixed_t for now so it still exactly
matches the position most recently sent to clients.
Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
Starting with commit 4cde507be6 "backend-drm: fix plane sorting" the
plane list will have a descending order of the planes rather than ascending.
This reversed order had the side-effect of exposing the fact that we
don't set-up a plane index when creating the drm_plane using the DRM
virtual API. Without settting a plane index for that drm_plane we
effectively overwrite the plane index which has the 0 (zero) entry.
This wasn't an issue before commit 4cde507be6 "backend-drm: fix
plane sorting" as it seems we never picked up that plane index as
being a suitable one due to the fact that those were assigned to primary
planes, but after that commit, the cursor plane will be one getting
the 0 (zero) plane index.
Finally, this would trip over because we attempt to place a (cursor)
view on a primary plane (where it would've normally be a cursor
plane) and we end up with no framebuffer ref.
This is fixed trivially by assigning a plane index, different than the
ones already created by create_spirtes().
Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
Search for planes that support the rotation required to properly display
a paint node, and properly set coordinates and rotation properties.
Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
For now we just always set the plane up to have a "normal" rotation, so
no new features are added with this commit.
Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
From our perspective, a bitmask is pretty much the same as an enum, so
allow it to use the same path.
Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
We can clear this via drm_plane_state_put_back() at the end of
drm_output_propose_state(). We need to set it back to the minimum zpos
when rendering.
Signed-off-by: Derek Foreman <derek.foreman@collabora.com>