mirror of
https://gitlab.steamos.cloud/holo/steamos-manager.git
synced 2025-07-12 01:12:30 -04:00
manager/user: Dynamically add or remove the TdpLimit1 interface if needed
This commit is contained in:
parent
6086e23cc8
commit
c8eb661bec
2 changed files with 54 additions and 14 deletions
15
src/power.rs
15
src/power.rs
|
@ -107,6 +107,9 @@ pub(crate) trait TdpLimitManager: Send + Sync {
|
|||
async fn get_tdp_limit(&self) -> Result<u32>;
|
||||
async fn set_tdp_limit(&self, limit: u32) -> Result<()>;
|
||||
async fn get_tdp_limit_range(&self) -> Result<RangeInclusive<u32>>;
|
||||
async fn is_active(&self) -> Result<bool> {
|
||||
Ok(true)
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) async fn tdp_limit_manager() -> Result<Box<dyn TdpLimitManager>> {
|
||||
|
@ -531,6 +534,18 @@ impl TdpLimitManager for LenovoWmiTdpLimitManager {
|
|||
.map_err(|e| anyhow!("Error parsing value: {e}"))?;
|
||||
Ok(min..=max)
|
||||
}
|
||||
|
||||
async fn is_active(&self) -> Result<bool> {
|
||||
let config = platform_config().await?;
|
||||
if let Some(config) = config
|
||||
.as_ref()
|
||||
.and_then(|config| config.performance_profile.as_ref())
|
||||
{
|
||||
Ok(get_platform_profile(&config.platform_profile_name).await? == "custom")
|
||||
} else {
|
||||
Ok(true)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) async fn get_max_charge_level() -> Result<i32> {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue