pub struct ObjectPropMeta<'card> { /* private fields */ }
Implementations§
Source§impl<'card> ObjectPropMeta<'card>
impl<'card> ObjectPropMeta<'card>
Sourcepub fn property_id(&self) -> PropertyId
pub fn property_id(&self) -> PropertyId
Examples found in repository?
293 pub fn populate_from<'card>(&mut self, from: linux_drm::modeset::ObjectPropMeta<'card>) {
294 match from.name() {
295 "CRTC_ID" => self.crtc_id = from.property_id(),
296 _ => {}
297 }
298 }
299}
300
301#[derive(Debug)]
302struct CrtcPropIds {
303 active: PropertyId,
304}
305
306impl CrtcPropIds {
307 pub fn new(crtc_id: CrtcId, card: &linux_drm::Card) -> Result<Self, Error> {
308 let mut ret: Self = unsafe { core::mem::zeroed() };
309 card.each_object_property_meta(linux_drm::modeset::ObjectId::Crtc(crtc_id), |meta, _| {
310 ret.populate_from(meta)
311 })?;
312 Ok(ret)
313 }
314
315 pub fn populate_from<'card>(&mut self, from: linux_drm::modeset::ObjectPropMeta<'card>) {
316 match from.name() {
317 "ACTIVE" => self.active = from.property_id(),
318 _ => {}
319 }
320 }
321}
322
323#[derive(Debug)]
324struct PlanePropIds {
325 typ: PropertyId,
326 fb_id: PropertyId,
327 crtc_id: PropertyId,
328 crtc_x: PropertyId,
329 crtc_y: PropertyId,
330 crtc_w: PropertyId,
331 crtc_h: PropertyId,
332 src_x: PropertyId,
333 src_y: PropertyId,
334 src_w: PropertyId,
335 src_h: PropertyId,
336}
337
338impl PlanePropIds {
339 pub fn new(plane_id: PlaneId, card: &linux_drm::Card) -> Result<Self, Error> {
340 let mut ret: Self = unsafe { core::mem::zeroed() };
341 card.each_object_property_meta(plane_id, |meta, _| ret.populate_from(meta))?;
342 Ok(ret)
343 }
344
345 pub fn populate_from<'card>(&mut self, from: linux_drm::modeset::ObjectPropMeta<'card>) {
346 let field: &mut PropertyId = match from.name() {
347 "type" => &mut self.typ,
348 "FB_ID" => &mut self.fb_id,
349 "CRTC_ID" => &mut self.crtc_id,
350 "CRTC_X" => &mut self.crtc_x,
351 "CRTC_Y" => &mut self.crtc_y,
352 "CRTC_W" => &mut self.crtc_w,
353 "CRTC_H" => &mut self.crtc_h,
354 "SRC_X" => &mut self.src_x,
355 "SRC_Y" => &mut self.src_y,
356 "SRC_W" => &mut self.src_w,
357 "SRC_H" => &mut self.src_h,
358 _ => return,
359 };
360 *field = from.property_id()
361 }
Sourcepub fn name(&self) -> &str
pub fn name(&self) -> &str
Examples found in repository?
293 pub fn populate_from<'card>(&mut self, from: linux_drm::modeset::ObjectPropMeta<'card>) {
294 match from.name() {
295 "CRTC_ID" => self.crtc_id = from.property_id(),
296 _ => {}
297 }
298 }
299}
300
301#[derive(Debug)]
302struct CrtcPropIds {
303 active: PropertyId,
304}
305
306impl CrtcPropIds {
307 pub fn new(crtc_id: CrtcId, card: &linux_drm::Card) -> Result<Self, Error> {
308 let mut ret: Self = unsafe { core::mem::zeroed() };
309 card.each_object_property_meta(linux_drm::modeset::ObjectId::Crtc(crtc_id), |meta, _| {
310 ret.populate_from(meta)
311 })?;
312 Ok(ret)
313 }
314
315 pub fn populate_from<'card>(&mut self, from: linux_drm::modeset::ObjectPropMeta<'card>) {
316 match from.name() {
317 "ACTIVE" => self.active = from.property_id(),
318 _ => {}
319 }
320 }
321}
322
323#[derive(Debug)]
324struct PlanePropIds {
325 typ: PropertyId,
326 fb_id: PropertyId,
327 crtc_id: PropertyId,
328 crtc_x: PropertyId,
329 crtc_y: PropertyId,
330 crtc_w: PropertyId,
331 crtc_h: PropertyId,
332 src_x: PropertyId,
333 src_y: PropertyId,
334 src_w: PropertyId,
335 src_h: PropertyId,
336}
337
338impl PlanePropIds {
339 pub fn new(plane_id: PlaneId, card: &linux_drm::Card) -> Result<Self, Error> {
340 let mut ret: Self = unsafe { core::mem::zeroed() };
341 card.each_object_property_meta(plane_id, |meta, _| ret.populate_from(meta))?;
342 Ok(ret)
343 }
344
345 pub fn populate_from<'card>(&mut self, from: linux_drm::modeset::ObjectPropMeta<'card>) {
346 let field: &mut PropertyId = match from.name() {
347 "type" => &mut self.typ,
348 "FB_ID" => &mut self.fb_id,
349 "CRTC_ID" => &mut self.crtc_id,
350 "CRTC_X" => &mut self.crtc_x,
351 "CRTC_Y" => &mut self.crtc_y,
352 "CRTC_W" => &mut self.crtc_w,
353 "CRTC_H" => &mut self.crtc_h,
354 "SRC_X" => &mut self.src_x,
355 "SRC_Y" => &mut self.src_y,
356 "SRC_W" => &mut self.src_w,
357 "SRC_H" => &mut self.src_h,
358 _ => return,
359 };
360 *field = from.property_id()
361 }
More examples
164fn property_meta<'a, 'card>(
165 prop_id: PropertyId,
166 prop_meta: &'a mut HashMap<u32, PropertyMeta>,
167 card: &Card,
168) -> Result<&'a PropertyMeta, Error> {
169 Ok(prop_meta.entry(prop_id.0).or_insert_with(|| {
170 card.property_meta(prop_id)
171 .map(|meta| {
172 let mut enum_names = BTreeMap::new();
173 for member in meta.enum_members().unwrap() {
174 enum_names.insert(member.value(), member.name().to_string());
175 }
176 PropertyMeta {
177 name: meta.name().to_string(),
178 typ: meta.property_type(),
179 immutable: meta.is_immutable(),
180 values: meta.values().unwrap(),
181 enum_names,
182 }
183 })
184 .unwrap_or(PropertyMeta {
185 name: String::from("<unknown>"),
186 typ: PropertyType::Unknown,
187 immutable: true,
188 values: Vec::new(),
189 enum_names: BTreeMap::new(),
190 })
191 }))
192}
Sourcepub fn property_type(&self) -> PropertyType
pub fn property_type(&self) -> PropertyType
Examples found in repository?
164fn property_meta<'a, 'card>(
165 prop_id: PropertyId,
166 prop_meta: &'a mut HashMap<u32, PropertyMeta>,
167 card: &Card,
168) -> Result<&'a PropertyMeta, Error> {
169 Ok(prop_meta.entry(prop_id.0).or_insert_with(|| {
170 card.property_meta(prop_id)
171 .map(|meta| {
172 let mut enum_names = BTreeMap::new();
173 for member in meta.enum_members().unwrap() {
174 enum_names.insert(member.value(), member.name().to_string());
175 }
176 PropertyMeta {
177 name: meta.name().to_string(),
178 typ: meta.property_type(),
179 immutable: meta.is_immutable(),
180 values: meta.values().unwrap(),
181 enum_names,
182 }
183 })
184 .unwrap_or(PropertyMeta {
185 name: String::from("<unknown>"),
186 typ: PropertyType::Unknown,
187 immutable: true,
188 values: Vec::new(),
189 enum_names: BTreeMap::new(),
190 })
191 }))
192}
Sourcepub fn is_immutable(&self) -> bool
pub fn is_immutable(&self) -> bool
Examples found in repository?
164fn property_meta<'a, 'card>(
165 prop_id: PropertyId,
166 prop_meta: &'a mut HashMap<u32, PropertyMeta>,
167 card: &Card,
168) -> Result<&'a PropertyMeta, Error> {
169 Ok(prop_meta.entry(prop_id.0).or_insert_with(|| {
170 card.property_meta(prop_id)
171 .map(|meta| {
172 let mut enum_names = BTreeMap::new();
173 for member in meta.enum_members().unwrap() {
174 enum_names.insert(member.value(), member.name().to_string());
175 }
176 PropertyMeta {
177 name: meta.name().to_string(),
178 typ: meta.property_type(),
179 immutable: meta.is_immutable(),
180 values: meta.values().unwrap(),
181 enum_names,
182 }
183 })
184 .unwrap_or(PropertyMeta {
185 name: String::from("<unknown>"),
186 typ: PropertyType::Unknown,
187 immutable: true,
188 values: Vec::new(),
189 enum_names: BTreeMap::new(),
190 })
191 }))
192}
pub fn is_mutable(&self) -> bool
Sourcepub fn range(&self) -> Result<(u64, u64), Error>
pub fn range(&self) -> Result<(u64, u64), Error>
Get the minimum and maximum value for a range-typed property.
This is essentially the same as Self::values
, except that because it’s
guaranteed that a range property always has exactly two values this function
can avoid making a dynamic memory allocation and can instead retrieve the
values directly into a stack object and then return those values.
Sourcepub fn values(&self) -> Result<Vec<u64>, Error>
pub fn values(&self) -> Result<Vec<u64>, Error>
Get a vector of describing the values that are acceptable for this property.
The meaning of the result depends on the property type:
-
For a range or signed range, the result always has length 2 and describes the minimum and maximum values respectively.
You can avoid a dynamic memory allocation in this case by using
Self::range
instead. -
For an enum or bitmask, the result describes the values of the valid enumeration members.
For these it’s typically better to use
Self::enum_members
since that can also return the name associated with each value.
Examples found in repository?
164fn property_meta<'a, 'card>(
165 prop_id: PropertyId,
166 prop_meta: &'a mut HashMap<u32, PropertyMeta>,
167 card: &Card,
168) -> Result<&'a PropertyMeta, Error> {
169 Ok(prop_meta.entry(prop_id.0).or_insert_with(|| {
170 card.property_meta(prop_id)
171 .map(|meta| {
172 let mut enum_names = BTreeMap::new();
173 for member in meta.enum_members().unwrap() {
174 enum_names.insert(member.value(), member.name().to_string());
175 }
176 PropertyMeta {
177 name: meta.name().to_string(),
178 typ: meta.property_type(),
179 immutable: meta.is_immutable(),
180 values: meta.values().unwrap(),
181 enum_names,
182 }
183 })
184 .unwrap_or(PropertyMeta {
185 name: String::from("<unknown>"),
186 typ: PropertyType::Unknown,
187 immutable: true,
188 values: Vec::new(),
189 enum_names: BTreeMap::new(),
190 })
191 }))
192}
Sourcepub fn enum_members(&self) -> Result<Vec<ObjectPropEnumMember>, Error>
pub fn enum_members(&self) -> Result<Vec<ObjectPropEnumMember>, Error>
Get a vector describing the valid values for an enum, or the bitfield values for a bitmask.
Examples found in repository?
164fn property_meta<'a, 'card>(
165 prop_id: PropertyId,
166 prop_meta: &'a mut HashMap<u32, PropertyMeta>,
167 card: &Card,
168) -> Result<&'a PropertyMeta, Error> {
169 Ok(prop_meta.entry(prop_id.0).or_insert_with(|| {
170 card.property_meta(prop_id)
171 .map(|meta| {
172 let mut enum_names = BTreeMap::new();
173 for member in meta.enum_members().unwrap() {
174 enum_names.insert(member.value(), member.name().to_string());
175 }
176 PropertyMeta {
177 name: meta.name().to_string(),
178 typ: meta.property_type(),
179 immutable: meta.is_immutable(),
180 values: meta.values().unwrap(),
181 enum_names,
182 }
183 })
184 .unwrap_or(PropertyMeta {
185 name: String::from("<unknown>"),
186 typ: PropertyType::Unknown,
187 immutable: true,
188 values: Vec::new(),
189 enum_names: BTreeMap::new(),
190 })
191 }))
192}