Add cpu governor getting and setting to steamosctl.

TODO: Need to test this manually but config issues are causing
daemon's to die here currently because of missing paths.
This commit is contained in:
Jeremy Whiting 2024-06-12 16:08:56 -06:00
parent 7f9d25074e
commit c75c50762d
2 changed files with 47 additions and 1 deletions

View file

@ -11,7 +11,7 @@ use itertools::Itertools;
use std::ops::Deref;
use steamos_manager::cec::HdmiCecState;
use steamos_manager::hardware::FanControlState;
use steamos_manager::power::{GPUPerformanceLevel, GPUPowerProfile};
use steamos_manager::power::{CPUGovernor, GPUPerformanceLevel, GPUPowerProfile};
use steamos_manager::proxy::ManagerProxy;
use steamos_manager::wifi::{WifiBackend, WifiDebugMode, WifiPowerManagement};
use zbus::fdo::PropertiesProxy;
@ -45,6 +45,18 @@ enum Commands {
/// Get the fan control state
GetFanControlState,
/// Get the CPU governors supported on this device
GetCpuGovernors,
/// Get the current CPU governor
GetCpuGovernor,
/// Set the current CPU governor
SetCpuGovernor {
/// Valid governors are get-cpu-governors.
governor: CPUGovernor,
},
/// Get the GPU power profiles supported on this device
GetGPUPowerProfiles,
@ -203,6 +215,30 @@ async fn main() -> Result<()> {
Err(_) => println!("Got unknown value {state} from backend"),
}
}
Commands::GetCpuGovernors => {
let governors = proxy.cpu_governors().await?;
println!("Governors:\n");
for key in governors.keys().sorted() {
let name = &governors[key];
println!("{key}: {name}");
}
}
Commands::GetCpuGovernor => {
let governor = proxy.cpu_governor().await?;
let governor_type = CPUGovernor::try_from(governor);
match governor_type {
Ok(t) => {
let name = t.to_string();
println!("CPU Governor: {governor} {name}");
}
Err(_) => {
println!("Unknown CPU governor or unable to get type from {governor}");
}
}
}
Commands::SetCpuGovernor { governor } => {
proxy.set_cpu_governor(*governor as u32).await?;
}
Commands::GetGPUPowerProfiles => {
let profiles = proxy.gpu_power_profiles().await?;
println!("Profiles:\n");

View file

@ -65,6 +65,16 @@ trait Manager {
#[zbus(property)]
fn set_gpu_performance_level(&self, value: u32) -> zbus::Result<()>;
/// CpuGovernor property
#[zbus(property)]
fn cpu_governor(&self) -> zbus::Result<u32>;
#[zbus(property)]
fn set_cpu_governor(&self, value: u32) -> zbus::Result<()>;
/// CpuGovernors property
#[zbus(property)]
fn cpu_governors(&self) -> zbus::Result<std::collections::HashMap<u32, String>>;
/// GpuPowerProfile property
#[zbus(property)]
fn gpu_power_profile(&self) -> zbus::Result<u32>;