drmModeModeInfo

Type Alias drmModeModeInfo 

Source
pub type drmModeModeInfo = _drmModeModeInfo;

Aliased Type§

#[repr(C)]
pub struct drmModeModeInfo {
Show 15 fields pub clock: u32, pub hdisplay: u16, pub hsync_start: u16, pub hsync_end: u16, pub htotal: u16, pub hskew: u16, pub vdisplay: u16, pub vsync_start: u16, pub vsync_end: u16, pub vtotal: u16, pub vscan: u16, pub vrefresh: u32, pub flags: u32, pub type_: u32, pub name: [u8; 32],
}

Fields§

§clock: u32§hdisplay: u16§hsync_start: u16§hsync_end: u16§htotal: u16§hskew: u16§vdisplay: u16§vsync_start: u16§vsync_end: u16§vtotal: u16§vscan: u16§vrefresh: u32§flags: u32§type_: u32§name: [u8; 32]

Implementations§

Source§

impl drmModeModeInfo

Source

pub fn name(&self) -> String

Source

pub fn refresh_rate(&self) -> f32

Examples found in repository?
examples/drm_mode.rs (line 36)
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 type_is_preferred(&self) -> bool

Examples found in repository?
examples/drm_mode.rs (line 37)
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 type_is_userdef(&self) -> bool

Source

pub fn type_is_driver(&self) -> bool

Examples found in repository?
examples/drm_mode.rs (line 38)
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_phsync(&self) -> bool

Source

pub fn is_nhsync(&self) -> bool

Source

pub fn is_pvsync(&self) -> bool

Source

pub fn is_nvsync(&self) -> bool

Source

pub fn is_interlace(&self) -> bool

Source

pub fn is_dblscan(&self) -> bool

Source

pub fn is_csync(&self) -> bool

Source

pub fn is_pcsync(&self) -> bool

Source

pub fn is_ncsync(&self) -> bool

Source

pub fn is_hskew(&self) -> bool

Source

pub fn is_dblclk(&self) -> bool

Source

pub fn is_clkdiv2(&self) -> bool