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

@ -34,6 +34,7 @@ pub(crate) struct PlatformConfig {
pub tdp_limit: Option<RangeConfig<u32>>,
pub gpu_clocks: Option<RangeConfig<u32>>,
pub battery_charge_limit: Option<BatteryChargeLimitConfig>,
pub performance_profile: Option<PerformanceProfileConfig>,
}
#[derive(Clone, Deserialize, Debug)]
@ -113,6 +114,12 @@ pub(crate) struct BatteryChargeLimitConfig {
pub attribute: String,
}
#[derive(Clone, Deserialize, Debug)]
pub(crate) struct PerformanceProfileConfig {
pub suggested_default: String,
pub platform_profile_name: String,
}
#[derive(Clone, Default, Deserialize, Debug)]
pub(crate) struct FormatDeviceConfig {
pub script: PathBuf,
@ -139,6 +146,7 @@ impl PlatformConfig {
async fn load() -> Result<Option<PlatformConfig>> {
let platform = match device_type().await? {
DeviceType::SteamDeck => "jupiter",
DeviceType::LegionGoS => "legion-go-s",
_ => return Ok(None),
};
let config = read_to_string(format!(