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?
273 pub fn populate_from<'card>(&mut self, from: linux_drm::modeset::ObjectPropMeta<'card>) {
274 match from.name() {
275 "CRTC_ID" => self.crtc_id = from.property_id(),
276 _ => {}
277 }
278 }
279}
280
281#[derive(Debug)]
282struct CrtcPropIds {
283 active: PropertyId,
284}
285
286impl CrtcPropIds {
287 pub fn new(crtc_id: CrtcId, card: &linux_drm::Card) -> Result<Self, Error> {
288 let mut ret: Self = unsafe { core::mem::zeroed() };
289 card.each_object_property_meta(linux_drm::modeset::ObjectId::Crtc(crtc_id), |meta, _| {
290 ret.populate_from(meta)
291 })?;
292 Ok(ret)
293 }
294
295 pub fn populate_from<'card>(&mut self, from: linux_drm::modeset::ObjectPropMeta<'card>) {
296 match from.name() {
297 "ACTIVE" => self.active = from.property_id(),
298 _ => {}
299 }
300 }
301}
302
303#[derive(Debug)]
304struct PlanePropIds {
305 typ: PropertyId,
306 fb_id: PropertyId,
307 crtc_id: PropertyId,
308 crtc_x: PropertyId,
309 crtc_y: PropertyId,
310 crtc_w: PropertyId,
311 crtc_h: PropertyId,
312 src_x: PropertyId,
313 src_y: PropertyId,
314 src_w: PropertyId,
315 src_h: PropertyId,
316}
317
318impl PlanePropIds {
319 pub fn new(plane_id: PlaneId, card: &linux_drm::Card) -> Result<Self, Error> {
320 let mut ret: Self = unsafe { core::mem::zeroed() };
321 card.each_object_property_meta(plane_id, |meta, _| ret.populate_from(meta))?;
322 Ok(ret)
323 }
324
325 pub fn populate_from<'card>(&mut self, from: linux_drm::modeset::ObjectPropMeta<'card>) {
326 let field: &mut PropertyId = match from.name() {
327 "type" => &mut self.typ,
328 "FB_ID" => &mut self.fb_id,
329 "CRTC_ID" => &mut self.crtc_id,
330 "CRTC_X" => &mut self.crtc_x,
331 "CRTC_Y" => &mut self.crtc_y,
332 "CRTC_W" => &mut self.crtc_w,
333 "CRTC_H" => &mut self.crtc_h,
334 "SRC_X" => &mut self.src_x,
335 "SRC_Y" => &mut self.src_y,
336 "SRC_W" => &mut self.src_w,
337 "SRC_H" => &mut self.src_h,
338 _ => return,
339 };
340 *field = from.property_id()
341 }
Sourcepub fn name(&self) -> &str
pub fn name(&self) -> &str
Examples found in repository?
273 pub fn populate_from<'card>(&mut self, from: linux_drm::modeset::ObjectPropMeta<'card>) {
274 match from.name() {
275 "CRTC_ID" => self.crtc_id = from.property_id(),
276 _ => {}
277 }
278 }
279}
280
281#[derive(Debug)]
282struct CrtcPropIds {
283 active: PropertyId,
284}
285
286impl CrtcPropIds {
287 pub fn new(crtc_id: CrtcId, card: &linux_drm::Card) -> Result<Self, Error> {
288 let mut ret: Self = unsafe { core::mem::zeroed() };
289 card.each_object_property_meta(linux_drm::modeset::ObjectId::Crtc(crtc_id), |meta, _| {
290 ret.populate_from(meta)
291 })?;
292 Ok(ret)
293 }
294
295 pub fn populate_from<'card>(&mut self, from: linux_drm::modeset::ObjectPropMeta<'card>) {
296 match from.name() {
297 "ACTIVE" => self.active = from.property_id(),
298 _ => {}
299 }
300 }
301}
302
303#[derive(Debug)]
304struct PlanePropIds {
305 typ: PropertyId,
306 fb_id: PropertyId,
307 crtc_id: PropertyId,
308 crtc_x: PropertyId,
309 crtc_y: PropertyId,
310 crtc_w: PropertyId,
311 crtc_h: PropertyId,
312 src_x: PropertyId,
313 src_y: PropertyId,
314 src_w: PropertyId,
315 src_h: PropertyId,
316}
317
318impl PlanePropIds {
319 pub fn new(plane_id: PlaneId, card: &linux_drm::Card) -> Result<Self, Error> {
320 let mut ret: Self = unsafe { core::mem::zeroed() };
321 card.each_object_property_meta(plane_id, |meta, _| ret.populate_from(meta))?;
322 Ok(ret)
323 }
324
325 pub fn populate_from<'card>(&mut self, from: linux_drm::modeset::ObjectPropMeta<'card>) {
326 let field: &mut PropertyId = match from.name() {
327 "type" => &mut self.typ,
328 "FB_ID" => &mut self.fb_id,
329 "CRTC_ID" => &mut self.crtc_id,
330 "CRTC_X" => &mut self.crtc_x,
331 "CRTC_Y" => &mut self.crtc_y,
332 "CRTC_W" => &mut self.crtc_w,
333 "CRTC_H" => &mut self.crtc_h,
334 "SRC_X" => &mut self.src_x,
335 "SRC_Y" => &mut self.src_y,
336 "SRC_W" => &mut self.src_w,
337 "SRC_H" => &mut self.src_h,
338 _ => return,
339 };
340 *field = from.property_id()
341 }
More examples
144fn property_meta<'a, 'card>(
145 prop_id: PropertyId,
146 prop_meta: &'a mut HashMap<u32, PropertyMeta>,
147 card: &Card,
148) -> Result<&'a PropertyMeta, Error> {
149 Ok(prop_meta.entry(prop_id.0).or_insert_with(|| {
150 card.property_meta(prop_id)
151 .map(|meta| {
152 let mut enum_names = BTreeMap::new();
153 for member in meta.enum_members().unwrap() {
154 enum_names.insert(member.value(), member.name().to_string());
155 }
156 PropertyMeta {
157 name: meta.name().to_string(),
158 typ: meta.property_type(),
159 immutable: meta.is_immutable(),
160 values: meta.values().unwrap(),
161 enum_names,
162 }
163 })
164 .unwrap_or(PropertyMeta {
165 name: String::from("<unknown>"),
166 typ: PropertyType::Unknown,
167 immutable: true,
168 values: Vec::new(),
169 enum_names: BTreeMap::new(),
170 })
171 }))
172}
Sourcepub fn property_type(&self) -> PropertyType
pub fn property_type(&self) -> PropertyType
Examples found in repository?
144fn property_meta<'a, 'card>(
145 prop_id: PropertyId,
146 prop_meta: &'a mut HashMap<u32, PropertyMeta>,
147 card: &Card,
148) -> Result<&'a PropertyMeta, Error> {
149 Ok(prop_meta.entry(prop_id.0).or_insert_with(|| {
150 card.property_meta(prop_id)
151 .map(|meta| {
152 let mut enum_names = BTreeMap::new();
153 for member in meta.enum_members().unwrap() {
154 enum_names.insert(member.value(), member.name().to_string());
155 }
156 PropertyMeta {
157 name: meta.name().to_string(),
158 typ: meta.property_type(),
159 immutable: meta.is_immutable(),
160 values: meta.values().unwrap(),
161 enum_names,
162 }
163 })
164 .unwrap_or(PropertyMeta {
165 name: String::from("<unknown>"),
166 typ: PropertyType::Unknown,
167 immutable: true,
168 values: Vec::new(),
169 enum_names: BTreeMap::new(),
170 })
171 }))
172}
Sourcepub fn is_immutable(&self) -> bool
pub fn is_immutable(&self) -> bool
Examples found in repository?
144fn property_meta<'a, 'card>(
145 prop_id: PropertyId,
146 prop_meta: &'a mut HashMap<u32, PropertyMeta>,
147 card: &Card,
148) -> Result<&'a PropertyMeta, Error> {
149 Ok(prop_meta.entry(prop_id.0).or_insert_with(|| {
150 card.property_meta(prop_id)
151 .map(|meta| {
152 let mut enum_names = BTreeMap::new();
153 for member in meta.enum_members().unwrap() {
154 enum_names.insert(member.value(), member.name().to_string());
155 }
156 PropertyMeta {
157 name: meta.name().to_string(),
158 typ: meta.property_type(),
159 immutable: meta.is_immutable(),
160 values: meta.values().unwrap(),
161 enum_names,
162 }
163 })
164 .unwrap_or(PropertyMeta {
165 name: String::from("<unknown>"),
166 typ: PropertyType::Unknown,
167 immutable: true,
168 values: Vec::new(),
169 enum_names: BTreeMap::new(),
170 })
171 }))
172}
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?
144fn property_meta<'a, 'card>(
145 prop_id: PropertyId,
146 prop_meta: &'a mut HashMap<u32, PropertyMeta>,
147 card: &Card,
148) -> Result<&'a PropertyMeta, Error> {
149 Ok(prop_meta.entry(prop_id.0).or_insert_with(|| {
150 card.property_meta(prop_id)
151 .map(|meta| {
152 let mut enum_names = BTreeMap::new();
153 for member in meta.enum_members().unwrap() {
154 enum_names.insert(member.value(), member.name().to_string());
155 }
156 PropertyMeta {
157 name: meta.name().to_string(),
158 typ: meta.property_type(),
159 immutable: meta.is_immutable(),
160 values: meta.values().unwrap(),
161 enum_names,
162 }
163 })
164 .unwrap_or(PropertyMeta {
165 name: String::from("<unknown>"),
166 typ: PropertyType::Unknown,
167 immutable: true,
168 values: Vec::new(),
169 enum_names: BTreeMap::new(),
170 })
171 }))
172}
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?
144fn property_meta<'a, 'card>(
145 prop_id: PropertyId,
146 prop_meta: &'a mut HashMap<u32, PropertyMeta>,
147 card: &Card,
148) -> Result<&'a PropertyMeta, Error> {
149 Ok(prop_meta.entry(prop_id.0).or_insert_with(|| {
150 card.property_meta(prop_id)
151 .map(|meta| {
152 let mut enum_names = BTreeMap::new();
153 for member in meta.enum_members().unwrap() {
154 enum_names.insert(member.value(), member.name().to_string());
155 }
156 PropertyMeta {
157 name: meta.name().to_string(),
158 typ: meta.property_type(),
159 immutable: meta.is_immutable(),
160 values: meta.values().unwrap(),
161 enum_names,
162 }
163 })
164 .unwrap_or(PropertyMeta {
165 name: String::from("<unknown>"),
166 typ: PropertyType::Unknown,
167 immutable: true,
168 values: Vec::new(),
169 enum_names: BTreeMap::new(),
170 })
171 }))
172}