ContextHandle

Struct ContextHandle 

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

Implementations§

Source§

impl ContextHandle

Source

pub fn new(_amdgpu_dev: &DeviceHandle, ctx_handle: *mut amdgpu_context) -> Self

Source

pub fn set_stable_pstate( &self, pstate_flag: StablePstateFlag, ) -> Result<StablePstateFlag, i32>

Examples found in repository?
examples/stable_pstate.rs (line 26)
4fn info(pci_bus: &PCI::BUS_INFO) {
5    let libdrm_amdgpu = LibDrmAmdgpu::new().unwrap();
6    let Ok(device_path) = pci_bus.get_drm_render_path() else { return };
7    let (amdgpu_dev, _major, _minor) = {
8        use std::fs::File;
9        use std::os::fd::IntoRawFd;
10
11        let fd = File::open(device_path).unwrap();
12
13        libdrm_amdgpu.init_device_handle(fd.into_raw_fd()).unwrap()
14    };
15
16    let ext_info = amdgpu_dev.device_info().unwrap();
17    println!("Marketing Name: [{}]", ext_info.find_device_name_or_default());
18
19    {
20        let ctx = amdgpu_dev.create_context().unwrap();
21        let current_stable_pstate = ctx.get_stable_pstate().unwrap();
22        println!("Current Stable PState: {current_stable_pstate:?}");
23
24        println!("Set STANDARD PState");
25
26        match ctx.set_stable_pstate(AMDGPU::StablePstateFlag::STANDARD) {
27            Ok(_) => {
28            },
29            Err(err) => println!("    Error: {err}"),
30        }
31
32        println!("Press enter to revert stable_pstate");
33
34        let mut input = String::new();
35        std::io::stdin().read_line(&mut input).unwrap();
36    }
37
38    println!("  stable_pstate is reverted.");
39}
Source

pub fn get_stable_pstate(&self) -> Result<StablePstateFlag, i32>

Examples found in repository?
examples/stable_pstate.rs (line 21)
4fn info(pci_bus: &PCI::BUS_INFO) {
5    let libdrm_amdgpu = LibDrmAmdgpu::new().unwrap();
6    let Ok(device_path) = pci_bus.get_drm_render_path() else { return };
7    let (amdgpu_dev, _major, _minor) = {
8        use std::fs::File;
9        use std::os::fd::IntoRawFd;
10
11        let fd = File::open(device_path).unwrap();
12
13        libdrm_amdgpu.init_device_handle(fd.into_raw_fd()).unwrap()
14    };
15
16    let ext_info = amdgpu_dev.device_info().unwrap();
17    println!("Marketing Name: [{}]", ext_info.find_device_name_or_default());
18
19    {
20        let ctx = amdgpu_dev.create_context().unwrap();
21        let current_stable_pstate = ctx.get_stable_pstate().unwrap();
22        println!("Current Stable PState: {current_stable_pstate:?}");
23
24        println!("Set STANDARD PState");
25
26        match ctx.set_stable_pstate(AMDGPU::StablePstateFlag::STANDARD) {
27            Ok(_) => {
28            },
29            Err(err) => println!("    Error: {err}"),
30        }
31
32        println!("Press enter to revert stable_pstate");
33
34        let mut input = String::new();
35        std::io::stdin().read_line(&mut input).unwrap();
36    }
37
38    println!("  stable_pstate is reverted.");
39}

Trait Implementations§

Source§

impl Drop for ContextHandle

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