-INTERN int
-tdm_display_check_module_abi(tdm_private_display *private_display, int abimaj, int abimin)
-{
- tdm_backend_module *module = private_display->module_data;
-
- if (TDM_BACKEND_GET_ABI_MAJOR(module->abi_version) < abimaj)
- return 0;
-
- if (TDM_BACKEND_GET_ABI_MINOR(module->abi_version) < abimin)
- return 0;
-
- return 1;
-}
-
-INTERN tdm_error
-tdm_display_enable_debug_module(const char*modules)
-{
- char temp[TDM_PATH_LEN];
- char *arg;
- char *end;
-
- snprintf(temp, TDM_PATH_LEN, "%s", modules);
-
- tdm_debug_module = 0;
-
- arg = strtok_r(temp, TDM_DELIM, &end);
- while (arg) {
- if (!strncmp(arg, "none", 4)) {
- tdm_debug_module = 0;
- return TDM_ERROR_NONE;
- }
- if (!strncmp(arg, "all", 3)) {
- tdm_debug_module = 0xFFFFFFFF;
- return TDM_ERROR_NONE;
- }
- if (!strncmp(arg, "buffer", 6))
- tdm_debug_module |= TDM_DEBUG_BUFFER;
- else if (!strncmp(arg, "thread", 6))
- tdm_debug_module |= TDM_DEBUG_THREAD;
- else if (!strncmp(arg, "mutex", 5))
- tdm_debug_module |= TDM_DEBUG_MUTEX;
- else if (!strncmp(arg, "vblank", 6))
- tdm_debug_module |= TDM_DEBUG_VBLANK;
- else if (!strncmp(arg, "commit", 6))
- tdm_debug_module |= TDM_DEBUG_COMMIT;
-
- arg = strtok_r(NULL, TDM_DELIM, &end);
- }
-
- TDM_INFO("module debugging... '%s'", modules);
-
- return TDM_ERROR_NONE;
-}
-
-INTERN tdm_error
-tdm_display_enable_dump(tdm_private_display *private_display, const char *dump_str, char *reply, int *len)
-{
- char temp[TDM_PATH_LEN] = {0,}, temp2[TDM_PATH_LEN] = {0,};
- char *path = NULL, *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++;
-
- tdm_debug_dump = 0;
-
- snprintf(temp, sizeof(temp), "%s", dump_str);
- arg = strtok_r(temp, ",", &end);
- TDM_GOTO_IF_FAIL(arg != NULL, done);
-
- if (!strncmp(arg, "none", 4)) {
- tdm_debug_dump = 0;
- TDM_SNPRINTF(reply, len, "path: %s\n", (tdm_debug_dump_dir) ? : "unknown");
- if (tdm_debug_dump_dir) {
- free(tdm_debug_dump_dir);
- tdm_debug_dump_dir = NULL;
- }
- goto done;
- }
-
- path = tdm_helper_dump_make_directory(path2, reply, len);
- TDM_GOTO_IF_FAIL(path != NULL, 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 || l->caps.capabilities & TDM_LAYER_CAPABILITY_VIDEO)
- continue;
- if (!l->showing_buffer)
- continue;
- snprintf(str, TDM_PATH_LEN, "layer_%d_%d", o->index, l->index);
- tdm_helper_dump_buffer_str(l->showing_buffer->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;
- goto done;
- } else if (!strncmp(arg, "layer", 5)) {
- tdm_debug_dump |= TDM_DUMP_FLAG_LAYER;
- } else if (!strncmp(arg, "pp", 2)) {
- tdm_debug_dump |= TDM_DUMP_FLAG_PP;
- } else if (!strncmp(arg, "capture", 7)) {
- tdm_debug_dump |= TDM_DUMP_FLAG_CAPTURE;
- } else if (!strncmp(arg, "window", 6)) {
- tdm_debug_dump |= TDM_DUMP_FLAG_WINDOW;
- } 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:
- if (path)
- free(path);
-
- return TDM_ERROR_NONE;
-}
-
-INTERN tdm_error
-tdm_display_enable_path(const char *path)
-{
- static int old_stdout = -1;
- char fd_name[TDM_PATH_LEN];
- int log_fd = -1;
- FILE *log_fl;
-
- if (old_stdout == -1)
- old_stdout = dup(STDOUT_FILENO);
-
- tdm_log_enable_dlog(0);
-
- snprintf(fd_name, TDM_PATH_LEN, "%s", path);
-
- log_fl = fopen(fd_name, "a");
- if (!log_fl) {
- TDM_ERR("failed: open file(%s)\n", fd_name);
- return TDM_ERROR_OPERATION_FAILED;
- }
-
- fflush(stderr);
- close(STDOUT_FILENO);
-
- setvbuf(log_fl, NULL, _IOLBF, 512);
- log_fd = fileno(log_fl);
-
- dup2(log_fd, STDOUT_FILENO);
- fclose(log_fl);
-
- 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_MARK(VBlank);
-
- 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_GOTO_IF_FAIL(mode != NULL, enable_fail);
-
- ret = tdm_vblank_set_fps(vblank, mode->vrefresh);
- TDM_GOTO_IF_FAIL(ret == TDM_ERROR_NONE, enable_fail);
-
- ret = tdm_vblank_set_enable_fake(vblank, 1);
- TDM_GOTO_IF_FAIL(ret == TDM_ERROR_NONE, enable_fail);
-
- ret = tdm_vblank_wait(vblank, 0, 0, 1, _tdm_display_ttrace_vblank_cb, NULL);
- TDM_GOTO_IF_FAIL(ret == TDM_ERROR_NONE, enable_fail);
- }
-
- return TDM_ERROR_NONE;
-
-enable_fail:
- if (vblank)
- tdm_vblank_destroy(vblank);
- vblank = NULL;
- return ret;
-}
-
-INTERN tdm_error
-tdm_display_enable_commit_per_vblank(tdm_private_display *private_display, int enable)