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.

Driver is the struct returned by Device::get_driver() and carries metadata about the kernel DRM driver that powers a device. It gives you the driver’s name, its semantic version, the date it was published, and a short human-readable description — all sourced directly from the kernel via a single ioctl call.
let driver = card.get_driver().unwrap();
println!("Driver name:    {:?}", driver.name());
println!("Version:        {}.{}.{}", driver.version.0, driver.version.1, driver.version.2);
println!("Date:           {:?}", driver.date());
println!("Description:    {:?}", driver.description());
Common driver names you might encounter:
Driver nameHardware
"i915"Intel integrated graphics
"amdgpu"AMD Radeon GCN and newer
"radeon"AMD Radeon pre-GCN (legacy)
"nouveau"NVIDIA (open-source)
"virtio_gpu"VirtIO virtual GPU (QEMU/KVM)
"vkms"Virtual KMS (software, testing)
"simpledrm"Firmware/EFI framebuffer

Driver Struct

pub struct Driver {
    pub version: (i32, i32, i32),
    pub name: OsString,
    pub date: OsString,
    pub desc: OsString,
}

Fields

version: (i32, i32, i32)

The driver’s version as a (major, minor, patchlevel) tuple. This is the DRM driver version, not the GPU firmware version.
let (major, minor, patch) = driver.version;
println!("{}.{}.{}", major, minor, patch);

name: OsString

The short name of the driver as registered with the DRM subsystem. This is the same string you would find in /sys/class/drm/card0/device/driver symlink. Borrow it with driver.name().

date: OsString

The date the driver was published, typically in "YYYYMMDD" format. Borrow it with driver.date().

desc: OsString

A human-readable description of the driver. Borrow it with driver.description().

Methods

name() -> &OsStr

pub fn name(&self) -> &OsStr
Returns a borrowed reference to the driver name string. Equivalent to driver.name.as_ref().
assert_eq!(driver.name(), "i915");

date() -> &OsStr

pub fn date(&self) -> &OsStr
Returns a borrowed reference to the driver date string.
println!("Published: {:?}", driver.date());
// e.g. "20160919"

description() -> &OsStr

pub fn description(&self) -> &OsStr
Returns a borrowed reference to the human-readable driver description string.
println!("Description: {:?}", driver.description());
// e.g. "Intel Graphics"

Full Usage Example

use drm::Device;

let driver = card.get_driver().unwrap();

let name = driver.name().to_string_lossy();
let (major, minor, patch) = driver.version;

println!("Driver:      {}", name);
println!("Version:     {}.{}.{}", major, minor, patch);
println!("Date:        {}", driver.date().to_string_lossy());
println!("Description: {}", driver.description().to_string_lossy());
OsStr does not guarantee UTF-8, but DRM driver strings are always ASCII in practice. Use .to_string_lossy() for display or .to_str().unwrap() when you are confident in the encoding.

AuthToken

#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
pub struct AuthToken(u32);
AuthToken is an opaque 32-bit token generated by Device::generate_auth_token(). It can be transmitted to a DRM master process (typically over a Unix domain socket), which then calls Device::authenticate_auth_token() to grant the originating process unprivileged access to the device.
The AuthToken mechanism is deprecated. Modern applications should open a render node (/dev/dri/renderD*) instead, which requires no authentication. AuthToken is documented here only for completeness and compatibility with legacy software.

Typical legacy flow

// --- Client process ---
#[allow(deprecated)]
let token = card.generate_auth_token().unwrap();
// send token.0 (a u32) over a Unix socket to the master process

// --- Master process ---
let received = AuthToken(received_u32);
master_card.authenticate_auth_token(received).unwrap();
// client is now authenticated

Build docs developers (and LLMs) love