Пример #1
0
void clear_adl(nDevs)
{
	struct gpu_adl *ga;
	int i;

	if (!adl_active)
		return;

	lock_adl();
	/* Try to reset values to their defaults */
	for (i = 0; i < nDevs; i++) {
		ga = &gpus[i].adl;
		/*  Only reset the values if we've changed them at any time */
		if (!gpus[i].has_adl || !ga->managed)
			continue;
		ADL_Overdrive5_ODPerformanceLevels_Set(ga->iAdapterIndex, ga->DefPerfLev);
		free(ga->DefPerfLev);
		ADL_Overdrive5_FanSpeed_Set(ga->iAdapterIndex, 0, &ga->DefFanSpeedValue);
		ADL_Overdrive5_FanSpeedToDefault_Set(ga->iAdapterIndex, 0);
	}

	ADL_Main_Memory_Free ( (void **)&lpInfo );
	ADL_Main_Control_Destroy ();
	unlock_adl();

#if defined (LINUX)
	dlclose(hDLL);
#else
	FreeLibrary(hDLL);
#endif
}
Пример #2
0
void StADLsdk::close() {
    if(myFunctions.ADL_Main_Control_Destroy != NULL) {
        myFunctions.ADL_Main_Control_Destroy();
    }
    ADL_Main_Memory_Free(myAdaptersInfoList);
    myAdaptersInfoList = NULL;
    myLib.close();
    myNumAdapters = 0;
    stMemSet(&myFunctions, 0, sizeof(ADLsdkFunctions));
}
Пример #3
0
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;
}