wrapadl.h 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. /* Copyright (C) 1883 Thomas Edison - All Rights Reserved
  2. * You may use, distribute and modify this code under the
  3. * terms of the GPLv3 license, which unfortunately won't be
  4. * written for another century.
  5. *
  6. * You should have received a copy of the LICENSE file with
  7. * this file.
  8. */
  9. #pragma once
  10. #if defined(__cplusplus)
  11. extern "C" {
  12. #endif
  13. typedef enum wrap_adlReturn_enum { WRAPADL_OK = 0 } wrap_adlReturn_t;
  14. // Some ADL defines and structs from adl sdk
  15. #if defined(__MSC_VER)
  16. #define ADL_API_CALL __cdecl
  17. #elif defined(_WIN32)
  18. #define ADL_API_CALL __stdcall
  19. #else
  20. #define ADL_API_CALL
  21. #endif
  22. typedef void*(ADL_API_CALL* ADL_MAIN_MALLOC_CALLBACK)(int);
  23. /// \brief Handle to ADL client context.
  24. ///
  25. /// ADL clients obtain context handle from initial call to \ref ADL2_Main_Control_Create.
  26. /// Clients have to pass the handle to each subsequent ADL call and finally destroy
  27. /// the context with call to \ref ADL2_Main_Control_Destroy
  28. /// \nosubgrouping
  29. typedef void* ADL_CONTEXT_HANDLE;
  30. #define ADL_MAX_PATH 256
  31. typedef struct AdapterInfo {
  32. /// \ALL_STRUCT_MEM
  33. /// Size of the structure.
  34. int iSize;
  35. /// The ADL index handle. One GPU may be associated with one or two index handles
  36. int iAdapterIndex;
  37. /// The unique device ID associated with this adapter.
  38. char strUDID[ADL_MAX_PATH];
  39. /// The BUS number associated with this adapter.
  40. int iBusNumber;
  41. /// The driver number associated with this adapter.
  42. int iDeviceNumber;
  43. /// The function number.
  44. int iFunctionNumber;
  45. /// The vendor ID associated with this adapter.
  46. int iVendorID;
  47. /// Adapter name.
  48. char strAdapterName[ADL_MAX_PATH];
  49. /// Display name. For example, "\\Display0" for Windows or ":0:0" for Linux.
  50. char strDisplayName[ADL_MAX_PATH];
  51. /// Present or not; 1 if present and 0 if not present.It the logical adapter is present, the
  52. /// display name such as \\.\Display1 can be found from OS
  53. int iPresent;
  54. // @}
  55. #if defined(_WIN32)
  56. /// \WIN_STRUCT_MEM
  57. /// Exist or not; 1 is exist and 0 is not present.
  58. int iExist;
  59. /// Driver registry path.
  60. char strDriverPath[ADL_MAX_PATH];
  61. /// Driver registry path Ext for.
  62. char strDriverPathExt[ADL_MAX_PATH];
  63. /// PNP string from Windows.
  64. char strPNPString[ADL_MAX_PATH];
  65. /// It is generated from EnumDisplayDevices.
  66. int iOSDisplayIndex;
  67. // @}
  68. #endif /* (_WIN32) */
  69. #if defined(LINUX)
  70. /// \LNX_STRUCT_MEM
  71. /// Internal X screen number from GPUMapInfo (DEPRICATED use XScreenInfo)
  72. int iXScreenNum;
  73. /// Internal driver index from GPUMapInfo
  74. int iDrvIndex;
  75. /// \deprecated Internal x config file screen identifier name. Use XScreenInfo instead.
  76. char strXScreenConfigName[ADL_MAX_PATH];
  77. // @}
  78. #endif /* (LINUX) */
  79. } AdapterInfo, *LPAdapterInfo;
  80. typedef struct ADLTemperature {
  81. /// Must be set to the size of the structure
  82. int iSize;
  83. /// Temperature in millidegrees Celsius.
  84. int iTemperature;
  85. } ADLTemperature;
  86. typedef struct ADLFanSpeedValue {
  87. /// Must be set to the size of the structure
  88. int iSize;
  89. /// Possible valies: \ref ADL_DL_FANCTRL_SPEED_TYPE_PERCENT or \ref
  90. /// ADL_DL_FANCTRL_SPEED_TYPE_RPM
  91. int iSpeedType;
  92. /// Fan speed value
  93. int iFanSpeed;
  94. /// The only flag for now is: \ref ADL_DL_FANCTRL_FLAG_USER_DEFINED_SPEED
  95. int iFlags;
  96. } ADLFanSpeedValue;
  97. /*
  98. * Handle to hold the function pointers for the entry points we need,
  99. * and the shared library itself.
  100. */
  101. typedef struct {
  102. void* adl_dll;
  103. int adl_gpucount;
  104. int log_gpucount;
  105. int* phys_logi_device_id;
  106. LPAdapterInfo devs;
  107. ADL_CONTEXT_HANDLE context;
  108. wrap_adlReturn_t (*adlMainControlCreate)(ADL_MAIN_MALLOC_CALLBACK, int);
  109. wrap_adlReturn_t (*adlAdapterNumberOfAdapters)(int*);
  110. wrap_adlReturn_t (*adlAdapterAdapterInfoGet)(LPAdapterInfo, int);
  111. wrap_adlReturn_t (*adlAdapterAdapterIdGet)(int, int*);
  112. wrap_adlReturn_t (*adlOverdrive5TemperatureGet)(int, int, ADLTemperature*);
  113. wrap_adlReturn_t (*adlOverdrive5FanSpeedGet)(int, int, ADLFanSpeedValue*);
  114. wrap_adlReturn_t (*adlMainControlRefresh)(void);
  115. wrap_adlReturn_t (*adlMainControlDestroy)(void);
  116. wrap_adlReturn_t (*adl2MainControlCreate)(ADL_MAIN_MALLOC_CALLBACK, int, ADL_CONTEXT_HANDLE*);
  117. wrap_adlReturn_t (*adl2MainControlDestroy)(ADL_CONTEXT_HANDLE);
  118. wrap_adlReturn_t (*adl2Overdrive6CurrentPowerGet)(ADL_CONTEXT_HANDLE, int, int, int*);
  119. wrap_adlReturn_t (*adl2MainControlRefresh)(ADL_CONTEXT_HANDLE);
  120. } wrap_adl_handle;
  121. wrap_adl_handle* wrap_adl_create();
  122. int wrap_adl_destroy(wrap_adl_handle* adlh);
  123. int wrap_adl_get_gpucount(wrap_adl_handle* adlh, int* gpucount);
  124. int wrap_adl_get_gpu_name(wrap_adl_handle* adlh, int gpuindex, char* namebuf, int bufsize);
  125. int wrap_adl_get_gpu_pci_id(wrap_adl_handle* adlh, int gpuindex, char* idbuf, int bufsize);
  126. int wrap_adl_get_tempC(wrap_adl_handle* adlh, int gpuindex, unsigned int* tempC);
  127. int wrap_adl_get_mem_tempC(wrap_adl_handle* adlh, int gpuindex, unsigned int* tempC);
  128. int wrap_adl_get_fanpcnt(wrap_adl_handle* adlh, int gpuindex, unsigned int* fanpcnt);
  129. int wrap_adl_get_power_usage(wrap_adl_handle* adlh, int gpuindex, unsigned int* milliwatts);
  130. #if defined(__cplusplus)
  131. }
  132. #endif