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.

TDA4x: Single camera application supports the YUV422 format

Other Parts Discussed in Thread: TCA6408

Dear Sir,

I have installed latest SDK (08_05_00) on ubuntu 18.04

i have added image sensor code for sony ISX016 and build the imaging folder it got built successfully 

serializer : TI DS90UB913A 

WIDTH : 1280

Height :724

when i execute the single camera application i get the error below 

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 !!!
68.864436 s: GTC Frequency = 200 MHz
APP: Init ... Done !!!
68.874301 s: VX_ZONE_INIT:Enabled
68.874331 s: VX_ZONE_ERROR:Enabled
68.874344 s: VX_ZONE_WARNING:Enabled
68.875153 s: VX_ZONE_INIT:[tivxInitLocal:145] Initialization Done !!!
68.876191 s: VX_ZONE_INIT:[tivxHostInitLocal:93] Initialization Done for HOST !!!
arm app_parse_cmd_line_args .......madhav .....

Single Camera Demo - (c) Texas Instruments 2019
========================================================

Usage,
./vx_app_single_cam.out --cfg <config file>

Defaulting to interactive mode madhav
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
68.892055 s: ISS: Enumerating sensors ... !!!
69.392198 s: ISS: Enumerating sensors ... found 0 : IMX390-UB953_D3
69.392221 s: ISS: Enumerating sensors ... found 1 : AR0233-UB953_MARS
69.392242 s: ISS: Enumerating sensors ... found 2 : AR0820-UB953_LI
69.392247 s: ISS: Enumerating sensors ... found 3 : UB9xxx_RAW12_TESTPATTERN
69.392252 s: ISS: Enumerating sensors ... found 4 : ISX016-UB913
69.392257 s: ISS: Enumerating sensors ... found 5 : UB96x_UYVY_TESTPATTERN
69.392261 s: ISS: Enumerating sensors ... found 6 : GW_AR0233_UYVY
Select camera port index 0-7 : 0
7 registered sensor drivers
a : IMX390-UB953_D3
b : AR0233-UB953_MARS
c : AR0820-UB953_LI
d : UB9xxx_RAW12_TESTPATTERN
e : ISX016-UB913
f : UB96x_UYVY_TESTPATTERN
g : GW_AR0233_UYVY
Select a sensor above or press '0' to autodetect the sensor : Invalid selection
. Try again
7 registered sensor drivers
a : IMX390-UB953_D3
b : AR0233-UB953_MARS
c : AR0820-UB953_LI
d : UB9xxx_RAW12_TESTPATTERN
e : ISX016-UB913
f : UB96x_UYVY_TESTPATTERN
g : GW_AR0233_UYVY
Select a sensor above or press '0' to autodetect the sensor : e
selectedSensor =4 Sensor selected : ISX016-UB913
LDC Selection Yes(1)/No(0) : LDC Selection Yes(1)/No(0) : 0
app_init done
Querying ISX016-UB913
77.420754 s: ISS: Querying sensor [ISX016-UB913] ... !!!
77.421117 s: ISS: Querying sensor [ISX016-UB913] ... Done !!!
sensorParams.sensorInfo.raw_params.format[0].pixel_container === 101000
VX_DF_IMAGE_UYVY === 59565955
Sensor width = 1280
Sensor height = 724
Sensor DCC ID = 160
Sensor Supported Features = 0x378
Sensor Enabled Features = 0x0
77.421147 s: ISS: Initializing sensor [ISX016-UB913], doing IM_SENSOR_CMD_PWRON ... !!!
79.981167 s: ISS: Initializing sensor [ISX016-UB913], doing IM_SENSOR_CMD_CONFIG ... !!!
123.253903 s: ISS: ERROR: Initializing sensor [ISX016-UB913] failed !!!
123.253955 s: ISS: Initializing sensor [ISX016-UB913] ... Done !!!
Error initializing sensor ISX016-UB913
Creating graph
Initializing params for capture node
capture_config = 0x0xffff9491ae08
Creating capture node
obj->capture_node = 0x0xffff9488cb88
Display Set Target done
vxSetGraphScheduleConfig done
123.270436 s: VX_ZONE_ERROR:[ownContextSendCmd:802] Command ack message returned failure cmd_status: -1
123.270450 s: VX_ZONE_ERROR:[ownContextSendCmd:838] tivxEventWait() failed.
123.270456 s: VX_ZONE_ERROR:[ownNodeKernelInit:525] Target kernel, TIVX_CMD_NODE_CREATE failed for node node_96
123.270463 s: VX_ZONE_ERROR:[ownNodeKernelInit:526] Please be sure the target callbacks have been registered for this core
123.270469 s: VX_ZONE_ERROR:[ownNodeKernelInit:527] If the target callbacks have been registered, please ensure no errors are occurring within the create callback of this kernel
123.270631 s: VX_ZONE_ERROR:[ownGraphNodeKernelInit:583] kernel init for node 0, kernel com.ti.capture ... failed !!!
123.270641 s: VX_ZONE_ERROR:[vxVerifyGraph:2055] Node kernel init failed
123.270647 s: VX_ZONE_ERROR:[vxVerifyGraph:2109] Graph verify failed
Scaler is disabled
app_create_graph exiting
app_create_graph done
123.271256 s: ISS: Starting sensor [ISX016-UB913] ... !!!


==========================
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] 123.269867 s: VX_ZONE_ERROR:[tivxCaptureCreate:1217] : Failed to set PHY Parameters!!!
[MCU2_0] 123.270108 s: VX_ZONE_ERROR:[tivxCaptureCreate:1217] : Failed to set PHY Parameters!!!
124.123419 s: ISS: Starting sensor [ISX016-UB913] ... !!!
get_dcc_dir_size : Could not open directory or directory is empty /opt/vision_apps/dcc/ISX016-UB913/wdr

Thanks,

Madhav

  • Dear Sir,

    Any updates on this thread.

    Thanks,

    Madhav

  • Hi Madhav,

    Couple of questions,

    - What's the lane speed that you are trying to set in the CSIRX?

    - Is it the new camera that you are trying to bringup?

    - Was this working fine in earlier release?

    Regards,

    Brijesh 

  • Dear Sir,

     Is it the new camera that you are trying to bringup?

    yes , sensor name is Sony ISX016

     Was this working fine in earlier release?

    yes it is working fine for SDK 7 version , now we trying to migrate changes to new SDK.

    What's the lane speed that you are trying to set in the CSIRX?

    As per the old SDK please find out the params initialised

    static IssSensor_CreateParams isx016CreatePrms = {
    SENSOR_SONY_ISX016, /*sensor name*/
    0x6, /*i2cInstId*/
    {SENSOR_0_I2C_ALIAS, SENSOR_1_I2C_ALIAS, SENSOR_2_I2C_ALIAS, SENSOR_3_I2C_ALIAS}, /*i2cAddrSensor*/
    {SER_0_I2C_ALIAS, SER_1_I2C_ALIAS, SER_2_I2C_ALIAS, SER_3_I2C_ALIAS}, /*i2cAddrSer*/
    /*IssSensor_Info*/
    {
    {
    ISX016_OUT_WIDTH, /*width*/
    ISX016_OUT_HEIGHT-ISX016_META_HEIGHT_AFTER, /*height*/
    1, /*num_exposures*/
    vx_false_e, /*line_interleaved*/
    {
    {TIVX_RAW_IMAGE_16_BIT, 7}, /*dataFormat and MSB [0]*/
    },
    0, /*meta_height_before*/
    ISX016_META_HEIGHT_AFTER, /*meta_height_after*/
    },
    ISS_SENSOR_ISX016_FEATURES, /*features*/
    ALGORITHMS_ISS_AEWB_MODE_NONE, /*aewbMode*/
    30, /*fps*/
    4, /*numDataLanes*/
    {1, 2, 3, 4}, /*dataLanesMap*/
    {0, 0, 0, 0}, /*dataLanesPolarity*/
    800, /*CSI Clock*/
    },
    4, /*numChan*/
    160, /*dccId-390*/
    };  

    after execution of single came application getting this log

    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 !!!
    110.177583 s: GTC Frequency = 200 MHz
    APP: Init ... Done !!!
    110.187022 s: VX_ZONE_INIT:Enabled
    110.187045 s: VX_ZONE_ERROR:Enabled
    110.187057 s: VX_ZONE_WARNING:Enabled
    110.187849 s: VX_ZONE_INIT:[tivxInitLocal:145] Initialization Done !!!
    110.189827 s: VX_ZONE_INIT:[tivxHostInitLocal:93] Initialization Done for HOST !!!

    Single Camera Demo - (c) Texas Instruments 2019
    ========================================================

    Usage,
    ./vx_app_single_cam.out --cfg <config file>

    Defaulting to interactive mode
    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
    110.205791 s: ISS: Enumerating sensors ... !!!
    [MCU2_0] 110.206016 s: ImageSensor_RemoteServiceHandler: IM_SENSOR_CMD_ENUMERATE
    [MCU2_0] 110.206357 s: write 0xfe to TCA6408 register 0x3
    [MCU2_0] 110.306213 s: UB960 config start
    112.866721 s: ISS: Enumerating sensors ... found 0 : IMX390-UB953_D3
    112.866745 s: ISS: Enumerating sensors ... found 1 : AR0233-UB953_MARS
    112.866766 s: ISS: Enumerating sensors ... found 2 : AR0820-UB953_LI
    112.866771 s: ISS: Enumerating sensors ... found 3 : UB9xxx_RAW12_TESTPATTERN
    112.866776 s: ISS: Enumerating sensors ... found 4 : ISX016-UB913
    112.866781 s: ISS: Enumerating sensors ... found 5 : UB96x_UYVY_TESTPATTERN
    112.866786 s: ISS: Enumerating sensors ... found 6 : GW_AR0233_UYVY
    Select camera port index 0-7 : [MCU2_0] 112.866480 s: End of UB960 config
    0
    7 registered sensor drivers
    a : IMX390-UB953_D3
    b : AR0233-UB953_MARS
    c : AR0820-UB953_LI
    d : UB9xxx_RAW12_TESTPATTERN
    e : ISX016-UB913
    f : UB96x_UYVY_TESTPATTERN
    g : GW_AR0233_UYVY
    Select a sensor above or press '0' to autodetect the sensor : Invalid selection
    . Try again
    7 registered sensor drivers
    a : IMX390-UB953_D3
    b : AR0233-UB953_MARS
    c : AR0820-UB953_LI
    d : UB9xxx_RAW12_TESTPATTERN
    e : ISX016-UB913
    f : UB96x_UYVY_TESTPATTERN
    g : GW_AR0233_UYVY
    Select a sensor above or press '0' to autodetect the sensor : e
    Sensor selected : ISX016-UB913
    LDC Selection Yes(1)/No(0) : LDC Selection Yes(1)/No(0) : 0
    app_init done
    Querying ISX016-UB913
    127.446236 s: ISS: Querying sensor [ISX016-UB913] ... !!!
    127.446716 s: ISS: Querying sensor [ISX016-UB913] ... Done !!!
    WDR mode is supported
    Expsoure control is supported
    Gain control is supported
    CMS Usecase is supported
    obj->aewb_cfg.ae_mode = 1
    obj->aewb_cfg.awb_mode = 2
    Sensor DCC is enabled
    Sensor width = 1280
    Sensor height = 724
    Sensor DCC ID = 160
    Sensor Supported Features = 0x378
    Sensor Enabled Features = 0x358
    127.446760 s: ISS: Initializing sensor [ISX016-UB913], doing IM_SENSOR_CMD_PWRON ... !!!
    127.447280 s: ISS: Initializing sensor [ISX016-UB913], doing IM_SENSOR_CMD_CONFIG ... !!!
    [MCU2_0] 127.446455 s: ImageSensor_RemoteServiceHandler: IM_SENSOR_CMD_QUERY
    [MCU2_0] 127.446529 s: Received Query for ISX016-UB913
    [MCU2_0] 127.446931 s: ImageSensor_RemoteServiceHandler: IM_SENSOR_CMD_PWRON
    [MCU2_0] 127.446983 s: IM_SENSOR_CMD_PWRON : channel_mask = 0x1
    [MCU2_0] 127.447049 s: ISX016_PowerOn : chId = 0x0
    [MCU2_0] 127.447458 s: ImageSensor_RemoteServiceHandler: IM_SENSOR_CMD_CONFIG
    [MCU2_0] 127.447515 s: Application requested features = 0x358
    [MCU2_0]
    [MCU2_0] 127.447563 s: UB960 config start
    [MCU2_0] 127.703302 s: End of UB960 config
    [MCU2_0] 127.703366 s: UB960 config start
    [MCU2_0] 127.959301 s: End of UB960 config
    [MCU2_0] 127.959366 s: Configuring camera # 0
    [MCU2_0] 127.959409 s: ub953 config start : slaveAddr = 0x74
    [MCU2_0] 128.151367 s: End of UB953 config
    [ 140.023435] Initializing XFRM netlink socket
    [ 143.268617] bridge: filtering via arp/ip/ip6tables is no longer available by default. Update your scripts to load br_netfilter if you need this.
    [ 143.287657] Bridge firewalling registered
    [ 144.486061] process 'docker/tmp/qemu-check066375676/check' started with executable stack
    170.876462 s: ISS: Initializing sensor [ISX016-UB913] ... Done !!!
    Creating graph
    Initializing params for capture node
    capture_config = 0x0xffff8e1cce08
    Creating capture node
    obj->capture_node = 0x0xffff8e13eb88
    [MCU2_0] 170.876209 s: IM_SENSOR_CMD_CONFIG returning status = 0
    read_test_image_raw : Unable to open file /opt/vision_apps/test_data/img_test.raw
    app_create_viss : sensor_dcc_id = 160
    Invalid DCC size for VISS. Disabling DCC
    Invalid DCC size for 2A. Disabling DCC
    AEWB Set Reference done
    Display Set Target done
    vxSetGraphScheduleConfig done
    170.898951 s: VX_ZONE_ERROR:[ownContextSendCmd:802] Command ack message returned failure cmd_status: -1
    170.898965 s: VX_ZONE_ERROR:[ownContextSendCmd:838] tivxEventWait() failed.
    170.898972 s: VX_ZONE_ERROR:[ownNodeKernelInit:525] Target kernel, TIVX_CMD_NODE_CREATE failed for node node_96
    170.898978 s: VX_ZONE_ERROR:[ownNodeKernelInit:526] Please be sure the target callbacks have been registered for this core
    170.898984 s: VX_ZONE_ERROR:[ownNodeKernelInit:527] If the target callbacks have been registered, please ensure no errors are occurring within the create callback of this kernel
    170.899141 s: VX_ZONE_ERROR:[ownGraphNodeKernelInit:583] kernel init for node 0, kernel com.ti.capture ... failed !!!
    170.899152 s: VX_ZONE_ERROR:[vxVerifyGraph:2055] Node kernel init failed
    170.899157 s: VX_ZONE_ERROR:[vxVerifyGraph:2109] Graph verify failed
    Scaler is disabled
    app_create_graph exiting
    app_create_graph done
    170.899473 s: ISS: Starting sensor [ISX016-UB913] ... !!!
    [MCU2_0] 170.898631 s: VX_ZONE_ERROR:[tivxCaptureSetCreateParams:706] CAPTURE: ERROR: Un-supported Capture Data-type!!!
    [MCU2_0] 170.899945 s: ImageSensor_RemoteServiceHandler: IM_SENSOR_CMD_STREAM_ON
    [MCU2_0] 170.900019 s: IM_SENSOR_CMD_STREAM_ON: channel_mask = 0x1
    [MCU2_0] 170.900064 s: UB960 config start
    [MCU2_0] 171.156305 s: End of UB960 config
    [MCU2_0] 171.156370 s: UB960 config start
    [MCU2_0] 171.412308 s: End of UB960 config +-----------------------------+
    [MCU2_0] 171.422366 s: UB960 config start | |
    [MCU2_0] 171.454298 s: End of UB960 config | Cannot open /dev/ttyUSB0! |
    [MCU2_0] 171.454353 s: UB960 config start | |
    [MCU2_0] 171.710307 s: End of UB960 config +-----------------------------+
    171.753771 s: ISS: Starting sensor [ISX016-UB913] ... !!!

    please let me know what changes needs to e done so that it supports YUV422 capturing , getting error in log that CAPTURE: ERROR: Un-supported Capture Data-type!!!

    Thanks,

    Madhav

  • Hi Madhav,

    We need to use correct lane speed in the below parameter.

    800, /*CSI Clock*/

    There are macros/enums available in the new SDK, using which we can set the lane speed from the sensor information. Please refer to these macros (TIVX_CAPTURE_LANE_BAND_SPEED_....... ) in ti-processor-sdk-rtos-j721e-evm-08_05_00_11\tiovx\kernels_j7\include\TI\j7_capture.h file.

    Regards,

    Brijesh

  • Dear Sir,

    As we have used the same lane speed for ISX016 camera for earlier release its works fine (reference lane speed mention in by default IMX390 camera  we have used the same in ISX016).

    please let me know how to calculate lane speed .

    Thanks,

    Madhav

  • Hi Sir,

    my serializer configuration settings 

    {0x01, 0x33, 0x80},
    {0x03, 0xC5, 0x10},
    {0x0D, 0x55, 0x10},
    {0x11, SERDES_I2C_SCL_HOLD_TIME, 0x10},
    {0x12, SERDES_I2C_SCL_HOLD_TIME, 0x10},
    {0xFFFF, 0x00, 0x0} //End of script

    and deserilizer configuration setting

    {0x01, 0x02, 0x10},
    {0x1f, 0x00, 0x10},

    {0xB0, 0x1C,0x10},
    {0xB1, 0x16,0x10},
    {0xB2, 0x00,0x10},
    {0xB1, 0x17,0x10},
    {0xB2, 0x00,0x10},
    {0xB1, 0x18,0x10},
    {0xB2, 0x00,0x10},
    {0xB1, 0x19,0x10},
    {0xB2, 0x00,0x10},
    {0xB0, 0x1C,0x10},
    {0xB1, 0x15,0x10},
    {0xB2, 0x0A,0x100},
    {0xB2, 0x00,0x100},

    {0x0D, 0x90, 0x10}, /*I/O to 3V3 - Options not valid with datashee*/
    {0x0C, 0x0F, 0x10}, /*Enable All ports*/

    /*Select Channel 0*/
    {0x4C, 0x01, 0x10},
    {0x58, 0x58, 0x10}, /*Enable Back channel, set to 50Mbs*/
    {0x72, 0x00, 0x10}, /*VC map*/

    /*Select Channel 1*/
    {0x4C, 0x12, 0x10},
    {0x58, 0x58, 0x10},/*Enable Back channel, set to 50Mbs*/

    /*Select Channel 2*/
    {0x4C, 0x24, 0x10},
    {0x58, 0x58, 0x10},/*Enable Back channel, set to 50Mbs*/

    /*Select Channel 3*/
    {0x4C, 0x38, 0x10},
    {0x58, 0x58, 0x10},/*Enable Back channel, set to 50Mbs*/

    /*Select Channel 0*/
    {0x4C, 0x01, 0x10},
    {0xB0, 0x04, 0x10},
    {0xB1, 0x03, 0x10},
    {0xB2, 0x20, 0x10},
    {0xB1, 0x13, 0x10},
    {0xB2, 0x20, 0x10},
    {0xB0, 0x04, 0x10},
    {0xB1, 0x04, 0x10},
    {0xB2, 0x3F, 0x10},
    {0xB1, 0x14, 0x10},
    {0xB2, 0x3F, 0x10},
    {0x42, 0x71, 0x10}, /*Unknown*/
    {0x41, 0xF0, 0x10}, /*Unknown*/
    {0xB9, 0x18, 0x10},

    /*Select Channel 1*/
    {0x4C, 0x12, 0x10},
    {0xB0, 0x08, 0x10},
    {0xB1, 0x03, 0x10},
    {0xB2, 0x20, 0x10},
    {0xB1, 0x13, 0x10},
    {0xB2, 0x20, 0x10},
    {0xB0, 0x08, 0x10},
    {0xB1, 0x04, 0x10},
    {0xB2, 0x3F, 0x10},
    {0xB1, 0x14, 0x10},
    {0xB2, 0x3F, 0x10},
    {0xB0, 0x08, 0x10},
    {0x42, 0x71, 0x10}, /*Unknown*/
    {0x41, 0xF0, 0x10}, /*Unknown*/
    {0xB9, 0x18, 0x10},

    /*Select Channel 2*/
    {0x4C, 0x24, 0x10},
    {0xB0, 0x0C, 0x10},
    {0xB1, 0x03, 0x10},
    {0xB2, 0x20, 0x10},
    {0xB1, 0x13, 0x10},
    {0xB2, 0x20, 0x10},
    {0xB0, 0x0C, 0x10},
    {0xB1, 0x04, 0x10},
    {0xB2, 0x3F, 0x10},
    {0xB1, 0x14, 0x10},
    {0xB2, 0x3F, 0x10},
    {0x42, 0x71, 0x10},/*Unknown*/
    {0x41, 0xF0, 0x10},/*Unknown*/
    {0xB9, 0x18, 0x10},

    /*Select Channel 3*/
    {0x4C, 0x38, 0x10},
    {0xB0, 0x10, 0x10},
    {0xB1, 0x03, 0x10},
    {0xB2, 0x20, 0x10},
    {0xB1, 0x13, 0x10},
    {0xB2, 0x20, 0x10},
    {0xB0, 0x10, 0x10},
    {0xB1, 0x04, 0x10},
    {0xB2, 0x3F, 0x10},
    {0xB1, 0x14, 0x10},
    {0xB2, 0x3F, 0x10},
    {0x42, 0x71, 0x10},/*Unknown*/
    {0x41, 0xF0, 0x10},/*Unknown*/
    {0xB9, 0x18, 0x10},

    {0x32, 0x01, 0x10}, /*Enable TX port 0*/
    {0x20, 0x00, 0x10}, /*Forwarding and using CSIport 0 */

    /*Sets GPIOS*/
    {0x10, 0x83, 0x10},
    {0x11, 0xA3, 0x10},
    {0x12, 0xC3, 0x10},
    {0x13, 0xE3, 0x10},

    {0x4C, 0x01, 0x10},
    {0x58, 0x58, 0x10}, /*Enable Back channel, set to 50Mbs */
    {0xD5, 0xF0, 0x10},
    {0x6D, 0x6F, 0x10},
    {0x70, 0x1E, 0x10},
    {0x7C, 0xC4, 0x10},
    {0x5D, (BSPUTILS_SER_ID_ADDR << 1U), 0x10}, /*Serializer I2C Address*/
    {0x65, (SER_0_I2C_ALIAS << 1U), 0x10},
    {0x5E, ISX016_I2C_ADDR, 0x10}, /*Sensor I2C Address*/
    {0x66, (SENSOR_0_I2C_ALIAS << 1U), 0x10},
    {0x32, 0x01, 0x0},

    {0x4C, 0x12, 0x10},
    {0x58, 0x58, 0x10}, /*Enable Back channel, set to 50Mbs */
    {0xD5, 0xF0, 0x10},
    {0x6D, 0x6F, 0x10},
    {0x70, 0x5E, 0x10},
    {0x7C, 0xC4, 0x10},
    {0x5D, (BSPUTILS_SER_ID_ADDR << 1U), 0x10}, /*Serializer I2C Address*/
    {0x65, (SER_1_I2C_ALIAS << 1U), 0x10},
    {0x5E, ISX016_I2C_ADDR, 0x10}, /*Sensor I2C Address*/
    {0x66, (SENSOR_1_I2C_ALIAS << 1U), 0x10},
    {0x32, 0x01, 0x0},

    {0x4C, 0x24, 0x10},
    {0x58, 0x58, 0x10}, /*Enable Back channel, set to 50Mbs */
    {0xD5, 0xF0, 0x10},
    {0x6D, 0x6F, 0x10},
    {0x70, 0x9E, 0x10},
    {0x7C, 0xC4, 0x10},
    {0x5D, (BSPUTILS_SER_ID_ADDR << 1U), 0x10}, /*Serializer I2C Address*/
    {0x65, (SER_2_I2C_ALIAS << 1U), 0x10},
    {0x5E, ISX016_I2C_ADDR, 0x10}, /*Sensor I2C Address*/
    {0x66, (SENSOR_2_I2C_ALIAS << 1U), 0x10},
    {0x32, 0x01, 0x0},

    {0x4C, 0x38, 0x10},
    {0x58, 0x58, 0x10}, /*Enable Back channel, set to 50Mbs */
    {0xD5, 0xF0, 0x10},
    {0x6D, 0x6F, 0x10},
    {0x70, 0xDE, 0x10},
    {0x7C, 0xC4, 0x10},
    {0x5D, (BSPUTILS_SER_ID_ADDR << 1U), 0x10}, /*Serializer I2C Address*/
    {0x65, (SER_3_I2C_ALIAS << 1U), 0x10},
    {0x5E, ISX016_I2C_ADDR, 0x10}, /*Sensor I2C Address*/
    {0x66, (SENSOR_3_I2C_ALIAS << 1U), 0x10},
    {0x32, 0x01, 0x0},

    {0x20, 0x00, 0x10}, /*Forwarding and using CSIport 0*/
    {0x33, 0x01, 0x0},
    {0x21, 0x03, 0x0},
    {0xFFFF, 0x00, 0x0} //End of script*/

    Thanks,

    Madhav

  • Madhav,

    But in earlier release, this variable was not used, now it is being used in the single camera and multi- camera applications. So please set it accordingly.

    Also in the below settings, i see you are setting register 0x33 with value 0x1, can you please set this value only in the streamon callback? 

    Regards,

    Brijesh

  • Dear Sir,

    how to calculate lane speed for ISX016 sensor please let me know 

    Thanks,

    Madhav

  • Width x height x fps x 16 (for yuv422) x number of channels / number of lanes

    This is the minimum required lane speed for this resolution. You could add 20% more to above lane speed to account for protocol overhead and other overheads.

    Regards,

    Brijesh

  • Dear Sir,

    width=1280, height=724, fps=30 numChannels=4 and numdatalanes=4

    1280*724*30*16*4/4=444825600

    i am selecting this flag TIVX_CAPTURE_LANE_BAND_SPEED_400_TO_480_MBPS

    is it right ?

    Thanks,

    Madhav

  • Well, it is right from minimum lane speed requirement, but please check what lane speed is configured in the TX and set it accordingly in the CSIRX.

    Regards,

    Brijesh

  • Dear Sir,

    i can able to get display of single camera output. but i got the green display 

      

    is there any solution for this or need to write our own kernel to convert.

    Thank,

    Madhav

  • Hi Madhav,

    This looks to be issue with interleaving format of YUV422 data, like application is expecting UYVY and output is in YUYV format.. 

    Are you using LDC in the application for the format conversion from YUV422 to YUV420? This is because LDC supports only UYVY format. 

    Also if you are bypassing LDC and directly connecting capture output to display, then display supports both the formats.. We might just have to set correct format in the display..

    Regards,

    Brijesh

  • Dear Sir,

    we are bypassing LDC and ony capture and display node availabe.

    Thanks,

    Madhav

  • In this case, it is coming due to format mismatch. Like capture is outputting in UYVY format, but display is configured for YUYV format. Please try changing format in the display node.

  • Dear Sir,

    can you please say where exactly need to change the format in display node.

    i am attaching app_single_cam_main.c and vx_display_target.c

    /*
     *
     * Copyright (c) 2017 Texas Instruments Incorporated
     *
     * All rights reserved not granted herein.
     *
     * Limited License.
     *
     * Texas Instruments Incorporated grants a world-wide, royalty-free, non-exclusive
     * license under copyrights and patents it now or hereafter owns or controls to make,
     * have made, use, import, offer to sell and sell ("Utilize") this software subject to the
     * terms herein.  With respect to the foregoing patent license, such license is granted
     * solely to the extent that any such patent is necessary to Utilize the software alone.
     * The patent license shall not apply to any combinations which include this software,
     * other than combinations with devices manufactured by or for TI ("TI Devices").
     * No hardware patent is licensed hereunder.
     *
     * Redistributions must preserve existing copyright notices and reproduce this license
     * (including the above copyright notice and the disclaimer and (if applicable) source
     * code license limitations below) in the documentation and/or other materials provided
     * with the distribution
     *
     * Redistribution and use in binary form, without modification, are permitted provided
     * that the following conditions are met:
     *
     * *       No reverse engineering, decompilation, or disassembly of this software is
     * permitted with respect to any software provided in binary form.
     *
     * *       any redistribution and use are licensed by TI for use only with TI Devices.
     *
     * *       Nothing shall obligate TI to provide you with source code for the software
     * licensed and provided to you in object code.
     *
     * If software source code is provided to you, modification and redistribution of the
     * source code are permitted provided that the following conditions are met:
     *
     * *       any redistribution and use of the source code, including any resulting derivative
     * works, are licensed by TI for use only with TI Devices.
     *
     * *       any redistribution and use of any object code compiled from the source code
     * and any resulting derivative works, are licensed by TI for use only with TI Devices.
     *
     * Neither the name of Texas Instruments Incorporated nor the names of its suppliers
     *
     * may be used to endorse or promote products derived from this software without
     * specific prior written permission.
     *
     * DISCLAIMER.
     *
     * THIS SOFTWARE IS PROVIDED BY TI AND TI'S LICENSORS "AS IS" AND ANY EXPRESS
     * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     * IN NO EVENT SHALL TI AND TI'S LICENSORS BE LIABLE FOR ANY DIRECT, INDIRECT,
     * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
     * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
     * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
     * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
     * OF THE POSSIBILITY OF SUCH DAMAGE.
     *
     */
    
    #include "TI/tivx.h"
    #include "VX/vx.h"
    #include "TI/tivx_event.h"
    #include "tivx_hwa_kernels.h"
    #include "tivx_kernel_display.h"
    #include "TI/tivx_target_kernel.h"
    #include "tivx_kernels_target_utils.h"
    #include "tivx_hwa_display_priv.h"
    #include <TI/tivx_queue.h>
    #include <ti/drv/dss/dss.h>
    
    #define DISPLAY_MAX_VALID_PLANES                      2U
    #define DISPLAY_MAX_COPY_BUFFERS                      2U
    
    typedef struct
    {
        Fvid2_PosConfig     posCfg;
        Dss_FrameRtParams   inFrmPrms;
        Dss_FrameRtParams   outFrmPrms;
        Dss_ScRtParams      scPrms;
        Dss_DispRtParams    rtPrms;
        tivx_obj_desc_t     *obj_desc;
    } tivxDisplayRtParams;
    
    typedef struct
    {
        uint32_t opMode;
        /**< Operation Mode of display kernel. Refer \ref Display_opMode for values */
        Fvid2_Frame copyFrame[DISPLAY_MAX_COPY_BUFFERS];
        /**< Copy frames for TIVX_KERNEL_DISPLAY_BUFFER_COPY_MODE */
        void *copyImagePtr[DISPLAY_MAX_COPY_BUFFERS][DISPLAY_MAX_VALID_PLANES];
        /**< Buffer addresses for copied frame */
        uint32_t copyImageSize[DISPLAY_MAX_VALID_PLANES];
        /**< Buffer addresses for copied frame */
        uint32_t currIdx;
        /**< Buffer addresses for copied frame */
        uint32_t firstFrameDisplay;
        /**< Option to tell whether display is processing first frame */
        SemaphoreP_Handle waitSem;
        /**< Semaphore for ISR */
        Dss_DispCreateParams createParams;
        /**< Create time parameters */
        Dss_DispCreateStatus createStatus;
        /**< Create status returned by driver during Fvid2_create() */
        Dss_DispParams dispParams;
        /**< DSS display parameters */
        Fvid2_Handle drvHandle;
        /**< FVID2 display driver handle */
        Fvid2_CbParams cbParams;
        /**< Callback parameters */
        tivx_queue fvid2FrameQ;
        /**< Internal FVID2 queue */
        uintptr_t fvid2FrameQMem[TIVX_DISPLAY_MAX_NUM_BUFS];
        /**< Queue memory */
        Fvid2_Frame fvid2Frames[TIVX_DISPLAY_MAX_NUM_BUFS];
        /**< FVID2 Frames that will be used for display */
        tivxDisplayRtParams dispRtPrms[TIVX_DISPLAY_MAX_NUM_BUFS];
    
        uint64_t chromaBufAddr;
        /**< Chroma Buffer Address, used when input frame format is U16 */
        uint32_t chromaBufSize;
        /**< Size of the chroma buffer */
        tivx_shared_mem_ptr_t chroma_mem_ptr;
    
        /**< Id of active channel */
        uint32_t active_channel;
    
        uint32_t offset0;
        uint32_t offset1;
        tivx_display_crop_params_t cropPrms;
        uint32_t bpp;
    
        uint32_t isRtPrmsUpdated;
    } tivxDisplayParams;
    
    static tivx_target_kernel vx_display_target_kernel1 = NULL;
    static tivx_target_kernel vx_display_target_kernel2 = NULL;
    
    static vx_status VX_CALLBACK tivxDisplayCreate(
           tivx_target_kernel_instance kernel,
           tivx_obj_desc_t *obj_desc[],
           uint16_t num_params, void *priv_arg);
    static vx_status VX_CALLBACK tivxDisplayDelete(
           tivx_target_kernel_instance kernel,
           tivx_obj_desc_t *obj_desc[],
           uint16_t num_params, void *priv_arg);
    static vx_status VX_CALLBACK tivxDisplayProcess(
           tivx_target_kernel_instance kernel,
           tivx_obj_desc_t *obj_desc[],
           uint16_t num_params, void *priv_arg);
    static vx_status tivxDisplayExtractFvid2Format(
        tivxDisplayParams *dispPrms, tivx_display_params_t *inDispPrms,
        const tivx_obj_desc_image_t *obj_desc_img, Fvid2_Format *format);
    static int32_t tivxDisplayCallback(Fvid2_Handle handle, void *appData);
    static uint32_t tivxDisplayGetPipeType(uint32_t drvId);
    static int32_t tivxDisplayGetImageSize(const tivx_obj_desc_image_t *obj_desc_image,
                                           uint32_t *copySize0,
                                           uint32_t *copySize1);
    static vx_status tivxDisplayAllocChromaBuff(tivxDisplayParams *dispPrms,
                                                const Fvid2_Format *fmt,
                                                const tivx_obj_desc_image_t *obj_desc_img);
    static void tivxDisplayCalcOffset(tivxDisplayParams *dispPrms);
    
    static vx_status VX_CALLBACK tivxDisplayControl(
           tivx_target_kernel_instance kernel,
           uint32_t node_cmd_id, tivx_obj_desc_t *obj_desc[],
           uint16_t num_params, void *priv_arg);
    static void tivxDisplayFreeChromaBuff(tivxDisplayParams *dispPrms);
    static vx_status tivxDisplaySwitchChannel(tivxDisplayParams *dispPrms,
        const tivx_obj_desc_user_data_object_t *usr_data_obj);
    static vx_status tivxDisplaySetCropParams(tivxDisplayParams *dispPrms,
        const tivx_obj_desc_user_data_object_t *usr_data_obj);
    
    static vx_status tivxDisplaySwitchChannel(tivxDisplayParams *dispPrms,
        const tivx_obj_desc_user_data_object_t *usr_data_obj)
    {
        vx_status                             status = (vx_status)VX_SUCCESS;
        tivx_display_select_channel_params_t *ch_prms = NULL;
        void                                 *target_ptr;
    
        if (NULL != usr_data_obj)
        {
            target_ptr = tivxMemShared2TargetPtr(&usr_data_obj->mem_ptr);
    
            tivxCheckStatus(&status, tivxMemBufferMap(target_ptr, usr_data_obj->mem_size,
                (vx_enum)VX_MEMORY_TYPE_HOST, (vx_enum)VX_READ_ONLY));
    
            if (sizeof(tivx_display_select_channel_params_t) ==
                    usr_data_obj->mem_size)
            {
                ch_prms = (tivx_display_select_channel_params_t *)target_ptr;
                dispPrms->active_channel = ch_prms->active_channel_id;
            }
            else
            {
                VX_PRINT(VX_ZONE_ERROR, "Invalid Size \n");
                status = (vx_status)VX_ERROR_INVALID_PARAMETERS;
            }
    
            tivxCheckStatus(&status, tivxMemBufferUnmap(target_ptr, usr_data_obj->mem_size,
                (vx_enum)VX_MEMORY_TYPE_HOST, (vx_enum)VX_READ_ONLY));
        }
        else
        {
            VX_PRINT(VX_ZONE_ERROR, "User Data Object is NULL \n");
            status = (vx_status)VX_ERROR_INVALID_PARAMETERS;
        }
    
        return (status);
    }
    
    static vx_status tivxDisplaySetCropParams(tivxDisplayParams *dispPrms,
        const tivx_obj_desc_user_data_object_t *usr_data_obj)
    {
        vx_status                   status = (vx_status)VX_SUCCESS;
        tivx_display_crop_params_t *ch_prms = NULL;
        void                       *target_ptr;
    
        if (NULL != usr_data_obj)
        {
            target_ptr = tivxMemShared2TargetPtr(&usr_data_obj->mem_ptr);
    
            tivxCheckStatus(&status, tivxMemBufferMap(target_ptr, usr_data_obj->mem_size,
                (vx_enum)VX_MEMORY_TYPE_HOST, (vx_enum)VX_READ_ONLY));
    
            if (sizeof(tivx_display_crop_params_t) ==
                    usr_data_obj->mem_size)
            {
                ch_prms = (tivx_display_crop_params_t *)target_ptr;
                memcpy(&dispPrms->cropPrms, ch_prms, sizeof(tivx_display_crop_params_t));
                dispPrms->isRtPrmsUpdated = 1;
            }
            else
            {
                VX_PRINT(VX_ZONE_ERROR, "Invalid Size \n");
                status = (vx_status)VX_ERROR_INVALID_PARAMETERS;
            }
    
            tivxCheckStatus(&status, tivxMemBufferUnmap(target_ptr, usr_data_obj->mem_size,
                (vx_enum)VX_MEMORY_TYPE_HOST, (vx_enum)VX_READ_ONLY));
        }
        else
        {
            VX_PRINT(VX_ZONE_ERROR, "User Data Object is NULL \n");
            status = (vx_status)VX_ERROR_INVALID_PARAMETERS;
        }
    
        return (status);
    }
    
    static vx_status tivxDisplayExtractFvid2Format(
        tivxDisplayParams *dispPrms, tivx_display_params_t *inDispPrms,
        const tivx_obj_desc_image_t *obj_desc_img, Fvid2_Format *format)
    {
        vx_status status = (vx_status)VX_SUCCESS;
    
        Fvid2Format_init(format);
    
        if (inDispPrms->enableCropping)
        {
            format->width = inDispPrms->cropPrms.width;
            format->height = inDispPrms->cropPrms.height;
    
            memcpy(&dispPrms->cropPrms,
                &inDispPrms->cropPrms, sizeof(dispPrms->cropPrms));
        }
        else
        {
            format->width = obj_desc_img->imagepatch_addr[0].dim_x;
            format->height = obj_desc_img->imagepatch_addr[0].dim_y;
        }
        format->ccsFormat = FVID2_CCSF_BITS8_PACKED;
        format->scanFormat = FVID2_SF_PROGRESSIVE;
    
        switch (obj_desc_img->format)
        {
            case (vx_df_image)TIVX_DF_IMAGE_RGB565:
                format->dataFormat = FVID2_DF_BGR16_565;
                format->pitch[FVID2_RGB_ADDR_IDX] = (uint32_t)obj_desc_img->imagepatch_addr[0].stride_y;
                dispPrms->bpp = 2;
                break;
            case (vx_df_image)VX_DF_IMAGE_RGB:
                format->dataFormat = FVID2_DF_RGB24_888;
                format->pitch[FVID2_RGB_ADDR_IDX] = (uint32_t)obj_desc_img->imagepatch_addr[0].stride_y;
                dispPrms->bpp = 3;
                break;
            case (vx_df_image)VX_DF_IMAGE_RGBX:
                format->dataFormat = FVID2_DF_RGBX24_8888;
                format->pitch[FVID2_RGB_ADDR_IDX] = (uint32_t)obj_desc_img->imagepatch_addr[0].stride_y;
                dispPrms->bpp = 4;
                break;
            case (vx_df_image)TIVX_DF_IMAGE_BGRX:
                format->dataFormat = FVID2_DF_BGRX32_8888;
                format->pitch[FVID2_RGB_ADDR_IDX] = (uint32_t)obj_desc_img->imagepatch_addr[0].stride_y;
                dispPrms->bpp = 4;
                break;
            case (vx_df_image)VX_DF_IMAGE_UYVY:
                format->dataFormat = FVID2_DF_YUV422I_UYVY;
                format->pitch[FVID2_YUV_INT_ADDR_IDX] = (uint32_t)obj_desc_img->imagepatch_addr[0].stride_y;
                dispPrms->bpp = 2;
                break;
            case (vx_df_image)VX_DF_IMAGE_YUYV:
                format->dataFormat = FVID2_DF_YUV422I_YUYV;
                format->pitch[FVID2_YUV_INT_ADDR_IDX] = (uint32_t)obj_desc_img->imagepatch_addr[0].stride_y;
                dispPrms->bpp = 2;
                break;
            case (vx_df_image)VX_DF_IMAGE_NV12:
                format->dataFormat = FVID2_DF_YUV420SP_UV;
                format->pitch[FVID2_YUV_SP_Y_ADDR_IDX] = (uint32_t)obj_desc_img->imagepatch_addr[0].stride_y;
                format->pitch[FVID2_YUV_SP_CBCR_ADDR_IDX] = (uint32_t)obj_desc_img->imagepatch_addr[1].stride_y;
                dispPrms->bpp = 1;
                break;
            case (vx_df_image)VX_DF_IMAGE_U16:
                format->ccsFormat = FVID2_CCSF_BITS12_UNPACKED16;
                format->dataFormat = FVID2_DF_YUV420SP_UV;
                format->pitch[FVID2_YUV_SP_Y_ADDR_IDX] = (uint32_t)obj_desc_img->imagepatch_addr[0].stride_y;
                format->pitch[FVID2_YUV_SP_CBCR_ADDR_IDX] = (uint32_t)obj_desc_img->imagepatch_addr[0].stride_y;
                dispPrms->bpp = 2;
                break;
            case (vx_df_image)VX_DF_IMAGE_U8:
                format->ccsFormat = FVID2_CCSF_BITS8_PACKED;
                format->dataFormat = FVID2_DF_YUV420SP_UV;
                format->pitch[FVID2_YUV_SP_Y_ADDR_IDX] = (uint32_t)obj_desc_img->imagepatch_addr[0].stride_y;
                format->pitch[FVID2_YUV_SP_CBCR_ADDR_IDX] = (uint32_t)obj_desc_img->imagepatch_addr[0].stride_y;
                dispPrms->bpp = 1;
                break;
            default:
                status = (vx_status)VX_FAILURE;
                break;
        }
    
        return status;
    }
    
    static vx_status tivxDisplayAllocChromaBuff(tivxDisplayParams *dispPrms,
                                                const Fvid2_Format *fmt,
                                                const tivx_obj_desc_image_t *obj_desc_img)
    {
        int32_t status = (vx_status)VX_SUCCESS;
        uint32_t cnt;
        void *chroma_target_ptr;
        uint16_t *chroma_ptr16;
        uint8_t *chroma_ptr8;
    
        if (((vx_df_image)VX_DF_IMAGE_U16 == obj_desc_img->format)||((vx_df_image)VX_DF_IMAGE_U8 == obj_desc_img->format))
        {
            dispPrms->chromaBufSize =
                (fmt->pitch[1] * fmt->height) / 2u;
            status = tivxMemBufferAlloc(&dispPrms->chroma_mem_ptr,
                dispPrms->chromaBufSize, (vx_enum)TIVX_MEM_EXTERNAL);
            if ((vx_status)VX_SUCCESS == status)
            {
                dispPrms->chromaBufAddr =
                    tivxMemShared2PhysPtr(dispPrms->chroma_mem_ptr.shared_ptr,
                    (int32_t)dispPrms->chroma_mem_ptr.mem_heap_region);
    
                chroma_target_ptr = tivxMemShared2TargetPtr(&dispPrms->chroma_mem_ptr);
    
                tivxCheckStatus(&status, tivxMemBufferMap(chroma_target_ptr, dispPrms->chromaBufSize,
                                 (vx_enum)VX_MEMORY_TYPE_HOST, (vx_enum)VX_READ_AND_WRITE));
    
                if ((vx_df_image)VX_DF_IMAGE_U16 == obj_desc_img->format)
                {
                    chroma_ptr16 = (uint16_t *)chroma_target_ptr;
                    for (cnt = 0; cnt < (dispPrms->chromaBufSize / 2U); cnt ++)
                    {
                           *chroma_ptr16 = 0x800u;
                           chroma_ptr16 ++;
                    }
                }
                else if ((vx_df_image)VX_DF_IMAGE_U8 == obj_desc_img->format)
                {
                    chroma_ptr8 = (uint8_t *)chroma_target_ptr;
                    for (cnt = 0; cnt < dispPrms->chromaBufSize  ; cnt ++)
                    {
                           *chroma_ptr8 = 0x80u;
                           chroma_ptr8 ++;
                    }
                }
                else
                {
                    /* do nothing */
                }
    
                tivxCheckStatus(&status, tivxMemBufferUnmap(chroma_target_ptr, dispPrms->chromaBufSize,
                                 (vx_enum)VX_MEMORY_TYPE_HOST, (vx_enum)VX_READ_AND_WRITE));
            }
        }
        else
        {
            dispPrms->chromaBufAddr = (uint64_t)NULL;
            dispPrms->chromaBufSize = 0x0;
        }
    
        return (status);
    }
    
    static void tivxDisplayFreeChromaBuff(tivxDisplayParams *dispPrms)
    {
        if (dispPrms->chromaBufSize > 0u)
        {
            tivxMemBufferFree(&dispPrms->chroma_mem_ptr, dispPrms->chromaBufSize);
        }
    }
    
    static int32_t tivxDisplayCallback(Fvid2_Handle handle, void *appData)
    {
        tivxDisplayParams *displayParams = (tivxDisplayParams *)(appData);
        SemaphoreP_post(displayParams->waitSem);
        return (vx_status)VX_SUCCESS;
    }
    
    static uint32_t tivxDisplayGetPipeType(uint32_t drvId)
    {
        uint32_t pipeType = CSL_DSS_VID_PIPE_TYPE_VID;
        if((DSS_DISP_INST_VIDL1 == drvId) || (DSS_DISP_INST_VIDL2 == drvId))
        {
            pipeType = CSL_DSS_VID_PIPE_TYPE_VIDL;
        }
        return pipeType;
    }
    
    static int32_t tivxDisplayGetImageSize(const tivx_obj_desc_image_t *obj_desc_image,
                                           uint32_t *copySize0,
                                           uint32_t *copySize1)
    {
        vx_status status = (vx_status)VX_SUCCESS;
        switch (obj_desc_image->format)
        {
            case (vx_df_image)VX_DF_IMAGE_RGB:
                *copySize0 = (uint32_t)obj_desc_image->imagepatch_addr[0].stride_y * obj_desc_image->height;
                break;
            case (vx_df_image)TIVX_DF_IMAGE_BGRX:
                *copySize0 = (uint32_t)obj_desc_image->imagepatch_addr[0].stride_y * obj_desc_image->height;
                break;
            case (vx_df_image)VX_DF_IMAGE_RGBX:
                *copySize0 = (uint32_t)obj_desc_image->imagepatch_addr[0].stride_y * obj_desc_image->height;
                break;
            case (vx_df_image)VX_DF_IMAGE_YUYV:
            case (vx_df_image)VX_DF_IMAGE_UYVY:
                *copySize0 = (uint32_t)obj_desc_image->imagepatch_addr[0].stride_y * obj_desc_image->height;
                break;
            case (vx_df_image)VX_DF_IMAGE_NV12:
                *copySize0 = (uint32_t)obj_desc_image->imagepatch_addr[0].stride_y * obj_desc_image->height;
                *copySize1 = (uint32_t)obj_desc_image->imagepatch_addr[1].stride_y * obj_desc_image->height;
                break;
            default:
                *copySize0 = 0;
                *copySize1 = 0;
                status = (vx_status)VX_ERROR_INVALID_PARAMETERS;
                break;
        }
        return status;
    }
    
    static vx_status VX_CALLBACK tivxDisplayCreate(
           tivx_target_kernel_instance kernel,
           tivx_obj_desc_t *obj_desc[],
           uint16_t num_params, void *priv_arg)
    {
        vx_status status = (vx_status)VX_SUCCESS;
        int32_t fvid2_status = FVID2_SOK;
        tivx_obj_desc_user_data_object_t *obj_desc_configuration;
        tivx_obj_desc_image_t *obj_desc_image;
        tivxDisplayParams *displayParams = NULL;
        tivx_display_params_t *params;
        void *display_config_target_ptr;
        uint32_t drvId;
        SemaphoreP_Params semParams;
    
        if((num_params != TIVX_KERNEL_DISPLAY_MAX_PARAMS) ||
           (NULL == obj_desc[TIVX_KERNEL_DISPLAY_CONFIGURATION_IDX]) ||
           (NULL == obj_desc[TIVX_KERNEL_DISPLAY_INPUT_IMAGE_IDX]))
        {
            status = (vx_status)VX_FAILURE;
        }
        else
        {
            obj_desc_configuration = (tivx_obj_desc_user_data_object_t *)obj_desc[TIVX_KERNEL_DISPLAY_CONFIGURATION_IDX];
            obj_desc_image = (tivx_obj_desc_image_t *)obj_desc[TIVX_KERNEL_DISPLAY_INPUT_IMAGE_IDX];
    
            displayParams = tivxMemAlloc(sizeof(tivxDisplayParams), (vx_enum)TIVX_MEM_EXTERNAL);
            if(NULL != displayParams)
            {
                memset(displayParams, 0, sizeof(tivxDisplayParams));
            }
            else
            {
                VX_PRINT(VX_ZONE_ERROR, "DISPLAY: ERROR: Couldn't allocate memory!\r\n");
                status = (vx_status)VX_ERROR_NO_MEMORY;
            }
    
            if(sizeof(tivx_display_params_t) != obj_desc_configuration->mem_size)
            {
                VX_PRINT(VX_ZONE_ERROR, "DISPLAY: ERROR: Display params size is not correct!\r\n");
                status = (vx_status)VX_ERROR_INVALID_PARAMETERS;
            }
            if((vx_status)VX_SUCCESS == status)
            {
                display_config_target_ptr = tivxMemShared2TargetPtr(&obj_desc_configuration->mem_ptr);
    
                tivxCheckStatus(&status, tivxMemBufferMap(display_config_target_ptr,
                                 obj_desc_configuration->mem_size,
                                 (vx_enum)VX_MEMORY_TYPE_HOST,
                                 (vx_enum)VX_READ_ONLY));
    
                params = (tivx_display_params_t *)display_config_target_ptr;
    
                drvId = params->pipeId;
                if(drvId >= DSS_DISP_INST_MAX)
                {
                    status = (vx_status)VX_ERROR_INVALID_PARAMETERS;
                    VX_PRINT(VX_ZONE_ERROR, "DISPLAY: ERROR: Invalid pipe id used by display!\r\n");
                }
            }
            if((vx_status)VX_SUCCESS == status)
            {
                Dss_dispCreateParamsInit(&displayParams->createParams);
                Fvid2CbParams_init(&displayParams->cbParams);
                displayParams->opMode = params->opMode;
                displayParams->firstFrameDisplay = TRUE;
                displayParams->cbParams.cbFxn = (Fvid2_CbFxn) (&tivxDisplayCallback);
                displayParams->cbParams.appData = displayParams;
                SemaphoreP_Params_init(&semParams);
                semParams.mode = SemaphoreP_Mode_BINARY;
                displayParams->waitSem = SemaphoreP_create(0U, &semParams);
                if(NULL == displayParams->waitSem)
                {
                    status = (vx_status)VX_FAILURE;
                    VX_PRINT(VX_ZONE_ERROR, "DISPLAY: ERROR: Semaphore Create Failed!\r\n");
                }
                else
                {
                    displayParams->drvHandle = Fvid2_create(DSS_DISP_DRV_ID,
                                                            drvId,
                                                            &displayParams->createParams,
                                                            &displayParams->createStatus,
                                                            &displayParams->cbParams);
                    if((NULL == displayParams->drvHandle) ||
                       (FVID2_SOK != displayParams->createStatus.retVal))
                    {
                        status = (vx_status)VX_FAILURE;
                        VX_PRINT(VX_ZONE_ERROR, "DISPLAY: ERROR: Display Create Failed!\r\n");
                    }
                }
            }
            if((vx_status)VX_SUCCESS == status)
            {
                Dss_dispParamsInit(&displayParams->dispParams);
                displayParams->dispParams.pipeCfg.pipeType = tivxDisplayGetPipeType(drvId);
                displayParams->dispParams.pipeCfg.outWidth = params->outWidth;
                displayParams->dispParams.pipeCfg.outHeight = params->outHeight;
                displayParams->dispParams.layerPos.startX = params->posX;
                displayParams->dispParams.layerPos.startY = params->posY;
                status = tivxDisplayExtractFvid2Format(displayParams,
                    params, obj_desc_image,
                    &displayParams->dispParams.pipeCfg.inFmt);
                if((displayParams->dispParams.pipeCfg.inFmt.width != displayParams->dispParams.pipeCfg.outWidth) ||
                   (displayParams->dispParams.pipeCfg.inFmt.height != displayParams->dispParams.pipeCfg.outHeight))
                {
                    displayParams->dispParams.pipeCfg.scEnable = TRUE;
                }
    
                tivxDisplayCalcOffset(displayParams);
            }
    
            if ((vx_status)VX_SUCCESS == status)
            {
                status = tivxDisplayAllocChromaBuff(displayParams,
                    &displayParams->dispParams.pipeCfg.inFmt,
                    obj_desc_image);
            }
    
            if ((vx_status)VX_SUCCESS == status)
            {
                if(TIVX_KERNEL_DISPLAY_BUFFER_COPY_MODE == params->opMode)
                {
                    status = tivxDisplayGetImageSize(obj_desc_image,
                                                     &displayParams->copyImageSize[0],
                                                     &displayParams->copyImageSize[1]);
    
                    if((vx_status)VX_SUCCESS == status)
                    {
                        if(displayParams->copyImageSize[0] != 0U)
                        {
                            displayParams->copyImagePtr[0][0] = tivxMemAlloc(displayParams->copyImageSize[0], (vx_enum)TIVX_MEM_EXTERNAL);
                            if(displayParams->copyImagePtr[0][0] == NULL)
                            {
                                status = (vx_status)VX_ERROR_NO_MEMORY;
                                VX_PRINT(VX_ZONE_ERROR, "DISPLAY: ERROR: Couldn't allocate memory for copy buffer!\r\n");
                            }
                            displayParams->copyImagePtr[1][0] = tivxMemAlloc(displayParams->copyImageSize[0], (vx_enum)TIVX_MEM_EXTERNAL);
                            if(displayParams->copyImagePtr[1][0] == NULL)
                            {
                                status = (vx_status)VX_ERROR_NO_MEMORY;
                                VX_PRINT(VX_ZONE_ERROR, "DISPLAY: ERROR: Couldn't allocate memory for copy buffer!\r\n");
                            }
                        }
                        if((displayParams->copyImageSize[1] != 0U) && ((vx_df_image)VX_DF_IMAGE_NV12 == obj_desc_image->format))
                        {
                            displayParams->copyImagePtr[0][1] = tivxMemAlloc(displayParams->copyImageSize[1], (vx_enum)TIVX_MEM_EXTERNAL);
                            if(displayParams->copyImagePtr[0][1] == NULL)
                            {
                                status = (vx_status)VX_ERROR_NO_MEMORY;
                                VX_PRINT(VX_ZONE_ERROR, "DISPLAY: ERROR: Couldn't allocate memory for copy buffer!\r\n");
                            }
                            displayParams->copyImagePtr[1][1] = tivxMemAlloc(displayParams->copyImageSize[1], (vx_enum)TIVX_MEM_EXTERNAL);
                            if(displayParams->copyImagePtr[1][1] == NULL)
                            {
                                status = (vx_status)VX_ERROR_NO_MEMORY;
                                VX_PRINT(VX_ZONE_ERROR, "DISPLAY: ERROR: Couldn't allocate memory for copy buffer!\r\n");
                            }
                        }
                    }
                    displayParams->currIdx = 0;
                }
            }
            if((vx_status)VX_SUCCESS == status)
            {
                fvid2_status = Fvid2_control(displayParams->drvHandle,
                                       IOCTL_DSS_DISP_SET_DSS_PARAMS,
                                       &displayParams->dispParams,
                                       NULL);
                if(FVID2_SOK != fvid2_status)
                {
                    status = (vx_status)VX_FAILURE;
                    VX_PRINT(VX_ZONE_ERROR, "DISPLAY: ERROR: Display Set Parameters Failed!\r\n");
                }
            }
            /* Creating FVID2 frame Q */
            if(((vx_status)VX_SUCCESS == status) && (TIVX_KERNEL_DISPLAY_ZERO_BUFFER_COPY_MODE == displayParams->opMode))
            {
                uint32_t bufId;
                status = tivxQueueCreate(&displayParams->fvid2FrameQ, TIVX_DISPLAY_MAX_NUM_BUFS, displayParams->fvid2FrameQMem, 0);
                if((vx_status)VX_SUCCESS != status)
                {
                    VX_PRINT(VX_ZONE_ERROR, "DISPLAY: ERROR: Fvid2 queue create failed!\r\n");
                }
    
                for(bufId = 0; bufId <TIVX_DISPLAY_MAX_NUM_BUFS; bufId++)
                {
                    displayParams->fvid2Frames[bufId].appData =
                        &displayParams->dispRtPrms[bufId];
                    tivxQueuePut(&displayParams->fvid2FrameQ, (uintptr_t)&displayParams->fvid2Frames[bufId], TIVX_EVENT_TIMEOUT_NO_WAIT);
                }
            }
    
            if((vx_status)VX_SUCCESS == status)
            {
                tivxCheckStatus(&status, tivxMemBufferUnmap(display_config_target_ptr,
                                   obj_desc_configuration->mem_size,
                                   (vx_enum)VX_MEMORY_TYPE_HOST,
                                   (vx_enum)VX_READ_ONLY));
                tivxSetTargetKernelInstanceContext(kernel,
                                                   displayParams,
                                                   sizeof(tivxDisplayParams));
            }
            else
            {
                if(NULL != displayParams)
                {
                    tivxMemFree(displayParams, sizeof(tivxDisplayParams), (vx_enum)TIVX_MEM_EXTERNAL);
                }
            }
        }
        return status;
    }
    
    static vx_status VX_CALLBACK tivxDisplayDelete(
           tivx_target_kernel_instance kernel,
           tivx_obj_desc_t *obj_desc[],
           uint16_t num_params, void *priv_arg)
    {
        vx_status status = (vx_status)VX_SUCCESS;
        int32_t fvid2_status = FVID2_SOK;
        tivxDisplayParams *displayParams = NULL;
        Fvid2_FrameList frmList;
        uint32_t size;
        tivx_obj_desc_image_t *obj_desc_image;
    
        if((num_params != TIVX_KERNEL_DISPLAY_MAX_PARAMS) ||
           (NULL == obj_desc[TIVX_KERNEL_DISPLAY_CONFIGURATION_IDX]) ||
           (NULL == obj_desc[TIVX_KERNEL_DISPLAY_INPUT_IMAGE_IDX]))
        {
            status = (vx_status)VX_FAILURE;
            VX_PRINT(VX_ZONE_ERROR, "DISPLAY: ERROR: Invalid parameters!\r\n");
        }
        else
        {
            obj_desc_image = (tivx_obj_desc_image_t *)obj_desc[TIVX_KERNEL_DISPLAY_INPUT_IMAGE_IDX];
            status = tivxGetTargetKernelInstanceContext(kernel,
                                                        (void **) &displayParams,
                                                        &size);
    
            if((vx_status)VX_SUCCESS != status)
            {
                VX_PRINT(VX_ZONE_ERROR, "DISPLAY: ERROR: Could not obtain display kernel instance context!\r\n");
            }
    
            if (NULL == displayParams)
            {
                status = (vx_status)VX_FAILURE;
                VX_PRINT(VX_ZONE_ERROR, "DISPLAY: ERROR: Display params is NULL!\r\n");
            }
    
            /* Stop Display */
            if((vx_status)VX_SUCCESS == status)
            {
                fvid2_status = Fvid2_stop(displayParams->drvHandle, NULL);
    
                if(FVID2_SOK != fvid2_status)
                {
                    status = (vx_status)VX_FAILURE;
                    VX_PRINT(VX_ZONE_ERROR, "DISPLAY: ERROR: FVID2 Stop Failed!\r\n");
                }
            }
    
            /* Dequeue all the request from the driver */
            if((vx_status)VX_SUCCESS == status)
            {
                do
                {
                    fvid2_status = Fvid2_dequeue(displayParams->drvHandle,
                                           &frmList,
                                           0,
                                           FVID2_TIMEOUT_NONE);
                } while(FVID2_SOK == fvid2_status);
    
                /* Delete FVID2 handle */
                fvid2_status = Fvid2_delete(displayParams->drvHandle, NULL);
    
                if(FVID2_SOK != fvid2_status)
                {
                    status = (vx_status)VX_FAILURE;
                    VX_PRINT(VX_ZONE_ERROR, "DISPLAY: ERROR: FVID2 Delete Failed!\r\n");
                }
            }
    
            /* Deleting FVID2 frame Q */
            if(((vx_status)VX_SUCCESS == status) && (TIVX_KERNEL_DISPLAY_ZERO_BUFFER_COPY_MODE == displayParams->opMode))
            {
                tivxQueueDelete(&displayParams->fvid2FrameQ);
            }
    
            /* Delete the wait semaphore */
            if(((vx_status)VX_SUCCESS == status) && (NULL != displayParams->waitSem))
            {
                SemaphoreP_delete(displayParams->waitSem);
                displayParams->waitSem = NULL;
            }
    
            /* Delete kernel instance params object */
            if(((vx_status)VX_SUCCESS == status) && (NULL != displayParams))
            {
                displayParams->drvHandle = NULL;
    
                tivxDisplayFreeChromaBuff(displayParams);
    
                if(TIVX_KERNEL_DISPLAY_BUFFER_COPY_MODE == displayParams->opMode)
                {
                    if(displayParams->copyImageSize[0] != 0U)
                    {
                        if(displayParams->copyImagePtr[0][0])
                        {
                            tivxMemFree(displayParams->copyImagePtr[0][0], displayParams->copyImageSize[0], (vx_enum)TIVX_MEM_EXTERNAL);
                        }
                        if(displayParams->copyImagePtr[1][0])
                        {
                            tivxMemFree(displayParams->copyImagePtr[1][0], displayParams->copyImageSize[0], (vx_enum)TIVX_MEM_EXTERNAL);
                        }
                    }
                    if((displayParams->copyImageSize[1] != 0U) && ((vx_df_image)VX_DF_IMAGE_NV12 == obj_desc_image->format))
                    {
                        if(displayParams->copyImagePtr[0][1])
                        {
                            tivxMemFree(displayParams->copyImagePtr[0][1], displayParams->copyImageSize[1], (vx_enum)TIVX_MEM_EXTERNAL);
                        }
                        if(displayParams->copyImagePtr[1][1])
                        {
                            tivxMemFree(displayParams->copyImagePtr[1][1], displayParams->copyImageSize[1], (vx_enum)TIVX_MEM_EXTERNAL);
                        }
                    }
                }
    
                if(sizeof(tivxDisplayParams) == size)
                {
                    tivxMemFree(displayParams, sizeof(tivxDisplayParams), (vx_enum)TIVX_MEM_EXTERNAL);
                }
            }
        }
    
        return status;
    }
    
    static vx_status VX_CALLBACK tivxDisplayControl(
           tivx_target_kernel_instance kernel,
           uint32_t node_cmd_id, tivx_obj_desc_t *obj_desc[],
           uint16_t num_params, void *priv_arg)
    {
        vx_status            status = (vx_status)VX_SUCCESS;
        uint32_t             size;
        tivxDisplayParams   *dispPrms = NULL;
    
        status = tivxGetTargetKernelInstanceContext(kernel,
            (void **)&dispPrms, &size);
    
        if ((vx_status)VX_SUCCESS != status)
        {
            VX_PRINT(VX_ZONE_ERROR, "Failed to Get Target Kernel Instance Context\n");
        }
        else if ((NULL == dispPrms) ||
            (sizeof(tivxDisplayParams) != size))
        {
            VX_PRINT(VX_ZONE_ERROR, "Invalid Object Size\n");
            status = (vx_status)VX_FAILURE;
        }
        else
        {
            /* do nothing */
        }
    
        if ((vx_status)VX_SUCCESS == status)
        {
            switch (node_cmd_id)
            {
                case TIVX_DISPLAY_SELECT_CHANNEL:
                {
                    status = tivxDisplaySwitchChannel(dispPrms,
                        (tivx_obj_desc_user_data_object_t *)obj_desc[0U]);
                    break;
                }
                case TIVX_DISPLAY_SET_CROP_PARAMS:
                {
                    status = tivxDisplaySetCropParams(dispPrms,
                        (tivx_obj_desc_user_data_object_t *)obj_desc[0U]);
                    break;
                }
                default:
                {
                    VX_PRINT(VX_ZONE_ERROR, "Invalid Command Id\n");
                    status = (vx_status)VX_FAILURE;
                    break;
                }
            }
        }
    
        return (status);
    }
    
    static void tivxDisplayCalcOffset(tivxDisplayParams *dispPrms)
    {
        Fvid2_Format *fmt;
    
        if (NULL != dispPrms)
        {
            fmt = &dispPrms->dispParams.pipeCfg.inFmt;
    
            dispPrms->offset0 = (dispPrms->cropPrms.startY * fmt->pitch[0]) +
                dispPrms->cropPrms.startX * dispPrms->bpp;
            if (fmt->dataFormat == FVID2_DF_YUV420SP_UV)
            {
                dispPrms->offset1 =
                    ((dispPrms->cropPrms.startY / 2) * fmt->pitch[0]) +
                    dispPrms->cropPrms.startX * dispPrms->bpp;
            }
            else
            {
                dispPrms->offset1 = dispPrms->offset0;
            }
        }
    }
    
    void tivxDisplayUpdateRtParams(tivxDisplayParams *dispPrms, Fvid2_Frame *frm)
    {
        uint32_t             cnt;
        tivxDisplayRtParams *rtPrms;
        Fvid2_Format        *fmt;
    
        if (dispPrms->isRtPrmsUpdated)
        {
            rtPrms = (tivxDisplayRtParams *)frm->appData;
            fmt = &dispPrms->dispParams.pipeCfg.inFmt;
    
            if (NULL != rtPrms)
            {
                rtPrms->inFrmPrms.width = dispPrms->cropPrms.width;
                rtPrms->inFrmPrms.height = dispPrms->cropPrms.height;
                for (cnt = 0; cnt < FVID2_MAX_PLANES; cnt ++)
                {
                    rtPrms->inFrmPrms.pitch[cnt] = fmt->pitch[cnt];
                }
                rtPrms->inFrmPrms.dataFormat = fmt->dataFormat;
    
                memset(&rtPrms->rtPrms, 0, sizeof(Dss_DispRtParams));
                rtPrms->rtPrms.inFrmParams = &rtPrms->inFrmPrms;
                frm->perFrameCfg = (void *)&rtPrms->rtPrms;
    
                tivxDisplayCalcOffset(dispPrms);
            }
            else
            {
                VX_PRINT(VX_ZONE_ERROR, "Appdata is null !!!\n");
            }
    
            dispPrms->isRtPrmsUpdated = 0u;
        }
    }
    
    static vx_status VX_CALLBACK tivxDisplayProcess(
           tivx_target_kernel_instance kernel,
           tivx_obj_desc_t *obj_desc[],
           uint16_t num_params, void *priv_arg)
    {
        vx_status status = (vx_status)VX_SUCCESS;
        int32_t fvid2_status = FVID2_SOK;
        tivxDisplayParams *displayParams = NULL;
        tivx_obj_desc_image_t *obj_desc_image;
        void *image_target_ptr1, *image_target_ptr2 = NULL;
        uint32_t size;
        Fvid2_FrameList frmList;
        Fvid2_Frame *frm;
        tivxDisplayRtParams *rtPrms;
    
        if((num_params != TIVX_KERNEL_DISPLAY_MAX_PARAMS) ||
           (NULL == obj_desc[TIVX_KERNEL_DISPLAY_CONFIGURATION_IDX]) ||
           (NULL == obj_desc[TIVX_KERNEL_DISPLAY_INPUT_IMAGE_IDX]))
        {
            status = (vx_status)VX_FAILURE;
            VX_PRINT(VX_ZONE_ERROR, "DISPLAY: ERROR: Parameters are NULL!\r\n");
        }
    
        if((vx_status)VX_SUCCESS == status)
        {
            status = tivxGetTargetKernelInstanceContext(kernel,
                                                        (void *)&displayParams,
                                                        &size);
    
            if(((vx_status)VX_SUCCESS != status) ||
               (NULL == displayParams) ||
               (sizeof(tivxDisplayParams) != size))
            {
                status = (vx_status)VX_FAILURE;
                VX_PRINT(VX_ZONE_ERROR, "DISPLAY: ERROR: Instance context is NULL!\r\n");
            }
        }
    
        if((vx_status)VX_SUCCESS == status)
        {
            uint32_t active_channel;
    
            active_channel = displayParams->active_channel;
    
            obj_desc_image = (tivx_obj_desc_image_t *)
                tivxGetObjDescElement(obj_desc[TIVX_KERNEL_DISPLAY_INPUT_IMAGE_IDX],
                                      active_channel);
    
            if (obj_desc_image == NULL)
            {
                status = (vx_status)VX_FAILURE;
            }
        }
    
        if((vx_status)VX_SUCCESS == status)
        {
            image_target_ptr1 = tivxMemShared2TargetPtr(&obj_desc_image->mem_ptr[0]);
            if((vx_df_image)VX_DF_IMAGE_NV12 == obj_desc_image->format)
            {
                image_target_ptr2 = tivxMemShared2TargetPtr(&obj_desc_image->mem_ptr[1]);
    
            }
    
            if(TIVX_KERNEL_DISPLAY_ZERO_BUFFER_COPY_MODE == displayParams->opMode)
            {
                /* Get frame from queue */
                tivxQueueGet(&displayParams->fvid2FrameQ, (uintptr_t*)&frm, TIVX_EVENT_TIMEOUT_NO_WAIT);
                if(NULL != frm)
                {
                    tivxDisplayUpdateRtParams(displayParams, frm);
    
                    /* Assign buffer addresses */
                    frm->addr[0U] = ((uint64_t)image_target_ptr1) +
                        displayParams->offset0;
                    if((vx_df_image)VX_DF_IMAGE_NV12 == obj_desc_image->format)
                    {
                        frm->addr[1U] = (uint64_t)image_target_ptr2 +
                            displayParams->offset1;
                    }
    
                    if (((vx_df_image)VX_DF_IMAGE_U16 == obj_desc_image->format)||((vx_df_image)VX_DF_IMAGE_U8 == obj_desc_image->format))
                    {
                        frm->addr[1U] = displayParams->chromaBufAddr;
                    }
                    frm->fid = FVID2_FID_FRAME;
    
                    rtPrms = (tivxDisplayRtParams *)frm->appData;
                    rtPrms->obj_desc = (tivx_obj_desc_t*)obj_desc_image;
    
                    /* Create frame list */
                    frmList.numFrames  = 1U;
                    frmList.frames[0U] = frm;
                    /* Call Fvid2 Queue */
                    fvid2_status = Fvid2_queue(displayParams->drvHandle, &frmList, 0U);
                    if(FVID2_SOK != fvid2_status)
                    {
                        status = (vx_status)VX_FAILURE;
                        VX_PRINT(VX_ZONE_ERROR, "DISPLAY: ERROR: Unable to queue frame!\r\n");
                    }
                }
                else
                {
                    status = (vx_status)VX_FAILURE;
                    VX_PRINT(VX_ZONE_ERROR, "DISPLAY: ERROR: Could not get frame from queue!\r\n");
                }
    
                if(TRUE == displayParams->firstFrameDisplay)
                {
                    fvid2_status = Fvid2_start(displayParams->drvHandle, NULL);
                    if(FVID2_SOK != fvid2_status)
                    {
                        status = (vx_status)VX_FAILURE;
                        VX_PRINT(VX_ZONE_ERROR, "DISPLAY: ERROR: Could not start display!\r\n");
                    }
                    else
                    {
                        displayParams->firstFrameDisplay = FALSE;
                        /* Can't return frame as this is first display */
                        obj_desc[TIVX_KERNEL_DISPLAY_INPUT_IMAGE_IDX] = NULL;
                    }
                }
                else
                {
                    do
                    {
                        SemaphoreP_pend(displayParams->waitSem, SemaphoreP_WAIT_FOREVER);
                        fvid2_status = Fvid2_dequeue(displayParams->drvHandle,
                                            &frmList,
                                            0U,
                                            FVID2_TIMEOUT_NONE);
                    } while(FVID2_EAGAIN == fvid2_status);
                    if((1U == frmList.numFrames) && (FVID2_SOK == fvid2_status))
                    {
                        frm = frmList.frames[0U];
    
                        frm->perFrameCfg = NULL;
                        rtPrms = (tivxDisplayRtParams *)frm->appData;
                        /* Return frame */
                        obj_desc[TIVX_KERNEL_DISPLAY_INPUT_IMAGE_IDX] = rtPrms->obj_desc;
                        tivxQueuePut(&displayParams->fvid2FrameQ, (uintptr_t)frm, TIVX_EVENT_TIMEOUT_NO_WAIT);
                    }
                    else /* (1U != frmList.numFrames) || (((vx_status)VX_SUCCESS != status) && (FVID2_EAGAIN != status))*/
                    {
                        status = (vx_status)VX_FAILURE;
                        VX_PRINT(VX_ZONE_ERROR, "DISPLAY: ERROR: Dequeue operation failed!\r\n");
                    }
                }
            }
            else if(TIVX_KERNEL_DISPLAY_BUFFER_COPY_MODE == displayParams->opMode)
            {
                tivxCheckStatus(&status, tivxMemBufferMap(
                    displayParams->copyImagePtr[displayParams->currIdx][0],
                    displayParams->copyImageSize[0],
                    (vx_enum)VX_MEMORY_TYPE_HOST,
                    (vx_enum)VX_WRITE_ONLY));
                tivxCheckStatus(&status, tivxMemBufferMap(
                    image_target_ptr1,
                    displayParams->copyImageSize[0],
                    (vx_enum)VX_MEMORY_TYPE_HOST,
                    (vx_enum)VX_WRITE_ONLY));
    
                /* Copy  and assign buffers */
                memcpy(displayParams->copyImagePtr[displayParams->currIdx][0], image_target_ptr1, displayParams->copyImageSize[0]);
    
                tivxCheckStatus(&status, tivxMemBufferUnmap(
                    displayParams->copyImagePtr[displayParams->currIdx][0],
                    displayParams->copyImageSize[0],
                    (vx_enum)VX_MEMORY_TYPE_HOST,
                    (vx_enum)VX_WRITE_ONLY));
                tivxCheckStatus(&status, tivxMemBufferUnmap(
                    image_target_ptr1,
                    displayParams->copyImageSize[0],
                    (vx_enum)VX_MEMORY_TYPE_HOST,
                    (vx_enum)VX_WRITE_ONLY));
    
                displayParams->copyFrame[displayParams->currIdx].addr[0] = (uint64_t)displayParams->copyImagePtr[displayParams->currIdx][0];
                if((vx_df_image)VX_DF_IMAGE_NV12 == obj_desc_image->format)
                {
                    tivxCheckStatus(&status, tivxMemBufferMap(
                        displayParams->copyImagePtr[displayParams->currIdx][1],
                        displayParams->copyImageSize[1],
                        (vx_enum)VX_MEMORY_TYPE_HOST,
                        (vx_enum)VX_WRITE_ONLY));
                    tivxCheckStatus(&status, tivxMemBufferMap(
                        image_target_ptr2,
                        displayParams->copyImageSize[1],
                        (vx_enum)VX_MEMORY_TYPE_HOST,
                        (vx_enum)VX_WRITE_ONLY));
    
                    if (NULL != image_target_ptr2)
                    {
                        memcpy(displayParams->copyImagePtr[displayParams->currIdx][1], image_target_ptr2, displayParams->copyImageSize[1]);
                    }
    
                    tivxCheckStatus(&status, tivxMemBufferUnmap(
                        displayParams->copyImagePtr[displayParams->currIdx][1],
                        displayParams->copyImageSize[1],
                        (vx_enum)VX_MEMORY_TYPE_HOST,
                        (vx_enum)VX_WRITE_ONLY));
                    tivxCheckStatus(&status, tivxMemBufferUnmap(
                        image_target_ptr2,
                        displayParams->copyImageSize[1],
                        (vx_enum)VX_MEMORY_TYPE_HOST,
                        (vx_enum)VX_WRITE_ONLY));
    
                    displayParams->copyFrame[displayParams->currIdx].addr[1] = (uint64_t)displayParams->copyImagePtr[displayParams->currIdx][1];
                }
                displayParams->copyFrame[displayParams->currIdx].fid = FVID2_FID_FRAME;
                displayParams->copyFrame[displayParams->currIdx].appData = NULL;
    
                /* Create frame list */
                frmList.numFrames  = 1U;
                frmList.frames[0U] = &displayParams->copyFrame[displayParams->currIdx];
                /* Call Fvid2 Queue */
                fvid2_status = Fvid2_queue(displayParams->drvHandle, &frmList, 0U);
                if(FVID2_SOK != fvid2_status)
                {
                    status = (vx_status)VX_FAILURE;
                    VX_PRINT(VX_ZONE_ERROR, "DISPLAY: ERROR: Unable to queue copy frame!\r\n");
                }
                if(TRUE == displayParams->firstFrameDisplay)
                {
                    fvid2_status = Fvid2_start(displayParams->drvHandle, NULL);
                    if(FVID2_SOK != fvid2_status)
                    {
                        status = (vx_status)VX_FAILURE;
                        VX_PRINT(VX_ZONE_ERROR, "DISPLAY: ERROR: Could not start display!\r\n");
                    }
                    displayParams->firstFrameDisplay = FALSE;
                    displayParams->currIdx = 1;
                }
                else
                {
                    do
                    {
                        SemaphoreP_pend(displayParams->waitSem, SemaphoreP_WAIT_FOREVER);
                        fvid2_status = Fvid2_dequeue(displayParams->drvHandle,
                                               &frmList,
                                               0U,
                                               FVID2_TIMEOUT_NONE);
                    } while(FVID2_EAGAIN == fvid2_status);
                    if((1U == frmList.numFrames) && (FVID2_SOK == fvid2_status))
                    {
                        /* Change Curr Index */
                        if(displayParams->currIdx == 0U)
                        {
                            displayParams->currIdx = 1;
                        }
                        else
                        {
                            displayParams->currIdx = 0;
                        }
                    }
                    else /* (1U != frmList.numFrames) || (((vx_status)VX_SUCCESS != status) && (FVID2_EAGAIN != status))*/
                    {
                        status = (vx_status)VX_FAILURE;
                        VX_PRINT(VX_ZONE_ERROR, "DISPLAY: ERROR: Dequeue operation failed!\r\n");
                    }
                }
            }
            else
            {
                status = (vx_status)VX_FAILURE;
                VX_PRINT(VX_ZONE_ERROR, "DISPLAY: ERROR: Wrong Operation Mode Selected!\r\n");
            }
        }
    
        return status;
    }
    
    void tivxAddTargetKernelDisplay(void)
    {
        char target_name[TIVX_TARGET_MAX_NAME];
        vx_enum self_cpu;
    
        self_cpu = tivxGetSelfCpuId();
    
        if (self_cpu == (vx_enum)TIVX_CPU_ID_MCU2_0)
        {
            strncpy(target_name, TIVX_TARGET_DISPLAY1,
                TIVX_TARGET_MAX_NAME);
    
            vx_display_target_kernel1 = tivxAddTargetKernelByName(
                                TIVX_KERNEL_DISPLAY_NAME,
                                target_name,
                                tivxDisplayProcess,
                                tivxDisplayCreate,
                                tivxDisplayDelete,
                                tivxDisplayControl,
                                NULL);
    
            strncpy(target_name, TIVX_TARGET_DISPLAY2,
                TIVX_TARGET_MAX_NAME);
    
            vx_display_target_kernel2 = tivxAddTargetKernelByName(
                                TIVX_KERNEL_DISPLAY_NAME,
                                target_name,
                                tivxDisplayProcess,
                                tivxDisplayCreate,
                                tivxDisplayDelete,
                                tivxDisplayControl,
                                NULL);
        }
    }
    
    void tivxRemoveTargetKernelDisplay(void)
    {
        vx_status status = (vx_status)VX_SUCCESS;
    
        status = tivxRemoveTargetKernel(vx_display_target_kernel1);
        if(status == (vx_status)VX_SUCCESS)
        {
            vx_display_target_kernel1 = NULL;
        }
        status = tivxRemoveTargetKernel(vx_display_target_kernel2);
        if(status == (vx_status)VX_SUCCESS)
        {
            vx_display_target_kernel2 = NULL;
        }
    }
    

    /*
     *
     * Copyright (c) 2018 Texas Instruments Incorporated
     *
     * All rights reserved not granted herein.
     *
     * Limited License.
     *
     * Texas Instruments Incorporated grants a world-wide, royalty-free, non-exclusive
     * license under copyrights and patents it now or hereafter owns or controls to make,
     * have made, use, import, offer to sell and sell ("Utilize") this software subject to the
     * terms herein.  With respect to the foregoing patent license, such license is granted
     * solely to the extent that any such patent is necessary to Utilize the software alone.
     * The patent license shall not apply to any combinations which include this software,
     * other than combinations with devices manufactured by or for TI ("TI Devices").
     * No hardware patent is licensed hereunder.
     *
     * Redistributions must preserve existing copyright notices and reproduce this license
     * (including the above copyright notice and the disclaimer and (if applicable) source
     * code license limitations below) in the documentation and/or other materials provided
     * with the distribution
     *
     * Redistribution and use in binary form, without modification, are permitted provided
     * that the following conditions are met:
     *
     * *       No reverse engineering, decompilation, or disassembly of this software is
     * permitted with respect to any software provided in binary form.
     *
     * *       any redistribution and use are licensed by TI for use only with TI Devices.
     *
     * *       Nothing shall obligate TI to provide you with source code for the software
     * licensed and provided to you in object code.
     *
     * If software source code is provided to you, modification and redistribution of the
     * source code are permitted provided that the following conditions are met:
     *
     * *       any redistribution and use of the source code, including any resulting derivative
     * works, are licensed by TI for use only with TI Devices.
     *
     * *       any redistribution and use of any object code compiled from the source code
     * and any resulting derivative works, are licensed by TI for use only with TI Devices.
     *
     * Neither the name of Texas Instruments Incorporated nor the names of its suppliers
     *
     * may be used to endorse or promote products derived from this software without
     * specific prior written permission.
     *
     * DISCLAIMER.
     *
     * THIS SOFTWARE IS PROVIDED BY TI AND TI'S LICENSORS "AS IS" AND ANY EXPRESS
     * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     * IN NO EVENT SHALL TI AND TI'S LICENSORS BE LIABLE FOR ANY DIRECT, INDIRECT,
     * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
     * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
     * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
     * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
     * OF THE POSSIBILITY OF SUCH DAMAGE.
     *
     */
    
    #include "app_single_cam_main.h"
    #include <utils/iss/include/app_iss.h>
    #include "app_test.h"
    
    #ifdef A72
    #if defined(LINUX)
    /*ITT server is supported only in target mode and only on Linux*/
    #include <itt_server.h>
    #endif
    #endif
    
    static char availableSensorNames[ISS_SENSORS_MAX_SUPPORTED_SENSOR][ISS_SENSORS_MAX_NAME];
    static vx_uint8 num_sensors_found;
    static IssSensor_CreateParams sensorParams;
    
    #define NUM_CAPT_CHANNELS   (4u)
    
    #ifdef _APP_DEBUG_
    static char *app_get_test_file_path()
    {
        char *tivxPlatformGetEnv(char *env_var);
    
        #if defined(SYSBIOS)
        return tivxPlatformGetEnv("VX_TEST_DATA_PATH");
        #else
        return getenv("VX_TEST_DATA_PATH");
        #endif
    }
    #endif //_APP_DEBUG_
    
    /*
     * Utility API used to add a graph parameter from a node, node parameter index
     */
    void add_graph_parameter_by_node_index(vx_graph graph, vx_node node, vx_uint32 node_parameter_index)
    {
        vx_parameter parameter = vxGetParameterByIndex(node, node_parameter_index);
    
        vxAddParameterToGraph(graph, parameter);
        vxReleaseParameter(&parameter);
    }
    
    vx_status app_init(AppObj *obj)
    {
        vx_status status = VX_SUCCESS;
        char* sensor_list[ISS_SENSORS_MAX_SUPPORTED_SENSOR];
        vx_uint8 count = 0;
        char ch = 0xFF;
        vx_uint8 selectedSensor = 0xFF;
        vx_uint8 detectedSensors[ISS_SENSORS_MAX_CHANNEL];
    #ifdef A72
    #if defined(LINUX)
    /*ITT server is supported only in target mode and only on Linux*/
        status = itt_server_init((void*)obj, (void*)save_debug_images, (void*)appSingleCamUpdateVpacDcc);
        if(status != 0)
        {
            printf("Warning : Failed to initialize ITT server. Live tuning will not work \n");
        }
    #endif
    #endif
    
        for(count=0;count<ISS_SENSORS_MAX_CHANNEL;count++)
        {
            detectedSensors[count] = 0xFF;
        }
    
        for(count=0;count<ISS_SENSORS_MAX_SUPPORTED_SENSOR;count++)
        {
            sensor_list[count] = NULL;
        }
    
        obj->stop_task = 0;
        obj->stop_task_done = 0;
        obj->selectedCam = 0xFF;
    
        if(status == VX_SUCCESS)
        {
            obj->context = vxCreateContext();
            status = vxGetStatus((vx_reference) obj->context);
        }
    
        if(status == VX_SUCCESS)
        {
            tivxHwaLoadKernels(obj->context);
            tivxImagingLoadKernels(obj->context);
            APP_PRINTF("tivxImagingLoadKernels done\n");
        }
    
        /*memset(availableSensorNames, 0, ISS_SENSORS_MAX_SUPPORTED_SENSOR*ISS_SENSORS_MAX_NAME);*/
        for(count=0;count<ISS_SENSORS_MAX_SUPPORTED_SENSOR;count++)
        {
            availableSensorNames[count][0] = '\0';
            sensor_list[count] = availableSensorNames[count];
        }
    
        if(status == VX_SUCCESS)
        {
            status = appEnumerateImageSensor(sensor_list, &num_sensors_found);
        }
    
        if(obj->is_interactive)
        {
            selectedSensor = 0xFF;
            obj->selectedCam = 0xFF;
            while(obj->selectedCam == 0xFF)
            {
                printf("Select camera port index 0-%d : ", ISS_SENSORS_MAX_CHANNEL-1);
                ch = getchar();
                obj->selectedCam = ch - '0';
    
                if(obj->selectedCam >= ISS_SENSORS_MAX_CHANNEL)
                {
                    printf("Invalid entry %c. Please choose between 0 and %d \n", ch, ISS_SENSORS_MAX_CHANNEL-1);
                    obj->selectedCam = 0xFF;
                }
    
                while ((obj->selectedCam != 0xFF) && (selectedSensor > (num_sensors_found-1)))
                {
                    printf("%d registered sensor drivers\n", num_sensors_found);
                    for(count=0;count<num_sensors_found;count++)
                    {
                        printf("%c : %s \n", count+'a', sensor_list[count]);
                    }
    
                    printf("Select a sensor above or press '0' to autodetect the sensor : ");
                    ch = getchar();
                    if(ch == '0')
                    {
                        uint8_t num_sensors_detected = 0;
                        uint8_t channel_mask = (1<<obj->selectedCam);
    
                        status = appDetectImageSensor(detectedSensors, &num_sensors_detected, channel_mask);
                        if(0 == status)
                        {
                            selectedSensor = detectedSensors[obj->selectedCam];
                            if(selectedSensor > ISS_SENSORS_MAX_SUPPORTED_SENSOR)
                            {
                                printf("No sensor detected at port %d. Please select another port \n", obj->selectedCam);
                                obj->selectedCam = 0xFF;
                                selectedSensor = 0xFF;
                            }
                        }
                        else
                        {
                            printf("sensor detection at port %d returned error . Please try again \n", obj->selectedCam);
                            obj->selectedCam = 0xFF;
                            selectedSensor = 0xFF;
                        }
                    }
                    else
                    {
                        selectedSensor = ch - 'a';
                        if(selectedSensor > (num_sensors_found-1))
                        {
                            printf("Invalid selection %c. Try again \n", ch);
                        }
                    }
                }
            }
    
            obj->sensor_name = sensor_list[selectedSensor];
            printf("Sensor selected : %s\n", obj->sensor_name);
    
            ch = 0xFF;
            fflush (stdin);
            while ((ch != '0') && (ch != '1'))
            {
                fflush (stdin);
                printf ("LDC Selection Yes(1)/No(0) : ");
                ch = getchar();
            }
    
            obj->ldc_enable = ch - '0';
        }
        else
        {
            selectedSensor = obj->sensor_sel;
            if(selectedSensor > (num_sensors_found-1))
            {
                printf("Invalid sensor selection %d \n", selectedSensor);
                return VX_FAILURE;
            }
        }
    
        obj->sensor_wdr_mode = 0;
    
        obj->table_width = LDC_TABLE_WIDTH;
        obj->table_height = LDC_TABLE_HEIGHT;
        obj->ds_factor = LDC_DS_FACTOR;
    
        /* Display initialization */
        memset(&obj->display_params, 0, sizeof(tivx_display_params_t));
        obj->display_params.opMode = TIVX_KERNEL_DISPLAY_ZERO_BUFFER_COPY_MODE;
        obj->display_params.pipeId = 2;
        obj->display_params.outHeight = 1080;
        obj->display_params.outWidth = 1920;
        obj->display_params.posX = 0;
        obj->display_params.posY = 0;
    
        obj->scaler_enable = vx_false_e;
    
        appPerfPointSetName(&obj->total_perf , "TOTAL");
    
        return status;
    }
    
    vx_status app_deinit(AppObj *obj)
    {
        vx_status status = VX_FAILURE;
        tivxHwaUnLoadKernels(obj->context);
        APP_PRINTF("tivxHwaUnLoadKernels done\n");
    
        tivxImagingUnLoadKernels(obj->context);
        APP_PRINTF("tivxImagingUnLoadKernels done\n");
    
        status = vxReleaseContext(&obj->context);
        if(VX_SUCCESS == status)
        {
            APP_PRINTF("vxReleaseContext done\n");
        }
        else
        {
            printf("Error: vxReleaseContext returned 0x%x \n", status);
        }
        return status;
    }
    
    /*
     * Graph,
     *           viss_config
     *               |
     *               v
     * input_img -> VISS -----> LDC -----> output_img
     *
     */
    
    vx_status app_create_graph(AppObj *obj)
    {
        vx_status status = VX_SUCCESS;
        int32_t sensor_init_status = -1;
        obj->configuration = NULL;
        obj->raw = NULL;
        obj->y12 = NULL;
        obj->uv12_c1 = NULL;
        obj->y8_r8_c2 = NULL;
        obj->uv8_g8_c3 = NULL;
        obj->s8_b8_c4 = NULL;
        obj->histogram = NULL;
        obj->h3a_aew_af = NULL;
        obj->display_image = NULL;
    
        unsigned int image_width = obj->width_in;
        unsigned int image_height = obj->height_in;
    
        tivx_raw_image raw_image = 0;
        vx_user_data_object capture_config;
        vx_uint8 num_capture_frames = 1;
        tivx_capture_params_t local_capture_config;
        uint32_t buf_id;
        const vx_char capture_user_data_object_name[] = "tivx_capture_params_t";
        uint32_t sensor_features_enabled = 0;
        uint32_t sensor_features_supported = 0;
        uint32_t sensor_wdr_enabled = 0;
        uint32_t sensor_exp_control_enabled = 0;
        uint32_t sensor_gain_control_enabled = 0;
    
        vx_bool yuv_cam_input = vx_false_e;
        vx_image viss_out_image = NULL;
        vx_image ldc_in_image = NULL;
        vx_image capt_yuv_image = NULL;
    
        uint8_t channel_mask = (1<<obj->selectedCam);
    
        vx_uint32 params_list_depth = 1;
        if(obj->test_mode == 1)
        {
            params_list_depth = 2;
        }
        vx_graph_parameter_queue_params_t graph_parameters_queue_params_list[params_list_depth];
    
        printf("Querying %s \n", obj->sensor_name);
        memset(&sensorParams, 0, sizeof(sensorParams));
        status = appQueryImageSensor(obj->sensor_name, &sensorParams);
    
    
        if(VX_SUCCESS != status)
        {
            printf("appQueryImageSensor returned %d\n", status);
            return status;
        }
    
        if(sensorParams.sensorInfo.raw_params.format[0].pixel_container == VX_DF_IMAGE_UYVY)
        {
            yuv_cam_input = vx_true_e;
            printf("YUV Input selected. VISS and AEWB nodes will be bypassed. \n");
        }
        //yuv_cam_input = vx_true_e;
    
        /*
        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(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++;
    
        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))
            {
                status = vxGraphParameterEnqueueReadyRef(obj->graph, 1, (vx_reference*)&(obj->display_image), 1);
            }
        }
    
        /*
            The application reads and  processes the same image "frm_loop_cnt" times
            The output may change because on VISS, parameters are updated every frame based on AEWB results
            AEWB result is avaialble after 1 frame and is applied after 2 frames
            Therefore, first 2 output images will have wrong colors
        */
        frm_loop_cnt = obj->num_frames_to_run;
        frm_loop_cnt += obj->num_cap_buf;
    
        if(obj->is_interactive)
        {
            /* in interactive mode loop for ever */
            frm_loop_cnt  = 0xFFFFFFFF;
        }
    
    #ifdef A72
    #if defined(LINUX)
    
        appDccUpdatefromFS(obj->sensor_name, obj->sensor_wdr_mode,
                            obj->node_aewb, 0,
                            obj->node_viss, 0,
                            obj->node_ldc, 0,
                            obj->context);
    #endif
    #endif
    
        for(i=0; i<frm_loop_cnt; i++)
        {
            vx_image test_image;
            appPerfPointBegin(&obj->total_perf);
            graph_parameter_num = 0;
            if(status == VX_SUCCESS)
            {
                status = vxGraphParameterDequeueDoneRef(obj->graph, graph_parameter_num, (vx_reference*)&out_capture_frames, 1, &num_refs_capture);
            }
            graph_parameter_num++;
            if((status == VX_SUCCESS) && (obj->test_mode == 1))
            {
                status = vxGraphParameterDequeueDoneRef(obj->graph, 1, (vx_reference*)&test_image, 1, &num_refs_capture);
            }
            if((obj->test_mode == 1) && (i > TEST_BUFFER) && (status == VX_SUCCESS))
            {
                vx_uint32 actual_checksum = 0;
                if(app_test_check_image(test_image, checksums_expected[obj->sensor_sel][0], &actual_checksum) == vx_false_e)
                {
                    test_result = vx_false_e;
                }
                populate_gatherer(obj->sensor_sel, 0, actual_checksum);
            }
            APP_PRINTF(" i %d...\n", i);
            graph_parameter_num = 0;
            if((status == VX_SUCCESS) && (obj->test_mode == 1))
            {
                status = vxGraphParameterEnqueueReadyRef(obj->graph, 1, (vx_reference*)&test_image, 1);
            }
            if(status == VX_SUCCESS)
            {
                status = vxGraphParameterEnqueueReadyRef(obj->graph, graph_parameter_num, (vx_reference*)&out_capture_frames, 1);
            }
            graph_parameter_num++;
    
            appPerfPointEnd(&obj->total_perf);
    
            if((obj->stop_task) || (status != VX_SUCCESS))
            {
                break;
            }
        }
    
        if(status == VX_SUCCESS)
        {
            status = vxWaitGraph(obj->graph);
        }
    /* Dequeue buf for pipe down */
    #if 0
        for(buf_id=0; buf_id<obj->num_cap_buf-2; buf_id++)
        {
            APP_PRINTF(" Dequeuing capture # %d...\n", buf_id);
            graph_parameter_num = 0;
            vxGraphParameterDequeueDoneRef(obj->graph, graph_parameter_num, (vx_reference*)&out_capture_frames, 1, &num_refs_capture);
            graph_parameter_num++;
        }
    #endif
        if(status == VX_SUCCESS)
        {
            status = appStopImageSensor(obj->sensor_name, channel_mask);
        }
        return status;
    }
    
    static void app_run_task(void *app_var)
    {
        AppObj *obj = (AppObj *)app_var;
    
        appPerfStatsCpuLoadResetAll();
    
        app_run_graph(obj);
    
        obj->stop_task_done = 1;
    }
    
    static int32_t app_run_task_create(AppObj *obj)
    {
        tivx_task_create_params_t params;
        int32_t status;
    
        tivxTaskSetDefaultCreateParams(&params);
        params.task_main = app_run_task;
        params.app_var = obj;
    
        obj->stop_task_done = 0;
        obj->stop_task = 0;
    
        status = tivxTaskCreate(&obj->task, &params);
    
        return status;
    }
    
    static void app_run_task_delete(AppObj *obj)
    {
        while(obj->stop_task_done==0)
        {
             tivxTaskWaitMsecs(100);
        }
    
        tivxTaskDelete(&obj->task);
    }
    
    static char menu[] = {
        "\n"
        "\n =========================="
        "\n Demo : Single Camera w/ 2A"
        "\n =========================="
        "\n"
        "\n p: Print performance statistics"
        "\n"
    #ifdef _APP_DEBUG_
        "\n s: Save Sensor RAW, VISS Output and H3A output images to File System"
        "\n"
    #endif
        "\n e: Export performance statistics"
    #ifdef A72
    #if defined(LINUX)
        "\n"
        "\n u: Update DCC from File System"
        "\n"
        "\n"
    #endif
    #endif
        "\n x: Exit"
        "\n"
        "\n Enter Choice: "
    };
    
    static vx_status app_run_graph_interactive(AppObj *obj)
    {
        vx_status status;
        uint32_t done = 0;
        char ch;
        FILE *fp;
        app_perf_point_t *perf_arr[1];
        uint8_t channel_mask = (1<<obj->selectedCam);
    
        status = app_run_task_create(obj);
        if(status!=0)
        {
            printf("ERROR: Unable to create task\n");
        }
        else
        {
            appPerfStatsResetAll();
            while(!done && (status == VX_SUCCESS))
            {
                printf(menu);
                ch = getchar();
                printf("\n");
    
                switch(ch)
                {
                    case 'p':
                        appPerfStatsPrintAll();
                        status = tivx_utils_graph_perf_print(obj->graph);
                        appPerfPointPrint(&obj->total_perf);
                        printf("\n");
                        appPerfPointPrintFPS(&obj->total_perf);
                        appPerfPointReset(&obj->total_perf);
                        printf("\n");
                        break;
    #ifdef _APP_DEBUG_
                    case 's':
                        save_debug_images(obj);
                        break;
    #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;
    }
    
    
     

    Thanks,

    Madhav

  • Madhav,

    I am not sure which data format you are using in the capture output, but can you try swapping value of format->dataFormat in below two cases in vx_display_target.c file? 

    case (vx_df_image)VX_DF_IMAGE_UYVY:
    format->dataFormat = FVID2_DF_YUV422I_UYVY;
    format->pitch[FVID2_YUV_INT_ADDR_IDX] = (uint32_t)obj_desc_img->imagepatch_addr[0].stride_y;
    dispPrms->bpp = 2;
    break;
    case (vx_df_image)VX_DF_IMAGE_YUYV:
    format->dataFormat = FVID2_DF_YUV422I_YUYV;
    format->pitch[FVID2_YUV_INT_ADDR_IDX] = (uint32_t)obj_desc_img->imagepatch_addr[0].stride_y;
    dispPrms->bpp = 2;
    break;

    Regards,

    Brijesh

  • Dear Sir,

    capture is setting the data format to VX_DF_IMAGE_UYVY  as you can see in the below functions it is going into first switch case 

    this function is present in vx_capture_target.c

    static uint32_t tivxCaptureExtractDataFormat(uint32_t format)
    {
    uint32_t dataFormat = FVID2_DF_BGRX32_8888;

    switch (format)
    {
    case (vx_df_image)VX_DF_IMAGE_UYVY:
    printf(" capture ::VX_DF_IMAGE_UYVY\n ");
    dataFormat = FVID2_DF_YUV422I_UYVY;
    break;
    case (vx_df_image)VX_DF_IMAGE_YUYV:
    dataFormat = FVID2_DF_YUV422I_YUYV;
    printf("capture ::VX_DF_IMAGE_YUYV\n ");
    break;
    default:
    dataFormat = FVID2_DF_BGRX32_8888;
    break;
    }

    return dataFormat;
    }

    as you told me to swap the format->dataFormat i have done that  i am getting image like this (hand colour getting blue)

    Thanks,

    Madhav

  • Hi Madhav,

    For VX_DF_IMAGE_UYVY input image format, can you try below options for dataFormat and see if any of them giving correct output?

     FVID2_DF_YUV422I_UYVY

     FVID2_DF_YUV422I_YUYV

     FVID2_DF_YUV422I_VYUY

     FVID2_DF_YUV422I_YVYU

    Regards,

    Brijesh

  • Dear Sir,

    I have tried all options as mentioned above, didn't get correct output.

    Thanks,

    Madhav

  • hi,

    Are you sure then that your sensor is outputting yuv422 data? Can you save one image from the sensor and analyze it offline? 

    Regards,

    Brijesh

  • Dear Sir,

    i have attached yuv dumped output 

    width 1280 

    height 724 

    color space  yuv

    data container interleaved 4:2:2

    channel order yuv

    bit depth 8bit

    cap_0004.zip

    Thanks,

    Madhav

  • Hi Madhav,

    This looks like proper UYVY frame. I could see correct colors with UYVY format. What TIOVX format that you are using for this frame? 

    Regards,

    Brijesh

  • Dear Sir,

    i have used format->dataFormat =  FVID2_DF_YUV422I_YVYU; in vx_display_taget.c file 

    and  in vx_capture_target.c dataFormat = FVID2_DF_YUV422I_UYVY;

    Thanks,

    Madhav

  • Hi Madhav,

    Can you please change fvid2 format in display to FVID2_DF_YUV422I_UYVY?

    Regards,

    Brijesh

  • Dear Sir,

    After doing the above changes getting the image green color as i have attched here .

    Thanks,

    Madhav

  • Strange, Is there any other changes in the DSS node? Are you using zero copy mode in the DSS Node? Which SDK release are you using? 

    Regards,

    Brijesh

  • Dear Sir,

    we are using  SDK (08_05_00) on ubuntu 18.04.

    i haven't done any changes in DSS node.

    can you please explain what is  zero copy mode in the DSS Node?

    Thanks,

    Madhav

  • Please make sure to set opMode to TIVX_KERNEL_DISPLAY_ZERO_BUFFER_COPY_MODE in Display create Parameters..

    Regards,

    Brijesh

  • Dear Sir,

    As i have shared already app_single_cam_main.c to you .

    by default it is  set to TIVX_KERNEL_DISPLAY_ZERO_BUFFER_COPY_MODE only.

    Thanks,

    Madhav

  • Hi,

    Are you sure that capture output is directed connected to display? Because in that case, you should got correct output for atleast one of the format. 

    I think we would have to now check all possible combinations..  

    There are 4 formats possible in CSIRX (YUYV, YVYU, UYVY, VYUY) and 2 in display (YUYV & UYVY), can you try these total 8 combinations and see if any one of them is giving correct output? 

    Regards,

    Brijesh

  • Dear Sir,

    Are you sure that capture output is directed connected to display?

    yes beacuse as per below loop VISS and AEWB nodes gets bypassed and i am selection LDC as zero

    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");
    }

    i have tried all combinations as mentioned CSIRX (YUYV, YVYU, UYVY, VYUY) and 2 in display (YUYV & UYVY) still not getting the correct output.

    please let me know anything form my side need to provide for your references 

    Thanks,

    madhav

  • Madhav,

    Unfortunately, no. If your sensor is outputting one of the above format, the one combination should have worked.. So i suspect, either the output format is incorrect or there is some other module between capture and display..

    Regards,

    Brijesh