Пример #1
0
/*****************************************************************************
* function : stop vi accroding to product type
*****************************************************************************/
HI_S32 SAMPLE_COMM_VI_Stop(SAMPLE_VI_MODE_E enViMode)
{
    VI_DEV ViDev;
    VI_CHN ViChn;
    HI_S32 i;
    HI_S32 s32Ret;
    SAMPLE_VI_PARAM_S stViParam;

    /*** get parameter from Sample_Vi_Mode ***/
    s32Ret = SAMPLE_COMM_VI_Mode2Param(enViMode, &stViParam);
    if (HI_SUCCESS !=s32Ret)
    {
        SAMPLE_PRT("SAMPLE_COMM_VI_Mode2Param failed!\n");
        return HI_FAILURE;
    }

    /*** Stop VI Chn ***/
    for(i=0;i<stViParam.s32ViChnCnt;i++)
    {
        /* Stop vi phy-chn */
        ViChn = i * stViParam.s32ViChnInterval;
        s32Ret = HI_MPI_VI_DisableChn(ViChn);
        if (HI_SUCCESS != s32Ret)
        {
            SAMPLE_PRT("SAMPLE_COMM_VI_StopChn failed with %#x\n",s32Ret);
            return HI_FAILURE;
        }
        /* HD mode, we will stop vi sub-chn */
        if (HI_TRUE == SAMPLE_COMM_VI_IsHd(enViMode))
        {
            ViChn += 16;
            s32Ret = HI_MPI_VI_DisableChn(ViChn);
            if (HI_SUCCESS != s32Ret)
            {
                SAMPLE_PRT("SAMPLE_COMM_VI_StopChn failed with %#x\n", s32Ret);
                return HI_FAILURE;
            }
        }
    }

    /*** Stop VI Dev ***/
    for(i=0; i<stViParam.s32ViDevCnt; i++)
    {
        ViDev = i * stViParam.s32ViDevInterval;
        s32Ret = HI_MPI_VI_DisableDev(ViDev);
        if (HI_SUCCESS != s32Ret)
        {
            SAMPLE_PRT("SAMPLE_COMM_VI_StopDev failed with %#x\n", s32Ret);
            return HI_FAILURE;
        }
    }

    return HI_SUCCESS;
}
Пример #2
0
/*****************************************************************************
 * function : Get Vi Dev No. according to Vi_Chn No.
 *****************************************************************************/
VI_DEV SAMPLE_COMM_VI_GetDev(SAMPLE_VI_MODE_E enViMode, VI_CHN ViChn) {
	HI_S32 s32Ret, s32ChnPerDev;
	SAMPLE_VI_PARAM_S stViParam;

	s32Ret = SAMPLE_COMM_VI_Mode2Param(enViMode, &stViParam);
	if (HI_SUCCESS != s32Ret) {
		SAMPLE_PRT("vi get param failed!\n");
		return (VI_DEV) -1;
	}

	s32ChnPerDev = stViParam.s32ViChnCnt / stViParam.s32ViDevCnt;
	return (VI_DEV) (ViChn / stViParam.s32ViChnInterval / s32ChnPerDev
			* stViParam.s32ViDevInterval);
}
Пример #3
0
/*****************************************************************************
* function : Vi chn unbind vpss group
*****************************************************************************/
HI_S32 SAMPLE_COMM_VI_UnBindVpss(SAMPLE_VI_MODE_E enViMode)
{
    HI_S32 i, j, s32Ret;
    VPSS_GRP VpssGrp;
    MPP_CHN_S stSrcChn;
    MPP_CHN_S stDestChn;
    SAMPLE_VI_PARAM_S stViParam;
    VI_DEV ViDev;
    VI_CHN ViChn;

    s32Ret = SAMPLE_COMM_VI_Mode2Param(enViMode, &stViParam);
    if (HI_SUCCESS !=s32Ret)
    {
        SAMPLE_PRT("SAMPLE_COMM_VI_Mode2Param failed!\n");
        return HI_FAILURE;
    }
    
    VpssGrp = 0;    
    for (i=0; i<stViParam.s32ViDevCnt; i++)
    {
        ViDev = i * stViParam.s32ViDevInterval;

        for (j=0; j<stViParam.s32ViChnCnt; j++)
        {
            ViChn = j * stViParam.s32ViChnInterval;
            
            stSrcChn.enModId = HI_ID_VIU;
            stSrcChn.s32DevId = ViDev;
            stSrcChn.s32ChnId = ViChn;
        
            stDestChn.enModId = HI_ID_VPSS;
            stDestChn.s32DevId = VpssGrp;
            stDestChn.s32ChnId = 0;
        
            s32Ret = HI_MPI_SYS_UnBind(&stSrcChn, &stDestChn);
            if (s32Ret != HI_SUCCESS)
            {
                SAMPLE_PRT("failed with %#x!\n", s32Ret);
                return HI_FAILURE;
            }
            
            VpssGrp ++;
        }
    }
    return HI_SUCCESS;
}
Пример #4
0
/******************************************************************************
 * function : Set vi system memory location
 ******************************************************************************/
HI_S32 SAMPLE_COMM_VI_MemConfig(SAMPLE_VI_MODE_E enViMode) {
	HI_CHAR * pcMmzName;
	MPP_CHN_S stMppChnVI;
	SAMPLE_VI_PARAM_S stViParam;
	VI_DEV ViDev;
	VI_CHN ViChn;

	HI_S32 i, j, s32Ret;

	s32Ret = SAMPLE_COMM_VI_Mode2Param(enViMode, &stViParam);
	if (HI_SUCCESS != s32Ret) {
		SAMPLE_PRT("vi get param failed!\n");
		return HI_FAILURE;
	}

	j = 0;
	for (i = 0; i < stViParam.s32ViChnCnt; i++) {
		ViChn = i * stViParam.s32ViChnInterval;
		ViDev = SAMPLE_COMM_VI_GetDev(enViMode, ViChn);
		//printf("dev:%d, chn:%d\n", ViDev, ViChn);
		if (ViDev < 0) {
			SAMPLE_PRT("get vi dev failed !\n");
			return HI_FAILURE;
		}

		pcMmzName = (0 == i % 2) ? NULL : "ddr1";
		stMppChnVI.enModId = HI_ID_VIU;
		stMppChnVI.s32DevId = 0; //For VIU mode, this item must be set to zero
		stMppChnVI.s32ChnId = ViChn;
		s32Ret = HI_MPI_SYS_SetMemConf(&stMppChnVI, pcMmzName);
		if (s32Ret) {
			SAMPLE_PRT("VI HI_MPI_SYS_SetMemConf failed with %#x!\n", s32Ret);
			return HI_FAILURE;
		}
	}

	return HI_SUCCESS;
}
Пример #5
0
HI_S32 SAMPLE_COMM_VI_BindVenc(SAMPLE_VI_MODE_E enViMode) {
	HI_S32 j, s32Ret;
	VENC_GRP VencGrp;
	MPP_CHN_S stSrcChn;
	MPP_CHN_S stDestChn;
	SAMPLE_VI_PARAM_S stViParam;
	VI_CHN ViChn;

	s32Ret = SAMPLE_COMM_VI_Mode2Param(enViMode, &stViParam);
	if (HI_SUCCESS != s32Ret) {
		SAMPLE_PRT("SAMPLE_COMM_VI_Mode2Param failed!\n");
		return HI_FAILURE;
	}

	VencGrp = 0;
	for (j = 0; j < stViParam.s32ViChnCnt; j++) {
		ViChn = j * stViParam.s32ViChnInterval;

		stSrcChn.enModId = HI_ID_VIU;
		stSrcChn.s32DevId = 0;
		stSrcChn.s32ChnId = ViChn;

		stDestChn.enModId = HI_ID_GROUP;
		stDestChn.s32DevId = VencGrp;
		stDestChn.s32ChnId = 0;

		s32Ret = HI_MPI_SYS_Bind(&stSrcChn, &stDestChn);
		if (s32Ret != HI_SUCCESS) {
			SAMPLE_PRT("failed with %#x!\n", s32Ret);
			return HI_FAILURE;
		}

		VencGrp++;
	}

	return HI_SUCCESS;
}
Пример #6
0
/*****************************************************************************
* function : star vi according to product type
*            if vi input is hd, we will start sub-chn for cvbs preview
*****************************************************************************/
HI_S32 SAMPLE_COMM_VI_Start(SAMPLE_VI_MODE_E enViMode, VIDEO_NORM_E enNorm)
{
    VI_DEV ViDev;
    VI_CHN ViChn, ViChn_Sub;
    HI_S32 i;
    HI_S32 s32Ret;
    SAMPLE_VI_PARAM_S stViParam;
    SIZE_S stMainTargetSize;
    SIZE_S stSubTargetSize;
    RECT_S stCapRect;
    
    /*** get parameter from Sample_Vi_Mode ***/
    s32Ret = SAMPLE_COMM_VI_Mode2Param(enViMode, &stViParam);
    if (HI_SUCCESS !=s32Ret)
    {
        SAMPLE_PRT("vi get param failed!\n");
        return HI_FAILURE;
    }
    s32Ret = SAMPLE_COMM_VI_Mode2Size(enViMode, enNorm, &stCapRect, &stMainTargetSize);
    if (HI_SUCCESS !=s32Ret)
    {
        SAMPLE_PRT("vi get size failed!\n");
        return HI_FAILURE;
    }
    
    /*** Start AD ***/
    s32Ret = SAMPLE_COMM_VI_ADStart(enViMode, enNorm);
    if (HI_SUCCESS !=s32Ret)
    {
        SAMPLE_PRT("Start AD failed!\n");
        return HI_FAILURE;
    }
    
    /*** Start VI Dev ***/
    for(i=0; i<stViParam.s32ViDevCnt; i++)
    {
        ViDev = i * stViParam.s32ViDevInterval;
        s32Ret = SAMPLE_COMM_VI_StartDev(ViDev, enViMode);
        if (HI_SUCCESS != s32Ret)
        {
            SAMPLE_PRT("SAMPLE_COMM_VI_StartDev failed with %#x\n", s32Ret);
            return HI_FAILURE;
        }
    }
    
    /*** Start VI Chn ***/
    for(i=0; i<stViParam.s32ViChnCnt; i++)
    {
        ViChn = i * stViParam.s32ViChnInterval;
        
        s32Ret = SAMPLE_COMM_VI_StartChn(ViChn, &stCapRect, &stMainTargetSize, enViMode, VI_CHN_SET_NORMAL);
        if (HI_SUCCESS != s32Ret)
        {
            SAMPLE_PRT("call SAMPLE_COMM_VI_StarChn failed with %#x\n", s32Ret);
            return HI_FAILURE;
        } 
        /* HD mode, we will start vi sub-chn */
        if (HI_TRUE == SAMPLE_COMM_VI_IsHd(enViMode))
        {
            ViChn_Sub = SUBCHN(ViChn);
            s32Ret = SAMPLE_COMM_VI_GetSubChnSize(ViChn_Sub, enNorm, &stSubTargetSize);
            if (HI_SUCCESS != s32Ret)
            {
                SAMPLE_PRT("SAMPLE_COMM_VI_GetSubChnSize(%d) failed!\n", ViChn_Sub);
                return HI_FAILURE;
            }
            s32Ret = SAMPLE_COMM_VI_StartChn(ViChn_Sub, &stCapRect, &stSubTargetSize,enViMode, VI_CHN_SET_NORMAL);
            if (HI_SUCCESS != s32Ret)
            {
                SAMPLE_PRT("SAMPLE_COMM_VI_StartChn (Sub_Chn-%d) failed!\n", ViChn_Sub);
                return HI_FAILURE;
            }
        }
    }

    return HI_SUCCESS;
}
Пример #7
0
/*****************************************************************************
* function : star vi according to product type
*           only for Hi3520D MixCap 
*****************************************************************************/
HI_S32 SAMPLE_COMM_VI_MixCap_Start(SAMPLE_VI_MODE_E enViMode, VIDEO_NORM_E enNorm)
{
    VI_DEV ViDev;
    VI_CHN ViChn;
    HI_S32 i;
    HI_S32 s32Ret;
    SAMPLE_VI_PARAM_S stViParam;
    VI_CHN_ATTR_S stChnAttr,stChnMinorAttr;
	
    /*** get parameter from Sample_Vi_Mode ***/
    s32Ret = SAMPLE_COMM_VI_Mode2Param(enViMode, &stViParam);
    if (HI_SUCCESS !=s32Ret)
    {
        SAMPLE_PRT("vi get param failed!\n");
        return HI_FAILURE;
    }
    
    /*** Start AD ***/
    s32Ret = SAMPLE_COMM_VI_ADStart(enViMode, enNorm);
    if (HI_SUCCESS !=s32Ret)
    {
        SAMPLE_PRT("Start AD failed!\n");
        return HI_FAILURE;
    }
    
    /*** Start VI Dev ***/
    for(i=0; i<stViParam.s32ViDevCnt; i++)
    {
        ViDev = i * stViParam.s32ViDevInterval;
        s32Ret = SAMPLE_COMM_VI_StartDev(ViDev, enViMode);
        if (HI_SUCCESS != s32Ret)
        {
            SAMPLE_PRT("SAMPLE_COMM_VI_StartDev failed with %#x\n", s32Ret);
            return HI_FAILURE;
        }
    }
    
    /*** Start VI Chn ***/
    for(i=0; i<stViParam.s32ViChnCnt; i++)
    {
        ViChn = i * stViParam.s32ViChnInterval;

	    stChnAttr.stCapRect.s32X = 0;
	    stChnAttr.stCapRect.s32Y = 0;
	    stChnAttr.enCapSel = VI_CAPSEL_BOTH;                      
	    stChnAttr.enPixFormat = SAMPLE_PIXEL_FORMAT;   /* sp420 or sp422 */
	    stChnAttr.bMirror = HI_FALSE;                             
	    stChnAttr.bFlip   = HI_FALSE;                              
	    stChnAttr.bChromaResample = HI_FALSE;                      
	    stChnAttr.s32SrcFrameRate = -1;
	    stChnAttr.s32FrameRate = -1;
		stChnAttr.stCapRect.u32Width= D1_WIDTH;
	    stChnAttr.stCapRect.u32Height= (VIDEO_ENCODING_MODE_PAL==enNorm)?576:480;	
	    stChnAttr.stDestSize.u32Width= D1_WIDTH;
	    stChnAttr.stDestSize.u32Height= (VIDEO_ENCODING_MODE_PAL==enNorm)?576:480;
		
		memcpy(&stChnMinorAttr, &stChnAttr, sizeof(VI_CHN_ATTR_S));
	    stChnMinorAttr.stDestSize.u32Width= D1_WIDTH / 2;
	    stChnMinorAttr.stDestSize.u32Height= (VIDEO_ENCODING_MODE_PAL==enNorm)?576:480;

		stChnAttr.s32SrcFrameRate = (VIDEO_ENCODING_MODE_PAL== enNorm)?25:30;
		stChnAttr.s32FrameRate = 6;
		
		s32Ret = HI_MPI_VI_SetChnAttr(ViChn, &stChnAttr);
        if (HI_SUCCESS != s32Ret)
        {
            SAMPLE_PRT("call HI_MPI_VI_SetChnAttr failed with %#x\n", s32Ret);
            return HI_FAILURE;
        } 
		s32Ret = HI_MPI_VI_SetChnMinorAttr(ViChn, &stChnMinorAttr);
		if (HI_SUCCESS != s32Ret)
		{
			SAMPLE_PRT("call HI_MPI_VI_SetChnMinorAttr failed with %#x\n", s32Ret);
			return HI_FAILURE;
		} 
		s32Ret = HI_MPI_VI_EnableChn(ViChn);
		if (s32Ret != HI_SUCCESS)
		{
			SAMPLE_PRT("HI_MPI_VI_EnableChn failed with %#x!\n", s32Ret);
			return HI_FAILURE;
		}

    }

    return HI_SUCCESS;
}
Пример #8
0
/*****************************************************************************
 * function : star vi according to product type
 *****************************************************************************/
HI_S32 SAMPLE_COMM_VI_StartBT656(SAMPLE_VI_MODE_E enViMode, VIDEO_NORM_E enNorm) {
	VI_DEV ViDev;
	VI_CHN ViChn;
	HI_S32 i;
	HI_S32 s32Ret;
	SAMPLE_VI_PARAM_S stViParam;
	SIZE_S stTargetSize;
	RECT_S stCapRect;

	/*** get parameter from Sample_Vi_Mode ***/
	s32Ret = SAMPLE_COMM_VI_Mode2Param(enViMode, &stViParam);
	if (HI_SUCCESS != s32Ret) {
		SAMPLE_PRT("vi get param failed!\n");
		return HI_FAILURE;
	}

	s32Ret = SAMPLE_COMM_VI_Mode2Size(enViMode, enNorm, &stTargetSize);
	if (HI_SUCCESS != s32Ret) {
		SAMPLE_PRT("vi get size failed!\n");
		return HI_FAILURE;
	}

	/*** Start AD ***/
	s32Ret = SAMPLE_COMM_VI_ADStart(enViMode, enNorm);
	if (HI_SUCCESS != s32Ret) {
		SAMPLE_PRT("Start AD failed!\n");
		return HI_FAILURE;
	}

	/*** Start VI Dev ***/
	for (i = 0; i < stViParam.s32ViDevCnt; i++) {
		ViDev = i * stViParam.s32ViDevInterval;
		s32Ret = SAMPLE_COMM_VI_StartDev(ViDev, enViMode);
		if (HI_SUCCESS != s32Ret) {
			SAMPLE_PRT("SAMPLE_COMM_VI_StartDev failed with %#x\n", s32Ret);
			return HI_FAILURE;
		}
	}

	/*** Start VI Chn ***/
	for (i = 0; i < stViParam.s32ViChnCnt; i++) {
		ViChn = i * stViParam.s32ViChnInterval;

		stCapRect.s32X = 0;
		stCapRect.s32Y = 0;
		switch (enViMode) {
		case SAMPLE_VI_MODE_1_D1:
			stCapRect.u32Width = 720;
			stCapRect.u32Height =
					(VIDEO_ENCODING_MODE_PAL == enNorm) ? 576 : 480;
			break;

		default:
			SAMPLE_PRT("vi mode invaild!\n");
			return HI_FAILURE;
		}

		s32Ret = SAMPLE_COMM_VI_StartChn(ViChn, &stCapRect, &stTargetSize,
		NULL);
		if (HI_SUCCESS != s32Ret) {
			SAMPLE_PRT("call SAMPLE_COMM_VI_StarChn failed with %#x\n", s32Ret);
			return HI_FAILURE;
		}
	}

	return HI_SUCCESS;
}