X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=src%2Ftdm_helper.c;h=61971e59666ab10cc90880449c353c46edf77156;hb=2adc0c96b4af5f88b3560e8ebd0b595a3f483578;hp=4adbcb859b921f147de4d4d0d507586d25e3e30b;hpb=bdf5ec0ef8368ad36dab2a280a4833fb88747d04;p=platform%2Fcore%2Fuifw%2Flibtdm.git diff --git a/src/tdm_helper.c b/src/tdm_helper.c index 4adbcb8..61971e5 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 @@ -38,16 +38,9 @@ #endif #include -#include -#include -#include -#include -#include #include -#include "tdm.h" #include "tdm_private.h" -#include "tdm_helper.h" #define PNG_DEPTH 8 @@ -67,12 +60,36 @@ tdm_helper_get_time(void) return 0; } +static int +_tdm_helper_check_file_is_symbolic_link(const char* path) +{ + struct stat sb; + + if (!path) + return 0; + + if (stat(path, &sb) != 0) + return 0; + + if (S_ISLNK(sb.st_mode)) + return 1; + + return 0; +} + static void _tdm_helper_dump_raw(const char *file, void *data1, int size1, void *data2, int size2, void *data3, int size3) { unsigned int *blocks; - FILE *fp = fopen(file, "w+"); + FILE *fp; + + 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); blocks = (unsigned int *)data1; @@ -95,7 +112,14 @@ static void _tdm_helper_dump_png(const char *file, const void *data, int width, int height) { - FILE *fp = fopen(file, "wb"); + FILE *fp; + + 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); png_structp pPngStruct = @@ -172,6 +196,7 @@ _tdm_helper_dump_png(const char *file, const void *data, int width, fclose(fp); } +/* LCOV_EXCL_START */ INTERN char * tdm_helper_dump_make_directory(const char *path, char *reply, int *len) { @@ -210,42 +235,41 @@ failed_make: return NULL; } -INTERN void +EXTERN void tdm_helper_dump_buffer_str(tbm_surface_h buffer, char *dir, char *str) { tbm_surface_info_s info; - const char *ext; char file[TDM_PATH_LEN]; - int ret, bw; + int ret, bw, bh; TDM_RETURN_IF_FAIL(buffer != NULL); - TDM_RETURN_IF_FAIL(dir != NULL); TDM_RETURN_IF_FAIL(str != NULL); + if (!dir) + dir = "."; + ret = tbm_surface_get_info(buffer, &info); TDM_RETURN_IF_FAIL(ret == TBM_SURFACE_ERROR_NONE); - if (info.format == TBM_FORMAT_ARGB8888 || info.format == TBM_FORMAT_XRGB8888) { - ext = file_exts[0]; - bw = info.planes[0].stride >> 2; - } else { - ext = file_exts[1]; - bw = info.planes[0].stride; - } + tdm_helper_get_buffer_full_size(buffer, &bw, &bh); - snprintf(file, TDM_PATH_LEN, "%s/%c%c%c%c_%dx%d_%s.%s", - dir, FOURCC_STR(info.format), bw, info.height, str, ext); + snprintf(file, TDM_PATH_LEN, "%s/%c%c%c%c_%dx%d_%dx%d_%s", + dir, FOURCC_STR(info.format), bw, bh, info.width, info.height, str); tdm_helper_dump_buffer(buffer, file); } +/* LCOV_EXCL_STOP */ EXTERN void tdm_helper_dump_buffer(tbm_surface_h buffer, const char *file) { + char temp[TDM_PATH_LEN] = {0,}; tbm_surface_info_s info; int len, ret; const char *ext; int bo_cnt; + int bw, bh; + char *dot, *p = temp; TDM_RETURN_IF_FAIL(buffer != NULL); TDM_RETURN_IF_FAIL(file != NULL); @@ -253,21 +277,32 @@ tdm_helper_dump_buffer(tbm_surface_h buffer, const char *file) ret = tbm_surface_map(buffer, TBM_OPTION_READ, &info); TDM_RETURN_IF_FAIL(ret == TBM_SURFACE_ERROR_NONE); - len = strnlen(file, 1024); - if (info.format == TBM_FORMAT_ARGB8888 || info.format == TBM_FORMAT_XRGB8888) + if (IS_RGB(info.format)) ext = file_exts[0]; else ext = file_exts[1]; - if (strncmp(file + (len - 3), ext, 3)) { - TDM_ERR("can't dump to '%s' file", file + (len - 3)); - tbm_surface_unmap(buffer); - return; + dot = strrchr(file, '.'); + if (!dot || strlen(dot + 1) != 3 || strncmp(dot + 1, ext, 3)) { + len = strnlen(file, TDM_PATH_LEN - 5); + strncat(p, file, len); + p += len; + *(p++) = '.'; + 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); + bo_cnt = tbm_surface_internal_get_num_bos(buffer); - TDM_DBG("buffer: bo_cnt(%d) %dx%d %c%c%c%c, plane: (%p+%d, %d,%d) (%p+%d, %d,%d) (%p+%d, %d,%d)", - bo_cnt, info.width, info.height, FOURCC_STR(info.format), + TDM_DBG("buffer: bo_cnt(%d) %dx%d(%dx%d) %c%c%c%c, plane: (%p+%d, %d,%d) (%p+%d, %d,%d) (%p+%d, %d,%d)", + bo_cnt, bw, bh, info.width, info.height, FOURCC_STR(info.format), info.planes[0].ptr, info.planes[0].offset, info.planes[0].stride, info.planes[0].size, info.planes[1].ptr, info.planes[1].offset, info.planes[1].stride, info.planes[1].size, info.planes[2].ptr, info.planes[2].offset, info.planes[2].stride, info.planes[2].size); @@ -275,39 +310,27 @@ tdm_helper_dump_buffer(tbm_surface_h buffer, const char *file) switch (info.format) { case TBM_FORMAT_ARGB8888: case TBM_FORMAT_XRGB8888: - _tdm_helper_dump_png(file, info.planes[0].ptr, - info.planes[0].stride >> 2, info.height); + _tdm_helper_dump_png(temp, info.planes[0].ptr, bw, bh); break; case TBM_FORMAT_YVU420: case TBM_FORMAT_YUV420: - _tdm_helper_dump_raw(file, + _tdm_helper_dump_raw((const char*)temp, info.planes[0].ptr, - info.planes[0].stride * info.height, + info.planes[0].size, info.planes[1].ptr, - info.planes[1].stride * (info.height >> 1), + info.planes[1].size, info.planes[2].ptr, - info.planes[2].stride * (info.height >> 1)); + info.planes[2].size); break; case TBM_FORMAT_NV12: case TBM_FORMAT_NV21: - if (bo_cnt == 1 && - (info.planes[0].ptr + info.planes[0].stride * info.height) != info.planes[1].ptr) - TDM_WRN("%p != %p", info.planes[0].ptr + info.planes[0].stride * info.height, info.planes[1].ptr); - - _tdm_helper_dump_raw(file, + _tdm_helper_dump_raw((const char*)temp, info.planes[0].ptr, - info.planes[0].stride * info.height, + info.planes[0].size, info.planes[1].ptr, - info.planes[1].stride * (info.height >> 1), NULL, + info.planes[1].size, NULL, 0); break; - case TBM_FORMAT_YUYV: - case TBM_FORMAT_UYVY: - _tdm_helper_dump_raw(file, - info.planes[0].ptr, - info.planes[0].stride * info.height, NULL, 0, - NULL, 0); - break; default: TDM_ERR("can't dump %c%c%c%c buffer", FOURCC_STR(info.format)); tbm_surface_unmap(buffer); @@ -316,11 +339,11 @@ tdm_helper_dump_buffer(tbm_surface_h buffer, const char *file) tbm_surface_unmap(buffer); - TDM_INFO("dump %s", file); + TDM_INFO("dump %s", temp); } -void -tdm_helper_clear_buffer_pos(tbm_surface_h buffer, tdm_pos *pos) +EXTERN void +tdm_helper_clear_buffer_color(tbm_surface_h buffer, tdm_pos *pos, unsigned int color) { tbm_surface_info_s info; int ret; @@ -341,8 +364,8 @@ tdm_helper_clear_buffer_pos(tbm_surface_h buffer, tdm_pos *pos) for (y = pos->y; y <= (pos->y + pos->h); y++) { p = info.planes[0].ptr + info.planes[0].stride * y; for (x = pos->x; x <= (pos->x + pos->w); x++) { - int *ibuf = (int*)p; - ibuf[x] = 0x00000000; + unsigned int *ibuf = (unsigned int*)p; + ibuf[x] = color; } } } @@ -358,22 +381,6 @@ tdm_helper_clear_buffer_pos(tbm_surface_h buffer, tdm_pos *pos) 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; @@ -383,6 +390,14 @@ tdm_helper_clear_buffer_pos(tbm_surface_h buffer, tdm_pos *pos) } EXTERN void +tdm_helper_clear_buffer_pos(tbm_surface_h buffer, tdm_pos *pos) +{ + TDM_RETURN_IF_FAIL(buffer != NULL); + + tdm_helper_clear_buffer_color(buffer, pos, 0); +} + +EXTERN void tdm_helper_clear_buffer(tbm_surface_h buffer) { TDM_RETURN_IF_FAIL(buffer != NULL); @@ -390,6 +405,28 @@ tdm_helper_clear_buffer(tbm_surface_h buffer) tdm_helper_clear_buffer_pos(buffer, NULL); } +EXTERN void +tdm_helper_get_buffer_full_size(tbm_surface_h buffer, int *buffer_w, int *buffer_h) +{ + tbm_surface_info_s info; + int ret; + + TDM_RETURN_IF_FAIL(buffer != NULL); + + ret = tbm_surface_get_info(buffer, &info); + TDM_RETURN_IF_FAIL(ret == TBM_SURFACE_ERROR_NONE); + + if (buffer_w) { + if (IS_RGB(info.format)) + *buffer_w = info.planes[0].stride >> 2; + else + *buffer_w = info.planes[0].stride; + } + + if (buffer_h) + *buffer_h = info.planes[0].size / info.planes[0].stride; +} + static pixman_format_code_t _tdm_helper_pixman_format_get(tbm_format format) { @@ -516,83 +553,29 @@ unmap_srcbuf: return ret; } +/* LCOV_EXCL_START */ EXTERN int tdm_helper_get_fd(const char *env) { - const char *value; - int fd, newfd, flags, ret; - char *end; - errno = 0; - - value = (const char*)getenv(env); - if (!value) - return -1; - - const long sl = strtol(value, &end, 10); - if (end == value) { - TDM_ERR("%s: not a decimal number\n", value); - return -1; - } else if (*end != '\0') { - TDM_ERR("%s: extra characters at end of input: %s\n", value, end); - return -1; - } else if ((sl == LONG_MIN || sl == LONG_MAX) && errno == ERANGE) { - TDM_ERR("%s out of range of type long\n", value); - return -1; - } else if (sl > INT_MAX) { - TDM_ERR("%ld greater than INT_MAX\n", sl); - return -1; - } else if (sl < INT_MIN) { - TDM_ERR("%ld less than INT_MIN\n", sl); - return -1; - } else { - fd = (int)sl; - if (fd < 0) { - TDM_ERR("%d out of fd range\n", fd); - return -1; - } - } - - flags = fcntl(fd, F_GETFD); - if (flags == -1) { - TDM_ERR("fcntl failed: %m"); - return -1; - } - - newfd = dup(fd); - if (newfd < 0) { - TDM_ERR("dup failed: %m"); + if (strncmp(env, "TBM_DRM_MASTER_FD", 17) && strncmp(env, "TDM_DRM_MASTER_FD", 17)) { + TDM_INFO("DEPRECATED! '%s'", env); return -1; } - TDM_INFO("%s: fd(%d) newfd(%d)", env, fd, newfd); - - ret = fcntl(newfd, F_SETFD, flags | FD_CLOEXEC); - if (ret == -1) { - TDM_ERR("fcntl failed: %m"); - close(newfd); - return -1; - } - - return newfd; + return tbm_drm_helper_get_master_fd(); } EXTERN void tdm_helper_set_fd(const char *env, int fd) { - char buf[32]; - int ret; - - snprintf(buf, sizeof(buf), "%d", fd); - - ret = setenv(env, (const char*)buf, 1); - if (ret) { - TDM_ERR("setenv failed: %m"); + if (strncmp(env, "TBM_DRM_MASTER_FD", 17) && strncmp(env, "TDM_DRM_MASTER_FD", 17)) { + TDM_INFO("DEPRECATED! '%s'", env); return; } - if (fd >= 0) - TDM_INFO("%s: fd(%d)", env, fd); + tbm_drm_helper_set_tbm_master_fd(fd); } +/* LCOV_EXCL_STOP */ EXTERN void tdm_helper_dump_start(char *dumppath, int *count) @@ -615,6 +598,7 @@ tdm_helper_dump_stop(void) TDM_DBG("tdm_helper_dump stop."); } +/* LCOV_EXCL_START */ static tdm_error _tdm_helper_buffer_convert(tbm_surface_h srcbuf, tbm_surface_h dstbuf, int dx, int dy, int dw, int dh, int count) @@ -702,6 +686,8 @@ cant_convert: return TDM_ERROR_OPERATION_FAILED; } +/* LCOV_EXCL_STOP */ + EXTERN tdm_error tdm_helper_capture_output(tdm_output *output, tbm_surface_h dst_buffer, @@ -719,7 +705,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) { @@ -750,10 +735,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; @@ -764,28 +748,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; - _pthread_mutex_lock(&private_display->lock); + 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, @@ -803,15 +782,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_GOTO_IF_FAIL(func_output->output_get_mode, unlock); - ret = func_output->output_get_mode(private_output->output_backend, ¤t_mode); - TDM_DBG_GOTO_IF_FAIL(ret == TDM_ERROR_NONE, unlock); - 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, @@ -835,29 +808,47 @@ tdm_helper_get_display_information(tdm_display *dpy, char *reply, int *len) TDM_SNPRINTF(reply, len, "\t%d properties:\n", private_output->caps.prop_count); if (private_output->caps.prop_count > 0) { - TDM_SNPRINTF(reply, len, "\t\tname\tidx\tvalue\n"); + 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_GOTO_IF_FAIL(func_output->output_get_property, unlock); + 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_GOTO_IF_FAIL(ret == TDM_ERROR_NONE, unlock); - TDM_SNPRINTF(reply, len, "\t\t%s\t%u\t%u\n", + 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, - private_output->caps.props[i].id, - value.u32); + tdm_value_type_str(private_output->caps.props[i].type), + private_output->caps.props[i].id); + switch (private_output->caps.props[i].type) { + case TDM_VALUE_TYPE_PTR: + TDM_SNPRINTF(reply, len, "%p\n", value.ptr); + break; + case TDM_VALUE_TYPE_INT32: + TDM_SNPRINTF(reply, len, "%d\n", value.s32); + break; + case TDM_VALUE_TYPE_INT64: + TDM_SNPRINTF(reply, len, "%"PRId64"\n", value.s64); + break; + case TDM_VALUE_TYPE_UINT64: + TDM_SNPRINTF(reply, len, "%"PRIu64"\n", value.u64); + break; + case TDM_VALUE_TYPE_UINT32: + default: + TDM_SNPRINTF(reply, len, "%u\n", value.u32); + break; + } } } } 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) { LIST_FOR_EACH_ENTRY(private_layer, &private_output->layer_list, link) { if (!private_layer->usable) { tdm_info_layer info; @@ -865,10 +856,10 @@ tdm_helper_get_display_information(tdm_display *dpy, char *reply, int *len) tdm_size size; tbm_surface_info_s buf_info; - TDM_DBG_GOTO_IF_FAIL(func_layer->layer_get_info, unlock); + 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_GOTO_IF_FAIL(ret == TDM_ERROR_NONE, unlock); + TDM_DBG_RETURN_VAL_IF_FAIL(ret == TDM_ERROR_NONE, reply); if (!private_layer->showing_buffer) continue; @@ -918,49 +909,67 @@ tdm_helper_get_display_information(tdm_display *dpy, char *reply, int *len) TDM_SNPRINTF(reply, len, "\t%u properties:\n", private_layer->caps.prop_count); if (private_layer->caps.prop_count > 0) { - TDM_SNPRINTF(reply, len, "\t\tname\tidx\tvalue\n"); + 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_GOTO_IF_FAIL(func_layer->layer_get_property, unlock); + 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_GOTO_IF_FAIL(ret == TDM_ERROR_NONE, unlock); - TDM_SNPRINTF(reply, len, "\t\t%s\t%u\t%u\n", + 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, - private_layer->caps.props[i].id, - value.u32); + tdm_value_type_str(private_output->caps.props[i].type), + private_layer->caps.props[i].id); + switch (private_layer->caps.props[i].type) { + case TDM_VALUE_TYPE_PTR: + TDM_SNPRINTF(reply, len, "%p\n", value.ptr); + break; + case TDM_VALUE_TYPE_INT32: + TDM_SNPRINTF(reply, len, "%d\n", value.s32); + break; + case TDM_VALUE_TYPE_INT64: + TDM_SNPRINTF(reply, len, "%"PRId64"\n", value.s64); + break; + case TDM_VALUE_TYPE_UINT64: + TDM_SNPRINTF(reply, len, "%"PRIu64"\n", value.u64); + break; + case TDM_VALUE_TYPE_UINT32: + default: + TDM_SNPRINTF(reply, len, "%u\n", value.u32); + break; + } } } } } 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, @@ -976,35 +985,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, @@ -1015,23 +1024,57 @@ 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); + } -unlock: _pthread_mutex_unlock(&private_display->lock); } +/* LCOV_EXCL_START */ EXTERN int tdm_helper_commit_per_vblank_enabled(tdm_display *dpy) { - tdm_private_display *private_display; + TDM_DEPRECATED("Use tdm_helper_output_commit_per_vblank_enabled"); - TDM_RETURN_VAL_IF_FAIL(dpy != NULL, 0); + return 0; +} +/* LCOV_EXCL_STOP */ - private_display = dpy; +EXTERN int +tdm_helper_output_commit_per_vblank_enabled(tdm_output *output) +{ + tdm_private_output *private_output = output; - return private_display->commit_per_vblank; + TDM_RETURN_VAL_IF_FAIL(private_output != NULL, -1); + + 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; +}