*
**************************************************************************/
-#include <stdio.h>
-#include <string.h>
-#include <stdlib.h>
-#include <stdint.h>
-
-#include "tdm.h"
#include "tdm_private.h"
-#include "tdm_helper.h"
-#include "tdm_log.h"
#define TDM_DBG_SERVER_ARGS_MAX 32
+/* LCOV_EXCL_START */
static void _tdm_monitor_server_usage(char *app_name, char *reply, int *len);
static void
_tdm_monitor_server_query(unsigned int pid, char *cwd, int argc, char *argv[], char *reply, int *len, tdm_display *dpy)
{
+ tdm_display_lock(dpy);
tdm_helper_get_display_information(dpy, reply, len);
+ tdm_display_unlock(dpy);
+}
+
+static void
+_tdm_monitor_server_protocol_trace(unsigned int pid, char *cwd, int argc, char *argv[], char *reply, int *len, tdm_display *dpy)
+{
+ int enable;
+
+ if (argc < 3) {
+ _tdm_monitor_server_usage(argv[0], reply, len);
+ return;
+ }
+
+ enable = atoi(argv[2]);
+
+ tdm_event_loop_trace_enable(dpy, enable);
+
+ TDM_SNPRINTF(reply, len, "protocol trace: '%s'\n", (enable) ? "enabled" : "disabled");
}
static void
}
static void
-_tdm_monitor_server_ttrace_vblank(unsigned int pid, char *cwd, int argc, char *argv[], char *reply, int *len, tdm_display *dpy)
+_tdm_monitor_server_ttrace(unsigned int pid, char *cwd, int argc, char *argv[], char *reply, int *len, tdm_display *dpy)
{
- int enable, output_id = 0;
- tdm_output *output;
- char *arg;
+ int output_id = 0;
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_display_enable_ttrace_vblank(dpy, output, enable);
+ if (argv[3])
+ output_id = strtol(argv[3], &end, 10);
- TDM_SNPRINTF(reply, len, "%s ttrace vblank for '%s'\n",
- (enable) ? "enable" : "disable", tdm_conn_str(type));
+ ret = tdm_display_enable_ttrace(dpy, argv[2], output_id, reply, len);
+ TDM_DBG_RETURN_IF_FAIL(ret == TDM_ERROR_NONE);
}
static void
tdm_log_enable_color(0);
}
- if (tdm_display_enable_path((const char*)fd_name) != TDM_ERROR_NONE) {
- TDM_SNPRINTF(reply, len, "failed: '%s'\n", path);
- return;
- }
+ tdm_log_set_path((const char*)fd_name);
done:
TDM_SNPRINTF(reply, len, "log path: '%s'\n", path);
}
static void
-_tdm_monitor_server_commit_per_vblank(unsigned int pid, char *cwd, int argc, char *argv[], char *reply, int *len, tdm_display *dpy)
+_tdm_monitor_server_choose_commit_per_vblank_mode(unsigned int pid, char *cwd, int argc, char *argv[], char *reply, int *len, tdm_display *dpy)
{
- int enable;
+ int output_idx;
+ int mode;
char *arg;
char *end;
+ tdm_error err;
- if (argc < 3) {
+ /* TODO: do we have to provide an ability to choose commit_per_vblank mode outside? */
+
+ if (argc < 4) {
_tdm_monitor_server_usage(argv[0], reply, len);
return;
}
arg = argv[2];
- enable = strtol(arg, &end, 10);
+ output_idx = strtol(arg, &end, 10);
+
+ arg = argv[3];
+ mode = strtol(arg, &end, 10);
- tdm_display_enable_commit_per_vblank(dpy, enable);
+ err = tdm_output_choose_commit_per_vblank_mode(tdm_display_get_output(dpy, output_idx, NULL), mode);
+ if (err != TDM_ERROR_NONE) {
+ TDM_SNPRINTF(reply, len, "an error: output_idx or mode is wrong\n");
+ return;
+ }
- TDM_SNPRINTF(reply, len, "%s the commit-per-vblank\n", (enable) ? "enable" : "disable");
+ TDM_SNPRINTF(reply, len, "the mode's been set\n");
}
static void
}
static void
+_tdm_monitor_server_global_fps(unsigned int pid, char *cwd, int argc, char *argv[],
+ char *reply, int *len, tdm_display *dpy)
+{
+ unsigned int fps;
+ char *arg;
+ char *end;
+ tdm_error ret;
+
+ if (argc < 3) {
+ _tdm_monitor_server_usage(argv[0], reply, len);
+ return;
+ }
+
+ arg = argv[2];
+ fps = strtol(arg, &end, 10);
+
+ if (fps > 0)
+ ret = tdm_vblank_enable_global_fps(1, fps);
+ else
+ ret = tdm_vblank_enable_global_fps(0, 0);
+
+ if (ret != TDM_ERROR_NONE) {
+ TDM_SNPRINTF(reply, len, "can't set '%u' fps to global fps\n", fps);
+ return;
+ }
+
+ TDM_SNPRINTF(reply, len, "success: '%u' global fps\n", fps);
+}
+
+static void
_tdm_monitor_server_prop(unsigned int pid, char *cwd, int argc, char *argv[], char *reply, int *len, tdm_display *dpy)
{
tdm_output *output;
"show tdm output, layer information", NULL, NULL
},
{
+ "trace", _tdm_monitor_server_protocol_trace,
+ "enable/disable the wl protocol",
+ "<enable>",
+ "0 or 1"
+ },
+ {
"dpms", _tdm_monitor_server_dpms,
"set output dpms", "<output_idx>:<dpms>", "0:3 or 0:0"
},
{
- "ttrace_vblank", _tdm_monitor_server_ttrace_vblank,
- "enable/disable the vblank for ttrace [0:disable 1:enable]",
- "<enable>[@<output_idx>]", "0 or 1"
+ "ttrace", _tdm_monitor_server_ttrace,
+ "enable/disable ttrace (module: none,vsync,client_vblank,server_vblank,vblank,layer,pp,capture,all",
+ "<module>[@<output_idx>]",
+ NULL
},
{
"debug", _tdm_monitor_server_debug,
"console"
},
{
- "commit_per_vblank", _tdm_monitor_server_commit_per_vblank,
- "enable/disable the commit per vblank",
- "<enable>",
- "0 or 1"
+ "choose_commit_per_vblank_mode", _tdm_monitor_server_choose_commit_per_vblank_mode,
+ "choose a commit_per_vblank mode for the output",
+ "<output_idx> <mode>",
+ "0 1 or 1 2 or 2 0"
},
{
"fps", _tdm_monitor_server_fps,
NULL
},
{
+ "global_fps", _tdm_monitor_server_global_fps,
+ "set the global vblank fps for the entire system",
+ "<fps>",
+ NULL
+ },
+ {
"prop", _tdm_monitor_server_prop,
"set the property of a output or a layer",
"<output_idx>[,<layer_idx>]:<prop_name>,<value>",
_tdm_monitor_server_command(pid, cwd, dpy, argc, argv, reply, len);
}
+/* LCOV_EXCL_STOP */