kms: full property registration infrastructure

property.rs: DrmProperty, PropertyRegistry with type-safe registration
  Range/Enum/Blob/Object property types
  ObjectType enum (CRTC/Connector/Plane)
  Properties filtered by object_id + object_type
  Register methods: register_range, register_enum, register_blob, register_object

This replaces the hardcoded synthetic property arrays in scheme.rs.
Compositors can now query properties dynamically per-object.
This commit is contained in:
2026-06-02 05:07:18 +03:00
parent 7f8f93146d
commit 7a5a881615
@@ -0,0 +1,101 @@
use std::fmt;
#[derive(Clone, Debug)]
pub struct DrmProperty {
pub prop_id: u32,
pub name: String,
pub flags: u32,
pub prop_type: PropertyType,
pub object_id: u32,
pub object_type: ObjectType,
}
#[derive(Clone, Debug)]
pub enum PropertyType {
Range { min: u64, max: u64, current: u64 },
Enum { values: Vec<(u64, String)>, current: u64 },
Blob { blob_id: u32 },
Object { current: u32 },
}
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum ObjectType {
Crtc,
Connector,
Plane,
}
#[derive(Clone, Debug)]
pub struct PropertyRegistry {
properties: Vec<DrmProperty>,
}
impl PropertyRegistry {
pub fn new() -> Self {
Self { properties: Vec::new() }
}
pub fn register_range(&mut self, prop_id: u32, name: &str, flags: u32,
obj_id: u32, obj_type: ObjectType,
min: u64, max: u64, current: u64) {
self.properties.push(DrmProperty {
prop_id, name: name.to_string(), flags,
object_id: obj_id, object_type: obj_type,
prop_type: PropertyType::Range { min, max, current },
});
}
pub fn register_enum(&mut self, prop_id: u32, name: &str, flags: u32,
obj_id: u32, obj_type: ObjectType,
values: Vec<(u64, String)>, current: u64) {
self.properties.push(DrmProperty {
prop_id, name: name.to_string(), flags,
object_id: obj_id, object_type: obj_type,
prop_type: PropertyType::Enum { values, current },
});
}
pub fn register_blob(&mut self, prop_id: u32, name: &str, flags: u32,
obj_id: u32, obj_type: ObjectType) {
self.properties.push(DrmProperty {
prop_id, name: name.to_string(), flags,
object_id: obj_id, object_type: obj_type,
prop_type: PropertyType::Blob { blob_id: 0 },
});
}
pub fn register_object(&mut self, prop_id: u32, name: &str, flags: u32,
obj_id: u32, obj_type: ObjectType, current: u32) {
self.properties.push(DrmProperty {
prop_id, name: name.to_string(), flags,
object_id: obj_id, object_type: obj_type,
prop_type: PropertyType::Object { current },
});
}
pub fn properties_for_object(&self, obj_id: u32, obj_type: ObjectType) -> Vec<&DrmProperty> {
self.properties.iter()
.filter(|p| p.object_id == obj_id && p.object_type == obj_type)
.collect()
}
pub fn property_count(&self, obj_id: u32, obj_type: ObjectType) -> usize {
self.properties.iter()
.filter(|p| p.object_id == obj_id && p.object_type == obj_type)
.count()
}
pub fn find_property(&self, prop_id: u32) -> Option<&DrmProperty> {
self.properties.iter().find(|p| p.prop_id == prop_id)
}
}
impl fmt::Display for ObjectType {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
ObjectType::Crtc => write!(f, "CRTC"),
ObjectType::Connector => write!(f, "Connector"),
ObjectType::Plane => write!(f, "Plane"),
}
}
}