Struct linux_drm::modeset::ObjectPropMeta

source ·
pub struct ObjectPropMeta<'card> { /* private fields */ }

Implementations§

source§

impl<'card> ObjectPropMeta<'card>

source

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()
    }
source

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
Hide additional 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(),
            })
    }))
}
source

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(),
            })
    }))
}
source

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(),
            })
    }))
}
source

pub fn is_mutable(&self) -> bool

source

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(),
            })
    }))
}
source

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§

source§

impl<'card> Debug for ObjectPropMeta<'card>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

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> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.