From 439b006342a0ebe037b916e9acf85888491a1c5f Mon Sep 17 00:00:00 2001 From: "Luke D. Jones" Date: Sun, 6 Jun 2021 12:24:15 +1200 Subject: [PATCH] Force change to integrated if in nvidia or hybrid mode Force change to integrated if in nvidia or hybrid mode and user tries to switch to vfio or compute --- CHANGELOG.md | 2 ++ daemon/src/ctrl_gfx/controller.rs | 17 +++++++++++++++-- daemon/src/ctrl_leds/controller.rs | 2 +- 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 73cfd8d1..41b1ad4a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Added ability to fade in/out gifs and images for anime. This does break anime configs. See manual for details. - Added task to CtrlLed to set the keyboard LED brightness on wake from suspend + requires a kernel patch which will be upstreamed and in fedora rog kernel +- Make gfx change from nvidia to vfio/compute also force-change to integrated _then_ + to requested mode # [3.6.1] - 2021-05-25 ### Changed diff --git a/daemon/src/ctrl_gfx/controller.rs b/daemon/src/ctrl_gfx/controller.rs index 6301b180..ad5d0cc2 100644 --- a/daemon/src/ctrl_gfx/controller.rs +++ b/daemon/src/ctrl_gfx/controller.rs @@ -548,8 +548,21 @@ impl CtrlGraphics { false }; - Self::do_vendor_tasks(vendor, vfio_enable, &devices, &bus)?; - Self::do_display_manager_action("restart")?; + // Need to change to integrated before we can change to vfio or compute + if let Ok(config) = config.try_lock() { + if matches!(vendor, GfxVendors::Compute | GfxVendors::Vfio) + && matches!(config.gfx_mode, GfxVendors::Nvidia | GfxVendors::Hybrid) + { + Self::do_vendor_tasks(GfxVendors::Integrated, vfio_enable, &devices, &bus)?; + Self::do_display_manager_action("restart")?; + sleep(Duration::from_millis(1000)); // Allow some time for the desktop to start + Self::do_vendor_tasks(vendor, vfio_enable, &devices, &bus)?; + } + } else { + Self::do_vendor_tasks(vendor, vfio_enable, &devices, &bus)?; + Self::do_display_manager_action("restart")?; + } + // Save selected mode in case of reboot Self::save_gfx_mode(vendor, config); info!("GFX thread: display-manager started"); diff --git a/daemon/src/ctrl_leds/controller.rs b/daemon/src/ctrl_leds/controller.rs index cce40c3e..15445858 100644 --- a/daemon/src/ctrl_leds/controller.rs +++ b/daemon/src/ctrl_leds/controller.rs @@ -17,7 +17,7 @@ use rog_aura::{ AuraEffect, LedBrightness, LED_MSG_LEN, }; use rog_types::supported::LedSupportedFunctions; -use std::{fs::OpenOptions, thread::{self, spawn}, time::Duration}; +use std::{fs::OpenOptions, thread::spawn}; use std::io::{Read, Write}; use std::path::Path; use std::sync::Arc;