DRM/KMS 基本组件介绍

Each DRM device provides access to manage which monitors and displays are currently used and what frames to be displayed. This task is calledKernel Mode-Setting (KMS). Historically, this was done in user-space and called User-space Mode-Setting (UMS). Almost all open-source drivers now provide the KMS kernel API to do this in the kernel, however, many non-open-source binary drivers from different vendors still do not support this. You can use drmModeSettingSupported(3) to check whether your driver supports this. To understand how KMS works, we need to introduce 5 objects: CRTCsPlanesEncodersConnectors and Framebuffers.

CRTCs

CRTC short for CRT Controller is an abstraction representing a part of the chip that contains a pointer to a scanout buffer. Therefore, the number of CRTCs available determines how many independent scanout buffers can be active at any given time. The CRTC structure contains several fields to support this: a pointer to some video memory (abstracted as a frame-buffer object), a list of driven connectors, a display mode and an (x, y) offset into the video memory to support panning or configurations where one piece of video memory spans multiple CRTCs. A CRTC is the central point where configuration of displays happens. You select which objects to use, which modes and which parameters and then configure each CRTC via drmModeCrtcSet(3) to drive the display devices.

Planes

plane respresents an image source that can be blended with or overlayed on top of a CRTC during the scanout process. Planes are associated with a frame-buffer to crop a portion of the image memory (source) and optionally scale it to a destination size. The result is then blended with or overlayed on top of a CRTC. Planes are not provided by all hardware and the number of available planes is limited. If planes are not available or if not enough planes are available, the user should fall back to normal software blending (via GPU or CPU).

Encoders

An encoder takes pixel data from a CRTC and converts it to a format suitable for any attached connectors. On some devices, it may be possible to have a CRTC send data to more than one encoder. In that case, both encoders would receive data from the same scanout buffer, resulting in a cloned display configuration across the connectors attached to each encoder.

Connectors

connector is the final destination of pixel-data on a device, and usually connects directly to an external display device like a monitor or laptop panel. A connector can only be attached to one encoder at a time. The connector is also the structure where information about the attached display is kept, so it contains fields for display data, EDID data, DPMS and connection status, and information about modes supported on the attached displays.

Framebuffers

Framebuffers are abstract memory objects that provide a source of pixel data to scanout to a CRTC. Applications explicitely request the creation of framebuffers and can control their behavior. Framebuffers rely on the underneath memory manager for low-level memory operations. When creating a framebuffer, applications pass a memory handle through the API which is used as backing storage. The framebuffer itself is only an abstract object with no data. It just refers to memory buffers that must be created with the drm-memory(7) API.
KMS Display Pipeline Overview
KMS Display Pipeline Overview

 

KMS Output Pipeline
KMS Output Pipeline
Atomic Mode Setting
Atomic Mode Setting
posted on 2017-09-13 12:23  图灵之梦  阅读(3872)  评论(0编辑  收藏  举报