Commit Graph

365 Commits

Author SHA1 Message Date
Pekka Paalanen
f880732004 backend-drm: rename eotf_list to str
I want re-use this variable for printing the colorimetry mode list as
well in a future patch, so a generic name is less confusing.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2024-01-29 15:22:33 +02:00
Pekka Paalanen
fc0a74a4c9 backend-drm: skip EDID parsing if no change
Performance-wise this is moot, but since we are detecting if the raw
EDID data changed, might as well use it.

Now we have a path where the head's device_changed is almost guaranteed
since EDID changed, and that's useful for the next patch.

We can only do this, because the core initializes a head with values
that we would be setting anyway when EDID is missing, e.g. disconnected
head on compositor start-up.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2024-01-29 15:22:27 +02:00
Pekka Paalanen
2c0a9c064a backend-drm: store EDID data
Store the EDID data as-is, so that we can tell when the EDID blob has
changed. This is not too useful yet, because all the weston_head_set_*()
API raises the device_changed flag only if the information actually
changes. However, I want to expose the libdisplay-info di_info structure
through weston_head, and those cannot be (as) easily compared.

We need to know when the EDID blob changes, so we can call
weston_head_set_device_changed() appropriately when updating di_info.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2024-01-29 15:20:04 +02:00
Robert Mader
e34e027515 backend-drm: Sort planes by faked zpos
Just like we already do for planes with proper zpos. Otherwise we'll
often end up choosing the primary plane instead of an overlay one
in `drm_output_find_plane_for_view()`.

Signed-off-by: Robert Mader <robert.mader@collabora.com>
2024-01-22 17:16:19 +01:00
Ray Smith
885c616589 backend-drm: fix confused fallback format handling
This seems to think formats needs to be NULL terminated, but it doesn't
and gl_renderer_get_egl_config asserts that all formats_count elements
are not NULL.

This happens when EGL_KHR_no_config_context is not supported.

Signed-off-by: Ray Smith <rsmith@brightsign.biz>
2024-01-22 09:29:01 +00:00
Robert Mader
e37454a262 linux-dmabuf: Add support for protocol version 5
It adds the followig paragraph:
```
Starting from version 5, the invalid_format protocol error is sent if
all planes don't use the same modifier.
```

We already assumed this in some places and, most importantly, it's
required by the kernel. Thus alter `dmabuf_attributes.modifier` to make
it clear that different modifiers for multi-planar dmabufs were never
supported.

Signed-off-by: Robert Mader <robert.mader@collabora.com>
2024-01-19 18:59:22 +01:00
Zhou Liang
b288e662d6 backend-drm: fix deinit unexpected connector
The `drm_output_deinit` should use the drm device passed by the
function, should not use the `b->drm` device.

Signed-off-by: Zhou Liang <174381115@qq.com>
2024-01-12 12:11:45 +00:00
Zhou Liang
66aaa41074 backend-drm: fix drm add connector to unexpected drm device
If both the head and writeback are not found, then we should add
connectors to the drm device passed by the function, not the b->drm
device.

Signed-off-by: Zhou Liang <174381115@qq.com>
2024-01-12 12:11:45 +00:00
Zhou Liang
8b3becf524 backend-drm: fix drm find wrong connector
In a multi-GPU environment, different cards may contain connectors with the
same ID, and drm_head_find_by_connector just use the connector_id to find
the connector, it may find the wrong connector.
Fix this by find the connector based on the drm device and connector id.

Signed-off-by: Zhou Liang <174381115@qq.com>
2024-01-12 12:11:45 +00:00
Robert Mader
5a2509ffb1 backend-drm: Don't force non-opaque overlays to primary plane
If a view is non-opaque - such as an overlay over a video - we shouldn't
force it to be on the primary plane, as that's where the underlying
content should be placed, such as the video view.

dc0de9ee already mentioned: "This check should be changed in future to
only filter for opaque views, but that's for another time."

Adding "Fixes" at this is arguably a bug fix:
Fixes: dc0de9ee (backend-drm: Move overlay vs. primary plane check earlier)
Fixes: 2538aacc (backend-drm: Construct a zpos candidate list of planes)

Signed-off-by: Robert Mader <robert.mader@collabora.com>
2024-01-11 15:57:09 +01:00
Derek Foreman
2abe4efcf7 libweston/backends: Move damage flush into backends
Currently we flush damage for the "primary plane" every repaint, but this
is folly.

The drm backend may skip rendering entirely if using an all-planes
composition. This could leave the renderer plane in a messy state if a
surface on an overlay plane disappears.

Instead, let the backends flush the primary plane damage when they know
they need to render.

Fixes #864

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2024-01-10 14:13:09 -06:00
Khem Raj
dbd134ca5a libweston,tools: Include libgen.h for basename signature
Latest musl has removed the declaration from string.h [1] as it only
implements POSIX version alone and string.h in glibc implements GNU
version of basename. This now results in compile errors on musl.

This might be a warning with older compilers but it is error with
Clang-17+ as it treats -Wimplicit-function-declaration as error

Switch the use in backlight_init function to use POSIX version

[1] https://git.musl-libc.org/cgit/musl/commit/?id=725e17ed6dff4d0cd22487bb64470881e86a92e7

Signed-off-by: Khem Raj <raj.khem@gmail.com>
2023-12-18 21:13:52 +00:00
Derek Foreman
78657c5ff3 drm-backend: Fix cursor updates with overlapping heads
We can't use the surface damage to determine when to upload new cursor
images because when heads overlap the first repainted head will accumulate
that damage as plane damage.

We can't easily use plane damage either because the plane isn't really
assigned until after an atomic test, which requires the cursor fb to be
current.

Untangle this mess a little by always testing with the first cursor fb,
which is identical to the second in all ways, then replace with the correct
fb in repaint.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2023-11-10 09:38:41 -06:00
Derek Foreman
754562fb52 Revert "launcher: Remove launcher-logind"
This reverts commit 55bf6b5046.

This accidentally removed things that should have stayed - libseat
can still use the logind API, even if weston doesn't directly use
it.

Note that the logind-launcher does not actually build anymore
because breaking changes landed before this revert.

Since we're removing it again right away, I've not taken care to
fix that.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2023-09-29 09:46:48 -05:00
Philipp Zabel
281aa0a4d7 backend-drm: enable multi-backend support
Insert the backend into the weston_compositor::backend_list instead
of setting weston_compositor::backend. The compositor uses this to
determine that the backend is capable of being loaded simultaneously
with other backends.

The DRM backend can only be loaded as primary backend.

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
2023-09-28 14:02:04 +00:00
Leandro Ribeiro
08018d3a28 linux-dmabuf: replace assert with the new weston-assert
Make use of the new weston-assert in linux-dmabuf.c

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
2023-09-28 06:52:24 +00:00
Derek Foreman
55bf6b5046 launcher: Remove launcher-logind
This has been deprecated and non-default for a full release cycle, so
we're going to remove it now.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2023-09-28 06:47:06 +00:00
Pekka Paalanen
d79fc78152 libweston: set default monitor strings
Allow passing NULL to monitor string in order to set the default
"unknown" strings. This allows a head to be initialized with the default
strings, meaning that it will no longer be mandatory for a backend to
call weston_head_set_monitor_strings(). In DRM-backend case this makes
future changes more convenient.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2023-09-15 06:56:59 +00:00
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