The documented size formula mixes a byte stride with a pixel width and applies an incorrect bits-to-bytes conversion to a value that already includes the pixel storage size.
Clarify that pitch is measured in bytes and includes row padding, so the rows occupy height * pitch bytes. Explain that allocation alignment may increase the returned size and that callers should use that size when mapping the buffer. This is a documentation-only change with no runtime behavior changes. Signed-off-by: Reda Maher <[email protected]> --- man/drm-memory.7.rst | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/man/drm-memory.7.rst b/man/drm-memory.7.rst index 9aa75e01..80aeda41 100644 --- a/man/drm-memory.7.rst +++ b/man/drm-memory.7.rst @@ -72,10 +72,12 @@ must be zeroed. Different flags to modify the behavior may be added in the future. After calling the ioctl, the handle, pitch and size fields are filled by the kernel. *handle* is a 32-bit gem handle that identifies the buffer. This is used by several other calls that take a gem-handle or memory-buffer as -argument. The *pitch* field is the pitch (or stride) of the new buffer. Most -drivers use 32-bit or 64-bit aligned stride-values. The size field contains the -absolute size in bytes of the buffer. This can normally also be computed with -``(height * pitch + width) * bpp / 4``. +argument. The *pitch* field is the pitch (or stride) of the new buffer in bytes, +including any padding between rows. Most drivers use 32-bit or 64-bit aligned +stride-values. The rows occupy ``height * pitch`` bytes. The *size* field +contains the total allocation size in bytes, which may be larger due to +alignment requirements. Use the returned *size* when mapping the buffer rather +than computing it from the dimensions. To prepare the buffer for **mmap**\ (2) you need to use the ``DRM_IOCTL_MODE_MAP_DUMB`` ioctl. It takes as argument a structure of type
