117 lines
4.2 KiB
C++
117 lines
4.2 KiB
C++
/*
|
|||
|
|
* Copyright (C) 2025 Amlogic Corporation.
|
||
|
|
*
|
||
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||
|
|
* you may not use this file except in compliance with the License.
|
||
|
|
* You may obtain a copy of the License at
|
||
|
|
*
|
||
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||
|
|
*
|
||
|
|
* Unless required by applicable law or agreed to in writing, software
|
||
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||
|
|
* See the License for the specific language governing permissions and
|
||
|
|
* limitations under the License.
|
||
|
|
*/
|
||
|
|
#include <errno.h>
|
||
|
|
#include <dlfcn.h>
|
||
|
|
#include <stdlib.h>
|
||
|
|
#include "displayAdapter_lib_wrap.h"
|
||
|
|
#include "Logger.h"
|
||
|
|
#include "ErrorCode.h"
|
||
|
|
|
||
|
|
#define TAG "rlib:displayadapter_lib_wrap"
|
||
|
|
|
||
|
|
#define DISPLAYADAPTER_LIB_NAME "libdisplayadapter.so"
|
||
|
|
|
||
|
|
displayAdapterLib * displayAdapterLoadLib(int logCategory)
|
||
|
|
{
|
||
|
|
INFO(logCategory, "load displayAdapter so symbol");
|
||
|
|
|
||
|
|
displayAdapterLib *handle = (displayAdapterLib*)calloc( 1, sizeof(displayAdapterLib));
|
||
|
|
if (!handle) {
|
||
|
|
ERROR(logCategory, "calloc displayAdapter struct fail");
|
||
|
|
goto err_label;
|
||
|
|
}
|
||
|
|
handle->libHandle = dlopen(DISPLAYADAPTER_LIB_NAME, RTLD_NOW);
|
||
|
|
if (handle->libHandle == NULL) {
|
||
|
|
ERROR(logCategory, "unable to dlopen %s : %s",DISPLAYADAPTER_LIB_NAME, dlerror());
|
||
|
|
goto err_label;
|
||
|
|
}
|
||
|
|
|
||
|
|
handle->dACreateLayer = (dA_createLayer)dlsym(handle->libHandle, "dispAdptCreateLayer");
|
||
|
|
if (handle->dACreateLayer == NULL) {
|
||
|
|
ERROR(logCategory,"dlsym dispAdptCreateLayer failed, err=%s \n", dlerror());
|
||
|
|
goto err_label;
|
||
|
|
}
|
||
|
|
|
||
|
|
handle->dADestroyLayer = (dA_destroyLayer)dlsym(handle->libHandle, "dispAdptDestroyLayer");
|
||
|
|
if (handle->dADestroyLayer == NULL) {
|
||
|
|
ERROR(logCategory,"dlsym dispAdptDestroyLayer failed, err=%s \n", dlerror());
|
||
|
|
goto err_label;
|
||
|
|
}
|
||
|
|
|
||
|
|
handle->dASetTunnelId = (dA_setTunnelId)dlsym(handle->libHandle, "dispAdptSetTunnelId");
|
||
|
|
if (handle->dASetTunnelId == NULL) {
|
||
|
|
ERROR(logCategory, "dlsym dispAdptSetTunnelId failed, err=%s \n", dlerror());
|
||
|
|
goto err_label;
|
||
|
|
}
|
||
|
|
|
||
|
|
handle->dASetLayerZorder = (dA_setLayerZorder)dlsym(handle->libHandle, "dispAdptSetLayerZorder");
|
||
|
|
if (handle->dASetLayerZorder == NULL) {
|
||
|
|
ERROR(logCategory,"dlsym dispAdptSetLayerZorder failed, err=%s \n", dlerror());
|
||
|
|
goto err_label;
|
||
|
|
}
|
||
|
|
|
||
|
|
handle->dASetLayerSourceCrop = (dA_setLayerSourceCrop)dlsym(handle->libHandle, "dispAdptSetLayerSourceCrop");
|
||
|
|
if (handle->dASetLayerSourceCrop == NULL) {
|
||
|
|
ERROR(logCategory,"dlsym dispAdptSetLayerSourceCrop failed, err=%s \n", dlerror());
|
||
|
|
goto err_label;
|
||
|
|
}
|
||
|
|
|
||
|
|
handle->dASetLayerDispFrame = (dA_setLayerDispFrame)dlsym(handle->libHandle, "dispAdptSetLayerDispFrame");
|
||
|
|
if (handle->dASetLayerDispFrame == NULL) {
|
||
|
|
ERROR(logCategory,"dlsym dispAdptSetLayerDispFrame failed, err=%s \n", dlerror());
|
||
|
|
goto err_label;
|
||
|
|
}
|
||
|
|
|
||
|
|
handle->dAGetVsyncDelayLatency = (dA_getVsyncDelayLatency)dlsym(handle->libHandle, "dispAdptGetVsyncDelayLatency");
|
||
|
|
if (handle->dAGetVsyncDelayLatency == NULL) {
|
||
|
|
ERROR(logCategory,"dlsym dispAdptGetVsyncDelayLatency failed, err=%s \n", dlerror());
|
||
|
|
goto err_label;
|
||
|
|
}
|
||
|
|
|
||
|
|
handle->dASetVideoDisplaytoMainplane = (dA_setVideoDisplaytoMainplane)dlsym(handle->libHandle, "dispAdptSetVideoDisplaytoMainplane");
|
||
|
|
if (handle->dASetVideoDisplaytoMainplane == NULL) {
|
||
|
|
ERROR(logCategory,"dlsym dispAdptSetVideoDisplaytoMainplane failed, err=%s \n", dlerror());
|
||
|
|
goto err_label;
|
||
|
|
}
|
||
|
|
|
||
|
|
handle->dADispAdptGetUiSize = (dA_dispAdptGetUiSize)dlsym(handle->libHandle, "dispAdptGetUiSize");
|
||
|
|
if (handle->dADispAdptGetUiSize == NULL) {
|
||
|
|
ERROR(logCategory,"dlsym dispAdptGetUiSize failed, err=%s \n", dlerror());
|
||
|
|
goto err_label;
|
||
|
|
}
|
||
|
|
|
||
|
|
return handle;
|
||
|
|
err_label:
|
||
|
|
if (handle) {
|
||
|
|
if (handle->libHandle) {
|
||
|
|
dlclose(handle->libHandle);
|
||
|
|
}
|
||
|
|
free(handle);
|
||
|
|
}
|
||
|
|
return NULL;
|
||
|
|
}
|
||
|
|
int displayAdapterUnloadLib(int logCategory,displayAdapterLib *dA)
|
||
|
|
{
|
||
|
|
INFO(logCategory, "unload displayAdapter so symbol");
|
||
|
|
if (dA) {
|
||
|
|
if (dA->libHandle) {
|
||
|
|
dlclose(dA->libHandle);
|
||
|
|
}
|
||
|
|
free(dA);
|
||
|
|
}
|
||
|
|
return NO_ERROR;
|
||
|
|
}
|