mirror of
https://github.com/ilya-zlobintsev/LACT.git
synced 2025-02-25 18:55:26 -06:00
fix: apply pstates correctly when clocks settings are used (#437)
* fix: apply pstates after clocks table and other settings * fix: take vram clock ratio into account for pstates
This commit is contained in:
@@ -873,18 +873,6 @@ impl GpuController for AmdGpuController {
|
||||
}
|
||||
}
|
||||
|
||||
for (kind, states) in &config.power_states {
|
||||
if config.performance_level != Some(PerformanceLevel::Manual) {
|
||||
return Err(anyhow!(
|
||||
"Performance level has to be set to `manual` to configure power states"
|
||||
));
|
||||
}
|
||||
|
||||
self.handle
|
||||
.set_enabled_power_levels(*kind, states)
|
||||
.with_context(|| format!("Could not set {kind:?} power states"))?;
|
||||
}
|
||||
|
||||
if config.fan_control_enabled {
|
||||
if let Some(ref settings) = config.fan_control_settings {
|
||||
match settings.mode {
|
||||
@@ -1017,6 +1005,18 @@ impl GpuController for AmdGpuController {
|
||||
handle.commit()?;
|
||||
}
|
||||
|
||||
for (kind, states) in &config.power_states {
|
||||
if config.performance_level != Some(PerformanceLevel::Manual) {
|
||||
return Err(anyhow!(
|
||||
"Performance level has to be set to `manual` to configure power states"
|
||||
));
|
||||
}
|
||||
|
||||
self.handle
|
||||
.set_enabled_power_levels(*kind, states)
|
||||
.with_context(|| format!("Could not set {kind:?} power states"))?;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
})
|
||||
}
|
||||
|
||||
@@ -121,6 +121,8 @@ impl OcPage {
|
||||
.map(|info| info.vram_clock_ratio)
|
||||
.unwrap_or(1.0);
|
||||
|
||||
self.power_states_frame
|
||||
.set_vram_clock_ratio(vram_clock_ratio);
|
||||
self.stats_section.set_vram_clock_ratio(vram_clock_ratio);
|
||||
self.clocks_frame.set_vram_clock_ratio(vram_clock_ratio);
|
||||
}
|
||||
|
||||
@@ -26,8 +26,10 @@ impl PowerStatesFrame {
|
||||
imp.expander.set_expanded(false);
|
||||
}
|
||||
|
||||
imp.core_states_list.set_power_states(states.core, "MHz");
|
||||
imp.vram_states_list.set_power_states(states.vram, "MHz");
|
||||
imp.core_states_list
|
||||
.set_power_states(states.core, "MHz", 1.0);
|
||||
imp.vram_states_list
|
||||
.set_power_states(states.vram, "MHz", self.vram_clock_ratio());
|
||||
}
|
||||
|
||||
pub fn connect_values_changed<F: Fn() + 'static + Clone>(&self, f: F) {
|
||||
@@ -76,7 +78,7 @@ mod imp {
|
||||
},
|
||||
CompositeTemplate, Expander,
|
||||
};
|
||||
use std::sync::atomic::AtomicBool;
|
||||
use std::{cell::Cell, sync::atomic::AtomicBool};
|
||||
|
||||
#[derive(CompositeTemplate, Default, Properties)]
|
||||
#[properties(wrapper_type = super::PowerStatesFrame)]
|
||||
@@ -91,6 +93,8 @@ mod imp {
|
||||
|
||||
#[property(get, set)]
|
||||
configurable: AtomicBool,
|
||||
#[property(get, set)]
|
||||
vram_clock_ratio: Cell<f64>,
|
||||
}
|
||||
|
||||
#[glib::object_subclass]
|
||||
|
||||
@@ -31,9 +31,15 @@ impl PowerStatesList {
|
||||
.collect()
|
||||
}
|
||||
|
||||
pub fn set_power_states(&self, power_states: Vec<PowerState>, value_suffix: &str) {
|
||||
pub fn set_power_states(
|
||||
&self,
|
||||
power_states: Vec<PowerState>,
|
||||
value_suffix: &str,
|
||||
value_ratio: f64,
|
||||
) {
|
||||
let store = gio::ListStore::new::<PowerStateRow>();
|
||||
for (i, state) in power_states.into_iter().enumerate() {
|
||||
for (i, mut state) in power_states.into_iter().enumerate() {
|
||||
state.value = (state.value as f64 * value_ratio) as u64;
|
||||
let index = u8::try_from(i).expect("Power state index doesn't fit in u8?");
|
||||
let row = PowerStateRow::new(state, index, value_suffix);
|
||||
store.append(&row);
|
||||
|
||||
Reference in New Issue
Block a user