int mpp_system_init(void) { HI_S32 s32Ret; MPP_SYS_CONF_S stSysConf = {0}; VB_CONF_S stVbConf ={0}; static int mpp_inited = 0; if(mpp_inited == 1) { msg_dbg("Mpp system have inited!\n"); return 0; } HI_MPI_SYS_Exit(); HI_MPI_VB_Exit(); // stVbConf.u32MaxPoolCnt = 128; stVbConf.astCommPool[0].u32BlkSize = 720 * 576 * 4; stVbConf.astCommPool[0].u32BlkCnt = 20; s32Ret = HI_MPI_VB_SetConf(&stVbConf); if (HI_SUCCESS != s32Ret) { printf("HI_MPI_VB_SetConf failed 0x%x!\n",s32Ret); return -1; } s32Ret = HI_MPI_VB_Init(); if(HI_SUCCESS != s32Ret) { printf("HI_MPI_VB_Init failed 0x%x!\n",s32Ret); return -1; } stSysConf.u32AlignWidth = 16; s32Ret = HI_MPI_SYS_SetConf(&stSysConf); if (HI_SUCCESS != s32Ret) { HI_MPI_VB_Exit(); printf("conf : system config failed 0x%x!\n",s32Ret); return -1; } s32Ret = HI_MPI_SYS_Init(); if(HI_SUCCESS != s32Ret) { HI_MPI_VB_Exit(); printf("HI_MPI_SYS_Init err 0x%x\n",s32Ret); return -1; } mpp_inited = 1; return 0; }
HI_S32 SampleSysInit(HI_VOID) { HI_S32 s32Ret; MPP_SYS_CONF_S stSysConf = {0}; VB_CONF_S stVbConf ={0}; HI_MPI_SYS_Exit(); HI_MPI_VB_Exit(); stVbConf.u32MaxPoolCnt = 64; stVbConf.astCommPool[0].u32BlkSize = 768*576*2; stVbConf.astCommPool[0].u32BlkCnt = 20; stVbConf.astCommPool[1].u32BlkSize = 384*288*2; stVbConf.astCommPool[1].u32BlkCnt = 40; s32Ret = HI_MPI_VB_SetConf(&stVbConf); if (HI_SUCCESS != s32Ret) { printf("HI_MPI_VB_SetConf failed 0x%x!\n",s32Ret); return HI_FAILURE; } s32Ret = HI_MPI_VB_Init(); if(HI_SUCCESS != s32Ret) { printf("HI_MPI_VB_Init failed 0x%x!\n",s32Ret); return HI_FAILURE; } stSysConf.u32AlignWidth = 64; s32Ret = HI_MPI_SYS_SetConf(&stSysConf); if (HI_SUCCESS != s32Ret) { HI_MPI_VB_Exit(); printf("conf : system config failed 0x%x!\n",s32Ret); return HI_FAILURE; } s32Ret = HI_MPI_SYS_Init(); if(HI_SUCCESS != s32Ret) { HI_MPI_VB_Exit(); printf("HI_MPI_SYS_Init err 0x%x\n",s32Ret); return HI_FAILURE; } return HI_SUCCESS; }
static int _mem_init() { //printf("Init hisi mpp sys & vb\n"); MPP_SYS_CONF_S stSysConf = {0}; stSysConf.u32AlignWidth = MPP_SYS_ALIGN_WIDTH; VB_CONF_S stVbConf; memset(&stVbConf,0,sizeof(VB_CONF_S)); unsigned int u32BlkSize; stVbConf.u32MaxPoolCnt = 128; SIZE_S size; size.u32Height = 1088; size.u32Width = 1920; u32BlkSize = calc_pic_vb_blk_size(&size, PIXEL_FORMAT_YUV_SEMIPLANAR_420, MPP_SYS_ALIGN_WIDTH); stVbConf.astCommPool[0].u32BlkSize = u32BlkSize; stVbConf.astCommPool[0].u32BlkCnt = 15; CHECK_RET(HI_MPI_VB_Exit(),"HI_MPI_VB_Exit"); CHECK_RET(HI_MPI_SYS_Exit(),"HI_MPI_SYS_Exit"); CHECK_RET(HI_MPI_VB_SetConf(&stVbConf),"HI_MPI_VB_SetConf"); CHECK_RET(HI_MPI_VB_Init(),"HI_MPI_VB_Init"); CHECK_RET(HI_MPI_SYS_SetConf(&stSysConf),"HI_MPI_SYS_SetConf"); CHECK_RET(HI_MPI_SYS_Init(),"HI_MPI_SYS_Init"); return HI_SUCCESS; }
bool HimppSysctl::disableObject() { HI_MPI_SYS_Exit(); HI_MPI_VB_Exit(); return true; }
bool HimppSysctl::enableObject() { HI_S32 s32Ret = HI_FAILURE; HI_MPI_SYS_Exit(); HI_MPI_VB_Exit(); VB_CONF_S vbconf; memset(&vbconf, 0, sizeof(vbconf)); vbconf.u32MaxPoolCnt = maxPoolCount; int i = 0; for (auto &b : buffers) { vbconf.astCommPool[i].u32BlkSize = b.blksiz; vbconf.astCommPool[i].u32BlkCnt = b.blkcnt; i++; } s32Ret = HI_MPI_VB_SetConf(&vbconf); if (s32Ret != HI_SUCCESS) { return HI_FAILURE; } s32Ret = HI_MPI_VB_Init(); if (s32Ret != HI_SUCCESS) { return HI_FAILURE; } MPP_SYS_CONF_S sysconf = { .u32AlignWidth = alignWidth }; s32Ret = HI_MPI_SYS_SetConf(&sysconf); if (s32Ret != HI_SUCCESS) { goto err_vb_cleanup; } s32Ret = HI_MPI_SYS_Init(); if (s32Ret != HI_SUCCESS) { goto err_vb_cleanup; } return true; err_vb_cleanup: HI_MPI_VB_Exit(); return false; }
static HI_S32 SAMPLE_IVE_MPI_Init(HI_VOID) { HI_S32 s32Ret; VB_CONF_S struVbConf; MPP_SYS_CONF_S struSysConf; HI_MPI_SYS_Exit(); HI_MPI_VB_Exit(); memset(&struVbConf,0,sizeof(VB_CONF_S)); struVbConf.u32MaxPoolCnt = 128; struVbConf.astCommPool[0].u32BlkSize = 1920*1080*3/2; struVbConf.astCommPool[0].u32BlkCnt = 4; s32Ret = HI_MPI_VB_SetConf(&struVbConf); if (HI_SUCCESS != s32Ret) { SAMPLE_PRT("HI_MPI_VB_SetConf fail,Error(%#x)\n",s32Ret); return s32Ret; } s32Ret = HI_MPI_VB_Init(); if (HI_SUCCESS != s32Ret) { SAMPLE_PRT("HI_MPI_VB_Init fail,Error(%#x)\n",s32Ret); return s32Ret; } struSysConf.u32AlignWidth = 64; s32Ret = HI_MPI_SYS_SetConf(&struSysConf); if (HI_SUCCESS != s32Ret) { SAMPLE_PRT("HI_MPI_SYS_SetConf fail,Error(%#x)\n",s32Ret); (HI_VOID)HI_MPI_VB_Exit(); return s32Ret; } s32Ret = HI_MPI_SYS_Init(); if (HI_SUCCESS != s32Ret) { SAMPLE_PRT("HI_MPI_SYS_Init fail,Error(%#x)\n",s32Ret); (HI_VOID)HI_MPI_VB_Exit(); return s32Ret; } return HI_SUCCESS; }
/* function to process abnormal case */ HI_VOID HandleSig(HI_S32 signo) { if (SIGINT == signo || SIGTSTP == signo) { (HI_VOID)HI_MPI_SYS_Exit(); (HI_VOID)HI_MPI_VB_Exit(); printf("\033[0;31mprogram exit abnormally!\033[0;39m\n"); } exit(0); }
HI_S32 PCIV_Slave_SysInit() { HI_S32 s32Ret, i; MPP_SYS_CONF_S stSysConf = {0}; VB_CONF_S stVbConf = {0}; VI_PUB_ATTR_S stviAttr; VO_PUB_ATTR_S stvoAttr; HI_MPI_SYS_Exit(); HI_MPI_VB_Exit(); stVbConf.u32MaxPoolCnt = 128; stVbConf.astCommPool[0].u32BlkSize = 884736;/* 768*576*1.5*/ stVbConf.astCommPool[0].u32BlkCnt = 20; stVbConf.astCommPool[1].u32BlkSize = 221184;/* 384*288*1.5*/ stVbConf.astCommPool[1].u32BlkCnt = 60; s32Ret = HI_MPI_VB_SetConf(&stVbConf); HI_ASSERT((HI_SUCCESS == s32Ret)); s32Ret = HI_MPI_VB_Init(); HI_ASSERT((HI_SUCCESS == s32Ret)); stSysConf.u32AlignWidth = 64; s32Ret = HI_MPI_SYS_SetConf(&stSysConf); HI_ASSERT((HI_SUCCESS == s32Ret)); s32Ret = HI_MPI_SYS_Init(); HI_ASSERT((HI_SUCCESS == s32Ret)); /* Enable VI device*/ memset(&stviAttr,0,sizeof(VI_PUB_ATTR_S)); stviAttr.enInputMode = VI_MODE_BT656; stviAttr.enWorkMode = VI_WORK_MODE_2D1; stviAttr.u32AdType = AD_2815; stviAttr.enViNorm = VIDEO_ENCODING_MODE_PAL; for (i = 0; i < VIU_MAX_DEV_NUM; i++) { s32Ret = HI_MPI_VI_SetPubAttr(i, &stviAttr); HI_ASSERT((HI_SUCCESS == s32Ret)); s32Ret = HI_MPI_VI_Enable(i); HI_ASSERT((HI_SUCCESS == s32Ret)); } /* Enable VO device*/ stvoAttr.stTvConfig.stComposeMode = VIDEO_ENCODING_MODE_PAL; stvoAttr.u32BgColor = 0x000000; s32Ret = HI_MPI_VO_SetPubAttr(&stvoAttr); HI_ASSERT((HI_SUCCESS == s32Ret)); s32Ret = HI_MPI_VO_Enable(); HI_ASSERT((HI_SUCCESS == s32Ret)); return HI_SUCCESS; }
HI_S32 SampleSysInit(MPP_SYS_CONF_S * pstSysConf,VB_CONF_S* pstVbConf) { HI_S32 s32Ret; HI_MPI_SYS_Exit(); HI_MPI_VB_Exit(); s32Ret = HI_MPI_VB_SetConf(pstVbConf); if (HI_SUCCESS != s32Ret) { printf("HI_MPI_VB_SetConf failed 0x%x!\n",s32Ret); return HI_FAILURE; } s32Ret = HI_MPI_VB_Init(); if(HI_SUCCESS != s32Ret) { printf("HI_MPI_VB_Init failed 0x%x!\n",s32Ret); return HI_FAILURE; } s32Ret = HI_MPI_SYS_SetConf(pstSysConf); if (HI_SUCCESS != s32Ret) { HI_MPI_VB_Exit(); printf("conf : system config failed 0x%x!\n",s32Ret); return HI_FAILURE; } s32Ret = HI_MPI_SYS_Init(); if(HI_SUCCESS != s32Ret) { HI_MPI_VB_Exit(); printf("HI_MPI_SYS_Init err 0x%x\n",s32Ret); return HI_FAILURE; } return HI_SUCCESS; }
HI_VOID SampleSysExit(HI_VOID) { HI_S32 s32Ret; s32Ret = HI_MPI_SYS_Exit(); if (HI_SUCCESS != s32Ret) { printf("HI_MPI_SYS_Exit 0x%x!\n",s32Ret); } s32Ret = HI_MPI_VB_Exit(); if (HI_SUCCESS != s32Ret) { printf("HI_MPI_VB_Exit 0x%x!\n",s32Ret); } }
int mpp_system_deinit(void) { if (HI_MPI_SYS_Exit()) { printf("sys exit fail\n"); return -1; } if (HI_MPI_VB_Exit()) { printf("vb exit fail\n"); return -1; } return 0; }
HI_S32 SAMPLE_COMM_IVE_IveMpiExit(HI_VOID) { bMpiInit = HI_FALSE; if (HI_MPI_SYS_Exit()) { SAMPLE_PRT("Sys exit failed!\n"); return HI_FAILURE; } if (HI_MPI_VB_Exit()) { SAMPLE_PRT("Vb exit failed!\n"); return HI_FAILURE; } return HI_SUCCESS; }
void ipcam_media_sys_ctrl_init_media_system(IpcamMediaSysCtrl *self) { VB_CONF_S stVbConf; MPP_SYS_CONF_S stSysConf = {0}; HI_S32 s32Ret = HI_FAILURE; memset(&stVbConf, 0, sizeof(VB_CONF_S)); stVbConf.u32MaxPoolCnt = VB_MAX_POOLS; stVbConf.astCommPool[0].u32BlkSize = (CEILING_2_POWER(IMAGE_MAX_WIDTH, SYS_ALIGN_WIDTH) * \ CEILING_2_POWER(IMAGE_MAX_HEIGHT, SYS_ALIGN_WIDTH) * \ 2); stVbConf.astCommPool[0].u32BlkCnt = 12; memset(stVbConf.astCommPool[0].acMmzName, 0, sizeof(stVbConf.astCommPool[0].acMmzName)); HI_MPI_SYS_Exit(); HI_MPI_VB_Exit(); s32Ret = HI_MPI_VB_SetConf(&stVbConf); if (HI_SUCCESS != s32Ret) { g_critical("HI_MPI_VB_SetConf failed with %#x!\n", s32Ret); return; } s32Ret = HI_MPI_VB_Init(); if (HI_SUCCESS != s32Ret) { g_critical("HI_MPI_VB_Init failed with %#x!\n", s32Ret); return; } stSysConf.u32AlignWidth = SYS_ALIGN_WIDTH; s32Ret = HI_MPI_SYS_SetConf(&stSysConf); if (HI_SUCCESS != s32Ret) { g_critical("HI_MPI_SYS_SetConf failed with %#x!\n", s32Ret); return; } s32Ret = HI_MPI_SYS_Init(); if (HI_SUCCESS != s32Ret) { g_critical("HI_MPI_SYS_Init failed with %#x!\n", s32Ret); return; } }
/****************************************************************************** * function : vb init & MPI system init ******************************************************************************/ HI_S32 SAMPLE_COMM_SYS_Init(VB_CONF_S *pstVbConf) { MPP_SYS_CONF_S stSysConf = {0}; HI_S32 s32Ret = HI_FAILURE; HI_MPI_SYS_Exit(); HI_MPI_VB_Exit(); if (NULL == pstVbConf) { SAMPLE_PRT("input parameter is null, it is invaild!\n"); return HI_FAILURE; } s32Ret = HI_MPI_VB_SetConf(pstVbConf); if (HI_SUCCESS != s32Ret) { SAMPLE_PRT("HI_MPI_VB_SetConf failed!\n"); return HI_FAILURE; } s32Ret = HI_MPI_VB_Init(); if (HI_SUCCESS != s32Ret) { SAMPLE_PRT("HI_MPI_VB_Init failed!\n"); return HI_FAILURE; } stSysConf.u32AlignWidth = SAMPLE_SYS_ALIGN_WIDTH; s32Ret = HI_MPI_SYS_SetConf(&stSysConf); if (HI_SUCCESS != s32Ret) { SAMPLE_PRT("HI_MPI_SYS_SetConf failed\n"); return HI_FAILURE; } s32Ret = HI_MPI_SYS_Init(); if (HI_SUCCESS != s32Ret) { SAMPLE_PRT("HI_MPI_SYS_Init failed!\n"); return HI_FAILURE; } return HI_SUCCESS; }
int framework_init () { VB_CONF_S stVbConf; MPP_SYS_CONF_S stSysConf = {0}; HI_S32 ret = HI_FAILURE; int result = FAILURE; HI_MPI_SYS_Exit (); HI_MPI_VB_Exit (); memset (&stVbConf, 0x00, sizeof (stVbConf)); ret = HI_MPI_VB_SetConf (&stVbConf); if (ret != HI_SUCCESS) { printf ("HI_MPI_VB_SetConf Eorr[%x]\n", ret); return result; } ret = HI_MPI_VB_Init (); if (ret != HI_SUCCESS) { printf ("HI_MPI_VB_Init Eorr[%x]\n", ret); return result; } stSysConf.u32AlignWidth = 64; ret = HI_MPI_SYS_SetConf (&stSysConf); if (ret != HI_SUCCESS) { printf ("HI_MPI_SYS_SetConf Eorr[%x]\n", ret); return result; } ret = HI_MPI_SYS_Init (); if (ret != HI_SUCCESS) { printf ("HI_MPI_SYS_Init Eorr[%x]\n", ret); return result; } result = SUCCESS; return result; }
/****************************************************************************** * function : vb exit & MPI system exit ******************************************************************************/ HI_VOID SAMPLE_COMM_SYS_Exit(void) { HI_MPI_SYS_Exit(); HI_MPI_VB_Exit(); return; }
/***************************************************************************** Prototype : main Description : main entry Input : argc : "reset", "N", "n" is optional. argv[] : 0 or 1 is optional Output : None Return Value : Global Variable Read Only : Read & Write : History 1.Date : 2008/8/30 Author : x00100808 Modification : Created function *****************************************************************************/ int main(int argc, char *argv[]) { char ch; /* configure for vi2vo preview */ MPP_SYS_CONF_S stSysConf = {0}; VB_CONF_S stVbConf ={0}; stVbConf.u32MaxPoolCnt = 64; stVbConf.astCommPool[0].u32BlkSize = 768*576*2; stVbConf.astCommPool[0].u32BlkCnt = 20; stVbConf.astCommPool[1].u32BlkSize = 384*288*2; stVbConf.astCommPool[1].u32BlkCnt = 60; stSysConf.u32AlignWidth = 64; if (argc > 1) { /* if program can not run anymore, you may try 'reset' adhere command */ if (!strcmp(argv[1],"reset")) { CHECK(HI_MPI_SYS_Exit(),"HI_MPI_SYS_Exit"); CHECK(HI_MPI_VB_Exit(),"HI_MPI_VB_Exit"); return HI_SUCCESS; } else if ((!strcmp(argv[1],"N") || (!strcmp(argv[1],"n")))) { /* if you live in Japan or North America, you may need adhere 'N/n' */ g_u32TvMode = VIDEO_ENCODING_MODE_NTSC; g_u32ScreenHeight = 480; } else if (!strcmp(argv[1],"vi2vo")) { /* you can open vi2vo preview only */ g_bPreviewOnly = HI_TRUE; } } /* process abnormal case */ signal(SIGINT, HandleSig); signal(SIGTERM, HandleSig); /* configure video buffer and initial system */ CHECK(HI_MPI_VB_SetConf(&stVbConf),"HI_MPI_VB_SetConf"); CHECK(HI_MPI_VB_Init(),"HI_MPI_VB_Init"); CHECK(HI_MPI_SYS_SetConf(&stSysConf),"HI_MPI_SYS_SetConf"); CHECK(HI_MPI_SYS_Init(),"HI_MPI_SYS_Init"); /* set AD and DA for VI and VO */ do_Set2815_2d1(); if (VIDEO_ENCODING_MODE_NTSC == g_u32TvMode) { do_Set7179(VIDEO_ENCODING_MODE_NTSC); } else { do_Set7179(VIDEO_ENCODING_MODE_PAL);; } Usage(); while((ch = getchar())!= 'q') { if('\n' == ch) { continue; } switch(ch) { case '1': { printf("\033[0;33mwhat you see is codecing!\033[0;39m\n"); CHECK(CODEC_1D1_H264(),"CODEC_1D1_H264"); break; } case '2': { printf("\033[0;33mthe last window is codecing!\033[0;39m\n"); CHECK(VI2VO_3CIF_CODEC_1CIF_H264(),"VI2VO_3CIF_CODEC_1CIF_H264"); break; } case '3': { printf("\033[0;33mthe last window is codecing!\033[0;39m\n"); CHECK(VI2VO_8CIF_CODEC_1CIF_H264(),"VI2VO_8CIF_CODEC_1CIF_H264"); break; } default: printf("\033[0;31mno order!\033[0;39m\n"); } Usage(); } /* de-init sys and vb */ CHECK(HI_MPI_SYS_Exit(),"HI_MPI_SYS_Exit"); CHECK(HI_MPI_VB_Exit(),"HI_MPI_VB_Exit"); return HI_SUCCESS; }
HI_VOID SampleSysExit(HI_VOID) { HI_MPI_SYS_Exit(); HI_MPI_VB_Exit(); }
void SYSTEM_Destroy() { DVR_ASSERT(HI_MPI_SYS_Exit()); DVR_ASSERT(HI_MPI_VB_Exit()); }
int main(int argc, char *argv[]) { pthread_t phifb0 = -1,phifb1=-1; PTHREAD_HIFB_sw_INFO stInfo0; PTHREAD_HIFB_sw_INFO stInfo1; VO_PUB_ATTR_S stPubAttr; VB_CONF_S stVbConf; HI_S32 s32Ret = HI_SUCCESS; HI_S32 i; sw_VI_MODE_E enViMode = sw_VI_MODE_1_D1; sw_VO_MODE_E stVoMode = VO_MODE_1MUX; HI_BOOL bExtendedMode=HI_TRUE; HI_CHAR ch; initFb(); InitQueue(); FontInit(); memset(&stVbConf, 0, sizeof(VB_CONF_S)); stVbConf.u32MaxPoolCnt = 16; stVbConf.astCommPool[0].u32BlkSize = 720*576*2; stVbConf.astCommPool[0].u32BlkCnt = 16; stPubAttr.u32BgColor = 0xff00ff00; stPubAttr.enIntfType = VO_INTF_VGA; stPubAttr.enIntfSync = VO_OUTPUT_720P50; stPubAttr.bDoubleFrame = HI_FALSE; if (HI_SUCCESS != sw_COMM_SYS_Init(&stVbConf)) { printf("func:%s,line:%d\n", __FUNCTION__, __LINE__); return -1; } s32Ret = sw_COMM_VO_StartDevLayer(VoDev,&stPubAttr,25); if (HI_SUCCESS != s32Ret) { printf("%s: Start DevLayer failed!\n", __FUNCTION__); sw_COMM_SYS_Exit(); return -1; } if (HI_SUCCESS != sw_COMM_VO_StartChn(VoDev, &stPubAttr, stVoMode)) { printf("%s: Start VOChn failed!\n", __FUNCTION__); sw_COMM_SYS_Exit(); return -1; } stInfo0.layer = 0; stInfo0.fd = -1; stInfo0.ctrlkey = 2; pthread_create(&phifb0,0,sw_HIFB_REFRESH,(void *)(&stInfo0)); stInfo1.layer = 3; stInfo1.fd = -1; stInfo1.ctrlkey = 3; if (HI_SUCCESS != HI_MPI_VO_GfxLayerUnBindDev(GRAPHICS_LAYER_HC0, sw_VO_DEV_DHD0)) { printf("%s: Graphic UnBind to VODev failed!,line:%d\n", __FUNCTION__, __LINE__); sw_COMM_SYS_Exit(); sw_HIFB_VO_Stop(); return -1; } if (HI_SUCCESS != HI_MPI_VO_GfxLayerBindDev(GRAPHICS_LAYER_HC0, sw_VO_DEV_DHD0)) { printf("%s: Graphic Bind to VODev failed!,line:%d\n", __FUNCTION__, __LINE__); sw_COMM_SYS_Exit(); sw_HIFB_VO_Stop(); return -1; } pthread_create(&phifb1,0,SAMPLE_HIFB_PANDISPLAY,(void *)(&stInfo1)); pthread_join(phifb0,0); pthread_join(phifb1,0); while(1); HI_MPI_SYS_Exit(); HI_MPI_VB_Exit(); return 0; }
HI_VOID sw_COMM_SYS_Exit(void) { HI_MPI_SYS_Exit(); HI_MPI_VB_Exit(); return; }
void ipcam_media_sys_ctrl_uninit_media_system(IpcamMediaSysCtrl *self) { HI_MPI_SYS_Exit(); HI_MPI_VB_Exit(); }