PStateAMD::~PStateAMD(void) { //ADL_Main_Memory_Free ( (void**)&lpAdapterInfo ); //ADL_Main_Memory_Free ( (void**)&lpAdlDisplayInfo ); ADL_Main_Control_Destroy(); FreeLibrary(m_hDLL); }
static int x264_detect_switchable_graphics( void ) { void *hDLL; ADL_MAIN_CONTROL_CREATE ADL_Main_Control_Create; ADL_ADAPTER_NUMBEROFADAPTERS_GET ADL_Adapter_NumberOfAdapters_Get; ADL_POWERXPRESS_SCHEME_GET ADL_PowerXpress_Scheme_Get; ADL_MAIN_CONTROL_DESTROY ADL_Main_Control_Destroy; int ret = 0; int numAdapters; int i; #ifdef _WIN32 hDLL = LoadLibraryW( L"atiadlxx.dll" ); if( !hDLL ) hDLL = LoadLibraryW( L"atiadlxy.dll" ); #else hDLL = dlopen( "libatiadlxx.so", RTLD_LAZY|RTLD_GLOBAL ); #endif if( !hDLL ) goto fail0; ADL_Main_Control_Create = (ADL_MAIN_CONTROL_CREATE)adl_address(hDLL, "ADL_Main_Control_Create"); ADL_Main_Control_Destroy = (ADL_MAIN_CONTROL_DESTROY)adl_address(hDLL, "ADL_Main_Control_Destroy"); ADL_Adapter_NumberOfAdapters_Get = (ADL_ADAPTER_NUMBEROFADAPTERS_GET)adl_address(hDLL, "ADL_Adapter_NumberOfAdapters_Get"); ADL_PowerXpress_Scheme_Get = (ADL_POWERXPRESS_SCHEME_GET)adl_address(hDLL, "ADL_PowerXpress_Scheme_Get"); if( !ADL_Main_Control_Create || !ADL_Main_Control_Destroy || !ADL_Adapter_NumberOfAdapters_Get || !ADL_PowerXpress_Scheme_Get ) goto fail1; if( ADL_OK != ADL_Main_Control_Create( adl_malloc_wrapper, 1 ) ) goto fail1; if( ADL_OK != ADL_Adapter_NumberOfAdapters_Get( &numAdapters ) ) goto fail2; for( i = 0; i < numAdapters; i++ ) { int PXSchemeRange, PXSchemeCurrentState, PXSchemeDefaultState; if( ADL_OK != ADL_PowerXpress_Scheme_Get( i, &PXSchemeRange, &PXSchemeCurrentState, &PXSchemeDefaultState) ) break; if( PXSchemeRange >= ADL_PX_SCHEME_DYNAMIC ) { ret = 1; break; } } fail2: ADL_Main_Control_Destroy(); fail1: adl_close( hDLL ); fail0: return ret; }
int hc_ADL_Main_Control_Destroy (HM_LIB hDLL) { ADL_MAIN_CONTROL_DESTROY ADL_Main_Control_Destroy = (ADL_MAIN_CONTROL_DESTROY) GetProcAddress (hDLL, "ADL_Main_Control_Destroy"); if (ADL_Main_Control_Destroy == NULL) { log_error ("ERROR: %s\n", "ADL_Main_Control_Destroy() is missing"); exit (-1); } int ADL_rc = ADL_Main_Control_Destroy (); if (ADL_rc != ADL_OK) { log_info ("WARN: %s: %d\n", "ADL_Main_Control_Destroy()", ADL_rc); } return (ADL_rc); }
Bool VA_FGLRXGetClientDriverName( Display *dpy, int screen, int *ddxDriverMajorVersion, int *ddxDriverMinorVersion, int *ddxDriverPatchVersion, char **clientDriverName ) { ADL_MAIN_CONTROL_CREATE ADL_Main_Control_Create; ADL_MAIN_CONTROL_DESTROY ADL_Main_Control_Destroy; ADL_ADAPTER_NUMBEROFADAPTERS_GET ADL_Adapter_NumberOfAdapters_Get; ADL_ADAPTER_ADAPTERINFO_GET ADL_Adapter_AdapterInfo_Get; ADL_ADAPTER_XSCREENINFO_GET ADL_Adapter_XScreenInfo_Get; LPAdapterInfo lpAdapterInfo = NULL; LPXScreenInfo lpXScreenInfo = NULL; void *libadl_handle = NULL; Bool success = False; int is_adl_initialized = 0; int i, num_adapters, lpAdapterInfo_size, lpXScreenInfo_size; if (ddxDriverMajorVersion) *ddxDriverMajorVersion = 0; if (ddxDriverMinorVersion) *ddxDriverMinorVersion = 0; if (ddxDriverPatchVersion) *ddxDriverPatchVersion = 0; if (clientDriverName) *clientDriverName = NULL; libadl_handle = dlopen("libatiadlxx.so", RTLD_LAZY|RTLD_GLOBAL); if (!libadl_handle) goto end; dlerror(); ADL_Main_Control_Create = (ADL_MAIN_CONTROL_CREATE) dlsym(libadl_handle,"ADL_Main_Control_Create"); if (dlerror()) goto end; ADL_Main_Control_Destroy = (ADL_MAIN_CONTROL_DESTROY) dlsym(libadl_handle,"ADL_Main_Control_Destroy"); if (dlerror()) goto end; ADL_Adapter_NumberOfAdapters_Get = (ADL_ADAPTER_NUMBEROFADAPTERS_GET) dlsym(libadl_handle,"ADL_Adapter_NumberOfAdapters_Get"); if (dlerror()) goto end; ADL_Adapter_AdapterInfo_Get = (ADL_ADAPTER_ADAPTERINFO_GET) dlsym(libadl_handle,"ADL_Adapter_AdapterInfo_Get"); if (dlerror()) goto end; ADL_Adapter_XScreenInfo_Get = (ADL_ADAPTER_XSCREENINFO_GET) dlsym(libadl_handle,"ADL_Adapter_XScreenInfo_Get"); if (dlerror()) goto end; if (ADL_Main_Control_Create(ADL_Main_Memory_Alloc, 1) != ADL_OK) goto end; is_adl_initialized = 1; if (ADL_Adapter_NumberOfAdapters_Get(&num_adapters) != ADL_OK) goto end; if (num_adapters <= 0) goto end; lpAdapterInfo_size = num_adapters * sizeof(*lpAdapterInfo); lpAdapterInfo = ADL_Main_Memory_Alloc(lpAdapterInfo_size); if (!lpAdapterInfo) goto end; memset(lpAdapterInfo, 0, lpAdapterInfo_size); for (i = 0; i < num_adapters; i++) lpAdapterInfo[i].iSize = sizeof(lpAdapterInfo[i]); lpXScreenInfo_size = num_adapters * sizeof(*lpXScreenInfo); lpXScreenInfo = ADL_Main_Memory_Alloc(lpXScreenInfo_size); if (!lpXScreenInfo) goto end; memset(lpXScreenInfo, 0, lpXScreenInfo_size); if (ADL_Adapter_AdapterInfo_Get(lpAdapterInfo, lpAdapterInfo_size) != ADL_OK) goto end; if (ADL_Adapter_XScreenInfo_Get(lpXScreenInfo, lpXScreenInfo_size) != ADL_OK) goto end; for (i = 0; i < num_adapters; i++) { LPXScreenInfo const lpCurrXScreenInfo = &lpXScreenInfo[i]; LPAdapterInfo const lpCurrAdapterInfo = &lpAdapterInfo[i]; if (!lpCurrAdapterInfo->iPresent) continue; #if 0 printf("Adapter %d:\n", i); printf(" iAdapterIndex: %d\n", lpCurrAdapterInfo->iAdapterIndex); printf(" strUDID: '%s'\n", lpCurrAdapterInfo->strUDID); printf(" iBusNumber: %d\n", lpCurrAdapterInfo->iBusNumber); printf(" iDeviceNumber: %d\n", lpCurrAdapterInfo->iDeviceNumber); printf(" iFunctionNumber: %d\n", lpCurrAdapterInfo->iFunctionNumber); printf(" iVendorID: 0x%04x\n", lpCurrAdapterInfo->iVendorID); printf(" strAdapterName: '%s'\n", lpCurrAdapterInfo->strAdapterName); printf(" strDisplayName: '%s'\n", lpCurrAdapterInfo->strDisplayName); printf(" iPresent: %d\n", lpCurrAdapterInfo->iPresent); printf(" iXScreenNum: %d\n", lpCurrXScreenInfo->iXScreenNum); #endif if (screen == lpCurrXScreenInfo->iXScreenNum && match_display_name(dpy, lpCurrAdapterInfo->strDisplayName)) { if (clientDriverName) *clientDriverName = strdup("fglrx"); success = True; break; } } end: if (lpXScreenInfo) ADL_Main_Memory_Free(&lpXScreenInfo); if (lpAdapterInfo) ADL_Main_Memory_Free(&lpAdapterInfo); if (is_adl_initialized) ADL_Main_Control_Destroy(); if (libadl_handle) dlclose(libadl_handle); return success; }