mirror of
https://github.com/jkocon/g-helper.git
synced 2026-02-23 13:00:52 +01:00
Power limits in Asus way
This commit is contained in:
@@ -1,20 +1,17 @@
|
|||||||
using System;
|
using GHelper.Mode;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
|
|
||||||
namespace GHelper.AutoTDP.PowerLimiter
|
namespace GHelper.AutoTDP.PowerLimiter
|
||||||
{
|
{
|
||||||
internal class ASUSACPIPowerLimiter : IPowerLimiter
|
internal class ASUSACPIPowerLimiter : IPowerLimiter
|
||||||
{
|
{
|
||||||
|
|
||||||
private int DefaultA0;
|
private bool allAmd;
|
||||||
private int DefaultA3;
|
private bool fPPT;
|
||||||
private int DefaultB0 = 0;
|
|
||||||
private int DefaultC1 = 0;
|
|
||||||
|
|
||||||
public ASUSACPIPowerLimiter()
|
public ASUSACPIPowerLimiter()
|
||||||
{
|
{
|
||||||
|
allAmd = Program.acpi.IsAllAmdPPT();
|
||||||
|
fPPT = Program.acpi.DeviceGet(AsusACPI.PPT_APUC1) >= 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static bool IsAvailable()
|
public static bool IsAvailable()
|
||||||
@@ -24,38 +21,23 @@ namespace GHelper.AutoTDP.PowerLimiter
|
|||||||
|
|
||||||
public void SavePowerLimits()
|
public void SavePowerLimits()
|
||||||
{
|
{
|
||||||
DefaultA0 = Program.acpi.DeviceGet(AsusACPI.PPT_APUA0);
|
|
||||||
DefaultA3 = Program.acpi.DeviceGet(AsusACPI.PPT_APUA3);
|
|
||||||
if (Program.acpi.IsAllAmdPPT()) // CPU limit all amd models
|
|
||||||
{
|
|
||||||
DefaultB0 = Program.acpi.DeviceGet(AsusACPI.PPT_CPUB0);
|
|
||||||
}
|
|
||||||
if (Program.acpi.DeviceGet(AsusACPI.PPT_APUC1) >= 0) // FPPT boost for non all-amd models
|
|
||||||
{
|
|
||||||
DefaultC1 = Program.acpi.DeviceGet(AsusACPI.PPT_APUC1);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetCPUPowerLimit(double watts)
|
public void SetCPUPowerLimit(double watts)
|
||||||
{
|
{
|
||||||
if (Program.acpi.DeviceGet(AsusACPI.PPT_APUA0) >= 0)
|
|
||||||
{
|
|
||||||
Program.acpi.DeviceSet(AsusACPI.PPT_APUA3, (int)watts, "PowerLimit A3");
|
|
||||||
Program.acpi.DeviceSet(AsusACPI.PPT_APUA0, (int)watts, "PowerLimit A0");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Program.acpi.IsAllAmdPPT()) // CPU limit all amd models
|
if (allAmd) // CPU limit all amd models
|
||||||
{
|
{
|
||||||
Program.acpi.DeviceSet(AsusACPI.PPT_CPUB0, (int)watts, "PowerLimit B0");
|
Program.acpi.DeviceSet(AsusACPI.PPT_CPUB0, (int)watts, "PowerLimit B0");
|
||||||
}
|
} else {
|
||||||
|
Program.acpi.DeviceSet(AsusACPI.PPT_APUA3, (int)watts, "PowerLimit A3");
|
||||||
if (Program.acpi.DeviceGet(AsusACPI.PPT_APUC1) >= 0) // FPPT boost for non all-amd models
|
Program.acpi.DeviceSet(AsusACPI.PPT_APUA0, (int)watts, "PowerLimit A0");
|
||||||
{
|
if (fPPT) Program.acpi.DeviceSet(AsusACPI.PPT_APUC1, (int)watts, "PowerLimit C1");
|
||||||
Program.acpi.DeviceSet(AsusACPI.PPT_APUC1, (int)watts, "PowerLimit C1");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// You can't read PPTs on ASUS :) endpoints just return 0 if they are available
|
||||||
public int GetCPUPowerLimit()
|
public int GetCPUPowerLimit()
|
||||||
{
|
{
|
||||||
return Program.acpi.DeviceGet(AsusACPI.PPT_APUA0);
|
return Program.acpi.DeviceGet(AsusACPI.PPT_APUA0);
|
||||||
@@ -66,24 +48,10 @@ namespace GHelper.AutoTDP.PowerLimiter
|
|||||||
//Nothing to dispose here
|
//Nothing to dispose here
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Correct Asus way to reset everything, is just to set mode again
|
||||||
public void ResetPowerLimits()
|
public void ResetPowerLimits()
|
||||||
{
|
{
|
||||||
//Load limits that were set before the limiter engaged
|
Program.modeControl.SetPerformanceMode(Modes.GetCurrent());
|
||||||
if (DefaultA3 > 0)
|
|
||||||
Program.acpi.DeviceSet(AsusACPI.PPT_APUA3, DefaultA3, "PowerLimit A0");
|
|
||||||
|
|
||||||
if (DefaultA0 > 0)
|
|
||||||
Program.acpi.DeviceSet(AsusACPI.PPT_APUA0, DefaultA0, "PowerLimit A3");
|
|
||||||
|
|
||||||
if (Program.acpi.IsAllAmdPPT() && DefaultB0 > 0) // CPU limit all amd models
|
|
||||||
{
|
|
||||||
Program.acpi.DeviceSet(AsusACPI.PPT_CPUB0, DefaultB0, "PowerLimit B0");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Program.acpi.DeviceGet(AsusACPI.PPT_APUC1) >= 0) // FPPT boost for non all-amd models
|
|
||||||
{
|
|
||||||
Program.acpi.DeviceSet(AsusACPI.PPT_APUC1, DefaultC1, "PowerLimit C1");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user