Exemplo n.º 1
0
bool HimppVpssChan::enableObject()
{
    int grp = _vpss_group->getGroupId();
    int chn = _chnid;
    VPSS_CHN_ATTR_S chn_attr;
    VPSS_CHN_MODE_S chn_mode;
    VPSS_EXT_CHN_ATTR_S ext_chn_attr;
    HI_S32 s32Ret;

    switch (_type) {
    case VPSS_CHN_TYPE_PHY:
        chn_attr.bSpEn = HI_FALSE;
        chn_attr.bBorderEn = HI_FALSE;
        chn_attr.bMirror = HI_FALSE;
        chn_attr.bFlip = HI_FALSE;
        chn_attr.s32SrcFrameRate = -1;
        chn_attr.s32DstFrameRate = -1;
        if ((s32Ret = HI_MPI_VPSS_SetChnAttr(grp, chn, &chn_attr)) != HI_SUCCESS) {
            HIMPP_PRINT("HI_MPI_VPSS_SetChnAttr %d-%d failed %#x\n",
                        grp, chn, s32Ret);
            return false;
        }
        chn_mode.enChnMode = VPSS_CHN_MODE_USER;
        chn_mode.u32Width = _resolution.Width;
        chn_mode.u32Height = _resolution.Height;
        chn_mode.bDouble = HI_FALSE;
        chn_mode.enPixelFormat = HIMPP_PIXEL_FORMAT;
        if ((s32Ret = HI_MPI_VPSS_SetChnMode(grp, chn, &chn_mode)) != HI_SUCCESS) {
            HIMPP_PRINT("HI_MPI_VPSS_SetChnMode %d-%d failed %#x\n",
                        grp, chn, s32Ret);
            return false;
        }
        break;
    case VPSS_CHN_TYPE_EXT:
        ext_chn_attr.s32BindChn = 0;
        ext_chn_attr.s32SrcFrameRate = _framerate;
        if ((s32Ret = HI_MPI_VPSS_SetExtChnAttr(grp, chn, &ext_chn_attr)) != HI_SUCCESS) {
            HIMPP_PRINT("HI_MPI_VPSS_SetExtChnAttr %d-%d failed %#x\n",
                        grp, chn, s32Ret);
            return false;
        }
        break;
    default:
        break;
    }

    if ((s32Ret = HI_MPI_VPSS_EnableChn(grp, chn)) != HI_SUCCESS) {
        HIMPP_PRINT("HI_MPI_VPSS_EnableChn %d-%d failed [%#x]\n",
                    grp, chn, s32Ret);
        return false;
    }

    return true;
}
HI_S32 SAMPLE_COMM_VPSS_EnableChn(VPSS_GRP VpssGrp, VPSS_CHN VpssChn, 
                                                  VPSS_CHN_ATTR_S *pstVpssChnAttr,
                                                  VPSS_CHN_MODE_S *pstVpssChnMode,
                                                  VPSS_EXT_CHN_ATTR_S *pstVpssExtChnAttr)
{
    HI_S32 s32Ret;

    if (VpssGrp < 0 || VpssGrp > VPSS_MAX_GRP_NUM)
    {
        printf("VpssGrp%d is out of rang[0,%d]. \n", VpssGrp, VPSS_MAX_GRP_NUM);
        return HI_FAILURE;
    }

    if (VpssChn < 0 || VpssChn > VPSS_MAX_CHN_NUM)
    {
        printf("VpssChn%d is out of rang[0,%d]. \n", VpssChn, VPSS_MAX_CHN_NUM);
        return HI_FAILURE;
    }

    if (HI_NULL == pstVpssChnAttr && HI_NULL == pstVpssExtChnAttr)
    {
        printf("null ptr,line%d. \n", __LINE__);
        return HI_FAILURE;
    }

    if (VpssChn < VPSS_MAX_PHY_CHN_NUM)
    {
        s32Ret = HI_MPI_VPSS_SetChnAttr(VpssGrp, VpssChn, pstVpssChnAttr);
        if (s32Ret != HI_SUCCESS)
        {
            SAMPLE_PRT("HI_MPI_VPSS_SetChnAttr failed with %#x\n", s32Ret);
            return HI_FAILURE;
        }
    }
    else
    {
        s32Ret = HI_MPI_VPSS_SetExtChnAttr(VpssGrp, VpssChn, pstVpssExtChnAttr);
        if (s32Ret != HI_SUCCESS)
        {
            SAMPLE_PRT("%s failed with %#x\n", __FUNCTION__, s32Ret);
            return HI_FAILURE;
        }
    }
    
    if (VpssChn < VPSS_MAX_PHY_CHN_NUM && HI_NULL != pstVpssChnMode)
    {
        s32Ret = HI_MPI_VPSS_SetChnMode(VpssGrp, VpssChn, pstVpssChnMode);
        if (s32Ret != HI_SUCCESS)
        {
            SAMPLE_PRT("%s failed with %#x\n", __FUNCTION__, s32Ret);
            return HI_FAILURE;
        }     
    }
    
    s32Ret = HI_MPI_VPSS_EnableChn(VpssGrp, VpssChn);
    if (s32Ret != HI_SUCCESS)
    {
        SAMPLE_PRT("HI_MPI_VPSS_EnableChn failed with %#x\n", s32Ret);
        return HI_FAILURE;
    }

    return HI_SUCCESS;
}