aboutsummaryrefslogtreecommitdiff
path: root/backend/drm/util.c
AgeCommit message (Collapse)Author
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-07backend/drm: fix NULL pointer deference due to typoIsaac Freund
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-05-26backend/drm: fix crash with null serialvaxerski
backend/drm: use serial_str instead
2022-05-26output: turn make/model/serial into char *Simon Ser
This allows the make/model/serial to be NULL when unset, and allows them to be longer than the hardcoded array length. This is a breaking change: compositors need to handle the new NULL case, and we stop setting make/model to useless "headless" or "wayland" strings.
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
2021-12-14backend/drm: use drmCloseBufferHandleSimon Ser
This has been added in [1] and allows us to close buffer handles without manually calling drmIoctl. [1]: https://gitlab.freedesktop.org/mesa/drm/-/merge_requests/192
2021-10-29backend/drm: get rid of BO handle tableSimon Ser
The BO handle table exists to avoid double-closing a BO handle, which aren't reference-counted by the kernel. But if we can guarantee that there is only ever a single ref for each BO handle, then we don't need the BO handle table anymore. This is possible if we create the handle right before the ADDFB2 IOCTL, and close the handle right after. The handles are very short-lived and we don't need to track their lifetime. Because of multi-planar FBs, we need to be a bit careful: some FB planes might share the same handle. But with a small check, it's easy to avoid double-closing the same handle (which wouldn't be a big deal anyways). There's one gotcha though: drmModeSetCursor2 takes a BO handle as input. Saving the handles until drmModeSetCursor2 time would require us to track BO handle lifetimes, so we wouldn't be able to get rid of the BO handle table. As a workaround, use drmModeGetFB to turn the FB ID back to a BO handle, call drmModeSetCursor2 and then immediately close the BO handle. The overhead should be minimal since these IOCTLs are pretty cheap. Closes: https://github.com/swaywm/wlroots/issues/3164
2021-10-26backend/drm: add entry for Valve EDID vendorSimon Ser
As found in e.g. the Steam Deck.
2021-08-25backend/drm: introduce wlr_drm_bo_handle_tableSimon Ser
Using GBM to import DRM dumb buffers tends to not work well. By using GBM we're calling some driver-specific functions in Mesa. These functions check whether Mesa can work with the buffer. Sometimes Mesa has requirements which differ from DRM dumb buffers and the GBM import will fail (e.g. on amdgpu). Instead, drop GBM and use drmPrimeFDToHandle directly. But there's a twist: BO handles are not ref'counted by the kernel and need to be ref'counted in user-space [1]. libdrm usually performs this bookkeeping and is used under-the-hood by Mesa. We can't re-use libdrm for this task without using driver-specific APIs. So let's just re-implement the ref'counting logic in wlroots. The wlroots implementation is inspired from amdgpu's in libdrm [2]. Closes: https://github.com/swaywm/wlroots/issues/2916 [1]: https://gitlab.freedesktop.org/mesa/drm/-/merge_requests/110 [2]: https://gitlab.freedesktop.org/mesa/drm/-/blob/1a4c0ec9aea13211997f982715fe5ffcf19dd067/amdgpu/handle_table.c
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-04-27Revert "backend/drm: fail instead of stripping a modifier"Simon Ser
This reverts commit f9f90b417366581b58d806956c9b2099417ed4b3. gbm_bo_get_modifier may return a modifier in these cases: - The kernel doesn't support modifiers but Mesa does - WLR_DRM_NO_MODIFIERS=1 is set However, in both of these cases, the gbm_bo has been allocated without modifiers. There is already a check in drm_fb_create for modifiers: wlr_drm_format_set_has will make sure buffers with an explicit modifier will be rejected if the DRM backend doesn't support them. So no need for an additional check in get_fb_for_bo. Closes: https://github.com/swaywm/wlroots/issues/2896
2021-04-26backend/drm: clarify error message on drmModeAddFB fallbackSimon Ser
The previous code would always print "falling back to legacy method", even if the format wasn't ARGB8888. Drop get_fb_for_bo_legacy, since the code can just be inlined without hurting readability. Ideally we should only fallback to drmModeAddFB if the error code indicates the BE failure, but the original PR [1] doesn't say what error code is returned by the kernel. [1]: https://github.com/swaywm/wlroots/pull/2569
2021-04-26backend/drm: fail instead of stripping a modifierSimon Ser
We shouldn't strip a modifiers from buffers, because the will make the kernel re-interpret the data as LINEAR on most drivers, resulting in an incorrect output on screen.
2021-03-05backend/drm: add new writeback and SPI connector typesSimon Ser
We already depend on libdrm 2.4.95, which is the first to have the writeback connector type.
2020-12-28drm: add fallback drmModeAddFB for drivers which do not support drmModeAddFB2Ariadne Conill
This makes wlroots able to run on some big-endian machines like G4 and G5 systems with ATI Radeon 7500 AGP graphics.
2020-12-22backend/drm: make drm_fb_acquire return a FB IDSimon Ser
2020-12-15Remove inline keywordSimon Ser
The compiler is smarter at figuring out whether a function should be inlined or not.
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>
2019-12-11backend/drm: add BenQ to manufacturer listSimon Ser
2019-06-07backend/drm: add support for multiplanar BOsSimon Ser
2019-06-07backend/drm: fallback to drmModeAddFB2Simon Ser
2019-06-07backend/drm: add basic support for direct scan-outemersion
2019-01-29backend/drm: fix GBM format mismatchemersion
We create the EGL config with GBM_FORMAT_ARGB8888, but then initialize GBM BOs with GBM_FORMAT_XRGB8888. This mismatch confuses Mesa. Instead, we can always use GBM_FORMAT_ARGB8888, and use DRM_FORMAT_XRGB8888 when calling drmModeAddFB2. Fixes https://github.com/swaywm/wlroots/issues/1438
2018-12-23backend/drm: get physical size from libdrmemersion
Values from libdrm are likely more reliable than raw values from the EDID. We were already using values from libdrm, but they were overwritten by parse_edid. See drm.c: wlr_conn->output.phys_width = drm_conn->mmWidth; wlr_conn->output.phys_height = drm_conn->mmHeight;
2018-12-16backend/drm: don't insert duplicate custom modes, fix refresh rateemersion
2018-10-04backend/drm: update EDID manufacturers databaseemersion
2018-09-15backend/drm: steal CRTCs from disabled outputsemersion
This commit allows outputs that need a CRTC to steal it from user-disabled outputs. Note that in the case there are enough CRTCs, disabled outputs don't loose it (so there's no modeset and plane initialization needed after DPMS). CRTC allocation still prefers to keep the old configuration, even if that means allocating an extra CRTC to a disabled output. CRTC reallocation now happen when enabling/disabling an output as well as when trying to modeset. When enabling an output without a CRTC, we realloc to try to steal a CRTC from a disabled output (that doesn't really need the CRTC). When disabling an output, we try to give our CRTC to an output that needs one. Modesetting is similar to enabling. A new DRM connector field has been added: `desired_enabled`. Outputs without CRTCs get automatically disabled. This field keeps track of the state desired by the user, allowing to automatically re-enable outputs when a CRTC becomes free. This required some changes to the allocation algorithm. Previously, the algorithm tried to keep the previous configuration even if a new configuration with a better score was possible (it only changed configuration when the old one didn't work anymore). This is now changed and the old configuration (still preferred) is only retained without considering new possibilities when it's perfect (all outputs have CRTCs). User-disabled outputs now have `possible_crtcs` set to 0, meaning they can only retain a previous CRTC (not acquire a new one). The allocation algorithm has been updated to do not bump the score when assigning a CRTC to a disabled output.
2018-09-04backend/drm: cosmetic enhancementsemersion
2018-09-04backend/drm: consider continue not using resourcesemersion
Fixes #1230
2018-09-04backend/drm: prevent use of uninitialized dataemersion
2018-09-04backend/drm: remove unused ifemersion
2018-08-21backend/drm: add support for DRM_MODE_CONNECTOR_DPIemersion
2018-07-09util: add wlr_ prefix to log symbolsemersion
2018-05-03Fix typos in comments and stringsmorganamilo
2018-02-12Reformat all #include directivesemersion
2017-12-28style: fix sizeof() calls without parenthesesDominique Martinet
2017-12-07Configure outputs with make, model, serial in rootstonemersion
Added fallbacks in DRM backend in case EDID extension data for model and serial is missing. Updates #403
2017-11-11Add wlr_output.serialemersion
2017-09-30Rename files to remove pointless drm prefixScott Anderson