aboutsummaryrefslogtreecommitdiff
path: root/backend/drm/drm.c
AgeCommit message (Collapse)Author
2020-11-24backend/drm: stop force-probing connectorsSimon Ser
After discussing with Pekka and Daniel on #dri-devel, we concluded [1] that user-space shouldn't need to force-probe connectors. Force-probing can take some time, so using drmModeGetConnectorCurrent can result in faster start-up. Users can manually trigger a force-probe if necessary: echo detect | sudo tee /sys/class/drm/card0-DP-1/status Or just by running a tool like drm_info. A similar change has been submitted to Weston [2]. [1]: https://lists.freedesktop.org/archives/dri-devel/2020-November/287728.html [2]: https://gitlab.freedesktop.org/wayland/weston/-/issues/437
2020-11-19backend/drm: Use legacy gamma size for legacy backendKenny Levinsen
We would always return the GAMMA_LUT_SIZE property if available, and only fall back to legacy gamma size otherwise. This leads to issues if both are available in differs in size while we use the legacy backend. Ensure that we only return the legacy size if we're using the legacy backend. Closes: https://github.com/swaywm/wlroots/issues/2429
2020-11-15backend/drm: check drm_surface_render_black_frame return valueSimon Ser
This avoids hitting an assertion in drm_fb_lock_surface when we failed to render a black frame.
2020-11-15backend/drm: get rid of wlr_drm_fb_typeSimon Ser
Since all DRM FBs are backed by a wlr_buffer, there's no need for this anymore.
2020-11-15backend/drm: add support for wlr_swapchain buffer ageSimon Ser
2020-11-15backend/drm: use wlr_swapchainSimon Ser
2020-11-05backend/drm: export pending FB in export_dmabuf, if anySimon Ser
This allows callers to grab the current frame right after committing it, without having to incur a full vblank worth of latency.
2020-11-03backend/drm: fix "a page-flip is already pending" errors on modesetSimon Ser
When performing a modeset, the DRM backend will request a page-flip event. However frame_pending wasn't set to true, so any subsequent wlr_output_schedule_frame calls would imemdiately trigger a synthetic frame event, asking the compositor to submit a new frame. Committing the new frame fails with "a page-flip is already pending" error in the DRM backend.
2020-10-30backend/drm: Check if output is enabled before sending frame eventMarten Ringwelski
When an output is disabled one last pageflip will happen to disable it. Currently this pageflip causes a frame event. Since the output is disabled we don't want to send this frame event.
2020-07-31drm: fix uninitialized readDevin J. Pohly
get_drm_prop_blob does not set path_len if it returns NULL. Check the return value before path_len to avoid reading uninitialized memory. (Granted, this doesn't change the logic at all, but it does make Valgrind a bit happier.)
2020-07-27Fix incorrect format parametersAntonin Décimo
2020-07-07backend/drm: check drm_surface_make_current return valueSimon Ser
drm_connector_set_cursor wasn't checking the return value of the drm_surface_make_current call. On failure, this results in a failed assertion in wlr_renderer_begin (because no rendering context is current).
2020-06-19output: rename impl->rollback to rollback_renderSimon Ser
The output backend API is now mostly state-less thanks to the atomic hooks (commit and test). There is one exception though: attach_render. This function makes the rendering context current. However sometimes the compositor might decide not to render after attach_render (e.g. when there's nothing new to render to the back buffer). Thus wlr_output_rollback has been introduced to revert the pending state. Because the output backend API is mostly state-less, the only thing wlr_output_impl.rollback needs to do is revert the current rendering context. Rename the function to rollback_render to make this clear. Add a check in the common wlr_output code to only call rollback_render when attach_buffer has been previously called. On the long term, we'll be able to remove attach_render and rollback_render together.
2020-06-08backend/drm: fix stack overflow in dealloc_crtcSimon Ser
Call drm_crtc_commit directly instead of calling drm_connector_set_mode. This restores the previous behaviour where conn_enable was called [1]. [1]: https://github.com/swaywm/wlroots/blob/0c7c562482575cacaecadcd7913ef25aeb21711f/backend/drm/drm.c#L1093 Closes: https://github.com/swaywm/wlroots/issues/2253
2020-06-03backend/drm: fix black screens when enabling outputSimon Ser
This patch fixes this failure: 01:57:16.642 [ERROR] [backend/drm/drm.c:360] Failed to page-flip output 'eDP-1': a page-flip is already pending 01:57:16.684 [ERROR] [backend/drm/drm.c:360] Failed to page-flip output 'eDP-1': a page-flip is already pending 01:57:16.684 [ERROR] [backend/drm/drm.c:732] Failed to initialize renderer on connector 'eDP-1': initial page-flip failed 01:57:16.684 [ERROR] [backend/drm/drm.c:805] Failed to initialize renderer for plane 01:57:16.684 [sway/config/output.c:423] Failed to commit output eDP-1 References: https://github.com/swaywm/sway/issues/5101
2020-06-01backend/drm: always perform a CRTC commit in drm_connector_commitSimon Ser
When the mode, status or buffer hasn't changed, drm_connector_commit was a no-op. Because of this individual changes to the gamma LUT or adaptive sync status were ignored (if committed without a buffer). Instead, perform a commit to apply the changes.
2020-06-01backend/drm: drop extra wlr_output_update_enabled callSimon Ser
drm_connector_set_mode already takes care of keeping this up-to-date.
2020-06-01backend/drm: commit/rollback FBs in drm_crtc_commitSimon Ser
We need to perform the FB bookkeeping on all commits, not just on page-flips.
2020-06-01backend/drm: make adaptive_sync atomicSimon Ser
Stop using drmModeObjectSetProperty, set the property in the crtc_commit function instead.
2020-06-01backend/drm: rollback pending CRTC state on test commitSimon Ser
A test commit doesn't apply the pending state. The CRTC state will be populated again if the compositor decides to perform a regular commit afterwards.
2020-05-27backend/drm: fix missing crtc->cursor NULL checkSimon Ser
Fixes: cdb6fdbc6cb7 ("backend/drm: remove missing cursor plane workaround")
2020-05-27backend/drm: don't set cursor if off-screenSimon Ser
Closes: https://github.com/swaywm/wlroots/issues/2216
2020-05-26backend/drm: introduce pending and current CRTC stateSimon Ser
Previously, we only had the pending state (crtc->pending, crtc->mode and crtc->active). This causes issues when a commit fails: the pending state is left as-is, and the next commit may read stale data from it. This will also cause issues when implementing test-only commits: we need to rollback the pending CRTC state after a test-only commit. Introduce separate pending and current CRTC states. Properly update the current state after a commit.
2020-05-26backend/drm: nuke retry_pageflipSimon Ser
retry_pageflip is now dead code, since drm_connector_start_renderer isn't called anymore. It was previously called when enabling an output. The name "retry_pageflip" was a little confusing because the function retried a modeset and the timer wasn't set up while performing a simple page-flip. Let's just remove this altogether for now. We can discuss whether it's worth it to bring it back. Should we only do it on failed page-flips? Should we only do it on EBUSY?
2020-05-26backend/drm: make drm_connector_set_mode take a wlr_drm_connectorSimon Ser
Since this is an internal DRM backend function, there's no reason we need to take a generic wlr_output.
2020-05-26backend/drm: remove enable_drm_connectorSimon Ser
Merge enable_drm_connector into drm_connector_set_mode. This allows us to de-duplicate logic since enabling an output performs a modeset.
2020-05-26backend/drm: remove drm_connector_set_custom_modeSimon Ser
Replace it with a function that returns the pending mode.
2020-05-26backend/drm: refuse to enable an output without a modeSimon Ser
2020-05-20render/egl: unset current context after swapping buffersSimon Ser
After swapping buffers, it doesn't make sense to perform more rendering operations. Unset the context to reflect this. This commit makes it so the context is always only current between wlr_egl_make_current and wlr_egl_swap_buffers. This is an alternative to [1]. [1]: https://github.com/swaywm/wlroots/pull/2212
2020-05-19backend/drm: add missing wlr_egl_unset_currentSimon Ser
2020-05-19render/egl: introduce wlr_egl_unset_currentSimon Ser
This function can be called after wlr_egl_make_current to cleanup the EGL context. This avoids having lingering EGL contexts that make things work by chance. Closes: https://github.com/swaywm/wlroots/issues/2197
2020-05-14output: make wlr_output_set_gamma atomicSimon Ser
wlr_output_set_gamma is now double-buffered and applies the gamma LUT on the next output commit.
2020-05-14backend/drm: fix segfault in drm_crtc_page_flipSimon Ser
When no cursor plane is available, drm_crtc_page_flip would segfault.
2020-05-12backend/drm: disable cursor in dealloc_crtcSimon Ser
dealloc_crtc was destroying GBM surfaces, but the cursor_enabled flag was left as-is. When re-enabling the output, atomic_crtc_pageflip would try enabling the cursor plane, but would fail because no framebuffer is available. Closes: https://github.com/swaywm/wlroots/issues/2150
2020-05-12backend/drm: fix combined modeset+enable commitsSimon Ser
When an output is enabled and modeset at the same time, drm_connector_commit would first try to modeset then try to commit. This won't work because both will trigger a page-flip. KMS will reject that. Change the logic to only enable an output if no modeset has been requested. The logic in wlr_output already checks that the user isn't doing a modeset and disabling the output at the same time.
2020-05-12backend/drm: remove missing cursor plane workaroundSimon Ser
We have a workaround for legacy drivers that support drmModeSetCursor without exposing a cursor plane. It doesn't work anymore now that we've moved to a more atomic interface. Let's just remove this workaround and fallback to software cursors. Closes: https://github.com/swaywm/wlroots/issues/2166
2020-05-11backend/drm: fix missing cursor on external monitors with multi-GPU setup ↵JonnyMako
and nouveau We need to make the multi-GPU surface current before the glFinish call. Closes: https://github.com/swaywm/sway/issues/5319
2020-05-10backend/drm: simplify atomic commit logicSimon Ser
We don't need a per-CRTC atomic request anymore. Let's make the request per-commit so that it's easier to debug. This is also groundwork for supporting wlr_output_test properly.
2020-05-10backend/drm: GAMMA_LUT_SIZE isn't atomicSimon Ser
GAMMA_LUT_SIZE isn't an atomic property. It can be used with the legacy interface too. So we can unify both codepaths and remove wlr_drm_interface.crtc_get_gamma_size. It's no guaranteed to exist though, so we still need to keep the fallback.
2020-05-09backend/drm: remove crtc_set_cursor from interfaceSimon Ser
2020-05-09backend/drm: remove conn_enable from interfaceSimon Ser
Use crtc_commit instead.
2020-05-09backend/drm: rename crtc_pageflip to crtc_commitSimon Ser
Also add a flags argument. The commit function will also be used for disabling the CRTC.
2020-05-09backend/drm: apply gamma LUT on page-flipSimon Ser
2020-05-09backend/drm: remove mode argument to crtc_pageflipSimon Ser
Add a new wlr_drm_crtc.pending bitfield which keeps track of pending output changes. More fields will be added in the future (e.g. active, gamma).
2020-05-09backend/drm: remove wlr_drm_interface.crtc_move_cursorSimon Ser
Instead, make the legacy backend call drmModeMoveCursor on page-flip.
2020-05-01backend/drm: make page-flip error scarierSimon Ser
The logs don't currently display the importance of a line. It's easy to read "skipping page-flip" as a debug message instead of an error message. Change the error message to make it more explicit. References: https://github.com/swaywm/wlroots/pull/2147
2020-05-01Fix error when reconnecting external displayWill Daly
Reconnecting an external display fails on initial page-flip. This occurs when the pageflip_pending flag has been set on the connector at the time the monitor is removed. Once the connector's CRTC has been deallocated, page_flip_handler cannot find the connector by its crtc_id, so pageflip_pending will remain set. This causes initialization to fail when the monitor is reconnected with the error messages: Skipping pageflip on output 'X' Failed to initialize renderer on connector 'X': initial page-flip failed To fix this problem, clear the pageflip_pending flag when cleaning up the connector.
2020-04-28backend/drm: don't allow legacy to use direct scanoutScott Anderson
2020-04-28backend/drm: move atomic cursor code into pageflip codeScott Anderson
It makes sense to construct as much atomic state as possible in the same place, so it doesn't get lost if we "reset" it.
2020-04-28backend/drm: introduce wlr_drm_fbScott Anderson
This is a type which manages gbm_surfaces and imported dmabufs in the same place, and makes the lifetime management between the two shared. It should lead to easier to understand code, and fewer special cases. This also contains a fair bit of refactoring to start using this new type. Co-authored-by: Simon Ser <contact@emersion.fr>