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.

RTOS/TDA3XEVM: ISS Capture usecase

Part Number: TDA3XEVM

Tool/software: TI-RTOS

Hi,

I'm using TDA3x-EVM board and TDA3x-EVM CSI2 Camera daughterboard with UB954 Deserializer. I configure UB954 to pattern mode. Vision SDK version is 3.03.

I want to make following use-case:

IssCapture -> Null

Null link dump data type is NULL_LINK_COPY_TYPE_NONE. I just want to save captured frame to SD card, I don't wan't to use ISP. The problem I have is that I can't capture any data on ISS Capture link (although UB954 starts to send data). Is it possible to use ISS without ISP? When I run isscapt_baremetal_app provided by TI I'm able to capture frames. Can you help us with this problem. I uploaded some files so can check them:

chains_iss_test_pattern.c -> Main usecase file.

deser.c -> Deserializer pattern mode configuration.

iss_sensor_tda3xx.c -> Check code from 299 - 318 line

iss_sensor_dummy.c -> New dummy sensor file added to ISS framework.

Please note that we don't have any sensor, we just wan't to get data from deserializer.

Best regards,

Stefan.

/******************************************************************************
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_iss_test_pattern_priv.h"
#include <src/include/chains_common.h>
#include <src/rtos/iss/include/iss_sensors.h>
#include <src/rtos/iss/include/iss_utils.h>
#include <src/rtos/iss/include/app_util_iss.h>


/*
 * AEWB algorithm memory requirement cannot be calculated upfront.
 * This size is known by running the use-case once with large size
 * and then checking the log for unused memory in AEWB algorithm
 */
#define ALG_AEWB_MEM_SIZE                           (896*1024)

void configDeser(void);

Int32 Utils_fileWriteFile(char *fileName, Uint8 *addr, Uint32 size);



/* returns 0 if does not exist, 1 if it does */
Int32 xUtils_fileExists( char *fileName )
{
    Int32 retVal = 0;
    Int32 hndlFile;

    hndlFile = File_open(fileName, "rb");

    if(hndlFile < 0)
    {
    retVal = 0;
    } else {
    retVal = 1;
    }
    File_close( hndlFile );

    return retVal;
}

/* creates a filepath from an index and the fmt with a %u in it
 * tries to find the next available unused value
 */
Int32 xUtils_nextAvailableFile( char * buf, char * fmt, Int32 theIndex )
{
sprintf( buf, fmt, theIndex );

while( xUtils_fileExists( buf ) && theIndex < 9999 )
{
Vps_printf( "filename %s %d exists... skipping\n", buf, theIndex );
theIndex++;
    sprintf( buf, fmt, theIndex );
}

if( theIndex >= 9999 ) {
theIndex = 0;
    sprintf( buf, fmt, theIndex );
}
return theIndex;
}

Int32 lastExposureTime = 0;

Int32 xUtils_fileWriteInfo( char * filename, char * extra )
{
Int32 status = 0;
char buf [200];

sprintf( buf, "%s, %u, %s\n", filename, lastExposureTime, extra );

status = Utils_fileWriteFile( filename, (Uint8 *)buf, strlen( buf ));

return status;
}


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

    chains_iss_test_patternObj  ucObj;

    IssM2mSimcopLink_ConfigParams   simcopConfig;
    vpsissldcConfig_t               ldcCfg;
    vpsissvtnfConfig_t              vtnfCfg;

    UInt32                          captureOutWidth;
    UInt32                          captureOutHeight;
    UInt32                          displayWidth;
    UInt32                          displayHeight;

    Chains_Ctrl                    *chainsCfg;

    IssM2mSimcopLink_OperatingMode  simcopMode;
    Bool                            bypassVtnf;
    Bool                            bypassLdc;

    AppUtils_Obj             appSensInfo;
} chains_iss_test_patternAppObj;


char gChains_IssIspSimcop_Display_runTimeMenu[] = {
"\r\n "
"\r\n ===================="
"\r\n Chains Run-time Menu"
"\r\n ===================="
"\r\n "
"\r\n 0: Stop Chain"
"\r\n "
"\r\n 1: Save Captured Frame"
"\r\n "
"\r\n p: Print Performance Statistics "
"\r\n "
"\r\n Enter Choice: "
"\r\n "
};


/**
 *******************************************************************************
 *
 * \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_iss_test_pattern_SetAppPrms(
    chains_iss_test_patternObj *pUcObj, Void *appObj)
{
    chains_iss_test_patternAppObj *pObj
        = (chains_iss_test_patternAppObj*)appObj;

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

    /* Create the sensor now */
    strncpy(pObj->appSensInfo.sensorName, "DUMMY", //pObj->chainsCfg->sensorName,
        ISS_SENSORS_MAX_NAME);
    pObj->appSensInfo.numCh = 1;
    pObj->appSensInfo.ispOpMode = pObj->chainsCfg->ispOpMode;
    pObj->appSensInfo.simcopOpMode = pObj->simcopMode;
    pObj->appSensInfo.numCSI2Inst = 1;
    appCreateISSSensor(&pObj->appSensInfo);

    appInitIssCaptParams(&pObj->appSensInfo, pUcObj->IssCaptureLinkID,
        &pUcObj->IssCapturePrm);


    pObj->captureOutWidth = pUcObj->IssCapturePrm.outParams[0U].width;
    pObj->captureOutHeight = pUcObj->IssCapturePrm.outParams[0U].height;
    
    Vps_printf("Width: %d\n", pObj->captureOutWidth);
    Vps_printf("Height: %d\n", pObj->captureOutHeight);
    
    pUcObj->IssCapturePrm.allocBufferForRawDump = TRUE;

    pUcObj->NullPrm.dumpDataType = NULL_LINK_COPY_TYPE_NONE;

/*

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

    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_iss_test_patternAppObj
 *
 * \return  SYSTEM_LINK_STATUS_SOK on success
 *
 *******************************************************************************
*/
Void chains_iss_test_pattern_StartApp(chains_iss_test_patternAppObj *pObj)
{
    Chains_memPrintHeapStatus();

    //appStartIssSensorSerDes(&pObj->appSensInfo);

    //ChainsCommon_StartDisplayDevice(pObj->chainsCfg->displayType);

    chains_iss_test_pattern_Start(&pObj->ucObj);

    Chains_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_iss_test_patternAppObj
 *
 *******************************************************************************
*/
Void chains_iss_test_pattern_StopAndDeleteApp(chains_iss_test_patternAppObj *pObj)
{
    chains_iss_test_pattern_Stop(&pObj->ucObj);
    chains_iss_test_pattern_Delete(&pObj->ucObj);

//    ChainsCommon_StopDisplayCtrl();

    appStopISSSensor(&pObj->appSensInfo);

    appDeleteISSSensor(&pObj->appSensInfo);

    ChainsCommon_StopDisplayDevice(pObj->chainsCfg->displayType);

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

/**
 *******************************************************************************
 *
 * \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_iss_test_pattern(Chains_Ctrl *chainsCfg)
{
    char ch;
    UInt32 done = FALSE;
    chains_iss_test_patternAppObj chainsObj;
    Int32 CapImCounter = 0;
    char fName[128];
    Int32 status = 0;
    IssCaptureLink_GetSaveFrameStatus rawSaveFrameStatus;
    UInt32 chId = 0U;

    chainsObj.bypassVtnf = 0; /* KW error fix */
    chainsObj.bypassLdc  = 0; /* KW error fix */

    Vps_printf(" Entered Chains_iss_test_pattern \n");

    if (TRUE == IssM2mIspLink_IsWdrMode(chainsCfg->ispOpMode))
    {
        Vps_printf(" CHAINS: Please make sure BSP is build with WDR and LDC enabled !!!\n");
    }

    chainsObj.chainsCfg = chainsCfg;

    /* Initialize Video Sensor, so that Algorithm can use Params
       from Vid Sensor layer */
    chains_iss_test_pattern_Create(&chainsObj.ucObj, &chainsObj);
    ChainsCommon_SetIssCaptureErrorHandlingCb(chainsObj.ucObj.IssCaptureLinkID);
    
    chains_iss_test_pattern_StartApp(&chainsObj);
    
    configDeser();
    Task_sleep(100);

    while(!done)
    {
        Vps_printf(gChains_IssIspSimcop_Display_runTimeMenu);

        ch = Chains_readChar();

        switch(ch)
        {
            case '0':
                done = TRUE;
                break;

            case '1':
                {
                /* Send command to Capture Link to save a frame */
                System_linkControl(
                        chainsObj.ucObj.IssCaptureLinkID,
                        ISSCAPTURE_LINK_CMD_SAVE_FRAME,
                        &chId,
                        sizeof(chId),
                        TRUE);

                        do {
                              System_linkControl(
                              chainsObj.ucObj.IssCaptureLinkID,
                              ISSCAPTURE_LINK_CMD_GET_SAVE_FRAME_STATUS,
                              &rawSaveFrameStatus,
                              sizeof(IssCaptureLink_GetSaveFrameStatus),
                              TRUE);

                        } while (rawSaveFrameStatus.isSaveFrameComplete == FALSE);
                        CapImCounter = xUtils_nextAvailableFile( fName, "raw%04u.raw", CapImCounter );

                        status = Utils_fileWriteFile( fName, (UInt8*)rawSaveFrameStatus.bufAddr, rawSaveFrameStatus.bufSize);

                        sprintf( fName, "raw%04u.txt", CapImCounter );

                        if(status)
                        {
                            Vps_printf("Error %d: Error performing file write\n",status);
                            xUtils_fileWriteInfo( fName, "RAW, Error" );
                        } else {
                            Vps_printf("Wrote image %s to file\n",fName);
                            xUtils_fileWriteInfo( fName, "RAW, OK" );
                    }

                break;
                }

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

    chains_iss_test_pattern_StopAndDeleteApp(&chainsObj);

}

/******************************************************************************
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.
******************************************************************************/

/**
 *******************************************************************************
 * \file iss_sensor_dummy.c
 *
 *
 *
 *******************************************************************************
*/

/*******************************************************************************
 *  INCLUDE FILES
 *******************************************************************************
 */

#include <iss_sensor_if.h>
#include <iss_sensor_serdes.h>
/**< ISS AEWB plugin is included here to get the default AEWB configuration
     from each sensor */
#include <algorithmLink_issAewb.h>

#include <ti/drv/vps/include/devices/bsp_device.h>

/*******************************************************************************
 *  Defines
 *******************************************************************************
 */



/*******************************************************************************
 *  Data structure's
 *******************************************************************************
 */

struct {

    UInt32                    maxCoarseIntgTime;
    /**< Max Coarse integration time supported by sensor */
    float                     lineIntgTimeInMs;
    /**< Line Integration time in ms */
    float                     pixIntgTimeInMs;
    /**< Pixel Integration time in ms */
} gDummyDeviceObj;


/*******************************************************************************
 *  Local Functions Declarations
 *******************************************************************************
 */

static Int32 Dummy_Start(UInt32 chId, IssSensor_CreateParams *pCreatePrms);
static Int32 Dummy_Stop(UInt32 chId, IssSensor_CreateParams *pCreatePrms);
static Int32 Dummy_SetAeParams(IssSensor_CreateParams *pCreatePrms,
    IssSensor_AeParams *pAePrms);
static Int32 Dummy_GetDccParams(IssSensor_CreateParams *pCreatePrms,
    IssSensor_DccParams *pDccPrms);
static Dummy_GetExpParams(IssSensor_CreateParams *pCreatePrms,
    IssSensor_ExposureParams *pExpPrms);
static Void Dummy_InitAewbConfig(
    IssSensor_CreateParams *pCreatePrms,
    AlgorithmLink_IssAewbCreateParams *pAewbPrms);
static Void Dummy_GetIspConfig (
    IssSensor_CreateParams *pCreatePrms,
    IssIspConfigurationParameters *pIspCfg);
static Int32 Dummy_ReadWriteReg (
    IssSensor_CreateParams *pCreatePrms, UInt32 readWriteFlag,
    IssSensor_ReadWriteReg *pReg);

static Int32 Dummy_ReadReg(UInt8         i2cInstId,
                             UInt8         i2cAddr,
                             const UInt16 *regAddr,
                             UInt8        *regVal,
                             UInt32        numRegs);
static Int32 Dummy_WriteReg(UInt8         i2cInstId,
                              UInt8         i2cAddr,
                              const UInt16 *regAddr,
                              const UInt8  *regVal,
                              UInt32        numRegs);

/*******************************************************************************
 *  Globals
 *******************************************************************************
 */

/* \brief Sensor Params structure used for registering this sensor to chains_iss
 */
static IssSensorIf_Params SensorParams_Dummy = {0};


/*******************************************************************************
 *  Function Definition
 *******************************************************************************
 */

Void IssSensor_Dummy_Init()
{
    Int32 status;
    IssSensorIf_Params *prms = &SensorParams_Dummy;
    IssSensor_Info *info = &SensorParams_Dummy.info;

    IssSensorIf_Params_Init(prms);

    strncpy(prms->name, "DUMMY", ISS_SENSORS_MAX_NAME);

    prms->dccId             = 19999;

    info->width             = 1280;
    info->height            = 720;
    info->dataFormat        = SYSTEM_DF_RGB24_888;
    info->bpp               = SYSTEM_BPP_BITS24;
    info->features          = ISS_SENSOR_FEATURE_LINEAR_MODE;
    info->aewbMode          = ALGORITHMS_ISS_AEWB_MODE_NONE;
    info->maxExp            = 1;
    info->ramOffset         = 25*1024*1024;

    prms->start             = Dummy_Start;
    prms->stop              = Dummy_Stop;
    prms->setAeParams       = Dummy_SetAeParams;
    prms->getExpParams      = Dummy_GetExpParams;
    prms->getDccParams      = Dummy_GetDccParams;
    prms->initAewbConfig    = Dummy_InitAewbConfig;
    prms->getIspConfig      = Dummy_GetIspConfig;
    prms->readWriteReg      = Dummy_ReadWriteReg;

    status = IssSensorIf_RegisterSensor(prms);
    UTILS_assert(SYSTEM_LINK_STATUS_SOK == status);
}


/*******************************************************************************
 *  Local Functions Definition
 *******************************************************************************
 */

static Int32 Dummy_Start(UInt32 chId, IssSensor_CreateParams *pCreatePrms)
{
    Int32 status = SYSTEM_LINK_STATUS_EFAIL;

    Vps_printf(">>>>>>>>> Dummy_Stop! <<<<<<<<<\n");

    return (status);
}


static Int32 Dummy_Stop(UInt32 chId,
    IssSensor_CreateParams *pCreatePrms)
{
    Int32 status = SYSTEM_LINK_STATUS_EFAIL;

    Vps_printf(">>>>>>>>> Dummy_Stop! <<<<<<<<<\n");

    return (status);
}

static Int32 Dummy_SetAeParams(IssSensor_CreateParams *pCreatePrms,
    IssSensor_AeParams *pAePrms)
{
    Vps_printf(">>>>>>>>> Dummy_SetAeParams! <<<<<<<<<\n");

    return (SYSTEM_LINK_STATUS_SOK);
}

static Int32 Dummy_ReadReg(UInt8         i2cInstId,
                             UInt8         i2cAddr,
                             const UInt16 *regAddr,
                             UInt8        *regVal,
                             UInt32        numRegs)
{
    Int32  status = SYSTEM_LINK_STATUS_SOK;
    UInt32 cnt;
    UInt8  rawRegVal[3];

    for (cnt = 0; cnt < numRegs; cnt++)
    {
        /* Convert Registers address and value into 8bit array */
        rawRegVal[0U] = (UInt8) ((regAddr[cnt] >> 8U) & (UInt8) 0xFF);
        rawRegVal[1U] = (UInt8) ((regAddr[cnt] >> 0U) & (UInt8) 0xFF);

        status = Bsp_deviceRawWrite8(i2cInstId, i2cAddr, rawRegVal, 2u);

        if (FVID2_SOK == status)
        {
            status = Bsp_deviceRawRead8(i2cInstId, i2cAddr, &rawRegVal[2U],
                1u);

            regVal[cnt] = rawRegVal[2u];
        }
    }

    return (status);
}

static Int32 Dummy_WriteReg(UInt8         i2cInstId,
                             UInt8         i2cAddr,
                             const UInt16 *regAddr,
                             const UInt8  *regValue,
                             UInt32        numRegs)
{
    Int32 status = SYSTEM_LINK_STATUS_EFAIL;
    UInt32 cnt;
    UInt8 rawRegVal[3];

    for (cnt = 0u; cnt < numRegs; cnt ++)
    {
        /* Convert Registers address and value into 8bit array */
        rawRegVal[0U] = (UInt8) ((regAddr[cnt] >> 8U) & (UInt8) 0xFF);
        rawRegVal[1U] = (UInt8) ((regAddr[cnt] >> 0U) & (UInt8) 0xFF);
        rawRegVal[2U] = (UInt8) ((regValue[cnt] >> 0U) & (UInt8) 0xFF);

        status = Bsp_deviceRawWrite8(i2cInstId, i2cAddr, rawRegVal, 3U);

        if (SYSTEM_LINK_STATUS_SOK != status)
        {
            break;
        }
    }

    return (status);
}

static Dummy_GetDccParams(IssSensor_CreateParams *pCreatePrms,
    IssSensor_DccParams *pDccPrms)
{
    Int32 status = SYSTEM_LINK_STATUS_SOK;

    Vps_printf(">>>>>>>>> Dummy_GetDccParams! <<<<<<<<<\n");

    return (status);
}

static Dummy_GetExpParams(IssSensor_CreateParams *pCreatePrms,
    IssSensor_ExposureParams *pExpPrms)
{
    Int32 status = SYSTEM_LINK_STATUS_SOK;

    Vps_printf(">>>>>>>>> Dummy_GetExpParams! <<<<<<<<<\n");

    return (status);
}

static Void Dummy_InitAewbConfig(
    IssSensor_CreateParams *pCreatePrms,
    AlgorithmLink_IssAewbCreateParams *pAewbPrms)
{
    Vps_printf(">>>>>>>>> Dummy_InitAewbConfig! <<<<<<<<<\n");
}

static Void Dummy_GetIspConfig (
    IssSensor_CreateParams *pCreatePrms,
    IssIspConfigurationParameters *pIspCfg)
{
    Vps_printf(">>>>>>>>> Dummy_GetIspConfig! <<<<<<<<<\n");
}

static Int32 Dummy_ReadWriteReg (
    IssSensor_CreateParams *pCreatePrms, UInt32 readWriteFlag,
    IssSensor_ReadWriteReg *pReg)
{
    Int32 status;
    UInt32 chId;
    UInt8 regValue;

    UTILS_assert(NULL != pReg);
    UTILS_assert(NULL != pReg);

    /* Assuming Channel Id as 0 */
    chId = pReg->chId;

    if (readWriteFlag)
    {
        regValue = pReg->regValue;
        status = Dummy_WriteReg(pCreatePrms->i2cInstId,
            pCreatePrms->i2cAddr[chId], &pReg->regAddr, &regValue, 1u);
    }
    else
    {
        status = Dummy_ReadReg(pCreatePrms->i2cInstId,
            pCreatePrms->i2cAddr[chId], &pReg->regAddr, &regValue, 1u);

        if (SYSTEM_LINK_STATUS_SOK == status)
        {
            pReg->regValue = regValue;
        }
    }

    return (status);
}
/******************************************************************************
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.
******************************************************************************/

/**
 *******************************************************************************
 * \file iss_sensor_tda3xx.c
 *
 *
 *
 *******************************************************************************
*/

/*******************************************************************************
 *  INCLUDE FILES
 *******************************************************************************
 */
/* Including system.h for Int32/UInt32 data type */
#include <include/link_api/system.h>
#include <ti/drv/vps/include/platforms/bsp_platform.h>
#include <ti/drv/vps/include/boards/bsp_board.h>
#include <ti/drv/vps/include/vps.h>
#include <ti/drv/vps/include/vps_capture.h>
#include <ti/drv/vps/include/devices/bsp_device.h>
#include <ti/drv/vps/examples/utility/bsputils_ub960.h>
#include <iss_sensors.h>
#include <iss_sensor_serdes.h>
#include <iss_utils.h>

/*******************************************************************************
 *  Defines
 *******************************************************************************
 */

/* I2C Instance for the board Mux */
#define CHAINS_COMMON_TDA3XX_BOARD_MUX_I2C_INST     (0U)
/* I2C Address of the board mux */
#define CHAINS_COMMON_TDA3XX_BOARD_MUX_I2C_ADDR     (0x23U)


/*******************************************************************************
 *  Data Structures
 *******************************************************************************
 */

typedef struct {
    char name[ISS_SENSORS_MAX_NAME];
    ChainsCommon_IssSensorIf info;
} ChainsCommon_SensorIntfInfo;

/*******************************************************************************
 *  Globals
 *******************************************************************************
 */

const static IssUtils_Ub96xSerDesCfg gSensorSerDesInfo[] = {
    {SENSOR_APTINA_AR0132, NULL, 0, NULL, 0, BSPUTILS_FPDCAMPOWERLEVEL_OFF, 0U},

    {SENSOR_APTINA_AR0140, NULL, 0, NULL, 0, BSPUTILS_FPDCAMPOWERLEVEL_OFF, 0U},

    {SENSOR_OMNIVISION_OV10640_CSI2, NULL, 0, NULL, 0, BSPUTILS_FPDCAMPOWERLEVEL_OFF, 0U},

    {SENSOR_SONY_IMX224_CSI2, NULL, 0, NULL, 0, BSPUTILS_FPDCAMPOWERLEVEL_OFF, 0U},

    {SENSOR_OMNIVISION_OV10640_IMI, gAppIssUtilsUb960Cfg_OV10640_IMI, OV10640_IMI_DES_CFG_SIZE,
                                                gUB913_OV10640_IMI_SerCfg, OV10640_IMI_SER_CFG_SIZE,
                                                BSPUTILS_FPDCAMPOWERLEVEL_12V0, 100U},

    {SENSOR_APTINA_AR0140_TIDA262, gAppIssUtilsUb960Cfg_AR0140_TIDA0262_DesCfg, AR0140_TIDA0262_DES_CFG_SIZE,
                                                gUB913_AR0140_TIDA0262_SerCfg, AR0140_TIDA0262_SER_CFG_SIZE,
                                                BSPUTILS_FPDCAMPOWERLEVEL_12V0, 100U},

    {SENSOR_OMNIVISION_OV2775_TIDA1130, gAppIssUtilsUb960Cfg_OV2775_TIDA1130_DesCfg, OV2775_TIDA1130_DES_CFG_SIZE,
                                                gUB953_OV2775_TIDA1130_SerCfg, OV2775_TIDA1130_SER_CFG_SIZE,
                                                BSPUTILS_FPDCAMPOWERLEVEL_12V0, 100U},

    {SENSOR_SONY_IMX390_UB953_D3, gUB960DesCfg_D3IMX390, IMX390_D3_DES_CFG_SIZE,
                                                gAppIssUtilsUB953SerCfg_D3IMX390, IMX390_D3_SER_CFG_SIZE,
                                                BSPUTILS_FPDCAMPOWERLEVEL_12V0, 2000U},

    {SENSOR_OMNIVISION_OV2775_CSI2, NULL, 0, NULL, 0, BSPUTILS_FPDCAMPOWERLEVEL_OFF, 0U},

    {SENSOR_APTINA_AR0143_MARS, gAppIssUtilsUb960Cfg_MARS_AR0143,AR143_MARS_DES_CFG_SIZE,
                                                gUB913MarsAR0143SerCfg, AR143_MARS_SER_CFG_SIZE,
                                                BSPUTILS_FPDCAMPOWERLEVEL_12V0, 500U},
};

const static ChainsCommon_SensorIntfInfo gSensorInterfaceInfo[] = {
    {SENSOR_APTINA_AR0132,
        {1u, {0x10}, {0x10}, FALSE, SYSTEM_VIFW_12BIT, SYSTEM_VIFM_SCH_CPI}},
    {SENSOR_APTINA_AR0140,
        {1u, {0x10}, {0x10}, FALSE, SYSTEM_VIFW_12BIT, SYSTEM_VIFM_SCH_CPI}},
    {SENSOR_OMNIVISION_OV10640_CSI2,
        {1u, {0x32}, {0x32}, FALSE, SYSTEM_VIFW_4LANES, SYSTEM_VIFM_SCH_CSI2,
            SYSTEM_CSI2_RAW12 /* CSI2 DataFormat*/, 0 /*Virtual Channel Id*/,
                0, /* IsCSIPostEnable Required */
                {TRUE /* isCplxCfgValid */,
                    {{FALSE, 2}, /* Clock Lane */
                     {FALSE, 1}, /* data1Lane */
                     {FALSE, 3}, /* data2Lane */
                     {FALSE, 4}, /* data3Lane*/
                     {FALSE, 5}},/* data4Lane */
                     400 /* csi2PhyClk */ }}},
    {SENSOR_SONY_IMX224_CSI2,
        {1u, {0x36}, {0x36}, FALSE, SYSTEM_VIFW_4LANES, SYSTEM_VIFM_SCH_CSI2,
            SYSTEM_CSI2_RAW12 /* CSI2 DataFormat*/, 0 /*Virtual Channel Id*/,
                0, /* IsCSIPostEnable Required */
                {TRUE /* isCplxCfgValid */,
                    {{FALSE, 2u}, /* Clock Lane */
                     {FALSE, 1u}, /* data1Lane */
                     {FALSE, 3u}, /* data2Lane */
                     {FALSE, 4u}, /* data3Lane*/
                     {FALSE, 5u}},/* data4Lane */
                     150u /* csi2PhyClk */ }}},
    {SENSOR_OMNIVISION_OV10640_IMI,
        {
#ifdef BOARD_TYPE_TDA3XX_RVP
            0u, /* TDA3X RVP board uses I2C instance 0 */
#else
            1u, /* TDA3X EVM board uses I2C instance 1 */
#endif
            {PORT_0_SENSOR_ADDR, PORT_1_SENSOR_ADDR, PORT_2_SENSOR_ADDR, PORT_3_SENSOR_ADDR},   /* Sensor alias address */
            {PORT_0_SER_ADDR, PORT_1_SER_ADDR, PORT_2_SER_ADDR, PORT_3_SER_ADDR},   /* Serializer alias address */
            TRUE, /* isMultiChannel */
            SYSTEM_VIFW_4LANES, SYSTEM_VIFM_SCH_CSI2,
            SYSTEM_CSI2_RAW12 /* CSI2 DataFormat*/,
            0 /*Virtual Channel Id*/,
                0, /* IsCSIPostEnable Required */
                {TRUE /* isCplxCfgValid */,
                    {{FALSE, 1}, /* Clock Lane */
                     {FALSE, 2}, /* data1Lane */
                     {FALSE, 3}, /* data2Lane */
                     {FALSE, 4}, /* data3Lane*/
                     {FALSE, 5}},/* data4Lane */
                     800 /* csi2PhyClk */ },
                     FVID2_VID_SENSOR_IMI_OV10640_DRV,          /* sensorDrvId */
                     TRUE,      /* sensorBroadcast */
                     TRUE}},    /* enableFsin */
    {SENSOR_APTINA_AR0140_TIDA262,
        {
#ifdef BOARD_TYPE_TDA3XX_RVP
            0u, /* TDA3X RVP board uses I2C instance 0 */
#else
            1u, /* TDA3X EVM board uses I2C instance 1 */
#endif
            {PORT_0_SENSOR_ADDR, PORT_1_SENSOR_ADDR, PORT_2_SENSOR_ADDR, PORT_3_SENSOR_ADDR},   /* Sensor alias address */
            {PORT_0_SER_ADDR, PORT_1_SER_ADDR, PORT_2_SER_ADDR, PORT_3_SER_ADDR},   /* Serializer alias address */
            TRUE, /* isMultiChannel */
            SYSTEM_VIFW_4LANES, SYSTEM_VIFM_SCH_CSI2,
            SYSTEM_CSI2_RAW12 /* CSI2 DataFormat*/,
            0 /*Virtual Channel Id*/,
                0, /* IsCSIPostEnable Required */
                {TRUE /* isCplxCfgValid */,
                    {{FALSE, 1}, /* Clock Lane */
                     {FALSE, 2}, /* data1Lane */
                     {FALSE, 3}, /* data2Lane */
                     {FALSE, 4}, /* data3Lane*/
                     {FALSE, 5}},/* data4Lane */
                     800 /* csi2PhyClk */ },
                     FVID2_VID_SENSOR_TIDA00262_APT_AR0140_DRV, /* sensorDrvId */
                     FALSE,     /* sensorBroadcast */
                     FALSE}},   /* enableFsin */
#ifdef BOARD_TYPE_TDA3XX_RVP
    {SENSOR_OMNIVISION_OV2775_TIDA1130,
        {
            0u, /* TDA3X RVP board uses I2C instance 1 */
            {PORT_0_SENSOR_ADDR, PORT_1_SENSOR_ADDR, PORT_2_SENSOR_ADDR, PORT_3_SENSOR_ADDR},    /* Sensor alias address */
            {PORT_0_SER_ADDR, PORT_1_SER_ADDR, PORT_2_SER_ADDR, PORT_3_SER_ADDR},    /* Serializer alias address */
            TRUE, /* isMultiChannel */
            SYSTEM_VIFW_4LANES, SYSTEM_VIFM_SCH_CSI2,
            SYSTEM_CSI2_RAW12 /* CSI2 DataFormat*/,
            0 /*Virtual Channel Id*/,
                0, /* IsCSIPostEnable Required */
                {TRUE /* isCplxCfgValid */,
                    {{FALSE, 1}, /* Clock Lane */
                     {FALSE, 2}, /* data1Lane */
                     {FALSE, 3}, /* data2Lane */
                     {FALSE, 4}, /* data3Lane*/
                     {FALSE, 5}},/* data4Lane */
                     800 /* csi2PhyClk */ },
                     FVID2_VID_SENSOR_OV2775_TIDA1130_DRV, /* sensorDrvId */
                     FALSE,     /* sensorBroadcast */
                     FALSE}},   /* enableFsin */
    {SENSOR_SONY_IMX390_UB953_D3,
        {
            0u, /* TDA3X EVM board uses I2C instance 1 */
            {PORT_0_SENSOR_ADDR, PORT_1_SENSOR_ADDR, PORT_2_SENSOR_ADDR, PORT_3_SENSOR_ADDR},    /* Sensor alias address */
            {PORT_0_SER_ADDR, PORT_1_SER_ADDR, PORT_2_SER_ADDR, PORT_3_SER_ADDR},    /* Serializer alias address */
            TRUE, /* isMultiChannel */
            SYSTEM_VIFW_4LANES, SYSTEM_VIFM_SCH_CSI2,
            SYSTEM_CSI2_RAW12 /* CSI2 DataFormat*/,
            0 /*Virtual Channel Id*/,
                1, /* Is CSI Enable Required in UB960 */
                {TRUE /* isCplxCfgValid */,
                    {{FALSE, 1}, /* Clock Lane */
                     {FALSE, 2}, /* data1Lane */
                     {FALSE, 3}, /* data2Lane */
                     {FALSE, 4}, /* data3Lane*/
                     {FALSE, 5}},/* data4Lane */
                     800 /* csi2PhyClk */ },
                     FVID2_VID_SENSOR_D3_SONY_IMX390_DRV, /* sensorDrvId */
                     FALSE,     /* sensorBroadcast */
                     FALSE},   /* enable Fsin */
                     },
#endif
    {SENSOR_OMNIVISION_OV2775_CSI2,
        {1u, {0x36}, {0x36}, FALSE, SYSTEM_VIFW_4LANES, SYSTEM_VIFM_SCH_CSI2,
            SYSTEM_CSI2_RAW12 /* CSI2 DataFormat*/, 0 /*Virtual Channel Id*/,
                0, /* IsCSIPostEnable Required */
                {TRUE /* isCplxCfgValid */,
                    {{FALSE, 3}, /* Clock Lane */
                     {FALSE, 4}, /* data1Lane */
                     {FALSE, 2}, /* data2Lane */
                     {FALSE, 0}, /* data3Lane*/
                     {FALSE, 0}},/* data4Lane */
                     480 /* csi2PhyClk */ }}},
    {SENSOR_APTINA_AR0143_MARS,
        {
#ifdef BOARD_TYPE_TDA3XX_RVP
            0u, /* TDA3X RVP board uses I2C instance 0 */
#else
            1u, /* TDA3X EVM board uses I2C instance 1 */
#endif
            {PORT_0_SENSOR_ADDR, PORT_1_SENSOR_ADDR, PORT_2_SENSOR_ADDR, PORT_3_SENSOR_ADDR},    /* Sensor alias address */
            {PORT_0_SER_ADDR, PORT_1_SER_ADDR, PORT_2_SER_ADDR, PORT_3_SER_ADDR},    /* Serializer alias address */
            TRUE, /* isMultiChannel */
            SYSTEM_VIFW_4LANES, SYSTEM_VIFM_SCH_CSI2,
            SYSTEM_CSI2_RAW12 /* CSI2 DataFormat*/,
            0 /*Virtual Channel Id*/,
                0, /* IsCSIPostEnable Required */
                {TRUE /* isCplxCfgValid */,
                    {{FALSE, 1}, /* Clock Lane */
                     {FALSE, 2}, /* data1Lane */
                     {FALSE, 3}, /* data2Lane */
                     {FALSE, 4}, /* data3Lane*/
                     {FALSE, 5}},/* data4Lane */
                     800 /* csi2PhyClk */ },
                     FVID2_VID_SENSOR_MARS_APT_AR0143_DRV,         /* sensorDrvId */
                     FALSE,     /* sensorBroadcast */
                     FALSE}},   /* enableFsin */
    // Koncar           
    {"DUMMY",
        {
            1u, /* TDA3X EVM board uses I2C instance 1 */
            {0x60},    /* Sensor alias address */
            {0x60},    /* Serializer alias address */
            FALSE, /* isMultiChannel */
            SYSTEM_VIFW_4LANES, SYSTEM_VIFM_SCH_CSI2,
            SYSTEM_CSI2_RAW8 /* CSI2 DataFormat*/,
            0 /*Virtual Channel Id*/,
                0, /* IsCSIPostEnable Required */
                {TRUE /* isCplxCfgValid */,
                    {{FALSE, 1}, /* Clock Lane */
                     {FALSE, 2}, /* data1Lane */
                     {FALSE, 3}, /* data2Lane */
                     {FALSE, 4}, /* data3Lane*/
                     {FALSE, 5}},/* data4Lane */
                     400 /* csi2PhyClk */ },
                     19999,         /* sensorDrvId */
                     FALSE,     /* sensorBroadcast */
                     FALSE}},   /* enableFsin */
                     
};

/*******************************************************************************
 *  Local Functions Declarations
 *******************************************************************************
 */


/*******************************************************************************
 *  Function Definition
 *******************************************************************************
 */

Int32 ChainsPlatform_GetSensorSerDesCfg(char name[],
    IssUtils_Ub96xSerDesCfg* cfg)
{
    Int32 status = SYSTEM_LINK_STATUS_EFAIL;
    UInt32 cnt, numSensors;

    UTILS_assert(NULL != cfg);

    numSensors = sizeof(gSensorSerDesInfo)/sizeof(IssUtils_Ub96xSerDesCfg);

    for (cnt = 0u; cnt < numSensors; cnt ++)
    {
        if (0 == strncmp(name, gSensorSerDesInfo[cnt].name,
                ISS_SENSORS_MAX_NAME))
        {
             cfg->desCfgScript = gSensorSerDesInfo[cnt].desCfgScript;
             cfg->num_des_registers= gSensorSerDesInfo[cnt].num_des_registers;
             cfg->serCfgScript = gSensorSerDesInfo[cnt].serCfgScript;
             cfg->num_ser_registers= gSensorSerDesInfo[cnt].num_ser_registers;
             cfg->cam_pwr_level = gSensorSerDesInfo[cnt].cam_pwr_level;
             cfg->waitAfterPowerOn = gSensorSerDesInfo[cnt].waitAfterPowerOn;
            status = SYSTEM_LINK_STATUS_SOK;
            break;
        }
    }

    return (status);

}

Int32 ChainsPlatform_GetSensorIntfInfo(char name[],
    ChainsCommon_IssSensorIf *info)
{
    Int32 status = SYSTEM_LINK_STATUS_EFAIL;
    UInt32 cnt, numSensors;

    UTILS_assert(NULL != info);

    numSensors = sizeof(gSensorInterfaceInfo)/sizeof(ChainsCommon_SensorIntfInfo);

    for (cnt = 0u; cnt < numSensors; cnt ++)
    {
        if (0 == strncmp(name, gSensorInterfaceInfo[cnt].name,
                ISS_SENSORS_MAX_NAME))
        {
            info->i2cInstId = gSensorInterfaceInfo[cnt].info.i2cInstId;
            info->i2cAddr[0] = gSensorInterfaceInfo[cnt].info.i2cAddr[0];
            info->i2cAddr[1] = gSensorInterfaceInfo[cnt].info.i2cAddr[1];
            info->i2cAddr[2] = gSensorInterfaceInfo[cnt].info.i2cAddr[2];
            info->i2cAddr[3] = gSensorInterfaceInfo[cnt].info.i2cAddr[3];
            info->i2cAddr[4] = gSensorInterfaceInfo[cnt].info.i2cAddr[4];
            info->i2cAddr[5] = gSensorInterfaceInfo[cnt].info.i2cAddr[5];
            info->i2cAddr[6] = gSensorInterfaceInfo[cnt].info.i2cAddr[6];
            info->i2cAddr[7] = gSensorInterfaceInfo[cnt].info.i2cAddr[7];
            info->i2cAddrSer[0] = gSensorInterfaceInfo[cnt].info.i2cAddrSer[0];
            info->i2cAddrSer[1] = gSensorInterfaceInfo[cnt].info.i2cAddrSer[1];
            info->i2cAddrSer[2] = gSensorInterfaceInfo[cnt].info.i2cAddrSer[2];
            info->i2cAddrSer[3] = gSensorInterfaceInfo[cnt].info.i2cAddrSer[3];
            info->i2cAddrSer[4] = gSensorInterfaceInfo[cnt].info.i2cAddrSer[4];
            info->i2cAddrSer[5] = gSensorInterfaceInfo[cnt].info.i2cAddrSer[5];
            info->i2cAddrSer[6] = gSensorInterfaceInfo[cnt].info.i2cAddrSer[6];
            info->i2cAddrSer[7] = gSensorInterfaceInfo[cnt].info.i2cAddrSer[7];

            info->isMultiChannel = gSensorInterfaceInfo[cnt].info.isMultiChannel;
            info->videoIfWidth = gSensorInterfaceInfo[cnt].info.videoIfWidth;
            info->videoIfMode = gSensorInterfaceInfo[cnt].info.videoIfMode;
            info->inCsi2DataFormat =
                gSensorInterfaceInfo[cnt].info.inCsi2DataFormat;
            info->inCsi2VirtualChanNum =
                gSensorInterfaceInfo[cnt].info.inCsi2VirtualChanNum;

            info->csi2Prms[0] = gSensorInterfaceInfo[cnt].info.csi2Prms[0];
            info->csi2Prms[1] = gSensorInterfaceInfo[cnt].info.csi2Prms[1];
            info->sensorDrvId = gSensorInterfaceInfo[cnt].info.sensorDrvId;
            info->sensorBroadcast = gSensorInterfaceInfo[cnt].info.sensorBroadcast;
            info->enableFsin = gSensorInterfaceInfo[cnt].info.enableFsin;

            info->isEnableCSIPostConfig = gSensorInterfaceInfo[cnt].info.isEnableCSIPostConfig;

            info->deserializerAddr[0] = gSensorInterfaceInfo[cnt].info.deserializerAddr[0];
            info->deserializerAddr[1] = gSensorInterfaceInfo[cnt].info.deserializerAddr[1];

            status = SYSTEM_LINK_STATUS_SOK;
            break;
        }
    }

    return (status);
}

Void ChainsPlatform_SetPinMux(char name[])
{
    Int32 status;
    UInt32 cnt, numSensors;
    Bsp_BoardMode boardMode;

    numSensors = sizeof(gSensorInterfaceInfo)/sizeof(ChainsCommon_IssSensorIf);

    for (cnt = 0u; cnt < numSensors; cnt ++)
    {
        if ((0 == strncmp(name, gSensorInterfaceInfo[cnt].name,
                ISS_SENSORS_MAX_NAME)) &&
            (SYSTEM_VIFM_SCH_CPI == gSensorInterfaceInfo[cnt].info.videoIfMode))
        {
            switch (gSensorInterfaceInfo[cnt].info.videoIfWidth)
            {
                default:
                    boardMode = BSP_BOARD_MODE_NONE;
                    break;
                case SYSTEM_VIFW_8BIT:
                    boardMode = BSP_BOARD_MODE_VIDEO_8BIT;
                    break;
                case SYSTEM_VIFW_10BIT:
                    boardMode = BSP_BOARD_MODE_VIDEO_10BIT;
                    break;
                case SYSTEM_VIFW_12BIT:
                    boardMode = BSP_BOARD_MODE_VIDEO_12BIT;
                    break;
                case SYSTEM_VIFW_14BIT:
                    boardMode = BSP_BOARD_MODE_VIDEO_14BIT;
                    break;
                case SYSTEM_VIFW_16BIT:
                    boardMode = BSP_BOARD_MODE_VIDEO_16BIT;
                    break;
                case SYSTEM_VIFW_24BIT:
                    boardMode = BSP_BOARD_MODE_VIDEO_24BIT;
                    break;
            }

            /* Set pinmux */
            status = Bsp_boardSetPinMux(FVID2_VPS_CAPT_VID_DRV,
                VPS_CAPT_INST_ISS_CAL_A, boardMode);

            UTILS_assert (SYSTEM_LINK_STATUS_SOK == status);

            break;
        }
    }

}

Void ChainsBoard_SetBoardMux(char name[])
{
    Int32 status;
    UInt32 cnt, numSensors;
    UInt8 regValue[3U];

    numSensors = sizeof(gSensorInterfaceInfo)/sizeof(ChainsCommon_IssSensorIf);

    for (cnt = 0u; cnt < numSensors; cnt ++)
    {
        if ((0 == strncmp(name, gSensorInterfaceInfo[cnt].name,
                ISS_SENSORS_MAX_NAME)) &&
            (SYSTEM_VIFM_SCH_CPI == gSensorInterfaceInfo[cnt].info.videoIfMode))
        {
            status = Bsp_boardReadTCA6424BoardMux(3, regValue);
            UTILS_assert(status == BSP_SOK);

            /* Select the CPI input by setting Mux Control 0 and 5 */
            regValue[0u] |= (0x21);
            /* Set VIN_MAP[0:2] to 010 for Aptina 12-bit - Level 2 */
            regValue[2u] &= ~(0x3D);

            status = Bsp_boardWriteTCA6424BoardMux(3, regValue);
            UTILS_assert(status == BSP_SOK);

            BspOsal_sleep(50);

            break;
        }
    }
}
/*
 *******************************************************************************
 *
 * Copyright (C) 2013 Texas Instruments Incorporated - http://www.ti.com/
 * ALL RIGHTS RESERVED
 *
 *******************************************************************************
 */

/*******************************************************************************
 *  INCLUDE FILES
 *******************************************************************************
 */
//#include <examples/tda2xx/include/chains.h>
#include <system_cfg.h>
#include <src/include/chains_common.h>
#include <ti/drv/vps/include/devices/bsp_device.h>

/**
 *  \brief Register address and value pair, with delay.
 */
typedef struct
{
    UInt8 nRegAddr;
    /**< Register Address */
    UInt8 nRegValue;
    /**< Slave Address */
    UInt32 nDelay;
    /**< Delay to be applied, after the register is programmed */
} BspUtils_Ub95xI2cParams;

static BspUtils_Ub95xI2cParams g954Cfg[] =
{
    {0x33, 0x01, 0x0},
    {0xB0, 0x00, 0x0},
    {0xB1, 0x01, 0x0},
    {0xB2, 0x01, 0x0},
    {0xB1, 0x02, 0x0},
    {0xB2, 0x33, 0x0},
    {0xB1, 0x03, 0x0},
    {0xB2, 0x24, 0x0},
    {0xB1, 0x04, 0x0},
    {0xB2, 0x0F, 0x0},
    {0xB1, 0x05, 0x0},
    {0xB2, 0x00, 0x0},
    {0xB1, 0x06, 0x0},
    {0xB2, 0x01, 0x0},
    {0xB1, 0x07, 0x0},
    {0xB2, 0xE0, 0x0},
    {0xB1, 0x08, 0x0},
    {0xB2, 0x02, 0x0},
    {0xB1, 0x09, 0x0},
    {0xB2, 0xD0, 0x0},
    {0xB1, 0x0A, 0x0},
    {0xB2, 0x04, 0x0},
    {0xB1, 0x0B, 0x0},
    {0xB2, 0x1A, 0x0},
    {0xB1, 0x0C, 0x0},
    {0xB2, 0x0C, 0x0},
    {0xB1, 0x0D, 0x0},
    {0xB2, 0x67, 0x0},
    {0xB1, 0x0E, 0x0},
    {0xB2, 0x21, 0x0},
    {0xB1, 0x0F, 0x0},
    {0xB2, 0x0A, 0x0},

};


void configDeser(void)
{
    Int32 retVal;
    Int32 idx;
    Int32 errCount = 0;

    for (idx = 0; idx < sizeof(g954Cfg) / sizeof(g954Cfg[0]); idx++)
    {
        retVal = Bsp_deviceWrite8(BSP_DEVICE_I2C_INST_ID_1,
                    0x30,
                    &(g954Cfg[idx].nRegAddr),
                    &(g954Cfg[idx].nRegValue),
                    (UInt32) 1U);
                
        if (retVal != BSP_SOK)
        {
            errCount++;
            Vps_printf("Error...\n");
        }
                
    }
    
    if (errCount == 0)
    {
        Vps_printf("Deser configuration OK!\n");
    }

}

  • Hello ,

    I am not sure how/if ISP bypass is done in the Vision SDK, so I will let Vision SDK experts comment on that. However as a side note, from hardware point of view, the CAL_A(CSI2) has a write DMA engine that is able to write to memory directly (i.e. not feeding the ISP through the video port). You can check the TDA3x ISS chapter for details.

    Thanks,
    Alex
  • Hi Stefan Koncar,

    Can you please check on the following
    1. Can you please share the IssCaptureLink parameters that being set in the usecase file
    2. Ensure to setup de-serializer after capture link has been started, i.e. call function configDeser () after capture link is started.

    Regards,
    Sujith
  • Hi Sujith,

    I checked following:

    1. You can check parameters in attached file, in function setCaptureParams.

    2. Yes, I started deserializer after link start.

    /******************************************************************************
    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_iss_test_pattern_priv.h"
    #include <src/include/chains_common.h>
    #include <src/rtos/iss/include/iss_sensors.h>
    #include <src/rtos/iss/include/iss_utils.h>
    #include <src/rtos/iss/include/app_util_iss.h>
    
    
    /*
     * AEWB algorithm memory requirement cannot be calculated upfront.
     * This size is known by running the use-case once with large size
     * and then checking the log for unused memory in AEWB algorithm
     */
    #define ALG_AEWB_MEM_SIZE                           (896*1024)
    
    void configDeser(void);
    
    Int32 Utils_fileWriteFile(char *fileName, Uint8 *addr, Uint32 size);
    
    
    
    /* returns 0 if does not exist, 1 if it does */
    Int32 xUtils_fileExists( char *fileName )
    {
        Int32 retVal = 0;
        Int32 hndlFile;
    
        hndlFile = File_open(fileName, "rb");
    
        if(hndlFile < 0)
        {
        retVal = 0;
        } else {
        retVal = 1;
        }
        File_close( hndlFile );
    
        return retVal;
    }
    
    /* creates a filepath from an index and the fmt with a %u in it
     * tries to find the next available unused value
     */
    Int32 xUtils_nextAvailableFile( char * buf, char * fmt, Int32 theIndex )
    {
    sprintf( buf, fmt, theIndex );
    
    while( xUtils_fileExists( buf ) && theIndex < 9999 )
    {
    Vps_printf( "filename %s %d exists... skipping\n", buf, theIndex );
    theIndex++;
        sprintf( buf, fmt, theIndex );
    }
    
    if( theIndex >= 9999 ) {
    theIndex = 0;
        sprintf( buf, fmt, theIndex );
    }
    return theIndex;
    }
    
    Int32 lastExposureTime = 0;
    
    Int32 xUtils_fileWriteInfo( char * filename, char * extra )
    {
    Int32 status = 0;
    char buf [200];
    
    sprintf( buf, "%s, %u, %s\n", filename, lastExposureTime, extra );
    
    status = Utils_fileWriteFile( filename, (Uint8 *)buf, strlen( buf ));
    
    return status;
    }
    
    
    /**
     *******************************************************************************
     *
     *  \brief  SingleCameraFrameCopyObject
     *
     *        This structure contains all the LinksId's and create Params.
     *        The same is passed to all create, start, stop functions.
     *
     *******************************************************************************
    */
    typedef struct {
    
        chains_iss_test_patternObj  ucObj;
    
        IssM2mSimcopLink_ConfigParams   simcopConfig;
        vpsissldcConfig_t               ldcCfg;
        vpsissvtnfConfig_t              vtnfCfg;
    
        UInt32                          captureOutWidth;
        UInt32                          captureOutHeight;
        UInt32                          displayWidth;
        UInt32                          displayHeight;
    
        Chains_Ctrl                    *chainsCfg;
    
        IssM2mSimcopLink_OperatingMode  simcopMode;
        Bool                            bypassVtnf;
        Bool                            bypassLdc;
    
        AppUtils_Obj             appSensInfo;
    } chains_iss_test_patternAppObj;
    
    
    char gChains_IssIspSimcop_Display_runTimeMenu[] = {
    "\r\n "
    "\r\n ===================="
    "\r\n Chains Run-time Menu"
    "\r\n ===================="
    "\r\n "
    "\r\n 0: Stop Chain"
    "\r\n "
    "\r\n 1: Save Captured Frame"
    "\r\n "
    "\r\n p: Print Performance Statistics "
    "\r\n "
    "\r\n Enter Choice: "
    "\r\n "
    };
    
    
    static Void setCaptureParams(chains_iss_test_patternAppObj *pObj)
    {
        UInt32 idx;
        IssCaptureLink_CreateParams*    pCaptPrm;
        IssCaptureLink_Csi2Params*      pCsi2Prm;
        IssCaptureLink_OutParams*       pOutPrm;
        System_VideoDataFormat          inOutDataFormat;
    
        pCaptPrm = &pObj->ucObj.IssCapturePrm;
        memset((void*) pCaptPrm, 0, sizeof(IssCaptureLink_CreateParams));
    
        pCaptPrm->videoIfMode            = SYSTEM_VIFM_SCH_CSI2;
        pCaptPrm->videoIfWidth           = SYSTEM_VIFW_4LANES;
        pCaptPrm->bufCaptMode            = SYSTEM_CAPT_BCM_LAST_FRM_REPEAT;
    
        for (idx = 0U; idx < ISSCAPT_LINK_MAX_CMPLXIO_INST; idx++)
        {
            pCsi2Prm = &pCaptPrm->csi2Params[idx];
    
            pCsi2Prm->isCmplxIoCfgValid = TRUE;
            pCsi2Prm->csi2PhyClk        = 400U;
    
            pCsi2Prm->cmplxIoCfg.clockLane.pol      = FALSE;
            pCsi2Prm->cmplxIoCfg.clockLane.position = 1U;
            pCsi2Prm->cmplxIoCfg.data1Lane.pol      = FALSE;
            pCsi2Prm->cmplxIoCfg.data1Lane.position = 2U;
            pCsi2Prm->cmplxIoCfg.data2Lane.pol      = FALSE;
            pCsi2Prm->cmplxIoCfg.data2Lane.position = 3U;
            pCsi2Prm->cmplxIoCfg.data3Lane.pol      = FALSE;
            pCsi2Prm->cmplxIoCfg.data3Lane.position = 4U;
            pCsi2Prm->cmplxIoCfg.data4Lane.pol      = FALSE;
            pCsi2Prm->cmplxIoCfg.data4Lane.position = 5U;
        }
    
        pCaptPrm->csi2Params[0U].isCmplxIoCfgValid = TRUE;
    
        pCaptPrm->numCh = 1;
    
        inOutDataFormat = SYSTEM_DF_RGB24_888;
    
        for (idx = 0U; idx < pCaptPrm->numCh; idx++)
        {
            pOutPrm = &pCaptPrm->outParams[idx];
            pOutPrm->phyInstance    = 0U;
            pOutPrm->width          = pObj->captureOutWidth;
            pOutPrm->height         = pObj->captureOutHeight;
            pOutPrm->dataFormat     = inOutDataFormat;
            pOutPrm->inCsi2DataFormat       = SYSTEM_CSI2_RAW8;
            pOutPrm->inCsi2VirtualChanNum   = idx;
            pOutPrm->maxWidth       = pObj->captureOutWidth;
            pOutPrm->maxHeight      = pObj->captureOutHeight;
            pOutPrm->numOutBuf      = 4;
            pOutPrm->outDataFormat  = inOutDataFormat;
            pOutPrm->outBpp         = SYSTEM_BPP_BITS24;
            if (idx >= 4)
            {
                pOutPrm->phyInstance    = 1U;
            }
        }
        pCaptPrm->allocBufferForRawDump  = TRUE;
    
        return;
    }
    
    
    /**
     *******************************************************************************
     *
     * \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_iss_test_pattern_SetAppPrms(
        chains_iss_test_patternObj *pUcObj, Void *appObj)
    {
        chains_iss_test_patternAppObj *pObj
            = (chains_iss_test_patternAppObj*)appObj;
    
        ChainsCommon_GetDisplayWidthHeight(
            pObj->chainsCfg->displayType,
            &pObj->displayWidth,
            &pObj->displayHeight
            );
    
        /* Create the sensor now */
        strncpy(pObj->appSensInfo.sensorName, "DUMMY", //pObj->chainsCfg->sensorName,
            ISS_SENSORS_MAX_NAME);
        pObj->appSensInfo.numCh = 1;
        pObj->appSensInfo.ispOpMode = pObj->chainsCfg->ispOpMode;
        pObj->appSensInfo.simcopOpMode = pObj->simcopMode;
        pObj->appSensInfo.numCSI2Inst = 1;
        appCreateISSSensor(&pObj->appSensInfo);
    
        appInitIssCaptParams(&pObj->appSensInfo, pUcObj->IssCaptureLinkID,
            &pUcObj->IssCapturePrm);
    
    
        pObj->captureOutWidth = pUcObj->IssCapturePrm.outParams[0U].width;
        pObj->captureOutHeight = pUcObj->IssCapturePrm.outParams[0U].height;
        
        Vps_printf("pUcObj->IssCapturePrm.outParams[0U].width: %d\n", pUcObj->IssCapturePrm.outParams[0U].width);
        Vps_printf("pUcObj->IssCapturePrm.outParams[0U].height: %d\n", pUcObj->IssCapturePrm.outParams[0U].height);
        Vps_printf("pUcObj->IssCapturePrm.videoIfMode: %d\n", pUcObj->IssCapturePrm.videoIfMode);
        Vps_printf("pUcObj->IssCapturePrm.outParams[0U].phyInstance: %d\n", pUcObj->IssCapturePrm.outParams[0U].phyInstance);
        
        pUcObj->IssCapturePrm.allocBufferForRawDump = TRUE;
        
        setCaptureParams(pObj);
    
        pUcObj->NullPrm.dumpDataType = NULL_LINK_COPY_TYPE_NONE;
    
    /*
    
        ChainsCommon_SetDisplayPrms(&pUcObj->Display_VideoPrm,
                                    NULL,
                                    pObj->chainsCfg->displayType,
                                    pObj->displayWidth,
                                    pObj->displayHeight
                                   );
    
        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_iss_test_patternAppObj
     *
     * \return  SYSTEM_LINK_STATUS_SOK on success
     *
     *******************************************************************************
    */
    Void chains_iss_test_pattern_StartApp(chains_iss_test_patternAppObj *pObj)
    {
        Chains_memPrintHeapStatus();
    
        //appStartIssSensorSerDes(&pObj->appSensInfo);
    
        //ChainsCommon_StartDisplayDevice(pObj->chainsCfg->displayType);
        
        appStartISSSensor(&pObj->appSensInfo, 0);
    
        chains_iss_test_pattern_Start(&pObj->ucObj);
    
        Chains_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_iss_test_patternAppObj
     *
     *******************************************************************************
    */
    Void chains_iss_test_pattern_StopAndDeleteApp(chains_iss_test_patternAppObj *pObj)
    {
        chains_iss_test_pattern_Stop(&pObj->ucObj);
        chains_iss_test_pattern_Delete(&pObj->ucObj);
    
    //    ChainsCommon_StopDisplayCtrl();
    
        appStopISSSensor(&pObj->appSensInfo);
    
        appDeleteISSSensor(&pObj->appSensInfo);
    
        ChainsCommon_StopDisplayDevice(pObj->chainsCfg->displayType);
    
        /* Print the HWI, SWI and all tasks load */
        /* Reset the accumulated timer ticks */
        Chains_prfLoadCalcEnable(FALSE, TRUE, TRUE);
    }
    
    /**
     *******************************************************************************
     *
     * \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_iss_test_pattern(Chains_Ctrl *chainsCfg)
    {
        char ch;
        UInt32 done = FALSE;
        chains_iss_test_patternAppObj chainsObj;
        Int32 CapImCounter = 0;
        char fName[128];
        Int32 status = 0;
        IssCaptureLink_GetSaveFrameStatus rawSaveFrameStatus;
        UInt32 chId = 0U;
    
        chainsObj.bypassVtnf = 0; /* KW error fix */
        chainsObj.bypassLdc  = 0; /* KW error fix */
    
        Vps_printf(" Entered Chains_iss_test_pattern \n");
    
        if (TRUE == IssM2mIspLink_IsWdrMode(chainsCfg->ispOpMode))
        {
            Vps_printf(" CHAINS: Please make sure BSP is build with WDR and LDC enabled !!!\n");
        }
    
        chainsObj.chainsCfg = chainsCfg;
    
        /* Initialize Video Sensor, so that Algorithm can use Params
           from Vid Sensor layer */
        chains_iss_test_pattern_Create(&chainsObj.ucObj, &chainsObj);
        ChainsCommon_SetIssCaptureErrorHandlingCb(chainsObj.ucObj.IssCaptureLinkID);
        
        chains_iss_test_pattern_StartApp(&chainsObj);
        
        configDeser();
        Task_sleep(100);
    
        while(!done)
        {
            Vps_printf(gChains_IssIspSimcop_Display_runTimeMenu);
    
            ch = Chains_readChar();
    
            switch(ch)
            {
                case '0':
                    done = TRUE;
                    break;
    
                case '1':
                    {
                    /* Send command to Capture Link to save a frame */
                    System_linkControl(
                            chainsObj.ucObj.IssCaptureLinkID,
                            ISSCAPTURE_LINK_CMD_SAVE_FRAME,
                            &chId,
                            sizeof(chId),
                            TRUE);
    
                            do {
                                  System_linkControl(
                                  chainsObj.ucObj.IssCaptureLinkID,
                                  ISSCAPTURE_LINK_CMD_GET_SAVE_FRAME_STATUS,
                                  &rawSaveFrameStatus,
                                  sizeof(IssCaptureLink_GetSaveFrameStatus),
                                  TRUE);
    
                            } while (rawSaveFrameStatus.isSaveFrameComplete == FALSE);
                            CapImCounter = xUtils_nextAvailableFile( fName, "raw%04u.raw", CapImCounter );
    
                            status = Utils_fileWriteFile( fName, (UInt8*)rawSaveFrameStatus.bufAddr, rawSaveFrameStatus.bufSize);
    
                            sprintf( fName, "raw%04u.txt", CapImCounter );
    
                            if(status)
                            {
                                Vps_printf("Error %d: Error performing file write\n",status);
                                xUtils_fileWriteInfo( fName, "RAW, Error" );
                            } else {
                                Vps_printf("Wrote image %s to file\n",fName);
                                xUtils_fileWriteInfo( fName, "RAW, OK" );
                        }
    
                    break;
                    }
    
                case 'p':
                case 'P':
                    ChainsCommon_PrintStatistics();
                    chains_iss_test_pattern_printStatistics(&chainsObj.ucObj);
                    break;
                default:
                    Vps_printf("\nUnsupported option '%c'. Please try again\n", ch);
                    break;
            }
        }
    
        chains_iss_test_pattern_StopAndDeleteApp(&chainsObj);
    
    }
    
    

    Best regards,

    Stefan.

  • Hi Stefan,

    Can you please check if the lane configuration and number of lanes are correct? Please also check if the CSI2 DDR clock is correct..

    Also please check if reset done bit is set in the CAL?

    Rgds,

    Brijesh

  • Hi Brijesh,

    Lane configuration is following:

                        {{FALSE, 1}, /* Clock Lane */
                         {FALSE, 2}, /* data1Lane */
                         {FALSE, 3}, /* data2Lane */
                         {FALSE, 4}, /* data3Lane*/
                         {FALSE, 5}},/* data4Lane */

    CSI2 DDR clock is 400 MHz (not sure is this correct value, I took it from working starterware example!!!).

    Reset done bit is set -> CAL_CSI2_COMPLEXIO_CFG_l register value is 0x6A054321.

    Also, frame number in CAL_CSI2_STATUS0_l register is constantly changing, but interrupt is not happening and frame is not received.

    Considering we are using just ISS Capture (without ISP), is there some additional configuration that needs to be done?

    Best regards,

    Stefan.

  • Hi Stefan,

    It might be capturing only on a single frame. Could you please press 'p' on UART console and share the log?
    Also how are checking the callback? Can you put breakpoint on driver callback in iss capture link?

    Rgds,
    Brijesh
  • Hi,

    Not even one frame is received. I attached file with logs.

    I put breakpoint on callback, but callback function is not called. Any other suggestions?

    Regards.

    [IPU1-0]     59.963307 s:
    [IPU1-0]     59.963368 s:  CPU [IPU1-0 ] Statistics,
    [IPU1-0]     59.963429 s:  *************************
    [IPU1-0]     59.963490 s:
    [IPU1-0]     59.963551 s:  LOAD: CPU: 3.9% HWI: 0.4%, SWI:0.3%, Low Power: 0.0%
    [IPU1-0]     59.963673 s:
    [IPU1-0]     59.963795 s:  LOAD: TSK: ISSCAPTURE          : 0.2%
    [IPU1-0]     59.963948 s:  LOAD: TSK: STAT_COLL           : 1.8%
    [IPU1-0]     59.964039 s:  LOAD: TSK: MISC                : 1.2%
    [IPU1-0]     59.964100 s:
    [IPU1-0]     59.964161 s:  SYSTEM: SW Message Box Msg Pool, Free Msg Count = 1023
    [IPU1-0]     59.964253 s:
    [IPU1-0]     59.964314 s:  SYSTEM: Sempahores Objects,  114 of 1024 free
    [IPU1-0]     59.964375 s:  SYSTEM: Task Objects      ,   11 of  100 free
    [IPU1-0]     59.964466 s:  SYSTEM: Clock Objects     ,   98 of  100 free
    [IPU1-0]     59.964558 s:  SYSTEM: Hwi Objects       ,   87 of  100 free
    [IPU1-0]     59.964649 s:
    [IPU1-0]     59.964680 s:  SYSTEM: Heap = LOCAL_DDR            @ 0x00000000, Total size = 262144 B (256 KB), Free size = 243784 B (238 KB)
    [IPU1-0]     59.964832 s:  SYSTEM: Heap = SR_OCMC              @ 0x00000000, Total size = 0 B (0 KB), Free size = 0 B (0 KB)
    [IPU1-0]     59.964985 s:  SYSTEM: Heap = SR_DDR_CACHED        @ 0x85703000, Total size = 369086464 B (351 MB), Free size = 365400064 B (348 MB)
    [IPU1-0]     59.965137 s:  SYSTEM: Heap = SR_DDR_NON_CACHED    @ 0xbfc00000, Total size = 916224 B (0 MB), Free size = 916224 B (0 MB)
    [IPU1-0]     59.965320 s:
    [IPU1-0]     59.965412 s:
    [IPU1-0]     59.965442 s:  UTILS_PRCM_STATS:  Current Temperature,
    [IPU1-0]     59.965534 s:
    [IPU1-0]     59.965564 s:   Voltage Rail         ||   Curr Temp Min - Max
    [IPU1-0]     59.965625 s:  ---------------------------------------------------------
    [IPU1-0]     59.965717 s:     PMHAL_PRCM_VD_CORE ||     [37.200 , 37.600]
    [IPU1-0]     59.965839 s:
    [IPU1-0]     59.965900 s:
    [IPU1-0]     59.965930 s:  Statistics Collector,
    [IPU1-0]     59.965991 s:
    [IPU1-0]     59.966052 s:        STATISTIC          Avg Data        Peak Data
    [IPU1-0]     59.966113 s:        COLLECTOR          MB/s            MB/s
    [IPU1-0]     59.966174 s:  --------------------------------------------------
    [IPU1-0]     59.966296 s:  SCI_EMIF_SYS         |      1.405069      7.387445
    [IPU1-0]     59.966418 s:  SCI_IPU              |      3.344607      9.171531
    [IPU1-0]     59.966510 s:  SCI_DSP1_MDMA        |      0.000000      0.000000
    [IPU1-0]     59.966601 s:  SCI_DSP2_MDMA        |      0.000000      0.000000
    [IPU1-0]     59.966723 s:  SCI_DSS              |      0.000000      0.000000
    [IPU1-0]     59.966815 s:  SCI_MMU              |      0.000000      0.000000
    [IPU1-0]     59.966906 s:  SCI_EDMA_TC0_RD      |      0.000000      0.000000
    [IPU1-0]     59.966998 s:  SCI_EDMA_TC0_WR      |      0.000000      0.000000
    [IPU1-0]     59.967120 s:  SCI_VIP_P1           |      0.000000      0.000000
    [IPU1-0]     59.967242 s:  SCI_VIP_P2           |      0.000000      0.000000
    [IPU1-0]     59.967333 s:  SCI_ISS_RT           |      0.000000      0.000000
    [IPU1-0]     59.967425 s:  SCI_ISS_NRT2         |      0.000000      0.000000
    [IPU1-0]     59.967547 s:  SCI_EVE_P1           |      0.000000      0.000000
    [IPU1-0]     59.967638 s:  SCI_EVE_P2           |      0.000000      0.000000
    [IPU1-0]     59.967730 s:  SCI_GMAC_SW          |      0.000606      0.043982
    [IPU1-0]     59.967821 s:  SCI_ISS_NRT1         |      0.000000      0.000000
    [IPU1-0]     59.967943 s:  SCI_DSP2_CFG         |      0.000000      0.000000
    [IPU1-0]     59.968035 s:  SCI_DSP2_EDMA        |      0.000000      0.000000
    [IPU1-0]     59.968126 s:  SCI_OCMC_RAM         |      0.000000      0.000000
    [IPU1-0]     59.968370 s:  SCI_DSP1_CFG         |      0.000000      0.000000
    [IPU1-0]     59.968462 s:  SCI_DSP1_EDMA        |      0.000000      0.000000
    [IPU1-0]     59.968553 s:  SCI_GPMC             |      0.000000      0.000000
    [IPU1-0]     59.968675 s:  SCI_MCASP            |      0.000000      0.000000
    [IPU1-0]     59.968767 s:  SCI_EDMA_TC1_RD      |      0.000000      0.000000
    [IPU1-0]     59.968858 s:  SCI_EDMA_TC1_WR      |      0.000000      0.000000
    [IPU1-0]     60.068321 s:
    [IPU1-0]     60.068382 s:
    [IPU1-0]     60.068474 s:
    [IPU1-0]     60.068504 s:  ### CPU [IPU1-0], LinkID [ 81],
    [IPU1-0]     60.068565 s:
    [IPU1-0]     60.068626 s:  [ ISSCAPTURE ] Link Statistics,
    [IPU1-0]     60.068687 s:  ******************************
    [IPU1-0]     60.068748 s:
    [IPU1-0]     60.068779 s:  Elapsed time       = 19431 msec
    [IPU1-0]     60.068840 s:
    [IPU1-0]     60.068901 s:
    [IPU1-0]     60.068931 s:  Input Statistics,
    [IPU1-0]     60.068992 s:
    [IPU1-0]     60.069023 s:  CH | In Recv | In Drop | In User Drop | In Process
    [IPU1-0]     60.069084 s:     | FPS     | FPS     | FPS          | FPS
    [IPU1-0]     60.069175 s:  --------------------------------------------------
    [IPU1-0]     60.069267 s:
    [IPU1-0]     60.069297 s:  Output Statistics,
    [IPU1-0]     60.069358 s:
    [IPU1-0]     60.069389 s:  CH | Out | Out     | Out Drop | Out User Drop
    [IPU1-0]     60.069480 s:     | ID  | FPS     | FPS      | FPS
    [IPU1-0]     60.069541 s:  ---------------------------------------------
    [IPU1-0]     60.069694 s:
    [IPU1-0]     60.069755 s:  [ ISSCAPTURE ] LATENCY,
    [IPU1-0]     60.069816 s:  ********************
    [IPU1-0]     60.069877 s:
    [IPU1-0]     60.069968 s:
    [IPU1-0]     60.069999 s:  ### CPU [IPU1-0], LinkID [ 20],
    [IPU1-0]     60.070060 s:
    [IPU1-0]     60.070090 s:  [ NULL ] Link Statistics,
    [IPU1-0]     60.070151 s:  ******************************
    [IPU1-0]     60.070243 s:
    [IPU1-0]     60.070273 s:  Elapsed time       = 19432 msec
    [IPU1-0]     60.070334 s:
    [IPU1-0]     60.070395 s:
    [IPU1-0]     60.070426 s:  Input Statistics,
    [IPU1-0]     60.070487 s:
    [IPU1-0]     60.070517 s:  CH | In Recv | In Drop | In User Drop | In Process
    [IPU1-0]     60.070578 s:     | FPS     | FPS     | FPS          | FPS
    [IPU1-0]     60.070670 s:  --------------------------------------------------
    [IPU1-0]     60.070731 s:
    [IPU1-0]     60.070792 s:  Output Statistics,
    [IPU1-0]     60.070822 s:
    [IPU1-0]     60.070853 s:  CH | Out | Out     | Out Drop | Out User Drop
    [IPU1-0]     60.070944 s:     | ID  | FPS     | FPS      | FPS
    [IPU1-0]     60.071005 s:  ---------------------------------------------
    [IPU1-0]     60.071097 s:
    [IPU1-0]     60.071127 s:  [ NULL ] LATENCY,
    [IPU1-0]     60.071188 s:  ********************
    [IPU1-0]     60.071249 s:
    [IPU1-0]     60.571249 s:
    [IPU1-0]
    [IPU1-0]  ====================
    [IPU1-0]  Chains Run-time Menu
    [IPU1-0]  ====================
    [IPU1-0]
    [IPU1-0]  0: Stop Chain
    [IPU1-0]
    [IPU1-0]  1: Save Captured Frame
    [IPU1-0]
    [IPU1-0]  p: Print Performance Statistics
    [IPU1-0]
    [IPU1-0]  Enter Choice:
    [IPU1-0]
    
    

  • Hi Brijesh,

    Can you help us with this?

    Regards.

  • ok, can you please put breakpoint in the internal driver callback?
    Can you put breakpoint on
    vcoreCaptDmaStartCb
    vcoreCaptDmaCmpltCb

    If one of them is getting called, at least, interrupts are coming in and isr is getting called.

    If one of them is getting called, it means driver is primed with only one buffer, which is why you are not getting any callback in the link. Driver keeps the last buffer with itself to make sure it always have buffer to capture to. To get this buffer back, you need to enqueue one more frame to the driver.

    If these are not getting called, it might be something to do with interrupt crossbar or irq being used by someone else. So have you changed anything from the release code? Are you trying this on the EVM??

    Regards,
    Brijesh
  • Hi,

    This functions are not called.

    Yes, we are trying this on EVM and we are using PROCESSOR SDK VISION 03.03. Only thing that we changed is that we added new "dummy" sensor on ISS framework. Start/stop functions are empty because we don't have sensor. We configure deserializer to send test images (1280 * 720 , RGB24). This are some parameters set in init function:

    ...

        strncpy(prms->name, "DUMMY", ISS_SENSORS_MAX_NAME);

        prms->dccId             = 19999;

        info->width             = 1280;
        info->height            = 720;
        info->dataFormat        = SYSTEM_DF_RGB24_888;
        info->bpp               = SYSTEM_BPP_BITS8;
        info->features          = ISS_SENSOR_FEATURE_LINEAR_MODE;
        info->aewbMode          = ALGORITHMS_ISS_AEWB_MODE_NONE;
        info->maxExp            = 1;
        info->ramOffset         = 25*1024*1024;
    ...

    Sensor info added in iss_sensor_tda3xx.c file:

        {"DUMMY",
            {
                1u, /* TDA3X EVM board uses I2C instance 1 */
                {0x60},    /* Sensor alias address */
                {0x60},    /* Serializer alias address */
                FALSE, /* isMultiChannel */
                SYSTEM_VIFW_4LANES, SYSTEM_VIFM_SCH_CSI2,
                SYSTEM_CSI2_RAW8 /* CSI2 DataFormat*/,
                0 /*Virtual Channel Id*/,
                    0, /* IsCSIPostEnable Required */
                    {TRUE /* isCplxCfgValid */,
                        {{FALSE, 1}, /* Clock Lane */
                         {FALSE, 2}, /* data1Lane */
                         {FALSE, 3}, /* data2Lane */
                         {FALSE, 4}, /* data3Lane*/
                         {FALSE, 5}},/* data4Lane */
                         400U /* csi2PhyClk */ },
                         19999,         /* sensorDrvId */
                         FALSE,     /* sensorBroadcast */
                         FALSE}},   /* enableFsin */
                         
    };

    Can wrong configuration cause this problem, or we should at least receive some random data?

    Regards.

  • Hi Stefan,

    Please use "SYSTEM_CSI2_RGB888" instead of "SYSTEM_CSI2_RAW8"

    Regards, Sujith

  • Hi Sujith,

    I already tried that and it asserts in issCaptureLink_drv.c (line 690). This format is not supported.
  • Hi Stefan,

    It seems like the CaptureLink dosent support RGB888 dataformat.
    Let me check on the changes required in the link to support this.

    Regards,
    Sujith
  • Stefen,

    I see that you are using RAW8 as the CSI2 data type, but your input is setup for RGB24. These two are different CSI2 data type.
    Could you please match the CSI2 data type, virtual channel in deserializer and CAL?
    CAL will capture only if the configured data type, virtual channel id are matching with the incoming stream..

    Please also note that ISS capture link does not really support RGB24 bit. There are some minor changes required in the capture link for RGB24 bit input.. Essentially, you will require to bypass pixel processing context, allocate the enough buffers etc for this format..

    Regards,
    Brijesh
  • Stefan,

    Can you try disabling pixel processing context at around around line number 613 in the file vision_sdk/links_fw/src/rtos/links_ipu/iss_capture/issCaptureLink_drv.c

    - drvCalCfg->isPixProcCfgValid[strmId] = (UInt32)TRUE;
    + //drvCalCfg->isPixProcCfgValid[strmId] = (UInt32)TRUE;

    Also you will require to multiple pitch by 3 to capture RGB888..

    Rgds,
    Brijesh
  • Hi,

    After I added support for RGB888 it works almost fine. Now I'm able to capture frames but 1/3 of the frame is black (black pixels starts at 2560 byte). I attached screenshot of the image and hex file. Do you have anu ide what can cause this problem? Frame width, hight and pitch are correct:

    Width: 1280

    Height: 720

    Pitch: 1280 * 3

    Regards,

    Stefan.

    pattern_image.txt

  • Seems capture is cropping it. Let me check it, still will have to change width somewhere

    Regards,
    Brijesh
  • Stefan,

    Can you change the outBpp in the CreateArgs->channelParams to FVID2_BPP_BITS24? This should solve the problem.

    Rgds,
    Brijesh
  • Hi Brijesh,

    We managed to get correct image. In function IssCaptureLink_drvProcessData, when saving RGB24 frames following should be changed:

    - dmaPrm.dataFormat = SYSTEM_DF_RAW16;
    + dmaPrm.dataFormat = SYSTEM_DF_RAW24;

    Thank you very much on your help.

    Best regards,
    Stefan.