Enum PPTable

Source
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§

Implementations§

Source§

impl PPTable

Source

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}
Source

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}
Source

pub fn is_valid(&self) -> bool

Trait Implementations§

Source§

impl Clone for PPTable

Source§

fn clone(&self) -> PPTable

Returns a copy 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 Debug for PPTable

Source§

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

Formats the value using the given formatter. 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.