动态切换HDR开关的sample code

更改HDR(线性)模式

1. Stop VPE channel - MI_VPE_StopChannel

2. Unbind VIF/VPE - ST_UnBind(VIF, VPE)

3. Disable Sensor - MI_SNR_Disable

4. Disable VIF    - MI_VIF_DisableChnPort, MI_VIF_DisableDev

5. Start sensor -

    MI_SNR_SetPlaneMode

    MI_SNR_SetRes

    MI_SNR_SetFps

    MI_SNR_Enable

6. Start vif -

    MI_VIF_SetDevAttr

    MI_VIF_EnableDev

    MI_VIF_SetChnPortAttr [ST_Vif_CreatePort]

    MI_VIF_EnableChnPort  [ST_Vif_StartPort]

7. Bind VIF/VPE

8. MI_VPE_StartChannel

9. Load ISP-API-BIN file if ISP is ready.

切换HDR开关的sample code

int videoSetHDR(Mixer_HDR_Mode_E hdr_flag)  
{  
    Mixer_Sys_BindInfo_T stBindInfo;  
    MI_VIF_DEV vifDev = 0;  
    MI_VIF_CHN vifChn = 0;  
    MI_VIF_PORT vifPort = 0;  
    MI_U8 u8ResIdx =0;  
    MI_SNR_Res_t stRes;  
    MI_SNR_PAD_ID_e eSnrPad = E_MI_SNR_PAD_ID_0;  
    MI_U32 u32CurFps = 0;  
    MI_SNR_PADInfo_t  stPad0Info;  
    MI_SNR_PlaneInfo_t stSnrPlane0Info;  
    Mixer_VIF_PortInfo_T stVifPortInfo;  
    MI_VPE_ChannelPara_t stVpeChParam;

    MIXERCHECKRESULT(Mixer_Vpe_StopChannel(0));  
    /************************************************  
    Step1:  unbind VIF->VPE  
    *************************************************/  
    memset(&stBindInfo, 0x0, sizeof(Mixer_Sys_BindInfo_T));  
    stBindInfo.stSrcChnPort.eModId = E_MI_MODULE_ID_VIF;  
    stBindInfo.stSrcChnPort.u32DevId = vifDev;  
    stBindInfo.stSrcChnPort.u32ChnId = vifChn;  
    stBindInfo.stSrcChnPort.u32PortId = vifPort;

    stBindInfo.stDstChnPort.eModId = E_MI_MODULE_ID_VPE;  
    stBindInfo.stDstChnPort.u32DevId = 0;  
    stBindInfo.stDstChnPort.u32ChnId = 0;  
    stBindInfo.stDstChnPort.u32PortId = 0;

    stBindInfo.u32SrcFrmrate = 30;  
    stBindInfo.u32DstFrmrate = 30;  
    MIXERCHECKRESULT(Mixer_Sys_UnBind(&stBindInfo));  
    /************************************************  
    Step2:  destory VIF  
    *************************************************/  
    MIXERCHECKRESULT(Mixer_Vif_StopPort(vifChn, vifPort));  
    MIXERCHECKRESULT(Mixer_Vif_DisableDev(vifDev));  
    /************************************************  
    Step3:  change SNR  
    *************************************************/  
    memset(&stPad0Info, 0x0, sizeof(MI_SNR_PADInfo_t));  
    memset(&stSnrPlane0Info, 0x0, sizeof(MI_SNR_PlaneInfo_t));  
    ExecFunc(MI_SNR_GetCurRes(eSnrPad, &u8ResIdx, &stRes), MI_VPE_OK);  
    ExecFunc(MI_SNR_GetFps(eSnrPad, &u32CurFps), MI_VPE_OK);  
    MI_SNR_Disable(eSnrPad);  
    if(hdr_flag == Mixer_HDR_TYPE_OFF){  
        MI_SNR_SetPlaneMode(eSnrPad, FALSE);  
    }  
    else {  
        MI_SNR_SetPlaneMode(eSnrPad, TRUE);  
    }  
    ExecFunc(MI_SNR_SetRes(eSnrPad,u8ResIdx), MI_SUCCESS);  
    ExecFunc(MI_SNR_Enable(eSnrPad), MI_SUCCESS);  
    //ExecFunc(MI_SNR_SetRes(eSnrPad,u8ResIdx), MI_SUCCESS);  
    ExecFunc(MI_SNR_SetFps(eSnrPad, u32CurFps), MI_SUCCESS);  
    printf("current use resolution idx=%d w=%d h=%d fps=%d \n",u8ResIdx,stRes.stCropRect.u16Width,stRes.stCropRect.u16Height,u32CurFps);  
    ExecFunc(MI_SNR_GetPadInfo(eSnrPad, &stPad0Info), MI_SUCCESS);  
    ExecFunc(MI_SNR_GetPlaneInfo(eSnrPad, 0, &stSnrPlane0Info), MI_SUCCESS);  
    /************************************************  
    Step4:  create VIF and vif port  
    *************************************************/  
    memset(&stVifPortInfo, 0x00, sizeof(Mixer_VIF_PortInfo_T));  
    MIXERCHECKRESULT(Mixer_Vif_EnableDev(vifDev, (MI_VIF_HDRType_e)hdr_flag, &stPad0Info));  
    stVifPortInfo.u32RectX = stSnrPlane0Info.stCapRect.u16X;  
    stVifPortInfo.u32RectY = stSnrPlane0Info.stCapRect.u16Y;  
    stVifPortInfo.s32FrameRate  = E_MI_VIF_FRAMERATE_FULL;  
    stVifPortInfo.u32RectWidth  = stSnrPlane0Info.stCapRect.u16Width;  
    stVifPortInfo.u32RectHeight = stSnrPlane0Info.stCapRect.u16Height;  
    stVifPortInfo.u32DestWidth  = stSnrPlane0Info.stCapRect.u16Width;  
    stVifPortInfo.u32DestHeight = stSnrPlane0Info.stCapRect.u16Height;  
    stVifPortInfo.ePixFormat    = (MI_SYS_PixelFormat_e)RGB_BAYER_PIXEL(stSnrPlane0Info.ePixPrecision, stSnrPlane0Info.eBayerId);  
    MIXERCHECKRESULT(Mixer_Vif_CreatePort(vifChn, vifPort, &stVifPortInfo));  
    /************************************************  
    Step5:  init VPE (create one VPE)  
    *************************************************/  
    memset(&stVpeChParam, 0x0, sizeof(MI_VPE_ChannelPara_t));  
    MIXERCHECKRESULT(MI_VPE_GetChannelParam(0, &stVpeChParam));  
    stVpeChParam.eHDRType = (MI_VPE_HDRType_e)hdr_flag;  
    MIXERCHECKRESULT(MI_VPE_SetChannelParam(0, &stVpeChParam));  
    MIXERCHECKRESULT(Mixer_Vpe_StartChannel(0));

    MIXERCHECKRESULT(Mixer_Vif_StartPort(vifDev,vifChn,vifPort));  
    /************************************************  
    Step6:  bind vif and vpe  
    *************************************************/  
    memset(&stBindInfo, 0x00, sizeof(Mixer_Sys_BindInfo_T));  
    stBindInfo.stSrcChnPort.eModId = E_MI_MODULE_ID_VIF;  
    stBindInfo.stSrcChnPort.u32DevId = 0;  
    stBindInfo.stSrcChnPort.u32PortId = 0;

    stBindInfo.stDstChnPort.eModId = E_MI_MODULE_ID_VPE;  
    stBindInfo.stDstChnPort.u32DevId = 0;  
    stBindInfo.stDstChnPort.u32PortId = 0;

    stBindInfo.u32SrcFrmrate = u32CurFps;  
    stBindInfo.u32DstFrmrate = u32CurFps;  
    stBindInfo.stSrcChnPort.u32ChnId = 0;  
    stBindInfo.stDstChnPort.u32ChnId = 0;  
    stBindInfo.eBindType = E_MI_SYS_BIND_TYPE_REALTIME;  
    MIXERCHECKRESULT(Mixer_Sys_Bind(&stBindInfo));


    return 0;  
}


MI_S32 Mixer_Vif_EnableDev(MI_VIF_DEV VifDev, MI_VIF_HDRType_e eHdrType, MI_SNR_PADInfo_t *pstSnrPadInfo)
{
    MI_VIF_DevAttr_t stDevAttr;

    memset(&stDevAttr, 0x0, sizeof(MI_VIF_DevAttr_t));

    stDevAttr.eIntfMode = pstSnrPadInfo->eIntfMode;
    stDevAttr.eWorkMode = E_MI_VIF_WORK_MODE_RGB_REALTIME;
    if(2 == VifDev)
    {
    stDevAttr.eWorkMode = E_MI_VIF_WORK_MODE_RGB_FRAMEMODE;
    }
    stDevAttr.eHDRType = eHdrType;
    if(stDevAttr.eIntfMode == E_MI_VIF_MODE_BT656)
        stDevAttr.eClkEdge = pstSnrPadInfo->unIntfAttr.stBt656Attr.eClkEdge;
    else
        stDevAttr.eClkEdge = E_MI_VIF_CLK_EDGE_DOUBLE;

    if(stDevAttr.eIntfMode == E_MI_VIF_MODE_MIPI)
        stDevAttr.eDataSeq =pstSnrPadInfo->unIntfAttr.stMipiAttr.eDataYUVOrder;
    else
        stDevAttr.eDataSeq = E_MI_VIF_INPUT_DATA_YUYV;

    if(stDevAttr.eIntfMode == E_MI_VIF_MODE_BT656)
        memcpy(&stDevAttr.stSyncAttr, &pstSnrPadInfo->unIntfAttr.stBt656Attr.stSyncAttr, sizeof(MI_VIF_SyncAttr_t));

    if(stDevAttr.eIntfMode == E_MI_VIF_MODE_DIGITAL_CAMERA)
        memcpy(&stDevAttr.stSyncAttr, &pstSnrPadInfo->unIntfAttr.stParallelAttr.stSyncAttr, sizeof(MI_VIF_SyncAttr_t));

    stDevAttr.eBitOrder = E_MI_VIF_BITORDER_NORMAL;

    ExecFunc(MI_VIF_SetDevAttr(VifDev, &stDevAttr), MI_SUCCESS);
    ExecFunc(MI_VIF_EnableDev(VifDev), MI_SUCCESS);
    return MI_SUCCESS;
}