mirror of
https://gitlab.com/asus-linux/asusctl.git
synced 2026-01-22 17:33:19 +01:00
gfx: tmp informational only store of vfio/compute mode
This commit is contained in:
@@ -14,7 +14,9 @@ pub static AURA_CONFIG_PATH: &str = "/etc/asusd/asusd.conf";
|
|||||||
#[derive(Deserialize, Serialize)]
|
#[derive(Deserialize, Serialize)]
|
||||||
pub struct Config {
|
pub struct Config {
|
||||||
pub gfx_mode: GfxVendors,
|
pub gfx_mode: GfxVendors,
|
||||||
pub gfx_last_mode: GfxVendors,
|
/// Only for informational purposes.
|
||||||
|
#[serde(skip)]
|
||||||
|
pub gfx_tmp_mode: Option<GfxVendors>,
|
||||||
pub gfx_managed: bool,
|
pub gfx_managed: bool,
|
||||||
pub gfx_vfio_enable: bool,
|
pub gfx_vfio_enable: bool,
|
||||||
pub active_profile: String,
|
pub active_profile: String,
|
||||||
@@ -34,7 +36,7 @@ impl Default for Config {
|
|||||||
|
|
||||||
Config {
|
Config {
|
||||||
gfx_mode: GfxVendors::Hybrid,
|
gfx_mode: GfxVendors::Hybrid,
|
||||||
gfx_last_mode: GfxVendors::Hybrid,
|
gfx_tmp_mode: None,
|
||||||
gfx_managed: true,
|
gfx_managed: true,
|
||||||
gfx_vfio_enable: false,
|
gfx_vfio_enable: false,
|
||||||
active_profile: "normal".into(),
|
active_profile: "normal".into(),
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ impl ConfigV317 {
|
|||||||
pub(crate) fn into_current(self) -> Config {
|
pub(crate) fn into_current(self) -> Config {
|
||||||
Config {
|
Config {
|
||||||
gfx_mode: GfxVendors::Hybrid,
|
gfx_mode: GfxVendors::Hybrid,
|
||||||
gfx_last_mode: GfxVendors::Hybrid,
|
gfx_tmp_mode: None,
|
||||||
gfx_managed: self.gfx_managed,
|
gfx_managed: self.gfx_managed,
|
||||||
gfx_vfio_enable: false,
|
gfx_vfio_enable: false,
|
||||||
active_profile: self.active_profile,
|
active_profile: self.active_profile,
|
||||||
@@ -53,7 +53,7 @@ impl ConfigV324 {
|
|||||||
pub(crate) fn into_current(self) -> Config {
|
pub(crate) fn into_current(self) -> Config {
|
||||||
Config {
|
Config {
|
||||||
gfx_mode: GfxVendors::Hybrid,
|
gfx_mode: GfxVendors::Hybrid,
|
||||||
gfx_last_mode: GfxVendors::Hybrid,
|
gfx_tmp_mode: None,
|
||||||
gfx_managed: self.gfx_managed,
|
gfx_managed: self.gfx_managed,
|
||||||
gfx_vfio_enable: false,
|
gfx_vfio_enable: false,
|
||||||
active_profile: self.active_profile,
|
active_profile: self.active_profile,
|
||||||
@@ -82,7 +82,7 @@ impl ConfigV341 {
|
|||||||
pub(crate) fn into_current(self) -> Config {
|
pub(crate) fn into_current(self) -> Config {
|
||||||
Config {
|
Config {
|
||||||
gfx_mode: GfxVendors::Hybrid,
|
gfx_mode: GfxVendors::Hybrid,
|
||||||
gfx_last_mode: GfxVendors::Hybrid,
|
gfx_tmp_mode: None,
|
||||||
gfx_managed: self.gfx_managed,
|
gfx_managed: self.gfx_managed,
|
||||||
gfx_vfio_enable: false,
|
gfx_vfio_enable: false,
|
||||||
active_profile: self.active_profile,
|
active_profile: self.active_profile,
|
||||||
@@ -114,7 +114,7 @@ impl ConfigV352 {
|
|||||||
pub(crate) fn into_current(self) -> Config {
|
pub(crate) fn into_current(self) -> Config {
|
||||||
Config {
|
Config {
|
||||||
gfx_mode: GfxVendors::Hybrid,
|
gfx_mode: GfxVendors::Hybrid,
|
||||||
gfx_last_mode: GfxVendors::Hybrid,
|
gfx_tmp_mode: None,
|
||||||
gfx_managed: self.gfx_managed,
|
gfx_managed: self.gfx_managed,
|
||||||
gfx_vfio_enable: false,
|
gfx_vfio_enable: false,
|
||||||
active_profile: self.active_profile,
|
active_profile: self.active_profile,
|
||||||
|
|||||||
@@ -111,7 +111,6 @@ impl CtrlGraphics {
|
|||||||
/// Save the selected `Vendor` mode to config
|
/// Save the selected `Vendor` mode to config
|
||||||
fn save_gfx_mode(vendor: GfxVendors, config: Arc<Mutex<Config>>) {
|
fn save_gfx_mode(vendor: GfxVendors, config: Arc<Mutex<Config>>) {
|
||||||
if let Ok(mut config) = config.lock() {
|
if let Ok(mut config) = config.lock() {
|
||||||
config.gfx_last_mode = config.gfx_mode;
|
|
||||||
config.gfx_mode = vendor;
|
config.gfx_mode = vendor;
|
||||||
config.write();
|
config.write();
|
||||||
}
|
}
|
||||||
@@ -120,6 +119,9 @@ impl CtrlGraphics {
|
|||||||
/// Associated method to get which vendor mode is set
|
/// Associated method to get which vendor mode is set
|
||||||
pub fn get_gfx_mode(&self) -> Result<GfxVendors, RogError> {
|
pub fn get_gfx_mode(&self) -> Result<GfxVendors, RogError> {
|
||||||
if let Ok(config) = self.config.lock() {
|
if let Ok(config) = self.config.lock() {
|
||||||
|
if let Some(mode) = config.gfx_tmp_mode {
|
||||||
|
return Ok(mode);
|
||||||
|
}
|
||||||
return Ok(config.gfx_mode);
|
return Ok(config.gfx_mode);
|
||||||
}
|
}
|
||||||
// TODO: Error here
|
// TODO: Error here
|
||||||
@@ -511,7 +513,11 @@ impl CtrlGraphics {
|
|||||||
Self::do_display_manager_action("stop")?;
|
Self::do_display_manager_action("stop")?;
|
||||||
Self::wait_display_manager_state("inactive")?;
|
Self::wait_display_manager_state("inactive")?;
|
||||||
|
|
||||||
let vfio_enable = if let Ok(config) = config.lock() {
|
let vfio_enable = if let Ok(mut config) = config.try_lock() {
|
||||||
|
// Since we have a lock, reset tmp to none. This thread should only ever run
|
||||||
|
// for Integrated, Hybrid, or Nvidia. Tmp is also only for informational
|
||||||
|
config.gfx_tmp_mode = None;
|
||||||
|
//
|
||||||
config.gfx_vfio_enable
|
config.gfx_vfio_enable
|
||||||
} else {
|
} else {
|
||||||
false
|
false
|
||||||
@@ -582,7 +588,7 @@ impl CtrlGraphics {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let vfio_enable = if let Ok(config) = self.config.lock() {
|
let vfio_enable = if let Ok(config) = self.config.try_lock() {
|
||||||
config.gfx_vfio_enable
|
config.gfx_vfio_enable
|
||||||
} else {
|
} else {
|
||||||
false
|
false
|
||||||
@@ -607,6 +613,11 @@ impl CtrlGraphics {
|
|||||||
let bus = self.bus.clone();
|
let bus = self.bus.clone();
|
||||||
Self::do_vendor_tasks(vendor, vfio_enable, &devices, &bus)?;
|
Self::do_vendor_tasks(vendor, vfio_enable, &devices, &bus)?;
|
||||||
info!("GFX: Graphics mode changed to {}", <&str>::from(vendor));
|
info!("GFX: Graphics mode changed to {}", <&str>::from(vendor));
|
||||||
|
if matches!(vendor, GfxVendors::Vfio | GfxVendors::Compute) {
|
||||||
|
if let Ok(mut config) = self.config.try_lock() {
|
||||||
|
config.gfx_tmp_mode = Some(vendor);
|
||||||
|
};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// TODO: undo if failed? Save last mode, catch errors...
|
// TODO: undo if failed? Save last mode, catch errors...
|
||||||
Ok(action_required)
|
Ok(action_required)
|
||||||
|
|||||||
@@ -145,10 +145,9 @@ fn start_daemon() -> Result<(), Box<dyn Error>> {
|
|||||||
// Need to check if a laptop has the dedicated gfx switch
|
// Need to check if a laptop has the dedicated gfx switch
|
||||||
if CtrlRogBios::has_dedicated_gfx_toggle() {
|
if CtrlRogBios::has_dedicated_gfx_toggle() {
|
||||||
if let Ok(ded) = CtrlRogBios::get_gfx_mode() {
|
if let Ok(ded) = CtrlRogBios::get_gfx_mode() {
|
||||||
if let Ok(mut config) = config.lock() {
|
if let Ok(config) = config.lock() {
|
||||||
if ded == 1 {
|
if ded == 1 {
|
||||||
warn!("Dedicated GFX toggle is on but driver mode is not nvidia \nSetting to nvidia driver mode");
|
warn!("Dedicated GFX toggle is on but driver mode is not nvidia \nSetting to nvidia driver mode");
|
||||||
config.gfx_last_mode = config.gfx_mode;
|
|
||||||
let devices = ctrl.devices();
|
let devices = ctrl.devices();
|
||||||
let bus = ctrl.bus();
|
let bus = ctrl.bus();
|
||||||
CtrlGraphics::do_vendor_tasks(
|
CtrlGraphics::do_vendor_tasks(
|
||||||
@@ -162,7 +161,7 @@ fn start_daemon() -> Result<(), Box<dyn Error>> {
|
|||||||
let devices = ctrl.devices();
|
let devices = ctrl.devices();
|
||||||
let bus = ctrl.bus();
|
let bus = ctrl.bus();
|
||||||
CtrlGraphics::do_vendor_tasks(
|
CtrlGraphics::do_vendor_tasks(
|
||||||
config.gfx_last_mode,
|
config.gfx_mode,
|
||||||
false,
|
false,
|
||||||
&devices,
|
&devices,
|
||||||
&bus,
|
&bus,
|
||||||
|
|||||||
Reference in New Issue
Block a user