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.

usecase support for 2 channels with dvrrdk

Guru 20755 points

Hello,

I am trying to capture 2 channels and display them through swms.

channel 0 is capturing SYSTEM_CAPTURE_INST_VIP1_PORTA, and channel 1 is capturing SYSTEM_CAPTURE_INST_VIP0_PORTA

I expected to find one channel as display ch 0, and the second channel as display channel 1, but I can only display channel 0. I also tried to see if I find channel #1 by changing swms to  4x4, but I can't see it, only channel 0.

When I create 2 usecases and in each I capture only one channel into channel 0 (in 1 usecase SYSTEM_CAPTURE_INST_VIP1_PORTA and in the second SYSTEM_CAPTURE_INST_VIP0_PORTA), it all works well, but I need them both as channel 0 and channel 1 (for fast switch between them in display/encode).

How can I start debugging this issue ?

Please advise ....

Thank you very much,

Ran

/* ranran new file */
/**
  \file demo_vcap_venc_vdec_vdis.c
  \brief
  */
#include <sys/time.h>
#include <demo_vcap_venc_vdec_vdis.h>
#include <demo_scd_bits_wr.h>

/* Setting secondary out <CIF> for 30 frames - this is the validated frame rate;
any higher number will impact performance. */


#define     CIF_FPS_ENC_NTSC         (30)
#define     CIF_FPS_ENC_PAL          (25)

#define     CIF_BITRATE         (500)
#define     MJPEG_BITRATE       (100)

int g_portIn = 0;
Void Demo_displayChangeFpsForLayout (VDIS_MOSAIC_S *vdMosaicParam, UInt32 layoutId);

static Int64 get_current_time_to_msec(void)
{
    struct timeval tv;
    gettimeofday(&tv, NULL);

    return ((Int64)tv.tv_sec*1000 + tv.tv_usec/1000);
}

/* used in 814x 16ch usecase */
#define H264_PRIMARY_STREAM_PROFILE     VENC_CHN_MAIN_PROFILE
#define H264_SECONDARY_STREAM_PROFILE   VENC_CHN_BASELINE_PROFILE

/* used to set resolution / buf size of ipcbits for varying resolutions based on usecase */
VcapVencVdecVdis_chBufInfo ipcBitsChInfo[MCFW_IPCBITS_MAX_CHANNELS];


Void CommitVcapVencVdecVdis_setChannels(int demoId, int *pEnable2ndOut)
{
    Int32 i;

    printf("ranran CommitVcapVencVdecVdis_setChannels 1");
    memset(ipcBitsChInfo, 0, sizeof(ipcBitsChInfo));

    switch (demoId)
    {
         case DEMO_COMMIT_VENC_VDIS:
            printf("ranran CommitVcapVencVdecVdis_setChannels 22");

            gDemo_info.maxVcapChannels = 2;
            gDemo_info.maxVdisChannels = 2;
            gDemo_info.maxVencChannels = 2;
            gDemo_info.maxVdecChannels = 0;
            gDemo_info.VsysNumChs      = 2;
            for(i=0; i<gDemo_info.maxVencChannels; i++)
            {
                ipcBitsChInfo[i].width = MCFW_IPCBITS_HD_WIDTH;
                ipcBitsChInfo[i].height = MCFW_IPCBITS_HD_HEIGHT;
                ipcBitsChInfo[i].chBufSize = ipcBitsChInfo[i].width * ipcBitsChInfo[i].height;
            }
            break;



        default:
            break;
    }
}



Void CommitVcapVencVdecVdis_start( Bool doProgressiveVenc, Bool enableSecondaryOut, int demoId, int port)
{
    UInt32 i, resolutionClass;
    VSYS_PARAMS_S vsysParams;
    VCAP_PARAMS_S vcapParams;
    VENC_PARAMS_S vencParams;
    VDEC_PARAMS_S vdecParams;
    VDIS_PARAMS_S vdisParams;
    Bool forceLowCostScale = FALSE, enableFWrite = FALSE, enableLayerWrite = FALSE;
    Int32 Enable2ndOut = enableSecondaryOut;
    static VDIS_MOSAIC_S vdMosaicParam;
    int startChId;
    int layoutId = DEMO_LAYOUT_MODE_4CH_4CH;
    UInt64 wallTimeBase;

    g_portIn = port;

    Vsys_params_init(&vsysParams);
    Vcap_params_init(&vcapParams);
    Venc_params_init(&vencParams);
    Vdec_params_init(&vdecParams);
    Vdis_params_init(&vdisParams);

    CommitVcapVencVdecVdis_setChannels(demoId, &Enable2ndOut);


    vcapParams.numChn = gDemo_info.maxVcapChannels;
    vencParams.numPrimaryChn = gDemo_info.maxVencChannels;
    vencParams.numSecondaryChn = 0;
    vdecParams.numChn = gDemo_info.maxVdecChannels;
    vdisParams.numChannels = gDemo_info.maxVdisChannels;
    vsysParams.numChs  = gDemo_info.VsysNumChs;

    enableSecondaryOut = (Bool)Enable2ndOut;


    resolutionClass = DEMO_SCD_RESOLUTION_CLASS_QCIF;
    if( doProgressiveVenc)
    {
		vsysParams.systemUseCase = VSYS_USECASE_COMMIT_VCAP_VENC_VDIS;


        if (enableSecondaryOut == FALSE)
        {
            vsysParams.enableSecondaryOut = FALSE;
            vsysParams.enableNsf     = FALSE;
        }
        else
        {
            vsysParams.enableSecondaryOut = TRUE;
            vsysParams.enableNsf     = TRUE;
            vsysParams.enableMjpegEnc = TRUE;
        }
		printf("11 vsysParams.systemUseCase = %d %d\n",vsysParams.systemUseCase,DEMO_COMMIT_VENC_VDIS);
        vsysParams.enableCapture = TRUE;
        vsysParams.enableNullSrc = FALSE;

        vsysParams.enableOsd     = TRUE;


        vsysParams.enableScd     = FALSE;
        vsysParams.numDeis       = 1;
        vsysParams.numSwMs       = 2;
        vsysParams.numDisplays   = 2;
        vsysParams.enableAVsync  = TRUE;

    }

    if (enableSecondaryOut)
    {
        vencParams.numSecondaryChn = gDemo_info.maxVencChannels;
        /*enableMjpegEnc should always be true in all usecases*/
        gDemo_info.maxVencChannels *= 3;
    }

    printf ("--------------- CHANNEL DETAILS-------------\n");
    printf ("Capture Channels => %d\n", vcapParams.numChn);
    printf ("Enc Channels => Primary %d, Secondary %d\n", vencParams.numPrimaryChn, vencParams.numSecondaryChn);
    printf ("Dec Channels => %d\n", vdecParams.numChn);
    printf ("Disp Channels => %d\n", vdisParams.numChannels);
    printf ("-------------------------------------------\n");

    Vsys_enableFastUsecaseSwitch(FALSE);
    if ((vsysParams.systemUseCase == VSYS_USECASE_MULTICHN_HD_VCAP_VENC) ||
    	(vsysParams.systemUseCase == VSYS_USECASE_COMMIT_VCAP_VENC_VDIS))
    {
    	printf("ranran osd disable !!!!!!!!!!\n");
        vsysParams.enableScd     = FALSE;
        vsysParams.enableOsd     = FALSE;
        vsysParams.numDeis       = 1;
        vsysParams.numSwMs       = 1;
        vsysParams.numDisplays   = 1;
        vsysParams.enableAVsync  = FALSE;
    }
    /* Override the context here as needed */
    Vsys_init(&vsysParams);
    //ranran

    vcapParams.enableConfigExtVideoDecoder = FALSE;
    /* Override the context here as needed */
    Vcap_init(&vcapParams);

    /*Enabling generation of motion vector for channel 0 only,
         * for other channels please add to the below line*/

    vencParams.encChannelParams[0].enableAnalyticinfo = 1;
    //vencParams.encChannelParams[1].enableAnalyticinfo = 1;
    vencParams.encChannelParams[0].maxBitRate = -1;

    /*Note:Specific for h264 Encoder: Enabling this flag adds svc extension
          headers to the stream, not all decoders are generally able to play back such a stream. */
    /* Needs to be enabled to IH264_SVC_EXTENSION_FLAG_ENABLE for the
          svc extension headers to be present in the stream*/
    vencParams.encChannelParams[0].enableSVCExtensionFlag =
                                       VENC_IH264_SVC_EXTENSION_FLAG_DISABLE;

    /** Note: For the encoder to give out frames with SVC-T properties,
             number of layers needs to be increased as per requirement.
             A flag enableLayerWrite needs to be set if for any channel the Layer is increased to beyond 1.
             This check has also been done for Channel 0, just before VcapVencVdecVdis_ipcBitsInit call.

             For example for Channel 0 it has been set to LAYERS_4,
             file stream dump will generate four(Base + 3) files with differing frame-rates**/
    /** WARNING: SVC-T cannot be used if B Frame is enabled */
    vencParams.encChannelParams[0].numTemporalLayer = VENC_TEMPORAL_LAYERS_4;
#ifdef USE_CAMERA
    vencParams.encChannelParams[0].dynamicParam.frameRate = 25 * 1000;
#else
    vencParams.encChannelParams[0].dynamicParam.frameRate = 30 * 1000;
#endif

    //vencParams.encChannelParams[0].dynamicParam.frameRate = 10 * 1000;

    printf("ranran framerate in demo %d\n",vencParams.encChannelParams[0].dynamicParam.frameRate);
    /* Override the context here as needed */
    Venc_init(&vencParams);


    /* Override the context here as needed */
    Vdec_init(&vdecParams);

    /* Override the context here as needed */
    vdisParams.deviceParams[VDIS_DEV_HDMI].resolution   = DEMO_HD_DISPLAY_DEFAULT_STD;
    vdisParams.deviceParams[VDIS_DEV_DVO2].resolution = DEMO_HD_DISPLAY_DEFAULT_STD;
    vdisParams.deviceParams[VDIS_DEV_HDCOMP].resolution = DEMO_HD_DISPLAY_DEFAULT_STD;
    vdisParams.mosaicLayoutResolution[VDIS_DEV_HDMI] =
        vdisParams.deviceParams[VDIS_DEV_HDMI].resolution;
    vdisParams.mosaicLayoutResolution[VDIS_DEV_DVO2] =
        vdisParams.deviceParams[VDIS_DEV_DVO2].resolution;
    vdisParams.mosaicLayoutResolution[VDIS_DEV_HDCOMP] =
        vdisParams.deviceParams[VDIS_DEV_HDCOMP].resolution;

    Vdis_tiedVencInit(VDIS_DEV_DVO2, VDIS_DEV_HDCOMP, &vdisParams);

    vdisParams.deviceParams[VDIS_DEV_SD].resolution     = VSYS_STD_NTSC;
    vdisParams.mosaicLayoutResolution[VDIS_DEV_SD] =
        vdisParams.deviceParams[VDIS_DEV_SD].resolution;

    vdisParams.enableLayoutGridDraw = FALSE;

    if (vsysParams.systemUseCase == VSYS_USECASE_MULTICHN_INTERLACED_VCAP_VDIS_VENC_VDEC)
        forceLowCostScale = TRUE;


    i = 0;
    /* set for 2 displays */

        Demo_swMsGenerateLayout(VDIS_DEV_HDMI, 0, gDemo_info.maxVdisChannels,
						  DEMO_LAYOUT_MODE_1CH,
                          &vdisParams.mosaicParams[VDIS_DEV_HDMI], forceLowCostScale,
                          gDemo_info.Type,
                          Vdis_getSwMsLayoutResolution(VDIS_DEV_HDMI));

    vdisParams.mosaicParams[VDIS_DEV_HDMI].userSetDefaultSWMLayout = TRUE;
    /* Set swMS outputFPS as 60 or 50 for this default 7x1 layout for TI814X */

    Demo_swMsSetOutputFPS(&vdisParams.mosaicParams[VDIS_DEV_HDMI], Demo_swMsGetOutputFPS(&vdisParams.mosaicParams[VDIS_DEV_HDMI])*2);


        Demo_swMsGenerateLayout(VDIS_DEV_SD, 0, gDemo_info.maxVdisChannels,
        		DEMO_LAYOUT_MODE_1CH,
                          &vdisParams.mosaicParams[VDIS_DEV_SD], forceLowCostScale,
                          gDemo_info.Type,
                          Vdis_getSwMsLayoutResolution(VDIS_DEV_SD));

    vdisParams.mosaicParams[VDIS_DEV_SD].userSetDefaultSWMLayout = TRUE;

    Demo_swMsSetOutputFPS(&vdisParams.mosaicParams[VDIS_DEV_SD], Demo_swMsGetOutputFPS(&vdisParams.mosaicParams[VDIS_DEV_SD])*2);

    //ranran we don't use this in elbit card
    vdisParams. enableConfigExtVideoEncoder = FALSE;
    vdisParams. enableConfigExtThsFilter = FALSE;

    Vdis_init(&vdisParams);

    enableFWrite = TRUE;

    /* Init the application specific module which will handle bitstream exchange */


    /*h264 Enc: Needs to be checked for any channel where this flag is enabled,
         * right now just checking for channel 0, default value for other codecs is 0*/
    /* ranran if(vencParams.encChannelParams[0].numTemporalLayer > 1)*/
        enableLayerWrite = FALSE; /*ranran */

    VcapVencVdecVdis_ipcBitsSetFileExtension("h264");
    VcapVencVdecVdis_ipcBitsInit(ipcBitsChInfo, enableFWrite, enableLayerWrite , TRUE);

    /* Start audio capture */
    /* ranran CommitDemo_startAudio(demoId); */

    wallTimeBase = get_current_time_to_msec();
    //wallTimeBase = 0;
    Vdis_setWallTimeBase(wallTimeBase);

    /* Configure display in order to start grpx before video */
    Vsys_configureDisplay();

#if USE_FBDEV
    grpx_init(GRPX_FORMAT_RGB565);
#endif


    /* Create Link instances and connects compoent blocks */
    Vsys_create();


    /* Start components in reverse order */
    Vdis_start();
    Vdec_start();
    Venc_start();
    Vcap_start();


    printf("<<<<<<<<<< type %d channels %d res %d [ranran]\n",gDemo_info.Type,gDemo_info.maxVdisChannels,Vdis_getSwMsLayoutResolution(VDIS_DEV_HDMI));
    Demo_displaySetResolution(VDIS_DEV_HDMI, VSYS_STD_XGA_60);

   forceLowCostScale = FALSE;

   startChId = 0;

   Demo_swMsGenerateLayout(
		   VDIS_DEV_HDMI,
			   startChId,
			   gDemo_info.maxVdisChannels,
			   layoutId,
			   &vdMosaicParam,
			   forceLowCostScale,
			   gDemo_info.Type,
			   Vdis_getSwMsLayoutResolution(VDIS_DEV_HDMI)
		   );
   //Demo_displaySwitchChn(VDIS_DEV_HDMI, startChId);
   Demo_displayChangeFpsForLayout(&vdMosaicParam,layoutId);
   Vdis_setMosaicParams(VDIS_DEV_HDMI,&vdMosaicParam);

}



Void CommitVcapVencVdecVdis_stop()
{
    VSYS_PARAMS_S contextInf;
    Vsys_getContext(&contextInf);

    Vsys_enableFastUsecaseSwitch(FALSE);

    printf("++++++++ VcapVencVdecVdis_stop()\n");

    /* Stop components */

    VcapVencVdecVdis_ipcBitsStop();

    Vcap_stop();
    Venc_stop();
    Vdec_stop();
    Vdis_stop();


#if USE_FBDEV
     grpx_exit();
#endif


    Vsys_delete();

    Vsys_deConfigureDisplay();

    VcapVencVdecVdis_ipcBitsExit();

    /* De-initialize components */
    Vcap_exit();
    Venc_exit();
    Vdec_exit();
    Vdis_exit();

    Vsys_exit();

}

/*******************************************************************************
 *                                                                             *
 * Copyright (c) 2009 Texas Instruments Incorporated - http://www.ti.com/      *
 *                        ALL RIGHTS RESERVED                                  *
 *                                                                             *
 ******************************************************************************/
/* ranran new file */
/*
                    Capture (YUV422I) 1CH 720P 60fps
                      |
                      |
                      |            
        DEIH (DEI-SC YUV422I )     
                      |           
                      |
                      |
                     DUP
                     | |
     +---------  ----  NSF (YUV420)-----IPC-OUT(VPSS)---IPC-IN(VIDEO-M3)---ENC--IPCBITS-OUT(M3)---IPCBITS-IN(Host)
     |                                      
     |                                       
  SW Mosaic          
 (SC5 YUV422I)  
     |                          
On-Chip HDMI    
  1080p60         
*/

#include "mcfw/src_linux/mcfw_api/usecases/multich_common.h"
#include "mcfw/src_linux/mcfw_api/usecases/multich_ipcbits.h"
#include "mcfw/src_linux/mcfw_api/ti_vdis_priv.h"
#include "mcfw/src_linux/devices/tw2968/src/tw2968_priv.h"
#include "mcfw/src_linux/devices/tvp5158/src/tvp5158_priv.h"
#include "mcfw/interfaces/link_api/system_tiler.h"
#include "mcfw/interfaces/link_api/avsync_hlos.h"
#include "mcfw/interfaces/ti_vdis_timings.h"




/* =============================================================================
 * Use case code
 * =============================================================================
 */

extern int g_portIn;

static
Void MultiCh_singlewin_layoutprm(SwMsLink_LayoutPrm *layoutInfo,VSYS_VIDEO_STANDARD_E outRes)
{
    SwMsLink_LayoutWinInfo *winInfo;
    UInt32 outWidth, outHeight, winId, widthAlign, heightAlign;

    MultiCh_swMsGetOutSize(outRes, &outWidth, &outHeight);
    widthAlign = 8;
    heightAlign = 1;

    /* init to known default */
    memset(layoutInfo, 0, sizeof(*layoutInfo));

    layoutInfo->onlyCh2WinMapChanged = FALSE;
    layoutInfo->outputFPS = 60;
    layoutInfo->numWin = 1;
    winId = 0;

    winInfo = &layoutInfo->winInfo[winId];

    winInfo->width  = SystemUtils_floor(outWidth, widthAlign);
    winInfo->height = SystemUtils_floor(outHeight, heightAlign);
    winInfo->startX = 0;
    winInfo->startY = 0;
    winInfo->bypass = FALSE;
 	winInfo->channelNum = 0;
}

#define MAX_NUM_CAPTURE_DEVICES     (4)
VCAP_DEVICE_CREATE_PARAM_S        vidDecVideoModeArgs[MAX_NUM_CAPTURE_DEVICES];


#define     NUM_CAPTURE_DEVICES          1

Void CommitCh_createHdDvr()
{
    CaptureLink_CreateParams    capturePrm;
    DeiLink_CreateParams        deiPrm;
    DupLink_CreateParams        dupPrm; /* ranran , dupPrm1; */
    SwMsLink_CreateParams       swMsPrm;
    DisplayLink_CreateParams    displayPrm;
    NsfLink_CreateParams        nsfPrm;

    CaptureLink_VipInstParams *pCaptureInstPrm;
    CaptureLink_OutParams     *pCaptureOutPrm;

    EncLink_ChCreateParams *pLinkChPrm;
    EncLink_ChDynamicParams *pLinkDynPrm;
    VENC_CHN_DYNAMIC_PARAM_S *pDynPrm;
    VENC_CHN_PARAMS_S *pChPrm;
    IpcLink_CreateParams            ipcOutVpssPrm;
    IpcLink_CreateParams            ipcInVideoPrm;
    EncLink_CreateParams            encPrm;
    IpcBitsOutLinkRTOS_CreateParams ipcBitsOutVideoPrm;
    IpcBitsInLinkHLOS_CreateParams  ipcBitsInHostPrm;
   /* MergeLink_CreateParams      mergePrm; ranran */
    
    UInt32 grpxId[VDIS_DEV_MAX];
    UInt32 dupId;
    /*ranran UInt32 mergeId, dupId1;*/
    UInt32 deiOutQue;
    UInt32 ipcOutVpssId;
    UInt32 ipcInVideoId;
    UInt32 chId;
    int vipInstId;

    MULTICH_INIT_STRUCT(CaptureLink_CreateParams ,capturePrm);
    MULTICH_INIT_STRUCT(DeiLink_CreateParams ,deiPrm);
    MULTICH_INIT_STRUCT(NsfLink_CreateParams ,nsfPrm);
    MULTICH_INIT_STRUCT(IpcLink_CreateParams ,ipcInVideoPrm);
    MULTICH_INIT_STRUCT(IpcBitsOutLinkRTOS_CreateParams,ipcBitsOutVideoPrm);
    MULTICH_INIT_STRUCT(IpcBitsInLinkHLOS_CreateParams,ipcBitsInHostPrm);
    MULTICH_INIT_STRUCT(DisplayLink_CreateParams,displayPrm);
    MULTICH_INIT_STRUCT(SwMsLink_CreateParams ,swMsPrm);
    MULTICH_INIT_STRUCT(EncLink_CreateParams, encPrm);



    MultiCh_detectBoard();

    System_linkControl(
        SYSTEM_LINK_ID_M3VPSS,
        SYSTEM_M3VPSS_CMD_RESET_VIDEO_DEVICES,
        NULL,
        0,
        TRUE
        );
    //ranran
#ifdef USE_CAMERA
    gVcapModuleContext.isPalMode = TRUE;
#else
    gVcapModuleContext.isPalMode = FALSE;
#endif

    capturePrm.isPalMode = Vcap_isPalMode();
    printf("ranran pal mode = %d (0-ntsc, 1 - pal)\n", capturePrm.isPalMode);
    gVcapModuleContext.captureId    = SYSTEM_LINK_ID_CAPTURE;
    gVcapModuleContext.nsfId[0]     = SYSTEM_LINK_ID_NSF_0;
    gVcapModuleContext.deiId[0]     = SYSTEM_LINK_ID_DEI_0;
    dupId                           = SYSTEM_VPSS_LINK_ID_DUP_0;
   /* ranran dupId1                          = SYSTEM_VPSS_LINK_ID_DUP_1;
    mergeId                         = SYSTEM_VPSS_LINK_ID_MERGE_0; */

    gVdisModuleContext.swMsId[0]    = SYSTEM_LINK_ID_SW_MS_MULTI_INST_0;
    swMsPrm.numSwMsInst             = 1;
    swMsPrm.swMsInstId[0]           = SYSTEM_SW_MS_SC_INST_SC5; /* ranran was SYSTEM_SW_MS_SC_INST_DEI_SC */

    gVdisModuleContext.displayId[0] = SYSTEM_LINK_ID_DISPLAY_0; // ON CHIP HDMI
    grpxId[0]                       = SYSTEM_LINK_ID_GRPX_0;

    ipcOutVpssId                    = SYSTEM_VPSS_LINK_ID_IPC_OUT_M3_0;
    ipcInVideoId                    = SYSTEM_VIDEO_LINK_ID_IPC_IN_M3_0;
    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;

    capturePrm.numVipInst    = 1;
    capturePrm.outQueParams[0].nextLink = gVcapModuleContext.deiId[0];

    capturePrm.tilerEnable              = FALSE;
    capturePrm.enableSdCrop             = FALSE;

    capturePrm.fakeHdMode                  = FALSE;

    vipInstId = 0;
    pCaptureInstPrm                     = &capturePrm.vipInst[vipInstId];
    //ranran
    printf("ranran xxxx\n");
    pCaptureInstPrm->vipInstId          = SYSTEM_CAPTURE_INST_VIP1_PORTA;
//#endif
    pCaptureOutPrm                      = &pCaptureInstPrm->outParams[0];

    printf(" ranran >>>>> vipInstId=%d\n",pCaptureInstPrm->vipInstId);
    pCaptureInstPrm->inScanFormat       = SYSTEM_SF_INTERLACED;
    pCaptureInstPrm->videoDecoderId     = SYSTEM_DEVICE_VID_DEC_TVP5158_DRV; /* ranran set to tvp5158 */ /* DONT set it to TVP5158 */
    pCaptureInstPrm->standard           = SYSTEM_STD_D1; /* ranran changed from 1080I */
    pCaptureInstPrm->inDataFormat       = SYSTEM_DF_YUV422P;
    pCaptureOutPrm->scOutWidth          = 0;
    pCaptureOutPrm->scOutHeight         = 0;

    pCaptureInstPrm->videoCaptureMode   = DEVICE_CAPT_VIDEO_CAPTURE_MODE_SINGLE_CH_NON_MUX_EMBEDDED_SYNC;
    pCaptureInstPrm->videoIfMode        = SYSTEM_CAPT_VIDEO_IF_MODE_8BIT; /* ranran changed from 16 */
    pCaptureOutPrm->dataFormat          = SYSTEM_DF_YUV422I_YUYV;

    pCaptureInstPrm->numOutput          = 1;

    pCaptureOutPrm->scEnable            = FALSE;
    pCaptureOutPrm->outQueId            = 0;



    vipInstId = 1;
    pCaptureInstPrm                     = &capturePrm.vipInst[vipInstId];
    pCaptureInstPrm->vipInstId          = SYSTEM_CAPTURE_INST_VIP0_PORTA;

    pCaptureOutPrm                      = &pCaptureInstPrm->outParams[0];

    pCaptureInstPrm->inScanFormat       = SYSTEM_SF_INTERLACED;
    pCaptureInstPrm->videoDecoderId     = SYSTEM_DEVICE_VID_DEC_TVP5158_DRV;
    pCaptureInstPrm->standard           = SYSTEM_STD_D1;
    pCaptureInstPrm->inDataFormat       = SYSTEM_DF_YUV422P;
    pCaptureOutPrm->scOutWidth          = 0;
    pCaptureOutPrm->scOutHeight         = 0;
    pCaptureInstPrm->videoCaptureMode   = DEVICE_CAPT_VIDEO_CAPTURE_MODE_SINGLE_CH_NON_MUX_EMBEDDED_SYNC;
    pCaptureInstPrm->videoIfMode        = SYSTEM_CAPT_VIDEO_IF_MODE_8BIT;
    pCaptureOutPrm->dataFormat          = SYSTEM_DF_YUV422I_YUYV;
    pCaptureInstPrm->numOutput          = 1;
    pCaptureOutPrm->scEnable            = FALSE;
    pCaptureOutPrm->outQueId            = 0;
/* use ELBIT_BOARD when required to work with EVM instead of readl board.
 * put define in component.mk
 */
    printf("ranran gVcapModuleContext.vcapConfig.enableConfigExtVideoDecoder is FALSE\n");
    gVcapModuleContext.vcapConfig.enableConfigExtVideoDecoder = FALSE;


    deiOutQue                = DEI_LINK_OUT_QUE_DEI_SC;
    deiPrm.inQueParams.prevLinkId                        = gVcapModuleContext.captureId;
    deiPrm.inQueParams.prevLinkQueId                     = 0;
    deiPrm.outQueParams[deiOutQue].nextLink              = dupId;
    deiPrm.enableOut[deiOutQue]                          = TRUE;
    deiPrm.tilerEnable[deiOutQue]                        = FALSE;

    deiPrm.comprEnable                                   = FALSE;
    deiPrm.setVipScYuv422Format                          = FALSE;

    deiPrm.enableDeiForceBypass                          = FALSE; /* ranran */
//    deiPrm.interlacedBypassMode                          = TRUE;
#ifdef USE_CAMERA
    deiPrm.inputFrameRate[deiOutQue] = 50;/*ranran was 60 */
    deiPrm.outputFrameRate[deiOutQue] = 25;
#else
    deiPrm.inputFrameRate[deiOutQue] = 60;/*ranran was 60 */
    deiPrm.outputFrameRate[deiOutQue] = 30;
#endif
    /* VIP Scalar ratio is 1:1 */
    deiPrm.outScaleFactor[deiOutQue][0].scaleMode = DEI_SCALE_MODE_RATIO;
    deiPrm.outScaleFactor[deiOutQue][0].ratio.widthRatio.numerator    = 1;
    deiPrm.outScaleFactor[deiOutQue][0].ratio.widthRatio.denominator  = 1;
    deiPrm.outScaleFactor[deiOutQue][0].ratio.heightRatio.numerator   = 1;
    deiPrm.outScaleFactor[deiOutQue][0].ratio.heightRatio.denominator     = 1;
    for (chId=1; chId < DEI_LINK_MAX_CH; chId++)
        deiPrm.outScaleFactor[deiOutQue][chId] = deiPrm.outScaleFactor[DEI_LINK_OUT_QUE_VIP_SC][0];

    dupPrm.inQueParams.prevLinkId         = gVcapModuleContext.deiId[0];
    dupPrm.inQueParams.prevLinkQueId      = deiOutQue;
    dupPrm.numOutQue                      = 2;
    dupPrm.outQueParams[0].nextLink       = gVdisModuleContext.swMsId[0];
    dupPrm.outQueParams[1].nextLink       = gVcapModuleContext.nsfId[0];
    dupPrm.notifyNextLink                 = TRUE;

    nsfPrm.bypassNsf                 = TRUE; /* ranran was false */
    nsfPrm.tilerEnable               = FALSE;
    nsfPrm.inQueParams.prevLinkId    = dupId;
    nsfPrm.inQueParams.prevLinkQueId = 1;
    nsfPrm.numOutQue                 = 1;
    nsfPrm.outQueParams[0].nextLink  = ipcOutVpssId; /* ranran gVdisModuleContext.swMsId[0]; */
    /*ranran

    dupPrm1.inQueParams.prevLinkId         = gVcapModuleContext.nsfId[0];
    dupPrm1.inQueParams.prevLinkQueId      = 0;
    dupPrm1.numOutQue                      = 2;
    dupPrm1.outQueParams[0].nextLink       = mergeId;
    dupPrm1.outQueParams[1].nextLink       = mergeId;
    dupPrm1.notifyNextLink                 = TRUE;

    mergePrm.numInQue                     = 2;
    mergePrm.inQueParams[0].prevLinkId    = dupId1;
    mergePrm.inQueParams[0].prevLinkQueId = 0;
    mergePrm.inQueParams[1].prevLinkId    = dupId1;
    mergePrm.inQueParams[1].prevLinkQueId = 1;
    mergePrm.outQueParams.nextLink        = ipcOutVpssId;
    mergePrm.notifyNextLink               = TRUE;
*/
    swMsPrm.inQueParams.prevLinkId    = dupId;
    swMsPrm.inQueParams.prevLinkQueId = 0;
    swMsPrm.outQueParams.nextLink     = gVdisModuleContext.displayId[0];
    swMsPrm.maxInputQueLen            = SYSTEM_SW_MS_DEFAULT_INPUT_QUE_LEN;
    swMsPrm.maxOutRes                 = VSYS_STD_1080P_60;
    swMsPrm.initOutRes                = VSYS_STD_1080P_60;
    swMsPrm.lineSkipMode = FALSE;

    swMsPrm.enableLayoutGridDraw = gVdisModuleContext.vdisConfig.enableLayoutGridDraw;

    MultiCh_singlewin_layoutprm(&swMsPrm.layoutPrm,swMsPrm.initOutRes);

    displayPrm.inQueParams[0].prevLinkId    = gVdisModuleContext.swMsId[0];
    displayPrm.inQueParams[0].prevLinkQueId = 0;
    displayPrm.displayRes                   = swMsPrm.initOutRes;

    ipcOutVpssPrm.inQueParams.prevLinkId    = gVcapModuleContext.nsfId[0];
    ipcOutVpssPrm.inQueParams.prevLinkQueId = 0;
    ipcOutVpssPrm.numOutQue                 = 1;
    ipcOutVpssPrm.outQueParams[0].nextLink  = ipcInVideoId;
    ipcOutVpssPrm.notifyNextLink            = TRUE; /* ranran was FALSE; */
    ipcOutVpssPrm.notifyPrevLink            = TRUE;
    ipcOutVpssPrm.noNotifyMode              = FALSE; /* ranran was TRUE; */

    ipcInVideoPrm.inQueParams.prevLinkId    = ipcOutVpssId;
    ipcInVideoPrm.inQueParams.prevLinkQueId = 0;
    ipcInVideoPrm.numOutQue                 = 1;
    ipcInVideoPrm.outQueParams[0].nextLink  = gVencModuleContext.encId;
    ipcInVideoPrm.notifyNextLink            = TRUE;
    ipcInVideoPrm.notifyPrevLink            = TRUE; /* ranran was FALSE; */
    ipcInVideoPrm.noNotifyMode              = FALSE; /* was TRUE; */


    ipcBitsOutVideoPrm.baseCreateParams.inQueParams.prevLinkId    = gVencModuleContext.encId;
    ipcBitsOutVideoPrm.baseCreateParams.inQueParams.prevLinkQueId = 0;
    ipcBitsOutVideoPrm.baseCreateParams.numOutQue                 = 1;
    ipcBitsOutVideoPrm.baseCreateParams.outQueParams[0].nextLink   = gVencModuleContext.ipcBitsInHLOSId;
    MultiCh_ipcBitsInitCreateParams_BitsOutRTOS(&ipcBitsOutVideoPrm, TRUE);

    ipcBitsInHostPrm.baseCreateParams.inQueParams.prevLinkId    = gVencModuleContext.ipcBitsOutRTOSId;
    ipcBitsInHostPrm.baseCreateParams.inQueParams.prevLinkQueId = 0;
    ipcBitsInHostPrm.baseCreateParams.numOutQue                 = 1;
    ipcBitsInHostPrm.baseCreateParams.outQueParams[0].nextLink  = SYSTEM_LINK_ID_INVALID;
    MultiCh_ipcBitsInitCreateParams_BitsInHLOS(&ipcBitsInHostPrm);
    EncLink_CreateParams_Init(&encPrm); /* ranran added */
    encPrm.inQueParams.prevLinkId   = ipcInVideoId;
    encPrm.inQueParams.prevLinkQueId= 0;
    encPrm.outQueParams.nextLink    = gVencModuleContext.ipcBitsOutRTOSId;

    pLinkChPrm  = &encPrm.chCreateParams[0];
    pLinkDynPrm = &pLinkChPrm->defaultDynamicParams;

    pChPrm      = &gVencModuleContext.vencConfig.encChannelParams[0];
    pDynPrm     = &pChPrm->dynamicParam;

    encPrm.numBufPerCh[0] = 6;
    encPrm.numBufPerCh[1] = 6;
    encPrm.numBufPerCh[2] = 6;

    pLinkChPrm->format                  = IVIDEO_H264HP;
    pLinkChPrm->profile                 = gVencModuleContext.vencConfig.h264Profile[0];
    pLinkChPrm->dataLayout              = VCODEC_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;


    /* same params for 2nd channel */
    encPrm.chCreateParams[1] = encPrm.chCreateParams[0];
 
    System_linkCreate (gVcapModuleContext.captureId, &capturePrm, sizeof(capturePrm));

    System_linkCreate(gVcapModuleContext.deiId[0]  , &deiPrm, sizeof(deiPrm));
    System_linkCreate(dupId, &dupPrm, sizeof(dupPrm));

    System_linkCreate(gVcapModuleContext.nsfId[0] , &nsfPrm, sizeof(nsfPrm));
/*
 ranran
     System_linkCreate(dupId1, &dupPrm1, sizeof(dupPrm1));
    System_linkCreate(mergeId   , &mergePrm  , sizeof(mergePrm));
*/
    System_linkCreate(ipcOutVpssId , &ipcOutVpssPrm , sizeof(ipcOutVpssPrm) );
    System_linkCreate(ipcInVideoId , &ipcInVideoPrm , sizeof(ipcInVideoPrm) );

    System_linkCreate(gVencModuleContext.encId, &encPrm, sizeof(encPrm));
    System_linkCreate(gVencModuleContext.ipcBitsOutRTOSId, &ipcBitsOutVideoPrm, sizeof(ipcBitsOutVideoPrm));
    System_linkCreate(gVencModuleContext.ipcBitsInHLOSId, &ipcBitsInHostPrm, sizeof(ipcBitsInHostPrm));

    System_linkCreate(gVdisModuleContext.swMsId[0]  , &swMsPrm, sizeof(swMsPrm));

    System_linkCreate(gVdisModuleContext.displayId[0], &displayPrm, sizeof(displayPrm));

    MultiCh_memPrintHeapStatus();

    Vdis_sysfsCmd(3, VDIS_SYSFSCMD_SET_GRPX, VDIS_SYSFS_GRPX0, VDIS_OFF);
    Vdis_sysfsCmd(3, VDIS_SYSFSCMD_SET_GRPX, VDIS_SYSFS_GRPX1, VDIS_OFF);
}



Void CommitCh_deleteHdDvr()
{
    UInt32 grpxId[VDIS_DEV_MAX];
    UInt32 dupId; /* ranran , dupId1, mergeId;*/
    UInt32 ipcOutVpssId;
    UInt32 ipcInVideoId;



    gVcapModuleContext.captureId    = SYSTEM_LINK_ID_CAPTURE;
    gVcapModuleContext.nsfId[0]     = SYSTEM_LINK_ID_NSF_0;
    gVcapModuleContext.deiId[0]     = SYSTEM_LINK_ID_DEI_0;
    dupId                           = SYSTEM_VPSS_LINK_ID_DUP_0;
   /*ranran dupId1                          = SYSTEM_VPSS_LINK_ID_DUP_1;
    mergeId                         = SYSTEM_VPSS_LINK_ID_MERGE_0;*/

    gVdisModuleContext.swMsId[0]    = SYSTEM_LINK_ID_SW_MS_MULTI_INST_0;

    gVdisModuleContext.displayId[0] = SYSTEM_LINK_ID_DISPLAY_0; // ON CHIP HDMI
    grpxId[0]                       = SYSTEM_LINK_ID_GRPX_0;

    ipcOutVpssId       = SYSTEM_VPSS_LINK_ID_IPC_OUT_M3_0;
    ipcInVideoId       = SYSTEM_VIDEO_LINK_ID_IPC_IN_M3_0;
    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;

    System_linkDelete(gVcapModuleContext.captureId);

    System_linkDelete(gVcapModuleContext.deiId[0]);

    System_linkDelete(dupId);
   /*ranran System_linkDelete(dupId1);
    System_linkDelete(mergeId);*/

    System_linkDelete(gVdisModuleContext.swMsId[0] );

    System_linkDelete(gVdisModuleContext.displayId[0]);


    System_linkDelete(gVcapModuleContext.nsfId[0]);
    System_linkDelete(ipcOutVpssId);
    System_linkDelete(ipcInVideoId);
    System_linkDelete(gVencModuleContext.encId);
    System_linkDelete(gVencModuleContext.ipcBitsInHLOSId);
    System_linkDelete(gVencModuleContext.ipcBitsOutRTOSId);

    /* Print the HWI, SWI and all tasks load */
    /* Reset the accumulated timer ticks */
    MultiCh_prfLoadCalcEnable(FALSE, TRUE, FALSE);

}


/* Dummy functions */
Int32 CommitCh_hdDvrSetCapDynamicParamChn(VCAP_CHN vcChnId, VCAP_CHN_DYNAMIC_PARAM_S *psCapChnDynaParam, VCAP_PARAMS_E paramId)
{
    vcChnId = vcChnId;
    psCapChnDynaParam = psCapChnDynaParam;
    paramId = paramId;
    return 0;
}
Int32 CommitCh_hdDvrGetCapDynamicParamChn(VCAP_CHN vcChnId, VCAP_CHN_DYNAMIC_PARAM_S *psCapChnDynaParam, VCAP_PARAMS_E paramId)
{
    vcChnId = vcChnId;
    psCapChnDynaParam = psCapChnDynaParam;
    paramId = paramId;
    return 0;
}

Int32 CommitCh_hdDvrSetCapFrameRate(VCAP_CHN vcChnId, VCAP_STRM vcStrmId, Int32 inputFrameRate, Int32 outputFrameRate)
{
    vcChnId = vcChnId;
    vcStrmId = vcStrmId;
    inputFrameRate = outputFrameRate;
    return 0;
}

Int32 CommitCh_hdDvrEnableDisableCapChn(VCAP_CHN vcChnId, VCAP_STRM vcStrmId, Bool enableChn)
{
    vcChnId = vcChnId;
    vcStrmId = vcStrmId;
    enableChn = enableChn;
    return 0;
}
void  CommitCh_hdDvrSwmsChReMap(VDIS_MOSAIC_S *psVdMosaicParam)
{
    psVdMosaicParam = psVdMosaicParam;
}