Commit graph

1817 commits

Author SHA1 Message Date
Furkan Sahin
d786e07899 backend/session: use device boot_display
shouldn't need to check for `boot_vga` if newer, more general
sysfs `boot_display` is set.
closes https://gitlab.freedesktop.org/wlroots/wlroots/-/issues/4016
2025-10-17 17:35:51 +00:00
llyyr
6e1c8748ff render: introduce bt.1886 transfer function 2025-10-04 18:13:37 +05:30
Félix Poisot
c2d9ae2142 render: introduce Gamma 2.2 color transform 2025-10-03 19:39:17 +00:00
Simon Ser
406aa5f7f5 backend/session: fix crash on udev device remove event
libwayland adds phantom listeners here:
d81525a235/src/wayland-server.c (L2378)

Closes: https://gitlab.freedesktop.org/wlroots/wlroots/-/issues/3982
2025-10-01 17:05:10 +02:00
Simon Ser
2ec4012559 backend/drm: avoid error message when EDID is missing
We'd attempt to parse an EDID even when the connector has no EDID,
printing "Failed to parse EDID" in logs. Instead, don't attempt to
parse the EDID and print a more appropriate log message.
2025-10-01 15:14:46 +02:00
Simon Ser
d039ad8da3 backend/wayland: continue reading on hangup
If we stop immediately, we won't see any wl_display.error events.
Make sure we've read everything before handling hangup.
2025-09-30 09:25:14 -04:00
Simon Ser
3f0d338643 backend/wayland: log when getting disconnected from remote display
It can be a bit confusing to understand why a compositor is shutting
down on its own. Log a message when we get disconnected from the
parent compositor to explain the cause.
2025-09-30 09:25:14 -04:00
Simon Ser
7392b3313a backend, output: send commit events after applying all in wlr_backend_commit()
We were iterating over involved outputs, applying the new state and
sending the commit event for each one. This resulted in commit
events being fired while we weren't done applying the new state for
all outputs.

Fix this by first applying all of the states, then firing all of
the events.

Closes: https://github.com/swaywm/sway/issues/8829
2025-08-12 19:04:05 +02:00
Simon Ser
8c7041c4e8 backend/drm: relay full HDR metadata 2025-06-26 11:02:26 +00:00
Simon Ser
0ee0452af0 render/color, render/vulkan: add EXT_LINEAR to enum wlr_color_transfer_function 2025-06-18 19:37:55 +00:00
Simon Ser
b482e9089b backend/drm: add support for image description transfer function 2025-06-18 00:11:33 +02:00
Simon Ser
f024d1b8c8 backend/drm: add support for color primaries 2025-06-18 00:07:58 +02:00
Simon Ser
f10dd1da1c backend/drm: add support for color transforms 2025-06-16 09:06:10 +00:00
tokyo4j
170f7e0706 backend/libinput: don't leak udev_device 2025-05-20 01:15:19 +09:00
David Turner
2420bfef0b backend/drm: Fix segfault in libliftoff startup
With labwc and WLR_DRM_FORCE_LIBLIFTOFF=1, a segfault is seen on startup
because we call output_state_get_buffer_src_box() when there is no
buffer set in the output state.  Fix this by getting the src/dst box
from state->primary_viewport instead.
2025-05-08 10:13:57 +00:00
YaoBing Xiao
22db307e4c backend/drm: assign plane_id from function parameter instead of drm_plane 2025-04-30 17:10:45 +08:00
YaoBing Xiao
648aee65ad backend/drm: rename conn_name to conn_type_name for clarity 2025-04-27 15:33:36 +00:00
YaoBing Xiao
3ad4374a54 backend/drm: add DRM object and property IDs to error 2025-04-18 17:36:05 +08:00
Kirill Primak
5fd43add1c Fix/cleanup includes a bit 2025-04-15 20:13:29 +03:00
Simon Ser
99da6ccc87 backend/drm: pass DRM_MODE_ATOMIC_NONBLOCK for test commits
The kernel performs some additional checks when
DRM_MODE_ATOMIC_NONBLOCK is supplied: it requires that none of the
planes are still busy with a previous page-flip.

Pass the flag during test-only commits so that we don't end up
performing a commit which will fail.
2025-03-24 12:45:47 +00:00
Simon Ser
94cb8e2bc7 backend/drm: fix enabling an output with a custom mode set
Since 5567aefb1c ("backend/drm: Don't add pollute fixed modes
list with custom modes"), when a custom mode is set on an output,
current_mode will be NULL.

Instead of checking current_mode, check width/height.

Closes: https://gitlab.freedesktop.org/wlroots/wlroots/-/issues/3946
2025-03-07 13:00:06 +00:00
Simon Ser
ca1f9f86e6 backend/drm: handle custom modes in connect_drm_connector()
On startup, some connectors might be already lit up with a custom
mode. We weren't correctly populating the current output state in
this case.
2025-03-07 13:00:06 +00:00
Kirill Primak
b13fe9b3a1 backend/wayland: use a separate event queue for busy loops
This avoids processing events which we're not interested in.
Specifically, this fixes a case where output_commit() could be
indirectly called from itself either from import_dmabuf() or while
waiting for a configure event when enabling the output.
2025-03-01 16:03:52 +00:00
Kirill Primak
35ff09a754 backend/output: extract backend to a variable in output_commit() 2025-03-01 16:03:52 +00:00
Kirill Primak
90b5f0dde5 backend/wayland: don't send request_state when enabling an output 2025-03-01 16:03:52 +00:00
Simon Ser
a64e1a58b1 backend/drm: log when creating multi-GPU renderer
Creating a renderer results in lots of logs. Make it clear that
the logs belong to a multi-GPU renderer (as opposed to a primary
renderer created by the compositor).
2025-01-30 02:10:58 +00:00
Alexander Orzechowski
82223e451a render/drm_syncobj: Add a callback when ready
The old approach of using a signal is fundamentally broken for a common
usecase: When the waiter is ready, it's common to immediately finish and
free any resources associated with it.
Because of the semantics of wl_signal_emit_mutable() this is UB.
wl_signal_emit_mutable() always excepts that the waiter hasn't been freed
until the signal has finished being emitted.

Instead of over engineering the solution, let's just add a callback required
by wlr_drm_syncobj_timeline_waiter_init(). In this callback, the implementation
is free to finish() or free() any resource it likes.
2025-01-26 18:02:05 -05:00
Kirill Primak
4f6dd01e5a backend/wayland: remove syncobj waiter on buffer destroy 2025-01-24 21:46:31 +03:00
llyyr
9ab87167b5 backend/drm: don't leak mgpu_formats 2025-01-16 14:58:59 +00:00
Kirill Primak
8f56f7ca43 Assert (almost all) signals have no attached listeners on destroy 2025-01-15 19:53:11 +03:00
Simon Ser
82f9cd5310 backend/headless: accept hardware cursors
When running headless, remoting programs (e.g. VNC servers) might
want to capture outputs without the cursor, and send the cursor
image separately.
2025-01-14 16:42:12 +01:00
Simon Ser
c0881bdc01 output: require commit after hardware cursor update
Up until now only the DRM backend required an output commit after
updating the cursor. Unify this for all backends, because:

- Screen capture can now catch cursor updates listening for output
  commits
- In the future we want to make the cursor a regular wlr_output_layer,
  which would need an output commit to be updated anyways
2025-01-14 16:42:12 +01:00
Kirill Primak
89000b7df0 backend/session: simplify udev event action matching
This avoids extra strcmp() calls and is easier to read.
2025-01-08 20:45:27 +03:00
Kirill Primak
d5d650f9f6 output: introduce wlr_output_finish() 2025-01-08 16:06:12 +00:00
sunzhguy
5eed5d622d session: skip adding duplicate DRM device
Signed-off-by: sunzhguy <sunzhigang1@kylinos.cn>
2025-01-06 10:10:46 +08:00
Simon Ser
b908d865b1 backend: replace get_buffer_caps hook with a struct field
Do the same as wlr_renderer: the supported buffer capabilities are
static for the lifetime of the backend.
2024-12-25 18:40:05 +00:00
Consolatis
be555a9a99 backend/drm: make drm_lease implementation follow docs
This ensures compositors get a output_destroy signal when the
lease is granted and a new_output signal when the lease is revoked.
2024-12-21 01:00:12 +01:00
Simon Ser
c6dd5e3c2e backend/drm: check buffer format for multi-GPU
Fixes on-screen corruption when displaying a fullscreen client
with an implicit modifier on the secondary GPU.

What happens here:

- Client allocates a buffer with an INVALID modifier on primary GPU.
- Compositor attempts to scan-out this buffer on an output connected
  to secondary GPU.
- Buffer is imported to secondary GPU, and is interpreted as if it had
  the secondary GPU's implicit tiling, even though it has the primary
  GPU's implicit tiling.

We need to forbid cross-device imports with implicit modifiers.
The mgpu_formats list is stripped from any INVALID modifier so
checking that fixes the bug.

Using the mgpu_formats list has an additional benefit: the buffer
is rejected in the test commit if it doesn't have a format supported
by the multi-GPU renderer.

Requires this Mesa bugfix:
https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/31725
2024-11-28 20:27:48 +01:00
Simon Ser
3e651b4642 backend/drm: fix drmModePageFlip() when disabling CRTC on legacy uAPI
drmModePageFlip() will fail with EBUSY on a disabled CRTC.

We can't fix this by clearing the DRM_MODE_PAGE_FLIP_EVENT when
performing a commit which disables CRTCs, because some device-wide
commits might also page-flip other enabled CRTCs (and skipping the
page-flip event would mess up our buffer tracking).

Fix this by immediately completing page-flips which disable a CRTC
on the legacy uAPI.

Closes: https://gitlab.freedesktop.org/wlroots/wlroots/-/issues/3918
2024-11-23 15:29:44 +01:00
Kirill Primak
2ff95e5c97 meson: use kwargs for wayland deps 2024-11-21 16:46:55 +00:00
Simon Ser
e9a6b3b85d backend/wayland: add support for explicit sync
wl_buffer.release event delivery becomes undefined when using the
linux-drm-syncobj-v1 protocol, so we need to wait for buffer
release via a timeline point instead.

The protocol requires both wait and signal timelines to be set, so
we need to create one when the compositor only supplies a wait
timeline.
2024-11-11 15:22:22 +00:00
Kenny Levinsen
f440c60128 backend/drm: Remove redundant error logs
wlr_renderer and wlr_allocator will print out errors as they go, and end
with a final error if they fail to create anything. The caller of this
function will also log when it fails.

Skip the redundant errors emitted here.
2024-11-08 15:14:08 +01:00
Kenny Levinsen
0108506c77 backend/drm: Allow proceeding with render-less mgpu
If an mgpu device does not have a renderer, continue without one rather
than ignoring it entirely. It is not guaranteed that we will be able to
scan out to it in any particular configuration, but that is true for any
output regardless, and having the output visible is not harmful even if
it cannot light up.

To proceed safely, we strip implicit modifier support from all planes,
while avoiding duplication of the same logic for mdgpu_formats.

This helps GUD and DisplayLink scenarios.
2024-11-08 15:14:08 +01:00
Kenny Levinsen
66ddd62e42 backend/drm: Move mgpu renderer setup to function
This helps readability a bit and will make error handling in a coming
commit easier.
2024-11-08 15:14:08 +01:00
Kenny Levinsen
b2bb111f03 backend/drm: Check for mgpu_renderer instead of parent
The presence of the renderer is what matters with respect to blitting.
Having a parent without the need to blit will be allowed later.
2024-11-08 15:14:08 +01:00
Kenny Levinsen
1dd05437bf backend/drm: Bail if renderer cannot import DMA-BUFs
We create a renderer for the sole purpose of blitting buffers from a
primary renderer that we might not be able to scan-out from. If we end
up with the pixman renderer, it either won't work becuase it cannot
import dmabufs from the primary renderer, or won't have any effect
because the primary renderer already uses dumb buffers.

We test for DMA-BUF capabilities specifically to make it clear what our
interest is, rather than focusing too much on the pixman renderer.
2024-11-08 15:14:08 +01:00
Kenny Levinsen
55f15d1abd backend/drm: Ensure renderer is set to NULL on error
If init_drm_renderer failed, it would destroy the renderer but would not
set it to NULL, leading to use-after-free.

NULL the renderer after destroying it.
2024-11-08 13:45:05 +01:00
Kenny Levinsen
014023c14f backend/drm: Set timeline support based on capability
We assumed that all atomic backends supported syncobj, but gud does not.
Instead, query DRM_CAP_SYNCOBJ_TIMELINE when using the atomic backend.
2024-11-08 13:45:05 +01:00
Simon Ser
4c4d74a564 backend/drm: use public wlr_allocator_autocreate()
We don't need any custom behavior since d8c0707e27 ("backend/drm: return
secondary backend DRM FD").
2024-11-07 18:50:25 +01:00
Simon Ser
4ec1defb3e all: use public <wlr/render/allocator.h>
We don't need to use the private header in these files.
2024-11-07 18:48:20 +01:00