This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Multiple capture input in DVR-RDK3.50

Other Parts Discussed in Thread: TVP7002

Hi,

I am using DVR-RDK3.50 for dm8168 EVM. EVM's daughter card has two tvp7002 video chip for component input. I have configured both TVP in 16-bit embedded sync mode from linux using i2c utilities. Here one TVP is on VIN0(Port A) and another TVP is on VIN1(Port A). I have developed two separate capture_display application two verify component input capture and it's working fine.

Now I want to capture two inputs simultaneously in single application. My use case is something like this,

                | -->720p60 on VIN0 ----> Display on-chip HDMI

Capture -> |

                |--> 720p60 on VIN1 ----> Encode ---> Dump to memory

Is this use case possible ? How to make chain to provide one capture stream 720p YUV data to Display and other 720p YUV data to encoder ?

Seeking quick response.

Thanks in advance,

Shabbir Limdiwala

  • Hi Shabbir,

     

    Capture Link supports multiple output queues, you can output VIP0 frames to queue 0 and VIp1 frames to queue 1, In the demo file, you could connect queue 0 to dispaly link and queue id 1 to encoder link,  In this way, you could achieve what you want.

    Please note that if you want 720p input from single source to both the VIP, that has to be taken care outside ti8168 evm..

     

    Thanks,

    Brijesh Jadav

  • Hi Brijesh,

    //For stream from VIN0

    pCaptureInstPrm                     = &capturePrm.vipInst[0];

    pCaptureInstPrm->vipInstId          = SYSTEM_CAPTURE_INST_VIP0_PORTA;

    pCaptureInstPrm->videoDecoderId     = SYSTEM_DEVICE_VID_DEC_TVP7002_DRV;

    pCaptureInstPrm->inDataFormat       = SYSTEM_DF_YUV422P;

    pCaptureInstPrm->standard           = SYSTEM_STD_720P_60;

    pCaptureInstPrm->numOutput          = 1;

    pCaptureOutPrm                      = &pCaptureInstPrm->outParams[0];

    pCaptureOutPrm->dataFormat          = SYSTEM_DF_YUV420SP_UV;

    pCaptureOutPrm->scEnable            = FALSE;

    //For stream 2 from VIN1

    pCaptureInstPrm                     = &capturePrm.vipInst[1];

    pCaptureInstPrm->vipInstId          = SYSTEM_CAPTURE_INST_VIP0_PORTA;

    pCaptureInstPrm->videoDecoderId     = SYSTEM_DEVICE_VID_DEC_TVP7002_DRV;

    pCaptureInstPrm->inDataFormat       = SYSTEM_DF_YUV422P;

    pCaptureInstPrm->standard           = SYSTEM_STD_720P_60;

    pCaptureInstPrm->numOutput          = 1;

    pCaptureOutPrm                      = &pCaptureInstPrm->outParams[0];

    pCaptureOutPrm->dataFormat          = SYSTEM_DF_YUV422I_YUYV;

    pCaptureOutPrm->scEnable            = FALSE;

    capturePrm.outQueParams[0].nextLink = gMultiChHd_VcapVencVdisObj.ipcOutVpssId;  //(will go for encoder)
    capturePrm.outQueParams[1].nextLink = gVdisModuleContext.displayId[0];            (will go for display)


    Am I doing correct ?

    Thanks,

    Shabbir Limdiwala

  • Hi Shabbir,

     

    For VIP0 output params, set queue id to 1 as shown below

    pCaptureOutPrm->outQueId = 0;

    For VIP1 output params, set queue id to 1 as shown below

    pCaptureOutPrm->outQueId = 1;

     

    rgds,

    Brijesh Jadav

  • Hi Brijesh,

    I am getting following error by adding your suggestion.

    [m3vpss ]  34745: Assertion @ Line: 857 in links_m3vpss/display/displayLink_drv.c: status == FVID2_SOK : failed !!!

    Thanks,

    Shabbir Limdiwala

  • Display link cannot take 420SP data. You will have to use SwMs in between to convert to 422I

  • If you are using VIP0 output only for display, you can store capture output itself in YUV422 format, so that display can accept it directly.

     

    Rgds,

    Brijesh

  • Hi Brijesh,

    I am doing the same.See code

    Brijesh Jadav said:

    //For stream 2 from VIN1

    pCaptureInstPrm                     = &capturePrm.vipInst[1];

    pCaptureInstPrm->vipInstId          = SYSTEM_CAPTURE_INST_VIP1_PORTA;

    pCaptureInstPrm->videoDecoderId     = SYSTEM_DEVICE_VID_DEC_TVP7002_DRV;

    pCaptureInstPrm->inDataFormat       = SYSTEM_DF_YUV422P;

    pCaptureInstPrm->standard           = SYSTEM_STD_720P_60;

    pCaptureInstPrm->numOutput          = 1;

    pCaptureOutPrm                      = &pCaptureInstPrm->outParams[0];

    pCaptureOutPrm->dataFormat          = SYSTEM_DF_YUV422I_YUYV;

    pCaptureOutPrm->scEnable            = FALSE;

    pCaptureOutPrm->outQueId            = 1;

    capturePrm.outQueParams[0].nextLink = gMultiChHd_VcapVencVdisObj.ipcOutVpssId;  //(will go for encoder)
    capturePrm.outQueParams[1].nextLink = gVdisModuleContext.displayId[0];            (will go for display)

    Although I am getting the same error. Any Idea ?

    Regards,

    Shabbir Limdiwala

  • Hi Shabbir,

     

    You also have to configure prevQueId to 1 in the display link params. If it is set to 0, it will try to get info from queid 0, which outputs YUV420.

     

    Rgds,

    Brijesh Jadav

  • Hi Brijesh,

    Yes it is also set to 1.

    displayPrm.inQueParams[0].prevLinkQueId = 1;

    Still the same issue.

    Thanks,

    Shabbir Limdiwala

  • Hi Shabbir,

     

    I am not sure which API failed, could you please provide code containing line 857?

     

    Rgds,

    Brijesh

  • Hi Brijesh,

    Please see attached displayLink_drv.c file. You can see line no. 857 of this file to see API.

    /*******************************************************************************
     *                                                                             *
     * Copyright (c) 2009 Texas Instruments Incorporated - http://www.ti.com/      *
     *                        ALL RIGHTS RESERVED                                  *
     *                                                                             *
     ******************************************************************************/
    
    #include "displayLink_priv.h"
    #include "mcfw/interfaces/common_def/ti_vsys_common_def.h"
    #include "mcfw/interfaces/link_api/avsync_rtos.h"
    
    static inline UInt32 DisplayLink_getSc1DispId()
    {
        UInt32 displayId;
    
    #if defined(TI_814X_BUILD) || defined(TI_8107_BUILD)
        displayId = VPS_DISP_INST_MAIN_DEI_SC1;
    #else
        displayId = VPS_DISP_INST_MAIN_DEIH_SC1;
    #endif
    
        return (displayId);
    }
    
    static inline UInt32 DisplayLink_getSc2DispId()
    {
        UInt32 displayId;
    
    #if defined(TI_814X_BUILD) || defined(TI_8107_BUILD)
        displayId = VPS_DISP_INST_AUX_SC2;
    #else
        displayId = VPS_DISP_INST_AUX_DEI_SC2;
    #endif
    
        return (displayId);
    }
    
    static inline Bool DisplayLink_drvIsDeiDisplayDrv(DisplayLink_Obj * pObj)
    {
        Bool isDeiDisplay = FALSE;
    
        if ((VPS_DISP_INST_MAIN_DEIH_SC1 == pObj->displayInstId) ||
            (VPS_DISP_INST_AUX_DEI_SC2 == pObj->displayInstId) ||
            (VPS_DISP_INST_MAIN_DEI_SC1 == pObj->displayInstId) ||
            (VPS_DISP_INST_AUX_SC2 == pObj->displayInstId))
        {
            isDeiDisplay = TRUE;
        }
    
        return (isDeiDisplay);
    }
    
    static
    Bool  DisplayLink_drvIsSDDef(DisplayLink_Obj * pObj)
    {
        Bool isSdDef = FALSE;
    
        if ((VSYS_STD_NTSC == pObj->createArgs.displayRes)
            ||
            (VSYS_STD_PAL == pObj->createArgs.displayRes))
        {
            isSdDef = TRUE;
        }
        return isSdDef;
    }
    
    static
    Bool DisplayLink_drvDoInputPitchDoubling(DisplayLink_Obj * pObj)
    {
        Bool doPitchDouble = FALSE;
    
        if (DisplayLink_drvIsSDDef(pObj)
            &&
            pObj->displayFormat.fieldMerged[0] == FALSE
            &&
                (
                    (FALSE == pObj->fieldInput[pObj->curActiveQueue])
                    ||
                    pObj->createArgs.forceFieldSeparatedInputMode
                )
            )
        {
            doPitchDouble = TRUE;
        }
        return doPitchDouble;
    }
    
    static
    Void  DisplayLink_drvCreateFrameInfo(DisplayLink_Obj * pObj)
    {
        Int32 status,i;
        struct DisplayLink_FrameInfoObj *frameInfo =
            &pObj->frameInfo;
    
        UTILS_COMPILETIME_ASSERT(UTILS_ARRAYSIZE(frameInfo->infoQMem) ==
                                 UTILS_ARRAYSIZE(frameInfo->infoMem));
        status =
        Utils_queCreate(&frameInfo->infoQ,
                        UTILS_ARRAYSIZE(frameInfo->infoQMem),
                        &frameInfo->infoQMem[0],
                        UTILS_QUE_FLAG_NO_BLOCK_QUE);
        UTILS_assert(status == 0);
        for (i = 0; i < UTILS_ARRAYSIZE(frameInfo->infoMem);i++)
        {
            DisplayLink_FrameInfo *frameInfoElem;
    
            frameInfoElem = &frameInfo->infoMem[i];
            status =
            Utils_quePut(&frameInfo->infoQ,frameInfoElem,
                         BIOS_NO_WAIT);
            UTILS_assert(status == 0);
        }
        return;
    }
    
    static
    Void  DisplayLink_drvDeleteFrameInfo(DisplayLink_Obj * pObj)
    {
        Int32 status;
    
        status =
        Utils_queDelete(&pObj->frameInfo.infoQ);
        UTILS_assert(status == 0);
    }
    
    
    
    
    static
    Void  DisplayLink_drvFreeFrameInfo(DisplayLink_Obj * pObj,
                                       FVID2_FrameList *frameList)
    {
        Int i;
        FVID2_Frame *frame;
        DisplayLink_FrameInfo *frameInfo;
        Int32 status;
    
        for (i = 0; i < frameList->numFrames; i++)
        {
            frame = frameList->frames[i];
            if (DISPLAY_LINK_BLANK_FRAME_CHANNEL_NUM != frame->channelNum)
            {
                frameInfo = frame->appData;
                UTILS_assert(UTILS_ARRAYISVALIDENTRY(frameInfo,
                                        pObj->frameInfo.infoMem));
                frame->appData = frameInfo->origFrameInfo;
                status =
                  Utils_quePut(&pObj->frameInfo.infoQ,
                               frameInfo,
                               BIOS_NO_WAIT);
                UTILS_assert(status == 0);
            }
        }
    }
    
    static
    Void DisplayLink_drvCreateRtParams(DisplayLink_Obj * pObj)
    {
        Int32 status;
        Int i;
    
        UTILS_COMPILETIME_ASSERT(UTILS_ARRAYSIZE(pObj->rtParams.freeQMem)
                                 ==
                                 UTILS_ARRAYSIZE(pObj->rtParams.paramsMem));
        status =
        Utils_queCreate(&pObj->rtParams.freeQ,
                        UTILS_ARRAYSIZE(pObj->rtParams.freeQMem),
                        pObj->rtParams.freeQMem,
                        UTILS_QUE_FLAG_NO_BLOCK_QUE);
        UTILS_assert(0 == status);
        for (i = 0; i < UTILS_ARRAYSIZE(pObj->rtParams.paramsMem); i++)
        {
            DisplayLink_drvRtParams *rtParams = &pObj->rtParams.paramsMem[i];
            rtParams->dispRtPrms.inFrmPrms = &rtParams->inFrmPrms;
            status = Utils_quePut(&pObj->rtParams.freeQ,
                                  rtParams,
                                  BIOS_NO_WAIT);
            UTILS_assert(0 == status);
        }
    }
    
    static
    Void DisplayLink_drvDeleteRtParams(DisplayLink_Obj * pObj)
    {
        Int32 status;
    
        status = Utils_queDelete(&pObj->rtParams.freeQ);
        UTILS_assert(0 == status);
    }
    
    
    static
    Vps_DispRtParams * DisplayLink_drvSetFramePitchRtParams(DisplayLink_Obj * pObj)
    {
        Int32 status;
        DisplayLink_drvRtParams *rtParams;
        Int i;
    
        status = Utils_queGet(&pObj->rtParams.freeQ,
                              (Ptr *)&rtParams,
                              1,
                              BIOS_NO_WAIT);
        UTILS_assert(status == 0);
        rtParams->dispRtPrms.inFrmPrms = &rtParams->inFrmPrms;
        rtParams->inFrmPrms.width      = pObj->displayFormat.width;
        rtParams->inFrmPrms.height     = pObj->displayFormat.height;
        for (i = 0; i < pObj->numDisplayBufPlanes; i++)
        {
            rtParams->inFrmPrms.pitch[i] = pObj->displayFormat.pitch[i];
        }
        return (&rtParams->dispRtPrms);
    }
    
    static
    Void DisplayLink_drvFreeRtParams(DisplayLink_Obj * pObj,
                                     FVID2_FrameList *freeFrameList)
    {
        Int32 status;
        DisplayLink_drvRtParams *rtParams;
    
        rtParams = freeFrameList->perListCfg;
        if (rtParams)
        {
            UTILS_COMPILETIME_ASSERT(
              offsetof(DisplayLink_drvRtParams,dispRtPrms) == 0);
            UTILS_assert(UTILS_ARRAYISVALIDENTRY(rtParams,pObj->rtParams.paramsMem));
            status = Utils_quePut(&pObj->rtParams.freeQ,
                                  rtParams,
                                  BIOS_NO_WAIT);
            UTILS_assert(status == 0);
        }
    
    }
    
    static
    Void  DisplayLink_drvSetPitchInfo(DisplayLink_Obj * pObj)
    {
        Int i;
        UInt32 curInQueId;
        UInt32 prevLinkQueId;
        System_LinkChInfo *chInfo;
    
        curInQueId = pObj->curActiveQueue;
        UTILS_assert(curInQueId < pObj->createArgs.numInputQueues);
        prevLinkQueId =
            pObj->createArgs.inQueParams[curInQueId].prevLinkQueId;
        UTILS_assert(prevLinkQueId <
                     pObj->inTskInfo[curInQueId].numQue);
        pObj->numDisplayBufPlanes =
        Utils_getNumPlanes((FVID2_DataFormat)pObj->displayFormat.dataFormat);
        UTILS_assert(pObj->numDisplayBufPlanes  != 0);
        if (pObj->curDisplayChannelNum <
            pObj->inTskInfo[curInQueId].queInfo[prevLinkQueId].numCh)
        {
            chInfo =
              &pObj->inTskInfo[curInQueId].queInfo[prevLinkQueId].chInfo[pObj->curDisplayChannelNum];
            UTILS_assert(chInfo->dataFormat == pObj->displayFormat.dataFormat);
            for (i = 0; i < pObj->numDisplayBufPlanes; i++)
            {
                pObj->displayFormat.pitch[i] = chInfo->pitch[i];
                if (DisplayLink_drvDoInputPitchDoubling(pObj))
                {
                    pObj->displayFormat.pitch[i] *= 2;
                }
            }
    
            pObj->displayFormat.width = chInfo->width;
            pObj->displayFormat.height = chInfo->height;
        }
    }
    
    Vps_DeiDispRtParams * DisplayLink_drvSetDeiFramePitchRtParams(DisplayLink_Obj * pObj)
    {
        Int32 status;
        DisplayLink_drvRtParams *rtParams;
        Int i;
    
        status = Utils_queGet(&pObj->rtParams.freeQ,
                              (Ptr *)&rtParams,
                              1,
                              BIOS_NO_WAIT);
        UTILS_assert(status == 0);
    
        rtParams->deiDispRtPrms.inFrmPrms = &rtParams->inFrmPrms;
        rtParams->inFrmPrms.width      = pObj->displayFormat.width;
        rtParams->inFrmPrms.height     = pObj->displayFormat.height;
        for (i = 0; i < pObj->numDisplayBufPlanes; i++)
        {
            rtParams->inFrmPrms.pitch[i] = pObj->displayFormat.pitch[i];
        }
        return (&rtParams->deiDispRtPrms);
    }
    
    
    static
    Void  DisplayLink_drvHandleDynamicPitchChange(DisplayLink_Obj * pObj,
                                                  FVID2_FrameList *frameList)
    {
        Bool updateDrvPitch = FALSE;
        UInt32 curInQueId;
        UInt32 prevLinkQueId;
        FVID2_Frame *frame;
        System_LinkChInfo *chInfo;
        DisplayLink_FrameInfo *frameInfo = NULL;
    
        curInQueId = pObj->curActiveQueue;
        UTILS_assert(curInQueId < pObj->createArgs.numInputQueues);
        prevLinkQueId =
            pObj->createArgs.inQueParams[curInQueId].prevLinkQueId;
        UTILS_assert(prevLinkQueId <
                     pObj->inTskInfo[curInQueId].numQue);
    
        UTILS_assert(frameList->numFrames == 1);
        frame = frameList->frames[0];
        if (frame->channelNum == pObj->curDisplayChannelNum)
        {
            Int i;
    
            chInfo =
              &pObj->inTskInfo[curInQueId].queInfo[prevLinkQueId].chInfo[pObj->curDisplayChannelNum];
    
            for (i = 0; i < pObj->numDisplayBufPlanes; i++)
            {
                UInt32 pitch;
    
                frameInfo = frame->appData;
                UTILS_assert((frameInfo != NULL)
                             &&
                             UTILS_ARRAYISVALIDENTRY(frameInfo,
                             pObj->frameInfo.infoMem));
    
                if ((frameInfo->origFrameInfo)
                    &&
                    (frameInfo->origFrameInfo->rtChInfoUpdate))
                {
                    chInfo->pitch[i] = frameInfo->origFrameInfo->rtChInfo.pitch[i];
                }
    
                pitch = chInfo->pitch[i];
    
                if (DisplayLink_drvDoInputPitchDoubling(pObj))
                {
                    pitch *= 2;
                }
                if (pObj->displayFormat.pitch[i] != pitch)
                {
                    updateDrvPitch = TRUE;
                    Vps_printf("DISPLAY:Runtime Pitch change:[%d->%d] for Inst %d",
                               pObj->displayFormat.pitch[i],pitch, pObj->displayInstId);
                    break;
                }
            }
    
            UTILS_assert(frameInfo != NULL);
            if ((frameInfo->origFrameInfo)
                &&
                (frameInfo->origFrameInfo->rtChInfoUpdate))
            {
                chInfo->width = frameInfo->origFrameInfo->rtChInfo.width;
                chInfo->height = frameInfo->origFrameInfo->rtChInfo.height;
    
                if ((pObj->displayFormat.width != chInfo->width) ||
                    (pObj->displayFormat.height != chInfo->height))
                {
                    updateDrvPitch = TRUE;
                    Vps_printf("DISPLAY:Runtime Size change:[%dx%d->%dx%d] for Inst %d",
                               pObj->displayFormat.width,
                               pObj->displayFormat.height,
                               chInfo->width,
                               chInfo->height,
                               pObj->displayInstId);
                }
            }
        }
    
        if (updateDrvPitch)
        {
            DisplayLink_drvSetPitchInfo(pObj);
    
            if (DisplayLink_drvIsDeiDisplayDrv(pObj))
            {
                frameList->perListCfg  =
                    DisplayLink_drvSetDeiFramePitchRtParams(pObj);
            }
            else
            {
                frameList->perListCfg  =
                    DisplayLink_drvSetFramePitchRtParams(pObj);
            }
        }
    }
    
    static
    Void  DisplayLink_validateFrameList(DisplayLink_Obj * pObj,
                                        FVID2_FrameList *frameList)
    {
        static Bool enableValidate = FALSE;
        FVID2_Frame *frame;
        DisplayLink_FrameInfo *frameInfo;
        Int i;
    
        if (enableValidate)
        {
            for (i = 0; i < frameList->numFrames; i++)
            {
                frame = frameList->frames[i];
                if (DISPLAY_LINK_BLANK_FRAME_CHANNEL_NUM !=
                    frame->channelNum)
                {
                    frameInfo = frame->appData;
                    UTILS_assert(UTILS_ARRAYISVALIDENTRY(frameInfo,
                                                         pObj->frameInfo.infoMem));
                }
            }
        }
    }
    
    static
    Void  DisplayLink_drvCreateFieldMergedFrame(DisplayLink_Obj * pObj, FVID2_Frame *top_field,
                                                FVID2_Frame *bot_field,
                                                DisplayLink_FrameInfo *frameInfo)
    {
        FVID2_Frame *fieldMergedFrame = &frameInfo->frame;
    
        fieldMergedFrame->addr[0][0] = top_field->addr[0][0];
        fieldMergedFrame->addr[0][1] = top_field->addr[0][1];
        fieldMergedFrame->addr[0][2] = top_field->addr[0][2];
        fieldMergedFrame->addr[1][0] = bot_field->addr[0][0];
        fieldMergedFrame->addr[1][1] = bot_field->addr[0][1];
        fieldMergedFrame->addr[1][2] = bot_field->addr[0][2];
    
        if(pObj->createArgs.forceFieldSeparatedInputMode)
        {
            /* go to next line in frame for bottom field */
            fieldMergedFrame->addr[1][0] =
             (Ptr)((UInt32)fieldMergedFrame->addr[1][0] + pObj->displayFormat.pitch[0]/2);
    
            fieldMergedFrame->addr[1][1] =
             (Ptr)((UInt32)fieldMergedFrame->addr[1][1] + pObj->displayFormat.pitch[1]/2);
    
            fieldMergedFrame->addr[1][2] =
             (Ptr)((UInt32)fieldMergedFrame->addr[1][2] + pObj->displayFormat.pitch[2]/2);
    
        }
    
        fieldMergedFrame->blankData  = top_field->blankData;
        fieldMergedFrame->channelNum = top_field->channelNum;
        fieldMergedFrame->drvData    = top_field->drvData;
        fieldMergedFrame->fid        = FVID2_FID_TOP;
        fieldMergedFrame->perFrameCfg = top_field->perFrameCfg;
        fieldMergedFrame->reserved    = top_field->reserved;
        fieldMergedFrame->subFrameInfo = top_field->subFrameInfo;
        fieldMergedFrame->timeStamp    = top_field->timeStamp;
        fieldMergedFrame->appData      = frameInfo;
    
        frameInfo->isFieldPair         = TRUE;
        frameInfo->origFrame[0]        = top_field;
        frameInfo->origFrame[1]        = bot_field;
        frameInfo->origFrameInfo       = NULL;
    }
    
    
    static
    Void  DisplayLink_drvSetFrameInfo(DisplayLink_Obj * pObj,
                                      FVID2_Frame **pFramePtr,
                                      Bool        *frameReject)
    {
        DisplayLink_FrameInfo *frameInfo;
        FVID2_Frame *frame;
        Int32 status;
        Bool fieldSeparatedInputMode;
    
        *frameReject = FALSE;
        frame = *pFramePtr;
    
    
        fieldSeparatedInputMode = FALSE;
    
        if (pObj->fieldInput[pObj->curActiveQueue]
                &&
            pObj->createArgs.forceFieldSeparatedInputMode == FALSE
           )
        {
            fieldSeparatedInputMode = TRUE;
        }
        if (pObj->fieldInput[pObj->curActiveQueue]
                &&
            pObj->createArgs.forceFieldSeparatedInputMode == TRUE
                &&
            pObj->enableFieldSeparatedInputMode
           )
        {
            fieldSeparatedInputMode = TRUE;
        }
    
        if (DISPLAY_LINK_BLANK_FRAME_CHANNEL_NUM !=
            frame->channelNum)
        {
            if(fieldSeparatedInputMode)
            {
                if(pObj->createArgs.forceFieldSeparatedInputMode)
                    frame->fid = pObj->nextFid;
    
                if (frame->fid == pObj->nextFid)
                {
                    pObj->nextFid = !(pObj->nextFid);
                    if (frame->fid == FVID2_FID_BOTTOM)
                    {
                        status = Utils_queGet(&pObj->frameInfo.infoQ,
                                              (Ptr *)&frameInfo,
                                              1,
                                              BIOS_NO_WAIT);
                        UTILS_assert(status == 0);
                        frameInfo->activeQueueId = pObj->curActiveQueue;
                        /* Received bot fields of frame.
                         * Create a field merged frame
                         */
                        UTILS_assert(pObj->topField != NULL);
                        UTILS_assert(pObj->topField->fid == FVID2_FID_TOP);
                        DisplayLink_drvCreateFieldMergedFrame(pObj, pObj->topField,
                                                             frame,
                                                             frameInfo);
                        pObj->topField = NULL;
                        *pFramePtr = &frameInfo->frame;
                    }
                    else
                    {
                        /* if top field. Store top field */
                        pObj->topField = frame;
                        frame->timeStamp = Utils_getCurTimeInMsec();
                        *pFramePtr = NULL;
                    }
                }
                else
                {
                    /* FID out of order. Reject */
                    *frameReject = TRUE;
                }
            }
            else
            {
                status = Utils_queGet(&pObj->frameInfo.infoQ,
                                      (Ptr *)&frameInfo,
                                      1,
                                      BIOS_NO_WAIT);
                UTILS_assert(status == 0);
                frameInfo->activeQueueId = pObj->curActiveQueue;
                frameInfo->isFieldPair = FALSE;
                frameInfo->origFrameInfo = frame->appData;
                frame->appData = frameInfo;
            }
        }
    }
    
    
    
    static
    Int32 DisplayLink_drvDeQueue(DisplayLink_Obj * pObj,
                                 FVID2_FrameList *freeFrameList,
                                 UInt32 *freeQueId)
    {
        Int32 status,i;
        FVID2_Frame *frame;
        FVID2_FrameList tmpFreeFrameList;
        DisplayLink_FrameInfo *frameInfo;
        UInt32 latency;
    
        freeFrameList->numFrames = 0;
        tmpFreeFrameList.numFrames = 0;
        *freeQueId = DISPLAY_LINK_INVALID_INQUEID;
        status =
            FVID2_dequeue(pObj->displayHndl,&tmpFreeFrameList,0,
                          BIOS_NO_WAIT);
        if (FVID2_SOK == status)
        {
            pObj->dequeCount += tmpFreeFrameList.numFrames;
    
            if (tmpFreeFrameList.numFrames)
            {
                pObj->maxQueueCount++;
    #ifdef SYSTEM_DEBUG_DISPLAY_RT
                Vps_printf(" %d: DISPLAY: Deque %d frames\n",
                           Utils_getCurTimeInMsec(),
                           tmpFreeFrameList.numFrames);
    #endif
                DisplayLink_drvFreeRtParams(pObj,&tmpFreeFrameList);
            }
            for (i = 0; i < tmpFreeFrameList.numFrames;i++)
            {
                frame = tmpFreeFrameList.frames[i];
                if (DISPLAY_LINK_BLANK_FRAME_CHANNEL_NUM !=
                    frame->channelNum)
                {
                    frameInfo = frame->appData;
                    UTILS_assert(UTILS_ARRAYISVALIDENTRY(frameInfo,pObj->frameInfo.infoMem));
                    *freeQueId = frameInfo->activeQueueId;
                    if (frameInfo->isFieldPair)
                    {
                        UInt32 curTime;
    
                        curTime = Utils_getCurTimeInMsec();
                        UTILS_assert(freeFrameList->numFrames <
                                     UTILS_ARRAYSIZE(freeFrameList->frames));
                        freeFrameList->frames[freeFrameList->numFrames] =
                                     frameInfo->origFrame[0];
                        pObj->drvTopFieldLatency +=
                        (curTime - frameInfo->origFrame[0]->timeStamp);
                        pObj->numTopFields++;
                        freeFrameList->numFrames++;
                        UTILS_assert(freeFrameList->numFrames <
                                     UTILS_ARRAYSIZE(freeFrameList->frames));
                        freeFrameList->frames[freeFrameList->numFrames] =
                                     frameInfo->origFrame[1];
                        freeFrameList->numFrames++;
                        pObj->numBufsInDriver--;
                    }
                    else
                    {
                        /* If not field pair, restore original appData */
                        frame->appData = frameInfo->origFrameInfo;
                        latency = Avsync_getWallTime() - frameInfo->origFrameInfo->ts64;
    
                        if(latency>pObj->maxLatency)
                            pObj->maxLatency = latency;
                        if(latency<pObj->minLatency)
                            pObj->minLatency = latency;
    
                        UTILS_assert(freeFrameList->numFrames <
                                     UTILS_ARRAYSIZE(freeFrameList->frames));
                        freeFrameList->frames[freeFrameList->numFrames] =
                                     frame;
                        freeFrameList->numFrames++;
                        pObj->numBufsInDriver--;
                    }
    
                    status =
                      Utils_quePut(&pObj->frameInfo.infoQ,
                                   frameInfo,
                                   BIOS_NO_WAIT);
                    UTILS_assert(status == 0);
                }
            }
        }
        return status;
    }
    
    Int32 DisplayLink_drvFvidCb(FVID2_Handle handle, Ptr appData, Ptr reserved)
    {
        DisplayLink_Obj *pObj = (DisplayLink_Obj *) appData;
        UInt32 elaspedTime, curTime;
    
        Utils_tskSendCmd(&pObj->tsk, DISPLAY_LINK_CMD_DO_DEQUE);
    
        pObj->cbCount++;
    
        curTime = Utils_getCurTimeInMsec();
    
        if (pObj->cbCount > 10)
        {
            elaspedTime = curTime - pObj->lastCbTime;
    
            if (elaspedTime > pObj->maxCbTime)
                pObj->maxCbTime = elaspedTime;
    
            if (elaspedTime < pObj->minCbTime)
                pObj->minCbTime = elaspedTime;
        }
    
        pObj->lastCbTime = curTime;
    
        Avsync_vidSynchCallbackFxn(pObj->tskId - SYSTEM_LINK_ID_DISPLAY_FIRST);
        return FVID2_SOK;
    }
    
    Int32 DisplayLink_drvSwitchCh(DisplayLink_Obj * pObj, DisplayLink_SwitchChannelParams *prm)
    {
        DisplayLink_drvLock(pObj);
    
        pObj->curDisplayChannelNum = prm->activeChId;
    
        DisplayLink_drvUnlock(pObj);
    
        return FVID2_SOK;
    }
    
    
    Int32 DisplayLink_drvSwitchActiveQueue(DisplayLink_Obj * pObj,
                                           DisplayLink_SwitchActiveQueueParams *prm)
    {
        Int32 status = FVID2_SOK;
    
        DisplayLink_drvLock(pObj);
    
        if (prm->activeQueueId < pObj->createArgs.numInputQueues)
        {
            if (NULL != pObj->topField)
            {
                System_LinkInQueParams *pInQueParams;
                UInt32 freeQueueId = pObj->curActiveQueue;
                FVID2_FrameList freeFrameList;
                Int32 status;
    
                UTILS_assert(freeQueueId <
                             pObj->createArgs.numInputQueues);
                pInQueParams = &pObj->createArgs.inQueParams[freeQueueId];
                freeFrameList.numFrames = 1;
                freeFrameList.frames[0] = pObj->topField;
                status =
                    System_putLinksEmptyFrames(pInQueParams->prevLinkId,
                                           pInQueParams->prevLinkQueId,
                                           &freeFrameList);
                UTILS_assert(status == 0);
                pObj->topField = NULL;
            }
            pObj->nextFid        = FVID2_FID_TOP;
            pObj->curActiveQueue = prm->activeQueueId;
        }
        else
        {
            status = -1;
        }
    
        DisplayLink_drvUnlock(pObj);
    
        return status;
    }
    
    Int32 DisplayLink_drvDisplayAllocAndQueBlankFrame(DisplayLink_Obj * pObj)
    {
        FVID2_FrameList frameList;
        UInt32 numQue;
        Int32 status;
    
        if(pObj->displayCreateArgs.memType != VPS_VPDMA_MT_TILEDMEM)
        {
            status = System_getBlankFrame(&pObj->blankFrame);
        }
        else
            status = FVID2_SOK;
        UTILS_assert(status == FVID2_SOK);
    
        pObj->blankFrame.channelNum = DISPLAY_LINK_BLANK_FRAME_CHANNEL_NUM;
        for (numQue = 0; numQue < DISPLAY_LINK_BLANK_FRAME_INIT_QUE; numQue++)
        {
            frameList.numFrames = 1;
            frameList.frames[0] = &pObj->blankFrame;
            frameList.perListCfg = NULL;
    
            if(pObj->displayCreateArgs.memType != VPS_VPDMA_MT_TILEDMEM)
            {
                pObj->blankFrame.addr[1][0] =
                (UInt8 *) pObj->blankFrame.addr[0][0] +
                pObj->displayFormat.pitch[0];
            }
            else
            {
                pObj->blankFrame.addr[1][0] = NULL;
                pObj->blankFrame.addr[0][0] = NULL;
            }
            pObj->numBufsInDriver++;
            status = FVID2_queue(pObj->displayHndl,&frameList,0);
            UTILS_assert(status == FVID2_SOK);
            pObj->maxQueueCount--;
        }
    
        return status;
    }
    
    static Int32 DisplayLink_drvSetDeiDispPrmsIctl(DisplayLink_Obj *pObj)
    {
        Int32              status;
    
        status = FVID2_control(
                     pObj->displayHndl,
                     IOCTL_VPS_DEI_DISP_SET_PARAMS,
                     &pObj->deiDispPrms,
                     NULL);
    
        return (status);
    }
    
    static
    Int32 DisplayLink_drvSetDeiDispPrms(DisplayLink_Obj *pObj, FVID2_Format *pFormat)
    {
        Int32              status;
        Vps_DeiDispParams *deiDispPrms = &pObj->deiDispPrms;
    
        deiDispPrms->fmt = *pFormat;
    
        deiDispPrms->comprEnable = FALSE;
        deiDispPrms->drnEnable = FALSE;
        deiDispPrms->scCfg.bypass = FALSE;
        deiDispPrms->scCfg.nonLinear = FALSE;
        deiDispPrms->scCfg.stripSize = 0;
        deiDispPrms->scCfg.vsType = VPS_SC_VST_POLYPHASE;
        deiDispPrms->scCfg.hsType = VPS_SC_HST_AUTO;
        deiDispPrms->scCfg.enablePeaking = FALSE;
        deiDispPrms->scCfg.enableEdgeDetect = FALSE;
    
        deiDispPrms->deiHqCfg = NULL;
        deiDispPrms->deiCfg = NULL;
    
        System_getOutSize(
            pObj->createArgs.displayRes,
            &deiDispPrms->scTarWidth,
            &deiDispPrms->scTarHeight);
    
        status = DisplayLink_drvSetDeiDispPrmsIctl(pObj);
    
        return (status);
    }
    
    Int32 DisplayLink_drvSetResolution(DisplayLink_Obj *pObj, UInt32 resolution)
    {
        Int32 status;
    
        /* For the DEI Display instances, set the DEI params */
        if (DisplayLink_drvIsDeiDisplayDrv(pObj))
        {
            System_getOutSize(
                resolution,
                &pObj->deiDispPrms.scTarWidth,
                &pObj->deiDispPrms.scTarHeight);
    
            status = DisplayLink_drvSetDeiDispPrmsIctl(pObj);
        }
        else
        {
            System_getOutSize(resolution,
                              &pObj->displayFormat.width,
                              &pObj->displayFormat.height);
    
            status = FVID2_setFormat(
                        pObj->displayHndl,
                        &pObj->displayFormat);
        }
    
        UTILS_assert(status == FVID2_SOK);
        return(status);
    }
    
    
    Int32 DisplayLink_drvSetFmt(DisplayLink_Obj * pObj, FVID2_Format *pFormat)
    {
        Int32 status;
    
        /* For the DEI Display instances, set the DEI params */
        if (DisplayLink_drvIsDeiDisplayDrv(pObj))
        {
            status = DisplayLink_drvSetDeiDispPrms(pObj, pFormat);
        }
        else
        {
            status = FVID2_setFormat(pObj->displayHndl, pFormat);
        }
    
        UTILS_assert(status == FVID2_SOK);
        return(status);
    }
    
    Int32 DisplayLink_drvSetCoeff(DisplayLink_Obj *pObj)
    {
        Int32                   status;
        Vps_ScCoeffParams       coeffPrms;
    
        /* Set the scaling coefficients,
           it is assumed here that the scalar is used for upscaling, so setting
           upscaling coefficients */
        coeffPrms.hScalingSet = VPS_SC_US_SET;
        coeffPrms.vScalingSet = VPS_SC_US_SET;
    
        coeffPrms.coeffPtr = NULL;
        coeffPrms.scalarId = VPS_M2M_DEI_SCALAR_ID_DEI_SC;
    
        status = FVID2_control(
                     pObj->displayHndl,
                     IOCTL_VPS_SET_COEFFS,
                     &coeffPrms,
                     NULL);
    
        return (status);
    }
    
    
    static Void DisplayLink_prdCalloutFcn(UArg arg)
    {
        DisplayLink_Obj *pObj = (DisplayLink_Obj *) arg;
    
        UTILS_assert(pObj->isDisplayRunning == FALSE);
    
        Utils_tskSendCmd(&pObj->tsk, DISPLAY_LINK_CMD_DO_DEQUE);
    }
    
    static Int32 DisplayLink_drvCreatePrdObj(DisplayLink_Obj * pObj)
    {
        Clock_Params clockParams;
    
        Clock_Params_init(&clockParams);
        clockParams.arg = (UArg) pObj;
        UTILS_assert(pObj->prd.clkHandle == NULL);
    
        Clock_construct(&(pObj->prd.clkStruct),
                        DisplayLink_prdCalloutFcn, 1, &clockParams);
    
        pObj->prd.clkHandle = Clock_handle(&pObj->prd.clkStruct);
        pObj->prd.clkStarted = FALSE;
    
        Clock_setPeriod(pObj->prd.clkHandle, DISPLAY_LINK_DONE_PERIOD_MS);
        Clock_setTimeout(pObj->prd.clkHandle, DISPLAY_LINK_DONE_PERIOD_MS);
    
        return FVID2_SOK;
    }
    
    static Int32 DisplayLink_drvDeletePrdObj(DisplayLink_Obj * pObj)
    {
    
        if(pObj->prd.clkStarted)
        {
            Clock_stop(pObj->prd.clkHandle);
        }
    
        Clock_destruct(&(pObj->prd.clkStruct));
        pObj->prd.clkHandle = NULL;
        pObj->prd.clkStarted = FALSE;
    
        return FVID2_SOK;
    }
    
    
    Int32 DisplayLink_drvDisplayCreate(DisplayLink_Obj * pObj)
    {
        Int32 status;
        UInt32 dispId[3] = {VPS_DISP_INST_BP0, VPS_DISP_INST_BP1, VPS_DISP_INST_SEC1};
        FVID2_CbParams cbParams;
        System_LinkChInfo *pInChInfo;
        FVID2_Format *pFormat;
    
        pInChInfo = &pObj->inQueInfo.chInfo[0];
    
        memset(&cbParams, 0, sizeof(cbParams));
        cbParams.cbFxn = DisplayLink_drvFvidCb;
        cbParams.appData = pObj;
    
        pObj->displayCreateArgs.memType = pInChInfo->memType;
        pObj->displayCreateArgs.periodicCallbackEnable = TRUE;
    
        pFormat = &pObj->displayFormat;
    
        pFormat->channelNum = 0;
        pFormat->width = pInChInfo->width;
        pFormat->height = pInChInfo->height;
        pFormat->pitch[0] = pInChInfo->pitch[0];
        pFormat->pitch[1] = pInChInfo->pitch[1];
        pFormat->pitch[2] = pInChInfo->pitch[2];
        pFormat->dataFormat = pInChInfo->dataFormat;
    
        switch (pObj->createArgs.displayId)
        {
            default:
            case DISPLAY_LINK_DISPLAY_AUTO_SELECT:
                pObj->displayInstId = dispId[pObj->tskId -
                                                SYSTEM_LINK_ID_DISPLAY_FIRST];
                pFormat->scanFormat = FVID2_SF_PROGRESSIVE;
                break;
            case DISPLAY_LINK_DISPLAY_BP0:
                pObj->displayInstId = VPS_DISP_INST_BP0;
                pFormat->scanFormat = FVID2_SF_PROGRESSIVE;
                break;
            case DISPLAY_LINK_DISPLAY_BP1:
                pObj->displayInstId = VPS_DISP_INST_BP1;
                pFormat->scanFormat = FVID2_SF_PROGRESSIVE;
                break;
            case DISPLAY_LINK_DISPLAY_SC1:
                pObj->displayInstId = DisplayLink_getSc1DispId();
                pFormat->scanFormat = FVID2_SF_PROGRESSIVE;
                break;
            case DISPLAY_LINK_DISPLAY_SC2:
                pObj->displayInstId = DisplayLink_getSc2DispId();
                pFormat->scanFormat = FVID2_SF_PROGRESSIVE;
                break;
            case DISPLAY_LINK_DISPLAY_SD:
                pObj->displayInstId = VPS_DISP_INST_SEC1;
                pFormat->scanFormat = FVID2_SF_INTERLACED;
                break;
        }
    
        pFormat->fieldMerged[0] = FALSE;
    
        if (pObj->createArgs.displayRes == VSYS_STD_1080I_60
            ||
            pObj->createArgs.displayRes == VSYS_STD_NTSC
            ||
            pObj->createArgs.displayRes == VSYS_STD_PAL)
        {
            Int i;
    
            pFormat->scanFormat = FVID2_SF_INTERLACED;
            pFormat->fieldMerged[0] = TRUE;
            if (DisplayLink_drvIsSDDef(pObj))
            {
                for (i = 0; i < pObj->createArgs.numInputQueues; i++)
                {
                    /* if we are going to get field input we should
                     * not enable field merged mode in the driver
                     * since we need to seamlessly switch from
                     * one input queue to another and changing
                     * field merged mode is not supported at
                     * runtime.
                     */
                    if (pObj->fieldInput[i] == TRUE)
                    {
                        pFormat->fieldMerged[0] = FALSE;
                    }
                }
                if (DisplayLink_drvDoInputPitchDoubling(pObj))
                {
                    pFormat->pitch[0] *= 2;
                    pFormat->pitch[1] *= 2;
                    pFormat->pitch[2] *= 2;
                }
            }
        }
        if (pObj->createArgs.displayRes == VSYS_STD_NTSC)
        {
            pFormat->width = 720;
            pFormat->height = 480;
        }
        if (pObj->createArgs.displayRes == VSYS_STD_PAL)
        {
            pFormat->width = 720;
            pFormat->height = 576;
        }
    
        pFormat->fieldMerged[1] = pFormat->fieldMerged[0];
        pFormat->fieldMerged[2] = pFormat->fieldMerged[0];
        pFormat->bpp = FVID2_BPP_BITS16;
        pFormat->reserved = NULL;
    
    #ifdef SYSTEM_VERBOSE_PRINTS
        Vps_printf(" %d: DISPLAY: %d: Window size %dx%d, %dB",
                   Utils_getCurTimeInMsec(),
                   pObj->displayInstId, pFormat->width, pFormat->height,
                   pFormat->pitch[0]);
    #endif
    
        pObj->displayHndl = FVID2_create(FVID2_VPS_DISP_DRV,
                                         pObj->displayInstId,
                                         &pObj->displayCreateArgs,
                                         &pObj->displayCreateStatus, &cbParams);
        UTILS_assert(pObj->displayHndl != NULL);
        pObj->maxQueueCount = pObj->displayCreateStatus.maxReqInQueue;
    
        /* Set the Scalar Coefficients */
        /* For the DEI Display instances, set the DEI params */
        if (DisplayLink_drvIsDeiDisplayDrv(pObj))
        {
            status = DisplayLink_drvSetCoeff(pObj);
            UTILS_assert(status == FVID2_SOK);
        }
    
        status = DisplayLink_drvSetFmt(pObj, pFormat);
        UTILS_assert(status == FVID2_SOK);
    
        pObj->queueCount = 0;
    
       return FVID2_SOK;
    }
    
    
    static
    Bool DisplayLink_drvIsFieldSeparatedInput(DisplayLink_Obj * pObj,
                                              System_LinkQueInfo *queInfo)
    {
        Bool isFieldSeparatedInput = FALSE;
        UInt32 fieldMergedHeightNTSC;
        UInt32 fieldMergedHeightPAL;
    
        UTILS_assert(DisplayLink_drvIsSDDef(pObj) == TRUE);
        fieldMergedHeightNTSC = 240;
        fieldMergedHeightPAL  = 288;
    
        pObj->enableFieldSeparatedInputMode = FALSE;
    
        if (queInfo->numCh > 0)
        {
            if(SYSTEM_SF_INTERLACED == queInfo->chInfo[0].scanFormat
            )
            {
                if ((queInfo->chInfo[0].height ==  fieldMergedHeightNTSC)
                    ||
                    (queInfo->chInfo[0].height ==  fieldMergedHeightPAL))
                {
                    isFieldSeparatedInput = TRUE;
                }
            }
            if(pObj->createArgs.forceFieldSeparatedInputMode)
            {
                isFieldSeparatedInput = TRUE;
                pObj->enableFieldSeparatedInputMode = TRUE;
            }
    
        }
        return isFieldSeparatedInput;
    }
    
    static
    Void DisplayLink_drvSetFieldSeparatedInfo(DisplayLink_Obj * pObj)
    {
        Int i,status;
        DisplayLink_CreateParams * pPrm;
    
        pPrm = &pObj->createArgs;
        for (i = 0; i < pObj->createArgs.numInputQueues;i++)
        {
            status = System_linkGetInfo(pPrm->inQueParams[i].prevLinkId,
                                        &pObj->inTskInfo[i]);
            UTILS_assert(status == FVID2_SOK);
            if (DisplayLink_drvIsSDDef(pObj))
            {
                pObj->fieldInput[i] =
                DisplayLink_drvIsFieldSeparatedInput (pObj,
                  &pObj->inTskInfo[i].queInfo[pPrm->inQueParams[i].prevLinkQueId]);
    
                if(pObj->fieldInput[i])
                {
                    Vps_printf(" %d: DISPLAY: %d: Field Separate Mode ENABLED for Que %d !!!\n",
                        Utils_getCurTimeInMsec(),
                        SYSTEM_GET_LINK_ID(pObj->tskId),
                        i
                      );
                }
            }
            else
            {
                pObj->fieldInput[i] = FALSE;
            }
        }
    }
    
    Int32 DisplayLink_drvCreate(DisplayLink_Obj * pObj,
                                DisplayLink_CreateParams * pPrm)
    {
        Semaphore_Params semParams;
        Int32 status = FVID2_SOK;
        DisplayLink_SwitchChannelParams switchParams;
    
    #ifdef SYSTEM_DEBUG_DISPLAY
        Vps_printf(" %d: DISPLAY: Create in progress !!!\n", Utils_getCurTimeInMsec());
    #endif
    
        pObj->cbCount = 0;
        pObj->dequeCount = 0;
        pObj->totalTime = 0;
        pObj->minCbTime = 0xFF;
        pObj->maxCbTime = 0;
        pObj->lastCbTime = 0;
        pObj->maxLatency = 0;
        pObj->minLatency = 0xFF;
        pObj->drvTopFieldLatency = 0;
        pObj->numTopFields = 0;
    
        pObj->inFrameGetCount = 0;
        pObj->inFramePutCount = 0;
        pObj->isDisplayRunning = FALSE;
    
        memcpy(&pObj->createArgs, pPrm, sizeof(*pPrm));
    
        UTILS_assertError((pPrm->activeQueue < UTILS_ARRAYSIZE(pPrm->inQueParams)),
                          status,
                          -1,
                          pObj->tskId,
                          -1);
        if (status != FVID2_SOK)
        {
            pPrm->activeQueue = 0;
        }
        DisplayLink_drvSetFieldSeparatedInfo(pObj);
        status = System_linkGetInfo(pPrm->inQueParams[pPrm->activeQueue].prevLinkId,
                                    &pObj->inTskInfo[pPrm->activeQueue]);
        UTILS_assert(status == FVID2_SOK);
        UTILS_assert(pPrm->inQueParams[pPrm->activeQueue].prevLinkQueId <
                     pObj->inTskInfo[pPrm->activeQueue].numQue);
    
        memcpy(&pObj->inQueInfo,
               &pObj->inTskInfo[pPrm->activeQueue].queInfo[pPrm->inQueParams[pPrm->activeQueue].prevLinkQueId],
               sizeof(pObj->inQueInfo));
        pObj->curActiveQueue = pPrm->activeQueue;
        pObj->numBufsInDriver = 0;
        pObj->topField = NULL;
        pObj->nextFid  = FVID2_FID_TOP;
        Semaphore_Params_init(&semParams);
    
        semParams.mode = Semaphore_Mode_BINARY;
    
        pObj->lock = Semaphore_create(1u, &semParams, NULL);
        UTILS_assert(pObj->lock != NULL);
    
        Semaphore_Params_init(&semParams);
    
        semParams.mode = Semaphore_Mode_BINARY;
    
        pObj->complete = Semaphore_create(0u, &semParams, NULL);
        UTILS_assert(pObj->complete != NULL);
    
        DisplayLink_drvDisplayCreate(pObj);
        DisplayLink_drvCreateFrameInfo(pObj);
        DisplayLink_drvCreateRtParams(pObj);
        DisplayLink_drvDisplayAllocAndQueBlankFrame(pObj);
        switchParams.activeChId = 0;
        DisplayLink_drvSwitchCh(pObj, &switchParams);
        DisplayLink_drvSetPitchInfo(pObj);
    
        DisplayLink_drvCreatePrdObj(pObj);
    
    #ifdef SYSTEM_DEBUG_DISPLAY
        Vps_printf(" %d: DISPLAY: Create Done !!!\n", Utils_getCurTimeInMsec());
    #endif
    
        return FVID2_SOK;
    }
    
    Int32 DisplayLink_drvPrintRtStatus(DisplayLink_Obj * pObj, UInt32 elaspedTime)
    {
        UInt32 displayId;
        char *displayName[] = { "HDDAC(BP0) ", "DVO2(BP1)  ", "SDDAC(SEC1)", "PRIMARY PATH", "AUX PATH" };
    
        displayId = pObj->displayInstId;
        if ((displayId == VPS_DISP_INST_MAIN_DEIH_SC1) ||
            (displayId == VPS_DISP_INST_MAIN_DEI_SC1))
        {
            displayId = 3;
        }
        if ((displayId == VPS_DISP_INST_AUX_DEI_SC2) ||
            (displayId == VPS_DISP_INST_AUX_SC2))
        {
            displayId = 4;
        }
    
        Vps_rprintf(" %d: DISPLAY: %s: %d fps, Latency (Min / Max) = ( %d / %d ), Callback Interval (Min / Max) = ( %d / %d ) !!! \r\n",
             Utils_getCurTimeInMsec(),
             displayName[displayId],
            pObj->cbCount*1000/elaspedTime,
            pObj->minLatency,
            pObj->maxLatency,
            pObj->minCbTime,
            pObj->maxCbTime
            );
    
    #if 1
        /* reset max time */
        pObj->maxCbTime = 0;
        pObj->minCbTime = 0xFF;
        pObj->maxLatency = 0;
        pObj->minLatency = 0xFF;
    #endif
    
        if(pObj->displayInstId==0)
        {
            System_displayUnderflowPrint(TRUE, TRUE);
            System_memPrintHeapStatus();
        }
    
        return 0;
    }
    
    Int32 DisplayLink_drvPrintStatistics(DisplayLink_Obj * pObj)
    {
        UInt32 elaspedTime;
    
        elaspedTime = Utils_getCurTimeInMsec() - pObj->startTime;
    
        DisplayLink_drvPrintRtStatus(pObj, elaspedTime);
    
        return 0;
    }
    
    #ifdef ENABLE_FXN_PROFILE
    #define DISPLAY_LINK_FXN_PROFILE_STG1_START_COUNT      (600)
    #define DISPLAY_LINK_FXN_PROFILE_STG2_START_COUNT      (900)
    #define DISPLAY_LINK_FXN_PROFILE_PRINT_COUNT           (1200)
    #include <mcfw/src_bios6/utils/utils_fnprof.h>
    
    static
    Void  DisplayLink_drvFxnProfileControl(DisplayLink_Obj * pObj)
    {
        static Bool fxnProfStg1Started = FALSE;
        static Bool fxnProfStg2Started = FALSE;
        static Bool fxnProfPrintDone = FALSE;
    
        if (SYSTEM_LINK_ID_DISPLAY_0 ==  pObj->tskId)
        {
            if ((pObj->inFrameGetCount >= DISPLAY_LINK_FXN_PROFILE_STG1_START_COUNT)
                &&
                (FALSE == fxnProfStg1Started))
            {
                FNPROF_STG1_enableProfile();
                fxnProfStg1Started = TRUE;
            }
            if ((pObj->inFrameGetCount >= DISPLAY_LINK_FXN_PROFILE_STG1_START_COUNT)
                &&
                (TRUE == fxnProfStg1Started)
                &&
                (FALSE == fxnProfPrintDone))
            {
                FNPROF_hookOverheadCalibrateFxn();
            }
            if ((pObj->inFrameGetCount >= DISPLAY_LINK_FXN_PROFILE_STG2_START_COUNT)
                &&
                (FALSE == fxnProfStg2Started))
            {
                FNPROF_STG2_setFxnCallCntThreshold(DISPLAY_LINK_FXN_PROFILE_STG2_START_COUNT
                                                   -
                                                   DISPLAY_LINK_FXN_PROFILE_STG1_START_COUNT);
                FNPROF_STG2_enableProfile();
                fxnProfStg2Started = TRUE;
            }
            if ((pObj->inFrameGetCount >= DISPLAY_LINK_FXN_PROFILE_STG2_START_COUNT)
                &&
                (TRUE == fxnProfStg2Started)
                &&
                (FALSE == fxnProfPrintDone))
            {
                FNPROF_hookOverheadCalibrateFxn();
            }
            if ((pObj->inFrameGetCount >= DISPLAY_LINK_FXN_PROFILE_PRINT_COUNT)
                &&
                (FALSE == fxnProfPrintDone))
            {
                FNPROF_printProfileInfo();
                fxnProfPrintDone = TRUE;
                FNPROF_disableProfiling();
            }
        }
    }
    #endif
    
    Int32 DisplayLink_drvProcessData(DisplayLink_Obj * pObj)
    {
        FVID2_FrameList frameList;
        FVID2_FrameList freeFrameList;
        FVID2_FrameList displayFrameList;
        UInt32 freeFrameNum, elaspedTime;
        System_LinkInQueParams *pInQueParams;
        FVID2_Frame *pFrame;
        Int32 status;
        Int i;
        UInt32 frameIdx;
    
        if(pObj->isDisplayRunning)
        {
            elaspedTime = Utils_getCurTimeInMsec() - pObj->startTime;
    
            if ((elaspedTime - pObj->prevTime) > 24 * 60 * 60 * 1000)
            {
                DisplayLink_drvPrintRtStatus(pObj, elaspedTime);
    
                pObj->prevTime = elaspedTime;
            }
    
            if(pObj->displayInstId==0)
            {
                System_displayUnderflowCheck(FALSE);
            }
    
            do
            {
                UInt32 freeQueueId;
                /* dequeue all completed frames */
                status = DisplayLink_drvDeQueue(pObj,&freeFrameList,
                                                &freeQueueId);
    
                if (freeFrameList.numFrames)
                {
                    pObj->inFramePutCount += freeFrameList.numFrames;
    
                    UTILS_assert(freeQueueId <
                                 pObj->createArgs.numInputQueues);
                    pInQueParams = &pObj->createArgs.inQueParams[freeQueueId];
                    System_putLinksEmptyFrames(pInQueParams->prevLinkId,
                                               pInQueParams->prevLinkQueId, &freeFrameList);
                }
    
            } while (status == FVID2_SOK);
    
    
            /* Free frames queued in inactive queues immediately */
            for (i = 0; i < pObj->createArgs.numInputQueues;i++)
            {
                if (i != pObj->curActiveQueue)
                {
                    frameList.numFrames = 0;
                    pInQueParams =
                      &pObj->createArgs.inQueParams[i];
                    System_getLinksFullFrames(pInQueParams->prevLinkId,
                                              pInQueParams->prevLinkQueId,
                                              &frameList);
                    if (frameList.numFrames)
                    {
                        pObj->inFrameGetCount += frameList.numFrames;
                        pObj->inFramePutCount += frameList.numFrames;
                        System_putLinksEmptyFrames(pInQueParams->prevLinkId,
                                                   pInQueParams->prevLinkQueId,
                                                   &frameList);
                    }
                }
            }
            UTILS_assert(pObj->curActiveQueue < pObj->createArgs.numInputQueues);
            pInQueParams = &pObj->createArgs.inQueParams[pObj->curActiveQueue];
            /* que frames if any */
    
            System_getLinksFullFrames(pInQueParams->prevLinkId,
                                      pInQueParams->prevLinkQueId, &frameList);
            pObj->inFrameGetCount += frameList.numFrames;
    
            #ifdef ENABLE_FXN_PROFILE
                DisplayLink_drvFxnProfileControl(pObj);
            #endif /* #ifdef ENABLE_FXN_PROFILE */
            freeFrameNum = 0;
    
            DisplayLink_drvLock(pObj);
            frameIdx = 0;
            while((pObj->maxQueueCount)
                  &&
                  (frameIdx < frameList.numFrames))
            {
                pFrame = frameList.frames[frameIdx];
                frameIdx++;
                UTILS_assert(pFrame != NULL);
                if (pFrame->channelNum == pObj->curDisplayChannelNum)
                {
                    Bool frameReject;
                    UInt32 pitch0,pitch1;
    
                    pitch0 = pObj->displayFormat.pitch[0];
                    pitch1 = pObj->displayFormat.pitch[1];
                    if (DisplayLink_drvDoInputPitchDoubling(pObj))
                    {
                        pitch0 /= 2;
                        pitch1 /= 2;
                    }
    
                    UTILS_assert(DISPLAY_LINK_BLANK_FRAME_CHANNEL_NUM !=
                                 pFrame->channelNum);
                    pFrame->addr[1][0] =
                        (UInt8 *) pFrame->addr[0][0] + pitch0;
                    pFrame->addr[1][1] =
                        (UInt8 *) pFrame->addr[0][1] + pitch1;
        #ifdef SYSTEM_DEBUG_DISPLAY_RT
                    Vps_printf(" %d: DISPLAY: Queue %d frames\n", Utils_getCurTimeInMsec(),
                               displayFrameList.numFrames);
        #endif
                    /* queue frame for display */
                    displayFrameList.numFrames = 0;
                    DisplayLink_drvSetFrameInfo(pObj,
                                                &pFrame,
                                                &frameReject);
                    if (pFrame)
                    {
                        if (frameReject)
                        {
                            UTILS_assert(freeFrameNum <
                                         UTILS_ARRAYSIZE(freeFrameList.frames));
                            /* error in queing to display, instead of asserting
                                release the frame and continue
                            */
                            freeFrameList.frames[freeFrameNum] = pFrame;
                            freeFrameNum++;
                        }
                        else
                        {
                            displayFrameList.frames[displayFrameList.numFrames] = pFrame;
                            displayFrameList.numFrames++;
                            displayFrameList.perListCfg = NULL;
                            DisplayLink_drvHandleDynamicPitchChange(pObj,&displayFrameList);
                            DisplayLink_validateFrameList(pObj,
                                                          &displayFrameList);
                            pObj->queueCount += displayFrameList.numFrames;
                            pObj->numBufsInDriver++;
    
                            status = FVID2_queue(pObj->displayHndl,
                                                 &displayFrameList,
                                                 0);
                            pObj->maxQueueCount--;
    
                            if(status!=FVID2_SOK)
                            {
    
                                 Vps_rprintf(" %d: DISPLAY (%d): Queue to driver failed !!!\n", Utils_getCurTimeInMsec(),
                                       pObj->tskId);
    
                                UTILS_assert(freeFrameNum <
                                             UTILS_ARRAYSIZE(freeFrameList.frames));
                                /* error in queing to display, instead of asserting
                                    release the frame and continue
                                */
                                freeFrameList.frames[freeFrameNum] = pFrame;
                                freeFrameNum++;
                                DisplayLink_drvFreeFrameInfo(pObj,
                                                             &displayFrameList);
                            }
                        }
                   }
                }
                else
                {
                    UTILS_assert(freeFrameNum <
                                 UTILS_ARRAYSIZE(freeFrameList.frames));
                    freeFrameList.frames[freeFrameNum] = pFrame;
                    freeFrameNum++;
                }
            }
            DisplayLink_drvUnlock(pObj);
    
            for (i = frameIdx; i < frameList.numFrames;i++)
            {
                UTILS_assert(freeFrameNum < UTILS_ARRAYSIZE(freeFrameList.frames));
                freeFrameList.frames[freeFrameNum] = frameList.frames[i];
                freeFrameNum++;
            }
            if (freeFrameNum)
            {
                freeFrameList.numFrames = freeFrameNum;
                pObj->inFramePutCount += freeFrameList.numFrames;
    
                System_putLinksEmptyFrames(pInQueParams->prevLinkId,
                                           pInQueParams->prevLinkQueId, &freeFrameList);
            }
    
        }
        else {
    
            /* Free frames queued in inactive queues immediately */
            for (i = 0; i < pObj->createArgs.numInputQueues;i++)
            {
                frameList.numFrames = 0;
                pInQueParams =
                  &pObj->createArgs.inQueParams[i];
                System_getLinksFullFrames(pInQueParams->prevLinkId,
                                          pInQueParams->prevLinkQueId,
                                          &frameList);
                if (frameList.numFrames)
                {
                    pObj->inFrameGetCount += frameList.numFrames;
                    pObj->inFramePutCount += frameList.numFrames;
                    System_putLinksEmptyFrames(pInQueParams->prevLinkId,
                                               pInQueParams->prevLinkQueId,
                                               &frameList);
                }
            }
        }
    
    
        return FVID2_SOK;
    }
    
    Int32 DisplayLink_drvDelete(DisplayLink_Obj * pObj)
    {
        FVID2_FrameList frameList;
        Int32 status;
    
    #ifdef SYSTEM_DEBUG_DEI
        Vps_printf(" %d: DISPLAY: Frames = %d (fps = %d) !!!\n",
                   Utils_getCurTimeInMsec(),
                   pObj->dequeCount,
                   pObj->dequeCount * 100 / (pObj->totalTime / 10));
    #endif
    
    #ifdef SYSTEM_DEBUG_DISPLAY
        Vps_printf(" %d: DISPLAY: Delete in progress !!!\n", Utils_getCurTimeInMsec());
    #endif
    
        do
        {
            // dequeue queued buffer's
            status = FVID2_dequeue(pObj->displayHndl, &frameList, 0, BIOS_NO_WAIT);
        } while (status == FVID2_SOK);
    
        status = FVID2_delete(pObj->displayHndl, NULL);
        if (FVID2_SOK != status)
        {
            Vps_printf("%s: Error %d @ line %d\n", __FUNCTION__, status, __LINE__);
            return (status);
        }
    
        Semaphore_delete(&pObj->lock);
        Semaphore_delete(&pObj->complete);
        DisplayLink_drvDeleteFrameInfo(pObj);
        DisplayLink_drvDeleteRtParams(pObj);
    
        DisplayLink_drvDeletePrdObj(pObj);
    
    #ifdef SYSTEM_DEBUG_DISPLAY
        Vps_printf(" %d: DISPLAY: Delete Done !!!\n", Utils_getCurTimeInMsec());
    #endif
    
        return FVID2_SOK;
    }
    
    Int32 DisplayLink_drvStart(DisplayLink_Obj * pObj)
    {
        Int32 status = FVID2_SOK;
    
    #ifdef SYSTEM_DEBUG_DISPLAY
        Vps_printf(" %d: DISPLAY: Start in progress !!!\n", Utils_getCurTimeInMsec());
    #endif
    
        pObj->lastCbTime = Utils_getCurTimeInMsec();
        pObj->startTime = Utils_getCurTimeInMsec();
        pObj->prevTime = pObj->startTime;
    
        if(pObj->prd.clkStarted)
        {
            Clock_stop(pObj->prd.clkHandle);
            pObj->prd.clkStarted = FALSE;
        }
    
        status = FVID2_start(pObj->displayHndl, NULL);
        UTILS_assert(status == FVID2_SOK);
    
        pObj->isDisplayRunning = TRUE;
    
        pObj->totalTime = Utils_getCurTimeInMsec();
    
    #ifdef SYSTEM_DEBUG_DISPLAY
        Vps_printf(" %d: DISPLAY: Start Done !!!\n", Utils_getCurTimeInMsec());
    #endif
    
        return status;
    }
    
    Int32 DisplayLink_drvStop(DisplayLink_Obj * pObj)
    {
        Int32 status = FVID2_SOK;
    
    #ifdef SYSTEM_DEBUG_DISPLAY
        Vps_printf(" %d: DISPLAY: Stop in progress !!!\n", Utils_getCurTimeInMsec());
    #endif
    
        pObj->totalTime = Utils_getCurTimeInMsec() - pObj->totalTime;
    
        pObj->isDisplayRunning = FALSE;
    
        status = FVID2_stop(pObj->displayHndl, NULL);
        UTILS_assert(status == FVID2_SOK);
    
        if(pObj->prd.clkStarted == FALSE)
        {
            Clock_start(pObj->prd.clkHandle);
            pObj->prd.clkStarted = TRUE;
        }
    
    #ifdef SYSTEM_DEBUG_DISPLAY
        Vps_printf(" %d: DISPLAY: Stop Done !!!\n", Utils_getCurTimeInMsec());
    #endif
    
        return status;
    }
    
    Int32 DisplayLink_drvLock(DisplayLink_Obj * pObj)
    {
        return Semaphore_pend(pObj->lock, BIOS_WAIT_FOREVER);
    }
    
    Int32 DisplayLink_drvUnlock(DisplayLink_Obj * pObj)
    {
        Semaphore_post(pObj->lock);
    
        return FVID2_SOK;
    }
    
    Int32 DisplayLink_drvSwitchInputMode(DisplayLink_Obj * pObj, DisplayLink_SwitchInputMode *pPrm)
    {
        if(pObj->createArgs.forceFieldSeparatedInputMode)
            pObj->enableFieldSeparatedInputMode = pPrm->enableFieldSeparatedInputMode;
        else
            pObj->enableFieldSeparatedInputMode = FALSE;
    
        return FVID2_SOK;
    }
    
    Int32 DisplayLink_printBufferStatus(DisplayLink_Obj * pObj)
    {
        Vps_rprintf
            (
            " \n"
            " *** Display Statistics *** \n"
            "%d: DISPLAY: Rcvd from prev = %d, Returned to prev = %d, BufsInDriver = %d\r\n",
            Utils_getCurTimeInMsec(), pObj->inFrameGetCount, pObj->inFramePutCount, pObj->numBufsInDriver);
    
        return 0;
    }
    
    

    Thanks,

    Shabbir Limdiwala

  • Pls share your usecase file where you are connecting links. Display link is failing as input format is still 420SP. Must be issue with connecting links. Pls attach the c file

  • Hi Badri,

    Attached is the file where i create Link for my use case. Please see it.

    /*******************************************************************************
     *                                                                             *
     * Copyright (c) 2009 Texas Instruments Incorporated - http://www.ti.com/      *
     *                        ALL RIGHTS RESERVED                                  *
     *                                                                             *
     ******************************************************************************/
    /*
                                              Capture (4CH 1080p30 422)
                                               ******************
                                                    |         |
                                                   DUP0      DUP1
                                                   | | |     | | |
                                                   | | |     | | +---------------------------+
                                                   | | |  +--+ |                             |
                                                   | | +--[----[--------------------------+  |
                                                   | |    |    +--+                       |  |
                                                   | +----[----+  |                      MERGE1
                                                   |      |    |  |                        |
                                                   | +----+  MERGE0                        |
                                                   | |          |                          |
                                                   | |          +----- SC5 ------+         |
                                                   | |             (4CH D1 422)  |        SC5
                                               +---+ +--------+                  |     (4CH 422) (MJPEG)
                                               |              |                  |         |
                                             DEIH (BP-Mode)  DEI (BP-Mode)       |         |
                                              | |            | |                 |  +------+
                                  2CH 1080p30 | |            | | 2CH 1080p30     |  |
                                              | |            | |                 |  |
                                   +----------+ +-----+  +---+ +---+             |  |
                                   |                  |  |            |          |  |
                                   |          +-------[--+            |         MERGE2
                                   |          |       |               |          |  |
                                   |   (DEI-SC2 422)  +--+            |          |  |
                                   |          |          |            |          |  |
                                   |          |          |       (VIP-SC4 420)   |  |
                              (DEI-SC1 422)   |   (VIP-SC3 420)       |          NSF
                                   |          |          |            |           |(4CH D1 420) + 4Ch MJEPG
                                   +--+   +---+          +----+       |           |
                                      |   |                   |       |           |
                                      MERGE3                 |       +--------+  |
                                        |                     +--------------+ |  |
                                       DUP2------------------+               | |  |
                                        |                    |               | |  |
        +--<<<processLink>>>--- IPC Frames Out (M3)          |               | |  |
        |                               |                    |               MERGE4
        |                       IPC Frames IN (A8)           |                 |
      FramesInDSP                       |                    |                 |
        |                       IPC Frames Out (A8)          |              IPC OUT(M3)----<<<processLink>>>---FramesInDSP--+
     ALG LINK                           |                    |                 |                                            |
     <OSD SCD Algs>             IPC Frames IN (M3)           |              IPC IN(M3)                                      |
                                        |              On-Chip HDMI            |                                            |
                                  OFF-Chip HDMI          1080p60      Encode (4CH 1080p30 + 4CH D1)                      ALG_LINK
                                     1080p60          (1-Ch 1-Window)          |                                       <OSD, SCD Algs>
                                 (1-Ch 1-Window)                          IPC Bits OUT (M3)
                                                                               |
                                                                          IPC Bits IN (A8)
    
    (BP-Mode) --> Bypass Mode
    */
    
    #include "multich_common.h"
    
    //#include "mcfw/interfaces/link_api/system_tiler.h"
    
    
    #define     NUM_CAPTURE_DEVICES     (4)
    
    #define     ENABLE_SCL_NSF           0
    
    /* =============================================================================
     * Externs
     * =============================================================================
     */
    
    //static UInt8 SCDChannelMonitor[4] = {4, 5, 6, 7};
    
    //#define TWOOSD_INSTANCE
    
    typedef struct {
    
        UInt32 mergeId[5];
        UInt32 dupId[3];
        UInt32 ipcOutVpssId;
        UInt32 ipcInVideoId;
        UInt32 ipcFrameOutVpssId[2];
        UInt32 ipcFramesInDspId[2];
    } MultiChHd_VcapVencVdisObj;
    
    MultiChHd_VcapVencVdisObj gMultiChHd_VcapVencVdisObj;
    
    /* =============================================================================
     * Use case code
     * =============================================================================
     */
    
    static SystemVideo_Ivahd2ChMap_Tbl systemVid_encDecIvaChMapTbl =
    {
        .isPopulated = 1,
        .ivaMap[0] =
        {
            .EncNumCh  = 2,
            .EncChList = {0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 , 0, 0},
            .DecNumCh  = 0,
            .DecChList = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
        },
        .ivaMap[1] =
        {
            .EncNumCh  = 2,
            .EncChList = {1, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 , 0, 0},
            .DecNumCh  = 0,
            .DecChList = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
        },
        .ivaMap[2] =
        {
            .EncNumCh  = 8,
            .EncChList = {4, 5, 6, 7, 8, 9, 10, 11, 0, 0, 0, 0, 0, 0 , 0, 0},
            .DecNumCh  = 0,
            .DecChList = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
        },
    };
    
    Void MultiChHd_createVcapVencVdis()
    {
        CaptureLink_CreateParams        capturePrm;
        //DupLink_CreateParams            dupPrm[3];
        DisplayLink_CreateParams    displayPrm;
    
    //    MergeLink_CreateParams          mergePrm;
    #if ENABLE_SCL_NSF
        SclrLink_CreateParams           sclrPrm;
    
        NsfLink_CreateParams            nsfParam;
    #endif
    
        IpcLink_CreateParams            ipcOutVpssPrm;
        IpcLink_CreateParams            ipcInVideoPrm;
        EncLink_CreateParams            encPrm;
        IpcBitsOutLinkRTOS_CreateParams ipcBitsOutVideoPrm;
        IpcBitsInLinkHLOS_CreateParams  ipcBitsInHostPrm[1/*2*/];
    
        CaptureLink_VipInstParams *pCaptureInstPrm;
        CaptureLink_OutParams     *pCaptureOutPrm;
        UInt32 vipInstId, i, j;
        UInt32 mergeId;
    
        MULTICH_INIT_STRUCT(IpcLink_CreateParams           ,ipcOutVpssPrm);
        MULTICH_INIT_STRUCT(IpcLink_CreateParams           ,ipcInVideoPrm);
        MULTICH_INIT_STRUCT(IpcBitsOutLinkRTOS_CreateParams,ipcBitsOutVideoPrm);
        MULTICH_INIT_STRUCT(IpcBitsInLinkHLOS_CreateParams ,ipcBitsInHostPrm[0]);
    #if ENABLE_SCL_NSF
        MULTICH_INIT_STRUCT(NsfLink_CreateParams,nsfParam);
    #endif
    
        MULTICH_INIT_STRUCT(EncLink_CreateParams, encPrm);
    //    for (i = 0; i < 2;i++)
      //  {
            MULTICH_INIT_STRUCT(DisplayLink_CreateParams ,displayPrm);
        //}
    
        MultiCh_detectBoard();
    
        System_linkControl(
            SYSTEM_LINK_ID_M3VPSS,
            SYSTEM_M3VPSS_CMD_RESET_VIDEO_DEVICES,
            NULL,
            0,
            TRUE
            );
    
        System_linkControl(
            SYSTEM_LINK_ID_M3VIDEO,
            SYSTEM_COMMON_CMD_SET_CH2IVAHD_MAP_TBL,
            &systemVid_encDecIvaChMapTbl,
            sizeof(SystemVideo_Ivahd2ChMap_Tbl),
            TRUE
        );
    
        gVcapModuleContext.captureId    = SYSTEM_LINK_ID_CAPTURE;
    #if ENABLE_SCL_NSF
        gVcapModuleContext.sclrId[0]       = SYSTEM_LINK_ID_SCLR_INST_0;
        gVcapModuleContext.nsfId[0]     = SYSTEM_LINK_ID_NSF_0;
    #endif
    
        gVdisModuleContext.displayId[0] = SYSTEM_LINK_ID_DISPLAY_0; // ON CHIP HDMI
    
        mergeId = SYSTEM_VPSS_LINK_ID_MERGE_0;
        gVencModuleContext.encId            = SYSTEM_LINK_ID_VENC_0;
        if(/*enableScdAlgLink*/0)
           gVencModuleContext.ipcBitsInHLOSId   = SYSTEM_HOST_LINK_ID_IPC_BITS_IN_1;
        else
           gVencModuleContext.ipcBitsInHLOSId   = SYSTEM_HOST_LINK_ID_IPC_BITS_IN_0;
    
        gVencModuleContext.ipcBitsOutRTOSId = SYSTEM_VIDEO_LINK_ID_IPC_BITS_OUT_0;
    
        gMultiChHd_VcapVencVdisObj.ipcOutVpssId      = SYSTEM_VPSS_LINK_ID_IPC_OUT_M3_0;
        gMultiChHd_VcapVencVdisObj.ipcInVideoId      = SYSTEM_VIDEO_LINK_ID_IPC_IN_M3_0;
    
        CaptureLink_CreateParams_Init(&capturePrm);
    
        capturePrm.numVipInst               = 1;//2*numSubChains; /* Need to change based on actual HD video decoder */
    #if !ENABLE_SCL_NSF
        capturePrm.outQueParams[0].nextLink = gMultiChHd_VcapVencVdisObj.ipcOutVpssId;//gMultiChHd_VcapVencVdisObj.dupId[0];
    #else
        capturePrm.outQueParams[0].nextLink = gVcapModuleContext.sclrId[0];
    #endif
    //    capturePrm.outQueParams[0].nextLink = mergeId;//gMultiChHd_VcapVencVdisObj.dupId[0];
        capturePrm.outQueParams[1].nextLink = gVdisModuleContext.displayId[0];//mergeId;
        capturePrm.tilerEnable              = FALSE;
       // capturePrm.fakeHdMode               = TRUE;
        capturePrm.enableSdCrop             = FALSE;
      //  capturePrm.doCropInCapture          = FALSE;
    //    capturePrm.maxBlindAreasPerCh       = 4;
        capturePrm.numBufsPerCh               = 8;
    //    capturePrm.numExtraBufs               = 6;
    
        for(vipInstId=0; vipInstId<capturePrm.numVipInst; vipInstId++)
        {
            pCaptureInstPrm                     = &capturePrm.vipInst[vipInstId];
            pCaptureInstPrm->vipInstId          = SYSTEM_CAPTURE_INST_VIP0_PORTA; /* Need to change based on actual HD video decoder */
            pCaptureInstPrm->videoDecoderId     = SYSTEM_DEVICE_VID_DEC_TVP7002_DRV; /* Need to change based on actual HD video decoder */
            pCaptureInstPrm->inDataFormat       = SYSTEM_DF_YUV422P;
            pCaptureInstPrm->standard           = SYSTEM_STD_720P_60; /* Need to change based on actual HD video decoder */
            pCaptureInstPrm->numOutput          = 1; /* Need to change based on actual HD video decoder */
    
            pCaptureOutPrm                      = &pCaptureInstPrm->outParams[0];
            pCaptureOutPrm->dataFormat          = /*SYSTEM_DF_YUV422I_YUYV;*/SYSTEM_DF_YUV420SP_UV;
            pCaptureOutPrm->scEnable            = /*TRUE;*/FALSE; /* Need to change based on actual HD video decoder */
            pCaptureOutPrm->scOutWidth          = 176; /* Need to change based on actual HD video decoder */
            pCaptureOutPrm->scOutHeight         = 144; /* Need to change based on actual HD video decoder */
            pCaptureOutPrm->outQueId            = 0;
        }
        printf("**********************vipInstId: %d\n",vipInstId);
    #if 1
        pCaptureInstPrm                     = &capturePrm.vipInst[vipInstId];
        pCaptureInstPrm->vipInstId          = SYSTEM_CAPTURE_INST_VIP1_PORTA; /* Need to change based on actual HD video decoder */
        pCaptureInstPrm->videoDecoderId     = SYSTEM_DEVICE_VID_DEC_TVP7002_DRV; /* Need to change based on actual HD video decoder */
        pCaptureInstPrm->inDataFormat       = SYSTEM_DF_YUV422P;
        pCaptureInstPrm->standard           = SYSTEM_STD_720P_60; /* Need to change based on actual HD video decoder */
        pCaptureInstPrm->numOutput          = 1; /* Need to change based on actual HD video decoder */
    
        pCaptureOutPrm                      = &pCaptureInstPrm->outParams[0];
        pCaptureOutPrm->dataFormat          = SYSTEM_DF_YUV422I_YUYV;//SYSTEM_DF_YUV420SP_UV;
        pCaptureOutPrm->scEnable            = /*TRUE;*/FALSE; /* Need to change based on actual HD video decoder */
        pCaptureOutPrm->scOutWidth          = 176; /* Need to change based on actual HD video decoder */
        pCaptureOutPrm->scOutHeight         = 144; /* Need to change based on actual HD video decoder */
        pCaptureOutPrm->outQueId            = 1;
    #endif
    #if 0
        mergePrm.numInQue = 2;
    
        for(i=0;i<mergePrm.numInQue;i++)
        {
                mergePrm.inQueParams[i].prevLinkId  = gVcapModuleContext.captureId;
                mergePrm.inQueParams[i].prevLinkQueId = 0;
        }
    
        mergePrm.outQueParams.nextLink  = gMultiChHd_VcapVencVdisObj.ipcOutVpssId;
        mergePrm.notifyNextLink         = TRUE;
    #endif
    
    #if ENABLE_SCL_NSF
        SclrLink_CreateParams_Init(&sclrPrm);
        sclrPrm.inQueParams.prevLinkId             = gVcapModuleContext.captureId;//dupId[CAPTURE_DISPLAY_DUP_LINK_IDX];
        sclrPrm.inQueParams.prevLinkQueId          = 0;
    //    sclrPrm.outQueParams.nextLink              = gMultiChHd_VcapVencVdisObj.ipcOutVpssId;
        sclrPrm.outQueParams.nextLink              = gVcapModuleContext.nsfId[0];
        sclrPrm.tilerEnable                        = FALSE;
        sclrPrm.enableLineSkipSc                   = TRUE;//FALSE;
        sclrPrm.inputFrameRate                     = 60;
        sclrPrm.outputFrameRate                    = 60;
        sclrPrm.scaleMode                          = DEI_SCALE_MODE_ABSOLUTE;//DEI_SCALE_MODE_RATIO;
        sclrPrm.outScaleFactor.absoluteResolution.outWidth = 400;
        sclrPrm.outScaleFactor.absoluteResolution.outHeight = 400;
        sclrPrm.numBufsPerCh                                 = 2;
    
        NsfLink_CreateParams_Init(&nsfParam);
        nsfParam.bypassNsf       = TRUE;
        nsfParam.inputFrameRate  = 1;
        nsfParam.outputFrameRate = 1;
        nsfParam.tilerEnable     = FALSE;
        nsfParam.inQueParams.prevLinkId    = gVcapModuleContext.sclrId[0];
        nsfParam.inQueParams.prevLinkQueId = 0;
        nsfParam.numOutQue                 = 1;
        nsfParam.outQueParams[0].nextLink  = gMultiChHd_VcapVencVdisObj.ipcOutVpssId;
        nsfParam.numBufsPerCh              = 2;
    #endif
    
        if(/*enableOsdAlgLink || enableScdAlgLink*/0)
        {
            ipcOutVpssPrm.inQueParams.prevLinkId    = gMultiChHd_VcapVencVdisObj.ipcFrameOutVpssId[0];
        }
        else
        {
    #if !ENABLE_SCL_NSF
            ipcOutVpssPrm.inQueParams.prevLinkId    = gVcapModuleContext.captureId;//gMultiChHd_VcapVencVdisObj.mergeId[4];
    #else
            ipcOutVpssPrm.inQueParams.prevLinkId    = gVcapModuleContext.nsfId[0];
    #endif
        }
    
    //    ipcOutVpssPrm.inQueParams.prevLinkId        = mergeId;
    
        ipcOutVpssPrm.inQueParams.prevLinkQueId = 0;
        ipcOutVpssPrm.outQueParams[0].nextLink  = gMultiChHd_VcapVencVdisObj.ipcInVideoId;
        ipcOutVpssPrm.notifyNextLink            = TRUE;//FALSE;
        ipcOutVpssPrm.notifyPrevLink            = TRUE;
        ipcOutVpssPrm.noNotifyMode              = FALSE;
    
        ipcInVideoPrm.inQueParams.prevLinkId    = gMultiChHd_VcapVencVdisObj.ipcOutVpssId;
        ipcInVideoPrm.inQueParams.prevLinkQueId = 0;
        ipcInVideoPrm.outQueParams[0].nextLink  = gVencModuleContext.encId;
        ipcInVideoPrm.notifyNextLink            = TRUE;
        ipcInVideoPrm.notifyPrevLink            = TRUE;//FALSE;
        ipcInVideoPrm.noNotifyMode              = TRUE;
    
        ipcBitsOutVideoPrm.baseCreateParams.inQueParams.prevLinkId    = gVencModuleContext.encId;
        ipcBitsOutVideoPrm.baseCreateParams.inQueParams.prevLinkQueId = 0;
        ipcBitsOutVideoPrm.baseCreateParams.outQueParams[0].nextLink   = gVencModuleContext.ipcBitsInHLOSId;
        MultiCh_ipcBitsInitCreateParams_BitsOutRTOS(&ipcBitsOutVideoPrm, TRUE);
    
        ipcBitsInHostPrm[0].baseCreateParams.inQueParams.prevLinkId    = gVencModuleContext.ipcBitsOutRTOSId;
        ipcBitsInHostPrm[0].baseCreateParams.inQueParams.prevLinkQueId = 0;
        ipcBitsInHostPrm[0].baseCreateParams.outQueParams[0].nextLink   = SYSTEM_LINK_ID_INVALID;
        MultiCh_ipcBitsInitCreateParams_BitsInHLOS(&ipcBitsInHostPrm[0]);
    
        encPrm.numBufPerCh[0] = 6; //D1
    //    encPrm.numBufPerCh[1] = 6;//4; //CIF
        /* available buffers per channel with CIF and MJPEG encoder support is less*/
        if (/*gVsysModuleContext.vsysConfig.enableMjpegEnc == TRUE*/0)
        {
            encPrm.numBufPerCh[0] = 3;
            encPrm.numBufPerCh[1] = 3;
            encPrm.numBufPerCh[2] = 3;
            encPrm.numBufPerCh[3] = 3;
        }
        {
            EncLink_ChCreateParams *pLinkChPrm;
            EncLink_ChDynamicParams *pLinkDynPrm;
            VENC_CHN_DYNAMIC_PARAM_S *pDynPrm;
            VENC_CHN_PARAMS_S *pChPrm;
    
            /* Primary Stream Params - D1 */
            for (i=0; i<1/*1gVencModuleContext.vencConfig.numPrimaryChn*/; i++)
            {
                pLinkChPrm  = &encPrm.chCreateParams[i];
                pLinkDynPrm = &pLinkChPrm->defaultDynamicParams;
    
                pChPrm      = &gVencModuleContext.vencConfig.encChannelParams[i];
                pDynPrm     = &pChPrm->dynamicParam;
    
                pLinkChPrm->format                  = IVIDEO_H264HP;
                pLinkChPrm->profile                 = gVencModuleContext.vencConfig.h264Profile[i];
                pLinkChPrm->dataLayout              = IVIDEO_FIELD_SEPARATED;
                pLinkChPrm->fieldMergeEncodeEnable  = FALSE;
                pLinkChPrm->enableAnalyticinfo      = pChPrm->enableAnalyticinfo;
                pLinkChPrm->enableWaterMarking      = pChPrm->enableWaterMarking;
                pLinkChPrm->maxBitRate              = pChPrm->maxBitRate;
                pLinkChPrm->encodingPreset          = pChPrm->encodingPreset;
                pLinkChPrm->rateControlPreset       = pChPrm->rcType;
                pLinkChPrm->enableSVCExtensionFlag  = pChPrm->enableSVCExtensionFlag;
                pLinkChPrm->numTemporalLayer        = pChPrm->numTemporalLayer;
    
                pLinkDynPrm->intraFrameInterval     = pDynPrm->intraFrameInterval;
                pLinkDynPrm->targetBitRate          = pDynPrm->targetBitRate;
                pLinkDynPrm->interFrameInterval     = 1;
                pLinkDynPrm->mvAccuracy             = IVIDENC2_MOTIONVECTOR_QUARTERPEL;
                pLinkDynPrm->inputFrameRate         = pDynPrm->inputFrameRate;
                pLinkDynPrm->rcAlg                  = pDynPrm->rcAlg;
                pLinkDynPrm->qpMin                  = pDynPrm->qpMin;
                pLinkDynPrm->qpMax                  = pDynPrm->qpMax;
                pLinkDynPrm->qpInit                 = pDynPrm->qpInit;
                pLinkDynPrm->vbrDuration            = pDynPrm->vbrDuration;
                pLinkDynPrm->vbrSensitivity         = pDynPrm->vbrSensitivity;
                printf("************************pLinkDynPrm->inputFrameRate: %d\n",pLinkDynPrm->inputFrameRate);
            }
    
            encPrm.inQueParams.prevLinkId   = gMultiChHd_VcapVencVdisObj.ipcInVideoId;
            encPrm.inQueParams.prevLinkQueId= 0;
            encPrm.outQueParams.nextLink    = gVencModuleContext.ipcBitsOutRTOSId;
        }
    
        displayPrm.inQueParams[0].prevLinkId    = gVcapModuleContext.captureId;
        displayPrm.inQueParams[0].prevLinkQueId = 1;
    
        displayPrm.displayRes                = gVdisModuleContext.vdisConfig.deviceParams[VDIS_DEV_HDMI].resolution;
    
    #ifndef SYSTEM_USE_VIDEO_DECODER
        capturePrm.isPalMode = Vcap_isPalMode();
    #endif
    
        System_linkCreate (gVcapModuleContext.captureId, &capturePrm, sizeof(capturePrm));
    
        //System_linkCreate(mergeId, &mergePrm, sizeof(mergePrm));
    #if ENABLE_SCL_NSF
        System_linkCreate(gVcapModuleContext.sclrId[0], &sclrPrm, sizeof(sclrPrm));
    
        System_linkCreate(gVcapModuleContext.nsfId[0], &nsfParam, sizeof(nsfParam));
    #endif
        System_linkCreate(gMultiChHd_VcapVencVdisObj.ipcOutVpssId , &ipcOutVpssPrm , sizeof(ipcOutVpssPrm) );
        System_linkCreate(gMultiChHd_VcapVencVdisObj.ipcInVideoId , &ipcInVideoPrm , sizeof(ipcInVideoPrm) );
    
        System_linkCreate(gVencModuleContext.encId, &encPrm, sizeof(encPrm));
        System_linkCreate(gVencModuleContext.ipcBitsOutRTOSId, &ipcBitsOutVideoPrm, sizeof(ipcBitsOutVideoPrm));
        System_linkCreate(gVencModuleContext.ipcBitsInHLOSId, &ipcBitsInHostPrm[0], sizeof(ipcBitsInHostPrm[0]));
        printf("creating display link\n");
        System_linkCreate(gVdisModuleContext.displayId[0], &displayPrm, sizeof(displayPrm));
        printf("display link created\n");
        MultiCh_memPrintHeapStatus();
    }
    
    
    Void MultiChHd_deleteVcapVencVdis()
    {
        UInt32 i;
        Bool enableOsdAlgLink = gVsysModuleContext.vsysConfig.enableOsd;
        Bool enableScdAlgLink = gVsysModuleContext.vsysConfig.enableScd;
    #ifdef TWOOSD_INSTANCE
        Bool   enableOsdAlgLinkA8Path = TRUE;
        Bool   enableScdAlgLinkA8Path = TRUE;
    #else
        Bool   enableOsdAlgLinkA8Path = FALSE;
        Bool   enableScdAlgLinkA8Path = FALSE;
    #endif
        UInt32 noOfDSPAlgo = 2;
        UInt32 ipcBitsOutDSPId;
    
        if(enableOsdAlgLink == FALSE)
            enableOsdAlgLinkA8Path = FALSE;
    
        if(enableScdAlgLink == FALSE)
            enableScdAlgLinkA8Path = FALSE;
    
        if((enableOsdAlgLinkA8Path == FALSE) && (enableScdAlgLinkA8Path == FALSE))
            noOfDSPAlgo = 1;
    
        /* delete can be done in any order */
    
        /* delete can be done in any order */
        ipcBitsOutDSPId = SYSTEM_DSP_LINK_ID_IPC_BITS_OUT_0;
    
        Vcap_delete();
        Venc_delete();
        Vdis_delete();
    
        for(i=0;i<5;i++)
            System_linkDelete(gMultiChHd_VcapVencVdisObj.mergeId[i]);
    
        for(i=0;i<3;i++)
        System_linkDelete(gMultiChHd_VcapVencVdisObj.dupId[i]);
    
    
        if(enableOsdAlgLink || enableScdAlgLink)
        {
            for(i=0;i<noOfDSPAlgo;i++)
            {
               System_linkDelete(gMultiChHd_VcapVencVdisObj.ipcFrameOutVpssId[i] );
               System_linkDelete(gMultiChHd_VcapVencVdisObj.ipcFramesInDspId[i]);
            }
    
            if(enableScdAlgLink)
            {
                System_linkDelete(ipcBitsOutDSPId);
                System_linkDelete(gVcapModuleContext.ipcBitsInHLOSId);
            }
        }
        System_linkDelete(gMultiChHd_VcapVencVdisObj.ipcOutVpssId );
        System_linkDelete(gMultiChHd_VcapVencVdisObj.ipcInVideoId );
        /* Print the HWI, SWI and all tasks load */
        /* Reset the accumulated timer ticks */
        MultiCh_prfLoadCalcEnable(FALSE, TRUE, FALSE);
    
        /* Reenable tiler allocator taht was disabled by this usecase
         * at delete time.
         */
    //    SystemTiler_enableAllocator();
    
    }
    

    Thanks,

    Shabbir Limdiwala

  • Hi Shabbir,

     

    One thing is capturePrm.numVipInst is set to 1, even if you are using two instances, could you try setting it to 2?

     

    Rgds,

    Brijesh

  • There were several mistakes in setting up the connections. Pls use attached file.I have deleted all unnecessary links.

    /*******************************************************************************
     *                                                                             *
     * Copyright (c) 2009 Texas Instruments Incorporated - http://www.ti.com/      *
     *                        ALL RIGHTS RESERVED                                  *
     *                                                                             *
     ******************************************************************************/
    /*
                                              Capture (4CH 1080p30 422)
                                               ******************
                                                    |         |
                                                   DUP0      DUP1
                                                   | | |     | | |
                                                   | | |     | | +---------------------------+
                                                   | | |  +--+ |                             |
                                                   | | +--[----[--------------------------+  |
                                                   | |    |    +--+                       |  |
                                                   | +----[----+  |                      MERGE1
                                                   |      |    |  |                        |
                                                   | +----+  MERGE0                        |
                                                   | |          |                          |
                                                   | |          +----- SC5 ------+         |
                                                   | |             (4CH D1 422)  |        SC5
                                               +---+ +--------+                  |     (4CH 422) (MJPEG)
                                               |              |                  |         |
                                             DEIH (BP-Mode)  DEI (BP-Mode)       |         |
                                              | |            | |                 |  +------+
                                  2CH 1080p30 | |            | | 2CH 1080p30     |  |
                                              | |            | |                 |  |
                                   +----------+ +-----+  +---+ +---+             |  |
                                   |                  |  |            |          |  |
                                   |          +-------[--+            |         MERGE2
                                   |          |       |               |          |  |
                                   |   (DEI-SC2 422)  +--+            |          |  |
                                   |          |          |            |          |  |
                                   |          |          |       (VIP-SC4 420)   |  |
                              (DEI-SC1 422)   |   (VIP-SC3 420)       |          NSF
                                   |          |          |            |           |(4CH D1 420) + 4Ch MJEPG
                                   +--+   +---+          +----+       |           |
                                      |   |                   |       |           |
                                      MERGE3                 |       +--------+  |
                                        |                     +--------------+ |  |
                                       DUP2------------------+               | |  |
                                        |                    |               | |  |
        +--<<<processLink>>>--- IPC Frames Out (M3)          |               | |  |
        |                               |                    |               MERGE4
        |                       IPC Frames IN (A8)           |                 |
      FramesInDSP                       |                    |                 |
        |                       IPC Frames Out (A8)          |              IPC OUT(M3)----<<<processLink>>>---FramesInDSP--+
     ALG LINK                           |                    |                 |                                            |
     <OSD SCD Algs>             IPC Frames IN (M3)           |              IPC IN(M3)                                      |
                                        |              On-Chip HDMI            |                                            |
                                  OFF-Chip HDMI          1080p60      Encode (4CH 1080p30 + 4CH D1)                      ALG_LINK
                                     1080p60          (1-Ch 1-Window)          |                                       <OSD, SCD Algs>
                                 (1-Ch 1-Window)                          IPC Bits OUT (M3)
                                                                               |
                                                                          IPC Bits IN (A8)
    
    (BP-Mode) --> Bypass Mode
    */
    
    #include "multich_common.h"
    
    //#include "mcfw/interfaces/link_api/system_tiler.h"
    
    
    #define     NUM_CAPTURE_DEVICES     (4)
    
    #define     ENABLE_SCL_NSF           0
    
    /* =============================================================================
     * Externs
     * =============================================================================
     */
    
    //static UInt8 SCDChannelMonitor[4] = {4, 5, 6, 7};
    
    //#define TWOOSD_INSTANCE
    
    typedef struct {
    
        UInt32 mergeId[5];
        UInt32 dupId[3];
        UInt32 ipcOutVpssId;
        UInt32 ipcInVideoId;
        UInt32 ipcFrameOutVpssId[2];
        UInt32 ipcFramesInDspId[2];
    } MultiChHd_VcapVencVdisObj;
    
    MultiChHd_VcapVencVdisObj gMultiChHd_VcapVencVdisObj;
    
    /* =============================================================================
     * Use case code
     * =============================================================================
     */
    
    static SystemVideo_Ivahd2ChMap_Tbl systemVid_encDecIvaChMapTbl =
    {
        .isPopulated = 1,
        .ivaMap[0] =
        {
            .EncNumCh  = 2,
            .EncChList = {0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 , 0, 0},
            .DecNumCh  = 0,
            .DecChList = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
        },
        .ivaMap[1] =
        {
            .EncNumCh  = 2,
            .EncChList = {1, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 , 0, 0},
            .DecNumCh  = 0,
            .DecChList = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
        },
        .ivaMap[2] =
        {
            .EncNumCh  = 8,
            .EncChList = {4, 5, 6, 7, 8, 9, 10, 11, 0, 0, 0, 0, 0, 0 , 0, 0},
            .DecNumCh  = 0,
            .DecChList = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
        },
    };
    
    Void MultiChHd_createVcapVencVdis()
    {
        CaptureLink_CreateParams        capturePrm;
        DisplayLink_CreateParams    displayPrm;
        IpcLink_CreateParams            ipcOutVpssPrm;
        IpcLink_CreateParams            ipcInVideoPrm;
        EncLink_CreateParams            encPrm;
        IpcBitsOutLinkRTOS_CreateParams ipcBitsOutVideoPrm;
        IpcBitsInLinkHLOS_CreateParams  ipcBitsInHostPrm;
    
        CaptureLink_VipInstParams *pCaptureInstPrm;
        CaptureLink_OutParams     *pCaptureOutPrm;
        UInt32 vipInstId, i, j;
    
        MULTICH_INIT_STRUCT(IpcLink_CreateParams           ,ipcOutVpssPrm);
        MULTICH_INIT_STRUCT(IpcLink_CreateParams           ,ipcInVideoPrm);
        MULTICH_INIT_STRUCT(IpcBitsOutLinkRTOS_CreateParams,ipcBitsOutVideoPrm);
        MULTICH_INIT_STRUCT(IpcBitsInLinkHLOS_CreateParams ,ipcBitsInHostPrm);
    	MULTICH_INIT_STRUCT(CaptureLink_CreateParams ,capturePrm);
        MULTICH_INIT_STRUCT(EncLink_CreateParams, encPrm);
        MULTICH_INIT_STRUCT(DisplayLink_CreateParams ,displayPrm);
    
        MultiCh_detectBoard();
    
        System_linkControl(
            SYSTEM_LINK_ID_M3VPSS,
            SYSTEM_M3VPSS_CMD_RESET_VIDEO_DEVICES,
            NULL,
            0,
            TRUE
            );
    
        System_linkControl(
            SYSTEM_LINK_ID_M3VIDEO,
            SYSTEM_COMMON_CMD_SET_CH2IVAHD_MAP_TBL,
            &systemVid_encDecIvaChMapTbl,
            sizeof(SystemVideo_Ivahd2ChMap_Tbl),
            TRUE
        );
    
        gVcapModuleContext.captureId    = SYSTEM_LINK_ID_CAPTURE;
        gVdisModuleContext.displayId[0] = SYSTEM_LINK_ID_DISPLAY_0; // ON CHIP HDMI
        gVencModuleContext.encId            = SYSTEM_LINK_ID_VENC_0;
        gVencModuleContext.ipcBitsInHLOSId   = SYSTEM_HOST_LINK_ID_IPC_BITS_IN_0;
        gVencModuleContext.ipcBitsOutRTOSId = SYSTEM_VIDEO_LINK_ID_IPC_BITS_OUT_0;
    
        gMultiChHd_VcapVencVdisObj.ipcOutVpssId      = SYSTEM_VPSS_LINK_ID_IPC_OUT_M3_0;
        gMultiChHd_VcapVencVdisObj.ipcInVideoId      = SYSTEM_VIDEO_LINK_ID_IPC_IN_M3_0;
    
        CaptureLink_CreateParams_Init(&capturePrm);
    
        capturePrm.numVipInst               = 2;
        capturePrm.outQueParams[0].nextLink = gMultiChHd_VcapVencVdisObj.ipcOutVpssId;
        capturePrm.outQueParams[1].nextLink = gVdisModuleContext.displayId[0];//mergeId;
        capturePrm.tilerEnable              = FALSE;
        capturePrm.enableSdCrop             = FALSE;
        capturePrm.numBufsPerCh               = 8;
        vipInstId = 0;
    	{
            pCaptureInstPrm                     = &capturePrm.vipInst[vipInstId];
            pCaptureInstPrm->vipInstId          = SYSTEM_CAPTURE_INST_VIP0_PORTA; /* Need to change based on actual HD video decoder */
            pCaptureInstPrm->videoDecoderId     = SYSTEM_DEVICE_VID_DEC_TVP7002_DRV; /* Need to change based on actual HD video decoder */
            pCaptureInstPrm->inDataFormat       = SYSTEM_DF_YUV422P;
            pCaptureInstPrm->standard           = SYSTEM_STD_720P_60; /* Need to change based on actual HD video decoder */
            pCaptureInstPrm->numOutput          = 1; /* Need to change based on actual HD video decoder */
    
            pCaptureOutPrm                      = &pCaptureInstPrm->outParams[0];
            pCaptureOutPrm->dataFormat          = SYSTEM_DF_YUV420SP_UV;
            pCaptureOutPrm->scEnable            = FALSE; /* Need to change based on actual HD video decoder */
            pCaptureOutPrm->scOutWidth          = 176; /* Need to change based on actual HD video decoder */
            pCaptureOutPrm->scOutHeight         = 144; /* Need to change based on actual HD video decoder */
            pCaptureOutPrm->outQueId            = 0;
        }
    	vipInstId = 1;
    	{
    		pCaptureInstPrm                     = &capturePrm.vipInst[vipInstId];
    		pCaptureInstPrm->vipInstId          = SYSTEM_CAPTURE_INST_VIP1_PORTA; /* Need to change based on actual HD video decoder */
    		pCaptureInstPrm->videoDecoderId     = SYSTEM_DEVICE_VID_DEC_TVP7002_DRV; /* Need to change based on actual HD video decoder */
    		pCaptureInstPrm->inDataFormat       = SYSTEM_DF_YUV422P;
    		pCaptureInstPrm->standard           = SYSTEM_STD_720P_60; /* Need to change based on actual HD video decoder */
    		pCaptureInstPrm->numOutput          = 1; /* Need to change based on actual HD video decoder */
    
    		pCaptureOutPrm                      = &pCaptureInstPrm->outParams[0];
    		pCaptureOutPrm->dataFormat          = SYSTEM_DF_YUV422I_YUYV;//SYSTEM_DF_YUV420SP_UV;
    		pCaptureOutPrm->scEnable            = FALSE; /* Need to change based on actual HD video decoder */
    		pCaptureOutPrm->scOutWidth          = 176; /* Need to change based on actual HD video decoder */
    		pCaptureOutPrm->scOutHeight         = 144; /* Need to change based on actual HD video decoder */
    		pCaptureOutPrm->outQueId            = 1;
    	}
    
        ipcOutVpssPrm.inQueParams.prevLinkId    = gVcapModuleContext.captureId;//gMultiChHd_VcapVencVdisObj.mergeId[4];
    
    //    ipcOutVpssPrm.inQueParams.prevLinkId        = mergeId;
    
        ipcOutVpssPrm.inQueParams.prevLinkQueId = 0;
        ipcOutVpssPrm.outQueParams[0].nextLink  = gMultiChHd_VcapVencVdisObj.ipcInVideoId;
        ipcOutVpssPrm.notifyNextLink            = TRUE;//FALSE;
        ipcOutVpssPrm.notifyPrevLink            = TRUE;
        ipcOutVpssPrm.noNotifyMode              = FALSE;
    
        ipcInVideoPrm.inQueParams.prevLinkId    = gMultiChHd_VcapVencVdisObj.ipcOutVpssId;
        ipcInVideoPrm.inQueParams.prevLinkQueId = 0;
        ipcInVideoPrm.outQueParams[0].nextLink  = gVencModuleContext.encId;
        ipcInVideoPrm.notifyNextLink            = TRUE;
        ipcInVideoPrm.notifyPrevLink            = TRUE;//FALSE;
        ipcInVideoPrm.noNotifyMode              = TRUE;
    
        ipcBitsOutVideoPrm.baseCreateParams.inQueParams.prevLinkId    = gVencModuleContext.encId;
        ipcBitsOutVideoPrm.baseCreateParams.inQueParams.prevLinkQueId = 0;
        ipcBitsOutVideoPrm.baseCreateParams.outQueParams[0].nextLink   = gVencModuleContext.ipcBitsInHLOSId;
        MultiCh_ipcBitsInitCreateParams_BitsOutRTOS(&ipcBitsOutVideoPrm, TRUE);
    
        ipcBitsInHostPrm[0].baseCreateParams.inQueParams.prevLinkId    = gVencModuleContext.ipcBitsOutRTOSId;
        ipcBitsInHostPrm[0].baseCreateParams.inQueParams.prevLinkQueId = 0;
        ipcBitsInHostPrm[0].baseCreateParams.outQueParams[0].nextLink   = SYSTEM_LINK_ID_INVALID;
        MultiCh_ipcBitsInitCreateParams_BitsInHLOS(&ipcBitsInHostPrm[0]);
    
        encPrm.numBufPerCh[0] = 6; //D1
        {
            EncLink_ChCreateParams *pLinkChPrm;
            EncLink_ChDynamicParams *pLinkDynPrm;
            VENC_CHN_DYNAMIC_PARAM_S *pDynPrm;
            VENC_CHN_PARAMS_S *pChPrm;
    
            /* Primary Stream Params - D1 */
            for (i=0; i<1; i++)
            {
                pLinkChPrm  = &encPrm.chCreateParams[i];
                pLinkDynPrm = &pLinkChPrm->defaultDynamicParams;
    
                pChPrm      = &gVencModuleContext.vencConfig.encChannelParams[i];
                pDynPrm     = &pChPrm->dynamicParam;
    
                pLinkChPrm->format                  = IVIDEO_H264HP;
                pLinkChPrm->profile                 = gVencModuleContext.vencConfig.h264Profile[i];
                pLinkChPrm->dataLayout              = IVIDEO_FIELD_SEPARATED;
                pLinkChPrm->fieldMergeEncodeEnable  = FALSE;
                pLinkChPrm->enableAnalyticinfo      = pChPrm->enableAnalyticinfo;
                pLinkChPrm->enableWaterMarking      = pChPrm->enableWaterMarking;
                pLinkChPrm->maxBitRate              = pChPrm->maxBitRate;
                pLinkChPrm->encodingPreset          = pChPrm->encodingPreset;
                pLinkChPrm->rateControlPreset       = pChPrm->rcType;
                pLinkChPrm->enableSVCExtensionFlag  = pChPrm->enableSVCExtensionFlag;
                pLinkChPrm->numTemporalLayer        = pChPrm->numTemporalLayer;
    
                pLinkDynPrm->intraFrameInterval     = pDynPrm->intraFrameInterval;
                pLinkDynPrm->targetBitRate          = pDynPrm->targetBitRate;
                pLinkDynPrm->interFrameInterval     = 1;
                pLinkDynPrm->mvAccuracy             = IVIDENC2_MOTIONVECTOR_QUARTERPEL;
                pLinkDynPrm->inputFrameRate         = pDynPrm->inputFrameRate;
                pLinkDynPrm->rcAlg                  = pDynPrm->rcAlg;
                pLinkDynPrm->qpMin                  = pDynPrm->qpMin;
                pLinkDynPrm->qpMax                  = pDynPrm->qpMax;
                pLinkDynPrm->qpInit                 = pDynPrm->qpInit;
                pLinkDynPrm->vbrDuration            = pDynPrm->vbrDuration;
                pLinkDynPrm->vbrSensitivity         = pDynPrm->vbrSensitivity;
                printf("************************pLinkDynPrm->inputFrameRate: %d\n",pLinkDynPrm->inputFrameRate);
            }
    
            encPrm.inQueParams.prevLinkId   = gMultiChHd_VcapVencVdisObj.ipcInVideoId;
            encPrm.inQueParams.prevLinkQueId= 0;
            encPrm.outQueParams.nextLink    = gVencModuleContext.ipcBitsOutRTOSId;
        }
    
        displayPrm.inQueParams[0].prevLinkId    = gVcapModuleContext.captureId;
        displayPrm.inQueParams[0].prevLinkQueId = 1;
    
        displayPrm.displayRes                = gVdisModuleContext.vdisConfig.deviceParams[VDIS_DEV_HDMI].resolution;
    
    #ifndef SYSTEM_USE_VIDEO_DECODER
        capturePrm.isPalMode = Vcap_isPalMode();
    #endif
    
        System_linkCreate (gVcapModuleContext.captureId, &capturePrm, sizeof(capturePrm));
    
        //System_linkCreate(mergeId, &mergePrm, sizeof(mergePrm));
        System_linkCreate(gMultiChHd_VcapVencVdisObj.ipcOutVpssId , &ipcOutVpssPrm , sizeof(ipcOutVpssPrm) );
        System_linkCreate(gMultiChHd_VcapVencVdisObj.ipcInVideoId , &ipcInVideoPrm , sizeof(ipcInVideoPrm) );
    
        System_linkCreate(gVencModuleContext.encId, &encPrm, sizeof(encPrm));
        System_linkCreate(gVencModuleContext.ipcBitsOutRTOSId, &ipcBitsOutVideoPrm, sizeof(ipcBitsOutVideoPrm));
        System_linkCreate(gVencModuleContext.ipcBitsInHLOSId, &ipcBitsInHostPrm[0], sizeof(ipcBitsInHostPrm[0]));
        System_linkCreate(gVdisModuleContext.displayId[0], &displayPrm, sizeof(displayPrm));
        MultiCh_memPrintHeapStatus();
    }
    
    
    

  • Hi,

    Yes Now it's working. There were two things i was missing.

    MULTICH_INIT_STRUCT(CaptureLink_CreateParams ,capturePrm);

    capturePrm.numVipInst               = 2;

    It is working fine now. Thanks Brijesh and Badri for your support.

    Thanks,

    Shabbir Limdiwala