X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=src%2Ftdm_display.c;h=d2fcde4523f977966b7924e49e0c9a16dc2a036e;hb=d5c10eca115610d5b5b85152bccbc22c96e47267;hp=ff605e27f4f753e8055bc7a54b5abfed39126c68;hpb=7d6d085e992322f66c2610a3006f173c0acdde25;p=platform%2Fcore%2Fuifw%2Flibtdm.git diff --git a/src/tdm_display.c b/src/tdm_display.c index ff605e2..d2fcde4 100644 --- a/src/tdm_display.c +++ b/src/tdm_display.c @@ -9,7 +9,7 @@ * Taeheon Kim , * YoungJun Cho , * SooChan Lim , - * Boram Park + * Boram Park * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the @@ -45,14 +45,12 @@ tdm_private_display *private_display; \ tdm_error ret = TDM_ERROR_NONE; /* default TDM_ERROR_NONE */\ TDM_RETURN_VAL_IF_FAIL(dpy != NULL, TDM_ERROR_INVALID_PARAMETER); \ - TDM_RETURN_VAL_IF_FAIL(tdm_display_is_valid(dpy), TDM_ERROR_INVALID_PARAMETER); \ private_display = (tdm_private_display*)dpy; #define DISPLAY_FUNC_ENTRY_ERROR() \ tdm_private_display *private_display; \ tdm_error ret = TDM_ERROR_NONE; /* default TDM_ERROR_NONE */\ TDM_RETURN_VAL_IF_FAIL_WITH_ERROR(dpy != NULL, TDM_ERROR_INVALID_PARAMETER, NULL); \ - TDM_RETURN_VAL_IF_FAIL_WITH_ERROR(tdm_display_is_valid(dpy), TDM_ERROR_INVALID_PARAMETER, NULL); \ private_display = (tdm_private_display*)dpy; #define BACKEND_FUNC_ENTRY() \ @@ -63,6 +61,292 @@ private_module = (tdm_private_module*)module; \ private_display = private_module->private_display; +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_CONFIG_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, "event", 5)) + tdm_debug_module |= TDM_DEBUG_EVENT; + 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_CONFIG_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_module *b = NULL; + tdm_private_output *o = NULL; + + if (!private_display) { + TDM_WRN("no private_display"); + goto done; + } + + LIST_FOR_EACH_ENTRY(b, &private_display->module_list, link) { + LIST_FOR_EACH_ENTRY(o, &b->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; +} + +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("VSYNC"); + + 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) +{ + tdm_private_display *private_display = dpy; + tdm_private_module *private_module = NULL; + tdm_private_output *private_output = NULL; + const tdm_output_mode *mode = NULL; + tdm_vblank *vblank = NULL; + tdm_error ret = TDM_ERROR_NONE; + + if (!enable) { + LIST_FOR_EACH_ENTRY(private_module, &private_display->module_list, link) { + LIST_FOR_EACH_ENTRY(private_output, &private_module->output_list, link) { + if (private_output->ttrace_vblank) + tdm_vblank_destroy(private_output->ttrace_vblank); + private_output->ttrace_vblank = NULL; + } + } + return TDM_ERROR_NONE; + } + + private_output = output; + TDM_RETURN_VAL_IF_FAIL(private_output != NULL, TDM_ERROR_INVALID_PARAMETER); + + if (private_output->ttrace_vblank) + return TDM_ERROR_NONE; + + vblank = tdm_vblank_create(private_display, 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); + + private_output->ttrace_vblank = vblank; + + return TDM_ERROR_NONE; + +enable_fail: + if (vblank) + tdm_vblank_destroy(vblank); + + return ret; +} + +INTERN tdm_error +tdm_display_enable_ttrace(tdm_private_display *private_display, const char *ttrace, int output_id, char *reply, int *len) +{ + char temp[TDM_PATH_LEN]; + char *arg; + char *end; + tdm_output *output; + tdm_error ret; + tdm_output_type type; + + snprintf(temp, TDM_PATH_LEN, "%s", ttrace); + + tdm_ttrace_output = output_id; + tdm_ttrace_module = 0; + + output = tdm_display_get_output(private_display, output_id, &ret); + if (!output) { + TDM_SNPRINTF(reply, len, "can't find the output_id(%d)\n", output_id); + return ret; + } + + 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 ret; + } + + arg = strtok_r(temp, TDM_CONFIG_DELIM, &end); + while (arg) { + if (!strncmp(arg, "none", 4)) + tdm_ttrace_module = 0; + else if (!strncmp(arg, "all", 3)) + tdm_ttrace_module = 0xFFFFFFFF; + else if (!strncmp(arg, "vsync", 5)) + tdm_ttrace_module |= TDM_TTRACE_VSYNC; + else if (!strncmp(arg, "client_vblank", 13)) + tdm_ttrace_module |= TDM_TTRACE_CLIENT_VBLANK; + else if (!strncmp(arg, "server_vblank", 13)) + tdm_ttrace_module |= TDM_TTRACE_SERVER_VBLANK; + else if (!strncmp(arg, "vblank", 6)) + tdm_ttrace_module |= TDM_TTRACE_VBLANK; + else if (!strncmp(arg, "layer", 5)) + tdm_ttrace_module |= TDM_TTRACE_LAYER; + else if (!strncmp(arg, "pp", 2)) + tdm_ttrace_module |= TDM_TTRACE_PP; + else if (!strncmp(arg, "capture", 7)) + tdm_ttrace_module |= TDM_TTRACE_CAPTURE; + else { + tdm_ttrace_module = 0; + tdm_display_enable_ttrace_vblank(private_display, NULL, 0); + tdm_server_enable_ttrace_client_vblank(private_display, NULL, 0); + TDM_SNPRINTF(reply, len, "unknown option: '%s'\n", arg); + return TDM_ERROR_NONE; + } + + arg = strtok_r(NULL, TDM_CONFIG_DELIM, &end); + } + + TDM_SNPRINTF(reply, len, "ttrace debugging... '%s' %x\n", ttrace, tdm_ttrace_module); + + if (tdm_ttrace_module & TDM_TTRACE_VSYNC) + tdm_display_enable_ttrace_vblank(private_display, output, 1); + else + tdm_display_enable_ttrace_vblank(private_display, NULL, 0); + + if (tdm_ttrace_module & TDM_TTRACE_CLIENT_VBLANK) + tdm_server_enable_ttrace_client_vblank(private_display, output, 1); + else + tdm_server_enable_ttrace_client_vblank(private_display, NULL, 0); + + return TDM_ERROR_NONE; +} + +INTERN tdm_error +tdm_display_enable_fps(tdm_private_display *private_display, int enable) +{ + private_display->print_fps = enable; + + TDM_INFO("print fps: %s", (enable) ? "enable" : "disable"); + + return TDM_ERROR_NONE; +} + EXTERN tdm_error tdm_display_get_capabilities(tdm_display *dpy, tdm_display_capability *capabilities) @@ -485,6 +769,22 @@ tdm_display_get_backend_info(tdm_display *dpy, const char **name, return ret; } +EXTERN tdm_pp * +tdm_display_create_pp(tdm_display *dpy, tdm_error *error) +{ + tdm_pp *pp; + + DISPLAY_FUNC_ENTRY_ERROR(); + + _pthread_mutex_lock(&private_display->lock); + + pp = (tdm_pp *)tdm_pp_create_internal(private_display->pp_module, error); + + _pthread_mutex_unlock(&private_display->lock); + + return pp; +} + EXTERN tdm_error tdm_module_get_info(tdm_module *module, const char **name, const char **vendor, int *major, int *minor) @@ -511,18 +811,17 @@ tdm_module_get_info(tdm_module *module, const char **name, return ret; } -EXTERN tdm_pp * -tdm_display_create_pp(tdm_display *dpy, tdm_error *error) +INTERN int +tdm_module_check_abi(tdm_private_module *private_module, int abimaj, int abimin) { - tdm_pp *pp; - - DISPLAY_FUNC_ENTRY_ERROR(); + tdm_backend_module *module = private_module->module_data; - _pthread_mutex_lock(&private_display->lock); + if (TDM_BACKEND_GET_ABI_MAJOR(module->abi_version) < abimaj) + return 0; - pp = (tdm_pp *)tdm_pp_create_internal(private_display->pp_module, error); + if (TDM_BACKEND_GET_ABI_MINOR(module->abi_version) < abimin) + return 0; - _pthread_mutex_unlock(&private_display->lock); - - return pp; + return 1; } +