From f520e381a90fa2b9c35ffb0866b1edbb05a749d9 Mon Sep 17 00:00:00 2001 From: "Luke D. Jones" Date: Sat, 29 May 2021 11:42:15 +1200 Subject: [PATCH] Attempt to provide more info to users gfx switching --- CHANGELOG.md | 4 ++++ daemon/src/ctrl_gfx/controller.rs | 19 ++++++++++++++++++- daemon/src/ctrl_rog_bios.rs | 5 +++-- 3 files changed, 25 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1fa0ec9d..40b9dad8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ## [Unreleased] +### Changed +- Set PM to auto for Nvidia always +- Extra info output for gfx dev scan +- Extra info in log for G-Sync to help prevent user confusion around gfx switching # [3.6.1] - 2021-05-25 ### Changed diff --git a/daemon/src/ctrl_gfx/controller.rs b/daemon/src/ctrl_gfx/controller.rs index b24504df..474c28bc 100644 --- a/daemon/src/ctrl_gfx/controller.rs +++ b/daemon/src/ctrl_gfx/controller.rs @@ -1,3 +1,4 @@ +use sysfs_class::RuntimePM; use ::zbus::Connection; use ctrl_gfx::error::GfxError; use ctrl_gfx::*; @@ -66,7 +67,10 @@ impl CtrlGraphics { let mut nvidia = Vec::new(); let mut other = Vec::new(); for dev in devs.iter() { - let c = dev.class()?; + let c = dev.class().map_err(|err|{ + error!("GFX: device error: {}, {}", dev.path().to_string_lossy(), err); + err + })?; if 0x03 == (c >> 16) & 0xFF { match dev.vendor()? { 0x1002 => { @@ -75,6 +79,7 @@ impl CtrlGraphics { } 0x10DE => { info!("GFX: {}: NVIDIA graphics", dev.id()); + dev.set_runtime_pm(sysfs_class::RuntimePowerManagement::On)?; nvidia.push(GraphicsDevice::new(dev.id().to_owned(), functions(&dev))); } 0x8086 => { @@ -400,6 +405,18 @@ impl CtrlGraphics { ) -> Result<(), RogError> { // Rescan before doing remove or add drivers bus.rescan()?; + // Make sure the power management is set to auto for nvidia devices + let devs = PciDevice::all()?; + for dev in devs.iter() { + let c = dev.class().map_err(|err|{ + error!("GFX: device error: {}, {}", dev.path().to_string_lossy(), err); + err + })?; + if 0x03 == (c >> 16) & 0xFF && dev.vendor()? == 0x10DE { + info!("GFX: {}: NVIDIA graphics, setting PM to auto", dev.id()); + dev.set_runtime_pm(sysfs_class::RuntimePowerManagement::On)?; + } + } // Self::write_xorg_conf(vendor)?; // Write different modprobe to enable boot control to work diff --git a/daemon/src/ctrl_rog_bios.rs b/daemon/src/ctrl_rog_bios.rs index f3c7d6bf..57394284 100644 --- a/daemon/src/ctrl_rog_bios.rs +++ b/daemon/src/ctrl_rog_bios.rs @@ -121,7 +121,8 @@ impl CtrlRogBios { CtrlRogBios::set_path_mutable(ASUS_SWITCH_GRAPHIC_MODE)?; } Err(err) => { - info!("ROG Switchable Graphics (bios) not detected: {}", err); + info!("G-Sync Switchable Graphics not detected: {}", err); + info!("If your laptop is not a G-Sync enabled laptop then you can ignore this. Standard graphics switching will still work."); } } @@ -130,7 +131,7 @@ impl CtrlRogBios { CtrlRogBios::set_path_mutable(ASUS_POST_LOGO_SOUND)?; } Err(err) => { - info!("ROG boot sound toggle (bios) not detected: {}", err); + info!("Switch for POST boot sound not detected: {}", err); } }