gfx: partial save and recover of mode change

Properly set and recover to last mode for g-sync laptops

Partial close of #75
This commit is contained in:
Luke D Jones
2021-04-12 10:45:00 +12:00
parent 59f54b76f6
commit 64d99a3e05
4 changed files with 51 additions and 109 deletions

View File

@@ -105,9 +105,10 @@ fn start_daemon() -> Result<(), Box<dyn Error>> {
// Need to check if a laptop has the dedicated gfx switch
if CtrlRogBios::has_dedicated_gfx_toggle() {
if let Ok(ded) = CtrlRogBios::get_gfx_mode() {
if let Ok(vendor) = ctrl.get_gfx_mode() {
if ded == 1 && vendor != GfxVendors::Nvidia {
if let Ok(mut config) = config.lock() {
if ded == 1 {
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 bus = ctrl.bus();
CtrlGraphics::do_vendor_tasks(
@@ -118,6 +119,14 @@ fn start_daemon() -> Result<(), Box<dyn Error>> {
)?;
} else if ded == 0 {
info!("Dedicated GFX toggle is off");
let devices = ctrl.devices();
let bus = ctrl.bus();
CtrlGraphics::do_vendor_tasks(
config.gfx_last_mode,
false,
&devices,
&bus,
)?;
}
}
}