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 std::ops::Deref;
use steamos_manager::cec::HdmiCecState; use steamos_manager::cec::HdmiCecState;
use steamos_manager::hardware::FanControlState; 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::proxy::ManagerProxy;
use steamos_manager::wifi::{WifiBackend, WifiDebugMode, WifiPowerManagement}; use steamos_manager::wifi::{WifiBackend, WifiDebugMode, WifiPowerManagement};
use zbus::fdo::PropertiesProxy; use zbus::fdo::PropertiesProxy;
@ -45,6 +45,18 @@ enum Commands {
/// Get the fan control state /// Get the fan control state
GetFanControlState, 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 /// Get the GPU power profiles supported on this device
GetGPUPowerProfiles, GetGPUPowerProfiles,
@ -203,6 +215,30 @@ async fn main() -> Result<()> {
Err(_) => println!("Got unknown value {state} from backend"), 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 => { Commands::GetGPUPowerProfiles => {
let profiles = proxy.gpu_power_profiles().await?; let profiles = proxy.gpu_power_profiles().await?;
println!("Profiles:\n"); println!("Profiles:\n");

View file

@ -65,6 +65,16 @@ trait Manager {
#[zbus(property)] #[zbus(property)]
fn set_gpu_performance_level(&self, value: u32) -> zbus::Result<()>; 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 /// GpuPowerProfile property
#[zbus(property)] #[zbus(property)]
fn gpu_power_profile(&self) -> zbus::Result<u32>; fn gpu_power_profile(&self) -> zbus::Result<u32>;