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 properties are named key-value pairs attached to KMS objects: connectors, CRTCs, planes, and framebuffers. Every configuration knob in the atomic modesetting model — framebuffer assignment, display mode, CRTC enable state, colour space, HDR metadata, rotation angle — is expressed as a property value. Properties are strongly typed; each one declares its value domain (boolean, integer range, enum, blob, or object reference). Properties are read with Device::get_properties() to get a set of handles and current values, then individually described with Device::get_property() to obtain the name and type.

property::Handle

An opaque, copy-cheap handle to a property resource. Internally a NonZeroU32 wrapped with repr(transparent). Implements ResourceHandle with FFI_TYPE = DRM_MODE_OBJECT_PROPERTY.

property::RawValue

pub type RawValue = u64;
The uninterpreted 64-bit integer that the kernel stores for every property value. Raw values are what PropertyValueSet and AtomicModeReq carry internally. Use ValueType::convert_value() to produce a typed Value<'_> from a RawValue.

property::Info

Returned by Device::get_property(). Describes the schema of a property.
MethodReturn typeDescription
handle()HandleThe property’s own handle
name()&CStrHuman-readable property name (e.g. "CRTC_ID", "MODE_ID", "active")
value_type()&ValueTypeThe type and constraint of the property’s value
mutable()booltrue if the property can be changed; false for read-only properties
atomic()booltrue if the property is only accessible when the device is opened with the Atomic client capability

property::ValueType

Describes the type and constraints of a property value. Used to interpret a raw u64 into a meaningful Rust value.
VariantDescription
Boolean0 (false) or 1 (true); a RANGE property with min=0, max=1
UnsignedRange(min, max)An unsigned 64-bit integer in the inclusive range [min, max]
SignedRange(min, max)A signed 64-bit integer in the inclusive range [min, max]
Enum(EnumValues)One of a fixed set of named variants; see EnumValues
BitmaskA bitmask whose bit positions are named enum variants
BlobA 64-bit blob ID referencing binary data stored in the kernel
CRTCA handle to a CRTC object (0 = none)
ConnectorA handle to a connector object
EncoderA handle to an encoder object
FramebufferA handle to a framebuffer object
PlaneA handle to a plane object
PropertyA handle to another property object
ObjectA handle to an unspecified DRM object
UnknownUnrecognised property type
ValueType::convert_value(raw: RawValue) -> Value<'_> interprets a raw value according to the type.

property::Value<'a>

A typed representation of a property value. Mirrors ValueType with concrete data.
VariantInner typeDescription
Boolean(bool)boolTrue or false
UnsignedRange(u64)u64Integer within declared range
SignedRange(i64)i64Signed integer within declared range
Enum(Option<&'a EnumValue>)Option<&EnumValue>Named enum variant, or None if the raw value is not in the set
Bitmask(u64)u64Bitmask value
Blob(u64)u64Blob ID; fetch content with Device::get_property_blob()
CRTC(Option<crtc::Handle>)Option<crtc::Handle>Optional CRTC handle
Connector(Option<connector::Handle>)Option<connector::Handle>Optional connector handle
Encoder(Option<encoder::Handle>)Option<encoder::Handle>Optional encoder handle
Framebuffer(Option<framebuffer::Handle>)Option<framebuffer::Handle>Optional framebuffer handle
Plane(Option<plane::Handle>)Option<plane::Handle>Optional plane handle
Property(Option<Handle>)Option<Handle>Optional property handle
Object(Option<RawResourceHandle>)Option<RawResourceHandle>Optional untyped object handle
Unknown(RawValue)u64Uninterpreted raw value
Value<'a> implements typed accessor methods (as_boolean(), as_unsigned_range(), as_blob(), as_crtc(), etc.) that return Option<T>. It also implements From<Value<'_>> for RawValue for converting back to a u64 to pass to AtomicModeReq.

property::EnumValues

Holds the set of valid named variants for ValueType::Enum and ValueType::Bitmask properties.
MethodReturn typeDescription
values()(&[RawValue], &[EnumValue])Parallel slices of raw values and named enum entries
get_value_from_raw_value(value: RawValue)Option<&EnumValue>Look up the named entry for a raw value

property::EnumValue

A single named variant within an enum property.
MethodReturn typeDescription
value()RawValueThe numeric value associated with this variant
name()&CStrThe name of this variant (e.g. "connected", "disconnected")

PropertyValueSet

Returned by Device::get_properties(). Holds all property handles and their current raw values for a KMS object.
MethodReturn typeDescription
as_props_and_values()(&[property::Handle], &[RawValue])Parallel slices of handles and values
as_hashmap(device)io::Result<HashMap<String, property::Info>>Build a map from property name to Info
iter()impl Iterator<Item = (&Handle, &RawValue)>Iterate handle-value pairs
PropertyValueSet also implements both IntoIterator forms: &PropertyValueSet yields (&Handle, &RawValue) and consuming PropertyValueSet yields (Handle, RawValue).

ModePropFlags

Internal bitflags describing the type of a property as reported by the kernel. These are decoded by Device::get_property() to produce a ValueType; you rarely need to use them directly.
FlagDescription
RANGEUnsigned integer range (or Boolean if min=0, max=1)
SIGNED_RANGESigned integer range
ENUMNamed enumeration
BLOBBinary blob
BITMASKNamed bitmask
OBJECTHandle to a DRM object
ATOMICProperty hidden unless ClientCapability::Atomic is set
IMMUTABLEProperty is read-only
LEGACY_TYPENon-extended type bitmask (one bit per legacy type)
EXTENDED_TYPEChunk of bits used as an integer type ID for extended types
PENDING(deprecated) Do not use

Reading Properties

use drm::control::Device as ControlDevice;

let prop_set = card.get_properties(connector_handle).unwrap();
let (handles, values) = prop_set.as_props_and_values();

for (&prop_handle, &raw_value) in handles.iter().zip(values.iter()) {
    let info = card.get_property(prop_handle).unwrap();
    let name = info.name().to_str().unwrap();
    let typed = info.value_type().convert_value(raw_value);

    println!("{name}: {typed:?}");
}

Looking Up a Specific Property by Name

use drm::control::Device as ControlDevice;

fn find_property(
    card: &impl ControlDevice,
    handle: impl drm::control::ResourceHandle,
    search: &str,
) -> Option<(drm::control::property::Handle, drm::control::property::RawValue)> {
    let prop_set = card.get_properties(handle).ok()?;
    let (handles, values) = prop_set.as_props_and_values();

    for (&ph, &rv) in handles.iter().zip(values.iter()) {
        let info = card.get_property(ph).ok()?;
        if info.name().to_str().ok()? == search {
            return Some((ph, rv));
        }
    }
    None
}

// Usage
let (mode_id_prop, _) = find_property(&card, crtc_handle, "MODE_ID").unwrap();

Build docs developers (and LLMs) love