pub struct IpHwId {
pub hw_id: HwId,
pub instances: Vec<IpHwInstance>,
}Fields§
§hw_id: HwId§instances: Vec<IpHwInstance>Implementations§
Source§impl IpHwId
impl IpHwId
Sourcepub fn get_from_die_id_sysfs<P: AsRef<Path>>(
hw_id: HwId,
die_id_path: P,
) -> Result<Self, Error>
pub fn get_from_die_id_sysfs<P: AsRef<Path>>( hw_id: HwId, die_id_path: P, ) -> Result<Self, Error>
die_id_path: ip_discovery/die/#die/
Examples found in repository?
examples/pp_table.rs (line 17)
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}Trait Implementations§
Auto Trait Implementations§
impl Freeze for IpHwId
impl RefUnwindSafe for IpHwId
impl Send for IpHwId
impl Sync for IpHwId
impl Unpin for IpHwId
impl UnwindSafe for IpHwId
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