mirror of
https://gitlab.com/asus-linux/asusctl.git
synced 2026-02-06 00:15:04 +01:00
Added ability to change what EPP is linked with each throttle profile
This commit is contained in:
@@ -6,7 +6,7 @@ use typeshare::typeshare;
|
||||
use zbus::zvariant::{OwnedValue, Type, Value};
|
||||
|
||||
use crate::error::{PlatformError, Result};
|
||||
use crate::platform::PlatformPolicy;
|
||||
use crate::platform::ThrottlePolicy;
|
||||
use crate::{read_attr_string, to_device};
|
||||
|
||||
const ATTR_AVAILABLE_GOVERNORS: &str = "cpufreq/scaling_available_governors";
|
||||
@@ -182,10 +182,21 @@ impl From<CPUGovernor> for String {
|
||||
#[typeshare]
|
||||
#[repr(u8)]
|
||||
#[derive(
|
||||
Deserialize, Serialize, Type, Value, OwnedValue, Debug, PartialEq, PartialOrd, Clone, Copy,
|
||||
Deserialize,
|
||||
Serialize,
|
||||
Type,
|
||||
Value,
|
||||
OwnedValue,
|
||||
Default,
|
||||
Debug,
|
||||
PartialEq,
|
||||
PartialOrd,
|
||||
Clone,
|
||||
Copy,
|
||||
)]
|
||||
#[zvariant(signature = "s")]
|
||||
pub enum CPUEPP {
|
||||
#[default]
|
||||
Default = 0,
|
||||
Performance = 1,
|
||||
BalancePerformance = 2,
|
||||
@@ -193,12 +204,12 @@ pub enum CPUEPP {
|
||||
Power = 4,
|
||||
}
|
||||
|
||||
impl From<PlatformPolicy> for CPUEPP {
|
||||
fn from(value: PlatformPolicy) -> Self {
|
||||
impl From<ThrottlePolicy> for CPUEPP {
|
||||
fn from(value: ThrottlePolicy) -> Self {
|
||||
match value {
|
||||
PlatformPolicy::Balanced => CPUEPP::BalancePerformance,
|
||||
PlatformPolicy::Performance => CPUEPP::Performance,
|
||||
PlatformPolicy::Quiet => CPUEPP::Power,
|
||||
ThrottlePolicy::Balanced => CPUEPP::BalancePerformance,
|
||||
ThrottlePolicy::Performance => CPUEPP::Performance,
|
||||
ThrottlePolicy::Quiet => CPUEPP::Power,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -268,15 +268,15 @@ impl Display for GpuMode {
|
||||
)]
|
||||
#[zvariant(signature = "s")]
|
||||
/// `throttle_thermal_policy` in asus_wmi
|
||||
pub enum PlatformPolicy {
|
||||
pub enum ThrottlePolicy {
|
||||
#[default]
|
||||
Balanced = 0,
|
||||
Performance = 1,
|
||||
Quiet = 2,
|
||||
}
|
||||
|
||||
impl PlatformPolicy {
|
||||
pub const fn next(&self) -> Self {
|
||||
impl ThrottlePolicy {
|
||||
pub const fn next(self) -> Self {
|
||||
match self {
|
||||
Self::Balanced => Self::Performance,
|
||||
Self::Performance => Self::Quiet,
|
||||
@@ -289,7 +289,7 @@ impl PlatformPolicy {
|
||||
}
|
||||
}
|
||||
|
||||
impl From<u8> for PlatformPolicy {
|
||||
impl From<u8> for ThrottlePolicy {
|
||||
fn from(num: u8) -> Self {
|
||||
match num {
|
||||
0 => Self::Balanced,
|
||||
@@ -303,55 +303,45 @@ impl From<u8> for PlatformPolicy {
|
||||
}
|
||||
}
|
||||
|
||||
impl From<PlatformPolicy> for u8 {
|
||||
fn from(p: PlatformPolicy) -> Self {
|
||||
impl From<ThrottlePolicy> for u8 {
|
||||
fn from(p: ThrottlePolicy) -> Self {
|
||||
match p {
|
||||
PlatformPolicy::Balanced => 0,
|
||||
PlatformPolicy::Performance => 1,
|
||||
PlatformPolicy::Quiet => 2,
|
||||
ThrottlePolicy::Balanced => 0,
|
||||
ThrottlePolicy::Performance => 1,
|
||||
ThrottlePolicy::Quiet => 2,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<PlatformPolicy> for &str {
|
||||
fn from(profile: PlatformPolicy) -> &'static str {
|
||||
impl From<ThrottlePolicy> for &str {
|
||||
fn from(profile: ThrottlePolicy) -> &'static str {
|
||||
match profile {
|
||||
PlatformPolicy::Balanced => "balanced",
|
||||
PlatformPolicy::Performance => "performance",
|
||||
PlatformPolicy::Quiet => "quiet",
|
||||
ThrottlePolicy::Balanced => "balanced",
|
||||
ThrottlePolicy::Performance => "performance",
|
||||
ThrottlePolicy::Quiet => "quiet",
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl std::str::FromStr for PlatformPolicy {
|
||||
impl std::str::FromStr for ThrottlePolicy {
|
||||
type Err = PlatformError;
|
||||
|
||||
fn from_str(profile: &str) -> Result<Self> {
|
||||
match profile.to_ascii_lowercase().trim() {
|
||||
"balanced" => Ok(PlatformPolicy::Balanced),
|
||||
"performance" => Ok(PlatformPolicy::Performance),
|
||||
"quiet" => Ok(PlatformPolicy::Quiet),
|
||||
"balanced" => Ok(ThrottlePolicy::Balanced),
|
||||
"performance" => Ok(ThrottlePolicy::Performance),
|
||||
"quiet" => Ok(ThrottlePolicy::Quiet),
|
||||
_ => Err(PlatformError::NotSupported),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Display for PlatformPolicy {
|
||||
impl Display for ThrottlePolicy {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
write!(f, "{:?}", self)
|
||||
}
|
||||
}
|
||||
|
||||
impl PlatformPolicy {
|
||||
pub fn get_next_profile(current: PlatformPolicy) -> PlatformPolicy {
|
||||
match current {
|
||||
PlatformPolicy::Balanced => PlatformPolicy::Performance,
|
||||
PlatformPolicy::Performance => PlatformPolicy::Quiet,
|
||||
PlatformPolicy::Quiet => PlatformPolicy::Balanced,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// CamelCase names of the properties. Intended for use with DBUS
|
||||
#[typeshare]
|
||||
#[repr(u8)]
|
||||
@@ -365,7 +355,7 @@ pub enum Properties {
|
||||
PanelOd,
|
||||
MiniLedMode,
|
||||
EgpuEnable,
|
||||
PlatformPolicy,
|
||||
ThrottlePolicy,
|
||||
PptPl1Spl,
|
||||
PptPl2Sppt,
|
||||
PptFppt,
|
||||
|
||||
Reference in New Issue
Block a user