2010-01-26 22:37:48 +00:00
|
|
|
|
/*
|
|
|
|
|
|
2012-05-27 14:23:31 +00:00
|
|
|
|
This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
|
License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
|
file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
2010-01-26 22:37:48 +00:00
|
|
|
|
|
2020-02-11 22:44:30 +01:00
|
|
|
|
Copyright (C) 2009-2020 Michael M<EFBFBD>ller <mmoeller@openhardwaremonitor.org>
|
2012-05-27 14:23:31 +00:00
|
|
|
|
|
2010-01-26 22:37:48 +00:00
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
2010-08-12 20:53:27 +00:00
|
|
|
|
using System.Globalization;
|
2010-01-26 22:37:48 +00:00
|
|
|
|
using System.Text;
|
|
|
|
|
|
|
|
|
|
namespace OpenHardwareMonitor.Hardware.ATI {
|
2010-08-08 13:57:26 +00:00
|
|
|
|
internal class ATIGroup : IGroup {
|
2010-01-26 22:37:48 +00:00
|
|
|
|
|
2010-09-21 20:32:36 +00:00
|
|
|
|
private readonly List<ATIGPU> hardware = new List<ATIGPU>();
|
|
|
|
|
private readonly StringBuilder report = new StringBuilder();
|
2010-01-26 22:37:48 +00:00
|
|
|
|
|
2020-02-11 22:44:30 +01:00
|
|
|
|
private IntPtr context = IntPtr.Zero;
|
|
|
|
|
|
2010-08-08 13:57:26 +00:00
|
|
|
|
public ATIGroup(ISettings settings) {
|
2010-01-26 22:37:48 +00:00
|
|
|
|
try {
|
2020-02-11 22:44:30 +01:00
|
|
|
|
int adlStatus = ADL.ADL_Main_Control_Create(1);
|
|
|
|
|
int adl2Status = ADL.ADL2_Main_Control_Create(1, out context);
|
2010-01-28 19:31:10 +00:00
|
|
|
|
|
|
|
|
|
report.AppendLine("AMD Display Library");
|
|
|
|
|
report.AppendLine();
|
2020-02-11 22:44:30 +01:00
|
|
|
|
report.Append("ADL Status: ");
|
|
|
|
|
report.AppendLine(adlStatus == ADL.ADL_OK ? "OK" :
|
|
|
|
|
adlStatus.ToString(CultureInfo.InvariantCulture));
|
|
|
|
|
report.Append("ADL2 Status: ");
|
|
|
|
|
report.AppendLine(adl2Status == ADL.ADL_OK ? "OK" :
|
|
|
|
|
adl2Status.ToString(CultureInfo.InvariantCulture));
|
2010-01-28 19:31:10 +00:00
|
|
|
|
report.AppendLine();
|
|
|
|
|
|
2020-02-11 22:44:30 +01:00
|
|
|
|
if (adlStatus == ADL.ADL_OK) {
|
2010-01-26 22:37:48 +00:00
|
|
|
|
int numberOfAdapters = 0;
|
|
|
|
|
ADL.ADL_Adapter_NumberOfAdapters_Get(ref numberOfAdapters);
|
2010-01-28 19:31:10 +00:00
|
|
|
|
|
2010-02-08 20:23:24 +00:00
|
|
|
|
report.Append("Number of adapters: ");
|
2010-08-12 20:53:27 +00:00
|
|
|
|
report.AppendLine(numberOfAdapters.ToString(CultureInfo.InvariantCulture));
|
2010-01-26 22:37:48 +00:00
|
|
|
|
report.AppendLine();
|
|
|
|
|
|
|
|
|
|
if (numberOfAdapters > 0) {
|
|
|
|
|
ADLAdapterInfo[] adapterInfo = new ADLAdapterInfo[numberOfAdapters];
|
2010-01-28 19:31:10 +00:00
|
|
|
|
if (ADL.ADL_Adapter_AdapterInfo_Get(adapterInfo) == ADL.ADL_OK)
|
2010-01-26 22:37:48 +00:00
|
|
|
|
for (int i = 0; i < numberOfAdapters; i++) {
|
|
|
|
|
int isActive;
|
|
|
|
|
ADL.ADL_Adapter_Active_Get(adapterInfo[i].AdapterIndex,
|
|
|
|
|
out isActive);
|
2010-02-07 16:42:26 +00:00
|
|
|
|
int adapterID;
|
|
|
|
|
ADL.ADL_Adapter_ID_Get(adapterInfo[i].AdapterIndex,
|
|
|
|
|
out adapterID);
|
2010-01-26 22:37:48 +00:00
|
|
|
|
|
|
|
|
|
report.Append("AdapterIndex: ");
|
2010-08-12 20:53:27 +00:00
|
|
|
|
report.AppendLine(i.ToString(CultureInfo.InvariantCulture));
|
2010-01-26 22:37:48 +00:00
|
|
|
|
report.Append("isActive: ");
|
2010-08-12 20:53:27 +00:00
|
|
|
|
report.AppendLine(isActive.ToString(CultureInfo.InvariantCulture));
|
2010-01-26 22:37:48 +00:00
|
|
|
|
report.Append("AdapterName: ");
|
|
|
|
|
report.AppendLine(adapterInfo[i].AdapterName);
|
|
|
|
|
report.Append("UDID: ");
|
|
|
|
|
report.AppendLine(adapterInfo[i].UDID);
|
2010-01-27 19:30:10 +00:00
|
|
|
|
report.Append("Present: ");
|
2010-08-12 20:53:27 +00:00
|
|
|
|
report.AppendLine(adapterInfo[i].Present.ToString(
|
|
|
|
|
CultureInfo.InvariantCulture));
|
2012-01-15 15:07:23 +00:00
|
|
|
|
report.Append("VendorID: 0x");
|
|
|
|
|
report.AppendLine(adapterInfo[i].VendorID.ToString("X",
|
2010-08-12 20:53:27 +00:00
|
|
|
|
CultureInfo.InvariantCulture));
|
2010-01-27 19:30:10 +00:00
|
|
|
|
report.Append("BusNumber: ");
|
2010-08-12 20:53:27 +00:00
|
|
|
|
report.AppendLine(adapterInfo[i].BusNumber.ToString(
|
|
|
|
|
CultureInfo.InvariantCulture));
|
2010-01-27 19:30:10 +00:00
|
|
|
|
report.Append("DeviceNumber: ");
|
2010-08-12 20:53:27 +00:00
|
|
|
|
report.AppendLine(adapterInfo[i].DeviceNumber.ToString(
|
|
|
|
|
CultureInfo.InvariantCulture));
|
2010-01-27 19:30:10 +00:00
|
|
|
|
report.Append("FunctionNumber: ");
|
2010-08-12 20:53:27 +00:00
|
|
|
|
report.AppendLine(adapterInfo[i].FunctionNumber.ToString(
|
|
|
|
|
CultureInfo.InvariantCulture));
|
2010-02-07 16:42:26 +00:00
|
|
|
|
report.Append("AdapterID: 0x");
|
2011-04-15 23:52:07 +00:00
|
|
|
|
report.AppendLine(adapterID.ToString("X",
|
|
|
|
|
CultureInfo.InvariantCulture));
|
2010-02-07 16:42:26 +00:00
|
|
|
|
|
2011-04-15 23:52:07 +00:00
|
|
|
|
if (!string.IsNullOrEmpty(adapterInfo[i].UDID) &&
|
2012-01-15 15:07:23 +00:00
|
|
|
|
adapterInfo[i].VendorID == ADL.ATI_VENDOR_ID)
|
|
|
|
|
{
|
2010-02-07 16:42:26 +00:00
|
|
|
|
bool found = false;
|
|
|
|
|
foreach (ATIGPU gpu in hardware)
|
|
|
|
|
if (gpu.BusNumber == adapterInfo[i].BusNumber &&
|
|
|
|
|
gpu.DeviceNumber == adapterInfo[i].DeviceNumber) {
|
|
|
|
|
found = true;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
if (!found)
|
|
|
|
|
hardware.Add(new ATIGPU(
|
|
|
|
|
adapterInfo[i].AdapterName.Trim(),
|
|
|
|
|
adapterInfo[i].AdapterIndex,
|
|
|
|
|
adapterInfo[i].BusNumber,
|
2020-02-11 22:44:30 +01:00
|
|
|
|
adapterInfo[i].DeviceNumber, context, settings));
|
2010-01-26 22:37:48 +00:00
|
|
|
|
}
|
2010-01-29 21:14:23 +00:00
|
|
|
|
|
|
|
|
|
report.AppendLine();
|
2010-01-26 22:37:48 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2010-01-29 21:14:23 +00:00
|
|
|
|
} catch (DllNotFoundException) { }
|
|
|
|
|
catch (EntryPointNotFoundException e) {
|
|
|
|
|
report.AppendLine();
|
|
|
|
|
report.AppendLine(e.ToString());
|
|
|
|
|
report.AppendLine();
|
|
|
|
|
}
|
2010-01-26 22:37:48 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public IHardware[] Hardware {
|
|
|
|
|
get {
|
|
|
|
|
return hardware.ToArray();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public string GetReport() {
|
|
|
|
|
return report.ToString();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void Close() {
|
|
|
|
|
try {
|
2011-01-20 21:31:54 +00:00
|
|
|
|
foreach (ATIGPU gpu in hardware)
|
|
|
|
|
gpu.Close();
|
2020-02-11 22:44:30 +01:00
|
|
|
|
|
|
|
|
|
if (context != IntPtr.Zero) {
|
|
|
|
|
ADL.ADL2_Main_Control_Destroy(context);
|
|
|
|
|
context = IntPtr.Zero;
|
|
|
|
|
}
|
|
|
|
|
|
2010-01-26 22:37:48 +00:00
|
|
|
|
ADL.ADL_Main_Control_Destroy();
|
|
|
|
|
} catch (Exception) { }
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|