aboutsummaryrefslogtreecommitdiff
path: root/backend/drm
AgeCommit message (Collapse)Author
2021-08-10backend/drm: always perform a test commit in drm_connector_testSimon Ser
This allows callers to use wlr_output_test to check whether a mode can be enabled, for instance. Closes: https://github.com/swaywm/wlroots/issues/2250
2021-08-10backend/drm: add proper error handling to wlr_drm_backend_createSimon Ser
Some listeners weren't removed and caused a use-after-free with e.g. vkms when used as a secondary GPU.
2021-08-04backend/drm: require buffer on modeset in drm_connector_testSimon Ser
When testing a modeset, make sure the caller has also provided a buffer. This allows df0e75ba05e2 ("output: try skipping buffer allocation if the backend allows it") to work as expected with the DRM backend. Closes: https://github.com/swaywm/wlroots/issues/3086
2021-08-02backend/drm: preserve mode order from kernelSimon Ser
The kernel orders the mode list from highest to lowest. Preserve this ordering in the wlr_output.modes list.
2021-07-29output: drop wlr_output_state.buffer_typeSimon Ser
This is now unconditionally set to WLR_OUTPUT_STATE_BUFFER_SCANOUT.
2021-07-28backend/drm: fix wrong type for get_cursor_format return valuesSimon Ser
These are bools but should be pointers.
2021-07-28backend/drm: stop initializing renderer for parent backendSimon Ser
Unless we're dealing with a multi-GPU setup and the backend being initialized is secondary, we don't need a renderer nor an allocator. Stop initializing these.
2021-07-28backend/drm: drop get_renderer implementationSimon Ser
We can now just rely on the common code for this.
2021-07-28backend/drm: drop drm_surface_{make,unset}_currentSimon Ser
2021-07-28backend/drm: remove SCANOUT check in drm_connector_testSimon Ser
We only accept SCANOUT, the buffer type should never be set to RENDER.
2021-07-28backend/drm: remove primary swapchainSimon Ser
We can't nuke it completely, we still need it for multi-GPU.
2021-07-28backend/drm: allow legacy scan-out if FB props matchSimon Ser
Historically we haven't allowed direct scan-out for legacy KMS, because legacy misses the functionality to make sure a buffer can be scanned out. However with renderer v6 the backend can't figure out anymore whether the buffer comes from its internal swap-chain, because the backend doesn't have an internal swap-chain. The legacy KMS API guarantees that the driver won't reject a buffer as long as it's been allocated with the same parameters as the previous one. Let's check this in legacy_crtc_test.
2021-07-28backend/drm: implement get_primary_formatsSimon Ser
2021-07-22render/wlr_texture: put wlr_texture_from_buffer into the public APISimon Zeni
2021-07-22backend: make DRM and libinput backends optionalayaka
Co-authored-by: Simon Ser <contact@emersion.fr>
2021-07-21backend/drm: add DRM_MODE_CONNECTOR_USB to conn_get_nameSimon Ser
See 757e26712337 ("drm/uapi: Add USB connector type") in the kernel tree.
2021-07-20backend/drm: stop restoring CRTCs on exitSimon Ser
This is the cause of the spurious "drmHandleEvent failed" messages at exit. restore_drm_outputs calls handle_drm_event in a loop without checking whether the FD is readable, so drmHandleEvent ends up with a short read (0 bytes) and returns an error. The loop's goal is to wait for all queued page-flip events to complete, to allow drmModeSetCrtc calls to succeed without EBUSY. The drmModeSetCrtc calls are supposed to restore whatever KMS state we were started with. But it's not clear from my PoV that restoring the KMS state on exit is desirable. KMS clients are supposed to save and restore the (full) KMS state on VT switch, but not on exit. Leaving our KMS state on exit avoids unnecessary modesets and allows flicker-free transitions between clients. See [1] for more details, and note that with Pekka we've concluded that a new flag to reset some KMS props to their default value on compositor start-up is the best way forward. As a side note, Weston doesn't restore the CRTC by does disable the cursor plane on exit (see drm_output_deinit_planes, I still think disabling the cursor plane shouldn't be necessary on exit). Additionally, restore_drm_outputs only a subset of the KMS state. Gamma and other atomic properties aren't accounted for. If the previous KMS client had some outputs disabled, restore_drm_outputs would restore a garbage mode. [1]: https://blog.ffwll.ch/2016/01/vt-switching-with-atomic-modeset.html
2021-07-19backend/drm: fix NULL data in handle_drm_eventSimon Ser
wl_event_loop_add_fd was called with a NULL data argument, but the function expects the data argument to be set to the wlr_drm_backend. Fixes: 053ebe7c278b ("backend/drm: terminate display on drmHandleEvent failure")
2021-07-12backend/drm: remove wlr_output_impl.export_dmabufSimon Ser
This is now provided by the generic wlr_output implementation.
2021-07-09backend/drm: remove backend arg from wlr_drm_interface.crtc_commitSimon Ser
The callee can just get it from the wlr_drm_connector.
2021-07-09backend/drm: move legacy-specific checks to legacy.cSimon Ser
Now that we have a test_only arg in crtc_commit, we can move the legacy checks to legacy.c.
2021-07-09backend/drm: add test_only arg to wlr_drm_interface.crtc_commitSimon Ser
Right now callers of drm_crtc_commit need to check whether the interface is legacy or atomic before passing the TEST_ONLY flag. Additionally, the fallbacks for legacy are in-place in the common code. Add a test_only arg to the crtc_commit hook. This way, there's no risk to pass atomic-only flags to the legacy function (add an assert to ensure this) and all of the legacy-specific logic can be put back into legacy.c (done in next commit).
2021-07-08backend/drm: stop using drm_surface_make_current in drm_surface_blitSimon Ser
drm_surface_make_current and drm_surface_unset_current set implicit state and are an unnecessary mid-layer. Prefer to use directly wlr_renderer_begin_with_buffer, which automatically unsets the back buffer on wlr_renderer_end. I'd like to get rid of drm_surface_make_current once we stop using it for the primary swapchain.
2021-07-08backend/drm: force linear layout for multi-GPU buffersSimon Ser
Some buffers need to be copied across GPUs. Such buffers need to be allocated with a format and modifier suitable for both the source and the destination. When explicit modifiers aren't supported, we were forcing the buffers to be allocated with a linear layout, because implicit modifiers aren't portable across GPUs. All is well with this case. When explicit modifiers are supported, we were advertising the whole list of destination modifiers, in the hope that the source might have some in common and might be able to allocate a buffer with a more optimized layout. This works well if the source supports explicit modifiers. However, if the source doesn't, then wlr_drm_format_intersect will fallback to implicit modifiers, and everything goes boom: the source uses a GPU-specific tiling and the destination interprets it as linear. To avoid this, just force linear unconditionally. We'll be able to revert this once we have a good way to indicate that an implicit modifier isn't supported in wlr_drm_format_set, see [1]. [1]: https://github.com/swaywm/wlroots/pull/2815 Closes: https://github.com/swaywm/wlroots/issues/3030
2021-07-06move wlr_box from /types to /utilSimon Zeni
2021-07-05backend/drm: don't clear pending cursor FB on failed commitSimon Ser
The previous fix tried to side-step cursor->pending_fb completely. However that messes up our buffer locking mechanism. Instead, stop clearing the pending cursor FB on a failed commit. The pending cursor FB will remain for the next commit. Fixes: 6c3d080e25e5 ("backend/drm: populate cursor plane's current_fb")
2021-07-05Revert "backend/drm: populate cursor plane's current_fb"Simon Ser
This reverts commit 6c3d080e25e56404228ad7704eed43e40fa0c623. Populating wlr_drm_plane.current_fb messes up the buffer's locking. The previous buffer is released while it's still being displayed on-screen.
2021-07-01buffer: make enum wlr_buffer_cap publicSimon Ser
Custom backends and renderers need to implement wlr_backend_impl.get_buffer_caps and wlr_renderer_impl.get_render_buffer_caps. They can't if enum wlr_buffer_cap isn't made public.
2021-07-01Remove unused wlr_list.h includesSimon Ser
2021-06-24backend/drm: rename page_flip_handler to handle_page_flipSimon Ser
This is more consistent with the rest of the wlroots naming.
2021-06-20backend: add output state allow-listsSimon Ser
Right now, when a new output state field is added, all backends by default won't reject it. This means we need to add new checks to each and every backend when we introduce a new state field. Instead, introduce a bitmask of supported output state fields in each backend, and error out if the user has submitted an unknown field. Some fields don't need any backend involvment to work. These are listed in WLR_OUTPUT_STATE_BACKEND_OPTIONAL as a convenience.
2021-06-17backend/drm: populate cursor plane's current_fbSimon Ser
The set_cursor() hook is a little bit special: it's not really synchronized to commit() or test(). Once set_cursor() returns true, the new cursor is part of the current state. This fixes a state where wlr_drm_connector.cursor_enabled is true but there is no FB available. This is triggered by set_cursor() followed by a failed commit(), which resets pending_fb. We should definitely fix the output interface to make the cursor part of the pending state, but that's a more involved change.
2021-06-13backend/drm: remove test_bufferSimon Ser
Instead, call drm_connector_set_pending_fb.
2021-06-13backend/drm: move session check from test_buffer to drm_connector_testSimon Ser
The other caller (drm_connector_commit_state) already checks this.
2021-06-13backend/drm: move drm_connector_set_pending_fb upSimon Ser
This will be used in drm_connector_test shortly.
2021-06-13backend/drm: allocate a CRTC in drm_connector_testSimon Ser
We can't perform a test-only atomic commit if the connector is missing a CRTC.
2021-06-13backend/drm: allocate a CRTC in drm_connector_commit_stateSimon Ser
drm_connector_set_pending_fb needs a CRTC to import the buffer.
2021-06-13backend/drm: introduce drm_connector_alloc_crtcSimon Ser
This function allocates a CRTC for a connector if necessary.
2021-06-13backend/drm: allow committing a buffer and a mode togetherSimon Ser
Set the plane's pending FB before calling drm_connector_set_mode.
2021-06-13backend/drm: use atomic test-only commits for modifier fallbackSimon Ser
Instead of trying to perform a real modeset in init_renderer, perform an atomic test-only commit to find out whether disabling modifiers is necessary because of bandwidth limitations. This decouples init_renderer from the actual commit, making it possible to modeset an output with a user-supplied buffer instead of a black frame. We loose the ability to make sure the buffers coming from the swapchain will work fine when using the legacy interface. This can break i915 when atomic is disabled and modifiers enabled. But i915 always has atomic (so the user must explicitly disable it to run into potential bandwidth limitations) and is the only known problematic driver.
2021-06-09render: drop wlr_ prefix from wlr_renderer_bind_bufferSimon Ser
Make it clear this function is a private wlroots API and will stay that way.
2021-06-02backend/drm: move cursor fields to wlr_drm_connectorSimon Ser
Doesn't make a lot of sense to split the cursor fields between wlr_drm_plane and wlr_drm_connector. Let's just move everything to wlr_drm_connector.
2021-06-02output: take a wlr_buffer in set_cursorSimon Ser
Instead of passing a wlr_texture to the backend, directly pass a wlr_buffer. Use get_cursor_size and get_cursor_formats to create a wlr_buffer that can be used as a cursor. We don't want to pass a wlr_texture because we want to remove as many rendering bits from the backend as possible.
2021-06-02backend/drm: introduce drm_plane_pick_render_formatSimon Ser
This is a new helper function to pick a render format suitable for a plane. The next commit will use it to initialize the cursor multi-GPU surface.
2021-06-02backend/drm: remove format arg from drm_plane_init_surfaceSimon Ser
This was always set to ARGB8888.
2021-06-02backend/drm: implement get_cursor_formats and get_cursor_sizeSimon Ser
2021-05-21backend: introduce wlr_backend_finishSimon Ser
This new functions cleans up the common backend state. While this currently only emits the destroy signal, this will also clean up the renderer and allocator in upcoming patches.
2021-05-17backend/drm: use wlr_texture_from_bufferSimon Ser
2021-04-30backend/drm: Do not require mode commit on enableKenny Levinsen
If a mode is not provided, use the current mode intead. Closes: https://github.com/swaywm/wlroots/issues/2904
2021-04-29backend/drm: introduce drm_connector_commit_stateSimon Ser
Backend-initiated mode changes can use this function instead of going through drm_connector_set_mode. drm_connector_set_mode becomes a mere drm_connector_commit_state helper.