AMD ADL Multiple bus support

This commit is contained in:
Andrey 2023-05-28 23:23:55 +00:00 committed by Adam Honse
parent 10047188ad
commit 8c6cba5117
5 changed files with 1191 additions and 2994 deletions

File diff suppressed because it is too large Load diff

View file

@ -1,5 +1,5 @@
// //
// Copyright (c) 2016 Advanced Micro Devices, Inc. All rights reserved. // Copyright (c) 2016 - 2022 Advanced Micro Devices, Inc. All rights reserved.
// //
// MIT LICENSE: // MIT LICENSE:
// Permission is hereby granted, free of charge, to any person obtaining a copy // Permission is hereby granted, free of charge, to any person obtaining a copy
@ -20,13 +20,6 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE. // SOFTWARE.
/// \file adl_sdk.h
/// \brief Contains the definition of the Memory Allocation Callback.\n <b>Included in ADL SDK</b>
///
/// \n\n
/// This file contains the definition of the Memory Allocation Callback.\n
/// It also includes definitions of the respective structures and constants.\n
/// <b> This is the only header file to be included in a C/C++ project using ADL </b>
#ifndef ADL_SDK_H_ #ifndef ADL_SDK_H_
#define ADL_SDK_H_ #define ADL_SDK_H_
@ -37,8 +30,9 @@
#define __stdcall #define __stdcall
#endif /* (LINUX) */ #endif /* (LINUX) */
/// Memory Allocation Call back
typedef void* ( __stdcall *ADL_MAIN_MALLOC_CALLBACK )( int ); typedef void* ( __stdcall *ADL_MAIN_MALLOC_CALLBACK )( int );
#define ADL_SDK_MAJOR_VERSION 17
#define ADL_SDK_MINOR_VERSION 0
#endif /* ADL_SDK_H_ */ #endif /* ADL_SDK_H_ */

File diff suppressed because it is too large Load diff

View file

@ -16,6 +16,7 @@ typedef int ( *ADL2_MAIN_CONTROL_DESTROY )(ADL_CONTEXT_HANDLE);
typedef int ( *ADL2_ADAPTER_NUMBEROFADAPTERS_GET ) ( ADL_CONTEXT_HANDLE , int* ); typedef int ( *ADL2_ADAPTER_NUMBEROFADAPTERS_GET ) ( ADL_CONTEXT_HANDLE , int* );
typedef int ( *ADL2_ADAPTER_PRIMARY_GET) (ADL_CONTEXT_HANDLE, int* lpPrimaryAdapterIndex); typedef int ( *ADL2_ADAPTER_PRIMARY_GET) (ADL_CONTEXT_HANDLE, int* lpPrimaryAdapterIndex);
typedef int ( *ADL2_ADAPTER_ADAPTERINFOX2_GET) (ADL_CONTEXT_HANDLE, AdapterInfo**); typedef int ( *ADL2_ADAPTER_ADAPTERINFOX2_GET) (ADL_CONTEXT_HANDLE, AdapterInfo**);
typedef int ( *ADL2_ADAPTER_ADAPTERINFOX4_GET) (ADL_CONTEXT_HANDLE, int iAdapterIndex, int* numAdapters, AdapterInfoX2** lppAdapterInfoX2);
typedef int ( *ADL2_DISPLAY_WRITEANDREADI2C) (ADL_CONTEXT_HANDLE, int iAdapterIndex, ADLI2C* plI2C); typedef int ( *ADL2_DISPLAY_WRITEANDREADI2C) (ADL_CONTEXT_HANDLE, int iAdapterIndex, ADLI2C* plI2C);
ADL2_MAIN_CONTROL_CREATE ADL2_Main_Control_Create; ADL2_MAIN_CONTROL_CREATE ADL2_Main_Control_Create;
@ -23,6 +24,7 @@ ADL2_MAIN_CONTROL_DESTROY ADL2_Main_Control_Destroy;
ADL2_ADAPTER_NUMBEROFADAPTERS_GET ADL2_Adapter_NumberOfAdapters_Get; ADL2_ADAPTER_NUMBEROFADAPTERS_GET ADL2_Adapter_NumberOfAdapters_Get;
ADL2_ADAPTER_PRIMARY_GET ADL2_Adapter_Primary_Get; ADL2_ADAPTER_PRIMARY_GET ADL2_Adapter_Primary_Get;
ADL2_ADAPTER_ADAPTERINFOX2_GET ADL2_Adapter_AdapterInfoX2_Get; ADL2_ADAPTER_ADAPTERINFOX2_GET ADL2_Adapter_AdapterInfoX2_Get;
ADL2_ADAPTER_ADAPTERINFOX4_GET ADL2_Adapter_AdapterInfoX4_Get;
ADL2_DISPLAY_WRITEANDREADI2C ADL2_Display_WriteAndReadI2C; ADL2_DISPLAY_WRITEANDREADI2C ADL2_Display_WriteAndReadI2C;
int LoadLibraries() int LoadLibraries()
@ -47,16 +49,18 @@ int LoadLibraries()
ADL2_Adapter_NumberOfAdapters_Get = (ADL2_ADAPTER_NUMBEROFADAPTERS_GET)GetProcAddress(hDLL, "ADL2_Adapter_NumberOfAdapters_Get"); ADL2_Adapter_NumberOfAdapters_Get = (ADL2_ADAPTER_NUMBEROFADAPTERS_GET)GetProcAddress(hDLL, "ADL2_Adapter_NumberOfAdapters_Get");
ADL2_Adapter_Primary_Get = (ADL2_ADAPTER_PRIMARY_GET)GetProcAddress(hDLL, "ADL2_Adapter_Primary_Get"); ADL2_Adapter_Primary_Get = (ADL2_ADAPTER_PRIMARY_GET)GetProcAddress(hDLL, "ADL2_Adapter_Primary_Get");
ADL2_Adapter_AdapterInfoX2_Get = (ADL2_ADAPTER_ADAPTERINFOX2_GET)GetProcAddress(hDLL, "ADL2_Adapter_AdapterInfoX2_Get"); ADL2_Adapter_AdapterInfoX2_Get = (ADL2_ADAPTER_ADAPTERINFOX2_GET)GetProcAddress(hDLL, "ADL2_Adapter_AdapterInfoX2_Get");
ADL2_Adapter_AdapterInfoX4_Get = (ADL2_ADAPTER_ADAPTERINFOX4_GET)GetProcAddress(hDLL, "ADL2_Adapter_AdapterInfoX4_Get");
ADL2_Display_WriteAndReadI2C = (ADL2_DISPLAY_WRITEANDREADI2C)GetProcAddress(hDLL, "ADL2_Display_WriteAndReadI2C"); ADL2_Display_WriteAndReadI2C = (ADL2_DISPLAY_WRITEANDREADI2C)GetProcAddress(hDLL, "ADL2_Display_WriteAndReadI2C");
/*---------------------------------------------------------------------*\ /*---------------------------------------------------------------------*\
| Only return OK if all function pointers are valid | | Only return OK if all function pointers are valid |
\*---------------------------------------------------------------------*/ \*---------------------------------------------------------------------*/
if( ADL2_Main_Control_Create if( ADL2_Main_Control_Create
&& ADL2_Main_Control_Destroy && ADL2_Main_Control_Destroy
&& ADL2_Adapter_NumberOfAdapters_Get && ADL2_Adapter_NumberOfAdapters_Get
&& ADL2_Adapter_Primary_Get && ADL2_Adapter_Primary_Get
&& ADL2_Adapter_AdapterInfoX2_Get && ADL2_Adapter_AdapterInfoX2_Get
&& ADL2_Adapter_AdapterInfoX4_Get
&& ADL2_Display_WriteAndReadI2C) && ADL2_Display_WriteAndReadI2C)
{ {
return ADL_OK; return ADL_OK;
@ -85,13 +89,14 @@ void __stdcall ADL_Main_Memory_Free ( void* lpBuffer )
} }
} }
i2c_smbus_amdadl::i2c_smbus_amdadl(ADL_CONTEXT_HANDLE context) i2c_smbus_amdadl::i2c_smbus_amdadl(ADL_CONTEXT_HANDLE context, int adapter_index)
{ {
AdapterInfo * info; int num_of_devices;
AdapterInfoX2* info;
this->context = context; this->context = context;
if (ADL_OK != ADL2_Adapter_AdapterInfoX2_Get(context, &info)) if (ADL_OK != ADL2_Adapter_AdapterInfoX4_Get(context, adapter_index, &num_of_devices, &info))
{ {
printf("Cannot get Adapter Info!\n"); printf("Cannot get Adapter Info!\n");
} }
@ -228,9 +233,24 @@ bool i2c_smbus_amdadl_detect()
} }
else else
{ {
i2c_smbus_amdadl * adl_bus = new i2c_smbus_amdadl(context); int num_of_devices;
LOG_INFO("ADL GPU Device %04X:%04X Subsystem: %04X:%04X", adl_bus->pci_vendor, adl_bus->pci_device,adl_bus->pci_subsystem_vendor,adl_bus->pci_subsystem_device); AdapterInfoX2* info;
ResourceManager::get()->RegisterI2CBus(adl_bus); if (ADL_OK == ADL2_Adapter_AdapterInfoX4_Get(context, -1, &num_of_devices, &info))
{
int last_bus_number = -1;
for(int i = 0; i < num_of_devices; i++)
{
AdapterInfoX2 current = *(info + i);
if(last_bus_number == current.iBusNumber)
{
continue;
}
last_bus_number = current.iBusNumber;
i2c_smbus_amdadl * adl_bus = new i2c_smbus_amdadl(context, current.iAdapterIndex);
LOG_INFO("ADL GPU Device %04X:%04X Subsystem: %04X:%04X", adl_bus->pci_vendor, adl_bus->pci_device,adl_bus->pci_subsystem_vendor,adl_bus->pci_subsystem_device);
ResourceManager::get()->RegisterI2CBus(adl_bus);
}
}
} }
} }

View file

@ -21,7 +21,7 @@
class i2c_smbus_amdadl : public i2c_smbus_interface class i2c_smbus_amdadl : public i2c_smbus_interface
{ {
public: public:
i2c_smbus_amdadl(ADL_CONTEXT_HANDLE context); i2c_smbus_amdadl(ADL_CONTEXT_HANDLE context, int adapter_index);
int LoadLibraries(); int LoadLibraries();
//void* __stdcall ADL_Main_Memory_Alloc ( int iSize ); //void* __stdcall ADL_Main_Memory_Alloc ( int iSize );