From: Boram Park Date: Mon, 26 Mar 2018 11:19:10 +0000 (+0900) Subject: display: move function position X-Git-Tag: accepted/tizen/unified/20180330.060625~7 X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Flibtdm.git;a=commitdiff_plain;h=fea25ace45feadad465b8b3a65233315ca66bc22 display: move function position Change-Id: Icccd42165bd5b19f97ebb2b0e358318004ab346b --- diff --git a/src/tdm.c b/src/tdm.c index 5d9e04d..b2e2c35 100644 --- a/src/tdm.c +++ b/src/tdm.c @@ -1213,305 +1213,3 @@ tdm_output_is_valid(tdm_output *output) return 0; } - -/* LCOV_EXCL_START */ -INTERN int -tdm_module_check_abi(tdm_private_module *private_module, int abimaj, int abimin) -{ - tdm_backend_module *module = private_module->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_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; -} -/* LCOV_EXCL_STOP */ diff --git a/src/tdm_display.c b/src/tdm_display.c index 57e5a11..d9741a4 100644 --- a/src/tdm_display.c +++ b/src/tdm_display.c @@ -63,6 +63,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 +771,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 +813,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; } +