nvapi_sys/gpu/
mod.rs

1use status::NvAPI_Status;
2use handles::NvPhysicalGpuHandle;
3use types;
4
5/// The GPU cooler APIs are used to get and set the fan level or equivalent
6/// cooler levels for various target devices associated with the GPU.
7pub mod cooler;
8
9/// The GPU performance state APIs are used to get and set various performance
10/// levels on a per-GPU basis. P-States are GPU active/executing performance
11/// capability and power consumption states.
12///
13/// P-States range from P0 to P15, with P0 being the highest performance/power
14/// state, and P15 being the lowest performance/power state. Each P-State maps
15/// to a performance level. Not all P-States are available on a given system.
16/// The definition of each P-States are currently as follows:
17///
18/// - `P0`/`P1` Maximum 3D performance
19/// - `P2`/`P3` Balanced 3D performance-power
20/// - `P8` Basic HD video playback
21/// - `P10` DVD playback
22/// - `P12` Minimum idle power consumption
23pub mod pstate;
24
25/// The GPU clock control APIs are used to get and set individual clock domains
26/// on a per-GPU basis.
27pub mod clock;
28
29/// The GPU thermal control APIs are used to get temperature levels from the
30/// various thermal sensors associated with the GPU.
31pub mod thermal;
32
33pub mod power;
34
35pub mod display;
36
37nvapi! {
38    pub type EnumPhysicalGPUsFn = extern "C" fn(nvGPUHandle: *mut [NvPhysicalGpuHandle; types::NVAPI_MAX_PHYSICAL_GPUS], pGpuCount: *mut u32) -> NvAPI_Status;
39
40    /// This function returns an array of physical GPU handles.
41    /// Each handle represents a physical GPU present in the system.
42    /// That GPU may be part of an SLI configuration, or may not be visible to the OS directly.
43    ///
44    /// At least one GPU must be present in the system and running an NVIDIA display driver.
45    ///
46    /// The array nvGPUHandle will be filled with physical GPU handle values. The returned
47    /// gpuCount determines how many entries in the array are valid.
48    ///
49    /// Note: In drivers older than 105.00, all physical GPU handles get invalidated on a
50    /// modeset. So the calling applications need to renum the handles after every modeset.
51    /// With drivers 105.00 and up, all physical GPU handles are constant.
52    /// Physical GPU handles are constant as long as the GPUs are not physically moved and
53    /// the SBIOS VGA order is unchanged.
54    ///
55    /// For GPU handles in TCC MODE please use NvAPI_EnumTCCPhysicalGPUs()
56    pub unsafe fn NvAPI_EnumPhysicalGPUs;
57}
58
59nvapi! {
60    pub type GPU_GetFullNameFn = extern "C" fn(hPhysicalGPU: NvPhysicalGpuHandle, szName: *mut types::NvAPI_ShortString) -> NvAPI_Status;
61
62    /// This function retrieves the full GPU name as an ASCII string - for example, "Quadro FX 1400".
63    pub unsafe fn NvAPI_GPU_GetFullName;
64}
65
66nvapi! {
67    pub type GPU_GetPhysicalFrameBufferSizeFn = extern "C" fn(hPhysicalGPU: NvPhysicalGpuHandle, pSize: *mut u32) -> NvAPI_Status;
68
69    /// This function returns the physical size of framebuffer in KB.  This does NOT include any
70    /// system RAM that may be dedicated for use by the GPU.
71    pub unsafe fn NvAPI_GPU_GetPhysicalFrameBufferSize;
72}
73
74nvapi! {
75    pub type GPU_GetVbiosVersionStringFn = extern "C" fn(hPhysicalGPU: NvPhysicalGpuHandle, szBiosRevision: *mut types::NvAPI_ShortString) -> NvAPI_Status;
76
77    /// This function returns the full video BIOS version string in the form of xx.xx.xx.xx.yy where
78    /// - xx numbers come from NvAPI_GPU_GetVbiosRevision() and
79    /// - yy comes from NvAPI_GPU_GetVbiosOEMRevision().
80    pub unsafe fn NvAPI_GPU_GetVbiosVersionString;
81}
82
83nvapi! {
84    pub type GPU_GetPCIIdentifiersFn = extern "C" fn(hPhysicalGPU: NvPhysicalGpuHandle, pDeviceId: *mut u32, pSubSystemId: *mut u32, pRevisionId: *mut u32, pExtDeviceId: *mut u32) -> NvAPI_Status;
85
86    /// This function returns the PCI identifiers associated with this GPU.
87    pub unsafe fn NvAPI_GPU_GetPCIIdentifiers;
88}
89
90nvenum! {
91    /// Used in NvAPI_GPU_GetSystemType()
92    pub enum NV_SYSTEM_TYPE / SystemType {
93        NV_SYSTEM_TYPE_UNKNOWN / Unknown = 0,
94        NV_SYSTEM_TYPE_LAPTOP / Laptop = 1,
95        NV_SYSTEM_TYPE_DESKTOP / Desktop = 2,
96    }
97}
98
99nvenum_display! {
100    SystemType => _
101}
102
103nvapi! {
104    pub type GPU_GetSystemTypeFn = extern "C" fn(hPhysicalGPU: NvPhysicalGpuHandle, pSystemType: *mut NV_SYSTEM_TYPE) -> NvAPI_Status;
105
106    /// This function identifies whether the GPU is a notebook GPU or a desktop GPU.
107    pub unsafe fn NvAPI_GPU_GetSystemType;
108}
109
110nvapi! {
111    pub type GPU_GetShaderSubPipeCountFn = extern "C" fn(hPhysicalGPU: NvPhysicalGpuHandle, pCount: *mut u32) -> NvAPI_Status;
112
113    /// This function retrieves the number of Shader SubPipes on the GPU
114    /// On newer architectures, this corresponds to the number of SM units
115    pub unsafe fn NvAPI_GPU_GetShaderSubPipeCount;
116}
117
118nvapi! {
119    pub type GPU_GetGpuCoreCountFn = extern "C" fn(hPhysicalGPU: NvPhysicalGpuHandle, pCount: *mut u32) -> NvAPI_Status;
120
121    /// Retrieves the total number of cores defined for a GPU.
122    /// Returns 0 on architectures that don't define GPU cores.
123    pub unsafe fn NvAPI_GPU_GetGpuCoreCount;
124}
125
126nvstruct! {
127    pub struct NV_BOARD_INFO_V1 {
128        /// structure version
129        pub version: u32,
130        /// Board Serial Number
131        pub BoardNum: [u8; 16],
132    }
133}
134
135nvversion! { NV_BOARD_INFO_VER1(NV_BOARD_INFO_V1 = 4+16, 1) }
136nvversion! { NV_BOARD_INFO_VER = NV_BOARD_INFO_VER1 }
137
138pub type NV_BOARD_INFO = NV_BOARD_INFO_V1;
139
140nvapi! {
141    /// This API Retrieves the Board information (a unique GPU Board Serial Number) stored in the InfoROM.
142    pub unsafe fn NvAPI_GPU_GetBoardInfo(hPhysicalGpu: NvPhysicalGpuHandle, pBoardInfo: *mut NV_BOARD_INFO) -> NvAPI_Status;
143}
144
145nvbits! {
146    /// Bit masks for knowing the exact reason for performance decrease
147    ///
148    /// Used in `NvAPI_GPU_GetPerfDecreaseInfo`
149    pub enum NVAPI_GPU_PERF_DECREASE / PerformanceDecreaseReason {
150        NV_GPU_PERF_DECREASE_NONE / NONE = 0x00,
151        NV_GPU_PERF_DECREASE_REASON_THERMAL_PROTECTION / THERMAL_PROTECTION = 0x01,
152        NV_GPU_PERF_DECREASE_REASON_POWER_CONTROL / POWER_CONTROL = 0x02,
153        NV_GPU_PERF_DECREASE_REASON_AC_BATT / AC_BATTERY = 0x04,
154        NV_GPU_PERF_DECREASE_REASON_API_TRIGGERED / API_TRIGGERED = 0x08,
155        NV_GPU_PERF_DECREASE_REASON_INSUFFICIENT_POWER / INSUFFICIENT_POWER = 0x10,
156        NV_GPU_PERF_DECREASE_REASON_UNKNOWN / UNKNOWN = 0x00,
157    }
158}
159
160nvapi! {
161    /// This function retrieves reasons for the current performance decrease.
162    pub unsafe fn NvAPI_GPU_GetPerfDecreaseInfo(hPhysicalGpu: NvPhysicalGpuHandle, pPerfDecrInfo: *mut NVAPI_GPU_PERF_DECREASE) -> NvAPI_Status;
163}
164
165/// Undocumented API
166pub mod private {
167    use status::NvAPI_Status;
168    use handles::NvPhysicalGpuHandle;
169    use types;
170
171    pub const NVAPI_MAX_PROCESSES: usize = 128;
172
173    nvapi! {
174        pub type GPU_GetShaderPipeCountFn = extern "C" fn(hPhysicalGPU: NvPhysicalGpuHandle, pCount: *mut u32) -> NvAPI_Status;
175
176        pub unsafe fn NvAPI_GPU_GetShaderPipeCount;
177    }
178
179    nvenum! {
180        /// Undocumented function NvAPI_GPU_GetRamType()
181        pub enum NV_GPU_RAM_TYPE / RamType {
182            NV_GPU_RAM_UNKNOWN / Unknown = 0,
183            NV_GPU_RAM_SDRAM / SDRAM = 1,
184            NV_GPU_RAM_DDR1 / DDR1 = 2,
185            NV_GPU_RAM_DDR2 / DDR2 = 3,
186            NV_GPU_RAM_GDDR2 / GDDR2 = 4,
187            NV_GPU_RAM_GDDR3 / GDDR3 = 5,
188            NV_GPU_RAM_GDDR4 / GDDR4 = 6,
189            NV_GPU_RAM_DDR3 / DDR3 = 7,
190            NV_GPU_RAM_GDDR5 / GDDR5 = 8,
191            NV_GPU_RAM_LPDDR2 / LPDDR2 = 9,
192            NV_GPU_RAM_GDDR5X / GDDR5X = 10,
193        }
194    }
195
196    nvenum_display! {
197        RamType => _
198    }
199
200    nvapi! {
201        pub type GPU_GetRamTypeFn = extern "C" fn(hPhysicalGPU: NvPhysicalGpuHandle, pMemType: *mut NV_GPU_RAM_TYPE) -> NvAPI_Status;
202
203        /// Undocumented function.
204        pub unsafe fn NvAPI_GPU_GetRamType;
205    }
206
207
208    nvenum! {
209        /// Undocumented function NvAPI_GPU_GetRamMaker()
210        pub enum NV_GPU_RAM_MAKER / RamMaker {
211            NV_GPU_RAM_MAKER_UNKNOWN / Unknown = 0,
212            NV_GPU_RAM_MAKER_SAMSUNG / Samsung = 1,
213            NV_GPU_RAM_MAKER_QIMONDA / Qimonda = 2,
214            NV_GPU_RAM_MAKER_ELPIDA / Elpida = 3,
215            NV_GPU_RAM_MAKER_ETRON / Etron = 4,
216            NV_GPU_RAM_MAKER_NANYA / Nanya = 5,
217            NV_GPU_RAM_MAKER_HYNIX / Hynix = 6,
218            NV_GPU_RAM_MAKER_MOSEL / Mosel = 7,
219            NV_GPU_RAM_MAKER_WINBOND / Winbond = 8,
220            NV_GPU_RAM_MAKER_ELITE / Elite = 9,
221            NV_GPU_RAM_MAKER_MICRON / Micron = 10,
222        }
223    }
224
225    nvenum_display! {
226        RamMaker => _
227    }
228
229    nvapi! {
230        pub type GPU_GetRamMakerFn = extern "C" fn(hPhysicalGPU: NvPhysicalGpuHandle, pRamMaker: *mut NV_GPU_RAM_MAKER) -> NvAPI_Status;
231
232        /// Undocumented function.
233        pub unsafe fn NvAPI_GPU_GetRamMaker;
234    }
235
236    nvapi! {
237        pub type GPU_GetRamBusWidthFn = extern "C" fn(hPhysicalGPU: NvPhysicalGpuHandle, pRamBusWidth: *mut u32) -> NvAPI_Status;
238
239        /// Undocumented function.
240        pub unsafe fn NvAPI_GPU_GetRamBusWidth;
241    }
242
243    nvapi! {
244        pub type GPU_GetRamBankCountFn = extern "C" fn(hPhysicalGPU: NvPhysicalGpuHandle, pRamBankCount: *mut u32) -> NvAPI_Status;
245
246        /// Undocumented function.
247        pub unsafe fn NvAPI_GPU_GetRamBankCount;
248    }
249
250    nvenum! {
251        /// Undocumented function NvAPI_GPU_GetFoundry()
252        pub enum NV_GPU_FOUNDRY / Foundry {
253            NV_GPU_FOUNDRY_UNKNOWN / Unknown = 0,
254            NV_GPU_FOUNDRY_TSMC / TSMC = 1,
255            NV_GPU_FOUNDRY_UMC / UMC = 2,
256            NV_GPU_FOUNDRY_IBM / IBM = 3,
257            NV_GPU_FOUNDRY_SMIC / SMIC = 4,
258            NV_GPU_FOUNDRY_CSM / CSM = 5,
259            NV_GPU_FOUNDRY_TOSHIBA / Toshiba = 6,
260        }
261    }
262
263    nvenum_display! {
264        Foundry => {
265            TSMC = "Taiwan Semiconductor Manufacturing Company (TSMC)",
266            UMC = "United Microelectronics Corporation (UMC)",
267            IBM = "IBM Microelectronics",
268            SMIC = "Semiconductor Manufacturing International Corporation (SMIC)",
269            CSM = "Chartered Semiconductor Manufacturing (CSM)",
270            Toshiba = "Toshiba Corporation",
271            _ = _,
272        }
273    }
274
275    nvapi! {
276        pub type GPU_GetFoundryFn = extern "C" fn(hPhysicalGPU: NvPhysicalGpuHandle, pFoundry: *mut NV_GPU_FOUNDRY) -> NvAPI_Status;
277
278        /// Undocumented function.
279        pub unsafe fn NvAPI_GPU_GetFoundry;
280    }
281
282    nvapi! {
283        pub unsafe fn NvAPI_GPU_GetFBWidthAndLocation(hPhysicalGpu: NvPhysicalGpuHandle, pWidth: *mut u32, pLocation: *mut u32) -> NvAPI_Status;
284    }
285
286    nvenum! {
287        pub enum NV_GPU_VENDOR / VendorId {
288            NV_GPU_VENDOR_UNKNOWN / Unknown = 0,
289            NV_GPU_VENDOR_ASUS / ASUS = 0x1043,
290            NV_GPU_VENDOR_ELSA / Elsa = 0x1048,
291            NV_GPU_VENDOR_LEADTEK / Leadtek = 0x107d,
292            NV_GPU_VENDOR_GAINWARD / Gainward = 0x10b0,
293            NV_GPU_VENDOR_NVIDIA / NVIDIA = 0x10de,
294            NV_GPU_VENDOR_GIGABYTE / Gigabyte = 0x1458,
295            NV_GPU_VENDOR_MSI / MSI = 0x1462,
296            NV_GPU_VENDOR_PNY_ / PNY_ = 0x154b, // maybe storage devices
297            NV_GPU_VENDOR_PALIT / Palit = 0x1569,
298            NV_GPU_VENDOR_XFX / XFX = 0x1682,
299            NV_GPU_VENDOR_CLUB3D / Club3D = 0x196d,
300            NV_GPU_VENDOR_PNY / PNY = 0x196e,
301            NV_GPU_VENDOR_ZOTAC / Zotac = 0x19da,
302            NV_GPU_VENDOR_BFG / BFG = 0x19f1,
303            NV_GPU_VENDOR_POV / PoV = 0x1acc,
304            NV_GPU_VENDOR_GALAX / Galax = 0x1b4c, // KFA2 in EU
305            NV_GPU_VENDOR_EVGA / EVGA = 0x3842,
306            NV_GPU_VENDOR_COLORFUL / Colorful = 0x7377,
307        }
308    }
309
310    nvenum_display! {
311        VendorId => {
312            ASUS = "ASUSTeK Computer Inc.",
313            Gigabyte = "Gigabyte Technology",
314            MSI = "Micro-Star International",
315            PNY_ = "PNY",
316            Galax = "Galax / KFA2",
317            _ = _,
318        }
319    }
320
321    nvapi! {
322        pub unsafe fn NvAPI_GetGPUIDFromPhysicalGPU(hPhysicalGpu: NvPhysicalGpuHandle, gpuid: *mut u32) -> NvAPI_Status;
323    }
324
325    nvapi! {
326        pub unsafe fn NvAPI_GPU_GetShortName(hPhysicalGpu: NvPhysicalGpuHandle, pName: *mut types::NvAPI_ShortString) -> NvAPI_Status;
327    }
328
329    nvapi! {
330        pub unsafe fn NvAPI_GPU_GetPartitionCount(hPhysicalGpu: NvPhysicalGpuHandle, pPartitionCount: *mut u32) -> NvAPI_Status;
331    }
332
333    nvapi! {
334        pub unsafe fn NvAPI_GetDriverModel(hPhysicalGpu: NvPhysicalGpuHandle, pDriverModel: *mut u32) -> NvAPI_Status;
335    }
336}