gfx: Remove option for vfio/compute save

This commit is contained in:
Luke D. Jones
2021-05-18 09:18:36 +12:00
parent 04c9285ee6
commit 7771c6b8da
4 changed files with 38 additions and 15 deletions

View File

@@ -17,7 +17,6 @@ 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)]
@@ -38,7 +37,6 @@ 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,
@@ -69,6 +67,11 @@ impl Config {
} else {
if let Ok(data) = serde_json::from_str(&buf) {
return data;
} else if let Ok(data) = serde_json::from_str::<ConfigV352>(&buf) {
let config = data.into_current();
config.write();
info!("Updated config version to: {}", VERSION);
return config;
} else if let Ok(data) = serde_json::from_str::<ConfigV341>(&buf) {
let config = data.into_current();
config.write();

View File

@@ -28,7 +28,6 @@ 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,
@@ -57,7 +56,6 @@ 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,
@@ -87,7 +85,6 @@ 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,
@@ -96,3 +93,35 @@ impl ConfigV341 {
}
}
}
#[derive(Deserialize, Serialize)]
pub struct ConfigV352 {
pub gfx_mode: GfxVendors,
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)]
pub curr_fan_mode: u8,
pub bat_charge_limit: u8,
pub power_profiles: BTreeMap<String, Profile>,
}
impl ConfigV352 {
pub(crate) fn into_current(self) -> Config {
Config {
gfx_mode: GfxVendors::Hybrid,
gfx_last_mode: GfxVendors::Hybrid,
gfx_managed: self.gfx_managed,
gfx_vfio_enable: false,
active_profile: self.active_profile,
toggle_profiles: self.toggle_profiles,
curr_fan_mode: self.curr_fan_mode,
bat_charge_limit: self.bat_charge_limit,
power_profiles: self.power_profiles,
}
}
}

View File

@@ -607,16 +607,6 @@ 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 matches!(vendor, GfxVendors::Compute | GfxVendors::Vfio) {
loop {
if let Ok(config) = self.config.try_lock() {
if config.gfx_save_compute_vfio {
Self::save_gfx_mode(vendor, self.config.clone());
}
return Ok(action_required);
}
}
}
}
// TODO: undo if failed? Save last mode, catch errors...
Ok(action_required)