X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=src%2Ftdm_helper.c;h=804a112133f5a6d363ced8c9ea44b9ac21a86ad7;hb=d2b86709393a6e7fba1e22a82625e4c2514c8a7e;hp=cd6426fdf95a5b6409f061f463a8ab3980da93db;hpb=17fa403ebeb3de0c042b684f45151e78a92483ce;p=platform%2Fcore%2Fuifw%2Flibtdm.git diff --git a/src/tdm_helper.c b/src/tdm_helper.c index cd6426f..804a112 100644 --- a/src/tdm_helper.c +++ b/src/tdm_helper.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 @@ -44,7 +44,7 @@ #define PNG_DEPTH 8 -static const char *file_exts[2] = {"png", "yuv"}; +static const char *file_exts[2] = {"png", "raw"}; int tdm_dump_enable; char *tdm_debug_dump_dir; @@ -61,26 +61,20 @@ tdm_helper_get_time(void) } static int -_tdm_helper_check_file_is_valid(const char* path, int del_link) +_tdm_helper_check_file_is_symbolic_link(const char* path) { - char *real_path; + struct stat sb; if (!path) return 0; - real_path = realpath(path, NULL); - if (real_path && strncmp(path, real_path, strlen(path))) { - if (del_link) - unlink(path); - free(real_path); - + if (stat(path, &sb) != 0) return 0; - } - if (real_path) - free(real_path); + if (S_ISLNK(sb.st_mode)) + return 1; - return 1; + return 0; } static void @@ -90,8 +84,10 @@ _tdm_helper_dump_raw(const char *file, void *data1, int size1, void *data2, unsigned int *blocks; FILE *fp; - if (!_tdm_helper_check_file_is_valid(file, 1)) - TDM_WRN("'%s' may be symbolic link\n", file); + if (_tdm_helper_check_file_is_symbolic_link(file)) { + TDM_ERR("'%s' may be symbolic link\n", file); + return; + } fp = fopen(file, "w+"); TDM_RETURN_IF_FAIL(fp != NULL); @@ -118,8 +114,10 @@ _tdm_helper_dump_png(const char *file, const void *data, int width, { FILE *fp; - if (!_tdm_helper_check_file_is_valid(file, 1)) - TDM_WRN("'%s' may be symbolic link\n", file); + if (_tdm_helper_check_file_is_symbolic_link(file)) { + TDM_ERR("'%s' may be symbolic link\n", file); + return; + } fp = fopen(file, "wb"); TDM_RETURN_IF_FAIL(fp != NULL); @@ -293,6 +291,11 @@ tdm_helper_dump_buffer(tbm_surface_h buffer, const char *file) strncat(p, ext, 3); p += 3; *p = '\0'; + } else { + len = strnlen(file, TDM_PATH_LEN - 1); + strncat(p, file, len); + p += len; + *p = '\0'; } tdm_helper_get_buffer_full_size(buffer, &bw, &bh); @@ -328,17 +331,15 @@ tdm_helper_dump_buffer(tbm_surface_h buffer, const char *file) info.planes[1].size, NULL, 0); break; - case TBM_FORMAT_YUYV: - case TBM_FORMAT_UYVY: + default: _tdm_helper_dump_raw((const char*)temp, info.planes[0].ptr, - info.planes[0].size, NULL, 0, - NULL, 0); + info.planes[0].size, + info.planes[1].ptr, + info.planes[1].size, + info.planes[2].ptr, + info.planes[2].size); break; - default: - TDM_ERR("can't dump %c%c%c%c buffer", FOURCC_STR(info.format)); - tbm_surface_unmap(buffer); - return; } tbm_surface_unmap(buffer); @@ -385,22 +386,6 @@ tdm_helper_clear_buffer_color(tbm_surface_h buffer, tdm_pos *pos, unsigned int c memset((char*)info.planes[0].ptr, 0x10, info.planes[0].stride * info.height); memset((char*)info.planes[1].ptr, 0x80, info.planes[1].stride * (info.height >> 1)); break; - case TBM_FORMAT_YUYV: { - int *ibuf = (int*)info.planes[0].ptr; - int i, size = info.planes[0].stride * info.height / 4; - - for (i = 0 ; i < size ; i++) - ibuf[i] = 0x10801080; - } - break; - case TBM_FORMAT_UYVY: { - int *ibuf = (int*)info.planes[0].ptr; - int i, size = info.planes[0].stride * info.height / 4; - - for (i = 0 ; i < size ; i++) - ibuf[i] = 0x80108010; /* YUYV -> 0xVYUY */ - } - break; default: TDM_ERR("can't clear %c%c%c%c buffer", FOURCC_STR(info.format)); break; @@ -725,7 +710,6 @@ tdm_helper_capture_output(tdm_output *output, tbm_surface_h dst_buffer, TDM_RETURN_VAL_IF_FAIL(w >= 0, TDM_ERROR_INVALID_PARAMETER); TDM_RETURN_VAL_IF_FAIL(h >= 0, TDM_ERROR_INVALID_PARAMETER); TDM_RETURN_VAL_IF_FAIL(func != NULL, TDM_ERROR_INVALID_PARAMETER); - TDM_RETURN_VAL_IF_FAIL(data != NULL, TDM_ERROR_INVALID_PARAMETER); err = tdm_output_get_layer_count(output, &count); if (err != TDM_ERROR_NONE) { @@ -756,10 +740,9 @@ tdm_helper_capture_output(tdm_output *output, tbm_surface_h dst_buffer, return TDM_ERROR_NONE; } -EXTERN void -tdm_helper_get_display_information(tdm_display *dpy, char *reply, int *len) +static char * +_tdm_helper_get_backend_information(tdm_private_module *private_module, char *reply, int *len) { - tdm_private_display *private_display; tdm_backend_module *module_data; tdm_func_output *func_output; tdm_func_layer *func_layer; @@ -770,27 +753,23 @@ tdm_helper_get_display_information(tdm_display *dpy, char *reply, int *len) tdm_error ret; int i; - TDM_DBG_RETURN_IF_FAIL(dpy != NULL); - - private_display = dpy; - func_output = &private_display->func_output; - func_layer = &private_display->func_layer; + func_output = &private_module->func_output; + func_layer = &private_module->func_layer; /* module information */ - module_data = private_display->module_data; - TDM_SNPRINTF(reply, len, "[TDM backend information]\n"); - TDM_SNPRINTF(reply, len, "name: %s\n", module_data->name); + module_data = private_module->module_data; + TDM_SNPRINTF(reply, len, "['%s' backend information]\n", module_data->name); TDM_SNPRINTF(reply, len, "vendor: %s\n", module_data->vendor); TDM_SNPRINTF(reply, len, "version: %d.%d\n\n", (int)TDM_BACKEND_GET_ABI_MAJOR(module_data->abi_version), (int)TDM_BACKEND_GET_ABI_MINOR(module_data->abi_version)); /* output information */ - TDM_SNPRINTF(reply, len, "[Output information]\n"); + TDM_SNPRINTF(reply, len, "['%s' backend output information]\n", module_data->name); TDM_SNPRINTF(reply, len, "--------------------------------------------------------------------------------------------\n"); TDM_SNPRINTF(reply, len, "idx maker model name type status dpms subpixel align_w min max phy(mm)\n"); TDM_SNPRINTF(reply, len, "--------------------------------------------------------------------------------------------\n"); - LIST_FOR_EACH_ENTRY(private_output, &private_display->output_list, link) { + LIST_FOR_EACH_ENTRY(private_output, &private_module->output_list, link) { TDM_SNPRINTF(reply, len, "%d %s %s %s %s %s %s %u %d %dx%d %dx%d %ux%u\n", private_output->index, private_output->caps.maker, private_output->caps.model, private_output->caps.name, @@ -808,15 +787,9 @@ tdm_helper_get_display_information(tdm_display *dpy, char *reply, int *len) TDM_SNPRINTF(reply, len, "\t%u modes:\n", private_output->caps.mode_count); if (private_output->caps.mode_count > 0) { - const tdm_output_mode *current_mode = NULL; - - TDM_DBG_RETURN_IF_FAIL(func_output->output_get_mode); - ret = func_output->output_get_mode(private_output->output_backend, ¤t_mode); - TDM_DBG_RETURN_IF_FAIL(ret == TDM_ERROR_NONE); - TDM_SNPRINTF(reply, len, "\t\t name refresh (Hz) clk hdisp hss hse htot vdisp vss vse vtot vscan\n"); for (i = 0; i < private_output->caps.mode_count; i++) { - char *current = (current_mode == private_output->caps.modes + i) ? "*" : " "; + char *current = (private_output->current_mode == private_output->caps.modes + i) ? "*" : " "; TDM_SNPRINTF(reply, len, "\t\t%s%s %u %u %u %u %u %u %u %u %u %u %u ", current, private_output->caps.modes[i].name, @@ -843,11 +816,11 @@ tdm_helper_get_display_information(tdm_display *dpy, char *reply, int *len) TDM_SNPRINTF(reply, len, "\t\tname\ttype\tidx\tvalue\n"); for (i = 0; i < private_output->caps.prop_count; i++) { tdm_value value; - TDM_DBG_RETURN_IF_FAIL(func_output->output_get_property); + TDM_DBG_RETURN_VAL_IF_FAIL(func_output->output_get_property, reply); ret = func_output->output_get_property(private_output->output_backend, private_output->caps.props[i].id, &value); - TDM_DBG_RETURN_IF_FAIL(ret == TDM_ERROR_NONE); + TDM_DBG_RETURN_VAL_IF_FAIL(ret == TDM_ERROR_NONE, reply); TDM_SNPRINTF(reply, len, "\t\t%s\t%s\t%u\t", private_output->caps.props[i].name, tdm_value_type_str(private_output->caps.props[i].type), @@ -873,14 +846,21 @@ tdm_helper_get_display_information(tdm_display *dpy, char *reply, int *len) } } } + if (LIST_IS_EMPTY(&private_module->output_list)) + TDM_SNPRINTF(reply, len, "(no output)\n"); TDM_SNPRINTF(reply, len, "\n"); /* layer information */ - TDM_SNPRINTF(reply, len, "[Layer information]\n"); + TDM_SNPRINTF(reply, len, "['%s' backend layer information]\n", module_data->name); TDM_SNPRINTF(reply, len, "-----------------------------------------------------------------------\n"); TDM_SNPRINTF(reply, len, "idx output zpos buf format size crop geometry transform\n"); TDM_SNPRINTF(reply, len, "-----------------------------------------------------------------------\n"); - LIST_FOR_EACH_ENTRY(private_output, &private_display->output_list, link) { + LIST_FOR_EACH_ENTRY(private_output, &private_module->output_list, link) { + if (private_output->caps.capabilities & TDM_OUTPUT_CAPABILITY_HWC) { + TDM_SNPRINTF(reply, len, "(no layer), hwc mode on\n"); + continue; + } + LIST_FOR_EACH_ENTRY(private_layer, &private_output->layer_list, link) { if (!private_layer->usable) { tdm_info_layer info; @@ -888,10 +868,10 @@ tdm_helper_get_display_information(tdm_display *dpy, char *reply, int *len) tdm_size size; tbm_surface_info_s buf_info; - TDM_DBG_RETURN_IF_FAIL(func_layer->layer_get_info); + TDM_DBG_RETURN_VAL_IF_FAIL(func_layer->layer_get_info, reply); memset(&info, 0, sizeof info); ret = func_layer->layer_get_info(private_layer->layer_backend, &info); - TDM_DBG_RETURN_IF_FAIL(ret == TDM_ERROR_NONE); + TDM_DBG_RETURN_VAL_IF_FAIL(ret == TDM_ERROR_NONE, reply); if (!private_layer->showing_buffer) continue; @@ -899,10 +879,7 @@ tdm_helper_get_display_information(tdm_display *dpy, char *reply, int *len) format = tbm_surface_get_format(private_layer->showing_buffer->buffer); tbm_surface_get_info(private_layer->showing_buffer->buffer, &buf_info); - if (IS_RGB(format)) - size.h = buf_info.planes[0].stride >> 2; - else - size.h = buf_info.planes[0].stride; + size.h = tbm_surface_get_width(private_layer->showing_buffer->buffer); size.v = tbm_surface_get_height(private_layer->showing_buffer->buffer); if (info.src_config.format) @@ -944,11 +921,11 @@ tdm_helper_get_display_information(tdm_display *dpy, char *reply, int *len) TDM_SNPRINTF(reply, len, "\t\tname\ttype\tidx\tvalue\n"); for (i = 0; i < private_layer->caps.prop_count; i++) { tdm_value value; - TDM_DBG_RETURN_IF_FAIL(func_layer->layer_get_property); + TDM_DBG_RETURN_VAL_IF_FAIL(func_layer->layer_get_property, reply); ret = func_layer->layer_get_property(private_layer->layer_backend, private_layer->caps.props[i].id, &value); - TDM_DBG_RETURN_IF_FAIL(ret == TDM_ERROR_NONE); + TDM_DBG_RETURN_VAL_IF_FAIL(ret == TDM_ERROR_NONE, reply); TDM_SNPRINTF(reply, len, "\t\t%s\t%s\t%u\t", private_layer->caps.props[i].name, tdm_value_type_str(private_output->caps.props[i].type), @@ -975,33 +952,35 @@ tdm_helper_get_display_information(tdm_display *dpy, char *reply, int *len) } } } + if (LIST_IS_EMPTY(&private_module->output_list)) + TDM_SNPRINTF(reply, len, "(no layer)\n"); TDM_SNPRINTF(reply, len, "\n"); - if (private_display->capabilities & TDM_DISPLAY_CAPABILITY_PP) { + if (private_module->capabilities & TDM_DISPLAY_CAPABILITY_PP) { const char *sep = ""; - TDM_SNPRINTF(reply, len, "[PP information]\n"); + TDM_SNPRINTF(reply, len, "['%s' backend PP information]\n", module_data->name); TDM_SNPRINTF(reply, len, "caps\t: "); - tdm_pp_caps_str(private_display->caps_pp.capabilities, &reply, len); + tdm_pp_caps_str(private_module->caps_pp.capabilities, &reply, len); TDM_SNPRINTF(reply, len, "\n"); TDM_SNPRINTF(reply, len, "formats\t: "); - for (i = 0; i < private_display->caps_pp.format_count; i++) { - if (private_display->caps_pp.formats[i] == 0) + for (i = 0; i < private_module->caps_pp.format_count; i++) { + if (private_module->caps_pp.formats[i] == 0) continue; - TDM_SNPRINTF(reply, len, "%s%c%c%c%c", sep, FOURCC_STR(private_display->caps_pp.formats[i])); + TDM_SNPRINTF(reply, len, "%s%c%c%c%c", sep, FOURCC_STR(private_module->caps_pp.formats[i])); sep = ","; } TDM_SNPRINTF(reply, len, "\n"); TDM_SNPRINTF(reply, len, "size\t: min(%dx%d) max(%dx%d) align_w(%d)\n", - TDM_FRONT_VALUE(private_display->caps_pp.min_w), - TDM_FRONT_VALUE(private_display->caps_pp.min_h), - TDM_FRONT_VALUE(private_display->caps_pp.max_w), - TDM_FRONT_VALUE(private_display->caps_pp.max_h), - TDM_FRONT_VALUE(private_display->caps_pp.preferred_align)); - if (!LIST_IS_EMPTY(&private_display->pp_list)) { + TDM_FRONT_VALUE(private_module->caps_pp.min_w), + TDM_FRONT_VALUE(private_module->caps_pp.min_h), + TDM_FRONT_VALUE(private_module->caps_pp.max_w), + TDM_FRONT_VALUE(private_module->caps_pp.max_h), + TDM_FRONT_VALUE(private_module->caps_pp.preferred_align)); + if (!LIST_IS_EMPTY(&private_module->pp_list)) { TDM_SNPRINTF(reply, len, "-------------------------------------------------------------\n"); TDM_SNPRINTF(reply, len, "src(format size crop) | dst(format size crop) | transform\n"); TDM_SNPRINTF(reply, len, "-------------------------------------------------------------\n"); - LIST_FOR_EACH_ENTRY(private_pp, &private_display->pp_list, link) { + LIST_FOR_EACH_ENTRY(private_pp, &private_module->pp_list, link) { TDM_SNPRINTF(reply, len, "%c%c%c%c %ux%u %ux%u+%u+%u | %c%c%c%c %ux%u %ux%u+%u+%u | %s\n", FOURCC_STR(private_pp->info.src_config.format), private_pp->info.src_config.size.h, @@ -1017,35 +996,35 @@ tdm_helper_get_display_information(tdm_display *dpy, char *reply, int *len) } } } else { - TDM_SNPRINTF(reply, len, "[No PP capability]\n"); + TDM_SNPRINTF(reply, len, "['%s' backend No PP capability]\n", module_data->name); } TDM_SNPRINTF(reply, len, "\n"); - if (private_display->capabilities & TDM_DISPLAY_CAPABILITY_CAPTURE) { + if (private_module->capabilities & TDM_DISPLAY_CAPABILITY_CAPTURE) { const char *sep = ""; - TDM_SNPRINTF(reply, len, "[Capture information]\n"); + TDM_SNPRINTF(reply, len, "['%s' backend capture information]\n", module_data->name); TDM_SNPRINTF(reply, len, "caps\t: "); - tdm_capture_caps_str(private_display->caps_capture.capabilities, &reply, len); + tdm_capture_caps_str(private_module->caps_capture.capabilities, &reply, len); TDM_SNPRINTF(reply, len, "\n"); TDM_SNPRINTF(reply, len, "formats\t: "); - for (i = 0; i < private_display->caps_capture.format_count; i++) { - if (private_display->caps_capture.formats[i] == 0) + for (i = 0; i < private_module->caps_capture.format_count; i++) { + if (private_module->caps_capture.formats[i] == 0) continue; - TDM_SNPRINTF(reply, len, "%s%c%c%c%c", sep, FOURCC_STR(private_display->caps_capture.formats[i])); + TDM_SNPRINTF(reply, len, "%s%c%c%c%c", sep, FOURCC_STR(private_module->caps_capture.formats[i])); sep = ","; } TDM_SNPRINTF(reply, len, "\n"); TDM_SNPRINTF(reply, len, "size\t: min(%dx%d) max(%dx%d) align_w(%d)\n", - TDM_FRONT_VALUE(private_display->caps_capture.min_w), - TDM_FRONT_VALUE(private_display->caps_capture.min_h), - TDM_FRONT_VALUE(private_display->caps_capture.max_w), - TDM_FRONT_VALUE(private_display->caps_capture.max_h), - TDM_FRONT_VALUE(private_display->caps_capture.preferred_align)); - if (!LIST_IS_EMPTY(&private_display->capture_list)) { + TDM_FRONT_VALUE(private_module->caps_capture.min_w), + TDM_FRONT_VALUE(private_module->caps_capture.min_h), + TDM_FRONT_VALUE(private_module->caps_capture.max_w), + TDM_FRONT_VALUE(private_module->caps_capture.max_h), + TDM_FRONT_VALUE(private_module->caps_capture.preferred_align)); + if (!LIST_IS_EMPTY(&private_module->capture_list)) { TDM_SNPRINTF(reply, len, "-----------------------------------\n"); TDM_SNPRINTF(reply, len, "dst(format size crop) | transform\n"); TDM_SNPRINTF(reply, len, "-----------------------------------\n"); - LIST_FOR_EACH_ENTRY(private_capture, &private_display->capture_list, link) { + LIST_FOR_EACH_ENTRY(private_capture, &private_module->capture_list, link) { TDM_SNPRINTF(reply, len, "%c%c%c%c %ux%u %ux%u+%u+%u | %s\n", FOURCC_STR(private_capture->info.dst_config.format), private_capture->info.dst_config.size.h, @@ -1056,16 +1035,36 @@ tdm_helper_get_display_information(tdm_display *dpy, char *reply, int *len) } } } else { - TDM_SNPRINTF(reply, len, "[No Capture capability]\n"); + TDM_SNPRINTF(reply, len, "['%s' backend No Capture capability]\n", module_data->name); } TDM_SNPRINTF(reply, len, "\n"); + return reply; +} + +EXTERN void +tdm_helper_get_display_information(tdm_display *dpy, char *reply, int *len) +{ + tdm_private_display *private_display; + tdm_private_module *private_module = NULL; + + TDM_DBG_RETURN_IF_FAIL(dpy != NULL); + + private_display = dpy; + + _pthread_mutex_lock(&private_display->lock); + + LIST_FOR_EACH_ENTRY(private_module, &private_display->module_list, link) { + reply = _tdm_helper_get_backend_information(private_module, reply, len); + } + + _pthread_mutex_unlock(&private_display->lock); } /* LCOV_EXCL_START */ EXTERN int tdm_helper_commit_per_vblank_enabled(tdm_display *dpy) { - TDM_ERR("the deprecated function, use 'tdm_helper_output_commit_per_vblank_enabled' instead."); + TDM_DEPRECATED("Use tdm_helper_output_commit_per_vblank_enabled"); return 0; } @@ -1081,3 +1080,12 @@ tdm_helper_output_commit_per_vblank_enabled(tdm_output *output) return !!private_output->commit_per_vblank; } +EXTERN unsigned int +tdm_helper_output_vblank_timer_expired(tdm_output *output) +{ + tdm_private_output *private_output = output; + + TDM_RETURN_VAL_IF_FAIL(private_output != NULL, -1); + + return private_output->vblank_timeout_timer_expired; +}