• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1===
2drm
3===
4
5------------------------
6Direct Rendering Manager
7------------------------
8
9:Date: September 2012
10:Manual section: 7
11:Manual group: Direct Rendering Manager
12
13Synopsis
14========
15
16``#include <xf86drm.h>``
17
18Description
19===========
20
21The *Direct Rendering Manager* (DRM) is a framework to manage *Graphics
22Processing Units* (GPUs). It is designed to support the needs of complex
23graphics devices, usually containing programmable pipelines well suited
24to 3D graphics acceleration. Furthermore, it is responsible for memory
25management, interrupt handling and DMA to provide a uniform interface to
26applications.
27
28In earlier days, the kernel framework was solely used to provide raw
29hardware access to privileged user-space processes which implement all
30the hardware abstraction layers. But more and more tasks were moved into
31the kernel. All these interfaces are based on **ioctl**\ (2) commands on
32the DRM character device. The *libdrm* library provides wrappers for these
33system-calls and many helpers to simplify the API.
34
35When a GPU is detected, the DRM system loads a driver for the detected
36hardware type. Each connected GPU is then presented to user-space via a
37character-device that is usually available as ``/dev/dri/card0`` and can
38be accessed with **open**\ (2) and **close**\ (2). However, it still
39depends on the graphics driver which interfaces are available on these
40devices. If an interface is not available, the syscalls will fail with
41``EINVAL``.
42
43Authentication
44--------------
45
46All DRM devices provide authentication mechanisms. Only a DRM master is
47allowed to perform mode-setting or modify core state and only one user
48can be DRM master at a time. See **drmSetMaster**\ (3) for information
49on how to become DRM master and what the limitations are. Other DRM users
50can be authenticated to the DRM-Master via **drmAuthMagic**\ (3) so they
51can perform buffer allocations and rendering.
52
53Mode-Setting
54------------
55
56Managing connected monitors and displays and changing the current modes
57is called *Mode-Setting*. This is restricted to the current DRM master.
58Historically, this was implemented in user-space, but new DRM drivers
59implement a kernel interface to perform mode-setting called *Kernel Mode
60Setting* (KMS). If your hardware-driver supports it, you can use the KMS
61API provided by DRM. This includes allocating framebuffers, selecting
62modes and managing CRTCs and encoders. See **drm-kms**\ (7) for more.
63
64Memory Management
65-----------------
66
67The most sophisticated tasks for GPUs today is managing memory objects.
68Textures, framebuffers, command-buffers and all other kinds of commands
69for the GPU have to be stored in memory. The DRM driver takes care of
70managing all memory objects, flushing caches, synchronizing access and
71providing CPU access to GPU memory. All memory management is hardware
72driver dependent. However, two generic frameworks are available that are
73used by most DRM drivers. These are the *Translation Table Manager*
74(TTM) and the *Graphics Execution Manager* (GEM). They provide generic
75APIs to create, destroy and access buffers from user-space. However,
76there are still many differences between the drivers so driver-depedent
77code is still needed. Many helpers are provided in *libgbm* (Graphics
78Buffer Manager) from the *Mesa* project. For more information on DRM
79memory management, see **drm-memory**\ (7).
80
81Reporting Bugs
82==============
83
84Bugs in this manual should be reported to
85https://gitlab.freedesktop.org/mesa/drm/-/issues.
86
87See Also
88========
89
90**drm-kms**\ (7), **drm-memory**\ (7), **drmSetMaster**\ (3),
91**drmAuthMagic**\ (3), **drmAvailable**\ (3), **drmOpen**\ (3)
92