mirror of
https://gitlab.com/asus-linux/asusctl.git
synced 2026-01-22 09:23:19 +01:00
rog-platform: add CPU and GPU tunings
rog-platform: add tunables to supported dat Anime: fixes to how some power options work
This commit is contained in:
@@ -7,6 +7,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||||||
## [Unreleased]
|
## [Unreleased]
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
|
- Gnome 45 plugin
|
||||||
- Support for G513RW LED modes
|
- Support for G513RW LED modes
|
||||||
- Support Rog Ally LED modes (basic)
|
- Support Rog Ally LED modes (basic)
|
||||||
- Add on_lid_closed and on_external_power_changed events for running certain tasks
|
- Add on_lid_closed and on_external_power_changed events for running certain tasks
|
||||||
@@ -14,6 +15,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||||||
- SetOffWhenUnplugged, also add asusctl CLI option
|
- SetOffWhenUnplugged, also add asusctl CLI option
|
||||||
- SetOffWhenSuspended, also add asusctl CLI option
|
- SetOffWhenSuspended, also add asusctl CLI option
|
||||||
- SetOffWhenLidClosed, also add asusctl CLI option
|
- SetOffWhenLidClosed, also add asusctl CLI option
|
||||||
|
- Anime: add brightness_on_battery config option
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
- asusd: remove set_image_brightness for anime
|
- asusd: remove set_image_brightness for anime
|
||||||
@@ -22,6 +24,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||||||
- rog-control-center: ensure brightness slider works correctly
|
- rog-control-center: ensure brightness slider works correctly
|
||||||
- Update `smithay-client-toolkit` for fix to issue #407
|
- Update `smithay-client-toolkit` for fix to issue #407
|
||||||
- Remove the "sleep" animations from Anime to stop preventing the display-off
|
- Remove the "sleep" animations from Anime to stop preventing the display-off
|
||||||
|
- Anime:
|
||||||
|
- Ensure display is off when lid is closed and option is set
|
||||||
|
- Ensure display is off when on battery and option is set
|
||||||
|
- Ensure builtin animations run instead of custom animations if option is set
|
||||||
|
|
||||||
## [v4.7.2]
|
## [v4.7.2]
|
||||||
### Added
|
### Added
|
||||||
|
|||||||
@@ -746,7 +746,7 @@ fn handle_fan_curve(
|
|||||||
|
|
||||||
fn handle_bios_option(
|
fn handle_bios_option(
|
||||||
dbus: &RogDbusClientBlocking<'_>,
|
dbus: &RogDbusClientBlocking<'_>,
|
||||||
supported: &RogBiosSupportedFunctions,
|
supported: &PlatformSupportedFunctions,
|
||||||
cmd: &BiosCommand,
|
cmd: &BiosCommand,
|
||||||
) -> Result<(), Box<dyn std::error::Error>> {
|
) -> Result<(), Box<dyn std::error::Error>> {
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -120,6 +120,7 @@ pub struct AnimeConfig {
|
|||||||
pub off_when_unplugged: bool,
|
pub off_when_unplugged: bool,
|
||||||
pub off_when_suspended: bool,
|
pub off_when_suspended: bool,
|
||||||
pub off_when_lid_closed: bool,
|
pub off_when_lid_closed: bool,
|
||||||
|
pub brightness_on_battery: Brightness,
|
||||||
pub builtin_anims: Animations,
|
pub builtin_anims: Animations,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -138,6 +139,7 @@ impl Default for AnimeConfig {
|
|||||||
off_when_unplugged: true,
|
off_when_unplugged: true,
|
||||||
off_when_suspended: true,
|
off_when_suspended: true,
|
||||||
off_when_lid_closed: true,
|
off_when_lid_closed: true,
|
||||||
|
brightness_on_battery: Brightness::Low,
|
||||||
builtin_anims: Animations::default(),
|
builtin_anims: Animations::default(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -169,6 +171,7 @@ impl From<&AnimeConfig> for DeviceState {
|
|||||||
off_when_unplugged: config.off_when_unplugged,
|
off_when_unplugged: config.off_when_unplugged,
|
||||||
off_when_suspended: config.off_when_suspended,
|
off_when_suspended: config.off_when_suspended,
|
||||||
off_when_lid_closed: config.off_when_lid_closed,
|
off_when_lid_closed: config.off_when_lid_closed,
|
||||||
|
brightness_on_battery: config.brightness_on_battery,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,19 +4,32 @@ use std::sync::Arc;
|
|||||||
use async_trait::async_trait;
|
use async_trait::async_trait;
|
||||||
use config_traits::StdConfig;
|
use config_traits::StdConfig;
|
||||||
use log::warn;
|
use log::warn;
|
||||||
|
use logind_zbus::manager::ManagerProxy;
|
||||||
use rog_anime::usb::{
|
use rog_anime::usb::{
|
||||||
pkt_set_brightness, pkt_set_builtin_animations, pkt_set_enable_display,
|
pkt_set_brightness, pkt_set_builtin_animations, pkt_set_enable_display,
|
||||||
pkt_set_enable_powersave_anim, AnimAwake, AnimBooting, AnimShutdown, AnimSleeping, Brightness,
|
pkt_set_enable_powersave_anim, AnimAwake, AnimBooting, AnimShutdown, AnimSleeping, Brightness,
|
||||||
};
|
};
|
||||||
use rog_anime::{AnimeDataBuffer, DeviceState};
|
use rog_anime::{AnimeDataBuffer, DeviceState};
|
||||||
use zbus::export::futures_util::lock::Mutex;
|
use zbus::export::futures_util::lock::Mutex;
|
||||||
use zbus::{dbus_interface, Connection, SignalContext};
|
use zbus::{dbus_interface, CacheProperties, Connection, SignalContext};
|
||||||
|
|
||||||
use super::CtrlAnime;
|
use super::CtrlAnime;
|
||||||
use crate::error::RogError;
|
use crate::error::RogError;
|
||||||
|
|
||||||
pub(super) const ZBUS_PATH: &str = "/org/asuslinux/Anime";
|
pub(super) const ZBUS_PATH: &str = "/org/asuslinux/Anime";
|
||||||
|
|
||||||
|
async fn get_logind_manager<'a>() -> ManagerProxy<'a> {
|
||||||
|
let connection = Connection::system()
|
||||||
|
.await
|
||||||
|
.expect("Controller could not create dbus connection");
|
||||||
|
|
||||||
|
ManagerProxy::builder(&connection)
|
||||||
|
.cache_properties(CacheProperties::No)
|
||||||
|
.build()
|
||||||
|
.await
|
||||||
|
.expect("Controller could not create ManagerProxy")
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub struct CtrlAnimeZbus(pub Arc<Mutex<CtrlAnime>>);
|
pub struct CtrlAnimeZbus(pub Arc<Mutex<CtrlAnime>>);
|
||||||
|
|
||||||
@@ -176,6 +189,16 @@ impl CtrlAnimeZbus {
|
|||||||
enabled: bool,
|
enabled: bool,
|
||||||
) {
|
) {
|
||||||
let mut lock = self.0.lock().await;
|
let mut lock = self.0.lock().await;
|
||||||
|
let manager = get_logind_manager().await;
|
||||||
|
let pow = manager.on_external_power().await.unwrap_or_default();
|
||||||
|
|
||||||
|
lock.node
|
||||||
|
.write_bytes(&pkt_set_enable_display(!pow && !enabled))
|
||||||
|
.map_err(|err| {
|
||||||
|
warn!("create_sys_event_tasks::off_when_lid_closed {}", err);
|
||||||
|
})
|
||||||
|
.ok();
|
||||||
|
|
||||||
lock.config.off_when_unplugged = enabled;
|
lock.config.off_when_unplugged = enabled;
|
||||||
lock.config.write();
|
lock.config.write();
|
||||||
Self::notify_device_state(&ctxt, DeviceState::from(&lock.config))
|
Self::notify_device_state(&ctxt, DeviceState::from(&lock.config))
|
||||||
@@ -204,6 +227,16 @@ impl CtrlAnimeZbus {
|
|||||||
enabled: bool,
|
enabled: bool,
|
||||||
) {
|
) {
|
||||||
let mut lock = self.0.lock().await;
|
let mut lock = self.0.lock().await;
|
||||||
|
let manager = get_logind_manager().await;
|
||||||
|
let lid = manager.lid_closed().await.unwrap_or_default();
|
||||||
|
|
||||||
|
lock.node
|
||||||
|
.write_bytes(&pkt_set_enable_display(lid && !enabled))
|
||||||
|
.map_err(|err| {
|
||||||
|
warn!("create_sys_event_tasks::off_when_lid_closed {}", err);
|
||||||
|
})
|
||||||
|
.ok();
|
||||||
|
|
||||||
lock.config.off_when_lid_closed = enabled;
|
lock.config.off_when_lid_closed = enabled;
|
||||||
lock.config.write();
|
lock.config.write();
|
||||||
Self::notify_device_state(&ctxt, DeviceState::from(&lock.config))
|
Self::notify_device_state(&ctxt, DeviceState::from(&lock.config))
|
||||||
@@ -225,15 +258,7 @@ impl CtrlAnimeZbus {
|
|||||||
// #[dbus_interface(property)]
|
// #[dbus_interface(property)]
|
||||||
async fn device_state(&self) -> DeviceState {
|
async fn device_state(&self) -> DeviceState {
|
||||||
let lock = self.0.lock().await;
|
let lock = self.0.lock().await;
|
||||||
DeviceState {
|
DeviceState::from(&lock.config)
|
||||||
display_enabled: lock.config.display_enabled,
|
|
||||||
display_brightness: lock.config.display_brightness,
|
|
||||||
builtin_anims_enabled: lock.config.builtin_anims_enabled,
|
|
||||||
builtin_anims: lock.config.builtin_anims,
|
|
||||||
off_when_unplugged: lock.config.off_when_unplugged,
|
|
||||||
off_when_suspended: lock.config.off_when_suspended,
|
|
||||||
off_when_lid_closed: lock.config.off_when_lid_closed,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Notify listeners of the status of AniMe LED power and factory
|
/// Notify listeners of the status of AniMe LED power and factory
|
||||||
@@ -320,6 +345,13 @@ impl crate::CtrlTask for CtrlAnimeZbus {
|
|||||||
warn!("create_sys_event_tasks::off_when_unplugged {}", err);
|
warn!("create_sys_event_tasks::off_when_unplugged {}", err);
|
||||||
})
|
})
|
||||||
.ok();
|
.ok();
|
||||||
|
} else {
|
||||||
|
lock.node
|
||||||
|
.write_bytes(&pkt_set_brightness(lock.config.brightness_on_battery))
|
||||||
|
.map_err(|err| {
|
||||||
|
warn!("create_sys_event_tasks::off_when_unplugged {}", err);
|
||||||
|
})
|
||||||
|
.ok();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ use async_trait::async_trait;
|
|||||||
use config_traits::StdConfig;
|
use config_traits::StdConfig;
|
||||||
use log::{info, warn};
|
use log::{info, warn};
|
||||||
use rog_platform::platform::{AsusPlatform, GpuMode};
|
use rog_platform::platform::{AsusPlatform, GpuMode};
|
||||||
use rog_platform::supported::RogBiosSupportedFunctions;
|
use rog_platform::supported::PlatformSupportedFunctions;
|
||||||
use zbus::export::futures_util::lock::Mutex;
|
use zbus::export::futures_util::lock::Mutex;
|
||||||
use zbus::{dbus_interface, Connection, SignalContext};
|
use zbus::{dbus_interface, Connection, SignalContext};
|
||||||
|
|
||||||
@@ -27,31 +27,11 @@ pub struct CtrlPlatform {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl GetSupported for CtrlPlatform {
|
impl GetSupported for CtrlPlatform {
|
||||||
type A = RogBiosSupportedFunctions;
|
type A = PlatformSupportedFunctions;
|
||||||
|
|
||||||
fn get_supported() -> Self::A {
|
fn get_supported() -> Self::A {
|
||||||
let mut panel_overdrive = false;
|
let platform = AsusPlatform::new().unwrap_or_default();
|
||||||
let mut mini_led_mode = false;
|
platform.into()
|
||||||
let mut dgpu_disable = false;
|
|
||||||
let mut egpu_enable = false;
|
|
||||||
let mut gpu_mux = false;
|
|
||||||
|
|
||||||
if let Ok(platform) = AsusPlatform::new() {
|
|
||||||
panel_overdrive = platform.has_panel_od();
|
|
||||||
mini_led_mode = platform.has_mini_led_mode();
|
|
||||||
dgpu_disable = platform.has_dgpu_disable();
|
|
||||||
egpu_enable = platform.has_egpu_enable();
|
|
||||||
gpu_mux = platform.has_gpu_mux_mode();
|
|
||||||
}
|
|
||||||
|
|
||||||
RogBiosSupportedFunctions {
|
|
||||||
post_sound: Path::new(ASUS_POST_LOGO_SOUND).exists(),
|
|
||||||
gpu_mux,
|
|
||||||
panel_overdrive,
|
|
||||||
mini_led_mode,
|
|
||||||
dgpu_disable,
|
|
||||||
egpu_enable,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ export class AnimeDbus extends DbusBase {
|
|||||||
if (this.deviceState.builtin_anims_enabled !== state) {
|
if (this.deviceState.builtin_anims_enabled !== state) {
|
||||||
this.deviceState.builtin_anims_enabled = state;
|
this.deviceState.builtin_anims_enabled = state;
|
||||||
}
|
}
|
||||||
return this.dbus_proxy.SetEnableBuiltinsSync(state);
|
return this.dbus_proxy.SetBuiltinsEnabledSync(state);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
//@ts-ignore
|
//@ts-ignore
|
||||||
log("AniMe DBus set builtins failed!", e);
|
log("AniMe DBus set builtins failed!", e);
|
||||||
|
|||||||
@@ -39,6 +39,7 @@ pub struct Animations {
|
|||||||
pub shutdown: AnimShutdown,
|
pub shutdown: AnimShutdown,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: move this out
|
||||||
#[typeshare]
|
#[typeshare]
|
||||||
#[cfg_attr(feature = "dbus", derive(Type))]
|
#[cfg_attr(feature = "dbus", derive(Type))]
|
||||||
#[typeshare]
|
#[typeshare]
|
||||||
@@ -51,6 +52,7 @@ pub struct DeviceState {
|
|||||||
pub off_when_unplugged: bool,
|
pub off_when_unplugged: bool,
|
||||||
pub off_when_suspended: bool,
|
pub off_when_suspended: bool,
|
||||||
pub off_when_lid_closed: bool,
|
pub off_when_lid_closed: bool,
|
||||||
|
pub brightness_on_battery: Brightness,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[typeshare]
|
#[typeshare]
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
#[macro_export]
|
#[macro_export]
|
||||||
macro_rules! has_attr {
|
macro_rules! has_attr {
|
||||||
($(#[$doc_comment:meta])? $attr_name:literal $item:ident) => {
|
($(#[$attr:meta])* $attr_name:literal $item:ident) => {
|
||||||
concat_idents::concat_idents!(fn_name = has_, $attr_name {
|
concat_idents::concat_idents!(fn_name = has_, $attr_name {
|
||||||
$(#[$doc_comment])*
|
$(#[$attr])*
|
||||||
pub fn fn_name(&self) -> bool {
|
pub fn fn_name(&self) -> bool {
|
||||||
match to_device(&self.$item) {
|
match to_device(&self.$item) {
|
||||||
Ok(p) => $crate::has_attr(&p, $attr_name),
|
Ok(p) => $crate::has_attr(&p, $attr_name),
|
||||||
@@ -15,9 +15,9 @@ macro_rules! has_attr {
|
|||||||
|
|
||||||
#[macro_export]
|
#[macro_export]
|
||||||
macro_rules! watch_attr {
|
macro_rules! watch_attr {
|
||||||
($(#[$doc_comment:meta])? $attr_name:literal $item:ident) => {
|
($(#[$attr:meta])* $attr_name:literal $item:ident) => {
|
||||||
concat_idents::concat_idents!(fn_name = monitor_, $attr_name {
|
concat_idents::concat_idents!(fn_name = monitor_, $attr_name {
|
||||||
$(#[$doc_comment])*
|
$(#[$attr])*
|
||||||
pub fn fn_name(&self) -> Result<inotify::Inotify> {
|
pub fn fn_name(&self) -> Result<inotify::Inotify> {
|
||||||
let mut path = self.$item.clone();
|
let mut path = self.$item.clone();
|
||||||
path.push($attr_name);
|
path.push($attr_name);
|
||||||
@@ -41,9 +41,9 @@ macro_rules! watch_attr {
|
|||||||
|
|
||||||
#[macro_export]
|
#[macro_export]
|
||||||
macro_rules! get_attr_bool {
|
macro_rules! get_attr_bool {
|
||||||
($(#[$doc_comment:meta])? $attr_name:literal $item:ident) => {
|
($(#[$attr:meta])* $attr_name:literal $item:ident) => {
|
||||||
concat_idents::concat_idents!(fn_name = get_, $attr_name {
|
concat_idents::concat_idents!(fn_name = get_, $attr_name {
|
||||||
$(#[$doc_comment])*
|
$(#[$attr])*
|
||||||
pub fn fn_name(&self) -> Result<bool> {
|
pub fn fn_name(&self) -> Result<bool> {
|
||||||
$crate::read_attr_bool(&to_device(&self.$item)?, $attr_name)
|
$crate::read_attr_bool(&to_device(&self.$item)?, $attr_name)
|
||||||
}
|
}
|
||||||
@@ -53,9 +53,9 @@ macro_rules! get_attr_bool {
|
|||||||
|
|
||||||
#[macro_export]
|
#[macro_export]
|
||||||
macro_rules! set_attr_bool {
|
macro_rules! set_attr_bool {
|
||||||
($(#[$doc_comment:meta])? $attr_name:literal $item:ident) => {
|
($(#[$attr:meta])* $attr_name:literal $item:ident) => {
|
||||||
concat_idents::concat_idents!(fn_name = set_, $attr_name {
|
concat_idents::concat_idents!(fn_name = set_, $attr_name {
|
||||||
$(#[$doc_comment])*
|
$(#[$attr])*
|
||||||
pub fn fn_name(&self, value: bool) -> Result<()> {
|
pub fn fn_name(&self, value: bool) -> Result<()> {
|
||||||
$crate::write_attr_bool(&mut to_device(&self.$item)?, $attr_name, value)
|
$crate::write_attr_bool(&mut to_device(&self.$item)?, $attr_name, value)
|
||||||
}
|
}
|
||||||
@@ -65,7 +65,7 @@ macro_rules! set_attr_bool {
|
|||||||
|
|
||||||
#[macro_export]
|
#[macro_export]
|
||||||
macro_rules! attr_bool {
|
macro_rules! attr_bool {
|
||||||
($attr_name:literal, $item:ident) => {
|
($(#[$attr:meta])* $attr_name:literal, $item:ident) => {
|
||||||
$crate::has_attr!($attr_name $item);
|
$crate::has_attr!($attr_name $item);
|
||||||
$crate::get_attr_bool!( $attr_name $item);
|
$crate::get_attr_bool!( $attr_name $item);
|
||||||
$crate::set_attr_bool!($attr_name $item);
|
$crate::set_attr_bool!($attr_name $item);
|
||||||
@@ -75,9 +75,9 @@ macro_rules! attr_bool {
|
|||||||
|
|
||||||
#[macro_export]
|
#[macro_export]
|
||||||
macro_rules! get_attr_u8 {
|
macro_rules! get_attr_u8 {
|
||||||
($(#[$doc_comment:meta])? $attr_name:literal $item:ident) => {
|
($(#[$attr:meta])* $attr_name:literal $item:ident) => {
|
||||||
concat_idents::concat_idents!(fn_name = get_, $attr_name {
|
concat_idents::concat_idents!(fn_name = get_, $attr_name {
|
||||||
$(#[$doc_comment])*
|
$(#[$attr])*
|
||||||
pub fn fn_name(&self) -> Result<u8> {
|
pub fn fn_name(&self) -> Result<u8> {
|
||||||
$crate::read_attr_u8(&to_device(&self.$item)?, $attr_name)
|
$crate::read_attr_u8(&to_device(&self.$item)?, $attr_name)
|
||||||
}
|
}
|
||||||
@@ -88,9 +88,9 @@ macro_rules! get_attr_u8 {
|
|||||||
/// Most attributes expect `u8` as a char, so `1` should be written as `b'1'`.
|
/// Most attributes expect `u8` as a char, so `1` should be written as `b'1'`.
|
||||||
#[macro_export]
|
#[macro_export]
|
||||||
macro_rules! set_attr_u8 {
|
macro_rules! set_attr_u8 {
|
||||||
($(#[$doc_comment:meta])? $attr_name:literal $item:ident) => {
|
($(#[$attr:meta])* $attr_name:literal $item:ident) => {
|
||||||
concat_idents::concat_idents!(fn_name = set_, $attr_name {
|
concat_idents::concat_idents!(fn_name = set_, $attr_name {
|
||||||
$(#[$doc_comment])*
|
$(#[$attr])*
|
||||||
pub fn fn_name(&self, value: u8) -> Result<()> {
|
pub fn fn_name(&self, value: u8) -> Result<()> {
|
||||||
$crate::write_attr_u8(&mut to_device(&self.$item)?, $attr_name, value)
|
$crate::write_attr_u8(&mut to_device(&self.$item)?, $attr_name, value)
|
||||||
}
|
}
|
||||||
@@ -100,19 +100,19 @@ macro_rules! set_attr_u8 {
|
|||||||
|
|
||||||
#[macro_export]
|
#[macro_export]
|
||||||
macro_rules! attr_u8 {
|
macro_rules! attr_u8 {
|
||||||
($attr_name:literal, $item:ident) => {
|
($(#[$attr:meta])* $attr_name:literal, $item:ident) => {
|
||||||
$crate::has_attr!($attr_name $item);
|
$crate::has_attr!($(#[$attr])* $attr_name $item);
|
||||||
$crate::get_attr_u8!($attr_name $item);
|
$crate::get_attr_u8!($(#[$attr])* $attr_name $item);
|
||||||
$crate::set_attr_u8!($attr_name $item);
|
$crate::set_attr_u8!($(#[$attr])* $attr_name $item);
|
||||||
$crate::watch_attr!($attr_name $item);
|
$crate::watch_attr!($(#[$attr])* $attr_name $item);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
#[macro_export]
|
#[macro_export]
|
||||||
macro_rules! get_attr_u8_array {
|
macro_rules! get_attr_u8_array {
|
||||||
($(#[$doc_comment:meta])? $attr_name:literal $item:ident) => {
|
($(#[$attr:meta])* $attr_name:literal $item:ident) => {
|
||||||
concat_idents::concat_idents!(fn_name = get_, $attr_name {
|
concat_idents::concat_idents!(fn_name = get_, $attr_name {
|
||||||
$(#[$doc_comment])*
|
$(#[$attr])*
|
||||||
pub fn fn_name(&self) -> Result<Vec<u8>> {
|
pub fn fn_name(&self) -> Result<Vec<u8>> {
|
||||||
$crate::read_attr_u8_array(&to_device(&self.$item)?, $attr_name)
|
$crate::read_attr_u8_array(&to_device(&self.$item)?, $attr_name)
|
||||||
}
|
}
|
||||||
@@ -122,9 +122,9 @@ macro_rules! get_attr_u8_array {
|
|||||||
|
|
||||||
#[macro_export]
|
#[macro_export]
|
||||||
macro_rules! set_attr_u8_array {
|
macro_rules! set_attr_u8_array {
|
||||||
($(#[$doc_comment:meta])? $attr_name:literal $item:ident) => {
|
($(#[$attr:meta])* $attr_name:literal $item:ident) => {
|
||||||
concat_idents::concat_idents!(fn_name = set_, $attr_name {
|
concat_idents::concat_idents!(fn_name = set_, $attr_name {
|
||||||
$(#[$doc_comment])*
|
$(#[$attr])*
|
||||||
pub fn fn_name(&self, values: &[u8]) -> Result<()> {
|
pub fn fn_name(&self, values: &[u8]) -> Result<()> {
|
||||||
$crate::write_attr_u8_array(&mut to_device(&self.$item)?, $attr_name, values)
|
$crate::write_attr_u8_array(&mut to_device(&self.$item)?, $attr_name, values)
|
||||||
}
|
}
|
||||||
@@ -134,7 +134,7 @@ macro_rules! set_attr_u8_array {
|
|||||||
|
|
||||||
#[macro_export]
|
#[macro_export]
|
||||||
macro_rules! attr_u8_array {
|
macro_rules! attr_u8_array {
|
||||||
($attr_name:literal, $item:ident) => {
|
($(#[$attr:meta])* $attr_name:literal, $item:ident) => {
|
||||||
$crate::has_attr!($attr_name $item);
|
$crate::has_attr!($attr_name $item);
|
||||||
$crate::get_attr_u8_array!($attr_name $item);
|
$crate::get_attr_u8_array!($attr_name $item);
|
||||||
$crate::set_attr_u8_array!($attr_name $item);
|
$crate::set_attr_u8_array!($attr_name $item);
|
||||||
@@ -144,9 +144,9 @@ macro_rules! attr_u8_array {
|
|||||||
|
|
||||||
#[macro_export]
|
#[macro_export]
|
||||||
macro_rules! get_attr_string {
|
macro_rules! get_attr_string {
|
||||||
($(#[$doc_comment:meta])? $attr_name:literal $item:ident) => {
|
($(#[$attr:meta])* $attr_name:literal $item:ident) => {
|
||||||
concat_idents::concat_idents!(fn_name = get_, $attr_name {
|
concat_idents::concat_idents!(fn_name = get_, $attr_name {
|
||||||
$(#[$doc_comment])*
|
$(#[$attr])*
|
||||||
pub fn fn_name(&self) -> Result<String> {
|
pub fn fn_name(&self) -> Result<String> {
|
||||||
$crate::read_attr_string(&to_device(&self.$item)?, $attr_name)
|
$crate::read_attr_string(&to_device(&self.$item)?, $attr_name)
|
||||||
}
|
}
|
||||||
@@ -156,9 +156,9 @@ macro_rules! get_attr_string {
|
|||||||
|
|
||||||
#[macro_export]
|
#[macro_export]
|
||||||
macro_rules! set_attr_string {
|
macro_rules! set_attr_string {
|
||||||
($(#[$doc_comment:meta])? $attr_name:literal $item:ident) => {
|
($(#[$attr:meta])* $attr_name:literal $item:ident) => {
|
||||||
concat_idents::concat_idents!(fn_name = set_, $attr_name {
|
concat_idents::concat_idents!(fn_name = set_, $attr_name {
|
||||||
$(#[$doc_comment])*
|
$(#[$attr])*
|
||||||
pub fn fn_name(&self, values: &str) -> Result<()> {
|
pub fn fn_name(&self, values: &str) -> Result<()> {
|
||||||
$crate::write_attr_string(&mut to_device(&self.$item)?, $attr_name, values)
|
$crate::write_attr_string(&mut to_device(&self.$item)?, $attr_name, values)
|
||||||
}
|
}
|
||||||
@@ -168,7 +168,7 @@ macro_rules! set_attr_string {
|
|||||||
|
|
||||||
#[macro_export]
|
#[macro_export]
|
||||||
macro_rules! attr_string {
|
macro_rules! attr_string {
|
||||||
($attr_name:literal, $item:ident) => {
|
($(#[$attr:meta])* $attr_name:literal, $item:ident) => {
|
||||||
$crate::has_attr!($attr_name $item);
|
$crate::has_attr!($attr_name $item);
|
||||||
$crate::get_attr_string!($attr_name $item);
|
$crate::get_attr_string!($attr_name $item);
|
||||||
$crate::set_attr_string!($attr_name $item);
|
$crate::set_attr_string!($attr_name $item);
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ use typeshare::typeshare;
|
|||||||
use zbus::zvariant::Type;
|
use zbus::zvariant::Type;
|
||||||
|
|
||||||
use crate::error::{PlatformError, Result};
|
use crate::error::{PlatformError, Result};
|
||||||
|
use crate::supported::PlatformSupportedFunctions;
|
||||||
use crate::{attr_bool, attr_string, attr_u8, to_device};
|
use crate::{attr_bool, attr_string, attr_u8, to_device};
|
||||||
|
|
||||||
/// The "platform" device provides access to things like:
|
/// The "platform" device provides access to things like:
|
||||||
@@ -15,6 +16,7 @@ use crate::{attr_bool, attr_string, attr_u8, to_device};
|
|||||||
/// - `egpu_enable`
|
/// - `egpu_enable`
|
||||||
/// - `panel_od`
|
/// - `panel_od`
|
||||||
/// - `gpu_mux`
|
/// - `gpu_mux`
|
||||||
|
/// - various CPU an GPU tunings
|
||||||
/// - `keyboard_mode`, set keyboard RGB mode and speed
|
/// - `keyboard_mode`, set keyboard RGB mode and speed
|
||||||
/// - `keyboard_state`, set keyboard power states
|
/// - `keyboard_state`, set keyboard power states
|
||||||
#[derive(Debug, PartialEq, Eq, PartialOrd, Clone)]
|
#[derive(Debug, PartialEq, Eq, PartialOrd, Clone)]
|
||||||
@@ -34,12 +36,69 @@ impl AsusPlatform {
|
|||||||
|
|
||||||
attr_bool!("gpu_mux_mode", path);
|
attr_bool!("gpu_mux_mode", path);
|
||||||
|
|
||||||
// This is technically the same as `platform_profile` since both are tied
|
attr_u8!(
|
||||||
// in-kernel
|
/// This is technically the same as `platform_profile` since both are
|
||||||
attr_u8!("throttle_thermal_policy", path);
|
/// tied in-kernel
|
||||||
|
"throttle_thermal_policy",
|
||||||
|
path
|
||||||
|
);
|
||||||
|
|
||||||
// The acpi platform_profile support
|
attr_string!(
|
||||||
attr_string!("platform_profile", pp_path);
|
/// The acpi platform_profile support
|
||||||
|
"platform_profile",
|
||||||
|
pp_path
|
||||||
|
);
|
||||||
|
|
||||||
|
attr_u8!(
|
||||||
|
/// Package Power Target total of CPU: PL1 on Intel, SPL on AMD.
|
||||||
|
/// Shown on Intel+Nvidia or AMD+Nvidia based systems:
|
||||||
|
/// * min=5, max=250
|
||||||
|
"ppt_pl1_spl",
|
||||||
|
path
|
||||||
|
);
|
||||||
|
|
||||||
|
attr_u8!(
|
||||||
|
/// Slow Package Power Tracking Limit of CPU: PL2 on Intel, SPPT,
|
||||||
|
/// on AMD. Shown on Intel+Nvidia or AMD+Nvidia based systems:
|
||||||
|
/// * min=5, max=250
|
||||||
|
"ppt_pl2_sppt",
|
||||||
|
path
|
||||||
|
);
|
||||||
|
|
||||||
|
attr_u8!(
|
||||||
|
/// Fast Package Power Tracking Limit of CPU. AMD+Nvidia only:
|
||||||
|
/// * min=5, max=250
|
||||||
|
"ppt_fppt",
|
||||||
|
path
|
||||||
|
);
|
||||||
|
|
||||||
|
attr_u8!(
|
||||||
|
/// APU SPPT limit. Shown on full AMD systems only:
|
||||||
|
/// * min=5, max=130
|
||||||
|
"ppt_apu_sppt",
|
||||||
|
path
|
||||||
|
);
|
||||||
|
|
||||||
|
attr_u8!(
|
||||||
|
/// Platform SPPT limit. Shown on full AMD systems only:
|
||||||
|
/// * min=5, max=130
|
||||||
|
"ppt_platform_sppt",
|
||||||
|
path
|
||||||
|
);
|
||||||
|
|
||||||
|
attr_u8!(
|
||||||
|
/// Dynamic boost limit of the Nvidia dGPU:
|
||||||
|
/// * min=5, max=25
|
||||||
|
"nv_dynamic_boost",
|
||||||
|
path
|
||||||
|
);
|
||||||
|
|
||||||
|
attr_u8!(
|
||||||
|
/// Target temperature limit of the Nvidia dGPU:
|
||||||
|
/// * min=75, max=87
|
||||||
|
"nv_temp_target",
|
||||||
|
path
|
||||||
|
);
|
||||||
|
|
||||||
pub fn new() -> Result<Self> {
|
pub fn new() -> Result<Self> {
|
||||||
let mut enumerator = udev::Enumerator::new().map_err(|err| {
|
let mut enumerator = udev::Enumerator::new().map_err(|err| {
|
||||||
@@ -73,6 +132,37 @@ impl AsusPlatform {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Default for AsusPlatform {
|
||||||
|
fn default() -> Self {
|
||||||
|
unsafe {
|
||||||
|
Self {
|
||||||
|
path: PathBuf::from_str("/this_shouldNeVErr_exisid").unwrap_unchecked(),
|
||||||
|
pp_path: PathBuf::from_str("/this_shouldNeVErr_exisid").unwrap_unchecked(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl From<AsusPlatform> for PlatformSupportedFunctions {
|
||||||
|
fn from(a: AsusPlatform) -> Self {
|
||||||
|
PlatformSupportedFunctions {
|
||||||
|
post_sound: false,
|
||||||
|
gpu_mux: a.has_gpu_mux_mode(),
|
||||||
|
panel_overdrive: a.has_panel_od(),
|
||||||
|
dgpu_disable: a.has_dgpu_disable(),
|
||||||
|
egpu_enable: a.has_egpu_enable(),
|
||||||
|
mini_led_mode: a.has_mini_led_mode(),
|
||||||
|
ppt_pl1_spl: a.has_ppt_pl1_spl(),
|
||||||
|
ppt_pl2_sppt: a.has_ppt_pl2_sppt(),
|
||||||
|
ppt_fppt: a.has_ppt_fppt(),
|
||||||
|
ppt_apu_sppt: a.has_ppt_apu_sppt(),
|
||||||
|
ppt_platform_sppt: a.has_ppt_platform_sppt(),
|
||||||
|
nv_dynamic_boost: a.has_nv_dynamic_boost(),
|
||||||
|
nv_temp_target: a.has_nv_temp_target(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[typeshare]
|
#[typeshare]
|
||||||
#[derive(Serialize, Deserialize, Default, Type, Debug, PartialEq, Eq, Clone, Copy)]
|
#[derive(Serialize, Deserialize, Default, Type, Debug, PartialEq, Eq, Clone, Copy)]
|
||||||
pub enum GpuMode {
|
pub enum GpuMode {
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ pub struct SupportedFunctions {
|
|||||||
pub charge_ctrl: ChargeSupportedFunctions,
|
pub charge_ctrl: ChargeSupportedFunctions,
|
||||||
pub platform_profile: PlatformProfileFunctions,
|
pub platform_profile: PlatformProfileFunctions,
|
||||||
pub keyboard_led: LedSupportedFunctions,
|
pub keyboard_led: LedSupportedFunctions,
|
||||||
pub rog_bios_ctrl: RogBiosSupportedFunctions,
|
pub rog_bios_ctrl: PlatformSupportedFunctions,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[typeshare]
|
#[typeshare]
|
||||||
@@ -68,13 +68,21 @@ pub struct LedSupportedFunctions {
|
|||||||
|
|
||||||
#[typeshare]
|
#[typeshare]
|
||||||
#[derive(Serialize, Deserialize, Type, Debug, Default, Clone)]
|
#[derive(Serialize, Deserialize, Type, Debug, Default, Clone)]
|
||||||
pub struct RogBiosSupportedFunctions {
|
pub struct PlatformSupportedFunctions {
|
||||||
pub post_sound: bool,
|
pub post_sound: bool,
|
||||||
pub gpu_mux: bool,
|
pub gpu_mux: bool,
|
||||||
pub panel_overdrive: bool,
|
pub panel_overdrive: bool,
|
||||||
pub dgpu_disable: bool,
|
pub dgpu_disable: bool,
|
||||||
pub egpu_enable: bool,
|
pub egpu_enable: bool,
|
||||||
pub mini_led_mode: bool,
|
pub mini_led_mode: bool,
|
||||||
|
|
||||||
|
pub ppt_pl1_spl: bool,
|
||||||
|
pub ppt_pl2_sppt: bool,
|
||||||
|
pub ppt_fppt: bool,
|
||||||
|
pub ppt_apu_sppt: bool,
|
||||||
|
pub ppt_platform_sppt: bool,
|
||||||
|
pub nv_dynamic_boost: bool,
|
||||||
|
pub nv_temp_target: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl fmt::Display for SupportedFunctions {
|
impl fmt::Display for SupportedFunctions {
|
||||||
@@ -120,7 +128,8 @@ impl fmt::Display for LedSupportedFunctions {
|
|||||||
writeln!(f, "\tAdvanced modes: {:?}", self.advanced_type)
|
writeln!(f, "\tAdvanced modes: {:?}", self.advanced_type)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl fmt::Display for RogBiosSupportedFunctions {
|
|
||||||
|
impl fmt::Display for PlatformSupportedFunctions {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
writeln!(f, "ROG BIOS:")?;
|
writeln!(f, "ROG BIOS:")?;
|
||||||
writeln!(f, "\tPOST sound switch: {}", self.post_sound)?;
|
writeln!(f, "\tPOST sound switch: {}", self.post_sound)?;
|
||||||
@@ -129,6 +138,13 @@ impl fmt::Display for RogBiosSupportedFunctions {
|
|||||||
writeln!(f, "\tdGPU disable switch: {}", self.dgpu_disable)?;
|
writeln!(f, "\tdGPU disable switch: {}", self.dgpu_disable)?;
|
||||||
writeln!(f, "\teGPU enable switch: {}", self.egpu_enable)?;
|
writeln!(f, "\teGPU enable switch: {}", self.egpu_enable)?;
|
||||||
writeln!(f, "\tGPU MUX control: {}", self.gpu_mux)?;
|
writeln!(f, "\tGPU MUX control: {}", self.gpu_mux)?;
|
||||||
|
writeln!(f, "\tppt_pl1_spl: {}", self.ppt_pl1_spl)?;
|
||||||
|
writeln!(f, "\tppt_pl2_sppt: {}", self.ppt_pl2_sppt)?;
|
||||||
|
writeln!(f, "\tppt_fppt {}", self.ppt_fppt)?;
|
||||||
|
writeln!(f, "\tppt_apu_sppt: {}", self.ppt_apu_sppt)?;
|
||||||
|
writeln!(f, "\tppt_platform_sppt: {}", self.ppt_platform_sppt)?;
|
||||||
|
writeln!(f, "\tnv_dynamic_boost: {}", self.nv_dynamic_boost)?;
|
||||||
|
writeln!(f, "\tnv_temp_target: {}", self.nv_temp_target)?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user