mirror of
https://github.com/ayufan/steam-deck-tools.git
synced 2025-12-06 07:12:01 +01:00
CommonHelpers: Vlv0100: Use Instance instead of static.
This commit is contained in:
parent
943cfd9aa5
commit
b47c5fa860
|
|
@ -78,9 +78,9 @@ namespace CommonHelpers
|
|||
useKernelDrivers = value;
|
||||
|
||||
if (value)
|
||||
Vlv0100.Open();
|
||||
Vlv0100.Instance.Open();
|
||||
else
|
||||
Vlv0100.Close();
|
||||
Vlv0100.Instance.Close();
|
||||
|
||||
// CPU requires reading RyzenSMU
|
||||
HardwareComputer.IsCpuEnabled = value;
|
||||
|
|
@ -140,13 +140,13 @@ namespace CommonHelpers
|
|||
{
|
||||
UseKernelDrivers = useKernelDrivers;
|
||||
|
||||
if (Vlv0100.IsOpen && !Vlv0100.IsSupported)
|
||||
if (Vlv0100.Instance.IsOpen && !Vlv0100.Instance.IsSupported)
|
||||
{
|
||||
String message = "";
|
||||
message += "Current device is not supported.\n";
|
||||
message += "FirmwareVersion: " + Vlv0100.FirmwareVersion.ToString("X") + "\n";
|
||||
message += "BoardID: " + Vlv0100.BoardID.ToString("X") + "\n";
|
||||
message += "PDCS: " + Vlv0100.PDCS.ToString("X") + "\n";
|
||||
message += "FirmwareVersion: " + Vlv0100.Instance.FirmwareVersion.ToString("X") + "\n";
|
||||
message += "BoardID: " + Vlv0100.Instance.BoardID.ToString("X") + "\n";
|
||||
message += "PDCS: " + Vlv0100.Instance.PDCS.ToString("X") + "\n";
|
||||
|
||||
Fatal(title, message);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
namespace CommonHelpers
|
||||
{
|
||||
public class Vlv0100
|
||||
public class Vlv0100 : IDisposable
|
||||
{
|
||||
// Those addresses are taken from DSDT for VLV0100
|
||||
// and might change at any time with a BIOS update
|
||||
|
|
@ -49,28 +49,41 @@
|
|||
new DeviceVersion() { Firmware = 0x1050, BoardID = 0x5, PDCS = 0 /* 0x2F */, BatteryTempLE = true }
|
||||
};
|
||||
|
||||
private static InpOut? inpOut;
|
||||
public static Vlv0100 Instance = new Vlv0100();
|
||||
|
||||
public static bool IsOpen
|
||||
~Vlv0100()
|
||||
{
|
||||
Close();
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
GC.SuppressFinalize(this);
|
||||
Close();
|
||||
}
|
||||
|
||||
private InpOut? inpOut;
|
||||
|
||||
public bool IsOpen
|
||||
{
|
||||
get { return inpOut is not null; }
|
||||
}
|
||||
|
||||
public static DeviceVersion? SupportedDevice
|
||||
public DeviceVersion? SupportedDevice
|
||||
{
|
||||
get { return deviceVersions.First((v) => v.IsSupported(FirmwareVersion, BoardID, PDCS)); }
|
||||
get { return deviceVersions.FirstOrDefault((v) => v.IsSupported(FirmwareVersion, BoardID, PDCS)); }
|
||||
}
|
||||
|
||||
public static bool IsSupported
|
||||
public bool IsSupported
|
||||
{
|
||||
get { return SupportedDevice is not null; }
|
||||
}
|
||||
|
||||
public static ushort FirmwareVersion { get; private set; }
|
||||
public static byte BoardID { get; private set; }
|
||||
public static byte PDCS { get; private set; }
|
||||
public ushort FirmwareVersion { get; private set; }
|
||||
public byte BoardID { get; private set; }
|
||||
public byte PDCS { get; private set; }
|
||||
|
||||
public static bool Open()
|
||||
public bool Open()
|
||||
{
|
||||
if (inpOut != null)
|
||||
return true;
|
||||
|
|
@ -96,7 +109,6 @@
|
|||
PDCS = data[0];
|
||||
else
|
||||
PDCS = 0xFF;
|
||||
|
||||
return true;
|
||||
}
|
||||
catch (Exception e)
|
||||
|
|
@ -107,14 +119,14 @@
|
|||
}
|
||||
}
|
||||
|
||||
public static void Close()
|
||||
public void Close()
|
||||
{
|
||||
SetFanControl(false);
|
||||
using (inpOut) { }
|
||||
inpOut = null;
|
||||
}
|
||||
|
||||
public static ushort GetFanDesiredRPM()
|
||||
public ushort GetFanDesiredRPM()
|
||||
{
|
||||
var data = inpOut?.ReadMemory(FSLO_FSHI, 2);
|
||||
if (data is null)
|
||||
|
|
@ -122,7 +134,7 @@
|
|||
return BitConverter.ToUInt16(data);
|
||||
}
|
||||
|
||||
public static ushort? GetFanRPM()
|
||||
public ushort? GetFanRPM()
|
||||
{
|
||||
var data = inpOut?.ReadMemory(FNRL_FNRH, 2);
|
||||
if (data is null)
|
||||
|
|
@ -130,7 +142,7 @@
|
|||
return BitConverter.ToUInt16(data);
|
||||
}
|
||||
|
||||
public static void SetFanControl(Boolean userControlled)
|
||||
public void SetFanControl(Boolean userControlled)
|
||||
{
|
||||
SetGain(10);
|
||||
SetRampRate(userControlled ? (byte)10 : (byte)20);
|
||||
|
|
@ -138,7 +150,7 @@
|
|||
inpOut?.DlPortWritePortUchar(IO6C, userControlled ? (byte)0xCC : (byte)0xCD);
|
||||
}
|
||||
|
||||
public static void SetFanDesiredRPM(ushort rpm)
|
||||
public void SetFanDesiredRPM(ushort rpm)
|
||||
{
|
||||
if (rpm > MAX_FAN_RPM)
|
||||
rpm = MAX_FAN_RPM;
|
||||
|
|
@ -147,7 +159,7 @@
|
|||
inpOut?.WriteMemory(FSLO_FSHI, data);
|
||||
}
|
||||
|
||||
public static bool GetFanCheck()
|
||||
public bool GetFanCheck()
|
||||
{
|
||||
var data = inpOut?.ReadMemory(FNCK, 1);
|
||||
if (data is null)
|
||||
|
|
@ -155,7 +167,7 @@
|
|||
return (data[0] & 0x1) != 0;
|
||||
}
|
||||
|
||||
public static float GetBattTemperature()
|
||||
public float GetBattTemperature()
|
||||
{
|
||||
var data = inpOut?.ReadMemory(BATH_BATL, 2);
|
||||
if (data is null)
|
||||
|
|
@ -166,12 +178,12 @@
|
|||
return (float)(value - 0x0AAC) / 10.0f;
|
||||
}
|
||||
|
||||
private static void SetGain(ushort gain)
|
||||
private void SetGain(ushort gain)
|
||||
{
|
||||
byte[] data = BitConverter.GetBytes(gain);
|
||||
inpOut?.WriteMemory(GNLO_GNHI, data);
|
||||
}
|
||||
private static void SetRampRate(byte rampRate)
|
||||
private void SetRampRate(byte rampRate)
|
||||
{
|
||||
byte[] data = BitConverter.GetBytes(rampRate);
|
||||
inpOut?.WriteMemory(FRPR, data);
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ namespace FanControl
|
|||
public ushort DesiredRPM { get; private set; }
|
||||
|
||||
[CategoryAttribute("Board")]
|
||||
public String PDVersion { get; private set; } = Vlv0100.FirmwareVersion.ToString("X");
|
||||
public String PDVersion { get; private set; } = Vlv0100.Instance.FirmwareVersion.ToString("X");
|
||||
|
||||
public FanController()
|
||||
{
|
||||
|
|
@ -80,7 +80,7 @@ namespace FanControl
|
|||
[Browsable(false)]
|
||||
public bool IsActive
|
||||
{
|
||||
get { return Vlv0100.IsOpen; }
|
||||
get { return Vlv0100.Instance.IsOpen; }
|
||||
}
|
||||
|
||||
public void Update(bool showForDefault = false)
|
||||
|
|
@ -89,7 +89,7 @@ namespace FanControl
|
|||
if (mutex is null)
|
||||
{
|
||||
// If we cannot acquire mutex slightly increase FAN to compensate just in case
|
||||
Vlv0100.SetFanDesiredRPM((ushort)(Vlv0100.GetFanDesiredRPM() * 110 / 100));
|
||||
Vlv0100.Instance.SetFanDesiredRPM((ushort)(Vlv0100.Instance.GetFanDesiredRPM() * 110 / 100));
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -104,7 +104,7 @@ namespace FanControl
|
|||
sensor.Reset();
|
||||
return;
|
||||
}
|
||||
else if (!Vlv0100.IsOpen)
|
||||
else if (!Vlv0100.Instance.IsOpen)
|
||||
{
|
||||
Instance.UseKernelDrivers = true;
|
||||
SetMode(Mode);
|
||||
|
|
@ -121,12 +121,12 @@ namespace FanControl
|
|||
mutex.ReleaseMutex();
|
||||
}
|
||||
|
||||
allSensors["Batt"].Update("VLV0100", Vlv0100.GetBattTemperature(), Mode);
|
||||
allSensors["Batt"].Update("VLV0100", Vlv0100.Instance.GetBattTemperature(), Mode);
|
||||
|
||||
Vlv0100.SetFanDesiredRPM(getDesiredRPM());
|
||||
Vlv0100.Instance.SetFanDesiredRPM(getDesiredRPM());
|
||||
|
||||
CurrentRPM = Vlv0100.GetFanRPM();
|
||||
DesiredRPM = Vlv0100.GetFanDesiredRPM();
|
||||
CurrentRPM = Vlv0100.Instance.GetFanRPM();
|
||||
DesiredRPM = Vlv0100.Instance.GetFanDesiredRPM();
|
||||
}
|
||||
|
||||
public void SetMode(FanMode mode)
|
||||
|
|
@ -134,12 +134,12 @@ namespace FanControl
|
|||
switch (mode)
|
||||
{
|
||||
case FanMode.Default:
|
||||
Vlv0100.SetFanControl(false);
|
||||
Vlv0100.Instance.SetFanControl(false);
|
||||
break;
|
||||
|
||||
default:
|
||||
Instance.UseKernelDrivers = true;
|
||||
Vlv0100.SetFanControl(true);
|
||||
Vlv0100.Instance.SetFanControl(true);
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -335,7 +335,7 @@ namespace PerformanceOverlay
|
|||
{
|
||||
Value = delegate ()
|
||||
{
|
||||
return CommonHelpers.Vlv0100.GetFanRPM();
|
||||
return Vlv0100.Instance.GetFanRPM();
|
||||
},
|
||||
Format = "F0"
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue