mirror of
https://github.com/terrymacdonald/DisplayMagician.git
synced 2024-08-30 18:32:20 +00:00
Change Display Profiles to v2.0
We have to do this as we will be moving to a new video card library-based way of getting the Display Profiles information. This is designed to enable me to add new video card drivers in the future, such as Intel, in order to support 'combined' video screens,
This commit is contained in:
parent
484b6d86b4
commit
4774b9a995
@ -145,6 +145,15 @@ namespace ATI.ADL
|
||||
/// <returns>return ADL Error Code</returns>
|
||||
internal delegate int ADL2_Display_HDRState_Get(IntPtr ADLContextHandle, int adapterIndex, ADLDisplayID displayID, out int support, out int enable);
|
||||
|
||||
/// <summary>ADL2 function to retrieve the current display mode information</summary>
|
||||
/// <param name="ADLContextHandle">Handle to ADL client context.</param>
|
||||
/// <param name="adapterIndex">Adapter Index</param>
|
||||
/// <param name="displayIndex">Display Index</param>
|
||||
/// <param name="numModes">return a pointer to the number of modes retrieved.</param>
|
||||
/// <param name="modes">return a pointer to the array of retrieved ADLMode display modes.</param>
|
||||
/// <returns>return ADL Error Code</returns>
|
||||
internal delegate int ADL2_Display_Modes_Get(IntPtr ADLContextHandle, int adapterIndex, int displayIndex, out int numModes, out IntPtr modes);
|
||||
|
||||
|
||||
// ADL version of function delagates
|
||||
|
||||
@ -1072,6 +1081,28 @@ namespace ATI.ADL
|
||||
/// <summary> Indicates the display is a projector </summary>
|
||||
internal const int ADL_DISPLAY_DISPLAYINFO_SHOWTYPE_PROJECTOR = 0x00100000;
|
||||
|
||||
// Display Mode Constants
|
||||
/// <summary> Indicates the display is in interlaced mode</summary>
|
||||
internal const int ADL_DISPLAY_MODE_INTERLACED_FLAG = 2;
|
||||
/// <summary> Indicates the display is in progressive mode </summary>
|
||||
internal const int ADL_DISPLAY_MODE_PROGRESSIVE_FLAG = 0;
|
||||
/// <summary> Indicates the display colour format is 565</summary>
|
||||
internal const int ADL_DISPLAY_MODE_COLOURFORMAT_565 = 0x00000001;
|
||||
/// <summary> Indicates the display colour format is 8888 </summary>
|
||||
internal const int ADL_DISPLAY_MODE_COLOURFORMAT_8888 = 0x00000002;
|
||||
/// <summary> Indicates the display orientation is normal position</summary>
|
||||
internal const int ADL_DISPLAY_MODE_ORIENTATION_SUPPORTED_000 = 0x00000004;
|
||||
/// <summary> Indicates the display is in the 90 degree position</summary>
|
||||
internal const int ADL_DISPLAY_MODE_ORIENTATION_SUPPORTED_090 = 0x00000008;
|
||||
/// <summary> Indicates the display in the 180 degree position</summary>
|
||||
internal const int ADL_DISPLAY_MODE_ORIENTATION_SUPPORTED_180 = 0x00000010;
|
||||
/// <summary> Indicates the display is in the 270 degree position</summary>
|
||||
internal const int ADL_DISPLAY_MODE_ORIENTATION_SUPPORTED_270 = 0x00000020;
|
||||
/// <summary> Indicates the display refresh rate is exact </summary>
|
||||
internal const int ADL_DISPLAY_MODE_REFRESHRATE_ONLY = 0x00000080;
|
||||
/// <summary> Indicates the display refresh rate is rounded</summary>
|
||||
internal const int ADL_DISPLAY_MODE_REFRESHRATE_ROUNDED = 0x00000040;
|
||||
|
||||
// DDCInfoX2 DDCInfo Flag values
|
||||
/// <summary> Indicates the display is a projector </summary>
|
||||
internal const int ADL_DISPLAYDDCINFOEX_FLAG_PROJECTORDEVICE = (1 << 0);
|
||||
@ -1140,6 +1171,32 @@ namespace ATI.ADL
|
||||
USBTypeC = 18
|
||||
}
|
||||
|
||||
internal enum ADLDisplayModeColourFormat
|
||||
{
|
||||
ColourFormat565 = 1,
|
||||
ColourFormat8888 = 2
|
||||
}
|
||||
|
||||
internal enum ADLDisplayModeInterlacing
|
||||
{
|
||||
Progressive = 0,
|
||||
Interlaced = 2
|
||||
}
|
||||
|
||||
internal enum ADLDisplayModeOrientation
|
||||
{
|
||||
Degrees0 = 4,
|
||||
Degrees90 = 8,
|
||||
Degrees180 = 10,
|
||||
Degrees270 = 20
|
||||
}
|
||||
|
||||
internal enum ADLDisplayModeRefreshRate
|
||||
{
|
||||
ExactRefreshRate = 80,
|
||||
RoundedRefreshRate = 40
|
||||
}
|
||||
|
||||
#endregion Internal Enums
|
||||
|
||||
#region Class ADLImport
|
||||
@ -1196,6 +1253,10 @@ namespace ATI.ADL
|
||||
[DllImport(Atiadlxx_FileName)]
|
||||
internal static extern int ADL2_Display_HDRState_Get(IntPtr ADLContextHandle, int adapterIndex, ADLDisplayID displayID, out int support, out int enable);
|
||||
|
||||
[DllImport(Atiadlxx_FileName)]
|
||||
internal static extern int ADL2_Display_Modes_Get(IntPtr ADLContextHandle, int adapterIndex, int displayIndex, out int numModes, out IntPtr modes);
|
||||
|
||||
|
||||
[DllImport(Atiadlxx_FileName)]
|
||||
internal static extern int ADL_Main_Control_Create (ADL_Main_Memory_Alloc callback, int enumConnectedAdapters);
|
||||
|
||||
@ -1667,6 +1728,30 @@ namespace ATI.ADL
|
||||
private static bool ADL2_Display_HDRState_Get_Check = false;
|
||||
#endregion ADL2_Display_HDRState_Get
|
||||
|
||||
#region ADL2_Display_Modes_Get
|
||||
/// <summary> ADL2_Display_Modes_Get Delegates</summary>
|
||||
internal static ADL2_Display_Modes_Get ADL2_Display_Modes_Get
|
||||
{
|
||||
get
|
||||
{
|
||||
if (!ADL2_Display_Modes_Get_Check && null == ADL2_Display_Modes_Get_)
|
||||
{
|
||||
ADL2_Display_Modes_Get_Check = true;
|
||||
if (ADLCheckLibrary.IsFunctionValid("ADL2_Display_Modes_Get"))
|
||||
{
|
||||
ADL2_Display_Modes_Get_ = ADLImport.ADL2_Display_Modes_Get;
|
||||
}
|
||||
}
|
||||
return ADL2_Display_Modes_Get_;
|
||||
}
|
||||
}
|
||||
/// <summary> Private Delegate</summary>
|
||||
private static ADL2_Display_Modes_Get ADL2_Display_Modes_Get_ = null;
|
||||
/// <summary> check flag to indicate the delegate has been checked</summary>
|
||||
private static bool ADL2_Display_Modes_Get_Check = false;
|
||||
#endregion ADL2_Display_Modes_Get
|
||||
|
||||
|
||||
// ================================
|
||||
|
||||
#region ADL_Main_Control_Create
|
||||
|
@ -19,7 +19,6 @@ namespace DisplayMagicianShared.AMD
|
||||
private static AMDLibrary _instance = new AMDLibrary();
|
||||
|
||||
private bool _initialised = false;
|
||||
private bool _initialisedADL2 = false;
|
||||
|
||||
// To detect redundant calls
|
||||
private bool _disposed = false;
|
||||
@ -28,36 +27,19 @@ namespace DisplayMagicianShared.AMD
|
||||
private SafeHandle _safeHandle = new SafeFileHandle(IntPtr.Zero, true);
|
||||
private IntPtr _adlContextHandle = IntPtr.Zero;
|
||||
|
||||
// Struct to be used as the AMD Profile
|
||||
public struct AMDProfile
|
||||
{
|
||||
int XPos;
|
||||
int YPos;
|
||||
}
|
||||
|
||||
static AMDLibrary() { }
|
||||
public AMDLibrary()
|
||||
{
|
||||
int ADLRet = ADL.ADL_ERR;
|
||||
|
||||
SharedLogger.logger.Trace("AMDLibrary/AMDLibrary: Intialising ADL library");
|
||||
try
|
||||
{
|
||||
if (ADL.ADL_Main_Control_Create != null)
|
||||
{
|
||||
// Second parameter is 1: Get only the present adapters
|
||||
ADLRet = ADL.ADL_Main_Control_Create(ADL.ADL_Main_Memory_Alloc, 1);
|
||||
}
|
||||
|
||||
if (ADLRet == ADL.ADL_OK)
|
||||
{
|
||||
_initialised = true;
|
||||
SharedLogger.logger.Trace("AMDLibrary/AMDLibrary: ADL library was initialised successfully");
|
||||
}
|
||||
else
|
||||
{
|
||||
SharedLogger.logger.Error("AMDLibrary/AMDLibrary: Error intialising ADL library. ADL_Main_Control_Create() returned error code " + ADLRet.ToString());
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
SharedLogger.logger.Error(ex, "AMDLibrary/AMDLibrary: Exception intialising ADL library. ADL_Main_Control_Create() caused an exception");
|
||||
}
|
||||
|
||||
SharedLogger.logger.Trace("AMDLibrary/AMDLibrary: Intialising ADL2 library interface");
|
||||
try
|
||||
{
|
||||
if (ADL.ADL2_Main_Control_Create != null)
|
||||
@ -68,7 +50,7 @@ namespace DisplayMagicianShared.AMD
|
||||
|
||||
if (ADLRet == ADL.ADL_OK)
|
||||
{
|
||||
_initialisedADL2 = true;
|
||||
_initialised = true;
|
||||
SharedLogger.logger.Trace("AMDLibrary/AMDLibrary: ADL2 library was initialised successfully");
|
||||
}
|
||||
else
|
||||
@ -85,14 +67,8 @@ namespace DisplayMagicianShared.AMD
|
||||
|
||||
~AMDLibrary()
|
||||
{
|
||||
// If the ADL library was initialised, then we need to free it up.
|
||||
if (_initialised)
|
||||
{
|
||||
if (null != ADL.ADL_Main_Control_Destroy)
|
||||
ADL.ADL_Main_Control_Destroy();
|
||||
}
|
||||
// If the ADL2 library was initialised, then we need to free it up.
|
||||
if (_initialisedADL2)
|
||||
if (_initialised)
|
||||
{
|
||||
if (null != ADL.ADL2_Main_Control_Destroy)
|
||||
ADL.ADL2_Main_Control_Destroy(_adlContextHandle);
|
||||
@ -125,7 +101,7 @@ namespace DisplayMagicianShared.AMD
|
||||
|
||||
public bool IsInstalled
|
||||
{
|
||||
get { return _initialised || _initialisedADL2; }
|
||||
get { return _initialised; }
|
||||
}
|
||||
|
||||
public static AMDLibrary GetLibrary()
|
||||
@ -177,14 +153,12 @@ namespace DisplayMagicianShared.AMD
|
||||
if (oneAdapter.Exist != 1)
|
||||
{
|
||||
SharedLogger.logger.Trace($"AMDLibrary/GenerateProfileDisplayIdentifiers: AMD Adapter #{oneAdapter.AdapterIndex.ToString()} doesn't exist at present so skipping detection for this adapter.");
|
||||
Console.WriteLine($"AMDLibrary/GenerateProfileDisplayIdentifiers: AMD Adapter #{oneAdapter.AdapterIndex.ToString()} doesn't exist at present so skipping detection for this adapter.");
|
||||
continue;
|
||||
}
|
||||
|
||||
if (oneAdapter.Present != 1)
|
||||
{
|
||||
SharedLogger.logger.Trace($"AMDLibrary/GenerateProfileDisplayIdentifiers: AMD Adapter #{oneAdapter.AdapterIndex.ToString()} isn't enabled at present so skipping detection for this adapter.");
|
||||
Console.WriteLine($"AMDLibrary/GenerateProfileDisplayIdentifiers: AMD Adapter #{oneAdapter.AdapterIndex.ToString()} isn't enabled at present so skipping detection for this adapter.");
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -266,7 +240,8 @@ namespace DisplayMagicianShared.AMD
|
||||
{
|
||||
oneDisplayInfo = (ADLDisplayInfo)Marshal.PtrToStructure(new IntPtr(DisplayBuffer.ToInt64() + (displayLoop * Marshal.SizeOf(oneDisplayInfo))), oneDisplayInfo.GetType());
|
||||
|
||||
if (oneDisplayInfo.DisplayID.DisplayLogicalAdapterIndex == -1)
|
||||
// Is the display mapped to this adapter? If not we skip it!
|
||||
if (oneDisplayInfo.DisplayID.DisplayLogicalAdapterIndex != oneAdapter.AdapterIndex)
|
||||
{
|
||||
SharedLogger.logger.Trace($"AMDLibrary/GenerateProfileDisplayIdentifiers: AMD Adapter #{oneAdapter.AdapterIndex.ToString()} ({oneAdapter.AdapterName}) AdapterID display ID#{oneDisplayInfo.DisplayID.DisplayLogicalIndex} is not a real display as its DisplayID.DisplayLogicalAdapterIndex is -1");
|
||||
continue;
|
||||
@ -636,14 +611,12 @@ namespace DisplayMagicianShared.AMD
|
||||
if (oneAdapter.Exist != 1)
|
||||
{
|
||||
SharedLogger.logger.Trace($"AMDLibrary/GenerateAllAvailableDisplayIdentifiers: AMD Adapter #{oneAdapter.AdapterIndex.ToString()} doesn't exist at present so skipping detection for this adapter.");
|
||||
Console.WriteLine($"AMDLibrary/GenerateAllAvailableDisplayIdentifiers: AMD Adapter #{oneAdapter.AdapterIndex.ToString()} doesn't exist at present so skipping detection for this adapter.");
|
||||
continue;
|
||||
}
|
||||
|
||||
if (oneAdapter.Present != 1)
|
||||
{
|
||||
SharedLogger.logger.Trace($"AMDLibrary/GenerateAllAvailableDisplayIdentifiers: AMD Adapter #{oneAdapter.AdapterIndex.ToString()} isn't enabled at present so skipping detection for this adapter.");
|
||||
Console.WriteLine($"AMDLibrary/GenerateAllAvailableDisplayIdentifiers: AMD Adapter #{oneAdapter.AdapterIndex.ToString()} isn't enabled at present so skipping detection for this adapter.");
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -705,9 +678,6 @@ namespace DisplayMagicianShared.AMD
|
||||
SharedLogger.logger.Trace($"AMDLibrary/GenerateAllAvailableDisplayIdentifiers: Adapter Num of GL Sync Connectors = {AdapterCapabilities.NumOfGLSyncConnectors}");
|
||||
SharedLogger.logger.Trace($"AMDLibrary/GenerateAllAvailableDisplayIdentifiers: Adapter Num of Overlays = {AdapterCapabilities.NumOverlays}");
|
||||
|
||||
// Obtain information about displays
|
||||
//ADLDisplayInfoArray displayInfoArray = new ADLDisplayInfoArray();
|
||||
|
||||
if (ADL.ADL2_Display_DisplayInfo_Get != null)
|
||||
{
|
||||
IntPtr DisplayBuffer = IntPtr.Zero;
|
||||
@ -723,11 +693,19 @@ namespace DisplayMagicianShared.AMD
|
||||
|
||||
for (int displayLoop = 0; displayLoop < numDisplays; displayLoop++)
|
||||
{
|
||||
oneDisplayInfo = (ADLDisplayInfo)Marshal.PtrToStructure(new IntPtr(DisplayBuffer.ToInt64() + (displayLoop * Marshal.SizeOf(oneDisplayInfo))), oneDisplayInfo.GetType());
|
||||
oneDisplayInfo = (ADLDisplayInfo)Marshal.PtrToStructure(new IntPtr(DisplayBuffer.ToInt64() + (displayLoop * Marshal.SizeOf(oneDisplayInfo))), oneDisplayInfo.GetType());
|
||||
|
||||
// Is the display mapped to this adapter? If not we skip it!
|
||||
if (oneDisplayInfo.DisplayID.DisplayLogicalAdapterIndex != oneAdapter.AdapterIndex)
|
||||
{
|
||||
SharedLogger.logger.Trace($"AMDLibrary/GenerateAllAvailableDisplayIdentifiers: AMD Adapter #{oneAdapter.AdapterIndex.ToString()} ({oneAdapter.AdapterName}) AdapterID display ID#{oneDisplayInfo.DisplayID.DisplayLogicalIndex} is not a real display as its DisplayID.DisplayLogicalAdapterIndex is -1");
|
||||
continue;
|
||||
}
|
||||
|
||||
// Convert the displayInfoValue to something usable using a library function I made
|
||||
ConvertedDisplayInfoValue displayInfoValue = ADL.ConvertDisplayInfoValue(oneDisplayInfo.DisplayInfoValue);
|
||||
|
||||
// Is the display mapped to this adapter? If not we skip it!
|
||||
if (!displayInfoValue.DISPLAYCONNECTED)
|
||||
{
|
||||
SharedLogger.logger.Trace($"AMDLibrary/GenerateAllAvailableDisplayIdentifiers: AMD Adapter #{oneAdapter.AdapterIndex.ToString()} ({oneAdapter.AdapterName}) AdapterID display ID#{oneDisplayInfo.DisplayID.DisplayLogicalIndex} is not connected");
|
||||
@ -1039,5 +1017,488 @@ namespace DisplayMagicianShared.AMD
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public AMDProfile GetActiveProfile()
|
||||
{
|
||||
SharedLogger.logger.Trace($"AMDLibrary/GetActiveProfile: Getting AMD active adapter count");
|
||||
|
||||
int ADLRet = ADL.ADL_ERR;
|
||||
int NumberOfAdapters = 0;
|
||||
|
||||
List<string> displayIdentifiers = new List<string>();
|
||||
AMDProfile profileToCreate = new AMDProfile();
|
||||
|
||||
if (null != ADL.ADL2_Adapter_NumberOfAdapters_Get)
|
||||
{
|
||||
ADL.ADL2_Adapter_NumberOfAdapters_Get(_adlContextHandle, ref NumberOfAdapters);
|
||||
SharedLogger.logger.Trace($"AMDLibrary/GetActiveProfile: Number Of Adapters: {NumberOfAdapters.ToString()} ");
|
||||
}
|
||||
|
||||
if (NumberOfAdapters > 0)
|
||||
{
|
||||
|
||||
IntPtr AdapterBuffer = IntPtr.Zero;
|
||||
if (ADL.ADL2_Adapter_AdapterInfoX4_Get != null)
|
||||
{
|
||||
SharedLogger.logger.Trace($"AMDLibrary/GetActiveProfile: ADL2_Adapter_AdapterInfoX4_Get DLL function exists.");
|
||||
|
||||
// Get the Adapter info and put it in the AdapterBuffer
|
||||
SharedLogger.logger.Trace($"AMDLibrary/GetActiveProfile: Running ADL2_Adapter_AdapterInfoX4_Get to find all known AMD adapters.");
|
||||
//ADLRet = ADL.ADL2_Adapter_AdapterInfoX4_Get(_adlContextHandle, AdapterBuffer, size);
|
||||
int numAdapters = 0;
|
||||
ADLRet = ADL.ADL2_Adapter_AdapterInfoX4_Get(_adlContextHandle, ADL.ADL_ADAPTER_INDEX_ALL, out numAdapters, out AdapterBuffer);
|
||||
if (ADLRet == ADL.ADL_OK)
|
||||
{
|
||||
|
||||
int IsActive = ADL.ADL_TRUE; // We only want to search for active adapters
|
||||
|
||||
SharedLogger.logger.Trace($"AMDLibrary/GetActiveProfile: Successfully run ADL2_Adapter_AdapterInfoX4_Get to find information about all known AMD adapters.");
|
||||
|
||||
ADLAdapterInfoX2 oneAdapter = new ADLAdapterInfoX2();
|
||||
// Go through each adapter
|
||||
for (int adapterLoop = 0; adapterLoop < numAdapters; adapterLoop++)
|
||||
{
|
||||
oneAdapter = (ADLAdapterInfoX2)Marshal.PtrToStructure(new IntPtr(AdapterBuffer.ToInt64() + (adapterLoop * Marshal.SizeOf(oneAdapter))), oneAdapter.GetType());
|
||||
|
||||
if (oneAdapter.Exist != 1)
|
||||
{
|
||||
SharedLogger.logger.Trace($"AMDLibrary/GetActiveProfile: AMD Adapter #{oneAdapter.AdapterIndex.ToString()} doesn't exist at present so skipping detection for this adapter.");
|
||||
continue;
|
||||
}
|
||||
|
||||
if (oneAdapter.Present != 1)
|
||||
{
|
||||
SharedLogger.logger.Trace($"AMDLibrary/GetActiveProfile: AMD Adapter #{oneAdapter.AdapterIndex.ToString()} isn't enabled at present so skipping detection for this adapter.");
|
||||
continue;
|
||||
}
|
||||
|
||||
// Check if the adapter is active
|
||||
if (ADL.ADL2_Adapter_Active_Get != null)
|
||||
ADLRet = ADL.ADL2_Adapter_Active_Get(_adlContextHandle, oneAdapter.AdapterIndex, ref IsActive);
|
||||
|
||||
if (ADLRet == ADL.ADL_OK)
|
||||
{
|
||||
// Only continue if the adapter is enabled
|
||||
if (IsActive != ADL.ADL_TRUE)
|
||||
{
|
||||
SharedLogger.logger.Trace($"AMDLibrary/GetActiveProfile: AMD Adapter #{oneAdapter.AdapterIndex.ToString()} isn't active ({oneAdapter.AdapterName}).");
|
||||
continue;
|
||||
}
|
||||
|
||||
// Only continue if the adapter index is > 0
|
||||
if (oneAdapter.AdapterIndex < 0)
|
||||
{
|
||||
SharedLogger.logger.Trace($"AMDLibrary/GenerateAllAGetActiveProfilevailableDisplayIdentifiers: AMD Adapter has an adapter index of {oneAdapter.AdapterIndex.ToString()} which indicates it is not a real adapter.");
|
||||
continue;
|
||||
}
|
||||
|
||||
SharedLogger.logger.Trace($"AMDLibrary/GetActiveProfile: AMD Adapter #{oneAdapter.AdapterIndex.ToString()} is active! ({oneAdapter.AdapterName}).");
|
||||
|
||||
SharedLogger.logger.Trace($"AMDLibrary/GetActiveProfile: ### Adapter Info for Adapter #{oneAdapter.AdapterIndex} ###");
|
||||
SharedLogger.logger.Trace($"AMDLibrary/GetActiveProfile: Adapter AdapterIndex = {oneAdapter.AdapterIndex}");
|
||||
SharedLogger.logger.Trace($"AMDLibrary/GetActiveProfile: Adapter AdapterName = {oneAdapter.AdapterName}");
|
||||
SharedLogger.logger.Trace($"AMDLibrary/GetActiveProfile: Adapter BusNumber = {oneAdapter.BusNumber}");
|
||||
SharedLogger.logger.Trace($"AMDLibrary/GetActiveProfile: Adapter DeviceNumber = {oneAdapter.DeviceNumber}");
|
||||
SharedLogger.logger.Trace($"AMDLibrary/GetActiveProfile: Adapter DisplayName = {oneAdapter.DisplayName}");
|
||||
SharedLogger.logger.Trace($"AMDLibrary/GetActiveProfile: Adapter DriverPath = {oneAdapter.DriverPath}");
|
||||
SharedLogger.logger.Trace($"AMDLibrary/GetActiveProfile: Adapter DriverPathExt = {oneAdapter.DriverPathExt}");
|
||||
SharedLogger.logger.Trace($"AMDLibrary/GetActiveProfile: Adapter Exist = {oneAdapter.Exist}");
|
||||
SharedLogger.logger.Trace($"AMDLibrary/GetActiveProfile: Adapter FunctionNumber = {oneAdapter.FunctionNumber}");
|
||||
SharedLogger.logger.Trace($"AMDLibrary/GetActiveProfile: Adapter InfoMask = {oneAdapter.InfoMask}");
|
||||
SharedLogger.logger.Trace($"AMDLibrary/GetActiveProfile: Adapter InfoValue = {oneAdapter.InfoValue}");
|
||||
SharedLogger.logger.Trace($"AMDLibrary/GetActiveProfile: Adapter OSDisplayIndex = {oneAdapter.OSDisplayIndex}");
|
||||
SharedLogger.logger.Trace($"AMDLibrary/GetActiveProfile: Adapter PNPString = {oneAdapter.PNPString}");
|
||||
SharedLogger.logger.Trace($"AMDLibrary/GetActiveProfile: Adapter Present = {oneAdapter.Present}");
|
||||
SharedLogger.logger.Trace($"AMDLibrary/GetActiveProfile: Adapter Size = {oneAdapter.Size}");
|
||||
SharedLogger.logger.Trace($"AMDLibrary/GetActiveProfile: Adapter UDID = {oneAdapter.UDID}");
|
||||
SharedLogger.logger.Trace($"AMDLibrary/GetActiveProfile: Adapter VendorID = {oneAdapter.VendorID}");
|
||||
|
||||
// Get the Adapter Capabilities
|
||||
ADLAdapterCapsX2 AdapterCapabilities = new ADLAdapterCapsX2();
|
||||
if (ADL.ADL2_AdapterX2_Caps != null)
|
||||
{
|
||||
ADLRet = ADL.ADL2_AdapterX2_Caps(_adlContextHandle, oneAdapter.AdapterIndex, out AdapterCapabilities);
|
||||
}
|
||||
|
||||
SharedLogger.logger.Trace($"AMDLibrary/GetActiveProfile: ### Adapter Capabilities for Adapter #{oneAdapter.AdapterIndex} ###");
|
||||
SharedLogger.logger.Trace($"AMDLibrary/GetActiveProfile: Adapter ID = {AdapterCapabilities.AdapterID}");
|
||||
SharedLogger.logger.Trace($"AMDLibrary/GetActiveProfile: Adapter Capabilities Mask = {AdapterCapabilities.CapsMask}");
|
||||
SharedLogger.logger.Trace($"AMDLibrary/GetActiveProfile: Adapter Capabilities Value = {AdapterCapabilities.CapsValue}");
|
||||
SharedLogger.logger.Trace($"AMDLibrary/GetActiveProfile: Adapter Num of Connectors = {AdapterCapabilities.NumConnectors}");
|
||||
SharedLogger.logger.Trace($"AMDLibrary/GetActiveProfile: Adapter Num of Controllers = {AdapterCapabilities.NumControllers}");
|
||||
SharedLogger.logger.Trace($"AMDLibrary/GetActiveProfile: Adapter Num of Displays = {AdapterCapabilities.NumDisplays}");
|
||||
SharedLogger.logger.Trace($"AMDLibrary/GetActiveProfile: Adapter Num of GL Sync Connectors = {AdapterCapabilities.NumOfGLSyncConnectors}");
|
||||
SharedLogger.logger.Trace($"AMDLibrary/GetActiveProfile: Adapter Num of Overlays = {AdapterCapabilities.NumOverlays}");
|
||||
|
||||
if (ADL.ADL2_Display_DisplayInfo_Get != null)
|
||||
{
|
||||
IntPtr DisplayBuffer = IntPtr.Zero;
|
||||
int numDisplays = 0;
|
||||
// Force the display detection and get the Display Info. Use 0 as last parameter to NOT force detection
|
||||
ADLRet = ADL.ADL2_Display_DisplayInfo_Get(_adlContextHandle, oneAdapter.AdapterIndex, ref numDisplays, out DisplayBuffer, 1);
|
||||
if (ADLRet == ADL.ADL_OK)
|
||||
{
|
||||
|
||||
try
|
||||
{
|
||||
ADLDisplayInfo oneDisplayInfo = new ADLDisplayInfo();
|
||||
|
||||
for (int displayLoop = 0; displayLoop < numDisplays; displayLoop++)
|
||||
{
|
||||
oneDisplayInfo = (ADLDisplayInfo)Marshal.PtrToStructure(new IntPtr(DisplayBuffer.ToInt64() + (displayLoop * Marshal.SizeOf(oneDisplayInfo))), oneDisplayInfo.GetType());
|
||||
|
||||
// Is the display mapped to this adapter? If not we skip it!
|
||||
if (oneDisplayInfo.DisplayID.DisplayLogicalAdapterIndex != oneAdapter.AdapterIndex)
|
||||
{
|
||||
SharedLogger.logger.Trace($"AMDLibrary/GetActiveProfile: AMD Adapter #{oneAdapter.AdapterIndex.ToString()} ({oneAdapter.AdapterName}) AdapterID display ID#{oneDisplayInfo.DisplayID.DisplayLogicalIndex} is not a real display as its DisplayID.DisplayLogicalAdapterIndex is -1");
|
||||
continue;
|
||||
}
|
||||
|
||||
// Convert the displayInfoValue to something usable using a library function I made
|
||||
ConvertedDisplayInfoValue displayInfoValue = ADL.ConvertDisplayInfoValue(oneDisplayInfo.DisplayInfoValue);
|
||||
|
||||
if (!displayInfoValue.DISPLAYCONNECTED)
|
||||
{
|
||||
SharedLogger.logger.Trace($"AMDLibrary/GetActiveProfile: AMD Adapter #{oneAdapter.AdapterIndex.ToString()} ({oneAdapter.AdapterName}) AdapterID display ID#{oneDisplayInfo.DisplayID.DisplayLogicalIndex} is not connected");
|
||||
continue;
|
||||
}
|
||||
|
||||
// Skip connected but non-mapped displays (not mapped in windows) - we only want displays currently visible in the OS because they're in use
|
||||
if (!displayInfoValue.DISPLAYMAPPED)
|
||||
{
|
||||
SharedLogger.logger.Trace($"AMDLibrary/GetActiveProfile: AMD Adapter #{oneAdapter.AdapterIndex.ToString()} ({oneAdapter.AdapterName}) AdapterID display ID#{oneDisplayInfo.DisplayID.DisplayLogicalIndex} is not mapped in Windows OS");
|
||||
continue;
|
||||
}
|
||||
|
||||
SharedLogger.logger.Trace($"AMDLibrary/GetActiveProfile: AMD Adapter #{oneAdapter.AdapterIndex.ToString()} ({oneAdapter.AdapterName}) AdapterID display ID#{oneDisplayInfo.DisplayID.DisplayLogicalIndex} is connected and mapped in Windows OS");
|
||||
|
||||
ADL.ADLDisplayConnectionType displayConnector = (ADL.ADLDisplayConnectionType)oneDisplayInfo.DisplayConnector;
|
||||
|
||||
SharedLogger.logger.Trace($"AMDLibrary/GetActiveprofile: ### Display Info for Display #{oneDisplayInfo.DisplayID.DisplayLogicalIndex} on Adapter #{oneAdapter.AdapterIndex} ###");
|
||||
SharedLogger.logger.Trace($"AMDLibrary/GetActiveprofile: Display Connector = {displayConnector.ToString("G")}");
|
||||
SharedLogger.logger.Trace($"AMDLibrary/GetActiveprofile: Display Controller Index = {oneDisplayInfo.DisplayControllerIndex}");
|
||||
SharedLogger.logger.Trace($"AMDLibrary/GetActiveprofile: Display Logical Adapter Index = {oneDisplayInfo.DisplayID.DisplayLogicalAdapterIndex}");
|
||||
SharedLogger.logger.Trace($"AMDLibrary/GetActiveprofile: Display Logical Index = {oneDisplayInfo.DisplayID.DisplayLogicalIndex}");
|
||||
SharedLogger.logger.Trace($"AMDLibrary/GetActiveprofile: Display Physical Adapter Index = {oneDisplayInfo.DisplayID.DisplayPhysicalAdapterIndex}");
|
||||
SharedLogger.logger.Trace($"AMDLibrary/GetActiveprofile: Display Physical Index = {oneDisplayInfo.DisplayID.DisplayPhysicalIndex}");
|
||||
SharedLogger.logger.Trace($"AMDLibrary/GetActiveprofile: Display Info Mask = {oneDisplayInfo.DisplayInfoMask}");
|
||||
SharedLogger.logger.Trace($"AMDLibrary/GetActiveprofile: Display Info Value = {oneDisplayInfo.DisplayInfoValue}");
|
||||
SharedLogger.logger.Trace($"AMDLibrary/GetActiveprofile: Display Manufacturer Name = {oneDisplayInfo.DisplayManufacturerName}");
|
||||
SharedLogger.logger.Trace($"AMDLibrary/GetActiveprofile: Display Name = {oneDisplayInfo.DisplayName}");
|
||||
SharedLogger.logger.Trace($"AMDLibrary/GetActiveprofile: Display Output Type = {oneDisplayInfo.DisplayOutputType}");
|
||||
SharedLogger.logger.Trace($"AMDLibrary/GetActiveprofile: Display Type = {oneDisplayInfo.DisplayType}");
|
||||
|
||||
SharedLogger.logger.Trace($"AMDLibrary/GetActiveprofile: Display Info Value DISPLAYCONNECTED = {displayInfoValue.DISPLAYCONNECTED}");
|
||||
SharedLogger.logger.Trace($"AMDLibrary/GetActiveprofile: Display Info Value DISPLAYMAPPED = {displayInfoValue.DISPLAYMAPPED}");
|
||||
SharedLogger.logger.Trace($"AMDLibrary/GetActiveprofile: Display Info Value FORCIBLESUPPORTED = {displayInfoValue.FORCIBLESUPPORTED}");
|
||||
SharedLogger.logger.Trace($"AMDLibrary/GetActiveprofile: Display Info Value GENLOCKSUPPORTED = {displayInfoValue.GENLOCKSUPPORTED}");
|
||||
SharedLogger.logger.Trace($"AMDLibrary/GetActiveprofile: Display Info Value LDA_DISPLAY = {displayInfoValue.LDA_DISPLAY}");
|
||||
SharedLogger.logger.Trace($"AMDLibrary/GetActiveprofile: Display Info Value MANNER_SUPPORTED_2HSTRETCH = {displayInfoValue.MANNER_SUPPORTED_2HSTRETCH}");
|
||||
SharedLogger.logger.Trace($"AMDLibrary/GetActiveprofile: Display Info Value MANNER_SUPPORTED_2VSTRETCH = {displayInfoValue.MANNER_SUPPORTED_2VSTRETCH}");
|
||||
SharedLogger.logger.Trace($"AMDLibrary/GetActiveprofile: Display Info Value MANNER_SUPPORTED_CLONE = {displayInfoValue.MANNER_SUPPORTED_CLONE}");
|
||||
SharedLogger.logger.Trace($"AMDLibrary/GetActiveprofile: Display Info Value MANNER_SUPPORTED_EXTENDED = {displayInfoValue.MANNER_SUPPORTED_EXTENDED}");
|
||||
SharedLogger.logger.Trace($"AMDLibrary/GetActiveprofile: Display Info Value MANNER_SUPPORTED_NSTRETCH1GPU = {displayInfoValue.MANNER_SUPPORTED_NSTRETCH1GPU}");
|
||||
SharedLogger.logger.Trace($"AMDLibrary/GetActiveprofile: Display Info Value MANNER_SUPPORTED_NSTRETCHNGPU = {displayInfoValue.MANNER_SUPPORTED_NSTRETCHNGPU}");
|
||||
SharedLogger.logger.Trace($"AMDLibrary/GetActiveprofile: Display Info Value MANNER_SUPPORTED_SINGLE = {displayInfoValue.MANNER_SUPPORTED_SINGLE}");
|
||||
SharedLogger.logger.Trace($"AMDLibrary/GetActiveprofile: Display Info Value MODETIMING_OVERRIDESSUPPORTED = {displayInfoValue.MODETIMING_OVERRIDESSUPPORTED}");
|
||||
SharedLogger.logger.Trace($"AMDLibrary/GetActiveprofile: Display Info Value MULTIVPU_SUPPORTED = {displayInfoValue.MULTIVPU_SUPPORTED}");
|
||||
SharedLogger.logger.Trace($"AMDLibrary/GetActiveprofile: Display Info Value NONLOCAL = {displayInfoValue.NONLOCAL}");
|
||||
SharedLogger.logger.Trace($"AMDLibrary/GetActiveprofile: Display Info Value SHOWTYPE_PROJECTOR = {displayInfoValue.SHOWTYPE_PROJECTOR}");
|
||||
|
||||
ADL.ADLDisplayConnectionType displayConnectionType = ADL.ADLDisplayConnectionType.Unknown;
|
||||
ADLMode oneDisplayMode = new ADLMode();
|
||||
IntPtr displayModeBuffer = IntPtr.Zero;
|
||||
int numModes = 0;
|
||||
if (ADL.ADL2_Display_Modes_Get != null)
|
||||
{
|
||||
// Get the ADLModes from the Display
|
||||
ADLRet = ADL.ADL2_Display_Modes_Get(_adlContextHandle, oneAdapter.AdapterIndex, oneDisplayInfo.DisplayID.DisplayPhysicalIndex, out numModes, out displayModeBuffer);
|
||||
if (ADLRet == ADL.ADL_OK)
|
||||
{
|
||||
for (int displayModeLoop = 0; displayModeLoop < numDisplays; displayModeLoop++)
|
||||
{
|
||||
oneDisplayMode = (ADLMode)Marshal.PtrToStructure(new IntPtr(displayModeBuffer.ToInt64() + (displayModeLoop * Marshal.SizeOf(oneDisplayMode))), oneDisplayMode.GetType());
|
||||
|
||||
//displayConnectionType = (ADL.ADLDisplayConnectionType)displayConfig.ConnectorType;
|
||||
|
||||
SharedLogger.logger.Trace($"AMDLibrary/GetActiveprofile: ### Display Modes for Display #{oneDisplayInfo.DisplayID.DisplayLogicalIndex} on Adapter #{oneAdapter.AdapterIndex} ###");
|
||||
SharedLogger.logger.Trace($"AMDLibrary/GetActiveprofile: DisplayMode Colour Depth = {oneDisplayMode.ColourDepth}");
|
||||
SharedLogger.logger.Trace($"AMDLibrary/GetActiveprofile: DisplayMode Mode Flag = {oneDisplayMode.ModeFlag}");
|
||||
SharedLogger.logger.Trace($"AMDLibrary/GetActiveprofile: DisplayMode Mode Mask = {oneDisplayMode.ModeMask}");
|
||||
SharedLogger.logger.Trace($"AMDLibrary/GetActiveprofile: DisplayMode Mode Value = {oneDisplayMode.ModeValue}");
|
||||
SharedLogger.logger.Trace($"AMDLibrary/GetActiveprofile: DisplayMode Orientation = {oneDisplayMode.Orientation}");
|
||||
SharedLogger.logger.Trace($"AMDLibrary/GetActiveprofile: DisplayMode Refresh Rate = {oneDisplayMode.RefreshRate}");
|
||||
SharedLogger.logger.Trace($"AMDLibrary/GetActiveprofile: DisplayMode X Position = {oneDisplayMode.XPos}");
|
||||
SharedLogger.logger.Trace($"AMDLibrary/GetActiveprofile: DisplayMode X Resolution = {oneDisplayMode.XRes}");
|
||||
SharedLogger.logger.Trace($"AMDLibrary/GetActiveprofile: DisplayMode Y Position = {oneDisplayMode.YPos}");
|
||||
SharedLogger.logger.Trace($"AMDLibrary/GetActiveprofile: DisplayMode Y Resolution = {oneDisplayMode.YRes}");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
SharedLogger.logger.Warn($"AMDLibrary/GetActiveprofile: Error running ADL2_Display_DeviceConfig_Get on Display #{oneDisplayInfo.DisplayID.DisplayLogicalIndex} on Adapter #{oneAdapter.AdapterIndex}: {ADL.ConvertADLReturnValueIntoWords(ADLRet)}");
|
||||
}
|
||||
}
|
||||
|
||||
ADLDDCInfo2 displayDDCInfo2 = new ADLDDCInfo2();
|
||||
displayDDCInfo2.Size = Marshal.SizeOf(displayDDCInfo2);
|
||||
// Create a stringbuilder buffer that EDID can be loaded into
|
||||
//displayEDIDData.EDIDData = new StringBuilder(256);
|
||||
|
||||
if (ADL.ADL2_Display_DDCInfo2_Get != null)
|
||||
{
|
||||
// Get the DDC Data from the Display
|
||||
ADLRet = ADL.ADL2_Display_DDCInfo2_Get(_adlContextHandle, oneAdapter.AdapterIndex, oneDisplayInfo.DisplayID.DisplayPhysicalIndex, out displayDDCInfo2);
|
||||
if (ADLRet == ADL.ADL_OK)
|
||||
{
|
||||
|
||||
// Convert the DDCInfoFlag to something usable using a library function I made
|
||||
ConvertedDDCInfoFlag DDCInfoFlag = ADL.ConvertDDCInfoFlag(displayDDCInfo2.DDCInfoFlag);
|
||||
|
||||
// Convert the DDCInfoFlag to something usable using a library function I made
|
||||
ConvertedSupportedHDR supportedHDR = ADL.ConvertSupportedHDR(displayDDCInfo2.SupportedHDR);
|
||||
|
||||
SharedLogger.logger.Trace($"AMDLibrary/GetActiveprofile: ### Display DDCInfo2 for Display #{oneDisplayInfo.DisplayID.DisplayLogicalIndex} on Adapter #{oneAdapter.AdapterIndex} ###");
|
||||
SharedLogger.logger.Trace($"AMDLibrary/GetActiveprofile: Display AvgLuminanceData = {displayDDCInfo2.AvgLuminanceData}");
|
||||
SharedLogger.logger.Trace($"AMDLibrary/GetActiveprofile: Display DDCInfoFlag = {displayDDCInfo2.DDCInfoFlag}");
|
||||
SharedLogger.logger.Trace($"AMDLibrary/GetActiveprofile: Display DiffuseScreenReflectance = {displayDDCInfo2.DiffuseScreenReflectance}");
|
||||
SharedLogger.logger.Trace($"AMDLibrary/GetActiveprofile: Display DisplayName = {displayDDCInfo2.DisplayName}");
|
||||
SharedLogger.logger.Trace($"AMDLibrary/GetActiveprofile: Display FreesyncFlags = {displayDDCInfo2.FreesyncFlags}");
|
||||
SharedLogger.logger.Trace($"AMDLibrary/GetActiveprofile: Display ManufacturerID = {displayDDCInfo2.ManufacturerID}");
|
||||
SharedLogger.logger.Trace($"AMDLibrary/GetActiveprofile: Display MaxBacklightMaxLuminanceData = {displayDDCInfo2.MaxBacklightMaxLuminanceData}");
|
||||
SharedLogger.logger.Trace($"AMDLibrary/GetActiveprofile: Display MaxBacklightMinLuminanceData = {displayDDCInfo2.MaxBacklightMinLuminanceData}");
|
||||
SharedLogger.logger.Trace($"AMDLibrary/GetActiveprofile: Display MaxHResolution = {displayDDCInfo2.MaxHResolution}");
|
||||
SharedLogger.logger.Trace($"AMDLibrary/GetActiveprofile: Display MaxLuminanceData = {displayDDCInfo2.MaxLuminanceData}");
|
||||
SharedLogger.logger.Trace($"AMDLibrary/GetActiveprofile: Display MaxRefresh = {displayDDCInfo2.MaxRefresh}");
|
||||
SharedLogger.logger.Trace($"AMDLibrary/GetActiveprofile: Display MaxVResolution = {displayDDCInfo2.MaxVResolution}");
|
||||
SharedLogger.logger.Trace($"AMDLibrary/GetActiveprofile: Display MinBacklightMaxLuminanceData = {displayDDCInfo2.MinBacklightMaxLuminanceData}");
|
||||
SharedLogger.logger.Trace($"AMDLibrary/GetActiveprofile: Display MinBacklightMinLuminanceData = {displayDDCInfo2.MinBacklightMinLuminanceData}");
|
||||
SharedLogger.logger.Trace($"AMDLibrary/GetActiveprofile: Display MinLuminanceData = {displayDDCInfo2.MinLuminanceData}");
|
||||
SharedLogger.logger.Trace($"AMDLibrary/GetActiveprofile: Display MinLuminanceNoDimmingData = {displayDDCInfo2.MinLuminanceNoDimmingData}");
|
||||
SharedLogger.logger.Trace($"AMDLibrary/GetActiveprofile: Display NativeDisplayChromaticityBlueX = {displayDDCInfo2.NativeDisplayChromaticityBlueX}");
|
||||
SharedLogger.logger.Trace($"AMDLibrary/GetActiveprofile: Display NativeDisplayChromaticityBlueY = {displayDDCInfo2.NativeDisplayChromaticityBlueY}");
|
||||
SharedLogger.logger.Trace($"AMDLibrary/GetActiveprofile: Display NativeDisplayChromaticityGreenX = {displayDDCInfo2.NativeDisplayChromaticityGreenX}");
|
||||
SharedLogger.logger.Trace($"AMDLibrary/GetActiveprofile: Display NativeDisplayChromaticityGreenY = {displayDDCInfo2.NativeDisplayChromaticityGreenY}");
|
||||
SharedLogger.logger.Trace($"AMDLibrary/GetActiveprofile: Display NativeDisplayChromaticityRedX = {displayDDCInfo2.NativeDisplayChromaticityRedX}");
|
||||
SharedLogger.logger.Trace($"AMDLibrary/GetActiveprofile: Display NativeDisplayChromaticityRedY = {displayDDCInfo2.NativeDisplayChromaticityRedY}");
|
||||
SharedLogger.logger.Trace($"AMDLibrary/GetActiveprofile: Display NativeDisplayChromaticityWhiteX = {displayDDCInfo2.NativeDisplayChromaticityWhiteX}");
|
||||
SharedLogger.logger.Trace($"AMDLibrary/GetActiveprofile: Display NativeDisplayChromaticityWhiteY = {displayDDCInfo2.NativeDisplayChromaticityWhiteY}");
|
||||
SharedLogger.logger.Trace($"AMDLibrary/GetActiveprofile: Display PackedPixelSupported = {displayDDCInfo2.PackedPixelSupported}");
|
||||
SharedLogger.logger.Trace($"AMDLibrary/GetActiveprofile: Display PanelPixelFormat = {displayDDCInfo2.PanelPixelFormat}");
|
||||
SharedLogger.logger.Trace($"AMDLibrary/GetActiveprofile: Display ProductID = {displayDDCInfo2.ProductID}");
|
||||
SharedLogger.logger.Trace($"AMDLibrary/GetActiveprofile: Display PTMCx = {displayDDCInfo2.PTMCx}");
|
||||
SharedLogger.logger.Trace($"AMDLibrary/GetActiveprofile: Display PTMCy = {displayDDCInfo2.PTMCy}");
|
||||
SharedLogger.logger.Trace($"AMDLibrary/GetActiveprofile: Display PTMRefreshRate = {displayDDCInfo2.PTMRefreshRate}");
|
||||
SharedLogger.logger.Trace($"AMDLibrary/GetActiveprofile: Display SerialID = {displayDDCInfo2.SerialID}");
|
||||
SharedLogger.logger.Trace($"AMDLibrary/GetActiveprofile: Display Size = {displayDDCInfo2.Size}");
|
||||
SharedLogger.logger.Trace($"AMDLibrary/GetActiveprofile: Display SpecularScreenReflectance = {displayDDCInfo2.SpecularScreenReflectance}");
|
||||
SharedLogger.logger.Trace($"AMDLibrary/GetActiveprofile: Display SupportedColorSpace = {displayDDCInfo2.SupportedColorSpace}");
|
||||
SharedLogger.logger.Trace($"AMDLibrary/GetActiveprofile: Display SupportedHDR = {displayDDCInfo2.SupportedHDR}");
|
||||
SharedLogger.logger.Trace($"AMDLibrary/GetActiveprofile: Display SupportedTransferFunction = {displayDDCInfo2.SupportedTransferFunction}");
|
||||
SharedLogger.logger.Trace($"AMDLibrary/GetActiveprofile: Display SupportsDDC = {displayDDCInfo2.SupportsDDC}");
|
||||
SharedLogger.logger.Trace($"AMDLibrary/GetActiveprofile: Display DDCInfoFlag Digital Device = {DDCInfoFlag.DIGITALDEVICE}");
|
||||
SharedLogger.logger.Trace($"AMDLibrary/GetActiveprofile: Display DDCInfoFlag EDID Extension = {DDCInfoFlag.EDIDEXTENSION}");
|
||||
SharedLogger.logger.Trace($"AMDLibrary/GetActiveprofile: Display DDCInfoFlag HDMI Audio Device = {DDCInfoFlag.HDMIAUDIODEVICE}");
|
||||
SharedLogger.logger.Trace($"AMDLibrary/GetActiveprofile: Display DDCInfoFlag Projector Device = {DDCInfoFlag.PROJECTORDEVICE}");
|
||||
SharedLogger.logger.Trace($"AMDLibrary/GetActiveprofile: Display DDCInfoFlag Supports AI = {DDCInfoFlag.SUPPORTS_AI}");
|
||||
SharedLogger.logger.Trace($"AMDLibrary/GetActiveprofile: Display DDCInfoFlag Supports xvYCC601 = {DDCInfoFlag.SUPPORT_xvYCC601}");
|
||||
SharedLogger.logger.Trace($"AMDLibrary/GetActiveprofile: Display DDCInfoFlag Supports xvYCC709 = {DDCInfoFlag.SUPPORT_xvYCC709}");
|
||||
SharedLogger.logger.Trace($"AMDLibrary/GetActiveprofile: Display SupportedHDR Supports CEA861_3 = {supportedHDR.CEA861_3}");
|
||||
SharedLogger.logger.Trace($"AMDLibrary/GetActiveprofile: Display SupportedHDR Supports DOLBYVISION = {supportedHDR.DOLBYVISION}");
|
||||
SharedLogger.logger.Trace($"AMDLibrary/GetActiveprofile: Display SupportedHDR Supports FREESYNC_HDR = {supportedHDR.FREESYNC_HDR}");
|
||||
}
|
||||
else
|
||||
{
|
||||
SharedLogger.logger.Warn($"AMDLibrary/GetActiveprofile: Error running ADL2_Display_DDCInfo2_Get on Display #{oneDisplayInfo.DisplayID.DisplayLogicalIndex} on Adapter #{oneAdapter.AdapterIndex}: {ADL.ConvertADLReturnValueIntoWords(ADLRet)}");
|
||||
}
|
||||
}
|
||||
|
||||
int HDRSupported = 0;
|
||||
int HDREnabled = 0;
|
||||
if (ADL.ADL2_Display_HDRState_Get != null)
|
||||
{
|
||||
// Get the HDR State from the Display
|
||||
ADLRet = ADL.ADL2_Display_HDRState_Get(_adlContextHandle, oneAdapter.AdapterIndex, oneDisplayInfo.DisplayID, out HDRSupported, out HDREnabled);
|
||||
if (ADLRet == ADL.ADL_OK)
|
||||
{
|
||||
SharedLogger.logger.Trace($"AMDLibrary/GetActiveprofile: ### Display HDR State for Display #{oneDisplayInfo.DisplayID.DisplayLogicalIndex} on Adapter #{oneAdapter.AdapterIndex} ###");
|
||||
SharedLogger.logger.Trace($"AMDLibrary/GetActiveprofile: Display HDR Supported = {HDRSupported}");
|
||||
SharedLogger.logger.Trace($"AMDLibrary/GetActiveprofile: Display HDR Enabled = {HDREnabled}");
|
||||
}
|
||||
else
|
||||
{
|
||||
SharedLogger.logger.Warn($"AMDLibrary/GetActiveprofile: Error running ADL2_Display_HDRState_Get on Display #{oneDisplayInfo.DisplayID.DisplayLogicalIndex} on Adapter #{oneAdapter.AdapterIndex}: {ADL.ConvertADLReturnValueIntoWords(ADLRet)}");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Create an array of all the important display info we need to record
|
||||
List<string> displayInfoIdentifierSection = new List<string>();
|
||||
displayInfoIdentifierSection.Add("AMD");
|
||||
try
|
||||
{
|
||||
displayInfoIdentifierSection.Add(oneAdapter.VendorID.ToString());
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
SharedLogger.logger.Warn(ex, $"AMDLibrary/GetActiveprofile: Exception getting AMD Vendor ID from video card. Substituting with a # instead");
|
||||
displayInfoIdentifierSection.Add("#");
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
displayInfoIdentifierSection.Add(oneAdapter.AdapterName);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
SharedLogger.logger.Warn(ex, $"AMDLibrary/GetActiveprofile: Exception getting AMD Adapter Name from video card. Substituting with a # instead");
|
||||
displayInfoIdentifierSection.Add("#");
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
displayInfoIdentifierSection.Add(oneAdapter.VendorID.ToString());
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
SharedLogger.logger.Warn(ex, $"AMDLibrary/GetActiveprofile: Exception getting AMD VendorID from video card. Substituting with a # instead");
|
||||
displayInfoIdentifierSection.Add("1002");
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
displayInfoIdentifierSection.Add(AdapterCapabilities.AdapterID.ToString());
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
SharedLogger.logger.Warn(ex, $"AMDLibrary/GetActiveprofile: Exception getting AMD AdapterID from video card. Substituting with a # instead");
|
||||
displayInfoIdentifierSection.Add("#");
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
displayInfoIdentifierSection.Add(displayConnector.ToString("G"));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
SharedLogger.logger.Warn(ex, $"AMDLibrary/GetActiveprofile: Exception getting AMD Display Connector from video card to display. Substituting with a # instead");
|
||||
displayInfoIdentifierSection.Add("#");
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
displayInfoIdentifierSection.Add(oneDisplayInfo.DisplayName);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
SharedLogger.logger.Warn(ex, $"AMDLibrary/GetActiveprofile: Exception getting Display Name from display connected to AMD video card. Substituting with a # instead");
|
||||
displayInfoIdentifierSection.Add("#");
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
displayInfoIdentifierSection.Add(displayDDCInfo2.ManufacturerID.ToString());
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
SharedLogger.logger.Warn(ex, $"AMDLibrary/GetActiveprofile: Exception getting Manufacturer ID from display connected to AMD video card. Substituting with a # instead");
|
||||
displayInfoIdentifierSection.Add("#");
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
displayInfoIdentifierSection.Add(displayDDCInfo2.ProductID.ToString());
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
SharedLogger.logger.Warn(ex, $"AMDLibrary/GetActiveprofile: Exception getting Product ID from display connected to AMD video card. Substituting with a # instead");
|
||||
displayInfoIdentifierSection.Add("#");
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
displayInfoIdentifierSection.Add(displayDDCInfo2.SerialID.ToString());
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
SharedLogger.logger.Warn(ex, $"AMDLibrary/GetActiveprofile: Exception getting Serial ID from display connected to AMD video card. Substituting with a # instead");
|
||||
displayInfoIdentifierSection.Add("#");
|
||||
}
|
||||
|
||||
// Create a display identifier out of it
|
||||
string displayIdentifier = String.Join("|", displayInfoIdentifierSection);
|
||||
|
||||
// Check first to see if there is already an existing display identifier the same!
|
||||
// This appears to be a bug with the AMD driver, or with the install on my test machine
|
||||
// Either way, it is potentially going to happen in the wild, so I will filter it out if it does
|
||||
if (displayIdentifiers.Contains(displayIdentifier))
|
||||
{
|
||||
SharedLogger.logger.Trace($"AMDLibrary/GetActiveprofile: Your AMD driver reported the following Display Identifier multiple times, so ignoring it as we already have it: {displayIdentifier}");
|
||||
continue;
|
||||
}
|
||||
|
||||
// Add it to the list of display identifiers so we can return it
|
||||
displayIdentifiers.Add(displayIdentifier);
|
||||
|
||||
SharedLogger.logger.Debug($"ProfileRepository/GetActiveprofile: DisplayIdentifier: {displayIdentifier}");
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
SharedLogger.logger.Warn(ex, $"ProfileRepository/GetActiveprofile: Exception caused trying to access attached displays");
|
||||
continue;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
SharedLogger.logger.Warn($"AMDLibrary/GetActiveprofile: Error running ADL2_Display_DisplayInfo_Get on Adapter #{oneAdapter.AdapterIndex}: {ADL.ConvertADLReturnValueIntoWords(ADLRet)}");
|
||||
}
|
||||
// Release the memory for the DisplayInfo structure
|
||||
if (IntPtr.Zero != DisplayBuffer)
|
||||
Marshal.FreeCoTaskMem(DisplayBuffer);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
SharedLogger.logger.Warn($"AMDLibrary/GetActiveprofile: Error running ADL2_Adapter_Active_Get on Adapter #{oneAdapter.AdapterIndex}: {ADL.ConvertADLReturnValueIntoWords(ADLRet)}");
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
SharedLogger.logger.Warn($"AMDLibrary/GetActiveprofile: Error running ADL2_Adapter_AdapterInfoX4_Get on AMD Video card: {ADL.ConvertADLReturnValueIntoWords(ADLRet)}");
|
||||
}
|
||||
}
|
||||
// Release the memory for the AdapterInfo structure
|
||||
if (IntPtr.Zero != AdapterBuffer)
|
||||
{
|
||||
Marshal.FreeCoTaskMem(AdapterBuffer);
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
SharedLogger.logger.Warn($"AMDLibrary/GetActiveprofile: There were no AMD adapters found by AMD ADL.");
|
||||
|
||||
}
|
||||
|
||||
// Return the profile
|
||||
return profileToCreate;
|
||||
}
|
||||
|
||||
public void SetActiveProfile(AMDProfile profileToUse)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void IsActiveProfile(AMDProfile profileToTest)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void IsValidProfile(AMDProfile profileToTest)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -26,7 +26,7 @@ namespace DisplayMagicianShared
|
||||
private static List<ProfileItem> _allProfiles = new List<ProfileItem>();
|
||||
public static Dictionary<string, bool> _profileWarningLookup = new Dictionary<string, bool>();
|
||||
private static bool _profilesLoaded = false;
|
||||
public static Version _version = new Version(1, 0, 0);
|
||||
public static Version _version = new Version(2, 0, 0);
|
||||
private static ProfileItem _currentProfile;
|
||||
private static List<string> _connectedDisplayIdentifiers = new List<string>();
|
||||
private static bool notifiedEDIDErrorToUser = false;
|
||||
|
Loading…
Reference in New Issue
Block a user