Skip to content

Commit

Permalink
Updated SDK components for CVITEK chips
Browse files Browse the repository at this point in the history
  • Loading branch information
wberube committed Aug 29, 2024
1 parent 44ea66f commit 8456a35
Show file tree
Hide file tree
Showing 7 changed files with 43 additions and 55 deletions.
40 changes: 19 additions & 21 deletions src/hal/plus/cvi_hal.c
Original file line number Diff line number Diff line change
Expand Up @@ -226,17 +226,17 @@ int cvi_pipeline_create(void)
{
int ret;

cvi_vpss.fnDestroyGroup(_cvi_vpss_grp);

{
cvi_sys_oper mode[4];
cvi_sys.fnGetViVpssMode((cvi_sys_oper**)&mode);
mode[_cvi_vi_dev] = CVI_SYS_OPER_VIOFF_VPSSON;
for (int i = 0; i < 4; i++)
mode[i] = CVI_SYS_OPER_VIOFF_VPSSOFF;
if (ret = cvi_sys.fnSetViVpssMode((cvi_sys_oper**)&mode))
return ret;
}

if (ret = cvi_sensor_config())
return ret;

if (ret = cvi_vi.fnSetDeviceConfig(_cvi_vi_dev, &cvi_config.videv))
return ret;
if (ret = cvi_vi.fnEnableDevice(_cvi_vi_dev))
Expand Down Expand Up @@ -288,13 +288,6 @@ int cvi_pipeline_create(void)
if (ret = cvi_vi.fnEnableChannel(_cvi_vi_pipe, _cvi_vi_chn))
return ret;

{
cvi_snr_bus bus;
bus.i2c = 0;
if (ret = cvi_snr_drv.obj->pfnSetBusInfo(_cvi_vi_pipe, bus))
return ret;
}

if (ret = cvi_snr_drv.obj->pfnRegisterCallback(_cvi_vi_pipe, &cvi_ae_lib, &cvi_awb_lib))
return ret;

Expand Down Expand Up @@ -369,8 +362,6 @@ void cvi_pipeline_destroy(void)
cvi_vi.fnDestroyPipe(_cvi_vi_pipe);

cvi_vi.fnDisableDevice(_cvi_vi_dev);

cvi_sensor_deconfig();
}

int cvi_region_create(char handle, hal_rect rect, short opacity)
Expand Down Expand Up @@ -456,7 +447,7 @@ int cvi_sensor_config(void) {
cvi_isp.fnResetSensor(device, 1);

cvi_isp.fnResetIntf(device, 1);

cvi_isp.fnSetIntfConfig(_cvi_vi_pipe, &config);

cvi_isp.fnSetSensorClock(device, 1);
Expand Down Expand Up @@ -487,7 +478,8 @@ void cvi_sensor_deinit(void)
int cvi_sensor_init(char *name, char *obj)
{
char path[128];
char* dirs[] = {"%s", "./%s", "/usr/lib/sensors/%s"};
char* dirs[] = {"%s", "./%s", "/usr/lib/sensors/%s", "/usr/lib/%s",
"/mnt/system/lib/%s", "/mnt/system/lib/libsns_full.so"};
char **dir = dirs;

while (*dir) {
Expand Down Expand Up @@ -883,17 +875,23 @@ int cvi_system_init(char *snrConfig)
return ret;

cvi_sys.fnExit();
//cvi_vb.fnExit();
cvi_vb.fnExit();

/*{
{
cvi_vb_pool pool;
memset(&pool, 0, sizeof(pool));
memset(&pool, 0, sizeof(pool));

pool.count = 2;
pool.comm[0].blockSize = 1920 * 1080 * 3;
pool.comm[0].blockCnt = 4;
pool.comm[1].blockSize = 1920 * 1080 * 3;
pool.comm[1].blockCnt = 4;

if (ret = cvi_vb.fnConfigPool(&pool))
return ret;
}*/
//if (ret = cvi_vb.fnInit())
// return ret;
}
if (ret = cvi_vb.fnInit())
return ret;

if (ret = cvi_sys.fnInit())
return ret;
Expand Down
2 changes: 0 additions & 2 deletions src/hal/plus/cvi_hal.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,6 @@ int cvi_region_create(char handle, hal_rect rect, short opacity);
void cvi_region_destroy(char handle);
int cvi_region_setbitmap(int handle, hal_bitmap *bitmap);

void cvi_sensor_deconfig(void);
int cvi_sensor_config(void);
void cvi_sensor_deinit(void);
int cvi_sensor_init(char *name, char *obj);

Expand Down
3 changes: 2 additions & 1 deletion src/hal/plus/cvi_isp.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ static int cvi_isp_load(cvi_isp_impl *isp_lib) {
if (!(isp_lib->handle = dlopen("libisp.so", RTLD_LAZY | RTLD_GLOBAL)) ||
!(isp_lib->handleAlgo = dlopen("libisp_algo.so", RTLD_LAZY | RTLD_GLOBAL)) ||
!(isp_lib->handleAe = dlopen("libae.so", RTLD_LAZY | RTLD_GLOBAL)) ||
!(isp_lib->handleAwb = dlopen("libawb.so", RTLD_LAZY | RTLD_GLOBAL)));
!(isp_lib->handleAwb = dlopen("libawb.so", RTLD_LAZY | RTLD_GLOBAL)))
HAL_ERROR("cvi_isp", "Failed to load library!\nError: %s\n", dlerror());

if (!(isp_lib->fnExit = (int(*)(int pipe))
hal_symbol_load("cvi_isp", isp_lib->handle, "CVI_ISP_Exit")))
Expand Down
24 changes: 12 additions & 12 deletions src/hal/plus/cvi_snr.h
Original file line number Diff line number Diff line change
Expand Up @@ -194,26 +194,26 @@ typedef struct {
} cvi_snr_init;

typedef struct {
int (*pfnRegisterCallback)(int pipe, cvi_isp_alg *aeLibrary, cvi_isp_alg *awbLibrary);
int (*pfnUnRegisterCallback)(int pipe, cvi_isp_alg *aeLibrary, cvi_isp_alg *awbLibrary);
int (*pfnSetBusInfo)(int pipe, cvi_snr_bus bus);
int (*pfnRegisterCallback)(int pipe, cvi_isp_alg *aeLibrary, cvi_isp_alg *awbLibrary);
int (*pfnUnRegisterCallback)(int pipe, cvi_isp_alg *aeLibrary, cvi_isp_alg *awbLibrary);
int (*pfnSetBusInfo)(int pipe, cvi_snr_bus bus);
void (*pfnStandby)(int pipe);
void (*pfnRestart)(int pipe);
void (*pfnMirrorFlip)(int pipe, cvi_isp_dir mode);
int (*pfnWriteReg)(int pipe, int addr, int data);
int (*pfnReadReg)(int pipe, int addr);
int (*pfnSetInit)(int pipe, cvi_snr_init *config);
int (*pfnPatchRxAttr)(cvi_snr_init *config);
int (*pfnWriteReg)(int pipe, int addr, int data);
int (*pfnReadReg)(int pipe, int addr);
int (*pfnSetInit)(int pipe, cvi_snr_init *config);
int (*pfnPatchRxAttr)(cvi_snr_init *config);
void (*pfnPatchI2cAddr)(int addr);
int (*pfnGetRxAttr)(int pipe, cvi_snr_dev *device);
int (*pfnExpSensorCb)(void *config);
int (*pfnExpAeCb)(void *config);
int (*pfnSnsProbe)(int pipe);
int (*pfnGetRxAttr)(int pipe, cvi_snr_dev *device);
int (*pfnExpSensorCb)(void *config);
int (*pfnExpAeCb)(void *config);
int (*pfnSnsProbe)(int pipe);
} cvi_snr_obj;

typedef struct {
void *handle;
cvi_snr_obj *obj;
} cvi_snr_drv_impl;

static const char cvi_snr_endp[] = {"/dev/cvi-mipi-tx"};
static const char cvi_snr_endp[] = {"/dev/cvi-mipi-rx"};
7 changes: 5 additions & 2 deletions src/hal/plus/cvi_sys.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ typedef struct {
} cvi_sys_ver;

typedef struct {
void *handle;
void *handle, *handleAtomic;

int (*fnExit)(void);
int (*fnGetChipId)(unsigned int *chip);
Expand All @@ -79,7 +79,8 @@ typedef struct {
} cvi_sys_impl;

static int cvi_sys_load(cvi_sys_impl *sys_lib) {
if (!(sys_lib->handle = dlopen("libsys.so", RTLD_LAZY | RTLD_GLOBAL)))
if (!(sys_lib->handleAtomic = dlopen("libatomic.so.1", 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))
Expand Down Expand Up @@ -120,5 +121,7 @@ static int cvi_sys_load(cvi_sys_impl *sys_lib) {
static void cvi_sys_unload(cvi_sys_impl *sys_lib) {
if (sys_lib->handle) dlclose(sys_lib->handle);
sys_lib->handle = NULL;
if (sys_lib->handleAtomic) dlclose(sys_lib->handleAtomic);
sys_lib->handleAtomic = NULL;
memset(sys_lib, 0, sizeof(*sys_lib));
}
2 changes: 1 addition & 1 deletion src/hal/plus/cvi_vb.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
typedef struct {
unsigned int count;
struct {
unsigned long long blockSize;
unsigned int blockSize;
unsigned int blockCnt;
// Accepts values from 0-2 (none, nocache, cached)
int rempVirt;
Expand Down
20 changes: 4 additions & 16 deletions src/hal/plus/cvi_venc.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,18 +78,19 @@ typedef enum {

typedef struct {
char rcnRefShareBufOn;
char singleBufLumaOn;
} cvi_venc_attr_h264;

typedef struct {
char rcnRefShareBufOn;
char singleBufLumaOn;
} cvi_venc_attr_h265;

typedef struct {
char dcfThumbs;
unsigned char numThumbs;
cvi_common_dim sizeThumbs[2];
int multiReceiveOn;
int shit;
} cvi_venc_attr_jpg;

typedef struct {
Expand Down Expand Up @@ -119,19 +120,6 @@ typedef struct {
char variFpsOn;
} cvi_venc_rate_h26xbr;

typedef struct {
unsigned int gop;
unsigned int statTime;
unsigned int srcFps;
unsigned int dstFps;
unsigned int maxBitrate;
unsigned int shortTermStatTime;
unsigned int longTermStatTime;
unsigned int longTermMaxBitrate;
unsigned int longTermMinBitrate;
char variFpsOn;
} cvi_venc_rate_h26xcvbr;

typedef struct {
unsigned int gop;
unsigned int srcFps;
Expand Down Expand Up @@ -182,19 +170,19 @@ typedef struct {
cvi_venc_rate_h26xbr h264Vbr;
cvi_venc_rate_h26xbr h264Avbr;
cvi_venc_rate_h26xbr h264Qvbr;
cvi_venc_rate_h26xcvbr h264Cvbr;
cvi_venc_rate_h26xqp h264Qp;
cvi_venc_rate_h264qpmap h264QpMap;
cvi_venc_rate_h26xbr h264Ubr;
cvi_venc_rate_mjpgbr mjpgCbr;
cvi_venc_rate_mjpgbr mjpgVbr;
cvi_venc_rate_mjpgqp mjpgQp;
cvi_venc_rate_h26xbr h265Cbr;
cvi_venc_rate_h26xbr h265Vbr;
cvi_venc_rate_h26xbr h265Avbr;
cvi_venc_rate_h26xbr h265Qvbr;
cvi_venc_rate_h26xcvbr h265Cvbr;
cvi_venc_rate_h26xqp h265Qp;
cvi_venc_rate_h265qpmap h265QpMap;
cvi_venc_rate_h26xbr h265Ubr;
};
} cvi_venc_rate;

Expand Down

0 comments on commit 8456a35

Please sign in to comment.