基于Hi3559AV100 RFCN实现细节解析-(3)系统输入VI分析一 :
1 SAMPLE_COMM_VI_GetSensorInfo(pstViConfig); 2 //pstViConfig->astViInfo[0].stSnsInfo.enSnsType = SENSOR0_TYPE; 3 4 pstViConfig->s32WorkingViNum = s32ViCnt; 5 6 pstViConfig->as32WorkingViId[0] = 0; 7 pstViConfig->astViInfo[0].stSnsInfo.MipiDev = SAMPLE_COMM_VI_GetComboDevBySensor(pstViConfig->astViInfo[0].stSnsInfo.enSnsType, 0); 8 pstViConfig->astViInfo[0].stSnsInfo.s32BusId = 0; 9 10 pstViConfig->astViInfo[0].stDevInfo.ViDev = ViDev0; 11 pstViConfig->astViInfo[0].stDevInfo.enWDRMode = enWDRMode; 12 13 pstViConfig->astViInfo[0].stPipeInfo.enMastPipeMode = enMastPipeMode; 14 pstViConfig->astViInfo[0].stPipeInfo.aPipe[0] = ViPipe0; 15 pstViConfig->astViInfo[0].stPipeInfo.aPipe[1] = -1; 16 pstViConfig->astViInfo[0].stPipeInfo.aPipe[2] = -1; 17 pstViConfig->astViInfo[0].stPipeInfo.aPipe[3] = -1; 18 19 pstViConfig->astViInfo[0].stChnInfo.ViChn = ViChn; 20 pstViConfig->astViInfo[0].stChnInfo.enPixFormat = enPixFormat; 21 pstViConfig->astViInfo[0].stChnInfo.enDynamicRange = enDynamicRange; 22 pstViConfig->astViInfo[0].stChnInfo.enVideoFormat = enVideoFormat; 23 pstViConfig->astViInfo[0].stChnInfo.enCompressMode = enCompressMode; 24 25 /****************************************** 26 Start vi 27 ******************************************/ 28 s32Ret = SAMPLE_COMM_VI_SetParam(pstViConfig); 29 SAMPLE_CHECK_EXPR_GOTO(HI_SUCCESS != s32Ret, END_INIT_1, 30 "Error(%#x),SAMPLE_COMM_VI_SetParam failed!\n",s32Ret); 31 32 s32Ret = SAMPLE_COMM_VI_StartVi(pstViConfig); 33 SAMPLE_CHECK_EXPR_GOTO(HI_SUCCESS != s32Ret, END_INIT_1, 34 "Error(%#x),SAMPLE_COMM_VI_StartVi failed!\n",s32Ret);
很大一部分都是对pstViConfig结构体进行初始化,配置像素格式、压缩形式等等,其中关键的两个函数为SAMPLE_COMM_VI_SetParam(pstViConfig)和SAMPLE_COMM_VI_StartVi(pstViConfig),二者具体实现见如下所示:
SAMPLE_COMM_VI_SetParam(pstViConfig)具体实现如下功能:
1 //获取 VI,VPSS 的工作模式 2 s32Ret = HI_MPI_SYS_GetVIVPSSMode(&stVIVPSSMode); 3 //设置 VI,VPSS 工作模式。 4 s32Ret = HI_MPI_SYS_SetVIVPSSMode(&stVIVPSSMode);
SAMPLE_COMM_VI_StartVi(pstViConfig)具体实现如下功能:
1 //function : init mipi 2 s32Ret = SAMPLE_COMM_VI_StartMIPI(pstViConfig); 3 4 5 //function :获取VI VPSS的工作模式并设置VI VPSS工作模式 6 s32Ret = SAMPLE_COMM_VI_SetParam(pstViConfig); 7 8 9 10 s32Ret = SAMPLE_COMM_VI_CreateVi(pstViConfig); 11 //涉及下面函数 12 SAMPLE_COMM_VI_CreateSingleVi(pstViInfo); 13 { 14 SAMPLE_COMM_VI_StartDev(pstViInfo); 15 { 16 SAMPLE_COMM_VI_GetDevAttrBySns(enSnsType, &stViDevAttr); 17 //memcpy_s(pstChnAttr, sizeof(VI_CHN_ATTR_S), &CHN_ATTR_4000x3000_420_SDR8_LINEAR, sizeof(VI_CHN_ATTR_S)); 18 19 HI_MPI_VI_SetDevAttr(ViDev, &stViDevAttr); 20 //设置 VI 设备属性。基本设备属性默认了部分芯片配置,满足绝大部分的 sensor 对接要求。 21 22 HI_MPI_VI_EnableDev(ViDev); 23 //启用 VI 设备。 24 } 25 26 SAMPLE_COMM_VI_BindPipeDev(pstViInfo);////we should bind pipe,then creat pipe 27 { 28 HI_MPI_VI_SetDevBindPipe(pstViInfo->stDevInfo.ViDev, &stDevBindPipe); 29 //设置 VI 设备与物理 PIPE 的绑定关系。 30 } 31 32 SAMPLE_COMM_VI_StartViPipe(pstViInfo); 33 { 34 SAMPLE_COMM_VI_GetPipeAttrBySns(pstViInfo->stSnsInfo.enSnsType, &stPipeAttr); 35 //memcpy_s(pstPipeAttr, sizeof(VI_PIPE_ATTR_S), &PIPE_ATTR_4000x3000_RAW12_420_3DNR_RFR, sizeof(VI_PIPE_ATTR_S)); 36 37 s32Ret = HI_MPI_VI_CreatePipe(ViPipe, &stPipeAttr); 38 //创建一个 VI PIPE。 39 } 40 41 SAMPLE_COMM_VI_StartViChn(pstViInfo); 42 { 43 SAMPLE_COMM_VI_GetChnAttrBySns(pstViInfo->stSnsInfo.enSnsType, &stChnAttr); 44 45 HI_MPI_VI_SetChnAttr(ViPipe, ViChn, &stChnAttr); 46 //设置 VI 通道属性。 47 48 HI_MPI_VI_EnableChn(ViPipe, ViChn); 49 //启用 VI 通道。 50 51 } 52 } 53 54 55 //此处有关ISP API接口函数的有关说明将在后面随笔介绍 56 s32Ret = SAMPLE_COMM_VI_CreateIsp(pstViConfig); 57 { 58 SAMPLE_COMM_VI_StartIsp(pstViInfo); 59 { 60 SAMPLE_COMM_ISP_GetIspAttrBySns(pstViInfo->stSnsInfo.enSnsType, &stPubAttr); 61 62 SAMPLE_COMM_ISP_Sensor_Regiter_callback(ViPipe, u32SnsId); 63 64 SAMPLE_COMM_ISP_BindSns(ViPipe, u32SnsId, pstViInfo->stSnsInfo.enSnsType, -1); 65 66 SAMPLE_COMM_ISP_Aelib_Callback(ViPipe); 67 68 SAMPLE_COMM_ISP_Awblib_Callback(ViPipe); 69 70 HI_MPI_ISP_MemInit(ViPipe); 71 72 HI_MPI_ISP_SetPubAttr(ViPipe, &stPubAttr); 73 74 HI_MPI_ISP_Init(ViPipe); 75 76 SAMPLE_COMM_ISP_GetSnsObj(u32SnsId); 77 78 SAMPLE_COMM_ISP_Run(&pstViInfo->stPipeInfo.aPipe[i]); 79 80 } 81 }
整个的RFCN VI实现过程如上所示,函数具体含义也通过注释进行了一一的说明,而在VI初始化过程中,用到了ISP(Image Signal Processing) 图像信号处理的相关知识,海思也为其定义了API接口,随后随笔将介绍ISP相关概念,方便大家对VI整个过程进行了更为清晰的认识。