-
-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Starting the port to CVITEK/SOPHGO platforms
- Loading branch information
Showing
4 changed files
with
491 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,135 @@ | ||
#pragma once | ||
|
||
#include <dlfcn.h> | ||
#include <stdio.h> | ||
#include <stdlib.h> | ||
#include <string.h> | ||
#include <sys/select.h> | ||
|
||
#include "../symbols.h" | ||
#include "../types.h" | ||
|
||
#define CVI_VI_PIPE_NUM 4 | ||
|
||
typedef enum { | ||
CVI_BAYER_BG, | ||
CVI_BAYER_GB, | ||
CVI_BAYER_GR, | ||
CVI_BAYER_RG, | ||
CVI_BAYER_END | ||
} cvi_common_bayer; | ||
|
||
typedef enum { | ||
CVI_COMPR_NONE, | ||
CVI_COMPR_TILE, | ||
CVI_COMPR_LINE, | ||
CVI_COMPR_FRAME, | ||
CVI_COMPR_END | ||
} cvi_common_compr; | ||
|
||
typedef enum { | ||
CVI_HDR_SDR8, | ||
CVI_HDR_SDR10, | ||
CVI_HDR_HDR10, | ||
CVI_HDR_HLG, | ||
CVI_HDR_SLF, | ||
CVI_HDR_XDR, | ||
CVI_HDR_END | ||
} cvi_common_hdr; | ||
|
||
typedef enum { | ||
CVI_PIXFMT_RGB888, | ||
CVI_PIXFMT_BGR888, | ||
CVI_PIXFMT_RGB888P, | ||
CVI_PIXFMT_BGR888P, | ||
CVI_PIXFMT_ARGB1555, | ||
CVI_PIXFMT_ARGB4444, | ||
CVI_PIXFMT_ARGB8888, | ||
CVI_PIXFMT_RGB_BAYER_8BPP, | ||
CVI_PIXFMT_RGB_BAYER_10BPP, | ||
CVI_PIXFMT_RGB_BAYER_12BPP, | ||
CVI_PIXFMT_RGB_BAYER_14BPP, | ||
CVI_PIXFMT_RGB_BAYER_16BPP, | ||
CVI_PIXFMT_YUV422P, | ||
CVI_PIXFMT_YUV420P, | ||
CVI_PIXFMT_YUV444P, | ||
CVI_PIXFMT_YUV400, | ||
CVI_PIXFMT_HSV888, | ||
CVI_PIXFMT_HSV888P, | ||
CVI_PIXFMT_NV12, | ||
CVI_PIXFMT_NV21, | ||
CVI_PIXFMT_NV16, | ||
CVI_PIXFMT_NV61, | ||
CVI_PIXFMT_YUV422_YUYV, | ||
CVI_PIXFMT_YUV422_UYVY, | ||
CVI_PIXFMT_YUV422_YVYU, | ||
CVI_PIXFMT_YUV422_VYUY, | ||
CVI_PIXFMT_FP32C1 = 32, | ||
CVI_PIXFMT_FP32C3P, | ||
CVI_PIXFMT_S32C1, | ||
CVI_PIXFMT_S32C3P, | ||
CVI_PIXFMT_U32C1, | ||
CVI_PIXFMT_U32C3P, | ||
CVI_PIXFMT_BF16C1, | ||
CVI_PIXFMT_BF16C3P, | ||
CVI_PIXFMT_S16C1, | ||
CVI_PIXFMT_S16C3P, | ||
CVI_PIXFMT_U16C1, | ||
CVI_PIXFMT_U16C3P, | ||
CVI_PIXFMT_S8C1, | ||
CVI_PIXFMT_S8C3P, | ||
CVI_PIXFMT_U8C1, | ||
CVI_PIXFMT_U8C3P, | ||
CVI_PIXFMT_8BITMODE = 48, | ||
CVI_PIXFMT_END | ||
} cvi_common_pixfmt; | ||
|
||
typedef enum { | ||
CVI_PREC_8BPP, | ||
CVI_PREC_10BPP, | ||
CVI_PREC_12BPP, | ||
CVI_PREC_14BPP, | ||
CVI_PREC_16BPP, | ||
CVI_PREC_END | ||
} cvi_common_prec; | ||
|
||
typedef enum { | ||
CVI_WDR_NONE, | ||
CVI_WDR_BUILTIN, | ||
CVI_WDR_QUDRA, | ||
CVI_WDR_2TO1_LINE, | ||
CVI_WDR_2TO1_FRAME, | ||
CVI_WDR_2TO1_FRAME_FULLRATE, | ||
CVI_WDR_3TO1_LINE, | ||
CVI_WDR_3TO1_FRAME, | ||
CVI_WDR_3TO1_FRAME_FULLRATE, | ||
CVI_WDR_4TO1_LINE, | ||
CVI_WDR_4TO1_FRAME, | ||
CVI_WDR_4TO1_FRAME_FULLRATE, | ||
CVI_WDR_END | ||
} cvi_common_wdr; | ||
|
||
typedef struct { | ||
unsigned int topWidth; | ||
unsigned int bottomWidth; | ||
unsigned int leftWidth; | ||
unsigned int rightWidth; | ||
unsigned int color; | ||
} cvi_common_bord; | ||
|
||
typedef struct { | ||
unsigned int width; | ||
unsigned int height; | ||
} cvi_common_dim; | ||
|
||
typedef struct { | ||
int x; | ||
int y; | ||
} cvi_common_pnt; | ||
|
||
typedef struct { | ||
int x; | ||
int y; | ||
unsigned int width; | ||
unsigned int height; | ||
} cvi_common_rect; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,133 @@ | ||
#pragma once | ||
|
||
#include "cvi_common.h" | ||
|
||
#define CVI_SYS_API "1.0" | ||
|
||
typedef enum { | ||
CVI_SYS_MOD_BASE, | ||
CVI_SYS_MOD_VB, | ||
CVI_SYS_MOD_SYS, | ||
CVI_SYS_MOD_RGN, | ||
CVI_SYS_MOD_CHNL, | ||
CVI_SYS_MOD_VDEC, | ||
CVI_SYS_MOD_VPSS, | ||
CVI_SYS_MOD_VENC, | ||
CVI_SYS_MOD_H264E, | ||
CVI_SYS_MOD_JPEGE, | ||
CVI_SYS_MOD_MPEG4E, | ||
CVI_SYS_MOD_H265E, | ||
CVI_SYS_MOD_JPEGD, | ||
CVI_SYS_MOD_VO, | ||
CVI_SYS_MOD_VI, | ||
CVI_SYS_MOD_DIS, | ||
CVI_SYS_MOD_RC, | ||
CVI_SYS_MOD_AIO, | ||
CVI_SYS_MOD_AI, | ||
CVI_SYS_MOD_AO, | ||
CVI_SYS_MOD_AENC, | ||
CVI_SYS_MOD_ADEC, | ||
CVI_SYS_MOD_AUD, | ||
CVI_SYS_MOD_VPU, | ||
CVI_SYS_MOD_ISP, | ||
CVI_SYS_MOD_IVE, | ||
CVI_SYS_MOD_USER, | ||
CVI_SYS_MOD_PROC, | ||
CVI_SYS_MOD_LOG, | ||
CVI_SYS_MOD_H264D, | ||
CVI_SYS_MOD_GDC, | ||
CVI_SYS_MOD_PHOTO, | ||
CVI_SYS_MOD_FB, | ||
CVI_SYS_MOD_END | ||
} cvi_sys_mod; | ||
|
||
typedef enum { | ||
CVI_SYS_OPER_VIOFF_VPSSOFF, | ||
CVI_SYS_OPER_VIOFF_VPSSON, | ||
CVI_SYS_OPER_VION_VPSSOFF, | ||
CVI_SYS_OPER_VION_VPSSON, | ||
CVI_SYS_OPER_VIOFF_POSTON, | ||
CVI_SYS_OPER_VIOFF_POSTOFF, | ||
CVI_SYS_OPER_VION_POSTOFF, | ||
CVI_SYS_OPER_VION_POSTON, | ||
CVI_SYS_OPER_END | ||
} cvi_sys_oper; | ||
|
||
typedef struct { | ||
cvi_sys_mod module; | ||
int device; | ||
int channel; | ||
} cvi_sys_bind; | ||
|
||
typedef struct { | ||
char version[128]; | ||
} cvi_sys_ver; | ||
|
||
typedef struct { | ||
void *handle, *handleVoiceEngine, *handleVqe, *handleMisc; | ||
|
||
int (*fnExit)(void); | ||
int (*fnGetChipId)(unsigned int *chip); | ||
int (*fnGetVersion)(cvi_sys_ver *version); | ||
int (*fnInit)(void); | ||
|
||
int (*fnBind)(cvi_sys_bind *source, cvi_sys_bind *dest); | ||
int (*fnUnbind)(cvi_sys_bind *source, cvi_sys_bind *dest); | ||
|
||
int (*fnGetViVpssMode)(cvi_sys_oper *mode[CVI_VI_PIPE_NUM]); | ||
int (*fnSetViVpssMode)(cvi_sys_oper *mode[CVI_VI_PIPE_NUM]); | ||
} cvi_sys_impl; | ||
|
||
static int cvi_sys_load(cvi_sys_impl *sys_lib) { | ||
if (!(sys_lib->handleMisc = dlopen("libmisc.so", RTLD_LAZY | RTLD_GLOBAL)) || | ||
!(sys_lib->handleVqe = dlopen("libcvi_vqe.so", RTLD_LAZY | RTLD_GLOBAL)) || | ||
!(sys_lib->handleVoiceEngine = dlopen("libcvi_VoiceEngine.so", RTLD_LAZY | RTLD_GLOBAL)) || | ||
!(sys_lib->handle = dlopen("libsys.so", RTLD_LAZY | RTLD_GLOBAL))) | ||
HAL_ERROR("cvi_sys", "Failed to load library!\nError: %s\n", dlerror()); | ||
|
||
if (!(sys_lib->fnExit = (int(*)(void)) | ||
hal_symbol_load("cvi_sys", sys_lib->handle, "CVI_SYS_Exit"))) | ||
return EXIT_FAILURE; | ||
|
||
if (!(sys_lib->fnGetChipId = (int(*)(unsigned int *chip)) | ||
hal_symbol_load("cvi_sys", sys_lib->handle, "CVI_SYS_GetChipId"))) | ||
return EXIT_FAILURE; | ||
|
||
if (!(sys_lib->fnGetVersion = (int(*)(cvi_sys_ver *version)) | ||
hal_symbol_load("cvi_sys", sys_lib->handle, "CVI_SYS_GetVersion"))) | ||
return EXIT_FAILURE; | ||
|
||
if (!(sys_lib->fnInit = (int(*)(void)) | ||
hal_symbol_load("cvi_sys", sys_lib->handle, "CVI_SYS_Init"))) | ||
return EXIT_FAILURE; | ||
|
||
if (!(sys_lib->fnBind = (int(*)(cvi_sys_bind *source, cvi_sys_bind *dest)) | ||
hal_symbol_load("cvi_sys", sys_lib->handle, "CVI_SYS_Bind"))) | ||
return EXIT_FAILURE; | ||
|
||
if (!(sys_lib->fnUnbind = (int(*)(cvi_sys_bind *source, cvi_sys_bind *dest)) | ||
hal_symbol_load("cvi_sys", sys_lib->handle, "CVI_SYS_UnBind"))) | ||
return EXIT_FAILURE; | ||
|
||
if (!(sys_lib->fnGetViVpssMode = (int(*)(cvi_sys_oper *mode[CVI_VI_PIPE_NUM])) | ||
hal_symbol_load("cvi_sys", sys_lib->handle, "CVI_SYS_GetVIVPSSMode"))) | ||
return EXIT_FAILURE; | ||
|
||
if (!(sys_lib->fnSetViVpssMode = (int(*)(cvi_sys_oper *mode[CVI_VI_PIPE_NUM])) | ||
hal_symbol_load("cvi_sys", sys_lib->handle, "CVI_SYS_SetVIVPSSMode"))) | ||
return EXIT_FAILURE; | ||
|
||
return EXIT_SUCCESS; | ||
} | ||
|
||
static void cvi_sys_unload(cvi_sys_impl *sys_lib) { | ||
if (sys_lib->handleMisc) dlclose(sys_lib->handleMisc); | ||
sys_lib->handleMisc = NULL; | ||
if (sys_lib->handleVqe) dlclose(sys_lib->handleVqe); | ||
sys_lib->handleVqe = NULL; | ||
if (sys_lib->handleVoiceEngine) dlclose(sys_lib->handleVoiceEngine); | ||
sys_lib->handleVoiceEngine = NULL; | ||
if (sys_lib->handle) dlclose(sys_lib->handle); | ||
sys_lib->handle = NULL; | ||
memset(sys_lib, 0, sizeof(*sys_lib)); | ||
} |
Oops, something went wrong.