*
**************************************************************************/
-#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(unsigned int pid, char *cwd, int argc, char *argv[], char *reply, int *len, tdm_display *dpy)
+{
+ int output_id = 0;
+ char *end;
+ tdm_error ret;
+
+ if (argc < 3) {
+ _tdm_monitor_server_usage(argv[0], reply, len);
+ return;
+ }
+
+ if (argv[3])
+ output_id = strtol(argv[3], &end, 10);
+
+ ret = tdm_display_enable_ttrace(dpy, argv[2], output_id, reply, len);
+ TDM_DBG_RETURN_IF_FAIL(ret == TDM_ERROR_NONE);
+}
+
+static void
_tdm_monitor_server_debug(unsigned int pid, char *cwd, int argc, char *argv[], char *reply, int *len, tdm_display *dpy)
{
int level;
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_choose_commit_per_vblank_mode(unsigned int pid, char *cwd, int argc, char *argv[], char *reply, int *len, tdm_display *dpy)
+{
+ int output_idx;
+ int mode;
+ char *arg;
+ char *end;
+ tdm_error err;
+
+ /* 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];
+ output_idx = strtol(arg, &end, 10);
+
+ arg = argv[3];
+ mode = strtol(arg, &end, 10);
+
+ 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, "the mode's been set\n");
+}
+
+static void
+_tdm_monitor_server_fps(unsigned int pid, char *cwd, int argc, char *argv[], char *reply, int *len, tdm_display *dpy)
+{
+ int enable;
+ char *arg;
+ char *end;
+
+ if (argc < 3) {
+ _tdm_monitor_server_usage(argv[0], reply, len);
+ return;
+ }
+
+ arg = argv[2];
+ enable = strtol(arg, &end, 10);
+
+ tdm_display_enable_fps(dpy, enable);
+
+ TDM_SNPRINTF(reply, len, "%s to print fps\n", (enable) ? "enable" : "disable");
+}
+
+static void
+_tdm_monitor_server_vblank_list(unsigned int pid, char *cwd, int argc, char *argv[],
+ char *reply, int *len, tdm_display *dpy)
+{
+ tdm_vblank_get_vblank_list_information(dpy, reply, len);
+}
+
+static void
+_tdm_monitor_server_vblank_fps(unsigned int pid, char *cwd, int argc, char *argv[],
+ char *reply, int *len, tdm_display *dpy)
+{
+ unsigned int target_pid, fps;
+ char *arg;
+ char *end;
+ char name[TDM_NAME_LEN];
+ tdm_error ret;
+
+ if (argc < 3) {
+ _tdm_monitor_server_usage(argv[0], reply, len);
+ return;
+ }
+
+ arg = argv[2];
+ target_pid = strtol(arg, &end, 10);
+
+ if (*end == ',') {
+ arg = end + 1;
+ end = strtostr(name, TDM_NAME_LEN, arg, TDM_DELIM);
+ } else {
+ strncpy(name, TDM_VBLANK_DEFAULT_NAME, TDM_NAME_LEN - 1);
+ name[TDM_NAME_LEN - 1] = '\0';
+ }
+
+ if (*end != '@') {
+ TDM_SNPRINTF(reply, len, "failed: no fps value\n");
+ return;
+ }
+
+ arg = end + 1;
+ fps = strtol(arg, &end, 10);
+
+ ret = tdm_vblank_set_client_vblank_fps(target_pid, name, fps);
+ if (ret != TDM_ERROR_NONE) {
+ TDM_SNPRINTF(reply, len, "can't set '%u' fps to '%s' client vblank(PID:%u)\n", fps, name, target_pid);
+ return;
+ }
+
+ TDM_SNPRINTF(reply, len, "success: '%u' fps for '%s' client vblank(PID:%u)\n", fps, name, target_pid);
+}
+
+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;
tdm_display_enable_dump(dpy, (const char*)argv[2], reply, len);
}
+static void
+_tdm_monitor_server_punch(unsigned int pid, char *cwd, int argc, char *argv[], char *reply, int *len, tdm_display *dpy)
+{
+ char *arg, *end;
+ unsigned int output_id, layer_id;
+ tdm_output *output;
+ tdm_layer *layer;
+ tbm_surface_h buffer;
+
+ arg = argv[2];
+
+ output_id = strtol(arg, &end, 10);
+ output = tdm_display_get_output(dpy, output_id, NULL);
+ if (!output) {
+ TDM_SNPRINTF(reply, len, "not found output\n");
+ return;
+ }
+ if (*end != ',') {
+ TDM_SNPRINTF(reply, len, "not found ',<layer_idx>'\n");
+ return;
+ }
+
+ arg = end + 1;
+ layer_id = strtol(arg, &end, 10);
+ layer = tdm_output_get_layer(output, layer_id, NULL);
+ if (!layer) {
+ TDM_SNPRINTF(reply, len, "not found layer\n");
+ return;
+ }
+
+ buffer = tdm_layer_get_displaying_buffer(layer, NULL);
+ if (!buffer) {
+ TDM_SNPRINTF(reply, len, "not found buffer\n");
+ return;
+ }
+
+ if (*end == ':') {
+ tdm_pos pos = {0,};
+
+ arg = end + 1;
+ pos.w = strtol(arg, &end, 10);
+ TDM_EXIT_IF_FAIL(*end == 'x');
+ arg = end + 1;
+ pos.h = strtol(arg, &end, 10);
+ if (*end == '+') {
+ arg = end + 1;
+ pos.x = strtol(arg, &end, 10);
+ TDM_EXIT_IF_FAIL(*end == '+');
+ arg = end + 1;
+ pos.y = strtol(arg, &end, 10);
+ }
+
+ tdm_helper_clear_buffer_pos(buffer, &pos);
+ } else
+ tdm_helper_clear_buffer(buffer);
+}
+
static struct {
const char *opt;
void (*func)(unsigned int pid, char *cwd, int argc, char *argv[], char *reply, int *len, tdm_display *dpy);
"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", _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,
"set the debug level and modules(module: none, mutex, buffer, thread, vblank)",
"<level>[@<module1>[,<module2>]]",
"console"
},
{
+ "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,
+ "enable/disable to print fps",
+ "<enable>",
+ "0 or 1"
+ },
+ {
+ "vblank_list", _tdm_monitor_server_vblank_list,
+ "print the client vblank list",
+ NULL,
+ NULL
+ },
+ {
+ "vblank_fps", _tdm_monitor_server_vblank_fps,
+ "set the client vblank fps for the given process ID and client vblank name",
+ "<pid>[,<vblank_name>]@<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>",
"\t\t layer, pp, capture - start to dump buffers of layer, pp, capture\n"
"\t\t none - stop to dump buffers\n"
"\t\t current - dump the current buffer of all layers",
- "<object_type1>[,<object_type2>[,...]]@[<directory_path>]",
+ "<object_type1>[,<object_type2>[,...]][@<directory_path>]",
+ NULL
+ },
+ {
+ "punch", _tdm_monitor_server_punch,
+ "punch a layer",
+ "<output_idx>,<layer_idx>[:<w>x<h>[+<x>+<y>]]",
NULL
},
};
_tdm_monitor_server_command(pid, cwd, dpy, argc, argv, reply, len);
}
+/* LCOV_EXCL_STOP */