mirror of
https://gitlab.com/asus-linux/asusctl.git
synced 2026-02-06 00:15:04 +01:00
Extend GpuMode to include other modes
This commit is contained in:
@@ -1,8 +1,8 @@
|
|||||||
use notify_rust::{Hint, Notification, NotificationHandle};
|
use notify_rust::{Hint, Notification, NotificationHandle};
|
||||||
use rog_aura::AuraEffect;
|
use rog_aura::AuraEffect;
|
||||||
use rog_dbus::{
|
use rog_dbus::{
|
||||||
zbus_charge::ChargeProxy, zbus_led::LedProxy, zbus_profile::ProfileProxy,
|
zbus_charge::ChargeProxy, zbus_led::LedProxy, zbus_platform::RogBiosProxy,
|
||||||
zbus_platform::RogBiosProxy,
|
zbus_profile::ProfileProxy,
|
||||||
};
|
};
|
||||||
use rog_profiles::Profile;
|
use rog_profiles::Profile;
|
||||||
use smol::{future, Executor};
|
use smol::{future, Executor};
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ use rog_anime::{AnimTime, AnimeDataBuffer, AnimeDiagonal, AnimeGif, AnimeImage,
|
|||||||
use rog_aura::usb::{AuraDev1866, AuraDev19b6, AuraDevTuf, AuraDevice, AuraPowerDev};
|
use rog_aura::usb::{AuraDev1866, AuraDev19b6, AuraDevTuf, AuraDevice, AuraPowerDev};
|
||||||
use rog_aura::{self, AuraEffect};
|
use rog_aura::{self, AuraEffect};
|
||||||
use rog_dbus::RogDbusClientBlocking;
|
use rog_dbus::RogDbusClientBlocking;
|
||||||
|
use rog_platform::platform::GpuMode;
|
||||||
use rog_platform::supported::*;
|
use rog_platform::supported::*;
|
||||||
use rog_profiles::error::ProfileError;
|
use rog_profiles::error::ProfileError;
|
||||||
|
|
||||||
@@ -787,7 +788,9 @@ fn handle_bios_option(
|
|||||||
|
|
||||||
if let Some(opt) = cmd.gpu_mux_mode_set {
|
if let Some(opt) = cmd.gpu_mux_mode_set {
|
||||||
println!("Rebuilding initrd to include drivers");
|
println!("Rebuilding initrd to include drivers");
|
||||||
dbus.proxies().rog_bios().set_gpu_mux_mode(opt.into())?;
|
dbus.proxies()
|
||||||
|
.rog_bios()
|
||||||
|
.set_gpu_mux_mode(GpuMode::from_mux(opt))?;
|
||||||
println!("The mode change is not active until you reboot, on boot the bios will make the required change");
|
println!("The mode change is not active until you reboot, on boot the bios will make the required change");
|
||||||
}
|
}
|
||||||
if cmd.gpu_mux_mode_get {
|
if cmd.gpu_mux_mode_get {
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
use crate::{config::Config, error::RogError, GetSupported};
|
use crate::{config::Config, error::RogError, GetSupported};
|
||||||
use async_trait::async_trait;
|
use async_trait::async_trait;
|
||||||
use log::{info, warn};
|
use log::{info, warn};
|
||||||
use rog_platform::platform::{AsusPlatform, GpuMuxMode};
|
use rog_platform::platform::{AsusPlatform, GpuMode};
|
||||||
use rog_platform::supported::RogBiosSupportedFunctions;
|
use rog_platform::supported::RogBiosSupportedFunctions;
|
||||||
use std::fs::OpenOptions;
|
use std::fs::OpenOptions;
|
||||||
use std::io::{Read, Write};
|
use std::io::{Read, Write};
|
||||||
@@ -51,7 +51,7 @@ impl CtrlRogBios {
|
|||||||
async fn set_gpu_mux_mode(
|
async fn set_gpu_mux_mode(
|
||||||
&mut self,
|
&mut self,
|
||||||
#[zbus(signal_context)] ctxt: SignalContext<'_>,
|
#[zbus(signal_context)] ctxt: SignalContext<'_>,
|
||||||
mode: GpuMuxMode,
|
mode: GpuMode,
|
||||||
) {
|
) {
|
||||||
self.set_gfx_mode(mode)
|
self.set_gfx_mode(mode)
|
||||||
.map_err(|err| {
|
.map_err(|err| {
|
||||||
@@ -62,12 +62,12 @@ impl CtrlRogBios {
|
|||||||
Self::notify_gpu_mux_mode(&ctxt, mode).await.ok();
|
Self::notify_gpu_mux_mode(&ctxt, mode).await.ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
fn gpu_mux_mode(&self) -> GpuMuxMode {
|
fn gpu_mux_mode(&self) -> GpuMode {
|
||||||
match self.platform.get_gpu_mux_mode() {
|
match self.platform.get_gpu_mux_mode() {
|
||||||
Ok(m) => m.into(),
|
Ok(m) => GpuMode::from_mux(m),
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
warn!("CtrlRogBios: get_gfx_mode {}", e);
|
warn!("CtrlRogBios: get_gfx_mode {}", e);
|
||||||
GpuMuxMode::Error
|
GpuMode::Error
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -75,7 +75,7 @@ impl CtrlRogBios {
|
|||||||
#[dbus_interface(signal)]
|
#[dbus_interface(signal)]
|
||||||
async fn notify_gpu_mux_mode(
|
async fn notify_gpu_mux_mode(
|
||||||
signal_ctxt: &SignalContext<'_>,
|
signal_ctxt: &SignalContext<'_>,
|
||||||
mode: GpuMuxMode,
|
mode: GpuMode,
|
||||||
) -> zbus::Result<()> {
|
) -> zbus::Result<()> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -183,10 +183,10 @@ impl CtrlRogBios {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn set_gfx_mode(&self, mode: GpuMuxMode) -> Result<(), RogError> {
|
fn set_gfx_mode(&self, mode: GpuMode) -> Result<(), RogError> {
|
||||||
self.platform.set_gpu_mux_mode(mode.into())?;
|
self.platform.set_gpu_mux_mode(mode.to_mux())?;
|
||||||
// self.update_initramfs(enable)?;
|
// self.update_initramfs(enable)?;
|
||||||
if mode == GpuMuxMode::Discrete {
|
if mode == GpuMode::Discrete {
|
||||||
info!("Set system-level graphics mode: Dedicated Nvidia");
|
info!("Set system-level graphics mode: Dedicated Nvidia");
|
||||||
} else {
|
} else {
|
||||||
info!("Set system-level graphics mode: Optimus");
|
info!("Set system-level graphics mode: Optimus");
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ use zvariant::Type;
|
|||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
ctrl_anime::CtrlAnime, ctrl_aura::controller::CtrlKbdLed, ctrl_charge::CtrlCharge,
|
ctrl_anime::CtrlAnime, ctrl_aura::controller::CtrlKbdLed, ctrl_charge::CtrlCharge,
|
||||||
ctrl_profiles::controller::CtrlPlatformProfile, ctrl_platform::CtrlRogBios, GetSupported,
|
ctrl_platform::CtrlRogBios, ctrl_profiles::controller::CtrlPlatformProfile, GetSupported,
|
||||||
};
|
};
|
||||||
|
|
||||||
use rog_platform::supported::*;
|
use rog_platform::supported::*;
|
||||||
|
|||||||
@@ -17,8 +17,8 @@ use daemon::ctrl_aura::controller::{
|
|||||||
CtrlKbdLed, CtrlKbdLedReloader, CtrlKbdLedTask, CtrlKbdLedZbus,
|
CtrlKbdLed, CtrlKbdLedReloader, CtrlKbdLedTask, CtrlKbdLedZbus,
|
||||||
};
|
};
|
||||||
use daemon::ctrl_charge::CtrlCharge;
|
use daemon::ctrl_charge::CtrlCharge;
|
||||||
use daemon::ctrl_profiles::config::ProfileConfig;
|
|
||||||
use daemon::ctrl_platform::CtrlRogBios;
|
use daemon::ctrl_platform::CtrlRogBios;
|
||||||
|
use daemon::ctrl_profiles::config::ProfileConfig;
|
||||||
use daemon::{
|
use daemon::{
|
||||||
config::Config, ctrl_supported::SupportedFunctions, laptops::print_board_info, GetSupported,
|
config::Config, ctrl_supported::SupportedFunctions, laptops::print_board_info, GetSupported,
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -7,6 +7,8 @@ pub mod ctrl_anime;
|
|||||||
pub mod ctrl_aura;
|
pub mod ctrl_aura;
|
||||||
/// Control of battery charge level
|
/// Control of battery charge level
|
||||||
pub mod ctrl_charge;
|
pub mod ctrl_charge;
|
||||||
|
/// Control ASUS bios function such as boot sound, Optimus/Dedicated gfx mode
|
||||||
|
pub mod ctrl_platform;
|
||||||
/// Control CPU min/max freq and turbo, fan mode, fan curves
|
/// Control CPU min/max freq and turbo, fan mode, fan curves
|
||||||
///
|
///
|
||||||
/// Intel machines can control:
|
/// Intel machines can control:
|
||||||
@@ -19,8 +21,6 @@ pub mod ctrl_charge;
|
|||||||
/// - Fan mode (normal, boost, silent)
|
/// - Fan mode (normal, boost, silent)
|
||||||
/// - Fan min/max RPM curve
|
/// - Fan min/max RPM curve
|
||||||
pub mod ctrl_profiles;
|
pub mod ctrl_profiles;
|
||||||
/// Control ASUS bios function such as boot sound, Optimus/Dedicated gfx mode
|
|
||||||
pub mod ctrl_platform;
|
|
||||||
/// Laptop matching to determine capabilities
|
/// Laptop matching to determine capabilities
|
||||||
pub mod laptops;
|
pub mod laptops;
|
||||||
|
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ use notify_rust::{Hint, Notification, NotificationHandle};
|
|||||||
use rog_aura::AuraEffect;
|
use rog_aura::AuraEffect;
|
||||||
use rog_dbus::{
|
use rog_dbus::{
|
||||||
zbus_anime::AnimeProxy, zbus_charge::ChargeProxy, zbus_led::LedProxy,
|
zbus_anime::AnimeProxy, zbus_charge::ChargeProxy, zbus_led::LedProxy,
|
||||||
zbus_profile::ProfileProxy, zbus_platform::RogBiosProxy,
|
zbus_platform::RogBiosProxy, zbus_profile::ProfileProxy,
|
||||||
};
|
};
|
||||||
use rog_profiles::Profile;
|
use rog_profiles::Profile;
|
||||||
use smol::{future, Executor};
|
use smol::{future, Executor};
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ use std::{
|
|||||||
|
|
||||||
use egui::Vec2;
|
use egui::Vec2;
|
||||||
use rog_aura::{layouts::KeyLayout, usb::AuraPowerDev, AuraEffect, AuraModeNum};
|
use rog_aura::{layouts::KeyLayout, usb::AuraPowerDev, AuraEffect, AuraModeNum};
|
||||||
use rog_platform::{platform::GpuMuxMode, supported::SupportedFunctions};
|
use rog_platform::{platform::GpuMode, supported::SupportedFunctions};
|
||||||
use rog_profiles::{fan_curve_set::FanCurveSet, FanCurvePU, Profile};
|
use rog_profiles::{fan_curve_set::FanCurveSet, FanCurvePU, Profile};
|
||||||
|
|
||||||
use crate::{error::Result, RogDbusClientBlocking};
|
use crate::{error::Result, RogDbusClientBlocking};
|
||||||
@@ -20,7 +20,7 @@ pub struct BiosState {
|
|||||||
/// updated, so the full state needs refresh
|
/// updated, so the full state needs refresh
|
||||||
pub was_notified: Arc<AtomicBool>,
|
pub was_notified: Arc<AtomicBool>,
|
||||||
pub post_sound: bool,
|
pub post_sound: bool,
|
||||||
pub dedicated_gfx: GpuMuxMode,
|
pub dedicated_gfx: GpuMode,
|
||||||
pub panel_overdrive: bool,
|
pub panel_overdrive: bool,
|
||||||
pub dgpu_disable: bool,
|
pub dgpu_disable: bool,
|
||||||
pub egpu_enable: bool,
|
pub egpu_enable: bool,
|
||||||
@@ -42,7 +42,7 @@ impl BiosState {
|
|||||||
dedicated_gfx: if supported.rog_bios_ctrl.dgpu_only {
|
dedicated_gfx: if supported.rog_bios_ctrl.dgpu_only {
|
||||||
dbus.proxies().rog_bios().gpu_mux_mode()?
|
dbus.proxies().rog_bios().gpu_mux_mode()?
|
||||||
} else {
|
} else {
|
||||||
GpuMuxMode::NotSupported
|
GpuMode::NotSupported
|
||||||
},
|
},
|
||||||
panel_overdrive: if supported.rog_bios_ctrl.panel_overdrive {
|
panel_overdrive: if supported.rog_bios_ctrl.panel_overdrive {
|
||||||
dbus.proxies().rog_bios().panel_overdrive()?
|
dbus.proxies().rog_bios().panel_overdrive()?
|
||||||
@@ -337,7 +337,7 @@ impl Default for PageDataStates {
|
|||||||
bios: BiosState {
|
bios: BiosState {
|
||||||
was_notified: Default::default(),
|
was_notified: Default::default(),
|
||||||
post_sound: Default::default(),
|
post_sound: Default::default(),
|
||||||
dedicated_gfx: GpuMuxMode::NotSupported,
|
dedicated_gfx: GpuMode::NotSupported,
|
||||||
panel_overdrive: Default::default(),
|
panel_overdrive: Default::default(),
|
||||||
dgpu_disable: Default::default(),
|
dgpu_disable: Default::default(),
|
||||||
egpu_enable: Default::default(),
|
egpu_enable: Default::default(),
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
use crate::{page_states::PageDataStates, RogDbusClientBlocking};
|
use crate::{page_states::PageDataStates, RogDbusClientBlocking};
|
||||||
use egui::Ui;
|
use egui::Ui;
|
||||||
use rog_platform::{platform::GpuMuxMode, supported::SupportedFunctions};
|
use rog_platform::{platform::GpuMode, supported::SupportedFunctions};
|
||||||
use rog_profiles::Profile;
|
use rog_profiles::Profile;
|
||||||
|
|
||||||
pub fn platform_profile(states: &mut PageDataStates, dbus: &RogDbusClientBlocking, ui: &mut Ui) {
|
pub fn platform_profile(states: &mut PageDataStates, dbus: &RogDbusClientBlocking, ui: &mut Ui) {
|
||||||
@@ -99,14 +99,14 @@ pub fn rog_bios_group(
|
|||||||
changed = ui
|
changed = ui
|
||||||
.selectable_value(
|
.selectable_value(
|
||||||
&mut states.bios.dedicated_gfx,
|
&mut states.bios.dedicated_gfx,
|
||||||
GpuMuxMode::Discrete,
|
GpuMode::Discrete,
|
||||||
"Dedicated (Ultimate)",
|
"Dedicated (Ultimate)",
|
||||||
)
|
)
|
||||||
.clicked()
|
.clicked()
|
||||||
|| ui
|
|| ui
|
||||||
.selectable_value(
|
.selectable_value(
|
||||||
&mut states.bios.dedicated_gfx,
|
&mut states.bios.dedicated_gfx,
|
||||||
GpuMuxMode::Optimus,
|
GpuMode::Optimus,
|
||||||
"Optimus (Hybrid)",
|
"Optimus (Hybrid)",
|
||||||
)
|
)
|
||||||
.clicked();
|
.clicked();
|
||||||
|
|||||||
@@ -5,8 +5,8 @@ pub static DBUS_IFACE: &str = "org.asuslinux.Daemon";
|
|||||||
pub mod zbus_anime;
|
pub mod zbus_anime;
|
||||||
pub mod zbus_charge;
|
pub mod zbus_charge;
|
||||||
pub mod zbus_led;
|
pub mod zbus_led;
|
||||||
pub mod zbus_profile;
|
|
||||||
pub mod zbus_platform;
|
pub mod zbus_platform;
|
||||||
|
pub mod zbus_profile;
|
||||||
pub mod zbus_supported;
|
pub mod zbus_supported;
|
||||||
|
|
||||||
// use rog_anime::AnimePowerStates;
|
// use rog_anime::AnimePowerStates;
|
||||||
|
|||||||
@@ -19,7 +19,7 @@
|
|||||||
//!
|
//!
|
||||||
//! …consequently `zbus-xmlgen` did not generate code for the above interfaces.
|
//! …consequently `zbus-xmlgen` did not generate code for the above interfaces.
|
||||||
|
|
||||||
use rog_platform::platform::GpuMuxMode;
|
use rog_platform::platform::GpuMode;
|
||||||
use zbus_macros::dbus_proxy;
|
use zbus_macros::dbus_proxy;
|
||||||
|
|
||||||
#[dbus_proxy(
|
#[dbus_proxy(
|
||||||
@@ -28,13 +28,13 @@ use zbus_macros::dbus_proxy;
|
|||||||
)]
|
)]
|
||||||
trait RogBios {
|
trait RogBios {
|
||||||
/// DedicatedGraphicMode method
|
/// DedicatedGraphicMode method
|
||||||
fn gpu_mux_mode(&self) -> zbus::Result<GpuMuxMode>;
|
fn gpu_mux_mode(&self) -> zbus::Result<GpuMode>;
|
||||||
|
|
||||||
/// PostBootSound method
|
/// PostBootSound method
|
||||||
fn post_boot_sound(&self) -> zbus::Result<i16>;
|
fn post_boot_sound(&self) -> zbus::Result<i16>;
|
||||||
|
|
||||||
/// SetDedicatedGraphicMode method
|
/// SetDedicatedGraphicMode method
|
||||||
fn set_gpu_mux_mode(&self, mode: GpuMuxMode) -> zbus::Result<()>;
|
fn set_gpu_mux_mode(&self, mode: GpuMode) -> zbus::Result<()>;
|
||||||
|
|
||||||
/// SetPostBootSound method
|
/// SetPostBootSound method
|
||||||
fn set_post_boot_sound(&self, on: bool) -> zbus::Result<()>;
|
fn set_post_boot_sound(&self, on: bool) -> zbus::Result<()>;
|
||||||
@@ -47,7 +47,7 @@ trait RogBios {
|
|||||||
|
|
||||||
/// NotifyDedicatedGraphicMode signal
|
/// NotifyDedicatedGraphicMode signal
|
||||||
#[dbus_proxy(signal)]
|
#[dbus_proxy(signal)]
|
||||||
fn notify_gpu_mux_mode(&self, mode: GpuMuxMode) -> zbus::Result<()>;
|
fn notify_gpu_mux_mode(&self, mode: GpuMode) -> zbus::Result<()>;
|
||||||
|
|
||||||
/// NotifyPostBootSound signal
|
/// NotifyPostBootSound signal
|
||||||
#[dbus_proxy(signal)]
|
#[dbus_proxy(signal)]
|
||||||
|
|||||||
@@ -71,29 +71,57 @@ impl AsusPlatform {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize, Type, Debug, PartialEq, Clone, Copy)]
|
#[derive(Serialize, Deserialize, Type, Debug, PartialEq, Clone, Copy)]
|
||||||
pub enum GpuMuxMode {
|
pub enum GpuMode {
|
||||||
Discrete,
|
Discrete,
|
||||||
Optimus,
|
Optimus,
|
||||||
|
Integrated,
|
||||||
|
Egpu,
|
||||||
Error,
|
Error,
|
||||||
NotSupported,
|
NotSupported,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<u8> for GpuMuxMode {
|
impl GpuMode {
|
||||||
fn from(m: u8) -> Self {
|
pub fn to_mux(&self) -> u8 {
|
||||||
if m > 0 {
|
if *self == Self::Discrete {
|
||||||
return Self::Optimus;
|
return 0;
|
||||||
}
|
}
|
||||||
Self::Discrete
|
1
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
impl From<GpuMuxMode> for u8 {
|
pub fn to_dgpu(&self) -> u8 {
|
||||||
fn from(m: GpuMuxMode) -> Self {
|
if *self == Self::Integrated {
|
||||||
match m {
|
return 1;
|
||||||
GpuMuxMode::Discrete => 0,
|
|
||||||
GpuMuxMode::Optimus => 1,
|
|
||||||
GpuMuxMode::Error => 254,
|
|
||||||
GpuMuxMode::NotSupported => 255,
|
|
||||||
}
|
}
|
||||||
|
0
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn to_egpu(&self) -> u8 {
|
||||||
|
if *self == Self::Egpu {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
0
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn from_mux(num: u8) -> Self {
|
||||||
|
if num == 0 {
|
||||||
|
return Self::Discrete;
|
||||||
|
}
|
||||||
|
Self::Optimus
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn from_dgpu(num: u8) -> Self {
|
||||||
|
if num == 1 {
|
||||||
|
return Self::Integrated;
|
||||||
|
}
|
||||||
|
Self::Optimus
|
||||||
|
}
|
||||||
|
|
||||||
|
// `from_dgpu()` should be called also, and should take precedence if result
|
||||||
|
// are not equal.
|
||||||
|
pub fn from_egpu(num: u8) -> Self {
|
||||||
|
if num == 1 {
|
||||||
|
return Self::Egpu;
|
||||||
|
}
|
||||||
|
Self::Optimus
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user