mirror of
https://gitlab.com/asus-linux/asusctl.git
synced 2026-02-06 00:15:04 +01:00
Rename RogBios bits to Platform. Better GPU MUX support.
This commit is contained in:
@@ -12,6 +12,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||||||
+ hidraw
|
+ hidraw
|
||||||
+ usbraw
|
+ usbraw
|
||||||
- Refactor how ROGCC handles IPC for background open, run-in-bg
|
- Refactor how ROGCC handles IPC for background open, run-in-bg
|
||||||
|
### Breaking
|
||||||
|
- DBUS: rename path `/org/asuslinux/RogBios` to `/org/asuslinux/Platform`
|
||||||
|
- DBUS: renamed `dedicated_graphic_mode` to `gpu_mux_mode` (`GpuMuxMode`)
|
||||||
|
- DBUS: renamed `set_dedicated_graphic_mode` to `set_gpu_mux_mode` (`SetGpuMuxMode`)
|
||||||
|
+ The methods above take an enum: 0 = Discrete, 1 = Optimus
|
||||||
|
|
||||||
## [4.3.4] - 2022-08-03
|
## [4.3.4] - 2022-08-03
|
||||||
### Bugfix
|
### Bugfix
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ 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_profile::ProfileProxy,
|
||||||
zbus_rogbios::RogBiosProxy,
|
zbus_platform::RogBiosProxy,
|
||||||
};
|
};
|
||||||
use rog_profiles::Profile;
|
use rog_profiles::Profile;
|
||||||
use smol::{future, Executor};
|
use smol::{future, Executor};
|
||||||
|
|||||||
@@ -80,11 +80,11 @@ pub struct BiosCommand {
|
|||||||
meta = "",
|
meta = "",
|
||||||
short = "D",
|
short = "D",
|
||||||
no_long,
|
no_long,
|
||||||
help = "activate dGPU dedicated/G-Sync: asusctl -d <true/false>, reboot required"
|
help = "Switch GPU MUX mode: 0 = Discrete, 1 = Optimus, reboot required"
|
||||||
)]
|
)]
|
||||||
pub dedicated_gfx_set: Option<bool>,
|
pub gpu_mux_mode_set: Option<u8>,
|
||||||
#[options(no_long, short = "d", help = "get GPU mode")]
|
#[options(no_long, short = "d", help = "get GPU mode")]
|
||||||
pub dedicated_gfx_get: bool,
|
pub gpu_mux_mode_get: bool,
|
||||||
#[options(
|
#[options(
|
||||||
meta = "",
|
meta = "",
|
||||||
short = "O",
|
short = "O",
|
||||||
|
|||||||
@@ -753,8 +753,8 @@ fn handle_bios_option(
|
|||||||
cmd: &BiosCommand,
|
cmd: &BiosCommand,
|
||||||
) -> Result<(), Box<dyn std::error::Error>> {
|
) -> Result<(), Box<dyn std::error::Error>> {
|
||||||
{
|
{
|
||||||
if (cmd.dedicated_gfx_set.is_none()
|
if (cmd.gpu_mux_mode_set.is_none()
|
||||||
&& !cmd.dedicated_gfx_get
|
&& !cmd.gpu_mux_mode_get
|
||||||
&& cmd.post_sound_set.is_none()
|
&& cmd.post_sound_set.is_none()
|
||||||
&& !cmd.post_sound_get
|
&& !cmd.post_sound_get
|
||||||
&& cmd.panel_overdrive_set.is_none()
|
&& cmd.panel_overdrive_set.is_none()
|
||||||
@@ -785,21 +785,14 @@ fn handle_bios_option(
|
|||||||
println!("Bios POST sound on: {}", res);
|
println!("Bios POST sound on: {}", res);
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(opt) = cmd.dedicated_gfx_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_dedicated_graphic_mode(opt)?;
|
dbus.proxies().rog_bios().set_gpu_mux_mode(opt.into())?;
|
||||||
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 opt {
|
|
||||||
println!(
|
|
||||||
"NOTE: on reboot your display manager will be forced to use Nvidia drivers"
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
println!("NOTE: after reboot you can then select regular graphics modes");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if cmd.dedicated_gfx_get {
|
if cmd.gpu_mux_mode_get {
|
||||||
let res = dbus.proxies().rog_bios().dedicated_graphic_mode()?;
|
let res = dbus.proxies().rog_bios().gpu_mux_mode()?;
|
||||||
println!("Bios dedicated GPU on: {}", res);
|
println!("Bios GPU MUX: {:?}", res);
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(opt) = cmd.panel_overdrive_set {
|
if let Some(opt) = cmd.panel_overdrive_set {
|
||||||
|
|||||||
@@ -1,10 +1,9 @@
|
|||||||
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::{error, info, warn};
|
use log::{info, warn};
|
||||||
use rog_platform::platform::AsusPlatform;
|
use rog_platform::platform::{AsusPlatform, GpuMuxMode};
|
||||||
use rog_platform::supported::RogBiosSupportedFunctions;
|
use rog_platform::supported::RogBiosSupportedFunctions;
|
||||||
use std::fs::OpenOptions;
|
use std::fs::OpenOptions;
|
||||||
use std::io::BufRead;
|
|
||||||
use std::io::{Read, Write};
|
use std::io::{Read, Write};
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
use std::process::Command;
|
use std::process::Command;
|
||||||
@@ -13,11 +12,6 @@ use std::sync::Mutex;
|
|||||||
use zbus::Connection;
|
use zbus::Connection;
|
||||||
use zbus::{dbus_interface, SignalContext};
|
use zbus::{dbus_interface, SignalContext};
|
||||||
|
|
||||||
const INITRAMFS_PATH: &str = "/usr/sbin/update-initramfs";
|
|
||||||
const DRACUT_PATH: &str = "/usr/bin/dracut";
|
|
||||||
|
|
||||||
// static ASUS_SWITCH_GRAPHIC_MODE: &str =
|
|
||||||
// "/sys/firmware/efi/efivars/AsusSwitchGraphicMode-607005d5-3f75-4b2e-98f0-85ba66797a3e";
|
|
||||||
static ASUS_POST_LOGO_SOUND: &str =
|
static ASUS_POST_LOGO_SOUND: &str =
|
||||||
"/sys/firmware/efi/efivars/AsusPostLogoSound-607005d5-3f75-4b2e-98f0-85ba66797a3e";
|
"/sys/firmware/efi/efivars/AsusPostLogoSound-607005d5-3f75-4b2e-98f0-85ba66797a3e";
|
||||||
|
|
||||||
@@ -54,36 +48,34 @@ impl GetSupported for CtrlRogBios {
|
|||||||
|
|
||||||
#[dbus_interface(name = "org.asuslinux.Daemon")]
|
#[dbus_interface(name = "org.asuslinux.Daemon")]
|
||||||
impl CtrlRogBios {
|
impl CtrlRogBios {
|
||||||
async fn set_dedicated_graphic_mode(
|
async fn set_gpu_mux_mode(
|
||||||
&mut self,
|
&mut self,
|
||||||
#[zbus(signal_context)] ctxt: SignalContext<'_>,
|
#[zbus(signal_context)] ctxt: SignalContext<'_>,
|
||||||
dedicated: bool,
|
mode: GpuMuxMode,
|
||||||
) {
|
) {
|
||||||
self.set_gfx_mode(dedicated)
|
self.set_gfx_mode(mode)
|
||||||
.map_err(|err| {
|
.map_err(|err| {
|
||||||
warn!("CtrlRogBios: set_asus_switch_graphic_mode {}", err);
|
warn!("CtrlRogBios: set_asus_switch_graphic_mode {}", err);
|
||||||
err
|
err
|
||||||
})
|
})
|
||||||
.ok();
|
.ok();
|
||||||
Self::notify_dedicated_graphic_mode(&ctxt, dedicated)
|
Self::notify_gpu_mux_mode(&ctxt, mode).await.ok();
|
||||||
.await
|
|
||||||
.ok();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn dedicated_graphic_mode(&self) -> bool {
|
fn gpu_mux_mode(&self) -> GpuMuxMode {
|
||||||
self.platform
|
match self.platform.get_gpu_mux_mode() {
|
||||||
.get_gpu_mux_mode()
|
Ok(m) => m.into(),
|
||||||
.map_err(|err| {
|
Err(e) => {
|
||||||
warn!("CtrlRogBios: get_gfx_mode {}", err);
|
warn!("CtrlRogBios: get_gfx_mode {}", e);
|
||||||
err
|
GpuMuxMode::Error
|
||||||
})
|
}
|
||||||
.unwrap_or(false)
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[dbus_interface(signal)]
|
#[dbus_interface(signal)]
|
||||||
async fn notify_dedicated_graphic_mode(
|
async fn notify_gpu_mux_mode(
|
||||||
signal_ctxt: &SignalContext<'_>,
|
signal_ctxt: &SignalContext<'_>,
|
||||||
dedicated: bool,
|
mode: GpuMuxMode,
|
||||||
) -> zbus::Result<()> {
|
) -> zbus::Result<()> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -151,7 +143,7 @@ impl CtrlRogBios {
|
|||||||
#[async_trait]
|
#[async_trait]
|
||||||
impl crate::ZbusAdd for CtrlRogBios {
|
impl crate::ZbusAdd for CtrlRogBios {
|
||||||
async fn add_to_server(self, server: &mut Connection) {
|
async fn add_to_server(self, server: &mut Connection) {
|
||||||
Self::add_to_server_helper(self, "/org/asuslinux/RogBios", server).await;
|
Self::add_to_server_helper(self, "/org/asuslinux/Platform", server).await;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -191,10 +183,10 @@ impl CtrlRogBios {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(super) fn set_gfx_mode(&self, enable: bool) -> Result<(), RogError> {
|
fn set_gfx_mode(&self, mode: GpuMuxMode) -> Result<(), RogError> {
|
||||||
self.platform.set_gpu_mux_mode(enable)?;
|
self.platform.set_gpu_mux_mode(mode.into())?;
|
||||||
self.update_initramfs(enable)?;
|
// self.update_initramfs(enable)?;
|
||||||
if enable {
|
if mode == GpuMuxMode::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");
|
||||||
@@ -243,89 +235,6 @@ impl CtrlRogBios {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
// required for g-sync mode
|
|
||||||
fn update_initramfs(&self, dedicated: bool) -> Result<(), RogError> {
|
|
||||||
let mut initfs_cmd = None;
|
|
||||||
|
|
||||||
if Path::new(INITRAMFS_PATH).exists() {
|
|
||||||
let mut cmd = Command::new("update-initramfs");
|
|
||||||
cmd.arg("-u");
|
|
||||||
initfs_cmd = Some(cmd);
|
|
||||||
info!("Using initramfs update command 'update-initramfs'");
|
|
||||||
} else if Path::new(DRACUT_PATH).exists() {
|
|
||||||
let mut cmd = Command::new("dracut");
|
|
||||||
cmd.arg("-f");
|
|
||||||
cmd.arg("-q");
|
|
||||||
initfs_cmd = Some(cmd);
|
|
||||||
info!("Using initramfs update command 'dracut'");
|
|
||||||
}
|
|
||||||
|
|
||||||
if let Some(mut cmd) = initfs_cmd {
|
|
||||||
info!("Updating initramfs");
|
|
||||||
|
|
||||||
// If switching to Nvidia dedicated we need these modules included
|
|
||||||
if Path::new(DRACUT_PATH).exists() && dedicated {
|
|
||||||
cmd.arg("--add-drivers");
|
|
||||||
cmd.arg("nvidia nvidia-drm nvidia-modeset nvidia-uvm");
|
|
||||||
info!("System uses dracut, forcing nvidia modules to be included in init");
|
|
||||||
} else if Path::new(INITRAMFS_PATH).exists() {
|
|
||||||
let modules = vec![
|
|
||||||
"nvidia\n",
|
|
||||||
"nvidia-drm\n",
|
|
||||||
"nvidia-modeset\n",
|
|
||||||
"nvidia-uvm\n",
|
|
||||||
];
|
|
||||||
|
|
||||||
let module_include = Path::new("/etc/initramfs-tools/modules");
|
|
||||||
|
|
||||||
if dedicated {
|
|
||||||
let mut file = std::fs::OpenOptions::new()
|
|
||||||
.append(true)
|
|
||||||
.open(module_include)
|
|
||||||
.map_err(|err| {
|
|
||||||
RogError::Write(module_include.to_string_lossy().to_string(), err)
|
|
||||||
})?;
|
|
||||||
// add nvidia modules to module_include
|
|
||||||
file.write_all(modules.concat().as_bytes())?;
|
|
||||||
} else {
|
|
||||||
let file = std::fs::OpenOptions::new()
|
|
||||||
.read(true)
|
|
||||||
.open(module_include)
|
|
||||||
.map_err(|err| {
|
|
||||||
RogError::Write(module_include.to_string_lossy().to_string(), err)
|
|
||||||
})?;
|
|
||||||
|
|
||||||
let mut buf = Vec::new();
|
|
||||||
// remove modules
|
|
||||||
for line in std::io::BufReader::new(file).lines().flatten() {
|
|
||||||
if !modules.contains(&line.as_str()) {
|
|
||||||
buf.append(&mut line.as_bytes().to_vec());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
let file = std::fs::OpenOptions::new()
|
|
||||||
.write(true)
|
|
||||||
.open(module_include)
|
|
||||||
.map_err(|err| {
|
|
||||||
RogError::Write(module_include.to_string_lossy().to_string(), err)
|
|
||||||
})?;
|
|
||||||
std::io::BufWriter::new(file).write_all(&buf)?;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
let status = cmd
|
|
||||||
.status()
|
|
||||||
.map_err(|err| RogError::Write(format!("{:?}", cmd), err))?;
|
|
||||||
if !status.success() {
|
|
||||||
error!("Ram disk update failed");
|
|
||||||
return Err(RogError::Initramfs("Ram disk update failed".into()));
|
|
||||||
} else {
|
|
||||||
info!("Successfully updated initramfs");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
|
|
||||||
fn set_panel_od(&mut self, enable: bool) -> Result<(), RogError> {
|
fn set_panel_od(&mut self, enable: bool) -> Result<(), RogError> {
|
||||||
self.platform.set_panel_od(enable).map_err(|err| {
|
self.platform.set_panel_od(enable).map_err(|err| {
|
||||||
warn!("CtrlRogBios: set_panel_overdrive {}", err);
|
warn!("CtrlRogBios: set_panel_overdrive {}", err);
|
||||||
@@ -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_rog_bios::CtrlRogBios, GetSupported,
|
ctrl_profiles::controller::CtrlPlatformProfile, ctrl_platform::CtrlRogBios, GetSupported,
|
||||||
};
|
};
|
||||||
|
|
||||||
use rog_platform::supported::*;
|
use rog_platform::supported::*;
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ use daemon::ctrl_aura::controller::{
|
|||||||
};
|
};
|
||||||
use daemon::ctrl_charge::CtrlCharge;
|
use daemon::ctrl_charge::CtrlCharge;
|
||||||
use daemon::ctrl_profiles::config::ProfileConfig;
|
use daemon::ctrl_profiles::config::ProfileConfig;
|
||||||
use daemon::ctrl_rog_bios::CtrlRogBios;
|
use daemon::ctrl_platform::CtrlRogBios;
|
||||||
use daemon::{
|
use daemon::{
|
||||||
config::Config, ctrl_supported::SupportedFunctions, laptops::print_board_info, GetSupported,
|
config::Config, ctrl_supported::SupportedFunctions, laptops::print_board_info, GetSupported,
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ pub mod ctrl_charge;
|
|||||||
/// - 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
|
/// Control ASUS bios function such as boot sound, Optimus/Dedicated gfx mode
|
||||||
pub mod ctrl_rog_bios;
|
pub mod ctrl_platform;
|
||||||
/// Laptop matching to determine capabilities
|
/// Laptop matching to determine capabilities
|
||||||
pub mod laptops;
|
pub mod laptops;
|
||||||
|
|
||||||
|
|||||||
@@ -62,7 +62,7 @@ impl Bios {
|
|||||||
pub fn post_boot_sound(&self) -> Result<i16> {
|
pub fn post_boot_sound(&self) -> Result<i16> {
|
||||||
Ok(1)
|
Ok(1)
|
||||||
}
|
}
|
||||||
pub fn dedicated_graphic_mode(&self) -> Result<i16> {
|
pub fn gpu_mux_mode(&self) -> Result<i16> {
|
||||||
Ok(1)
|
Ok(1)
|
||||||
}
|
}
|
||||||
pub fn panel_overdrive(&self) -> Result<i16> {
|
pub fn panel_overdrive(&self) -> Result<i16> {
|
||||||
@@ -71,7 +71,7 @@ impl Bios {
|
|||||||
pub fn set_post_boot_sound(&self, _b: bool) -> Result<()> {
|
pub fn set_post_boot_sound(&self, _b: bool) -> Result<()> {
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
pub fn set_dedicated_graphic_mode(&self, _b: bool) -> Result<()> {
|
pub fn set_gpu_mux_mode(&self, _b: bool) -> Result<()> {
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
pub fn set_panel_overdrive(&self, _b: bool) -> Result<()> {
|
pub fn set_panel_overdrive(&self, _b: bool) -> Result<()> {
|
||||||
|
|||||||
@@ -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_rogbios::RogBiosProxy,
|
zbus_profile::ProfileProxy, zbus_platform::RogBiosProxy,
|
||||||
};
|
};
|
||||||
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::supported::SupportedFunctions;
|
use rog_platform::{platform::GpuMuxMode, 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: bool,
|
pub dedicated_gfx: GpuMuxMode,
|
||||||
pub panel_overdrive: bool,
|
pub panel_overdrive: bool,
|
||||||
pub dgpu_disable: bool,
|
pub dgpu_disable: bool,
|
||||||
pub egpu_enable: bool,
|
pub egpu_enable: bool,
|
||||||
@@ -40,9 +40,9 @@ impl BiosState {
|
|||||||
false
|
false
|
||||||
},
|
},
|
||||||
dedicated_gfx: if supported.rog_bios_ctrl.dgpu_only {
|
dedicated_gfx: if supported.rog_bios_ctrl.dgpu_only {
|
||||||
dbus.proxies().rog_bios().dedicated_graphic_mode()?
|
dbus.proxies().rog_bios().gpu_mux_mode()?
|
||||||
} else {
|
} else {
|
||||||
false
|
GpuMuxMode::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: Default::default(),
|
dedicated_gfx: GpuMuxMode::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::supported::SupportedFunctions;
|
use rog_platform::{platform::GpuMuxMode, 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) {
|
||||||
@@ -91,16 +91,33 @@ pub fn rog_bios_group(
|
|||||||
}
|
}
|
||||||
|
|
||||||
if supported.rog_bios_ctrl.dgpu_only {
|
if supported.rog_bios_ctrl.dgpu_only {
|
||||||
if ui
|
let mut changed = false;
|
||||||
.add(egui::Checkbox::new(
|
ui.group(|ui| {
|
||||||
&mut states.bios.dedicated_gfx,
|
ui.vertical(|ui| {
|
||||||
"G-Sync Dedicated GPU mode",
|
ui.horizontal_wrapped(|ui| ui.label("GPU MUX mode (reboot required)"));
|
||||||
))
|
ui.horizontal_wrapped(|ui| {
|
||||||
.changed()
|
changed = ui
|
||||||
{
|
.selectable_value(
|
||||||
|
&mut states.bios.dedicated_gfx,
|
||||||
|
GpuMuxMode::Discrete,
|
||||||
|
"Dedicated (Ultimate)",
|
||||||
|
)
|
||||||
|
.clicked()
|
||||||
|
|| ui
|
||||||
|
.selectable_value(
|
||||||
|
&mut states.bios.dedicated_gfx,
|
||||||
|
GpuMuxMode::Optimus,
|
||||||
|
"Optimus (Hybrid)",
|
||||||
|
)
|
||||||
|
.clicked();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
if changed {
|
||||||
dbus.proxies()
|
dbus.proxies()
|
||||||
.rog_bios()
|
.rog_bios()
|
||||||
.set_dedicated_graphic_mode(states.bios.dedicated_gfx)
|
.set_gpu_mux_mode(states.bios.dedicated_gfx)
|
||||||
.map_err(|err| {
|
.map_err(|err| {
|
||||||
states.error = Some(err.to_string());
|
states.error = Some(err.to_string());
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ 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_profile;
|
||||||
pub mod zbus_rogbios;
|
pub mod zbus_platform;
|
||||||
pub mod zbus_supported;
|
pub mod zbus_supported;
|
||||||
|
|
||||||
// use rog_anime::AnimePowerStates;
|
// use rog_anime::AnimePowerStates;
|
||||||
@@ -21,7 +21,7 @@ pub struct DbusProxiesBlocking<'a> {
|
|||||||
charge: zbus_charge::ChargeProxyBlocking<'a>,
|
charge: zbus_charge::ChargeProxyBlocking<'a>,
|
||||||
led: zbus_led::LedProxyBlocking<'a>,
|
led: zbus_led::LedProxyBlocking<'a>,
|
||||||
profile: zbus_profile::ProfileProxyBlocking<'a>,
|
profile: zbus_profile::ProfileProxyBlocking<'a>,
|
||||||
rog_bios: zbus_rogbios::RogBiosProxyBlocking<'a>,
|
rog_bios: zbus_platform::RogBiosProxyBlocking<'a>,
|
||||||
supported: zbus_supported::SupportedProxyBlocking<'a>,
|
supported: zbus_supported::SupportedProxyBlocking<'a>,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -36,7 +36,7 @@ impl<'a> DbusProxiesBlocking<'a> {
|
|||||||
led: zbus_led::LedProxyBlocking::new(&conn)?,
|
led: zbus_led::LedProxyBlocking::new(&conn)?,
|
||||||
charge: zbus_charge::ChargeProxyBlocking::new(&conn)?,
|
charge: zbus_charge::ChargeProxyBlocking::new(&conn)?,
|
||||||
profile: zbus_profile::ProfileProxyBlocking::new(&conn)?,
|
profile: zbus_profile::ProfileProxyBlocking::new(&conn)?,
|
||||||
rog_bios: zbus_rogbios::RogBiosProxyBlocking::new(&conn)?,
|
rog_bios: zbus_platform::RogBiosProxyBlocking::new(&conn)?,
|
||||||
supported: zbus_supported::SupportedProxyBlocking::new(&conn)?,
|
supported: zbus_supported::SupportedProxyBlocking::new(&conn)?,
|
||||||
},
|
},
|
||||||
conn,
|
conn,
|
||||||
@@ -59,7 +59,7 @@ impl<'a> DbusProxiesBlocking<'a> {
|
|||||||
&self.profile
|
&self.profile
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn rog_bios(&self) -> &zbus_rogbios::RogBiosProxyBlocking<'a> {
|
pub fn rog_bios(&self) -> &zbus_platform::RogBiosProxyBlocking<'a> {
|
||||||
&self.rog_bios
|
&self.rog_bios
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -90,7 +90,7 @@ pub struct DbusProxies<'a> {
|
|||||||
charge: zbus_charge::ChargeProxy<'a>,
|
charge: zbus_charge::ChargeProxy<'a>,
|
||||||
led: zbus_led::LedProxy<'a>,
|
led: zbus_led::LedProxy<'a>,
|
||||||
profile: zbus_profile::ProfileProxy<'a>,
|
profile: zbus_profile::ProfileProxy<'a>,
|
||||||
rog_bios: zbus_rogbios::RogBiosProxy<'a>,
|
rog_bios: zbus_platform::RogBiosProxy<'a>,
|
||||||
supported: zbus_supported::SupportedProxy<'a>,
|
supported: zbus_supported::SupportedProxy<'a>,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -105,7 +105,7 @@ impl<'a> DbusProxies<'a> {
|
|||||||
led: zbus_led::LedProxy::new(&conn).await?,
|
led: zbus_led::LedProxy::new(&conn).await?,
|
||||||
charge: zbus_charge::ChargeProxy::new(&conn).await?,
|
charge: zbus_charge::ChargeProxy::new(&conn).await?,
|
||||||
profile: zbus_profile::ProfileProxy::new(&conn).await?,
|
profile: zbus_profile::ProfileProxy::new(&conn).await?,
|
||||||
rog_bios: zbus_rogbios::RogBiosProxy::new(&conn).await?,
|
rog_bios: zbus_platform::RogBiosProxy::new(&conn).await?,
|
||||||
supported: zbus_supported::SupportedProxy::new(&conn).await?,
|
supported: zbus_supported::SupportedProxy::new(&conn).await?,
|
||||||
},
|
},
|
||||||
conn,
|
conn,
|
||||||
@@ -128,7 +128,7 @@ impl<'a> DbusProxies<'a> {
|
|||||||
&self.profile
|
&self.profile
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn rog_bios(&self) -> &zbus_rogbios::RogBiosProxy<'a> {
|
pub fn rog_bios(&self) -> &zbus_platform::RogBiosProxy<'a> {
|
||||||
&self.rog_bios
|
&self.rog_bios
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
//! # DBus interface proxy for: `org.asuslinux.Daemon`
|
//! # DBus interface proxy for: `org.asuslinux.Daemon`
|
||||||
//!
|
//!
|
||||||
//! This code was generated by `zbus-xmlgen` `1.0.0` from DBus introspection data.
|
//! This code was generated by `zbus-xmlgen` `1.0.0` from DBus introspection data.
|
||||||
//! Source: `Interface '/org/asuslinux/RogBios' from service 'org.asuslinux.Daemon' on system bus`.
|
//! Source: `Interface '/org/asuslinux/Platform' from service 'org.asuslinux.Daemon' on system bus`.
|
||||||
//!
|
//!
|
||||||
//! You may prefer to adapt it, instead of using it verbatim.
|
//! You may prefer to adapt it, instead of using it verbatim.
|
||||||
//!
|
//!
|
||||||
@@ -19,21 +19,22 @@
|
|||||||
//!
|
//!
|
||||||
//! …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 zbus_macros::dbus_proxy;
|
use zbus_macros::dbus_proxy;
|
||||||
|
|
||||||
#[dbus_proxy(
|
#[dbus_proxy(
|
||||||
interface = "org.asuslinux.Daemon",
|
interface = "org.asuslinux.Daemon",
|
||||||
default_path = "/org/asuslinux/RogBios"
|
default_path = "/org/asuslinux/Platform"
|
||||||
)]
|
)]
|
||||||
trait RogBios {
|
trait RogBios {
|
||||||
/// DedicatedGraphicMode method
|
/// DedicatedGraphicMode method
|
||||||
fn dedicated_graphic_mode(&self) -> zbus::Result<bool>;
|
fn gpu_mux_mode(&self) -> zbus::Result<GpuMuxMode>;
|
||||||
|
|
||||||
/// 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_dedicated_graphic_mode(&self, dedicated: bool) -> zbus::Result<()>;
|
fn set_gpu_mux_mode(&self, mode: GpuMuxMode) -> 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<()>;
|
||||||
@@ -46,7 +47,7 @@ trait RogBios {
|
|||||||
|
|
||||||
/// NotifyDedicatedGraphicMode signal
|
/// NotifyDedicatedGraphicMode signal
|
||||||
#[dbus_proxy(signal)]
|
#[dbus_proxy(signal)]
|
||||||
fn notify_dedicated_graphic_mode(&self, dedicated: bool) -> zbus::Result<()>;
|
fn notify_gpu_mux_mode(&self, mode: GpuMuxMode) -> zbus::Result<()>;
|
||||||
|
|
||||||
/// NotifyPostBootSound signal
|
/// NotifyPostBootSound signal
|
||||||
#[dbus_proxy(signal)]
|
#[dbus_proxy(signal)]
|
||||||
@@ -1,3 +1,6 @@
|
|||||||
|
//! This crate functions as a wrapper of all the relevant ASUS functionality
|
||||||
|
//! on ROG, Strix, and TUF laptops.
|
||||||
|
|
||||||
pub mod error;
|
pub mod error;
|
||||||
pub mod hid_raw;
|
pub mod hid_raw;
|
||||||
pub mod keyboard_led;
|
pub mod keyboard_led;
|
||||||
|
|||||||
@@ -1,9 +1,11 @@
|
|||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
|
|
||||||
use log::warn;
|
use log::warn;
|
||||||
|
use serde::{Deserialize, Serialize};
|
||||||
|
use zvariant::Type;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
attr_bool,
|
attr_bool, attr_u8,
|
||||||
error::{PlatformError, Result},
|
error::{PlatformError, Result},
|
||||||
to_device,
|
to_device,
|
||||||
};
|
};
|
||||||
@@ -60,10 +62,38 @@ impl AsusPlatform {
|
|||||||
|
|
||||||
attr_bool!(has_panel_od, get_panel_od, set_panel_od, "panel_od");
|
attr_bool!(has_panel_od, get_panel_od, set_panel_od, "panel_od");
|
||||||
|
|
||||||
attr_bool!(
|
attr_u8!(
|
||||||
has_gpu_mux_mode,
|
has_gpu_mux_mode,
|
||||||
get_gpu_mux_mode,
|
get_gpu_mux_mode,
|
||||||
set_gpu_mux_mode,
|
set_gpu_mux_mode,
|
||||||
"gpu_mux_mode"
|
"gpu_mux_mode"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Serialize, Deserialize, Type, Debug, PartialEq, Clone, Copy)]
|
||||||
|
pub enum GpuMuxMode {
|
||||||
|
Discrete,
|
||||||
|
Optimus,
|
||||||
|
Error,
|
||||||
|
NotSupported,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl From<u8> for GpuMuxMode {
|
||||||
|
fn from(m: u8) -> Self {
|
||||||
|
if m > 0 {
|
||||||
|
return Self::Optimus;
|
||||||
|
}
|
||||||
|
Self::Discrete
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl From<GpuMuxMode> for u8 {
|
||||||
|
fn from(m: GpuMuxMode) -> Self {
|
||||||
|
match m {
|
||||||
|
GpuMuxMode::Discrete => 0,
|
||||||
|
GpuMuxMode::Optimus => 1,
|
||||||
|
GpuMuxMode::Error => 254,
|
||||||
|
GpuMuxMode::NotSupported => 255,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user