Files
2026-08-24 10:03:24 +08:00

74 lines
2.1 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 "meson_display_wrap.h"
#include "Logger.h"
#include "ErrorCode.h"
#define TAG "rlib:meson_display_wrap"
#define MEDSON_DISPLAY_LIB_NAME "libdisplay_settings.so"
mesonDisplayLib * mesonDisplayLoadLib(int logCategory)
{
bool ret = true;
INFO(logCategory, "load meson display so symbol");
mesonDisplayLib *handle = (mesonDisplayLib*)calloc( 1, sizeof(mesonDisplayLib));
if (!handle) {
ERROR(logCategory, "calloc resman struct fail");
return NULL;
}
handle->libHandle = dlopen(MEDSON_DISPLAY_LIB_NAME, RTLD_NOW);
if (handle->libHandle == NULL) {
ERROR(logCategory, "unable to dlopen %s : %s",MEDSON_DISPLAY_LIB_NAME, dlerror());
free(handle);
return NULL;
}
handle->getDisplayMode = (_getDisplayMode)dlsym(handle->libHandle, "getDisplayMode");
if (handle->getDisplayMode == NULL) {
ERROR(logCategory,"dlsym getDisplayMode failed, err=%s \n", dlerror());
ret = false;
}
if (ret)
return handle;
// something error
if (handle) {
if (handle->libHandle) {
dlclose(handle->libHandle);
}
free(handle);
}
ERROR(logCategory,"meson display load fail !!! \n");
return NULL;
}
int mesonDisplayUnLoadLib(int logCategory, mesonDisplayLib *handle)
{
if (handle) {
if (handle->libHandle) {
dlclose(handle->libHandle);
}
free(handle);
}
INFO(logCategory, "unload meson display so symbol");
return NO_ERROR;
}