a48c7372d441303d979ac56572a31fdc62247892
[hashcat.git] / include / ext_nvapi.h
1 /**
2 * Authors.....: Jens Steube <jens.steube@gmail.com>
3 * Gabriele Gristina <matrix@hashcat.net>
4 *
5 * License.....: MIT
6 */
7
8 #ifndef EXT_NVAPI_H
9 #define EXT_NVAPI_H
10
11 #if defined(HAVE_HWMON)
12
13 #include <common.h>
14
15 /*
16 * Declarations from nvapi.h and subheaders
17 **/
18
19 #ifndef __success
20 #define __nvapi_success
21 #define __success(epxr)
22 #endif
23
24 #define NVAPI_INTERFACE extern __success(return == NVAPI_OK) NvAPI_Status __cdecl
25
26 /*
27 * Definitions from nvapi_lite_common.h
28 */
29
30 // 64-bit types for compilers that support them, plus some obsolete variants
31 #if defined(__GNUC__) || defined(__arm) || defined(__IAR_SYSTEMS_ICC__) || defined(__ghs__) || defined(_WIN64)
32 typedef unsigned long long NvU64; /* 0 to 18446744073709551615 */
33 typedef long long NvS64; /* -9223372036854775808 to 9223372036854775807 */
34 #else
35 typedef unsigned __int64 NvU64; /* 0 to 18446744073709551615 */
36 typedef __int64 NvS64; /* -9223372036854775808 to 9223372036854775807 */
37 #endif
38
39 // mac os 32-bit still needs this
40 #if (defined(macintosh) || defined(__APPLE__)) && !defined(__LP64__)
41 typedef signed long NvS32; /* -2147483648 to 2147483647 */
42 #else
43 typedef signed int NvS32; /* -2147483648 to 2147483647 */
44 #endif
45
46 // mac os 32-bit still needs this
47 #if ( (defined(macintosh) && defined(__LP64__) && (__NVAPI_RESERVED0__)) || \
48 (!defined(macintosh) && defined(__NVAPI_RESERVED0__)) )
49 typedef unsigned int NvU32; /* 0 to 4294967295 */
50 #else
51 typedef unsigned long NvU32; /* 0 to 4294967295 */
52 #endif
53
54 typedef signed short NvS16;
55 typedef unsigned short NvU16;
56 typedef unsigned char NvU8;
57 typedef signed char NvS8;
58
59 #define NV_DECLARE_HANDLE(name) struct name##__ { int unused; }; typedef struct name##__ *name
60
61 NV_DECLARE_HANDLE(NvPhysicalGpuHandle); // A single physical GPU
62
63 #define NVAPI_GENERIC_STRING_MAX 4096
64 #define NVAPI_LONG_STRING_MAX 256
65 #define NVAPI_SHORT_STRING_MAX 64
66
67 typedef char NvAPI_String[NVAPI_GENERIC_STRING_MAX];
68 typedef char NvAPI_LongString[NVAPI_LONG_STRING_MAX];
69 typedef char NvAPI_ShortString[NVAPI_SHORT_STRING_MAX];
70
71 #define MAKE_NVAPI_VERSION(typeName,ver) (NvU32)(sizeof(typeName) | ((ver)<<16))
72 #define GET_NVAPI_VERSION(ver) (NvU32)((ver)>>16)
73 #define GET_NVAPI_SIZE(ver) (NvU32)((ver) & 0xffff)
74
75 #define NVAPI_MAX_PHYSICAL_GPUS 64
76
77 typedef enum _NvAPI_Status
78 {
79 NVAPI_OK = 0, // Success. Request is completed.
80 NVAPI_ERROR = -1, // Generic error
81 NVAPI_LIBRARY_NOT_FOUND = -2, // NVAPI support library cannot be loaded.
82 NVAPI_NO_IMPLEMENTATION = -3, // not implemented in current driver installation
83 NVAPI_API_NOT_INITIALIZED = -4, // NvAPI_Initialize has not been called (successfully)
84 NVAPI_INVALID_ARGUMENT = -5, // The argument/parameter value is not valid or NULL.
85 NVAPI_NVIDIA_DEVICE_NOT_FOUND = -6, // No NVIDIA display driver, or NVIDIA GPU driving a display, was found.
86 NVAPI_END_ENUMERATION = -7, // No more items to enumerate
87 NVAPI_INVALID_HANDLE = -8, // Invalid handle
88 NVAPI_INCOMPATIBLE_STRUCT_VERSION = -9, // An argument's structure version is not supported
89 NVAPI_HANDLE_INVALIDATED = -10, // The handle is no longer valid (likely due to GPU or display re-configuration)
90 NVAPI_OPENGL_CONTEXT_NOT_CURRENT = -11, // No NVIDIA OpenGL context is current (but needs to be)
91 NVAPI_INVALID_POINTER = -14, // An invalid pointer, usually NULL, was passed as a parameter
92 NVAPI_NO_GL_EXPERT = -12, // OpenGL Expert is not supported by the current drivers
93 NVAPI_INSTRUMENTATION_DISABLED = -13, // OpenGL Expert is supported, but driver instrumentation is currently disabled
94 NVAPI_NO_GL_NSIGHT = -15, // OpenGL does not support Nsight
95
96 NVAPI_EXPECTED_LOGICAL_GPU_HANDLE = -100, // Expected a logical GPU handle for one or more parameters
97 NVAPI_EXPECTED_PHYSICAL_GPU_HANDLE = -101, // Expected a physical GPU handle for one or more parameters
98 NVAPI_EXPECTED_DISPLAY_HANDLE = -102, // Expected an NV display handle for one or more parameters
99 NVAPI_INVALID_COMBINATION = -103, // The combination of parameters is not valid.
100 NVAPI_NOT_SUPPORTED = -104, // Requested feature is not supported in the selected GPU
101 NVAPI_PORTID_NOT_FOUND = -105, // No port ID was found for the I2C transaction
102 NVAPI_EXPECTED_UNATTACHED_DISPLAY_HANDLE = -106, // Expected an unattached display handle as one of the input parameters.
103 NVAPI_INVALID_PERF_LEVEL = -107, // Invalid perf level
104 NVAPI_DEVICE_BUSY = -108, // Device is busy; request not fulfilled
105 NVAPI_NV_PERSIST_FILE_NOT_FOUND = -109, // NV persist file is not found
106 NVAPI_PERSIST_DATA_NOT_FOUND = -110, // NV persist data is not found
107 NVAPI_EXPECTED_TV_DISPLAY = -111, // Expected a TV output display
108 NVAPI_EXPECTED_TV_DISPLAY_ON_DCONNECTOR = -112, // Expected a TV output on the D Connector - HDTV_EIAJ4120.
109 NVAPI_NO_ACTIVE_SLI_TOPOLOGY = -113, // SLI is not active on this device.
110 NVAPI_SLI_RENDERING_MODE_NOTALLOWED = -114, // Setup of SLI rendering mode is not possible right now.
111 NVAPI_EXPECTED_DIGITAL_FLAT_PANEL = -115, // Expected a digital flat panel.
112 NVAPI_ARGUMENT_EXCEED_MAX_SIZE = -116, // Argument exceeds the expected size.
113 NVAPI_DEVICE_SWITCHING_NOT_ALLOWED = -117, // Inhibit is ON due to one of the flags in NV_GPU_DISPLAY_CHANGE_INHIBIT or SLI active.
114 NVAPI_TESTING_CLOCKS_NOT_SUPPORTED = -118, // Testing of clocks is not supported.
115 NVAPI_UNKNOWN_UNDERSCAN_CONFIG = -119, // The specified underscan config is from an unknown source (e.g. INF)
116 NVAPI_TIMEOUT_RECONFIGURING_GPU_TOPO = -120, // Timeout while reconfiguring GPUs
117 NVAPI_DATA_NOT_FOUND = -121, // Requested data was not found
118 NVAPI_EXPECTED_ANALOG_DISPLAY = -122, // Expected an analog display
119 NVAPI_NO_VIDLINK = -123, // No SLI video bridge is present
120 NVAPI_REQUIRES_REBOOT = -124, // NVAPI requires a reboot for the settings to take effect
121 NVAPI_INVALID_HYBRID_MODE = -125, // The function is not supported with the current Hybrid mode.
122 NVAPI_MIXED_TARGET_TYPES = -126, // The target types are not all the same
123 NVAPI_SYSWOW64_NOT_SUPPORTED = -127, // The function is not supported from 32-bit on a 64-bit system.
124 NVAPI_IMPLICIT_SET_GPU_TOPOLOGY_CHANGE_NOT_ALLOWED = -128, // There is no implicit GPU topology active. Use NVAPI_SetHybridMode to change topology.
125 NVAPI_REQUEST_USER_TO_CLOSE_NON_MIGRATABLE_APPS = -129, // Prompt the user to close all non-migratable applications.
126 NVAPI_OUT_OF_MEMORY = -130, // Could not allocate sufficient memory to complete the call.
127 NVAPI_WAS_STILL_DRAWING = -131, // The previous operation that is transferring information to or from this surface is incomplete.
128 NVAPI_FILE_NOT_FOUND = -132, // The file was not found.
129 NVAPI_TOO_MANY_UNIQUE_STATE_OBJECTS = -133, // There are too many unique instances of a particular type of state object.
130 NVAPI_INVALID_CALL = -134, // The method call is invalid. For example, a method's parameter may not be a valid pointer.
131 NVAPI_D3D10_1_LIBRARY_NOT_FOUND = -135, // d3d10_1.dll cannot be loaded.
132 NVAPI_FUNCTION_NOT_FOUND = -136, // Couldn't find the function in the loaded DLL.
133 NVAPI_INVALID_USER_PRIVILEGE = -137, // Current User is not Admin.
134 NVAPI_EXPECTED_NON_PRIMARY_DISPLAY_HANDLE = -138, // The handle corresponds to GDIPrimary.
135 NVAPI_EXPECTED_COMPUTE_GPU_HANDLE = -139, // Setting Physx GPU requires that the GPU is compute-capable.
136 NVAPI_STEREO_NOT_INITIALIZED = -140, // The Stereo part of NVAPI failed to initialize completely. Check if the stereo driver is installed.
137 NVAPI_STEREO_REGISTRY_ACCESS_FAILED = -141, // Access to stereo-related registry keys or values has failed.
138 NVAPI_STEREO_REGISTRY_PROFILE_TYPE_NOT_SUPPORTED = -142, // The given registry profile type is not supported.
139 NVAPI_STEREO_REGISTRY_VALUE_NOT_SUPPORTED = -143, // The given registry value is not supported.
140 NVAPI_STEREO_NOT_ENABLED = -144, // Stereo is not enabled and the function needed it to execute completely.
141 NVAPI_STEREO_NOT_TURNED_ON = -145, // Stereo is not turned on and the function needed it to execute completely.
142 NVAPI_STEREO_INVALID_DEVICE_INTERFACE = -146, // Invalid device interface.
143 NVAPI_STEREO_PARAMETER_OUT_OF_RANGE = -147, // Separation percentage or JPEG image capture quality is out of [0-100] range.
144 NVAPI_STEREO_FRUSTUM_ADJUST_MODE_NOT_SUPPORTED = -148, // The given frustum adjust mode is not supported.
145 NVAPI_TOPO_NOT_POSSIBLE = -149, // The mosaic topology is not possible given the current state of the hardware.
146 NVAPI_MODE_CHANGE_FAILED = -150, // An attempt to do a display resolution mode change has failed.
147 NVAPI_D3D11_LIBRARY_NOT_FOUND = -151, // d3d11.dll/d3d11_beta.dll cannot be loaded.
148 NVAPI_INVALID_ADDRESS = -152, // Address is outside of valid range.
149 NVAPI_STRING_TOO_SMALL = -153, // The pre-allocated string is too small to hold the result.
150 NVAPI_MATCHING_DEVICE_NOT_FOUND = -154, // The input does not match any of the available devices.
151 NVAPI_DRIVER_RUNNING = -155, // Driver is running.
152 NVAPI_DRIVER_NOTRUNNING = -156, // Driver is not running.
153 NVAPI_ERROR_DRIVER_RELOAD_REQUIRED = -157, // A driver reload is required to apply these settings.
154 NVAPI_SET_NOT_ALLOWED = -158, // Intended setting is not allowed.
155 NVAPI_ADVANCED_DISPLAY_TOPOLOGY_REQUIRED = -159, // Information can't be returned due to "advanced display topology".
156 NVAPI_SETTING_NOT_FOUND = -160, // Setting is not found.
157 NVAPI_SETTING_SIZE_TOO_LARGE = -161, // Setting size is too large.
158 NVAPI_TOO_MANY_SETTINGS_IN_PROFILE = -162, // There are too many settings for a profile.
159 NVAPI_PROFILE_NOT_FOUND = -163, // Profile is not found.
160 NVAPI_PROFILE_NAME_IN_USE = -164, // Profile name is duplicated.
161 NVAPI_PROFILE_NAME_EMPTY = -165, // Profile name is empty.
162 NVAPI_EXECUTABLE_NOT_FOUND = -166, // Application not found in the Profile.
163 NVAPI_EXECUTABLE_ALREADY_IN_USE = -167, // Application already exists in the other profile.
164 NVAPI_DATATYPE_MISMATCH = -168, // Data Type mismatch
165 NVAPI_PROFILE_REMOVED = -169, // The profile passed as parameter has been removed and is no longer valid.
166 NVAPI_UNREGISTERED_RESOURCE = -170, // An unregistered resource was passed as a parameter.
167 NVAPI_ID_OUT_OF_RANGE = -171, // The DisplayId corresponds to a display which is not within the normal outputId range.
168 NVAPI_DISPLAYCONFIG_VALIDATION_FAILED = -172, // Display topology is not valid so the driver cannot do a mode set on this configuration.
169 NVAPI_DPMST_CHANGED = -173, // Display Port Multi-Stream topology has been changed.
170 NVAPI_INSUFFICIENT_BUFFER = -174, // Input buffer is insufficient to hold the contents.
171 NVAPI_ACCESS_DENIED = -175, // No access to the caller.
172 NVAPI_MOSAIC_NOT_ACTIVE = -176, // The requested action cannot be performed without Mosaic being enabled.
173 NVAPI_SHARE_RESOURCE_RELOCATED = -177, // The surface is relocated away from video memory.
174 NVAPI_REQUEST_USER_TO_DISABLE_DWM = -178, // The user should disable DWM before calling NvAPI.
175 NVAPI_D3D_DEVICE_LOST = -179, // D3D device status is D3DERR_DEVICELOST or D3DERR_DEVICENOTRESET - the user has to reset the device.
176 NVAPI_INVALID_CONFIGURATION = -180, // The requested action cannot be performed in the current state.
177 NVAPI_STEREO_HANDSHAKE_NOT_DONE = -181, // Call failed as stereo handshake not completed.
178 NVAPI_EXECUTABLE_PATH_IS_AMBIGUOUS = -182, // The path provided was too short to determine the correct NVDRS_APPLICATION
179 NVAPI_DEFAULT_STEREO_PROFILE_IS_NOT_DEFINED = -183, // Default stereo profile is not currently defined
180 NVAPI_DEFAULT_STEREO_PROFILE_DOES_NOT_EXIST = -184, // Default stereo profile does not exist
181 NVAPI_CLUSTER_ALREADY_EXISTS = -185, // A cluster is already defined with the given configuration.
182 NVAPI_DPMST_DISPLAY_ID_EXPECTED = -186, // The input display id is not that of a multi stream enabled connector or a display device in a multi stream topology
183 NVAPI_INVALID_DISPLAY_ID = -187, // The input display id is not valid or the monitor associated to it does not support the current operation
184 NVAPI_STREAM_IS_OUT_OF_SYNC = -188, // While playing secure audio stream, stream goes out of sync
185 NVAPI_INCOMPATIBLE_AUDIO_DRIVER = -189, // Older audio driver version than required
186 NVAPI_VALUE_ALREADY_SET = -190, // Value already set, setting again not allowed.
187 NVAPI_TIMEOUT = -191, // Requested operation timed out
188 NVAPI_GPU_WORKSTATION_FEATURE_INCOMPLETE = -192, // The requested workstation feature set has incomplete driver internal allocation resources
189 NVAPI_STEREO_INIT_ACTIVATION_NOT_DONE = -193, // Call failed because InitActivation was not called.
190 NVAPI_SYNC_NOT_ACTIVE = -194, // The requested action cannot be performed without Sync being enabled.
191 NVAPI_SYNC_MASTER_NOT_FOUND = -195, // The requested action cannot be performed without Sync Master being enabled.
192 NVAPI_INVALID_SYNC_TOPOLOGY = -196, // Invalid displays passed in the NV_GSYNC_DISPLAY pointer.
193 NVAPI_ECID_SIGN_ALGO_UNSUPPORTED = -197, // The specified signing algorithm is not supported. Either an incorrect value was entered or the current installed driver/hardware does not support the input value.
194 NVAPI_ECID_KEY_VERIFICATION_FAILED = -198, // The encrypted public key verification has failed.
195 NVAPI_FIRMWARE_OUT_OF_DATE = -199, // The device's firmware is out of date.
196 NVAPI_FIRMWARE_REVISION_NOT_SUPPORTED = -200, // The device's firmware is not supported.
197 } NvAPI_Status;
198
199 /*
200 * Declarations from from nvapi.h
201 */
202
203 #define NVAPI_MAX_THERMAL_SENSORS_PER_GPU 3
204
205 // Used in NV_GPU_THERMAL_SETTINGS
206 typedef enum
207 {
208 NVAPI_THERMAL_TARGET_NONE = 0,
209 NVAPI_THERMAL_TARGET_GPU = 1, // GPU core temperature requires NvPhysicalGpuHandle
210 NVAPI_THERMAL_TARGET_MEMORY = 2, // GPU memory temperature requires NvPhysicalGpuHandle
211 NVAPI_THERMAL_TARGET_POWER_SUPPLY = 4, // GPU power supply temperature requires NvPhysicalGpuHandle
212 NVAPI_THERMAL_TARGET_BOARD = 8, // GPU board ambient temperature requires NvPhysicalGpuHandle
213 NVAPI_THERMAL_TARGET_VCD_BOARD = 9, // Visual Computing Device Board temperature requires NvVisualComputingDeviceHandle
214 NVAPI_THERMAL_TARGET_VCD_INLET = 10, // Visual Computing Device Inlet temperature requires NvVisualComputingDeviceHandle
215 NVAPI_THERMAL_TARGET_VCD_OUTLET = 11, // Visual Computing Device Outlet temperature requires NvVisualComputingDeviceHandle
216
217 NVAPI_THERMAL_TARGET_ALL = 15,
218 NVAPI_THERMAL_TARGET_UNKNOWN = -1,
219 } NV_THERMAL_TARGET;
220
221 // Used in NV_GPU_THERMAL_SETTINGS
222 typedef enum
223 {
224 NVAPI_THERMAL_CONTROLLER_NONE = 0,
225 NVAPI_THERMAL_CONTROLLER_GPU_INTERNAL,
226 NVAPI_THERMAL_CONTROLLER_ADM1032,
227 NVAPI_THERMAL_CONTROLLER_MAX6649,
228 NVAPI_THERMAL_CONTROLLER_MAX1617,
229 NVAPI_THERMAL_CONTROLLER_LM99,
230 NVAPI_THERMAL_CONTROLLER_LM89,
231 NVAPI_THERMAL_CONTROLLER_LM64,
232 NVAPI_THERMAL_CONTROLLER_ADT7473,
233 NVAPI_THERMAL_CONTROLLER_SBMAX6649,
234 NVAPI_THERMAL_CONTROLLER_VBIOSEVT,
235 NVAPI_THERMAL_CONTROLLER_OS,
236 NVAPI_THERMAL_CONTROLLER_UNKNOWN = -1,
237 } NV_THERMAL_CONTROLLER;
238
239 // Used in NvAPI_GPU_GetThermalSettings()
240 typedef struct
241 {
242 NvU32 version; // structure version
243 NvU32 count; // number of associated thermal sensors
244 struct
245 {
246 NV_THERMAL_CONTROLLER controller; // internal, ADM1032, MAX6649...
247 NvU32 defaultMinTemp; // The min default temperature value of the thermal sensor in degree Celsius
248 NvU32 defaultMaxTemp; // The max default temperature value of the thermal sensor in degree Celsius
249 NvU32 currentTemp; // The current temperature value of the thermal sensor in degree Celsius
250 NV_THERMAL_TARGET target; // Thermal sensor targeted @ GPU, memory, chipset, powersupply, Visual Computing Device, etc.
251 } sensor[NVAPI_MAX_THERMAL_SENSORS_PER_GPU];
252
253 } NV_GPU_THERMAL_SETTINGS_V1;
254
255 typedef struct
256 {
257 NvU32 version; // structure version
258 NvU32 count; // number of associated thermal sensors
259 struct
260 {
261 NV_THERMAL_CONTROLLER controller; // internal, ADM1032, MAX6649...
262 NvS32 defaultMinTemp; // Minimum default temperature value of the thermal sensor in degree Celsius
263 NvS32 defaultMaxTemp; // Maximum default temperature value of the thermal sensor in degree Celsius
264 NvS32 currentTemp; // Current temperature value of the thermal sensor in degree Celsius
265 NV_THERMAL_TARGET target; // Thermal sensor targeted - GPU, memory, chipset, powersupply, Visual Computing Device, etc
266 } sensor[NVAPI_MAX_THERMAL_SENSORS_PER_GPU];
267
268 } NV_GPU_THERMAL_SETTINGS_V2;
269
270 typedef NV_GPU_THERMAL_SETTINGS_V2 NV_GPU_THERMAL_SETTINGS;
271
272 // Macro for constructing the version field of NV_GPU_THERMAL_SETTINGS_V1
273 #define NV_GPU_THERMAL_SETTINGS_VER_1 MAKE_NVAPI_VERSION(NV_GPU_THERMAL_SETTINGS_V1,1)
274
275 // Macro for constructing the version field of NV_GPU_THERMAL_SETTINGS_V2
276 #define NV_GPU_THERMAL_SETTINGS_VER_2 MAKE_NVAPI_VERSION(NV_GPU_THERMAL_SETTINGS_V2,2)
277
278 // Macro for constructing the version field of NV_GPU_THERMAL_SETTINGS
279 #define NV_GPU_THERMAL_SETTINGS_VER NV_GPU_THERMAL_SETTINGS_VER_2
280
281 #define NVAPI_MAX_GPU_UTILIZATIONS 8
282
283 // Used in NvAPI_GPU_GetDynamicPstatesInfoEx().
284 typedef struct
285 {
286 NvU32 version; // Structure version
287 NvU32 flags; // bit 0 indicates if the dynamic Pstate is enabled or not
288 struct
289 {
290 NvU32 bIsPresent:1; // Set if this utilization domain is present on this GPU
291 NvU32 percentage; // Percentage of time where the domain is considered busy in the last 1 second interval
292 } utilization[NVAPI_MAX_GPU_UTILIZATIONS];
293 } NV_GPU_DYNAMIC_PSTATES_INFO_EX;
294
295 // Macro for constructing the version field of NV_GPU_DYNAMIC_PSTATES_INFO_EX
296 #define NV_GPU_DYNAMIC_PSTATES_INFO_EX_VER MAKE_NVAPI_VERSION(NV_GPU_DYNAMIC_PSTATES_INFO_EX,1)
297
298 #define NVAPI_MAX_COOLER_PER_GPU 20
299
300 #define GPU_COOLER_SETTINGS_VER 0x20000
301 #define GPU_COOLER_LEVELS_VER 0x10000
302
303 // Used in NV_GPU_COOLER_SETTINGS
304 typedef struct
305 {
306 NvS32 Type;
307 NvS32 Controller;
308 NvS32 DefaultMin;
309 NvS32 DefaultMax;
310 NvS32 CurrentMin;
311 NvS32 CurrentMax;
312 NvS32 CurrentLevel;
313 NvS32 DefaultPolicy;
314 NvS32 CurrentPolicy;
315 NvS32 Target;
316 NvS32 ControlType;
317 NvS32 Active;
318
319 } NvCooler;
320
321 // Used in NvAPI_GPU_GetCoolerSettings().
322 typedef struct
323 {
324 NvU32 Version;
325 NvU32 Count;
326 NvCooler Cooler[NVAPI_MAX_COOLER_PER_GPU];
327
328 } NV_GPU_COOLER_SETTINGS;
329
330 typedef struct
331 {
332 NvS32 Level;
333 NvS32 Policy;
334
335 } NvLevel;
336
337 typedef struct
338 {
339 NvU32 Version;
340 NvLevel Levels[NVAPI_MAX_COOLER_PER_GPU];
341
342 } NV_GPU_COOLER_LEVELS;
343
344 #define NVAPI_MAX_GPU_PUBLIC_CLOCKS 32
345
346 typedef enum _NV_GPU_PUBLIC_CLOCK_ID
347 {
348 NVAPI_GPU_PUBLIC_CLOCK_GRAPHICS = 0,
349 NVAPI_GPU_PUBLIC_CLOCK_MEMORY = 4,
350 NVAPI_GPU_PUBLIC_CLOCK_PROCESSOR = 7,
351 NVAPI_GPU_PUBLIC_CLOCK_VIDEO = 8,
352 NVAPI_GPU_PUBLIC_CLOCK_UNDEFINED = NVAPI_MAX_GPU_PUBLIC_CLOCKS,
353 } NV_GPU_PUBLIC_CLOCK_ID;
354
355 //! Used in NvAPI_GPU_GetAllClockFrequencies()
356 typedef struct
357 {
358 NvU32 version; //!< Structure version
359 NvU32 reserved; //!< These bits are reserved for future use.
360 struct
361 {
362 NvU32 bIsPresent:1; //!< Set if this domain is present on this GPU
363 NvU32 reserved:31; //!< These bits are reserved for future use.
364 NvU32 frequency; //!< Clock frequency (kHz)
365 }domain[NVAPI_MAX_GPU_PUBLIC_CLOCKS];
366 } NV_GPU_CLOCK_FREQUENCIES_V1;
367
368 //! Used in NvAPI_GPU_GetAllClockFrequencies()
369 typedef enum
370 {
371 NV_GPU_CLOCK_FREQUENCIES_CURRENT_FREQ = 0,
372 NV_GPU_CLOCK_FREQUENCIES_BASE_CLOCK = 1,
373 NV_GPU_CLOCK_FREQUENCIES_BOOST_CLOCK = 2,
374 NV_GPU_CLOCK_FREQUENCIES_CLOCK_TYPE_NUM = 3
375 } NV_GPU_CLOCK_FREQUENCIES_CLOCK_TYPE;
376
377 //! Used in NvAPI_GPU_GetAllClockFrequencies()
378 typedef struct
379 {
380 NvU32 version; //!< Structure version
381 NvU32 ClockType:2; //!< One of NV_GPU_CLOCK_FREQUENCIES_CLOCK_TYPE. Used to specify the type of clock to be returned.
382 NvU32 reserved:22; //!< These bits are reserved for future use. Must be set to 0.
383 NvU32 reserved1:8; //!< These bits are reserved.
384 struct
385 {
386 NvU32 bIsPresent:1; //!< Set if this domain is present on this GPU
387 NvU32 reserved:31; //!< These bits are reserved for future use.
388 NvU32 frequency; //!< Clock frequency (kHz)
389 }domain[NVAPI_MAX_GPU_PUBLIC_CLOCKS];
390 } NV_GPU_CLOCK_FREQUENCIES_V2;
391
392 //! \ingroup gpuclock
393 //! Used in NvAPI_GPU_GetAllClockFrequencies()
394 typedef NV_GPU_CLOCK_FREQUENCIES_V2 NV_GPU_CLOCK_FREQUENCIES;
395
396 //! \addtogroup gpuclock
397 //! @{
398 #define NV_GPU_CLOCK_FREQUENCIES_VER_1 MAKE_NVAPI_VERSION(NV_GPU_CLOCK_FREQUENCIES_V1,1)
399 #define NV_GPU_CLOCK_FREQUENCIES_VER_2 MAKE_NVAPI_VERSION(NV_GPU_CLOCK_FREQUENCIES_V2,2)
400 #define NV_GPU_CLOCK_FREQUENCIES_VER_3 MAKE_NVAPI_VERSION(NV_GPU_CLOCK_FREQUENCIES_V2,3)
401 #define NV_GPU_CLOCK_FREQUENCIES_VER NV_GPU_CLOCK_FREQUENCIES_VER_3
402 //! @}
403
404 //! Used in NvAPI_GPU_GetPerfDecreaseInfo.
405 //! Bit masks for knowing the exact reason for performance decrease
406 typedef enum _NVAPI_GPU_PERF_DECREASE
407 {
408 NV_GPU_PERF_DECREASE_NONE = 0, //!< No Slowdown detected
409 NV_GPU_PERF_DECREASE_REASON_THERMAL_PROTECTION = 0x00000001, //!< Thermal slowdown/shutdown/POR thermal protection
410 NV_GPU_PERF_DECREASE_REASON_POWER_CONTROL = 0x00000002, //!< Power capping / pstate cap
411 NV_GPU_PERF_DECREASE_REASON_AC_BATT = 0x00000004, //!< AC->BATT event
412 NV_GPU_PERF_DECREASE_REASON_API_TRIGGERED = 0x00000008, //!< API triggered slowdown
413 NV_GPU_PERF_DECREASE_REASON_INSUFFICIENT_POWER = 0x00000010, //!< Power connector missing
414 NV_GPU_PERF_DECREASE_REASON_UNKNOWN = 0x80000000, //!< Unknown reason
415 } NVAPI_GPU_PERF_DECREASE;
416
417
418 NVAPI_INTERFACE NvAPI_QueryInterface(uint offset);
419 NVAPI_INTERFACE NvAPI_Initialize();
420 NVAPI_INTERFACE NvAPI_Unload();
421 NVAPI_INTERFACE NvAPI_GetErrorMessage(NvAPI_Status nr,NvAPI_ShortString szDesc);
422 NVAPI_INTERFACE NvAPI_EnumPhysicalGPUs(NvPhysicalGpuHandle nvGPUHandle[NVAPI_MAX_PHYSICAL_GPUS], NvU32 *pGpuCount);
423 NVAPI_INTERFACE NvAPI_GPU_GetThermalSettings(NvPhysicalGpuHandle hPhysicalGpu, NvU32 sensorIndex, NV_GPU_THERMAL_SETTINGS *pThermalSettings);
424 NVAPI_INTERFACE NvAPI_GPU_GetTachReading(NvPhysicalGpuHandle hPhysicalGPU, NvU32 *pValue);
425 NVAPI_INTERFACE NvAPI_GPU_GetCoolerSettings(NvPhysicalGpuHandle hPhysicalGpu, NvU32 coolerIndex, NV_GPU_COOLER_SETTINGS *pCoolerSettings);
426 NVAPI_INTERFACE NvAPI_GPU_SetCoolerLevels(NvPhysicalGpuHandle hPhysicalGpu, NvU32 coolerIndex, NV_GPU_COOLER_LEVELS *pCoolerLevels);
427 NVAPI_INTERFACE NvAPI_GPU_GetDynamicPstatesInfoEx(NvPhysicalGpuHandle hPhysicalGpu, NV_GPU_DYNAMIC_PSTATES_INFO_EX *pDynamicPstatesInfoEx);
428 NVAPI_INTERFACE NvAPI_GPU_GetAllClockFrequencies(NvPhysicalGpuHandle hPhysicalGpu, NV_GPU_CLOCK_FREQUENCIES *pClkFreqs);
429 NVAPI_INTERFACE NvAPI_GPU_GetCurrentPCIEDownstreamWidth(NvPhysicalGpuHandle hPhysicalGpu, NvU32 *pWidth);
430 NVAPI_INTERFACE NvAPI_GPU_GetPerfDecreaseInfo(NvPhysicalGpuHandle hPhysicalGpu, NvU32 *pPerfDecrInfo);
431
432 #ifdef __nvapi_success
433 #undef __success
434 #undef __nvapi_success
435 #endif
436
437 /*
438 * End of declarations from nvapi.h and subheaders
439 **/
440
441 // Just annotations (they do nothing special)
442
443 #ifndef __success
444 #define __success(x)
445 #endif
446 #ifndef __in
447 #define __in
448 #endif
449 #ifndef __out
450 #define __out
451 #endif
452 #ifndef __in_ecount
453 #define __in_ecount(x)
454 #endif
455 #ifndef __out_ecount
456 #define __out_ecount(x)
457 #endif
458 #ifndef __in_opt
459 #define __in_opt
460 #endif
461 #ifndef __out_opt
462 #define __out_opt
463 #endif
464 #ifndef __inout
465 #define __inout
466 #endif
467 #ifndef __inout_opt
468 #define __inout_opt
469 #endif
470 #ifndef __inout_ecount
471 #define __inout_ecount(x)
472 #endif
473 #ifndef __inout_ecount_full
474 #define __inout_ecount_full(x)
475 #endif
476 #ifndef __inout_ecount_part_opt
477 #define __inout_ecount_part_opt(x,y)
478 #endif
479 #ifndef __inout_ecount_full_opt
480 #define __inout_ecount_full_opt(x,y)
481 #endif
482 #ifndef __out_ecount_full_opt
483 #define __out_ecount_full_opt(x)
484 #endif
485
486 typedef NvPhysicalGpuHandle HM_ADAPTER_NV;
487
488 #include <shared.h>
489
490 typedef int *(*NVAPI_QUERYINTERFACE) (uint);
491 typedef int (*NVAPI_INITIALIZE) (void);
492 typedef int (*NVAPI_UNLOAD) (void);
493 typedef int (*NVAPI_GETERRORMESSAGE) (NvAPI_Status, NvAPI_ShortString);
494 typedef int (*NVAPI_ENUMPHYSICALGPUS) (NvPhysicalGpuHandle nvGPUHandle[NVAPI_MAX_PHYSICAL_GPUS], NvU32 *);
495 typedef int (*NVAPI_GPU_GETTHERMALSETTINGS) (NvPhysicalGpuHandle, NvU32, NV_GPU_THERMAL_SETTINGS *);
496 typedef int (*NVAPI_GPU_GETTACHREADING) (NvPhysicalGpuHandle, NvU32 *);
497 typedef int (*NVAPI_GPU_GETCOOLERSETTINGS) (NvPhysicalGpuHandle, NvU32, NV_GPU_COOLER_SETTINGS *);
498 typedef int (*NVAPI_GPU_SETCOOLERLEVELS) (NvPhysicalGpuHandle, NvU32, NV_GPU_COOLER_LEVELS *);
499 typedef int (*NVAPI_GPU_GETDYNAMICPSTATESINFOEX) (NvPhysicalGpuHandle, NV_GPU_DYNAMIC_PSTATES_INFO_EX *);
500 typedef int (*NVAPI_GPU_GETALLCLOCKFREQUENCIES) (NvPhysicalGpuHandle, NV_GPU_CLOCK_FREQUENCIES *);
501 typedef int (*NVAPI_GPU_GETCURRENTPCIEDOWNSTREAMWIDTH) (NvPhysicalGpuHandle, NvU32 *);
502 typedef int (*NVAPI_GPU_GETPERFDECREASEINFO) (NvPhysicalGpuHandle, NvU32 *);
503
504 typedef struct
505 {
506 NV_LIB lib;
507
508 NVAPI_QUERYINTERFACE nvapi_QueryInterface;
509 NVAPI_INITIALIZE NvAPI_Initialize;
510 NVAPI_UNLOAD NvAPI_Unload;
511 NVAPI_GETERRORMESSAGE NvAPI_GetErrorMessage;
512 NVAPI_ENUMPHYSICALGPUS NvAPI_EnumPhysicalGPUs;
513 NVAPI_GPU_GETTHERMALSETTINGS NvAPI_GPU_GetThermalSettings;
514 NVAPI_GPU_GETTACHREADING NvAPI_GPU_GetTachReading;
515 NVAPI_GPU_GETCOOLERSETTINGS NvAPI_GPU_GetCoolerSettings;
516 NVAPI_GPU_SETCOOLERLEVELS NvAPI_GPU_SetCoolerLevels;
517 NVAPI_GPU_GETDYNAMICPSTATESINFOEX NvAPI_GPU_GetDynamicPstatesInfoEx;
518 NVAPI_GPU_GETALLCLOCKFREQUENCIES NvAPI_GPU_GetAllClockFrequencies;
519 NVAPI_GPU_GETCURRENTPCIEDOWNSTREAMWIDTH NvAPI_GPU_GetCurrentPCIEDownstreamWidth;
520 NVAPI_GPU_GETPERFDECREASEINFO NvAPI_GPU_GetPerfDecreaseInfo;
521
522 } hm_nvapi_lib_t;
523
524 #define NVAPI_PTR hm_nvapi_lib_t
525
526 int nvapi_init (NVAPI_PTR *nvapi);
527 void nvapi_close (NVAPI_PTR *nvapi);
528
529 int hm_NvAPI_QueryInterface (NVAPI_PTR *nvapi, uint offset);
530 int hm_NvAPI_Initialize (NVAPI_PTR *nvapi);
531 int hm_NvAPI_Unload (NVAPI_PTR *nvapi);
532 int hm_NvAPI_GetErrorMessage (NVAPI_PTR *nvapi, NvAPI_Status nr, NvAPI_ShortString szDesc);
533 int hm_NvAPI_EnumPhysicalGPUs (NVAPI_PTR *nvapi, NvPhysicalGpuHandle nvGPUHandle[NVAPI_MAX_PHYSICAL_GPUS], NvU32 *pGpuCount);
534 int hm_NvAPI_GPU_GetThermalSettings (NVAPI_PTR *nvapi, NvPhysicalGpuHandle hPhysicalGpu, NvU32 sensorIndex, NV_GPU_THERMAL_SETTINGS *pThermalSettings);
535 int hm_NvAPI_GPU_GetTachReading (NVAPI_PTR *nvapi, NvPhysicalGpuHandle hPhysicalGPU, NvU32 *pValue);
536 int hm_NvAPI_GPU_GetCoolerSettings (NVAPI_PTR *nvapi, NvPhysicalGpuHandle hPhysicalGpu, NvU32 coolerIndex, NV_GPU_COOLER_SETTINGS *pCoolerSettings);
537 int hm_NvAPI_GPU_SetCoolerLevels (NVAPI_PTR *nvapi, NvPhysicalGpuHandle hPhysicalGpu, NvU32 coolerIndex, NV_GPU_COOLER_LEVELS *pCoolerLevels);
538 int hm_NvAPI_GPU_GetDynamicPstatesInfoEx (NVAPI_PTR *nvapi, NvPhysicalGpuHandle hPhysicalGpu, NV_GPU_DYNAMIC_PSTATES_INFO_EX *pDynamicPstatesInfoEx);
539 int hm_NvAPI_GPU_GetAllClockFrequencies (NVAPI_PTR *nvapi, NvPhysicalGpuHandle hPhysicalGpu, NV_GPU_CLOCK_FREQUENCIES *pClkFreqs);
540 int hm_NvAPI_GPU_GetCurrentPCIEDownstreamWidth (NVAPI_PTR *nvapi, NvPhysicalGpuHandle hPhysicalGpu, NvU32 *pWidth);
541 int hm_NvAPI_GPU_GetPerfDecreaseInfo (NVAPI_PTR *nvapi, NvPhysicalGpuHandle hPhysicalGpu, NvU32 *pPerfDecrInfo);
542
543 #endif // HAVE_HWMON
544
545 #endif // EXT_NVAPI_H