Commit graph

1697 commits

Author SHA1 Message Date
Ian Forbes
e3bd318547 drm/backend: add support for cursor hotspots
Enables DRM_CLIENT_CAP_CURSOR_PLANE_HOTSPOT and sets the cursor hotspots on the
cursor plane so virtualized drivers can accelerate mouse movement.

Closes: https://gitlab.freedesktop.org/wlroots/wlroots/-/issues/3776
2024-03-22 13:54:18 -05:00
Simon Ser
7a8e2cd8ed backend/libinput: drop stray space 2024-03-15 12:48:27 +01:00
Simon Ser
bd8796d465 backend/libinput: drop outdated gesture cap logging
We've been supporting gesture events for a long time.
2024-03-15 12:34:19 +01:00
Kirill Primak
71be993982 backend/drm: set adaptive_sync_status again
Fixes: d7d974ae30
2024-03-15 10:39:05 +03:00
Simon Ser
52e01a9c8b backend/drm: implement wlr_backend_impl.{test,commit} 2024-03-14 22:03:10 +00:00
Simon Ser
d41b5efc65 backend/drm: fix adaptive sync no-op changes
When a compositors submits a wlr_output_state with
WLR_OUTPUT_STATE_ADAPTIVE_SYNC_ENABLED set and
adaptive_sync_enabled = false on an output which doesn't support
adaptive sync, we'd fail the commit. Fix this.

This bug was previously hidden because wlr_output_commit() drops
no-op changes from wlr_output_state.committed.
2024-03-14 22:03:10 +00:00
Simon Ser
35737ab00c backend/drm: add drm_connector_prepare()
Extract bits we'll re-use for device-wide commits.
2024-03-14 22:03:10 +00:00
Simon Ser
a4f54086c1 backend/drm: move post-commit disable logic to drm_connector_apply_commit()
After disabling a connector, we need to cleanup the connector to
teardown the surfaces and unlock the FBs.

Move this logic into drm_connector_apply_commit() so that it's
applied when drm_commit() is called from somewhere else than
drm_connector_commit_state().
2024-03-14 22:03:10 +00:00
Simon Ser
5efa88ee7a backend/drm: drop drm_device_state_init_single()
There is a single caller now, so we can inline the function.
2024-03-14 22:03:10 +00:00
Simon Ser
ee01712847 backend/drm: unify connector test and commit codepaths
There is some duplicated logic between these two functions.

The commit codepath was calling the test function before doing the
real commit, so this also saves an unnecessary test-only commit
when performing a real commit.
2024-03-14 22:03:10 +00:00
Simon Ser
917c650903 backend/multi: implement wlr_backend_impl.{test,commit} 2024-03-14 22:03:10 +00:00
Simon Ser
78c76ddd09 backend: add wlr_backend_{test,commit}() 2024-03-14 22:03:10 +00:00
Simon Ser
fc4996d853 backend/drm: rework struct wlr_drm_page_flip for multiple connectors
We need to store the CRTC ID for each connector at the time of the
atomic commit, because future commits may change the CRTC/connector
mapping.
2024-03-14 22:03:10 +00:00
Simon Ser
805807fd5b backend/drm: add infrastructure for device-wide commits 2024-03-14 22:03:10 +00:00
Simon Ser
4636f8c407 backend/drm: track pending atomic state in wlr_drm_connector_state
This centralizes logic common for both the atomic and libliftoff
backends. Additionally, a struct will make it easier to implement
multi-connector commits (since it can be stored in an array).
2024-03-14 22:03:10 +00:00
Simon Ser
d7d974ae30 backend/drm: drop VRR debug message
These weren't super helpful and will get in our way for
multi-connector commits.
2024-03-14 22:03:10 +00:00
Simon Ser
3d72da9ed7 backend/drm: extract post-commit logic into functions
It's more readable, and we'll soon call this from a loop for
multi-connector commits.
2024-03-14 22:03:10 +00:00
Simon Ser
f8f2dde1f0 backend/drm: add wlr_drm_connector_state.connector
Will be useful for multi-connector commits, to avoid having to
pass the list of connectors separately from their state.
2024-03-14 22:03:10 +00:00
Simon Ser
94dbb3cfb5 backend/libinput: check bus type before setting tablet USB IDs
References: https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/977
2024-03-07 12:19:07 +01:00
Simon Ser
edbf8bf2ce input-device: drop wlr_input_device.{vendor,product}
These aren't super useful without the bus type. Compositors can
fish back this information from the libinput device if they want to.

Closes: https://gitlab.freedesktop.org/wlroots/wlroots/-/issues/3818
2024-03-07 11:08:18 +00:00
Simon Ser
e21b975f5d tablet-tool: add usb_vendor_id and usb_product_id to wlr_tablet 2024-03-07 11:08:18 +00:00
Simon Ser
c3743364e2 backend/drm: ensure CRTC is set up in drm_connector_state_init()
In [1] we discovered a bug where wlr_drm_connector_state.primary_fb
would not be set up correctly because drm_connector_alloc_crtc() was
called after drm_connector_state_init(). This is tricky to discover,
so instead assert() that we have a usable CRTC by the time
drm_connector_state_init() is called.

[1]: https://gitlab.freedesktop.org/wlroots/wlroots/-/merge_requests/4569
2024-03-04 14:42:11 +00:00
Simon Ser
16b42bf65b backend/drm: track cursor FB in wlr_drm_connector_state
Use the same logic for cursor FBs as we currently use for primary
FBs. This also fixes the same bug as [1] but in a different, more
robust way.

The new logic integrates better with atomic and will be required
anyways in the future when set_cursor will be superseded by a better
API.

[1]: https://gitlab.freedesktop.org/wlroots/wlroots/-/merge_requests/4577
2024-03-04 11:26:20 +01:00
Simon Ser
f6659414ba backend/drm: add drm_fb_copy()
Similar to drm_fb_move(), but leaves old as-is.
2024-03-04 11:25:33 +01:00
Simon Ser
1a54d33e77 backend/drm: clear pending cursor FB in drm_connector_set_cursor()
When disabling the cursor, don't leave a stale pending FB behind.
2024-03-04 11:23:35 +01:00
Simon Ser
f5889319f7 backend/drm: fix queued cursor FB overwritten with NULL
With the following sequence of events, the cursor FB fields could
end up being all set to NULL while the cursor is enabled:

1. set_cursor is called, conn->cursor_pending_fb is set to a FB
   pointer.
2. The output is committed with a buffer. crtc->cursor->queued_fb
   is set to the FB pointer, conn->cursor_pending_fb is reset to
   NULL. A page-flip event is expected in the future.
3. The output is committed with a modeset before the page-flip
   event is triggered. crtc->cursor->queued_fb is reset to NULL.

At this point all of crtc->cursor->current_fb,
crtc->cursor->queued_fb and conn->cursor_pending_fb are NULL which
is a bogus state when the cursor plane is enabled.

To avoid this issue, avoid overwriting crtc->cursor->queued_fb
with a NULL pointer on commit. The cursor logic still isn't great,
but let's keep a rework of that for a separate patch.

Closes: https://gitlab.freedesktop.org/wlroots/wlroots/-/issues/3734
2024-03-04 01:37:52 +00:00
Simon Ser
e3ab52af7b backend/x11: add error logging to query_dri3_drm_fd() 2024-03-02 13:14:12 +01:00
Isaac Freund
b821be5749
input-device: unconfuse tablet naming
WLR_INPUT_DEVICE_TABLET_TOOL is renamed to WLR_INPUT_DEVICE_TABLET

The input device corresponds to wlr_tablet, not wlr_tablet_tool.
2024-02-29 16:09:07 +01:00
Simon Ser
ee70932422 backend/libinput: use NULL to indicate missing device name
libinput guarantees that the name is non-NULL, and an empty string
if unset. However wlroots uses NULL to indicate that an input device
name is unset.
2024-02-29 12:08:02 +01:00
Simon Ser
488a23c169 pointer: drop enum wlr_axis_orientation
Instead, use enum wl_pointer_axis from the Wayland protocol.
2024-02-28 16:39:18 +00:00
Simon Ser
ec5263e6b7 pointer: drop enum wlr_axis_relative_direction
Instead, use enum wl_pointer_axis_relative_direction from the
Wayland protocol.
2024-02-28 16:39:18 +00:00
Simon Ser
812451cd8f pointer: use enum wl_pointer_button_state 2024-02-28 16:39:18 +00:00
Simon Ser
9f4cf242d9 pointer: drop enum wlr_axis_source
Instead, use enum wl_pointer_axis_source from the Wayland protocol.
2024-02-28 16:39:18 +00:00
Simon Ser
d83c15c318 backend/drm: use CRTC pointers instead of indices in realloc_crtcs()
Improves readability, no functional change.
2024-02-27 11:46:19 +01:00
Simon Ser
4b1713d203 backend/drm: improve CRTC reallocation pretty printing
Only print the list of connectors once, with both the old and new
status. Use CRTC object IDs instead of CRTC indices. Make it obvious
when a connector keeps the same CRTC.
2024-02-27 11:40:25 +01:00
Simon Ser
db2b1892ad backend/drm: move primary FB check after pending buffer logic
If a connector has no current/queued buffer, but has a pending
buffer in the commit, we need to process that pending buffer before
checking pending.primary_fb.
2024-02-26 17:32:50 +01:00
Simon Ser
0e839ab1c2 backend/drm: fix primary FB check
When turning off a CRTC, we don't need a buffer.

It doesn't matter whether this is a modeset or not: we always need
a buffer even for regular page-flips as long as a connector is
active.

Fixes: 374daeb256 ("backend/drm: Ensure a primary fb is available when configuring an output")
2024-02-26 17:30:59 +01:00
Simon Ser
ef4997b722 backend/drm: use output_pending_enabled()
Use the helper instead of hand-rolling the logic.
2024-02-26 17:19:51 +01:00
Alexander Orzechowski
374daeb256 backend/drm: Ensure a primary fb is available when configuring an output 2024-02-25 05:54:08 -05:00
Alexander Orzechowski
f9a371717c backend/drm: Remove dead code
We can never hit the case where we try to light up an output without
a buffer. output_ensure_buffer() will catch this for now, and when that's
removed, output_basic_test() will catch this case.
2024-02-25 04:12:52 -05:00
Alexander Orzechowski
672ff1e14e backend/drm: Init connector after we try to allocate a crtc for it
drm_connect_state_init() will set primary_fd to null if no CRTC is active
for the connector and can crash later if the code expects a CRTC (like
when lighting up an output).
2024-02-25 04:11:00 -05:00
Kenny Levinsen
8dec0f6174 backend/drm: Remove erroneous free
init_plane tries to free a single plane on error, but this is an element
in a calloc'd array by the caller that we should not touch.
2024-02-22 00:41:00 +01:00
Kenny Levinsen
153dea9c28 backend/drm: Free current_modeinfo on error 2024-02-22 00:40:54 +01:00
Simon Ser
0d9ffef774 backend/drm: don't destroy previous DRM master blobs
On startup, we fetch the previous MODE_ID blob ID so that
compositors can keep using the previous mode if they want to.
However, that blob doesn't belong to us, it belongs to the
previous DRM master. As a result, we get an error when trying to
destroy it.

Fix this by tracking whether the blob belongs to us or not.

Closes: https://gitlab.freedesktop.org/wlroots/wlroots/-/issues/3811
2024-02-21 15:10:44 +00:00
Simon Ser
842093bb84 Define _POSIX_C_SOURCE globally
Stop trying to maintain a per-file _POSIX_C_SOURCE. Instead,
require POSIX.1-2008 globally. A lot of core source files depend
on that already.

Some care must be taken on a few select files where we need a bit
more than POSIX. Some files need XSI extensions (_XOPEN_SOURCE) and
some files need BSD extensions (_DEFAULT_SOURCE). In both cases,
these feature test macros imply _POSIX_C_SOURCE. Make sure to not
define both these macros and _POSIX_C_SOURCE explicitly to avoid
POSIX requirement conflicts (e.g. _POSIX_C_SOURCE says POSIX.1-2001
but _XOPEN_SOURCE says POSIX.1-2008).

Additionally, there is one special case in render/vulkan/vulkan.c.
That file needs major()/minor(), and these are system-specific.
On FreeBSD, _POSIX_C_SOURCE hides system-specific symbols so we need
to make sure it's not defined for this file. On Linux, we can
explicitly include <sys/sysmacros.h> and ensure that apart from
symbols defined there the file only uses POSIX toys.
2024-02-15 15:41:12 +01:00
Simon Ser
17fe87af5e backend/drm: skip reset after VT switch if possible
If all connectors and planes already have the right CRTC set, or
are disabled, we can skip the device-wide reset after a VT switch.

I've contemplated using a more fine-grained logic to only reset
the connectors, CRTCs and planes that need to be migrated. However,
writing a correct algorithm for this would be quite involved, and it
doesn't seem worth the trouble anyways.

Closes: https://github.com/swaywm/sway/issues/7956
2024-02-15 09:56:33 +01:00
Simon Ser
653e28d2a3 backend/drm: fix typo in restore_drm_device() comment 2024-02-15 09:53:13 +01:00
Simon Ser
d2acd4c362 backend/drm: move restore logic to drm.c
We'll need to use a bunch of internal functions from that file in
the next commits.
2024-02-15 09:37:46 +01:00
Simon Ser
505175e56f backend/drm: atomically reset state after VT switch
Allows the KMS driver to parallelize the modesets, so should be
faster than going through each CRTC one by one.
2024-02-14 19:13:23 +01:00
Simon Ser
836cb820d0 backend/drm: call get_drm_connector_props() when creating connector
This function fetches property IDs. These don't change for the
lifetime of the connector. Instead of refreshing the property IDs
on hotplug (and leaving property IDs unset for disconnected
connectors), only fetch the property IDs when we create the
connector.
2024-02-14 19:12:14 +01:00