2022-12-19 22:47:10 +01:00
|
|
|
using System.Diagnostics;
|
2023-01-12 22:58:40 +01:00
|
|
|
using CommonHelpers;
|
2022-12-19 22:47:10 +01:00
|
|
|
using PowerControl.Helpers.AMD;
|
|
|
|
|
|
|
|
|
|
namespace PowerControl.Options
|
|
|
|
|
{
|
|
|
|
|
public static class TDP
|
|
|
|
|
{
|
|
|
|
|
public static Menu.MenuItemWithOptions Instance = new Menu.MenuItemWithOptions()
|
|
|
|
|
{
|
|
|
|
|
Name = "TDP",
|
2023-01-10 11:12:31 +01:00
|
|
|
PersistentKey = "TDP",
|
|
|
|
|
PersistOnCreate = false,
|
2022-12-19 22:47:10 +01:00
|
|
|
Options = { "3W", "4W", "5W", "6W", "7W", "8W", "10W", "12W", "15W" },
|
|
|
|
|
ApplyDelay = 1000,
|
|
|
|
|
ResetValue = () => { return "15W"; },
|
|
|
|
|
ActiveOption = "?",
|
2022-12-19 23:36:22 +01:00
|
|
|
ApplyValue = (selected) =>
|
2022-12-19 22:47:10 +01:00
|
|
|
{
|
2023-01-12 22:58:40 +01:00
|
|
|
if (!AntiCheatSettings.Default.AckAntiCheat(
|
2022-12-19 22:47:10 +01:00
|
|
|
Controller.TitleWithVersion,
|
2023-01-12 22:58:40 +01:00
|
|
|
"Changing TDP requires kernel access for a short period.",
|
|
|
|
|
"Leave the game if it uses anti-cheat protection."))
|
2022-12-19 22:47:10 +01:00
|
|
|
return null;
|
|
|
|
|
|
2022-12-19 23:36:22 +01:00
|
|
|
uint mW = uint.Parse(selected.Replace("W", "")) * 1000;
|
2022-12-19 22:47:10 +01:00
|
|
|
|
|
|
|
|
if (VangoghGPU.IsSupported)
|
|
|
|
|
{
|
2022-12-19 23:36:22 +01:00
|
|
|
return CommonHelpers.Instance.WithGlobalMutex<string>(200, () =>
|
2022-12-19 22:47:10 +01:00
|
|
|
{
|
|
|
|
|
using (var sd = VangoghGPU.Open())
|
|
|
|
|
{
|
|
|
|
|
if (sd is null)
|
|
|
|
|
return null;
|
|
|
|
|
|
|
|
|
|
sd.SlowTDP = mW;
|
|
|
|
|
sd.FastTDP = mW;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return selected;
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
uint stampLimit = mW / 10;
|
|
|
|
|
|
|
|
|
|
Process.Start(new ProcessStartInfo()
|
|
|
|
|
{
|
|
|
|
|
FileName = "Resources/RyzenAdj/ryzenadj.exe",
|
|
|
|
|
ArgumentList = {
|
|
|
|
|
"--stapm-limit=" + stampLimit.ToString(),
|
|
|
|
|
"--slow-limit=" + mW.ToString(),
|
|
|
|
|
"--fast-limit=" + mW.ToString(),
|
|
|
|
|
},
|
|
|
|
|
WindowStyle = ProcessWindowStyle.Hidden,
|
|
|
|
|
UseShellExecute = false,
|
|
|
|
|
CreateNoWindow = true
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
return selected;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
}
|