gfx: asusd config option to not save compute/vfio mode switch

This commit is contained in:
Luke D. Jones
2021-04-20 21:10:23 +12:00
parent 6926aeed20
commit ab80b0742f
7 changed files with 124 additions and 31 deletions

View File

@@ -17,6 +17,7 @@ pub struct Config {
pub gfx_last_mode: GfxVendors,
pub gfx_managed: bool,
pub gfx_vfio_enable: bool,
pub gfx_save_compute_vfio: bool,
pub active_profile: String,
pub toggle_profiles: Vec<String>,
#[serde(skip)]
@@ -37,6 +38,7 @@ impl Default for Config {
gfx_last_mode: GfxVendors::Hybrid,
gfx_managed: true,
gfx_vfio_enable: false,
gfx_save_compute_vfio: true,
active_profile: "normal".into(),
toggle_profiles: vec!["normal".into(), "boost".into(), "silent".into()],
curr_fan_mode: 0,

View File

@@ -28,6 +28,7 @@ impl ConfigV317 {
gfx_last_mode: GfxVendors::Hybrid,
gfx_managed: self.gfx_managed,
gfx_vfio_enable: false,
gfx_save_compute_vfio: false,
active_profile: self.active_profile,
toggle_profiles: self.toggle_profiles,
curr_fan_mode: self.curr_fan_mode,
@@ -56,6 +57,7 @@ impl ConfigV324 {
gfx_last_mode: GfxVendors::Hybrid,
gfx_managed: self.gfx_managed,
gfx_vfio_enable: false,
gfx_save_compute_vfio: false,
active_profile: self.active_profile,
toggle_profiles: self.toggle_profiles,
curr_fan_mode: self.curr_fan_mode,
@@ -85,6 +87,7 @@ impl ConfigV341 {
gfx_last_mode: GfxVendors::Hybrid,
gfx_managed: self.gfx_managed,
gfx_vfio_enable: false,
gfx_save_compute_vfio: false,
active_profile: self.active_profile,
toggle_profiles: self.toggle_profiles,
curr_fan_mode: self.curr_fan_mode,

View File

@@ -286,7 +286,7 @@ impl CtrlGraphics {
let mut base = MODPROBE_BASE.to_vec();
base.append(&mut MODPROBE_DRM_MODESET.to_vec());
base
},
}
GfxVendors::Vfio => Self::get_vfio_conf(devices),
GfxVendors::Integrated => MODPROBE_INTEGRATED.to_vec(),
GfxVendors::Compute => MODPROBE_BASE.to_vec(),
@@ -423,9 +423,13 @@ impl CtrlGraphics {
fn logout_required(&self, vendor: GfxVendors) -> GfxRequiredUserAction {
if let Ok(config) = self.config.lock() {
let current = config.gfx_mode;
if matches!(current, GfxVendors::Integrated | GfxVendors::Vfio | GfxVendors::Compute)
&& matches!(vendor, GfxVendors::Integrated | GfxVendors::Vfio | GfxVendors::Compute)
{
if matches!(
current,
GfxVendors::Integrated | GfxVendors::Vfio | GfxVendors::Compute
) && matches!(
vendor,
GfxVendors::Integrated | GfxVendors::Vfio | GfxVendors::Compute
) {
return GfxRequiredUserAction::None;
}
}
@@ -660,6 +664,13 @@ impl CtrlGraphics {
let bus = self.bus.clone();
Self::do_vendor_tasks(vendor, vfio_enable, &devices, &bus)?;
info!("GFX: Graphics mode changed to {}", <&str>::from(vendor));
if let Ok(config) = self.config.lock() {
if matches!(vendor, GfxVendors::Compute | GfxVendors::Vfio)
&& config.gfx_save_compute_vfio
{
Self::save_gfx_mode(vendor, self.config.clone());
}
}
}
// TODO: undo if failed? Save last mode, catch errors...
Ok(action_required)