/* * Copyright (C) 2017-2019 Intel Corporation * * SPDX-License-Identifier: MIT * */ #include "va_sharing_functions.h" #include "runtime/os_interface/debug_settings_manager.h" #include namespace Os { extern const char *libvaDllName; } namespace NEO { std::function VASharingFunctions::fdlopen = dlopen; std::function VASharingFunctions::fdlsym = dlsym; std::function VASharingFunctions::fdlclose = dlclose; VASharingFunctions::VASharingFunctions(VADisplay vaDisplay) : vaDisplay(vaDisplay) { initFunctions(); }; VASharingFunctions::~VASharingFunctions() { if (libHandle != nullptr) { fdlclose(libHandle); libHandle = nullptr; } } bool VASharingFunctions::isVaLibraryAvailable() { auto lib = fdlopen(Os::libvaDllName, RTLD_LAZY); if (lib) { fdlclose(lib); return true; } return false; } void VASharingFunctions::initFunctions() { if (DebugManager.flags.EnableVaLibCalls.get()) { libHandle = fdlopen(Os::libvaDllName, RTLD_LAZY); if (libHandle) { vaDisplayIsValidPFN = reinterpret_cast(fdlsym(libHandle, "vaDisplayIsValid")); vaDeriveImagePFN = reinterpret_cast(fdlsym(libHandle, "vaDeriveImage")); vaDestroyImagePFN = reinterpret_cast(fdlsym(libHandle, "vaDestroyImage")); vaSyncSurfacePFN = reinterpret_cast(fdlsym(libHandle, "vaSyncSurface")); vaGetLibFuncPFN = reinterpret_cast(fdlsym(libHandle, "vaGetLibFunc")); vaExtGetSurfaceHandlePFN = reinterpret_cast(getLibFunc("DdiMedia_ExtGetSurfaceHandle")); } else { vaDisplayIsValidPFN = nullptr; vaDeriveImagePFN = nullptr; vaDestroyImagePFN = nullptr; vaSyncSurfacePFN = nullptr; vaGetLibFuncPFN = nullptr; vaExtGetSurfaceHandlePFN = nullptr; } } } } // namespace NEO