drm:Direct Rendering Manager

来源:互联网 发布:sqlserver 创建临时表 编辑:程序博客网 时间:2024/05/15 12:15

Direct Rendering Manager

From Wikipedia, the free encyclopedia
Direct Rendering ManagerOriginal author(s)kernel.org & freedesktop.orgDeveloper(s)kernel.org & freedesktop.orgWritten inCType
  • Device driver
  • Loadable kernel module
License
  • MIT License[citation needed]
  • GPL[citation needed]
Websitedri.freedesktop.org/wiki/DRM

The Direct Rendering Manager (DRM) is a subsystem of theLinux kernel responsible for interfacing with GPUs of modernvideo cards. DRM exposes an API that user space programs can use to send commands and data to the GPU, and perform operations like configuring the mode setting of the display. DRM was first developed as the kernel space component of the X Server's Direct Rendering Infrastructure,[1] but since then it has been used by other graphic stack alternatives like Wayland.

The Direct Rendering Manager can be compiled into the Linux kernel or loaded via the standard module interface.

Contents

  [hide] 
  • 1 Overview
  • 2 Software architecture
    • 2.1 API
    • 2.2 Translation Table Maps
    • 2.3 Graphics Execution Manager
    • 2.4 KMS driver (Kernel mode setting)
    • 2.5 Render nodes
    • 2.6 Universal plane
  • 3 Hardware support
  • 4 Development
  • 5 History
  • 6 See also
  • 7 References
  • 8 External links

Overview[edit]

The Linux Kernel already had an API called fbdev allowing to manage the framebuffer of a graphics adapter, but it couldn't be used to handle the needs of modern 3D accelerated GPU based video cards. These type of cards usually require setting and managing a command queue in the memory of the card (Video RAM) to dispatch commands to the GPU, and also they need a proper management of the buffers and free space of the Video RAM itself.[2]Initially own user space programs (like the X Server) directly managed these resources, but these programs usually acted as if they were the only ones with access to the card's resources. When two or more programs tried to control the same video card at the same time, and set its resources each one in its own way, most times they ended catastrophically.[2]

Access to video card without DRM
Without DRM
Access to video card with DRM
With DRM
DRM allows multiple programs concurrently access to the 3D video card avoiding collisions

When the Direct Render Manager was first created, the purpose was that multiple programs that would use the resources of the video card cooperate through it. The DRM has exclusive access to the video card's resources, and it's responsible for initializing and maintaining the command queue, the VRAM and any other hardware resource of the GPU. The programs that want to use a GPU send their requests to DRM, which acts as an arbitrator and takes care to avoid possible conflicts.

Since then, the scope of DRM has been expanded over the years to cover more functionality previously handled by user space programs, like framebuffer managing and mode setting, memory sharing objects and memory synchronization.[3][4] These expansions had carried its own specific names, like Graphics Execution Manager (GEM) or Kernel Mode-Setting (KMS), and are often called by these names when referring specifically to its functionality. But they are really parts of the whole kernel DRM subsystem.

Software architecture[edit]

A process using the Direct Rendering Manager of the Linux Kernel to access a 3D accelerated graphics card

The Direct Rendering Manager resides in kernel space, so the user space programs must use kernel system calls to request its services. However, DRM doesn't define its own customized system calls. Instead, it follows the Unixprinciple "everything is a file" to expose the GPUs through the filesystem name space using device files under the /dev hierarchy. Each GPU detected by DRM is referred as a DRM device, and a device file /dev/dri/cardX(where X is a correlative number) is created to interface with the device.[5][6] The user space programs that want to talk to the GPU must openthe file and use ioctl calls to communicate with DRM. Different ioctls correspond to different functions of the DRM API.

A library called libdrm was created to facilitate the interface of user space applications with the DRM subsystem. This library is merely a wrapper that provides a function written inC for every ioctl of the DRM API, as well as constants, structures and other helper elements.[7] The use of libdrm not only avoids exposing the kernel interface directly to the user space applications, but presents the usual advantages of reusing and sharing code between programs.

It consists of two in-kernel drivers: a generic drm driver, and another which has specific support for theGPUs. This pair of drivers allows a userspace client direct access to the video hardware. The entire DRI system enables hardware accelerated 3D rendering, video decoding as well as GPGPU.

AGP, PCIe and other graphics cards contain an IOMMU called Graphics address remapping table (GART) which can be used to map various pages of system memory into the GPU's address space. The result is that, at any time, an arbitrary (scattered) subset of the system's RAM pages are accessible to the GPU.[8]

API[edit]

The Linux API is composed out of the System Call Interface of the Linux kernel, the GNU C Library (byGNU), libcgroup,[9] libdrm, libalsaand libevedv[10] (byfreedesktop.org).

The DRM core exports several interfaces to user-space applications, generally intended to be used through corresponding libdrm wrapper functions. In addition, drivers export device-specific interfaces for use by user-space drivers & device-aware applications through ioctls and sysfsfiles. External interfaces include: memory mapping, context management, DMAoperations, AGP management, vblank control, fence management, memory management, and output management.

Translation Table Maps[edit]

Translation Table Maps memory manager developed by Tungsten Graphics.

Graphics Execution Manager[edit]

It has been suggested that Graphics Execution Manager be merged into this article. (Discuss) Proposed since August 2014.

The Graphics Execution Manager (GEM) is part of the DRM API that allow multiple applications to share graphics device memory resources (called GEM objects). GEM ensures conflict-free sharing of data between applications by managing the memory synchronization. In contrary to its name, it executes nothing, it manages graphics memory.

KMS driver (Kernel mode setting)[edit]

The KMS driver is the component which is solely responsible for the mode setting. It is the device driver for adisplay controller, and it can be distinguished from the device driver of a rendering accelerator. Due to the fact that dies of modern the GPU found on graphics cards for desktop computers integrate "processing logic", "display controller" and "hardware video acceleration" SIP cores, non-technical people don't distinguish between these three very different components. SoCs on the other hand, regularly mix SIP from different developers, and e.g. ARM's Mali SIP does not feature a display controller. For historical reasons, the DRM and the KMS of the Linux kernel were amalgamated into one component. They were split in 2013 for technical reasons.[11]

The video Embedded Linux Conference 2013 – Anatomy of an Embedded KMS driver on YouTube explains what a KMS driver is.

Render nodes[edit]

In version 3.12 an (experimental) implementation of render nodes were merged into the Direct Rendering Manager.[12][13][14][15]

A render node is a character device that exposes a GPU's off-screen rendering and GPGPU capabilities to unprivileged programs, without exposing any display manipulation access. This is the first step in of an effort to decouple the kernel's interfaces for GPUs and display controllers from the obsolete notion of a graphics card.[11] Coincidentally, unprivileged off-screen rendering is presumed by both Wayland and Mir display protocols — only the compositor is entitled to send its output to a display, and rendering on behalf of client programs is outside the scope of these protocols.

Universal plane[edit]

Patches for universal plane were submitted by Intel's Matthew. D. Roper in May 2014. The idea behind universal plane is to expose all types of hardware planes to userspace via one consistent Kernel–user space API.[16] Universal plane brings framebuffers (primary planes), overlays (secondary planes) and cursors (cursor planes) together under the same API. No more type specific ioctls, but common ioctls shared by them all.[17]

Universal plane prepares the way for Atomic mode setting and nuclear pageflip.

Hardware support[edit]

All hardware mentioned in the article free and open-source graphics device driver has drm code.[18]

As of August 2013, the kernel component of the freedreno driver mainly authored by Rob Clark for Qualcomm'sAdreno GPU family, called MSM driver, has been accepted into mainline, and has been available since Linux kernel 3.12.[19][20]

In Linux kernel 3.13

  • DRM support for Marvell's ARMADA 510 display subsystem.[21]

DRM/i915 obtained support for MIPI Display Serial Interface (DSI) for Linux kernel 3.16.[22]

Development[edit]

The Direct Rendering Manager is developed within the Linux kernel, and its source code resides in the/drivers/gpu/drm directory of the Linux source code. The subsystem maintainter is Dave Airlie, with other maintainers taking care of specific drivers.[23] As usual in the Linux kernel development, DRM submaintainers and contributors send their patches with new features and bug fixes to the main DRM maintainer which integrates them into its own Linux repository. The DRM maintainer in turn submits all of these patches that are ready to be mainlined to Linus Torvalds whenever a new Linux version is going to be released. Torvalds, as top maintainer of the whole kernel, holds the last word on whether a patch is suitable or not for inclusion in the kernel.

For historical reasons, the source code of the libdrm library is maintained under the umbrella of the Mesaproject.[24]

History[edit]

In 1999, while developing DRI for XFree86, Precision Insight created the first version of DRM for the 3dfxvideo cards, as a linux kernel patch included within the Mesa source code.[25] Later that year, the DRM code was mainlined in Linux kernel 2.3.18 under the /drivers/char/drm/ directory for character devices.[26] During the following years the number of supported video cards grew. When Linux 2.4.0 was released in January 2001 there was already support for Creative Labs GMX 2000, Intel i810, Matrox G200/G400 and ATI Rage 128, in addition to 3dfx Voodoo3 cards.[27]

[icon]This section requiresexpansion. (August 2014)

See also[edit]

Portal iconFree software portal
  • Free and open-source graphics device driver
  • Mesa 3D
  • Graphics address remapping table (GART)
  • Vblank & V-sync

References[edit]

  1. Jump up^ "Linux kernel/drivers/gpu/drm/README.drm". kernel.org. Retrieved 2014-02-26.
  2. Jump up to:a b White, Thomas. "How DRI and DRM Work". Retrieved 22 July 2014.
  3. Jump up^ Corbet, Jonathan. "Memory management for graphics processors". LWN.Net. Retrieved 23 July 2014.
  4. Jump up^ Packard, Keith; Anholt, Eric. "The Graphics Execution Manager". LWN.Net. Retrieved 23 July 2014.
  5. Jump up^ Kitching, Simon. "DRM and KMS kernel modules". Retrieved 23 July 2014.
  6. Jump up^ Herrmann, David. "Splitting DRM and KMS device nodes". Retrieved 23 July 2014.
  7. Jump up^ "libdrm README". Retrieved 23 July 2014.
  8. Jump up^ "Memory management for graphics processors". LWN.net. 2007-11-06. Retrieved 2014-06-25.
  9. Jump up^ "ControlGroupInterface". freedesktop.org.
  10. Jump up^ "libevdev". freedesktop.org.
  11. Jump up to:a b "Splitting DRM and KMS nodes". David Herrmann. 2013-09-01.
  12. Jump up^ "drm: implement experimental render nodes".
  13. Jump up^ "drm/i915: Support render nodes".
  14. Jump up^ "drm/radeon: Support render nodes".
  15. Jump up^ "drm/nouveau: Support render nodes".
  16. Jump up^ "Universal plane support". 2014-05-07.
  17. Jump up^ "From pre-history to beyond the global thermonuclear war". 2014-06-05.
  18. Jump up^ "/drivers/gpu/drm". kernel.org.
  19. Jump up^ "Merge the MSM driver from Rob Clark". freedesktop.org. 2013-08-28. Retrieved 2014-06-25.
  20. Jump up^ "drm/msm for Linux kernel 3.13". freedesktop.org. 2013-10-20.
  21. Jump up^ "Armada DRM support for Linux kernel 3.13".
  22. Jump up^ "Neat drm/i915 stuff for 3.16". 2014-06-10.
  23. Jump up^ "List of maintainers of the linux kernel". Kernel.org. Retrieved 14 July 2014.
  24. Jump up^ "libdrm git repository". Retrieved 23 July 2014.
  25. Jump up^ "First DRI release of 3dfx driver.". Mesa 3D. Retrieved 15 July 2014.
  26. Jump up^ "Import 2.3.18pre1". The History of Linux in GIT Repository Format 1992-2010 (2010). Retrieved 15 July 2014.
  27. Jump up^ Torvalds, Linus. "Linux 2.4.0 source code". Kernel.org. Retrieved 29 July 2014.

External links[edit]

  • DRM home page
  • The Direct Rendering Manager: Kernel Support for the Direct Rendering Infrastructure
  • Linux DRM Developer's Guide
  • David Herrmann on Splitting DRM and KMS device nodes
  • Embedded Linux Conference 2013 - Anatomy of an Embedded KMS driver on YouTube
  • http://en.wikipedia.org/wiki/Direct_Rendering_Manager
  • https://www.kernel.org/doc/htmldocs/drm/

0 0