I have not touched Linux DRM before, although I’m very familiar with BSP. Now I need to fix display-related issues due to OpenHarmony porting, so let me start by getting an overview of this firstly.

DRM(Direct Rendering Manager) was initially designed for accessing GPU hardware, but it has expanded to cover more functions previously handled by userpace, such as GEM(Graphics Execution Manager) and KMS(kernel mode-setting).

The software architecture is as follows:

There are two parts: DRM core and DRM driver(GEM + KMS). Access the DRM via userspace libdrm to avoid duplicate code.

GEM is the memory managerment in DRM. For example, userspace can use GEM to request memory to store a framebuffer or data required by GPU.

KMS mode includes screen resolution, color depth and refresh rate.

The display output pipeline is as follows:

fb ->plane
crtc -> encoder -> bridge (optional) -> connector -> display device (monitor, laptop panel...)
fb ->plane
  • Framebuffer(fb): Includes pixel data for a single frame or image to be displayed on the screen.
  • Plane: Image source, framebuffer feed.
  • CRTC: Read pixel data from different planes and blends them together.
  • Connector: Phyical connector, like VGA, HDMI, DisplayPort(DP).
  • Encoder: Encodes the signal from CRTC for the connector.
  • Panel: The actual screen that displays the image. Panel types include LCD(IPS, VA, TN) and OLED.
  • Monitor: Panel plus other components(power supply, connect port, etc.).
  • Bridge: Convert signals, such as MIPI DSI to eDP.

We can use libdrm/modetest to test KMS. The DRM device is /dev/dri/cardX, the code is in drivers/gpu/drm.

OK, that’s all. No need to read kernel documents about DRM now, the wiki is enough.