Allow max == min, fix SMT bug, compile missing .mo files

This commit is contained in:
NGnius (Graham) 2023-01-18 17:54:33 -05:00
parent df69a5a2db
commit aff5005ca9
15 changed files with 71 additions and 18 deletions

2
backend/Cargo.lock generated
View file

@ -826,7 +826,7 @@ dependencies = [
[[package]] [[package]]
name = "powertools-rs" name = "powertools-rs"
version = "1.1.0" version = "1.1.0-beta4"
dependencies = [ dependencies = [
"async-trait", "async-trait",
"limits_core", "limits_core",

View file

@ -1,6 +1,6 @@
[package] [package]
name = "powertools-rs" name = "powertools-rs"
version = "1.1.0" version = "1.1.0-beta4"
edition = "2021" edition = "2021"
authors = ["NGnius (Graham) <ngniusness@gmail.com>"] authors = ["NGnius (Graham) <ngniusness@gmail.com>"]
description = "Backend (superuser) functionality for PowerTools" description = "Backend (superuser) functionality for PowerTools"

View file

@ -145,6 +145,7 @@ impl CpuMessage {
matches!(self, matches!(self,
Self::SetCpuOnline(_, _) Self::SetCpuOnline(_, _)
| Self::SetCpusOnline(_) | Self::SetCpusOnline(_)
| Self::SetSmt(_, _)
| Self::SetClockLimits(_, _) | Self::SetClockLimits(_, _)
| Self::SetCpuGovernor(_, _) | Self::SetCpuGovernor(_, _)
| Self::SetCpusGovernor(_) | Self::SetCpusGovernor(_)

View file

@ -256,7 +256,8 @@ impl Cpu {
}, },
)?; )?;
// min clock // min clock
let payload_min = format!("p {} 0 {}\n", self.index / 2, clock_limits.min); let valid_min = if clock_limits.min < self.limits.clock_min.min {self.limits.clock_min.min} else {clock_limits.min};
let payload_min = format!("p {} 0 {}\n", self.index / 2, valid_min);
usdpl_back::api::files::write_single(CPU_CLOCK_LIMITS_PATH, &payload_min).map_err( usdpl_back::api::files::write_single(CPU_CLOCK_LIMITS_PATH, &payload_min).map_err(
|e| SettingError { |e| SettingError {
msg: format!( msg: format!(
@ -339,7 +340,7 @@ impl Cpu {
fn limits(&self) -> crate::api::CpuLimits { fn limits(&self) -> crate::api::CpuLimits {
crate::api::CpuLimits { crate::api::CpuLimits {
clock_min_limits: Some(RangeLimit { clock_min_limits: Some(RangeLimit {
min: self.limits.clock_min.min, min: self.limits.clock_max.min, // allows min to be set by max (it's weird, blame the kernel)
max: self.limits.clock_min.max max: self.limits.clock_min.max
}), }),
clock_max_limits: Some(RangeLimit { clock_max_limits: Some(RangeLimit {

View file

@ -1,7 +1,7 @@
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use crate::settings::MinMax; use crate::settings::MinMax;
const OC_LIMITS_FILEPATH: &str = "./pt_oc.json"; const OC_LIMITS_FILEPATH: &str = "pt_oc.json";
#[derive(Serialize, Deserialize, Debug)] #[derive(Serialize, Deserialize, Debug)]
pub(super) struct OverclockLimits { pub(super) struct OverclockLimits {
@ -23,7 +23,7 @@ impl Default for OverclockLimits {
impl OverclockLimits { impl OverclockLimits {
/// (Self, is_default) /// (Self, is_default)
pub fn load_or_default() -> (Self, bool) { pub fn load_or_default() -> (Self, bool) {
let path = std::path::Path::new(OC_LIMITS_FILEPATH); let path = oc_limits_filepath();
if path.exists() { if path.exists() {
log::info!("Steam Deck limits file {} found", path.display()); log::info!("Steam Deck limits file {} found", path.display());
let mut file = match std::fs::File::open(&path) { let mut file = match std::fs::File::open(&path) {
@ -86,7 +86,7 @@ impl Default for CpuLimits {
fn default() -> Self { fn default() -> Self {
Self { Self {
clock_min: MinMax { min: 1400, max: 3500 }, clock_min: MinMax { min: 1400, max: 3500 },
clock_max: MinMax { min: 500, max: 3500 } clock_max: MinMax { min: 400, max: 3500 }
} }
} }
} }
@ -109,3 +109,7 @@ impl Default for GpuLimits {
} }
} }
} }
fn oc_limits_filepath() -> std::path::PathBuf {
crate::utility::settings_dir().join(OC_LIMITS_FILEPATH)
}

View file

@ -1,6 +1,6 @@
{ {
"name": "PowerTools", "name": "PowerTools",
"version": "1.1.0", "version": "1.1.0-beta4",
"description": "Power tweaks for power users", "description": "Power tweaks for power users",
"scripts": { "scripts": {
"build": "shx rm -rf dist && rollup -c", "build": "shx rm -rf dist && rollup -c",

47
pt_oc.json Normal file
View file

@ -0,0 +1,47 @@
{
"battery": {
"charge_rate": {"min": 250, "max": 2500}
},
"cpus": {
"cpus": [
{
"clock_min": {"min": 1400, "max": 3500},
"clock_max": {"min": 500, "max": 3500}
},
{
"clock_min": {"min": 1400, "max": 3500},
"clock_max": {"min": 500, "max": 3500}
},
{
"clock_min": {"min": 1400, "max": 3500},
"clock_max": {"min": 500, "max": 3500}
},
{
"clock_min": {"min": 1400, "max": 3500},
"clock_max": {"min": 500, "max": 3500}
},
{
"clock_min": {"min": 1400, "max": 3500},
"clock_max": {"min": 500, "max": 3500}
},
{
"clock_min": {"min": 1400, "max": 3500},
"clock_max": {"min": 500, "max": 3500}
},
{
"clock_min": {"min": 1400, "max": 3500},
"clock_max": {"min": 500, "max": 3500}
},
{
"clock_min": {"min": 1400, "max": 3500},
"clock_max": {"min": 500, "max": 3500}
}
]
},
"gpu": {
"fast_ppt": {"min": 1000000, "max": 30000000},
"slow_ppt": {"min": 1000000, "max": 29000000},
"clock_min": {"min": 200, "max": 1600},
"clock_max": {"min": 200, "max": 1600}
}
}

View file

@ -173,7 +173,7 @@ export class Cpus extends Component<{}, CpuState> {
backend.log(backend.LogLevel.Debug, "Min freq slider is now " + freq.toString()); backend.log(backend.LogLevel.Debug, "Min freq slider is now " + freq.toString());
const freqNow = get_value(CLOCK_MIN_CPU); const freqNow = get_value(CLOCK_MIN_CPU);
const maxNow = get_value(CLOCK_MAX_CPU); const maxNow = get_value(CLOCK_MAX_CPU);
if (freq != freqNow && ((maxNow != null && freq > maxNow) || maxNow == null)) { if (freq != freqNow && ((maxNow != null && freq <= maxNow) || maxNow == null)) {
set_value(CLOCK_MIN_CPU, freq); set_value(CLOCK_MIN_CPU, freq);
for (let i = 0; i < total_cpus; i++) { for (let i = 0; i < total_cpus; i++) {
backend.resolve(backend.setCpuClockLimits(i, freq, get_value(CLOCK_MAX_CPU)), backend.resolve(backend.setCpuClockLimits(i, freq, get_value(CLOCK_MAX_CPU)),
@ -204,7 +204,7 @@ export class Cpus extends Component<{}, CpuState> {
backend.log(backend.LogLevel.Debug, "Max freq slider is now " + freq.toString()); backend.log(backend.LogLevel.Debug, "Max freq slider is now " + freq.toString());
const freqNow = get_value(CLOCK_MAX_CPU); const freqNow = get_value(CLOCK_MAX_CPU);
const minNow = get_value(CLOCK_MIN_CPU); const minNow = get_value(CLOCK_MIN_CPU);
if (freq != freqNow && ((minNow != null && freq > minNow) || minNow == null)) { if (freq != freqNow && ((minNow != null && freq >= minNow) || minNow == null)) {
set_value(CLOCK_MAX_CPU, freq); set_value(CLOCK_MAX_CPU, freq);
for (let i = 0; i < total_cpus; i++) { for (let i = 0; i < total_cpus; i++) {
backend.resolve(backend.setCpuClockLimits(i, get_value(CLOCK_MIN_CPU), freq), backend.resolve(backend.setCpuClockLimits(i, get_value(CLOCK_MIN_CPU), freq),
@ -303,7 +303,7 @@ export class Cpus extends Component<{}, CpuState> {
onChange={(freq: number) => { onChange={(freq: number) => {
backend.log(backend.LogLevel.Debug, "Min freq slider for " + advancedCpu.toString() + " is now " + freq.toString()); backend.log(backend.LogLevel.Debug, "Min freq slider for " + advancedCpu.toString() + " is now " + freq.toString());
const freqNow = get_value(CLOCK_MIN_MAX_CPU)[advancedCpuIndex] as MinMax; const freqNow = get_value(CLOCK_MIN_MAX_CPU)[advancedCpuIndex] as MinMax;
if (freq != freqNow.min && ((freqNow.max != null && freqNow.max > freq) || freqNow.max == null)) { if (freq != freqNow.min && ((freqNow.max != null && freq <= freqNow.max) || freqNow.max == null)) {
backend.resolve(backend.setCpuClockLimits(advancedCpuIndex, freq, freqNow.max!), backend.resolve(backend.setCpuClockLimits(advancedCpuIndex, freq, freqNow.max!),
(limits: number[]) => { (limits: number[]) => {
const clocks = get_value(CLOCK_MIN_MAX_CPU) as MinMax[]; const clocks = get_value(CLOCK_MIN_MAX_CPU) as MinMax[];
@ -328,7 +328,7 @@ export class Cpus extends Component<{}, CpuState> {
onChange={(freq: number) => { onChange={(freq: number) => {
backend.log(backend.LogLevel.Debug, "Max freq slider for " + advancedCpu.toString() + " is now " + freq.toString()); backend.log(backend.LogLevel.Debug, "Max freq slider for " + advancedCpu.toString() + " is now " + freq.toString());
const freqNow = get_value(CLOCK_MIN_MAX_CPU)[advancedCpuIndex] as MinMax; const freqNow = get_value(CLOCK_MIN_MAX_CPU)[advancedCpuIndex] as MinMax;
if (freq != freqNow.max && ((freqNow.min != null && freq > freqNow.min) || freqNow.min == null)) { if (freq != freqNow.max && ((freqNow.min != null && freq >= freqNow.min) || freqNow.min == null)) {
backend.resolve(backend.setCpuClockLimits(advancedCpuIndex, freqNow.min!, freq), backend.resolve(backend.setCpuClockLimits(advancedCpuIndex, freqNow.min!, freq),
(limits: number[]) => { (limits: number[]) => {
const clocks = get_value(CLOCK_MIN_MAX_CPU) as MinMax[]; const clocks = get_value(CLOCK_MIN_MAX_CPU) as MinMax[];

View file

@ -145,7 +145,7 @@ export class Gpu extends Component<{}> {
backend.log(backend.LogLevel.Debug, "GPU Clock Min is now " + val.toString()); backend.log(backend.LogLevel.Debug, "GPU Clock Min is now " + val.toString());
const valNow = get_value(CLOCK_MIN_GPU); const valNow = get_value(CLOCK_MIN_GPU);
const maxNow = get_value(CLOCK_MAX_GPU); const maxNow = get_value(CLOCK_MAX_GPU);
if (val != valNow && ((maxNow != null && val < maxNow) || maxNow == null)) { if (val != valNow && ((maxNow != null && val <= maxNow) || maxNow == null)) {
backend.resolve(backend.setGpuClockLimits(val, get_value(CLOCK_MAX_GPU)), backend.resolve(backend.setGpuClockLimits(val, get_value(CLOCK_MAX_GPU)),
(limits: number[]) => { (limits: number[]) => {
set_value(CLOCK_MIN_GPU, limits[0]); set_value(CLOCK_MIN_GPU, limits[0]);
@ -169,7 +169,7 @@ export class Gpu extends Component<{}> {
backend.log(backend.LogLevel.Debug, "GPU Clock Max is now " + val.toString()); backend.log(backend.LogLevel.Debug, "GPU Clock Max is now " + val.toString());
const valNow = get_value(CLOCK_MAX_GPU); const valNow = get_value(CLOCK_MAX_GPU);
const minNow = get_value(CLOCK_MIN_GPU); const minNow = get_value(CLOCK_MIN_GPU);
if (val != valNow && ((minNow != null && val > minNow) || minNow == null)) { if (val != valNow && ((minNow != null && val >= minNow) || minNow == null)) {
backend.resolve(backend.setGpuClockLimits(get_value(CLOCK_MIN_GPU), val), backend.resolve(backend.setGpuClockLimits(get_value(CLOCK_MIN_GPU), val),
(limits: number[]) => { (limits: number[]) => {
set_value(CLOCK_MIN_GPU, limits[0]); set_value(CLOCK_MIN_GPU, limits[0]);

BIN
translations/es-ES.mo Normal file

Binary file not shown.

View file

@ -9,10 +9,10 @@ msgstr ""
"Project-Id-Version: v1.1\n" "Project-Id-Version: v1.1\n"
"Report-Msgid-Bugs-To: https://github.com/NGnius/PowerTools/issues\n" "Report-Msgid-Bugs-To: https://github.com/NGnius/PowerTools/issues\n"
"POT-Creation-Date: 2023-01-09 19:52-0500\n" "POT-Creation-Date: 2023-01-09 19:52-0500\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "PO-Revision-Date: 2023-01-18 19:52-0500\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Last-Translator: \n"
"Language-Team: LANGUAGE <LL@li.org>\n" "Language-Team: \n"
"Language: \n" "Language: es-ES\n"
"MIME-Version: 1.0\n" "MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=utf-8\n" "Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n" "Content-Transfer-Encoding: 8bit\n"

BIN
translations/zh-HK.mo Normal file

Binary file not shown.