commit 5b9b144910267647ff886c0004b7800c3888f628
Author: Nikhil Dasan <n-dasan@ti.com>
Date:   Mon Aug 8 13:10:54 2022 +0530

    Freeze Demo
    
    Signed-off-by: Nikhil Dasan <n-dasan@ti.com>

diff --git a/apps/basic_demos/app_single_cam/app_single_cam_common.h b/apps/basic_demos/app_single_cam/app_single_cam_common.h
index bad9c78..06f8269 100755
--- a/apps/basic_demos/app_single_cam/app_single_cam_common.h
+++ b/apps/basic_demos/app_single_cam/app_single_cam_common.h
@@ -141,6 +141,7 @@ typedef struct {
     vx_user_data_object dcc_param_2a;
     vx_user_data_object dcc_param_ldc;
     vx_user_data_object display_param_obj;
+    vx_user_data_object safetyChk_obj;
 
     vx_object_array cap_frames[MAX_NUM_BUF];
     vx_image display_image;
diff --git a/apps/basic_demos/app_single_cam/app_single_cam_main.c b/apps/basic_demos/app_single_cam/app_single_cam_main.c
index 2804f50..93b9342 100755
--- a/apps/basic_demos/app_single_cam/app_single_cam_main.c
+++ b/apps/basic_demos/app_single_cam/app_single_cam_main.c
@@ -63,6 +63,7 @@
 #include "app_single_cam_main.h"
 #include <utils/iss/include/app_iss.h>
 #include "app_test.h"
+#include <utils/grpx/include/app_grpx.h>
 
 #ifdef A72
 #if defined(LINUX)
@@ -76,6 +77,8 @@ static vx_uint8 num_sensors_found;
 static IssSensor_CreateParams sensorParams;
 
 #define NUM_CAPT_CHANNELS   (4u)
+#define OUT_WIDTH           (1280U)
+#define OUT_HEIGHT          (720U)
 
 #ifdef _APP_DEBUG_
 static char *app_get_test_file_path()
@@ -109,6 +112,7 @@ vx_status app_init(AppObj *obj)
     char ch = 0xFF;
     vx_uint8 selectedSensor = 0xFF;
     vx_uint8 detectedSensors[ISS_SENSORS_MAX_CHANNEL];
+    app_grpx_init_prms_t grpx_prms;
 #ifdef A72
 #if defined(LINUX)
 /*ITT server is supported only in target mode and only on Linux*/
@@ -258,6 +262,12 @@ vx_status app_init(AppObj *obj)
     obj->display_params.posX = 0;
     obj->display_params.posY = 0;
 
+    if (status == VX_SUCCESS)
+    {
+       appGrpxInitParamsInit(&grpx_prms, obj->context);
+       appGrpxInit(&grpx_prms);
+    }
+
     obj->scaler_enable = vx_false_e;
 
     appPerfPointSetName(&obj->total_perf , "TOTAL");
@@ -723,6 +733,8 @@ Sensor driver does not support metadata yet.
     }
     else
     {
+        obj->display_params.outHeight = OUT_HEIGHT;
+        obj->display_params.outWidth = OUT_WIDTH;
         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);
@@ -1223,6 +1235,8 @@ static char menu[] = {
     "\n"
 #endif
     "\n e: Export performance statistics"
+    "\n"
+    "\n f: Set safety params"
 #ifdef A72
 #if defined(LINUX)
     "\n"
@@ -1244,6 +1258,9 @@ static vx_status app_run_graph_interactive(AppObj *obj)
     FILE *fp;
     app_perf_point_t *perf_arr[1];
     uint8_t channel_mask = (1<<obj->selectedCam);
+    tivx_display_safety_check_params_t safetyChk_params;
+    uint32_t in_width, in_height;
+    vx_reference refs[1];
 
     status = app_run_task_create(obj);
     if(status!=0)
@@ -1290,6 +1307,32 @@ static vx_status app_run_graph_interactive(AppObj *obj)
                         printf("fp is null\n");
                     }
                     break;
+
+                case 'f':
+                    printf("Setting DSS Safety Check\n");
+
+                    tivx_dss_safety_chk_params_init(&safetyChk_params);
+                    vxQueryImage(obj->display_image, (vx_enum)VX_IMAGE_WIDTH, &in_width, sizeof(uint32_t));
+                    vxQueryImage(obj->display_image, (vx_enum)VX_IMAGE_HEIGHT, &in_height, sizeof(uint32_t));
+
+                    safetyChk_params.safetyChkEnable = 1U;
+                    safetyChk_params.safetyChkMode = 0U;
+                    safetyChk_params.thresholdValue = 200U;
+                    safetyChk_params.regionSize.width = obj->display_params.outWidth - 1 ;
+                    safetyChk_params.regionSize.height = obj->display_params.outHeight - 1;
+                    safetyChk_params.disp_prm = obj->display_params;
+
+                    obj->safetyChk_obj = vxCreateUserDataObject(obj->context, "tivx_display_safety_check_params_t", sizeof(tivx_display_safety_check_params_t), NULL);
+                    if(status == VX_SUCCESS)
+                    {
+                        status = vxCopyUserDataObject(obj->safetyChk_obj, 0, sizeof(tivx_display_safety_check_params_t), &safetyChk_params, VX_WRITE_ONLY, VX_MEMORY_TYPE_HOST);
+                    }
+                    refs[0] = (vx_reference)obj->safetyChk_obj;
+                    if(status == VX_SUCCESS)
+                    {
+                        status = tivxNodeSendCommand(obj->displayNode, 0u, TIVX_DISPLAY_SET_PIPE_SAFETY_CHK_PARAMS, refs, 1u);
+                    }
+                    break;
 #ifdef A72
 #if defined(LINUX)
                 case 'u':
diff --git a/utils/grpx/src/app_grpx.c b/utils/grpx/src/app_grpx.c
index 71aaf53..1d04ae6 100755
--- a/utils/grpx/src/app_grpx.c
+++ b/utils/grpx/src/app_grpx.c
@@ -145,6 +145,11 @@ int32_t appGrpxInit(app_grpx_init_prms_t *prm)
     int32_t status = 0;
     #ifdef ENABLE_GRPX
     app_grpx_obj_t *obj = (app_grpx_obj_t*)&g_app_grpx_obj;
+    tivx_display_safety_check_params_t safetyChk_params;
+    uint32_t in_width, in_height;
+    vx_user_data_object safetyChk_obj;
+    vx_reference refs[1];
+    tivx_display_params_t disp_config_prm;
 
     memset(obj, 0, sizeof(app_grpx_obj_t));
 
@@ -158,8 +163,6 @@ int32_t appGrpxInit(app_grpx_init_prms_t *prm)
     }
     if(status==VX_SUCCESS)
     {
-        tivx_display_params_t disp_config_prm;
-
         memset(&disp_config_prm, 0, sizeof(tivx_display_params_t));
         disp_config_prm.opMode = TIVX_KERNEL_DISPLAY_ZERO_BUFFER_COPY_MODE;
         disp_config_prm.pipeId = prm->display_pipe;
@@ -200,7 +203,33 @@ int32_t appGrpxInit(app_grpx_init_prms_t *prm)
         {
             printf("GRPX: ERROR: Unable to verify graph for graphics !!!\n");
         }
+        else
+        {
+            printf("Setting DSS Safety Check VID1\n");
+
+            tivx_dss_safety_chk_params_init(&safetyChk_params);
+            vxQueryImage(obj->disp_image, (vx_enum)VX_IMAGE_WIDTH, &in_width, sizeof(uint32_t));
+            vxQueryImage(obj->disp_image, (vx_enum)VX_IMAGE_HEIGHT, &in_height, sizeof(uint32_t));
+            safetyChk_params.safetyChkEnable = 1U;
+            safetyChk_params.safetyChkMode = 0U;
+            safetyChk_params.thresholdValue = 100U;
+            safetyChk_params.regionSize.width = in_width - 1 ;
+            safetyChk_params.regionSize.height = in_height - 1;
+            safetyChk_params.disp_prm = disp_config_prm;
+
+            safetyChk_obj = vxCreateUserDataObject(prm->openvx_context, "tivx_display_safety_check_params_t", sizeof(tivx_display_safety_check_params_t), NULL);
+            if(status == VX_SUCCESS)
+            {
+                status = vxCopyUserDataObject(safetyChk_obj, 0, sizeof(tivx_display_safety_check_params_t), &safetyChk_params, VX_WRITE_ONLY, VX_MEMORY_TYPE_HOST);
+            }
+            refs[0] = (vx_reference)safetyChk_obj;
+            if(status == VX_SUCCESS)
+            {
+                status = tivxNodeSendCommand(obj->disp_node, 0u, TIVX_DISPLAY_SET_PIPE_SAFETY_CHK_PARAMS, refs, 1u);
+            }
+        }
     }
+
     if(status==VX_SUCCESS)
     {
         status = Draw2D_create(&obj->draw2d_obj);
@@ -384,7 +413,7 @@ void appGrpxInitParamsInit(app_grpx_init_prms_t *prm, vx_context context)
     prm->height = 1080;
     prm->pos_x = 0;
     prm->pos_y = 0;
-    prm->display_pipe = 1;
+    prm->display_pipe = 0;
     prm->update_interval = 500;
     prm->draw_callback = appGrpxDrawDefault;
     prm->openvx_context = context;
