Save clocks/voltage modification

This commit is contained in:
Ilya Zlobintsev 2020-11-22 13:29:05 +02:00
parent 65780bb881
commit 6dc0f7b13f
2 changed files with 17 additions and 1 deletions

View File

@ -41,6 +41,8 @@ pub struct GpuConfig {
pub fan_curve: BTreeMap<i32, f64>,
pub power_cap: i32,
pub power_profile: PowerProfile,
pub gpu_power_states: BTreeMap<u32, (i32, i32)>, //<id, (clockspeed, voltage)>
pub vram_power_states: BTreeMap<u32, (i32, i32)>,
}
impl GpuConfig {
@ -57,6 +59,8 @@ impl GpuConfig {
fan_control_enabled: false,
power_cap: -1,
power_profile: PowerProfile::Auto,
gpu_power_states: BTreeMap::new(),
vram_power_states: BTreeMap::new(),
}
}
}

View File

@ -157,7 +157,15 @@ impl GpuController {
_ => None,
};
self.set_power_profile(config.power_profile).unwrap();
self.set_power_profile(config.power_profile.clone()).unwrap();
for (num, (clockspeed, voltage)) in &config.gpu_power_states {
self.set_gpu_power_state(*num, *clockspeed, Some(*voltage)).expect("Failed to load power states");
}
for (num, (clockspeed, voltage)) in &config.vram_power_states {
self.set_vram_power_state(*num, *clockspeed, Some(*voltage)).expect("Failed to load power states");
}
}
pub fn get_config(&self) -> GpuConfig {
@ -521,6 +529,8 @@ impl GpuController {
fs::write(self.hw_path.join("pp_od_clk_voltage"), line)?;
self.config.gpu_power_states.insert(num, (clockspeed, voltage.unwrap()));
Ok(())
}
@ -537,6 +547,8 @@ impl GpuController {
fs::write(self.hw_path.join("pp_od_clk_voltage"), line)?;
self.config.vram_power_states.insert(num, (clockspeed, voltage.unwrap()));
Ok(())
}