</>EmbeddedInterview

What is the DRM/KMS display stack?

HardLinux Kernel & Device Drivers

Short answer: The Direct Rendering Manager (DRM) is the Linux graphics and display subsystem; KMS (kernel mode setting) is the display part. KMS models the display pipeline as objects: framebuffers (memory holding pixels, backed by GEM buffer objects), planes (layers that scan out a framebuffer: primary, overlay, cursor, with format, scaling and position), CRTCs (the scan-out engines that blend planes and generate timing for one display mode), encoders (convert the pixel stream to a signal type: DSI, HDMI, eDP, LVDS) and connectors (the outputs with their modes and hot-plug status), plus bridges and panels for external chips and displays. User space commits a complete new state with the atomic API, which is validated (atomic_check) and applied at vblank (atomic_commit), so updates are all-or-nothing and tear-free.

GEM buffers → framebuffers → planes ─┐
                                     ├→ CRTC (timing, blending) → encoder → bridge(s) → connector → panel/monitor
                         overlay ────┘

Atomic commit flow

  1. User space (Wayland compositor, Android HWComposer via drm_hwcomposer, modetest, Weston) builds a property set: plane FB_ID, CRTC_X/Y/W/H, CRTC MODE_ID, ACTIVE, connector CRTC_ID.
  2. DRM_IOCTL_MODE_ATOMIC with TEST_ONLY can check a configuration without applying it.
  3. The driver's atomic_check callbacks validate bandwidth, formats, scaling limits and clocks.
  4. atomic_commit programs the hardware (usually through helpers: drm_atomic_helper_commit_tail), latches at the next vblank, and sends page-flip events with timestamps to user space.

MIPI DSI panel driver essentials

static int mypanel_prepare(struct drm_panel *panel)
{
    struct mypanel *p = container_of(panel, struct mypanel, panel);
    int ret = regulator_bulk_enable(ARRAY_SIZE(p->supplies), p->supplies);
    if (ret) return ret;
    gpiod_set_value_cansleep(p->reset, 0);
    msleep(20);
    mipi_dsi_dcs_exit_sleep_mode(p->dsi);
    msleep(120);
    return mipi_dsi_dcs_set_display_on(p->dsi);
}
/* get_modes() returns the panel's drm_display_mode (timings, size);
 * probe sets dsi->lanes, dsi->format, dsi->mode_flags and calls mipi_dsi_attach() */

Concepts interviewers probe

  • GEM (buffer objects), dumb buffers (simple CPU-drawn framebuffers), PRIME/dma-buf (sharing buffers between GPU, camera and display), fences (implicit/explicit synchronisation: render finished before scan-out).
  • Vblank handling and page-flip events; underflow debugging (memory bandwidth, QoS, clocks).
  • Mode timings: pixel clock, hactive/hfp/hsync/hbp, same for vertical; refresh = pixel clock / (htotal × vtotal).
  • DSI: video vs command mode, lanes, burst mode, low-power vs high-speed transmission for DCS commands.
  • Debug: modetest -M <driver>, /sys/kernel/debug/dri/0/state, drm.debug=0x1e on the command line, cat /sys/class/drm/card0-DSI-1/modes.