Struct linux_drm::modeset::ObjectPropMeta
source · pub struct ObjectPropMeta<'card> { /* private fields */ }
Implementations§
source§impl<'card> ObjectPropMeta<'card>
impl<'card> ObjectPropMeta<'card>
sourcepub fn property_id(&self) -> u32
pub fn property_id(&self) -> u32
Examples found in repository?
examples/modesetting-atomic.rs (line 278)
276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347
pub fn populate_from<'card>(&mut self, from: linux_drm::modeset::ObjectPropMeta<'card>) {
match from.name() {
"CRTC_ID" => self.crtc_id = from.property_id(),
_ => {}
}
}
}
#[derive(Debug)]
struct CrtcPropIds {
active: u32,
}
impl CrtcPropIds {
pub fn new(crtc_id: u32, card: &linux_drm::Card) -> Result<Self, Error> {
let mut ret: Self = unsafe { core::mem::zeroed() };
card.each_object_property_meta(linux_drm::modeset::ObjectId::Crtc(crtc_id), |meta, _| {
ret.populate_from(meta)
})?;
Ok(ret)
}
pub fn populate_from<'card>(&mut self, from: linux_drm::modeset::ObjectPropMeta<'card>) {
match from.name() {
"ACTIVE" => self.active = from.property_id(),
_ => {}
}
}
}
#[derive(Debug)]
struct PlanePropIds {
typ: u32,
fb_id: u32,
crtc_id: u32,
crtc_x: u32,
crtc_y: u32,
crtc_w: u32,
crtc_h: u32,
src_x: u32,
src_y: u32,
src_w: u32,
src_h: u32,
}
impl PlanePropIds {
pub fn new(plane_id: u32, card: &linux_drm::Card) -> Result<Self, Error> {
let mut ret: Self = unsafe { core::mem::zeroed() };
card.each_object_property_meta(
linux_drm::modeset::ObjectId::Plane(plane_id),
|meta, _| ret.populate_from(meta),
)?;
Ok(ret)
}
pub fn populate_from<'card>(&mut self, from: linux_drm::modeset::ObjectPropMeta<'card>) {
let field: &mut u32 = match from.name() {
"type" => &mut self.typ,
"FB_ID" => &mut self.fb_id,
"CRTC_ID" => &mut self.crtc_id,
"CRTC_X" => &mut self.crtc_x,
"CRTC_Y" => &mut self.crtc_y,
"CRTC_W" => &mut self.crtc_w,
"CRTC_H" => &mut self.crtc_h,
"SRC_X" => &mut self.src_x,
"SRC_Y" => &mut self.src_y,
"SRC_W" => &mut self.src_w,
"SRC_H" => &mut self.src_h,
_ => return,
};
*field = from.property_id()
}
sourcepub fn name(&self) -> &str
pub fn name(&self) -> &str
Examples found in repository?
examples/modesetting-atomic.rs (line 277)
276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347
pub fn populate_from<'card>(&mut self, from: linux_drm::modeset::ObjectPropMeta<'card>) {
match from.name() {
"CRTC_ID" => self.crtc_id = from.property_id(),
_ => {}
}
}
}
#[derive(Debug)]
struct CrtcPropIds {
active: u32,
}
impl CrtcPropIds {
pub fn new(crtc_id: u32, card: &linux_drm::Card) -> Result<Self, Error> {
let mut ret: Self = unsafe { core::mem::zeroed() };
card.each_object_property_meta(linux_drm::modeset::ObjectId::Crtc(crtc_id), |meta, _| {
ret.populate_from(meta)
})?;
Ok(ret)
}
pub fn populate_from<'card>(&mut self, from: linux_drm::modeset::ObjectPropMeta<'card>) {
match from.name() {
"ACTIVE" => self.active = from.property_id(),
_ => {}
}
}
}
#[derive(Debug)]
struct PlanePropIds {
typ: u32,
fb_id: u32,
crtc_id: u32,
crtc_x: u32,
crtc_y: u32,
crtc_w: u32,
crtc_h: u32,
src_x: u32,
src_y: u32,
src_w: u32,
src_h: u32,
}
impl PlanePropIds {
pub fn new(plane_id: u32, card: &linux_drm::Card) -> Result<Self, Error> {
let mut ret: Self = unsafe { core::mem::zeroed() };
card.each_object_property_meta(
linux_drm::modeset::ObjectId::Plane(plane_id),
|meta, _| ret.populate_from(meta),
)?;
Ok(ret)
}
pub fn populate_from<'card>(&mut self, from: linux_drm::modeset::ObjectPropMeta<'card>) {
let field: &mut u32 = match from.name() {
"type" => &mut self.typ,
"FB_ID" => &mut self.fb_id,
"CRTC_ID" => &mut self.crtc_id,
"CRTC_X" => &mut self.crtc_x,
"CRTC_Y" => &mut self.crtc_y,
"CRTC_W" => &mut self.crtc_w,
"CRTC_H" => &mut self.crtc_h,
"SRC_X" => &mut self.src_x,
"SRC_Y" => &mut self.src_y,
"SRC_W" => &mut self.src_w,
"SRC_H" => &mut self.src_h,
_ => return,
};
*field = from.property_id()
}
More examples
examples/properties.rs (line 161)
148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176
fn property_meta<'a, 'card>(
prop_id: u32,
prop_meta: &'a mut HashMap<u32, PropertyMeta>,
card: &Card,
) -> Result<&'a PropertyMeta, Error> {
Ok(prop_meta.entry(prop_id).or_insert_with(|| {
card.property_meta(prop_id)
.map(|meta| {
let mut enum_names = BTreeMap::new();
for member in meta.enum_members().unwrap() {
enum_names.insert(member.value(), member.name().to_string());
}
PropertyMeta {
name: meta.name().to_string(),
typ: meta.property_type(),
immutable: meta.is_immutable(),
values: meta.values().unwrap(),
enum_names,
}
})
.unwrap_or(PropertyMeta {
name: String::from("<unknown>"),
typ: PropertyType::Unknown,
immutable: true,
values: Vec::new(),
enum_names: BTreeMap::new(),
})
}))
}
sourcepub fn property_type(&self) -> PropertyType
pub fn property_type(&self) -> PropertyType
Examples found in repository?
examples/properties.rs (line 162)
148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176
fn property_meta<'a, 'card>(
prop_id: u32,
prop_meta: &'a mut HashMap<u32, PropertyMeta>,
card: &Card,
) -> Result<&'a PropertyMeta, Error> {
Ok(prop_meta.entry(prop_id).or_insert_with(|| {
card.property_meta(prop_id)
.map(|meta| {
let mut enum_names = BTreeMap::new();
for member in meta.enum_members().unwrap() {
enum_names.insert(member.value(), member.name().to_string());
}
PropertyMeta {
name: meta.name().to_string(),
typ: meta.property_type(),
immutable: meta.is_immutable(),
values: meta.values().unwrap(),
enum_names,
}
})
.unwrap_or(PropertyMeta {
name: String::from("<unknown>"),
typ: PropertyType::Unknown,
immutable: true,
values: Vec::new(),
enum_names: BTreeMap::new(),
})
}))
}
sourcepub fn is_immutable(&self) -> bool
pub fn is_immutable(&self) -> bool
Examples found in repository?
examples/properties.rs (line 163)
148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176
fn property_meta<'a, 'card>(
prop_id: u32,
prop_meta: &'a mut HashMap<u32, PropertyMeta>,
card: &Card,
) -> Result<&'a PropertyMeta, Error> {
Ok(prop_meta.entry(prop_id).or_insert_with(|| {
card.property_meta(prop_id)
.map(|meta| {
let mut enum_names = BTreeMap::new();
for member in meta.enum_members().unwrap() {
enum_names.insert(member.value(), member.name().to_string());
}
PropertyMeta {
name: meta.name().to_string(),
typ: meta.property_type(),
immutable: meta.is_immutable(),
values: meta.values().unwrap(),
enum_names,
}
})
.unwrap_or(PropertyMeta {
name: String::from("<unknown>"),
typ: PropertyType::Unknown,
immutable: true,
values: Vec::new(),
enum_names: BTreeMap::new(),
})
}))
}
pub fn is_mutable(&self) -> bool
sourcepub fn values(&self) -> Result<Vec<u64>, Error>
pub fn values(&self) -> Result<Vec<u64>, Error>
Examples found in repository?
examples/properties.rs (line 164)
148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176
fn property_meta<'a, 'card>(
prop_id: u32,
prop_meta: &'a mut HashMap<u32, PropertyMeta>,
card: &Card,
) -> Result<&'a PropertyMeta, Error> {
Ok(prop_meta.entry(prop_id).or_insert_with(|| {
card.property_meta(prop_id)
.map(|meta| {
let mut enum_names = BTreeMap::new();
for member in meta.enum_members().unwrap() {
enum_names.insert(member.value(), member.name().to_string());
}
PropertyMeta {
name: meta.name().to_string(),
typ: meta.property_type(),
immutable: meta.is_immutable(),
values: meta.values().unwrap(),
enum_names,
}
})
.unwrap_or(PropertyMeta {
name: String::from("<unknown>"),
typ: PropertyType::Unknown,
immutable: true,
values: Vec::new(),
enum_names: BTreeMap::new(),
})
}))
}
sourcepub fn enum_members(&self) -> Result<Vec<ObjectPropEnumMember>, Error>
pub fn enum_members(&self) -> Result<Vec<ObjectPropEnumMember>, Error>
Examples found in repository?
examples/properties.rs (line 157)
148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176
fn property_meta<'a, 'card>(
prop_id: u32,
prop_meta: &'a mut HashMap<u32, PropertyMeta>,
card: &Card,
) -> Result<&'a PropertyMeta, Error> {
Ok(prop_meta.entry(prop_id).or_insert_with(|| {
card.property_meta(prop_id)
.map(|meta| {
let mut enum_names = BTreeMap::new();
for member in meta.enum_members().unwrap() {
enum_names.insert(member.value(), member.name().to_string());
}
PropertyMeta {
name: meta.name().to_string(),
typ: meta.property_type(),
immutable: meta.is_immutable(),
values: meta.values().unwrap(),
enum_names,
}
})
.unwrap_or(PropertyMeta {
name: String::from("<unknown>"),
typ: PropertyType::Unknown,
immutable: true,
values: Vec::new(),
enum_names: BTreeMap::new(),
})
}))
}
Trait Implementations§
Auto Trait Implementations§
impl<'card> Freeze for ObjectPropMeta<'card>
impl<'card> RefUnwindSafe for ObjectPropMeta<'card>
impl<'card> Send for ObjectPropMeta<'card>
impl<'card> Sync for ObjectPropMeta<'card>
impl<'card> Unpin for ObjectPropMeta<'card>
impl<'card> UnwindSafe for ObjectPropMeta<'card>
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more