pub enum PPTable {
V11_0_0(smu_11_0_powerplay_table),
V11_0_7(smu_11_0_7_powerplay_table),
V13_0_0(smu_13_0_0_powerplay_table),
V13_0_7(smu_13_0_7_powerplay_table),
Unknown(atom_common_table_header),
Invalid,
}Variants§
V11_0_0(smu_11_0_powerplay_table)
V11_0_7(smu_11_0_7_powerplay_table)
V13_0_0(smu_13_0_0_powerplay_table)
V13_0_7(smu_13_0_7_powerplay_table)
Unknown(atom_common_table_header)
Invalid
Implementations§
Source§impl PPTable
impl PPTable
Sourcepub fn decode(bytes: &[u8]) -> Result<Self, PPTableDecodeError>
pub fn decode(bytes: &[u8]) -> Result<Self, PPTableDecodeError>
Examples found in repository?
examples/pp_table.rs (line 42)
5fn main() {
6 let libdrm_amdgpu = LibDrmAmdgpu::new().unwrap();
7 let device_path = std::env::var("AMDGPU_PATH").unwrap_or("/dev/dri/renderD128".to_string());
8 let (amdgpu_dev, _, _) = {
9 use std::os::fd::IntoRawFd;
10
11 let f = File::open(device_path).unwrap();
12
13 libdrm_amdgpu.init_device_handle(f.into_raw_fd()).unwrap()
14 };
15
16 let sysfs = amdgpu_dev.get_sysfs_path().unwrap();
17 let smu = IpHwId::get_from_die_id_sysfs(HwId::MP1, &sysfs.join("ip_discovery/die/0/")).ok().and_then(|smu| smu.instances.get(0).map(|v| v.clone()));
18
19 if let Some(smu) = &smu {
20 println!("SMU (MP1) version: {}.{}.{}", smu.major, smu.minor, smu.revision);
21 }
22
23 let pp_table_bytes_sysfs = std::fs::read(&sysfs.join("pp_table")).ok();
24 let pp_table_bytes_vbios = amdgpu_dev.get_vbios_image().ok().and_then(|vbios_image| {
25 use AMDGPU::VBIOS::VbiosParser;
26
27 let vbios_parser = VbiosParser::new(vbios_image);
28 let rom_header = vbios_parser.get_atom_rom_header()?;
29 let data_table = vbios_parser.get_atom_data_table(&rom_header)?;
30
31 Some(vbios_parser.get_powerplay_table_bytes(&data_table)?.to_vec())
32 });
33
34 for (bytes, src) in [
35 (pp_table_bytes_sysfs, "sysfs"),
36 (pp_table_bytes_vbios, "VBIOS"),
37 ] {
38 let Some(bytes) = bytes else { continue };
39 let pp_table = if let Some(smu) = &smu {
40 AMDGPU::PPTable::decode_with_smu_version(&bytes, smu.version())
41 } else {
42 AMDGPU::PPTable::decode(&bytes)
43 };
44
45 println!("from {src}: {pp_table:#?}");
46 }
47}Sourcepub fn decode_with_smu_version(
bytes: &[u8],
smu_ver: (u8, u8, u8),
) -> Result<Self, PPTableDecodeError>
pub fn decode_with_smu_version( bytes: &[u8], smu_ver: (u8, u8, u8), ) -> Result<Self, PPTableDecodeError>
Examples found in repository?
examples/pp_table.rs (line 40)
5fn main() {
6 let libdrm_amdgpu = LibDrmAmdgpu::new().unwrap();
7 let device_path = std::env::var("AMDGPU_PATH").unwrap_or("/dev/dri/renderD128".to_string());
8 let (amdgpu_dev, _, _) = {
9 use std::os::fd::IntoRawFd;
10
11 let f = File::open(device_path).unwrap();
12
13 libdrm_amdgpu.init_device_handle(f.into_raw_fd()).unwrap()
14 };
15
16 let sysfs = amdgpu_dev.get_sysfs_path().unwrap();
17 let smu = IpHwId::get_from_die_id_sysfs(HwId::MP1, &sysfs.join("ip_discovery/die/0/")).ok().and_then(|smu| smu.instances.get(0).map(|v| v.clone()));
18
19 if let Some(smu) = &smu {
20 println!("SMU (MP1) version: {}.{}.{}", smu.major, smu.minor, smu.revision);
21 }
22
23 let pp_table_bytes_sysfs = std::fs::read(&sysfs.join("pp_table")).ok();
24 let pp_table_bytes_vbios = amdgpu_dev.get_vbios_image().ok().and_then(|vbios_image| {
25 use AMDGPU::VBIOS::VbiosParser;
26
27 let vbios_parser = VbiosParser::new(vbios_image);
28 let rom_header = vbios_parser.get_atom_rom_header()?;
29 let data_table = vbios_parser.get_atom_data_table(&rom_header)?;
30
31 Some(vbios_parser.get_powerplay_table_bytes(&data_table)?.to_vec())
32 });
33
34 for (bytes, src) in [
35 (pp_table_bytes_sysfs, "sysfs"),
36 (pp_table_bytes_vbios, "VBIOS"),
37 ] {
38 let Some(bytes) = bytes else { continue };
39 let pp_table = if let Some(smu) = &smu {
40 AMDGPU::PPTable::decode_with_smu_version(&bytes, smu.version())
41 } else {
42 AMDGPU::PPTable::decode(&bytes)
43 };
44
45 println!("from {src}: {pp_table:#?}");
46 }
47}pub fn is_valid(&self) -> bool
Trait Implementations§
Auto Trait Implementations§
impl Freeze for PPTable
impl RefUnwindSafe for PPTable
impl Send for PPTable
impl Sync for PPTable
impl Unpin for PPTable
impl UnwindSafe for PPTable
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more