2017-12-21 00:45:38 +01:00
|
|
|
/*
|
2019-02-27 11:39:32 +01:00
|
|
|
* Copyright (C) 2017-2019 Intel Corporation
|
2017-12-21 00:45:38 +01:00
|
|
|
*
|
2018-09-18 09:11:08 +02:00
|
|
|
* SPDX-License-Identifier: MIT
|
2017-12-21 00:45:38 +01:00
|
|
|
*
|
|
|
|
|
*/
|
2018-09-18 09:11:08 +02:00
|
|
|
|
2017-12-21 00:45:38 +01:00
|
|
|
#include "va_sharing_functions.h"
|
2019-02-27 11:39:32 +01:00
|
|
|
|
|
|
|
|
#include "runtime/os_interface/debug_settings_manager.h"
|
|
|
|
|
|
2017-12-21 00:45:38 +01:00
|
|
|
#include <dlfcn.h>
|
|
|
|
|
|
|
|
|
|
namespace Os {
|
|
|
|
|
extern const char *libvaDllName;
|
|
|
|
|
}
|
|
|
|
|
|
2019-03-26 11:59:46 +01:00
|
|
|
namespace NEO {
|
2017-12-21 00:45:38 +01:00
|
|
|
std::function<void *(const char *, int)> VASharingFunctions::fdlopen = dlopen;
|
|
|
|
|
std::function<void *(void *handle, const char *symbol)> VASharingFunctions::fdlsym = dlsym;
|
|
|
|
|
std::function<int(void *handle)> 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) {
|
2018-05-17 23:57:53 +02:00
|
|
|
vaDisplayIsValidPFN = reinterpret_cast<VADisplayIsValidPFN>(fdlsym(libHandle, "vaDisplayIsValid"));
|
|
|
|
|
vaDeriveImagePFN = reinterpret_cast<VADeriveImagePFN>(fdlsym(libHandle, "vaDeriveImage"));
|
|
|
|
|
vaDestroyImagePFN = reinterpret_cast<VADestroyImagePFN>(fdlsym(libHandle, "vaDestroyImage"));
|
|
|
|
|
vaSyncSurfacePFN = reinterpret_cast<VASyncSurfacePFN>(fdlsym(libHandle, "vaSyncSurface"));
|
|
|
|
|
vaGetLibFuncPFN = reinterpret_cast<VAGetLibFuncPFN>(fdlsym(libHandle, "vaGetLibFunc"));
|
|
|
|
|
vaExtGetSurfaceHandlePFN = reinterpret_cast<VAExtGetSurfaceHandlePFN>(getLibFunc("DdiMedia_ExtGetSurfaceHandle"));
|
2017-12-21 00:45:38 +01:00
|
|
|
} else {
|
|
|
|
|
vaDisplayIsValidPFN = nullptr;
|
|
|
|
|
vaDeriveImagePFN = nullptr;
|
|
|
|
|
vaDestroyImagePFN = nullptr;
|
|
|
|
|
vaSyncSurfacePFN = nullptr;
|
|
|
|
|
vaGetLibFuncPFN = nullptr;
|
|
|
|
|
vaExtGetSurfaceHandlePFN = nullptr;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2019-03-26 11:59:46 +01:00
|
|
|
} // namespace NEO
|