mirror of
https://gitlab.steamos.cloud/holo/steamos-manager.git
synced 2025-07-12 09:22:26 -04:00
Add set_gpu_clocks for setting manual clock rates.
Also fix typos in dbus xml to match generated api signatures.
This commit is contained in:
parent
0a49fdaf1f
commit
e2190d69eb
2 changed files with 42 additions and 7 deletions
|
@ -136,28 +136,26 @@
|
|||
</method>
|
||||
|
||||
<!--
|
||||
SetGPUPerformanceLevel:
|
||||
SetGpuPerformanceLevel:
|
||||
@level: The level to use 0 - auto, 1 - low, 2 - high, 3 - manual, 4 - profile_peak
|
||||
@success: True on success. False otherwise.
|
||||
|
||||
Set the GPU performance level to the given value.
|
||||
-->
|
||||
<method name="SetGPUPerformanceLevel">
|
||||
<method name="SetGpuPerformanceLevel">
|
||||
<arg type="i" name="level" direction="in"/>
|
||||
<arg type="b" name="success" direction="out"/>
|
||||
</method>
|
||||
|
||||
<!--
|
||||
SetGPUClocks:
|
||||
@clocks: The clocks to use.
|
||||
@clear: True if we should clear to go back to defaults. False to use clocks above.
|
||||
SetGpuClocks:
|
||||
@clocks: The clocks to use Range is 200-1600 but only takes effect when GpuPerformanceLevel is manual.
|
||||
@success: True on success. False otherwise.
|
||||
|
||||
Set the GPU clocks to the given value.
|
||||
-->
|
||||
<method name="SetGPUClocks">
|
||||
<method name="SetGpuClocks">
|
||||
<arg type="i" name="clocks" direction="in"/>
|
||||
<arg type="b" name="clear" direction="in"/>
|
||||
<arg type="b" name="success" direction="out"/>
|
||||
</method>
|
||||
|
||||
|
|
|
@ -163,6 +163,43 @@ impl SMManager {
|
|||
}
|
||||
}
|
||||
|
||||
async fn set_gpu_clocks(&self, clocks: i32) -> bool {
|
||||
// Set gpu clocks to given value valid between 200 - 1600
|
||||
// Only used when Gpu Performance Level is manual, but write whenever called.
|
||||
// Writes value to /sys/class/drm/card0/device/pp_od_clk_voltage
|
||||
if !(200..=1600).contains(&clocks) {
|
||||
return false;
|
||||
}
|
||||
|
||||
let result = File::create("/sys/class/drm/card0/device/pp_od_clk_voltage").await;
|
||||
let mut myfile;
|
||||
match result {
|
||||
Ok(f) => myfile = f,
|
||||
Err(message) => { println!("Error opening sysfs file for writing {message}"); return false; }
|
||||
};
|
||||
|
||||
// write value
|
||||
let data = format!("s 0 {clocks}\n");
|
||||
let result = myfile.write(data.as_bytes()).await;
|
||||
match result {
|
||||
Ok(_worked) => {
|
||||
let data = format!("s 1 {clocks}\n");
|
||||
let result = myfile.write(data.as_bytes()).await;
|
||||
match result {
|
||||
Ok(_worked) => {
|
||||
let result = myfile.write("c\n".as_bytes()).await;
|
||||
match result {
|
||||
Ok(_worked) => true,
|
||||
Err(message) => { println!("Error writing to sysfs file {message}"); false }
|
||||
}
|
||||
},
|
||||
Err(message) => { println!("Error writing to sysfs file {message}"); false }
|
||||
}
|
||||
},
|
||||
Err(message) => { println!("Error writing to sysfs file {message}"); false }
|
||||
}
|
||||
}
|
||||
|
||||
/// A version property.
|
||||
#[dbus_interface(property)]
|
||||
async fn version(&self) -> u32 {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue