Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/Smithay/drm-rs/llms.txt

Use this file to discover all available pages before exploring further.

drm-rs is a safe, idiomatic Rust library for interacting with the Linux Direct Rendering Manager (DRM) subsystem. It provides a zero-libdrm path to GPU hardware and display management, making it the foundation of choice for Wayland compositors, standalone display servers, kiosk applications, and embedded Linux systems that need direct, low-overhead control over graphics hardware. Instead of routing through libdrm (the C library shipped as part of Mesa), drm-rs calls DRM ioctls directly, keeping the abstraction minimal and the surface area auditable — exactly what a security-conscious or resource-constrained project needs.

What Is the DRM Subsystem?

The Direct Rendering Manager is a Linux kernel subsystem that exposes GPU hardware to unprivileged userspace processes. Userspace programs communicate with it by opening a device node — typically a file under /dev/dri/ such as /dev/dri/card0 for primary nodes or /dev/dri/renderD128 for render-only nodes — and issuing ioctl calls on the resulting file descriptor. Through these ioctls, a program can query the connected display hardware, configure scanout pipelines, allocate GPU memory buffers, and schedule page flips. The subsystem is also found on FreeBSD and DragonFly BSD, where it provides an equivalent interface.

Core Traits

drm-rs organises its API around two primary traits:
  • drm::Device — The baseline trait. Any type that implements AsFd (providing a file descriptor to a DRM device node) can implement this trait with an empty body. It grants access to fundamental device operations: querying the driver version, reading bus IDs, managing the DRM Master lock, waiting for vertical blanks, and querying or setting driver/client capabilities.
  • drm::control::Device — The Kernel Mode Setting (KMS) trait, also implemented with an empty body once drm::Device is in place. It unlocks the full modesetting API: enumerating connectors, encoders, CRTCs, planes, and framebuffers; reading and applying display modes; creating dumb buffers; performing legacy or atomic commits; and executing page flips. This is the trait you will use most heavily when building a compositor or display manager.

Three-Crate Workspace

The repository is structured as a workspace of three crates with clearly separated responsibilities:
CrateVersionRole
drm0.15.0High-level, safe Rust API — the crate most users depend on
drm-ffi0.9.1Low-level safe ioctl wrappers; used internally by drm
drm-sys0.8.1Raw C bindgen bindings to kernel DRM headers; rarely needed directly
Most projects only need to add drm to their Cargo.toml. The lower-level crates are available for advanced use cases where finer control over ioctl arguments is required.

File Descriptor Ownership

drm-rs deliberately does not open device files on your behalf. The library has no opinion about how you obtain a file descriptor — you might open /dev/dri/card0 directly, receive a socket-activated file descriptor from a compositor, or use udev to enumerate available nodes. All you need to do is wrap whatever handle you have in a type that implements the standard AsFd trait, and drm-rs takes care of the rest. This design keeps the crate free of privileged-open logic and makes it straightforward to integrate with seat managers like logind or seatd.

Platform Support

drm-rs targets Linux as its primary platform. Limited support is also available for FreeBSD and DragonFly BSD, where the DRM subsystem provides a compatible ioctl interface. Windows and macOS are not supported, as the DRM subsystem is specific to Unix-like kernels that expose /dev/dri device nodes.
drm-rs does not wrap libdrm. It bypasses the Mesa libdrm library entirely and issues DRM ioctls directly via Rust’s rustix crate. This means your binary has no runtime dependency on libdrm.so, and you have full visibility into every kernel call the library makes.

Explore Further

Quick Start

Open a DRM device, query the driver, and list display connectors in minutes.

DRM Overview

Understand CRTCs, connectors, encoders, planes, and the KMS pipeline.

Atomic Modesetting

Learn how to perform atomic commits for tear-free display configuration.

API Reference

Browse the full drm::Device and drm::control::Device API documentation.

Build docs developers (and LLMs) love