weston-help-client: add debug tool [1/1]

PD#TV-79887

Problem:
Wayland debug tool support

Solution:
add debug tool

Verify:
ah212

Change-Id: I38ace684baa8f49886b625d5815fa466896f2de2
Signed-off-by: limin.tian <limin.tian@amlogic.com>
diff --git a/display_framework/src/extension/weston-6.0/client/drm-help-client.c b/display_framework/src/extension/weston-6.0/client/drm-help-client.c
index dcf0f70..bf134f1 100644
--- a/display_framework/src/extension/weston-6.0/client/drm-help-client.c
+++ b/display_framework/src/extension/weston-6.0/client/drm-help-client.c
@@ -264,3 +264,6 @@
     }
     free(data);
 }
+void drm_help_client_get_debug_info(drm_client_ctx* client, int count) {
+    send_cmd(client, "get info", &count, OPT_TYPE_INT);
+}
diff --git a/display_framework/src/extension/weston-6.0/client/drm-help-client.h b/display_framework/src/extension/weston-6.0/client/drm-help-client.h
index d537ccb..38edf01 100644
--- a/display_framework/src/extension/weston-6.0/client/drm-help-client.h
+++ b/display_framework/src/extension/weston-6.0/client/drm-help-client.h
@@ -101,6 +101,7 @@
 
     json_object* send_cmd_sync(drm_client_ctx* client, const char* cmd, void* opt, opt_type type);
 
+    void drm_help_client_get_debug_info(drm_client_ctx* client, int count);
 #ifdef __cplusplus
 }
 #endif //__cplusplus
diff --git a/display_framework/src/extension/weston-6.0/client/main.c b/display_framework/src/extension/weston-6.0/client/main.c
index 6a09831..3d3f0b7 100644
--- a/display_framework/src/extension/weston-6.0/client/main.c
+++ b/display_framework/src/extension/weston-6.0/client/main.c
@@ -26,6 +26,7 @@
     {"raw-cmd", required_argument, 0, 'r'},
     {"G", required_argument, 0, 'G'},
     {"S", required_argument, 0, 'S'},
+    {"debug", optional_argument, 0, 'd'},
     {0, 0, 0, 0}
 };
 
@@ -41,6 +42,7 @@
             "       -s,--set-connector-property \"[Content Protection | Color Depth | Color Space]\"=value\tset connector property\n"
             "       -G \"[ui-rect|display-mode]\"\tget [logic ui rect|display mode]\n"
             "       -S \"[ui-rect]\"\tset [logic ui rect]\n"
+            "       -d  --debug\n"
             "       -r,--raw-cmd           \tsend raw cmd\n", name);
 }
 
@@ -168,6 +170,13 @@
                     send_cmd(client, optarg, NULL, OPT_TYPE_NULL);
                 }
                 break;
+            case 'd':
+                {
+                    int value = 1;
+                    printf("get info for %d frame(s) \n", value);
+                    drm_help_client_get_debug_info(client, value);
+                }
+                break;
             default:
                 print_usage(argv[0]);
         }
diff --git a/display_framework/src/extension/weston-6.0/compositor-drm-help.c b/display_framework/src/extension/weston-6.0/compositor-drm-help.c
index 48a1f30..da55a08 100644
--- a/display_framework/src/extension/weston-6.0/compositor-drm-help.c
+++ b/display_framework/src/extension/weston-6.0/compositor-drm-help.c
@@ -90,6 +90,7 @@
 typedef struct _compositor_interface {
     switch_mode switch_mode;
     force_refresh force_refresh;
+    print_info print_info;
 } compositor_interface;
 
 typedef struct _compositor_output_list {
@@ -121,7 +122,7 @@
 
 compositor_output_list g_output_list = { 0 };
 compositor_interface g_interface = { 0 };
-
+struct weston_compositor* g_compositor = NULL;
 
 helper_task_queue  g_task_after_repaint_cycle = { 0 };
 
@@ -439,9 +440,9 @@
                     DEBUG_INFO("schedule task failed");
                     ret = -1;
                 }
-                else {

-                    help_do_repaint_cycle_completed();

-                }

+                else {
+                    help_do_repaint_cycle_completed();
+                }
                 //trigger a refresh, for the next repaint
                 if (g_interface.force_refresh && g_output_list.data) {
                     //TODO: refresh for need output olny
@@ -586,6 +587,12 @@
         DEBUG_INFO("CMD[%s] not support or incorrect parameter!", cmd);
         //reply a empty json object to avoid client block.
         *data_out = json_object_new_object();
+    } else if (0 == strcmp("get info", cmd)) {
+        errno = 0;
+        int nframes = json_object_get_int(opt);
+        if (errno != 0)
+            DEBUG_INFO("get nframes error:%d", errno);
+        g_interface.print_info(g_compositor, nframes);
     }
     json_object_put(data_in);
     if (ret != 0) {
@@ -934,3 +941,7 @@
     dump_output_status(__func__);
     END_EVENT;
 }
+void help_set_printinfo_function(struct weston_compositor* ec, print_info fun) {
+    g_interface.print_info = fun;
+    g_compositor = ec;
+}
diff --git a/display_framework/src/extension/weston-6.0/compositor-drm-help.h b/display_framework/src/extension/weston-6.0/compositor-drm-help.h
index 453c966..a5e0240 100644
--- a/display_framework/src/extension/weston-6.0/compositor-drm-help.h
+++ b/display_framework/src/extension/weston-6.0/compositor-drm-help.h
@@ -42,6 +42,7 @@
  * it save weston_output for weston
  */
 struct compositor_output;
+struct weston_compositor;
 
 /* For compatible with old version */
 typedef struct compositor_output* output_ctx;
@@ -94,6 +95,8 @@
 
 void help_switch_compositor_output(struct compositor_output* output, bool enable);
 
+typedef void (*print_info)(struct weston_compositor* ec, int count);
+void help_set_printinfo_function(struct weston_compositor* ec , print_info fun);
 #ifdef __cplusplus
 }
 #endif