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/TDA2PXEVM: TDA2PXEVM

Part Number: TDA2PXEVM

Tool/software: TI-RTOS

HI,

I am trying to generate test pattern on TDA2px EVM with DS90UB954 EVM. I have added iss_capture_null use case for the same. I am storing the o/p in raw format. I am getting black image.

I was referring "e2e.ti.com/.../683940

1) Sensor configuration --> is this ok? 

info->dataFormat = SYSTEM_DF_RGB24_888;

info->bpp = SYSTEM_BPP_BITS8;

callback API's for sensor, I put empty.

2)  In sensor interface info, I have added below. is that ok?

{SENSOR,
{
4u, /* I2C Instance id for the sensor */
{0x36}, /* I2C Address of the sensor */
{0x18}, /* I2C Address of the serializer */
FALSE, /* Flag for single/multi channel sensor config */
SYSTEM_VIFW_4LANES, /* Interface width */
SYSTEM_VIFM_SCH_CSI2, /* Video Interface mode - Single channel capture via CSI2 interface */
SYSTEM_CSI2_RGB888, /* Input CSI2 Data Format */
0, /* Virtual Channel Id */
0, /* Is CSI Enable Required in UB954 */
{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 */

3) I have added support for SYSTEM_CSI2_RGB888 in issCaptureLink_drv.c like below, Is that correct.

case SYSTEM_CSI2_RGB888:
drvCalCfg->pixProcCfg[strmId].extract = VPS_ISS_CAL_PIX_EXRCT_B8;
drvCalCfg->pixProcCfg[strmId].pack = VPS_ISS_CAL_PIX_PACK_B8;

4) I had put breakpoint in function "IssCaptureLink_drvProcessData()" function, It is not hitting there. Am I missing something?

Thanks,

Swati

  • Attached isscapture->null use case files

    /******************************************************************************
    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_issCapture_Null_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_fileExists1( 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_nextAvailableFile1( char * buf, char * fmt, Int32 theIndex )
    {
    	Vps_printf("Inside function xUtils_nextAvailableFile1\n");
    sprintf( buf, fmt, theIndex );
    
    while( xUtils_fileExists1( 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 lastExposureTime1 = 0;
    
    Int32 xUtils_fileWriteInfo1( char * filename, char * extra )
    {
    Int32 status = 0;
    char buf [200];
    
    sprintf( buf, "%s, %u, %s\n", filename, lastExposureTime1, 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_issCapture_NullObj  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_Iss_capture_null_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_issCapture_NullObj *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, "AR0220", //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;
    
    	// SWATI :: CHECK this
        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_issCapture_Null_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_issCapture_Null_Stop(&pObj->ucObj);
        chains_issCapture_Null_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_issCapture_Null_Create(&chainsObj.ucObj, &chainsObj);
        ChainsCommon_SetIssCaptureErrorHandlingCb(chainsObj.ucObj.IssCaptureLinkID);
        
        chains_iss_test_pattern_StartApp(&chainsObj);
        
        configDeser();
        Task_sleep(100);
    
        while(!done)
        {
    		Vps_printf("inside Chains_iss_test_pattern while(!done) \n");
            Vps_printf(gChains_Iss_capture_null_runTimeMenu);
    		
            ch = Chains_readChar();
    		//ch = '1';
    		Vps_printf("1.%c,\n",ch);
    		
            switch(ch)
            {
                case '0':
                    done = TRUE;
                    break;
    
                case '1':
                    {
    				Vps_printf("Success::Inside Chains_iss_test_pattern writing raw data\n");
                    /* Send command to Capture Link to save a frame */
                    System_linkControl(
                            chainsObj.ucObj.IssCaptureLinkID,
                            ISSCAPTURE_LINK_CMD_SAVE_FRAME,
                            &chId,
                            sizeof(chId),
                            TRUE);
    				Vps_printf("Success::After System_linkControl to save Frame\n");
                            do {
    							  Vps_printf("Success::Inside do while loop before System_linkControl\n");
                                  System_linkControl(
                                  chainsObj.ucObj.IssCaptureLinkID,
                                  ISSCAPTURE_LINK_CMD_GET_SAVE_FRAME_STATUS,
                                  &rawSaveFrameStatus,
                                  sizeof(IssCaptureLink_GetSaveFrameStatus),
                                  TRUE);
    							  Vps_printf("Success::Inside do while After System_linkControl\n");
    
                            } while (rawSaveFrameStatus.isSaveFrameComplete == FALSE);
    						
    						Vps_printf("Success::After do while After System_linkControl\n");
                            CapImCounter = xUtils_nextAvailableFile1( fName, "raw%04u.raw", CapImCounter );
    						Vps_printf("Success::After Function call xUtils_nextAvailableFile1\n");
                            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_fileWriteInfo1( fName, "RAW, Error" );
                            } else {
                                Vps_printf("Wrote image %s to file\n",fName);
                                xUtils_fileWriteInfo1( fName, "RAW, OK" );
                        }
    
                    break;
                    }
    
                case 'p':
                case 'P':
    				Vps_printf("Success::Before ChainsCommon_PrintStatistics");
                    ChainsCommon_PrintStatistics();
    				Vps_printf("Success::After ChainsCommon_PrintStatistics");
                    chains_issCapture_Null_printStatistics(&chainsObj.ucObj);
    				Vps_printf("Success::After chains_issCapture_Null_printStatistics");
                    break;
                default:
                    Vps_printf("\nUnsupported option '%c'. Please try again\n", ch);
                    break;
            }
        }
    
        chains_iss_test_pattern_StopAndDeleteApp(&chainsObj);
    
    }
    
    
    chains_issCapture_Null_priv.h

  • Swati,

    The config looks file, if the processData is not getting called, it means there is no capture callback. Which means, either initial CSI handshake did not complete or incorrect virtualchannel/datatype. Please check and make sure you are setting correct virtual channel id and data type in deserializer. Please also check to see the lane configuration is correct. Also see if you are selecting correct sensor from the settings menu. 

    Regads,

    Brijesh

  • Hi Brijesh,

    I checked the virtual channel and datatype, they are set correctly in the code. One thing I observed is that, I have added prints in the "issCaptDrvCallback" function in file "\vision_sdk\links_fw\src\rtos\links_ipu\iss_capture\issCaptureLink_drv.c" and when I run my usecase, I do not see the prints from this function. "issCaptDrvCallback" function is not called and that is why processData is not called.

    Do I need to do any configuration in my usecase file to start the callback function. I have attached the usecase file.

    Regards,

    Swati

    /******************************************************************************
    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_issCapture_Null_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_fileExists1( 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_nextAvailableFile1( char * buf, char * fmt, Int32 theIndex )
    {
    	Vps_printf("Inside function xUtils_nextAvailableFile1\n");
    sprintf( buf, fmt, theIndex );
    
    while( xUtils_fileExists1( 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 lastExposureTime1 = 0;
    
    Int32 xUtils_fileWriteInfo1( char * filename, char * extra )
    {
    Int32 status = 0;
    char buf [200];
    
    sprintf( buf, "%s, %u, %s\n", filename, lastExposureTime1, 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_issCapture_NullObj  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_Iss_capture_null_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_issCapture_NullObj *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, "AR0220", //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;
    
    	// SWATI :: CHECK this
        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_issCapture_Null_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_issCapture_Null_Stop(&pObj->ucObj);
        chains_issCapture_Null_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;
    	configDeser();
    	
        /* Initialize Video Sensor, so that Algorithm can use Params
           from Vid Sensor layer */
        chains_issCapture_Null_Create(&chainsObj.ucObj, &chainsObj);
        ChainsCommon_SetIssCaptureErrorHandlingCb(chainsObj.ucObj.IssCaptureLinkID);
        
        chains_iss_test_pattern_StartApp(&chainsObj);
        
        //configDeser();
        Task_sleep(100);
    
        while(!done)
        {
    		Vps_printf("inside Chains_iss_test_pattern while(!done) \n");
            Vps_printf(gChains_Iss_capture_null_runTimeMenu);
    		
            ch = Chains_readChar();
    		//ch = '1';
    		Vps_printf("1.%c,\n",ch);
    		
            switch(ch)
            {
                case '0':
                    done = TRUE;
                    break;
    
                case '1':
                    {
    				Vps_printf("Success::Inside Chains_iss_test_pattern writing raw data\n");
                    /* Send command to Capture Link to save a frame */
                    System_linkControl(
                            chainsObj.ucObj.IssCaptureLinkID,
                            ISSCAPTURE_LINK_CMD_SAVE_FRAME,
                            &chId,
                            sizeof(chId),
                            TRUE);
    				Vps_printf("Success::After System_linkControl to save Frame\n");
                            do {
    							  Vps_printf("Success::Inside do while loop before System_linkControl\n");
                                  System_linkControl(
                                  chainsObj.ucObj.IssCaptureLinkID,
                                  ISSCAPTURE_LINK_CMD_GET_SAVE_FRAME_STATUS,
                                  &rawSaveFrameStatus,
                                  sizeof(IssCaptureLink_GetSaveFrameStatus),
                                  TRUE);
    							  Vps_printf("Success::Inside do while After System_linkControl\n");
    
                            } while (rawSaveFrameStatus.isSaveFrameComplete == FALSE);
    						
    						Vps_printf("Success::After do while After System_linkControl\n");
                            CapImCounter = xUtils_nextAvailableFile1( fName, "raw%04u.raw", CapImCounter );
    						Vps_printf("Success::After Function call xUtils_nextAvailableFile1\n");
                            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_fileWriteInfo1( fName, "RAW, Error" );
                            } else {
                                Vps_printf("Wrote image %s to file\n",fName);
                                xUtils_fileWriteInfo1( fName, "RAW, OK" );
                        }
    
                    break;
                    }
    
                case 'p':
                case 'P':
    				Vps_printf("Success::Before ChainsCommon_PrintStatistics");
                    ChainsCommon_PrintStatistics();
    				Vps_printf("Success::After ChainsCommon_PrintStatistics");
                    chains_issCapture_Null_printStatistics(&chainsObj.ucObj);
    				Vps_printf("Success::After chains_issCapture_Null_printStatistics");
                    break;
                default:
                    Vps_printf("\nUnsupported option '%c'. Please try again\n", ch);
                    break;
            }
        }
    
        chains_iss_test_pattern_StopAndDeleteApp(&chainsObj);
    
    }
    
    

  • Hi Swati,

    Can you please check the value at 0x489B 0304 and also at 0x489B 0350

    Regards,
    Sujith
  • Hi Sujith,

    Thanks for the reply. I checked the values. I got below

    0x489B0304  - 0x4A054321

    0x489B0350 - 0

    Currently I am just checking Pattern Generation from DS90UB954EVM to TDA2px EVM.

    Regards,

    Swati

  • Hi Swati,

    It seems like some issue in UB964 configuration. Yes, please validate with TDA2Px evm first.

    Regards,
    Sujith
  • Hi Sujith,

    Thanks for the reply Sujith.

    We are configuring UB954 DESER EVM from TDA2px EVM.

    We are using attached deser.c for pattern Generation and attached iss_sensor_ar0220.c to configure dummy sensor.

    Am I missing something?

    Thanks,

    Swati

    /*
     *******************************************************************************
     *
     * 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;
    
    	retVal = Bsp_deviceI2cProbeDevice(
                    BSP_DEVICE_I2C_INST_ID_4,
                    0x30);
    	if (retVal == BSP_SOK)
    	{
    		Vps_printf("Bsp_deviceI2cProbeDevice Deseralizer is successful...\n");
    	}
    	
    	UInt8 regAddr = 0x20;
    	UInt8 regVal = 0x30;
    	retVal = Bsp_deviceWrite8(BSP_DEVICE_I2C_INST_ID_4,
                        0x30,
                        &(regAddr),
                        &(regVal),
                        (UInt32) 1U);
    	if (retVal != BSP_SOK)
        {
            Vps_printf("set register 0x20 to 0x30) failed\n");
        }
    	Task_sleep(10);
    
    	regAddr = 0x1F;
    	regVal = 0x02;
    	retVal = Bsp_deviceWrite8(BSP_DEVICE_I2C_INST_ID_4,
                        0x30,
                         &(regAddr),
                        &(regVal),
                        (UInt32) 1U);
    	if (retVal != BSP_SOK)
        {
            Vps_printf("Configure CSI-2 Transmitter operating speed failed\n");
        }
    	Task_sleep(10);
    
    	regAddr = 0x33;
    	regVal = 0x03;
    	retVal = Bsp_deviceWrite8(BSP_DEVICE_I2C_INST_ID_4,
                        0x30,
                        &(regAddr),
                        &(regVal),
                        (UInt32) 1U);
    	if (retVal != BSP_SOK)
        {
            Vps_printf("Enable the CSI-2 Transmitter for port 0 failed\n");
        }
    
    	Task_sleep(10);
        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);
    		
    		retVal = Bsp_deviceWrite8(BSP_DEVICE_I2C_INST_ID_4,
                        0x30,
                        &(g954Cfg[idx].nRegAddr),
                        &(g954Cfg[idx].nRegValue),
                        (UInt32) 1U);
            if (retVal != BSP_SOK)
            {
                errCount++;
                Vps_printf("Error...\n");
            }
    		
    		Task_sleep(10);
    		//UInt8 regData = 0x0;
            // retVal = Bsp_deviceRead8(
                                // BSP_DEVICE_I2C_INST_ID_4,
                                // 0x30,
                                // &(g954Cfg[idx].nRegAddr),
                                // &regData,
                                // 1);
    
           // Vps_printf("reg data = %d\n",regData);
    		if (retVal != BSP_SOK)
            {
                Vps_printf("Error...\n");
            }
    		// else if(regData != (g954Cfg[idx].nRegValue)) {
    			// Vps_printf("Error:::Read and write data mismatch...\n");
    		// }
            
        }
        
        if (errCount == 0)
        {
            Vps_printf("Deser configuration OK!\n");
        }
    
    }
    
    
    /**
     *******************************************************************************
     * \file iss_sensor_ar0220.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 "ar0220_linear_1280x800_setup.h"
    #include "ar0220_wdr_1280x800_setup.h"
    #include "ar0220_tida_linear_1280x800_setup.h"
    #include "ar0220_tida_wdr_1280x800_setup.h"
    #include "ar0220_gain_table.h"
    #include "ar0220_dcc.h"
    #include "ar0220_dcc_1pass.h"
    
    #include <ti/drv/vps/include/devices/bsp_device.h>
    
    /*******************************************************************************
     *  Defines
     *******************************************************************************
     */
    
    /* #define _USE_DIGITAL_GAIN_ */
    /**
     *	@TODO Below MACRO values to be confirmed
     */
    #define ISS_SENSORS_AR0220_ANALOG_MAX_GAIN      (57U)
    
    #define ISS_SENSORS_AR0220_DEFAULT_EXP_RATIO    (16U)
    
    ////#define ISS_SENSORS_AR0220_FEATURES     (ISS_SENSOR_FEATURE_HFLIP|             \
    //                                         ISS_SENSOR_FEATURE_VFLIP|             \
    //                                         ISS_SENSOR_FEATURE_MANUAL_EXPOSURE|   \
    //                                         ISS_SENSOR_FEATURE_MANUAL_GAIN|       \
    //                                         ISS_SENSOR_FEATURE_LINEAR_MODE|       \
    //                                         ISS_SENSOR_FEATURE_TWO_PASS_WDR_MODE| \
    //                                         ISS_SENSOR_FEATURE_ONE_PASS_WDR_MODE| \
    //                                         ISS_SENSOR_FEATURE_DCC_SUPPORTED)
    
    #define ISS_SENSORS_AR0220_FEATURES 0
    										 
    #define CSI2_AR0220_SER_ADDR                    (0x18U)
    /**< Serializer address */
    #define CSI2_AR0220_SENSOR_ADDR                 (0x20U)
    /**< Sensor address */										 
    
    
    /*******************************************************************************
     *  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 */
    } gAr0220DeviceObj;
    
    /*******************************************************************************
     *  Local Functions Declarations
     *******************************************************************************
     */
    static Int32 AR0220_Start(UInt32 chId, IssSensor_CreateParams *pCreatePrms);
    //static Int32 AR0220_TIDA_Start(UInt32 chId, IssSensor_CreateParams *pCreatePrms);
    static Int32 AR0220_Stop(UInt32 chId, IssSensor_CreateParams *pCreatePrms);
    static Int32 AR0220_SetAeParams(IssSensor_CreateParams *pCreatePrms,
        IssSensor_AeParams *pAePrms);
    static Int32 AR0220_GetDccParams(IssSensor_CreateParams *pCreatePrms,
        IssSensor_DccParams *pDccPrms);
    static AR0220_GetExpParams(IssSensor_CreateParams *pCreatePrms,
        IssSensor_ExposureParams *pExpPrms);
    static Void AR0220_InitAewbConfig(
        IssSensor_CreateParams *pCreatePrms,
        AlgorithmLink_IssAewbCreateParams *pAewbPrms);
    static Void AR0220_GetIspConfig (
        IssSensor_CreateParams *pCreatePrms,
        IssIspConfigurationParameters *pIspCfg);
    static Int32 AR0220_ReadWriteReg (
        IssSensor_CreateParams *pCreatePrms, UInt32 readWriteFlag,
        IssSensor_ReadWriteReg *pReg);
    
    #if SWATI
    static Int32 AR0220_ReadReg(UInt8         i2cInstId,
                                UInt8         i2cAddr,
                                const UInt16 *regAddr,
                                UInt16       *regVal,
                                UInt32        numRegs);
    static Int32 AR0220_WriteReg(UInt8         i2cInstId,
                                 UInt8         i2cAddr,
                                 const UInt16 *regAddr,
                                 const UInt16 *regVal,
                                 UInt32        numRegs);
    #endif
    /*******************************************************************************
     *  Globals
     *******************************************************************************
     */
    
    /** \brief Sensor Params structure used for registering this sensor to chains_iss
     * 	@TODO To be updated when AR0220 datasheet is available
     */
    static IssSensorIf_Params SensorParams_Ar0220 = {0};
    
    #if SWATI
    static const UInt8 gAr0220DccCfgLinearAndWdr[] = AR0220DCC_CFG;
    static const UInt8 gAr0220DccCfgSinglePassWdr[] = AR0220_1PASSDCC_CFG;
    
    static IssSensor_ConfigRegs gAR0220SensorsLinearConfig[] =
        AR0220_LINEAR_1280X800_CONFIG;
    static IssSensor_ConfigRegs gAR0220SensorsWdrConfig[] =
        AR0220_WDR_1280X800_CONFIG;
    
    //static IssSensor_ConfigRegs gAR0220TidaSensorsLinearConfig[] =
    //    AR0220_TIDA_LINEAR_1280X800_CONFIG;
    //static IssSensor_ConfigRegs gAR0220TidaSensorsWdrConfig[] =
    //    AR0220_TIDA_WDR_1280X800_CONFIG;
    
    static UInt32 gAr0220GainsTable[ISS_SENSORS_AR0220_ANALOG_MAX_GAIN][3] =
        AR0220_GAIN_TABLE;
    
    /**
     * \brief Structure for ISP H3A AEWB engine parameters.
     * 	@TODO To be updated when AR0220 datasheet is available
     */
    static vpsissH3aAewbConfig_t aewbConfig_ar0220 =
    {
        FALSE, /* enableALowComp */
        FALSE, /* enableMedFilt */
        0xFFF, /* midFiltThreshold */
        {   /* vpsissH3aPaxelConfig_t      winCfg */
            {64u, 16u}, /* Fvid2_PosConfig pos */
            36u,     /* width */
            48u,     /* height */
            32u,     /* horzCount */
            16u,     /* vertCount */
            6,      /* horzIncr */
            6,      /* vertIncr */
        },
        798U,       /* Black Line Vertical Start */
        2U,         /* Black Line Height */
        VPS_ISS_H3A_OUTPUT_MODE_SUM_ONLY, /* vpsissH3aOutputMode_t outMode; */
        2,  /* sumShift */
        1023u, /* satLimit */
        VPS_ISS_H3A_MODE_NORMAL /* vpsissH3aMode_t mode */
    } ;
    
    /**
     * \brief Structure for ISP GLBCE WDR Params.
     * 	@TODO To be updated when AR0220 datasheet is available
     */
    static vpsissGlbceWdrConfig_t glbceWdrCfg_ar0220 =
    {
        TRUE,
        {
            0U,24U,64U,114U,172U,237U,307U,383U,464U,549U,638U,731U,828U,928U,
            1031U,1138U,1248U,1361U,1477U,1596U,1717U,1841U,1967U,2096U,2228U,
            2361U,2498U,2636U,2777U,2919U,3064U,3211U,3360U,3511U,3664U,3819U,
            3976U,4134U,4295U,4457U,4622U,4787U,4955U,5125U,5296U,5468U,5643U,
            5819U,5997U,6176U,6357U,6539U,6723U,6908U,7095U,7284U,7474U,7665U,
            7858U,8052U,8248U,8445U,8644U,8843U,9045U,9247U,9451U,9656U,9863U,
            10071U,10280U,10490U,10702U,10915U,11129U,11345U,11561U,11779U,11998U,
            12219U,12440U,12663U,12887U,13112U,13338U,13566U,13794U,14024U,14255U,
            14487U,14720U,14954U,15189U,15426U,15663U,15902U,16142U,16382U,16624U,
            16867U,17111U,17356U,17602U,17849U,18097U,18346U,18596U,18847U,19099U,
            19353U,19607U,19862U,20118U,20375U,20633U,20892U,21152U,21413U,21675U,
            21938U,22202U,22467U,22732U,22999U,23267U,23535U,23805U,24075U,24346U,
            24618U,24891U,25165U,25440U,25716U,25993U,26270U,26549U,26828U,27108U,
            27389U,27671U,27954U,28238U,28522U,28807U,29094U,29381U,29669U,29957U,
            30247U,30537U,30829U,31121U,31414U,31707U,32002U,32297U,32593U,32890U,
            33188U,33487U,33786U,34086U,34387U,34689U,34992U,35295U,35599U,35904U,
            36210U,36516U,36823U,37132U,37440U,37750U,38060U,38371U,38683U,38996U,
            39309U,39623U,39938U,40254U,40570U,40887U,41205U,41523U,41843U,42163U,
            42483U,42805U,43127U,43450U,43774U,44098U,44423U,44749U,45075U,45403U,
            45731U,46059U,46389U,46719U,47049U,47381U,47713U,48046U,48379U,48714U,
            49048U,49384U,49720U,50057U,50395U,50733U,51072U,51412U,51752U,52093U,
            52435U,52777U,53121U,53464U,53809U,54154U,54499U,54846U,55193U,55540U,
            55889U,56238U,56587U,56938U,57289U,57640U,57992U,58345U,58699U,59053U,
            59408U,59763U,60119U,60476U,60833U,61191U,61550U,61909U,62269U,62629U,
            62990U,63352U,63714U,64077U,64441U,64805U,65170U,65535U
        }
    };
    #endif
    // Swati has commented this, Uncomment this
    #if 1
    BspUtils_Ub960I2cParams gAppIssUtilsUb954Cfg_AR0220_CSI2_DesCfg[AR0220_CSI2_DES_CFG_SIZE] = {
        /* Setup for AR0220 to UB954 on 2 lanes */
        {0x01, 0x01, 0x64},	/* Digital Reset 0 */
        {0x0C, 0x0E, 0x10},	/* Port 1 receiver enable */	
        {0x1F, 0x02, 0x20},	/* Default 800Mbps CSI Freq */
    
        /* CAMERA 1 */
        {0x4C, 0x01, 0x1},	/*Page FPD3 port RX0 registers for R/W*/
        {0x58, 0x00, 0x1},	/*Back channel disabled / I2C passthrough disabled*/
        {0x5C, 0x30, 0x1},  /*set serializer alias to Ox18 (7-bit)*/
        {0x5D, ((uint8_t) (CSI2_AR0220_SER_ADDR << 1U)), 0x0},	/* Slave0 ID */
        {0x65, ((uint8_t) ((0x20) << 1), 0x0},	/** @TODO to confirm */
        {0x6D, 0x7C, 0x1},        /* CSI and coax mode */
        {0xD5, 0xF0, 0x1},        /* Set AEQ MIN/MAX widest values*/
        {0x7C, 0x00, 0x1},        /* Default polarity */
        {0x70, 0x2B, 0x1},        /* CSI data type used in RAW10 mode */
        {0x71, 0x2C, 0x1},        /* CSI data type used in RAW12 mode */
        {0x72, 0xE4, 0x1},        /* Default CSI2 virtual channel mapping */
    
    	
        {0x33, 0x03, 0x1},	/* CSI_EN & CSI0 4-Lanes */
    	{0x20, 0x20, 0x1},	/* Forwarding enabled for RX Port 0 */
        {0x21, 0x01, 0x1},	/* CSI0 Round robin forwarding enabled */
        {0xB9, 0x18, 0x1},	/* Enable parity error count */
        {0x42, 0x71, 0x1},	/* Enable S-Filter with AEQ */
    };
    
    
    BspUtils_Ub960I2cParams gUB953_AR0220_CSI2_SerCfg[AR0220_CSI2_SER_CFG_SIZE] = {
        {0x01, 0x01, 0x10},	 /* Digital Reset 0 */
        {0x02, 0x73, 0x10},	 /* Setup for AR0220 to UB953 on 4 lanes */
        {0x06, 0x21, 0x1}, /* Clock output control0 (Div by 2) */
        {0x07, 0x28, 0x1}, /* Clock output control1 */
    };
    #endif
    /*******************************************************************************
     *  Function Definition
     * 	@TODO To be updated when AR0220 datasheet is available
     *******************************************************************************
     */
    
    Void IssSensor_AR0220_Init()
    {
    	Vps_printf(" IssSensor_AR0220_Init \r\n");
        Int32 status;
        IssSensorIf_Params *prms = &SensorParams_Ar0220;
        IssSensor_Info *info = &SensorParams_Ar0220.info;
    
        IssSensorIf_Params_Init(prms);
    
        strncpy(prms->name, SENSOR_AR0220, 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_SENSORS_AR0220_FEATURES;
        info->aewbMode          = ALGORITHMS_ISS_AEWB_MODE_AEWB;
        info->maxExp            = 1;
        info->ramOffset         = 24*1024*1024;
    
        prms->start             = AR0220_Start;
        prms->stop              = AR0220_Stop;
        prms->setAeParams       = AR0220_SetAeParams;
        prms->getExpParams      = AR0220_GetExpParams;
        prms->getDccParams      = AR0220_GetDccParams;
        prms->initAewbConfig    = AR0220_InitAewbConfig;
        prms->getIspConfig      = AR0220_GetIspConfig;
        prms->readWriteReg      = AR0220_ReadWriteReg;
    
        status = IssSensorIf_RegisterSensor(prms);
        UTILS_assert(SYSTEM_LINK_STATUS_SOK == status);
    }
    
    #if 0
    /**
     *	@TODO To confirm whether this is required
     */
    Void IssSensor_AR0220_TIDA_Init()
    {
        Int32 status;
        IssSensorIf_Params *prms = &SensorParams_Ar0220;
        IssSensor_Info *info = &SensorParams_Ar0220.info;
    
        IssSensorIf_Params_Init(prms);
    
        strncpy(prms->name, SENSOR_APTINA_AR0220_TIDA262, ISS_SENSORS_MAX_NAME);
    
        prms->dccId             = 140;
    
        info->width             = 1820;
        info->height            = 940;
        info->dataFormat        = SYSTEM_DF_RGB24_888;
    
        /*  If the color looks invalid with purple cast then change the
            bayer pattern as follows by modify "#if 0" to "#if 1". 
            This issue is seen only with the UB964 rev 3 chip */
    #if 0
        info->dataFormat        = SYSTEM_DF_BAYER_BGGR;
    #endif 
    
        info->bpp               = SYSTEM_BPP_BITS24;
        info->features          = ISS_SENSORS_AR0220_FEATURES;
        info->aewbMode          = ALGORITHMS_ISS_AEWB_MODE_AEWB;
        info->maxExp            = 1;
        info->ramOffset         = 24*1024*1024;
    
        prms->start             = AR0220_TIDA_Start;
        prms->stop              = AR0220_Stop;
        prms->setAeParams       = AR0220_SetAeParams;
        prms->getExpParams      = AR0220_GetExpParams;
        prms->getDccParams      = AR0220_GetDccParams;
        prms->initAewbConfig    = AR0220_InitAewbConfig;
        prms->getIspConfig      = AR0220_GetIspConfig;
        prms->readWriteReg      = AR0220_ReadWriteReg;
    
        status = IssSensorIf_RegisterSensor(prms);
        UTILS_assert(SYSTEM_LINK_STATUS_SOK == status);
    }
    #endif
    
    /*******************************************************************************
     *  Local Functions Definition
     *******************************************************************************
     */
    /**
     *	@TODO Register addresses needs to be updated for AR0220
     */
    static Int32 AR0220_Start(UInt32 chId, IssSensor_CreateParams *pCreatePrms)
    {
    #if 0
        Int32 status = SYSTEM_LINK_STATUS_EFAIL;
        UInt32 cnt, i2cInstId, features, numRegs;
        UInt8 i2cAddr;
        UInt16 regAddr, regValue;
        IssSensor_ConfigRegs *sensorRegs;
    
        UTILS_assert(NULL != pCreatePrms);
    
        i2cInstId = pCreatePrms->i2cInstId;
        i2cAddr = pCreatePrms->i2cAddr[chId];
        features = pCreatePrms->enableFeatures[chId];
    
        if (ISS_SENSOR_FEATURE_LINEAR_MODE ==
            (features & ISS_SENSOR_FEATURE_LINEAR_MODE))
        {
            sensorRegs = gAR0220SensorsLinearConfig;
            numRegs = sizeof(gAR0220SensorsLinearConfig)/
                sizeof(IssSensor_ConfigRegs);
    
            gAr0220DeviceObj.maxCoarseIntgTime =
                SensorParams_Ar0220.info.height - 1U;
        }
        else
        {
            sensorRegs = gAR0220SensorsWdrConfig;
            numRegs = sizeof(gAR0220SensorsWdrConfig)/
                sizeof(IssSensor_ConfigRegs);
    
            if ((51u * ISS_SENSORS_AR0220_DEFAULT_EXP_RATIO) >
                    (SensorParams_Ar0220.info.height - 52U))
            {
                gAr0220DeviceObj.maxCoarseIntgTime =
                    SensorParams_Ar0220.info.height - 52u;
            }
            else
            {
                gAr0220DeviceObj.maxCoarseIntgTime =
                    51u * ISS_SENSORS_AR0220_DEFAULT_EXP_RATIO;
            }
        }
        gAr0220DeviceObj.lineIntgTimeInMs = 22.22267f;
        gAr0220DeviceObj.pixIntgTimeInMs  = 0.0134f;
    
    
        for (cnt = 0u; cnt < numRegs; cnt ++)
        {
            regAddr  = sensorRegs[cnt].regAddr;
            regValue = sensorRegs[cnt].regValue;
    
            /* Change the exposure ratio */
            if ((UInt16) 0x3082 == regAddr)
            {
                regValue &= ((UInt16) ~((UInt16) 0x000CU));
                if (ISS_SENSORS_AR0220_DEFAULT_EXP_RATIO == 32U)
                {
                    regValue |= (UInt16) (((UInt16) 0x3U) << 2);
                }
                else if (ISS_SENSORS_AR0220_DEFAULT_EXP_RATIO == 16U)
                {
                    regValue |= (UInt16) (((UInt16) 0x2U) << 2);
                }
                else if (ISS_SENSORS_AR0220_DEFAULT_EXP_RATIO == 8U)
                {
                    regValue |= (UInt16) (((UInt16) 0x1U) << 2);
                }
                else /* 4x exposure ration */
                {
                    regValue |= (UInt16) (((UInt16) 0x0U) << 2);
                }
            }
    
            /* READ_MODE - control vertical flip / horizontal mirror */
            if (0x3040U == regAddr)
            {
                regValue &= ((UInt16) ~((uint16_t)(1u << 14u) |
                    (uint16_t)(1u << 15u)));
                if (ISS_SENSOR_FEATURE_HFLIP ==
                    (features & ISS_SENSOR_FEATURE_HFLIP))
                {
                    regValue |= ((uint16_t)(1u << 14u));
                }
                if (ISS_SENSOR_FEATURE_VFLIP ==
                    (features & ISS_SENSOR_FEATURE_VFLIP))
                {
                    regValue |= ((uint16_t)(1u << 15u));
                }
            }
    
            /* Convert Registers address and value into 8bit array */
            status = AR0220_WriteReg(i2cInstId, i2cAddr, &regAddr,
                &regValue, 1u);
    
            if (SYSTEM_LINK_STATUS_SOK != status)
            {
                break;
            }
        }
    
        return (status);
    #endif
    	return SYSTEM_LINK_STATUS_SOK;
    }
    
    #if 0
    /**
     *	@TODO To confirm whether this is required
     */
    static Int32 AR0220_TIDA_Start(UInt32 chId, IssSensor_CreateParams *pCreatePrms)
    {
        Int32 status = SYSTEM_LINK_STATUS_EFAIL;
        UInt32 cnt, i2cInstId, features, numRegs;
        UInt8 i2cAddr;
        UInt16 regAddr, regValue;
        IssSensor_ConfigRegs *sensorRegs;
    
        UTILS_assert(NULL != pCreatePrms);
    
        i2cInstId = pCreatePrms->i2cInstId;
        i2cAddr = pCreatePrms->i2cAddr[chId];
        features = pCreatePrms->enableFeatures[chId];
    
        if (ISS_SENSOR_FEATURE_LINEAR_MODE ==
            (features & ISS_SENSOR_FEATURE_LINEAR_MODE))
        {
            sensorRegs = gAR0220TidaSensorsLinearConfig;
            numRegs = sizeof(gAR0220TidaSensorsLinearConfig)/
                sizeof(IssSensor_ConfigRegs);
    
            gAr0220DeviceObj.maxCoarseIntgTime =
                SensorParams_Ar0220.info.height - 1U;
        }
        else
        {
            sensorRegs = gAR0220TidaSensorsWdrConfig;
            numRegs = sizeof(gAR0220TidaSensorsWdrConfig)/
                sizeof(IssSensor_ConfigRegs);
    
            if ((51u * ISS_SENSORS_AR0220_DEFAULT_EXP_RATIO) >
                    (SensorParams_Ar0220.info.height - 52U))
            {
                gAr0220DeviceObj.maxCoarseIntgTime =
                    SensorParams_Ar0220.info.height - 52u;
            }
            else
            {
                gAr0220DeviceObj.maxCoarseIntgTime =
                    51u * ISS_SENSORS_AR0220_DEFAULT_EXP_RATIO;
            }
        }
        gAr0220DeviceObj.lineIntgTimeInMs = 22.22267f;
        gAr0220DeviceObj.pixIntgTimeInMs  = 0.0134f;
    
    
        for (cnt = 0u; cnt < numRegs; cnt ++)
        {
            regAddr  = sensorRegs[cnt].regAddr;
            regValue = sensorRegs[cnt].regValue;
    
            /* Change the exposure ratio */
            if ((UInt16) 0x3082 == regAddr)
            {
                regValue &= ((UInt16) ~((UInt16) 0x000CU));
                if (ISS_SENSORS_AR0220_DEFAULT_EXP_RATIO == 32U)
                {
                    regValue |= (UInt16) (((UInt16) 0x3U) << 2);
                }
                else if (ISS_SENSORS_AR0220_DEFAULT_EXP_RATIO == 16U)
                {
                    regValue |= (UInt16) (((UInt16) 0x2U) << 2);
                }
                else if (ISS_SENSORS_AR0220_DEFAULT_EXP_RATIO == 8U)
                {
                    regValue |= (UInt16) (((UInt16) 0x1U) << 2);
                }
                else /* 4x exposure ration */
                {
                    regValue |= (UInt16) (((UInt16) 0x0U) << 2);
                }
            }
    
            /* READ_MODE - control vertical flip / horizontal mirror */
            if (0x3040U == regAddr)
            {
                regValue &= ((UInt16) ~((uint16_t)(1u << 14u) |
                    (uint16_t)(1u << 15u)));
                if (ISS_SENSOR_FEATURE_HFLIP ==
                    (features & ISS_SENSOR_FEATURE_HFLIP))
                {
                    regValue |= ((uint16_t)(1u << 14u));
                }
                if (ISS_SENSOR_FEATURE_VFLIP ==
                    (features & ISS_SENSOR_FEATURE_VFLIP))
                {
                    regValue |= ((uint16_t)(1u << 15u));
                }
            }
    
            /* Convert Registers address and value into 8bit array */
            status = AR0220_WriteReg(i2cInstId, i2cAddr, &regAddr,
                &regValue, 1u);
    
            if (SYSTEM_LINK_STATUS_SOK != status)
            {
                break;
            }
        }
    
        return (status);
    }
    #endif
    
    /**
     *	@TODO Register addresses needs to be updated for AR0220
     */
    static Int32 AR0220_Stop(UInt32 chId,
        IssSensor_CreateParams *pCreatePrms)
    {
    #if 0
        Int32 status = SYSTEM_LINK_STATUS_EFAIL;
        UInt16 regAddr, regValue;
    
        UTILS_assert(NULL != pCreatePrms);
    
        regAddr = 0x301AU;
        regValue = 0x10D8U;
    
        /* Convert Registers address and value into 8bit array */
        status = AR0220_WriteReg(pCreatePrms->i2cInstId,
            pCreatePrms->i2cAddr[chId], &regAddr, &regValue, 1u);
    
        return (status);
    #endif
    	return SYSTEM_LINK_STATUS_SOK;
    }
    
    /**
     *	@TODO Register addresses needs to be updated for AR0220
     */
    static Int32 AR0220_SetAeParams(IssSensor_CreateParams *pCreatePrms,
        IssSensor_AeParams *pAePrms)
    {
    #if 0
        Int32 status = SYSTEM_LINK_STATUS_EFAIL;
        UInt32 gain, cnt, chId;
        UInt16 regAddr, regValue;
    
        UTILS_assert(NULL != pCreatePrms);
        UTILS_assert(NULL != pAePrms);
    
        chId = pAePrms->chId;
        regAddr = 0x3012U;
        regValue = (UInt16) (pAePrms->exposureTime[0] /
            gAr0220DeviceObj.lineIntgTimeInMs);
    
        /* For WDR mode, max exposure lines are 816 */
        if (regValue > gAr0220DeviceObj.maxCoarseIntgTime)
        {
            regValue = gAr0220DeviceObj.maxCoarseIntgTime;
        }
    
        /* Convert Registers address and value into 8bit array */
        status = AR0220_WriteReg(pCreatePrms->i2cInstId,
            pCreatePrms->i2cAddr[chId], &regAddr, &regValue, 1u);
    
        if (SYSTEM_LINK_STATUS_SOK == status)
        {
            gain = pAePrms->analogGain;
    
            /* Sensor support at max 10x analog gain */
            for (cnt = 0; cnt < ISS_SENSORS_AR0220_ANALOG_MAX_GAIN; cnt ++)
            {
                if (gain <= gAr0220GainsTable[cnt][0])
                {
                    regAddr = 0x3060U;
    
                    regValue = (UInt16)
                             ((gAr0220GainsTable[cnt][1] &
                               (UInt32) 0x7) << 4);
                    regValue |= (UInt16)
                              ((gAr0220GainsTable[cnt][2] &
                                (UInt32) 0xF) << 0);
    
                    status = AR0220_WriteReg(pCreatePrms->i2cInstId,
                        pCreatePrms->i2cAddr[chId], &regAddr, &regValue, 1u);
                    break;
                }
            }
        }
    
        return (status);
    #endif
    	return SYSTEM_LINK_STATUS_SOK;
    }
    
    #if SWATI
    static Int32 AR0220_ReadReg(UInt8         i2cInstId,
                                        UInt8         i2cAddr,
                                        const UInt16 *regAddr,
                                        UInt16       *regVal,
                                        UInt32        numRegs)
    {
    #if 0
        Int32  status = SYSTEM_LINK_STATUS_SOK;
        UInt32 cnt;
        UInt8  rawRegVal[4];
    
        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],
                    2u);
    
                regVal[cnt] =
                    (UInt16)((UInt16)((rawRegVal[2U] & (UInt16) 0xFF) << 8U) |
                             ((UInt16)(rawRegVal[3U] & (UInt16) 0xFF)));
            }
        }
    
        return (status);
    #endif
    	return SYSTEM_LINK_STATUS_SOK;
    }
    
    static Int32 AR0220_WriteReg(UInt8         i2cInstId,
                                 UInt8         i2cAddr,
                                 const UInt16 *regAddr,
                                 const UInt16 *regValue,
                                 UInt32        numRegs)
    {
    #if 0
        Int32 status = SYSTEM_LINK_STATUS_EFAIL;
        UInt32 cnt;
        UInt8 rawRegVal[4];
    
        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] >> 8U) & (UInt8) 0xFF);
            rawRegVal[3U] = (UInt8) ((regValue[cnt] >> 0U) & (UInt8) 0xFF);
    
            status = Bsp_deviceRawWrite8(i2cInstId, i2cAddr, rawRegVal, 4U);
    
            if (SYSTEM_LINK_STATUS_SOK != status)
            {
                break;
            }
        }
    
        return (status);
    #endif
    	return SYSTEM_LINK_STATUS_SOK;
    }
    #endif
    
    static AR0220_GetDccParams(IssSensor_CreateParams *pCreatePrms,
        IssSensor_DccParams *pDccPrms)
    {
    #if 0
        Int32 status = SYSTEM_LINK_STATUS_SOK;
        UInt32 features;
    
        UTILS_assert(NULL != pCreatePrms);
        UTILS_assert(NULL != pDccPrms);
    
        features = pCreatePrms->enableFeatures[pDccPrms->chId];
    
        if (ISS_SENSOR_FEATURE_ONE_PASS_WDR_MODE ==
            (features & ISS_SENSOR_FEATURE_ONE_PASS_WDR_MODE))
        {
            pDccPrms->pDccCfg = (UInt8 *)gAr0220DccCfgSinglePassWdr;
            pDccPrms->dccCfgSize = sizeof(gAr0220DccCfgSinglePassWdr);
        }
        else
        {
            pDccPrms->pDccCfg = (UInt8 *)gAr0220DccCfgLinearAndWdr;
            pDccPrms->dccCfgSize = sizeof(gAr0220DccCfgLinearAndWdr);
        }
    
        return (status);
    #endif
    	return SYSTEM_LINK_STATUS_SOK;
    }
    
    /**
     *	@TODO Register addresses needs to be updated for AR0220
     */
    static AR0220_GetExpParams(IssSensor_CreateParams *pCreatePrms,
        IssSensor_ExposureParams *pExpPrms)
    {
    #if 0
        Int32 status = SYSTEM_LINK_STATUS_SOK;
        UInt32 chId;
        UInt16 regAddr, regValue;
    
        UTILS_assert(NULL != pCreatePrms);
        UTILS_assert(NULL != pExpPrms);
    
        regAddr = 0x3012U;
    
        chId = pExpPrms->chId;
    
        /* Convert Registers address and value into 8bit array */
        status = AR0220_ReadReg(pCreatePrms->i2cInstId,
            pCreatePrms->i2cAddr[chId], &regAddr, &regValue, 1u);
    
        if (SYSTEM_LINK_STATUS_SOK == status)
        {
            pExpPrms->expRatio = ISS_SENSORS_AR0220_DEFAULT_EXP_RATIO;
            pExpPrms->exposureTime[chId] = regValue *
                gAr0220DeviceObj.lineIntgTimeInMs;
        }
    
        return (status);
    #endif
    	return SYSTEM_LINK_STATUS_SOK;
    }
    
    /**
     *	@TODO Parameters need to be updated for AR0220 sensor
     */
    static Void AR0220_InitAewbConfig(
        IssSensor_CreateParams *pCreatePrms,
        AlgorithmLink_IssAewbCreateParams *pAewbPrms)
    {
    #if 0
        AlgorithmLink_IssAewbAeDynamicParams *dynPrms = NULL;
    
        UTILS_assert(NULL != pCreatePrms);
        UTILS_assert(NULL != pAewbPrms);
    
        /* Set H3A Params */
        pAewbPrms->h3aParams.winCountH = aewbConfig_ar0220.winCfg.horzCount;
        pAewbPrms->h3aParams.winCountV = aewbConfig_ar0220.winCfg.vertCount;
        pAewbPrms->h3aParams.winSizeH  = aewbConfig_ar0220.winCfg.width;
        pAewbPrms->h3aParams.winSizeV  = aewbConfig_ar0220.winCfg.height;
        pAewbPrms->h3aParams.winSkipH  = aewbConfig_ar0220.winCfg.horzIncr;
        pAewbPrms->h3aParams.winSkipV  = aewbConfig_ar0220.winCfg.vertIncr;
        pAewbPrms->numH3aPlanes = 1u;
    
        pAewbPrms->dataFormat = SensorParams_Ar0220.info.dataFormat;
        pAewbPrms->mode = (AlgorithmLink_IssAewbMode)SensorParams_Ar0220.info.aewbMode;
    
        /* Using Channel Id 9 */
        if (ISS_SENSOR_FEATURE_LINEAR_MODE ==
                (ISS_SENSOR_FEATURE_LINEAR_MODE&pCreatePrms->enableFeatures[0]))
        {
            pAewbPrms->isWdrEnable = FALSE;
        }
        else
        {
            pAewbPrms->isWdrEnable = TRUE;
        }
    
        pAewbPrms->dccCameraId = SensorParams_Ar0220.dccId;
    
        dynPrms = &pAewbPrms->aeDynParams;
    
        if (ISS_SENSOR_FEATURE_ONE_PASS_WDR_MODE ==
                (ISS_SENSOR_FEATURE_ONE_PASS_WDR_MODE &
                    pCreatePrms->enableFeatures[pAewbPrms->chId]))
        {
            dynPrms->targetBrightnessRange.min = 18;
            dynPrms->targetBrightnessRange.max = 22;
            dynPrms->targetBrightness = 20;
        }
        else
        {
            dynPrms->targetBrightnessRange.min = 35;
            dynPrms->targetBrightnessRange.max = 45;
            dynPrms->targetBrightness = 40;
        }
        dynPrms->threshold = 5;
    
        dynPrms->exposureTimeRange[0].min = 100;
        dynPrms->exposureTimeRange[0].max = 8333;
        dynPrms->apertureLevelRange[0].min = 1;
        dynPrms->apertureLevelRange[0].max = 1;
        dynPrms->sensorGainRange[0].min = 1000;
        dynPrms->sensorGainRange[0].max = 1000;
        dynPrms->ipipeGainRange[0].min = 512;
        dynPrms->ipipeGainRange[0].max = 512;
    
        dynPrms->exposureTimeRange[1].min = 8333;
        dynPrms->exposureTimeRange[1].max = 8333;
        dynPrms->apertureLevelRange[1].min = 1;
        dynPrms->apertureLevelRange[1].max = 1;
        dynPrms->sensorGainRange[1].min = 1000;
        dynPrms->sensorGainRange[1].max = 2000;
        dynPrms->ipipeGainRange[1].min = 512;
        dynPrms->ipipeGainRange[1].max = 512;
    
    
    //Limiting exposure time to 16.6 ms for 16x WDR mode
        dynPrms->exposureTimeRange[2].min = 16666;
        dynPrms->exposureTimeRange[2].max = 16666;
        dynPrms->apertureLevelRange[2].min = 1;
        dynPrms->apertureLevelRange[2].max = 1;
        dynPrms->sensorGainRange[2].min = 1000;
        dynPrms->sensorGainRange[2].max = 1150;
        dynPrms->ipipeGainRange[2].min = 512;
        dynPrms->ipipeGainRange[2].max = 512;
    
        dynPrms->exposureTimeRange[3].min = 16666;
        dynPrms->exposureTimeRange[3].max = 16666;
        dynPrms->apertureLevelRange[3].min = 1;
        dynPrms->apertureLevelRange[3].max = 1;
        dynPrms->sensorGainRange[3].min = 1000;
        dynPrms->sensorGainRange[3].max = 12000;
        dynPrms->ipipeGainRange[3].min = 512;
        dynPrms->ipipeGainRange[3].max = 512;
    
    #ifdef _USE_DIGITAL_GAIN_
        dynPrms->exposureTimeRange[4].min = 16666;
        dynPrms->exposureTimeRange[4].max = 16666;
        dynPrms->apertureLevelRange[4].min = 1;
        dynPrms->apertureLevelRange[4].max = 1;
        dynPrms->sensorGainRange[4].min = 12000;
        dynPrms->sensorGainRange[4].max = 12000;
        dynPrms->ipipeGainRange[4].min = 512;
        dynPrms->ipipeGainRange[4].max = 4095;
    
        dynPrms->numAeDynParams = 5;
    #else
        dynPrms->numAeDynParams = 4;
    #endif
        dynPrms->exposureTimeStepSize = 1;
        dynPrms->enableBlc = TRUE;
    
        pAewbPrms->calbData = NULL;
    #endif
    }
    
    static Void AR0220_GetIspConfig (
        IssSensor_CreateParams *pCreatePrms,
        IssIspConfigurationParameters *pIspCfg)
    {
    #if 0
        UInt32 chId;
    
        UTILS_assert(NULL != pIspCfg);
        UTILS_assert(NULL != pCreatePrms);
    
        /* Assuming Channel Id as 0 */
        chId = 0;
    
        /* Override common settings for specific sensor */
        pIspCfg->aewbCfg = &aewbConfig_ar0220;
    
        if (ISS_SENSOR_FEATURE_ONE_PASS_WDR_MODE ==
                (ISS_SENSOR_FEATURE_ONE_PASS_WDR_MODE &
                    pCreatePrms->enableFeatures[chId]))
        {
            /* WDR Config */
            pIspCfg->glbceWdrCfg = &glbceWdrCfg_ar0220;
        }
    #endif
    }
    
    static Int32 AR0220_ReadWriteReg (
        IssSensor_CreateParams *pCreatePrms, UInt32 readWriteFlag,
        IssSensor_ReadWriteReg *pReg)
    {
    #if 0
        Int32 status;
        UInt32 chId;
    
        UTILS_assert(NULL != pReg);
        UTILS_assert(NULL != pReg);
    
        /* Assuming Channel Id as 0 */
        chId = pReg->chId;
    
        if (readWriteFlag)
        {
            status = AR0220_WriteReg(pCreatePrms->i2cInstId,
                pCreatePrms->i2cAddr[chId], &pReg->regAddr, &pReg->regValue, 1u);
        }
        else
        {
            status = AR0220_ReadReg(pCreatePrms->i2cInstId,
                pCreatePrms->i2cAddr[chId], &pReg->regAddr, &pReg->regValue, 1u);
        }
    
        return (status);
    #endif
    	return SYSTEM_LINK_STATUS_SOK;
    }
    
    /******************************************************************************
    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_tda2px.c
     *
     *
     *
     *******************************************************************************
    */
    
    /*******************************************************************************
     *  INCLUDE FILES
     *******************************************************************************
     */
    /* Including system.h for Int32/UInt32 data type */
    #include <include/link_api/system.h>
    #include <iss_utils.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_TDA2PX_BOARD_MUX_I2C_INST     (0U)
    /* I2C Address of the board mux */
    #define CHAINS_COMMON_TDA2PX_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_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_OMNIVISION_OV2775_CSI2, NULL, 0, NULL, 0, BSPUTILS_FPDCAMPOWERLEVEL_OFF, 0U},
    
        {SENSOR_SONY_IMX390_UB953_D3, gUB960DesCfg_D3IMX390, IMX390_D3_DES_CFG_SIZE,
                                                    gAppIssUtilsUB953SerCfg_D3IMX390, IMX390_D3_SER_CFG_SIZE,
                                                    BSPUTILS_FPDCAMPOWERLEVEL_12V0, 2000U},
    
        {SENSOR_APTINA_AR0143_MARS, gAppIssUtilsUb960Cfg_MARS_AR0143,AR143_MARS_DES_CFG_SIZE,
                                                    gUB913MarsAR0143SerCfg, AR143_MARS_SER_CFG_SIZE,
                                                    BSPUTILS_FPDCAMPOWERLEVEL_12V0, 500U},
    #if 1
    	{SENSOR_AR0220, gAppIssUtilsUb954Cfg_AR0220_CSI2_DesCfg, AR0220_CSI2_DES_CFG_SIZE,
                                                    gUB953_AR0220_CSI2_SerCfg, AR0220_CSI2_SER_CFG_SIZE,
                                                    BSPUTILS_FPDCAMPOWERLEVEL_12V0, 500U},
    #endif
    };
    
    const static ChainsCommon_SensorIntfInfo gSensorInterfaceInfo[] = {
        {SENSOR_OMNIVISION_OV10640_CSI2,
            {4u, {0x32}, {0x32}, FALSE, SYSTEM_VIFW_4LANES, SYSTEM_VIFM_SCH_CSI2,
                SYSTEM_CSI2_RAW12 /* CSI2 DataFormat*/, 0 /*Virtual Channel Id*/,
                    0, /* Is CSI Enable Required in UB960 */
                    {TRUE /* isCplxCfgValid */,
                        {{FALSE, 2}, /* Clock Lane */
                         {FALSE, 1}, /* data1Lane */
                         {FALSE, 3}, /* data2Lane */
                         {FALSE, 4}, /* data3Lane*/
                         {FALSE, 5}},/* data4Lane */
                         400 /* csi2PhyClk */ }}},
        {SENSOR_SONY_IMX224_CSI2,
            {4u, {0x36}, {0x36}, FALSE, SYSTEM_VIFW_4LANES, SYSTEM_VIFM_SCH_CSI2,
                SYSTEM_CSI2_RAW12 /* CSI2 DataFormat*/, 0 /*Virtual Channel Id*/,
                    0, /* Is CSI Enable Required in UB960 */
                    {TRUE /* isCplxCfgValid */,
                        {{FALSE, 2u}, /* Clock Lane */
                         {FALSE, 1u}, /* data1Lane */
                         {FALSE, 3u}, /* data2Lane */
                         {FALSE, 4u}, /* data3Lane*/
                         {FALSE, 5u}},/* data4Lane */
                         150u /* csi2PhyClk */ }}},
        {SENSOR_OMNIVISION_OV10640_IMI,
            {
                4u, /* 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*/,
                    0, /* 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_IMI_OV10640_DRV,      /* sensorDrvId */
                         TRUE,      /* sensorBroadcast */
                         TRUE}},    /* enableFsin */
        {SENSOR_APTINA_AR0140_TIDA262,
            {
                4u, /* 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*/,
                    0, /* 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_TIDA00262_APT_AR0140_DRV, /* sensorDrvId */
                         FALSE,     /* sensorBroadcast */
                         FALSE}},   /* enableFsin */
        {SENSOR_OMNIVISION_OV2775_TIDA1130,
            {
                4u, /* TDA3X EVM board uses I2C instance 1 */
                {PORT_0_SENSOR_ADDR,
                 PORT_1_SENSOR_ADDR,
                 PORT_2_SENSOR_ADDR,
                 PORT_3_SENSOR_ADDR,
                 PORT_4_SENSOR_ADDR,
                 PORT_5_SENSOR_ADDR,
                 PORT_6_SENSOR_ADDR,
                 PORT_7_SENSOR_ADDR},    /* Sensor alias address */
                {PORT_0_SER_ADDR,
                 PORT_1_SER_ADDR,
                 PORT_2_SER_ADDR,
                 PORT_3_SER_ADDR,
                 PORT_4_SER_ADDR,
                 PORT_5_SER_ADDR,
                 PORT_6_SER_ADDR,
                 PORT_7_SER_ADDR},    /* Serializer alias address */
                TRUE, /* isMultiChannel */
                SYSTEM_VIFW_4LANES, SYSTEM_VIFM_SCH_CSI2,
                SYSTEM_CSI2_RAW12 /* CSI2 DataFormat*/,
                0 /*Virtual Channel Id*/,
                    0, /* 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 */ },
                       {TRUE /* isCplxCfgValid */,
                        {{FALSE, 1}, /* Clock Lane */
                         {FALSE, 2}, /* data1Lane */
                         {FALSE, 3}, /* data2Lane */
                         {FALSE, 0}, /* data3Lane*/
                         {FALSE, 0}},/* data4Lane */
                         800 /* csi2PhyClk */ }},
                         FVID2_VID_SENSOR_OV2775_TIDA1130_DRV, /* sensorDrvId */
                         FALSE,     /* sensorBroadcast */
                         FALSE,     /* enableFsin */
                         {0x3d, 0x36}}},
        {SENSOR_OMNIVISION_OV2775_CSI2,
            {4u, {0x36}, {0x36}, FALSE, SYSTEM_VIFW_4LANES, SYSTEM_VIFM_SCH_CSI2,
                SYSTEM_CSI2_RAW12 /* CSI2 DataFormat*/, 0 /*Virtual Channel Id*/,
                    0, /* Is CSI Enable Required in UB960 */
                    {TRUE /* isCplxCfgValid */,
                        {{FALSE, 3}, /* Clock Lane */
                         {FALSE, 4}, /* data1Lane */
                         {FALSE, 2}, /* data2Lane */
                         {FALSE, 0}, /* data3Lane*/
                         {FALSE, 0}},/* data4Lane */
                         480 /* csi2PhyClk */ }}},
    
        {SENSOR_SONY_IMX390_UB953_D3,
            {
                4u, /* 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 */
                         },
        {SENSOR_APTINA_AR0143_MARS,
            {
                4u, /* 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*/,
                    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 */
    	/**
    	 *	@TODO AR0220 sensor address to be updated
    	 */
    	 //swati: Change this if required
    	{SENSOR_AR0220, 
            {
    			4u,		/* I2C Instance id for the sensor */ 
    			{0x60}, /* I2C Address of the sensor */
    			{0x60}, /* I2C Address of the serializer */
    			FALSE, 	/* Flag for single/multi channel sensor config */
    			SYSTEM_VIFW_4LANES, 	/* Interface width */
    			SYSTEM_VIFM_SCH_CSI2,	/* Video Interface mode - Single channel capture via CSI2 interface */
                SYSTEM_CSI2_RGB888, 		/* Input CSI2 Data Format */
    			0,	/* Virtual Channel Id */
                1, 	/* Is CSI Enable Required in UB954 */
                {TRUE /* isCplxCfgValid */,
                     {{FALSE, 1}, /* Clock Lane */
                         {FALSE, 2}, /* data1Lane */
                         {FALSE, 3}, /* data2Lane */
                         {FALSE, 4}, /* data3Lane*/
                         {FALSE, 5}},/* data4Lane */
                         800 /* 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;
            }
        }
    }
    

  • Hi Swati,

    I was thinking this was UB964x, my mistake. There is ISS Capture demo application that configures the UB954x to generate the color bars.
    Please check \ti_components\drivers\pdk\packages\ti\drv\vps\examples\utility\src\bsputils_ub95x.c, gUb954Cfg describes the required configuration.

    1. Build the ISS capture demo application and ensure this works on TDA2Px EVM with UB954x EVM.
    2. Use these UB954x settings update your deser.c and check on TDA2Px / custom board

    Regards,
    Sujith
  • Hi Sujith,

    Thanks for the reply.
    I can see "..\ti_components\drivers\pdk_01_09_00_17\packages\ti\drv\vps\examples\iss\isscapt_baremetal_app" which is generating pattern for UB954.
    But that example is for TDA3x. How can we build that example for tda2px?

    Thanks,
    Swati
  • Hi Swati,

    It's should work on TDApx also, please use BOARD=tda2px-evm while building the pdk.

    Regards,
    Sujith
  • Hi Sujith,

    I am working with Swati on this.

    I tried to build "vps_examples_isscapt_baremetal" from "psdk_3_3\ti_components\drivers\pdk_01_09_00_17\packages\ti\build".

    I made following changes in "vps_component.mk" at "psdk_3_3\ti_components\drivers\pdk_01_09_00_17\packages\ti\drv\vps\",

    -  vps_examples_isscapt_baremetal_BOARDLIST = tda3xx-evm

    + vps_examples_isscapt_baremetal_BOARDLIST = tda2px-evm

    -  vps_examples_isscapt_baremetal_tda3xx_CORELIST = ipu1_0

    + vps_examples_isscapt_baremetal_tda2px_CORELIST = ipu1_0

    Also in the makefile of "C:\psdk_3_3\ti_components\drivers\pdk_01_09_00_17\packages\ti\drv\vps\examples\iss\isscapt_baremetal_app\makefile", I have replaced "tda3xx" with "tda2px".

    After doing above changes I tried to build the example with following command,

            gmake -s vps_examples_isscapt_baremetal CORE=ipu1_0 BOARD=tda2px-evm

    but I am getting following error,

    This IRQ "ISS_IRQ_INT0" belongs to tda3xx and we searched in the TRM and we found that for tda2px, "ISS_IRQ0" needs to be added. 

    But this IRQ is not added in "C:\psdk_3_3\ti_components\drivers\pdk_01_09_00_17\packages\ti\drv\stw_lld\platform\src\tda2xx\irq_xbar_interrupt_ids.h" file.

    Can you suggest how can we fix this.

    Regards,

    Abhay

  • Hi Abhay,

    Please try the VPS example, \ti_components\drivers\pdk\packages\ti\drv\vps\examples\iss\captureIss\src\CaptureIss_main.c
    and choose option "Sensor Config Bypassed CSI2 4Lanes capture color bars from UB954"from the uart console.

    Regards,
    Sujith
  • Hi Sujith,

    I tried using gUb954Cfg  values present in bsputils_ub95x.c  in deser.c. Still I am not getting any pattern(0x489B0304  - 0x4A054321, 0x489B0350 - 0).

    we tried Bsp_deviceI2cProbeDevice for deserializer, which was successful. Even we are able to read the data what we are writing.

    We have done setup like below. We are using tda2px EVm and UB954 EVM. We have removed sensor fusion board.

    Thanks,

    Swati

  • Hi Abhay,

    This version of the UB954x is not yet supported. You will have to bringup this board.
    It's good that I2C connection is verified. Please get the schematics and check for lanes connections compatibility with TDA2Px.

    Regards,
    Sujith
  • Hi Sujith,

    We have confirmed the lane connection compatibility of UB954-EVM with TDA2Px-EVM wih out hardware team.
    You mentioned that the UB954x is not yet supported, so does that mean the example "\ti_components\drivers\pdk\packages\ti\drv\vps\examples\iss\captureIss\" will not work with UB954 EVM ?

    Regards,
    Abhay
  • Hi Sujith,

    We are running "captureIss" example. But it is going in infinite while loop CaptureIss_main.c[line 450]

    while (appObj->rcvedFramesCount <

              (appObj->numFramesToCapture * pCfg->numStreams))

    Thanks,

    Swati

  • Hi Abhay,

    There seems to 2 versions of UB954x board and the board that you are using is not tested by VisionSDK/PDK.

    Hi Swati,

    What is the I2C address of UB954x is it 0x3D or 0x30? From the log that you have attached. It seems like there is device at 0x30.

    Regards,
    Sujith
  • Also, you should have an EVM guide. Can you share that please?

    Regards,
    Sujith
  • Hi Sujith,

    Here’s the link for user guide
    www.ti.com/.../snlu223.pdf

    Regards,
    Abhay
  • Hi Sujith,

    I2C address is 0x30.

    Thanks,

    Swati

  • Hi Swati,

    Did you check on the following from UB95x user guide.

    Regards,

    Sujith

  • Hi Sujith,

    Thanks for reply. Do we need to mount 0 ohm resistors ( R60-R69, R71,R72 0Ω resistors) at the bottom of the board.

    Regards,
    Abhay
  • Hi Abhay,

    Can you request your h/w team to check out the userguide/schematics and make the necessary changes?
    Please note that are high frequency signals, exercise caution while making these changes.

    Regards,
    Sujith
  • Hi Sujith,

    For DS90UB954-EVM, currently we are not able to get 0 ohm resistors of 0201 SMD package. So will it work if we short the lines for R60-R69, R71 & R72 instead.

    Regards,
    Abhay
  • Hi Abhay,

    These lines carry high-speed signals (800 MHz), a lead short might have other side effects which could be difficult to debug.
    Also note that you will have to connect R71 to 0_0201_BOT_CLK0_P and so on.

    Regards,
    Sujith
  • Hi Sujith,

    We mounted 0 ohm resistors and we are able to test the pattern generation code with UB954-EVM.
    Thank you for your support.

    Regards,
    Abhay
  • Hi Abhay,

    Thanks for the confirmation, it would help other if you could list the changes that you had to do and mark the thread as answered.

    Regards,
    Sujith
  • Hi Sujith,

    As we were using the back side of the ds90ub954 evm..we had to mount the 0 ohm resisters on the CSI data lines.
    Apart from that this is our following configuration for successful pattern generation.

    // deserializer configuration
    {0x4c, 0x0f, 0xf},
    {0x58, 0X5E, 0x2},
    {0x6D, 0x7C, 0x1}, /*CSI and coax mode*/
    {0x1f, 0x02, 0x1},
    {0x12, 0x13, 0x1},
    {0x32, 0x01, 0x1},
    {0x0C, 0x83, 0x1},
    {0x21, 0x04, 0x1}, // ---> round robin disabled and synchronous enabled
    {0x33, 0x01, 0x0},
    {0x20, 0x00, 0x1},
    {0x10, 0x59, 0x1},


    // For pattern Generation
    {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},

    Thanks,
    Swati