mirror of
https://github.com/ayufan/steam-deck-tools.git
synced 2026-04-05 14:25:40 +00:00
GPU detection will log errors to Sentry.io
This commit is contained in:
parent
4398177722
commit
9d4828fdf1
3 changed files with 32 additions and 19 deletions
|
|
@ -1,5 +1,6 @@
|
|||
using CommonHelpers;
|
||||
using System.Diagnostics;
|
||||
using static CommonHelpers.Log;
|
||||
using Device = System.Tuple<string, ulong, ulong, uint>;
|
||||
|
||||
namespace PowerControl.Helpers.AMD
|
||||
|
|
@ -35,7 +36,14 @@ namespace PowerControl.Helpers.AMD
|
|||
return OpenMMIO(new IntPtr((long)device.Item2), (uint)(device.Item3 - device.Item2 + 1));
|
||||
}
|
||||
|
||||
public static bool Detect()
|
||||
public enum DetectionStatus
|
||||
{
|
||||
Detected,
|
||||
Retryable,
|
||||
NotDetected
|
||||
}
|
||||
|
||||
public static DetectionStatus Detect()
|
||||
{
|
||||
var discoveredDevices = new Dictionary<string, string>();
|
||||
|
||||
|
|
@ -61,12 +69,17 @@ namespace PowerControl.Helpers.AMD
|
|||
var ranges = DeviceManager.GetDeviceMemResources(devicePNP);
|
||||
if (ranges is null)
|
||||
{
|
||||
TraceLine("GPU: {0}: {1}: No memory ranges", deviceName, devicePNP);
|
||||
TraceError("GPU: {0}: {1}: No memory ranges", deviceName, devicePNP);
|
||||
continue;
|
||||
}
|
||||
if (!ranges.Contains(new Tuple<UIntPtr, UIntPtr>(new UIntPtr(device.Item2), new UIntPtr(device.Item3))))
|
||||
var expectedRange = new Tuple<UIntPtr, UIntPtr>(new UIntPtr(device.Item2), new UIntPtr(device.Item3));
|
||||
if (!ranges.Contains(expectedRange))
|
||||
{
|
||||
TraceLine("GPU: {0}: {1}: Memory range not found", deviceName, devicePNP);
|
||||
TraceError("GPU: {0}: {1}: Memory range not found: {2}",
|
||||
deviceName,
|
||||
devicePNP,
|
||||
String.Join(",", ranges.Select((item) => item.ToString()))
|
||||
);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
@ -74,24 +87,24 @@ namespace PowerControl.Helpers.AMD
|
|||
{
|
||||
if (gpu is null)
|
||||
{
|
||||
TraceLine("GPU: {0}: {1}: Failed to open.", deviceName, devicePNP);
|
||||
TraceError("GPU: {0}: {1}: Failed to open.", deviceName, devicePNP);
|
||||
continue;
|
||||
}
|
||||
|
||||
var smuVersion = gpu.SMUVersion;
|
||||
if (smuVersion != device.Item4)
|
||||
{
|
||||
TraceLine("GPU: {0}: {1}: SMU not supported: {2:X8}", deviceName, devicePNP, smuVersion);
|
||||
continue;
|
||||
TraceError("GPU: {0}: {1}: SMU not supported: {2:X8} (IO: {3})", deviceName, devicePNP, smuVersion, expectedRange);
|
||||
return DetectionStatus.Retryable;
|
||||
}
|
||||
|
||||
TraceLine("GPU: {0}: Matched!", deviceName);
|
||||
DetectedDevice = device;
|
||||
return true;
|
||||
return DetectionStatus.Detected;
|
||||
}
|
||||
}
|
||||
DetectedDevice = null;
|
||||
return false;
|
||||
return DetectionStatus.Detected;
|
||||
}
|
||||
|
||||
// Addresses:
|
||||
|
|
@ -441,10 +454,5 @@ namespace PowerControl.Helpers.AMD
|
|||
CC6_BIT = 58,
|
||||
GFX_EDC_BIT = 59
|
||||
}
|
||||
|
||||
private static void TraceLine(string format, params object?[]? arg)
|
||||
{
|
||||
Trace.WriteLine(string.Format(format, arg));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue