From e2c3575ecc8c69e5d3e7f82b35d64f361477547b Mon Sep 17 00:00:00 2001 From: jsteube Date: Sat, 1 Oct 2016 13:33:39 +0200 Subject: [PATCH] Use NvAPI_Status for RC with NvAPI instead of pure int --- include/ext_nvapi.h | 15 ++++++++------- src/ext_nvapi.c | 40 ++++++++++++++++++++-------------------- 2 files changed, 28 insertions(+), 27 deletions(-) diff --git a/include/ext_nvapi.h b/include/ext_nvapi.h index e4f0fb449..3a5c68162 100644 --- a/include/ext_nvapi.h +++ b/include/ext_nvapi.h @@ -259,13 +259,14 @@ int nvapi_init (NVAPI_PTR *nvapi); void nvapi_close (NVAPI_PTR *nvapi); int hm_NvAPI_QueryInterface (NVAPI_PTR *nvapi, unsigned int offset); -int hm_NvAPI_Initialize (NVAPI_PTR *nvapi); -int hm_NvAPI_Unload (NVAPI_PTR *nvapi); int hm_NvAPI_GetErrorMessage (NVAPI_PTR *nvapi, NvAPI_Status nr, NvAPI_ShortString szDesc); -int hm_NvAPI_EnumPhysicalGPUs (NVAPI_PTR *nvapi, NvPhysicalGpuHandle nvGPUHandle[NVAPI_MAX_PHYSICAL_GPUS], NvU32 *pGpuCount); -int hm_NvAPI_GPU_GetPerfPoliciesInfo (NVAPI_PTR *nvapi, NvPhysicalGpuHandle hPhysicalGpu, NV_GPU_PERF_POLICIES_INFO_PARAMS_V1 *perfPolicies_info); -int hm_NvAPI_GPU_GetPerfPoliciesStatus (NVAPI_PTR *nvapi, NvPhysicalGpuHandle hPhysicalGpu, NV_GPU_PERF_POLICIES_STATUS_PARAMS_V1 *perfPolicies_status); -int hm_NvAPI_GPU_SetCoolerLevels (NVAPI_PTR *nvapi, NvPhysicalGpuHandle hPhysicalGpu, NvU32 coolerIndex, NV_GPU_COOLER_LEVELS *pCoolerLevels); -int hm_NvAPI_GPU_RestoreCoolerSettings (NVAPI_PTR *nvapi, NvPhysicalGpuHandle hPhysicalGpu, NvU32 coolerIndex); + +NvAPI_Status hm_NvAPI_Initialize (NVAPI_PTR *nvapi); +NvAPI_Status hm_NvAPI_Unload (NVAPI_PTR *nvapi); +NvAPI_Status hm_NvAPI_EnumPhysicalGPUs (NVAPI_PTR *nvapi, NvPhysicalGpuHandle nvGPUHandle[NVAPI_MAX_PHYSICAL_GPUS], NvU32 *pGpuCount); +NvAPI_Status hm_NvAPI_GPU_GetPerfPoliciesInfo (NVAPI_PTR *nvapi, NvPhysicalGpuHandle hPhysicalGpu, NV_GPU_PERF_POLICIES_INFO_PARAMS_V1 *perfPolicies_info); +NvAPI_Status hm_NvAPI_GPU_GetPerfPoliciesStatus (NVAPI_PTR *nvapi, NvPhysicalGpuHandle hPhysicalGpu, NV_GPU_PERF_POLICIES_STATUS_PARAMS_V1 *perfPolicies_status); +NvAPI_Status hm_NvAPI_GPU_SetCoolerLevels (NVAPI_PTR *nvapi, NvPhysicalGpuHandle hPhysicalGpu, NvU32 coolerIndex, NV_GPU_COOLER_LEVELS *pCoolerLevels); +NvAPI_Status hm_NvAPI_GPU_RestoreCoolerSettings (NVAPI_PTR *nvapi, NvPhysicalGpuHandle hPhysicalGpu, NvU32 coolerIndex); #endif // _EXT_NVAPI_H diff --git a/src/ext_nvapi.c b/src/ext_nvapi.c index 0b96a7f22..b50f08ec4 100644 --- a/src/ext_nvapi.c +++ b/src/ext_nvapi.c @@ -57,10 +57,17 @@ void nvapi_close (NVAPI_PTR *nvapi) } } -int hm_NvAPI_Initialize (NVAPI_PTR *nvapi) +int hm_NvAPI_GetErrorMessage (NVAPI_PTR *nvapi, NvAPI_Status NvAPI_rc, NvAPI_ShortString string) { if (!nvapi) return -1; + return nvapi->NvAPI_GetErrorMessage (NvAPI_rc, string); +} + +NvAPI_Status hm_NvAPI_Initialize (NVAPI_PTR *nvapi) +{ + if (!nvapi) return (NvAPI_Status) -1; + NvAPI_Status NvAPI_rc = nvapi->NvAPI_Initialize (); if (NvAPI_rc == NVAPI_LIBRARY_NOT_FOUND) NvAPI_rc = NVAPI_OK; // not a bug @@ -77,9 +84,9 @@ int hm_NvAPI_Initialize (NVAPI_PTR *nvapi) return NvAPI_rc; } -int hm_NvAPI_Unload (NVAPI_PTR *nvapi) +NvAPI_Status hm_NvAPI_Unload (NVAPI_PTR *nvapi) { - if (!nvapi) return -1; + if (!nvapi) return (NvAPI_Status) -1; NvAPI_Status NvAPI_rc = nvapi->NvAPI_Unload (); @@ -95,16 +102,9 @@ int hm_NvAPI_Unload (NVAPI_PTR *nvapi) return NvAPI_rc; } -int hm_NvAPI_GetErrorMessage (NVAPI_PTR *nvapi, NvAPI_Status NvAPI_rc, NvAPI_ShortString string) +NvAPI_Status hm_NvAPI_EnumPhysicalGPUs (NVAPI_PTR *nvapi, NvPhysicalGpuHandle nvGPUHandle[NVAPI_MAX_PHYSICAL_GPUS], NvU32 *pGpuCount) { - if (!nvapi) return -1; - - return nvapi->NvAPI_GetErrorMessage (NvAPI_rc, string); -} - -int hm_NvAPI_EnumPhysicalGPUs (NVAPI_PTR *nvapi, NvPhysicalGpuHandle nvGPUHandle[NVAPI_MAX_PHYSICAL_GPUS], NvU32 *pGpuCount) -{ - if (!nvapi) return -1; + if (!nvapi) return (NvAPI_Status) -1; NvAPI_Status NvAPI_rc = nvapi->NvAPI_EnumPhysicalGPUs (nvGPUHandle, pGpuCount); @@ -120,9 +120,9 @@ int hm_NvAPI_EnumPhysicalGPUs (NVAPI_PTR *nvapi, NvPhysicalGpuHandle nvGPUHandle return NvAPI_rc; } -int hm_NvAPI_GPU_GetPerfPoliciesInfo (NVAPI_PTR *nvapi, NvPhysicalGpuHandle hPhysicalGpu, NV_GPU_PERF_POLICIES_INFO_PARAMS_V1 *perfPolicies_info) +NvAPI_Status hm_NvAPI_GPU_GetPerfPoliciesInfo (NVAPI_PTR *nvapi, NvPhysicalGpuHandle hPhysicalGpu, NV_GPU_PERF_POLICIES_INFO_PARAMS_V1 *perfPolicies_info) { - if (!nvapi) return -1; + if (!nvapi) return (NvAPI_Status) -1; NvAPI_Status NvAPI_rc = nvapi->NvAPI_GPU_GetPerfPoliciesInfo (hPhysicalGpu, perfPolicies_info); @@ -138,9 +138,9 @@ int hm_NvAPI_GPU_GetPerfPoliciesInfo (NVAPI_PTR *nvapi, NvPhysicalGpuHandle hPhy return NvAPI_rc; } -int hm_NvAPI_GPU_GetPerfPoliciesStatus (NVAPI_PTR *nvapi, NvPhysicalGpuHandle hPhysicalGpu, NV_GPU_PERF_POLICIES_STATUS_PARAMS_V1 *perfPolicies_status) +NvAPI_Status hm_NvAPI_GPU_GetPerfPoliciesStatus (NVAPI_PTR *nvapi, NvPhysicalGpuHandle hPhysicalGpu, NV_GPU_PERF_POLICIES_STATUS_PARAMS_V1 *perfPolicies_status) { - if (!nvapi) return -1; + if (!nvapi) return (NvAPI_Status) -1; NvAPI_Status NvAPI_rc = nvapi->NvAPI_GPU_GetPerfPoliciesStatus (hPhysicalGpu, perfPolicies_status); @@ -156,9 +156,9 @@ int hm_NvAPI_GPU_GetPerfPoliciesStatus (NVAPI_PTR *nvapi, NvPhysicalGpuHandle hP return NvAPI_rc; } -int hm_NvAPI_GPU_SetCoolerLevels (NVAPI_PTR *nvapi, NvPhysicalGpuHandle hPhysicalGpu, NvU32 coolerIndex, NV_GPU_COOLER_LEVELS *pCoolerLevels) +NvAPI_Status hm_NvAPI_GPU_SetCoolerLevels (NVAPI_PTR *nvapi, NvPhysicalGpuHandle hPhysicalGpu, NvU32 coolerIndex, NV_GPU_COOLER_LEVELS *pCoolerLevels) { - if (!nvapi) return -1; + if (!nvapi) return (NvAPI_Status) -1; NvAPI_Status NvAPI_rc = nvapi->NvAPI_GPU_SetCoolerLevels (hPhysicalGpu, coolerIndex, pCoolerLevels); @@ -174,9 +174,9 @@ int hm_NvAPI_GPU_SetCoolerLevels (NVAPI_PTR *nvapi, NvPhysicalGpuHandle hPhysica return NvAPI_rc; } -int hm_NvAPI_GPU_RestoreCoolerSettings (NVAPI_PTR *nvapi, NvPhysicalGpuHandle hPhysicalGpu, NvU32 coolerIndex) +NvAPI_Status hm_NvAPI_GPU_RestoreCoolerSettings (NVAPI_PTR *nvapi, NvPhysicalGpuHandle hPhysicalGpu, NvU32 coolerIndex) { - if (!nvapi) return -1; + if (!nvapi) return (NvAPI_Status) -1; NvAPI_Status NvAPI_rc = nvapi->NvAPI_GPU_RestoreCoolerSettings (hPhysicalGpu, coolerIndex);