Browse Source

adl: code cleanup after last commit.

nfactor-troky
Noel Maersk 11 years ago
parent
commit
6089dfbbac
  1. 92
      adl.c

92
adl.c

@ -39,7 +39,6 @@ @@ -39,7 +39,6 @@
bool adl_active;
bool opt_reorder = false;
bool adl6 = false;
int opt_hysteresis = 3;
const int opt_targettemp = 75;
@ -64,7 +63,7 @@ static void * __stdcall ADL_Main_Memory_Alloc(int iSize) @@ -64,7 +63,7 @@ static void * __stdcall ADL_Main_Memory_Alloc(int iSize)
// Optional Memory de-allocation function
static void __stdcall ADL_Main_Memory_Free (void **lpBuffer)
{
if (NULL != *lpBuffer) {
if (*lpBuffer != NULL) {
free (*lpBuffer);
*lpBuffer = NULL;
}
@ -78,42 +77,42 @@ static void *GetProcAddress(void *pLibrary, const char *name) @@ -78,42 +77,42 @@ static void *GetProcAddress(void *pLibrary, const char *name)
}
#endif
static ADL_MAIN_CONTROL_CREATE ADL_Main_Control_Create;
static ADL_MAIN_CONTROL_DESTROY ADL_Main_Control_Destroy;
static ADL_MAIN_CONTROL_CREATE ADL_Main_Control_Create;
static ADL_MAIN_CONTROL_DESTROY ADL_Main_Control_Destroy;
static ADL_ADAPTER_NUMBEROFADAPTERS_GET ADL_Adapter_NumberOfAdapters_Get;
static ADL_ADAPTER_ADAPTERINFO_GET ADL_Adapter_AdapterInfo_Get;
static ADL_ADAPTER_ID_GET ADL_Adapter_ID_Get;
static ADL_MAIN_CONTROL_REFRESH ADL_Main_Control_Refresh;
static ADL_ADAPTER_ADAPTERINFO_GET ADL_Adapter_AdapterInfo_Get;
static ADL_ADAPTER_ID_GET ADL_Adapter_ID_Get;
static ADL_MAIN_CONTROL_REFRESH ADL_Main_Control_Refresh;
static ADL_ADAPTER_VIDEOBIOSINFO_GET ADL_Adapter_VideoBiosInfo_Get;
static ADL_DISPLAY_DISPLAYINFO_GET ADL_Display_DisplayInfo_Get;
static ADL_DISPLAY_DISPLAYINFO_GET ADL_Display_DisplayInfo_Get;
static ADL_ADAPTER_ACCESSIBILITY_GET ADL_Adapter_Accessibility_Get;
static ADL_OVERDRIVE_CAPS ADL_Overdrive_Caps;
static ADL_OVERDRIVE_CAPS ADL_Overdrive_Caps;
static ADL_OVERDRIVE5_TEMPERATURE_GET ADL_Overdrive5_Temperature_Get;
static ADL_OVERDRIVE5_TEMPERATURE_GET ADL_Overdrive5_Temperature_Get;
static ADL_OVERDRIVE5_CURRENTACTIVITY_GET ADL_Overdrive5_CurrentActivity_Get;
static ADL_OVERDRIVE5_ODPARAMETERS_GET ADL_Overdrive5_ODParameters_Get;
static ADL_OVERDRIVE5_FANSPEEDINFO_GET ADL_Overdrive5_FanSpeedInfo_Get;
static ADL_OVERDRIVE5_FANSPEED_GET ADL_Overdrive5_FanSpeed_Get;
static ADL_OVERDRIVE5_FANSPEED_SET ADL_Overdrive5_FanSpeed_Set;
static ADL_OVERDRIVE5_ODPARAMETERS_GET ADL_Overdrive5_ODParameters_Get;
static ADL_OVERDRIVE5_FANSPEEDINFO_GET ADL_Overdrive5_FanSpeedInfo_Get;
static ADL_OVERDRIVE5_FANSPEED_GET ADL_Overdrive5_FanSpeed_Get;
static ADL_OVERDRIVE5_FANSPEED_SET ADL_Overdrive5_FanSpeed_Set;
static ADL_OVERDRIVE5_ODPERFORMANCELEVELS_GET ADL_Overdrive5_ODPerformanceLevels_Get;
static ADL_OVERDRIVE5_ODPERFORMANCELEVELS_SET ADL_Overdrive5_ODPerformanceLevels_Set;
static ADL_OVERDRIVE5_POWERCONTROL_GET ADL_Overdrive5_PowerControl_Get;
static ADL_OVERDRIVE5_POWERCONTROL_SET ADL_Overdrive5_PowerControl_Set;
static ADL_OVERDRIVE5_POWERCONTROL_GET ADL_Overdrive5_PowerControl_Get;
static ADL_OVERDRIVE5_POWERCONTROL_SET ADL_Overdrive5_PowerControl_Set;
static ADL_OVERDRIVE5_FANSPEEDTODEFAULT_SET ADL_Overdrive5_FanSpeedToDefault_Set;
static ADL_OVERDRIVE6_CAPABILITIES_GET ADL_Overdrive6_Capabilities_Get;
static ADL_OVERDRIVE6_FANSPEED_GET ADL_Overdrive6_FanSpeed_Get;
static ADL_OVERDRIVE6_THERMALCONTROLLER_CAPS ADL_Overdrive6_ThermalController_Caps;
static ADL_OVERDRIVE6_TEMPERATURE_GET ADL_Overdrive6_Temperature_Get;
static ADL_OVERDRIVE6_STATEINFO_GET ADL_Overdrive6_StateInfo_Get;
static ADL_OVERDRIVE6_CURRENTSTATUS_GET ADL_Overdrive6_CurrentStatus_Get;
static ADL_OVERDRIVE6_POWERCONTROL_CAPS ADL_Overdrive6_PowerControl_Caps;
static ADL_OVERDRIVE6_POWERCONTROLINFO_GET ADL_Overdrive6_PowerControlInfo_Get;
static ADL_OVERDRIVE6_POWERCONTROL_GET ADL_Overdrive6_PowerControl_Get;
static ADL_OVERDRIVE6_FANSPEED_SET ADL_Overdrive6_FanSpeed_Set;
static ADL_OVERDRIVE6_STATE_SET ADL_Overdrive6_State_Set;
static ADL_OVERDRIVE6_POWERCONTROL_SET ADL_Overdrive6_PowerControl_Set;
static ADL_OVERDRIVE6_CAPABILITIES_GET ADL_Overdrive6_Capabilities_Get;
static ADL_OVERDRIVE6_FANSPEED_GET ADL_Overdrive6_FanSpeed_Get;
static ADL_OVERDRIVE6_THERMALCONTROLLER_CAPS ADL_Overdrive6_ThermalController_Caps;
static ADL_OVERDRIVE6_TEMPERATURE_GET ADL_Overdrive6_Temperature_Get;
static ADL_OVERDRIVE6_STATEINFO_GET ADL_Overdrive6_StateInfo_Get;
static ADL_OVERDRIVE6_CURRENTSTATUS_GET ADL_Overdrive6_CurrentStatus_Get;
static ADL_OVERDRIVE6_POWERCONTROL_CAPS ADL_Overdrive6_PowerControl_Caps;
static ADL_OVERDRIVE6_POWERCONTROLINFO_GET ADL_Overdrive6_PowerControlInfo_Get;
static ADL_OVERDRIVE6_POWERCONTROL_GET ADL_Overdrive6_PowerControl_Get;
static ADL_OVERDRIVE6_FANSPEED_SET ADL_Overdrive6_FanSpeed_Set;
static ADL_OVERDRIVE6_STATE_SET ADL_Overdrive6_State_Set;
static ADL_OVERDRIVE6_POWERCONTROL_SET ADL_Overdrive6_PowerControl_Set;
#if defined (LINUX)
static void *hDLL; // Handle to .so library
@ -170,11 +169,9 @@ static bool init_overdrive5() @@ -170,11 +169,9 @@ static bool init_overdrive5()
!ADL_Overdrive5_ODPerformanceLevels_Get || !ADL_Overdrive5_ODPerformanceLevels_Set ||
!ADL_Overdrive5_PowerControl_Get || !ADL_Overdrive5_PowerControl_Set ||
!ADL_Overdrive5_FanSpeedToDefault_Set) {
applog(LOG_WARNING, "ATI ADL Overdrive5's API is missing");
return false;
}
else
{
applog(LOG_WARNING, "ATI ADL Overdrive5's API is missing or broken.");
return false;
} else {
applog(LOG_INFO, "ATI ADL Overdrive5 API found.");
}
@ -202,12 +199,9 @@ static bool init_overdrive6() @@ -202,12 +199,9 @@ static bool init_overdrive6()
!ADL_Overdrive6_PowerControl_Caps || !ADL_Overdrive6_PowerControlInfo_Get ||
!ADL_Overdrive6_PowerControl_Get || !ADL_Overdrive6_FanSpeed_Set ||
!ADL_Overdrive6_State_Set || !ADL_Overdrive6_PowerControl_Set) {
applog(LOG_WARNING, "ATI ADL Overdrive6's API is missing");
applog(LOG_WARNING, "ATI ADL Overdrive6's API is missing or broken.");
return false;
}
else
{
adl6 = true;
} else {
applog(LOG_INFO, "ATI ADL Overdrive6 API found.");
}
@ -228,7 +222,7 @@ static bool prepare_adl(void) @@ -228,7 +222,7 @@ static bool prepare_adl(void)
hDLL = LoadLibrary("atiadlxy.dll");
#endif
if (hDLL == NULL) {
applog(LOG_INFO, "Unable to load ati adl library");
applog(LOG_INFO, "Unable to load ATI ADL library.");
return false;
}
ADL_Main_Control_Create = (ADL_MAIN_CONTROL_CREATE) GetProcAddress(hDLL,"ADL_Main_Control_Create");
@ -248,26 +242,26 @@ static bool prepare_adl(void) @@ -248,26 +242,26 @@ static bool prepare_adl(void)
!ADL_Display_DisplayInfo_Get ||
!ADL_Adapter_ID_Get || !ADL_Main_Control_Refresh ||
!ADL_Adapter_VideoBiosInfo_Get || !ADL_Overdrive_Caps) {
applog(LOG_WARNING, "ATI ADL's API is missing");
applog(LOG_WARNING, "ATI ADL API is missing or broken.");
return false;
}
// Initialise ADL. The second parameter is 1, which means:
// retrieve adapter information only for adapters that are physically present and enabled in the system
result = ADL_Main_Control_Create (ADL_Main_Memory_Alloc, 1);
result = ADL_Main_Control_Create(ADL_Main_Memory_Alloc, 1);
if (result != ADL_OK) {
applog(LOG_INFO, "ADL Initialisation Error! Error %d!", result);
applog(LOG_INFO, "ADL initialisation error: %d!", result);
return false;
}
result = ADL_Main_Control_Refresh();
if (result != ADL_OK) {
applog(LOG_INFO, "ADL Refresh Error! Error %d!", result);
applog(LOG_INFO, "ADL refresh error: %d!", result);
return false;
}
init_overdrive5();
init_overdrive6();
init_overdrive6(); // FIXME: don't if ADL6 is not present
return true;
}
@ -278,9 +272,9 @@ void init_adl(int nDevs) @@ -278,9 +272,9 @@ void init_adl(int nDevs)
struct gpu_adapters adapters[MAX_GPUDEVICES], vadapters[MAX_GPUDEVICES];
bool devs_match = true;
ADLBiosInfo BiosInfo;
int iNumDisplays;
int iNumDisplays;
applog(LOG_INFO, "Number of ADL devices %d", nDevs);
applog(LOG_INFO, "Number of ADL devices: %d", nDevs);
if (unlikely(pthread_mutex_init(&adl_lock, NULL))) {
applog(LOG_ERR, "Failed to init adl_lock in init_adl");
@ -334,7 +328,7 @@ void init_adl(int nDevs) @@ -334,7 +328,7 @@ void init_adl(int nDevs)
if (result != ADL_OK) {
applog(LOG_INFO, "Failed to ADL_Adapter_ID_Get. Error %d", result);
if (result == -10)
applog(LOG_INFO, "This error says the device is not enabled");
applog(LOG_INFO, "(Device is not enabled.)");
continue;
}
@ -345,11 +339,11 @@ void init_adl(int nDevs) @@ -345,11 +339,11 @@ void init_adl(int nDevs)
applog(LOG_INFO, "GPU %d assigned: "
"iAdapterIndex:%d "
"iPresent:%d "
"iPresent:%d "
"strUDID:%s "
"iBusNumber:%d "
"iDeviceNumber:%d "
"iDrvIndex:%d "
"iDrvIndex:%d "
"iFunctionNumber:%d "
"iVendorID:%d "
"name:%s",

Loading…
Cancel
Save