osdrv: weekly rls 2024.06.6

-36b886, add CVI_SYS_IsInit & CVI_VB_IsInit api.
-f57fbd, comm_pool_cnt = 0 allowed when CVI_VB_SetConfig.
-512cf1, Fix sys flush cache op.
-b0f503, CVI_VENC_RequestIDR, use instant parameter as reset gop flag.
-40441e, add gridinfo framework.

Change-Id: Ia4c85f52d57d02409cc893ac492194102c63341e
This commit is contained in:
sophgo-forum-service
2024-06-06 15:20:12 +08:00
committed by carbon
parent 5ec5f7889a
commit b94e342d8a
15 changed files with 102 additions and 33 deletions

View File

@ -139,8 +139,7 @@ static int32_t _vb_set_config(struct cvi_vb_cfg *vb_cfg)
{
int i;
if (vb_cfg->comm_pool_cnt > VB_COMM_POOL_MAX_CNT
|| vb_cfg->comm_pool_cnt == 0) {
if (vb_cfg->comm_pool_cnt > VB_COMM_POOL_MAX_CNT) {
CVI_TRACE_BASE(CVI_BASE_DBG_ERR, "Invalid comm_pool_cnt(%d)\n", vb_cfg->comm_pool_cnt);
return -EINVAL;
}
@ -1164,6 +1163,14 @@ long vb_ctrl(struct vb_ext_control *p)
}
#endif
case VB_IOCTL_GET_VB_INIT:
{
p->value = atomic_read(&ref_count);
ret = 0;
break;
}
default:
break;
}

View File

@ -3312,7 +3312,7 @@ CVI_S32 CVI_VENC_GetStream(VENC_CHN VeChn, VENC_STREAM_S *pstStream,
}
#if (KERNEL_VERSION(5, 10, 0) <= LINUX_VERSION_CODE) && defined(__riscv)
pstStream->pstPack = vmalloc(sizeof(VENC_PACK_S) * _cviGetNumPacks(pChnAttr->stVencAttr.enType));
pstStream->pstPack = vzalloc(sizeof(VENC_PACK_S) * _cviGetNumPacks(pChnAttr->stVencAttr.enType));
if (pstStream->pstPack == NULL)
return CVI_ERR_VENC_NOMEM;
#endif

View File

@ -726,6 +726,11 @@ int cviPutEsInPack(stTestEncoder *pTestEnc, PhysicalAddress paBsBufStart,
return FALSE;
}
}
if (cviNalType == NAL_I || cviNalType == NAL_IDR) {
pTestEnc->encParam.idr_request = TRUE;
}
psp->dropCnt++;
psp->seq++;
MUTEX_UNLOCK(&psp->packMutex);

View File

@ -977,6 +977,7 @@ static int initEncOneFrame(stTestEncoder *pTestEnc, TestEncConfig *pEncConfig)
pTestEnc->encParam.codeOption.encodeAUD = pEncCfg->encAUD;
pTestEnc->encParam.codeOption.encodeEOS = 0;
pTestEnc->encParam.force_i_for_gop_sync = 1;
CVI_VC_TRACE("ringBufferEnable = %d\n",
pEncOP->ringBufferEnable);
@ -1202,6 +1203,12 @@ RETRY:
pEncParam->is_idr_frame = cviCheckIdrPeriod(pTestEnc);
if (pEncParam->idr_request && pEncParam->resetGop) {
pTestEnc->frameIdx = 0;
pEncParam->resetGop = 0;
CVI_VC_FLOW("reset gop, frameIdx = %d\n", pTestEnc->frameIdx);
}
#ifdef DROP_FRAME
// because bitstream not enough, need request IDR and reduce target bitrate
if (pTestEnc->bDrop) {
@ -1596,10 +1603,11 @@ static BOOL cviCheckIdrValid(EncOpenParam *pEncOP, Uint32 frameIdx)
}
static void cviForcePicTypeCtrl(EncOpenParam *pEncOP, EncParam *encParam,
EncInfo *pEncInfo, BOOL is_intra_period,
BOOL force_idr, BOOL force_skip_frame,
Uint32 frameIdx)
EncInfo *pEncInfo, BOOL force_skip_frame, Uint32 frameIdx)
{
int force_idr = encParam->idr_request;
int is_intra_period = encParam->is_i_period;
encParam->skipPicture = 0;
encParam->forceIPicture = 0;
encParam->forcePicTypeEnable = 0;
@ -1619,7 +1627,12 @@ static void cviForcePicTypeCtrl(EncOpenParam *pEncOP, EncParam *encParam,
(is_intra_period && encParam->force_i_for_gop_sync)) {
if (pEncOP->bitstreamFormat == STD_HEVC) {
encParam->forcePicTypeEnable = 1;
encParam->forcePicType = 3;
encParam->forcePicType =
(pEncOP->EncStdParam.hevcParam.decodingRefreshType == H265_RT_IDR) ? 3 : 4;
// first frame and request idr frame should be idr
if (frameIdx == 0) {
encParam->forcePicType = 3;
}
} else { // encOP->bitstreamFormat == STD_AVC
encParam->forceIPicture = 1;
pEncInfo->force_as_long_term_ref = 1;
@ -1730,7 +1743,6 @@ static void cviPicParamChangeCtrl(EncHandle handle, TestEncConfig *pEncConfig,
}
cviForcePicTypeCtrl(pEncOP, encParam, &handle->CodecInfo->encInfo,
encParam->is_i_period, encParam->idr_request,
force_skip_frame, frameIdx);
} while (0);
@ -2970,12 +2982,15 @@ int cviVEncGetStream(void *handle, cviVEncStreamInfo *pStreamInfo,
CVI_VC_IF("\n");
if (pTestEnc->encConfig.bIsoSendFrmEn) {
wait:
ret = wait_for_completion_timeout(&pTestEnc->semGetStreamCmd,
usecs_to_jiffies(s32MilliSec * 1000));
if (ret == 0) {
CVI_VC_WARN("get stream timeout!\n");
return RET_VCODEC_TIMEOUT;
}
if (0 == pTestEnc->streamPack.totalPacks)
goto wait;
memcpy(pStreamInfo, &pTestEnc->tStreamInfo, sizeof(cviVEncStreamInfo));
return RETCODE_SUCCESS;
}
@ -3315,13 +3330,13 @@ int cviVEncReleaseStream(void *handle, cviVEncStreamInfo *pStreamInfo)
static int cviVEncSetRequestIDR(stTestEncoder *pTestEnc, void *arg)
{
unsigned int *resetGop = (unsigned int *)arg;
int ret = 0;
UNREFERENCED_PARAMETER(arg);
CVI_VC_IF("\n");
pTestEnc->encParam.idr_request = TRUE;
pTestEnc->encParam.resetGop = *resetGop;
return ret;
}

View File

@ -5047,6 +5047,7 @@ packet-based streaming with ring-buffer, this variable is ignored.
/*
* A flag to use a force picture type
* by source index order
* 0 : I, 1 : P, 2 : B, 3 : IDR, 4 : CRA
*/
int forcePicType; /**< A force picture type (I, P, B, IDR, CRA) */
int srcIdx; /**< A source frame buffer index */
@ -5089,6 +5090,7 @@ packet-based streaming with ring-buffer, this variable is ignored.
BOOL is_i_period;
BOOL idr_registered;
BOOL force_i_for_gop_sync;
BOOL resetGop;
BOOL roi_request;
BOOL roi_enable[8];

View File

@ -1001,7 +1001,7 @@ RetCode Wave4VpuEncSetup(CodecInst *instance)
VpuWriteReg(coreIdx, W4_CMD_ENC_SEQ_INTRA_PARAM,
(pHevc->decodingRefreshType << 0) | (pHevc->intraQP << 3) |
(pHevc->forcedIdrHeaderEnable << 9) |
(pHevc->intraPeriod << 16));
(0 << 16));
VpuWriteReg(coreIdx, W4_CMD_ENC_SEQ_CONF_WIN_TOP_BOT,
pHevc->confWinBot << 16 | pHevc->confWinTop);

View File

@ -98,6 +98,7 @@ void ldc_intr_ctrl(u8 intr_mask)
void ldc_intr_clr(u8 intr_mask)
{
_reg_write(reg_base + REG_LDC_IRQCLR, intr_mask);
_reg_write(reg_base + REG_LDC_SRC_BG, 0x0);
}
/**

View File

@ -276,6 +276,7 @@ static s32 mesh_gdc_do_ldc(struct cvi_dwa_vdev *wdev, const void *pUsageParam,
SIZE_S size_out[2];
ROTATION_E enRotationOut[2];
u32 mesh_1st_size;
LDC_ATTR_S *pstLDCAttr = NULL;
pstTask[0] = vmalloc(sizeof(struct gdc_task_attr));
pstTask[1] = vmalloc(sizeof(struct gdc_task_attr));
@ -288,6 +289,7 @@ static s32 mesh_gdc_do_ldc(struct cvi_dwa_vdev *wdev, const void *pUsageParam,
blk = vb_get_block_with_id(VB_INVALID_POOLID, buf_size, CVI_ID_GDC);
if (blk == VB_INVALID_HANDLE) {
vb_release_block((VB_BLK)vb_in);
CVI_TRACE_DWA(CVI_DBG_ERR, "vb_get_block failed.\n");
ret = CVI_ERR_GDC_NOBUF;
goto LDC_FAIL_EXIT;
}
@ -319,8 +321,14 @@ static s32 mesh_gdc_do_ldc(struct cvi_dwa_vdev *wdev, const void *pUsageParam,
switch (enRotation) {
default:
case ROTATION_0:
enRotationOut[0] = ROTATION_90;
enRotationOut[1] = ROTATION_270;
pstLDCAttr = (LDC_ATTR_S *)pUsageParam;
if (pstLDCAttr->stGridInfoAttr.Enable) {
enRotationOut[0] = ROTATION_270;
enRotationOut[1] = ROTATION_90;
} else {
enRotationOut[0] = ROTATION_90;
enRotationOut[1] = ROTATION_270;
}
break;
case ROTATION_90:
enRotationOut[0] = ROTATION_90;

View File

@ -269,7 +269,8 @@ int dwa_create_instance(struct platform_device *pdev)
// clk_ldc_src_sel default 1(clk_src_vip_sys_2), 600 MHz
// set 0(clk_src_vip_sys_4), 400MHz for ND
vip_sys_reg_write_mask(VIP_SYS_VIP_CLK_CTRL1, BIT(20), 0);
vip_sys_reg_write_mask(VIP_SYS_VIP_CLK_CTRL1, BIT(20), BIT(20));
CVI_TRACE_DWA(CVI_DBG_DEBUG, "VIP_SYS_VIP_CLK_CTRL1:%#x\n", vip_sys_reg_read(VIP_SYS_VIP_CLK_CTRL1));
//wdev->align = LDC_ADDR_ALIGN;
@ -321,9 +322,12 @@ void dwa_irq_handler(u8 intr_status, struct cvi_dwa_vdev *wdev)
{
struct cvi_dwa_job *job = NULL;
struct gdc_task *tsk;
unsigned long flags;
spin_lock_irqsave(&wdev->lock, flags);
if (!list_empty(&wdev->jobq))
job = list_entry(wdev->jobq.next, struct cvi_dwa_job, node);
spin_unlock_irqrestore(&wdev->lock, flags);
if (job) {
if (!list_empty(&job->task_list)) {

View File

@ -444,6 +444,18 @@ typedef struct _BITMAP_S {
CVI_VOID * ATTRIBUTE pData;
} BITMAP_S;
typedef struct _GRID_INFO_ATTR_S {
CVI_BOOL Enable;
char gridFileName[128];
char gridBindName[128];
CVI_BOOL isBlending;
CVI_BOOL bEISEnable; /* enable EIS */
uint8_t homoRgnNum;
#if 0
HOMOGRAPH_REGION_S homo_regions[GDC_MAX_REGION_NUM];
#endif
} GRID_INFO_ATTR_S;
/*
*
* s32CenterXOffset: RW; Range: [-511, 511], horizontal offset of the image distortion center relative to image center
@ -454,12 +466,13 @@ typedef struct _BITMAP_S {
// ++++++++ If you want to change these interfaces, please contact the isp team. ++++++++
typedef struct _LDC_ATTR_S {
CVI_BOOL bAspect; /* RW;Whether aspect ration is keep */
CVI_S32 s32XRatio; /* RW; Range: [0x00, 0x64], field angle ration of horizontal,valid when bAspect=0.*/
CVI_S32 s32YRatio; /* RW; Range: [0x00, 0x64], field angle ration of vertical,valid when bAspect=0.*/
CVI_S32 s32XYRatio; /* RW; Range: [0x00, 0x64], field angle ration of all,valid when bAspect=1.*/
CVI_S32 s32CenterXOffset; /* RW; Range: [-0x1FF, 0x1FF]*/
CVI_S32 s32CenterYOffset; /* RW; Range: [-0x1FF, 0x1FF]*/
CVI_S32 s32DistortionRatio; /* RW; Range:[-0x12C, 0x1F4]*/
CVI_S32 s32XRatio; /* RW; Range: [0, 100], field angle ration of horizontal,valid when bAspect=0.*/
CVI_S32 s32YRatio; /* RW; Range: [0, 100], field angle ration of vertical,valid when bAspect=0.*/
CVI_S32 s32XYRatio; /* RW; Range: [0, 100], field angle ration of all,valid when bAspect=1.*/
CVI_S32 s32CenterXOffset;
CVI_S32 s32CenterYOffset;
CVI_S32 s32DistortionRatio;
GRID_INFO_ATTR_S stGridInfoAttr;
} LDC_ATTR_S;
// -------- If you want to change these interfaces, please contact the isp team. --------

View File

@ -25,6 +25,7 @@ enum VB_IOCTL {
VB_IOCTL_GET_POOL_MAX_CNT,
VB_IOCTL_PRINT_POOL,
VB_IOCTL_UNIT_TEST,
VB_IOCTL_GET_VB_INIT,
VB_IOCTL_MAX,
};

View File

@ -2863,7 +2863,9 @@ int vi_start_streaming(struct cvi_vi_dev *vdev)
}
_vi_mempool_reset();
vi_tuning_buf_clear();
vi_tuning_buf_setup(ctx);
vi_tuning_buf_clear(ctx);
_vi_scene_ctrl(vdev, &raw_max);
@ -4734,7 +4736,6 @@ static int _vi_mempool_setup(void)
int ret = 0;
_vi_mempool_reset();
ret = vi_tuning_buf_setup();
return ret;
}
@ -5588,12 +5589,16 @@ static long _vi_g_ctrl(struct cvi_vi_dev *vdev, struct vi_ext_control *p)
void *tun_addr = NULL;
u32 size;
rc = vi_tuning_buf_setup(ctx);
tun_addr = vi_get_tuning_buf_addr(&size);
if (copy_to_user(p->ptr, tun_addr, size) != 0)
if (copy_to_user(p->ptr, tun_addr, size) != 0) {
vi_pr(VI_ERR, "Failed to copy tun_addr\n");
rc = -EINVAL;
break;
}
rc = 0;
break;
}
@ -8157,7 +8162,7 @@ int vi_destroy_instance(struct platform_device *pdev)
for (i = 0; i < E_VI_TH_MAX; i++)
vi_destory_thread(vdev, i);
vi_tuning_buf_release();
vi_tuning_buf_release(&vdev->ctx);
for (i = 0; i < ISP_PRERAW_VIRT_MAX; i++) {
sync_task_exit(i);

View File

@ -727,10 +727,10 @@ void vi_tuning_clut_update(
enum cvi_isp_raw raw_num);
int vi_tuning_get_clut_tbl_idx(enum cvi_isp_raw raw_num, int tun_idx);
int vi_tuning_sw_init(void);
int vi_tuning_buf_setup(void);
void vi_tuning_buf_release(void);
int vi_tuning_buf_setup(struct isp_ctx *ctx);
void vi_tuning_buf_release(struct isp_ctx *ctx);
void *vi_get_tuning_buf_addr(u32 *size);
void vi_tuning_buf_clear(void);
void vi_tuning_buf_clear(struct isp_ctx *ctx);
/*******************************************************************************
* Tuning modules update

View File

@ -217,20 +217,22 @@ int vi_tuning_sw_init(void)
return 0;
}
int vi_tuning_buf_setup(void)
int vi_tuning_buf_setup(struct isp_ctx *ctx)
{
u8 i = 0;
static u64 fe_paddr[ISP_PRERAW_VIRT_MAX] = {0, 0};
static u64 be_paddr[ISP_PRERAW_VIRT_MAX] = {0, 0};
static u64 post_paddr[ISP_PRERAW_VIRT_MAX] = {0, 0};
u32 size = 0;
u64 phyAddr = 0;
size = (VI_ALIGN(sizeof(struct cvi_vip_isp_post_cfg)) +
VI_ALIGN(sizeof(struct cvi_vip_isp_be_cfg)) +
VI_ALIGN(sizeof(struct cvi_vip_isp_fe_cfg)));
for (i = 0; i < ISP_PRERAW_VIRT_MAX; i++) {
u64 phyAddr = 0;
if (!ctx->isp_pipe_enable[i])
continue;
if (vi_tuning_ptr[i] == NULL) {
vi_tuning_ptr[i] = kzalloc(size, GFP_KERNEL | __GFP_RETRY_MAYFAIL);
@ -270,11 +272,14 @@ int vi_tuning_buf_setup(void)
return 0;
}
void vi_tuning_buf_release(void)
void vi_tuning_buf_release(struct isp_ctx *ctx)
{
u8 i;
for (i = 0; i < ISP_PRERAW_VIRT_MAX; i++) {
if (!ctx->isp_pipe_enable[i])
continue;
kfree(vi_tuning_ptr[i]);
vi_tuning_ptr[i] = NULL;
}
@ -287,7 +292,7 @@ void *vi_get_tuning_buf_addr(u32 *size)
return (void *)&tuning_buf_addr;
}
void vi_tuning_buf_clear(void)
void vi_tuning_buf_clear(struct isp_ctx *ctx)
{
struct cvi_vip_isp_post_cfg *post_cfg;
struct cvi_vip_isp_be_cfg *be_cfg;
@ -295,6 +300,9 @@ void vi_tuning_buf_clear(void)
u8 i = 0, tun_idx = 0;
for (i = 0; i < ISP_PRERAW_VIRT_MAX; i++) {
if (!ctx->isp_pipe_enable[i])
continue;
post_cfg = (struct cvi_vip_isp_post_cfg *)tuning_buf_addr.post_vir[i];
be_cfg = (struct cvi_vip_isp_be_cfg *)tuning_buf_addr.be_vir[i];
fe_cfg = (struct cvi_vip_isp_fe_cfg *)tuning_buf_addr.fe_vir[i];