aboutsummaryrefslogtreecommitdiff
path: root/backend/drm/drm.c
AgeCommit message (Collapse)Author
2022-11-02backend/drm: get possible CRTCs in create_drm_connector()Simon Ser
This stuff is immutable for a given connector.
2022-11-02backend/drm: extract create_drm_connector()Simon Ser
Move a bit more logic out of the big loop in scan_drm_connectors().
2022-10-19backend/drm: fetch current CRTC once on startupSimon Ser
Once we are DRM master, the CRTC cannot be changed behind our back except during a VT switch. After a VT switch, we try to restore whatever KMS state we had last programmed. Reloading the current CRTC from KMS breaks this and can result in a modeset without a FB. Closes: https://gitlab.freedesktop.org/wlroots/wlroots/-/issues/3432
2022-10-17backend/drm: drop drm_crtc_page_flip()Simon Ser
Inline it in drm_connector_commit_state(). Brings us a step closer to unifying the test code-path and the commit code-path.
2022-10-17backend/drm: fix EINVAL atomic commits after VT switchSimon Ser
The drm_connector_commit_state() call in handle_session_active() was not resulting in any atomic commit, because it didn't match any of the if branches: active = true, no new buffer was committed, and adaptive sync/gamma LUT were unchanged. Thus the commit was a no-op. Later on, when the compositor performs regular page-flips, the kernel would return EINVAL indicating that a modeset was needed. Rework the logic to use a non-blocking page-flip commit if a buffer was committed, and use a blocking commit if the connector is on or is being disabled. The only case where we should skip the atomic commit is when disabling (active = false) an already-disabled connector (conn->crtc == NULL). Note, 6936e163b514 ("backend/drm: short-circuit no-op commits") has introduced early returns for other situations where we don't need to perform an atomic commit (e.g. updating scale or transform of an output). Fixes: f216e979836a ("backend/drm: drop drm_connector_set_mode()") Closes: https://gitlab.freedesktop.org/wlroots/wlroots/-/issues/3432
2022-10-17backend/drm: extract current mode logic into separate functionSimon Ser
Extract the logic to fetch the current mode to a separate function to make it more readable. Stop dying in an assert when get_drm_prop_blob() fails. Always make it so the drmModeModeInfo pointer is allocated so that we can free() it unconditionally.
2022-10-15backend/drm: extract connect_drm_connector() logicSimon Ser
We already have disconnect_drm_connector() to handle the CONNECTED → DISCONNECTED transition. Let's add connect_drm_connector() to handle DISCONNECTED → CONNECTED. This makes scan_drm_connectors() shorter and easier to follow. No functional change, literally just moving code around.
2022-10-14backend/drm: use atomic API to fetch current connector's CRTCSimon Ser
We were using the legacy API (with a detour through drmModeEncoder) to find out the current CRTC for a connector. Use the atomic API when available. Also extract the whole logic into a separate function for better readability, and better handle errors.
2022-10-13backend/drm: use wl_container_of() instead of casts for wlr_drm_modeSimon Ser
Instead of casting a wlr_output_mode to wlr_drm_mode, use wl_container_of() for slightly better type safety.
2022-10-10backend/drm: drop drm_connector_set_mode()Simon Ser
Instead of special-casing modesets, we can just cut the wrapper and directly call drm_crtc_page_flip(). drm_connector_test() should already have the checks previously done in drm_connector_set_mode(), all we need to do is update enabled/mode after a successful atomic commit.
2022-10-07backend/drm: allocate connector CRTC on lease creationSimon Zeni
This was leading to crash in compositors if the wanted connector had no CRTC
2022-10-07backend/drm: nuke wlr_drm_connector.desired_enabledSimon Ser
This field becomes stale too easily: for instance, see 6adca4089cf4 ("backend/drm: don't unconditionally set desired_enabled"). Additionally, drm_connector_alloc_crtc() needs to do some weird dance, restoring its previous value. Instead, add a connector arg to realloc_crtcs() to indicate a new connector we want to enable.
2022-10-07backend/drm: drop unnecessary wlr_drm_connector.crtc checksSimon Ser
drm_connector_alloc_crtc() already checks this.
2022-10-03backend/drm: remove outdated TODOSimon Ser
This has been addressed in 8795dde94eeb ("Initialize connectors current mode to the mode used by KMS on startup.").
2022-10-03backend/drm: don't unconditionally set desired_enabledSimon Ser
We were unconditonally setting desired_enabled = true for all connected connectors. This makes realloc_crtcs() always keep a CRTC active for these, even if the user doesn't want to enable them.
2022-09-30backend/drm: fix missing wlr_output_state.allow_artifactsSimon Ser
Without allow_artifacts, applying the new state will fail because it requires ALLOW_MODESET. Fixes VT switch and disabling CRTCs.
2022-09-30output: add wlr_output_state.allow_artifactsSimon Ser
When starting up, the compositor might call wlr_output_set_mode() with a mode which is already the current one. wlroots will detect this and make the wlr_output_set_mode() call a no-op. During the next wlr_output_commit() call, wlroots will perform an atomic commit without the ALLOW_MODESET flag. This is an issue, because some drivers need ALLOW_MODESET even if the mode is the same. For instance, if the FB stride or modifier changed, some drivers require a modeset. Add a new flag "allow_artifacts" which is set when the compositor calls mode-setting functions. Use this flag to figure out whether we want to perform atomic commits with ALLOW_MODESET. (The name "allow_artifacts" is picked because ALLOW_MODESET is a misnomer, see [1].) [1]: https://patchwork.freedesktop.org/patch/505107/ Closes: https://gitlab.freedesktop.org/wlroots/wlroots/-/issues/3499
2022-09-22backend/drm: pass through mode picture aspect ratioSimon Ser
2022-09-21backend/drm: de-duplicate wlr_drm_mode creationSimon Ser
Introduce a function to convert a drmModeModeInfo into a new wlr_drm_mode.
2022-09-16Initialize connectors current mode to the mode used by KMS on startup.vanfanel
2022-08-30output: fail commits if adaptive sync cannot be enabledSimon Ser
Previously, adaptive sync was just a hint and wouldn't make any atomic commit fail if the backend didn't support it. The main reason is wlr_output_test wasn't supported at the time. Now that we have a way for compositors to test whether a change can work, let's remove the exception for adaptive sync and convert it to a regular output state field.
2022-08-22Use env helpersAlexander Orzechowski
2022-08-18Use wl_signal_emit_mutableAlexander Orzechowski
2022-08-10backend/drm: drop enum wlr_drm_connector_statusSimon Ser
We can just use libdrm's drmModeConnection enum instead.
2022-08-10backend/drm: drop WLR_DRM_CONN_NEEDS_MODESETSimon Ser
- Add wlr_output.enabled checks to CONNECTED checks - Replace NEEDS_MODESET with CONNECTED
2022-07-25backend/drm: use drmModeConnectorGetPossibleCrtcsSimon Ser
This function has been merged in libdrm. References: https://gitlab.freedesktop.org/mesa/drm/-/commit/3ee004ef529f43366fdd1f4d32b26872cc82c6ca
2022-07-25backend/drm: use drmModeGetConnectorTypeNameSimon Ser
No need to manually maintain this table now. The wlroots names and the libdrm (= kernel) names all match. References: https://gitlab.freedesktop.org/mesa/drm/-/commit/50f8d517733d24fce6693ffae552f9833e2e6aa9
2022-06-19backend/drm: set "max bpc" to the maxSimon Ser
"max bpc" is a maximum value, the driver is free to choose a smaller value depending on the bandwidth available. Some faulty monitors misbehave with higher bpc values. We'll add a workaround if users get hit by these in practice. References: https://gitlab.freedesktop.org/wayland/weston/-/issues/612
2022-06-19backend/drm: remove unused CRTC count checkSimon Ser
drmIsKMS already checks for this.
2022-06-07backend/drm: make serial optionalSimon Ser
The EDID 1.4 spec says that the serial number is optional: > If this field is not used, then enter “00h, 00h, 00h, 00h”. Leave the wlr_output.serial field NULL in that case, and hide it from the output description.
2022-06-02backend/drm: fix check for no-op commitsIsaac Freund
Since 6936e163b, we short-circut no-op commits as an optimization. However, the logic in the check was slightly off.
2022-06-02backend/drm: short-circuit no-op commitsSimon Ser
Some output commits (changing e.g. the output scale or transform) don't require any change in the KMS state. Instead of going through a KMS commit, return early. Blocking KMS commits can be expensive.
2022-05-30output: pass wlr_output_state to backendSimon Ser
Groundwork for the following commits. The goal is to allow users to specify their own wlr_output_state instead of wlr_output.pending.
2022-05-11backend/drm: fetch EDID manufacturer from udev_hwdbSimon Ser
Maintaining our internal table up-to-date is tedious: one needs to manually go through the PnP ID registry [1] and check whether we're missing any entry. udev_hwdb already has an API to fetch a manufacturer name from its PnP ID. Use that instead. [1]: https://uefi.org/pnp_id_list
2022-04-28Zero-initialize structs in init functionsSimon Ser
Ensures there is no field left to its previous undefined value after calling an init function.
2022-03-13Pass O_CLOEXEC to drmModeCreateLease callsSamuel Čavoj
The lease_fd is currently being leaked to child processes Link: https://github.com/swaywm/sway/issues/4286#issuecomment-1065987957
2021-12-14backend/drm: use drmModeFormatModifierBlobIterNextSimon Ser
This avoids open-coding our own logic. The resulting code is more readable. References: https://gitlab.freedesktop.org/mesa/drm/-/merge_requests/146
2021-12-09output: introduce wlr_output_set_nameSimon Ser
wlroots picks names for all outputs, but it might be desirable for compositor to override it. For instance, Sway will use a headless output as a fallback in case no outputs are connected. Sway wants to clearly label the fallback output as such and label "real" headless outputs starting from HEADLESS-1.
2021-11-26backend/drm: always add LINEAR to supported modifiersSimon Ser
2021-11-26Require INVALID for implicit format modifiersSimon Ser
See [1] for the motivation. [1]: https://gitlab.freedesktop.org/wayland/wayland-protocols/-/merge_requests/75
2021-11-19backend/drm: scan leases on ueventSimon Ser
Closes: https://gitlab.freedesktop.org/wlroots/wlroots/-/issues/3181
2021-11-19backend/drm: introduce wlr_drm_leaseSimon Ser
Closes: https://gitlab.freedesktop.org/wlroots/wlroots/-/issues/3183
2021-11-02backend/drm: handle per-connector hotplug eventsSimon Ser
When a connector ID is specified in a hotplug event, don't scan all connectors. Only scan the connector that has changed.
2021-10-15output: add presented flag to presentation eventKirill Primak
2021-10-01Revert "Require INVALID for implicit format modifiers"Simon Ser
This reverts commit ea7357b70366588069c83f158e6a4eb2d3a702b3.
2021-10-01Require INVALID for implicit format modifiersSimon Ser
See [1] for the motivation. [1]: https://gitlab.freedesktop.org/wayland/wayland-protocols/-/merge_requests/75
2021-09-21backend/drm: add support for panel orientationSimon Ser
Expose the panel orientation with wlr_drm_connector_get_panel_orientation. Leave it to the compositor to consume this information and configure the output accordingly. Closes: https://github.com/swaywm/wlroots/issues/1581
2021-09-08backend/drm: introduce wlr_drm_backend_get_non_master_fdSimon Zeni
2021-09-08backend/drm: implement drm lease functionSimon Zeni
2021-09-07backend/drm: drop wlr_drm_connector.desired_modeSimon Ser
Previously used by attempt_enable_needs_modeset, but this has been dropped in the previous commit.