drmModeProperty

Struct drmModeProperty 

Source
pub struct drmModeProperty { /* private fields */ }

Implementations§

Source§

impl drmModeProperty

Source

pub fn get(fd: i32, property_id: u32) -> Option<Self>

Source

pub fn name(&self) -> String

Examples found in repository?
examples/drm_mode.rs (line 51)
4fn main() {
5    let fd = {
6        use std::os::fd::IntoRawFd;
7
8        let f = File::open("/dev/dri/card0").unwrap();
9
10        f.into_raw_fd()
11    };
12
13    let libdrm = LibDrm::new().unwrap();
14    libdrm.set_all_client_caps(fd);
15    let drm_mode_res = libdrm.get_drm_mode_resources(fd).unwrap();
16    let current_connectors = drm_mode_res.get_drm_mode_all_connector_current(fd);
17
18    for connector in current_connectors.iter() {
19        println!(
20            "Connector {} ({}-{}), {}",
21            connector.connector_id(),
22            connector.connector_type(),
23            connector.connector_type_id(),
24            connector.connection(),
25        );
26
27        let modes = connector.get_modes();
28
29        if !modes.is_empty() {
30            println!("    Modes");
31            for mode in connector.get_modes() {
32                println!(
33                    "        {}x{}@{:.2}{}{}",
34                    mode.vdisplay,
35                    mode.hdisplay,
36                    mode.refresh_rate(),
37                    if mode.type_is_preferred() { " preferred" } else { "" },
38                    if mode.type_is_driver() { " driver" } else { "" },
39                );
40            }
41        }
42
43        if let Some(conn_prop) = connector.get_drm_mode_connector_properties(fd) {
44            let mode_props = conn_prop.get_mode_property(fd);
45
46            for (prop, value) in mode_props {
47                let type_ = prop.property_type();
48
49                println!(
50                    "    {:?}, id: {}, value: {}, type: {}",
51                    prop.name(),
52                    prop.prop_id(),
53                    value,
54                    type_,
55                );
56
57                match type_ {
58                    drmModePropType::RANGE => println!("        values: {:?}", prop.values()),
59                    drmModePropType::ENUM => {
60                        print!("        enums: [");
61                        for enum_ in prop.enums().iter() {
62                            print!("{:?}={}, ", enum_.name(), enum_.value);
63                        }
64                        println!("] ");
65                    },
66                    drmModePropType::BLOB => {
67                        if let Some(b) = libdrm.get_drm_mode_property_blob(fd, value as u32) {
68                            print!("        blob:");
69
70                            for (i, byte) in b.data().iter().enumerate() {
71                                if (i % 16) == 0 { print!("\n            "); }
72                                print!("{byte:02x}");
73                            }
74
75                            println!();
76                        }
77                    },
78                    _ => {},
79                }
80            }
81        }
82        println!();
83    }
84}
Source

pub fn prop_id(&self) -> u32

Examples found in repository?
examples/drm_mode.rs (line 52)
4fn main() {
5    let fd = {
6        use std::os::fd::IntoRawFd;
7
8        let f = File::open("/dev/dri/card0").unwrap();
9
10        f.into_raw_fd()
11    };
12
13    let libdrm = LibDrm::new().unwrap();
14    libdrm.set_all_client_caps(fd);
15    let drm_mode_res = libdrm.get_drm_mode_resources(fd).unwrap();
16    let current_connectors = drm_mode_res.get_drm_mode_all_connector_current(fd);
17
18    for connector in current_connectors.iter() {
19        println!(
20            "Connector {} ({}-{}), {}",
21            connector.connector_id(),
22            connector.connector_type(),
23            connector.connector_type_id(),
24            connector.connection(),
25        );
26
27        let modes = connector.get_modes();
28
29        if !modes.is_empty() {
30            println!("    Modes");
31            for mode in connector.get_modes() {
32                println!(
33                    "        {}x{}@{:.2}{}{}",
34                    mode.vdisplay,
35                    mode.hdisplay,
36                    mode.refresh_rate(),
37                    if mode.type_is_preferred() { " preferred" } else { "" },
38                    if mode.type_is_driver() { " driver" } else { "" },
39                );
40            }
41        }
42
43        if let Some(conn_prop) = connector.get_drm_mode_connector_properties(fd) {
44            let mode_props = conn_prop.get_mode_property(fd);
45
46            for (prop, value) in mode_props {
47                let type_ = prop.property_type();
48
49                println!(
50                    "    {:?}, id: {}, value: {}, type: {}",
51                    prop.name(),
52                    prop.prop_id(),
53                    value,
54                    type_,
55                );
56
57                match type_ {
58                    drmModePropType::RANGE => println!("        values: {:?}", prop.values()),
59                    drmModePropType::ENUM => {
60                        print!("        enums: [");
61                        for enum_ in prop.enums().iter() {
62                            print!("{:?}={}, ", enum_.name(), enum_.value);
63                        }
64                        println!("] ");
65                    },
66                    drmModePropType::BLOB => {
67                        if let Some(b) = libdrm.get_drm_mode_property_blob(fd, value as u32) {
68                            print!("        blob:");
69
70                            for (i, byte) in b.data().iter().enumerate() {
71                                if (i % 16) == 0 { print!("\n            "); }
72                                print!("{byte:02x}");
73                            }
74
75                            println!();
76                        }
77                    },
78                    _ => {},
79                }
80            }
81        }
82        println!();
83    }
84}
Source

pub fn flags(&self) -> u32

Source

pub fn property_type(&self) -> drmModePropType

Examples found in repository?
examples/drm_mode.rs (line 47)
4fn main() {
5    let fd = {
6        use std::os::fd::IntoRawFd;
7
8        let f = File::open("/dev/dri/card0").unwrap();
9
10        f.into_raw_fd()
11    };
12
13    let libdrm = LibDrm::new().unwrap();
14    libdrm.set_all_client_caps(fd);
15    let drm_mode_res = libdrm.get_drm_mode_resources(fd).unwrap();
16    let current_connectors = drm_mode_res.get_drm_mode_all_connector_current(fd);
17
18    for connector in current_connectors.iter() {
19        println!(
20            "Connector {} ({}-{}), {}",
21            connector.connector_id(),
22            connector.connector_type(),
23            connector.connector_type_id(),
24            connector.connection(),
25        );
26
27        let modes = connector.get_modes();
28
29        if !modes.is_empty() {
30            println!("    Modes");
31            for mode in connector.get_modes() {
32                println!(
33                    "        {}x{}@{:.2}{}{}",
34                    mode.vdisplay,
35                    mode.hdisplay,
36                    mode.refresh_rate(),
37                    if mode.type_is_preferred() { " preferred" } else { "" },
38                    if mode.type_is_driver() { " driver" } else { "" },
39                );
40            }
41        }
42
43        if let Some(conn_prop) = connector.get_drm_mode_connector_properties(fd) {
44            let mode_props = conn_prop.get_mode_property(fd);
45
46            for (prop, value) in mode_props {
47                let type_ = prop.property_type();
48
49                println!(
50                    "    {:?}, id: {}, value: {}, type: {}",
51                    prop.name(),
52                    prop.prop_id(),
53                    value,
54                    type_,
55                );
56
57                match type_ {
58                    drmModePropType::RANGE => println!("        values: {:?}", prop.values()),
59                    drmModePropType::ENUM => {
60                        print!("        enums: [");
61                        for enum_ in prop.enums().iter() {
62                            print!("{:?}={}, ", enum_.name(), enum_.value);
63                        }
64                        println!("] ");
65                    },
66                    drmModePropType::BLOB => {
67                        if let Some(b) = libdrm.get_drm_mode_property_blob(fd, value as u32) {
68                            print!("        blob:");
69
70                            for (i, byte) in b.data().iter().enumerate() {
71                                if (i % 16) == 0 { print!("\n            "); }
72                                print!("{byte:02x}");
73                            }
74
75                            println!();
76                        }
77                    },
78                    _ => {},
79                }
80            }
81        }
82        println!();
83    }
84}
Source

pub fn is_atomic(&self) -> bool

Source

pub fn is_pending(&self) -> bool

Source

pub fn is_immutable(&self) -> bool

Source

pub fn values(&self) -> Vec<u64>

Examples found in repository?
examples/drm_mode.rs (line 58)
4fn main() {
5    let fd = {
6        use std::os::fd::IntoRawFd;
7
8        let f = File::open("/dev/dri/card0").unwrap();
9
10        f.into_raw_fd()
11    };
12
13    let libdrm = LibDrm::new().unwrap();
14    libdrm.set_all_client_caps(fd);
15    let drm_mode_res = libdrm.get_drm_mode_resources(fd).unwrap();
16    let current_connectors = drm_mode_res.get_drm_mode_all_connector_current(fd);
17
18    for connector in current_connectors.iter() {
19        println!(
20            "Connector {} ({}-{}), {}",
21            connector.connector_id(),
22            connector.connector_type(),
23            connector.connector_type_id(),
24            connector.connection(),
25        );
26
27        let modes = connector.get_modes();
28
29        if !modes.is_empty() {
30            println!("    Modes");
31            for mode in connector.get_modes() {
32                println!(
33                    "        {}x{}@{:.2}{}{}",
34                    mode.vdisplay,
35                    mode.hdisplay,
36                    mode.refresh_rate(),
37                    if mode.type_is_preferred() { " preferred" } else { "" },
38                    if mode.type_is_driver() { " driver" } else { "" },
39                );
40            }
41        }
42
43        if let Some(conn_prop) = connector.get_drm_mode_connector_properties(fd) {
44            let mode_props = conn_prop.get_mode_property(fd);
45
46            for (prop, value) in mode_props {
47                let type_ = prop.property_type();
48
49                println!(
50                    "    {:?}, id: {}, value: {}, type: {}",
51                    prop.name(),
52                    prop.prop_id(),
53                    value,
54                    type_,
55                );
56
57                match type_ {
58                    drmModePropType::RANGE => println!("        values: {:?}", prop.values()),
59                    drmModePropType::ENUM => {
60                        print!("        enums: [");
61                        for enum_ in prop.enums().iter() {
62                            print!("{:?}={}, ", enum_.name(), enum_.value);
63                        }
64                        println!("] ");
65                    },
66                    drmModePropType::BLOB => {
67                        if let Some(b) = libdrm.get_drm_mode_property_blob(fd, value as u32) {
68                            print!("        blob:");
69
70                            for (i, byte) in b.data().iter().enumerate() {
71                                if (i % 16) == 0 { print!("\n            "); }
72                                print!("{byte:02x}");
73                            }
74
75                            println!();
76                        }
77                    },
78                    _ => {},
79                }
80            }
81        }
82        println!();
83    }
84}
Source

pub fn blob_ids(&self) -> Vec<u32>

Source

pub fn enums(&self) -> Vec<drm_mode_property_enum>

Examples found in repository?
examples/drm_mode.rs (line 61)
4fn main() {
5    let fd = {
6        use std::os::fd::IntoRawFd;
7
8        let f = File::open("/dev/dri/card0").unwrap();
9
10        f.into_raw_fd()
11    };
12
13    let libdrm = LibDrm::new().unwrap();
14    libdrm.set_all_client_caps(fd);
15    let drm_mode_res = libdrm.get_drm_mode_resources(fd).unwrap();
16    let current_connectors = drm_mode_res.get_drm_mode_all_connector_current(fd);
17
18    for connector in current_connectors.iter() {
19        println!(
20            "Connector {} ({}-{}), {}",
21            connector.connector_id(),
22            connector.connector_type(),
23            connector.connector_type_id(),
24            connector.connection(),
25        );
26
27        let modes = connector.get_modes();
28
29        if !modes.is_empty() {
30            println!("    Modes");
31            for mode in connector.get_modes() {
32                println!(
33                    "        {}x{}@{:.2}{}{}",
34                    mode.vdisplay,
35                    mode.hdisplay,
36                    mode.refresh_rate(),
37                    if mode.type_is_preferred() { " preferred" } else { "" },
38                    if mode.type_is_driver() { " driver" } else { "" },
39                );
40            }
41        }
42
43        if let Some(conn_prop) = connector.get_drm_mode_connector_properties(fd) {
44            let mode_props = conn_prop.get_mode_property(fd);
45
46            for (prop, value) in mode_props {
47                let type_ = prop.property_type();
48
49                println!(
50                    "    {:?}, id: {}, value: {}, type: {}",
51                    prop.name(),
52                    prop.prop_id(),
53                    value,
54                    type_,
55                );
56
57                match type_ {
58                    drmModePropType::RANGE => println!("        values: {:?}", prop.values()),
59                    drmModePropType::ENUM => {
60                        print!("        enums: [");
61                        for enum_ in prop.enums().iter() {
62                            print!("{:?}={}, ", enum_.name(), enum_.value);
63                        }
64                        println!("] ");
65                    },
66                    drmModePropType::BLOB => {
67                        if let Some(b) = libdrm.get_drm_mode_property_blob(fd, value as u32) {
68                            print!("        blob:");
69
70                            for (i, byte) in b.data().iter().enumerate() {
71                                if (i % 16) == 0 { print!("\n            "); }
72                                print!("{byte:02x}");
73                            }
74
75                            println!();
76                        }
77                    },
78                    _ => {},
79                }
80            }
81        }
82        println!();
83    }
84}

Trait Implementations§

Source§

impl Clone for drmModeProperty

Source§

fn clone(&self) -> drmModeProperty

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Drop for drmModeProperty

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

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>,

Source§

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.