Fix incorrect CPU defaults loaded by defaults button
This commit is contained in:
parent
aff5005ca9
commit
ea89de01d7
8 changed files with 58 additions and 18 deletions
|
@ -122,6 +122,27 @@ pub fn set_smt(
|
|||
}
|
||||
}
|
||||
|
||||
pub fn get_smt(
|
||||
sender: Sender<ApiMessage>,
|
||||
) -> impl AsyncCallable {
|
||||
let sender = Arc::new(Mutex::new(sender)); // Sender is not Sync; this is required for safety
|
||||
let getter = move || {
|
||||
let sender2 = sender.clone();
|
||||
move || {
|
||||
let (tx, rx) = mpsc::channel();
|
||||
let callback = move |value: bool| tx.send(value).expect("get_smt callback send failed");
|
||||
sender2.lock().unwrap().send(ApiMessage::Cpu(CpuMessage::GetSmt(Box::new(callback)))).expect("get_smt send failed");
|
||||
rx.recv().expect("get_smt callback recv failed")
|
||||
}
|
||||
};
|
||||
super::async_utils::AsyncIshGetter {
|
||||
set_get: getter,
|
||||
trans_getter: |result| {
|
||||
vec![result.into()]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn get_cpus_online(
|
||||
sender: Sender<ApiMessage>,
|
||||
) -> impl AsyncCallable {
|
||||
|
|
|
@ -57,6 +57,7 @@ pub enum CpuMessage {
|
|||
SetCpuOnline(usize, bool),
|
||||
SetCpusOnline(Vec<bool>),
|
||||
SetSmt(bool, Callback<Vec<bool>>),
|
||||
GetSmt(Callback<bool>),
|
||||
GetCpusOnline(Callback<Vec<bool>>),
|
||||
SetClockLimits(usize, Option<MinMax<u64>>),
|
||||
GetClockLimits(usize, Callback<Option<MinMax<u64>>>),
|
||||
|
@ -113,7 +114,10 @@ impl CpuMessage {
|
|||
result.push(*settings.cpus()[i].online());
|
||||
}
|
||||
cb(result);
|
||||
}
|
||||
},
|
||||
Self::GetSmt(cb) => {
|
||||
cb(*settings.smt());
|
||||
},
|
||||
Self::GetCpusOnline(cb) => {
|
||||
let mut result = Vec::with_capacity(settings.len());
|
||||
for cpu in settings.cpus() {
|
||||
|
|
|
@ -125,6 +125,10 @@ fn main() -> Result<(), ()> {
|
|||
"CPU_set_smt",
|
||||
api::cpu::set_smt(api_sender.clone())
|
||||
)
|
||||
.register_async(
|
||||
"CPU_get_smt",
|
||||
api::cpu::get_smt(api_sender.clone())
|
||||
)
|
||||
.register(
|
||||
"CPU_set_clock_limits",
|
||||
api::cpu::set_clock_limits(api_sender.clone())
|
||||
|
|
|
@ -91,7 +91,7 @@ impl Cpus {
|
|||
if let Some(max_cpu) = Self::cpu_count() {
|
||||
let mut sys_cpus = Vec::with_capacity(max_cpu);
|
||||
for i in 0..max_cpu {
|
||||
sys_cpus.push(Cpu::from_sys(i, oc_limits.cpus.get(i).map(|x| x.to_owned()).unwrap_or_default()));
|
||||
sys_cpus.push(Cpu::system_default(i, oc_limits.cpus.get(i).map(|x| x.to_owned()).unwrap_or_default()));
|
||||
}
|
||||
let (_, can_smt) = Self::system_smt_capabilities();
|
||||
Self {
|
||||
|
@ -325,7 +325,7 @@ impl Cpu {
|
|||
}
|
||||
}
|
||||
|
||||
fn from_sys(cpu_index: usize, oc_limits: CpuLimits) -> Self {
|
||||
/*fn from_sys(cpu_index: usize, oc_limits: CpuLimits) -> Self {
|
||||
Self {
|
||||
online: usdpl_back::api::files::read_single(cpu_online_path(cpu_index)).unwrap_or(1u8) != 0,
|
||||
clock_limits: None,
|
||||
|
@ -335,6 +335,17 @@ impl Cpu {
|
|||
index: cpu_index,
|
||||
state: crate::state::steam_deck::Cpu::default(),
|
||||
}
|
||||
}*/
|
||||
|
||||
fn system_default(cpu_index: usize, oc_limits: CpuLimits) -> Self {
|
||||
Self {
|
||||
online: true,
|
||||
clock_limits: None,
|
||||
governor: "schedutil".to_owned(),
|
||||
limits: oc_limits,
|
||||
index: cpu_index,
|
||||
state: crate::state::steam_deck::Cpu::default(),
|
||||
}
|
||||
}
|
||||
|
||||
fn limits(&self) -> crate::api::CpuLimits {
|
||||
|
|
|
@ -132,6 +132,10 @@ export async function setCpuSmt(status: boolean): Promise<boolean[]> {
|
|||
return await call_backend("CPU_set_smt", [status]);
|
||||
}
|
||||
|
||||
export async function getCpuSmt(): Promise<boolean> {
|
||||
return await call_backend("CPU_get_smt", []);
|
||||
}
|
||||
|
||||
/*export async function getCpuCount(): Promise<number> {
|
||||
return (await call_backend("CPU_count", []))[0];
|
||||
}*/
|
||||
|
|
|
@ -25,33 +25,28 @@ import { set_value, get_value } from "usdpl-front";
|
|||
|
||||
interface CpuState {
|
||||
reloadThingy: string;
|
||||
advancedCpu: number;
|
||||
advancedMode: boolean;
|
||||
}
|
||||
|
||||
let advancedMode = false;
|
||||
let advancedCpu = 1;
|
||||
|
||||
export class Cpus extends Component<{}, CpuState> {
|
||||
constructor(props: {}) {
|
||||
super(props);
|
||||
this.state = {
|
||||
reloadThingy: "/shrug",
|
||||
advancedCpu: 1,
|
||||
advancedMode: false,
|
||||
};
|
||||
}
|
||||
|
||||
render() {
|
||||
const reloadGUI = (x: string) => this.setState((state) => {
|
||||
const reloadGUI = (x: string) => this.setState((_state) => {
|
||||
return {
|
||||
reloadThingy: x,
|
||||
advancedCpu: state.advancedCpu,
|
||||
advancedMode: state.advancedMode,
|
||||
};
|
||||
});
|
||||
|
||||
const total_cpus = (get_value(LIMITS_INFO) as backend.SettingsLimits | null)?.cpu.count ?? 8;
|
||||
const advancedCpuIndex = this.state.advancedCpu - 1;
|
||||
const advancedCpu = this.state.advancedCpu;
|
||||
const advancedMode = this.state.advancedMode;
|
||||
const advancedCpuIndex = advancedCpu - 1;
|
||||
const smtAllowed = (get_value(LIMITS_INFO) as backend.SettingsLimits | null)?.cpu.smt_capable ?? true;
|
||||
|
||||
const governorOptions: SingleDropdownOption[] = (get_value(LIMITS_INFO) as backend.SettingsLimits).cpu.cpus[advancedCpuIndex].governors.map((elem) => {return {
|
||||
|
@ -70,12 +65,10 @@ export class Cpus extends Component<{}, CpuState> {
|
|||
label={tr("Advanced")}
|
||||
description={tr("Enables per-thread configuration")}
|
||||
onChange={(advanced: boolean) => {
|
||||
//advancedMode = advanced;
|
||||
advancedMode = advanced;
|
||||
this.setState((state) => {
|
||||
return {
|
||||
reloadThingy: state.reloadThingy,
|
||||
advancedCpu: state.advancedCpu,
|
||||
advancedMode: advanced,
|
||||
};
|
||||
});
|
||||
}}
|
||||
|
@ -232,11 +225,10 @@ export class Cpus extends Component<{}, CpuState> {
|
|||
min={1}
|
||||
showValue={true}
|
||||
onChange={(cpuNum: number) => {
|
||||
advancedCpu = cpuNum;
|
||||
this.setState((state) => {
|
||||
return {
|
||||
reloadThingy: state.reloadThingy,
|
||||
advancedCpu: cpuNum,
|
||||
advancedMode: state.advancedMode,
|
||||
};
|
||||
});
|
||||
}}
|
||||
|
|
|
@ -117,6 +117,9 @@ const reload = function() {
|
|||
set_value(ONLINE_CPUS, count);
|
||||
set_value(SMT_CPU, statii.length > 3 && statii[0] == statii[1] && statii[2] == statii[3]);
|
||||
});
|
||||
backend.resolve(backend.getCpuSmt(), (smt: boolean) => {
|
||||
set_value(SMT_CPU, smt);
|
||||
});
|
||||
backend.resolve(backend.getCpuClockLimits(0), (limits: number[]) => {
|
||||
set_value(CLOCK_MIN_CPU, limits[0]);
|
||||
set_value(CLOCK_MAX_CPU, limits[1]);
|
||||
|
|
1
translations/fr-FR.mo
Symbolic link
1
translations/fr-FR.mo
Symbolic link
|
@ -0,0 +1 @@
|
|||
fr-CA.mo
|
Loading…
Reference in a new issue