From adff2d3031547ac6d596346e521bc1502bdee598 Mon Sep 17 00:00:00 2001 From: Boram Park Date: Mon, 29 Aug 2016 14:37:02 +0900 Subject: [PATCH] add -ttrace_vblank option to tdm-monitor Change-Id: I9939c5bd2cca6f2fed1a9cc1f9d518cc5bf068c0 --- src/tdm.c | 50 ++++++++++++++++++++++++++++++++++++++++ src/tdm_monitor_server.c | 49 +++++++++++++++++++++++++++++++++++++++ src/tdm_private.h | 4 ++++ 3 files changed, 103 insertions(+) diff --git a/src/tdm.c b/src/tdm.c index a4dcdf85..550b0436 100644 --- a/src/tdm.c +++ b/src/tdm.c @@ -1172,3 +1172,53 @@ tdm_display_enable_path(const char *path) return TDM_ERROR_NONE; } + + +static void +_tdm_display_ttrace_vblank_cb(tdm_vblank *vblank, tdm_error error, unsigned int sequence, + unsigned int tv_sec, unsigned int tv_usec, void *user_data) +{ + tdm_error ret = TDM_ERROR_NONE; + + TDM_TRACE_COUNT(VBlank, sequence); + + ret = tdm_vblank_wait(vblank, 0, 0, 1, _tdm_display_ttrace_vblank_cb, NULL); + TDM_RETURN_IF_FAIL(ret == TDM_ERROR_NONE); +} + +INTERN tdm_error +tdm_display_enable_ttrace_vblank(tdm_display *dpy, tdm_output *output, int enable) +{ + static tdm_vblank *vblank = NULL; + tdm_error ret = TDM_ERROR_NONE; + + if (!enable) { + if (vblank) + tdm_vblank_destroy(vblank); + vblank = NULL; + return TDM_ERROR_NONE; + } else { + const tdm_output_mode *mode = NULL; + + if (vblank) + return TDM_ERROR_NONE; + + vblank = tdm_vblank_create(dpy, output, &ret); + TDM_RETURN_VAL_IF_FAIL(vblank != NULL, ret); + + ret = tdm_output_get_mode(output, &mode); + TDM_RETURN_VAL_IF_FAIL(mode != NULL, ret); + + ret = tdm_vblank_set_fps(vblank, mode->vrefresh); + TDM_RETURN_VAL_IF_FAIL(ret == TDM_ERROR_NONE, ret); + + ret = tdm_vblank_set_enable_fake(vblank, 1); + TDM_RETURN_VAL_IF_FAIL(ret == TDM_ERROR_NONE, ret); + + ret = tdm_vblank_wait(vblank, 0, 0, 1, _tdm_display_ttrace_vblank_cb, NULL); + TDM_RETURN_VAL_IF_FAIL(ret == TDM_ERROR_NONE, ret); + } + + return TDM_ERROR_NONE; +} + diff --git a/src/tdm_monitor_server.c b/src/tdm_monitor_server.c index 25874ab0..a3e24b4e 100644 --- a/src/tdm_monitor_server.c +++ b/src/tdm_monitor_server.c @@ -86,6 +86,50 @@ _tdm_monitor_server_dpms(unsigned int pid, char *cwd, int argc, char *argv[], ch TDM_SNPRINTF(reply, len, "done: DPMS %s\n", tdm_dpms_str(dpms_value)); } +static void +_tdm_monitor_server_ttrace_vblank(unsigned int pid, char *cwd, int argc, char *argv[], char *reply, int *len, tdm_display *dpy) +{ + int enable, output_id = 0; + tdm_output *output; + const char *name = NULL; + char *arg; + char *end; + tdm_error ret; + tdm_output_type type; + + if (argc < 3) { + _tdm_monitor_server_usage(argv[0], reply, len); + return; + } + + arg = argv[2]; + enable = strtol(arg, &end, 10); + + if (*end == '@') { + arg = end + 1; + output_id = strtol(arg, &end, 10); + } + + output = tdm_display_get_output(dpy, output_id, NULL); + if (!output) { + TDM_SNPRINTF(reply, len, "can't find the output_id(%d)\n", output_id); + return; + } + + ret = tdm_output_get_output_type(output, &type); + if (ret != TDM_ERROR_NONE) { + TDM_SNPRINTF(reply, len, "can't find the type of output_id(%d)\n", output_id); + return; + } + + tdm_output_get_model_info(output, NULL, NULL, &name); + + tdm_display_enable_ttrace_vblank(dpy, output, enable); + + TDM_SNPRINTF(reply, len, "%s ttrace vblank for '%s'\n", + (enable)?"enable":"disable", tdm_conn_str(type)); +} + static void _tdm_monitor_server_debug(unsigned int pid, char *cwd, int argc, char *argv[], char *reply, int *len, tdm_display *dpy) { @@ -278,6 +322,11 @@ static struct { "dpms", _tdm_monitor_server_dpms, "set output dpms", ":", "0:3 or 0:0" }, + { + "ttrace_vblank", _tdm_monitor_server_ttrace_vblank, + "enable/disable the vblank for ttrace [0:disable 1:enable]", + "[@]", "0 or 1" + }, { "debug", _tdm_monitor_server_debug, "set the debug level and modules(module: none, mutex, buffer, thread, vblank)", diff --git a/src/tdm_private.h b/src/tdm_private.h index bc049712..5cfddc75 100644 --- a/src/tdm_private.h +++ b/src/tdm_private.h @@ -89,9 +89,11 @@ extern int tdm_debug_dump; #include #define TDM_TRACE_BEGIN(NAME) traceBegin(TTRACE_TAG_GRAPHICS, "TDM:"#NAME) #define TDM_TRACE_END() traceEnd(TTRACE_TAG_GRAPHICS) +#define TDM_TRACE_COUNT(NAME, COUNT) traceCounter(TTRACE_TAG_GRAPHICS, COUNT, "TDM:"#NAME) #else #define TDM_TRACE_BEGIN(NAME) #define TDM_TRACE_END() +#define TDM_TRACE_COUNT(NAME, COUNT) #endif typedef enum { @@ -575,6 +577,8 @@ tdm_error tdm_display_enable_dump(tdm_private_display *private_display, const char *dump_str, char *reply, int *len); tdm_error tdm_display_enable_path(const char *path); +tdm_error +tdm_display_enable_ttrace_vblank(tdm_display *dpy, tdm_output *output, int enable); /** * @brief The tdm vblank object -- 2.34.1