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.

TDA4VL-Q1: How to export YUV format pictures to CSITX

Part Number: TDA4VL-Q1

Dear TI expert,

        Now my code is running and looks quite normal, but after measuring the waveform of csitx and the connected display device, I find that no graphic data comes out.

Can you help me analyze what is wrong with the code of csitx?Thanks!

  • /*
     *
     * 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
    
    #define VX_CALL(fn_call) fn_call
    #define VX_CALL_(ret_code, fn_call) fn_call
    #define VX_CALL_RET(fn_call) fn_call
    
    static char availableSensorNames[ISS_SENSORS_MAX_SUPPORTED_SENSOR][ISS_SENSORS_MAX_NAME];
    static vx_uint8 num_sensors_found;
    static IssSensor_CreateParams sensorParams;
    
    #define NUM_CAPT_CHANNELS   (4u)
    
    //#define M2M
    //#define DEBUG
    
    
    
    #define CSITX_NODE_W        (1)
    #if (CSITX_NODE_W == 1U)
    //#define CSITX_FORMAT           (VX_DF_IMAGE_YUYV) //VX_DF_IMAGE_UYVY
    #define CSITX_WDP           (0)
    #define CSITX_FORMAT        (VX_DF_IMAGE_UYVY)
    #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"
    
    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 vx_node m2m_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_
    
    vx_status app_init_fmt_conv(vx_context context, FmtConvObj *fmtObj, uint32_t out_width, uint32_t out_height, uint32_t num_ch, char *objName)
    {
        vx_status status = VX_SUCCESS;
        vx_image out_img;
    
        fmtObj->num_ch = num_ch;//;
    
        printf ("zqq [FMT-CONV-MODULE]: Num Channels %d WxH %dx%d\n",
            fmtObj->num_ch, out_width, out_height);
    
        out_img  = vxCreateImage(context, out_width, out_height, fmtObj->color_format);
        status = vxGetStatus((vx_reference)out_img);
    
        if(status == VX_SUCCESS)
        {
            fmtObj->arr  = vxCreateObjectArray(context, (vx_reference)out_img, fmtObj->num_ch);
            vxReleaseImage(&out_img);
    
            status = vxGetStatus((vx_reference)fmtObj->arr);
            if(status != VX_SUCCESS)
            {
                printf("zqq [FMT-CONV-MODULE] Unable to create output array! \n");
            }
            else
            {
                tivx_display_m2m_params_init(&fmtObj->m2m_params);
                fmtObj->m2m_params.instId     = 0u;
                /* Only one pipeline is supported */
                fmtObj->m2m_params.numPipe    = 1u;
                fmtObj->m2m_params.pipeId[0U] = 3u;
                fmtObj->m2m_params.overlayId  = 3u;
    
                fmtObj->m2m_obj = vxCreateUserDataObject(
                    context, "tivx_display_m2m_params_t",
                    sizeof(tivx_display_m2m_params_t), &fmtObj->m2m_params);
    
                status = vxGetStatus((vx_reference)fmtObj->m2m_obj);
                if(status != VX_SUCCESS)
                {
                    printf("zqq [FMT-CONV-MODULE] Unable to create m2m object! \n");
                }
            }
        }
        else
        {
            printf("zqq [FMT-CONV-MODULE] Unable to create output image template! \n");
        }
    
        return status;
    }
    
    vx_status app_create_graph_fmt_conv(vx_graph graph, FmtConvObj *obj, vx_image in_img)
    {
        vx_status status = VX_SUCCESS;
        vx_image input, output;
        vx_bool replicate[] = {vx_false_e, vx_false_e, vx_true_e};
    
        input = in_img;
        if(obj->arr != NULL)
        {
            obj->output = output = (vx_image)vxGetObjectArrayItem((vx_object_array)obj->arr, 0);
        }
    
        obj->node = tivxDisplayM2MNode(graph, obj->m2m_obj, input, output);
        status = vxGetStatus((vx_reference)obj->node);
    
        if(status == VX_SUCCESS)
        {
            vxSetNodeTarget(obj->node, VX_TARGET_STRING, TIVX_TARGET_DISPLAY_M2M1);
            vxSetReferenceName((vx_reference)obj->node, "FmtConvNode");
    
            vxReplicateNode(graph, obj->node, replicate, 3);
        }
        else
        {
            printf("zqq [FMT-CONV-MODULE] Unable to create scaler node! \n");
        }
    
        vxReleaseImage(&input);
        vxReleaseImage(&output);
    
        return status;
    }
    
    /*
     * 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);
    //        tivxFileIOLoadKernels(obj->context);
    //        tivxImgProcLoadKernels(obj->context);
    //        tivxTIDLLoadKernels(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;
    }
    
    #if defined(DEBUG)
    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;
    }
    #endif
    /*
     * 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 == 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;
            }
            else
            {
                if ((image_width >= obj->display_params.outWidth) && (image_height >= obj->display_params.outHeight))
                {
                    obj->scaler_enable = vx_false_e;
                }
                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, scaler_out_h;
                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, scaler_out_w, scaler_out_h, 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;
            }
        }
    #ifdef M2M
        if (status == VX_SUCCESS)
        {
            obj->fmtConvObj.color_format = VX_DF_IMAGE_UYVY;
            status = app_init_fmt_conv(obj->context, &obj->fmtConvObj, 1920, 1080, 1, "Format Conversion Object");
        }
    
        if(status == VX_SUCCESS)
        {
            status = app_create_graph_fmt_conv(obj->graph, &obj->fmtConvObj, obj->scaler_out_img);
        }
        //display_in_image = obj->imgMosaicObj.output_image[0];
    
        status = tivxSetNodeParameterNumBufByIndex(obj->fmtConvObj.node, 2, 4);
    #endif
    
     //   vx_map_id map_id;
     //   vx_int32 i,j;
     //   vx_imagepatch_addressing_t addr;
     //   uint16_t *ptr = NULL;
        vx_image tx_frame_array_item=0;
    //    vx_int16 width, height;
    //    width = 3840;
    //    height = 2160;
    //    vx_rectangle_t rect;
    //    rect.start_x = 0;
    //    rect.start_y = 0;
    //    rect.end_x = width;
    //    rect.end_y = height;
    
        
    #if defined(DEBUG)
        tx_frame_array_item = vxCreateImage(obj->context, 1920, 1300, CSITX_FORMAT);    
        app_csitx_load_vximage_from_yuvfile(tx_frame_array_item, IMAGE_1920x1300_30P_UYVY);
        tx_frame = vxCreateObjectArray(obj->context, (vx_reference)tx_frame_array_item, NUM_CHANNELS);   
    #else
    #if 0
        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);
            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));
        }
    #endif
        tx_frame_array_item = vxCreateImage(obj->context, 1920, 1300, CSITX_FORMAT);    
        tx_frame_array_item = viss_out_image;
    #endif
        tx_frame = vxCreateObjectArray(obj->context, (vx_reference)tx_frame_array_item, NUM_CHANNELS);
        vxReleaseImage(&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++;
        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++;
    
        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);
            }
            if(status == VX_SUCCESS)
            {
                status = vxGraphParameterDequeueDoneRef(obj->graph, 1, (vx_reference*)&tx_frame, 1, &num_refs);
                printf("zqq vxGraphParameterDequeueDoneRef ----tx_frame\n");
            }
            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);
            }
            if(status == VX_SUCCESS)
            {
                status = vxGraphParameterEnqueueReadyRef(obj->graph, 1, (vx_reference*)&tx_frame, 1);
    			printf("zqq vxGraphParameterEnqueueReadyRef ----tx_frame\n");
            }
            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;
    #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;
    }
    
    

    • This is my code, please help analyze it.

  • Hi,

    I did not get it, Do you see video data and not graphics data? or nothing comes out of CSITX? Which CSITX instance are you using? Is your graph running fine?

    Regards,

    Brijesh 

  • Dear TI expert,

    nothing comes out of CSITX and graph running fine.  I am using CSITX instance 1.

  • Hi,

    Can you please check if below code is present in the file vision_apps\utils\hwa\src\app_hwa.c? This sets control module mux to set the output for CSITX.

    int32_t appCsi2TxInit(void)
    {
        int32_t status = FVID2_SOK;
    
        uint32_t regVal = 0U, unlocked = 0U;
        Csitx_InitParams initPrmsCsitx;
    
        appLogPrintf("CSI2TX: Init ... !!!\n");
    
        SET_DEVICE_STATE_ON(TISCI_DEV_CSI_PSILSS0);
        #if defined(SOC_J721S2)
        SET_DEVICE_STATE_ON(TISCI_DEV_CSI_TX_IF_V2_0);
        SET_DEVICE_STATE_ON(TISCI_DEV_CSI_TX_IF_V2_1);
        #elif defined(SOC_J784S4)
        SET_DEVICE_STATE_ON(TISCI_DEV_CSI_TX_IF0);
        SET_DEVICE_STATE_ON(TISCI_DEV_CSI_TX_IF1);
        #else
        SET_DEVICE_STATE_ON(TISCI_DEV_CSI_TX_IF0);
        #endif
        SET_DEVICE_STATE_ON(TISCI_DEV_DPHY_TX0);
    
        regVal = CSL_REG32_RD(CSL_CTRL_MMR0_CFG0_BASE +
                              CSL_MAIN_CTRL_MMR_CFG0_LOCK1_KICK0);
        if ((regVal & 0x1) == 0U)
        {
            /* Unlock MMR */
            unlocked = 1U;
            CSL_REG32_WR(CSL_CTRL_MMR0_CFG0_BASE +
                         CSL_MAIN_CTRL_MMR_CFG0_LOCK1_KICK0,
                         0x68EF3490U);
            CSL_REG32_WR(CSL_CTRL_MMR0_CFG0_BASE +
                         CSL_MAIN_CTRL_MMR_CFG0_LOCK1_KICK1,
                         0xD172BC5AU);
            appLogPrintf("Unlocked MMR to program CSITX DPHY register ... !!!\n");
        }
    
        /* Select CSITX0 as the source for DPHYTX0 */
        CSL_REG32_WR(CSL_CTRL_MMR0_CFG0_BASE +
                        CSL_MAIN_CTRL_MMR_CFG0_DPHY_TX0_CTRL,
                        0x1);
        #if defined(SOC_J721S2) || defined(SOC_J784S4)
        /* Select CSITX1 as the source for DPHYTX1 */
        CSL_REG32_WR(CSL_CTRL_MMR0_CFG0_BASE +
                        CSL_MAIN_CTRL_MMR_CFG0_DPHY_TX1_CTRL,
                        0x1);
        #endif
        /* Lock MMR back if unlocked here */
        if (unlocked == 1U)
        {
            CSL_REG32_WR(CSL_CTRL_MMR0_CFG0_BASE +
                         CSL_MAIN_CTRL_MMR_CFG0_LOCK1_KICK0,
                         0U);
            appLogPrintf("Locked MMR after programming CSITX DPHY register ... !!!\n");
        }
    
        Csitx_initParamsInit(&initPrmsCsitx);
        initPrmsCsitx.drvHandle = appUdmaCsirxCsitxGetObj();
        status = Csitx_init(&initPrmsCsitx);
        if(status!=FVID2_SOK)
        {
            appLogPrintf("CSI2TX: ERROR: Csitx_init failed !!!\n");
        }
        appLogPrintf("CSI2TX: Init ... Done !!!\n");
    
        return (status);
    }
    

    Regards,

    Brijesh

  • Dear TI expert,

       I've checked the code and it's the same.

  • have any update ? Thanks

  • /*
     *
     * 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
    
    #define VX_CALL(fn_call) fn_call
    #define VX_CALL_(ret_code, fn_call) fn_call
    #define VX_CALL_RET(fn_call) fn_call
    
    static char availableSensorNames[ISS_SENSORS_MAX_SUPPORTED_SENSOR][ISS_SENSORS_MAX_NAME];
    static vx_uint8 num_sensors_found;
    static IssSensor_CreateParams sensorParams;
    
    #define NUM_CAPT_CHANNELS   (4u)
    
    //#define M2M
    #define PIC
    //#define FRONT
    //#define ROUND
    
    #define CSITX_NODE_W        (1)
    #if (CSITX_NODE_W == 1U)
    //#define CSITX_FORMAT           (VX_DF_IMAGE_YUYV) //VX_DF_IMAGE_UYVY
    #define CSITX_WDP           (0)
    #define CSITX_FORMAT        (VX_DF_IMAGE_UYVY)
    #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"
    
    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 vx_node m2m_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_
    
    vx_status app_init_fmt_conv(vx_context context, FmtConvObj *fmtObj, uint32_t out_width, uint32_t out_height, uint32_t num_ch, char *objName)
    {
        vx_status status = VX_SUCCESS;
        vx_image out_img;
    
        fmtObj->num_ch = num_ch;//;
    
        printf ("zqq [FMT-CONV-MODULE]: Num Channels %d WxH %dx%d\n",
            fmtObj->num_ch, out_width, out_height);
    
        out_img  = vxCreateImage(context, out_width, out_height, fmtObj->color_format);
        status = vxGetStatus((vx_reference)out_img);
    
        if(status == VX_SUCCESS)
        {
            fmtObj->arr  = vxCreateObjectArray(context, (vx_reference)out_img, fmtObj->num_ch);
            vxReleaseImage(&out_img);
    
            status = vxGetStatus((vx_reference)fmtObj->arr);
            if(status != VX_SUCCESS)
            {
                printf("zqq [FMT-CONV-MODULE] Unable to create output array! \n");
            }
            else
            {
                tivx_display_m2m_params_init(&fmtObj->m2m_params);
                fmtObj->m2m_params.instId     = 0u;
                /* Only one pipeline is supported */
                fmtObj->m2m_params.numPipe    = 1u;
                fmtObj->m2m_params.pipeId[0U] = 3u;
                fmtObj->m2m_params.overlayId  = 3u;
    
                fmtObj->m2m_obj = vxCreateUserDataObject(
                    context, "tivx_display_m2m_params_t",
                    sizeof(tivx_display_m2m_params_t), &fmtObj->m2m_params);
    
                status = vxGetStatus((vx_reference)fmtObj->m2m_obj);
                if(status != VX_SUCCESS)
                {
                    printf("zqq [FMT-CONV-MODULE] Unable to create m2m object! \n");
                }
            }
        }
        else
        {
            printf("zqq [FMT-CONV-MODULE] Unable to create output image template! \n");
        }
    
        return status;
    }
    
    vx_status app_create_graph_fmt_conv(vx_graph graph, FmtConvObj *obj, vx_image in_img)
    {
        vx_status status = VX_SUCCESS;
        vx_image input, output;
        vx_bool replicate[] = {vx_false_e, vx_false_e, vx_true_e};
    
        input = in_img;
        if(obj->arr != NULL)
        {
            obj->output = output = (vx_image)vxGetObjectArrayItem((vx_object_array)obj->arr, 0);
        }
    
        obj->node = tivxDisplayM2MNode(graph, obj->m2m_obj, input, output);
        status = vxGetStatus((vx_reference)obj->node);
    
        if(status == VX_SUCCESS)
        {
            vxSetNodeTarget(obj->node, VX_TARGET_STRING, TIVX_TARGET_DISPLAY_M2M1);
            vxSetReferenceName((vx_reference)obj->node, "FmtConvNode");
    
            vxReplicateNode(graph, obj->node, replicate, 3);
        }
        else
        {
            printf("zqq [FMT-CONV-MODULE] Unable to create scaler node! \n");
        }
    
        vxReleaseImage(&input);
        vxReleaseImage(&output);
    
        return status;
    }
    
    /*
     * 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);
    //        tivxFileIOLoadKernels(obj->context);
    //        tivxImgProcLoadKernels(obj->context);
    //        tivxTIDLLoadKernels(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;
    }
    
    #if defined(PIC)
    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;
    }
    #endif
    /*
     * 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 == 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;
            }
            else
            {
                if ((image_width >= obj->display_params.outWidth) && (image_height >= obj->display_params.outHeight))
                {
    #if defined(FRONT)                
                    obj->scaler_enable = vx_false_e;
    #else  
                    obj->scaler_enable = vx_true_e;
    #endif                              
                }
                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, scaler_out_h;
                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, scaler_out_w, scaler_out_h, 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;
            }
        }
    #ifdef M2M
        if (status == VX_SUCCESS)
        {
            obj->fmtConvObj.color_format = VX_DF_IMAGE_UYVY;
            status = app_init_fmt_conv(obj->context, &obj->fmtConvObj, 1920, 1080, 1, "Format Conversion Object");
        }
    
        if(status == VX_SUCCESS)
        {
            status = app_create_graph_fmt_conv(obj->graph, &obj->fmtConvObj, obj->scaler_out_img);
        }
        //display_in_image = obj->imgMosaicObj.output_image[0];
    
        status = tivxSetNodeParameterNumBufByIndex(obj->fmtConvObj.node, 2, 4);
    #endif
    
     //   vx_map_id map_id;
     //   vx_int32 i,j;
     //   vx_imagepatch_addressing_t addr;
     //   uint16_t *ptr = NULL;
     //   vx_image tx_frame_array_item=0;
     
    //    vx_int16 width, height;
    //    width = 3840;
    //    height = 2160;
    //    vx_rectangle_t rect;
    //    rect.start_x = 0;
    //    rect.start_y = 0;
    //    rect.end_x = width;
    //    rect.end_y = height;
    
        
    #if defined(PIC)
    #if 0
        vx_image csitx_image;
        vx_image tx_frame_array_item=0;
        csitx_image = vxCreateImage(obj->context, 1920, 1300, CSITX_FORMAT);
        tx_frame = vxCreateObjectArray(obj->context, (vx_reference)csitx_image, 1);
    
        tx_frame_array_item = (vx_image)vxGetObjectArrayItem(tx_frame , 0);          
        app_csitx_load_vximage_from_yuvfile(tx_frame_array_item, IMAGE_1920x1300_30P_UYVY);
        vxReleaseImage(&tx_frame_array_item);
    #endif
        vx_image csitx_image;
        csitx_image = vxCreateImage(obj->context, 1920, 1300, CSITX_FORMAT);
        app_csitx_load_vximage_from_yuvfile(csitx_image, IMAGE_1920x1300_30P_UYVY);
        tx_frame = vxCreateObjectArray(obj->context, (vx_reference)csitx_image, 1);  
    #endif
    
    #if defined(FRONT)
        tx_frame = vxCreateObjectArray(obj->context, (vx_reference)viss_out_image, NUM_CHANNELS);
    #endif    
    
    #if defined(ROUND)    
        vx_image tx_frame_array_item = vxCreateImage(obj->context, 1920, 1300, CSITX_FORMAT);
        tx_frame_array_item = (vx_image)vxGetObjectArrayItem(obj->cap_frames[0] , 0);
        tx_frame = vxCreateObjectArray(obj->context, (vx_reference)tx_frame_array_item, NUM_CHANNELS);
    #endif   
             
    
      
        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");
        }
    #if defined(DEBUG)  
        csitx_node = tivxCsitxNode(obj->graph, csitx_config, tx_frame);
    #else
        csitx_node = tivxCsitxNode(obj->graph, csitx_config, tx_frame);
    #endif      
        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++;
    
        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;
        vx_object_array transmitted_frames = NULL;
        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);
            }
            if(status == VX_SUCCESS)
            {
                status = vxGraphParameterDequeueDoneRef(obj->graph, 1, (vx_reference*)&transmitted_frames, 1, &num_refs);
                printf("zqq vxGraphParameterDequeueDoneRef ----tx_frame\n");
            }
            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);
            }
            if(status == VX_SUCCESS)
            {
                status = vxGraphParameterEnqueueReadyRef(obj->graph, 1, (vx_reference*)&transmitted_frames, 1);
    			printf("zqq vxGraphParameterEnqueueReadyRef ----tx_frame\n");
            }
            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;
    #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,

            Could you please check this new code for me? In this code I try three ways to use csitx nodes. One is to send the fixed images on the sd card. The other is to use the front-facing camera to convert the raw images of the capture node into yuv images through viss and then send them to the csitx node. The last option is to use a circumferential camera to send the yuv graph generated by the capture node directly to the csitx node.However, these three methods did not see the normal waveform on the oscilloscope.

          I have looked at this problem for a long time, can you spare no effort to help us solve this problem together?   Thanks very much.

       

         Regards,

  • Hi,

    But why are you creating a separate image for the CSITX? You should just use output from M2M driver as input to the CSITX. 

    I have made changes in the attached file, can you please try with it?

    /*
     *
     * 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
    
    #define VX_CALL(fn_call) fn_call
    #define VX_CALL_(ret_code, fn_call) fn_call
    #define VX_CALL_RET(fn_call) fn_call
    
    static char availableSensorNames[ISS_SENSORS_MAX_SUPPORTED_SENSOR][ISS_SENSORS_MAX_NAME];
    static vx_uint8 num_sensors_found;
    static IssSensor_CreateParams sensorParams;
    
    #define NUM_CAPT_CHANNELS   (4u)
    
    #define M2M
    //#define PIC
    //#define FRONT
    //#define ROUND
    
    #define CSITX_NODE_W        (1)
    #if (CSITX_NODE_W == 1U)
    //#define CSITX_FORMAT           (VX_DF_IMAGE_YUYV) //VX_DF_IMAGE_UYVY
    #define CSITX_WDP           (0)
    #define CSITX_FORMAT        (VX_DF_IMAGE_UYVY)
    #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"
    
    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 vx_node m2m_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_
    
    vx_status app_init_fmt_conv(vx_context context, FmtConvObj *fmtObj, uint32_t out_width, uint32_t out_height, uint32_t num_ch, char *objName)
    {
        vx_status status = VX_SUCCESS;
        vx_image out_img;
    
        fmtObj->num_ch = num_ch;//;
    
        printf ("zqq [FMT-CONV-MODULE]: Num Channels %d WxH %dx%d\n",
            fmtObj->num_ch, out_width, out_height);
    
        out_img  = vxCreateImage(context, out_width, out_height, fmtObj->color_format);
        status = vxGetStatus((vx_reference)out_img);
    
        if(status == VX_SUCCESS)
        {
            fmtObj->arr  = vxCreateObjectArray(context, (vx_reference)out_img, fmtObj->num_ch);
            vxReleaseImage(&out_img);
    
            status = vxGetStatus((vx_reference)fmtObj->arr);
            if(status != VX_SUCCESS)
            {
                printf("zqq [FMT-CONV-MODULE] Unable to create output array! \n");
            }
            else
            {
                tivx_display_m2m_params_init(&fmtObj->m2m_params);
                fmtObj->m2m_params.instId     = 0u;
                /* Only one pipeline is supported */
                fmtObj->m2m_params.numPipe    = 1u;
                fmtObj->m2m_params.pipeId[0U] = 3u;
                fmtObj->m2m_params.overlayId  = 3u;
    
                fmtObj->m2m_obj = vxCreateUserDataObject(
                    context, "tivx_display_m2m_params_t",
                    sizeof(tivx_display_m2m_params_t), &fmtObj->m2m_params);
    
                status = vxGetStatus((vx_reference)fmtObj->m2m_obj);
                if(status != VX_SUCCESS)
                {
                    printf("zqq [FMT-CONV-MODULE] Unable to create m2m object! \n");
                }
            }
        }
        else
        {
            printf("zqq [FMT-CONV-MODULE] Unable to create output image template! \n");
        }
    
        return status;
    }
    
    vx_status app_create_graph_fmt_conv(vx_graph graph, FmtConvObj *obj, vx_image in_img)
    {
        vx_status status = VX_SUCCESS;
        vx_image input, output;
        vx_bool replicate[] = {vx_false_e, vx_false_e, vx_true_e};
    
        input = in_img;
        if(obj->arr != NULL)
        {
            obj->output = output = (vx_image)vxGetObjectArrayItem((vx_object_array)obj->arr, 0);
        }
    
        obj->node = tivxDisplayM2MNode(graph, obj->m2m_obj, input, output);
        status = vxGetStatus((vx_reference)obj->node);
    
        if(status == VX_SUCCESS)
        {
            vxSetNodeTarget(obj->node, VX_TARGET_STRING, TIVX_TARGET_DISPLAY_M2M1);
            vxSetReferenceName((vx_reference)obj->node, "FmtConvNode");
    
            vxReplicateNode(graph, obj->node, replicate, 3);
        }
        else
        {
            printf("zqq [FMT-CONV-MODULE] Unable to create scaler node! \n");
        }
    
        vxReleaseImage(&input);
        vxReleaseImage(&output);
    
        return status;
    }
    
    /*
     * 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);
    //        tivxFileIOLoadKernels(obj->context);
    //        tivxImgProcLoadKernels(obj->context);
    //        tivxTIDLLoadKernels(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;
    }
    
    #if defined(PIC)
    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;
    }
    #endif
    /*
     * 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 == 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;
            }
            else
            {
                if ((image_width >= obj->display_params.outWidth) && (image_height >= obj->display_params.outHeight))
                {
    #if defined(FRONT)
                    obj->scaler_enable = vx_false_e;
    #else
                    obj->scaler_enable = vx_true_e;
    #endif
                }
                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, scaler_out_h;
                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, scaler_out_w, scaler_out_h, 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;
            }
        }
    #ifdef M2M
        if (status == VX_SUCCESS)
        {
            obj->fmtConvObj.color_format = VX_DF_IMAGE_UYVY;
            status = app_init_fmt_conv(obj->context, &obj->fmtConvObj, 1920, 1080, 1, "Format Conversion Object");
        }
    
        if(status == VX_SUCCESS)
        {
            status = app_create_graph_fmt_conv(obj->graph, &obj->fmtConvObj, obj->display_image);
        }
        obj->display_image = obj->fmtConvObj.output;
        tx_frame = obj->fmtConvObj.arr;
    
        status = tivxSetNodeParameterNumBufByIndex(obj->fmtConvObj.node, 2, 4);
    #endif
    
     //   vx_map_id map_id;
     //   vx_int32 i,j;
     //   vx_imagepatch_addressing_t addr;
     //   uint16_t *ptr = NULL;
     //   vx_image tx_frame_array_item=0;
    
    //    vx_int16 width, height;
    //    width = 3840;
    //    height = 2160;
    //    vx_rectangle_t rect;
    //    rect.start_x = 0;
    //    rect.start_y = 0;
    //    rect.end_x = width;
    //    rect.end_y = height;
    
    
    #if defined(PIC)
    #if 0
        vx_image csitx_image;
        vx_image tx_frame_array_item=0;
        csitx_image = vxCreateImage(obj->context, 1920, 1300, CSITX_FORMAT);
        tx_frame = vxCreateObjectArray(obj->context, (vx_reference)csitx_image, 1);
    
        tx_frame_array_item = (vx_image)vxGetObjectArrayItem(tx_frame , 0);
        app_csitx_load_vximage_from_yuvfile(tx_frame_array_item, IMAGE_1920x1300_30P_UYVY);
        vxReleaseImage(&tx_frame_array_item);
    #endif
        vx_image csitx_image;
        csitx_image = vxCreateImage(obj->context, 1920, 1300, CSITX_FORMAT);
        app_csitx_load_vximage_from_yuvfile(csitx_image, IMAGE_1920x1300_30P_UYVY);
        tx_frame = vxCreateObjectArray(obj->context, (vx_reference)csitx_image, 1);
    #endif
    
    #if defined(FRONT)
        tx_frame = vxCreateObjectArray(obj->context, (vx_reference)viss_out_image, NUM_CHANNELS);
    #endif
    
    #if defined(ROUND)
        vx_image tx_frame_array_item = vxCreateImage(obj->context, 1920, 1300, CSITX_FORMAT);
        tx_frame_array_item = (vx_image)vxGetObjectArrayItem(obj->cap_frames[0] , 0);
        tx_frame = vxCreateObjectArray(obj->context, (vx_reference)tx_frame_array_item, NUM_CHANNELS);
    #endif
    
    
    
        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");
        }
    #if defined(DEBUG)
        csitx_node = tivxCsitxNode(obj->graph, csitx_config, tx_frame);
    #else
        csitx_node = tivxCsitxNode(obj->graph, csitx_config, tx_frame);
    #endif
        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++;
    
        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;
        vx_object_array transmitted_frames = NULL;
        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);
            }
            if(status == VX_SUCCESS)
            {
                status = vxGraphParameterDequeueDoneRef(obj->graph, 1, (vx_reference*)&transmitted_frames, 1, &num_refs);
                printf("zqq vxGraphParameterDequeueDoneRef ----tx_frame\n");
            }
            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);
            }
            if(status == VX_SUCCESS)
            {
                status = vxGraphParameterEnqueueReadyRef(obj->graph, 1, (vx_reference*)&transmitted_frames, 1);
                printf("zqq vxGraphParameterEnqueueReadyRef ----tx_frame\n");
            }
            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;
    #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;
    }

    Regards,

    Brijesh

  • Dear TI expert,

    I am not using M2M node at present, the code of this place is not enabled, but I will follow your modification, try it, and then feedback the result.

  • Sure, if you are not planning to use M2M, then please connect CSITX to one of the node, which outputs YUV422 data.

  • Dear TI expert,

            I took a look at your changes and you just enabled my M2M node and then gave the M2M output to the CSITX input. This change does not work. If M2M is turned on, the log will indicate that the M2M node related things are not registered. Can you help us to modify the existing code base, do not change our node related it, the current modification can not be tried.

  • Yes, i just connected M2M output to CSITX by providing output array to CSITX. This is how it should be connected. Please enable it properly in the code and it should then work fine. 

  • Dear TI expert,

    Sure, if you are not planning to use M2M, then please connect CSITX to one of the node, which outputs YUV422 data----------------->I have tried three methods: one is a fixed image, one is a direct capture of the yuv graph, and the last one is using the output data of the VISS node.But none of these methods succeeded in getting csitx to display.

  • Dear TI expert,

       Right now, I just want to send the images on my SD card to csitx.

       please help me,Thanks.

  • Dear  Brijesh,

            camera->ser->des->capture->viss->csitx1->ser

            But I found that CSITx1 and DSI1 GPIO are common. Do you need to configure CSITx1's GPIO separately

  • Additionally, I measured the mipi waveform and did not see any mipi long packets

  • Hi qin,

    No, these modules do not have dependency on GPIO, atleast not on EVM. 

    I would suggest connecting DSS M2M output to the CSITX and then checking the waveform. If you haven't connected CSITX input some other node, or just reading one file for CSITX, it may not show any output. There should be continuous input to the CSITX and that's possible by connecting CSITX to DSS M2M node. 

    Regards,

    Brijesh

  • Dear Brijesh,

            Thank you very much for your suggestion. I will now try connecting DSS M2M output to the CSITX1

  • After connecting it, please share your example code for the review. I remember there were some issue in the last shared code. 

  • Dear Brijesh,

          Compilation will report an error, unknown type name:FmtConvObj

          No definition found for FmtConvObj in rtos-sdk

  • Dear Brijesh

             run_app_single_cam  will fail to run:

     [FMT-CONV-MODULE]: Num Channels 1 WxH 1920x1080

    Initializing Transmit Buffers Done.
    csitx_node create done!!!!
    add_graph_parameter_by_node_index start:tx_frame!!!
    vxSetGraphScheduleConfig done
    44.003331 s: VX_ZONE_ERROR:[ownContextSendCmd:799] Command ack message returned failure cmd_status: -7
    44.003356 s: VX_ZONE_ERROR:[ownContextSendCmd:835] tivxEventWait() failed.
    44.003363 s: VX_ZONE_ERROR:[ownNodeKernelInit:527] Target kernel, TIVX_CMD_NODE_CREATE failed for node FmtConvNode
    44.003370 s: VX_ZONE_ERROR:[ownNodeKernelInit:528] Please be sure the target callbacks have been registered for this core
    44.003376 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
    44.003560 s: VX_ZONE_ERROR:[ownGraphNodeKernelInit:583] kernel init for node 4, kernel com.ti.hwa.displaym2m ... failed !!!
    44.003574 s: VX_ZONE_ERROR:[vxVerifyGraph:2055] Node kernel init failed
    44.003580 s: VX_ZONE_ERROR:[vxVerifyGraph:2109] Graph verify failed
    Scaler is enabled
    app_create_graph exiting
    app_create_graph done

  • 5040.app_single_cam_main.c camera output is 3840x2160, raw12, Please help check the code, thank you

  • Dear Brijesh

        Are there any new analytical developments?  Thank you very much

  • Hi qin,

    Did not understand your question. what do you mean by analytical development?

    Regarding above error, please check if all of below kernels are loaded in OpenVX?

    tivxHwaLoadKernels(obj->context);
    tivxImagingLoadKernels(obj->context);
    tivxFileIOLoadKernels(obj->context);

    Are you seeing any other error from mcu2_0? 

    Btw format conversion module is configured to output 1920x1080 frame, as per below statement. Please check if it is correct.

    status = app_init_fmt_conv(obj->context, &obj->fmtConvObj, 1920, 1080, 1, "Format Conversion Object");

    Regards,

    Brijesh

  • Dear Brijesh:

    [MCU2_0] 83.886365 s: src/fvid2_drvMgr.c @ Line 768:
    [MCU2_0] 83.886403 s: EALLOC: Invalid driver ID!!
    [MCU2_0] 83.886439 s: VX_ZONE_ERROR:[tivxDisplayM2MDrvCfg:906] : Display M2M Create Failed!!!
    [MCU2_0] 83.886479 s: VX_ZONE_ERROR:[tivxDisplayM2MCreate:379] Unable to allocate local memory

  • Dear Brijesh: 

    log:

    WDR mode is supported
    Expsoure control is supported
    Gain control is supported
    CMS Usecase is supported
    obj->aewb_cfg.ae_mode = 0
    obj->aewb_cfg.awb_mode = 0
    Sensor DCC is enabled
    Sensor width = 3840
    Sensor height = 2160
    Sensor DCC ID = 840
    Sensor Supported Features = 0x378
    Sensor Enabled Features = 0x358
    102.006478 s: ISS: Initializing sensor [SENSOR_OX08B40_MAX96717], doing IM_SENSOR_CMD_PWRON ... !!!
    102.006803 s: ISS: Initializing sensor [SENSOR_OX08B40_MAX96717], doing IM_SENSOR_CMD_CONFIG ... !!!
    [MCU2_0] 102.006252 s: ImageSensor_RemoteServiceHandler: IM_SENSOR_CMD_QUERY
    [MCU2_0] 102.006285 s: Received Query for SENSOR_OX08B40_MAX96717
    [MCU2_0] 102.006608 s: ImageSensor_RemoteServiceHandler: IM_SENSOR_CMD_PWRON
    [MCU2_0] 102.006638 s: IM_SENSOR_CMD_PWRON : channel_mask = 0x10
    [MCU2_0] 102.006685 s: OX08B40_PowerOn : chId = 0x4
    [MCU2_0] 102.006932 s: ImageSensor_RemoteServiceHandler: IM_SENSOR_CMD_CONFIG
    [MCU2_0] 102.006964 s: Application requested features = 0x358
    [MCU2_0]
    [MCU2_0] 102.006994 s: IM_SENSOR_CMD_CONFIG channel_mask = 10
    [MCU2_0] 102.007038 s: OX08B40_Probe chId: 0x4
    [MCU2_0] 102.007061 s: Configuring camera # 4
    [MCU2_0] 102.007107 s: OX08B40_Config chId: 0x4, sensor_features_requested = 856
    [MCU2_0] 102.007137 s: max96717 config start : slaveAddr = 0x40
    [MCU2_0] 102.007605 s: max96717 Reg Write Success for regAddr 0x1 regValue 8
    [MCU2_0] 102.039435 s: max96717 Reg Write Success for regAddr 0x331 regValue 51
    [MCU2_0] 102.071434 s: max96717 Reg Write Success for regAddr 0x311 regValue 64
    [MCU2_0] 102.103433 s: max96717 Reg Write Success for regAddr 0x318 regValue 108
    [MCU2_0] 102.135433 s: max96717 Reg Write Success for regAddr 0x308 regValue 100
    [MCU2_0] 102.167433 s: max96717 Reg Write Success for regAddr 0x6 regValue 191
    [MCU2_0] 102.199432 s: max96717 Reg Write Success for regAddr 0x3 regValue 7
    [MCU2_0] 102.231433 s: max96717 Reg Write Success for regAddr 0x3f0 regValue 217
    [MCU2_0] 102.263432 s: max96717 Reg Write Success for regAddr 0x570 regValue 16
    [MCU2_0] 102.295432 s: max96717 Reg Write Success for regAddr 0x3f1 regValue 9
    [MCU2_0] 102.327433 s: max96717 Reg Write Success for regAddr 0xffff regValue 0
    [MCU2_0] 102.327462 s: End of max96717 config
    [MCU2_0] 102.327498 s: OX08B40_Sensor_RegConfig E sensor_cfg_script_len = 1173
    [MCU2_0] 102.327544 s: Configuring OX08B40 imager 0x36.. Please wait till it finishes
    103.600244 s: ISS: Initializing sensor [SENSOR_OX08B40_MAX96717] ... Done !!!
    Creating graph
    Initializing params for capture node
    capture_config = 0x0xffffb6069158
    Creating capture node
    obj->capture_node = 0x0xffffb5fdaed8
    [MCU2_0] 103.600016 s: OX08B40_Sensor_RegConfig X = regCnt = 1173
    [MCU2_0] 103.600069 s: OX08B40_Config chId: 0x4, sensor_features_requested = 856, status = 0
    [MCU2_0] 103.600101 s: IM_SENSOR_CMD_CONFIG returning status = 0
    Test data path is NULL. Defaulting to current folder
    read_test_image_raw : Unable to open file .//img_test.raw
    app_create_viss : sensor_dcc_id = 840
    AEWB Set Reference done
    [FMT-CONV-MODULE]: Num Channels 1 WxH 1920x1080
    Initializing Transmit Buffers Done.
    csitx_node create done!!!!
    add_graph_parameter_by_node_index start:tx_frame!!!
    vxSetGraphScheduleConfig done
    103.656175 s: VX_ZONE_ERROR:[ownContextSendCmd:799] Command ack message returned failure cmd_status: -8
    103.656199 s: VX_ZONE_ERROR:[ownContextSendCmd:835] tivxEventWait() failed.
    103.656207 s: VX_ZONE_ERROR:[ownNodeKernelInit:527] Target kernel, TIVX_CMD_NODE_CREATE failed for node FmtConvNode
    103.656214 s: VX_ZONE_ERROR:[ownNodeKernelInit:528] Please be sure the target callbacks have been registered for this core
    103.656221 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
    103.656405 s: VX_ZONE_ERROR:[ownGraphNodeKernelInit:583] kernel init for node 4, kernel com.ti.hwa.displaym2m ... failed !!!
    103.656421 s: VX_ZONE_ERROR:[vxVerifyGraph:2055] Node kernel init failed
    103.656427 s: VX_ZONE_ERROR:[vxVerifyGraph:2109] Graph verify failed
    Scaler is enabled
    app_create_graph exiting
    app_create_graph done
    103.659890 s: ISS: Starting sensor [SENSOR_OX08B40_MAX96717] channel_mask = 0x10 ... !!!


    ==========================
    Demo : Single Camera w/ 2A
    ==========================

    p: Print performance statistics

    s: Save Sensor RAW, VISS Output and H3A output images to File System

    e: Export performance statistics

    u: Update DCC from File System


    x: Exit

    Enter Choice:
    Unsupported command

    ==========================

    Demo : Single Camera w/ 2A
    ==========================

    p: Print performance statistics

    s: Save Sensor RAW, VISS Output and H3A output images to File System

    e: Export performance statistics

    u: Update DCC from File System


    x: Exit

    Enter Choice: [MCU2_0] 103.655907 s: src/fvid2_drvMgr.c @ Line 768:
    [MCU2_0] 103.655944 s: EALLOC: Invalid driver ID!!
    [MCU2_0] 103.655980 s: VX_ZONE_ERROR:[tivxDisplayM2MDrvCfg:906] : Display M2M Create Failed!!!
    [MCU2_0] 103.656030 s: VX_ZONE_ERROR:[tivxDisplayM2MCreate:379] Unable to allocate local memory
    [MCU2_0] 103.656573 s: ==========================================================
    [MCU2_0] 103.656627 s: Capture Status: Instance|0
    [MCU2_0] 103.656653 s: ==========================================================
    [MCU2_0] 103.656690 s: overflowCount: 0
    [MCU2_0] 103.656720 s: spuriousUdmaIntrCount: 0
    [MCU2_0] 103.656751 s: frontFIFOOvflCount: 0
    [MCU2_0] 103.656779 s: crcCount: 0
    [MCU2_0] 103.656804 s: eccCount: 0
    [MCU2_0] 103.656831 s: correctedEccCount: 0
    [MCU2_0] 103.656860 s: dataIdErrorCount: 0
    [MCU2_0] 103.656890 s: invalidAccessCount: 0
    [MCU2_0] 103.656919 s: invalidSpCount: 0
    [MCU2_0] 103.656952 s: strmFIFOOvflCount[0]: 0
    [MCU2_0] 103.656985 s: strmFIFOOvflCount[1]: 0
    [MCU2_0] 103.657018 s: Channel Num | Frame Queue Count | Frame De-queue Count | Frame Drop Count | Error Frame Count |
    [MCU2_0] 103.657241 s: ==========================================================
    [MCU2_0] 103.657292 s: Capture Status: Instance|1
    [MCU2_0] 103.657318 s: ==========================================================
    [MCU2_0] 103.657355 s: overflowCount: 0
    [MCU2_0] 103.657385 s: spuriousUdmaIntrCount: 0
    [MCU2_0] 103.657415 s: frontFIFOOvflCount: 0
    [MCU2_0] 103.657441 s: crcCount: 0
    [MCU2_0] 103.657466 s: eccCount: 0
    [MCU2_0] 103.657493 s: correctedEccCount: 0
    [MCU2_0] 103.657522 s: dataIdErrorCount: 0
    [MCU2_0] 103.657550 s: invalidAccessCount: 0
    [MCU2_0] 103.657579 s: invalidSpCount: 0
    [MCU2_0] 103.657611 s: strmFIFOOvflCount[0]: 0
    [MCU2_0] 103.657644 s: strmFIFOOvflCount[1]: 0
    [MCU2_0] 103.657669 s: Channel Num | Frame Queue Count | Frame De-queue Count | Frame Drop Count | Error Frame Count |
    [MCU2_0] 103.657733 s: 0 | 0 | 0 | 0 | 0 |
    [MCU2_0] 103.660103 s: ImageSensor_RemoteServiceHandler: IM_SENSOR_CMD_STREAM_ON
    [MCU2_0] 103.660158 s: IM_SENSOR_CMD_STREAM_ON: channel_mask = 0x10
    103.702105 s: ISS: Starting sensor [SENSOR_OX08B40_MAX96717] ... !!!
    [MCU2_0] 103.660190 s: IM_SENSOR_CMD_STREAM_ON: 2 channel_mask = 0x10 chId 0
    [MCU2_0] 103.660244 s: IssSensor_Start chId = 4
    [MCU2_0] 103.660279 s: OX08B40_StreamOn chId: 0x4
    [MCU2_0] 103.665001 s: max96716 config start2
    [MCU2_0] 103.665028 s: write 96716DES 313 TEST start!!!
    [MCU2_0] 103.665475 s: write 96716DES 313 TEST successful!!!
    [MCU2_0] 103.696999 s: End of max96716 config2
    [MCU2_0] 103.697040 s: OX08B40_StreamOn chId: 0x4, status = 0

  • Strange, is the patch that i shared earlier working for you? Are you able to integrate and run dss m2m path in multi-camera demo? 

    Also there is a flag, enableM2m, in dss initliazation, please check if this is set to TRUE.

    Regards,

    Brijesh

  • Dear Brijesh,

          our rtos is  8.0.6,  I have checked all the patches and the code contains.

           enableM2m is true:

           platform/j721s2/rtos/common/app_init.c

     appInit()

      ... ...

    prm.enableM2m = true;
    /* Do not rely on "init". Always provide known good tmings */
    prm.timings.width = 1920U;
    prm.timings.height = 1080U;
    prm.timings.hFrontPorch = 88U;
    prm.timings.hBackPorch = 148U;
    prm.timings.hSyncLen = 44U;
    prm.timings.vFrontPorch = 4U;
    prm.timings.vBackPorch = 36U;
    prm.timings.vSyncLen = 5U;
    prm.timings.pixelClock = 148500000ULL; 

  • Dear Brijesh,  

                 I don't understand why this condition needs to be added:  if(APP_IPC_CPU_MCU2_0 != ipc_init_prm.self_cpu_id)

    if(APP_IPC_CPU_MCU2_0 != ipc_init_prm.self_cpu_id){
    app_dss_default_prm_t prm;

    appDssDefaultSetDefaultPrm(&prm);

    #ifdef ENABLE_DSS_HDMI
    prm.display_type = APP_DSS_DEFAULT_DISPLAY_TYPE_DPI_HDMI;
    #endif
    #ifdef ENABLE_DSS_EDP
    prm.display_type = APP_DSS_DEFAULT_DISPLAY_TYPE_EDP;
    #endif
    prm.enableM2m = true;
    /* Do not rely on "init". Always provide known good tmings */
    prm.timings.width = 1920U;
    prm.timings.height = 1080U;
    prm.timings.hFrontPorch = 88U;
    prm.timings.hBackPorch = 148U;
    prm.timings.hSyncLen = 44U;
    prm.timings.vFrontPorch = 4U;
    prm.timings.vBackPorch = 36U;
    prm.timings.vSyncLen = 5U;
    prm.timings.pixelClock = 148500000ULL;

    #ifdef ENABLE_DSS_DSI
    prm.display_type = APP_DSS_DEFAULT_DISPLAY_TYPE_DSI;

    prm.timings.width = 1280U;
    prm.timings.height = 800U;
    prm.timings.hFrontPorch = 110U;
    prm.timings.hBackPorch = 220U;
    prm.timings.hSyncLen = 40U;
    prm.timings.vFrontPorch = 5U;
    prm.timings.vBackPorch = 20U;
    prm.timings.vSyncLen = 5U;
    prm.timings.pixelClock = 74250000ULL;
    #endif
    appLogPrintf("APP: 2. qindh Init ... !!!\n");
    status = appDssDefaultInit(&prm);
    APP_ASSERT_SUCCESS(status);
    }
    }

  • Dear Brijesh,

           when define ENABLE_DSS_SINGLE in  vision_apps/platform/j721s2/rtos/common/app_cfg_mcu2_0.h,  run_app_single_cam will report error:

    [MCU2_0] 13.138407 s: DSS: Init ... !!!
    [MCU2_0] 13.138429 s: DSS: Display type is eDP !!!
    [MCU2_0] 13.138453 s: DSS: M2M Path is enabled !!!
    [MCU2_0] 13.138476 s: DSS: SoC init ... !!!

    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 !!!
    115.225360 s: GTC Frequency = 200 MHz
    APP: Init ... Done !!!
    115.232870 s: VX_ZONE_INIT:Enabled
    115.232902 s: VX_ZONE_ERROR:Enabled
    115.232908 s: VX_ZONE_WARNING:Enabled
    115.233890 s: VX_ZONE_INIT:[tivxInitLocal:130] Initialization Done !!!
    115.235234 s: VX_ZONE_INIT:[tivxHostInitLocal:93] Initialization Done for HOST !!!
    Invalid token [
    ]
    sensor_selection = [0]
    Invalid token [
    ]
    ldc_enable = [0]
    Invalid token [
    ]
    num_frames_to_run = [1000000000]
    Invalid token [
    ]
    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!!!
    tivxImagingLoadKernels done
    115.252224 s: ISS: Enumerating sensors ... !!!
    115.252556 s: ISS: ERROR: Enumerating sensors failed !!!
    Select camera port index 0-11 : [MCU2_0] 115.252391 s: REMOTE_SERVICE: ERROR: Unable to find handler for service [com.ti.image_sensor]

  • You should not need to add this condition, (if(APP_IPC_CPU_MCU2_0 != ipc_init_prm.self_cpu_id)). This code is under ENABLE_DSS macro, so just define this macro in app_cfg_mcu2_0.h header file. Then it will configure DSS and enable m2m DSS.

    Regarding below error, can you please check if mcu2_0 initialization is complete? please share complete log of running vision_apps_init.sh script. It seems remote service for image sensor is not running. 

    Select camera port index 0-11 : [MCU2_0] 115.252391 s: REMOTE_SERVICE: ERROR: Unable to find handler for service [com.ti.image_sensor]

    Have you done any changes in the default sdk? This is working fine in the default sdk. Any specific reason you have disabled DSS? Is it because you have only CSITX enabled in your platform? 

    Regards,

    Brijesh

  • Any specific reason you have disabled DSS?

          --> We have no Dislay Hardware

  • [MCU2_0] 115.252391 s: REMOTE_SERVICE: ERROR: Unable to find handler for service [com.ti.image_sensor]
  • Can you please share the complete log of vision_apps_init.sh script? 

    It seems this service aren't registered somehow, due to, may be, mcu2_0 is not working. 

    Regards,

    Brijesh 

  • [MCU1_0] 0.025252 s: CIO: Init ... Done !!!
    [MCU1_0] 0.025335 s: ### CPU Frequency = 1000000000 Hz
    [MCU1_0] 0.025380 s: CPU is running FreeRTOS
    [MCU1_0] 0.025410 s: APP: Init ... !!!
    [MCU1_0] 0.025437 s: MEM: Init ... !!!
    [MCU1_0] 0.025481 s: MEM: Created heap (DDR_LOCAL_MEM, id=0, flags=0x00000004) @ d8000000 of size 8388608 bytes !!!
    [MCU1_0] 0.025578 s: MEM: Init ... Done !!!
    [MCU1_0] 0.025609 s: IPC: Init ... !!!
    [MCU1_0] 0.025672 s: IPC: 6 CPUs participating in IPC !!!
    [MCU1_0] 0.025721 s: IPC: Waiting for HLOS to be ready ... !!!
    [MCU1_0] 11.782013 s: IPC: HLOS is ready !!!
    [MCU1_0] 11.803687 s: IPC: Init ... Done !!!
    [MCU1_0] 11.803763 s: APP: Syncing with 5 CPUs ... !!!
    [MCU1_0] 12.277363 s: APP: Syncing with 5 CPUs ... Done !!!
    [MCU1_0] 12.277586 s: REMOTE_SERVICE: Init ... !!!
    [MCU1_0] 12.286010 s: REMOTE_SERVICE: Init ... Done !!!
    [MCU1_0] 12.286092 s: APP: Init ... Done !!!
    [MCU1_0] 12.286131 s: APP: Run ... !!!
    [MCU1_0] 12.286161 s: IPC: Starting echo test ...
    [MCU1_0] 12.290364 s: IPC: Echo status: mpu1_0[x] mcu1_0[s] mcu2_0[x] mcu2_1[x] C7X_1[P] C7X_2[x]
    [MCU1_0] 12.290931 s: APP: Run ... Done !!!
    [MCU1_0] 12.291085 s: IPC: Echo status: mpu1_0[x] mcu1_0[s] mcu2_0[x] mcu2_1[x] C7X_1[P] C7X_2[P]
    [MCU1_0] 12.292262 s: IPC: Echo status: mpu1_0[x] mcu1_0[s] mcu2_0[x] mcu2_1[P] C7X_1[P] C7X_2[P]
    [MCU1_0] 12.294397 s: can_func_Task create !!!
    [MCU1_0] 12.294474 s: can_func_Task RUN !!!
    [MCU1_0] 12.294520 s: -----CAN--Func TASK run-------
    [MCU1_0] 12.314521 s: CrossBar/Interrupt Configuration done.
    [MCU1_0] 12.314588 s: MCANSS Revision ID:
    [MCU1_0] 12.314620 s: scheme:0x1
    [MCU1_0] 12.314650 s: Business Unit:0x2
    [MCU1_0] 12.314681 s: Module ID:0x8e0
    [MCU1_0] 12.314710 s: RTL Revision:0xa
    [MCU1_0] 12.314741 s: Major Revision:0x1
    [MCU1_0] 12.314772 s: Custom Revision:0x0
    [MCU1_0] 12.314803 s: Minor Revision:0x1
    [MCU1_0] 12.314836 s: CAN-FD operation is enabled through E-Fuse.
    [MCU1_0] 12.314875 s: Endianess Value: 0x87654321
    [MCU1_0] 12.315212 s: CrossBar/Interrupt Configuration done.
    [MCU1_0] 12.315263 s: MCANSS Revision ID:
    [MCU1_0] 12.315294 s: scheme:0x1
    [MCU1_0] 12.315322 s: Business Unit:0x2
    [MCU1_0] 12.315352 s: Module ID:0x8e0
    [MCU1_0] 12.315382 s: RTL Revision:0xa
    [MCU1_0] 12.315412 s: Major Revision:0x1
    [MCU1_0] 12.315442 s: Custom Revision:0x0
    [MCU1_0] 12.315473 s: Minor Revision:0x1
    [MCU1_0] 12.315514 s: CAN-FD operation is enabled through E-Fuse.
    [MCU1_0] 12.315552 s: Endianess Value: 0x87654321
    [MCU1_0] 12.316121 s: ADC : ADC application started...
    [MCU1_0] 12.316186 s: ADC application started...
    [MCU1_0] 12.316219 s: ADC : ADC App_Udma_init !!
    [MCU1_0] 12.316255 s: ADC App_Udma_init !!
    [MCU1_0] 12.316856 s: ADC : ADC App_adcInit started...
    [MCU1_0] 12.316932 s: ADC App_adcInit started...
    [MCU1_0] 12.317513 s: ADC : ADC App_adcInit end!!!.
    [MCU1_0] 12.317555 s: ADC App_adcInit end!!!.
    [MCU1_0] 12.317583 s: ADC : ADC App_adcInit started...
    [MCU1_0] 12.317619 s: ADC App_adcInit started...
    [MCU1_0] 12.318495 s: ADC : ADC App_adcInit end!!!.
    [MCU1_0] 12.318531 s: ADC App_adcInit end!!!.
    [MCU1_0] 12.318560 s: ADC : ADC App_create started...
    [MCU1_0] 12.318596 s: ADC App_create started...
    [MCU1_0] 12.318996 s: ADC : ADC App_create Udma_chOpen gADC_0_RX_PDMA_CH end...
    [MCU1_0] 12.319064 s: ADC App_create Udma_chOpen gADC_0_RX_PDMA_CH end...
    [MCU1_0] 12.319365 s: ADC : ADC App_create Udma_chOpen gADC_1_RX_PDMA_CH end...
    [MCU1_0] 12.319426 s: ADC App_create Udma_chOpen gADC_1_RX_PDMA_CH end...
    [MCU1_0] 12.319906 s: ADC : ADC App_create end !!!!...
    [MCU1_0] 12.319980 s: ADC App_create end !!!!...
    [MCU1_0] 12.322360 s: Message successfully transferred with payload Bytes:64
    [MCU2_0] 4.015606 s: CIO: Init ... Done !!!
    [MCU2_0] 4.015659 s: ### CPU Frequency = 1000000000 Hz

    [MCU2_0] 4.015692 s: CPU is running FreeRTOS
    [MCU2_0] 4.015713 s: APP: Init ... !!!
    [MCU2_0] 4.015732 s: SCICLIENT: Init ... !!!
    [MCU2_0] 4.015857 s: SCICLIENT: DMSC FW version [8.6.3--v08.06.03 (Chill Capybar]
    [MCU2_0] 4.015891 s: SCICLIENT: DMSC FW revision 0x8
    [MCU2_0] 4.015918 s: SCICLIENT: DMSC FW ABI revision 3.1
    [MCU2_0] 4.015948 s: SCICLIENT: Init ... Done !!!
    [MCU2_0] 4.015971 s: UDMA: Init ... !!!
    [MCU2_0] 4.016883 s: UDMA: Init ... Done !!!
    [MCU2_0] 4.016919 s: UDMA: Init ... !!!
    [MCU2_0] 4.017386 s: UDMA: Init for CSITX/CSIRX ... Done !!!
    [MCU2_0] 4.017438 s: MEM: Init ... !!!
    [MCU2_0] 4.017474 s: MEM: Created heap (DDR_LOCAL_MEM, id=0, flags=0x00000004) @ d9000000 of size 16777216 bytes !!!
    [MCU2_0] 4.017532 s: MEM: Created heap (L3_MEM, id=1, flags=0x00000000) @ 60000000 of size 524288 bytes !!!
    [MCU2_0] 4.017585 s: MEM: Init ... Done !!!
    [MCU2_0] 4.017606 s: IPC: Init ... !!!
    [MCU2_0] 4.017653 s: IPC: 6 CPUs participating in IPC !!!
    [MCU2_0] 4.017691 s: IPC: Waiting for HLOS to be ready ... !!!
    [MCU2_0] 12.106771 s: IPC: HLOS is ready !!!
    [MCU2_0] 12.118462 s: IPC: Init ... Done !!!
    [MCU2_0] 12.118504 s: APP: Syncing with 5 CPUs ... !!!
    [MCU2_0] 12.277359 s: APP: Syncing with 5 CPUs ... Done !!!
    [MCU2_0] 12.277394 s: REMOTE_SERVICE: Init ... !!!
    [MCU2_0] 12.278799 s: REMOTE_SERVICE: Init ... Done !!!
    [MCU2_0] 12.278845 s: FVID2: Init ... !!!
    [MCU2_0] 12.278909 s: FVID2: Init ... Done !!!
    [MCU2_0] 12.278937 s: SCICLIENT: Sciclient_pmSetModuleState module=219 state=2
    [MCU2_0] 12.279145 s: SCICLIENT: Sciclient_pmSetModuleState success
    [MCU2_0] 12.279902 s: appGpioInit Done!!!
    [MCU2_0] 12.279937 s: DSS: Init ... !!!
    [MCU2_0] 12.279960 s: DSS: Display type is HDMI !!!
    [MCU2_0] 12.279984 s: DSS: M2M Path is enabled !!!
    [MCU2_0] 12.280062 s: DSS: SoC init ... !!!
    [MCU2_0] 12.280086 s: SCICLIENT: Sciclient_pmSetModuleState module=158 state=0
    [MCU2_0] 12.280176 s: SCICLIENT: Sciclient_pmSetModuleState success
    [MCU2_0] 12.280206 s: SCICLIENT: Sciclient_pmSetModuleClkParent module=158 clk=5 parent=7
    [MCU2_0] 12.280316 s: SCICLIENT: Sciclient_pmSetModuleClkParent success
    [MCU2_0] 12.280344 s: SCICLIENT: Sciclient_pmSetModuleClkFreq module=158 clk=5 freq=148500000
    [MCU2_0] 12.281550 s: SCICLIENT: Sciclient_pmSetModuleClkFreq success
    [MCU2_0] 12.281578 s: SCICLIENT: Sciclient_pmModuleClkRequest module=158 clk=5 state=2 flag=0
    [MCU2_0] 12.281742 s: SCICLIENT: Sciclient_pmModuleClkRequest success
    [MCU2_0] 12.281769 s: DSS: SoC init ... Done !!!
    [MCU2_0] 12.281792 s: DSS: Board init ... !!!
    [MCU2_0] 12.281813 s: DSS: Board init ... Done !!!
    [MCU2_1] 4.087970 s: CIO: Init ... Done !!!
    [MCU2_1] 4.088023 s: ### CPU Frequency = 1000000000 Hz
    [MCU2_1] 4.088054 s: CPU is running FreeRTOS
    [MCU2_1] 4.088076 s: APP: Init ... !!!
    [MCU2_1] 4.088095 s: SCICLIENT: Init ... !!!
    [MCU2_1] 4.088218 s: SCICLIENT: DMSC FW version [8.6.3--v08.06.03 (Chill Capybar]
    [MCU2_1] 4.088250 s: SCICLIENT: DMSC FW revision 0x8
    [MCU2_1] 4.088277 s: SCICLIENT: DMSC FW ABI revision 3.1
    [MCU2_1] 4.088308 s: SCICLIENT: Init ... Done !!!
    [MCU2_1] 4.088330 s: UDMA: Init ... !!!
    [MCU2_1] 4.089225 s: UDMA: Init ... Done !!!
    [MCU2_1] 4.089273 s: MEM: Init ... !!!
    [MCU2_1] 4.089308 s: MEM: Created heap (DDR_LOCAL_MEM, id=0, flags=0x00000004) @ da000000 of size 16777216 bytes !!!
    [MCU2_1] 4.089364 s: MEM: Created heap (L3_MEM, id=1, flags=0x00000001) @ 60080000 of size 524288 bytes !!!
    [MCU2_1] 4.089414 s: MEM: Init ... Done !!!
    [MCU2_1] 4.089435 s: IPC: Init ... !!!
    [MCU2_1] 4.089483 s: IPC: 6 CPUs participating in IPC !!!
    [MCU2_1] 4.089520 s: IPC: Waiting for HLOS to be ready ... !!!
    [MCU2_1] 12.265586 s: IPC: HLOS is ready !!!
    [MCU2_1] 12.277282 s: IPC: Init ... Done !!!
    [MCU2_1] 12.277320 s: APP: Syncing with 5 CPUs ... !!!
    [MCU2_1] 12.277358 s: APP: Syncing with 5 CPUs ... Done !!!
    [MCU2_1] 12.277386 s: REMOTE_SERVICE: Init ... !!!
    [MCU2_1] 12.278821 s: REMOTE_SERVICE: Init ... Done !!!
    [MCU2_1] 12.278862 s: FVID2: Init ... !!!
    [MCU2_1] 12.278921 s: FVID2: Init ... Done !!!
    [MCU2_1] 12.278945 s: VHWA: DMPAC: Init ... !!!
    [MCU2_1] 12.278966 s: SCICLIENT: Sciclient_pmSetModuleState module=58 state=2
    [MCU2_1] 12.279333 s: SCICLIENT: Sciclient_pmSetModuleState success
    [MCU2_1] 12.279363 s: SCICLIENT: Sciclient_pmSetModuleState module=62 state=2
    [MCU2_1] 12.279469 s: SCICLIENT: Sciclient_pmSetModuleState success
    [MCU2_1] 12.279496 s: VHWA: DOF Init ... !!!
    [MCU2_1] 12.284334 s: VHWA: DOF Init ... Done !!!
    [MCU2_1] 12.284369 s: VHWA: SDE Init ... !!!
    [MCU2_1] 12.285845 s: VHWA: SDE Init ... Done !!!
    [MCU2_1] 12.285877 s: VHWA: DMPAC: Init ... Done !!!
    [MCU2_1] 12.285912 s: VX_ZONE_INIT:Enabled
    [MCU2_1] 12.285936 s: VX_ZONE_ERROR:Enabled
    [MCU2_1] 12.285959 s: VX_ZONE_WARNING:Enabled
    [MCU2_1] 12.287104 s: VX_ZONE_INIT:[tivxPlatformCreateTargetId:66] Added target MCU2-1
    [MCU2_1] 12.287289 s: VX_ZONE_INIT:[tivxPlatformCreateTargetId:66] Added target DMPAC_SDE
    [MCU2_1] 12.287457 s: VX_ZONE_INIT:[tivxPlatformCreateTargetId:66] Added target DMPAC_DOF
    [MCU2_1] 12.287498 s: VX_ZONE_INIT:[tivxInitLocal:130] Initialization Done !!!
    [MCU2_1] 12.287527 s: APP: OpenVX Target kernel init ... !!!
    [MCU2_1] 12.287760 s: APP: OpenVX Target kernel init ... Done !!!
    [MCU2_1] 12.287790 s: UDMA Copy: Init ... !!!
    [MCU2_1] 12.288982 s: UDMA Copy: Init ... Done !!!
    [MCU2_1] 12.289020 s: APP: Init ... Done !!!
    [MCU2_1] 12.289044 s: APP: Run ... !!!
    [MCU2_1] 12.289065 s: IPC: Starting echo test ...
    [MCU2_1] 12.291555 s: APP: Run ... Done !!!
    [MCU2_1] 12.292231 s: IPC: Echo status: mpu1_0[x] mcu1_0[.] mcu2_0[x] mcu2_1[s] C7X_1[P] C7X_2[.]
    [MCU2_1] 12.292306 s: IPC: Echo status: mpu1_0[x] mcu1_0[.] mcu2_0[x] mcu2_1[s] C7X_1[P] C7X_2[P]
    [MCU2_1] 12.292374 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.716321 s: CIO: Init ... Done !!!
    [C7x_1 ] 4.716337 s: ### CPU Frequency = 1000000000 Hz
    [C7x_1 ] 4.716349 s: CPU is running FreeRTOS
    [C7x_1 ] 4.716358 s: APP: Init ... !!!
    [C7x_1 ] 4.716366 s: SCICLIENT: Init ... !!!
    [C7x_1 ] 4.716471 s: SCICLIENT: DMSC FW version [8.6.3--v08.06.03 (Chill Capybar]
    [C7x_1 ] 4.716486 s: SCICLIENT: DMSC FW revision 0x8
    [C7x_1 ] 4.716497 s: SCICLIENT: DMSC FW ABI revision 3.1
    [C7x_1 ] 4.716508 s: SCICLIENT: Init ... Done !!!
    [C7x_1 ] 4.716517 s: UDMA: Init ... !!!
    [C7x_1 ] 4.717316 s: UDMA: Init ... Done !!!
    [C7x_1 ] 4.717329 s: MEM: Init ... !!!
    [C7x_1 ] 4.717341 s: MEM: Created heap (DDR_LOCAL_MEM, id=0, flags=0x00000004) @ 117000000 of size 268435456 bytes !!!
    [C7x_1 ] 4.717362 s: MEM: Created heap (L3_MEM, id=1, flags=0x00000001) @ 70020000 of size 3964928 bytes !!!
    [C7x_1 ] 4.717380 s: MEM: Created heap (L2_MEM, id=2, flags=0x00000001) @ 64800000 of size 458752 bytes !!!
    [C7x_1 ] 4.717398 s: MEM: Created heap (L1_MEM, id=3, flags=0x00000001) @ 64e00000 of size 16384 bytes !!!
    [C7x_1 ] 4.717415 s: MEM: Created heap (DDR_SCRATCH_MEM, id=4, flags=0x00000001) @ 100000000 of size 385875968 bytes !!!
    [C7x_1 ] 4.717434 s: MEM: Init ... Done !!!
    [C7x_1 ] 4.717442 s: IPC: Init ... !!!
    [C7x_1 ] 4.717457 s: IPC: 6 CPUs participating in IPC !!!
    [C7x_1 ] 4.717471 s: IPC: Waiting for HLOS to be ready ... !!!
    [C7x_1 ] 11.735955 s: IPC: HLOS is ready !!!
    [C7x_1 ] 11.738304 s: IPC: Init ... Done !!!
    [C7x_1 ] 11.738319 s: APP: Syncing with 5 CPUs ... !!!
    [C7x_1 ] 12.277360 s: APP: Syncing with 5 CPUs ... Done !!!
    [C7x_1 ] 12.277380 s: REMOTE_SERVICE: Init ... !!!
    [C7x_1 ] 12.277580 s: REMOTE_SERVICE: Init ... Done !!!
    [C7x_1 ] 12.277606 s: VX_ZONE_INIT:Enabled
    [C7x_1 ] 12.277617 s: VX_ZONE_ERROR:Enabled
    [C7x_1 ] 12.277662 s: VX_ZONE_WARNING:Enabled
    [C7x_1 ] 12.277958 s: VX_ZONE_INIT:[tivxPlatformCreateTargetId:59] Added target DSP_C7-1
    [C7x_1 ] 12.278072 s: VX_ZONE_INIT:[tivxPlatformCreateTargetId:59] Added target DSP_C7-1_PRI_2
    [C7x_1 ] 12.278147 s: VX_ZONE_INIT:[tivxPlatformCreateTargetId:59] Added target DSP_C7-1_PRI_3
    [C7x_1 ] 12.278236 s: VX_ZONE_INIT:[tivxPlatformCreateTargetId:59] Added target DSP_C7-1_PRI_4
    [C7x_1 ] 12.278324 s: VX_ZONE_INIT:[tivxPlatformCreateTargetId:59] Added target DSP_C7-1_PRI_5
    [C7x_1 ] 12.278402 s: VX_ZONE_INIT:[tivxPlatformCreateTargetId:59] Added target DSP_C7-1_PRI_6
    [C7x_1 ] 12.278476 s: VX_ZONE_INIT:[tivxPlatformCreateTargetId:59] Added target DSP_C7-1_PRI_7
    [C7x_1 ] 12.278552 s: VX_ZONE_INIT:[tivxPlatformCreateTargetId:59] Added target DSP_C7-1_PRI_8
    [C7x_1 ] 12.278575 s: VX_ZONE_INIT:[tivxInitLocal:130] Initialization Done !!!
    [C7x_1 ] 12.278589 s: APP: OpenVX Target kernel init ... !!!
    [C7x_1 ] 12.278721 s: APP: OpenVX Target kernel init ... Done !!!
    [C7x_1 ] 12.278736 s: APP: Init ... Done !!!
    [C7x_1 ] 12.278746 s: APP: Run ... !!!
    [C7x_1 ] 12.278755 s: IPC: Starting echo test ...
    [C7x_1 ] 12.278948 s: APP: Run ... Done !!!
    [C7x_1 ] 12.280252 s: IPC: Echo status: mpu1_0[x] mcu1_0[x] mcu2_0[x] mcu2_1[x] C7X_1[s] C7X_2[P]
    [C7x_1 ] 12.287165 s: IPC: Echo status: mpu1_0[x] mcu1_0[P] mcu2_0[x] mcu2_1[x] C7X_1[s] C7X_2[P]
    [C7x_1 ] 12.292099 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.143955 s: CIO: Init ... Done !!!
    [C7x_2 ] 5.143972 s: ### CPU Frequency = 1000000000 Hz
    [C7x_2 ] 5.143985 s: CPU is running FreeRTOS
    [C7x_2 ] 5.143995 s: APP: Init ... !!!
    [C7x_2 ] 5.144003 s: SCICLIENT: Init ... !!!
    [C7x_2 ] 5.144113 s: SCICLIENT: DMSC FW version [8.6.3--v08.06.03 (Chill Capybar]
    [C7x_2 ] 5.144128 s: SCICLIENT: DMSC FW revision 0x8
    [C7x_2 ] 5.144139 s: SCICLIENT: DMSC FW ABI revision 3.1
    [C7x_2 ] 5.144151 s: SCICLIENT: Init ... Done !!!
    [C7x_2 ] 5.144160 s: UDMA: Init ... !!!
    [C7x_2 ] 5.144949 s: UDMA: Init ... Done !!!
    [C7x_2 ] 5.144962 s: MEM: Init ... !!!
    [C7x_2 ] 5.144975 s: MEM: Created heap (DDR_LOCAL_MEM, id=0, flags=0x00000004) @ 127000000 of size 16777216 bytes !!!
    [C7x_2 ] 5.144997 s: MEM: Created heap (L2_MEM, id=2, flags=0x00000001) @ 65800000 of size 458752 bytes !!!
    [C7x_2 ] 5.145016 s: MEM: Created heap (L1_MEM, id=3, flags=0x00000001) @ 65e00000 of size 16384 bytes !!!
    [C7x_2 ] 5.145035 s: MEM: Created heap (DDR_SCRATCH_MEM, id=4, flags=0x00000001) @ 128000000 of size 67108864 bytes !!!
    [C7x_2 ] 5.145054 s: MEM: Init ... Done !!!
    [C7x_2 ] 5.145063 s: IPC: Init ... !!!
    [C7x_2 ] 5.145078 s: IPC: 6 CPUs participating in IPC !!!
    [C7x_2 ] 5.145093 s: IPC: Waiting for HLOS to be ready ... !!!
    [C7x_2 ] 11.956515 s: IPC: HLOS is ready !!!
    [C7x_2 ] 11.958961 s: IPC: Init ... Done !!!
    [C7x_2 ] 11.958977 s: APP: Syncing with 5 CPUs ... !!!
    [C7x_2 ] 12.277360 s: APP: Syncing with 5 CPUs ... Done !!!
    [C7x_2 ] 12.277380 s: REMOTE_SERVICE: Init ... !!!
    [C7x_2 ] 12.277591 s: REMOTE_SERVICE: Init ... Done !!!
    [C7x_2 ] 12.277620 s: VX_ZONE_INIT:Enabled
    [C7x_2 ] 12.277663 s: VX_ZONE_ERROR:Enabled
    [C7x_2 ] 12.277676 s: VX_ZONE_WARNING:Enabled
    [C7x_2 ] 12.278291 s: VX_ZONE_INIT:[tivxPlatformCreateTargetId:59] Added target DSP-1
    [C7x_2 ] 12.278320 s: VX_ZONE_INIT:[tivxInitLocal:130] Initialization Done !!!
    [C7x_2 ] 12.278334 s: APP: OpenVX Target kernel init ... !!!
    [C7x_2 ] 12.278615 s: APP: OpenVX Target kernel init ... Done !!!
    [C7x_2 ] 12.278632 s: UDMA Copy: Init ... !!!
    [C7x_2 ] 12.279708 s: UDMA Copy: Init ... Done !!!
    [C7x_2 ] 12.279725 s: APP: Init ... Done !!!
    [C7x_2 ] 12.279736 s: APP: Run ... !!!
    [C7x_2 ] 12.279745 s: IPC: Starting echo test ...
    [C7x_2 ] 12.279944 s: APP: Run ... Done !!!
    [C7x_2 ] 12.280261 s: IPC: Echo status: mpu1_0[x] mcu1_0[x] mcu2_0[x] mcu2_1[x] C7X_1[P] C7X_2[s]
    [C7x_2 ] 12.287191 s: IPC: Echo status: mpu1_0[x] mcu1_0[P] mcu2_0[x] mcu2_1[x] C7X_1[P] C7X_2[s]
    [C7x_2 ] 12.292113 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 !!!
    114.813496 s: GTC Frequency = 200 MHz
    APP: Init ... Done !!!
    114.821184 s: VX_ZONE_INIT:Enabled
    114.821224 s: VX_ZONE_ERROR:Enabled
    114.821232 s: VX_ZONE_WARNING:Enabled
    114.822428 s: VX_ZONE_INIT:[tivxInitLocal:130] Initialization Done !!!
    114.825021 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!!!
    114.839477 s: ISS: Enumerating sensors ... !!!
    [ 128.670744] Initializing XFRM netlink socket
    [ 130.145512] bridge: filtering via arp/ip/ip6tables is no longer available by default. Update your scripts to load br_netfilter if you need this.
    [ 130.163416] Bridge firewalling registered
    [ 130.833205] process 'docker/tmp/qemu-check458823016/check' started with executable stack

  • It seems it is getting stuck after below statement. Most likely DSS initialization is hanging. 

    [MCU2_0] 12.281769 s: DSS: SoC init ... Done !!!
    [MCU2_0] 12.281792 s: DSS: Board init ... !!!
    [MCU2_0] 12.281813 s: DSS: Board init ... Done !!!

    Can you please try removing call to appDssConfigureBoard, like below in app_dss_default.c file?

    if( (prm->display_type==APP_DSS_DEFAULT_DISPLAY_TYPE_DPI_HDMI) ||
    (prm->display_type==APP_DSS_DEFAULT_DISPLAY_TYPE_EDP))
    {
    //appDssConfigureBoard(prm);
    }

    Can you please check and confirm that DSS is not enabled on Linux? 

    Regards,

    Brijesh

  • Dear Brijesh,

           it is getting stuck still:

    --- a/rtos-sdk/vision_apps/utils/dss/src/app_dss_defaults.c
    +++ b/rtos-sdk/vision_apps/utils/dss/src/app_dss_defaults.c
    @@ -143,7 +143,7 @@ int32_t appDssDefaultInit(app_dss_default_prm_t *prm)
    if( (prm->display_type==APP_DSS_DEFAULT_DISPLAY_TYPE_DPI_HDMI) ||
    (prm->display_type==APP_DSS_DEFAULT_DISPLAY_TYPE_EDP))
    {
    - appDssConfigureBoard(prm);
    + //appDssConfigureBoard(prm);
    }

    [MCU1_0] 0.025329 s: ### CPU Frequency = 1000000000 Hz
    [MCU1_0] 0.025376 s: CPU is running FreeRTOS
    [MCU1_0] 0.025406 s: APP: Init ... !!!
    [MCU1_0] 0.025434 s: MEM: Init ... !!!
    [MCU1_0] 0.025479 s: MEM: Created heap (DDR_LOCAL_MEM, id=0, flags=0x00000004) @ d8000000 of size 8388608 bytes !!!
    [MCU1_0] 0.025577 s: MEM: Init ... Done !!!
    [MCU1_0] 0.025609 s: IPC: Init ... !!!
    [MCU1_0] 0.025669 s: IPC: 6 CPUs participating in IPC !!!
    [MCU1_0] 0.025720 s: IPC: Waiting for HLOS to be ready ... !!!
    [MCU1_0] 11.842371 s: IPC: HLOS is ready !!!
    [MCU1_0] 11.865025 s: IPC: Init ... Done !!!
    [MCU1_0] 11.865103 s: APP: Syncing with 5 CPUs ... !!!
    [MCU1_0] 12.588052 s: APP: Syncing with 5 CPUs ... Done !!!
    [MCU1_0] 12.588252 s: REMOTE_SERVICE: Init ... !!!
    [MCU1_0] 12.596507 s: REMOTE_SERVICE: Init ... Done !!!
    [MCU1_0] 12.596589 s: APP: Init ... Done !!!
    [MCU1_0] 12.596627 s: APP: Run ... !!!
    [MCU1_0] 12.596655 s: IPC: Starting echo test ...
    [MCU1_0] 12.600945 s: IPC: Echo status: mpu1_0[x] mcu1_0[s] mcu2_0[x] mcu2_1[x] C7X_1[P] C7X_2[x]
    [MCU1_0] 12.601572 s: APP: Run ... Done !!!
    [MCU1_0] 12.601730 s: IPC: Echo status: mpu1_0[x] mcu1_0[s] mcu2_0[x] mcu2_1[x] C7X_1[P] C7X_2[P]
    [MCU1_0] 12.602725 s: IPC: Echo status: mpu1_0[x] mcu1_0[s] mcu2_0[x] mcu2_1[P] C7X_1[P] C7X_2[P]
    [MCU1_0] 12.605075 s: can_func_Task create !!!
    [MCU1_0] 12.605146 s: can_func_Task RUN !!!
    [MCU1_0] 12.605177 s: -----CAN--Func TASK run-------
    [MCU1_0] 12.624518 s: CrossBar/Interrupt Configuration done.
    [MCU1_0] 12.624584 s: MCANSS Revision ID:
    [MCU1_0] 12.624614 s: scheme:0x1
    [MCU1_0] 12.624643 s: Business Unit:0x2
    [MCU1_0] 12.624673 s: Module ID:0x8e0
    [MCU1_0] 12.624703 s: RTL Revision:0xa
    [MCU1_0] 12.624733 s: Major Revision:0x1
    [MCU1_0] 12.624764 s: Custom Revision:0x0
    [MCU1_0] 12.624796 s: Minor Revision:0x1
    [MCU1_0] 12.624827 s: CAN-FD operation is enabled through E-Fuse.
    [MCU1_0] 12.624865 s: Endianess Value: 0x87654321
    [MCU1_0] 12.625205 s: CrossBar/Interrupt Configuration done.
    [MCU1_0] 12.625255 s: MCANSS Revision ID:
    [MCU1_0] 12.625285 s: scheme:0x1
    [MCU1_0] 12.625315 s: Business Unit:0x2
    [MCU1_0] 12.625345 s: Module ID:0x8e0
    [MCU1_0] 12.625374 s: RTL Revision:0xa
    [MCU1_0] 12.625404 s: Major Revision:0x1
    [MCU1_0] 12.625434 s: Custom Revision:0x0
    [MCU1_0] 12.625465 s: Minor Revision:0x1
    [MCU1_0] 12.625505 s: CAN-FD operation is enabled through E-Fuse.
    [MCU1_0] 12.625543 s: Endianess Value: 0x87654321
    [MCU1_0] 12.626105 s: ADC : ADC application started...
    [MCU1_0] 12.626168 s: ADC application started...
    [MCU1_0] 12.626204 s: ADC : ADC App_Udma_init !!
    [MCU1_0] 12.626241 s: ADC App_Udma_init !!
    [MCU1_0] 12.626835 s: ADC : ADC App_adcInit started...
    [MCU1_0] 12.626935 s: ADC App_adcInit started...
    [MCU1_0] 12.627509 s: ADC : ADC App_adcInit end!!!.
    [MCU1_0] 12.627549 s: ADC App_adcInit end!!!.
    [MCU1_0] 12.627578 s: ADC : ADC App_adcInit started...
    [MCU1_0] 12.627614 s: ADC App_adcInit started...
    [MCU1_0] 12.628496 s: ADC : ADC App_adcInit end!!!.
    [MCU1_0] 12.628533 s: ADC App_adcInit end!!!.
    [MCU1_0] 12.628562 s: ADC : ADC App_create started...
    [MCU1_0] 12.628599 s: ADC App_create started...
    [MCU1_0] 12.629003 s: ADC : ADC App_create Udma_chOpen gADC_0_RX_PDMA_CH end...
    [MCU1_0] 12.629076 s: ADC App_create Udma_chOpen gADC_0_RX_PDMA_CH end...
    [MCU1_0] 12.629379 s: ADC : ADC App_create Udma_chOpen gADC_1_RX_PDMA_CH end...
    [MCU1_0] 12.629438 s: ADC App_create Udma_chOpen gADC_1_RX_PDMA_CH end...
    [MCU1_0] 12.629925 s: ADC : ADC App_create end !!!!...
    [MCU1_0] 12.630002 s: ADC App_create end !!!!...
    [MCU1_0] 12.632371 s: Message successfully transferred with payload Bytes:64
    [MCU2_0] 4.014708 s: CIO: Init ... Done !!!
    [MCU2_0] 4.014758 s: ### CPU Frequency = 1000000000 Hz

    [MCU2_0] 4.014790 s: CPU is running FreeRTOS
    [MCU2_0] 4.014810 s: APP: Init ... !!!
    [MCU2_0] 4.014829 s: SCICLIENT: Init ... !!!
    [MCU2_0] 4.014956 s: SCICLIENT: DMSC FW version [8.6.3--v08.06.03 (Chill Capybar]
    [MCU2_0] 4.014987 s: SCICLIENT: DMSC FW revision 0x8
    [MCU2_0] 4.015014 s: SCICLIENT: DMSC FW ABI revision 3.1
    [MCU2_0] 4.015044 s: SCICLIENT: Init ... Done !!!
    [MCU2_0] 4.015067 s: UDMA: Init ... !!!
    [MCU2_0] 4.015975 s: UDMA: Init ... Done !!!
    [MCU2_0] 4.016011 s: UDMA: Init ... !!!
    [MCU2_0] 4.016481 s: UDMA: Init for CSITX/CSIRX ... Done !!!
    [MCU2_0] 4.016530 s: MEM: Init ... !!!
    [MCU2_0] 4.016564 s: MEM: Created heap (DDR_LOCAL_MEM, id=0, flags=0x00000004) @ d9000000 of size 16777216 bytes !!!
    [MCU2_0] 4.016623 s: MEM: Created heap (L3_MEM, id=1, flags=0x00000000) @ 60000000 of size 524288 bytes !!!
    [MCU2_0] 4.016674 s: MEM: Init ... Done !!!
    [MCU2_0] 4.016695 s: IPC: Init ... !!!
    [MCU2_0] 4.016743 s: IPC: 6 CPUs participating in IPC !!!
    [MCU2_0] 4.016777 s: IPC: Waiting for HLOS to be ready ... !!!
    [MCU2_0] 12.078678 s: IPC: HLOS is ready !!!
    [MCU2_0] 12.090142 s: IPC: Init ... Done !!!
    [MCU2_0] 12.090186 s: APP: Syncing with 5 CPUs ... !!!
    [MCU2_0] 12.588048 s: APP: Syncing with 5 CPUs ... Done !!!
    [MCU2_0] 12.588083 s: REMOTE_SERVICE: Init ... !!!
    [MCU2_0] 12.589442 s: REMOTE_SERVICE: Init ... Done !!!
    [MCU2_0] 12.589482 s: FVID2: Init ... !!!
    [MCU2_0] 12.589541 s: FVID2: Init ... Done !!!
    [MCU2_0] 12.589566 s: SCICLIENT: Sciclient_pmSetModuleState module=219 state=2
    [MCU2_0] 12.589749 s: SCICLIENT: Sciclient_pmSetModuleState success
    [MCU2_0] 12.590478 s: appGpioInit Done!!!
    [MCU2_0] 12.590512 s: DSS: Init ... !!!
    [MCU2_0] 12.590586 s: DSS: Display type is HDMI !!!
    [MCU2_0] 12.590612 s: DSS: M2M Path is enabled !!!
    [MCU2_0] 12.590636 s: DSS: SoC init ... !!!
    [MCU2_0] 12.590656 s: SCICLIENT: Sciclient_pmSetModuleState module=158 state=0
    [MCU2_0] 12.590736 s: SCICLIENT: Sciclient_pmSetModuleState success
    [MCU2_0] 12.590764 s: SCICLIENT: Sciclient_pmSetModuleClkParent module=158 clk=5 parent=7
    [MCU2_0] 12.590864 s: SCICLIENT: Sciclient_pmSetModuleClkParent success
    [MCU2_0] 12.590893 s: SCICLIENT: Sciclient_pmSetModuleClkFreq module=158 clk=5 freq=148500000
    [MCU2_0] 12.592099 s: SCICLIENT: Sciclient_pmSetModuleClkFreq success
    [MCU2_0] 12.592127 s: SCICLIENT: Sciclient_pmModuleClkRequest module=158 clk=5 state=2 flag=0
    [MCU2_0] 12.592299 s: SCICLIENT: Sciclient_pmModuleClkRequest success
    [MCU2_0] 12.592329 s: DSS: SoC init ... Done !!!
    [MCU2_1] 4.086849 s: CIO: Init ... Done !!!
    [MCU2_1] 4.086900 s: ### CPU Frequency = 1000000000 Hz
    [MCU2_1] 4.086931 s: CPU is running FreeRTOS
    [MCU2_1] 4.086952 s: APP: Init ... !!!
    [MCU2_1] 4.086971 s: SCICLIENT: Init ... !!!
    [MCU2_1] 4.087093 s: SCICLIENT: DMSC FW version [8.6.3--v08.06.03 (Chill Capybar]
    [MCU2_1] 4.087125 s: SCICLIENT: DMSC FW revision 0x8
    [MCU2_1] 4.087152 s: SCICLIENT: DMSC FW ABI revision 3.1
    [MCU2_1] 4.087182 s: SCICLIENT: Init ... Done !!!
    [MCU2_1] 4.087205 s: UDMA: Init ... !!!
    [MCU2_1] 4.088088 s: UDMA: Init ... Done !!!
    [MCU2_1] 4.088135 s: MEM: Init ... !!!
    [MCU2_1] 4.088171 s: MEM: Created heap (DDR_LOCAL_MEM, id=0, flags=0x00000004) @ da000000 of size 16777216 bytes !!!
    [MCU2_1] 4.088229 s: MEM: Created heap (L3_MEM, id=1, flags=0x00000001) @ 60080000 of size 524288 bytes !!!
    [MCU2_1] 4.088278 s: MEM: Init ... Done !!!
    [MCU2_1] 4.088300 s: IPC: Init ... !!!
    [MCU2_1] 4.088345 s: IPC: 6 CPUs participating in IPC !!!
    [MCU2_1] 4.088380 s: IPC: Waiting for HLOS to be ready ... !!!
    [MCU2_1] 12.576427 s: IPC: HLOS is ready !!!
    [MCU2_1] 12.587975 s: IPC: Init ... Done !!!
    [MCU2_1] 12.588013 s: APP: Syncing with 5 CPUs ... !!!
    [MCU2_1] 12.588047 s: APP: Syncing with 5 CPUs ... Done !!!
    [MCU2_1] 12.588075 s: REMOTE_SERVICE: Init ... !!!
    [MCU2_1] 12.589466 s: REMOTE_SERVICE: Init ... Done !!!
    [MCU2_1] 12.589510 s: FVID2: Init ... !!!
    [MCU2_1] 12.589564 s: FVID2: Init ... Done !!!
    [MCU2_1] 12.589587 s: VHWA: DMPAC: Init ... !!!
    [MCU2_1] 12.589662 s: SCICLIENT: Sciclient_pmSetModuleState module=58 state=2
    [MCU2_1] 12.589929 s: SCICLIENT: Sciclient_pmSetModuleState success
    [MCU2_1] 12.589958 s: SCICLIENT: Sciclient_pmSetModuleState module=62 state=2
    [MCU2_1] 12.590054 s: SCICLIENT: Sciclient_pmSetModuleState success
    [MCU2_1] 12.590080 s: VHWA: DOF Init ... !!!
    [MCU2_1] 12.594874 s: VHWA: DOF Init ... Done !!!
    [MCU2_1] 12.594910 s: VHWA: SDE Init ... !!!
    [MCU2_1] 12.596356 s: VHWA: SDE Init ... Done !!!
    [MCU2_1] 12.596386 s: VHWA: DMPAC: Init ... Done !!!
    [MCU2_1] 12.596422 s: VX_ZONE_INIT:Enabled
    [MCU2_1] 12.596445 s: VX_ZONE_ERROR:Enabled
    [MCU2_1] 12.596475 s: VX_ZONE_WARNING:Enabled
    [MCU2_1] 12.597595 s: VX_ZONE_INIT:[tivxPlatformCreateTargetId:66] Added target MCU2-1
    [MCU2_1] 12.597779 s: VX_ZONE_INIT:[tivxPlatformCreateTargetId:66] Added target DMPAC_SDE
    [MCU2_1] 12.597946 s: VX_ZONE_INIT:[tivxPlatformCreateTargetId:66] Added target DMPAC_DOF
    [MCU2_1] 12.597989 s: VX_ZONE_INIT:[tivxInitLocal:130] Initialization Done !!!
    [MCU2_1] 12.598018 s: APP: OpenVX Target kernel init ... !!!
    [MCU2_1] 12.598255 s: APP: OpenVX Target kernel init ... Done !!!
    [MCU2_1] 12.598284 s: UDMA Copy: Init ... !!!
    [MCU2_1] 12.599446 s: UDMA Copy: Init ... Done !!!
    [MCU2_1] 12.599495 s: APP: Init ... Done !!!
    [MCU2_1] 12.599518 s: APP: Run ... !!!
    [MCU2_1] 12.599538 s: IPC: Starting echo test ...
    [MCU2_1] 12.602013 s: APP: Run ... Done !!!
    [MCU2_1] 12.602682 s: IPC: Echo status: mpu1_0[x] mcu1_0[.] mcu2_0[x] mcu2_1[s] C7X_1[P] C7X_2[.]
    [MCU2_1] 12.602758 s: IPC: Echo status: mpu1_0[x] mcu1_0[.] mcu2_0[x] mcu2_1[s] C7X_1[P] C7X_2[P]
    [MCU2_1] 12.602827 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.715447 s: CIO: Init ... Done !!!
    [C7x_1 ] 4.715461 s: ### CPU Frequency = 1000000000 Hz
    [C7x_1 ] 4.715474 s: CPU is running FreeRTOS
    [C7x_1 ] 4.715483 s: APP: Init ... !!!
    [C7x_1 ] 4.715491 s: SCICLIENT: Init ... !!!
    [C7x_1 ] 4.715596 s: SCICLIENT: DMSC FW version [8.6.3--v08.06.03 (Chill Capybar]
    [C7x_1 ] 4.715610 s: SCICLIENT: DMSC FW revision 0x8
    [C7x_1 ] 4.715621 s: SCICLIENT: DMSC FW ABI revision 3.1
    [C7x_1 ] 4.715632 s: SCICLIENT: Init ... Done !!!
    [C7x_1 ] 4.715641 s: UDMA: Init ... !!!
    [C7x_1 ] 4.716434 s: UDMA: Init ... Done !!!
    [C7x_1 ] 4.716448 s: MEM: Init ... !!!
    [C7x_1 ] 4.716459 s: MEM: Created heap (DDR_LOCAL_MEM, id=0, flags=0x00000004) @ 117000000 of size 268435456 bytes !!!
    [C7x_1 ] 4.716480 s: MEM: Created heap (L3_MEM, id=1, flags=0x00000001) @ 70020000 of size 3964928 bytes !!!
    [C7x_1 ] 4.716498 s: MEM: Created heap (L2_MEM, id=2, flags=0x00000001) @ 64800000 of size 458752 bytes !!!
    [C7x_1 ] 4.716517 s: MEM: Created heap (L1_MEM, id=3, flags=0x00000001) @ 64e00000 of size 16384 bytes !!!
    [C7x_1 ] 4.716534 s: MEM: Created heap (DDR_SCRATCH_MEM, id=4, flags=0x00000001) @ 100000000 of size 385875968 bytes !!!
    [C7x_1 ] 4.716553 s: MEM: Init ... Done !!!
    [C7x_1 ] 4.716561 s: IPC: Init ... !!!
    [C7x_1 ] 4.716575 s: IPC: 6 CPUs participating in IPC !!!
    [C7x_1 ] 4.716590 s: IPC: Waiting for HLOS to be ready ... !!!
    [C7x_1 ] 11.689928 s: IPC: HLOS is ready !!!
    [C7x_1 ] 11.692286 s: IPC: Init ... Done !!!
    [C7x_1 ] 11.692301 s: APP: Syncing with 5 CPUs ... !!!
    [C7x_1 ] 12.588049 s: APP: Syncing with 5 CPUs ... Done !!!
    [C7x_1 ] 12.588069 s: REMOTE_SERVICE: Init ... !!!
    [C7x_1 ] 12.588251 s: REMOTE_SERVICE: Init ... Done !!!
    [C7x_1 ] 12.588277 s: VX_ZONE_INIT:Enabled
    [C7x_1 ] 12.588288 s: VX_ZONE_ERROR:Enabled
    [C7x_1 ] 12.588298 s: VX_ZONE_WARNING:Enabled
    [C7x_1 ] 12.588605 s: VX_ZONE_INIT:[tivxPlatformCreateTargetId:59] Added target DSP_C7-1
    [C7x_1 ] 12.588707 s: VX_ZONE_INIT:[tivxPlatformCreateTargetId:59] Added target DSP_C7-1_PRI_2
    [C7x_1 ] 12.588777 s: VX_ZONE_INIT:[tivxPlatformCreateTargetId:59] Added target DSP_C7-1_PRI_3
    [C7x_1 ] 12.588847 s: VX_ZONE_INIT:[tivxPlatformCreateTargetId:59] Added target DSP_C7-1_PRI_4
    [C7x_1 ] 12.588922 s: VX_ZONE_INIT:[tivxPlatformCreateTargetId:59] Added target DSP_C7-1_PRI_5
    [C7x_1 ] 12.588994 s: VX_ZONE_INIT:[tivxPlatformCreateTargetId:59] Added target DSP_C7-1_PRI_6
    [C7x_1 ] 12.589061 s: VX_ZONE_INIT:[tivxPlatformCreateTargetId:59] Added target DSP_C7-1_PRI_7
    [C7x_1 ] 12.589131 s: VX_ZONE_INIT:[tivxPlatformCreateTargetId:59] Added target DSP_C7-1_PRI_8
    [C7x_1 ] 12.589156 s: VX_ZONE_INIT:[tivxInitLocal:130] Initialization Done !!!
    [C7x_1 ] 12.589169 s: APP: OpenVX Target kernel init ... !!!
    [C7x_1 ] 12.589299 s: APP: OpenVX Target kernel init ... Done !!!
    [C7x_1 ] 12.589314 s: APP: Init ... Done !!!
    [C7x_1 ] 12.589324 s: APP: Run ... !!!
    [C7x_1 ] 12.589339 s: IPC: Starting echo test ...
    [C7x_1 ] 12.589513 s: APP: Run ... Done !!!
    [C7x_1 ] 12.590780 s: IPC: Echo status: mpu1_0[x] mcu1_0[x] mcu2_0[x] mcu2_1[x] C7X_1[s] C7X_2[P]
    [C7x_1 ] 12.597641 s: IPC: Echo status: mpu1_0[x] mcu1_0[P] mcu2_0[x] mcu2_1[x] C7X_1[s] C7X_2[P]
    [C7x_1 ] 12.602553 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.143190 s: CIO: Init ... Done !!!
    [C7x_2 ] 5.143206 s: ### CPU Frequency = 1000000000 Hz
    [C7x_2 ] 5.143219 s: CPU is running FreeRTOS
    [C7x_2 ] 5.143228 s: APP: Init ... !!!
    [C7x_2 ] 5.143238 s: SCICLIENT: Init ... !!!
    [C7x_2 ] 5.143344 s: SCICLIENT: DMSC FW version [8.6.3--v08.06.03 (Chill Capybar]
    [C7x_2 ] 5.143359 s: SCICLIENT: DMSC FW revision 0x8
    [C7x_2 ] 5.143371 s: SCICLIENT: DMSC FW ABI revision 3.1
    [C7x_2 ] 5.143382 s: SCICLIENT: Init ... Done !!!
    [C7x_2 ] 5.143392 s: UDMA: Init ... !!!
    [C7x_2 ] 5.144184 s: UDMA: Init ... Done !!!
    [C7x_2 ] 5.144198 s: MEM: Init ... !!!
    [C7x_2 ] 5.144211 s: MEM: Created heap (DDR_LOCAL_MEM, id=0, flags=0x00000004) @ 127000000 of size 16777216 bytes !!!
    [C7x_2 ] 5.144233 s: MEM: Created heap (L2_MEM, id=2, flags=0x00000001) @ 65800000 of size 458752 bytes !!!
    [C7x_2 ] 5.144252 s: MEM: Created heap (L1_MEM, id=3, flags=0x00000001) @ 65e00000 of size 16384 bytes !!!
    [C7x_2 ] 5.144271 s: MEM: Created heap (DDR_SCRATCH_MEM, id=4, flags=0x00000001) @ 128000000 of size 67108864 bytes !!!
    [C7x_2 ] 5.144290 s: MEM: Init ... Done !!!
    [C7x_2 ] 5.144299 s: IPC: Init ... !!!
    [C7x_2 ] 5.144314 s: IPC: 6 CPUs participating in IPC !!!
    [C7x_2 ] 5.144330 s: IPC: Waiting for HLOS to be ready ... !!!
    [C7x_2 ] 12.004083 s: IPC: HLOS is ready !!!
    [C7x_2 ] 12.006477 s: IPC: Init ... Done !!!
    [C7x_2 ] 12.006493 s: APP: Syncing with 5 CPUs ... !!!
    [C7x_2 ] 12.588049 s: APP: Syncing with 5 CPUs ... Done !!!
    [C7x_2 ] 12.588071 s: REMOTE_SERVICE: Init ... !!!
    [C7x_2 ] 12.588266 s: REMOTE_SERVICE: Init ... Done !!!
    [C7x_2 ] 12.588293 s: VX_ZONE_INIT:Enabled
    [C7x_2 ] 12.588305 s: VX_ZONE_ERROR:Enabled
    [C7x_2 ] 12.588320 s: VX_ZONE_WARNING:Enabled
    [C7x_2 ] 12.588941 s: VX_ZONE_INIT:[tivxPlatformCreateTargetId:59] Added target DSP-1
    [C7x_2 ] 12.588970 s: VX_ZONE_INIT:[tivxInitLocal:130] Initialization Done !!!
    [C7x_2 ] 12.588984 s: APP: OpenVX Target kernel init ... !!!
    [C7x_2 ] 12.589262 s: APP: OpenVX Target kernel init ... Done !!!
    [C7x_2 ] 12.589278 s: UDMA Copy: Init ... !!!
    [C7x_2 ] 12.590275 s: UDMA Copy: Init ... Done !!!
    [C7x_2 ] 12.590289 s: APP: Init ... Done !!!
    [C7x_2 ] 12.590301 s: APP: Run ... !!!
    [C7x_2 ] 12.590309 s: IPC: Starting echo test ...
    [C7x_2 ] 12.590479 s: APP: Run ... Done !!!
    [C7x_2 ] 12.590789 s: IPC: Echo status: mpu1_0[x] mcu1_0[x] mcu2_0[x] mcu2_1[x] C7X_1[P] C7X_2[s]
    [C7x_2 ] 12.597669 s: IPC: Echo status: mpu1_0[x] mcu1_0[P] mcu2_0[x] mcu2_1[x] C7X_1[P] C7X_2[s]
    [C7x_2 ] 12.602565 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# ./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 !!!
    37.844341 s: GTC Frequency = 200 MHz
    APP: Init ... Done !!!
    37.851777 s: VX_ZONE_INIT:Enabled
    37.851804 s: VX_ZONE_ERROR:Enabled
    37.851810 s: VX_ZONE_WARNING:Enabled
    37.852838 s: VX_ZONE_INIT:[tivxInitLocal:130] Initialization Done !!!
    37.853027 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!!!
    37.867386 s: ISS: Enumerating sensors ... !!!

  • Dear Brijesh,

           it is getting stuck  in  appDssInit(&dssParams);

  • Hi qin,

    Do you have CCS and JTAG to connect and check where mcu2_0 is stuck? Because this appDssInit API just calls Dss_init, which initializes DSS drivers on mcu2_0. This should not get stuck. 

    Are there any changes from the released sdk? This is because this is working fine in released SDK. 

    Have you enabled DSS on A72 core? or can we try disabling initialization of eDP? can you try setting "dssInitParams.socParams.dpInitParams.isAvailable" flag to false in vision_apps\utils\dss\src\app_dss.c file? 

    Regards,

    Brijesh

  • 1. setting "dssInitParams.socParams.dpInitParams.isAvailable" flag to false, but it is getting stuck still

    2. Do you have CCS and JTAG to connect and check where mcu2_0 is stuck?

             --> We have no CCS or  JTAG

  • Dear Brijesh,

         Why we use M2m ?  Can We use 2M UYUV Camera to check ? 

         2M UYVY camera ->ser->des->capture->viss->csitx1->ser

  • Hi Qin,

    Yes, if you have YUV422 camera, you can directly connect it to CSITX, no need to have VISS in between. 

    Regards,

    Brijesh

  • Dear Brijesh,

    How to directly connect it to CSITX, no need to have VISS in between? I'll give you the code later. Can you help me check it?

  • Hi Qin,

    You can just use output object array of CSIRX as input to the CSITX. Since capture is in YUV422, it can be directly connected. 

    Regards,

    Brijesh

  • please help me check, Thanks :

    /*
     *
     * 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"
    #include <utils/perf_stats/include/app_perf_stats.h>
    #include <utils/ipc/include/app_ipc.h>
    #include <utils/console_io/include/app_log.h>
    
    #ifdef A72
    #if defined(LINUX)
    /*ITT server is supported only in target mode and only on Linux*/
    #include <itt_server.h>
    #endif
    #endif
    
    #define VX_CALL(fn_call) fn_call
    #define VX_CALL_(ret_code, fn_call) fn_call
    #define VX_CALL_RET(fn_call) fn_call
    static char availableSensorNames[ISS_SENSORS_MAX_SUPPORTED_SENSOR][ISS_SENSORS_MAX_NAME];
    static vx_uint8 num_sensors_found;
    static IssSensor_CreateParams sensorParams;
    
    uint32_t g_frame_lost_times = 0;
    uint32_t g_frame_lost_num = 0;
    uint32_t g_frame_lost_rate[2] = {0,0};
    uint64_t frame_begin_time,frame_end_time;
    
    
    #define NUM_CAPT_CHANNELS   (4u)
    #define CSITX_FORMAT        (VX_DF_IMAGE_UYVY)
    #define NUM_CHANNELS        (1)
    #define CSITX_INST_ID       (1U)
    #define CAPT_INST_ID        (1U)
    
    //#define CSITX_LANE_BAND_SPEED       TIVX_CSITX_LANE_BAND_SPEED_770_TO_870_MBPS 
    //#define CSITX_LANE_SPEED_MBPS       (800U)
    #define CSITX_LANE_BAND_SPEED TIVX_CSITX_LANE_BAND_SPEED_560_TO_640_MBPS
    #define CSITX_LANE_SPEED_MBPS       (600U)
    
    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_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;
    
    #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 = 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 == 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;
            }
            else
            {
                if ((image_width >= obj->display_params.outWidth) && (image_height >= obj->display_params.outHeight))
                {
                    obj->scaler_enable = vx_true_e;
                }
                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, scaler_out_h;
                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, scaler_out_w, scaler_out_h, 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) {
        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");
        }
    }
    
        tx_frame = vxCreateObjectArray(obj->context, (vx_reference)obj->capt_yuv_image, NUM_CHANNELS);
    
        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_CSITX2));
        status = vxGetStatus((vx_reference)csitx_node);
        if (status == VX_SUCCESS)
        {
            printf("zqq csitx_node create 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++;
    #if 1
        add_graph_parameter_by_node_index(obj->graph, csitx_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 = 1;
        graph_parameters_queue_params_list[graph_parameter_num].refs_list = (vx_reference*)&(tx_frame);
        graph_parameter_num++;
    #endif	
        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;
    	uint32_t num_refs;
    	vx_object_array transmitted_frames = NULL;
    
        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))
            {
                status = vxGraphParameterEnqueueReadyRef(obj->graph, 1, (vx_reference*)&(obj->display_image), 1);
            }
    #if 1		
    	if(status == VX_SUCCESS)
             {
                 status = vxGraphParameterEnqueueReadyRef(obj->graph, 1, (vx_reference*)&(tx_frame), 1);
             }
    #endif
        }
    
        /*
            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);
    
            frame_begin_time = appLogGetTimeInUsec();
    
            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);
            }
    #if 1		
    	if(status == VX_SUCCESS)
            {
                status = vxGraphParameterDequeueDoneRef(obj->graph, 1, (vx_reference*)&transmitted_frames, 1, &num_refs);
            }
    #endif 		
    		
            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, 1, (vx_reference*)&transmitted_frames, 1);
            }
    #if 1
            if(status == VX_SUCCESS)
            {
                status = vxGraphParameterEnqueueReadyRef(obj->graph, graph_parameter_num, (vx_reference*)&out_capture_frames, 1);
            }
    #endif
            graph_parameter_num++;
    
            frame_end_time = appLogGetTimeInUsec();
    
            appPerfPointEnd(&obj->total_perf);
    
            if(frame_end_time - frame_begin_time > 1000*1000ull/30*3)
            {
                g_frame_lost_times++;
                APP_PERF_PRINTF("[APP][Single] PERF total consecutive 2 frames lost %d times\n",g_frame_lost_times);
            }
            if(frame_end_time - frame_begin_time > 1000*1000ull/30*2)
            {
                g_frame_lost_num++;
                g_frame_lost_rate[0] = (g_frame_lost_num*10000)/(obj->total_perf.num)/100;
                g_frame_lost_rate[1] = ((g_frame_lost_num*10000)/(obj->total_perf.num))%100;
                APP_PERF_PRINTF("[APP][Single] PERF total frame lost num is %d,frame lost rate is %d.%d\n",g_frame_lost_num,g_frame_lost_rate[0],g_frame_lost_rate[1]);
            }
            else
            {
                g_frame_lost_rate[0] = (g_frame_lost_num*10000)/(obj->total_perf.num)/100;
                g_frame_lost_rate[1] = ((g_frame_lost_num*10000)/(obj->total_perf.num))%100;
            }
    
            //mask fps          : 0x0001xxxx
            //mask lost_rate    : 0x0002xxxx
            //mask lost_times   : 0x0004xxxx
    
            //send ipc msg about camera_info per 30 frame to mcu1_0
            if((i%30) == 0)
            {
                com_data_t send_data;
                memset(&send_data, 0, sizeof(com_data_t)); 
    
                uint32_t fps[2]={0,0};
    
                appPerfPointGetFPS(fps,&obj->total_perf);
    
                fps[0] &= 0x000000ff;
                fps[1] &= 0x000000ff;
    
                APP_PERF_PRINTF("[APP][Single] perf geted fps[0] = %d ,fps[1] = %d\n",fps[0],fps[1]);
                uint32_t msg_fps = (fps[0] | (fps[1]<< 8));
    
                send_data.data.playload = (msg_fps & 0x0000ffff) | 0x00010000; 
                status = appIpcSendNotify(1/*mcu1_0*/, &send_data, sizeof(com_data_t));
                APP_PERF_PRINTF("[APP][Single] IPC:CPU[%s] Sent msg_fps 0x%x to CPU [%s],status is %d\n", appIpcGetCpuName(0),msg_fps, appIpcGetCpuName(1),status);
    
                uint32_t msg_lost_rate = ((g_frame_lost_rate[0] & 0x000000ff) | ((g_frame_lost_rate[1] & 0x000000ff) << 8));
    
                send_data.data.playload = (msg_lost_rate & 0x0000ffff) | 0x00020000; 
                status = appIpcSendNotify(1/*mcu1_0*/, &send_data, sizeof(com_data_t));           
                APP_PERF_PRINTF("[APP][Single]IPC:CPU[%s] Sent msg_lost_rate 0x%x to CPU [%s],status is %d\n", appIpcGetCpuName(0),msg_lost_rate, appIpcGetCpuName(1),status);
    
                uint32_t msg_lost_times = (g_frame_lost_times & 0x000000ff);
    
                send_data.data.playload = (msg_lost_times | 0x00040000); 
                status = appIpcSendNotify(1/*mcu1_0*/, &send_data, sizeof(com_data_t));               
                APP_PERF_PRINTF("[APP][Single] IPC:CPU[%s] Sent msg_lost_times 0x%x to CPU [%s],status is %d\n", appIpcGetCpuName(0),msg_lost_times, appIpcGetCpuName(1),status);
            }
    
            //reset perf count per 150 frames (5s)
            if(i%150 == 0)
            {
                APP_PERF_PRINTF("[APP][Single] reset perf count and frame lost num/rate count in frame No %d\n",i);
                appPerfPointReset(&obj->total_perf);
                g_frame_lost_num = 0;
                g_frame_lost_rate[0] = 0;
                g_frame_lost_rate[1] = 0;
            }
    
            if((obj->stop_task) || (status != VX_SUCCESS))
            {
                com_data_t send_data;
                memset(&send_data, 0, sizeof(com_data_t)); 
                send_data.data.playload = 0x00010000;   
                appIpcSendNotify(1/*mcu1_0*/, &send_data, sizeof(com_data_t));
                send_data.data.playload = 0x00020000;   
                appIpcSendNotify(1/*mcu1_0*/,&send_data, sizeof(com_data_t));
                send_data.data.playload = 0x00040000;             
                appIpcSendNotify(1/*mcu1_0*/, &send_data, sizeof(com_data_t));
                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;
    #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;
    }
    
    

  • There is no need to create another object array for yuv image. We need to use same the object array that is used for CSIRX output. Please change as shown below. 

    //tx_frame = vxCreateObjectArray(obj->context, (vx_reference)obj->capt_yuv_image, NUM_CHANNELS);
    tx_frame = obj->cap_frames[0];

    Regards,

    Brijesh

  • Dear Brijesh,

          After this modification, the camera has no output

  • Summary of CPU load,
    ====================

    CPU: mpu1_0: TOTAL LOAD = 0.16 % ( HWI = 0. 3 %, SWI = 0. 1 % )
    CPU: mcu1_0: TOTAL LOAD = 19. 0 % ( HWI = 0. 0 %, SWI = 0. 0 % )
    CPU: mcu2_0: TOTAL LOAD = 14. 0 % ( HWI = 0. 0 %, SWI = 0. 0 % )
    CPU: mcu2_1: TOTAL LOAD = 13. 0 % ( HWI = 0. 0 %, SWI = 0. 0 % )
    CPU: c7x_1: TOTAL LOAD = 0. 0 % ( HWI = 0. 0 %, SWI = 0. 0 % )
    CPU: c7x_2: TOTAL LOAD = 1. 0 % ( HWI = 0. 0 %, SWI = 0. 0 % )


    HWA performance statistics,
    ===========================

    DDR performance statistics,
    ===========================

    DDR: READ BW: AVG = 1 MB/s, PEAK = 7363 MB/s
    DDR: WRITE BW: AVG = 117 MB/s, PEAK = 1760 MB/s
    DDR: TOTAL BW: AVG = 118 MB/s, PEAK = 9123 MB/s


    Detailed CPU performance/memory statistics,
    ===========================================

    DDR_SHARED_MEM: Alloc's: 6 alloc's of 16589168 bytes
    DDR_SHARED_MEM: Free's : 0 free's of 0 bytes
    DDR_SHARED_MEM: Open's : 6 allocs of 16589168 bytes
    DDR_SHARED_MEM: Total size: 536870912 bytes

    CPU: mcu1_0: TASK: IPC_RX: 0. 0 %
    CPU: mcu1_0: TASK: REMOTE_SRV: 0. 0 %
    CPU: mcu1_0: TASK: LOAD_TEST: 0. 0 %
    CPU: mcu1_0: TASK: IPC_TEST_RX: 0. 0 %
    CPU: mcu1_0: TASK: IPC_TEST_TX: 0. 0 %
    CPU: mcu1_0: TASK: IPC_TEST_TX: 0. 0 %
    CPU: mcu1_0: TASK: IPC_TEST_TX: 0. 0 %
    CPU: mcu1_0: TASK: IPC_TEST_TX: 0. 0 %
    CPU: mcu1_0: TASK: IPC_TEST_TX: 0. 0 %

    CPU: mcu1_0: HEAP: DDR_LOCAL_MEM: size = 8388608 B, free = 8388352 B ( 99 % unused)

    CPU: mcu2_0: TASK: IPC_RX: 0. 0 %
    CPU: mcu2_0: TASK: REMOTE_SRV: 0.32 %
    CPU: mcu2_0: TASK: LOAD_TEST: 0. 0 %
    CPU: mcu2_0: TASK: TIVX_CPU_0: 0. 0 %
    CPU: mcu2_0: TASK: TIVX_V1NF: 0. 0 %
    CPU: mcu2_0: TASK: TIVX_V1LDC1: 0. 0 %
    CPU: mcu2_0: TASK: TIVX_V1SC1: 0. 0 %
    CPU: mcu2_0: TASK: TIVX_V1MSC2: 0. 0 %
    CPU: mcu2_0: TASK: TIVXVVISS1: 0. 0 %
    CPU: mcu2_0: TASK: TIVX_CAPT1: 0. 0 %
    CPU: mcu2_0: TASK: TIVX_CAPT2: 0. 0 %
    CPU: mcu2_0: TASK: TIVX_DISP1: 0. 0 %
    CPU: mcu2_0: TASK: TIVX_DISP2: 0. 0 %
    CPU: mcu2_0: TASK: TIVX_CSITX: 0. 0 %
    CPU: mcu2_0: TASK: TIVX_CSITX2: 0. 0 %
    CPU: mcu2_0: TASK: TIVX_CAPT3: 0. 0 %
    CPU: mcu2_0: TASK: TIVX_CAPT4: 0. 0 %
    CPU: mcu2_0: TASK: TIVX_CAPT5: 0. 0 %
    CPU: mcu2_0: TASK: TIVX_CAPT6: 0. 0 %
    CPU: mcu2_0: TASK: TIVX_CAPT7: 0. 0 %
    CPU: mcu2_0: TASK: TIVX_CAPT8: 0. 0 %
    CPU: mcu2_0: TASK: TIVX_DPM2M1: 0. 0 %
    CPU: mcu2_0: TASK: TIVX_DPM2M2: 0. 0 %
    CPU: mcu2_0: TASK: TIVX_DPM2M3: 0. 0 %

    CPU: mcu2_0: HEAP: DDR_LOCAL_MEM: size = 16777216 B, free = 16690688 B ( 99 % unused)
    CPU: mcu2_0: HEAP: L3_MEM: size = 524288 B, free = 524032 B ( 99 % unused)

    CPU: mcu2_1: TASK: IPC_RX: 0. 0 %
    CPU: mcu2_1: TASK: REMOTE_SRV: 0. 0 %
    CPU: mcu2_1: TASK: LOAD_TEST: 0. 0 %
    CPU: mcu2_1: TASK: TIVX_CPU_1: 0. 0 %
    CPU: mcu2_1: TASK: TIVX_SDE: 0. 0 %
    CPU: mcu2_1: TASK: TIVX_DOF: 0. 0 %
    CPU: mcu2_1: TASK: IPC_TEST_RX: 0. 0 %
    CPU: mcu2_1: TASK: IPC_TEST_TX: 0. 0 %
    CPU: mcu2_1: TASK: IPC_TEST_TX: 0. 0 %
    CPU: mcu2_1: TASK: IPC_TEST_TX: 0. 0 %
    CPU: mcu2_1: TASK: IPC_TEST_TX: 0. 0 %
    CPU: mcu2_1: TASK: IPC_TEST_TX: 0. 0 %

    CPU: mcu2_1: HEAP: DDR_LOCAL_MEM: size = 16777216 B, free = 16773120 B ( 99 % unused)
    CPU: mcu2_1: HEAP: L3_MEM: size = 524288 B, free = 524288 B (100 % unused)

    CPU: c7x_1: TASK: IPC_RX: 0. 0 %
    CPU: c7x_1: TASK: REMOTE_SRV: 0. 0 %
    CPU: c7x_1: TASK: LOAD_TEST: 0. 0 %
    CPU: c7x_1: TASK: TIVX_C71_P1: 0. 0 %
    CPU: c7x_1: TASK: TIVX_C71_P2: 0. 0 %
    CPU: c7x_1: TASK: TIVX_C71_P3: 0. 0 %
    CPU: c7x_1: TASK: TIVX_C71_P4: 0. 0 %
    CPU: c7x_1: TASK: TIVX_C71_P5: 0. 0 %
    CPU: c7x_1: TASK: TIVX_C71_P6: 0. 0 %
    CPU: c7x_1: TASK: TIVX_C71_P7: 0. 0 %
    CPU: c7x_1: TASK: TIVX_C71_P8: 0. 0 %
    CPU: c7x_1: TASK: IPC_TEST_RX: 0. 0 %
    CPU: c7x_1: TASK: IPC_TEST_TX: 0. 0 %
    CPU: c7x_1: TASK: IPC_TEST_TX: 0. 0 %
    CPU: c7x_1: TASK: IPC_TEST_TX: 0. 0 %
    CPU: c7x_1: TASK: IPC_TEST_TX: 0. 0 %
    CPU: c7x_1: TASK: IPC_TEST_TX: 0. 0 %

    CPU: c7x_1: HEAP: DDR_LOCAL_MEM: size = 268435456 B, free = 268435200 B ( 99 % unused)
    CPU: c7x_1: HEAP: L3_MEM: size = 3964928 B, free = 3964928 B (100 % unused)
    CPU: c7x_1: HEAP: L2_MEM: size = 458752 B, free = 458752 B (100 % unused)
    CPU: c7x_1: HEAP: L1_MEM: size = 16384 B, free = 16384 B (100 % unused)
    CPU: c7x_1: HEAP: DDR_SCRATCH_MEM: size = 385875968 B, free = 385875968 B (100 % unused)

    CPU: c7x_2: TASK: IPC_RX: 0. 0 %
    CPU: c7x_2: TASK: REMOTE_SRV: 0. 0 %
    CPU: c7x_2: TASK: LOAD_TEST: 0. 0 %
    CPU: c7x_2: TASK: TIVX_CPU: 0. 0 %
    CPU: c7x_2: TASK: IPC_TEST_RX: 0. 0 %
    CPU: c7x_2: TASK: IPC_TEST_TX: 0. 0 %
    CPU: c7x_2: TASK: IPC_TEST_TX: 0. 0 %
    CPU: c7x_2: TASK: IPC_TEST_TX: 0. 0 %
    CPU: c7x_2: TASK: IPC_TEST_TX: 0. 0 %
    CPU: c7x_2: TASK: IPC_TEST_TX: 0. 0 %

    CPU: c7x_2: HEAP: DDR_LOCAL_MEM: size = 16777216 B, free = 16772608 B ( 99 % unused)
    CPU: c7x_2: HEAP: L2_MEM: size = 458752 B, free = 458752 B (100 % unused)
    CPU: c7x_2: HEAP: L1_MEM: size = 16384 B, free = 16384 B (100 % unused)
    CPU: c7x_2: HEAP: DDR_SCRATCH_MEM: size = 67108864 B, free = 67108864 B (100 % unused)


    GRAPH: graph_85 (#nodes = 2, #executions = 2)
    NODE: CAPTURE2: node_96: avg = 38334 usecs, min/max = 33272 / 43397 usecs, #executions = 2
    NODE: CSITX2: node_97: avg = 22285 usecs, min/max = 22242 / 22329 usecs, #executions = 2

    PERF: TOTAL: avg = 0 usecs, min/max = 4294967295 / 0 usecs, #executions = 0

    PERF: TOTAL: 0. 0 FPS