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.

TDA4AL-Q1: How to crop 8M to 2M, and How to put 2M yuv to CSITX1 ?

Part Number: TDA4AL-Q1

Dear TI expert,

        Our front camera is 8M. We need to output 8M YUV to the algorithm, and then need to crop the 8M YUV to 2M and output it to DVR through a deserializer. How to crop  8M YUV to 2M ,  and How to put 2M yuv to CSITX1? Thanks.

  • Hi,

    Cropping is simple operation, requiring just moving the start pointer into the image. So you dont require any HW module for cropping, you can just slightly change existing CSITX node to support it.. Yes, CSITX can support 2MP output.. 

    Regards,

    Brijesh

  • Dear Brijesh,

          The FOV requirements after cropping are the same as before. Thanks

           CSITX can support 2MP output. Is there any demo code can run? Thanks 

  • Hi daohong qin,

    There isn't any existing demo using CSITX in the SDK, because of EVM limitatios, but existing demo can easily be modified to support CSITX node. You would require to remove DSS node and replace it with CSITX node.

    Regards,

    Brijesh

  • Dear TI expert,

                  I have written a dome, which is sent by csitx0 using the picture on the SD card. The code runs normally, but I did not measure the waveform with the oscilloscope. Could you please help me check what is wrong with my code?

    /*
     *
     * Copyright (c) 2018 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 <stdio.h>
    #include <VX/vx.h>
    #include <TI/tivx.h>
    //#include <TI/j7.h>
    #include <TI/tivx_config.h>
    #include <string.h>
    #include <TI/tivx_task.h>
    #include <TI/tivx_event.h>
    #include "math.h"
    #include <limits.h>
    #include <utils/mem/include/app_mem.h>
    #include <tivx_utils_file_rd_wr.h>
    
    
    /* ========================================================================== */
    /*                                Macros                                      */
    /* ========================================================================== */
    #define MAX_NUM_BUF         (8u)
    #define CAPTURE_MIN_PIPEUP_BUFS (3u)
    
    #define NUM_CHANNELS        (1U)
    #define CSITX_INST_ID       (0U)
    
    /* For YUV DF */
    #define CSITX_FORMAT           (VX_DF_IMAGE_UYVY)
    
    #define TIVX_TARGET_DEFAULT_STACK_SIZE      (256U * 1024U)
    #define TIVX_TARGET_DEFAULT_TASK_PRIORITY1   (8u)
    
    #define IMAGE_3840x2160_30P_UYVY  "./test_data/img_viss_0002_uyvy.yuv"
    #define IMAGE_1920x1080_UYVY  "./test_data/Test_Chart_1920x1080_uyvy.yuv"
    #define IMAGE_1920x720_UYVY "./test_data/Test_Chart_1920x720_uyvy.yuv"
    
    #define IMAGE_POSI_START_X       0U
    #define IMAGE_POSI_START_Y       0U
    #define IMAGE_POSI_3840_2160_END_X     3840U
    #define IMAGE_POSI_3840_2160_END_Y     2160U
    #define IMAGE_POSI_1920_720_END_X     1920U
    #define IMAGE_POSI_1920_720_END_Y     720U
    
    /* ========================================================================== */
    /*                    Data Structure definition                               */
    /* ========================================================================== */
    typedef struct {
    
        /* interface argument */
        vx_user_data_object     csitx_config_obj;
        vx_object_array         csitx_frame_obj;
    
        /* init value */
        tivx_csitx_params_t     csitx_config;
        vx_image                csitx_image;
        tivx_raw_image          csitx_raw_image;
    
        /* OpenVX references */
        vx_context              context;
        vx_graph                graph;
        vx_node                 csitx_node;
    
        /* demo use only */
        uint32_t                num_buf;
        uint32_t                loop_cnt;
        
        uint32_t                is_interactive;
        uint32_t                stop_task;
        uint32_t                stop_task_done;
        tivx_task               task;
        
        vx_rectangle_t          rect;
    } AppCsitxObj;
    
    /* ========================================================================== */
    /*                    static variable definition                              */
    /* ========================================================================== */
    static AppCsitxObj gAppCsitxObj;
    static uint32_t    gTestNo;
    
    static char csitx_menu0[] = {
        "\n"
        "\n ==============================="
        "\n Demo : CSITX demo "
        "\n ==============================="
        "\n 1. 3840x2160@30P"
        "\n 2. 1920x1080@25P"
        "\n 3. 1920x 720@25P"
        "\n"
    };
    
    static char csitx_menu1[] = {
        "\n"
        "\n =========================="
        "\n Demo : CSITX demo "
        "\n =========================="
        "\n"
        "\n T: GET STATISTICS"
        "\n"
        "\n S: PRINT STATISTICS"
        "\n"
        "\n X: Exit the CSITX demo"
        "\n"
        "\n Enter Choice: "
    };
    
    /* ========================================================================== */
    /*                    static Function definition                              */
    /* ========================================================================== */
    /*
     * Utility API used to add a graph parameter from a node, node parameter index
     */
    static void add_graph_parameter_by_node_index(vx_graph graph, vx_node node, vx_uint32 node_parameter_index)
    {
        vx_parameter parameter = vxGetParameterByIndex(node, node_parameter_index);
    
        vxAddParameterToGraph(graph, parameter);
        vxReleaseParameter(&parameter);
    }
    
    static vx_status app_csitx_init(AppCsitxObj *obj)
    {
        vx_status status = VX_SUCCESS;
    
        obj->stop_task = 0;
        obj->stop_task_done = 0;
        obj->is_interactive = 1;
        gTestNo = 0xFF;
        
        VX_PRINT(VX_ZONE_INFO, "%s[%d] start to call vxCreateContext\n", __FUNCTION__, __LINE__);
        if(status == VX_SUCCESS)
        {
            obj->context = vxCreateContext();
            status = vxGetStatus((vx_reference) obj->context);
        }
        
        if(status == VX_SUCCESS)
        {
            VX_PRINT(VX_ZONE_INFO, "%s[%d] start to call tivxHwaLoadKernels\n", __FUNCTION__, __LINE__);
            tivxHwaLoadKernels(obj->context);
            VX_PRINT(VX_ZONE_INFO, "tivxHwaLoadKernels done\n");
        }
    
        /* init the config parameters of obj */
        
        printf(csitx_menu0);
        gTestNo = getchar();
        printf("\n");
    
        return status;
    }
    
    static vx_status app_csitx_deinit(AppCsitxObj *obj)
    {
        vx_status status = VX_FAILURE;
    
        tivxHwaUnLoadKernels(obj->context);
    
        status = vxReleaseContext(&obj->context);
        if(VX_SUCCESS != status)
        {
            VX_PRINT(VX_ZONE_ERROR,"Error: vxReleaseContext returned 0x%x \n", status);
        }
        
        tivx_clr_debug_zone(VX_ZONE_INFO);
    
        return status;
    }
    
    vx_status app_csitx_load_vximage_from_yuvfile(vx_image image, char *filename)
    {
        vx_status  vxStatus = (vx_status)VX_SUCCESS;
    
        vx_rectangle_t             rect;
        vx_imagepatch_addressing_t image_addr;
        vx_map_id                  map_id;
        void                     * data_ptr;
        vx_uint32                  img_width;
        vx_uint32                  img_height;
        vx_df_image                img_format;
        vx_int32                   j;
    
        FILE *fp= fopen(filename, "rb");
        if(fp==NULL)
        {
            VX_PRINT(VX_ZONE_ERROR, "# ERROR: Unable to open input file [%s]\n", filename);
            return(VX_FAILURE);
        }
        else
        {
            VX_PRINT(VX_ZONE_INFO, "opened the file [%s]\n", filename);
        }
    
        vxQueryImage(image, VX_IMAGE_WIDTH, &img_width, sizeof(vx_uint32));
        vxQueryImage(image, VX_IMAGE_HEIGHT, &img_height, sizeof(vx_uint32));
        vxQueryImage(image, VX_IMAGE_FORMAT, &img_format, sizeof(vx_df_image));
        VX_PRINT(VX_ZONE_INFO, "img_width = %d \timg_height = %d \timg_format = %c%c%c%c\n", img_width, img_height, (uint8_t)(img_format&0x000000FF), (uint8_t)((img_format & 0x0000FF00)>> 8), (uint8_t)((img_format & 0x00FF0000)>> 16), (uint8_t)((img_format & 0xFF000000)>> 24));
        rect.start_x = 0;
        rect.start_y = 0;
        rect.end_x = img_width;
        rect.end_y = img_height;
    
        // Copy Luma or Luma+Chroma
        vxStatus = vxMapImagePatch(image,
                                   &rect,
                                   0,
                                   &map_id,
                                   &image_addr,
                                   &data_ptr,
                                   VX_WRITE_ONLY,
                                   VX_MEMORY_TYPE_HOST,
                                   VX_NOGAP_X);
    
        VX_PRINT(VX_ZONE_INFO, "dim_x = %d \tdim_y = %d \tstride_x = %d \tstride_y = %d\n", image_addr.dim_x, image_addr.dim_y, image_addr.stride_x, image_addr.stride_y);
        for (j = 0; j < image_addr.dim_y; j++)
        {
            fread(data_ptr, 1, image_addr.dim_x*image_addr.stride_x, fp);
            data_ptr += image_addr.stride_y;
        }
        vxUnmapImagePatch(image, map_id);
    
        fclose(fp);
        return vxStatus;
    }
    
    static vx_status app_csitx_create_graph_3840_2160_30P(AppCsitxObj *obj)
    {
        vx_status                   status = VX_SUCCESS;
        uint32_t                    frmIdx = 0;
        uint32_t                    loopCnt = 0;
        vx_image                    tx_frame_array_item = NULL;
    
        VX_PRINT(VX_ZONE_INFO, "Creating graph \n");
        /* Create graph */
        obj->graph = vxCreateGraph(obj->context);
        if(status == VX_SUCCESS)
        {
            VX_PRINT(VX_ZONE_INFO, "Creating graph done\n");
            status = vxGetStatus((vx_reference) obj->graph);
        }
        
        obj->rect.start_x = IMAGE_POSI_START_X;
        obj->rect.start_y = IMAGE_POSI_START_Y;
        obj->rect.end_x = IMAGE_POSI_3840_2160_END_X;
        obj->rect.end_y = IMAGE_POSI_3840_2160_END_Y;
    
        /* set init value of all parameters */
        obj->csitx_image = vxCreateImage(obj->context, obj->rect.end_x, obj->rect.end_y, CSITX_FORMAT);
        if (obj->csitx_image == NULL)
        {
            VX_PRINT(VX_ZONE_ERROR, "%s[%d]csitx_image create failed\n", __FUNCTION__, __LINE__);
        }
    
        /* create the parameter list */
        /* allocate Input and Output refs*/
        obj->csitx_frame_obj = vxCreateObjectArray(obj->context, (vx_reference)obj->csitx_image, NUM_CHANNELS);
        if (obj->csitx_frame_obj == NULL)
        {
            VX_PRINT(VX_ZONE_ERROR, "%s[%d] csitx_frame_obj create failed\n", __FUNCTION__, __LINE__);
        }
    
        /* this is currently supported for UYVY formats only */
        /* initialization of frames for each channel with unique pattern
           it is (channel no. + x) */
        VX_PRINT(VX_ZONE_INFO,"Initializing Transmit Buffers...\n");
        for (frmIdx = 0U ; frmIdx < NUM_CHANNELS ; frmIdx++)
        {
            tx_frame_array_item = (vx_image)vxGetObjectArrayItem(obj->csitx_frame_obj , frmIdx);
            if (tx_frame_array_item == NULL)
            {
                VX_PRINT(VX_ZONE_ERROR,"%s[%d]vx_frame_array_item create failed\n", __FUNCTION__, __LINE__);
            }
            else
            {
                VX_PRINT(VX_ZONE_INFO, "vxGetObjectArrayItem success\n");
            }
            app_csitx_load_vximage_from_yuvfile(tx_frame_array_item, IMAGE_3840x2160_30P_UYVY);
            status = vxReleaseImage(&tx_frame_array_item);
            if(status != VX_SUCCESS)
            {
                VX_PRINT(VX_ZONE_ERROR, "%s[%d] tx_frame_array_item Release failed\n", __FUNCTION__, __LINE__);
            }
        }
        VX_PRINT(VX_ZONE_INFO, "Initializing Transmit Buffers Done.\n");
    
        /* CSITX Config initialization */
        tivx_csitx_params_init(&obj->csitx_config);
        obj->csitx_config.numInst                          = 1U;
        obj->csitx_config.numCh                            = NUM_CHANNELS;
        obj->csitx_config.instId[0U]                       = CSITX_INST_ID;
        obj->csitx_config.instCfg[0U].rxCompEnable         = (uint32_t)vx_true_e;
        obj->csitx_config.instCfg[0U].rxv1p3MapEnable      = (uint32_t)vx_true_e;
        obj->csitx_config.instCfg[0U].laneBandSpeed        = TIVX_CSITX_LANE_BAND_SPEED_120_TO_160_MBPS;
        obj->csitx_config.instCfg[0U].numDataLanes         = 4U;
        for (loopCnt = 0U ;
            loopCnt < obj->csitx_config.instCfg[0U].numDataLanes ;
            loopCnt++)
        {
            obj->csitx_config.instCfg[0U].lanePolarityCtrl[loopCnt] = 0u;
        }
        for (loopCnt = 0U; loopCnt < NUM_CHANNELS; loopCnt++)
        {
            obj->csitx_config.chVcNum[loopCnt]   = loopCnt;
            obj->csitx_config.chInstMap[loopCnt] = CSITX_INST_ID;
        }
    
        VX_PRINT(VX_ZONE_INFO, "start to call vxCreateUserDataObject\n");
        obj->csitx_config_obj = vxCreateUserDataObject(obj->context, "tivx_csitx_params_t", sizeof(tivx_csitx_params_t), &obj->csitx_config);
        if (obj->csitx_config_obj == NULL)
        {
            VX_PRINT(VX_ZONE_ERROR, "%s[%d] csitx_config create failed\n", __FUNCTION__, __LINE__);
        }
        
        VX_PRINT(VX_ZONE_INFO, "Start to call tivxCsitxNode\n");
        obj->csitx_node = tivxCsitxNode(obj->graph, obj->csitx_config_obj, obj->csitx_frame_obj);
        if (obj->csitx_node == NULL)
        {
            VX_PRINT(VX_ZONE_ERROR, "%s[%d] csitx_node create failed\n", __FUNCTION__, __LINE__);
        }
    
        VX_PRINT(VX_ZONE_INFO, "Start to call vxSetNodeTarget\n");
        status = vxSetNodeTarget(obj->csitx_node, VX_TARGET_STRING, TIVX_TARGET_CSITX);
        if (status != VX_SUCCESS)
        {
            VX_PRINT(VX_ZONE_ERROR, "%s[%d] TIVX_TARGET_CSITX set failed\n", __FUNCTION__, __LINE__);
        }
    
        /* input @ node index 0, becomes csitx_graph parameter 1 */
        VX_PRINT(VX_ZONE_INFO, "Start to call add_graph_parameter_by_node_index\n");
        add_graph_parameter_by_node_index(obj->graph, obj->csitx_node, 1);
    
        VX_PRINT(VX_ZONE_INFO, "Start to run vxVerifyGraph\n");
        status = vxVerifyGraph(obj->graph);
        if (status != VX_SUCCESS)
        {
            VX_PRINT(VX_ZONE_ERROR, "%s[%d] csitx_graph verified failed\n", __FUNCTION__, __LINE__);
        }
    
        VX_PRINT(VX_ZONE_INFO, "app_create_graph exiting\n");
        return status;
    }
    
    static vx_status app_csitx_create_graph_1920_1080_25P(AppCsitxObj *obj)
    {
        vx_status                   status = VX_SUCCESS;
        uint32_t                    frmIdx = 0;
        uint32_t                    loopCnt = 0;
    
        vx_image                    tx_frame_array_item = NULL;
    
        VX_PRINT(VX_ZONE_INFO, "Creating graph \n");
        /* Create graph */
        obj->graph = vxCreateGraph(obj->context);
        if(status == VX_SUCCESS)
        {
            VX_PRINT(VX_ZONE_INFO, "Creating graph done\n");
            status = vxGetStatus((vx_reference) obj->graph);
        }
        
        obj->rect.start_x = IMAGE_POSI_START_X;
        obj->rect.start_y = IMAGE_POSI_START_Y;
        obj->rect.end_x = IMAGE_POSI_3840_2160_END_X;
        obj->rect.end_y = IMAGE_POSI_3840_2160_END_Y;
    
        /* set init value of all parameters */
        obj->csitx_image = vxCreateImage(obj->context, obj->rect.end_x, obj->rect.end_y, CSITX_FORMAT);
        if (obj->csitx_image == NULL)
        {
            VX_PRINT(VX_ZONE_ERROR, "%s[%d]csitx_image cretae failed\n", __FUNCTION__, __LINE__);
        }
    
        /* create the parameter list */
        /* allocate Input and Output refs*/
        obj->csitx_frame_obj = vxCreateObjectArray(obj->context, (vx_reference)obj->csitx_image, NUM_CHANNELS);
        if (obj->csitx_frame_obj == NULL)
        {
            VX_PRINT(VX_ZONE_ERROR, "%s[%d] csitx_frame_obj create failed\n", __FUNCTION__, __LINE__);
        }
    
        /* this is currently supported for UYVY formats only */
        /* initialization of frames for each channel with unique pattern
           it is (channel no. + x) */
        VX_PRINT(VX_ZONE_INFO,"Initializing Transmit Buffers...\n");
        for (frmIdx = 0U ; frmIdx < NUM_CHANNELS ; frmIdx++)
        {
            tx_frame_array_item = (vx_image)vxGetObjectArrayItem(obj->csitx_frame_obj , frmIdx);
            if (tx_frame_array_item == NULL)
            {
                VX_PRINT(VX_ZONE_ERROR,"%s[%d]vx_frame_array_item create failed\n", __FUNCTION__, __LINE__);
            }
            else
            {
                VX_PRINT(VX_ZONE_INFO, "vxGetObjectArrayItem success\n");
            }
    
            app_csitx_load_vximage_from_yuvfile(tx_frame_array_item, IMAGE_1920x1080_UYVY);
            status = vxReleaseImage(&tx_frame_array_item);
            if(status != VX_SUCCESS)
            {
                VX_PRINT(VX_ZONE_ERROR, "%s[%d] tx_frame_array_item Release failed\n", __FUNCTION__, __LINE__);
            }
        }
        VX_PRINT(VX_ZONE_INFO, "Initializing Transmit Buffers Done.\n");
    
        /* CSITX Config initialization */
        tivx_csitx_params_init(&obj->csitx_config);
        obj->csitx_config.numInst                          = 1U;
        obj->csitx_config.numCh                            = NUM_CHANNELS;
        obj->csitx_config.instId[0U]                       = CSITX_INST_ID;
        obj->csitx_config.instCfg[0U].rxCompEnable         = (uint32_t)vx_true_e;
        obj->csitx_config.instCfg[0U].rxv1p3MapEnable      = (uint32_t)vx_true_e;
        obj->csitx_config.instCfg[0U].laneBandSpeed        = TIVX_CSITX_LANE_BAND_SPEED_1000_TO_1200_MBPS;
        obj->csitx_config.instCfg[0U].numDataLanes         = 4U;
        for (loopCnt = 0U ;
            loopCnt < obj->csitx_config.instCfg[0U].numDataLanes ;
            loopCnt++)
        {
            obj->csitx_config.instCfg[0U].lanePolarityCtrl[loopCnt] = 0u;
        }
        for (loopCnt = 0U; loopCnt < NUM_CHANNELS; loopCnt++)
        {
            obj->csitx_config.chVcNum[loopCnt]   = loopCnt;
            obj->csitx_config.chInstMap[loopCnt] = CSITX_INST_ID;
        }
    
        VX_PRINT(VX_ZONE_INFO, "start to call vxCreateUserDataObject\n");
        obj->csitx_config_obj = vxCreateUserDataObject(obj->context, "tivx_csitx_params_t", sizeof(tivx_csitx_params_t), &obj->csitx_config);
        if (obj->csitx_config_obj == NULL)
        {
            VX_PRINT(VX_ZONE_ERROR, "%s[%d] csitx_config create failed\n", __FUNCTION__, __LINE__);
        }
        
        VX_PRINT(VX_ZONE_INFO, "Start to call tivxCsitxNode\n");
        obj->csitx_node = tivxCsitxNode(obj->graph, obj->csitx_config_obj, obj->csitx_frame_obj);
        if (obj->csitx_node == NULL)
        {
            VX_PRINT(VX_ZONE_ERROR, "%s[%d] csitx_node create failed\n", __FUNCTION__, __LINE__);
        }
    
        VX_PRINT(VX_ZONE_INFO, "Start to call vxSetNodeTarget\n");
        status = vxSetNodeTarget(obj->csitx_node, VX_TARGET_STRING, TIVX_TARGET_CSITX);
        if (status != VX_SUCCESS)
        {
            VX_PRINT(VX_ZONE_ERROR, "%s[%d] TIVX_TARGET_CSITX set failed\n", __FUNCTION__, __LINE__);
        }
    
        /* input @ node index 0, becomes csitx_graph parameter 1 */
        VX_PRINT(VX_ZONE_INFO, "Start to call add_graph_parameter_by_node_index\n");
        add_graph_parameter_by_node_index(obj->graph, obj->csitx_node, 1);
    
        VX_PRINT(VX_ZONE_INFO, "Start to run vxVerifyGraph\n");
        status = vxVerifyGraph(obj->graph);
        if (status != VX_SUCCESS)
        {
            VX_PRINT(VX_ZONE_ERROR, "%s[%d] csitx_graph verified failed\n", __FUNCTION__, __LINE__);
        }
    
        VX_PRINT(VX_ZONE_INFO, "app_create_graph exiting\n");
        return status;
    }
    static vx_status app_csitx_create_graph_1920_0720_25P(AppCsitxObj *obj)
    {
        vx_status                   status = VX_SUCCESS;
        uint32_t                    frmIdx = 0;
        uint32_t                    loopCnt = 0;
        vx_image                    tx_frame_array_item = NULL;
    
        VX_PRINT(VX_ZONE_INFO, "Creating graph \n");
        /* Create graph */
        obj->graph = vxCreateGraph(obj->context);
        if(status == VX_SUCCESS)
        {
            VX_PRINT(VX_ZONE_INFO, "Creating graph done\n");
            status = vxGetStatus((vx_reference) obj->graph);
        }
        
        obj->rect.start_x = IMAGE_POSI_START_X;
        obj->rect.start_y = IMAGE_POSI_START_Y;
        obj->rect.end_x = IMAGE_POSI_1920_720_END_X;
        obj->rect.end_y = IMAGE_POSI_1920_720_END_Y;
    
        /* set init value of all parameters */
        obj->csitx_image = vxCreateImage(obj->context, obj->rect.end_x, obj->rect.end_y, CSITX_FORMAT);
        if (obj->csitx_image == NULL)
        {
            VX_PRINT(VX_ZONE_ERROR, "%s[%d]csitx_image cretae failed\n", __FUNCTION__, __LINE__);
        }
    
        /* create the parameter list */
        /* allocate Input and Output refs*/
        obj->csitx_frame_obj = vxCreateObjectArray(obj->context, (vx_reference)obj->csitx_image, NUM_CHANNELS);
        if (obj->csitx_frame_obj == NULL)
        {
            VX_PRINT(VX_ZONE_ERROR, "%s[%d] csitx_frame_obj create failed\n", __FUNCTION__, __LINE__);
        }
    
        /* this is currently supported for UYVY formats only */
        /* initialization of frames for each channel with unique pattern
           it is (channel no. + x) */
        VX_PRINT(VX_ZONE_INFO,"Initializing Transmit Buffers...\n");
        for (frmIdx = 0U ; frmIdx < NUM_CHANNELS ; frmIdx++)
        {
            tx_frame_array_item = (vx_image)vxGetObjectArrayItem(obj->csitx_frame_obj , frmIdx);
            if (tx_frame_array_item == NULL)
            {
                VX_PRINT(VX_ZONE_ERROR,"%s[%d]vx_frame_array_item create failed\n", __FUNCTION__, __LINE__);
            }
            else
            {
                VX_PRINT(VX_ZONE_INFO, "vxGetObjectArrayItem success\n");
            }
            app_csitx_load_vximage_from_yuvfile(tx_frame_array_item, IMAGE_1920x720_UYVY);
            status = vxReleaseImage(&tx_frame_array_item);
            if(status != VX_SUCCESS)
            {
                VX_PRINT(VX_ZONE_ERROR, "%s[%d] tx_frame_array_item Release failed\n", __FUNCTION__, __LINE__);
            }
        }
        VX_PRINT(VX_ZONE_INFO, "Initializing Transmit Buffers Done.\n");
    
        /* CSITX Config initialization */
        tivx_csitx_params_init(&obj->csitx_config);
        obj->csitx_config.numInst                          = 1U;
        obj->csitx_config.numCh                            = NUM_CHANNELS;
        obj->csitx_config.instId[0U]                       = CSITX_INST_ID;
        obj->csitx_config.instCfg[0U].rxCompEnable         = (uint32_t)vx_true_e;
        obj->csitx_config.instCfg[0U].rxv1p3MapEnable      = (uint32_t)vx_true_e;
        obj->csitx_config.instCfg[0U].laneBandSpeed        = TIVX_CSITX_LANE_BAND_SPEED_80_TO_100_MBPS;
        obj->csitx_config.instCfg[0U].numDataLanes         = 4U;
        for (loopCnt = 0U;
            loopCnt < obj->csitx_config.instCfg[0U].numDataLanes ;
            loopCnt++)
        {
            obj->csitx_config.instCfg[0U].lanePolarityCtrl[loopCnt] = 0u;
        }
        for (loopCnt = 0U; loopCnt < NUM_CHANNELS; loopCnt++)
        {
            obj->csitx_config.chVcNum[loopCnt]   = loopCnt;
            obj->csitx_config.chInstMap[loopCnt] = CSITX_INST_ID;
        }
    
        VX_PRINT(VX_ZONE_INFO, "start to call vxCreateUserDataObject\n");
        obj->csitx_config_obj = vxCreateUserDataObject(obj->context, "tivx_csitx_params_t", sizeof(tivx_csitx_params_t), &obj->csitx_config);
        if (obj->csitx_config_obj == NULL)
        {
            VX_PRINT(VX_ZONE_ERROR, "%s[%d] csitx_config create failed\n", __FUNCTION__, __LINE__);
        }
        
        VX_PRINT(VX_ZONE_INFO, "Start to call tivxCsitxNode\n");
        obj->csitx_node = tivxCsitxNode(obj->graph, obj->csitx_config_obj, obj->csitx_frame_obj);
        if (obj->csitx_node == NULL)
        {
            VX_PRINT(VX_ZONE_ERROR, "%s[%d] csitx_node create failed\n", __FUNCTION__, __LINE__);
        }
    
        VX_PRINT(VX_ZONE_INFO, "Start to call vxSetNodeTarget\n");
        status = vxSetNodeTarget(obj->csitx_node, VX_TARGET_STRING, TIVX_TARGET_CSITX);
        if (status != VX_SUCCESS)
        {
            VX_PRINT(VX_ZONE_ERROR, "%s[%d] TIVX_TARGET_CSITX set failed\n", __FUNCTION__, __LINE__);
        }
    
        /* input @ node index 0, becomes csitx_graph parameter 1 */
        VX_PRINT(VX_ZONE_INFO, "Start to call add_graph_parameter_by_node_index\n");
        add_graph_parameter_by_node_index(obj->graph, obj->csitx_node, 1);
    
        VX_PRINT(VX_ZONE_INFO, "Start to run vxVerifyGraph\n");
        status = vxVerifyGraph(obj->graph);
        if (status != VX_SUCCESS)
        {
            VX_PRINT(VX_ZONE_ERROR, "%s[%d] csitx_graph verified failed\n", __FUNCTION__, __LINE__);
        }
    
        VX_PRINT(VX_ZONE_INFO, "app_create_graph exiting\n");
        return status;
    }
    
    static vx_status app_csitx_delete_graph(AppCsitxObj *obj)
    {
        vx_status status = VX_SUCCESS;
    
        status = vxReleaseImage(&obj->csitx_image);
        if (status != VX_SUCCESS)
        {
            VX_PRINT(VX_ZONE_ERROR, "%s[%d] csitx_image_exemplar Release failed\n", __FUNCTION__, __LINE__);
        }
        
        status = vxReleaseGraph(&obj->graph);
        if (status != VX_SUCCESS)
        {
            VX_PRINT(VX_ZONE_ERROR, "%s[%d] csitx_graph Release failed\n", __FUNCTION__, __LINE__);
        }
        VX_PRINT(VX_ZONE_INFO, "releasing graph done\n");
    
        return status;
    }
    
    static vx_status app_csitx_run_graph(AppCsitxObj *obj)
    {
        vx_status status = VX_SUCCESS;
    
        do{
            vxProcessGraph(obj->graph);
        }while(obj->stop_task != 1);
    
        return status;
    }
    
    static void app_csitx_run_task(void *app_var)
    {
        AppCsitxObj *obj = (AppCsitxObj *)app_var;
    
        app_csitx_run_graph(obj);
    
        obj->stop_task_done = 1;
    }
    
    static int32_t app_csitx_run_task_create(AppCsitxObj *obj)
    {
        tivx_task_create_params_t taskParams_csitx;
        int32_t status;
    
        tivxTaskSetDefaultCreateParams(&taskParams_csitx);
        taskParams_csitx.task_main = &app_csitx_run_task;
        taskParams_csitx.app_var = obj;
        taskParams_csitx.stack_ptr = NULL;
        taskParams_csitx.stack_size = TIVX_TARGET_DEFAULT_STACK_SIZE;
        taskParams_csitx.core_affinity = TIVX_TASK_AFFINITY_ANY;
        taskParams_csitx.priority = TIVX_TARGET_DEFAULT_TASK_PRIORITY1;
        //Create Csitx Tasks
        status = tivxTaskCreate(&obj->task, &taskParams_csitx);
        if (status != VX_SUCCESS)
        {
            VX_PRINT(VX_ZONE_ERROR, "%s[%d] taskHandle_csitx cretae failed\n", __FUNCTION__, __LINE__);
        }
        
        obj->stop_task_done = 0;
        obj->stop_task = 0;
    
        return status;
    }
    
    static void app_csitx_run_task_delete(AppCsitxObj *obj)
    {
        while(obj->stop_task_done==0)
        {
             tivxTaskWaitMsecs(100);
        }
    
        tivxTaskDelete(&obj->task);
    }
    
    static vx_status app_csitx_run_graph_interactive(AppCsitxObj *obj)
    {
        vx_status status;
        uint32_t done = 0;
        char ch;
    
        //FILE *fp;
        //app_perf_point_t *perf_arr[1];
    
        status = app_csitx_run_task_create(obj);
        if(status!=0)
        {
            VX_PRINT(VX_ZONE_ERROR, "ERROR: Unable to create task\n");
        }
        else
        {
            while(!done && (status == VX_SUCCESS))
            {
                printf(csitx_menu1);
                ch = getchar();
                printf("\n");
    
                switch(ch)
                {
                    case 'T':
                    case 't':
                        {
                            vx_reference refs[2];
    
                            VX_PRINT(VX_ZONE_INFO, "Start to send cmd:TIVX_CSITX_GET_STATISTICS\n");
                            refs[0] = (vx_reference )obj->csitx_config_obj;
                            refs[1] = (vx_reference )obj->csitx_frame_obj;
    
                            status = tivxNodeSendCommand(obj->csitx_node, 0u, TIVX_CSITX_GET_STATISTICS , refs, 2u);
                        }
                        break;
                    case 'S':
                    case 's':
                        {
                            vx_reference refs[2];
    
                            VX_PRINT(VX_ZONE_INFO, "Start to send cmd:TIVX_CSITX_PRINT_STATISTICS\n");
                            refs[0] = (vx_reference )obj->csitx_config_obj;
                            refs[1] = (vx_reference )obj->csitx_frame_obj;
    
                            status = tivxNodeSendCommand(obj->csitx_node, 0u, TIVX_CSITX_PRINT_STATISTICS, refs, 2u);
                        }
                        break;
                    case 'X':
                    case 'x':
                        VX_PRINT(VX_ZONE_INFO,"Start to exit the demo\n", ch);
    					obj->stop_task = 1;
                        done = 1;
                        break;
    
                    case '\n':
                        ch = 0;
                        break;
    
                    default:
                        VX_PRINT(VX_ZONE_ERROR,"Unsupported command %c\n", ch);
                        break;
    
                }
                VX_PRINT(VX_ZONE_INFO, "Msg send finished\n");
            }
            app_csitx_run_task_delete(obj);
        }
    
        return status;
    }
    
    int app_csitx_main(void)
    {
        AppCsitxObj *obj = &gAppCsitxObj;
        vx_status status = VX_FAILURE;
    
        tivx_set_debug_zone(VX_ZONE_INFO);
        VX_PRINT(VX_ZONE_INFO, "%s[%d] Start to call app_init\n", __FUNCTION__, __LINE__);
        status = app_csitx_init(obj);
        if(VX_SUCCESS == status)
        {
            VX_PRINT(VX_ZONE_INFO, "app_init done\n");
            /* Not checking status because application may be waiting for
                error/test frame */
            switch(gTestNo)
            {
                case '0':
     //               status = app_test_share_mem();
                    printf("error\n");
                    break;
                case '1':
                    status = app_csitx_create_graph_3840_2160_30P(obj);
                    break;
                case '2':
                    status = app_csitx_create_graph_1920_1080_25P(obj);
                    break;
                case '3':
                    status = app_csitx_create_graph_1920_0720_25P(obj);
                    break;
                case '4':
    //                app_csitx_create_graph_1920_1080_30P_PipeLine(obj);
    //                status = VX_FAILURE;
    //               print_error();
                    printf("error\n");
                    break;
                default:
                    VX_PRINT(VX_ZONE_ERROR, "Test case No wrong\n");
                    status = VX_FAILURE;
                    break;
            }
            
            if(VX_SUCCESS == status)
            {
                VX_PRINT(VX_ZONE_INFO, "app_create_graph done\n");
                if(obj->is_interactive)
                {
                    status = app_csitx_run_graph_interactive(obj);
                }
                else
                {
                    status = app_csitx_run_graph(obj);
                }
                if(VX_SUCCESS == status)
                {
                    VX_PRINT(VX_ZONE_INFO, "app_run_graph done\n");
                    status = app_csitx_delete_graph(obj);
                    if(VX_SUCCESS == status)
                    {
                        VX_PRINT(VX_ZONE_INFO, "app_delete_graph done\n");
                    }
                    else
                    {
                        VX_PRINT(VX_ZONE_ERROR, "Error : app_delete_graph returned 0x%x \n", status);
                    }
                }
                else
                {
                    VX_PRINT(VX_ZONE_ERROR, "Error : app_run_graph_xx returned 0x%x \n", status);
                }
            }
            else
            {
                VX_PRINT(VX_ZONE_ERROR, "Error : app_create_graph returned 0x%x is_interactive =%d  \n", status, obj->is_interactive);
            }
        }
        else
        {
            VX_PRINT(VX_ZONE_ERROR, "Error : app_init returned 0x%x \n", status);
        }
        status = app_csitx_deinit(obj);
        if(VX_SUCCESS == status)
        {
            VX_PRINT(VX_ZONE_INFO, "app_deinit done\n");
        }
        else
        {
            VX_PRINT(VX_ZONE_ERROR, "Error : app_deinit returned 0x%x \n", status);
        }
    
        return status;
    }
    
    
    

  • Hi daohong qin,

    The application looks to be fine. what's the issue are you facing with it? it is just creating graph and verifying it and then running this graph. There is no cropping involved here in this graph or in the CSITX node. What exactly issue are you facing with this application?

    Regards,

    Brijesh

  • Dear TI expert,

            Does the IMAGE format of csitx need must be VX_DF_IMAGE_YUYV? I tried to configure it in VX_DF_IMAGE_NV21 format, but the software would report an error, the log as belows:VX_ZONE_ERROR:[ownCopyAndMapCheckParams:523] image is not valid

  • Hi daohong qin,

    Yes, For YUV format, it must be set to YUV422 ie UYVY or YUYV. YUV420 format ie NV12 is not supported on CSITX. 

    Regards,

    Brijesh

  • /*
     *
     * Copyright (c) 2018 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 "app_single_cam_main.h"
    #include <utils/iss/include/app_iss.h>
    #include "app_test.h"
    
    #ifdef A72
    #if defined(LINUX)
    /*ITT server is supported only in target mode and only on Linux*/
    #include <itt_server.h>
    #endif
    #endif
    
    static char availableSensorNames[ISS_SENSORS_MAX_SUPPORTED_SENSOR][ISS_SENSORS_MAX_NAME];
    static vx_uint8 num_sensors_found;
    static IssSensor_CreateParams sensorParams;
    IssNhhwinfo_hil_mode_t hilModeInfo;
    
    #define VX_CALL(fn_call) fn_call
    #define VX_CALL_(ret_code, fn_call) fn_call
    #define VX_CALL_RET(fn_call) fn_call
    
    #define NUM_CAPT_CHANNELS   (4u)
    
    #define CSITX_WDP (0)
    #define CSITX_NODE_W (1)
    #define CSITX_FORMAT           (VX_DF_IMAGE_YUYV)
    #define NUM_CHANNELS (1)
    #define CSITX_INST_ID       (0U)
    #define CAPT_INST_ID        (0U)
    
    #define CSITX_LANE_BAND_SPEED       (TIVX_CSITX_LANE_BAND_SPEED_1200_TO_1400_MBPS)
    #define CSITX_LANE_SPEED_MBPS       (800U)
    
    #if (CSITX_NODE_W == 1U)
    
    typedef struct {
        vx_node  csitx_node;
        vx_user_data_object csitx_params_obj;
        tivx_display_params_t csitx_params;
        vx_int32 csitx_option;
        vx_int32 graph_parameter_index;
        vx_char objName[512];
    
    } CsiTxObj;
    
    CsiTxObj gCsiTxObj;
    static vx_int32 csitx_index;
    static vx_object_array tx_frame = 0;
    static vx_user_data_object csitx_config;
    static tivx_csitx_params_t local_csitx_config;
    static uint32_t  loopCnt;
    static vx_node csitx_node = 0;
    //static uint32_t num_refs;
    #endif  
    
    #ifdef _APP_DEBUG_
    static char *app_get_test_file_path()
    {
        char *tivxPlatformGetEnv(char *env_var);
    
        #if defined(SYSBIOS)
        return tivxPlatformGetEnv("VX_TEST_DATA_PATH");
        #else
        return getenv("VX_TEST_DATA_PATH");
        #endif
    }
    #endif //_APP_DEBUG_
    
    /*
     * Utility API used to add a graph parameter from a node, node parameter index
     */
    void add_graph_parameter_by_node_index(vx_graph graph, vx_node node, vx_uint32 node_parameter_index)
    {
        vx_parameter parameter = vxGetParameterByIndex(node, node_parameter_index);
    
        vxAddParameterToGraph(graph, parameter);
        vxReleaseParameter(&parameter);
    }
    
    vx_status app_init(AppObj *obj)
    {
        vx_status status = VX_SUCCESS;
        char* sensor_list[ISS_SENSORS_MAX_SUPPORTED_SENSOR];
        vx_uint8 count = 0;
        char ch = 0xFF;
        vx_uint8 selectedSensor = 0xFF;
        vx_uint8 detectedSensors[ISS_SENSORS_MAX_CHANNEL];
    #ifdef A72
    #if defined(LINUX)
    /*ITT server is supported only in target mode and only on Linux*/
        status = itt_server_init((void*)obj, (void*)save_debug_images, (void*)appSingleCamUpdateVpacDcc);
        if(status != 0)
        {
            printf("Warning : Failed to initialize ITT server. Live tuning will not work \n");
        }
    #endif
    #endif
    
        for(count=0;count<ISS_SENSORS_MAX_CHANNEL;count++)
        {
            detectedSensors[count] = 0xFF;
        }
    
        for(count=0;count<ISS_SENSORS_MAX_SUPPORTED_SENSOR;count++)
        {
            sensor_list[count] = NULL;
        }
    
        obj->stop_task = 0;
        obj->stop_task_done = 0;
        obj->selectedCam = 0xFF;
    
        if(status == VX_SUCCESS)
        {
            obj->context = vxCreateContext();
            status = vxGetStatus((vx_reference) obj->context);
        }
    
        if(status == VX_SUCCESS)
        {
            tivxHwaLoadKernels(obj->context);
            tivxImagingLoadKernels(obj->context);
            APP_PRINTF("tivxImagingLoadKernels done\n");
        }
    
        /*memset(availableSensorNames, 0, ISS_SENSORS_MAX_SUPPORTED_SENSOR*ISS_SENSORS_MAX_NAME);*/
        for(count=0;count<ISS_SENSORS_MAX_SUPPORTED_SENSOR;count++)
        {
            availableSensorNames[count][0] = '\0';
            sensor_list[count] = availableSensorNames[count];
        }
    
        if(status == VX_SUCCESS)
        {
            status = appEnumerateImageSensor(sensor_list, &num_sensors_found);
        }
    
        if(obj->is_interactive)
        {
            selectedSensor = 0xFF;
            obj->selectedCam = 0xFF;
            while(obj->selectedCam == 0xFF)
            {
                printf("Select camera port index 0-%d : ", ISS_SENSORS_MAX_CHANNEL-1);
                ch = getchar();
                obj->selectedCam = ch - '0';
    
                if(obj->selectedCam >= ISS_SENSORS_MAX_CHANNEL)
                {
                    printf("Invalid entry %c. Please choose between 0 and %d \n", ch, ISS_SENSORS_MAX_CHANNEL-1);
                    obj->selectedCam = 0xFF;
                }
    
                while ((obj->selectedCam != 0xFF) && (selectedSensor > (num_sensors_found-1)))
                {
                    printf("%d registered sensor drivers\n", num_sensors_found);
                    for(count=0;count<num_sensors_found;count++)
                    {
                        printf("%c : %s \n", count+'a', sensor_list[count]);
                    }
    
                    printf("Select a sensor above or press '0' to autodetect the sensor : ");
                    ch = getchar();
                    if(ch == '0')
                    {
                        uint8_t num_sensors_detected = 0;
                        uint8_t channel_mask = (1<<obj->selectedCam);
    
                        status = appDetectImageSensor(detectedSensors, &num_sensors_detected, channel_mask);
                        if(0 == status)
                        {
                            selectedSensor = detectedSensors[obj->selectedCam];
                            if(selectedSensor > ISS_SENSORS_MAX_SUPPORTED_SENSOR)
                            {
                                printf("No sensor detected at port %d. Please select another port \n", obj->selectedCam);
                                obj->selectedCam = 0xFF;
                                selectedSensor = 0xFF;
                            }
                        }
                        else
                        {
                            printf("sensor detection at port %d returned error . Please try again \n", obj->selectedCam);
                            obj->selectedCam = 0xFF;
                            selectedSensor = 0xFF;
                        }
                    }
                    else
                    {
                        selectedSensor = ch - 'a';
                        if(selectedSensor > (num_sensors_found-1))
                        {
                            printf("Invalid selection %c. Try again \n", ch);
                        }
                    }
                }
            }
    
            obj->sensor_name = sensor_list[selectedSensor];
            printf("Sensor selected : %s\n", obj->sensor_name);
    
            ch = 0xFF;
            fflush (stdin);
            while ((ch != '0') && (ch != '1'))
            {
                fflush (stdin);
                printf ("LDC Selection Yes(1)/No(0) : ");
                ch = getchar();
            }
    
            obj->ldc_enable = ch - '0';
        }
        else
        {
            selectedSensor = obj->sensor_sel;
            if(selectedSensor > (num_sensors_found-1))
            {
                printf("Invalid sensor selection %d \n", selectedSensor);
                return VX_FAILURE;
            }
        }
    
        obj->sensor_wdr_mode = 0;
    
        obj->table_width = LDC_TABLE_WIDTH;
        obj->table_height = LDC_TABLE_HEIGHT;
        obj->ds_factor = LDC_DS_FACTOR;
    
        /* Display initialization */
        memset(&obj->display_params, 0, sizeof(tivx_display_params_t));
        obj->display_params.opMode = TIVX_KERNEL_DISPLAY_ZERO_BUFFER_COPY_MODE;
        obj->display_params.pipeId = 2;
        obj->display_params.outHeight = 1080;
        obj->display_params.outWidth = 1920;
        obj->display_params.posX = 0;
        obj->display_params.posY = 0;
    
        obj->scaler_enable = vx_false_e;
    
        appPerfPointSetName(&obj->total_perf , "TOTAL");
    
        return status;
    }
    
    vx_status app_deinit(AppObj *obj)
    {
        vx_status status = VX_FAILURE;
        tivxHwaUnLoadKernels(obj->context);
        APP_PRINTF("tivxHwaUnLoadKernels done\n");
    
        tivxImagingUnLoadKernels(obj->context);
        APP_PRINTF("tivxImagingUnLoadKernels done\n");
    
        status = vxReleaseContext(&obj->context);
        if(VX_SUCCESS == status)
        {
            APP_PRINTF("vxReleaseContext done\n");
        }
        else
        {
            printf("Error: vxReleaseContext returned 0x%x \n", status);
        }
        return status;
    }
    
    /*
     * Graph,
     *           viss_config
     *               |
     *               v
     * input_img -> VISS -----> LDC -----> output_img
     *
     */
    
    vx_status app_create_graph(AppObj *obj)
    {
        vx_status status = VX_SUCCESS;
        int32_t sensor_init_status = -1;
        obj->configuration = NULL;
        obj->raw = NULL;
        obj->y12 = NULL;
        obj->uv12_c1 = NULL;
        obj->y8_r8_c2 = NULL;
        obj->uv8_g8_c3 = NULL;
        obj->s8_b8_c4 = NULL;
        obj->histogram = NULL;
        obj->h3a_aew_af = NULL;
        obj->display_image = NULL;
    
        unsigned int image_width = obj->width_in;
        unsigned int image_height = obj->height_in;
    
        tivx_raw_image raw_image = 0;
        vx_user_data_object capture_config;
        vx_uint8 num_capture_frames = 1;
        tivx_capture_params_t local_capture_config;
        uint32_t buf_id;
        const vx_char capture_user_data_object_name[] = "tivx_capture_params_t";
        uint32_t sensor_features_enabled = 0;
        uint32_t sensor_features_supported = 0;
        uint32_t sensor_wdr_enabled = 0;
        uint32_t sensor_exp_control_enabled = 0;
        uint32_t sensor_gain_control_enabled = 0;
    
        vx_bool yuv_cam_input = vx_false_e;
        vx_image viss_out_image = NULL;
        vx_image ldc_in_image = NULL;
        vx_image capt_yuv_image = NULL;
    
        uint8_t channel_mask = (1<<obj->selectedCam);
    
        vx_uint32 params_list_depth = 1;
        if(obj->test_mode == 1)
        {
            params_list_depth = 2;
        }
        vx_graph_parameter_queue_params_t graph_parameters_queue_params_list[params_list_depth];
    
        printf("Querying %s \n", obj->sensor_name);
        memset(&sensorParams, 0, sizeof(sensorParams));
        status = appQueryImageSensor(obj->sensor_name, &sensorParams);
        if(VX_SUCCESS != status)
        {
            printf("appQueryImageSensor returned %d\n", status);
            return status;
        }
    
        if(sensorParams.sensorInfo.raw_params.format[0].pixel_container == VX_DF_IMAGE_UYVY)
        {
            yuv_cam_input = vx_true_e;
            printf("YUV Input selected. VISS and AEWB nodes will be bypassed. \n");
        }
    
    
        /*
        Check for supported sensor features.
        It is upto the application to decide which features should be enabled.
        This demo app enables WDR, DCC and 2A if the sensor supports it.
        */
        sensor_features_supported = sensorParams.sensorInfo.features;
    
        if(vx_false_e == yuv_cam_input)
        {
            if(ISS_SENSOR_FEATURE_COMB_COMP_WDR_MODE == (sensor_features_supported & ISS_SENSOR_FEATURE_COMB_COMP_WDR_MODE))
            {
                APP_PRINTF("WDR mode is supported \n");
                sensor_features_enabled |= ISS_SENSOR_FEATURE_COMB_COMP_WDR_MODE;
                sensor_wdr_enabled = 1;
                obj->sensor_wdr_mode = 1;
            }else
            {
                APP_PRINTF("WDR mode is not supported. Defaulting to linear \n");
                sensor_features_enabled |= ISS_SENSOR_FEATURE_LINEAR_MODE;
                sensor_wdr_enabled = 0;
                obj->sensor_wdr_mode = 0;
            }
    
            if(ISS_SENSOR_FEATURE_MANUAL_EXPOSURE == (sensor_features_supported & ISS_SENSOR_FEATURE_MANUAL_EXPOSURE))
            {
                APP_PRINTF("Expsoure control is supported \n");
                sensor_features_enabled |= ISS_SENSOR_FEATURE_MANUAL_EXPOSURE;
                sensor_exp_control_enabled = 1;
            }
    
            if(ISS_SENSOR_FEATURE_MANUAL_GAIN == (sensor_features_supported & ISS_SENSOR_FEATURE_MANUAL_GAIN))
            {
                APP_PRINTF("Gain control is supported \n");
                sensor_features_enabled |= ISS_SENSOR_FEATURE_MANUAL_GAIN;
                sensor_gain_control_enabled = 1;
            }
    
            if(ISS_SENSOR_FEATURE_CFG_UC1 == (sensor_features_supported & ISS_SENSOR_FEATURE_CFG_UC1))
            {
                APP_PRINTF("CMS Usecase is supported \n");
                sensor_features_enabled |= ISS_SENSOR_FEATURE_CFG_UC1;
            }
    
            switch(sensorParams.sensorInfo.aewbMode)
            {
                case ALGORITHMS_ISS_AEWB_MODE_NONE:
                    obj->aewb_cfg.ae_mode = ALGORITHMS_ISS_AE_DISABLED;
                    obj->aewb_cfg.awb_mode = ALGORITHMS_ISS_AWB_DISABLED;
                    break;
                case ALGORITHMS_ISS_AEWB_MODE_AWB:
                    obj->aewb_cfg.ae_mode = ALGORITHMS_ISS_AE_DISABLED;
                    obj->aewb_cfg.awb_mode = ALGORITHMS_ISS_AWB_AUTO;
                    break;
                case ALGORITHMS_ISS_AEWB_MODE_AE:
                    obj->aewb_cfg.ae_mode = ALGORITHMS_ISS_AE_AUTO;
                    obj->aewb_cfg.awb_mode = ALGORITHMS_ISS_AWB_DISABLED;
                    break;
                case ALGORITHMS_ISS_AEWB_MODE_AEWB:
                    obj->aewb_cfg.ae_mode = ALGORITHMS_ISS_AE_AUTO;
                    obj->aewb_cfg.awb_mode = ALGORITHMS_ISS_AWB_AUTO;
                    break;
            }
            if(obj->aewb_cfg.ae_mode == ALGORITHMS_ISS_AE_DISABLED)
            {
                if(sensor_exp_control_enabled || sensor_gain_control_enabled )
                {
                    obj->aewb_cfg.ae_mode = ALGORITHMS_ISS_AE_MANUAL;
                }
            }
    
            APP_PRINTF("obj->aewb_cfg.ae_mode = %d\n", obj->aewb_cfg.ae_mode);
            APP_PRINTF("obj->aewb_cfg.awb_mode = %d\n", obj->aewb_cfg.awb_mode);
    
        }
    
        if(ISS_SENSOR_FEATURE_DCC_SUPPORTED == (sensor_features_supported & ISS_SENSOR_FEATURE_DCC_SUPPORTED))
        {
            sensor_features_enabled |= ISS_SENSOR_FEATURE_DCC_SUPPORTED;
            APP_PRINTF("Sensor DCC is enabled \n");
        }else
        {
            APP_PRINTF("Sensor DCC is NOT enabled \n");
        }
    
        APP_PRINTF("Sensor width = %d\n", sensorParams.sensorInfo.raw_params.width);
        APP_PRINTF("Sensor height = %d\n", sensorParams.sensorInfo.raw_params.height);
        APP_PRINTF("Sensor DCC ID = %d\n", sensorParams.dccId);
        APP_PRINTF("Sensor Supported Features = 0x%x\n", sensor_features_supported);
        APP_PRINTF("Sensor Enabled Features = 0x%x\n", sensor_features_enabled);
        sensor_init_status = appInitImageSensor(obj->sensor_name, sensor_features_enabled, channel_mask);/*Mask = 1 for camera # 0*/
        if(0 != sensor_init_status)
        {
            /* Not returning failure because application may be waiting for
                error/test frame */
            printf("Error initializing sensor %s \n", obj->sensor_name);
        }
    
        image_width     = sensorParams.sensorInfo.raw_params.width;
        image_height    = sensorParams.sensorInfo.raw_params.height;
        obj->cam_dcc_id = sensorParams.dccId;
        obj->width_in = image_width;
        obj->height_in = image_height;
    
    /*
    Assuming same dataformat for all exposures.
    This may not be true for staggered HDR. WIll be handled later
        for(count = 0;count<raw_params.num_exposures;count++)
        {
            memcpy(&(raw_params.format[count]), &(sensorProperties.sensorInfo.dataFormat), sizeof(tivx_raw_image_format_t));
        }
    */
    
    /*
    Sensor driver does not support metadata yet.
    */
    
        APP_PRINTF("Creating graph \n");
    
        obj->graph = vxCreateGraph(obj->context);
        if(status == VX_SUCCESS)
        {
            status = vxGetStatus((vx_reference) obj->graph);
        }
        APP_ASSERT(vx_true_e == tivxIsTargetEnabled(TIVX_TARGET_VPAC_VISS1));
    
        APP_PRINTF("Initializing params for capture node \n");
    
        /* Setting to num buf of capture node */
        obj->num_cap_buf = NUM_BUFS;
    
        if(vx_false_e == yuv_cam_input)
        {
            raw_image = tivxCreateRawImage(obj->context, &sensorParams.sensorInfo.raw_params);
    
            /* allocate Input and Output refs, multiple refs created to allow pipelining of graph */
            for(buf_id=0; buf_id<obj->num_cap_buf; buf_id++)
            {
                if(status == VX_SUCCESS)
                {
                    obj->cap_frames[buf_id] = vxCreateObjectArray(obj->context, (vx_reference)raw_image, num_capture_frames);
                    status = vxGetStatus((vx_reference) obj->cap_frames[buf_id]);
                }
            }
        }
        else
        {
            capt_yuv_image = vxCreateImage(
                                    obj->context,
                                    sensorParams.sensorInfo.raw_params.width,
                                    sensorParams.sensorInfo.raw_params.height,
                                    VX_DF_IMAGE_UYVY
                             );
    
            /* allocate Input and Output refs, multiple refs created to allow pipelining of graph */
            for(buf_id=0; buf_id<obj->num_cap_buf; buf_id++)
            {
                if(status == VX_SUCCESS)
                {
                    obj->cap_frames[buf_id] = vxCreateObjectArray(obj->context, (vx_reference)capt_yuv_image, num_capture_frames);
                    status = vxGetStatus((vx_reference) obj->cap_frames[buf_id]);
                }
            }
        }
    
        /* Config initialization */
        tivx_capture_params_init(&local_capture_config);
    
        local_capture_config.timeout = 33;
        local_capture_config.timeoutInitial = 500;
    
        local_capture_config.numInst  = 2U;/* Configure both instances */
        local_capture_config.numCh = 1U;/* Single cam. Only 1 channel enabled */
        {
            vx_uint8 ch, id, lane, q;
            for(id = 0; id < local_capture_config.numInst; id++)
            {
                local_capture_config.instId[id]                       = id;
                local_capture_config.instCfg[id].enableCsiv2p0Support = (uint32_t)vx_true_e;
                local_capture_config.instCfg[id].numDataLanes         = sensorParams.sensorInfo.numDataLanes;
                local_capture_config.instCfg[id].laneBandSpeed        = sensorParams.sensorInfo.csi_laneBandSpeed;
    
                for (lane = 0; lane < local_capture_config.instCfg[id].numDataLanes; lane++)
                {
                    local_capture_config.instCfg[id].dataLanesMap[lane] = lane + 1;
                }
                for (q = 0; q < NUM_CAPT_CHANNELS; q++)
                {
                    ch = (NUM_CAPT_CHANNELS-1)* id + q;
                    local_capture_config.chVcNum[ch]   = q;
                    local_capture_config.chInstMap[ch] = id;
                }
            }
        }
    
        local_capture_config.chInstMap[0] = obj->selectedCam/NUM_CAPT_CHANNELS;
        local_capture_config.chVcNum[0]   = obj->selectedCam%NUM_CAPT_CHANNELS;
    
        capture_config = vxCreateUserDataObject(obj->context, capture_user_data_object_name, sizeof(tivx_capture_params_t), &local_capture_config);
        APP_PRINTF("capture_config = 0x%p \n", capture_config);
    
        APP_PRINTF("Creating capture node \n");
        obj->capture_node = tivxCaptureNode(obj->graph, capture_config, obj->cap_frames[0]);
        APP_PRINTF("obj->capture_node = 0x%p \n", obj->capture_node);
    
        if(status == VX_SUCCESS)
        {
            status = vxReleaseUserDataObject(&capture_config);
        }
        if(status == VX_SUCCESS)
        {
            status = vxSetNodeTarget(obj->capture_node, VX_TARGET_STRING, TIVX_TARGET_CAPTURE2);
        }
    
        if(vx_false_e == yuv_cam_input)
        {
            obj->raw = (tivx_raw_image)vxGetObjectArrayItem(obj->cap_frames[0], 0);
            if(status == VX_SUCCESS)
            {
                status = tivxReleaseRawImage(&raw_image);
            }
    #ifdef _APP_DEBUG_
    
    
            obj->fs_test_raw_image = tivxCreateRawImage(obj->context, &(sensorParams.sensorInfo.raw_params));
    
            if (NULL != obj->fs_test_raw_image)
            {
                if(status == VX_SUCCESS)
                {
                    status = read_test_image_raw(NULL, obj->fs_test_raw_image, obj->test_mode);
                }
                else
                {
                    status = tivxReleaseRawImage(&obj->fs_test_raw_image);
                    obj->fs_test_raw_image = NULL;
                }
            }
    #endif //_APP_DEBUG_
    
            status = app_create_viss(obj, sensor_wdr_enabled);
            if(VX_SUCCESS == status)
            {
            vxSetNodeTarget(obj->node_viss, VX_TARGET_STRING, TIVX_TARGET_VPAC_VISS1);
            tivxSetNodeParameterNumBufByIndex(obj->node_viss, 6u, obj->num_cap_buf);
            }
            else
            {
                printf("app_create_viss failed \n");
                return -1;
            }
    
            status = app_create_aewb(obj, sensor_wdr_enabled);
            if(VX_SUCCESS != status)
            {
                printf("app_create_aewb failed \n");
                return -1;
            }
            viss_out_image = obj->y8_r8_c2;
            ldc_in_image = viss_out_image;
        }
        else
        {
            obj->capt_yuv_image = (vx_image)vxGetObjectArrayItem(obj->cap_frames[0], 0);
            ldc_in_image = obj->capt_yuv_image;
            vxReleaseImage(&capt_yuv_image);
        }
    
        if (obj->ldc_enable)
        {
            printf ("Enabling LDC \n");
            status = app_create_ldc(obj, ldc_in_image);
    
            if(status == VX_SUCCESS)
            {
                status = vxSetNodeTarget(obj->node_ldc, VX_TARGET_STRING, TIVX_TARGET_VPAC_LDC1);
            }
            else
            {
                printf("app_create_ldc returned error \n");
                return status;
            }
            if(status == VX_SUCCESS)
            {
                status = tivxSetNodeParameterNumBufByIndex(obj->node_ldc, 7u, obj->num_cap_buf);
            }
    
            /*Check if resizing is needed for display*/
            if((obj->table_width >= obj->display_params.outWidth) && (obj->table_height >= obj->display_params.outHeight))
            {
                vx_uint16 scaler_out_w, scaler_out_h;
                obj->scaler_enable = vx_true_e;
                appIssGetResizeParams(obj->table_width, obj->table_height, obj->display_params.outWidth, obj->display_params.outHeight, &scaler_out_w, &scaler_out_h);
                obj->scaler_out_img = vxCreateImage(obj->context, scaler_out_w, scaler_out_h, VX_DF_IMAGE_NV12);
                obj->scalerNode = tivxVpacMscScaleNode(obj->graph, obj->ldc_out, obj->scaler_out_img, NULL, NULL, NULL, NULL);
                if(status == VX_SUCCESS)
                {
                    status = tivxSetNodeParameterNumBufByIndex(obj->scalerNode, 1u, obj->num_cap_buf);
                }
                obj->display_params.outHeight = scaler_out_h;
                obj->display_params.outWidth = scaler_out_w;
                obj->display_image = obj->scaler_out_img;
            }else /*No resize needed*/
            {
                obj->scaler_enable = vx_false_e;
                obj->display_image = obj->ldc_out;
    
                /* MSC can only downsize. If ldc resolution is lower,
                   display resolution must be set accordingly
                */
                obj->display_params.outWidth = obj->table_width;
                obj->display_params.outHeight = obj->table_height;
            }
        }
        else /*ldc_enable*/
        {
            if(NULL != obj->capt_yuv_image)
            {
                /*MSC does not support YUV422 input*/
                obj->scaler_enable = vx_false_e;
                printf("zqq: set scaler_enable = 0 \n");
            }
            else
            {
                if ((image_width != 1920) && (image_height != 1080))
                {
                    obj->scaler_enable = vx_true_e;
                    printf("zqq: set scaler_enable = 1 \n");
                }
                else
                {
                    obj->scaler_enable = vx_false_e;
                    /* MSC can only downsize. If viss resolution is lower,
                       display resolution must be set accordingly
                    */
                    obj->display_params.outWidth = image_width;
                    obj->display_params.outHeight = image_height;
                }
            }
    
            if(vx_true_e == obj->scaler_enable)
            {
                vx_uint16 scaler_out_w = 0, scaler_out_h = 0;
    //            appIssGetResizeParams(image_width, image_height, obj->display_params.outWidth, obj->display_params.outHeight, &scaler_out_w, &scaler_out_h);
                obj->scaler_out_img = vxCreateImage(obj->context, 1920, 1080, VX_DF_IMAGE_NV12);
                obj->scalerNode = tivxVpacMscScaleNode(obj->graph, ldc_in_image, obj->scaler_out_img, NULL, NULL, NULL, NULL);
                if(status == VX_SUCCESS)
                {
                    status = tivxSetNodeParameterNumBufByIndex(obj->scalerNode, 1u, obj->num_cap_buf);
                }
                if(status == VX_SUCCESS)
                {
                    status = vxSetNodeTarget(obj->scalerNode, VX_TARGET_STRING, TIVX_TARGET_VPAC_MSC1);
                }
                obj->display_params.outHeight = scaler_out_h;
                obj->display_params.outWidth = scaler_out_w;
                obj->display_image = obj->scaler_out_img;
            }
            else
            {
                obj->display_image = ldc_in_image;
            }
        }
    #if 0
        vx_image csitx_image;
        csitx_image = (vx_image)vxGetObjectArrayItem(&obj->scaler_out_img, 0); //obj->imgMosaicObj.output_image[0];
        tx_frame = vxCreateObjectArray(obj->context, (vx_reference)csitx_image, NUM_CHANNELS);
        status = vxGetStatus((vx_reference)tx_frame);
    #endif    
    //    tx_frame = obj->scaler_out_img;
        tx_frame = vxCreateObjectArray(obj->context, (vx_reference)obj->scaler_out_img, NUM_CHANNELS);
        if (status == VX_SUCCESS){
            printf("zqq tx_frame create done!!!!\n");
        }
        printf("zqq start CSITX Config initialization\n");
    
        vx_map_id map_id;
        vx_int32 i,j;
        vx_imagepatch_addressing_t addr;
        uint16_t *ptr = NULL;
        uint16_t frmIdx;
        tivx_raw_image tx_frame_array_item=0;
        vx_rectangle_t rect;
        vx_int16 width, height;
        width = 1920;
        height = 1080;
        rect.start_x = 0;
        rect.start_y = 0;
        rect.end_x = width;
        rect.end_y = height;
        printf("zqq Initializing Transmit Buffers...\n");
        for (frmIdx = 0U ; frmIdx < NUM_CHANNELS ; frmIdx++)
        {
            tx_frame_array_item = (tivx_raw_image)vxGetObjectArrayItem(tx_frame , frmIdx);
            printf("zqq tivxMapRawImagePatch start...\n");
            VX_CALL(tivxMapRawImagePatch(tx_frame_array_item, &rect, 0U, &map_id, &addr, (void **)&ptr, VX_WRITE_ONLY, VX_MEMORY_TYPE_HOST, TIVX_RAW_IMAGE_PIXEL_BUFFER));
            printf("zqq tivxMapRawImagePatch end...\n");
            if (ptr != NULL){
                printf("zqq ptr is not null\n");
            }
            for (i = 0; i <height; i++)
            {
                for(j=0; j<width; j++)
                {
                    ptr[((i*width)+j)] = (j + frmIdx);
                }
            }
            /* Do cache operations on each buffer to avoid coherency issues */
            appMemCacheWb(ptr, (width * height * sizeof(uint16_t)));
            VX_CALL(tivxUnmapRawImagePatch(tx_frame_array_item, map_id));
            VX_CALL(tivxReleaseRawImage(&tx_frame_array_item));
        }
        printf("zqq Initializing Transmit Buffers Done.\n");
        tivx_csitx_params_init(&local_csitx_config);
        local_csitx_config.numInst = 1U;
        local_csitx_config.numCh = NUM_CHANNELS;
        local_csitx_config.instId[0U] = CSITX_INST_ID;
        local_csitx_config.instCfg[0U].rxCompEnable = (uint32_t)vx_true_e;
        local_csitx_config.instCfg[0U].rxv1p3MapEnable = (uint32_t)vx_true_e;
        local_csitx_config.instCfg[0U].laneBandSpeed = CSITX_LANE_BAND_SPEED;
        local_csitx_config.instCfg[0U].laneSpeedMbps = CSITX_LANE_SPEED_MBPS;
        local_csitx_config.instCfg[0U].numDataLanes = 4U;
        for (loopCnt = 0U; loopCnt < local_csitx_config.instCfg[0U].numDataLanes; loopCnt++)
        {
            local_csitx_config.instCfg[0U].lanePolarityCtrl[loopCnt] = 0u;
        }
    
        for (loopCnt = 0U; loopCnt < NUM_CHANNELS; loopCnt++)
        {
            local_csitx_config.chVcNum[loopCnt]   = loopCnt;
            local_csitx_config.chInstMap[loopCnt] = CSITX_INST_ID;
        }
        csitx_config = vxCreateUserDataObject(obj->context, "tivx_csitx_params_t", sizeof(tivx_csitx_params_t), &local_csitx_config);
        if (csitx_config == NULL)
        {
            printf("zqq:csitx_config create failed\n");
        }
        csitx_node = tivxCsitxNode(obj->graph, csitx_config, tx_frame);
        VX_CALL(vxSetNodeTarget(csitx_node, VX_TARGET_STRING, TIVX_TARGET_CSITX));
        status = vxGetStatus((vx_reference)csitx_node);
        if (status == VX_SUCCESS)
        {
            printf("zqq csitx_node create done!!!!\n");
        }
    
    if (0) {
        if(NULL == obj->display_image)
        {
            printf("Error : Display input is uninitialized \n");
            return VX_FAILURE;
        }
        else
        {
            obj->display_params.posX = (1920U - obj->display_params.outWidth)/2;
            obj->display_params.posY = (1080U - obj->display_params.outHeight)/2;
            obj->display_param_obj = vxCreateUserDataObject(obj->context, "tivx_display_params_t", sizeof(tivx_display_params_t), &obj->display_params);
            obj->displayNode = tivxDisplayNode(obj->graph, obj->display_param_obj, obj->display_image);
        }
    
        if(status == VX_SUCCESS)
        {
            status = vxSetNodeTarget(obj->displayNode, VX_TARGET_STRING, TIVX_TARGET_DISPLAY1);
            APP_PRINTF("Display Set Target done\n");
        }
    }
        int graph_parameter_num = 0;
    
        /* input @ node index 1, becomes graph parameter 0 */
        add_graph_parameter_by_node_index(obj->graph, obj->capture_node, 1);
    
        /* set graph schedule config such that graph parameter @ index 0 is enqueuable */
        graph_parameters_queue_params_list[graph_parameter_num].graph_parameter_index = graph_parameter_num;
        graph_parameters_queue_params_list[graph_parameter_num].refs_list_size = obj->num_cap_buf;
        graph_parameters_queue_params_list[graph_parameter_num].refs_list = (vx_reference*)&(obj->cap_frames[0]);
        graph_parameter_num++;
    
        add_graph_parameter_by_node_index(obj->graph, csitx_node, 1);
        csitx_index = graph_parameter_num;
        /* set csitx_graph schedule config such that csitx_graph parameter @ index 0 and 1 are enqueuable */
        graph_parameters_queue_params_list[graph_parameter_num].graph_parameter_index = graph_parameter_num;
        graph_parameters_queue_params_list[graph_parameter_num].refs_list_size = 1;
        graph_parameters_queue_params_list[graph_parameter_num].refs_list = (vx_reference*)&tx_frame;
        graph_parameter_num++;
    
        if(obj->test_mode == 1)
        {
            add_graph_parameter_by_node_index(obj->graph, obj->displayNode, 1);
    
            /* set graph schedule config such that graph parameter @ index 0 is enqueuable */
            graph_parameters_queue_params_list[graph_parameter_num].graph_parameter_index = graph_parameter_num;
            graph_parameters_queue_params_list[graph_parameter_num].refs_list_size = 1;
            graph_parameters_queue_params_list[graph_parameter_num].refs_list = (vx_reference*)&(obj->display_image);
            graph_parameter_num++;
        }
    
        if(status == VX_SUCCESS)
        {
            status = tivxSetGraphPipelineDepth(obj->graph, obj->num_cap_buf);
        }
    
        /* Schedule mode auto is used, here we dont need to call vxScheduleGraph
         * Graph gets scheduled automatically as refs are enqueued to it
         */
        if(status == VX_SUCCESS)
        {
            status = vxSetGraphScheduleConfig(obj->graph,
                            VX_GRAPH_SCHEDULE_MODE_QUEUE_AUTO,
                            params_list_depth,
                            graph_parameters_queue_params_list
                            );
        }
        APP_PRINTF("vxSetGraphScheduleConfig done\n");
    
        if(status == VX_SUCCESS)
        {
            status = vxVerifyGraph(obj->graph);
        }
    
        if(vx_true_e == obj->scaler_enable)
        {
            tivx_vpac_msc_coefficients_t sc_coeffs;
            vx_reference refs[1];
    
            printf("Scaler is enabled\n");
    
            tivx_vpac_msc_coefficients_params_init(&sc_coeffs, VX_INTERPOLATION_BILINEAR);
    
            obj->sc_coeff_obj = vxCreateUserDataObject(obj->context, "tivx_vpac_msc_coefficients_t", sizeof(tivx_vpac_msc_coefficients_t), NULL);
            if(status == VX_SUCCESS)
            {
                status = vxCopyUserDataObject(obj->sc_coeff_obj, 0, sizeof(tivx_vpac_msc_coefficients_t), &sc_coeffs, VX_WRITE_ONLY, VX_MEMORY_TYPE_HOST);
            }
            refs[0] = (vx_reference)obj->sc_coeff_obj;
            if(status == VX_SUCCESS)
            {
                status = tivxNodeSendCommand(obj->scalerNode, 0u, TIVX_VPAC_MSC_CMD_SET_COEFF, refs, 1u);
            }
        }
        else
        {
            printf("Scaler is disabled\n");
        }
    
        if(status == VX_SUCCESS)
        {
            status = tivxExportGraphToDot(obj->graph, ".", "single_cam_graph");
        }
    
    #ifdef _APP_DEBUG_
        if(vx_false_e == yuv_cam_input)
        {
            if( (NULL != obj->fs_test_raw_image) && (NULL != obj->capture_node) && (status == VX_SUCCESS))
            {
                status = app_send_test_frame(obj->capture_node, obj->fs_test_raw_image);
            }
        }
    #endif //_APP_DEBUG_
    
        APP_PRINTF("app_create_graph exiting\n");
        return status;
    }
    
    vx_status app_delete_graph(AppObj *obj)
    {
        uint32_t buf_id;
        vx_status status = VX_SUCCESS;
    
        if(NULL != obj->capture_node)
        {
            APP_PRINTF("releasing capture node\n");
            status |= vxReleaseNode(&obj->capture_node);
        }
    
        if(NULL != obj->node_viss)
        {
            APP_PRINTF("releasing node_viss\n");
            status |= vxReleaseNode(&obj->node_viss);
        }
    
        if(NULL != obj->node_aewb)
        {
            APP_PRINTF("releasing node_aewb\n");
            status |= vxReleaseNode(&obj->node_aewb);
        }
    
        if(NULL != obj->displayNode)
        {
            APP_PRINTF("releasing displayNode\n");
            status |= vxReleaseNode(&obj->displayNode);
        }
    
        status |= tivxReleaseRawImage(&obj->raw);
        APP_PRINTF("releasing raw image done\n");
    
        for(buf_id=0; buf_id<obj->num_cap_buf; buf_id++)
        {
           if(NULL != obj->cap_frames[buf_id])
           {
            APP_PRINTF("releasing cap_frame # %d\n", buf_id);
            status |= vxReleaseObjectArray(&(obj->cap_frames[buf_id]));
           }
        }
    
        for(buf_id=0; buf_id<obj->num_viss_out_buf; buf_id++)
        {
          if(NULL != obj->viss_out_luma[buf_id])
          {
            APP_PRINTF("releasing y8 buffer # %d\n", buf_id);
            status |= vxReleaseImage(&(obj->viss_out_luma[buf_id]));
          }
        }
    
        if(NULL != obj->capt_yuv_image)
        {
            APP_PRINTF("releasing capt_yuv_image\n");
            status |= vxReleaseImage(&obj->capt_yuv_image);
        }
    
    
        if(NULL != obj->y12)
        {
            APP_PRINTF("releasing y12\n");
            status |= vxReleaseImage(&obj->y12);
        }
    
        if(NULL != obj->uv12_c1)
        {
            APP_PRINTF("releasing uv12_c1\n");
            status |= vxReleaseImage(&obj->uv12_c1);
        }
    
        if(NULL != obj->s8_b8_c4)
        {
            APP_PRINTF("releasing s8_b8_c4\n");
            status |= vxReleaseImage(&obj->s8_b8_c4);
        }
    
        if(NULL != obj->y8_r8_c2)
        {
            APP_PRINTF("releasing y8_r8_c2\n");
            status |= vxReleaseImage(&obj->y8_r8_c2);
        }
    
        if(NULL != obj->uv8_g8_c3)
        {
            APP_PRINTF("releasing uv8_g8_c3\n");
            status |= vxReleaseImage(&obj->uv8_g8_c3);
        }
    
        if(NULL != obj->histogram)
        {
            APP_PRINTF("releasing histogram\n");
            status |= vxReleaseDistribution(&obj->histogram);
        }
    
        if(NULL != obj->configuration)
        {
            APP_PRINTF("releasing configuration\n");
            status |= vxReleaseUserDataObject(&obj->configuration);
    
        }
    
        if (NULL != obj->ae_awb_result)
        {
            status |= vxReleaseUserDataObject(&obj->ae_awb_result);
            APP_PRINTF("releasing ae_awb_result done\n");
        }
    
        if(NULL != obj->h3a_aew_af)
        {
            APP_PRINTF("releasing h3a_aew_af\n");
            status |= vxReleaseUserDataObject(&obj->h3a_aew_af);
        }
    
        if(NULL != obj->aewb_config)
        {
            APP_PRINTF("releasing aewb_config\n");
            status |= vxReleaseUserDataObject(&obj->aewb_config);
        }
    
        if(NULL != obj->dcc_param_viss)
        {
            APP_PRINTF("releasing VISS DCC Data Object\n");
            status |= vxReleaseUserDataObject(&obj->dcc_param_viss);
        }
    
        if(NULL != obj->display_param_obj)
        {
            APP_PRINTF("releasing Display Param Data Object\n");
            status |= vxReleaseUserDataObject(&obj->display_param_obj);
        }
    
        if(NULL != obj->dcc_param_2a)
        {
            APP_PRINTF("releasing 2A DCC Data Object\n");
            status |= vxReleaseUserDataObject(&obj->dcc_param_2a);
        }
    
        if(NULL != obj->dcc_param_ldc)
        {
            APP_PRINTF("releasing LDC DCC Data Object\n");
            status |= vxReleaseUserDataObject(&obj->dcc_param_ldc);
        }
    
        if (obj->ldc_enable)
        {
            if (NULL != obj->mesh_img)
            {
                APP_PRINTF("releasing LDC Mesh Image \n");
                status |= vxReleaseImage(&obj->mesh_img);
            }
    
            if (NULL != obj->ldc_out)
            {
                APP_PRINTF("releasing LDC Output Image \n");
                status |= vxReleaseImage(&obj->ldc_out);
            }
    
            if (NULL != obj->mesh_params_obj)
            {
                APP_PRINTF("releasing LDC Mesh Parameters Object\n");
                status |= vxReleaseUserDataObject(&obj->mesh_params_obj);
            }
    
            if (NULL != obj->ldc_param_obj)
            {
                APP_PRINTF("releasing LDC Parameters Object\n");
                status |= vxReleaseUserDataObject(&obj->ldc_param_obj);
            }
    
            if (NULL != obj->region_params_obj)
            {
                APP_PRINTF("releasing LDC Region Parameters Object\n");
                status |= vxReleaseUserDataObject(&obj->region_params_obj);
            }
    
            if(NULL != obj->node_ldc)
            {
                APP_PRINTF("releasing LDC Node \n");
                status |= vxReleaseNode(&obj->node_ldc);
            }
        }
        if(vx_true_e == obj->scaler_enable)
        {
            if (NULL != obj->scaler_out_img)
            {
                APP_PRINTF("releasing Scaler Output Image \n");
                status |= vxReleaseImage(&obj->scaler_out_img);
            }
    
            if(NULL != obj->scalerNode)
            {
                APP_PRINTF("releasing Scaler Node \n");
                status |= vxReleaseNode(&obj->scalerNode);
            }
    
            if (NULL != obj->sc_coeff_obj)
            {
                APP_PRINTF("release Scalar coefficient data object \n");
                status |= vxReleaseUserDataObject(&obj->sc_coeff_obj);
            }
        }
    
    #ifdef _APP_DEBUG_
        if(NULL != obj->fs_test_raw_image)
        {
            APP_PRINTF("releasing test raw image buffer # %d\n", buf_id);
            status |= tivxReleaseRawImage(&obj->fs_test_raw_image);
        }
    #endif
    
        APP_PRINTF("releasing graph\n");
        status |= vxReleaseGraph(&obj->graph);
        APP_PRINTF("releasing graph done\n");
        return status;
    }
    
    vx_status app_run_graph(AppObj *obj)
    {
        vx_status status = VX_SUCCESS;
        vx_uint32 i;
        vx_uint32 frm_loop_cnt;
    
        uint32_t buf_id;
        uint32_t num_refs_capture;
        vx_object_array out_capture_frames;
        int graph_parameter_num = 0;
    
        uint8_t channel_mask = (1<<obj->selectedCam);
    
        if(NULL == obj->sensor_name)
        {
            printf("sensor name is NULL \n");
            return VX_FAILURE;
        }
        status = appStartImageSensor(obj->sensor_name, channel_mask);
        if(status < 0)
        {
            printf("Failed to start sensor %s \n", obj->sensor_name);
            if (NULL != obj->fs_test_raw_image)
            {
                printf("Defaulting to file test mode \n");
                status = 0;
            }
        }
    
        graph_parameter_num = 0;
        for(buf_id=0; buf_id<obj->num_cap_buf; buf_id++)
        {
            if(status == VX_SUCCESS)
            {
                status = vxGraphParameterEnqueueReadyRef(obj->graph, 0, (vx_reference*)&(obj->cap_frames[buf_id]), 1);
            }
            /* in order for the graph to finish execution, the
                display still needs to be enqueued 4 times for testing */
    //        if((status == VX_SUCCESS) && (obj->test_mode == 1))
            if(status == VX_SUCCESS)
            {
                status = vxGraphParameterEnqueueReadyRef(obj->graph, 1, (vx_reference*)&tx_frame, 1);
            }
        }
    
        /*
            The application reads and  processes the same image "frm_loop_cnt" times
            The output may change because on VISS, parameters are updated every frame based on AEWB results
            AEWB result is avaialble after 1 frame and is applied after 2 frames
            Therefore, first 2 output images will have wrong colors
        */
        frm_loop_cnt = obj->num_frames_to_run;
        frm_loop_cnt += obj->num_cap_buf;
    
        if(obj->is_interactive)
        {
            /* in interactive mode loop for ever */
            frm_loop_cnt  = 0xFFFFFFFF;
        }
    
    #ifdef A72
    #if defined(LINUX)
    
        appDccUpdatefromFS(obj->sensor_name, obj->sensor_wdr_mode,
                            obj->node_aewb, 0,
                            obj->node_viss, 0,
                            obj->node_ldc, 0,
                            obj->context);
    #endif
    #endif
    
        for(i=0; i<frm_loop_cnt; i++)
        {
            vx_image test_image;
            appPerfPointBegin(&obj->total_perf);
            graph_parameter_num = 0;
            if(status == VX_SUCCESS)
            {
                status = vxGraphParameterDequeueDoneRef(obj->graph, graph_parameter_num, (vx_reference*)&out_capture_frames, 1, &num_refs_capture);
            }
            graph_parameter_num++;
            if((status == VX_SUCCESS) && (obj->test_mode == 1))
            {
                status = vxGraphParameterDequeueDoneRef(obj->graph, 1, (vx_reference*)&test_image, 1, &num_refs_capture);
            }
            if((obj->test_mode == 1) && (i > TEST_BUFFER) && (status == VX_SUCCESS))
            {
                vx_uint32 actual_checksum = 0;
                if(app_test_check_image(test_image, checksums_expected[obj->sensor_sel][0], &actual_checksum) == vx_false_e)
                {
                    test_result = vx_false_e;
                }
                populate_gatherer(obj->sensor_sel, 0, actual_checksum);
            }
            APP_PRINTF(" i %d...\n", i);
            graph_parameter_num = 0;
            if((status == VX_SUCCESS) && (obj->test_mode == 1))
            {
                status = vxGraphParameterEnqueueReadyRef(obj->graph, 1, (vx_reference*)&test_image, 1);
            }
            if(status == VX_SUCCESS)
            {
                status = vxGraphParameterEnqueueReadyRef(obj->graph, graph_parameter_num, (vx_reference*)&out_capture_frames, 1);
            }
            graph_parameter_num++;
    
            appPerfPointEnd(&obj->total_perf);
    
            if((obj->stop_task) || (status != VX_SUCCESS))
            {
                break;
            }
        }
    
        if(status == VX_SUCCESS)
        {
            status = vxWaitGraph(obj->graph);
        }
    /* Dequeue buf for pipe down */
    #if 0
        for(buf_id=0; buf_id<obj->num_cap_buf-2; buf_id++)
        {
            APP_PRINTF(" Dequeuing capture # %d...\n", buf_id);
            graph_parameter_num = 0;
            vxGraphParameterDequeueDoneRef(obj->graph, graph_parameter_num, (vx_reference*)&out_capture_frames, 1, &num_refs_capture);
            graph_parameter_num++;
        }
    #endif
        if(status == VX_SUCCESS)
        {
            status = appStopImageSensor(obj->sensor_name, channel_mask);
        }
        return status;
    }
    
    static void app_run_task(void *app_var)
    {
        AppObj *obj = (AppObj *)app_var;
    
        appPerfStatsCpuLoadResetAll();
    
        app_run_graph(obj);
    
        obj->stop_task_done = 1;
    }
    
    static int32_t app_run_task_create(AppObj *obj)
    {
        tivx_task_create_params_t params;
        int32_t status;
    
        tivxTaskSetDefaultCreateParams(&params);
        params.task_main = app_run_task;
        params.app_var = obj;
    
        obj->stop_task_done = 0;
        obj->stop_task = 0;
    
        status = tivxTaskCreate(&obj->task, &params);
    
        return status;
    }
    
    static void app_run_task_delete(AppObj *obj)
    {
        while(obj->stop_task_done==0)
        {
             tivxTaskWaitMsecs(100);
        }
    
        tivxTaskDelete(&obj->task);
    }
    
    static char menu[] = {
        "\n"
        "\n =========================="
        "\n Demo : Single Camera w/ 2A"
        "\n =========================="
        "\n"
        "\n p: Print performance statistics"
        "\n"
    #ifdef _APP_DEBUG_
        "\n s: Save Sensor RAW, VISS Output and H3A output images to File System"
        "\n"
    #endif
        "\n e: Export performance statistics"
    #ifdef A72
    #if defined(LINUX)
        "\n"
        "\n u: Update DCC from File System"
        "\n"
        "\n"
    #endif
    #endif
        "\n x: Exit"
        "\n"
        "\n Enter Choice: "
    };
    
    static vx_status app_run_graph_interactive(AppObj *obj)
    {
        vx_status status;
        uint32_t done = 0;
        char ch;
        FILE *fp;
        app_perf_point_t *perf_arr[1];
        uint8_t channel_mask = (1<<obj->selectedCam);
    
        status = app_run_task_create(obj);
        if(status!=0)
        {
            printf("ERROR: Unable to create task\n");
        }
        else
        {
            appPerfStatsResetAll();
            while(!done && (status == VX_SUCCESS))
            {
                printf(menu);
                ch = getchar();
                printf("\n");
    
                switch(ch)
                {
                    case 'p':
                        appPerfStatsPrintAll();
                        status = tivx_utils_graph_perf_print(obj->graph);
                        appPerfPointPrint(&obj->total_perf);
                        printf("\n");
                        appPerfPointPrintFPS(&obj->total_perf);
                        appPerfPointReset(&obj->total_perf);
                        printf("\n");
                        break;
    #ifdef _APP_DEBUG_
                    case 's':
                        save_debug_images(obj);
                        break;
                    case 'a':
                        printf("zqq:send cmd get otp\n");
                        appGetSensorOtp(obj->sensor_name, &hilModeInfo);
                        break;
    #endif
                    case 'e':
                        perf_arr[0] = &obj->total_perf;
                        fp = appPerfStatsExportOpenFile(".", "basic_demos_app_single_cam");
                        if (NULL != fp)
                        {
                            appPerfStatsExportAll(fp, perf_arr, 1);
                            status = tivx_utils_graph_perf_export(fp, obj->graph);
                            appPerfStatsExportCloseFile(fp);
                            appPerfStatsResetAll();
                        }
                        else
                        {
                            printf("fp is null\n");
                        }
                        break;
    #ifdef A72
    #if defined(LINUX)
                    case 'u':
                        appDccUpdatefromFS(obj->sensor_name, obj->sensor_wdr_mode,
                            obj->node_aewb, 0,
                            obj->node_viss, 0,
                            obj->node_ldc, 0,
                            obj->context);
                        break;
    #endif
    #endif
    
                    case 'x':
                        obj->stop_task = 1;
                        done = 1;
                        break;
    
                    default:
                        printf("Unsupported command %c\n", ch);
                        break;
    
                }
            }
            app_run_task_delete(obj);
        }
        if(status == VX_SUCCESS)
        {
            status = appStopImageSensor(obj->sensor_name, channel_mask);
        }
        return status;
    }
    
    static void app_show_usage(int argc, char* argv[])
    {
        printf("\n");
        printf(" Single Camera Demo - (c) Texas Instruments 2019\n");
        printf(" ========================================================\n");
        printf("\n");
        printf(" Usage,\n");
        printf("  %s --cfg <config file>\n", argv[0]);
        printf("\n");
    }
    
    #ifdef A72
    #if defined(LINUX)
    int appSingleCamUpdateVpacDcc(AppObj *obj, uint8_t* dcc_buf, uint32_t dcc_buf_size)
    {
        int32_t status = 0;
    
        status = appUpdateVpacDcc(dcc_buf, dcc_buf_size, obj->context,
                    obj->node_viss, 0,
                    obj->node_aewb, 0,
                    obj->node_ldc, 0
                 );
    
        return status;
    }
    #endif
    #endif
    
    #ifdef _APP_DEBUG_
    int save_debug_images(AppObj *obj)
    {
        int num_bytes_io = 0;
        static int file_index = 0;
        char raw_image_fname[MAX_FNAME];
        char yuv_image_fname[MAX_FNAME];
        char h3a_image_fname[MAX_FNAME];
        char failsafe_test_data_path[3] = "./";
        char * test_data_path = app_get_test_file_path();
        struct stat s;
    
        if(NULL == test_data_path)
        {
            printf("Test data path is NULL. Defaulting to current folder \n");
            test_data_path = failsafe_test_data_path;
        }
    
        if (stat(test_data_path, &s))
        {
            printf("Test data path %s does not exist. Defaulting to current folder \n", test_data_path);
            test_data_path = failsafe_test_data_path;
        }
    
        if(NULL == obj->capt_yuv_image)
        {
            snprintf(raw_image_fname, MAX_FNAME, "%s/%s_%04d.raw", test_data_path, "img", file_index);
            printf("RAW file name %s \n", raw_image_fname);
            num_bytes_io = write_output_image_raw(raw_image_fname, obj->raw);
            if(num_bytes_io < 0)
            {
                printf("Error writing to RAW file \n");
                return VX_FAILURE;
            }
    
            snprintf(yuv_image_fname, MAX_FNAME, "%s/%s_%04d.yuv", test_data_path, "img_viss", file_index);
            printf("YUV file name %s \n", yuv_image_fname);
            num_bytes_io = write_output_image_nv12_8bit(yuv_image_fname, obj->y8_r8_c2);
            if(num_bytes_io < 0)
            {
                printf("Error writing to VISS NV12 file \n");
                return VX_FAILURE;
            }
    
            snprintf(h3a_image_fname, MAX_FNAME, "%s/%s_%04d.bin", test_data_path, "h3a", file_index);
            printf("H3A file name %s \n", h3a_image_fname);
            num_bytes_io = write_h3a_image(h3a_image_fname, obj->h3a_aew_af);
            if(num_bytes_io < 0)
            {
                printf("Error writing to H3A file \n");
                return VX_FAILURE;
            }
    
        }
        else
        {
            vx_image cap_yuv;
            snprintf(raw_image_fname, MAX_FNAME, "%s/%s_%04d.yuv", test_data_path, "cap", file_index);
            printf("YUV file name %s \n", raw_image_fname);
            cap_yuv = (vx_image)vxGetObjectArrayItem(obj->cap_frames[0], 0);
            num_bytes_io = write_output_image_yuv422_8bit(raw_image_fname, cap_yuv);
            if(num_bytes_io < 0)
            {
                printf("Error writing to YUV file \n");
                return VX_FAILURE;
            }
        }
    
        if(obj->scaler_enable)
        {
            snprintf(yuv_image_fname, MAX_FNAME, "%s/%s_%04d.yuv", test_data_path, "img_msc", file_index);
            printf("YUV file name %s \n", yuv_image_fname);
            num_bytes_io = write_output_image_nv12_8bit(yuv_image_fname, obj->scaler_out_img);
            if(num_bytes_io < 0)
            {
                printf("Error writing to MSC NV12 file \n");
                return VX_FAILURE;
            }
        }
    
        if(obj->ldc_enable)
        {
            snprintf(yuv_image_fname, MAX_FNAME, "%s/%s_%04d.yuv", test_data_path, "img_ldc", file_index);
            printf("YUV file name %s \n", yuv_image_fname);
            num_bytes_io = write_output_image_nv12_8bit(yuv_image_fname, obj->ldc_out);
            if(num_bytes_io < 0)
            {
                printf("Error writing to LDC NV12 file \n");
                return VX_FAILURE;
            }
        }
    
        file_index++;
        return (file_index-1);
    }
    #endif //_APP_DEBUG_
    
    static void app_parse_cfg_file(AppObj *obj, char *cfg_file_name)
    {
        FILE *fp = fopen(cfg_file_name, "r");
        char line_str[1024];
        char *token;
    
        if(fp==NULL)
        {
            printf("# ERROR: Unable to open config file [%s]. Switching to interactive mode\n", cfg_file_name);
            obj->is_interactive = 1;
        }
        else
        {
            while(fgets(line_str, sizeof(line_str), fp)!=NULL)
            {
                char s[]=" \t";
    
                if (strchr(line_str, '#'))
                {
                    continue;
                }
    
                /* get the first token */
                token = strtok(line_str, s);
                if (NULL != token)
                {
                    if(strcmp(token, "sensor_index")==0)
                    {
                        token = strtok(NULL, s);
                        if (NULL != token)
                        {
                            obj->sensor_sel = atoi(token);
                            printf("sensor_selection = [%d]\n", obj->sensor_sel);
                        }
                    }
                    else
                    if(strcmp(token, "ldc_enable")==0)
                    {
                        token = strtok(NULL, s);
                        if (NULL != token)
                        {
                            obj->ldc_enable = atoi(token);
                            printf("ldc_enable = [%d]\n", obj->ldc_enable);
                        }
                    }
                    else
                    if(strcmp(token, "num_frames_to_run")==0)
                    {
                        token = strtok(NULL, s);
                        if (NULL != token)
                        {
                            obj->num_frames_to_run = atoi(token);
                            printf("num_frames_to_run = [%d]\n", obj->num_frames_to_run);
                        }
                    }
                    else
                    if(strcmp(token, "is_interactive")==0)
                    {
                        token = strtok(NULL, s);
                        if (NULL != token)
                        {
                            obj->is_interactive = atoi(token);
                            printf("is_interactive = [%d]\n", obj->is_interactive);
                        }
                    }
                    else
                    {
                        APP_PRINTF("Invalid token [%s]\n", token);
                    }
                }
            }
    
            fclose(fp);
        }
    
        if(obj->width_in<128)
            obj->width_in = 128;
        if(obj->height_in<128)
            obj->height_in = 128;
        if(obj->width_out<128)
            obj->width_out = 128;
        if(obj->height_out<128)
            obj->height_out = 128;
    
    }
    
    vx_status app_parse_cmd_line_args(AppObj *obj, int argc, char *argv[])
    {
        vx_bool set_test_mode = vx_false_e;
        vx_int8 sensor_override = 0xFF;
        app_set_cfg_default(obj);
    
        int i;
        if(argc==1)
        {
            app_show_usage(argc, argv);
            printf("Defaulting to interactive mode \n");
            obj->is_interactive = 1;
            return VX_SUCCESS;
        }
    
        for(i=0; i<argc; i++)
        {
            if(strcmp(argv[i], "--cfg")==0)
            {
                i++;
                if(i>=argc)
                {
                    app_show_usage(argc, argv);
                }
                app_parse_cfg_file(obj, argv[i]);
            }
            else
            if(strcmp(argv[i], "--help")==0)
            {
                app_show_usage(argc, argv);
                return VX_FAILURE;
            }
            else
            if(strcmp(argv[i], "--test")==0)
            {
                set_test_mode = vx_true_e;
            }
            else
            if(strcmp(argv[i], "--sensor")==0)
            {
                // check to see if there is another argument following --sensor
                if (argc > i+1)
                {
                    sensor_override = atoi(argv[i+1]);
                    // increment i again to avoid this arg
                    i++;
                }
            }
        }
    
        if(set_test_mode == vx_true_e)
        {
            obj->test_mode = 1;
            obj->is_interactive = 0;
            obj->num_frames_to_run = NUM_FRAMES;
            if (sensor_override != 0xFF)
            {
                obj->sensor_sel = sensor_override;
            }
        }
        return VX_SUCCESS;
    }
    
    
    
    #ifdef _APP_DEBUG_
    vx_int32 write_output_image_nv12(char * file_name, vx_image out_nv12)
    {
        FILE * fp = fopen(file_name, "wb");
        if(!fp)
        {
            APP_PRINTF("Unable to open file %s\n", file_name);
            return -1;
        }
        vx_uint32 len1 = write_output_image_fp(fp, out_nv12);
        fclose(fp);
        APP_PRINTF("%d bytes written to %s\n", len1, file_name);
        return len1;
    }
    #endif
    
    
    AppObj gAppObj;
    
    int app_single_cam_main(int argc, char* argv[])
    {
        AppObj *obj = &gAppObj;
        vx_status status = VX_FAILURE;
        status = app_parse_cmd_line_args(obj, argc, argv);
        if(VX_SUCCESS == status)
        {
            status = app_init(obj);
            if(VX_SUCCESS == status)
            {
                APP_PRINTF("app_init done\n");
                /* Not checking status because application may be waiting for
                    error/test frame */
                app_create_graph(obj);
                if(VX_SUCCESS == status)
                {
                    APP_PRINTF("app_create_graph done\n");
                    if(obj->is_interactive)
                    {
                        status = app_run_graph_interactive(obj);
                    }
                    else
                    {
                        status = app_run_graph(obj);
                    }
                    if(VX_SUCCESS == status)
                    {
                        APP_PRINTF("app_run_graph done\n");
                        status = app_delete_graph(obj);
                        if(VX_SUCCESS == status)
                        {
                            APP_PRINTF("app_delete_graph done\n");
                        }
                        else
                        {
                            printf("Error : app_delete_graph returned 0x%x \n", status);
                        }
                    }
                    else
                    {
                        printf("Error : app_run_graph_xx returned 0x%x \n", status);
                    }
                }
                else
                {
                    printf("Error : app_create_graph returned 0x%x is_interactive =%d  \n", status, obj->is_interactive);
                }
            }
            else
            {
                printf("Error : app_init returned 0x%x \n", status);
            }
            status = app_deinit(obj);
            if(VX_SUCCESS == status)
            {
                APP_PRINTF("app_deinit done\n");
            }
            else
            {
                printf("Error : app_deinit returned 0x%x \n", status);
            }
            appDeInitImageSensor(obj->sensor_name);
        }
        else
        {
            printf("Error: app_parse_cmd_line_args returned 0x%x \n", status);
        }
        if(obj->test_mode == 1)
        {
            if((test_result == vx_false_e) || (status == VX_FAILURE))
            {
                printf("\n\nTEST FAILED\n\n");
                print_new_checksum_structs();
                status = (status == VX_SUCCESS) ? VX_FAILURE : status;
            }
            else
            {
                printf("\n\nTEST PASSED\n\n");
            }
        }
        return status;
    }
    
    vx_status app_send_test_frame(vx_node cap_node, tivx_raw_image raw_img)
    {
        vx_status status = VX_SUCCESS;
    
        status = tivxCaptureRegisterErrorFrame(cap_node, (vx_reference)raw_img);
    
        return status;
    }
    
    

    Dear TI expert,

    I have modified the app_single_cam_main.c file,I have added two nodes in the graph, one is to crop 8M images to 2M, the other is to send 2M images through csitx. Could you please help me check if there is any problem with my code.

    • Please ignore what I said earlier about the image format.

  • Hi,

    I don't understand, where are you doing cropping? Have you added new node for cropping functionality? 

    The code seems for CSIRX + VISS + LDC path. Are you connecting Scalar output to the CSITX without cropping?  

    Regards,

    Brijesh

  • Dear TI expert,

    tivxVpacMscScaleNode Doesn't this function add clipped nodes?

  • hi,

    Yes, scalar node can do cropping, but it needs to be configuring using a separate control command and that control command can be called only after graph verification. 

    Regards,

    Brijesh

  • Dear TI expert

       The code I sent has these cmd in it. Could you please help me confirm whether the current process of my code belongs to capture>viss>scalar>csitx? Will this pipeline run when wo run the graph?

  • But this command sets the coefficients of the scalar, it does not set the cropping parameters.. 

    Yes, scalar will be used in your dataflow in the multi-camera application. 

  • /*
     *
     * Copyright (c) 2021 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 "app_single_cam_common.h"
    
    
    #include "ldc_lut_1920x1080.h"
    static uint8_t  ldc_lut[] = LDC_LUT_1920_1080;
    
    char *app_get_test_file_path()
    {
        char *tivxPlatformGetEnv(char *env_var);
    
        #if defined(SYSBIOS)
        return tivxPlatformGetEnv("VX_TEST_DATA_PATH");
        #else
        return getenv("VX_TEST_DATA_PATH");
        #endif
    }
    
    static char default_sensor_name[ISS_SENSORS_MAX_NAME] = "Noname";
    static uint32_t default_sensor_id = 1234;
    void app_set_cfg_default(AppObj *obj)
    {
        obj->width_in = 1920;
        obj->height_in = 1080;
        obj->width_out = 1920;
        obj->height_out = 1080;
        obj->is_interactive = 1;
        obj->test_mode = 0;
        obj->ldc_enable = 0;
        obj->table_width = LDC_TABLE_WIDTH;
        obj->table_height = LDC_TABLE_HEIGHT;
        obj->ds_factor = LDC_DS_FACTOR;
        obj->sensor_name = default_sensor_name;
        obj->cam_dcc_id = default_sensor_id;
        obj->selectedCam = 0;
    #ifdef VPAC3
        obj->vpac3_dual_fcp_enable = 0;
    #endif
    }
    
    vx_int32 write_aewb_output(FILE * fp, tivx_ae_awb_params_t * aewb_result)
    {
        int i;
        printf("exposure_time = %d \n", aewb_result->exposure_time);
        printf("analog_gain = %d \n", aewb_result->analog_gain);
        printf("color_temperature = %d \n", aewb_result->color_temperature);
        for(i=0;i<4;i++)
        {
            printf("wb_gains[%d] = %d \n", i, aewb_result->wb_gains[i]);
        }
        return 0;
    }
    vx_int32 write_output_image_fp(FILE * fp, vx_image out_image)
    {
        vx_uint32 width, height;
        vx_df_image df;
        vx_imagepatch_addressing_t image_addr;
        vx_rectangle_t rect;
        vx_map_id map_id1, map_id2;
        void *data_ptr1, *data_ptr2;
        vx_uint32 num_bytes_per_4pixels;
        vx_uint32 num_luma_bytes_written_to_file=0;
        vx_uint32 num_chroma_bytes_written_to_file=0;
        vx_uint32 num_bytes_written_to_file=0;
        vx_uint32 imgaddr_width, imgaddr_height, imgaddr_stride;
        int i;
    
        vxQueryImage(out_image, VX_IMAGE_WIDTH, &width, sizeof(vx_uint32));
        vxQueryImage(out_image, VX_IMAGE_HEIGHT, &height, sizeof(vx_uint32));
        vxQueryImage(out_image, VX_IMAGE_FORMAT, &df, sizeof(vx_df_image));
    
    
        if(VX_DF_IMAGE_NV12 == df)
        {
            num_bytes_per_4pixels = 4;
        }
        else if(TIVX_DF_IMAGE_NV12_P12 == df)
        {
            num_bytes_per_4pixels = 6;
        }
        else
        {
            num_bytes_per_4pixels = 8;
        }
    
        rect.start_x = 0;
        rect.start_y = 0;
        rect.end_x = width;
        rect.end_y = height;
    
        vxMapImagePatch(out_image,
            &rect,
            0,
            &map_id1,
            &image_addr,
            &data_ptr1,
            VX_WRITE_ONLY,
            VX_MEMORY_TYPE_HOST,
            VX_NOGAP_X
            );
    
        if(!data_ptr1)
        {
            printf("data_ptr1 is NULL \n");
            return -1;
        }
    
        imgaddr_width  = image_addr.dim_x;
        imgaddr_height = image_addr.dim_y;
        imgaddr_stride = image_addr.stride_y;
        printf("imgaddr_width = %d \n", imgaddr_width);
        printf("imgaddr_height = %d \n", imgaddr_height);
        printf("imgaddr_stride = %d \n", imgaddr_stride);
        printf("width = %d \n", width);
        printf("height = %d \n", height);
    
        num_luma_bytes_written_to_file = 0;
    
        for(i=0;i<height;i++)
        {
            num_luma_bytes_written_to_file  += fwrite(data_ptr1, 1, width*num_bytes_per_4pixels/4, fp);
            data_ptr1 += imgaddr_stride;
        }
        vxUnmapImagePatch(out_image, map_id1);
    
        fflush(fp);
    
    
        if(VX_DF_IMAGE_NV12 == df || TIVX_DF_IMAGE_NV12_P12 == df)
        {
            vxMapImagePatch(out_image,
                &rect,
                1,
                &map_id2,
                &image_addr,
                &data_ptr2,
                VX_WRITE_ONLY,
                VX_MEMORY_TYPE_HOST,
                VX_NOGAP_X
                );
    
            if(!data_ptr2)
            {
                printf("data_ptr2 is NULL \n");
                return -1;
            }
    
            imgaddr_width  = image_addr.dim_x;
            imgaddr_height = image_addr.dim_y;
            imgaddr_stride = image_addr.stride_y;
    
            num_chroma_bytes_written_to_file = 0;
            for(i=0;i<imgaddr_height/2;i++)
            {
                num_chroma_bytes_written_to_file  += fwrite(data_ptr2, 1, imgaddr_width*num_bytes_per_4pixels/4, fp);
                data_ptr2 += imgaddr_stride;
            }
    
            fflush(fp);
    
            vxUnmapImagePatch(out_image, map_id2);
        }
    
        num_bytes_written_to_file = num_luma_bytes_written_to_file + num_chroma_bytes_written_to_file;
        printf("Written %d bytes \n", num_bytes_written_to_file);
    
        return num_bytes_written_to_file;
    }
    
    vx_int32 write_output_image_yuv422_8bit(char * file_name, vx_image out_yuv)
    {
        FILE * fp = fopen(file_name, "wb");
        if(!fp)
        {
            APP_PRINTF("Unable to open file %s\n", file_name);
            return -1;
        }
        vx_uint32 len1 = write_output_image_fp(fp, out_yuv);
        fclose(fp);
        APP_PRINTF("%d bytes written to %s\n", len1, file_name);
        return len1;
    }
    
    vx_int32 write_output_image_nv12_8bit(char * file_name, vx_image out_nv12)
    {
        FILE * fp = fopen(file_name, "wb");
        if(!fp)
        {
            APP_PRINTF("Unable to open file %s\n", file_name);
            return -1;
        }
        vx_uint32 len1 = write_output_image_fp(fp, out_nv12);
        fclose(fp);
        APP_PRINTF("%d bytes written to %s\n", len1, file_name);
        return len1;
    }
    
    vx_int32 read_test_image_raw(char *raw_image_test_fname, tivx_raw_image raw_image, vx_uint32 test_mode)
    {
        char raw_image_fname[MAX_FNAME] = {0};
        char failsafe_test_data_path[3] = "./";
        char * test_data_path = app_get_test_file_path();
        FILE * fp;
        vx_uint32 width, height, i;
        vx_imagepatch_addressing_t image_addr;
        vx_rectangle_t rect;
        vx_map_id map_id;
        void *data_ptr;
        vx_uint32 num_bytes_per_pixel = 2; /*Supports only RAW 12b Unpacked format*/
        vx_uint32 num_bytes_read_from_file = 0;
        tivx_raw_image_format_t format;
        vx_uint32 imgaddr_width, imgaddr_height, imgaddr_stride;
    
        tivxQueryRawImage(raw_image, TIVX_RAW_IMAGE_WIDTH, &width, sizeof(vx_uint32));
        tivxQueryRawImage(raw_image, TIVX_RAW_IMAGE_HEIGHT, &height, sizeof(vx_uint32));
        tivxQueryRawImage(raw_image, TIVX_RAW_IMAGE_FORMAT, &format, sizeof(format));
        if(0==test_mode)
        {
            if(NULL == test_data_path)
            {
                printf("Test data path is NULL. Defaulting to current folder \n");
                test_data_path = failsafe_test_data_path;
            }
            snprintf(raw_image_fname, MAX_FNAME, "%s/%s.raw", test_data_path, "img_test");
        }
        else if(1==test_mode)
        {
            char test_data_paths[2][255] = {"psdkra/app_single_cam/IMX390_001/input2",
                                             "psdkra/app_single_cam/AR0233_001/input2"};
            int sensor_idx = 0;
            if ((width == 1920) && (height == 1280))
            {
                sensor_idx = 1;
            }
            snprintf(raw_image_fname, MAX_FNAME, "%s/%s.raw", test_data_path, test_data_paths[sensor_idx]);
        }
        else if(2==test_mode)
        {
            if(NULL != raw_image_test_fname)
            {
                memcpy(raw_image_fname, raw_image_test_fname,MAX_FNAME);
            }
        }
    
        if (NULL != raw_image_fname)
        {
            fp = fopen(raw_image_fname, "rb");
            if(!fp)
            {
                printf("read_test_image_raw : Unable to open file %s\n", raw_image_fname);
                return -1;
            }
            rect.start_x = 0;
            rect.start_y = 0;
            rect.end_x = width;
            rect.end_y = height;
    
            tivxMapRawImagePatch(raw_image,
                &rect,
                0,
                &map_id,
                &image_addr,
                &data_ptr,
                VX_READ_AND_WRITE,
                VX_MEMORY_TYPE_HOST,
                TIVX_RAW_IMAGE_PIXEL_BUFFER
                );
    
            if(!data_ptr)
            {
                APP_PRINTF("data_ptr is NULL \n");
                fclose(fp);
                return -1;
            }
            num_bytes_read_from_file = 0;
    
            imgaddr_width  = image_addr.dim_x;
            imgaddr_height = image_addr.dim_y;
            imgaddr_stride = image_addr.stride_y;
    
            printf("imgaddr_width = %d \n", imgaddr_width);
            printf("imgaddr_height = %d \n", imgaddr_height);
            printf("imgaddr_stride = %d \n", imgaddr_stride);
    
            for(i=0;i<imgaddr_height;i++)
            {
                num_bytes_read_from_file += fread(data_ptr, 1, imgaddr_width*num_bytes_per_pixel, fp);
                data_ptr += imgaddr_stride;
            }
    
            tivxUnmapRawImagePatch(raw_image, map_id);
    
            fclose(fp);
            printf("%d bytes read from %s\n", num_bytes_read_from_file, raw_image_fname);
        }
    
        return num_bytes_read_from_file;
    }
    
    vx_int32 write_output_image_raw(char * file_name, tivx_raw_image raw_image)
    {
        FILE * fp = fopen(file_name, "wb");
        vx_uint32 width, height, i;
        vx_imagepatch_addressing_t image_addr;
        vx_rectangle_t rect;
        vx_map_id map_id;
        void *data_ptr;
        vx_uint32 num_bytes_per_pixel = 2; /*Supports only RAW12b Unpacked format*/
        vx_uint32 num_bytes_written_to_file;
        tivx_raw_image_format_t format;
        vx_uint32 imgaddr_width, imgaddr_height, imgaddr_stride;
    
        if(!fp)
        {
            APP_PRINTF("Unable to open file %s\n", file_name);
            return -1;
        }
    
        tivxQueryRawImage(raw_image, TIVX_RAW_IMAGE_WIDTH, &width, sizeof(vx_uint32));
        tivxQueryRawImage(raw_image, TIVX_RAW_IMAGE_HEIGHT, &height, sizeof(vx_uint32));
        tivxQueryRawImage(raw_image, TIVX_RAW_IMAGE_FORMAT, &format, sizeof(format));
    
        APP_PRINTF("in width =  %d\n", width);
        APP_PRINTF("in height =  %d\n", height);
        APP_PRINTF("in format =  %d\n", format.pixel_container);
    
        rect.start_x = 0;
        rect.start_y = 0;
        rect.end_x = width;
        rect.end_y = height;
    
        tivxMapRawImagePatch(raw_image,
            &rect,
            0,
            &map_id,
            &image_addr,
            &data_ptr,
            VX_READ_ONLY,
            VX_MEMORY_TYPE_HOST,
            TIVX_RAW_IMAGE_PIXEL_BUFFER
            );
    
        if(!data_ptr)
        {
            APP_PRINTF("data_ptr is NULL \n");
            fclose(fp);
            return -1;
        }
        num_bytes_written_to_file = 0;
    
        imgaddr_width  = image_addr.dim_x;
        imgaddr_height = image_addr.dim_y;
        imgaddr_stride = image_addr.stride_y;
    
        for(i=0;i<imgaddr_height;i++)
        {
            num_bytes_written_to_file += fwrite(data_ptr, 1, imgaddr_width*num_bytes_per_pixel, fp);
            data_ptr += imgaddr_stride;
        }
    
        tivxUnmapRawImagePatch(raw_image, map_id);
    
        fflush(fp);
        fclose(fp);
        APP_PRINTF("%d bytes written to %s\n", num_bytes_written_to_file, file_name);
        return num_bytes_written_to_file;
    }
    
    vx_int32 write_h3a_image(char * file_name, vx_user_data_object out_h3a)
    {
        FILE * fp = fopen(file_name, "wb");
        tivx_h3a_data_t *h3a_data = NULL;
        vx_map_id h3a_buf_map_id;
        vx_uint8 *h3a_payload = NULL;
        vx_uint32 h3a_size = 0;
        if(!fp)
        {
            APP_PRINTF("Unable to open file %s\n", file_name);
            return -1;
        }
    
        vxMapUserDataObject(
                out_h3a,
                0,
                sizeof(tivx_h3a_data_t),
                &h3a_buf_map_id,
                (void **)&h3a_data,
                VX_READ_ONLY,
                VX_MEMORY_TYPE_HOST,
                0
            );
    
        h3a_payload = h3a_data->data;// + 12; /*C model 12-byte header*/
        h3a_size = fwrite(h3a_payload, 1, TIVX_VPAC_VISS_MAX_H3A_STAT_NUMBYTES, fp);
        APP_PRINTF("%d bytes saved from H3A output buffer \n", h3a_size);
        fflush(fp);
        fclose(fp);
        vxUnmapUserDataObject(out_h3a, h3a_buf_map_id);
    
        return h3a_size;
    }
    
    vx_status app_create_ldc(AppObj *obj, vx_image ldc_in_image)
    {
        uint32_t sensor_dcc_enabled = 1;
        vx_status status = VX_SUCCESS;
        uint32_t table_width, table_height;
        vx_imagepatch_addressing_t image_addr;
        vx_rectangle_t rect;
        int32_t dcc_buff_size = 0;
        int32_t dcc_buff_size_driver = 0;
    
    #ifdef x86_64
        int32_t dcc_buff_size_fs = 0;
    #endif
    
        const vx_char dcc_ldc_user_data_object_name[] = "dcc_ldc";
        vx_map_id dcc_ldc_buf_map_id;
        uint8_t * dcc_ldc_buf;
        uint32_t sensor_wdr_enabled = 1;
    
        printf ("Creating LDC \n");
    
        obj->dcc_param_ldc = NULL;
        if (1 == sensor_dcc_enabled)
        {
            dcc_buff_size_driver = appIssGetDCCSizeLDC(obj->sensor_name, sensor_wdr_enabled);
    
            if(dcc_buff_size_driver > 0)
            {
                dcc_buff_size += dcc_buff_size_driver;
            }
            else
            {
                dcc_buff_size_driver = 0;
            }
    
    #ifdef x86_64
            dcc_buff_size_fs = obj->fs_dcc_numbytes_ldc;
            if(dcc_buff_size_fs > 0)
            {
                dcc_buff_size += dcc_buff_size_fs;
            }
    #endif
    
            if (dcc_buff_size <= 0)
            {
                printf("Invalid DCC size for LDC. Disabling DCC \n");
                obj->dcc_param_ldc = NULL;
            }
            else
            {
                obj->dcc_param_ldc = vxCreateUserDataObject(
                        obj->context,
                        (const vx_char*)&dcc_ldc_user_data_object_name,
                        dcc_buff_size,
                        NULL
                        );
    
                if(status == VX_SUCCESS)
                {
                    status = vxMapUserDataObject(
                                    obj->dcc_param_ldc,
                                    0,
                                    dcc_buff_size,
                                    &dcc_ldc_buf_map_id,
                                    (void **)&dcc_ldc_buf,
                                    VX_WRITE_ONLY,
                                    VX_MEMORY_TYPE_HOST,
                                    0
                             );
                }
                if(status == VX_SUCCESS)
                {
                    status = appIssGetDCCBuffLDC(obj->sensor_name, sensor_wdr_enabled,  dcc_ldc_buf, dcc_buff_size_driver);
                    if(status != VX_SUCCESS)
                    {
                            printf("Couldn't get LDC DCC buffer from sensor driver \n");
                    }
    
    #ifdef x86_64
                    if(dcc_buff_size_fs > 0)
                    {
                        memcpy(dcc_ldc_buf+dcc_buff_size_driver, obj->fs_dcc_buf_ldc, dcc_buff_size_fs);
                    }
    #endif
                    if(status == VX_SUCCESS)
                    {
                        vxUnmapUserDataObject(obj->dcc_param_ldc, dcc_ldc_buf_map_id);
                    }
                }
            }
        }
    
        table_width = (((obj->table_width / (1 << obj->ds_factor)) + 1u) + 15u) & (~15u);
        table_height = ((obj->table_height / (1 << obj->ds_factor)) + 1u);
        /* Mesh Image */
        obj->mesh_img = vxCreateImage(obj->context,table_width, table_height, VX_DF_IMAGE_U32);
    
        /* Copy Mesh table */
        rect.start_x = 0;
        rect.start_y = 0;
        rect.end_x = table_width;
        rect.end_y = table_height;
    
        image_addr.dim_x = table_width;
        image_addr.dim_y = table_height;
        image_addr.stride_x = 4u;
        image_addr.stride_y = table_width * 4u;
        if(status == VX_SUCCESS)
        {
            status = vxCopyImagePatch(obj->mesh_img, &rect, 0, &image_addr,
                ldc_lut, VX_WRITE_ONLY, VX_MEMORY_TYPE_HOST);
        }
        if (VX_SUCCESS != status)
        {
            APP_PRINTF("Copy Image Failed\n");
        }
    
        /* LDC Output image in NV12 format */
        obj->ldc_out = vxCreateImage(obj->context,
            obj->table_width, obj->table_height,
            VX_DF_IMAGE_NV12);
    
        /* Mesh Parameters */
        obj->mesh_params_obj = vxCreateUserDataObject(obj->context,
            "tivx_vpac_ldc_mesh_params_t", sizeof(tivx_vpac_ldc_mesh_params_t), NULL);
        memset(&obj->mesh_params, 0, sizeof(tivx_vpac_ldc_mesh_params_t));
    
        tivx_vpac_ldc_mesh_params_init(&obj->mesh_params);
        obj->mesh_params.mesh_frame_width = obj->table_width;
        obj->mesh_params.mesh_frame_height = obj->table_height;
        obj->mesh_params.subsample_factor = obj->ds_factor;
        if(status == VX_SUCCESS)
        {
            status = vxCopyUserDataObject(obj->mesh_params_obj, 0,
                            sizeof(tivx_vpac_ldc_mesh_params_t), &obj->mesh_params,
                            VX_WRITE_ONLY, VX_MEMORY_TYPE_HOST);
        }
        /* Block Size parameters */
        obj->region_params_obj = vxCreateUserDataObject(obj->context,
            "tivx_vpac_ldc_region_params_t", sizeof(tivx_vpac_ldc_region_params_t),
            NULL);
        obj->region_params.out_block_width = LDC_BLOCK_WIDTH;
        obj->region_params.out_block_height = LDC_BLOCK_HEIGHT;
        obj->region_params.pixel_pad = LDC_PIXEL_PAD;
        if(status == VX_SUCCESS)
        {
            status = vxCopyUserDataObject(obj->region_params_obj, 0,
                        sizeof(tivx_vpac_ldc_region_params_t), &obj->region_params,
                        VX_WRITE_ONLY, VX_MEMORY_TYPE_HOST);
        }
        /* LDC Configuration */
        tivx_vpac_ldc_params_init(&obj->ldc_params);
        obj->ldc_params.luma_interpolation_type = 1;
    
        obj->ldc_params.dcc_camera_id = obj->cam_dcc_id;
    
        obj->ldc_param_obj = vxCreateUserDataObject(obj->context,
            "tivx_vpac_ldc_params_t", sizeof(tivx_vpac_ldc_params_t), NULL);
        if(status == VX_SUCCESS)
        {
            status = vxCopyUserDataObject(obj->ldc_param_obj, 0, sizeof(tivx_vpac_ldc_params_t),
                            &obj->ldc_params, VX_WRITE_ONLY, VX_MEMORY_TYPE_HOST);
        }
    
        if (NULL == obj->dcc_param_ldc)
        {
            obj->node_ldc = tivxVpacLdcNode(obj->graph, obj->ldc_param_obj, NULL,
                    obj->region_params_obj, obj->mesh_params_obj,
                    obj->mesh_img, NULL, ldc_in_image,
                    obj->ldc_out, NULL);
        }
        else
        {
            obj->node_ldc = tivxVpacLdcNode(obj->graph, obj->ldc_param_obj, NULL,
                    NULL, NULL,
                    NULL, obj->dcc_param_ldc, ldc_in_image,
                    obj->ldc_out, NULL);
        }
        return status;
    }
    
    vx_status app_delete_ldc(AppObj *obj)
    {
    #ifdef x86_64
        if(NULL != obj->fs_dcc_buf_ldc)
        {
            APP_PRINTF("freeing fs_dcc_buf_ldc\n");
            free(obj->fs_dcc_buf_ldc);
        }
    #endif
    
        if(NULL != obj->dcc_param_ldc)
        {
            vxReleaseUserDataObject(&obj->dcc_param_ldc);
        }
    
        if(NULL != obj->mesh_img)
        {
            vxReleaseImage(&obj->mesh_img);
        }
    
        if(NULL != obj->ldc_out)
        {
            vxReleaseImage(&obj->ldc_out);
        }
    
        if(NULL != obj->mesh_params_obj)
        {
            vxReleaseUserDataObject(&obj->mesh_params_obj);
        }
    
        if(NULL != obj->region_params_obj)
        {
            vxReleaseUserDataObject(&obj->region_params_obj);
        }
    
        if(NULL != obj->ldc_param_obj)
        {
            vxReleaseUserDataObject(&obj->ldc_param_obj);
        }
    
        if(NULL != obj->node_ldc)
        {
            vxReleaseNode(&obj->node_ldc);
        }
    
        return VX_SUCCESS;
    }
    
    vx_status app_create_viss(AppObj *obj, uint32_t sensor_wdr_mode)
    {
        vx_status status = VX_SUCCESS;
        vx_uint32 sensor_dcc_enabled = 1;
    
        const vx_char dcc_viss_user_data_object_name[] = "dcc_viss";
        uint8_t * dcc_viss_buf;
        vx_map_id dcc_viss_buf_map_id;
        unsigned int image_width;
        unsigned int image_height;
        int32_t dcc_buff_size = 0;
        int32_t dcc_buff_size_driver;
    
    #ifdef x86_64
        int32_t dcc_buff_size_fs;
    #endif
        vx_uint32 sensor_wdr_enabled = sensor_wdr_mode;
    
        image_width = obj->width_in;
        image_height = obj->height_in;
    
        obj->num_viss_out_buf = 3;
        obj->y8_r8_c2 = vxCreateImage(obj->context, image_width, image_height, VX_DF_IMAGE_UYVY);
        obj->uv8_g8_c3 = NULL;
    
        obj->y12 = NULL;
        obj->uv12_c1 = NULL;
    
    #ifdef VPAC3
        /* YUV12 output from dual CC for MV */
        if (obj->vpac3_dual_fcp_enable)
        {
            obj->y12 = vxCreateImage(obj->context, image_width, image_height, TIVX_DF_IMAGE_NV12_P12);
            obj->uv12_c1 = NULL;
        }
    #endif
    
        obj->s8_b8_c4 = NULL;
        obj->histogram = NULL;
    
        /* VISS Initialize parameters */
        tivx_vpac_viss_params_init(&obj->viss_params);
        obj->viss_params.sensor_dcc_id = obj->cam_dcc_id;
        printf("app_create_viss : sensor_dcc_id = %d \n", obj->viss_params.sensor_dcc_id);
        obj->viss_params.fcp[0].ee_mode = 0;
        obj->viss_params.fcp[0].mux_output0 = 0;
        obj->viss_params.fcp[0].mux_output1 = 0;
        obj->viss_params.fcp[0].mux_output2 = 4;
        obj->viss_params.fcp[0].mux_output3 = 0;
        obj->viss_params.fcp[0].mux_output4 = 3;
        obj->viss_params.h3a_in = 3;
        obj->viss_params.h3a_aewb_af_mode = 0;
        obj->viss_params.channel_id = obj->selectedCam;
        obj->viss_params.fcp[0].chroma_mode = 0;
    
    #ifdef VPAC3
        /* turn on CAC, dual FCP, and YUV12 output */
        if (obj->vpac3_dual_fcp_enable)
        {
            obj->viss_params.bypass_cac = 0;  /* CAC on */
            obj->viss_params.fcp1_config = 1; /* RAWFE --> FCP1 */
            obj->viss_params.fcp[0].mux_output2 = TIVX_VPAC_VISS_MUX2_NV12;
    
            obj->viss_params.output_fcp_mapping[0] = 1;
            obj->viss_params.output_fcp_mapping[1] = 1;
            obj->viss_params.output_fcp_mapping[2] = 2;
            obj->viss_params.output_fcp_mapping[3] = 2;
            obj->viss_params.output_fcp_mapping[4] = 1;
    
            obj->viss_params.fcp[1].mux_output0 = TIVX_VPAC_VISS_MUX0_NV12_P12;
            obj->viss_params.fcp[1].mux_output1 = TIVX_VPAC_VISS_MUX0_NV12_P12;
            obj->viss_params.fcp[1].mux_output2 = 4;
            obj->viss_params.fcp[1].mux_output3 = 0;
            obj->viss_params.fcp[1].mux_output4 = 3;
    
            obj->viss_params.fcp[1].ee_mode = 0;
            obj->viss_params.fcp[1].chroma_mode = 0;
        }
    #endif
    
        obj->viss_params.enable_ctx = 1;
    
        if(sensor_wdr_enabled == 1)
        {
            obj->viss_params.bypass_glbce = 0;
        }else
        {
            obj->viss_params.bypass_glbce = 1;
        }
        obj->viss_params.bypass_nsf4 = 0;
        obj->configuration = vxCreateUserDataObject(obj->context, "tivx_vpac_viss_params_t", sizeof(tivx_vpac_viss_params_t), &obj->viss_params);
    
        /* Create h3a_aew_af output buffer (uninitialized) */
        obj->h3a_aew_af = vxCreateUserDataObject(obj->context, "tivx_h3a_data_t", sizeof(tivx_h3a_data_t), NULL);
    
        if(sensor_dcc_enabled)
        {
            dcc_buff_size_driver = appIssGetDCCSizeVISS(obj->sensor_name, sensor_wdr_enabled);
            if(dcc_buff_size_driver > 0)
            {
                dcc_buff_size += dcc_buff_size_driver;
            }
            else
            {
                dcc_buff_size_driver = 0;
            }
    
    #ifdef x86_64
            dcc_buff_size_fs = obj->fs_dcc_numbytes_viss;
            if(dcc_buff_size_fs > 0)
            {
                dcc_buff_size += dcc_buff_size_fs;
            }
    #endif
    
            if(dcc_buff_size<=0)
            {
                printf("Invalid DCC size for VISS. Disabling DCC \n");
                obj->dcc_param_viss = NULL;
            }
            else
            {
                obj->dcc_param_viss = vxCreateUserDataObject(
                    obj->context,
                    (const vx_char*)&dcc_viss_user_data_object_name,
                    dcc_buff_size,
                    NULL
                );
                vxMapUserDataObject(
                        obj->dcc_param_viss,
                        0,
                        dcc_buff_size,
                        &dcc_viss_buf_map_id,
                        (void **)&dcc_viss_buf,
                        VX_WRITE_ONLY,
                        VX_MEMORY_TYPE_HOST,
                        0
                    );
    
                if(dcc_buff_size_driver > 0)
                {
                    status = appIssGetDCCBuffVISS(obj->sensor_name, sensor_wdr_enabled, dcc_viss_buf, dcc_buff_size_driver);
                    if(status != VX_SUCCESS)
                    {
                        printf("Couldn't get VISS DCC buffer from sensor driver \n");
                    }
                }
    
    #ifdef x86_64
    
                if(dcc_buff_size_fs> 0)
                {
                    memcpy(dcc_viss_buf+dcc_buff_size_driver, obj->fs_dcc_buf_viss, dcc_buff_size_fs);
                }
    #endif
                if(obj->dcc_param_viss)
                {
                    vxUnmapUserDataObject(obj->dcc_param_viss, dcc_viss_buf_map_id);
                }
            }
        }else
        {
            obj->dcc_param_viss = NULL;
        }
    
        obj->node_viss = tivxVpacVissNode(
                                    obj->graph,
                                    obj->configuration,
                                    NULL,
                                    obj->dcc_param_viss,
                                    obj->raw, obj->y12, NULL,
                                    obj->y8_r8_c2, NULL, NULL,
                                    obj->h3a_aew_af, NULL, NULL, NULL
                );
    
        vxSetReferenceName((vx_reference)obj->node_viss, "VISS_Processing");
    
        return status;
    }
    
    vx_status app_delete_viss(AppObj *obj)
    {
        vx_status status = VX_SUCCESS;
        uint32_t buf_id;
    
    #ifdef x86_64
        if(NULL != obj->fs_dcc_buf_viss)
        {
            APP_PRINTF("freeing fs_dcc_buf_viss\n");
            free(obj->fs_dcc_buf_viss);
        }
    #endif
    
        if(NULL != obj->node_viss)
        {
            APP_PRINTF("releasing node_viss\n");
            status |= vxReleaseNode(&obj->node_viss);
        }
    
        for(buf_id=0; buf_id<obj->num_viss_out_buf; buf_id++)
        {
          if(NULL != obj->viss_out_luma[buf_id])
          {
            APP_PRINTF("releasing y8 buffer # %d\n", buf_id);
            status |= vxReleaseImage(&(obj->viss_out_luma[buf_id]));
          }
        }
    
        if(NULL != obj->y12)
        {
            APP_PRINTF("releasing y12\n");
            status |= vxReleaseImage(&obj->y12);
        }
    
        if(NULL != obj->uv12_c1)
        {
            APP_PRINTF("releasing uv12_c1\n");
            status |= vxReleaseImage(&obj->uv12_c1);
        }
    
        if(NULL != obj->s8_b8_c4)
        {
            APP_PRINTF("releasing s8_b8_c4\n");
            status |= vxReleaseImage(&obj->s8_b8_c4);
        }
    
        if(NULL != obj->y8_r8_c2)
        {
            APP_PRINTF("releasing y8_r8_c2\n");
            status |= vxReleaseImage(&obj->y8_r8_c2);
        }
    
        if(NULL != obj->uv8_g8_c3)
        {
            APP_PRINTF("releasing uv8_g8_c3\n");
            status |= vxReleaseImage(&obj->uv8_g8_c3);
        }
    
        if(NULL != obj->histogram)
        {
            APP_PRINTF("releasing histogram\n");
            status |= vxReleaseDistribution(&obj->histogram);
        }
    
        if(NULL != obj->configuration)
        {
            APP_PRINTF("releasing configuration\n");
            status |= vxReleaseUserDataObject(&obj->configuration);
    
        }
    
        if(NULL != obj->dcc_param_viss)
        {
            APP_PRINTF("releasing VISS DCC Data Object\n");
            status |= vxReleaseUserDataObject(&obj->dcc_param_viss);
        }
    
        if(NULL != obj->h3a_aew_af)
        {
            APP_PRINTF("releasing h3a_aew_af\n");
            status |= vxReleaseUserDataObject(&obj->h3a_aew_af);
        }
    
        return status;
    }
    
    vx_status app_create_aewb(AppObj *obj, uint32_t sensor_wdr_mode)
    {
        vx_status status = VX_SUCCESS;
        int32_t dcc_buff_size = 0;
        int32_t dcc_buff_size_driver = 0;
    
    #ifdef x86_64
        int32_t dcc_buff_size_fs = 0;
    #endif
    
        const vx_char dcc_2a_user_data_object_name[] = "dcc_2a";
        uint8_t * dcc_2a_buf;
        vx_map_id dcc_2a_buf_map_id;
        vx_int32 sensor_dcc_enabled = 1;
    
        obj->aewb_cfg.sensor_dcc_id = obj->cam_dcc_id;
        obj->aewb_cfg.sensor_img_format = 0;
        obj->aewb_cfg.sensor_img_phase = 3;
        obj->aewb_cfg.awb_num_skip_frames = 0;
        obj->aewb_cfg.ae_num_skip_frames = 0;
        obj->aewb_cfg.channel_id = obj->selectedCam;
    
        obj->aewb_config = vxCreateUserDataObject(obj->context, "tivx_aewb_config_t", sizeof(tivx_aewb_config_t), &obj->aewb_cfg);
    
        if(sensor_dcc_enabled)
        {
            dcc_buff_size_driver = appIssGetDCCSize2A(obj->sensor_name, sensor_wdr_mode);
    
            if(dcc_buff_size_driver > 0)
            {
                dcc_buff_size += dcc_buff_size_driver;
            }
            else
            {
                dcc_buff_size_driver = 0;
            }
    
    #ifdef x86_64
            dcc_buff_size_fs = obj->fs_dcc_numbytes_2a;
            if(dcc_buff_size_fs > 0)
            {
                dcc_buff_size += dcc_buff_size_fs;
            }
    #endif
    
            if(dcc_buff_size<=0)
            {
                printf("Invalid DCC size for 2A. Disabling DCC \n");
                obj->dcc_param_2a = NULL;
            }
            else
            {
                obj->dcc_param_2a = vxCreateUserDataObject(
                    obj->context,
                    (const vx_char*)&dcc_2a_user_data_object_name,
                    dcc_buff_size,
                    NULL
                );
                if(status == VX_SUCCESS)
                {
                    status = vxMapUserDataObject(
                                        obj->dcc_param_2a,
                                        0,
                                        dcc_buff_size,
                                        &dcc_2a_buf_map_id,
                                        (void **)&dcc_2a_buf,
                                        VX_WRITE_ONLY,
                                        VX_MEMORY_TYPE_HOST,
                                        0
                                    );
                }
    
                if(status == VX_SUCCESS)
                {
                    status = appIssGetDCCBuff2A(obj->sensor_name, sensor_wdr_mode,  dcc_2a_buf, dcc_buff_size_driver);
                    if(status != VX_SUCCESS)
                    {
                        printf("Couldn't get 2A DCC buffer from sensor driver \n");
                        status = VX_SUCCESS;
                    }
    
    #ifdef x86_64
                    if(dcc_buff_size_fs> 0)
                    {
                        memcpy(dcc_2a_buf+dcc_buff_size_driver, obj->fs_dcc_buf_2a, dcc_buff_size_fs);
                    }
    #endif
                }
                vxUnmapUserDataObject(obj->dcc_param_2a, dcc_2a_buf_map_id);
            }
        }
        else
        {
            obj->dcc_param_2a = NULL;
        }
    
        obj->ae_awb_result =
                vxCreateUserDataObject(obj->context, "tivx_ae_awb_params_t",
                sizeof(tivx_ae_awb_params_t), NULL);
        if (vxGetStatus((vx_reference)obj->ae_awb_result) != VX_SUCCESS)
        {
            APP_PRINTF("obj->ae_awb_result) create failed\n");
            return VX_FAILURE;
        }
    
        obj->node_aewb = tivxAewbNode(obj->graph,
                                          obj->aewb_config,
                                          obj->histogram,
                                          obj->h3a_aew_af,
                                          NULL,
                                          obj->ae_awb_result,
                                          obj->dcc_param_2a);
        vxSetNodeTarget(obj->node_aewb, VX_TARGET_STRING, TIVX_TARGET_MCU2_0);
        tivxSetNodeParameterNumBufByIndex(obj->node_aewb, 4u, NUM_BUFS);
        if(NULL != obj->node_aewb)
        {
            vxSetReferenceName((vx_reference)obj->node_aewb, "2A_AlgNode");
        }
        else
        {
            APP_PRINTF("tivxAewbNode returned NULL \n");
            status = VX_FAILURE;
        }
        APP_PRINTF("AEWB Set Reference done\n");
    
        return status;
    }
    
    vx_status app_delete_aewb(AppObj *obj)
    {
        vx_status status = VX_SUCCESS;
    
    #ifdef x86_64
        if(NULL != obj->fs_dcc_buf_2a)
        {
            APP_PRINTF("freeing fs_dcc_buf_2a\n");
            free(obj->fs_dcc_buf_2a);
        }
    #endif
    
        if(obj->ae_awb_result)
        {
            APP_PRINTF("releasing ae_awb_result\n");
            vxReleaseUserDataObject(&obj->ae_awb_result);
        }
    
        if(obj->node_aewb)
        {
            APP_PRINTF("releasing node_aewb\n");
            vxReleaseNode(&obj->node_aewb);
        }
    
        if(obj->aewb_config)
        {
            APP_PRINTF("releasing aewb_config\n");
            vxReleaseUserDataObject(&obj->aewb_config);
        }
    
        if(obj->dcc_param_2a)
        {
            APP_PRINTF("releasing 2A DCC Data Object\n");
            vxReleaseUserDataObject(&obj->dcc_param_2a);
        }
    
        return status;
    }
    
    

    Dear TI expert:

             Now my code runs with an error, which is as follows:

    42.644597 s: VX_ZONE_ERROR:[tivxAddKernelVpacVissValidate:581] params.output_fcp_mapping[2] must be set to output2 for YUYV or UYVY output of output0
    42.644613 s: VX_ZONE_ERROR:[tivxAddKernelVpacVissValidate:583] fcp[0].mux_output2 must be set to TIVX_VPAC_VISS_MUX2_YUV422 for YUYV or UYVY output of output2
    42.644621 s: VX_ZONE_ERROR:[ownGraphNodeKernelValidate:531] node kernel validate failed for kernel com.ti.hwa.vpac_viss at index 2
    42.644628 s: VX_ZONE_ERROR:[vxVerifyGraph:1941] Node kernel Validate failed
    42.644634 s: VX_ZONE_ERROR:[vxVerifyGraph:2109] Graph verify failed

         

    • Please help me see how this problem is caused, Thank you very much.

  • Hi,

    The issue is due to below statement.

    obj->viss_params.fcp[0].mux_output2 = 4;

    Your output image is in UYVY format, as below statement.

    obj->y8_r8_c2 = vxCreateImage(obj->context, image_width, image_height, VX_DF_IMAGE_UYVY);

    But the mux_output2 is set to 4, which is for NV12/YUV420 format. Please change mux value to properly indicate output format. 

    Regards,

    Brijesh 

  •  Dear TI expert:

          When I change the format to VX_DF_IMAGE_YUYV, what should I set the parameters in the box below.

    • Can you list these parameters for me?  Thanks!

  • Please refer to below table in the VISS node documentation.

    According to this table, mux_output2 should be set to value 5 for YUV422 (YUYV or UYVY) output format. 

    Regards,

    Brijesh

  • Dear TI expert:

    mux_output0,mux_output1,mux_output3, mux_output4, mux_output5 What should I set these parameters to?

  • Hi,

    I see you are using Y12 and Y8_C8 output. Any specific reason for using Y12 output? Can you please confirm that Y12 is set to NULL?

    If y12 is not being used, then only mux_output2 should be set, rest all you can set to 0.

    Regards,

    Brijesh

  • Dear TI expert:

     My requirement is to convert the raw image output of the module into VX_DF_IMAGE_YUYV format through viss. 

    Can you tell me how to set the parameters in the red box mentioned above?

  • ok, please set the mux_output2 to value 5 and that should be good enough. 

    Regards,

    Brijesh

  • /*
     *
     * Copyright (c) 2018 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 "app_single_cam_main.h"
    #include <utils/iss/include/app_iss.h>
    #include "app_test.h"
    
    #ifdef A72
    #if defined(LINUX)
    /*ITT server is supported only in target mode and only on Linux*/
    #include <itt_server.h>
    #endif
    #endif
    
    static char availableSensorNames[ISS_SENSORS_MAX_SUPPORTED_SENSOR][ISS_SENSORS_MAX_NAME];
    static vx_uint8 num_sensors_found;
    static IssSensor_CreateParams sensorParams;
    
    #define VX_CALL(fn_call) fn_call
    #define VX_CALL_(ret_code, fn_call) fn_call
    #define VX_CALL_RET(fn_call) fn_call
    
    #define NUM_CAPT_CHANNELS   (4u)
    
    #define CSITX_WDP (0)
    #define CSITX_NODE_W (1)
    //#define CSITX_FORMAT           (VX_DF_IMAGE_YUYV) //VX_DF_IMAGE_UYVY
    #define CSITX_FORMAT           (VX_DF_IMAGE_U16)
    #define NUM_CHANNELS (1)
    #define CSITX_INST_ID       (1U)
    #define CAPT_INST_ID        (1U)
    
    #define CSITX_LANE_BAND_SPEED       (TIVX_CSITX_LANE_BAND_SPEED_950_TO_1000_MBPS)
    #define CSITX_LANE_SPEED_MBPS       (800U)
    #define IMAGE_1920x1300_30P_UYVY    "./test_data/img_viss_0002_uyvy.yuv"
    
    #if (CSITX_NODE_W == 1U)
    
    typedef struct {
        vx_node  csitx_node;
        vx_user_data_object csitx_params_obj;
        tivx_display_params_t csitx_params;
        vx_int32 csitx_option;
        vx_int32 graph_parameter_index;
        vx_char objName[512];
    
    } CsiTxObj;
    
    CsiTxObj gCsiTxObj;
    //static vx_int32 csitx_index;
    static vx_object_array tx_frame = 0;
    static vx_user_data_object csitx_config;
    static tivx_csitx_params_t local_csitx_config;
    static uint32_t  loopCnt;
    static vx_node csitx_node = 0;
    static uint32_t num_refs;
    #endif  
    
    #ifdef _APP_DEBUG_
    static char *app_get_test_file_path()
    {
        char *tivxPlatformGetEnv(char *env_var);
    
        #if defined(SYSBIOS)
        return tivxPlatformGetEnv("VX_TEST_DATA_PATH");
        #else
        return getenv("VX_TEST_DATA_PATH");
        #endif
    }
    #endif //_APP_DEBUG_
    
    /*
     * Utility API used to add a graph parameter from a node, node parameter index
     */
    void add_graph_parameter_by_node_index(vx_graph graph, vx_node node, vx_uint32 node_parameter_index)
    {
        vx_parameter parameter = vxGetParameterByIndex(node, node_parameter_index);
    
        vxAddParameterToGraph(graph, parameter);
        vxReleaseParameter(&parameter);
    }
    
    vx_status app_init(AppObj *obj)
    {
        vx_status status = VX_SUCCESS;
        char* sensor_list[ISS_SENSORS_MAX_SUPPORTED_SENSOR];
        vx_uint8 count = 0;
        char ch = 0xFF;
        vx_uint8 selectedSensor = 0xFF;
        vx_uint8 detectedSensors[ISS_SENSORS_MAX_CHANNEL];
    #ifdef A72
    #if defined(LINUX)
    /*ITT server is supported only in target mode and only on Linux*/
        status = itt_server_init((void*)obj, (void*)save_debug_images, (void*)appSingleCamUpdateVpacDcc);
        if(status != 0)
        {
            printf("Warning : Failed to initialize ITT server. Live tuning will not work \n");
        }
    #endif
    #endif
    
        for(count=0;count<ISS_SENSORS_MAX_CHANNEL;count++)
        {
            detectedSensors[count] = 0xFF;
        }
    
        for(count=0;count<ISS_SENSORS_MAX_SUPPORTED_SENSOR;count++)
        {
            sensor_list[count] = NULL;
        }
    
        obj->stop_task = 0;
        obj->stop_task_done = 0;
        obj->selectedCam = 0xFF;
    
        if(status == VX_SUCCESS)
        {
            obj->context = vxCreateContext();
            status = vxGetStatus((vx_reference) obj->context);
        }
    
        if(status == VX_SUCCESS)
        {
            tivxHwaLoadKernels(obj->context);
            tivxImagingLoadKernels(obj->context);
            APP_PRINTF("tivxImagingLoadKernels done\n");
        }
    
        /*memset(availableSensorNames, 0, ISS_SENSORS_MAX_SUPPORTED_SENSOR*ISS_SENSORS_MAX_NAME);*/
        for(count=0;count<ISS_SENSORS_MAX_SUPPORTED_SENSOR;count++)
        {
            availableSensorNames[count][0] = '\0';
            sensor_list[count] = availableSensorNames[count];
        }
    
        if(status == VX_SUCCESS)
        {
            status = appEnumerateImageSensor(sensor_list, &num_sensors_found);
        }
    
        if(obj->is_interactive)
        {
            selectedSensor = 0xFF;
            obj->selectedCam = 0xFF;
            while(obj->selectedCam == 0xFF)
            {
                printf("Select camera port index 0-%d : ", ISS_SENSORS_MAX_CHANNEL-1);
                ch = getchar();
                obj->selectedCam = ch - '0';
    
                if(obj->selectedCam >= ISS_SENSORS_MAX_CHANNEL)
                {
                    printf("Invalid entry %c. Please choose between 0 and %d \n", ch, ISS_SENSORS_MAX_CHANNEL-1);
                    obj->selectedCam = 0xFF;
                }
    
                while ((obj->selectedCam != 0xFF) && (selectedSensor > (num_sensors_found-1)))
                {
                    printf("%d registered sensor drivers\n", num_sensors_found);
                    for(count=0;count<num_sensors_found;count++)
                    {
                        printf("%c : %s \n", count+'a', sensor_list[count]);
                    }
    
                    printf("Select a sensor above or press '0' to autodetect the sensor : ");
                    ch = getchar();
                    if(ch == '0')
                    {
                        uint8_t num_sensors_detected = 0;
                        uint8_t channel_mask = (1<<obj->selectedCam);
    
                        status = appDetectImageSensor(detectedSensors, &num_sensors_detected, channel_mask);
                        if(0 == status)
                        {
                            selectedSensor = detectedSensors[obj->selectedCam];
                            if(selectedSensor > ISS_SENSORS_MAX_SUPPORTED_SENSOR)
                            {
                                printf("No sensor detected at port %d. Please select another port \n", obj->selectedCam);
                                obj->selectedCam = 0xFF;
                                selectedSensor = 0xFF;
                            }
                        }
                        else
                        {
                            printf("sensor detection at port %d returned error . Please try again \n", obj->selectedCam);
                            obj->selectedCam = 0xFF;
                            selectedSensor = 0xFF;
                        }
                    }
                    else
                    {
                        selectedSensor = ch - 'a';
                        if(selectedSensor > (num_sensors_found-1))
                        {
                            printf("Invalid selection %c. Try again \n", ch);
                        }
                    }
                }
            }
    
            obj->sensor_name = sensor_list[selectedSensor];
            printf("Sensor selected : %s\n", obj->sensor_name);
    
            ch = 0xFF;
            fflush (stdin);
            while ((ch != '0') && (ch != '1'))
            {
                fflush (stdin);
                printf ("LDC Selection Yes(1)/No(0) : ");
                ch = getchar();
            }
    
            obj->ldc_enable = ch - '0';
        }
        else
        {
            selectedSensor = obj->sensor_sel;
            if(selectedSensor > (num_sensors_found-1))
            {
                printf("Invalid sensor selection %d \n", selectedSensor);
                return VX_FAILURE;
            }
        }
    
        obj->sensor_wdr_mode = 0;
    
        obj->table_width = LDC_TABLE_WIDTH;
        obj->table_height = LDC_TABLE_HEIGHT;
        obj->ds_factor = LDC_DS_FACTOR;
    
        /* Display initialization */
        memset(&obj->display_params, 0, sizeof(tivx_display_params_t));
        obj->display_params.opMode = TIVX_KERNEL_DISPLAY_ZERO_BUFFER_COPY_MODE;
        obj->display_params.pipeId = 2;
        obj->display_params.outHeight = 1080;
        obj->display_params.outWidth = 1920;
        obj->display_params.posX = 0;
        obj->display_params.posY = 0;
    
        obj->scaler_enable = vx_false_e;
    
        appPerfPointSetName(&obj->total_perf , "TOTAL");
    
        return status;
    }
    
    vx_status app_deinit(AppObj *obj)
    {
        vx_status status = VX_FAILURE;
        tivxHwaUnLoadKernels(obj->context);
        APP_PRINTF("tivxHwaUnLoadKernels done\n");
    
        tivxImagingUnLoadKernels(obj->context);
        APP_PRINTF("tivxImagingUnLoadKernels done\n");
    
        status = vxReleaseContext(&obj->context);
        if(VX_SUCCESS == status)
        {
            APP_PRINTF("vxReleaseContext done\n");
        }
        else
        {
            printf("Error: vxReleaseContext returned 0x%x \n", status);
        }
        return status;
    }
    
    vx_status app_csitx_load_vximage_from_yuvfile(vx_image image, char *filename)
    {
        vx_status  vxStatus = (vx_status)VX_SUCCESS;
    
        vx_rectangle_t             rect;
        vx_imagepatch_addressing_t image_addr;
        vx_map_id                  map_id;
        void                     * data_ptr;
        vx_uint32                  img_width;
        vx_uint32                  img_height;
        vx_df_image                img_format;
        vx_int32                   j;
    
        FILE *fp= fopen(filename, "rb");
        if(fp==NULL)
        {
            printf("zqq # ERROR: Unable to open input file [%s]\n", filename);
            return(VX_FAILURE);
        }
        else
        {
            printf("zqq opened the file [%s]\n", filename);
        }
    
        vxQueryImage(image, VX_IMAGE_WIDTH, &img_width, sizeof(vx_uint32));
        vxQueryImage(image, VX_IMAGE_HEIGHT, &img_height, sizeof(vx_uint32));
        vxQueryImage(image, VX_IMAGE_FORMAT, &img_format, sizeof(vx_df_image));
        printf("zqq img_width = %d \timg_height = %d \timg_format = %c%c%c%c\n", img_width, img_height, (uint8_t)(img_format&0x000000FF), (uint8_t)((img_format & 0x0000FF00)>> 8), (uint8_t)((img_format & 0x00FF0000)>> 16), (uint8_t)((img_format & 0xFF000000)>> 24));
        rect.start_x = 0;
        rect.start_y = 0;
        rect.end_x = img_width;
        rect.end_y = img_height;
    
        // Copy Luma or Luma+Chroma
        vxStatus = vxMapImagePatch(image,
                                   &rect,
                                   0,
                                   &map_id,
                                   &image_addr,
                                   &data_ptr,
                                   VX_WRITE_ONLY,
                                   VX_MEMORY_TYPE_HOST,
                                   VX_NOGAP_X);
    
        printf("zqq dim_x = %d \tdim_y = %d \tstride_x = %d \tstride_y = %d\n", image_addr.dim_x, image_addr.dim_y, image_addr.stride_x, image_addr.stride_y);
        for (j = 0; j < image_addr.dim_y; j++)
        {
            fread(data_ptr, 1, image_addr.dim_x*image_addr.stride_x, fp);
            data_ptr += image_addr.stride_y;
        }
        vxUnmapImagePatch(image, map_id);
    
        fclose(fp);
        return vxStatus;
    }
    /*
     * Graph,
     *           viss_config
     *               |
     *               v
     * input_img -> VISS -----> LDC -----> output_img
     *
     */
    
    vx_status app_create_graph(AppObj *obj)
    {
        vx_status status = VX_SUCCESS;
        int32_t sensor_init_status = -1;
        obj->configuration = NULL;
        obj->raw = NULL;
        obj->y12 = NULL;
        obj->uv12_c1 = NULL;
        obj->y8_r8_c2 = NULL;
        obj->uv8_g8_c3 = NULL;
        obj->s8_b8_c4 = NULL;
        obj->histogram = NULL;
        obj->h3a_aew_af = NULL;
        obj->display_image = NULL;
    
        unsigned int image_width = obj->width_in;
        unsigned int image_height = obj->height_in;
    
        tivx_raw_image raw_image = 0;
        vx_user_data_object capture_config;
        vx_uint8 num_capture_frames = 1;
        tivx_capture_params_t local_capture_config;
        uint32_t buf_id;
        const vx_char capture_user_data_object_name[] = "tivx_capture_params_t";
        uint32_t sensor_features_enabled = 0;
        uint32_t sensor_features_supported = 0;
        uint32_t sensor_wdr_enabled = 0;
        uint32_t sensor_exp_control_enabled = 0;
        uint32_t sensor_gain_control_enabled = 0;
    
        vx_bool yuv_cam_input = vx_false_e;
        vx_image viss_out_image = NULL;
        vx_image ldc_in_image = NULL;
        vx_image capt_yuv_image = NULL;
    
        uint8_t channel_mask = (1<<obj->selectedCam);
    
        vx_uint32 params_list_depth = 2;
        if(obj->test_mode == 1)
        {
            params_list_depth = 2;
        }
        vx_graph_parameter_queue_params_t graph_parameters_queue_params_list[params_list_depth];
    
        printf("Querying %s \n", obj->sensor_name);
        memset(&sensorParams, 0, sizeof(sensorParams));
        status = appQueryImageSensor(obj->sensor_name, &sensorParams);
        if(VX_SUCCESS != status)
        {
            printf("appQueryImageSensor returned %d\n", status);
            return status;
        }
    
        if(sensorParams.sensorInfo.raw_params.format[0].pixel_container == CSITX_FORMAT)
        {
            yuv_cam_input = vx_true_e;
            printf("YUV Input selected. VISS and AEWB nodes will be bypassed. \n");
        }
    
    
        /*
        Check for supported sensor features.
        It is upto the application to decide which features should be enabled.
        This demo app enables WDR, DCC and 2A if the sensor supports it.
        */
        sensor_features_supported = sensorParams.sensorInfo.features;
    
        if(vx_false_e == yuv_cam_input)
        {
            if(ISS_SENSOR_FEATURE_COMB_COMP_WDR_MODE == (sensor_features_supported & ISS_SENSOR_FEATURE_COMB_COMP_WDR_MODE))
            {
                APP_PRINTF("WDR mode is supported \n");
                sensor_features_enabled |= ISS_SENSOR_FEATURE_COMB_COMP_WDR_MODE;
                sensor_wdr_enabled = 1;
                obj->sensor_wdr_mode = 1;
            }else
            {
                APP_PRINTF("WDR mode is not supported. Defaulting to linear \n");
                sensor_features_enabled |= ISS_SENSOR_FEATURE_LINEAR_MODE;
                sensor_wdr_enabled = 0;
                obj->sensor_wdr_mode = 0;
            }
    
            if(ISS_SENSOR_FEATURE_MANUAL_EXPOSURE == (sensor_features_supported & ISS_SENSOR_FEATURE_MANUAL_EXPOSURE))
            {
                APP_PRINTF("Expsoure control is supported \n");
                sensor_features_enabled |= ISS_SENSOR_FEATURE_MANUAL_EXPOSURE;
                sensor_exp_control_enabled = 1;
            }
    
            if(ISS_SENSOR_FEATURE_MANUAL_GAIN == (sensor_features_supported & ISS_SENSOR_FEATURE_MANUAL_GAIN))
            {
                APP_PRINTF("Gain control is supported \n");
                sensor_features_enabled |= ISS_SENSOR_FEATURE_MANUAL_GAIN;
                sensor_gain_control_enabled = 1;
            }
    
            if(ISS_SENSOR_FEATURE_CFG_UC1 == (sensor_features_supported & ISS_SENSOR_FEATURE_CFG_UC1))
            {
                APP_PRINTF("CMS Usecase is supported \n");
                sensor_features_enabled |= ISS_SENSOR_FEATURE_CFG_UC1;
            }
    
            switch(sensorParams.sensorInfo.aewbMode)
            {
                case ALGORITHMS_ISS_AEWB_MODE_NONE:
                    obj->aewb_cfg.ae_mode = ALGORITHMS_ISS_AE_DISABLED;
                    obj->aewb_cfg.awb_mode = ALGORITHMS_ISS_AWB_DISABLED;
                    break;
                case ALGORITHMS_ISS_AEWB_MODE_AWB:
                    obj->aewb_cfg.ae_mode = ALGORITHMS_ISS_AE_DISABLED;
                    obj->aewb_cfg.awb_mode = ALGORITHMS_ISS_AWB_AUTO;
                    break;
                case ALGORITHMS_ISS_AEWB_MODE_AE:
                    obj->aewb_cfg.ae_mode = ALGORITHMS_ISS_AE_AUTO;
                    obj->aewb_cfg.awb_mode = ALGORITHMS_ISS_AWB_DISABLED;
                    break;
                case ALGORITHMS_ISS_AEWB_MODE_AEWB:
                    obj->aewb_cfg.ae_mode = ALGORITHMS_ISS_AE_AUTO;
                    obj->aewb_cfg.awb_mode = ALGORITHMS_ISS_AWB_AUTO;
                    break;
            }
            if(obj->aewb_cfg.ae_mode == ALGORITHMS_ISS_AE_DISABLED)
            {
                if(sensor_exp_control_enabled || sensor_gain_control_enabled )
                {
                    obj->aewb_cfg.ae_mode = ALGORITHMS_ISS_AE_MANUAL;
                }
            }
    
            APP_PRINTF("obj->aewb_cfg.ae_mode = %d\n", obj->aewb_cfg.ae_mode);
            APP_PRINTF("obj->aewb_cfg.awb_mode = %d\n", obj->aewb_cfg.awb_mode);
    
        }
    
        if(ISS_SENSOR_FEATURE_DCC_SUPPORTED == (sensor_features_supported & ISS_SENSOR_FEATURE_DCC_SUPPORTED))
        {
            sensor_features_enabled |= ISS_SENSOR_FEATURE_DCC_SUPPORTED;
            APP_PRINTF("Sensor DCC is enabled \n");
        }else
        {
            APP_PRINTF("Sensor DCC is NOT enabled \n");
        }
    
        APP_PRINTF("Sensor width = %d\n", sensorParams.sensorInfo.raw_params.width);
        APP_PRINTF("Sensor height = %d\n", sensorParams.sensorInfo.raw_params.height);
        APP_PRINTF("Sensor DCC ID = %d\n", sensorParams.dccId);
        APP_PRINTF("Sensor Supported Features = 0x%x\n", sensor_features_supported);
        APP_PRINTF("Sensor Enabled Features = 0x%x\n", sensor_features_enabled);
        sensor_init_status = appInitImageSensor(obj->sensor_name, sensor_features_enabled, channel_mask);/*Mask = 1 for camera # 0*/
        if(0 != sensor_init_status)
        {
            /* Not returning failure because application may be waiting for
                error/test frame */
            printf("Error initializing sensor %s \n", obj->sensor_name);
        }
    
        image_width     = sensorParams.sensorInfo.raw_params.width;
        image_height    = sensorParams.sensorInfo.raw_params.height;
        obj->cam_dcc_id = sensorParams.dccId;
        obj->width_in = image_width;
        obj->height_in = image_height;
    
    /*
    Assuming same dataformat for all exposures.
    This may not be true for staggered HDR. WIll be handled later
        for(count = 0;count<raw_params.num_exposures;count++)
        {
            memcpy(&(raw_params.format[count]), &(sensorProperties.sensorInfo.dataFormat), sizeof(tivx_raw_image_format_t));
        }
    */
    
    /*
    Sensor driver does not support metadata yet.
    */
    
        APP_PRINTF("Creating graph \n");
    
        obj->graph = vxCreateGraph(obj->context);
        if(status == VX_SUCCESS)
        {
            status = vxGetStatus((vx_reference) obj->graph);
        }
        APP_ASSERT(vx_true_e == tivxIsTargetEnabled(TIVX_TARGET_VPAC_VISS1));
    
        APP_PRINTF("Initializing params for capture node \n");
    
        /* Setting to num buf of capture node */
        obj->num_cap_buf = NUM_BUFS;
    
        if(vx_false_e == yuv_cam_input)
        {
            raw_image = tivxCreateRawImage(obj->context, &sensorParams.sensorInfo.raw_params);
    
            /* allocate Input and Output refs, multiple refs created to allow pipelining of graph */
            for(buf_id=0; buf_id<obj->num_cap_buf; buf_id++)
            {
                if(status == VX_SUCCESS)
                {
                    obj->cap_frames[buf_id] = vxCreateObjectArray(obj->context, (vx_reference)raw_image, num_capture_frames);
                    status = vxGetStatus((vx_reference) obj->cap_frames[buf_id]);
                }
            }
        }
        else
        {
            capt_yuv_image = vxCreateImage(
                                    obj->context,
                                    sensorParams.sensorInfo.raw_params.width,
                                    sensorParams.sensorInfo.raw_params.height,
                                    CSITX_FORMAT
                             );
    
            /* allocate Input and Output refs, multiple refs created to allow pipelining of graph */
            for(buf_id=0; buf_id<obj->num_cap_buf; buf_id++)
            {
                if(status == VX_SUCCESS)
                {
                    obj->cap_frames[buf_id] = vxCreateObjectArray(obj->context, (vx_reference)capt_yuv_image, num_capture_frames);
                    status = vxGetStatus((vx_reference) obj->cap_frames[buf_id]);
                }
            }
        }
    
        /* Config initialization */
        tivx_capture_params_init(&local_capture_config);
    
        local_capture_config.timeout = 33;
        local_capture_config.timeoutInitial = 500;
    
        local_capture_config.numInst  = 2U;/* Configure both instances */
        local_capture_config.numCh = 1U;/* Single cam. Only 1 channel enabled */
        {
            vx_uint8 ch, id, lane, q;
            for(id = 0; id < local_capture_config.numInst; id++)
            {
                local_capture_config.instId[id]                       = id;
                local_capture_config.instCfg[id].enableCsiv2p0Support = (uint32_t)vx_true_e;
                local_capture_config.instCfg[id].numDataLanes         = sensorParams.sensorInfo.numDataLanes;
                local_capture_config.instCfg[id].laneBandSpeed        = sensorParams.sensorInfo.csi_laneBandSpeed;
    
                for (lane = 0; lane < local_capture_config.instCfg[id].numDataLanes; lane++)
                {
                    local_capture_config.instCfg[id].dataLanesMap[lane] = lane + 1;
                }
                for (q = 0; q < NUM_CAPT_CHANNELS; q++)
                {
                    ch = (NUM_CAPT_CHANNELS-1)* id + q;
                    local_capture_config.chVcNum[ch]   = q;
                    local_capture_config.chInstMap[ch] = id;
                }
            }
        }
    
        local_capture_config.chInstMap[0] = obj->selectedCam/NUM_CAPT_CHANNELS;
        local_capture_config.chVcNum[0]   = obj->selectedCam%NUM_CAPT_CHANNELS;
    
        capture_config = vxCreateUserDataObject(obj->context, capture_user_data_object_name, sizeof(tivx_capture_params_t), &local_capture_config);
        APP_PRINTF("capture_config = 0x%p \n", capture_config);
    
        APP_PRINTF("Creating capture node \n");
        obj->capture_node = tivxCaptureNode(obj->graph, capture_config, obj->cap_frames[0]);
        APP_PRINTF("obj->capture_node = 0x%p \n", obj->capture_node);
    
        if(status == VX_SUCCESS)
        {
            status = vxReleaseUserDataObject(&capture_config);
        }
        if(status == VX_SUCCESS)
        {
            status = vxSetNodeTarget(obj->capture_node, VX_TARGET_STRING, TIVX_TARGET_CAPTURE2);
        }
    
        if(vx_false_e == yuv_cam_input)
        {
            obj->raw = (tivx_raw_image)vxGetObjectArrayItem(obj->cap_frames[0], 0);
            if(status == VX_SUCCESS)
            {
                status = tivxReleaseRawImage(&raw_image);
            }
    #ifdef _APP_DEBUG_
    
    
            obj->fs_test_raw_image = tivxCreateRawImage(obj->context, &(sensorParams.sensorInfo.raw_params));
    
            if (NULL != obj->fs_test_raw_image)
            {
                if(status == VX_SUCCESS)
                {
                    status = read_test_image_raw(NULL, obj->fs_test_raw_image, obj->test_mode);
                }
                else
                {
                    status = tivxReleaseRawImage(&obj->fs_test_raw_image);
                    obj->fs_test_raw_image = NULL;
                }
            }
    #endif //_APP_DEBUG_
    
            status = app_create_viss(obj, sensor_wdr_enabled);
            if(VX_SUCCESS == status)
            {
            vxSetNodeTarget(obj->node_viss, VX_TARGET_STRING, TIVX_TARGET_VPAC_VISS1);
            tivxSetNodeParameterNumBufByIndex(obj->node_viss, 6u, obj->num_cap_buf);
            }
            else
            {
                printf("app_create_viss failed \n");
                return -1;
            }
    
            status = app_create_aewb(obj, sensor_wdr_enabled);
            if(VX_SUCCESS != status)
            {
                printf("app_create_aewb failed \n");
                return -1;
            }
            viss_out_image = obj->y8_r8_c2;
            ldc_in_image = viss_out_image;
        }
        else
        {
            obj->capt_yuv_image = (vx_image)vxGetObjectArrayItem(obj->cap_frames[0], 0);
            ldc_in_image = obj->capt_yuv_image;
            vxReleaseImage(&capt_yuv_image);
        }
    
        if (obj->ldc_enable)
        {
            printf ("Enabling LDC \n");
            status = app_create_ldc(obj, ldc_in_image);
    
            if(status == VX_SUCCESS)
            {
                status = vxSetNodeTarget(obj->node_ldc, VX_TARGET_STRING, TIVX_TARGET_VPAC_LDC1);
            }
            else
            {
                printf("app_create_ldc returned error \n");
                return status;
            }
            if(status == VX_SUCCESS)
            {
                status = tivxSetNodeParameterNumBufByIndex(obj->node_ldc, 7u, obj->num_cap_buf);
            }
    
            /*Check if resizing is needed for display*/
            if((obj->table_width >= obj->display_params.outWidth) && (obj->table_height >= obj->display_params.outHeight))
            {
                vx_uint16 scaler_out_w, scaler_out_h;
                obj->scaler_enable = vx_true_e;
                appIssGetResizeParams(obj->table_width, obj->table_height, obj->display_params.outWidth, obj->display_params.outHeight, &scaler_out_w, &scaler_out_h);
                obj->scaler_out_img = vxCreateImage(obj->context, scaler_out_w, scaler_out_h, CSITX_FORMAT);
                obj->scalerNode = tivxVpacMscScaleNode(obj->graph, obj->ldc_out, obj->scaler_out_img, NULL, NULL, NULL, NULL);
                if(status == VX_SUCCESS)
                {
                    status = tivxSetNodeParameterNumBufByIndex(obj->scalerNode, 1u, obj->num_cap_buf);
                }
                obj->display_params.outHeight = scaler_out_h;
                obj->display_params.outWidth = scaler_out_w;
                obj->display_image = obj->scaler_out_img;
            }else /*No resize needed*/
            {
                obj->scaler_enable = vx_false_e;
                obj->display_image = obj->ldc_out;
    
                /* MSC can only downsize. If ldc resolution is lower,
                   display resolution must be set accordingly
                */
                obj->display_params.outWidth = obj->table_width;
                obj->display_params.outHeight = obj->table_height;
            }
        }
        else /*ldc_enable*/
        {
            if(NULL != obj->capt_yuv_image)
            {
                /*MSC does not support YUV422 input*/
                obj->scaler_enable = vx_false_e;
                printf("zqq: set scaler_enable = 0 \n");
            }
            else
            {
    //            if ((image_width != 1920) && (image_height != 1080))
                if ((image_width >= obj->display_params.outWidth) && (image_height >= obj->display_params.outHeight))
                {
                    obj->scaler_enable = vx_true_e;
                    printf("zqq: set scaler_enable = 1 \n");
                }
                else
                {
                    obj->scaler_enable = vx_false_e;
                    /* MSC can only downsize. If viss resolution is lower,
                       display resolution must be set accordingly
                    */
                    obj->display_params.outWidth = image_width;
                    obj->display_params.outHeight = image_height;
                }
            }
    
            if(vx_true_e == obj->scaler_enable)
            {
                vx_uint16 scaler_out_w = 0, scaler_out_h = 0;
    //            appIssGetResizeParams(image_width, image_height, obj->display_params.outWidth, obj->display_params.outHeight, &scaler_out_w, &scaler_out_h);
                obj->scaler_out_img = vxCreateImage(obj->context, 1920, 1080, CSITX_FORMAT);//VX_DF_IMAGE_YUYV
                obj->scalerNode = tivxVpacMscScaleNode(obj->graph, ldc_in_image, obj->scaler_out_img, NULL, NULL, NULL, NULL);
                if(status == VX_SUCCESS)
                {
                    status = tivxSetNodeParameterNumBufByIndex(obj->scalerNode, 1u, obj->num_cap_buf);
                    if(status != 0)
                    {
                        printf("zqq: tivxSetNodeParameterNumBufByIndex error!!! \n");
                    }
                }
                if(status == VX_SUCCESS)
                {
                    status = vxSetNodeTarget(obj->scalerNode, VX_TARGET_STRING, TIVX_TARGET_VPAC_MSC1);
                    if(0 != status )
                    {
                        printf("zqq: vxSetNodeTarget error!!! \n");
                    }
                }
                obj->display_params.outHeight = scaler_out_h;
                obj->display_params.outWidth = scaler_out_w;
                obj->display_image = obj->scaler_out_img;
                printf("zqq: scaler set ok!!! \n");
            }
            else
            {
                obj->display_image = ldc_in_image;
            }
        }  
    //    tx_frame = obj->scaler_out_img;
    //   vx_image csitx_image;
    //    vx_image tx_frame_array_item=0;
    //   uint16_t frmIdx;
    //    csitx_image = vxCreateImage(obj->context, 1920, 1300, CSITX_FORMAT);
    //    csitx_image = obj->capt_yuv_image;
    //    tx_frame = vxCreateObjectArray(obj->context, (vx_reference)csitx_image, NUM_CHANNELS);
    //    csitx_image = (vx_image)vxGetObjectArrayItem(obj->cap_frames[0], 0);
           //tx_frame = vxCreateObjectArray(obj->context, (vx_reference)obj->scaler_out_img, NUM_CHANNELS);
           
        tx_frame = vxCreateObjectArray(obj->context, (vx_reference)viss_out_image, NUM_CHANNELS);
        status = vxGetStatus((vx_reference)tx_frame);
        if (status == VX_SUCCESS){
            printf("zqq tx_frame create done!!!!\n");
        }
    //    printf("zqq start CSITX Config initialization\n");
    
    /*    obj->rect.start_x = 0U;
        obj->rect.start_y = 0U;
        obj->rect.end_x = 1920U;
        obj->rect.end_y = 1300U;
    
        csitx_image = vxCreateImage(obj->context, obj->rect.end_x, obj->rect.end_y, CSITX_FORMAT);
        if (csitx_image == NULL)
        {
            printf("csitx_image create failed\n");
        }
        tx_frame = vxCreateObjectArray(obj->context, (vx_reference)csitx_image, NUM_CHANNELS);
        if (tx_frame == NULL)
        {
            VX_PRINT(VX_ZONE_ERROR, "%s[%d] csitx_frame_obj create failed\n", __FUNCTION__, __LINE__);
        }*/
        vx_map_id map_id;
        vx_int32 i,j;
        vx_imagepatch_addressing_t addr;
        uint16_t *ptr = NULL;
        uint16_t frmIdx;
        vx_image tx_frame_array_item=0;
        vx_rectangle_t rect;
        vx_int16 width, height;
        width = 1920;
        height = 1080;
        rect.start_x = 0;
        rect.start_y = 0;
        rect.end_x = width;
        rect.end_y = height;
        printf("zqq Initializing Transmit Buffers...\n");
        for (frmIdx = 0U ; frmIdx < NUM_CHANNELS ; frmIdx++)
        {
            tx_frame_array_item = (vx_image)vxGetObjectArrayItem(tx_frame , frmIdx);
            printf("zqq vxMapImagePatch start...\n");
            vxMapImagePatch(tx_frame_array_item, &rect, 0, &map_id, &addr, (void **)&ptr, VX_WRITE_ONLY, VX_MEMORY_TYPE_HOST, VX_NOGAP_X);
    //       tivxMapRawImagePatch(tx_frame_array_item, &rect, 0U, &map_id, &addr, (void **)&ptr, VX_WRITE_ONLY, VX_MEMORY_TYPE_HOST, TIVX_RAW_IMAGE_PIXEL_BUFFER);
            printf("zqq vxMapImagePatch end...\n");
            if (ptr != NULL){
                printf("zqq ptr is not null\n");
            }
            for (i = 0; i <height; i++)
            {
                for(j=0; j<width; j++)
                {
                    ptr[((i*width)+j)] = (j + frmIdx);
                }
            }
            /* Do cache operations on each buffer to avoid coherency issues */
            appMemCacheWb(ptr, (width * height * sizeof(uint16_t)));
            VX_CALL(vxUnmapImagePatch(tx_frame_array_item, map_id));
            VX_CALL(vxReleaseImage(&tx_frame_array_item));
        }
    //   for (frmIdx = 0U ; frmIdx < NUM_CHANNELS ; frmIdx++)
    //    {
    //        tx_frame_array_item = (vx_image)vxGetObjectArrayItem(tx_frame , frmIdx);
    //        if (tx_frame_array_item == NULL)
    //        {
    //            VX_PRINT(VX_ZONE_ERROR,"%s[%d]vx_frame_array_item create failed\n", __FUNCTION__, __LINE__);
    //        }
    //        else
    //        {
    //            VX_PRINT(VX_ZONE_INFO, "vxGetObjectArrayItem success\n");
    //        }
    //        app_csitx_load_vximage_from_yuvfile(tx_frame_array_item, IMAGE_1920x1300_30P_UYVY);
    //        status = vxReleaseImage(&tx_frame_array_item);
    //        if(status != VX_SUCCESS)
    //        {
    //            VX_PRINT(VX_ZONE_ERROR, "%s[%d] tx_frame_array_item Release failed\n", __FUNCTION__, __LINE__);
    //        }
    //    }
        printf("zqq Initializing Transmit Buffers Done.\n");
        tivx_csitx_params_init(&local_csitx_config);
        local_csitx_config.numInst = 1U;
        local_csitx_config.numCh = NUM_CHANNELS;
        local_csitx_config.instId[0U] = CSITX_INST_ID;
        local_csitx_config.instCfg[0U].rxCompEnable = (uint32_t)vx_true_e;
        local_csitx_config.instCfg[0U].rxv1p3MapEnable = (uint32_t)vx_true_e;
        local_csitx_config.instCfg[0U].laneBandSpeed = CSITX_LANE_BAND_SPEED;
        local_csitx_config.instCfg[0U].laneSpeedMbps = CSITX_LANE_SPEED_MBPS;
        local_csitx_config.instCfg[0U].numDataLanes = 4U;
        for (loopCnt = 0U; loopCnt < local_csitx_config.instCfg[0U].numDataLanes; loopCnt++)
        {
            local_csitx_config.instCfg[0U].lanePolarityCtrl[loopCnt] = 0u;
        }
    
        for (loopCnt = 0U; loopCnt < NUM_CHANNELS; loopCnt++)
        {
            local_csitx_config.chVcNum[loopCnt]   = loopCnt;
            local_csitx_config.chInstMap[loopCnt] = CSITX_INST_ID;
        }
        csitx_config = vxCreateUserDataObject(obj->context, "tivx_csitx_params_t", sizeof(tivx_csitx_params_t), &local_csitx_config);
        if (csitx_config == NULL)
        {
            printf("zqq:csitx_config create failed\n");
        }
        csitx_node = tivxCsitxNode(obj->graph, csitx_config, tx_frame);
        VX_CALL(vxSetNodeTarget(csitx_node, VX_TARGET_STRING, TIVX_TARGET_CSITX));
        status = vxGetStatus((vx_reference)csitx_node);
        if (status == VX_SUCCESS)
        {
            printf("zqq csitx_node create done!!!!\n");
        }
    
    if (0) {
        if(NULL == obj->display_image)
        {
            printf("Error : Display input is uninitialized \n");
            return VX_FAILURE;
        }
        else
        {
            obj->display_params.posX = (1920U - obj->display_params.outWidth)/2;
            obj->display_params.posY = (1080U - obj->display_params.outHeight)/2;
            obj->display_param_obj = vxCreateUserDataObject(obj->context, "tivx_display_params_t", sizeof(tivx_display_params_t), &obj->display_params);
            obj->displayNode = tivxDisplayNode(obj->graph, obj->display_param_obj, obj->display_image);
        }
    
        if(status == VX_SUCCESS)
        {
            status = vxSetNodeTarget(obj->displayNode, VX_TARGET_STRING, TIVX_TARGET_DISPLAY1);
            APP_PRINTF("Display Set Target done\n");
        }
    }
        int graph_parameter_num = 0;
    
        /* input @ node index 1, becomes graph parameter 0 */
        add_graph_parameter_by_node_index(obj->graph, obj->capture_node, 1);
    
        /* set graph schedule config such that graph parameter @ index 0 is enqueuable */
        graph_parameters_queue_params_list[graph_parameter_num].graph_parameter_index = graph_parameter_num;
        graph_parameters_queue_params_list[graph_parameter_num].refs_list_size = obj->num_cap_buf;
        graph_parameters_queue_params_list[graph_parameter_num].refs_list = (vx_reference*)&(obj->cap_frames[0]);
        graph_parameter_num++;
        printf("zqq add_graph_parameter_by_node_index start:tx_frame!!!\n");
        add_graph_parameter_by_node_index(obj->graph, csitx_node, 1);
    //    csitx_index = graph_parameter_num;
        /* set csitx_graph schedule config such that csitx_graph parameter @ index 0 and 1 are enqueuable */
        graph_parameters_queue_params_list[graph_parameter_num].graph_parameter_index = graph_parameter_num;
        graph_parameters_queue_params_list[graph_parameter_num].refs_list_size = 1;
        graph_parameters_queue_params_list[graph_parameter_num].refs_list = (vx_reference*)&tx_frame;
        graph_parameter_num++;
        printf("zqq add_graph_parameter_by_node_index end:tx_frame!!!\n");
        if(obj->test_mode == 1)
        {
            add_graph_parameter_by_node_index(obj->graph, obj->displayNode, 1);
    
            /* set graph schedule config such that graph parameter @ index 0 is enqueuable */
            graph_parameters_queue_params_list[graph_parameter_num].graph_parameter_index = graph_parameter_num;
            graph_parameters_queue_params_list[graph_parameter_num].refs_list_size = 1;
            graph_parameters_queue_params_list[graph_parameter_num].refs_list = (vx_reference*)&tx_frame;
            graph_parameter_num++;
        }
    
        if(status == VX_SUCCESS)
        {
            status = tivxSetGraphPipelineDepth(obj->graph, obj->num_cap_buf);
           // status = tivxSetGraphPipelineDepth(obj->graph, 10);
        }
    
        /* Schedule mode auto is used, here we dont need to call vxScheduleGraph
         * Graph gets scheduled automatically as refs are enqueued to it
         */
        if(status == VX_SUCCESS)
        {
            status = vxSetGraphScheduleConfig(obj->graph,
                            VX_GRAPH_SCHEDULE_MODE_QUEUE_AUTO,
                            params_list_depth,
                            graph_parameters_queue_params_list
                            );
        }
        APP_PRINTF("vxSetGraphScheduleConfig done\n");
    
        if(status == VX_SUCCESS)
        {
            status = vxVerifyGraph(obj->graph);
        }
    
        if(vx_true_e == obj->scaler_enable)
        {
            tivx_vpac_msc_coefficients_t sc_coeffs;
            vx_reference refs[1];
    
            printf("Scaler is enabled\n");
    
            tivx_vpac_msc_coefficients_params_init(&sc_coeffs, VX_INTERPOLATION_BILINEAR);
    
            obj->sc_coeff_obj = vxCreateUserDataObject(obj->context, "tivx_vpac_msc_coefficients_t", sizeof(tivx_vpac_msc_coefficients_t), NULL);
            if(status == VX_SUCCESS)
            {
                status = vxCopyUserDataObject(obj->sc_coeff_obj, 0, sizeof(tivx_vpac_msc_coefficients_t), &sc_coeffs, VX_WRITE_ONLY, VX_MEMORY_TYPE_HOST);
            }
            refs[0] = (vx_reference)obj->sc_coeff_obj;
            if(status == VX_SUCCESS)
            {
                status = tivxNodeSendCommand(obj->scalerNode, 0u, TIVX_VPAC_MSC_CMD_SET_COEFF, refs, 1u);
            }
        }
        else
        {
            printf("Scaler is disabled\n");
        }
    
        if(status == VX_SUCCESS)
        {
            status = tivxExportGraphToDot(obj->graph, ".", "single_cam_graph");
        }
    
    #ifdef _APP_DEBUG_
        if(vx_false_e == yuv_cam_input)
        {
            if( (NULL != obj->fs_test_raw_image) && (NULL != obj->capture_node) && (status == VX_SUCCESS))
            {
                status = app_send_test_frame(obj->capture_node, obj->fs_test_raw_image);
            }
        }
    #endif //_APP_DEBUG_
    
        APP_PRINTF("app_create_graph exiting\n");
        return status;
    }
    
    vx_status app_delete_graph(AppObj *obj)
    {
        uint32_t buf_id;
        vx_status status = VX_SUCCESS;
    
        if(NULL != obj->capture_node)
        {
            APP_PRINTF("releasing capture node\n");
            status |= vxReleaseNode(&obj->capture_node);
        }
    
        if(NULL != obj->node_viss)
        {
            APP_PRINTF("releasing node_viss\n");
            status |= vxReleaseNode(&obj->node_viss);
        }
    
        if(NULL != obj->node_aewb)
        {
            APP_PRINTF("releasing node_aewb\n");
            status |= vxReleaseNode(&obj->node_aewb);
        }
    
        if(NULL != obj->displayNode)
        {
            APP_PRINTF("releasing displayNode\n");
            status |= vxReleaseNode(&obj->displayNode);
        }
    
        status |= tivxReleaseRawImage(&obj->raw);
        APP_PRINTF("releasing raw image done\n");
    
        for(buf_id=0; buf_id<obj->num_cap_buf; buf_id++)
        {
           if(NULL != obj->cap_frames[buf_id])
           {
            APP_PRINTF("releasing cap_frame # %d\n", buf_id);
            status |= vxReleaseObjectArray(&(obj->cap_frames[buf_id]));
           }
        }
    
        for(buf_id=0; buf_id<obj->num_viss_out_buf; buf_id++)
        {
          if(NULL != obj->viss_out_luma[buf_id])
          {
            APP_PRINTF("releasing y8 buffer # %d\n", buf_id);
            status |= vxReleaseImage(&(obj->viss_out_luma[buf_id]));
          }
        }
    
        if(NULL != obj->capt_yuv_image)
        {
            APP_PRINTF("releasing capt_yuv_image\n");
            status |= vxReleaseImage(&obj->capt_yuv_image);
        }
    
    
        if(NULL != obj->y12)
        {
            APP_PRINTF("releasing y12\n");
            status |= vxReleaseImage(&obj->y12);
        }
    
        if(NULL != obj->uv12_c1)
        {
            APP_PRINTF("releasing uv12_c1\n");
            status |= vxReleaseImage(&obj->uv12_c1);
        }
    
        if(NULL != obj->s8_b8_c4)
        {
            APP_PRINTF("releasing s8_b8_c4\n");
            status |= vxReleaseImage(&obj->s8_b8_c4);
        }
    
        if(NULL != obj->y8_r8_c2)
        {
            APP_PRINTF("releasing y8_r8_c2\n");
            status |= vxReleaseImage(&obj->y8_r8_c2);
        }
    
        if(NULL != obj->uv8_g8_c3)
        {
            APP_PRINTF("releasing uv8_g8_c3\n");
            status |= vxReleaseImage(&obj->uv8_g8_c3);
        }
    
        if(NULL != obj->histogram)
        {
            APP_PRINTF("releasing histogram\n");
            status |= vxReleaseDistribution(&obj->histogram);
        }
    
        if(NULL != obj->configuration)
        {
            APP_PRINTF("releasing configuration\n");
            status |= vxReleaseUserDataObject(&obj->configuration);
    
        }
    
        if (NULL != obj->ae_awb_result)
        {
            status |= vxReleaseUserDataObject(&obj->ae_awb_result);
            APP_PRINTF("releasing ae_awb_result done\n");
        }
    
        if(NULL != obj->h3a_aew_af)
        {
            APP_PRINTF("releasing h3a_aew_af\n");
            status |= vxReleaseUserDataObject(&obj->h3a_aew_af);
        }
    
        if(NULL != obj->aewb_config)
        {
            APP_PRINTF("releasing aewb_config\n");
            status |= vxReleaseUserDataObject(&obj->aewb_config);
        }
    
        if(NULL != obj->dcc_param_viss)
        {
            APP_PRINTF("releasing VISS DCC Data Object\n");
            status |= vxReleaseUserDataObject(&obj->dcc_param_viss);
        }
    
        if(NULL != obj->display_param_obj)
        {
            APP_PRINTF("releasing Display Param Data Object\n");
            status |= vxReleaseUserDataObject(&obj->display_param_obj);
        }
    
        if(NULL != obj->dcc_param_2a)
        {
            APP_PRINTF("releasing 2A DCC Data Object\n");
            status |= vxReleaseUserDataObject(&obj->dcc_param_2a);
        }
    
        if(NULL != obj->dcc_param_ldc)
        {
            APP_PRINTF("releasing LDC DCC Data Object\n");
            status |= vxReleaseUserDataObject(&obj->dcc_param_ldc);
        }
    
        if (obj->ldc_enable)
        {
            if (NULL != obj->mesh_img)
            {
                APP_PRINTF("releasing LDC Mesh Image \n");
                status |= vxReleaseImage(&obj->mesh_img);
            }
    
            if (NULL != obj->ldc_out)
            {
                APP_PRINTF("releasing LDC Output Image \n");
                status |= vxReleaseImage(&obj->ldc_out);
            }
    
            if (NULL != obj->mesh_params_obj)
            {
                APP_PRINTF("releasing LDC Mesh Parameters Object\n");
                status |= vxReleaseUserDataObject(&obj->mesh_params_obj);
            }
    
            if (NULL != obj->ldc_param_obj)
            {
                APP_PRINTF("releasing LDC Parameters Object\n");
                status |= vxReleaseUserDataObject(&obj->ldc_param_obj);
            }
    
            if (NULL != obj->region_params_obj)
            {
                APP_PRINTF("releasing LDC Region Parameters Object\n");
                status |= vxReleaseUserDataObject(&obj->region_params_obj);
            }
    
            if(NULL != obj->node_ldc)
            {
                APP_PRINTF("releasing LDC Node \n");
                status |= vxReleaseNode(&obj->node_ldc);
            }
        }
        if(vx_true_e == obj->scaler_enable)
        {
            if (NULL != obj->scaler_out_img)
            {
                APP_PRINTF("releasing Scaler Output Image \n");
                status |= vxReleaseImage(&obj->scaler_out_img);
            }
    
            if(NULL != obj->scalerNode)
            {
                APP_PRINTF("releasing Scaler Node \n");
                status |= vxReleaseNode(&obj->scalerNode);
            }
    
            if (NULL != obj->sc_coeff_obj)
            {
                APP_PRINTF("release Scalar coefficient data object \n");
                status |= vxReleaseUserDataObject(&obj->sc_coeff_obj);
            }
        }
    
    #ifdef _APP_DEBUG_
        if(NULL != obj->fs_test_raw_image)
        {
            APP_PRINTF("releasing test raw image buffer # %d\n", buf_id);
            status |= tivxReleaseRawImage(&obj->fs_test_raw_image);
        }
    #endif
    
        APP_PRINTF("releasing graph\n");
        status |= vxReleaseGraph(&obj->graph);
        APP_PRINTF("releasing graph done\n");
        return status;
    }
    
    vx_status app_run_graph(AppObj *obj)
    {
        vx_status status = VX_SUCCESS;
        vx_uint32 i;
        vx_uint32 frm_loop_cnt;
    
        uint32_t buf_id;
        uint32_t num_refs_capture;
        vx_object_array out_capture_frames;
    //    int graph_parameter_num = 0;
    
        uint8_t channel_mask = (1<<obj->selectedCam);
    
        if(NULL == obj->sensor_name)
        {
            printf("sensor name is NULL \n");
            return VX_FAILURE;
        }
        status = appStartImageSensor(obj->sensor_name, channel_mask);
        if(status < 0)
        {
            printf("Failed to start sensor %s \n", obj->sensor_name);
            if (NULL != obj->fs_test_raw_image)
            {
                printf("Defaulting to file test mode \n");
                status = 0;
            }
        }
    
    //    graph_parameter_num = 0;
        for(buf_id=0; buf_id<obj->num_cap_buf; buf_id++)
        {
            if(status == VX_SUCCESS)
            {
                status = vxGraphParameterEnqueueReadyRef(obj->graph, 0, (vx_reference*)&(obj->cap_frames[buf_id]), 1);
            }
            /* in order for the graph to finish execution, the
                display still needs to be enqueued 4 times for testing */
    //        if((status == VX_SUCCESS) && (obj->test_mode == 1))
            if(status == VX_SUCCESS)
            {
                status = vxGraphParameterEnqueueReadyRef(obj->graph, 1, (vx_reference*)&tx_frame, 1);
            }
        }
    
        /*
            The application reads and  processes the same image "frm_loop_cnt" times
            The output may change because on VISS, parameters are updated every frame based on AEWB results
            AEWB result is avaialble after 1 frame and is applied after 2 frames
            Therefore, first 2 output images will have wrong colors
        */
        frm_loop_cnt = obj->num_frames_to_run;
        frm_loop_cnt += obj->num_cap_buf;
    
        if(obj->is_interactive)
        {
            /* in interactive mode loop for ever */
            frm_loop_cnt  = 0xFFFFFFFF;
        }
    
    #ifdef A72
    #if defined(LINUX)
    
        appDccUpdatefromFS(obj->sensor_name, obj->sensor_wdr_mode,
                            obj->node_aewb, 0,
                            obj->node_viss, 0,
                            obj->node_ldc, 0,
                            obj->context);
    #endif
    #endif
        printf("zqq frm_loop_cnt %d \n",frm_loop_cnt);
        for(i=0; i<frm_loop_cnt; i++)
        {
    //        vx_image test_image;
            printf("run num %d \n",i);
            appPerfPointBegin(&obj->total_perf);
    //        graph_parameter_num = 0;
            if(status == VX_SUCCESS)
            {
                status = vxGraphParameterDequeueDoneRef(obj->graph, 0, (vx_reference*)&out_capture_frames, 1, &num_refs_capture);
                status = vxGraphParameterDequeueDoneRef(obj->graph, 1, (vx_reference*)&tx_frame, 1, &num_refs);
                printf("zqq vxGraphParameterDequeueDoneRef\n");
            }
    //        graph_parameter_num++;
    
    //        APP_PRINTF(" i %d...\n", i);
    //        graph_parameter_num = 0;
    
            if(status == VX_SUCCESS)
            {
                status = vxGraphParameterEnqueueReadyRef(obj->graph, 0, (vx_reference*)&out_capture_frames, 1);
                
                status = vxGraphParameterEnqueueReadyRef(obj->graph, 1, (vx_reference*)&tx_frame, 1);
                printf("zqq vxGraphParameterEnqueueReadyRef\n");
            }
    //        graph_parameter_num++;
    
            appPerfPointEnd(&obj->total_perf);
    
            if((obj->stop_task) || (status != VX_SUCCESS))
            {
                break;
                printf("zqq vxGraphParameterEnqueue ERROR!!!\n");
            }
        }
    
        if(status == VX_SUCCESS)
        {
            status = vxWaitGraph(obj->graph);
        }
    /* Dequeue buf for pipe down */
    #if 0
        for(buf_id=0; buf_id<obj->num_cap_buf-2; buf_id++)
        {
            APP_PRINTF(" Dequeuing capture # %d...\n", buf_id);
            graph_parameter_num = 0;
            vxGraphParameterDequeueDoneRef(obj->graph, graph_parameter_num, (vx_reference*)&out_capture_frames, 1, &num_refs_capture);
            graph_parameter_num++;
        }
    #endif
        if(status == VX_SUCCESS)
        {
            status = appStopImageSensor(obj->sensor_name, channel_mask);
        }
        return status;
    }
    
    static void app_run_task(void *app_var)
    {
        AppObj *obj = (AppObj *)app_var;
    
        appPerfStatsCpuLoadResetAll();
    
        app_run_graph(obj);
    
        obj->stop_task_done = 1;
    }
    
    static int32_t app_run_task_create(AppObj *obj)
    {
        tivx_task_create_params_t params;
        int32_t status;
    
        tivxTaskSetDefaultCreateParams(&params);
        params.task_main = app_run_task;
        params.app_var = obj;
    
        obj->stop_task_done = 0;
        obj->stop_task = 0;
    
        status = tivxTaskCreate(&obj->task, &params);
    
        return status;
    }
    
    static void app_run_task_delete(AppObj *obj)
    {
        while(obj->stop_task_done==0)
        {
             tivxTaskWaitMsecs(100);
        }
    
        tivxTaskDelete(&obj->task);
    }
    
    static char menu[] = {
        "\n"
        "\n =========================="
        "\n Demo : Single Camera w/ 2A"
        "\n =========================="
        "\n"
        "\n p: Print performance statistics"
        "\n"
    #ifdef _APP_DEBUG_
        "\n s: Save Sensor RAW, VISS Output and H3A output images to File System"
        "\n"
    #endif
        "\n e: Export performance statistics"
    #ifdef A72
    #if defined(LINUX)
        "\n"
        "\n u: Update DCC from File System"
        "\n"
        "\n"
    #endif
    #endif
        "\n x: Exit"
        "\n"
        "\n Enter Choice: "
    };
    
    static vx_status app_run_graph_interactive(AppObj *obj)
    {
        vx_status status;
        uint32_t done = 0;
        char ch;
        FILE *fp;
        app_perf_point_t *perf_arr[1];
        uint8_t channel_mask = (1<<obj->selectedCam);
    
        status = app_run_task_create(obj);
        if(status!=0)
        {
            printf("ERROR: Unable to create task\n");
        }
        else
        {
            appPerfStatsResetAll();
            while(!done && (status == VX_SUCCESS))
            {
                printf(menu);
                ch = getchar();
                printf("\n");
    
                switch(ch)
                {
                    case 'p':
                        appPerfStatsPrintAll();
                        status = tivx_utils_graph_perf_print(obj->graph);
                        appPerfPointPrint(&obj->total_perf);
                        printf("\n");
                        appPerfPointPrintFPS(&obj->total_perf);
                        appPerfPointReset(&obj->total_perf);
                        printf("\n");
                        break;
    #ifdef _APP_DEBUG_
                    case 's':
                        save_debug_images(obj);
                        break;
    #endif
                    case 'e':
                        perf_arr[0] = &obj->total_perf;
                        fp = appPerfStatsExportOpenFile(".", "basic_demos_app_single_cam");
                        if (NULL != fp)
                        {
                            appPerfStatsExportAll(fp, perf_arr, 1);
                            status = tivx_utils_graph_perf_export(fp, obj->graph);
                            appPerfStatsExportCloseFile(fp);
                            appPerfStatsResetAll();
                        }
                        else
                        {
                            printf("fp is null\n");
                        }
                        break;
    #ifdef A72
    #if defined(LINUX)
                    case 'u':
                        appDccUpdatefromFS(obj->sensor_name, obj->sensor_wdr_mode,
                            obj->node_aewb, 0,
                            obj->node_viss, 0,
                            obj->node_ldc, 0,
                            obj->context);
                        break;
    #endif
    #endif
    
                    case 'x':
                        obj->stop_task = 1;
                        done = 1;
                        break;
    
                    default:
                        printf("Unsupported command %c\n", ch);
                        break;
    
                }
            }
            app_run_task_delete(obj);
        }
        if(status == VX_SUCCESS)
        {
            status = appStopImageSensor(obj->sensor_name, channel_mask);
        }
        return status;
    }
    
    static void app_show_usage(int argc, char* argv[])
    {
        printf("\n");
        printf(" Single Camera Demo - (c) Texas Instruments 2019\n");
        printf(" ========================================================\n");
        printf("\n");
        printf(" Usage,\n");
        printf("  %s --cfg <config file>\n", argv[0]);
        printf("\n");
    }
    
    #ifdef A72
    #if defined(LINUX)
    int appSingleCamUpdateVpacDcc(AppObj *obj, uint8_t* dcc_buf, uint32_t dcc_buf_size)
    {
        int32_t status = 0;
    
        status = appUpdateVpacDcc(dcc_buf, dcc_buf_size, obj->context,
                    obj->node_viss, 0,
                    obj->node_aewb, 0,
                    obj->node_ldc, 0
                 );
    
        return status;
    }
    #endif
    #endif
    
    #ifdef _APP_DEBUG_
    int save_debug_images(AppObj *obj)
    {
        int num_bytes_io = 0;
        static int file_index = 0;
        char raw_image_fname[MAX_FNAME];
        char yuv_image_fname[MAX_FNAME];
        char h3a_image_fname[MAX_FNAME];
        char failsafe_test_data_path[3] = "./";
        char * test_data_path = app_get_test_file_path();
        struct stat s;
    
        if(NULL == test_data_path)
        {
            printf("Test data path is NULL. Defaulting to current folder \n");
            test_data_path = failsafe_test_data_path;
        }
    
        if (stat(test_data_path, &s))
        {
            printf("Test data path %s does not exist. Defaulting to current folder \n", test_data_path);
            test_data_path = failsafe_test_data_path;
        }
    
        if(NULL == obj->capt_yuv_image)
        {
            snprintf(raw_image_fname, MAX_FNAME, "%s/%s_%04d.raw", test_data_path, "img", file_index);
            printf("RAW file name %s \n", raw_image_fname);
            num_bytes_io = write_output_image_raw(raw_image_fname, obj->raw);
            if(num_bytes_io < 0)
            {
                printf("Error writing to RAW file \n");
                return VX_FAILURE;
            }
    
            snprintf(yuv_image_fname, MAX_FNAME, "%s/%s_%04d.yuv", test_data_path, "img_viss", file_index);
            printf("YUV file name %s \n", yuv_image_fname);
            num_bytes_io = write_output_image_nv12_8bit(yuv_image_fname, obj->y8_r8_c2);
            if(num_bytes_io < 0)
            {
                printf("Error writing to VISS NV12 file \n");
                return VX_FAILURE;
            }
    
            snprintf(h3a_image_fname, MAX_FNAME, "%s/%s_%04d.bin", test_data_path, "h3a", file_index);
            printf("H3A file name %s \n", h3a_image_fname);
            num_bytes_io = write_h3a_image(h3a_image_fname, obj->h3a_aew_af);
            if(num_bytes_io < 0)
            {
                printf("Error writing to H3A file \n");
                return VX_FAILURE;
            }
    
        }
        else
        {
            vx_image cap_yuv;
            snprintf(raw_image_fname, MAX_FNAME, "%s/%s_%04d.yuv", test_data_path, "cap", file_index);
            printf("YUV file name %s \n", raw_image_fname);
            cap_yuv = (vx_image)vxGetObjectArrayItem(obj->cap_frames[0], 0);
            num_bytes_io = write_output_image_yuv422_8bit(raw_image_fname, cap_yuv);
            if(num_bytes_io < 0)
            {
                printf("Error writing to YUV file \n");
                return VX_FAILURE;
            }
        }
    
        if(obj->scaler_enable)
        {
            snprintf(yuv_image_fname, MAX_FNAME, "%s/%s_%04d.yuv", test_data_path, "img_msc", file_index);
            printf("YUV file name %s \n", yuv_image_fname);
            num_bytes_io = write_output_image_nv12_8bit(yuv_image_fname, obj->scaler_out_img);
            if(num_bytes_io < 0)
            {
                printf("Error writing to MSC NV12 file \n");
                return VX_FAILURE;
            }
        }
    
        if(obj->ldc_enable)
        {
            snprintf(yuv_image_fname, MAX_FNAME, "%s/%s_%04d.yuv", test_data_path, "img_ldc", file_index);
            printf("YUV file name %s \n", yuv_image_fname);
            num_bytes_io = write_output_image_nv12_8bit(yuv_image_fname, obj->ldc_out);
            if(num_bytes_io < 0)
            {
                printf("Error writing to LDC NV12 file \n");
                return VX_FAILURE;
            }
        }
    
        file_index++;
        return (file_index-1);
    }
    #endif //_APP_DEBUG_
    
    static void app_parse_cfg_file(AppObj *obj, char *cfg_file_name)
    {
        FILE *fp = fopen(cfg_file_name, "r");
        char line_str[1024];
        char *token;
    
        if(fp==NULL)
        {
            printf("# ERROR: Unable to open config file [%s]. Switching to interactive mode\n", cfg_file_name);
            obj->is_interactive = 1;
        }
        else
        {
            while(fgets(line_str, sizeof(line_str), fp)!=NULL)
            {
                char s[]=" \t";
    
                if (strchr(line_str, '#'))
                {
                    continue;
                }
    
                /* get the first token */
                token = strtok(line_str, s);
                if (NULL != token)
                {
                    if(strcmp(token, "sensor_index")==0)
                    {
                        token = strtok(NULL, s);
                        if (NULL != token)
                        {
                            obj->sensor_sel = atoi(token);
                            printf("sensor_selection = [%d]\n", obj->sensor_sel);
                        }
                    }
                    else
                    if(strcmp(token, "ldc_enable")==0)
                    {
                        token = strtok(NULL, s);
                        if (NULL != token)
                        {
                            obj->ldc_enable = atoi(token);
                            printf("ldc_enable = [%d]\n", obj->ldc_enable);
                        }
                    }
                    else
                    if(strcmp(token, "num_frames_to_run")==0)
                    {
                        token = strtok(NULL, s);
                        if (NULL != token)
                        {
                            obj->num_frames_to_run = atoi(token);
                            printf("num_frames_to_run = [%d]\n", obj->num_frames_to_run);
                        }
                    }
                    else
                    if(strcmp(token, "is_interactive")==0)
                    {
                        token = strtok(NULL, s);
                        if (NULL != token)
                        {
                            obj->is_interactive = atoi(token);
                            printf("is_interactive = [%d]\n", obj->is_interactive);
                        }
                    }
                    else
                    {
                        APP_PRINTF("Invalid token [%s]\n", token);
                    }
                }
            }
    
            fclose(fp);
        }
    
        if(obj->width_in<128)
            obj->width_in = 128;
        if(obj->height_in<128)
            obj->height_in = 128;
        if(obj->width_out<128)
            obj->width_out = 128;
        if(obj->height_out<128)
            obj->height_out = 128;
    
    }
    
    vx_status app_parse_cmd_line_args(AppObj *obj, int argc, char *argv[])
    {
        vx_bool set_test_mode = vx_false_e;
        vx_int8 sensor_override = 0xFF;
        app_set_cfg_default(obj);
    
        int i;
        if(argc==1)
        {
            app_show_usage(argc, argv);
            printf("Defaulting to interactive mode \n");
            obj->is_interactive = 1;
            return VX_SUCCESS;
        }
    
        for(i=0; i<argc; i++)
        {
            if(strcmp(argv[i], "--cfg")==0)
            {
                i++;
                if(i>=argc)
                {
                    app_show_usage(argc, argv);
                }
                app_parse_cfg_file(obj, argv[i]);
            }
            else
            if(strcmp(argv[i], "--help")==0)
            {
                app_show_usage(argc, argv);
                return VX_FAILURE;
            }
            else
            if(strcmp(argv[i], "--test")==0)
            {
                set_test_mode = vx_true_e;
            }
            else
            if(strcmp(argv[i], "--sensor")==0)
            {
                // check to see if there is another argument following --sensor
                if (argc > i+1)
                {
                    sensor_override = atoi(argv[i+1]);
                    // increment i again to avoid this arg
                    i++;
                }
            }
        }
    
        if(set_test_mode == vx_true_e)
        {
            obj->test_mode = 1;
            obj->is_interactive = 0;
            obj->num_frames_to_run = NUM_FRAMES;
            if (sensor_override != 0xFF)
            {
                obj->sensor_sel = sensor_override;
            }
        }
        return VX_SUCCESS;
    }
    
    
    
    #ifdef _APP_DEBUG_
    vx_int32 write_output_image_nv12(char * file_name, vx_image out_nv12)
    {
        FILE * fp = fopen(file_name, "wb");
        if(!fp)
        {
            APP_PRINTF("Unable to open file %s\n", file_name);
            return -1;
        }
        vx_uint32 len1 = write_output_image_fp(fp, out_nv12);
        fclose(fp);
        APP_PRINTF("%d bytes written to %s\n", len1, file_name);
        return len1;
    }
    #endif
    
    
    AppObj gAppObj;
    
    int app_single_cam_main(int argc, char* argv[])
    {
        AppObj *obj = &gAppObj;
        vx_status status = VX_FAILURE;
        status = app_parse_cmd_line_args(obj, argc, argv);
        if(VX_SUCCESS == status)
        {
            status = app_init(obj);
            if(VX_SUCCESS == status)
            {
                APP_PRINTF("app_init done\n");
                /* Not checking status because application may be waiting for
                    error/test frame */
                app_create_graph(obj);
                if(VX_SUCCESS == status)
                {
                    APP_PRINTF("app_create_graph done\n");
                    if(obj->is_interactive)
                    {
                        status = app_run_graph_interactive(obj);
                    }
                    else
                    {
                        status = app_run_graph(obj);
                    }
                    if(VX_SUCCESS == status)
                    {
                        APP_PRINTF("app_run_graph done\n");
                        status = app_delete_graph(obj);
                        if(VX_SUCCESS == status)
                        {
                            APP_PRINTF("app_delete_graph done\n");
                        }
                        else
                        {
                            printf("Error : app_delete_graph returned 0x%x \n", status);
                        }
                    }
                    else
                    {
                        printf("Error : app_run_graph_xx returned 0x%x \n", status);
                    }
                }
                else
                {
                    printf("Error : app_create_graph returned 0x%x is_interactive =%d  \n", status, obj->is_interactive);
                }
            }
            else
            {
                printf("Error : app_init returned 0x%x \n", status);
            }
            status = app_deinit(obj);
            if(VX_SUCCESS == status)
            {
                APP_PRINTF("app_deinit done\n");
            }
            else
            {
                printf("Error : app_deinit returned 0x%x \n", status);
            }
            appDeInitImageSensor(obj->sensor_name);
        }
        else
        {
            printf("Error: app_parse_cmd_line_args returned 0x%x \n", status);
        }
        if(obj->test_mode == 1)
        {
            if((test_result == vx_false_e) || (status == VX_FAILURE))
            {
                printf("\n\nTEST FAILED\n\n");
                print_new_checksum_structs();
                status = (status == VX_SUCCESS) ? VX_FAILURE : status;
            }
            else
            {
                printf("\n\nTEST PASSED\n\n");
            }
        }
        return status;
    }
    
    vx_status app_send_test_frame(vx_node cap_node, tivx_raw_image raw_img)
    {
        vx_status status = VX_SUCCESS;
    
        status = tivxCaptureRegisterErrorFrame(cap_node, (vx_reference)raw_img);
    
        return status;
    }
    
    
    Dear TI expert:

          I had a problem with my program running, Blocks in :vxGraphParameterDequeueDoneRef (obj - > graph, 0, (vx_reference *) & out_capture_frames, 1, & num_refs_capture);  Can you help me see what's wrong.

  • Hi,

    But this means your capture is working. If the code is blocked here, capture is not getting any frame or it is not able to detect input frames. Is the sensor and SERDES brought up already? If not, first you need to bringup the sensor. Then we can check how to change format in the VISS. 

    Regards

    Brijesh

  • Dear TI expert:

     The sensor and the SERDES are already brought up,I haven't found anything wrong with my viss node, could you please help me check it.

  • Hi,

    But with which application have you brought up CSIRX? Were you able to capture frames in that applicatoin? Can you please use the same settings in this application?

    Because currently, CSIRX is not able to detect the input. 

    Regards,

    Brijesh

  • Dear TI expert:

         this is the current app  brought up CSIRX,I just changed the output format of the viss node and the application blocked.

         I am now setting the output format of the viss node to VX_DF_IMAGE_U16. 

    • Specific parameters are as follows:

    •     obj->num_viss_out_buf = 3;
          obj->y8_r8_c2 = vxCreateImage(obj->context, image_width, image_height, VX_DF_IMAGE_U16);
          obj->uv8_g8_c3 = NULL;

          obj->y12 = NULL;
          obj->uv12_c1 = NULL;


          obj->s8_b8_c4 = NULL;
          obj->histogram = NULL;

          /* VISS Initialize parameters */
          tivx_vpac_viss_params_init(&obj->viss_params);
          obj->viss_params.sensor_dcc_id = obj->cam_dcc_id;
          printf("app_create_viss : sensor_dcc_id = %d \n", obj->viss_params.sensor_dcc_id);
          obj->viss_params.fcp[0].ee_mode = 0;
          obj->viss_params.fcp[0].mux_output0 = 0;
          obj->viss_params.fcp[0].mux_output1 = 0;
          obj->viss_params.fcp[0].mux_output2 = 2;
          obj->viss_params.fcp[0].mux_output3 = 0;
          obj->viss_params.fcp[0].mux_output4 = 3;
          obj->viss_params.h3a_in = 3;
          obj->viss_params.h3a_aewb_af_mode = 0;
          obj->viss_params.channel_id = obj->selectedCam;
          obj->viss_params.fcp[0].chroma_mode = 0;

          Help me see why this configuration is wrong,Thanks.

  • Hi

    Sorry, i did not get it. Do you mean the default example with YUV420/NV12 output format is working fine and you are able to get correct output image? If this is the case, which format do you require from VISS? VISS output format has not dependency on CSIRX and it should not cause hang in CSIRX. 

    Regards,

    Brijesh

  • Dear TI expert:

          yes,I want to output VX DF IMAGE U16 format from the VISS node.Above is my current parameter configuration, help me to check

  • Hi,

    But why do you require U16 output? and what exactly is format required in U16? When you say U16 output format for output2 and mux_output2 set to value 2, it essentially means one of the CFA outputs. Is this what you are looking for? This output is not really validated in the SDK..

    Regards,

    Brijesh

  • Dear TI expert:

    My pipeline is as follows:capture->viss->tivxVpacMscScaleNode->csitx,The capture node outputs raw images。

           But csitx nodes do not support the NV12 format, and tivxVpacMscScaleNode nodes do not support the YUV422 format. I found that both nodes support the VX_DF_IMAGE_U16 format by referring to the API description, so I want the VISS node to output the VX_DF_IMAGE_U16 format directly. Do you have any good suggestions?

  • Hi,

    Well, we can keep the path capture->viss->tivxVpacMscScaleNode same as multi-camera example, configure viss to output NV12/YUV420 format and use Scale node to downscale or convert into mosaic. After this conversion, you can add another node, DSS WB M2M node, to convert NV12/YUV420 format back to YUV422 and then you can connect this to CSITX. This is possible and DSS M2M Node is supported in the sdk. 

    Regards,

    Brijesh

  • Dear TI expert:

    Do you mean to add a DSS M2M Node to my current process and send the output of this node to csitx?

  • Hi,

    Yes, DSS M2M node can convert NV12 image to YUV422 image and YUV422 is be supported in CSITX.

    Regards,

    Brijesh

  • Dear TI expert:

       Is there a examplefor using the DSS M2M node?

     

  • Dear TI expert:

      Is it necessary to combine patch if I want to use DSS M2M node? 

      If yes, please provide it to me as soon as possible, thank you very much

    Regards,

  • Hi,

    Please refer to attached patch, i have added DSS M2M path for format conversion from YUV420 to UYVY just before display in multi-camera example. 

    /cfs-file/__key/communityserver-discussions-components-files/791/8715.0001_2D00_Added_2D00_Format_2D00_Conversion_2D00_module_2D00_at_2D00_end_2D00_of_2D00_mosaic_2D00_in_2D00_M.patch

    Regards,

    Brijesh

  • Dear TI expert:

             Ok, I'll try it。

             Regards,

  • Dear TI expert:

     At present, I use the routine of single-camera example to make modifications, but I don't understand this modification, can you explain it?

    Thanks!

  • Dear TI expert:

    I have tried your patch, and the error is the same as the one I modified yesterday. The error is as follows:

    54.536307 s: VX_ZONE_ERROR:[ownContextSendCmd:799] Command ack message returned failure cmd_status: -7
    54.536333 s: VX_ZONE_ERROR:[ownContextSendCmd:835] tivxEventWait() failed.
    54.536351 s: VX_ZONE_ERROR:[ownNodeKernelInit:527] Target kernel, TIVX_CMD_NODE_CREATE failed for node FmtConvNode
    54.536358 s: VX_ZONE_ERROR:[ownNodeKernelInit:528] Please be sure the target callbacks have been registered for this core
    54.536365 s: VX_ZONE_ERROR:[ownNodeKernelInit:529] If the target callbacks have been registered, please ensure no errors are occurring within the create callback of this kernel
    54.536549 s: VX_ZONE_ERROR:[ownGraphNodeKernelInit:583] kernel init for node 4, kernel com.ti.hwa.displaym2m ... failed !!!
    54.536562 s: VX_ZONE_ERROR:[vxVerifyGraph:2055] Node kernel init failed
    54.536568 s: VX_ZONE_ERROR:[vxVerifyGraph:2109] Graph verify failed

    Enter Choice: [MCU2_0] 54.536095 s: VX_ZONE_ERROR:[ownTargetKernelInstanceAlloc:116] kernel com.ti.hwa.displaym2m has not been registered on this CPU
    [MCU2_0] 54.536162 s: VX_ZONE_ERROR:[ownTargetKernelInstanceAlloc:117] Please register this kernel on the appropriate target core
    [MCU2_0] 54.536215 s: VX_ZONE_ERROR:[ownTargetNodeDescNodeCreate:761] target_kernel_instance is NULL

  • Hi,

    Enter Choice: [MCU2_0] 54.536095 s: VX_ZONE_ERROR:[ownTargetKernelInstanceAlloc:116] kernel com.ti.hwa.displaym2m has not been registered on this CPU

    Which SDK release are you using? Display M2M is supported in the SDK since last two SDK release. I tried it on SDK8.6 and could get multi-camera demo working with this patch.

    At present, I use the routine of single-camera example to make modifications, but I don't understand this modification, can you explain it?

    This is used to tell the framework to allocate number of buffers for this node. 

    Regards,

    Brijesh

  • Dear TI expert:

    This is used to tell the framework to allocate number of buffers for this node.    --->   How to determine the buffer value?

     and the sdk version we use is 8.0.6.

  • Hi,

    This depends on the performance of previous and next node. If both of them are running in real time, usually, you should keep 3 to 4 frames.

    Regards,

    Brijesh

  • Dear TI expert:

            Does our version currently not support DSS M2M nodes? 

    • Can you confirm that for us? Thanks!

  • Dear Brijesh,

            Please help me check the path:  capture(8M RAW)->viss(8M NV12)->tivxVpacMscScaleNode(2M NV12)->DSS M2M(1080P UYVY)->CSITx,  is it right? Thank you very much.

            

           

  • Hi Qin,

    The path is correct. Is MScScale Node used to scale down 8M resolution to 2M? Are you able to get it working? Any issue are you facing in the above path?

    Regards,

    Brijesh

  • Dear  Brijesh,

          MScScale Node is ok,  but after add M2M node,  DSS is stuck:

    MCU1_0] 0.025499 s: ### CPU Frequency = 1000000000 Hz
    [MCU1_0] 0.025546 s: CPU is running FreeRTOS
    [MCU1_0] 0.025573 s: APP: Init ... !!!
    [MCU1_0] 0.025600 s: MEM: Init ... !!!
    [MCU1_0] 0.025642 s: MEM: Created heap (DDR_LOCAL_MEM, id=0, flags=0x00000004) @ d8000000 of size 8388608 bytes !!!
    [MCU1_0] 0.025735 s: MEM: Init ... Done !!!
    [MCU1_0] 0.025764 s: IPC: Init ... !!!
    [MCU1_0] 0.025827 s: IPC: 6 CPUs participating in IPC !!!
    [MCU1_0] 0.025876 s: IPC: Waiting for HLOS to be ready ... !!!
    [MCU1_0] 15.035745 s: IPC: HLOS is ready !!!
    [MCU1_0] 15.057150 s: IPC: Init ... Done !!!
    [MCU1_0] 15.057219 s: APP: Syncing with 5 CPUs ... !!!
    [MCU1_0] 15.686972 s: APP: Syncing with 5 CPUs ... Done !!!
    [MCU1_0] 15.687178 s: REMOTE_SERVICE: Init ... !!!
    [MCU1_0] 15.695454 s: REMOTE_SERVICE: Init ... Done !!!
    [MCU1_0] 15.695539 s: APP: Init ... Done !!!
    [MCU1_0] 15.695577 s: APP: Run ... !!!
    [MCU1_0] 15.695605 s: IPC: Starting echo test ...
    [MCU1_0] 15.699868 s: IPC: Echo status: mpu1_0[x] mcu1_0[s] mcu2_0[x] mcu2_1[x] C7X_1[P] C7X_2[x]
    [MCU1_0] 15.700495 s: APP: Run ... Done !!!
    [MCU1_0] 15.700644 s: IPC: Echo status: mpu1_0[x] mcu1_0[s] mcu2_0[x] mcu2_1[x] C7X_1[P] C7X_2[P]
    [MCU1_0] 15.702229 s: IPC: Echo status: mpu1_0[x] mcu1_0[s] mcu2_0[x] mcu2_1[P] C7X_1[P] C7X_2[P]
    [MCU1_0] 15.703374 s: [MCU1_0] IPC regist cb status = 0
    [MCU1_0] 15.703929 s: can_func_Task create !!!
    [MCU1_0] 15.703981 s: can_func_Task RUN !!!
    [MCU1_0] 15.704013 s: -----CAN--Func TASK run-------
    [MCU1_0] 15.723717 s: CrossBar/Interrupt Configuration done.
    [MCU1_0] 15.723782 s: MCANSS Revision ID:
    [MCU1_0] 15.723812 s: scheme:0x1
    [MCU1_0] 15.723841 s: Business Unit:0x2
    [MCU1_0] 15.723873 s: Module ID:0x8e0
    [MCU1_0] 15.723903 s: RTL Revision:0xa
    [MCU1_0] 15.723933 s: Major Revision:0x1
    [MCU1_0] 15.723964 s: Custom Revision:0x0
    [MCU1_0] 15.723995 s: Minor Revision:0x1
    [MCU1_0] 15.724028 s: CAN-FD operation is enabled through E-Fuse.
    [MCU1_0] 15.724068 s: Endianess Value: 0x87654321
    [MCU1_0] 15.724406 s: CrossBar/Interrupt Configuration done.
    [MCU1_0] 15.724448 s: MCANSS Revision ID:
    [MCU1_0] 15.724475 s: scheme:0x1
    [MCU1_0] 15.724503 s: Business Unit:0x2
    [MCU1_0] 15.724533 s: Module ID:0x8e0
    [MCU1_0] 15.724563 s: RTL Revision:0xa
    [MCU1_0] 15.724593 s: Major Revision:0x1
    [MCU1_0] 15.724623 s: Custom Revision:0x0
    [MCU1_0] 15.724654 s: Minor Revision:0x1
    [MCU1_0] 15.724693 s: CAN-FD operation is enabled through E-Fuse.
    [MCU1_0] 15.724731 s: Endianess Value: 0x87654321
    [MCU1_0] 15.725301 s: ADC : ADC application started...
    [MCU1_0] 15.725364 s: ADC application started...
    [MCU1_0] 15.725396 s: ADC : ADC App_Udma_init !!
    [MCU1_0] 15.725431 s: ADC App_Udma_init !!
    [MCU1_0] 15.726012 s: ADC : ADC App_adcInit started...
    [MCU1_0] 15.726091 s: ADC App_adcInit started...
    [MCU1_0] 15.726706 s: ADC : ADC App_adcInit end!!!.
    [MCU1_0] 15.726748 s: ADC App_adcInit end!!!.
    [MCU1_0] 15.726777 s: ADC : ADC App_adcInit started...
    [MCU1_0] 15.726813 s: ADC App_adcInit started...
    [MCU1_0] 15.727691 s: ADC : ADC App_adcInit end!!!.
    [MCU1_0] 15.727727 s: ADC App_adcInit end!!!.
    [MCU1_0] 15.727756 s: ADC : ADC App_create started...
    [MCU1_0] 15.727791 s: ADC App_create started...
    [MCU1_0] 15.728204 s: ADC : ADC App_create Udma_chOpen gADC_0_RX_PDMA_CH end...
    [MCU1_0] 15.728275 s: ADC App_create Udma_chOpen gADC_0_RX_PDMA_CH end...
    [MCU1_0] 15.728588 s: ADC : ADC App_create Udma_chOpen gADC_1_RX_PDMA_CH end...
    [MCU1_0] 15.728648 s: ADC App_create Udma_chOpen gADC_1_RX_PDMA_CH end...
    [MCU1_0] 15.729167 s: ADC : ADC App_create end !!!!...
    [MCU1_0] 15.729239 s: ADC App_create end !!!!...
    [MCU2_0] 3.972279 s: CIO: Init ... Done !!!
    [MCU2_0] 3.972329 s: ### CPU Frequency = 1000000000 Hz

    [MCU2_0] 3.972360 s: CPU is running FreeRTOS
    [MCU2_0] 3.972381 s: APP: Init ... !!!
    [MCU2_0] 3.972401 s: SCICLIENT: Init ... !!!
    [MCU2_0] 3.972527 s: SCICLIENT: DMSC FW version [8.6.3--v08.06.03 (Chill Capybar]
    [MCU2_0] 3.972561 s: SCICLIENT: DMSC FW revision 0x8
    [MCU2_0] 3.972588 s: SCICLIENT: DMSC FW ABI revision 3.1
    [MCU2_0] 3.972618 s: SCICLIENT: Init ... Done !!!
    [MCU2_0] 3.972641 s: UDMA: Init ... !!!
    [MCU2_0] 3.973510 s: UDMA: Init ... Done !!!
    [MCU2_0] 3.973541 s: UDMA: Init ... !!!
    [MCU2_0] 3.974017 s: UDMA: Init for CSITX/CSIRX ... Done !!!
    [MCU2_0] 3.974067 s: MEM: Init ... !!!
    [MCU2_0] 3.974101 s: MEM: Created heap (DDR_LOCAL_MEM, id=0, flags=0x00000004) @ d9000000 of size 16777216 bytes !!!
    [MCU2_0] 3.974160 s: MEM: Created heap (L3_MEM, id=1, flags=0x00000000) @ 60000000 of size 524288 bytes !!!
    [MCU2_0] 3.974211 s: MEM: Init ... Done !!!
    [MCU2_0] 3.974232 s: IPC: Init ... !!!
    [MCU2_0] 3.974278 s: IPC: 6 CPUs participating in IPC !!!
    [MCU2_0] 3.974313 s: IPC: Waiting for HLOS to be ready ... !!!
    [MCU2_0] 15.355293 s: IPC: HLOS is ready !!!
    [MCU2_0] 15.366927 s: IPC: Init ... Done !!!
    [MCU2_0] 15.366967 s: APP: Syncing with 5 CPUs ... !!!
    [MCU2_0] 15.686967 s: APP: Syncing with 5 CPUs ... Done !!!
    [MCU2_0] 15.687001 s: REMOTE_SERVICE: Init ... !!!
    [MCU2_0] 15.688376 s: REMOTE_SERVICE: Init ... Done !!!
    [MCU2_0] 15.688418 s: FVID2: Init ... !!!
    [MCU2_0] 15.688473 s: FVID2: Init ... Done !!!
    [MCU2_0] 15.688495 s: SCICLIENT: Sciclient_pmSetModuleState module=219 state=2
    [MCU2_0] 15.688771 s: SCICLIENT: Sciclient_pmSetModuleState success
    [MCU2_0] 15.689415 s: appGpioInit Done!!!
    [MCU2_0] 15.689494 s: DSS: Init ... !!!
    [MCU2_0] 15.689516 s: DSS: Init ... !!!
    [MCU2_0] 15.689535 s: DSS: Init ... !!!
    [MCU2_0] 15.689555 s: DSS: Init ... !!!
    [MCU2_0] 15.689574 s: DSS: Init ... !!!
    [MCU2_0] 15.689593 s: DSS: Init ... !!!
    [MCU2_0] 15.689612 s: DSS: Init ... !!!
    [MCU2_0] 15.689631 s: DSS: Init ... !!!
    [MCU2_0] 15.689650 s: DSS: Init ... !!!
    [MCU2_0] 15.689669 s: DSS: Display type is HDMI !!!
    [MCU2_0] 15.689692 s: DSS: M2M Path is enabled !!!
    [MCU2_0] 15.689714 s: DSS: M2M Path is enabled !!!
    [MCU2_0] 15.689735 s: DSS: M2M Path is enabled !!!
    [MCU2_0] 15.689756 s: DSS: M2M Path is enabled !!!
    [MCU2_0] 15.689778 s: DSS: M2M Path is enabled !!!
    [MCU2_0] 15.689799 s: DSS: M2M Path is enabled !!!
    [MCU2_0] 15.689820 s: DSS: M2M Path is enabled !!!
    [MCU2_0] 15.689841 s: DSS: M2M Path is enabled !!!
    [MCU2_0] 15.689863 s: DSS: SoC init ... !!!
    [MCU2_0] 15.689884 s: SCICLIENT: Sciclient_pmSetModuleState module=158 state=0
    [MCU2_0] 15.690005 s: SCICLIENT: Sciclient_pmSetModuleState success
    [MCU2_0] 15.690032 s: SCICLIENT: Sciclient_pmSetModuleClkParent module=158 clk=5 parent=7
    [MCU2_0] 15.690139 s: SCICLIENT: Sciclient_pmSetModuleClkParent success
    [MCU2_0] 15.690167 s: SCICLIENT: Sciclient_pmSetModuleClkFreq module=158 clk=5 freq=148500000
    [MCU2_0] 15.691375 s: SCICLIENT: Sciclient_pmSetModuleClkFreq success
    [MCU2_0] 15.691402 s: SCICLIENT: Sciclient_pmModuleClkRequest module=158 clk=5 state=2 flag=0
    [MCU2_0] 15.691547 s: SCICLIENT: Sciclient_pmModuleClkRequest success
    [MCU2_0] 15.691574 s: DSS: SoC init ... Done !!!
    [MCU2_1] 3.970843 s: CIO: Init ... Done !!!
    [MCU2_1] 3.970895 s: ### CPU Frequency = 1000000000 Hz
    [MCU2_1] 3.970926 s: CPU is running FreeRTOS
    [MCU2_1] 3.970947 s: APP: Init ... !!!
    [MCU2_1] 3.970967 s: SCICLIENT: Init ... !!!
    [MCU2_1] 3.971094 s: SCICLIENT: DMSC FW version [8.6.3--v08.06.03 (Chill Capybar]
    [MCU2_1] 3.971126 s: SCICLIENT: DMSC FW revision 0x8
    [MCU2_1] 3.971153 s: SCICLIENT: DMSC FW ABI revision 3.1
    [MCU2_1] 3.971184 s: SCICLIENT: Init ... Done !!!
    [MCU2_1] 3.971206 s: UDMA: Init ... !!!
    [MCU2_1] 3.972240 s: UDMA: Init ... Done !!!
    [MCU2_1] 3.972289 s: MEM: Init ... !!!
    [MCU2_1] 3.972326 s: MEM: Created heap (DDR_LOCAL_MEM, id=0, flags=0x00000004) @ da000000 of size 16777216 bytes !!!
    [MCU2_1] 3.972384 s: MEM: Created heap (L3_MEM, id=1, flags=0x00000001) @ 60080000 of size 524288 bytes !!!
    [MCU2_1] 3.972434 s: MEM: Init ... Done !!!
    [MCU2_1] 3.972455 s: IPC: Init ... !!!
    [MCU2_1] 3.972506 s: IPC: 6 CPUs participating in IPC !!!
    [MCU2_1] 3.972541 s: IPC: Waiting for HLOS to be ready ... !!!
    [MCU2_1] 15.675184 s: IPC: HLOS is ready !!!
    [MCU2_1] 15.686889 s: IPC: Init ... Done !!!
    [MCU2_1] 15.686929 s: APP: Syncing with 5 CPUs ... !!!
    [MCU2_1] 15.686966 s: APP: Syncing with 5 CPUs ... Done !!!
    [MCU2_1] 15.686997 s: REMOTE_SERVICE: Init ... !!!
    [MCU2_1] 15.688602 s: REMOTE_SERVICE: Init ... Done !!!
    [MCU2_1] 15.688640 s: FVID2: Init ... !!!
    [MCU2_1] 15.688696 s: FVID2: Init ... Done !!!
    [MCU2_1] 15.688720 s: VHWA: DMPAC: Init ... !!!
    [MCU2_1] 15.688744 s: SCICLIENT: Sciclient_pmSetModuleState module=58 state=2
    [MCU2_1] 15.688916 s: SCICLIENT: Sciclient_pmSetModuleState success
    [MCU2_1] 15.688944 s: SCICLIENT: Sciclient_pmSetModuleState module=62 state=2
    [MCU2_1] 15.689079 s: SCICLIENT: Sciclient_pmSetModuleState success
    [MCU2_1] 15.689106 s: VHWA: DOF Init ... !!!
    [MCU2_1] 15.693892 s: VHWA: DOF Init ... Done !!!
    [MCU2_1] 15.693933 s: VHWA: SDE Init ... !!!
    [MCU2_1] 15.695382 s: VHWA: SDE Init ... Done !!!
    [MCU2_1] 15.695415 s: VHWA: DMPAC: Init ... Done !!!
    [MCU2_1] 15.695450 s: VX_ZONE_INIT:Enabled
    [MCU2_1] 15.695485 s: VX_ZONE_ERROR:Enabled
    [MCU2_1] 15.695510 s: VX_ZONE_WARNING:Enabled
    [MCU2_1] 15.696660 s: VX_ZONE_INIT:[tivxPlatformCreateTargetId:66] Added target MCU2-1
    [MCU2_1] 15.696862 s: VX_ZONE_INIT:[tivxPlatformCreateTargetId:66] Added target DMPAC_SDE
    [MCU2_1] 15.697051 s: VX_ZONE_INIT:[tivxPlatformCreateTargetId:66] Added target DMPAC_DOF
    [MCU2_1] 15.697095 s: VX_ZONE_INIT:[tivxInitLocal:130] Initialization Done !!!
    [MCU2_1] 15.697124 s: APP: OpenVX Target kernel init ... !!!
    [MCU2_1] 15.697374 s: APP: OpenVX Target kernel init ... Done !!!
    [MCU2_1] 15.697404 s: UDMA Copy: Init ... !!!
    [MCU2_1] 15.698591 s: UDMA Copy: Init ... Done !!!
    [MCU2_1] 15.698632 s: APP: Init ... Done !!!
    [MCU2_1] 15.698657 s: APP: Run ... !!!
    [MCU2_1] 15.698677 s: IPC: Starting echo test ...
    [MCU2_1] 15.701540 s: APP: Run ... Done !!!
    [MCU2_1] 15.702208 s: IPC: Echo status: mpu1_0[x] mcu1_0[.] mcu2_0[x] mcu2_1[s] C7X_1[P] C7X_2[.]
    [MCU2_1] 15.702289 s: IPC: Echo status: mpu1_0[x] mcu1_0[.] mcu2_0[x] mcu2_1[s] C7X_1[P] C7X_2[P]
    [MCU2_1] 15.702361 s: IPC: Echo status: mpu1_0[x] mcu1_0[P] mcu2_0[x] mcu2_1[s] C7X_1[P] C7X_2[P]
    [C7x_1 ] 4.600793 s: CIO: Init ... Done !!!
    [C7x_1 ] 4.600809 s: ### CPU Frequency = 1000000000 Hz
    [C7x_1 ] 4.600820 s: CPU is running FreeRTOS
    [C7x_1 ] 4.600830 s: APP: Init ... !!!
    [C7x_1 ] 4.600838 s: SCICLIENT: Init ... !!!
    [C7x_1 ] 4.600948 s: SCICLIENT: DMSC FW version [8.6.3--v08.06.03 (Chill Capybar]
    [C7x_1 ] 4.600963 s: SCICLIENT: DMSC FW revision 0x8
    [C7x_1 ] 4.600974 s: SCICLIENT: DMSC FW ABI revision 3.1
    [C7x_1 ] 4.600985 s: SCICLIENT: Init ... Done !!!
    [C7x_1 ] 4.600994 s: UDMA: Init ... !!!
    [C7x_1 ] 4.601829 s: UDMA: Init ... Done !!!
    [C7x_1 ] 4.601842 s: MEM: Init ... !!!
    [C7x_1 ] 4.601854 s: MEM: Created heap (DDR_LOCAL_MEM, id=0, flags=0x00000004) @ 117000000 of size 268435456 bytes !!!
    [C7x_1 ] 4.601876 s: MEM: Created heap (L3_MEM, id=1, flags=0x00000001) @ 70020000 of size 3964928 bytes !!!
    [C7x_1 ] 4.601895 s: MEM: Created heap (L2_MEM, id=2, flags=0x00000001) @ 64800000 of size 458752 bytes !!!
    [C7x_1 ] 4.601913 s: MEM: Created heap (L1_MEM, id=3, flags=0x00000001) @ 64e00000 of size 16384 bytes !!!
    [C7x_1 ] 4.601930 s: MEM: Created heap (DDR_SCRATCH_MEM, id=4, flags=0x00000001) @ 100000000 of size 385875968 bytes !!!
    [C7x_1 ] 4.601948 s: MEM: Init ... Done !!!
    [C7x_1 ] 4.601957 s: IPC: Init ... !!!
    [C7x_1 ] 4.601972 s: IPC: 6 CPUs participating in IPC !!!
    [C7x_1 ] 4.601988 s: IPC: Waiting for HLOS to be ready ... !!!
    [C7x_1 ] 14.692688 s: IPC: HLOS is ready !!!
    [C7x_1 ] 14.695055 s: IPC: Init ... Done !!!
    [C7x_1 ] 14.695071 s: APP: Syncing with 5 CPUs ... !!!
    [C7x_1 ] 15.686968 s: APP: Syncing with 5 CPUs ... Done !!!
    [C7x_1 ] 15.686987 s: REMOTE_SERVICE: Init ... !!!
    [C7x_1 ] 15.687172 s: REMOTE_SERVICE: Init ... Done !!!
    [C7x_1 ] 15.687198 s: VX_ZONE_INIT:Enabled
    [C7x_1 ] 15.687238 s: VX_ZONE_ERROR:Enabled
    [C7x_1 ] 15.687252 s: VX_ZONE_WARNING:Enabled
    [C7x_1 ] 15.687569 s: VX_ZONE_INIT:[tivxPlatformCreateTargetId:59] Added target DSP_C7-1
    [C7x_1 ] 15.687650 s: VX_ZONE_INIT:[tivxPlatformCreateTargetId:59] Added target DSP_C7-1_PRI_2
    [C7x_1 ] 15.687727 s: VX_ZONE_INIT:[tivxPlatformCreateTargetId:59] Added target DSP_C7-1_PRI_3
    [C7x_1 ] 15.687797 s: VX_ZONE_INIT:[tivxPlatformCreateTargetId:59] Added target DSP_C7-1_PRI_4
    [C7x_1 ] 15.687875 s: VX_ZONE_INIT:[tivxPlatformCreateTargetId:59] Added target DSP_C7-1_PRI_5
    [C7x_1 ] 15.687949 s: VX_ZONE_INIT:[tivxPlatformCreateTargetId:59] Added target DSP_C7-1_PRI_6
    [C7x_1 ] 15.688020 s: VX_ZONE_INIT:[tivxPlatformCreateTargetId:59] Added target DSP_C7-1_PRI_7
    [C7x_1 ] 15.688092 s: VX_ZONE_INIT:[tivxPlatformCreateTargetId:59] Added target DSP_C7-1_PRI_8
    [C7x_1 ] 15.688116 s: VX_ZONE_INIT:[tivxInitLocal:130] Initialization Done !!!
    [C7x_1 ] 15.688130 s: APP: OpenVX Target kernel init ... !!!
    [C7x_1 ] 15.688262 s: APP: OpenVX Target kernel init ... Done !!!
    [C7x_1 ] 15.688276 s: APP: Init ... Done !!!
    [C7x_1 ] 15.688286 s: APP: Run ... !!!
    [C7x_1 ] 15.688296 s: IPC: Starting echo test ...
    [C7x_1 ] 15.688458 s: APP: Run ... Done !!!
    [C7x_1 ] 15.689688 s: IPC: Echo status: mpu1_0[x] mcu1_0[x] mcu2_0[x] mcu2_1[x] C7X_1[s] C7X_2[P]
    [C7x_1 ] 15.696552 s: IPC: Echo status: mpu1_0[x] mcu1_0[P] mcu2_0[x] mcu2_1[x] C7X_1[s] C7X_2[P]
    [C7x_1 ] 15.702070 s: IPC: Echo status: mpu1_0[x] mcu1_0[P] mcu2_0[x] mcu2_1[P] C7X_1[s] C7X_2[P]
    [C7x_2 ] 5.028659 s: CIO: Init ... Done !!!
    [C7x_2 ] 5.028676 s: ### CPU Frequency = 1000000000 Hz
    [C7x_2 ] 5.028690 s: CPU is running FreeRTOS
    [C7x_2 ] 5.028698 s: APP: Init ... !!!
    [C7x_2 ] 5.028707 s: SCICLIENT: Init ... !!!
    [C7x_2 ] 5.028815 s: SCICLIENT: DMSC FW version [8.6.3--v08.06.03 (Chill Capybar]
    [C7x_2 ] 5.028830 s: SCICLIENT: DMSC FW revision 0x8
    [C7x_2 ] 5.028841 s: SCICLIENT: DMSC FW ABI revision 3.1
    [C7x_2 ] 5.028852 s: SCICLIENT: Init ... Done !!!
    [C7x_2 ] 5.028862 s: UDMA: Init ... !!!
    [C7x_2 ] 5.029694 s: UDMA: Init ... Done !!!
    [C7x_2 ] 5.029708 s: MEM: Init ... !!!
    [C7x_2 ] 5.029721 s: MEM: Created heap (DDR_LOCAL_MEM, id=0, flags=0x00000004) @ 127000000 of size 16777216 bytes !!!
    [C7x_2 ] 5.029743 s: MEM: Created heap (L2_MEM, id=2, flags=0x00000001) @ 65800000 of size 458752 bytes !!!
    [C7x_2 ] 5.029762 s: MEM: Created heap (L1_MEM, id=3, flags=0x00000001) @ 65e00000 of size 16384 bytes !!!
    [C7x_2 ] 5.029780 s: MEM: Created heap (DDR_SCRATCH_MEM, id=4, flags=0x00000001) @ 128000000 of size 67108864 bytes !!!
    [C7x_2 ] 5.029799 s: MEM: Init ... Done !!!
    [C7x_2 ] 5.029808 s: IPC: Init ... !!!
    [C7x_2 ] 5.029823 s: IPC: 6 CPUs participating in IPC !!!
    [C7x_2 ] 5.029839 s: IPC: Waiting for HLOS to be ready ... !!!
    [C7x_2 ] 15.089058 s: IPC: HLOS is ready !!!
    [C7x_2 ] 15.091563 s: IPC: Init ... Done !!!
    [C7x_2 ] 15.091577 s: APP: Syncing with 5 CPUs ... !!!
    [C7x_2 ] 15.686969 s: APP: Syncing with 5 CPUs ... Done !!!
    [C7x_2 ] 15.686988 s: REMOTE_SERVICE: Init ... !!!
    [C7x_2 ] 15.687183 s: REMOTE_SERVICE: Init ... Done !!!
    [C7x_2 ] 15.687209 s: VX_ZONE_INIT:Enabled
    [C7x_2 ] 15.687252 s: VX_ZONE_ERROR:Enabled
    [C7x_2 ] 15.687265 s: VX_ZONE_WARNING:Enabled
    [C7x_2 ] 15.687856 s: VX_ZONE_INIT:[tivxPlatformCreateTargetId:59] Added target DSP-1
    [C7x_2 ] 15.687880 s: VX_ZONE_INIT:[tivxInitLocal:130] Initialization Done !!!
    [C7x_2 ] 15.687893 s: APP: OpenVX Target kernel init ... !!!
    [C7x_2 ] 15.688158 s: APP: OpenVX Target kernel init ... Done !!!
    [C7x_2 ] 15.688174 s: UDMA Copy: Init ... !!!
    [C7x_2 ] 15.689196 s: UDMA Copy: Init ... Done !!!
    [C7x_2 ] 15.689213 s: APP: Init ... Done !!!
    [C7x_2 ] 15.689223 s: APP: Run ... !!!
    [C7x_2 ] 15.689232 s: IPC: Starting echo test ...
    [C7x_2 ] 15.689391 s: APP: Run ... Done !!!
    [C7x_2 ] 15.689692 s: IPC: Echo status: mpu1_0[x] mcu1_0[x] mcu2_0[x] mcu2_1[x] C7X_1[P] C7X_2[s]
    [C7x_2 ] 15.696591 s: IPC: Echo status: mpu1_0[x] mcu1_0[P] mcu2_0[x] mcu2_1[x] C7X_1[P] C7X_2[s]
    [C7x_2 ] 15.702083 s: IPC: Echo status: mpu1_0[x] mcu1_0[P] mcu2_0[x] mcu2_1[P] C7X_1[P] C7X_2[s]
    root@j721s2-evm:/opt/vision_apps#
    root@j721s2-evm:/opt/vision_apps#
    root@j721s2-evm:/opt/vision_apps#
    root@j721s2-evm:/opt/vision_apps#
    root@j721s2-evm:/opt/vision_apps#
    root@j721s2-evm:/opt/vision_apps#
    root@j721s2-evm:/opt/vision_apps#
    root@j721s2-evm:/opt/vision_apps#
    root@j721s2-evm:/opt/vision_apps#
    root@j721s2-evm:/opt/vision_apps# ./run_app_single_cam.sh
    APP: Init ... !!!
    MEM: Init ... !!!
    MEM: Initialized DMA HEAP (fd=4) !!!
    MEM: Init ... Done !!!
    IPC: Init ... !!!
    IPC: Init ... Done !!!
    REMOTE_SERVICE: Init ... !!!
    REMOTE_SERVICE: Init ... Done !!!
    33.484650 s: GTC Frequency = 200 MHz
    APP: Init ... Done !!!
    33.492242 s: VX_ZONE_INIT:Enabled
    33.492274 s: VX_ZONE_ERROR:Enabled
    33.492281 s: VX_ZONE_WARNING:Enabled
    33.493227 s: VX_ZONE_INIT:[tivxInitLocal:130] Initialization Done !!!
    33.494469 s: VX_ZONE_INIT:[tivxHostInitLocal:93] Initialization Done for HOST !!!
    sensor_selection = [0]
    ldc_enable = [0]
    num_frames_to_run = [1000000000]
    is_interactive = [1]
    IttCtrl_registerHandler: command echo registered at location 0
    IttCtrl_registerHandler: command iss_read_2a_params registered at location 1
    IttCtrl_registerHandler: command iss_write_2a_params registered at location 2
    IttCtrl_registerHandler: command iss_raw_save registered at location 3
    IttCtrl_registerHandler: command iss_yuv_save registered at location 4
    IttCtrl_registerHandler: command iss_read_sensor_reg registered at location 5
    IttCtrl_registerHandler: command iss_write_sensor_reg registered at location 6
    IttCtrl_registerHandler: command dev_ctrl registered at location 7
    IttCtrl_registerHandler: command iss_send_dcc_file registered at location 8
    NETWORK: Opened at IP Addr = 1.4.16.64, socket port=5000!!!
    33.509215 s: ISS: Enumerating sensors ... !!!

  • Dear  Brijesh,

            Please help and support this issue. I really don't have a way to solve it. Thank you very much.

  • Dear  Brijesh,

          Our TDA4 does not link display device,can we use DSS's M2M in this situation?