Update 'Equivalent Commands'

NGnius 2023-10-09 16:30:11 +01:00
parent 046442ad9e
commit d1a668ec1f

@ -1,110 +1,116 @@
In case you still want some of the functionality, without the nice GUI, here's some equivalent commands. In case you still want some of the functionality, without the nice GUI, here's some equivalent commands.
These should all be run as superuser, i.e. run `sudo su` and then run these commands in that. These should all be run as superuser, i.e. run `sudo su` and then run these commands in that.
# Enable & Disable CPU threads NOTE: sysfs entries are subject to change with kernel updates. For example, hwmon indices may be incorrect if they were written for an older kernel. NGnius does not always keep this up to date with the latest numbers.
Enable: `echo 1 > /sys/devices/system/cpu/cpu{cpu_number}/online` where `{cpu_number}` is a number from 1 to 7 (inclusive). # Enable & Disable CPU threads
Disable: `echo 0 > /sys/devices/system/cpu/cpu{cpu_number}/online` where `{cpu_number}` is a number from 1 to 7 (inclusive). Enable: `echo 1 > /sys/devices/system/cpu/cpu{cpu_number}/online` where `{cpu_number}` is a number from 1 to 7 (inclusive).
NOTE: You cannot enable or disable cpu0, hence why there are only 7 in the range for 8 cpu threads. Disable: `echo 0 > /sys/devices/system/cpu/cpu{cpu_number}/online` where `{cpu_number}` is a number from 1 to 7 (inclusive).
# Enable & Disable CPU SMT NOTE: You cannot enable or disable cpu0, hence why there are only 7 in the range for 8 cpu threads.
Enable: `echo on > /sys/devices/system/cpu/smt/control`. # Enable & Disable CPU SMT
Disable: `echo off > /sys/devices/system/cpu/smt/control`. Enable: `echo on > /sys/devices/system/cpu/smt/control`.
# Enable & Disable CPU boost Disable: `echo off > /sys/devices/system/cpu/smt/control`.
Enable: `echo 1 > /sys/devices/system/cpu/cpufreq/boost` enables boost across all threads. # Enable & Disable CPU boost
Disable: `echo 0 > /sys/devices/system/cpu/cpufreq/boost` disables boost across all threads. Enable: `echo 1 > /sys/devices/system/cpu/cpufreq/boost` enables boost across all threads.
# Set CPU frequency Disable: `echo 0 > /sys/devices/system/cpu/cpufreq/boost` disables boost across all threads.
Refer to https://github.com/NGnius/PowerTools/issues/21 # Set CPU frequency
## Old method Refer to https://git.ngni.us/NG-SD-Plugins/PowerTools/issues/21
Use `cpupower` (usage: `cpupower --help`).
This is not how PowerTools does it, but it's a multi-step process which can involve changing the CPU governor. ## Old method
All that can be done automatically by `cpupower frequency-set --freq {frequency}` where `{frequency}` is `1.7G`, `2.4G` or `2.8G`. Use `cpupower` (usage: `cpupower --help`).
This is not how PowerTools does it, but it's a multi-step process which can involve changing the CPU governor.
# Set GPU Power All that can be done automatically by `cpupower frequency-set --freq {frequency}` where `{frequency}` is `1.7G`, `2.4G` or `2.8G`.
Set Slow Powerplay Table (PPT):`echo {microwatts} > /sys/class/hwmon/hwmon4/power1_cap` where `{microwatts}` is a wattage in millionths of a Watt. This doesn't seem to do a lot. # Set GPU Power
Set Fast Powerplay Table (PPT): `echo {microwatts} > /sys/class/hwmon/hwmon4/power2_cap` where `{microwatts}` is a wattage in millionths of a Watt. Set Slow Powerplay Table (PPT):`echo {microwatts} > /sys/class/hwmon/hwmon4/power1_cap` where `{microwatts}` is a wattage in millionths of a Watt. This doesn't seem to do a lot.
Get the entry limits for those two commands with `cat /sys/class/hwmon/hwmon4/power{number}_cap_max` where `{number}` is `1` (slowPPT) or `2` (fastPPT). Set Fast Powerplay Table (PPT): `echo {microwatts} > /sys/class/hwmon/hwmon4/power2_cap` where `{microwatts}` is a wattage in millionths of a Watt.
# Set GPU frequency Get the entry limits for those two commands with `cat /sys/class/hwmon/hwmon4/power{number}_cap_max` where `{number}` is `1` (slowPPT) or `2` (fastPPT).
Refer to https://github.com/NGnius/PowerTools/issues/21 # Set GPU frequency
# Set Fan speed Refer to https://git.ngni.us/NG-SD-Plugins/PowerTools/issues/21
NOTE: PowerTools no longer supports this, since [Fantastic](https://github.com/NGnius/Fantastic) does it much better. # Set Fan speed
Enable automatic control: `echo 0 > /sys/class/hwmon/hwmon5/recalculate` enables automatic fan control. NOTE: PowerTools no longer supports this, since [Fantastic](https://git.ngni.us/NG-SD-Plugins/Fantastic) does it much better.
Disable automatic control: `echo 1 > /sys/class/hwmon/hwmon5/recalculate` disables automatic (temperature-based) fan control and starts using the set fan target instead. Enable automatic control: `echo 0 > /sys/class/hwmon/hwmon5/recalculate` enables automatic fan control.
Set the fan speed: `echo {rpm} > /sys/class/hwmon/hwmon5/fan1_target` where `{rpm}` is the RPM. Disable automatic control: `echo 1 > /sys/class/hwmon/hwmon5/recalculate` disables automatic (temperature-based) fan control and starts using the set fan target instead.
Read the actual fan RPM: `cat /sys/class/hwmon/hwmon5/fan1_input` gives the fan speed. Set the fan speed: `echo {rpm} > /sys/class/hwmon/hwmon5/fan1_target` where `{rpm}` is the RPM.
NOTE: There's a bug in the fan controller; if you enable automatic fan control it will forget any previously-set target despite it appearing to be set correctly (i.e. `cat /sys/class/hwmon/hwmon5/fan1_target` will display the correct value). Read the actual fan RPM: `cat /sys/class/hwmon/hwmon5/fan1_input` gives the fan speed.
When you disable automatic fan control, you will need to set the fan RPM again.
NOTE: There's a bug in the fan controller; if you enable automatic fan control it will forget any previously-set target despite it appearing to be set correctly (i.e. `cat /sys/class/hwmon/hwmon5/fan1_target` will display the correct value).
# Get battery stats When you disable automatic fan control, you will need to set the fan RPM again.
Get the battery charge right now: `cat /sys/class/hwmon/hwmon2/device/charge_now` gives charge in uAh (uAh * 7.7/1000000 = charge in Wh). # Get battery stats
Get the maximum battery capacity: `cat /sys/class/hwmon/hwmon2/device/charge_full` gives charge in uAh. Get the battery charge right now: `cat /sys/class/hwmon/hwmon2/device/charge_now` gives charge in uAh (uAh * 7.7/1000000 = charge in Wh).
Get the design battery capacity: `cat /sys/class/hwmon/hwmon2/device/charge_full_design` gives charge in uAh. Get the maximum battery capacity: `cat /sys/class/hwmon/hwmon2/device/charge_full` gives charge in uAh.
Get battery current: `cat /sys/class/hwmon/hwmon5/curr1_input` gives the charger current in mA. Get the design battery capacity: `cat /sys/class/hwmon/hwmon2/device/charge_full_design` gives charge in uAh.
NOTE: 7.7 is the voltage of the battery -- it's not just a magic number. Get battery current: `cat /sys/class/hwmon/hwmon5/curr1_input` gives the charger current in mA.
# Set battery charge rate NOTE: 7.7 is the voltage of the battery -- it's not just a magic number.
Set the charge rate: `echo {rate} > /sys/class/hwmon/hwmon5/maximum_battery_charge_rate` where `{rate}` is the charge rate in mA, between 250 and 2500 mA. # Set battery charge rate
That file is write only, so changes cannot be directly observed. Set the charge rate: `echo {rate} > /sys/class/hwmon/hwmon5/maximum_battery_charge_rate` where `{rate}` is the charge rate in mA, between 250 and 2500 mA.
# Set battery charge mode That file is write only, so changes cannot be directly observed.
There exists a binary which may or may not be executable (depending on which SteamOS version) which can be used to set this and other things. [More details in the issue](https://github.com/NGnius/PowerTools/issues/50). # Set battery charge mode
Refer to [util.rs](https://github.com/NGnius/PowerTools/blob/main/backend/src/settings/steam_deck/util.rs) for how the firmware interface works. There exists a binary which may or may not be executable (depending on which SteamOS version) which can be used to set this and other things. [More details in the issue](https://git.ngni.us/NG-SD-Plugins/PowerTools/issues/50). Unfortunately recent SteamOS updates have removed that part of the binary's functionality.
# Steam Deck kernel patches Refer to [util.rs](https://git.ngni.us/NG-SD-Plugins/PowerTools/blob/main/backend/src/settings/steam_deck/util.rs) for how the firmware interface works.
This is how I figured out how the fan stuff works. # Set battery charge limit
I've only scratched the surface of what this code allows, I'm sure it has more useful information.
https://lkml.org/lkml/2022/2/5/391 This also used to require the binary in [this issue](https://git.ngni.us/NG-SD-Plugins/PowerTools/issues/50). Luckily this is replaced by a sysfs interface in SteamOS 3.5: `/sys/class/hwmon/hwmon4/max_battery_charge_level`. The number is the percent charge; 100 is full, 0 is empty.
# Game launch detection # Steam Deck kernel patches
```typescript This is how I figured out how the fan stuff works.
//@ts-ignore I've only scratched the surface of what this code allows, I'm sure it has more useful information.
let lifetimeHook = SteamClient.GameSessions.RegisterForAppLifetimeNotifications((update) => { https://lkml.org/lkml/2022/2/5/391
if (update.bRunning) {
console.log("AppID " + update.unAppID.toString() + " is now running"); # Game launch detection
} else {
console.log("AppID " + update.unAppID.toString() + " is no longer running"); ```typescript
// game exit code here //@ts-ignore
// NOTE: custom games always have 0 as AppID, so AppID is bad to use as ID let lifetimeHook = SteamClient.GameSessions.RegisterForAppLifetimeNotifications((update) => {
} if (update.bRunning) {
}); console.log("AppID " + update.unAppID.toString() + " is now running");
//@ts-ignore } else {
let startHook = SteamClient.Apps.RegisterForGameActionStart((actionType, id) => { console.log("AppID " + update.unAppID.toString() + " is no longer running");
//@ts-ignore // game exit code here
let gameInfo: any = appStore.GetAppOverviewByGameID(id); // NOTE: custom games always have 0 as AppID, so AppID is bad to use as ID
// game start code here }
// NOTE: GameID (variable: id) is always unique, even for custom games, so it's better to use than AppID });
}); //@ts-ignore
let startHook = SteamClient.Apps.RegisterForGameActionStart((actionType, id) => {
//@ts-ignore
let gameInfo: any = appStore.GetAppOverviewByGameID(id);
// game start code here
// NOTE: GameID (variable: id) is always unique, even for custom games, so it's better to use than AppID
});
``` ```