Commit graph

10517 commits

Author SHA1 Message Date
Pekka Paalanen
a17d5b4eb2 color: validate luminances more
Make sure the given values are finite, positive, and non-zero where
appropriate.

Because these validations are not mandated in the color-management
protocol, they are not immediate failures. They will fail the final
image description creation.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2025-10-07 17:23:35 +03:00
Pekka Paalanen
6fbc1376ee color: improve profile builder errors
Statements phrased positive are easier to understand than phrased
negative. Use "must" instead of "should".

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2025-10-07 17:23:35 +03:00
Pekka Paalanen
3f150b090b color: fix CIE value validation
The old code checked x for low limit and y for high limit, rather than
checking both for both limits. Fix this.

Check all value pairs rather than the first one four times. Don't stop
at the first error, record them all.

While at it, we might as well print exactly what value was the problem.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2025-10-07 17:23:35 +03:00
Pekka Paalanen
d180517ae4 color: move validate_color_gamut() up the file
This is a simple move of code, no changes. The next patch needs it here.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2025-10-07 17:23:35 +03:00
Robert Mader
8e30a7efc7 clients: screenshot: YUV support
If any output uses a YUV format, instead of trying to composite into a
png, write the raw data into .yuv files for each output.

These files don't contain any metadata yet, thus one may want to convert
them into y4m files with e.g. a command like the this:
ffmpeg -s 1024x768 -r 1 -pix_fmt yuv420p -i ~/wayland-screenshot-output-0-2025-08-01_15-58-24.yuv -c:v copy screenshot.y4m

Note that this may only work for certain pixel formats, such as
DRM_FORMAT_YUV4[20|22|44], and not for e.g. DRM_FORMAT_P010.

Signed-off-by: Robert Mader <robert.mader@collabora.com>
2025-10-07 11:48:33 +02:00
Robert Mader
a9fc1fc0f7 clients: screenshot: Fixup --help command line option
Signed-off-by: Robert Mader <robert.mader@collabora.com>
2025-10-07 11:48:33 +02:00
Robert Mader
a09895e907 clients: screenshot: Support dmabuf passthrough for writeback connectors
Instead of relying on the compositor to allocate dmabufs for the
writeback connector and copying the results to the client-provided
shm-buffer, support allocating dmabufs in the client. The compositor
will pass them through to the writeback connector, effectively doing
the equivalent to "passthrough"/"plane-offloading"/"zero-copy".

Based on a patch by Chien Phung Van <chien.phungvan@vn.bosch.com>

Signed-off-by: Robert Mader <robert.mader@collabora.com>
2025-10-06 16:04:18 +02:00
Robert Mader
722f0a2664 tests: drm-writeback-screenshot: Test client dmabuf support
Which is not supported with Pixman, thus test the GL and VK renderers.

This ensures the code-path for directly forwarding client-allocated
dmabufs to the writeback connector works as expected.

Signed-off-by: Robert Mader <robert.mader@collabora.com>
2025-10-06 15:53:45 +02:00
Robert Mader
e6b67d2c72 shared/client-buffer-util: Sync for read as well
In the next commit we will need syncing for reading. Thus adapt the sync
helper accordingly. We are not using the helper for performance-critical
tasks yet, thus there's currently no strong reason to allow users to
differentiate between the cases.

Signed-off-by: Robert Mader <robert.mader@collabora.com>
2025-10-06 14:06:30 +02:00
Robert Mader
203dbd3393 tests: client-helper: Make client_capture_output() take a client_buffer_type
Using the newly introduced create_buffer(), to which the buffer type is
passed on in order to allow taking writeback screenshots with dmabufs.

Signed-off-by: Robert Mader <robert.mader@collabora.com>
2025-10-06 14:06:30 +02:00
Robert Mader
23f396aa30 tests: client-helper: Add create_buffer() helper
Taking the newly introduced client_buffer_type enum, allowing simple
creation of dmabuf buffers.

Signed-off-by: Robert Mader <robert.mader@collabora.com>
2025-10-06 14:06:30 +02:00
Robert Mader
e27929e3b3 shared/client-buffer-util: Add buffer type enum
This will be helpful in follow-up commits.

Signed-off-by: Robert Mader <robert.mader@collabora.com>
2025-10-06 14:06:30 +02:00
Robert Mader
618bfad1d4 libweston: Get framebuffer from dma buffer in drm backend
If the client requests to take a screenshot using the writeback source
with a DMA buffer, Weston will get the framebuffer from that dmabuf
object and attach it to the writeback connector.

Original commit by Chien Phung Van.

Signed-off-by: Robert Mader <robert.mader@collabora.com>
Co-authored-by: Chien Phung Van <chien.phungvan@vn.bosch.com>
2025-10-06 14:06:30 +02:00
Erico Nunes
ad0f4cf94b vulkan-renderer: make dmabuf import dedicated allocation optional
This is not strictly always necessary depending on the implementation,
so the extension requirement can be made optional.
Also improve its usage by first checking whether the dedicated
allocation is preferred/required by the driver, before importing
with dedicated allocation.

Signed-off-by: Erico Nunes <nunes.erico@gmail.com>
2025-10-02 21:22:45 +01:00
Robert Mader
6cc8f48cd8 clients: Paint desktop-shell color background with single-pixel-buffer
So the buffer has the WESTON_BUFFER_SOLID type, which will make
additional optimizations easier going forward.

Signed-off-by: Robert Mader <robert.mader@collabora.com>
2025-10-02 17:05:22 +01:00
Marius Vlad
2497377af4 libweston/desktop/xwayland: Add MINIMZE state change
This is identical to MAXIMIZE side where we change the state to
MAXIMIZE, and implicitly go through a state surface check.

For XWAYLAND type of windows (non weston_desktop_surface)
that surface state check will be needed. This is a temporary work-around
to avoid Weston crashing as some X11 Window types will hit this path.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2025-10-02 08:43:46 +03:00
Derek Foreman
cb17b87a65 xwm: Fix crash when querying position of XWAYLAND windows
windows in the XWAYLAND state are popups and other such things that aren't
managed by libweston-desktop, so we crash if we query their position
with weston_desktop_api.

Query the position for these XWAYLAND windows based on their weston_view
and window geometry.

This should result in synthetic configure notify events no longer crashing.

Fixes #831
Fixes #1019

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2025-10-02 07:37:04 +03:00
liang zhou
1560cc3f0b compositor: prevent crash when moving view with popup on first output removal
In a multi-screen setup, removing the first screen triggers `handle_output_move`.
If `weston_view_set_position` is called on an output that has an active popup,
it causes a weston crash due to the view has a parent.

Signed-off-by: liang zhou <liang.zhou@gehealthcare.com>
2025-09-30 13:17:23 +00:00
Marco Felsch
4ba62103a6 backend-drm: set DRM_MODE_ATOMIC_ALLOW_MODESET during head disable
A change in the connector state require a possible full modest depending on the
hardware.

The connector wasn't set to unconnect if the head was detached while the output
is still enabled. Fix this by always checking the disable_head_link list during
drm_output_apply_state_atomic().

Signed-off-by: Marco Felsch <m.felsch@pengutronix.de>
2025-09-30 15:37:37 +03:00
Marco Felsch
9c67c8c0d8 backend-drm: chek DRM_MODE_ATOMIC_TEST_ONLY before remove from list
DRM_MODE_ATOMIC_TEST_ONLY shouldn't remove the head from the
drm_output::disable_head list else the head is lost for the actual modeset
action.

Signed-off-by: Marco Felsch <m.felsch@pengutronix.de>
2025-09-30 15:36:38 +03:00
liang zhou
0b540ba8d6 desktop-shell: Fix crash when fullscreen surface has no output
The shell_set_view_fullscreen function was dereferencing
shsurf->fullscreen_output without checking if it was NULL first. This
could lead to a crash when a fullscreen surface had no associated
output during display hotplug.

Fix issue: https://gitlab.freedesktop.org/wayland/weston/-/issues/1028

Signed-off-by: liang zhou <liang.zhou@gehealthcare.com>
2025-09-30 12:10:41 +00:00
Robert Mader
5e7835bf2b ci: Bump kernel and Mesa version
1. Bump the kernel version to the drm-misc-next-2025-09-04 tag, fixing
   various issues required for vkms testing.

2. Use /sys/bus/faux/devices/vkms/drm/ instead of /sys/devices/platform/vkms/drm/
   for the card basename.

3. Bump Mesa to the commit needed for vkms+lavapipe. This also needs another
   leak workaround, so the code got a small cleanup.

Signed-off-by: Robert Mader <robert.mader@collabora.com>
2025-09-26 14:12:04 +02:00
Robert Mader
e187420e38 output-capture: Fix protocol event order
The new formats_done event has to be at the end, triggering warnings
like the following otherwise:

warning: since version not increasing

Fixes: 00902a592 (output-capture: Allow multiple formats and add formats_done event)
Signed-off-by: Robert Mader <robert.mader@collabora.com>
2025-09-25 17:53:59 +02:00
Robert Mader
b6c1bc872e output-capture: Fix assertions in pull_capture_task()
Fixes: 9ea205e00 (output-capture: Support writeback connector formats)
Signed-off-by: Robert Mader <robert.mader@collabora.com>
2025-09-25 17:51:22 +02:00
Pekka Paalanen
be71b5a094 color-lcms: compare parameters with tolerance
Comparing floating-point values for identity is fragile. Comparaing with
a small tolerance allows for matches that differ only due to numerical
precision of computations.

The tolerance is taken from
weston_color_tf_info_from_parametric_curve().

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2025-09-25 18:03:31 +03:00
Pekka Paalanen
d7030571c5 frontend,color: print details of the set color profile
It is nice to see the numbers of a parametric color profile when created
from CTA or EDID or just to cross-check with weston.ini.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2025-09-25 18:03:31 +03:00
Pekka Paalanen
daec4a0994 color: print name of unsupported TF
Helps debugging when you have the name rather than a number.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2025-09-25 18:03:31 +03:00
Pekka Paalanen
f3badf2c2d color: introduce struct weston_color_tf
At first I wanted to wrap

	float tf_params[MAX_PARAMS_TF]

into a struct, so that it would become type-safe to pass into functions,
and it could be copied with a simple assignment. Then I noticed that for
tf_params to be operable, it must always be accompanied by struct
weston_color_tf_info. Hence, struct weston_color_tf was born.

The need for #define MAX_PARAMS_TF got eliminated.

Because struct weston_color_tf is a member of struct
weston_color_profile_params, now both need to not contain implicit
padding.

This patch makes the internal enumerated TF structures follow the
current protocol requests: all color channels use the same curve.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2025-09-25 18:03:31 +03:00
Pekka Paalanen
7b5053f7fa color: drop weston_color_curve_from_tf_info()
This was never used, and I happened to write a slightly different
version of it in color-lcms.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2025-09-25 18:03:31 +03:00
Pekka Paalanen
bcfa2724d2 color-lcms: fix TF_POWER from type 1 inverse
Forgotten early return. Without it, the code continues to set up LINPOW
instead.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2025-09-25 18:03:31 +03:00
Marius Vlad
bcb7676ed7 backend-drm: Add some further debug message for hot-plug events
And also for connector changes. This would allow tracking hot-plug
events from the udev/kernel and figure out that connector properties
changed.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2025-09-25 14:07:48 +01:00
Marius Vlad
fdb43447a2 backend-drm: Explicitly set an invalid state
A infinitesimal short-flip in HDMI HDP in-out (hot-plug event) would
cause a discrepancy between kernel's connector's state and Weston
connector state resulting in kernel and Weston disagreeing on the final
connector state.

This has the undesired effect where the output would never turn on when
this short burst of HDP events come through.

To avoid that, just set the device invalid_state as true to go through a
modeset.  Also, schedule a repaint when that happens to go through a
repaint.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2025-09-25 14:07:48 +01:00
Marius Vlad
794c1eb490 backend-drm: Allow to pass connector ID
This way we can differentiate when we get a HOTPLUG event that gave us a
CONNECTOR ID to work with.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2025-09-25 14:07:48 +01:00
Marius Vlad
aa04d9d4ad backend-drm: Refactor drm_backend_update_connectors
This splits drm_backend_update_connectors into
drm_backend_update_connector and a post destroy phase/function.

There's no functional change, but this allows to pass
drm_backend_update_connector() on its own as we'll need that.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2025-09-25 14:07:48 +01:00
Robert Mader
b6f890d249 clients: screenshot: Allow selecting format and capture source
Add support for using writeback connectors as source. Those potentially
support more than one format, thus allow selecting those as well.
While on it, add a verbose flag for useful debug output.

Signed-off-by: Robert Mader <robert.mader@collabora.com>
2025-09-25 12:39:26 +02:00
Robert Mader
9ea205e007 output-capture: Support writeback connector formats
Writeback connectors often support multiple formats, fully independent
of the input framebuffer. Wire up support for querying formats and send
them to clients.

Signed-off-by: Robert Mader <robert.mader@collabora.com>
2025-09-25 12:39:23 +02:00
Robert Mader
07a5ec8157 output-capture: Add output_get_writeback_formats helper
And implement it in the DRM backend. This will be used by the next
commit.

Signed-off-by: Robert Mader <robert.mader@collabora.com>
2025-09-25 11:26:21 +02:00
Robert Mader
00902a5921 output-capture: Allow multiple formats and add formats_done event
The writeback output capture source may allow clients to select from
multiple possible formats. Update the protocol and its users
accordingly, and add formats_done event, making the implementation
easier and following common protocol practice.

Signed-off-by: Robert Mader <robert.mader@collabora.com>
2025-09-25 11:26:16 +02:00
Robert Mader
967537d525 backend-drm: Populate writeback formats with modifier
The writeback connector UAPI does not mention modifiers explicitly,
however implicitly we assume and use a linear modifier when using
dumb buffers.

Adding that to the format thus makes the assumption more obvious and
allows us to use the weston_drm_format_array as intended.
For example we can now use weston_drm_format_array_count_pairs() to
log the number of supported formats - previously it always returned 0.

See
https://www.kernel.org/doc/html/v6.16/gpu/drm-kms.html#writeback-connectors

Signed-off-by: Robert Mader <robert.mader@collabora.com>
2025-09-22 12:25:31 +02:00
Robert Mader
3706d860f1 backend-drm/kms: Log writeback connector format
So it becomes easy to check in test output or when running
`weston-debug drm-backend`.

Signed-off-by: Robert Mader <robert.mader@collabora.com>
2025-09-22 12:25:31 +02:00
Erico Nunes
042aa06b28 vulkan-renderer: fix gbm_bo destroy in drm backend
Create a linux_dmabuf_memory subclass so that it holds the associated
gbm_bo and it can be properly destroyed with the dmabuf object.

Signed-off-by: Erico Nunes <nunes.erico@gmail.com>
2025-09-22 10:12:33 +02:00
Erico Nunes
b0c99998ef vulkan-renderer: drop fb get from create_renderbuffers
This is not required and creates a refcount imbalance,
causing a memory leak at drm-backend teardown.

Signed-off-by: Erico Nunes <nunes.erico@gmail.com>
2025-09-22 10:12:33 +02:00
Erico Nunes
41823d237b vulkan-renderer: remove unused allocation in renderbuffer dmabuf
Signed-off-by: Erico Nunes <nunes.erico@gmail.com>
2025-09-22 10:12:33 +02:00
Leandro Ribeiro
3026c44897 test: add color-effects test
Follow-up of "color: introduce output color effects". This adds a few
sanity tests for color effects.

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
2025-09-18 12:32:15 -03:00
Leandro Ribeiro
6fe0cfc2b8 color: introduce output color effects
Output color effects are applied to the whole output scenegraph. It
depends on color-management being disabled, as the color effects are
applied in sRGB content.

For now we added only a few accessibility options: color inversion,
deuteranopia, protanopia and tritanopia CVD correction.

Note that surfaces presented on outputs that contains a color effect
can't be used for direct scanout (i.e. bypass composition and offloading
to KMS overlay planes). The color effect is applied in our GL-renderer.

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
2025-09-18 12:32:13 -03:00
Derek Foreman
1a9cf3bfb6 compositor: Fix output reflowing when mirroring is in use
When we have a mirror, it will be at the same x,y position as the output
it's mirroring. On hot unplug, the current logic results in the mirroring
output being moved to the left by the width of its target output. The
mirror will then be destroyed, and the views can be left dangling outside
of usable space when a hot plug restores the outputs.

Subtly change the reflow logic to only reflow outputs to the right of the
removed output by testing co-ordinates, instead of assuming that every
output in the list is to the right of the previous.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2025-09-17 11:39:03 +00:00
Derek Foreman
a38cc9982b drm: Add more failure reasons that we can't use the scanout tranche for
Now that FAILURE_REASONS_FORCE_RENDERER isn't set for all not-scanout
capable failures, add some other reasons to the test in
dma_feedback_maybe_update.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2025-09-16 12:25:15 -05:00
Erico Nunes
6f1d9cdffd backend-drm: fix vulkan output init format
The default output format setting to the backend format was removed and
renderer-specific format picking functions were introduced, but one was
not included for vulkan-renderer.
Vulkan-renderer doesn't yet implement color management features which
would benefit from a full featured format selection here, so for now
just have a base implementation which restores the previous behavior.
This fixes the introduced segfault with vulkan-renderer and drm-backend.

Fixes: 56c27ea2 ("backend-drm: improve code that chooses output->format")

Signed-off-by: Erico Nunes <nunes.erico@gmail.com>
2025-09-16 07:39:20 +00:00
Leandro Ribeiro
39108501b3 libweston: make use of some of the new weston assert
We didn't have many Weston assert macros in place, but now we do.

Make use of a few of the newer macros where they make sense. No big
difference, but just to exercise using the correct ones now that they
exist.

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
2025-09-15 19:16:17 -03:00
Leandro Ribeiro
6d8a15839d shared: add many weston assert that were missing
This adds a ton of weston assert macros that were missing, as well as
tests for all of that.

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
2025-09-15 19:14:00 -03:00