pub struct PropertyStore { /* private fields */ }Expand description
Per-object property cache.
Building an atomic request means naming properties by id, and resolving a name to an id costs an ioctl per property. Caching once per object turns per-frame property lookup into a hash-map hit.
Implementations§
Source§impl PropertyStore
impl PropertyStore
Sourcepub fn cache_properties(
&mut self,
device: &Device,
object_id: u32,
object_type: ObjectType,
) -> Result<()>
pub fn cache_properties( &mut self, device: &Device, object_id: u32, object_type: ObjectType, ) -> Result<()>
Query and cache every property of one object, replacing any previous entry for it.
A property whose get_property lookup fails is skipped rather than
failing the whole object, matching the C++ continue: one unreadable
property should not make a plane unusable.
§Errors
CoreError::NoSuchObject for object id 0. Otherwise, if the object’s
property set cannot be read at all, the kernel’s refusal: normally
CoreError::Io.
Sourcepub fn properties(&self, object_id: u32) -> Option<&[PropertyInfo]>
pub fn properties(&self, object_id: u32) -> Option<&[PropertyInfo]>
Every cached property of an object, or None if it was never cached.
Sourcepub fn property_id(&self, object_id: u32, name: &str) -> Result<u32>
pub fn property_id(&self, object_id: u32, name: &str) -> Result<u32>
The id of a named property, for building an atomic request.
§Errors
CoreError::NoSuchObject if the object was never cached, or
CoreError::NoSuchProperty if it has no such property. The C++
reports no_such_file_or_directory for both; splitting them says which
mistake was made.
Sourcepub fn enum_value(
&self,
device: &Device,
object_id: u32,
property: &str,
variant: &str,
) -> Result<u64>
pub fn enum_value( &self, device: &Device, object_id: u32, property: &str, variant: &str, ) -> Result<u64>
The raw value of an enum property’s named variant.
Enum properties are named by string in the KMS ABI but written as
integers, and the integer a driver assigns to a given name is its own
business. Hardcoding one that happened to be right on the card in front
of you silently selects a different variant elsewhere – for
COLOR_ENCODING that is a wrong YCbCr matrix, which is a visible tint
rather than an error.
§Errors
CoreError::NoSuchObject if the object was never cached;
CoreError::NoSuchProperty if it has no such property, if it is not
an enum, or if it has no variant by that name.
Sourcepub fn bitmask_bits(
&self,
device: &Device,
object_id: u32,
property: &str,
) -> Result<u64>
pub fn bitmask_bits( &self, device: &Device, object_id: u32, property: &str, ) -> Result<u64>
The union of the bits a bitmask property advertises.
rotation is the one that matters: it is a bitmask whose enum entries
name the DRM_MODE_ROTATE_* and DRM_MODE_REFLECT_* bits the plane
actually implements, and a plane can expose the property while
implementing only 0/180 or a reflect. A caller that treats the
property’s presence as “can rotate” and asks for 90 degrees gets a
driver that silently drops the request, so the layer comes out the
wrong way round with every ioctl succeeding.
The drm crate reports a bitmask property as
ValueType::Bitmask with no payload – it parses the enum table only
for ValueType::Enum – so this reads the property directly.
§Errors
CoreError::NoSuchObject if the object was never cached;
CoreError::NoSuchProperty if it has no such property or it is not a
bitmask.
Sourcepub fn is_immutable(&self, object_id: u32, name: &str) -> Result<bool>
pub fn is_immutable(&self, object_id: u32, name: &str) -> Result<bool>
Whether a named property is DRM_MODE_PROP_IMMUTABLE.
Writing an immutable property in an atomic commit is rejected with
EINVAL whatever the value, so a request builder must skip it.
§Errors
Sourcepub fn range(&self, object_id: u32, name: &str) -> Result<Option<(u64, u64)>>
pub fn range(&self, object_id: u32, name: &str) -> Result<Option<(u64, u64)>>
The inclusive (min, max) of a named unsigned range property.
None when the property is not an unsigned range – see
PropertyInfo::range – which callers treat as “no bound to enforce”
rather than an error.