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.

TDA2PXEVM: Linux: Mosaic View-Four channel NullSrc unable to display four different videos .

Part Number: TDA2PXEVM

Hi

I'am trying to display four different videos in mosaic view.

when I give each individual video each time it is able to display same video in four different views

I'am also able to display 1st view - video1,2nd view - video2,3rd view -video1, 4th view- video2.

But when i give four different video the screen goes blank.

My usecase is in mentioned in chains_main_linux_single_cam.c

Attaching herewith is the chains_nullSrc_sgx_Display.c chains_nullSrc_sgx_Display.txt files of my usecase which is present in path vision_sdk/apps/src/hlos/adas/src/usecases

Attaching nullSrcLink_tsk.c and nullSrcLink_priv.h  I have made changes in the nullsrclink for four channel present in path vision_sdk/links_fw/src/hlos/links_a15/nullSrc  

/******************************************************************************
Copyright (c) [2012 - 2017] Texas Instruments Incorporated

All rights reserved not granted herein.

Limited License.

 Texas Instruments Incorporated grants a world-wide, royalty-free, non-exclusive
 license under copyrights and patents it now or hereafter owns or controls to
 make,  have made, use, import, offer to sell and sell ("Utilize") this software
 subject to the terms herein.  With respect to the foregoing patent license,
 such license is granted  solely to the extent that any such patent is necessary
 to Utilize the software alone.  The patent license shall not apply to any
 combinations which include this software, other than combinations with devices
 manufactured by or for TI ("TI Devices").  No hardware patent is licensed
 hereunder.

 Redistributions must preserve existing copyright notices and reproduce this
 license (including the above copyright notice and the disclaimer and
 (if applicable) source code license limitations below) in the documentation
 and/or other materials provided with the distribution

 Redistribution and use in binary form, without modification, are permitted
 provided that the following conditions are met:

 * No reverse engineering, decompilation, or disassembly of this software
   is permitted with respect to any software provided in binary form.

 * Any redistribution and use are licensed by TI for use only with TI Devices.

 * Nothing shall obligate TI to provide you with source code for the software
   licensed and provided to you in object code.

 If software source code is provided to you, modification and redistribution of
 the source code are permitted provided that the following conditions are met:

 * Any redistribution and use of the source code, including any resulting
   derivative works, are licensed by TI for use only with TI Devices.

 * Any redistribution and use of any object code compiled from the source code
   and any resulting derivative works, are licensed by TI for use only with TI
   Devices.

 Neither the name of Texas Instruments Incorporated nor the names of its
 suppliers may be used to endorse or promote products derived from this software
 without specific prior written permission.

 DISCLAIMER.

 THIS SOFTWARE IS PROVIDED BY TI AND TI�S LICENSORS "AS IS" AND ANY EXPRESS OR
 IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
 MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
 IN NO EVENT SHALL TI AND TI�S LICENSORS BE LIABLE FOR ANY DIRECT, INDIRECT,
 INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
 PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
 LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
 OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
 ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
******************************************************************************/

/*******************************************************************************
 *  INCLUDE FILES
 *******************************************************************************
 */
#include "chains_nullSrc_sgx_Display_priv.h"
//#include "svs_opengl_es.h"
#include <src/hlos/adas/include/chains.h>
#include <src/hlos/common/chains_common.h>
#include <src/hlos/system/system_gbm_allocator.h>

#define MAX_NUMBER_OF_CHANNELS    (4)//(1)
#define ENCDEC_MAX_FRAME_WIDTH    (1280)//(1920)
#define ENCDEC_MAX_FRAME_HEIGHT   (720)//(1080)


/**
 *******************************************************************************
 * \brief Channels with timestamp difference <= SYNC_DELTA_IN_MSEC
 *        are synced together by sync link
 *******************************************************************************
 */
#define SYNC_DELTA_IN_MSEC              (16)

/**
 *******************************************************************************
 * \brief Channels with timestamp older than SYNC_DROP_THRESHOLD_IN_MSEC
 *        are dropped by sync link
 *******************************************************************************
 */
#define SYNC_DROP_THRESHOLD_IN_MSEC     (33)


/**
 *******************************************************************************
 *
 *  \brief  Use-case object
 *
 *        This structure contains all the LinksId's and create Params.
 *        The same is passed to all create, start, stop functions.
 *
 *******************************************************************************
*/
typedef struct {

	chains_nullSrc_sgx_DisplayObj ucObj;

    UInt32  displayWidth;
    UInt32  displayHeight;

    Chains_Ctrl *chainsCfg;

    UInt32 codecType;
} Chains_NullSrcSgxDisplayAppObj;

static struct control_srv_egl_ctx chainsEglParams = {
   .get_egl_native_display = gbm_allocator_get_native_display,
   .get_egl_native_buffer = gbm_allocator_get_native_buffer,
   .destroy_egl_native_buffer = gbm_allocator_destroy_native_buffer,
   .wrap_native_buffers = gbm_wrap_native_buffers,
   .wrapper_get_next_buffer = gbm_wrapper_get_next_buffer,
   .wrapper_put_buffer = gbm_wrapper_put_buffer,
   .unwrap_native_buffers = gbm_unwrap_native_buffers,
};


/**
 *******************************************************************************
 *
 * \brief   Set SGXDISPLAY Link Parameters
 *
 *          It is called in Create function.

 *
 * \param   pPrm    [IN]    IpcLink_CreateParams
 *
 *******************************************************************************
*/
static Void chains_nullSrc_sgx_Display_SetSgxDisplayLinkPrms (
                                  SgxFrmcpyLink_CreateParams *prms,
                                  UInt32 width, UInt32 height)
{
    prms->displayWidth = width;
    prms->displayHeight = height;
    //prms->renderType = SGXFRMCPY_RENDER_TYPE_1x1;
    prms->renderType = SGXFRMCPY_RENDER_TYPE_2x2;
    prms->inBufType = SYSTEM_BUFFER_TYPE_VIDEO_FRAME_CONTAINER;
    prms->bEglInfoInCreate = TRUE;
    prms->EglInfo = (void *)&chainsEglParams;
}

/**
 *******************************************************************************
 *
 * \brief   Set Sync Create Parameters
 *
 *          This function is used to set the sync params.
 *          It is called in Create function. It is advisable to have
 *          Chains_lvdsSingleVipCaptureDisplay_ResetLinkPrm prior to set params
 *          so all the default params get set.
 *          Number of channels to be synced and sync delta and threshold.
 *
 * \param   pPrm    [OUT]    SyncLink_CreateParams
 *
 *******************************************************************************
*/
static Void chains_nullSrc_sgx_Display_SetSyncPrm(
                    SyncLink_CreateParams *pPrm,
                    UInt32 numLvdsCh
                    )
{
    pPrm->syncDelta = SYNC_DELTA_IN_MSEC;
    pPrm->syncThreshold = SYNC_DROP_THRESHOLD_IN_MSEC;
}


/*Void chains_nullSrc_sgx_Display_SetAlgPrms(
                                    AlgorithmLink_OfflineCalibrationCreateParams *pPrm,
                                      Chains_Ctrl *chainsCfg)
{
    if( chainsCfg->algProcId == SYSTEM_PROC_DSP1
             ||
             chainsCfg->algProcId == SYSTEM_PROC_DSP2)
             {
                 pPrm->baseClassCreate.algId = ALGORITHM_LINK_DSP_ALG_OFFLINECALIBRATION;
             }

    pPrm->maxWidth    = ENCDEC_MAX_FRAME_WIDTH;
    pPrm->maxHeight   = ENCDEC_MAX_FRAME_HEIGHT;

    pPrm->numOutputFrames = 3;
}
*/

/**
 *******************************************************************************
 *
 *
 *******************************************************************************
*/
Void chains_nullSrc_sgx_Display_SetNullSrcPrms(Chains_NullSrcSgxDisplayAppObj *pObj,
                        NullSrcLink_CreateParams *pPrm)
{
    UInt32 chId;
    System_LinkChInfo *pChInfo;

    //pPrm->outQueInfo.numCh = 1;
    pPrm->outQueInfo.numCh = 4;

    pPrm->timerPeriodMilliSecs = 32;

    for (chId = 0; chId < pPrm->outQueInfo.numCh; chId++)
    {
        pPrm->channelParams[chId].numBuffers = 4;

        pChInfo = &pPrm->outQueInfo.chInfo[chId];

        pChInfo->flags = System_Link_Ch_Info_Set_Flag_Data_Format(pChInfo->flags,
                                                    SYSTEM_DF_YUV420SP_UV);
        pChInfo->flags = System_Link_Ch_Info_Set_Flag_Scan_Format(pChInfo->flags,
                                                    SYSTEM_SF_PROGRESSIVE);
        pChInfo->flags = System_Link_Ch_Info_Set_Flag_Buf_Type(pChInfo->flags,
                                               /*SYSTEM_BUFFER_TYPE_VIDEO_FRAME*/
                                               SYSTEM_BUFFER_TYPE_BITSTREAM);
        pChInfo->width = ENCDEC_MAX_FRAME_WIDTH;//pObj->displayWidth;
        pChInfo->height = ENCDEC_MAX_FRAME_HEIGHT;//pObj->displayHeight;
        pChInfo->startX = 0;
        pChInfo->startY = 0;
        pChInfo->pitch[0] = SystemUtils_align(pChInfo->width, 32);
        pChInfo->pitch[1] = SystemUtils_align(pChInfo->width, 32);

        pPrm->channelParams[chId].fileReadMode = NULLSRC_LINK_FILEREAD_RUN_TIME;

        if(chId == 0){
            strncpy(pPrm->channelParams[chId].nameDataFile, "/home/Front.h264", 260);//"/home/Front.h264"
            strncpy(pPrm->channelParams[chId].nameIndexFile, "/home/Front.hdr", 260);//"/home/Front.h264"
        }
        else if(chId == 1){
            strncpy(pPrm->channelParams[chId].nameDataFile, "/home/Left.h264", 260);//"/home/1280x720_00.h264" "/home/Right.h264"
            strncpy(pPrm->channelParams[chId].nameIndexFile, "/home/Left.hdr", 260);//"/home/1280x720_00.h264" "/home/Right.hdr"
        }
        else if(chId == 2){
            strncpy(pPrm->channelParams[chId].nameDataFile, "/home/Right.h264", 260);//"/home/Front.hdr"
            strncpy(pPrm->channelParams[chId].nameIndexFile, "/home/Right.hdr", 260);//"/home/Front.hdr"
        }
        else if(chId == 3){
            strncpy(pPrm->channelParams[chId].nameDataFile, "/home/Rear.h264", 260);//"/home/Right.h264"
            strncpy(pPrm->channelParams[chId].nameIndexFile, "/home/Rear.hdr", 260);//"/home/Right.h264"
        }
        /*strncpy(pPrm->channelParams[chId].nameDataFile, "/home/1280x720_00.h264", 260);
        strncpy(pPrm->channelParams[chId].nameIndexFile, "/home/1280x720_00.hdr", 260);*/
    }

    pPrm->dataRxMode = NULLSRC_LINK_DATA_RX_MODE_FILE;
}








/**
 *******************************************************************************
 *
 * \brief   Set Decode Create Parameters
 *
 * \param   pPrm         [IN]    DecodeLink_CreateParams
 *
 *******************************************************************************
*/
static Void chains_nullSrc_sgx_Display_SetDecodePrms(
					Chains_NullSrcSgxDisplayAppObj *pObj,
                    DecLink_CreateParams *pPrm)
{
    UInt32 chId;
    DecLink_ChCreateParams *decPrm;

    for (chId = 0; chId<MAX_NUMBER_OF_CHANNELS; chId++)
    {
        UTILS_assert (chId < DEC_LINK_MAX_CH);
        decPrm = &pPrm->chCreateParams[chId];

        decPrm->dpbBufSizeInFrames  = DEC_LINK_DPB_SIZE_IN_FRAMES_DEFAULT;
        decPrm->algCreateStatus     = DEC_LINK_ALG_CREATE_STATUS_CREATE;
        decPrm->decodeFrameType     = DEC_LINK_DECODE_ALL;

        decPrm->processCallLevel    = DEC_LINK_FRAMELEVELPROCESSCALL;
        decPrm->targetMaxWidth      = ENCDEC_MAX_FRAME_WIDTH;
        decPrm->targetMaxHeight     = ENCDEC_MAX_FRAME_HEIGHT;
        decPrm->numBufPerCh         = 6;
        decPrm->defaultDynamicParams.targetBitRate = 10*1000*1000;
        decPrm->defaultDynamicParams.targetFrameRate = 30;
        decPrm->fieldMergeDecodeEnable = FALSE;

        switch (pObj->codecType)
        {
            case '0': /* MJPEG */
                decPrm->format = SYSTEM_IVIDEO_MJPEG;
                decPrm->profile = 0;
                decPrm->displayDelay = 0;
                break;

            case '1': /* H264 */
                decPrm->format = SYSTEM_IVIDEO_H264HP;
                decPrm->profile = 3;
                decPrm->displayDelay = 0;
                break;

            default: /* D1 */
                printf("\r\nCodec Type: %d, returning \n", pObj->codecType);
                UTILS_assert(FALSE);
                break;
        }
    }
}



/**
 *******************************************************************************
 *
 * \brief   Set VPE Create Parameters
 *
 * \param   pPrm    [OUT]    VpeLink_CreateParams
 *
 *******************************************************************************
*/
static Void chains_nullSrc_sgx_Display_SetVPEPrms(
                    VpeLink_CreateParams *pPrm,
                    UInt32 numCh,
                    UInt32 displayWidth,
                    UInt32 displayHeight,
                    UInt32 inputWidth,
                    UInt32 inputHeight
                    )
{
    UInt16 chId;

    pPrm->enableOut[0] = TRUE;

    for(chId = 0; chId < numCh; chId++)
    {
        pPrm->chParams[chId].outParams[0].numBufsPerCh = 4;

        pPrm->chParams[chId].outParams[0].width = displayWidth;
        pPrm->chParams[chId].outParams[0].height = displayHeight;
        pPrm->chParams[chId].outParams[0].dataFormat = SYSTEM_DF_YUV420SP_UV;

        pPrm->chParams[chId].scCfg.bypass       = FALSE;
        pPrm->chParams[chId].scCfg.nonLinear    = FALSE;
        pPrm->chParams[chId].scCfg.stripSize    = 0;

        pPrm->chParams[chId].scCropCfg.cropStartX = 32;
        pPrm->chParams[chId].scCropCfg.cropStartY = 24;
        pPrm->chParams[chId].scCropCfg.cropWidth = inputWidth-32;
        pPrm->chParams[chId].scCropCfg.cropHeight = inputHeight-24;
    }
}

/**
 *******************************************************************************
 *
 * \brief   Set link Parameters
 *
 *          It is called in Create function of the auto generated use-case file.
 *
 * \param pUcObj    [IN] Auto-generated usecase object
 * \param appObj    [IN] Application specific object
 *
 *******************************************************************************
*/
Void chains_nullSrc_sgx_Display_SetAppPrms(chains_nullSrc_sgx_DisplayObj *pUcObj, Void *appObj)
{
	Chains_NullSrcSgxDisplayAppObj *pObj
        = (Chains_NullSrcSgxDisplayAppObj*)appObj;


	chains_nullSrc_sgx_Display_SetSyncPrm(
        &pUcObj->SyncPrm,
        pObj->chainsCfg->numLvdsCh
        );

    ChainsCommon_GetDisplayWidthHeight(
        pObj->chainsCfg->displayType,
        &pObj->displayWidth,
        &pObj->displayHeight
        );

    ChainsCommon_SetGrpxSrcPrms(
		&pUcObj->GrpxSrcPrm,
		pObj->displayWidth,
		pObj->displayHeight
		);

    chains_nullSrc_sgx_Display_SetNullSrcPrms(pObj, &pUcObj->NullSourcePrm);

    chains_nullSrc_sgx_Display_SetDecodePrms(pObj, &pUcObj->DecodePrm);

    ChainsCommon_SetDisplayPrms(
		&pUcObj->Display_M4Prm,
		NULL,
		pObj->chainsCfg->displayType,
		pObj->displayWidth,
		pObj->displayHeight
	    );

    /*chains_nullSrc_sgx_Display_SetVPEPrms(
        &pUcObj->VPEPrm,
        1,
        ENCDEC_MAX_FRAME_WIDTH,
        ENCDEC_MAX_FRAME_HEIGHT,
        ENCDEC_MAX_FRAME_WIDTH,
        ENCDEC_MAX_FRAME_HEIGHT
		);*/


 /*chains_nullSrc_sgx_Display_SetAlgPrms(&pUcObj->Alg_OfflineCalibrationPrm,
                                                            pObj->chainsCfg);*/

    chains_nullSrc_sgx_Display_SetVPEPrms(
            &pUcObj->VPEPrm,
            4,
            ENCDEC_MAX_FRAME_WIDTH,
            ENCDEC_MAX_FRAME_HEIGHT,
            ENCDEC_MAX_FRAME_WIDTH,
            ENCDEC_MAX_FRAME_HEIGHT
            );

    chains_nullSrc_sgx_Display_SetSgxDisplayLinkPrms
		(&pUcObj->SgxFrmcpyPrm,
		ENCDEC_MAX_FRAME_WIDTH,
		ENCDEC_MAX_FRAME_HEIGHT
		);

    pUcObj->Display_GrpxPrm.rtParams.tarWidth       = ENCDEC_MAX_FRAME_WIDTH;
	pUcObj->Display_GrpxPrm.rtParams.tarHeight      = ENCDEC_MAX_FRAME_HEIGHT;
	pUcObj->Display_GrpxPrm.rtParams.posX           = 0;
	pUcObj->Display_GrpxPrm.rtParams.posY           = 0;
	pUcObj->Display_GrpxPrm.displayId               = DISPLAY_LINK_INST_DSS_GFX1;


    ChainsCommon_StartDisplayCtrl(
        pObj->chainsCfg->displayType,
        pObj->displayWidth,
        pObj->displayHeight
        );
}

/**
 *******************************************************************************
 *
 * \brief   Start the capture display Links
 *
 *          Function sends a control command to capture and display link to
 *          to Start all the required links . Links are started in reverce
 *          order as information of next link is required to connect.
 *          System_linkStart is called with LinkId to start the links.
 *
 * \param   pObj  [IN] Chains_VipSingleCameraViewObj
 *
 * \return  SYSTEM_LINK_STATUS_SOK on success
 *
 *******************************************************************************
*/
Void chains_nullSrc_sgx_Display_StartApp(Chains_NullSrcSgxDisplayAppObj *pObj)
{
    ChainsCommon_statCollectorReset();
    ChainsCommon_memPrintHeapStatus();

    chains_nullSrc_sgx_Display_Start(&pObj->ucObj);

    ChainsCommon_prfLoadCalcEnable(TRUE, FALSE, FALSE);
}

/**
 *******************************************************************************
 *
 * \brief   Delete the capture display Links
 *
 *          Function sends a control command to capture and display link to
 *          to delete all the prior created links
 *          System_linkDelete is called with LinkId to delete the links.
 *
 * \param   pObj   [IN]   Chains_VipSingleCameraViewObj
 *
 *******************************************************************************
*/
Void chains_nullSrc_sgx_Display_StopAndDeleteApp(Chains_NullSrcSgxDisplayAppObj *pObj)
{
	chains_nullSrc_sgx_Display_Stop(&pObj->ucObj);
	chains_nullSrc_sgx_Display_Delete(&pObj->ucObj);

    ChainsCommon_StopDisplayCtrl();

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

/**
 *******************************************************************************
 * \brief Run Time Menu string for codec Type Selection.
 *******************************************************************************
 */
char chains_nullSrc_sgx_Display_codecTypeSelect[] = {
    "\r\n "
    "\r\n ========================================="
    "\r\n Chains Run-time Codec Type Selection Menu"
    "\r\n ========================================="
    "\r\n "
    "\r\n Enter '0' for MJPEG "
    "\r\n "
    "\r\n Enter '1' for H.264 "
    "\r\n "
    "\r\n Enter Choice: "
    "\r\n "
};

/**
 *******************************************************************************
 *
 * \brief   Single Channel Capture Display usecase function
 *`
 *          This functions executes the create, start functions
 *
 *          Further in a while loop displays run time menu and waits
 *          for user inputs to print the statistics or to end the demo.
 *
 *          Once the user inputs end of demo stop and delete
 *          functions are executed.
 *
 * \param   chainsCfg       [IN]   Chains_Ctrl
 *
 *******************************************************************************
*/
Void Chains_nullSrc_Decode_sgx_Display(Chains_Ctrl *chainsCfg)
{
    char ch = 'a';
    UInt32 done = FALSE;
    Chains_NullSrcSgxDisplayAppObj chainsObj;

    chainsObj.chainsCfg = chainsCfg;

    while(!done)
    {
        Vps_printf(chains_nullSrc_sgx_Display_codecTypeSelect);
        chainsObj.codecType = Chains_readChar();

        switch(chainsObj.codecType)
        {
            case '0':
                done = TRUE;
                break;
            case '1':
                done = TRUE;
                break;
            default:
                Vps_printf("\nUnsupported option '%c'. Please try again\n",
                           chainsObj.codecType);
                break;
        }
    }

    chains_nullSrc_sgx_Display_Create(&chainsObj.ucObj, &chainsObj);

    chains_nullSrc_sgx_Display_StartApp(&chainsObj);

    done = FALSE;
    while(!done)
    {
        ch = '1';
        ch = Chains_menuRunTime();
        switch(ch)
        {
            case '0':
                done = TRUE;
                break;

            case 'p':
            case 'P':
                ChainsCommon_PrintStatistics();
                chains_nullSrc_sgx_Display_printStatistics(&chainsObj.ucObj);
                break;
            default:
                Vps_printf("\nUnsupported option '%c'. Please try again\n", ch);
                break;
        }
    }

    chains_nullSrc_sgx_Display_StopAndDeleteApp(&chainsObj);
}

UseCase: chains_nullSrc_sgx_Display

NullSource (A15) -> Decode -> VPE -> Sync (A15) -> SgxFrmcpy (A15)

// display on m4
Sync -> SgxFrmcpy

//
SgxFrmcpy -> Display_M4 (IPU1_0)
//
// Graphics overlay display
//
GrpxSrc -> Display_Grpx

nullSrcLink_priv.h6622.nullSrcLink_tsk.c

With Regards 

Pratik Brid