power: Add interface for accessing platform-profiles

This commit is contained in:
Vicki Pfau 2025-03-20 16:21:26 -07:00
parent b26cc0f45c
commit 45edfe2c7c
10 changed files with 305 additions and 12 deletions

View file

@ -27,7 +27,8 @@ use crate::job::JobManager;
use crate::platform::platform_config;
use crate::power::{
set_cpu_scaling_governor, set_gpu_clocks, set_gpu_performance_level, set_gpu_power_profile,
set_max_charge_level, set_tdp_limit, CPUScalingGovernor, GPUPerformanceLevel, GPUPowerProfile,
set_max_charge_level, set_platform_profile, set_tdp_limit, CPUScalingGovernor,
GPUPerformanceLevel, GPUPowerProfile,
};
use crate::process::{run_script, script_output};
use crate::wifi::{
@ -429,6 +430,19 @@ impl SteamOSManager {
.map_err(to_zbus_fdo_error)
}
async fn set_performance_profile(&self, profile: &str) -> fdo::Result<()> {
let config = platform_config().await.map_err(to_zbus_fdo_error)?;
let config = config
.as_ref()
.and_then(|config| config.performance_profile.as_ref())
.ok_or(fdo::Error::Failed(String::from(
"No performance platform-profile configured",
)))?;
set_platform_profile(&config.platform_profile_name, profile)
.await
.map_err(to_zbus_fdo_error)
}
/// A version property.
#[zbus(property(emits_changed_signal = "const"))]
async fn version(&self) -> u32 {