From 1b899b6011c5b2635d359c35dfd3d0d4d5a1189b Mon Sep 17 00:00:00 2001 From: viktorxda <35473052+viktorxda@users.noreply.github.com> Date: Fri, 31 May 2024 09:01:44 +0200 Subject: [PATCH] Add check for hisilicon libraries --- src/hal/hisi/v4_common.h | 3 ++- src/hal/hisi/v4_hal.c | 9 +++++++-- src/hal/hisi/v4_isp.h | 15 +++++++++++++-- 3 files changed, 22 insertions(+), 5 deletions(-) diff --git a/src/hal/hisi/v4_common.h b/src/hal/hisi/v4_common.h index b34785a..2a461a6 100644 --- a/src/hal/hisi/v4_common.h +++ b/src/hal/hisi/v4_common.h @@ -4,6 +4,7 @@ #include #include #include +#include #include #include "../types.h" @@ -164,4 +165,4 @@ typedef struct { int y; unsigned int width; unsigned int height; -} v4_common_rect; \ No newline at end of file +} v4_common_rect; diff --git a/src/hal/hisi/v4_hal.c b/src/hal/hisi/v4_hal.c index 7a2d4df..57d929d 100644 --- a/src/hal/hisi/v4_hal.c +++ b/src/hal/hisi/v4_hal.c @@ -246,6 +246,12 @@ int v4_pipeline_create(void) if (ret = v4_snr_drv.obj->pfnSetBusInfo(_v4_vi_pipe, bus)) return ret; } + + if (!v4_isp.handleGoke) { + strcpy(v4_ae_lib.libName, "hisi_ae_lib"); + strcpy(v4_awb_lib.libName, "hisi_awb_lib"); + } + if (ret = v4_snr_drv.obj->pfnRegisterCallback(_v4_vi_pipe, &v4_ae_lib, &v4_awb_lib)) return ret; @@ -412,7 +418,6 @@ int v4_sensor_config(void) { else if (config.input == V4_SNR_INPUT_LVDS) memcpy(&config.lvds, &v4_config.lvds, sizeof(v4_snr_lvds)); - if (!access(v4_snr_endp, F_OK)) fd = open(v4_snr_endp, O_RDWR); else fd = open("/dev/mipi", O_RDWR); @@ -878,4 +883,4 @@ int v4_system_init(char *snrConfig) return ret; return EXIT_SUCCESS; -} \ No newline at end of file +} diff --git a/src/hal/hisi/v4_isp.h b/src/hal/hisi/v4_isp.h index f10cafa..6947ab1 100644 --- a/src/hal/hisi/v4_isp.h +++ b/src/hal/hisi/v4_isp.h @@ -47,7 +47,17 @@ typedef struct { } v4_isp_impl; static int v4_isp_load(v4_isp_impl *isp_lib) { - if ((!(isp_lib->handleAe = dlopen("lib_hiae.so", RTLD_LAZY | RTLD_GLOBAL)) || + if (!access("/usr/lib/libisp.so", 0) && + !(isp_lib->handle = dlopen("libisp.so", RTLD_LAZY | RTLD_GLOBAL)) || + !(isp_lib->handleAe = dlopen("lib_hiae.so", RTLD_LAZY | RTLD_GLOBAL)) || + !(isp_lib->handleAwb = dlopen("lib_hiawb.so", RTLD_LAZY | RTLD_GLOBAL))) { + + fprintf(stderr, "[v4_isp] Failed to load library!\nError: %s\n", dlerror()); + return EXIT_FAILURE; + } + + if (!access("/usr/lib/libgk_isp.so", 0) && + (!(isp_lib->handleAe = dlopen("lib_hiae.so", RTLD_LAZY | RTLD_GLOBAL)) || !(isp_lib->handleAwb = dlopen("lib_hiawb.so", RTLD_LAZY | RTLD_GLOBAL)) || !(isp_lib->handleLdci = dlopen("lib_hildci.so", RTLD_LAZY | RTLD_GLOBAL)) || !(isp_lib->handleDehaze = dlopen("lib_hidehaze.so", RTLD_LAZY | RTLD_GLOBAL)) || @@ -64,6 +74,7 @@ static int v4_isp_load(v4_isp_impl *isp_lib) { !(isp_lib->handleDrc = dlopen("libdrc.so", RTLD_LAZY | RTLD_GLOBAL)) || !(isp_lib->handleDehaze = dlopen("libdehaze.so", RTLD_LAZY | RTLD_GLOBAL)) || !(isp_lib->handle = dlopen("libhi_isp.so", RTLD_LAZY | RTLD_GLOBAL)))) { + fprintf(stderr, "[v4_isp] Failed to load library!\nError: %s\n", dlerror()); return EXIT_FAILURE; } @@ -171,4 +182,4 @@ static void v4_isp_unload(v4_isp_impl *isp_lib) { if (isp_lib->handle) dlclose(isp_lib->handle); isp_lib->handle = NULL; memset(isp_lib, 0, sizeof(*isp_lib)); -} \ No newline at end of file +}