return g_private_display;
}
+ private_display = calloc(1, sizeof(tdm_private_display));
+ if (!private_display) {
+ ret = TDM_ERROR_OUT_OF_MEMORY;
+ TDM_ERR("'private_display != NULL' failed");
+ goto failed_alloc;
+ }
+
debug = getenv("TDM_DEBUG_MODULE");
if (debug)
tdm_display_enable_debug_module(debug);
debug = getenv("TDM_DEBUG_DUMP");
if (debug)
- tdm_display_enable_dump(debug);
+ tdm_display_enable_dump(private_display, debug, NULL, NULL);
debug = getenv("TDM_DEBUG_PATH");
if (debug)
tdm_display_enable_path(debug);
- private_display = calloc(1, sizeof(tdm_private_display));
- if (!private_display) {
- ret = TDM_ERROR_OUT_OF_MEMORY;
- TDM_ERR("'private_display != NULL' failed");
- goto failed_alloc;
- }
-
if (pthread_mutex_init(&private_display->lock, NULL)) {
ret = TDM_ERROR_OPERATION_FAILED;
TDM_ERR("mutex init failed: %m");
}
INTERN tdm_error
-tdm_display_enable_dump(const char *dump_str)
+tdm_display_enable_dump(tdm_private_display *private_display, const char *dump_str, char *reply, int *len)
{
- char temp[1024];
+ char temp[TDM_PATH_LEN] = {0,}, temp2[TDM_PATH_LEN] = {0,};
+ char *path, *path2;
char *arg;
char *end;
+ snprintf(temp2, TDM_PATH_LEN, "%s", dump_str);
+ path2 = strtostr(temp, TDM_PATH_LEN, temp2, "@");
+ if (!path2 || path2[0] == '\0')
+ path2 = TDM_DUMP_DIR;
+ else
+ path2++;
+
+ path = tdm_helper_dump_make_directory(path2, reply, len);
+ TDM_GOTO_IF_FAIL(path != NULL, done);
+
tdm_debug_dump = 0;
snprintf(temp, sizeof(temp), "%s", dump_str);
arg = strtok_r(temp, ",", &end);
- while (arg) {
- if (!strncmp(arg, "none", 4)) {
- tdm_debug_dump = 0;
- return TDM_ERROR_NONE;
+
+ if (!strncmp(arg, "none", 4)) {
+ tdm_debug_dump = 0;
+ if (tdm_debug_dump_dir) {
+ free(tdm_debug_dump_dir);
+ tdm_debug_dump_dir = NULL;
}
+ TDM_SNPRINTF(reply, len, "path: %s\n", path);
+ goto done;
+ }
+
+ if (!strncmp(arg, "current", 7)) {
+ tdm_private_output *o = NULL;
+ if (!private_display) {
+ TDM_WRN("no private_display");
+ goto done;
+ }
+
+ LIST_FOR_EACH_ENTRY(o, &private_display->output_list, link) {
+ tdm_private_layer *l = NULL;
+ LIST_FOR_EACH_ENTRY(l, &o->layer_list, link) {
+ char str[TDM_PATH_LEN];
+ if (l->usable)
+ continue;
+ snprintf(str, TDM_PATH_LEN, "layer_%d_%d", o->index, l->index);
+ tdm_helper_dump_buffer_str(l->showing_buffer, path, str);
+ }
+ }
+
+ TDM_SNPRINTF(reply, len, "path: %s\n", path);
+ goto done;
+ }
+
+ TDM_SNPRINTF(reply, len, "dump: %s\n", arg);
+
+ while (arg) {
if (!strncmp(arg, "all", 3)) {
tdm_debug_dump = 0xFFFFFFFF;
- return TDM_ERROR_NONE;
- }
- if (!strncmp(arg, "layer", 5))
+ goto done;
+ } else if (!strncmp(arg, "layer", 5)) {
tdm_debug_dump |= TDM_DUMP_FLAG_LAYER;
- else if (!strncmp(arg, "pp", 2))
+ } else if (!strncmp(arg, "pp", 2)) {
tdm_debug_dump |= TDM_DUMP_FLAG_PP;
- else if (!strncmp(arg, "capture", 7))
+ } else if (!strncmp(arg, "capture", 7)) {
tdm_debug_dump |= TDM_DUMP_FLAG_CAPTURE;
- else
- return TDM_ERROR_BAD_REQUEST;
+ } else
+ goto done;
arg = strtok_r(NULL, ",", &end);
}
+ if (tdm_debug_dump_dir)
+ free(tdm_debug_dump_dir);
+
+ tdm_debug_dump_dir = strndup(path, TDM_PATH_LEN);
+
TDM_INFO("dump... '%s'", dump_str);
+done:
+ free(path);
return TDM_ERROR_NONE;
}
char str[TDM_PATH_LEN];
static int i;
snprintf(str, TDM_PATH_LEN, "capture_%03d", i++);
- tdm_helper_dump_buffer_str(buffer, str);
+ tdm_helper_dump_buffer_str(buffer, tdm_debug_dump_dir, str);
}
if (tdm_debug_module & TDM_DEBUG_BUFFER)
char str[TDM_PATH_LEN];
static int i;
snprintf(str, TDM_PATH_LEN, "layer_%d_%d_%03d",
- private_output->pipe, private_layer->caps.zpos, i++);
- tdm_helper_dump_buffer_str(buffer, str);
+ private_output->index, private_layer->index, i++);
+ tdm_helper_dump_buffer_str(buffer, tdm_debug_dump_dir, str);
}
func_layer = &private_display->func_layer;
static const char *file_exts[2] = {"png", "yuv"};
int tdm_dump_enable;
+char *tdm_debug_dump_dir;
INTERN unsigned long
tdm_helper_get_time_in_millis(void)
fclose(fp);
}
+INTERN char *
+tdm_helper_dump_make_directory(const char *path, char *reply, int *len)
+{
+ char *fullpath = NULL;
+ time_t timer;
+ struct tm *t, *buf = NULL;
+
+ timer = time(NULL);
+
+ buf = calloc(1, sizeof (struct tm));
+ TDM_GOTO_IF_FAIL(buf != NULL, failed_make);
+
+ fullpath = calloc(1, TDM_PATH_LEN * sizeof(char));
+ TDM_GOTO_IF_FAIL(fullpath != NULL, failed_make);
+
+ t = localtime_r(&timer, buf);
+ TDM_GOTO_IF_FAIL(t != NULL, failed_make);
+
+ snprintf(fullpath, TDM_PATH_LEN, "%s/dump_%04d%02d%02d.%02d%02d%02d", path,
+ t->tm_year+1900, t->tm_mon+1, t->tm_mday, t->tm_hour, t->tm_min, t->tm_sec);
+
+ if ((mkdir(fullpath, 0755)) < 0) {
+ TDM_ERR("mkdir '%s' fail\n", fullpath);
+ TDM_SNPRINTF(reply, len, "mkdir '%s' fail\n", fullpath);
+ goto failed_make;
+ }
+
+ free(buf);
+
+ return fullpath;
+failed_make:
+ if (fullpath)
+ free(fullpath);
+ if (buf)
+ free(buf);
+ return NULL;
+}
+
INTERN void
-tdm_helper_dump_buffer_str(tbm_surface_h buffer, const char *str)
+tdm_helper_dump_buffer_str(tbm_surface_h buffer, char *dir, char *str)
{
tbm_surface_info_s info;
- const char *dir = "/tmp/dump-tdm";
const char *ext;
char file[TDM_PATH_LEN];
int ret, bw;
TDM_RETURN_IF_FAIL(buffer != NULL);
TDM_RETURN_IF_FAIL(str != NULL);
+ if (!dir) {
+ dir = tdm_helper_dump_make_directory(TDM_DUMP_DIR, NULL, NULL);
+ TDM_RETURN_IF_FAIL(dir != NULL);
+ }
+
ret = tbm_surface_get_info(buffer, &info);
TDM_RETURN_IF_FAIL(ret == TBM_SURFACE_ERROR_NONE);
return;
}
- tdm_display_enable_dump((const char*)argv[2]);
-
- TDM_SNPRINTF(reply, len, "%s done\n", argv[2]);
+ tdm_display_enable_dump(dpy, (const char*)argv[2], reply, len);
}
static struct {
},
{
"debug", _tdm_monitor_server_debug,
- "set the debug level and modules(none,mutex,buffer,thread,vblank)",
+ "set the debug level and modules(module: none, mutex, buffer, thread, vblank)",
"<level>[@<module1>[,<module2>]]",
NULL
},
},
{
"dump", _tdm_monitor_server_dump,
- "dump buffers (type: layer, pp, capture, none)",
- "<object_type1>[,<object_type2>[,...]]",
+ "dump buffers (type: none, layer, pp, capture, current)\n"
+ "\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>]",
NULL
},
};
char str[TDM_PATH_LEN];
static int i;
snprintf(str, TDM_PATH_LEN, "pp_dst_%03d", i++);
- tdm_helper_dump_buffer_str(dst, str);
+ tdm_helper_dump_buffer_str(dst, tdm_debug_dump_dir, str);
}
if (tdm_debug_module & TDM_DEBUG_BUFFER)
char str[TDM_PATH_LEN];
static int i;
snprintf(str, TDM_PATH_LEN, "pp_src_%03d", i++);
- tdm_helper_dump_buffer_str(src, str);
+ tdm_helper_dump_buffer_str(src, tdm_debug_dump_dir, str);
}
pp_buffer = calloc(1, sizeof *pp_buffer);
TDM_DUMP_FLAG_CAPTURE = (1 << 2),
};
+#define TDM_DUMP_DIR "/tmp"
+
typedef struct _tdm_private_display tdm_private_display;
typedef struct _tdm_private_output tdm_private_output;
typedef struct _tdm_private_layer tdm_private_layer;
void
tdm_server_deinit(tdm_private_loop *private_loop);
+char *
+tdm_helper_dump_make_directory(const char *path, char *reply, int *len);
void
-tdm_helper_dump_buffer_str(tbm_surface_h buffer, const char *str);
+tdm_helper_dump_buffer_str(tbm_surface_h buffer, char *dir, char *str);
unsigned long
tdm_helper_get_time_in_millis(void);
unsigned long
extern pthread_mutex_t tdm_mutex_check_lock;
extern int tdm_mutex_locked;
extern int tdm_dump_enable;
+extern char *tdm_debug_dump_dir;
#define _pthread_mutex_unlock(l) \
do { \
tdm_error
tdm_display_enable_debug_module(const char*modules);
tdm_error
-tdm_display_enable_dump(const char *dump_str);
+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);