drm.7.rst 3.6 KB

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