Skip to main content

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 21)
5fn info(pci_bus: &PCI::BUS_INFO) {
6    let libdrm_amdgpu = LibDrmAmdgpu::new().unwrap();
7    let Ok(device_path) = pci_bus.get_drm_render_path() else { return };
8    let f = File::open(device_path).unwrap();
9    let (amdgpu_dev, _major, _minor) = libdrm_amdgpu.init_device_handle_with_fd(f).unwrap();
10
11    let ext_info = amdgpu_dev.device_info().unwrap();
12    println!("Marketing Name: [{}]", ext_info.find_device_name_or_default());
13
14    {
15        let ctx = amdgpu_dev.create_context().unwrap();
16        let current_stable_pstate = ctx.get_stable_pstate().unwrap();
17        println!("Current Stable PState: {current_stable_pstate:?}");
18
19        println!("Set STANDARD PState");
20
21        match ctx.set_stable_pstate(AMDGPU::StablePstateFlag::STANDARD) {
22            Ok(_) => {
23            },
24            Err(err) => println!("    Error: {err}"),
25        }
26
27        println!("Press enter to revert stable_pstate");
28
29        let mut input = String::new();
30        std::io::stdin().read_line(&mut input).unwrap();
31    }
32
33    println!("  stable_pstate is reverted.");
34}
Source

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

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

Trait Implementations§

Source§

impl Drop for ContextHandle

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. 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.