steam-deck-tools/PowerControl/Options/CPUFrequency.cs
Kamil Trzciński 2ff2864f23 PowerControl: Expose all settings and apply them in order
Since some settings impact others, the application will
apply them in a correct order with a fixed delay.

This additionally exposes all settings, just some of them
are not persisted on create, only on change.
2023-01-10 12:01:33 +01:00

65 lines
2.2 KiB
C#

using PowerControl.Helpers.AMD;
namespace PowerControl.Options
{
public static class CPUFrequency
{
public static Menu.MenuItemWithOptions Instance = new Menu.MenuItemWithOptions()
{
Name = "CPU",
PersistentKey = "CPUFrequency",
PersistOnCreate = false,
Options = { "Default", "Power-Save", "Balanced", "Max" },
ApplyDelay = 1000,
ActiveOption = "?",
Visible = VangoghGPU.IsSupported,
ResetValue = () => { return "Default"; },
ApplyValue = (selected) =>
{
if (!Settings.Default.AckAntiCheat(
Controller.TitleWithVersion,
"CPU",
"Changing GPU frequency requires kernel access for a short period. Leave the game if it uses anti-cheat protection.")
)
return null;
return CommonHelpers.Instance.WithGlobalMutex<string>(200, () =>
{
using (var sd = VangoghGPU.Open())
{
if (sd is null)
return null;
switch (selected.ToString())
{
case "Default":
sd.MinCPUClock = 1400;
sd.MaxCPUClock = 3500;
break;
case "Power-Save":
sd.MinCPUClock = 1400;
sd.MaxCPUClock = 1800;
break;
case "Balanced":
sd.MinCPUClock = 2200;
sd.MaxCPUClock = 2800;
break;
case "Max":
sd.MinCPUClock = 3000;
sd.MaxCPUClock = 3500;
break;
default:
return null;
}
return selected;
}
});
}
};
}
}