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
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.
| Method | Return type | Description |
|---|
handle() | Handle | The property’s own handle |
name() | &CStr | Human-readable property name (e.g. "CRTC_ID", "MODE_ID", "active") |
value_type() | &ValueType | The type and constraint of the property’s value |
mutable() | bool | true if the property can be changed; false for read-only properties |
atomic() | bool | true 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.
| Variant | Description |
|---|
Boolean | 0 (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 |
Bitmask | A bitmask whose bit positions are named enum variants |
Blob | A 64-bit blob ID referencing binary data stored in the kernel |
CRTC | A handle to a CRTC object (0 = none) |
Connector | A handle to a connector object |
Encoder | A handle to an encoder object |
Framebuffer | A handle to a framebuffer object |
Plane | A handle to a plane object |
Property | A handle to another property object |
Object | A handle to an unspecified DRM object |
Unknown | Unrecognised 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.
| Variant | Inner type | Description |
|---|
Boolean(bool) | bool | True or false |
UnsignedRange(u64) | u64 | Integer within declared range |
SignedRange(i64) | i64 | Signed 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) | u64 | Bitmask value |
Blob(u64) | u64 | Blob 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) | u64 | Uninterpreted 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.
| Method | Return type | Description |
|---|
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.
| Method | Return type | Description |
|---|
value() | RawValue | The numeric value associated with this variant |
name() | &CStr | The 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.
| Method | Return type | Description |
|---|
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.
| Flag | Description |
|---|
RANGE | Unsigned integer range (or Boolean if min=0, max=1) |
SIGNED_RANGE | Signed integer range |
ENUM | Named enumeration |
BLOB | Binary blob |
BITMASK | Named bitmask |
OBJECT | Handle to a DRM object |
ATOMIC | Property hidden unless ClientCapability::Atomic is set |
IMMUTABLE | Property is read-only |
LEGACY_TYPE | Non-extended type bitmask (one bit per legacy type) |
EXTENDED_TYPE | Chunk 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();