Skip to content

Commit

Permalink
Logical 3A (de)init on Hisi devices
Browse files Browse the repository at this point in the history
  • Loading branch information
wberube committed Sep 12, 2024
1 parent 267b1ba commit 319529e
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 27 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ In spite of these design choices, Divinus boasts numerous features that cater to
| CV181x[^1] ||||||
| GM813x[^2] | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ |
| Hi3516AV100[^3] | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ |
| Hi3516CV100[^4] ||| |||
| Hi3516CV100[^4] ||| ✔️ |||
| Hi3516CV200[^5] | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ |
| Hi3516CV300[^6] | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ |
| Hi3516CV500[^7] | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ |
Expand Down
30 changes: 15 additions & 15 deletions src/hal/hisi/v1_hal.c
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,12 @@ int v1_pipeline_create(void)

void v1_pipeline_destroy(void)
{
v1_isp.fnExit();
v1_isp.fnUnregisterAWB(&v1_awb_lib);
v1_isp.fnUnregisterAE(&v1_ae_lib);

v1_snr_drv.fnUnRegisterCallback();

for (char grp = 0; grp < V1_VPSS_GRP_NUM; grp++)
{
for (char chn = 0; chn < V1_VPSS_CHN_NUM; chn++)
Expand All @@ -330,12 +336,6 @@ void v1_pipeline_destroy(void)
v1_vi.fnDisableChannel(_v1_vi_chn);

v1_vi.fnDisableDevice(_v1_vi_dev);

v1_isp.fnExit();
v1_isp.fnUnregisterAE(&v1_ae_lib);
v1_isp.fnUnregisterAWB(&v1_awb_lib);

v1_snr_drv.fnUnRegisterCallback();
}

int v1_region_create(char handle, hal_rect rect, short opacity)
Expand Down Expand Up @@ -448,7 +448,7 @@ int v1_video_create(char index, hal_vidconfig *config)
channel.attrib.jpg.maxPic.width = config->width;
channel.attrib.jpg.maxPic.height = config->height;
channel.attrib.jpg.bufSize =
config->height * config->width * 2;
ALIGN_UP(config->height, 16) * ALIGN_UP(config->width, 16);
channel.attrib.jpg.byFrame = 1;
channel.attrib.jpg.fieldOrFrame = 0;
channel.attrib.jpg.priority = 0;
Expand All @@ -460,7 +460,7 @@ int v1_video_create(char index, hal_vidconfig *config)
channel.attrib.mjpg.maxPic.width = config->width;
channel.attrib.mjpg.maxPic.height = config->height;
channel.attrib.mjpg.bufSize =
config->height * config->width * 2;
ALIGN_UP(config->height, 16) * ALIGN_UP(config->width, 16);
channel.attrib.mjpg.byFrame = 1;
channel.attrib.mjpg.mainStrmOn = 1;
channel.attrib.mjpg.fieldOrFrame = 0;
Expand All @@ -471,7 +471,7 @@ int v1_video_create(char index, hal_vidconfig *config)
case HAL_VIDMODE_CBR:
channel.rate.mode = V1_VENC_RATEMODE_MJPGCBR;
channel.rate.mjpgCbr = (v1_venc_rate_mjpgcbr){ .statTime = 1, .srcFps = config->framerate,
.dstFps = config->framerate, .bitrate = config->bitrate, .avgLvl = 1 }; break;
.dstFps = config->framerate, .bitrate = config->bitrate, .avgLvl = 0 }; break;
case HAL_VIDMODE_VBR:
channel.rate.mode = V1_VENC_RATEMODE_MJPGVBR;
channel.rate.mjpgVbr = (v1_venc_rate_mjpgvbr){ .statTime = 1, .srcFps = config->framerate,
Expand All @@ -490,12 +490,12 @@ int v1_video_create(char index, hal_vidconfig *config)
attrib = &channel.attrib.h264;
switch (config->mode) {
case HAL_VIDMODE_CBR:
channel.rate.mode = V1_VENC_RATEMODE_H264CBR;
channel.rate.mode = V1_VENC_RATEMODE_H264CBRv2;
channel.rate.h264Cbr = (v1_venc_rate_h264cbr){ .gop = config->gop,
.statTime = 1, .srcFps = config->framerate, .dstFps = config->framerate,
.bitrate = config->bitrate, .avgLvl = 1 }; break;
.bitrate = config->bitrate, .avgLvl = 0 }; break;
case HAL_VIDMODE_VBR:
channel.rate.mode = V1_VENC_RATEMODE_H264VBR;
channel.rate.mode = V1_VENC_RATEMODE_H264VBRv2;
channel.rate.h264Vbr = (v1_venc_rate_h264vbr){ .gop = config->gop,
.statTime = 1, .srcFps = config->framerate, .dstFps = config->framerate,
.maxBitrate = MAX(config->bitrate, config->maxBitrate), .maxQual = config->maxQual,
Expand All @@ -511,9 +511,9 @@ int v1_video_create(char index, hal_vidconfig *config)
} else HAL_ERROR("v1_venc", "This codec is not supported by the hardware!");
attrib->maxPic.width = config->width;
attrib->maxPic.height = config->height;
attrib->bufSize = config->height * config->width * 2;
attrib->bufSize = config->height * config->width;
attrib->profile = MIN(config->profile, 1);
attrib->byFrame = 0;
attrib->byFrame = 1;
attrib->fieldOn = 0;
attrib->mainStrmOn = 1;
attrib->priority = 0;
Expand Down Expand Up @@ -825,7 +825,7 @@ int v1_system_init(char *snrConfig)
v1_config.vichn.capt.height ?
v1_config.vichn.capt.height : v1_config.videv.rect.height,
V1_PIXFMT_YUV420SP, alignWidth);
pool.comm[0].blockCnt = 5;
pool.comm[0].blockCnt = 10;

if (ret = v1_vb.fnConfigPool(&pool))
return ret;
Expand Down
10 changes: 5 additions & 5 deletions src/hal/hisi/v2_hal.c
Original file line number Diff line number Diff line change
Expand Up @@ -315,8 +315,8 @@ int v2_pipeline_create(void)
void v2_pipeline_destroy(void)
{
v2_isp.fnExit(_v2_vi_dev);
v2_isp.fnUnregisterAE(_v2_vi_dev, &v2_ae_lib);
v2_isp.fnUnregisterAWB(_v2_vi_dev, &v2_awb_lib);
v2_isp.fnUnregisterAE(_v2_vi_dev, &v2_ae_lib);

v2_snr_drv.fnUnRegisterCallback();

Expand Down Expand Up @@ -476,7 +476,7 @@ int v2_video_create(char index, hal_vidconfig *config)
channel.attrib.jpg.maxPic.width = config->width;
channel.attrib.jpg.maxPic.height = config->height;
channel.attrib.jpg.bufSize =
config->height * config->width * 2;
ALIGN_UP(config->height, 16) * ALIGN_UP(config->width, 16);
channel.attrib.jpg.byFrame = 1;
channel.attrib.jpg.pic.width = config->width;
channel.attrib.jpg.pic.height = config->height;
Expand All @@ -486,8 +486,8 @@ int v2_video_create(char index, hal_vidconfig *config)
channel.attrib.codec = V2_VENC_CODEC_MJPG;
channel.attrib.mjpg.maxPic.width = config->width;
channel.attrib.mjpg.maxPic.height = config->height;
channel.attrib.mjpg.bufSize =
config->height * config->width * 2;
channel.attrib.mjpg.bufSize =
ALIGN_UP(config->height, 16) * ALIGN_UP(config->width, 16);
channel.attrib.mjpg.byFrame = 1;
channel.attrib.mjpg.pic.width = config->width;
channel.attrib.mjpg.pic.height = config->height;
Expand Down Expand Up @@ -568,7 +568,7 @@ int v2_video_create(char index, hal_vidconfig *config)
} else HAL_ERROR("v2_venc", "This codec is not supported by the hardware!");
attrib->maxPic.width = config->width;
attrib->maxPic.height = config->height;
attrib->bufSize = config->height * config->width * 2;
attrib->bufSize = config->height * config->width;
attrib->profile = config->profile;
attrib->byFrame = 1;
attrib->pic.width = config->width;
Expand Down
10 changes: 5 additions & 5 deletions src/hal/hisi/v3_hal.c
Original file line number Diff line number Diff line change
Expand Up @@ -309,8 +309,8 @@ int v3_pipeline_create(void)
void v3_pipeline_destroy(void)
{
v3_isp.fnExit(_v3_vi_dev);
v3_isp.fnUnregisterAE(_v3_vi_dev, &v3_ae_lib);
v3_isp.fnUnregisterAWB(_v3_vi_dev, &v3_awb_lib);
v3_isp.fnUnregisterAE(_v3_vi_dev, &v3_ae_lib);

v3_snr_drv.fnUnRegisterCallback();

Expand Down Expand Up @@ -497,7 +497,7 @@ int v3_video_create(char index, hal_vidconfig *config)
channel.attrib.jpg.maxPic.width = config->width;
channel.attrib.jpg.maxPic.height = config->height;
channel.attrib.jpg.bufSize =
config->height * config->width * 2;
ALIGN_UP(config->height, 16) * ALIGN_UP(config->width, 16);
channel.attrib.jpg.byFrame = 1;
channel.attrib.jpg.pic.width = config->width;
channel.attrib.jpg.pic.height = config->height;
Expand All @@ -507,8 +507,8 @@ int v3_video_create(char index, hal_vidconfig *config)
channel.attrib.codec = V3_VENC_CODEC_MJPG;
channel.attrib.mjpg.maxPic.width = config->width;
channel.attrib.mjpg.maxPic.height = config->height;
channel.attrib.mjpg.bufSize =
config->height * config->width * 2;
channel.attrib.mjpg.bufSize =
ALIGN_UP(config->height, 16) * ALIGN_UP(config->width, 16);
channel.attrib.mjpg.byFrame = 1;
channel.attrib.mjpg.pic.width = config->width;
channel.attrib.mjpg.pic.height = config->height;
Expand Down Expand Up @@ -589,7 +589,7 @@ int v3_video_create(char index, hal_vidconfig *config)
} else HAL_ERROR("v3_venc", "This codec is not supported by the hardware!");
attrib->maxPic.width = config->width;
attrib->maxPic.height = config->height;
attrib->bufSize = config->height * config->width * 2;
attrib->bufSize = config->height * config->width;
attrib->profile = config->profile;
attrib->byFrame = 1;
attrib->pic.width = config->width;
Expand Down
2 changes: 1 addition & 1 deletion src/hal/hisi/v4_hal.c
Original file line number Diff line number Diff line change
Expand Up @@ -358,8 +358,8 @@ int v4_pipeline_create(void)
void v4_pipeline_destroy(void)
{
v4_isp.fnExit(_v4_vi_pipe);
v4_isp.fnUnregisterAE(_v4_vi_pipe, &v4_ae_lib);
v4_isp.fnUnregisterAWB(_v4_vi_pipe, &v4_awb_lib);
v4_isp.fnUnregisterAE(_v4_vi_pipe, &v4_ae_lib);

v4_snr_drv.obj->pfnUnRegisterCallback(_v4_vi_pipe, &v4_ae_lib, &v4_awb_lib);

Expand Down

0 comments on commit 319529e

Please sign in to comment.