mirror of
https://github.com/terrymacdonald/DisplayMagician.git
synced 2024-08-30 18:32:20 +00:00
[WIP] Working nearly DisplayIds
Have now go the required data, but for some reason AMD is returning two valid adapters when there is actually just one in the system! Could be a problem with the device installation, but I will need figuring out how to either remove duplicates, or figure out the information to use as a filter for ignoring one of the adapters.
This commit is contained in:
parent
0808c6b1ba
commit
16c143cffe
@ -896,7 +896,7 @@ namespace ATI.ADL
|
||||
/// <summary> Define the maximum device name length</summary>
|
||||
internal const int ADL_MAX_DEVICENAME = 32;
|
||||
/// <summary> Define the maximum EDID Data length</summary>
|
||||
internal const int ADL_MAX_EDIDDATA_SIZE = 256;
|
||||
internal const int ADL_MAX_EDIDDATA_SIZE = 256; // number of UCHAR
|
||||
/// <summary> Define the maximum display names</summary>
|
||||
internal const int ADL_MAX_DISPLAY_NAME = 256;
|
||||
|
||||
@ -1012,6 +1012,44 @@ namespace ATI.ADL
|
||||
/// <summary> Indicates Virtual Connector type.</summary>
|
||||
internal const int ADL_CONNECTOR_TYPE_VIRTUAL = 13;
|
||||
|
||||
// ADL Display Connector Types
|
||||
/// <summary> Indicates Unknown Display Connector type.</summary>
|
||||
internal const int ADL_DISPLAY_CONTYPE_UNKNOWN = 0;
|
||||
/// <summary> Indicates VGA Display Connector type.</summary>
|
||||
internal const int ADL_DISPLAY_CONTYPE_VGA = 1;
|
||||
/// <summary> Indicates DVI-D Display Connector type.</summary>
|
||||
internal const int ADL_DISPLAY_CONTYPE_DVI_D = 2;
|
||||
/// <summary> Indicates DVI-I Display Connector type.</summary>
|
||||
internal const int ADL_DISPLAY_CONTYPE_DVI_I = 3;
|
||||
/// <summary> Indicates ATICV NTSC Dongle Display Connector type.</summary>
|
||||
internal const int ADL_DISPLAY_CONTYPE_ATICVDONGLE_NTSC = 4;
|
||||
/// <summary> Indicates ATICV Japanese Display Connector type.</summary>
|
||||
internal const int ADL_DISPLAY_CONTYPE_ATICVDONGLE_JPN = 5;
|
||||
/// <summary> Indicates ATICV non-I2C Japanese Display Connector type.</summary>
|
||||
internal const int ADL_DISPLAY_CONTYPE_ATICVDONGLE_NONI2C_JPN = 6;
|
||||
/// <summary> Indicates ATICV non-I2C NTSC Display Connector type.</summary>
|
||||
internal const int ADL_DISPLAY_CONTYPE_ATICVDONGLE_NONI2C_NTSC = 7;
|
||||
/// <summary> Indicates Proprietary Display Connector type.</summary>
|
||||
internal const int ADL_DISPLAY_CONTYPE_PROPRIETARY = 8;
|
||||
/// <summary> Indicates HDMI Type A Display Connector type.</summary>
|
||||
internal const int ADL_DISPLAY_CONTYPE_HDMI_TYPE_A = 10;
|
||||
/// <summary> Indicates HDMI Type B Display Connector type.</summary>
|
||||
internal const int ADL_DISPLAY_CONTYPE_HDMI_TYPE_B = 11;
|
||||
/// <summary> Indicates S-Video Display Connector type.</summary>
|
||||
internal const int ADL_DISPLAY_CONTYPE_SVIDEO = 12;
|
||||
/// <summary> Indicates Composite Display Connector type.</summary>
|
||||
internal const int ADL_DISPLAY_CONTYPE_COMPOSITE = 13;
|
||||
/// <summary> Indicates RCA 3-component Display Connector type.</summary>
|
||||
internal const int ADL_DISPLAY_CONTYPE_RCA_3COMPONENT = 14;
|
||||
/// <summary> Indicates DisplayPort Display Connector type.</summary>
|
||||
internal const int ADL_DISPLAY_CONTYPE_DISPLAYPORT = 15;
|
||||
/// <summary> Indicates EDP Display Connector type.</summary>
|
||||
internal const int ADL_DISPLAY_CONTYPE_EDP = 16;
|
||||
/// <summary> Indicates Wireless Display Connector type.</summary>
|
||||
internal const int ADL_DISPLAY_CONTYPE_WIRELESSDISPLAY = 17;
|
||||
/// <summary> Indicates USB Type-C Display Connector type.</summary>
|
||||
internal const int ADL_DISPLAY_CONTYPE_USB_TYPE_C = 18;
|
||||
|
||||
// Display Info Constants
|
||||
/// <summary> Indicates the display is connected .</summary>
|
||||
internal const int ADL_DISPLAY_DISPLAYINFO_DISPLAYCONNECTED = 0x00000001;
|
||||
@ -1079,7 +1117,7 @@ namespace ATI.ADL
|
||||
|
||||
internal enum ADLConnectionType
|
||||
{
|
||||
Unknown = 1,
|
||||
VGA = 0,
|
||||
DVI = 1,
|
||||
DVI_SL = 2,
|
||||
HDMI = 4,
|
||||
@ -1094,6 +1132,30 @@ namespace ATI.ADL
|
||||
ActiveDongle = 12,
|
||||
Virtual = 13
|
||||
}
|
||||
|
||||
internal enum ADLDisplayConnectionType
|
||||
{
|
||||
Unknown = 0,
|
||||
VGA = 1,
|
||||
DVI_D = 2,
|
||||
DVI_I = 3,
|
||||
HDMI = 4,
|
||||
ATICV_NTSC_Dongle = 4,
|
||||
ATICV_JPN_Dongle = 5,
|
||||
ATICV_NONI2C_NTSC_Dongle = 6,
|
||||
ATICV_NONI2C_JPN_Dongle = 7,
|
||||
Proprietary = 8,
|
||||
HDMITypeA = 10,
|
||||
HTMITypeB = 11,
|
||||
SVideo = 12,
|
||||
Composite = 13,
|
||||
RCA_3Component = 14,
|
||||
DisplayPort = 15,
|
||||
EDP = 16,
|
||||
WirelessDisplay = 17,
|
||||
USBTypeC = 18
|
||||
}
|
||||
|
||||
#endregion Internal Enums
|
||||
|
||||
#region Class ADLImport
|
||||
|
@ -256,10 +256,21 @@ namespace DisplayMagicianShared.AMD
|
||||
SharedLogger.logger.Trace($"ADLWrapper/GenerateProfileDisplayIdentifiers: Successfully run ADL2_Adapter_AdapterInfoX4_Get to find information about all known AMD adapters.");
|
||||
|
||||
// Go through each adapter
|
||||
for (int i = 0; i < NumberOfAdapters; i++)
|
||||
foreach (ADLAdapterInfoX2 oneAdapter in OSAdapterInfoData.ADLAdapterInfoX2)
|
||||
{
|
||||
ADLAdapterInfoX2 oneAdapter = OSAdapterInfoData.ADLAdapterInfoX2[i];
|
||||
if (oneAdapter.Exist != 1)
|
||||
{
|
||||
SharedLogger.logger.Trace($"ADLWrapper/GenerateProfileDisplayIdentifiers: AMD Adapter #{oneAdapter.AdapterIndex.ToString()} doesn't exist at present so skipping detection for this adapter.");
|
||||
Console.WriteLine($"ADLWrapper/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($"ADLWrapper/GenerateProfileDisplayIdentifiers: AMD Adapter #{oneAdapter.AdapterIndex.ToString()} isn't enabled at present so skipping detection for this adapter.");
|
||||
Console.WriteLine($"ADLWrapper/GenerateProfileDisplayIdentifiers: 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)
|
||||
@ -270,11 +281,18 @@ namespace DisplayMagicianShared.AMD
|
||||
// Only continue if the adapter is enabled
|
||||
if (IsActive != ADL.ADL_TRUE)
|
||||
{
|
||||
SharedLogger.logger.Trace($"ADLWrapper/GenerateProfileDisplayIdentifiers: AMD Adapter #{i} isn't active ({oneAdapter.AdapterName}).");
|
||||
SharedLogger.logger.Trace($"ADLWrapper/GenerateProfileDisplayIdentifiers: AMD Adapter #{oneAdapter.AdapterIndex.ToString()} isn't active ({oneAdapter.AdapterName}).");
|
||||
continue;
|
||||
}
|
||||
|
||||
SharedLogger.logger.Trace($"ADLWrapper/GenerateProfileDisplayIdentifiers: AMD Adapter #{i} is active! ({oneAdapter.AdapterName}).");
|
||||
// Only continue if the adapter index is > 0
|
||||
if (oneAdapter.AdapterIndex < 0)
|
||||
{
|
||||
SharedLogger.logger.Trace($"ADLWrapper/GenerateProfileDisplayIdentifiers: AMD Adapter has an adapter index of {oneAdapter.AdapterIndex.ToString()} which indicates it is not a real adapter.");
|
||||
continue;
|
||||
}
|
||||
|
||||
SharedLogger.logger.Trace($"ADLWrapper/GenerateProfileDisplayIdentifiers: AMD Adapter #{oneAdapter.AdapterIndex.ToString()} is active! ({oneAdapter.AdapterName}).");
|
||||
|
||||
Console.WriteLine($"### Adapter Info for Adapter #{oneAdapter.AdapterIndex} ###");
|
||||
Console.WriteLine($"Adapter AdapterIndex = {oneAdapter.AdapterIndex}");
|
||||
@ -314,12 +332,11 @@ namespace DisplayMagicianShared.AMD
|
||||
Console.WriteLine($"Adapter Num of Overlays = {AdapterCapabilities.NumOverlays}");
|
||||
|
||||
// Obtain information about displays
|
||||
ADLDisplayInfo oneDisplayInfo = new ADLDisplayInfo();
|
||||
ADLDisplayInfoArray displayInfoArray = new ADLDisplayInfoArray();
|
||||
|
||||
if (ADL.ADL2_Display_DisplayInfo_Get != null)
|
||||
{
|
||||
IntPtr DisplayBuffer = IntPtr.Zero;
|
||||
int j = 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 NumberOfDisplays, out DisplayBuffer, 0);
|
||||
@ -328,16 +345,14 @@ namespace DisplayMagicianShared.AMD
|
||||
|
||||
try
|
||||
{
|
||||
displayInfoArray = (ADLDisplayInfoArray)Marshal.PtrToStructure(DisplayBuffer, displayInfoArray.GetType());
|
||||
|
||||
for (j = 0; j < NumberOfDisplays; j++)
|
||||
foreach (ADLDisplayInfo oneDisplayInfo in displayInfoArray.ADLDisplayInfo)
|
||||
{
|
||||
// Marshal the returned array of displayinfo into managed objects one by one
|
||||
// NOTE: the ToInt64 work on 64 bit, need to change to ToInt32 for 32 bit OS
|
||||
oneDisplayInfo = (ADLDisplayInfo)Marshal.PtrToStructure(new IntPtr(DisplayBuffer.ToInt64() + (j * Marshal.SizeOf(oneDisplayInfo))), oneDisplayInfo.GetType());
|
||||
|
||||
if (oneDisplayInfo.DisplayID.DisplayLogicalAdapterIndex == -1)
|
||||
{
|
||||
SharedLogger.logger.Trace($"ADLWrapper/GenerateProfileDisplayIdentifiers: AMD Adapter #{i} ({oneAdapter.AdapterName}) AdapterID display ID#{j} is not a real display as its DisplayID.DisplayLogicalAdapterIndex is -1");
|
||||
SharedLogger.logger.Trace($"ADLWrapper/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;
|
||||
}
|
||||
|
||||
@ -346,20 +361,21 @@ namespace DisplayMagicianShared.AMD
|
||||
|
||||
if (!displayInfoValue.DISPLAYCONNECTED)
|
||||
{
|
||||
SharedLogger.logger.Trace($"ADLWrapper/GenerateProfileDisplayIdentifiers: AMD Adapter #{i} ({oneAdapter.AdapterName}) AdapterID display ID#{j} is not connected");
|
||||
SharedLogger.logger.Trace($"ADLWrapper/GenerateProfileDisplayIdentifiers: 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 want all displays currently visible in the OS
|
||||
if (!displayInfoValue.DISPLAYMAPPED)
|
||||
{
|
||||
SharedLogger.logger.Trace($"ADLWrapper/GenerateProfileDisplayIdentifiers: AMD Adapter #{i} ({oneAdapter.AdapterName}) AdapterID display ID#{j} is not mapped in Windows OS");
|
||||
SharedLogger.logger.Trace($"ADLWrapper/GenerateProfileDisplayIdentifiers: AMD Adapter #{oneAdapter.AdapterIndex.ToString()} ({oneAdapter.AdapterName}) AdapterID display ID#{oneDisplayInfo.DisplayID.DisplayLogicalIndex} is not mapped in Windows OS");
|
||||
continue;
|
||||
}
|
||||
|
||||
// Skip fake displays
|
||||
ADL.ADLDisplayConnectionType displayConnector = (ADL.ADLDisplayConnectionType)oneDisplayInfo.DisplayConnector;
|
||||
|
||||
Console.WriteLine($"### Display Info for Display #{oneDisplayInfo.DisplayID.DisplayLogicalIndex} on Adapter #{oneAdapter.AdapterIndex} ###");
|
||||
Console.WriteLine($"Display Connector = {oneDisplayInfo.DisplayConnector}");
|
||||
Console.WriteLine($"Display Connector = {displayConnector.ToString("G")}");
|
||||
Console.WriteLine($"Display Controller Index = {oneDisplayInfo.DisplayControllerIndex}");
|
||||
Console.WriteLine($"Display Logical Adapter Index = {oneDisplayInfo.DisplayID.DisplayLogicalAdapterIndex}");
|
||||
Console.WriteLine($"Display Logical Index = {oneDisplayInfo.DisplayID.DisplayLogicalIndex}");
|
||||
@ -369,7 +385,7 @@ namespace DisplayMagicianShared.AMD
|
||||
Console.WriteLine($"Display Info Value = {oneDisplayInfo.DisplayInfoValue}");
|
||||
Console.WriteLine($"Display Manufacturer Name = {oneDisplayInfo.DisplayManufacturerName}");
|
||||
Console.WriteLine($"Display Name = {oneDisplayInfo.DisplayName}");
|
||||
Console.WriteLine($"Display Output Type = {oneDisplayInfo.DisplayOutputType.ToString("G")}");
|
||||
Console.WriteLine($"Display Output Type = {oneDisplayInfo.DisplayOutputType}");
|
||||
Console.WriteLine($"Display Type = {oneDisplayInfo.DisplayType}");
|
||||
|
||||
Console.WriteLine($"Display Info Value DISPLAYCONNECTED = {displayInfoValue.DISPLAYCONNECTED}");
|
||||
@ -389,7 +405,7 @@ namespace DisplayMagicianShared.AMD
|
||||
Console.WriteLine($"Display Info Value NONLOCAL = {displayInfoValue.NONLOCAL}");
|
||||
Console.WriteLine($"Display Info Value SHOWTYPE_PROJECTOR = {displayInfoValue.SHOWTYPE_PROJECTOR}");
|
||||
|
||||
|
||||
ADL.ADLDisplayConnectionType displayConnectionType = ADL.ADLDisplayConnectionType.Unknown;
|
||||
ADLDisplayConfig displayConfig = new ADLDisplayConfig();
|
||||
displayConfig.Size = Marshal.SizeOf(displayConfig);
|
||||
if (ADL.ADL2_Display_DeviceConfig_Get != null)
|
||||
@ -398,8 +414,10 @@ namespace DisplayMagicianShared.AMD
|
||||
ADLRet = ADL.ADL2_Display_DeviceConfig_Get(_adlContextHandle, oneAdapter.AdapterIndex, oneDisplayInfo.DisplayID.DisplayPhysicalIndex, out displayConfig);
|
||||
if (ADLRet == ADL.ADL_OK)
|
||||
{
|
||||
displayConnectionType = (ADL.ADLDisplayConnectionType)displayConfig.ConnectorType;
|
||||
|
||||
Console.WriteLine($"### Display Device Config for Display #{oneDisplayInfo.DisplayID.DisplayLogicalIndex} on Adapter #{oneAdapter.AdapterIndex} ###");
|
||||
Console.WriteLine($"Display Connector Type = {displayConfig.ConnectorType}");
|
||||
Console.WriteLine($"Display Connector Type = {displayConnectionType.ToString("G")}");
|
||||
Console.WriteLine($"Display Device Data = {displayConfig.DeviceData}");
|
||||
Console.WriteLine($"Display Overridded Device Data = {displayConfig.OverriddedDeviceData}");
|
||||
Console.WriteLine($"Display Reserved Data = {displayConfig.Reserved}");
|
||||
@ -497,6 +515,16 @@ namespace DisplayMagicianShared.AMD
|
||||
// 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, $"ADLWrapper/GenerateProfileDisplayIdentifiers: Exception getting AMD Vendor ID from video card. Substituting with a # instead");
|
||||
displayInfoIdentifierSection.Add("#");
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
displayInfoIdentifierSection.Add(oneAdapter.AdapterName);
|
||||
@ -539,8 +567,7 @@ namespace DisplayMagicianShared.AMD
|
||||
|
||||
try
|
||||
{
|
||||
ADL.ADLConnectionType connector = (ADL.ADLConnectionType)oneDisplayInfo.DisplayOutputType;
|
||||
displayInfoIdentifierSection.Add(connector.ToString("G"));
|
||||
displayInfoIdentifierSection.Add(displayConnector.ToString("G"));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@ -550,21 +577,41 @@ namespace DisplayMagicianShared.AMD
|
||||
|
||||
try
|
||||
{
|
||||
displayInfoIdentifierSection.Add(oneDisplayInfo.DisplayManufacturerName);
|
||||
displayInfoIdentifierSection.Add(oneDisplayInfo.DisplayName);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
SharedLogger.logger.Warn(ex, $"ADLWrapper/GenerateProfileDisplayIdentifiers: Exception getting Display manufacturer from AMD video card. Substituting with a # instead");
|
||||
SharedLogger.logger.Warn(ex, $"ADLWrapper/GenerateProfileDisplayIdentifiers: Exception getting Display Name from display connected to AMD video card. Substituting with a # instead");
|
||||
displayInfoIdentifierSection.Add("#");
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
displayInfoIdentifierSection.Add(oneDisplayInfo.DisplayName);
|
||||
displayInfoIdentifierSection.Add(displayDDCInfo2.ManufacturerID.ToString());
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
SharedLogger.logger.Warn(ex, $"ADLWrapper/GenerateProfileDisplayIdentifiers: Exception getting Display Name from AMD video card. Substituting with a # instead");
|
||||
SharedLogger.logger.Warn(ex, $"ADLWrapper/GenerateProfileDisplayIdentifiers: 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, $"ADLWrapper/GenerateProfileDisplayIdentifiers: 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, $"ADLWrapper/GenerateProfileDisplayIdentifiers: Exception getting Serial ID from display connected to AMD video card. Substituting with a # instead");
|
||||
displayInfoIdentifierSection.Add("#");
|
||||
}
|
||||
|
||||
@ -573,6 +620,7 @@ namespace DisplayMagicianShared.AMD
|
||||
// Add it to the list of display identifiers so we can return it
|
||||
displayIdentifiers.Add(displayIdentifier);
|
||||
|
||||
Console.WriteLine($"ProfileRepository/GenerateProfileDisplayIdentifiers: DisplayIdentifier: {displayIdentifier}");
|
||||
SharedLogger.logger.Debug($"ProfileRepository/GenerateProfileDisplayIdentifiers: DisplayIdentifier: {displayIdentifier}");
|
||||
}
|
||||
}
|
||||
@ -628,6 +676,7 @@ namespace DisplayMagicianShared.AMD
|
||||
|
||||
List<string> displayIdentifiers = new List<string>();
|
||||
|
||||
return displayIdentifiers;
|
||||
|
||||
if (null != ADL.ADL_Adapter_NumberOfAdapters_Get)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user