mirror of
https://gitlab.com/asus-linux/asusctl.git
synced 2026-01-22 17:33:19 +01:00
Compare commits
6 Commits
d006837198
...
5.0.10
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9faebe9e38 | ||
|
|
2e2d5cb46b | ||
|
|
4e3a610a0f | ||
|
|
03e10610dd | ||
|
|
a6a10a5bc4 | ||
|
|
0985eca7ce |
26
Cargo.lock
generated
26
Cargo.lock
generated
@@ -199,7 +199,7 @@ checksum = "96d30a06541fbafbc7f82ed10c06164cfbd2c401138f6addd8404629c4b16711"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "asusctl"
|
name = "asusctl"
|
||||||
version = "5.0.8"
|
version = "5.0.10"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"asusd",
|
"asusd",
|
||||||
"cargo-husky",
|
"cargo-husky",
|
||||||
@@ -219,7 +219,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "asusd"
|
name = "asusd"
|
||||||
version = "5.0.8"
|
version = "5.0.10"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cargo-husky",
|
"cargo-husky",
|
||||||
"concat-idents",
|
"concat-idents",
|
||||||
@@ -244,7 +244,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "asusd-user"
|
name = "asusd-user"
|
||||||
version = "5.0.8"
|
version = "5.0.10"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cargo-husky",
|
"cargo-husky",
|
||||||
"config-traits",
|
"config-traits",
|
||||||
@@ -847,7 +847,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "config-traits"
|
name = "config-traits"
|
||||||
version = "5.0.8"
|
version = "5.0.10"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cargo-husky",
|
"cargo-husky",
|
||||||
"log",
|
"log",
|
||||||
@@ -900,7 +900,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "cpuctl"
|
name = "cpuctl"
|
||||||
version = "5.0.8"
|
version = "5.0.10"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "cpufeatures"
|
name = "cpufeatures"
|
||||||
@@ -1024,7 +1024,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "dmi_id"
|
name = "dmi_id"
|
||||||
version = "5.0.8"
|
version = "5.0.10"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"log",
|
"log",
|
||||||
"udev",
|
"udev",
|
||||||
@@ -2834,7 +2834,7 @@ checksum = "c08c74e62047bb2de4ff487b251e4a92e24f48745648451635cec7d591162d9f"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rog-control-center"
|
name = "rog-control-center"
|
||||||
version = "5.0.8"
|
version = "5.0.10"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"asusd",
|
"asusd",
|
||||||
"cargo-husky",
|
"cargo-husky",
|
||||||
@@ -2867,7 +2867,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rog_anime"
|
name = "rog_anime"
|
||||||
version = "5.0.8"
|
version = "5.0.10"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cargo-husky",
|
"cargo-husky",
|
||||||
"dmi_id",
|
"dmi_id",
|
||||||
@@ -2884,7 +2884,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rog_aura"
|
name = "rog_aura"
|
||||||
version = "5.0.8"
|
version = "5.0.10"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cargo-husky",
|
"cargo-husky",
|
||||||
"dmi_id",
|
"dmi_id",
|
||||||
@@ -2898,7 +2898,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rog_dbus"
|
name = "rog_dbus"
|
||||||
version = "5.0.8"
|
version = "5.0.10"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"asusd",
|
"asusd",
|
||||||
"cargo-husky",
|
"cargo-husky",
|
||||||
@@ -2911,7 +2911,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rog_platform"
|
name = "rog_platform"
|
||||||
version = "5.0.8"
|
version = "5.0.10"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cargo-husky",
|
"cargo-husky",
|
||||||
"concat-idents",
|
"concat-idents",
|
||||||
@@ -2928,7 +2928,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rog_profiles"
|
name = "rog_profiles"
|
||||||
version = "5.0.8"
|
version = "5.0.10"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cargo-husky",
|
"cargo-husky",
|
||||||
"log",
|
"log",
|
||||||
@@ -2942,7 +2942,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rog_simulators"
|
name = "rog_simulators"
|
||||||
version = "5.0.8"
|
version = "5.0.10"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"glam",
|
"glam",
|
||||||
"log",
|
"log",
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ default-members = ["asusctl", "asusd", "asusd-user", "cpuctl", "rog-control-cent
|
|||||||
resolver = "2"
|
resolver = "2"
|
||||||
|
|
||||||
[workspace.package]
|
[workspace.package]
|
||||||
version = "5.0.8"
|
version = "5.0.10"
|
||||||
rust-version = "1.75"
|
rust-version = "1.75"
|
||||||
|
|
||||||
[workspace.dependencies]
|
[workspace.dependencies]
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
use std::thread::sleep;
|
||||||
|
use std::time::Duration;
|
||||||
|
|
||||||
use config_traits::{StdConfig, StdConfigLoad};
|
use config_traits::{StdConfig, StdConfigLoad};
|
||||||
use futures_lite::StreamExt;
|
use futures_lite::StreamExt;
|
||||||
@@ -21,9 +23,7 @@ pub const FAN_CURVE_ZBUS_PATH: &str = "/org/asuslinux/FanCurves";
|
|||||||
|
|
||||||
#[derive(Deserialize, Serialize, Debug, Default)]
|
#[derive(Deserialize, Serialize, Debug, Default)]
|
||||||
pub struct FanCurveConfig {
|
pub struct FanCurveConfig {
|
||||||
pub balanced: Vec<CurveData>,
|
pub profiles: FanCurveProfiles,
|
||||||
pub performance: Vec<CurveData>,
|
|
||||||
pub quiet: Vec<CurveData>,
|
|
||||||
#[serde(skip)]
|
#[serde(skip)]
|
||||||
pub current: u8,
|
pub current: u8,
|
||||||
}
|
}
|
||||||
@@ -49,7 +49,6 @@ impl StdConfigLoad for FanCurveConfig {}
|
|||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
pub struct CtrlFanCurveZbus {
|
pub struct CtrlFanCurveZbus {
|
||||||
config: Arc<Mutex<FanCurveConfig>>,
|
config: Arc<Mutex<FanCurveConfig>>,
|
||||||
fan_curves: Arc<Mutex<FanCurveProfiles>>,
|
|
||||||
platform: RogPlatform,
|
platform: RogPlatform,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -64,10 +63,11 @@ impl CtrlFanCurveZbus {
|
|||||||
let mut config = FanCurveConfig::new();
|
let mut config = FanCurveConfig::new();
|
||||||
let mut fan_curves = FanCurveProfiles::default();
|
let mut fan_curves = FanCurveProfiles::default();
|
||||||
|
|
||||||
// Only do defaults if the config doesn't already exist
|
// Only do defaults if the config doesn't already exist\
|
||||||
if !config.file_path().exists() {
|
if config.profiles.balanced.is_empty() || !config.file_path().exists() {
|
||||||
info!("{MOD_NAME}: Fetching default fan curves");
|
info!("{MOD_NAME}: Fetching default fan curves");
|
||||||
|
|
||||||
|
let current = platform.get_throttle_thermal_policy()?;
|
||||||
for this in [
|
for this in [
|
||||||
ThrottlePolicy::Balanced,
|
ThrottlePolicy::Balanced,
|
||||||
ThrottlePolicy::Performance,
|
ThrottlePolicy::Performance,
|
||||||
@@ -76,51 +76,31 @@ impl CtrlFanCurveZbus {
|
|||||||
// For each profile we need to switch to it before we
|
// For each profile we need to switch to it before we
|
||||||
// can read the existing values from hardware. The ACPI method used
|
// can read the existing values from hardware. The ACPI method used
|
||||||
// for this is what limits us.
|
// for this is what limits us.
|
||||||
let next = ThrottlePolicy::next(this);
|
platform.set_throttle_thermal_policy(this.into())?;
|
||||||
platform.set_throttle_thermal_policy(next.into())?;
|
let mut dev = find_fan_curve_node()?;
|
||||||
|
fan_curves.set_active_curve_to_defaults(this, &mut dev)?;
|
||||||
|
|
||||||
let active = platform
|
info!("{MOD_NAME}: {this:?}:");
|
||||||
.get_throttle_thermal_policy()
|
for curve in fan_curves.get_fan_curves_for(this) {
|
||||||
.map_or(ThrottlePolicy::Balanced, |t| t.into());
|
|
||||||
|
|
||||||
info!("{MOD_NAME}: {active:?}:");
|
|
||||||
for curve in fan_curves.get_fan_curves_for(active) {
|
|
||||||
info!("{}", String::from(curve));
|
info!("{}", String::from(curve));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
platform.set_throttle_thermal_policy(current)?;
|
||||||
|
config.profiles = fan_curves;
|
||||||
config.write();
|
config.write();
|
||||||
} else {
|
} else {
|
||||||
info!("{MOD_NAME}: Fan curves previously stored, loading...");
|
info!("{MOD_NAME}: Fan curves previously stored, loading...");
|
||||||
config = config.load();
|
config = config.load();
|
||||||
fan_curves.balanced = config.balanced.clone();
|
|
||||||
fan_curves.performance = config.performance.clone();
|
|
||||||
fan_curves.quiet = config.quiet.clone();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return Ok(Self {
|
return Ok(Self {
|
||||||
config: Arc::new(Mutex::new(config)),
|
config: Arc::new(Mutex::new(config)),
|
||||||
fan_curves: Arc::new(Mutex::new(fan_curves)),
|
|
||||||
platform,
|
platform,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
Err(ProfileError::NotSupported.into())
|
Err(ProfileError::NotSupported.into())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn update_profiles_from_config(&self) {
|
|
||||||
self.fan_curves.lock().await.balanced = self.config.lock().await.balanced.clone();
|
|
||||||
self.fan_curves.lock().await.performance = self.config.lock().await.performance.clone();
|
|
||||||
self.fan_curves.lock().await.quiet = self.config.lock().await.quiet.clone();
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Because this locks both config and fan_curves, it means nothing else can
|
|
||||||
/// hold a lock across this function call. Stupid choice to do this and
|
|
||||||
/// needs to be fixed.
|
|
||||||
pub async fn update_config_from_profiles(&self) {
|
|
||||||
self.config.lock().await.balanced = self.fan_curves.lock().await.balanced.clone();
|
|
||||||
self.config.lock().await.performance = self.fan_curves.lock().await.performance.clone();
|
|
||||||
self.config.lock().await.quiet = self.fan_curves.lock().await.quiet.clone();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[dbus_interface(name = "org.asuslinux.Daemon")]
|
#[dbus_interface(name = "org.asuslinux.Daemon")]
|
||||||
@@ -132,15 +112,16 @@ impl CtrlFanCurveZbus {
|
|||||||
profile: ThrottlePolicy,
|
profile: ThrottlePolicy,
|
||||||
enabled: bool,
|
enabled: bool,
|
||||||
) -> zbus::fdo::Result<()> {
|
) -> zbus::fdo::Result<()> {
|
||||||
self.fan_curves
|
self.config
|
||||||
.lock()
|
.lock()
|
||||||
.await
|
.await
|
||||||
|
.profiles
|
||||||
.set_profile_curves_enabled(profile, enabled);
|
.set_profile_curves_enabled(profile, enabled);
|
||||||
self.fan_curves
|
self.config
|
||||||
.lock()
|
.lock()
|
||||||
.await
|
.await
|
||||||
|
.profiles
|
||||||
.write_profile_curve_to_platform(profile, &mut find_fan_curve_node()?)?;
|
.write_profile_curve_to_platform(profile, &mut find_fan_curve_node()?)?;
|
||||||
self.update_config_from_profiles().await;
|
|
||||||
self.config.lock().await.write();
|
self.config.lock().await.write();
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
@@ -153,15 +134,16 @@ impl CtrlFanCurveZbus {
|
|||||||
fan: FanCurvePU,
|
fan: FanCurvePU,
|
||||||
enabled: bool,
|
enabled: bool,
|
||||||
) -> zbus::fdo::Result<()> {
|
) -> zbus::fdo::Result<()> {
|
||||||
self.fan_curves
|
self.config
|
||||||
.lock()
|
.lock()
|
||||||
.await
|
.await
|
||||||
|
.profiles
|
||||||
.set_profile_fan_curve_enabled(profile, fan, enabled);
|
.set_profile_fan_curve_enabled(profile, fan, enabled);
|
||||||
self.fan_curves
|
self.config
|
||||||
.lock()
|
.lock()
|
||||||
.await
|
.await
|
||||||
|
.profiles
|
||||||
.write_profile_curve_to_platform(profile, &mut find_fan_curve_node()?)?;
|
.write_profile_curve_to_platform(profile, &mut find_fan_curve_node()?)?;
|
||||||
self.update_config_from_profiles().await;
|
|
||||||
self.config.lock().await.write();
|
self.config.lock().await.write();
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
@@ -172,9 +154,10 @@ impl CtrlFanCurveZbus {
|
|||||||
profile: ThrottlePolicy,
|
profile: ThrottlePolicy,
|
||||||
) -> zbus::fdo::Result<Vec<CurveData>> {
|
) -> zbus::fdo::Result<Vec<CurveData>> {
|
||||||
let curve = self
|
let curve = self
|
||||||
.fan_curves
|
.config
|
||||||
.lock()
|
.lock()
|
||||||
.await
|
.await
|
||||||
|
.profiles
|
||||||
.get_fan_curves_for(profile)
|
.get_fan_curves_for(profile)
|
||||||
.to_vec();
|
.to_vec();
|
||||||
Ok(curve)
|
Ok(curve)
|
||||||
@@ -187,15 +170,16 @@ impl CtrlFanCurveZbus {
|
|||||||
profile: ThrottlePolicy,
|
profile: ThrottlePolicy,
|
||||||
curve: CurveData,
|
curve: CurveData,
|
||||||
) -> zbus::fdo::Result<()> {
|
) -> zbus::fdo::Result<()> {
|
||||||
self.fan_curves
|
self.config
|
||||||
.lock()
|
.lock()
|
||||||
.await
|
.await
|
||||||
|
.profiles
|
||||||
.save_fan_curve(curve, profile)?;
|
.save_fan_curve(curve, profile)?;
|
||||||
self.fan_curves
|
self.config
|
||||||
.lock()
|
.lock()
|
||||||
.await
|
.await
|
||||||
|
.profiles
|
||||||
.write_profile_curve_to_platform(profile, &mut find_fan_curve_node()?)?;
|
.write_profile_curve_to_platform(profile, &mut find_fan_curve_node()?)?;
|
||||||
self.update_config_from_profiles().await;
|
|
||||||
self.config.lock().await.write();
|
self.config.lock().await.write();
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
@@ -207,11 +191,11 @@ impl CtrlFanCurveZbus {
|
|||||||
/// read only for the currently active profile.
|
/// read only for the currently active profile.
|
||||||
async fn set_active_curve_to_defaults(&mut self) -> zbus::fdo::Result<()> {
|
async fn set_active_curve_to_defaults(&mut self) -> zbus::fdo::Result<()> {
|
||||||
let active = self.platform.get_throttle_thermal_policy()?;
|
let active = self.platform.get_throttle_thermal_policy()?;
|
||||||
self.fan_curves
|
self.config
|
||||||
.lock()
|
.lock()
|
||||||
.await
|
.await
|
||||||
|
.profiles
|
||||||
.set_active_curve_to_defaults(active.into(), &mut find_fan_curve_node()?)?;
|
.set_active_curve_to_defaults(active.into(), &mut find_fan_curve_node()?)?;
|
||||||
self.update_config_from_profiles().await;
|
|
||||||
self.config.lock().await.write();
|
self.config.lock().await.write();
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
@@ -225,13 +209,13 @@ impl CtrlFanCurveZbus {
|
|||||||
let active = self.platform.get_throttle_thermal_policy()?;
|
let active = self.platform.get_throttle_thermal_policy()?;
|
||||||
|
|
||||||
self.platform.set_throttle_thermal_policy(profile.into())?;
|
self.platform.set_throttle_thermal_policy(profile.into())?;
|
||||||
self.fan_curves
|
self.config
|
||||||
.lock()
|
.lock()
|
||||||
.await
|
.await
|
||||||
|
.profiles
|
||||||
.set_active_curve_to_defaults(active.into(), &mut find_fan_curve_node()?)?;
|
.set_active_curve_to_defaults(active.into(), &mut find_fan_curve_node()?)?;
|
||||||
self.platform.set_throttle_thermal_policy(active)?;
|
self.platform.set_throttle_thermal_policy(active)?;
|
||||||
|
|
||||||
self.update_config_from_profiles().await;
|
|
||||||
self.config.lock().await.write();
|
self.config.lock().await.write();
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
@@ -252,7 +236,7 @@ impl CtrlTask for CtrlFanCurveZbus {
|
|||||||
let watch_throttle_thermal_policy = self.platform.monitor_throttle_thermal_policy()?;
|
let watch_throttle_thermal_policy = self.platform.monitor_throttle_thermal_policy()?;
|
||||||
let platform = self.platform.clone();
|
let platform = self.platform.clone();
|
||||||
let config = self.config.clone();
|
let config = self.config.clone();
|
||||||
let fan_curves = self.fan_curves.clone();
|
let fan_curves = self.config.clone();
|
||||||
|
|
||||||
tokio::spawn(async move {
|
tokio::spawn(async move {
|
||||||
let mut buffer = [0; 32];
|
let mut buffer = [0; 32];
|
||||||
@@ -266,6 +250,7 @@ impl CtrlTask for CtrlFanCurveZbus {
|
|||||||
fan_curves
|
fan_curves
|
||||||
.lock()
|
.lock()
|
||||||
.await
|
.await
|
||||||
|
.profiles
|
||||||
.write_profile_curve_to_platform(
|
.write_profile_curve_to_platform(
|
||||||
profile.into(),
|
profile.into(),
|
||||||
&mut find_fan_curve_node().unwrap(),
|
&mut find_fan_curve_node().unwrap(),
|
||||||
@@ -294,8 +279,10 @@ impl crate::Reloadable for CtrlFanCurveZbus {
|
|||||||
// initialises the data from system read and we need to save it
|
// initialises the data from system read and we need to save it
|
||||||
// after
|
// after
|
||||||
loop {
|
loop {
|
||||||
if let Ok(mut curves) = self.fan_curves.try_lock() {
|
if let Ok(mut config) = self.config.try_lock() {
|
||||||
curves.write_profile_curve_to_platform(active, &mut device)?;
|
config
|
||||||
|
.profiles
|
||||||
|
.write_profile_curve_to_platform(active, &mut device)?;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -69,6 +69,16 @@ async fn start_daemon() -> Result<(), Box<dyn Error>> {
|
|||||||
|
|
||||||
// supported.add_to_server(&mut connection).await;
|
// supported.add_to_server(&mut connection).await;
|
||||||
|
|
||||||
|
match CtrlFanCurveZbus::new() {
|
||||||
|
Ok(ctrl) => {
|
||||||
|
let sig_ctx = CtrlFanCurveZbus::signal_context(&connection)?;
|
||||||
|
start_tasks(ctrl, &mut connection, sig_ctx).await?;
|
||||||
|
}
|
||||||
|
Err(err) => {
|
||||||
|
error!("FanCurves: {}", err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
match CtrlPlatform::new(
|
match CtrlPlatform::new(
|
||||||
config.clone(),
|
config.clone(),
|
||||||
&cfg_path,
|
&cfg_path,
|
||||||
@@ -83,16 +93,6 @@ async fn start_daemon() -> Result<(), Box<dyn Error>> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
match CtrlFanCurveZbus::new() {
|
|
||||||
Ok(ctrl) => {
|
|
||||||
let sig_ctx = CtrlFanCurveZbus::signal_context(&connection)?;
|
|
||||||
start_tasks(ctrl, &mut connection, sig_ctx).await?;
|
|
||||||
}
|
|
||||||
Err(err) => {
|
|
||||||
error!("FanCurves: {}", err);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
match CtrlAnime::new(AnimeConfig::new().load()) {
|
match CtrlAnime::new(AnimeConfig::new().load()) {
|
||||||
Ok(ctrl) => {
|
Ok(ctrl) => {
|
||||||
let zbus = CtrlAnimeZbus(Arc::new(Mutex::new(ctrl)));
|
let zbus = CtrlAnimeZbus(Arc::new(Mutex::new(ctrl)));
|
||||||
|
|||||||
Reference in New Issue
Block a user