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.

Adding drm-rs to a Rust project is straightforward: a single line in Cargo.toml pulls in the high-level API crate with all of its dependencies, including the low-level ioctl wrappers and pre-generated kernel bindings. No system library needs to be installed because drm-rs does not link against libdrm — it speaks directly to the kernel. The sections below cover the basic dependency declaration, the structure of the three-crate workspace, the optional use_bindgen feature flag, and the minimum environment requirements.

Basic Installation

Add the following to your project’s Cargo.toml:
[dependencies]
drm = "0.15"
That is all most projects need. The drm crate re-exports the full high-level API for both basic device access (drm::Device) and kernel mode setting (drm::control::Device). Run cargo build to fetch and compile the crate and its transitive dependencies from crates.io.

Full Dependency Block

The current release is drm 0.15.0. If you want to pin to the exact patch version, use:
[dependencies]
drm = "0.15.0"
The crate follows Semantic Versioning. The "0.15" range (without a patch component) accepts any 0.15.x release, which is the recommended form for most projects.

Workspace Crate Structure

The drm-rs repository is a Cargo workspace of three crates. Understanding this structure helps you decide whether you need to depend on any of the lower-level crates directly.

drm v0.15.0 — High-Level Safe API

This is the crate almost every project should depend on. It provides:
  • The drm::Device trait for basic device operations (driver info, master lock, vblank waits, capability queries).
  • The drm::control::Device trait for the full KMS/modesetting API (connectors, CRTCs, encoders, planes, framebuffers, atomic commits, page flips).
  • Safe Rust types for all DRM objects (Mode, Handle, Info structs, etc.).
  • The drm::buffer module and DumbBuffer for software-rendered scanout buffers.
  • The drm::node module for working with primary and render node paths.
[dependencies]
drm = "0.15"

drm-ffi v0.9.1 — Low-Level Safe ioctl Wrappers

drm-ffi sits between drm and the raw C bindings. It wraps every DRM ioctl in a safe Rust function that handles argument marshalling and error conversion, but does not add higher-level abstractions like typed handles or iterator adapters. You should depend on this crate directly only if you need to call an ioctl that the drm crate does not yet expose.
[dependencies]
drm-ffi = "0.9.1"

drm-sys v0.8.1 — Raw C Bindgen Bindings

drm-sys contains the auto-generated Rust bindings to the DRM kernel UAPI headers. It exposes raw C structs, constants, and type aliases exactly as they appear in the kernel headers. Direct use of this crate is rarely necessary; prefer drm-ffi or drm instead.
[dependencies]
drm-sys = "0.8.1"

The use_bindgen Feature Flag

By default, drm-sys ships with pre-generated bindings that are bundled inside the crate source. These cover all stable DRM UAPI definitions up to the kernel version targeted at release time and require no additional build tooling. If you need bindings generated from your system’s installed DRM headers — for example, because you are targeting a very recent kernel with new DRM features not covered by the bundled headers — you can enable the use_bindgen feature:
[dependencies]
drm = { version = "0.15", features = ["use_bindgen"] }
This propagates the feature flag through the dependency chain (drmdrm-ffidrm-sys), which causes drm-sys’s build script to invoke bindgen against the DRM headers found via pkg-config on the host system. The bindgen and pkg-config crates are pulled in automatically as build dependencies when the feature is active.
Most users do not need use_bindgen. The pre-generated bindings bundled with drm-sys cover all stable, public DRM UAPI interfaces. Enable use_bindgen only if you are working with an experimental kernel feature or a very new driver that exposes structures not yet present in the bundled headers.

When to Use use_bindgen

SituationRecommendation
Standard desktop or embedded Linux projectUse the default (pre-generated) bindings
Targeting a kernel newer than the bundled headersEnable use_bindgen
CI running on a minimal environment without DRM headersUse the default; avoid use_bindgen
Contributing to drm-rs itself and updating headersUse update_bindings feature in drm-sys directly

Minimum Supported Rust Version (MSRV)

drm-rs requires Rust 1.70 or newer. This version is specified in the rust-version field of each crate’s Cargo.toml. If your toolchain is older, update it with:
rustup update stable

Platform Requirements

drm-rs is designed for operating systems that expose the DRM subsystem:
  • Linux — Primary and fully supported platform. Device nodes are located at /dev/dri/card* (primary nodes) and /dev/dri/renderD* (render nodes).
  • FreeBSD — Supported. The DRM subsystem is available and exposes compatible device nodes.
  • DragonFly BSD — Supported. Requires the drm-kmod package to be installed.
macOS and Windows are not supported. The DRM subsystem is a Unix kernel feature and has no equivalent on those platforms. Cross-compilation targeting Linux from macOS is possible for building the binary, but you cannot run or test it without a Linux (or BSD) host with actual /dev/dri device nodes.
Your process also needs sufficient permissions to open the device node. On most Linux distributions, /dev/dri/card0 is owned by root and the video group. Add your user to the video group, or use a seat manager such as logind or seatd that can hand you an already-opened file descriptor.

Build docs developers (and LLMs) love