Skip to content
This repository has been archived by the owner on Sep 28, 2024. It is now read-only.

Commit

Permalink
* Rebase from upstream.
Browse files Browse the repository at this point in the history
  - Upstream PR: aarron-lee#43
  • Loading branch information
fewtarius committed Sep 22, 2024
1 parent f90e247 commit 4601f31
Show file tree
Hide file tree
Showing 8 changed files with 37 additions and 11 deletions.
10 changes: 6 additions & 4 deletions py_modules/cpu_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,16 +50,18 @@ def ryzenadj(tdp: int):
if advanced_options.get_setting(RogAllySettings.USE_WMI.value):
return rog_ally.ryzenadj(tdp)

fast_tdp = (tdp+2)*1000
tdp = tdp*1000

if RYZENADJ_PATH:
commands = [
RYZENADJ_PATH,
'--stapm-limit', f"{tdp}",
'--fast-limit', f"{fast_tdp}",
'--fast-limit', f"{tdp}",
'--slow-limit', f"{tdp}",
'--apu-slow-limit', f"{tdp}"
'--tctl-temp', f"95",
'--apu-skin-temp', f"95",
'--dgpu-skin-temp', f"95",
'--max-performance'
]

results = subprocess.call(commands)
Expand Down Expand Up @@ -235,4 +237,4 @@ def get_scaling_driver():
return scaling_driver
except Exception as e:
logging.error(f'{__name__} get_scaling_driver {e}')
return ''
return ''
4 changes: 4 additions & 0 deletions py_modules/gpu_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,10 @@ def set_gpu_frequency(current_game_id):
except Exception as e:
decky_plugin.logger.error(f"{__name__} power mode error {e}")
return False
elif gpu_mode == GpuModes.RANGE.value:
new_min = tdp_profile.get(GpuRange.MIN.value, 0)
new_max = tdp_profile.get(GpuRange.MAX.value, 0)
return set_gpu_frequency_range(new_min, new_max)
elif gpu_mode == GpuModes.FIXED.value:
new_freq = tdp_profile.get(GpuRange.FIXED.value, 0)
return set_gpu_frequency_range(new_freq, new_freq)
Expand Down
4 changes: 3 additions & 1 deletion py_modules/plugin_enums.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
from enum import Enum

class GpuModes(Enum):
DEFAULT = "DEFAULT"
BATTERY = "BATTERY"
BALANCE = "BALANCE"
PERFORMANCE = "PERFORMANCE"
RANGE = "RANGE"
FIXED = "FIXED"

Expand Down
2 changes: 1 addition & 1 deletion py_modules/plugin_update.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import ssl
import shutil

API_URL = "https://api.github.com/repos/aarron-lee/SimpleDeckyTDP/releases/latest"
API_URL = "https://api.github.com/repos/SteamFork/SimpleDeckyTDP/releases/latest"

def recursive_chmod(path, perms):
for dirpath, dirnames, filenames in os.walk(path):
Expand Down
14 changes: 12 additions & 2 deletions py_modules/plugin_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from time import sleep
# import advanced_options
from plugin_settings import bootstrap_profile, merge_tdp_profiles, get_tdp_profile, set_setting as persist_setting
from cpu_utils import ryzenadj, set_cpu_boost, get_scaling_driver, set_smt
from cpu_utils import ryzenadj, set_cpu_boost, get_scaling_driver, set_smt, supports_cpu_boost
from gpu_utils import set_gpu_frequency_range
import power_utils

Expand Down Expand Up @@ -56,7 +56,9 @@ def set_smt_for_tdp_profile(tdp_profile):

def set_cpu_boost_for_tdp_profile(tdp_profile):
cpu_boost = tdp_profile.get('cpuBoost', False)
set_cpu_boost(cpu_boost)

if supports_cpu_boost():
set_cpu_boost(cpu_boost)

def set_tdp_for_tdp_profile(tdp_profile):
if tdp_profile.get('tdp'):
Expand All @@ -72,6 +74,7 @@ def set_gpu_for_tdp_profile(tdp_profile):
min_frequency = tdp_profile.get('minGpuFrequency')
max_frequency = tdp_profile.get('maxGpuFrequency')


if gpu_mode:
try:
with file_timeout.time_limit(3):
Expand All @@ -87,6 +90,9 @@ def set_gpu_for_tdp_profile(tdp_profile):
elif gpu_mode == 'FIXED' and fixed_frequency:
set_gpu_frequency_range(fixed_frequency, fixed_frequency)
return True
elif gpu_mode == 'RANGE' and min_frequency and max_frequency:
set_gpu_frequency_range(min_frequency, max_frequency)
return True
return False
except Exception as e:
logging.error(f'main#set_gpu_for_game_id timeout {e}')
Expand Down Expand Up @@ -123,6 +129,10 @@ def persist_gpu(minGpuFrequency, maxGpuFrequency, game_id):
elif minGpuFrequency == maxGpuFrequency:
gpu_mode = 'FIXED'
profile_contents["fixedGpuFrequency"] = maxGpuFrequency
elif minGpuFrequency < maxGpuFrequency:
gpu_mode = 'RANGE'
profile_contents["minGpuFrequency"] = minGpuFrequency
profile_contents["maxGpuFrequency"] = maxGpuFrequency
else:
# invalid, return
return
Expand Down
4 changes: 3 additions & 1 deletion src/backend/utils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ export const DesktopAdvancedOptions = [
] as string[];

export enum GpuModes {
DEFAULT = "DEFAULT",
BATTERY = "BATTERY",
BALANCE = "BALANCE",
PERFORMANCE = "PERFORMANCE",
RANGE = "RANGE",
FIXED = "FIXED",
}
Expand Down
5 changes: 3 additions & 2 deletions src/components/atoms/GpuModeSlider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ enum Mode {
BATTERY = 0,
BALANCE = 1,
PERFORMANCE = 2
FIXED = 3,
RANGE = 3,
FIXED = 4,
}

const GpuModeSlider: FC<{ showSeparator: boolean }> = ({ showSeparator }) => {
Expand All @@ -21,7 +22,7 @@ const GpuModeSlider: FC<{ showSeparator: boolean }> = ({ showSeparator }) => {
const MODES: NotchLabel[] = Object.keys(Mode)
.filter((key) => isNaN(Number(key)))
.map((mode, idx) => {
return { notchIndex: idx, label: capitalize(mode), value: idx };
return { notchIndex: idx, label: capitalize(mode.slice(0,7) + " " + mode.slice(7)), value: idx };
});

// known bug: typescript has incorrect type for reverse mapping from enums
Expand Down
5 changes: 5 additions & 0 deletions src/components/molecules/Gpu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ const Gpu = () => {
<GpuModeSlider showSeparator={gpuMode == GpuModes.BALANCE} />
</DeckyRow>

{gpuMode === GpuModes.RANGE && (
<DeckyRow>
<GpuRangeSliders showSeparator />
</DeckyRow>
)}
{gpuMode === GpuModes.FIXED && (
<DeckyRow>
<GpuFixedSlider />
Expand Down

0 comments on commit 4601f31

Please sign in to comment.