mirror-linux/include/uapi/drm
Thomas Zimmermann fb24aaf541 drm/dumb-buffers: Provide helper to set pitch and size
Add drm_modes_size_dumb(), a helper to calculate the dumb-buffer
scanline pitch and allocation size. Implementations of struct
drm_driver.dumb_create can call the new helper for their size
computations.

There is currently quite a bit of code duplication among DRM's
memory managers. Each calculates scanline pitch and buffer size
from the given arguments, but the implementations are inconsistent
in how they treat alignment and format support. Later patches will
unify this code on top of drm_mode_size_dumb() as much as possible.

drm_mode_size_dumb() uses existing 4CC format helpers to interpret
the given color mode. This makes the dumb-buffer interface behave
similar the kernel's video= parameter. Current per-driver implementations
again likely have subtle differences or bugs in how they support color
modes.

The dumb-buffer UAPI is only specified for known color modes. These
values describe linear, single-plane RGB color formats or legacy index
formats. Other values should not be specified. But some user space
still does. So for unknown color modes, there are a number of known
exceptions for which drm_mode_size_dumb() calculates the pitch from
the bpp value, as before. All other values work the same but print
an error.

v6:
- document additional use cases for DUMB_CREATE2 in TODO list (Tomi)
- fix typos in documentation (Tomi)
v5:
- check for overflows with check_mul_overflow() (Tomi)
v4:
- use %u conversion specifier (Geert)
- list DRM_FORMAT_Dn in UAPI docs (Geert)
- avoid dmesg spamming with drm_warn_once() (Sima)
- add more information about bpp special case (Sima)
- clarify parameters for hardware alignment
- add a TODO item for DUMB_CREATE2
v3:
- document the UAPI semantics
- compute scanline pitch from for unknown color modes (Andy, Tomi)

Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
Reviewed-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
Reviewed-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
Link: https://lore.kernel.org/r/20250821081918.79786-3-tzimmermann@suse.de
2025-09-29 13:57:43 +02:00
..
amdgpu_drm.h drm/amdgpu: Add mapping info option for GEM_OP ioctl 2025-09-02 15:53:33 -04:00
amdxdna_accel.h accel/amdxdna: Add ioctl DRM_IOCTL_AMDXDNA_GET_ARRAY 2025-09-04 08:26:43 -07:00
armada_drm.h
asahi_drm.h drm: Add UAPI for the Asahi driver 2025-04-08 17:15:57 -04:00
drm.h drm: Move drm_gem ioctl kerneldoc to uapi file 2025-07-18 09:18:48 +02:00
drm_fourcc.h drm/fourcc: Add RGB161616 and BGR161616 formats 2025-06-28 09:36:16 +02:00
drm_mode.h drm/dumb-buffers: Provide helper to set pitch and size 2025-09-29 13:57:43 +02:00
drm_sarea.h
etnaviv_drm.h Revert "drm/etnaviv: Expose a few more chipspecs to userspace" 2024-04-25 16:56:20 +02:00
exynos_drm.h
habanalabs_accel.h accel/habanalabs/gaudi2: add signed dev info uAPI 2023-12-19 11:09:43 +02:00
i915_drm.h drm/i915: Support replaying GPU hangs with captured context image 2024-05-16 07:37:05 +00:00
ivpu_accel.h accel/ivpu: Add support for user-managed preemption buffer 2025-09-18 08:42:38 +02:00
lima_drm.h
msm_drm.h drm/msm: Add VM_BIND ioctl 2025-07-04 17:48:38 -07:00
nouveau_drm.h drm/nouveau: use tile_mode and pte_kind for VM_BIND bo allocations 2024-05-13 22:27:33 +02:00
nova_drm.h drm: nova-drm: add initial driver skeleton 2025-05-12 20:48:15 +02:00
omap_drm.h
panfrost_drm.h drm/panfrost: Introduce uAPI for JM context creation 2025-09-18 14:09:47 +01:00
panthor_drm.h drm/panthor: Add support for Mali-Gx15 family of GPUs 2025-08-15 10:51:24 +01:00
pvr_drm.h drm/imagination: Numerous documentation fixes. 2023-11-28 18:56:03 +01:00
qaic_accel.h accel/qaic: Fix typo for struct qaic_manage_trans_passthrough 2024-12-13 08:55:09 -07:00
qxl_drm.h
radeon_drm.h
rocket_accel.h accel/rocket: Add IOCTLs for synchronizing memory accesses 2025-07-25 10:04:46 -06:00
tegra_drm.h
v3d_drm.h drm/v3d: Add parameter to retrieve the number of GPU resets per-fd 2025-07-17 11:17:32 -03:00
vc4_drm.h
vgem_drm.h
virtgpu_drm.h drm/virtio: Add capset definitions to UAPI 2025-03-28 04:53:51 +03:00
vmwgfx_drm.h drm/vmwgfx: Add SPDX header to vmwgfx_drm.h 2024-01-30 14:18:19 -05:00
xe_drm.h drm/xe/uapi: Fix kernel-doc formatting for madvise and vma_query 2025-08-28 07:08:08 -07:00