-
-
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.
- Loading branch information
Showing
5 changed files
with
324 additions
and
2 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
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,179 @@ | ||
#pragma once | ||
|
||
#include "cvi_common.h" | ||
#include "cvi_sys.h" | ||
|
||
typedef enum { | ||
CVI_RGN_BLK_8, | ||
CVI_RGN_BLK_16, | ||
CVI_RGN_BLK_END | ||
} cvi_rgn_blk; | ||
|
||
typedef enum { | ||
CVI_RGN_COMPR_NONE, | ||
CVI_RGN_COMPR_SW, | ||
CVI_RGN_COMPR_HW, | ||
CVI_RGN_COMPR_END | ||
} cvi_rgn_compr; | ||
|
||
typedef enum { | ||
CVI_RGN_TYPE_OVERLAY, | ||
CVI_RGN_TYPE_COVER, | ||
CVI_RGN_TYPE_COVEREX, | ||
CVI_RGN_TYPE_OVERLAYEX, | ||
CVI_RGN_TYPE_MOSAIC, | ||
CVI_RGN_TYPE_END | ||
} cvi_rgn_type; | ||
|
||
typedef struct { | ||
cvi_common_pixfmt pixFmt; | ||
cvi_common_dim size; | ||
void *data; | ||
} cvi_rgn_bmp; | ||
|
||
typedef struct { | ||
cvi_rgn_compr mode; | ||
unsigned int estSize; | ||
unsigned int realSize; | ||
} cvi_rgn_cmpinfo; | ||
|
||
typedef struct { | ||
cvi_common_dim invColArea; | ||
unsigned int lumThresh; | ||
unsigned int highThanOn; | ||
char invColOn; | ||
} cvi_rgn_inv; | ||
|
||
typedef struct { | ||
cvi_common_pnt point; | ||
// Accepts values from 0-7 | ||
unsigned int layer; | ||
cvi_rgn_inv invert; | ||
} cvi_rgn_ovlc; | ||
|
||
typedef struct { | ||
char solidOn; | ||
unsigned int lineThick; | ||
cvi_common_pnt point[4]; | ||
} cvi_rgn_qdr; | ||
|
||
typedef struct { | ||
int quadRangleOn; | ||
union { | ||
cvi_common_rect rect; | ||
cvi_rgn_qdr quadR; | ||
}; | ||
unsigned int color; | ||
unsigned int layer; | ||
int absOrRatioCoord; | ||
} cvi_rgn_covc; | ||
|
||
typedef struct { | ||
int quadRangleOn; | ||
union { | ||
cvi_common_rect rect; | ||
cvi_rgn_qdr quadR; | ||
}; | ||
unsigned int color; | ||
unsigned int layer; | ||
} cvi_rgn_covxc; | ||
|
||
typedef struct { | ||
cvi_common_rect rect; | ||
cvi_rgn_blk blkSize; | ||
// Accepts values from 0-3 | ||
unsigned int layer; | ||
} cvi_rgn_mosc; | ||
|
||
typedef struct { | ||
char show; | ||
cvi_rgn_type type; | ||
union { | ||
cvi_rgn_ovlc overlay; | ||
cvi_rgn_covc cover; | ||
cvi_rgn_covxc coverex; | ||
cvi_rgn_ovlc overlayex; | ||
cvi_rgn_mosc mosaic; | ||
}; | ||
} cvi_rgn_chn; | ||
|
||
typedef struct { | ||
cvi_common_pixfmt pixFmt; | ||
unsigned int bgColor; | ||
cvi_common_dim size; | ||
unsigned int canvas; | ||
cvi_rgn_cmpinfo compInfo; | ||
} cvi_rgn_ovl; | ||
|
||
typedef struct { | ||
cvi_rgn_type type; | ||
union { | ||
cvi_rgn_ovl overlay; | ||
cvi_rgn_ovl overlayex; | ||
}; | ||
} cvi_rgn_cnf; | ||
|
||
typedef struct { | ||
void *handle; | ||
|
||
int (*fnCreateRegion)(unsigned int handle, cvi_rgn_cnf *config); | ||
int (*fnDestroyRegion)(unsigned int handle); | ||
int (*fnGetRegionConfig)(unsigned int handle, cvi_rgn_cnf *config); | ||
int (*fnSetRegionConfig)(unsigned int handle, cvi_rgn_cnf *config); | ||
|
||
int (*fnAttachChannel)(unsigned int handle, cvi_sys_bind *dest, cvi_rgn_chn *config); | ||
int (*fnDetachChannel)(unsigned int handle, cvi_sys_bind *dest); | ||
int (*fnGetChannelConfig)(unsigned int handle, cvi_sys_bind *dest, cvi_rgn_chn *config); | ||
int (*fnSetChannelConfig)(unsigned int handle, cvi_sys_bind *dest, cvi_rgn_chn *config); | ||
|
||
int (*fnSetBitmap)(unsigned int handle, cvi_rgn_bmp *bitmap); | ||
} cvi_rgn_impl; | ||
|
||
static int cvi_rgn_load(cvi_rgn_impl *rgn_lib) { | ||
if (!(rgn_lib->handle = dlopen("libvpu.so", RTLD_LAZY | RTLD_GLOBAL))) | ||
HAL_ERROR("cvi_rgn", "Failed to load library!\nError: %s\n", dlerror()); | ||
|
||
if (!(rgn_lib->fnCreateRegion = (int(*)(unsigned int handle, cvi_rgn_cnf *config)) | ||
hal_symbol_load("cvi_rgn", rgn_lib->handle, "CVI_RGN_Create"))) | ||
return EXIT_FAILURE; | ||
|
||
if (!(rgn_lib->fnDestroyRegion = (int(*)(unsigned int handle)) | ||
hal_symbol_load("cvi_rgn", rgn_lib->handle, "CVI_RGN_Destroy"))) | ||
return EXIT_FAILURE; | ||
|
||
if (!(rgn_lib->fnGetRegionConfig = (int(*)(unsigned int handle, cvi_rgn_cnf *config)) | ||
hal_symbol_load("cvi_rgn", rgn_lib->handle, "CVI_RGN_GetAttr"))) | ||
return EXIT_FAILURE; | ||
|
||
if (!(rgn_lib->fnSetRegionConfig = (int(*)(unsigned int handle, cvi_rgn_cnf *config)) | ||
hal_symbol_load("cvi_rgn", rgn_lib->handle, "CVI_RGN_SetAttr"))) | ||
return EXIT_FAILURE; | ||
|
||
if (!(rgn_lib->fnAttachChannel = (int(*)(unsigned int handle, cvi_sys_bind *dest, cvi_rgn_chn *config)) | ||
hal_symbol_load("cvi_rgn", rgn_lib->handle, "CVI_RGN_AttachToChn"))) | ||
return EXIT_FAILURE; | ||
|
||
if (!(rgn_lib->fnDetachChannel = (int(*)(unsigned int handle, cvi_sys_bind *dest)) | ||
hal_symbol_load("cvi_rgn", rgn_lib->handle, "CVI_RGN_DetachFromChn"))) | ||
return EXIT_FAILURE; | ||
|
||
if (!(rgn_lib->fnGetChannelConfig = (int(*)(unsigned int handle, cvi_sys_bind *dest, cvi_rgn_chn *config)) | ||
hal_symbol_load("cvi_rgn", rgn_lib->handle, "CVI_RGN_GetDisplayAttr"))) | ||
return EXIT_FAILURE; | ||
|
||
if (!(rgn_lib->fnSetChannelConfig = (int(*)(unsigned int handle, cvi_sys_bind *dest, cvi_rgn_chn *config)) | ||
hal_symbol_load("cvi_rgn", rgn_lib->handle, "CVI_RGN_SetDisplayAttr"))) | ||
return EXIT_FAILURE; | ||
|
||
if (!(rgn_lib->fnSetBitmap = (int(*)(unsigned int handle, cvi_rgn_bmp *bitmap)) | ||
hal_symbol_load("cvi_rgn", rgn_lib->handle, "CVI_RGN_SetBitMap"))) | ||
return EXIT_FAILURE; | ||
|
||
return EXIT_SUCCESS; | ||
} | ||
|
||
static void cvi_rgn_unload(cvi_rgn_impl *rgn_lib) { | ||
if (rgn_lib->handle) dlclose(rgn_lib->handle); | ||
rgn_lib->handle = NULL; | ||
memset(rgn_lib, 0, sizeof(*rgn_lib)); | ||
} |
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,47 @@ | ||
#pragma once | ||
|
||
#include "cvi_common.h" | ||
|
||
typedef struct { | ||
unsigned int count; | ||
struct { | ||
unsigned long long blockSize; | ||
unsigned int blockCnt; | ||
// Accepts values from 0-2 (none, nocache, cached) | ||
int rempVirt; | ||
char heapName[32]; | ||
} comm[16]; | ||
} cvi_vb_pool; | ||
|
||
typedef struct { | ||
void *handle; | ||
|
||
int (*fnConfigPool)(cvi_vb_pool *config); | ||
int (*fnExit)(void); | ||
int (*fnInit)(void); | ||
} cvi_vb_impl; | ||
|
||
static int cvi_vb_load(cvi_vb_impl *vb_lib) { | ||
if (!(vb_lib->handle = dlopen("libmpi.so", RTLD_LAZY | RTLD_GLOBAL))) | ||
HAL_ERROR("cvi_vb", "Failed to load library!\nError: %s\n", dlerror()); | ||
|
||
if (!(vb_lib->fnConfigPool = (int(*)(cvi_vb_pool *config)) | ||
hal_symbol_load("cvi_vb", vb_lib->handle, "CVI_VB_SetConfig"))) | ||
return EXIT_FAILURE; | ||
|
||
if (!(vb_lib->fnExit = (int(*)(void)) | ||
hal_symbol_load("cvi_vb", vb_lib->handle, "CVI_VB_Exit"))) | ||
return EXIT_FAILURE; | ||
|
||
if (!(vb_lib->fnInit = (int(*)(void)) | ||
hal_symbol_load("cvi_vb", vb_lib->handle, "CVI_VB_Init"))) | ||
return EXIT_FAILURE; | ||
|
||
return EXIT_SUCCESS; | ||
} | ||
|
||
static void cvi_vb_unload(cvi_vb_impl *vb_lib) { | ||
if (vb_lib->handle) dlclose(vb_lib->handle); | ||
vb_lib->handle = NULL; | ||
memset(vb_lib, 0, sizeof(*vb_lib)); | ||
} |
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,93 @@ | ||
#pragma once | ||
|
||
#include "cvi_common.h" | ||
|
||
typedef struct { | ||
cvi_common_dim dest; | ||
int reserved; | ||
cvi_common_pixfmt pixFmt; | ||
int srcFps; | ||
int dstFps; | ||
int mirror; | ||
int flip; | ||
// Accepts values from 0-8 | ||
unsigned int depth; | ||
// Accepts values from 0-2 (none, auto, manual) | ||
int aspectRatio; | ||
char aspectBgOn; | ||
unsigned int aspectBgCol; | ||
cvi_common_rect aspectRect; | ||
} cvi_vpss_chn; | ||
|
||
typedef struct { | ||
cvi_common_dim dest; | ||
cvi_common_pixfmt pixFmt; | ||
int srcFps; | ||
int dstFps; | ||
// Only used when VPSS mode is set to dual | ||
unsigned char device; | ||
} cvi_vpss_grp; | ||
|
||
typedef struct { | ||
void *handle; | ||
|
||
int (*fnCreateGroup)(int group, cvi_vpss_grp *config); | ||
int (*fnDestroyGroup)(int group); | ||
int (*fnResetGroup)(int group); | ||
int (*fnSetGroupConfig)(int channel, cvi_vpss_grp *config); | ||
int (*fnStartGroup)(int group); | ||
int (*fnStopGroup)(int group); | ||
|
||
int (*fnDisableChannel)(int group, int channel); | ||
int (*fnEnableChannel)(int group, int channel); | ||
int (*fnSetChannelConfig)(int group, int channel, cvi_vpss_chn *config); | ||
} cvi_vpss_impl; | ||
|
||
static int cvi_vpss_load(cvi_vpss_impl *vpss_lib) { | ||
if ( !(vpss_lib->handle = dlopen("libvpu.so", RTLD_LAZY | RTLD_GLOBAL))) | ||
HAL_ERROR("cvi_vpss", "Failed to load library!\nError: %s\n", dlerror()); | ||
|
||
if (!(vpss_lib->fnCreateGroup = (int(*)(int group, cvi_vpss_grp *config)) | ||
hal_symbol_load("cvi_vpss", vpss_lib->handle, "CVI_VPSS_CreateGrp"))) | ||
return EXIT_FAILURE; | ||
|
||
if (!(vpss_lib->fnDestroyGroup = (int(*)(int group)) | ||
hal_symbol_load("cvi_vpss", vpss_lib->handle, "CVI_VPSS_DestroyGrp"))) | ||
return EXIT_FAILURE; | ||
|
||
if (!(vpss_lib->fnResetGroup = (int(*)(int group)) | ||
hal_symbol_load("cvi_vpss", vpss_lib->handle, "CVI_VPSS_ResetGrp"))) | ||
return EXIT_FAILURE; | ||
|
||
if (!(vpss_lib->fnSetGroupConfig = (int(*)(int group, cvi_vpss_grp *config)) | ||
hal_symbol_load("cvi_vpss", vpss_lib->handle, "CVI_VPSS_SetGrpAttr"))) | ||
return EXIT_FAILURE; | ||
|
||
if (!(vpss_lib->fnStartGroup = (int(*)(int group)) | ||
hal_symbol_load("cvi_vpss", vpss_lib->handle, "CVI_VPSS_StartGrp"))) | ||
return EXIT_FAILURE; | ||
|
||
if (!(vpss_lib->fnStopGroup = (int(*)(int group)) | ||
hal_symbol_load("cvi_vpss", vpss_lib->handle, "CVI_VPSS_StopGrp"))) | ||
return EXIT_FAILURE; | ||
|
||
if (!(vpss_lib->fnDisableChannel = (int(*)(int group, int channel)) | ||
hal_symbol_load("cvi_vpss", vpss_lib->handle, "CVI_VPSS_DisableChn"))) | ||
return EXIT_FAILURE; | ||
|
||
if (!(vpss_lib->fnEnableChannel = (int(*)(int group, int channel)) | ||
hal_symbol_load("cvi_vpss", vpss_lib->handle, "CVI_VPSS_EnableChn"))) | ||
return EXIT_FAILURE; | ||
|
||
if (!(vpss_lib->fnSetChannelConfig = (int(*)(int group, int channel, cvi_vpss_chn *config)) | ||
hal_symbol_load("cvi_vpss", vpss_lib->handle, "CVI_VPSS_SetChnAttr"))) | ||
return EXIT_FAILURE; | ||
|
||
return EXIT_SUCCESS; | ||
} | ||
|
||
static void cvi_vpss_unload(cvi_vpss_impl *vpss_lib) { | ||
if (vpss_lib->handle) dlclose(vpss_lib->handle); | ||
vpss_lib->handle = NULL; | ||
memset(vpss_lib, 0, sizeof(*vpss_lib)); | ||
} |