From 8bf130d7b0a92368b7869301b93b115da6014287 Mon Sep 17 00:00:00 2001 From: Boram Park Date: Mon, 11 Jul 2016 11:21:00 +0900 Subject: [PATCH 01/16] correct usage of rand_r() Change-Id: Iebaf7cdaafcedd6b08e1bf34f6c2495393b83f0f --- tools/buffers.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/tools/buffers.c b/tools/buffers.c index 53ed615..c4de575 100644 --- a/tools/buffers.c +++ b/tools/buffers.c @@ -141,6 +141,8 @@ static const struct format_info format_info[] = { { TBM_FORMAT_BGRX1010102, "BX30", MAKE_RGB_INFO(10, 2, 10, 12, 10, 22, 0, 0) }, }; +static unsigned int rand_seed; + unsigned int format_fourcc(const char *name) { unsigned int i; @@ -558,7 +560,6 @@ fill_smpte_rgb32(const struct rgb_info *rgb, unsigned char *mem, }; unsigned int x; unsigned int y; - unsigned int seed = time(NULL);; if (width < 8) return; @@ -584,7 +585,7 @@ fill_smpte_rgb32(const struct rgb_info *rgb, unsigned char *mem, colors_bottom[(x - width * 5 / 7) * 3 / (width / 7) + 4]; for (; x < width; ++x) { - ((uint32_t *)mem)[x] = (rand_r(&seed) % 2) ? MAKE_RGBA(rgb, 255, 255, 255, 255) : MAKE_RGBA(rgb, 0, 0, 0, 255); + ((uint32_t *)mem)[x] = (rand_r(&rand_seed) % 2) ? MAKE_RGBA(rgb, 255, 255, 255, 255) : MAKE_RGBA(rgb, 0, 0, 0, 255); } mem += stride; } @@ -939,6 +940,9 @@ tdm_test_buffer_fill(tbm_surface_h buffer, int pattern) void *plane[3]; int ret; + if (rand_seed == 0) + rand_seed = time(NULL); + ret = tbm_surface_map(buffer, TBM_OPTION_WRITE, &info); TDM_EXIT_IF_FAIL(ret == 0); -- 2.7.4 From 02d2100670785551b95cde50a3cf0f0ee395031a Mon Sep 17 00:00:00 2001 From: Boram Park Date: Mon, 11 Jul 2016 16:24:56 +0900 Subject: [PATCH 02/16] fix the too many logs when enabled Change-Id: I155b5fc09cc38d0786b5e66867b7565de51cf53e --- src/tdm.c | 93 ++++++++++++++++++++++++++++++++-------------------- src/tdm_buffer.c | 6 ++-- src/tdm_capture.c | 4 +-- src/tdm_dbg_server.c | 34 +++++++------------ src/tdm_display.c | 20 +++++------ src/tdm_event_loop.c | 4 +-- src/tdm_pp.c | 4 +-- src/tdm_private.h | 25 +++++++++----- src/tdm_server.c | 8 ++--- src/tdm_thread.c | 14 ++++---- src/tdm_vblank.c | 49 +++++++++++++++++---------- 11 files changed, 146 insertions(+), 115 deletions(-) diff --git a/src/tdm.c b/src/tdm.c index 0bbd7a7..d388f19 100644 --- a/src/tdm.c +++ b/src/tdm.c @@ -668,9 +668,7 @@ tdm_display_update(tdm_display *dpy) #define SUFFIX_MODULE ".so" #define DEFAULT_MODULE "libtdm-default"SUFFIX_MODULE -int tdm_debug_buffer; -int tdm_debug_thread; -int tdm_debug_mutex; +int tdm_debug_module; int tdm_debug_dump; static tdm_private_display *g_private_display; @@ -901,22 +899,14 @@ tdm_display_init(tdm_error *error) return g_private_display; } - debug = getenv("TDM_DEBUG_BUFFER"); - if (debug && (strstr(debug, "1"))) - tdm_debug_buffer = 1; + debug = getenv("TDM_DEBUG_MODULE"); + if (debug) + tdm_display_enable_debug_module(debug); debug = getenv("TDM_DEBUG_DUMP"); if (debug) tdm_display_enable_dump(debug); - debug = getenv("TDM_DEBUG_THREAD"); - if (debug && (strstr(debug, "1"))) - tdm_debug_thread = 1; - - debug = getenv("TDM_DEBUG_MUTEX"); - if (debug && (strstr(debug, "1"))) - tdm_debug_mutex = 1; - private_display = calloc(1, sizeof(tdm_private_display)); if (!private_display) { ret = TDM_ERROR_OUT_OF_MEMORY; @@ -984,7 +974,6 @@ failed_event: failed_mutex_init: free(private_display); failed_alloc: - tdm_debug_buffer = 0; if (error) *error = ret; _pthread_mutex_unlock(&gLock); @@ -1028,7 +1017,6 @@ tdm_display_deinit(tdm_display *dpy) pthread_mutex_destroy(&private_display->lock); free(private_display); g_private_display = NULL; - tdm_debug_buffer = 0; _pthread_mutex_unlock(&gLock); @@ -1049,42 +1037,77 @@ tdm_display_check_module_abi(tdm_private_display *private_display, int abimaj, i return 1; } -INTERN void -tdm_display_enable_debug(char *debug, int enable) +INTERN tdm_error +tdm_display_enable_debug_module(const char*modules) { - if (!strncmp(debug, "TDM_DEBUG_BUFFER", 16)) - tdm_debug_buffer = enable; - else if (!strncmp(debug, "TDM_DEBUG_THREAD", 16)) - tdm_debug_thread = enable; - else if (!strncmp(debug, "TDM_DEBUG_MUTEX", 15)) - tdm_debug_mutex = enable; + 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 + return TDM_ERROR_BAD_REQUEST; + + arg = strtok_r(NULL, TDM_DELIM, &end); + } + + TDM_INFO("module debugging... '%s'", modules); + + return TDM_ERROR_NONE; } -INTERN void +INTERN tdm_error tdm_display_enable_dump(const char *dump_str) { char temp[1024]; char *arg; char *end; - int flags = 0; + + tdm_debug_dump = 0; snprintf(temp, sizeof(temp), "%s", dump_str); arg = strtok_r(temp, ",", &end); while (arg) { + if (!strncmp(arg, "none", 4)) { + tdm_debug_dump = 0; + return TDM_ERROR_NONE; + } if (!strncmp(arg, "all", 3)) { - flags = TDM_DUMP_FLAG_LAYER|TDM_DUMP_FLAG_PP|TDM_DUMP_FLAG_CAPTURE; - break; + tdm_debug_dump = 0xFFFFFFFF; + return TDM_ERROR_NONE; } - else if (!strncmp(arg, "layer", 5)) - flags |= TDM_DUMP_FLAG_LAYER; + if (!strncmp(arg, "layer", 5)) + tdm_debug_dump |= TDM_DUMP_FLAG_LAYER; else if (!strncmp(arg, "pp", 2)) - flags |= TDM_DUMP_FLAG_PP; + tdm_debug_dump |= TDM_DUMP_FLAG_PP; else if (!strncmp(arg, "capture", 7)) - flags |= TDM_DUMP_FLAG_CAPTURE; - else if (!strncmp(arg, "none", 4)) - flags = 0; + tdm_debug_dump |= TDM_DUMP_FLAG_CAPTURE; + else + return TDM_ERROR_BAD_REQUEST; + arg = strtok_r(NULL, ",", &end); } - tdm_debug_dump = flags; + TDM_INFO("dump... '%s'", dump_str); + + return TDM_ERROR_NONE; } diff --git a/src/tdm_buffer.c b/src/tdm_buffer.c index 93bbd61..9b4bdb8 100644 --- a/src/tdm_buffer.c +++ b/src/tdm_buffer.c @@ -60,7 +60,7 @@ _tdm_buffer_destroy_info(void *user_data) if (buf_info->backend_ref_count > 0) { TDM_NEVER_GET_HERE(); - if (tdm_debug_buffer) + if (tdm_debug_module & TDM_DEBUG_BUFFER) TDM_INFO("%p", buf_info->buffer); } @@ -77,7 +77,7 @@ _tdm_buffer_destroy_info(void *user_data) free(func_info); } - if (tdm_debug_buffer) + if (tdm_debug_module & TDM_DEBUG_BUFFER) TDM_INFO("%p destroyed", buf_info->buffer); free(buf_info); @@ -107,7 +107,7 @@ tdm_buffer_get_info(tbm_surface_h buffer) return NULL; } - if (tdm_debug_buffer) + if (tdm_debug_module & TDM_DEBUG_BUFFER) TDM_INFO("%p created", buf_info->buffer); } diff --git a/src/tdm_capture.c b/src/tdm_capture.c index cc79f62..f5bcfc2 100644 --- a/src/tdm_capture.c +++ b/src/tdm_capture.c @@ -112,7 +112,7 @@ tdm_capture_cb_done(tdm_capture *capture_backend, tbm_surface_h buffer, tdm_helper_dump_buffer_str(buffer, str); } - if (tdm_debug_buffer) + if (tdm_debug_module & TDM_DEBUG_BUFFER) TDM_INFO("capture(%p) done: %p", private_capture, buffer); first_entry = tdm_buffer_list_get_first_entry(&private_capture->buffer_list); @@ -387,7 +387,7 @@ tdm_capture_attach(tdm_capture *capture, tbm_surface_h buffer) if ((buf_info = tdm_buffer_get_info(buffer))) LIST_ADDTAIL(&buf_info->link, &private_capture->pending_buffer_list); - if (tdm_debug_buffer) { + if (tdm_debug_module & TDM_DEBUG_BUFFER) { TDM_INFO("capture(%p) attached:", private_capture); tdm_buffer_list_dump(&private_capture->buffer_list); } diff --git a/src/tdm_dbg_server.c b/src/tdm_dbg_server.c index 76f895f..c5db70a 100644 --- a/src/tdm_dbg_server.c +++ b/src/tdm_dbg_server.c @@ -89,7 +89,7 @@ _tdm_dbg_server_dpms(unsigned int pid, char *cwd, int argc, char *argv[], char * static void _tdm_dbg_server_debug(unsigned int pid, char *cwd, int argc, char *argv[], char *reply, int *len, tdm_display *dpy) { - int value; + int level; char *arg; char *end; @@ -99,29 +99,17 @@ _tdm_dbg_server_debug(unsigned int pid, char *cwd, int argc, char *argv[], char } arg = argv[2]; - value = strtol(arg, &end, 10); + level = strtol(arg, &end, 10); - tdm_log_set_debug_level(value); + tdm_log_set_debug_level(level); + TDM_SNPRINTF(reply, len, "debug level: %d\n", level); - value = !!value; - tdm_log_enable_debug(value); + if (*end == '@') { + char *arg = end + 1; - TDM_SNPRINTF(reply, len, "debug '%s'\n", (value) ? "on" : "off"); + tdm_display_enable_debug_module((const char *)arg); - if (argc > 3) { - char temp[TDM_PATH_LEN]; - char *arg; - char *end; - - snprintf(temp, TDM_PATH_LEN, "%s", argv[3]); - - arg = strtok_r(temp, TDM_DELIM, &end); - while (arg) { - tdm_display_enable_debug(arg, value); - if (value) - TDM_SNPRINTF(reply, len, "debuging '%s'...\n", arg); - arg = strtok_r(NULL, TDM_DELIM, &end); - } + TDM_SNPRINTF(reply, len, "debugging... '%s'\n", arg); } } @@ -296,9 +284,9 @@ static struct { }, { "debug", _tdm_dbg_server_debug, - "enable the debug level log", - "", - "0 or 1" + "set the debug level and modules(none,mutex,buffer,thread,vblank)", + "[@[,]]", + NULL }, { "log_path", _tdm_dbg_server_log_path, diff --git a/src/tdm_display.c b/src/tdm_display.c index fd4dff6..8dcf66f 100644 --- a/src/tdm_display.c +++ b/src/tdm_display.c @@ -332,7 +332,7 @@ tdm_display_handle_events(tdm_display *dpy) fds.fd = fd; fds.revents = 0; - if (tdm_debug_thread) + if (tdm_debug_module & TDM_DEBUG_THREAD) TDM_INFO("fd(%d) polling in", fd); while (poll(&fds, 1, -1) < 0) { @@ -344,7 +344,7 @@ tdm_display_handle_events(tdm_display *dpy) } } - if (tdm_debug_thread) + if (tdm_debug_module & TDM_DEBUG_THREAD) TDM_INFO("fd(%d) polling out", fd); if (tdm_thread_is_running()) @@ -898,7 +898,7 @@ tdm_output_cb_commit(tdm_output *output_backend, unsigned int sequence, private_layer->showing_buffer = private_layer->waiting_buffer; private_layer->waiting_buffer = NULL; - if (tdm_debug_buffer) + if (tdm_debug_module & TDM_DEBUG_BUFFER) TDM_INFO("layer(%p) waiting_buffer(%p) showing_buffer(%p)", private_layer, private_layer->waiting_buffer, private_layer->showing_buffer); @@ -1496,7 +1496,7 @@ tdm_layer_set_buffer(tdm_layer *layer, tbm_surface_h buffer) } private_layer->waiting_buffer = tdm_buffer_ref_backend(buffer); - if (tdm_debug_buffer) + if (tdm_debug_module & TDM_DEBUG_BUFFER) TDM_INFO("layer(%p) waiting_buffer(%p)", private_layer, private_layer->waiting_buffer); } @@ -1522,7 +1522,7 @@ tdm_layer_unset_buffer(tdm_layer *layer) _pthread_mutex_lock(&private_display->lock); private_layer->waiting_buffer = NULL; - if (tdm_debug_buffer) + if (tdm_debug_module & TDM_DEBUG_BUFFER) TDM_INFO("layer(%p) waiting_buffer(%p)", private_layer, private_layer->waiting_buffer); } @@ -1533,7 +1533,7 @@ tdm_layer_unset_buffer(tdm_layer *layer) _pthread_mutex_lock(&private_display->lock); private_layer->showing_buffer = NULL; - if (tdm_debug_buffer) + if (tdm_debug_module & TDM_DEBUG_BUFFER) TDM_INFO("layer(%p) showing_buffer(%p)", private_layer, private_layer->showing_buffer); } @@ -1622,7 +1622,7 @@ _tbm_layer_queue_acquirable_cb(tbm_surface_queue_h surface_queue, void *data) private_layer->waiting_buffer = tdm_buffer_ref_backend(surface); - if (tdm_debug_buffer) + if (tdm_debug_module & TDM_DEBUG_BUFFER) TDM_INFO("layer(%p) waiting_buffer(%p)", private_layer, private_layer->waiting_buffer); @@ -1693,7 +1693,7 @@ tdm_layer_set_buffer_queue(tdm_layer *layer, tbm_surface_queue_h buffer_queue) private_layer->waiting_buffer = NULL; _pthread_mutex_lock(&private_display->lock); - if (tdm_debug_buffer) + if (tdm_debug_module & TDM_DEBUG_BUFFER) TDM_INFO("layer(%p) waiting_buffer(%p)", private_layer, private_layer->waiting_buffer); } @@ -1728,7 +1728,7 @@ tdm_layer_unset_buffer_queue(tdm_layer *layer) private_layer->waiting_buffer = NULL; _pthread_mutex_lock(&private_display->lock); - if (tdm_debug_buffer) + if (tdm_debug_module & TDM_DEBUG_BUFFER) TDM_INFO("layer(%p) waiting_buffer(%p)", private_layer, private_layer->waiting_buffer); } @@ -1741,7 +1741,7 @@ tdm_layer_unset_buffer_queue(tdm_layer *layer) _pthread_mutex_lock(&private_display->lock); private_layer->showing_buffer = NULL; - if (tdm_debug_buffer) + if (tdm_debug_module & TDM_DEBUG_BUFFER) TDM_INFO("layer(%p) showing_buffer(%p)", private_layer, private_layer->showing_buffer); } diff --git a/src/tdm_event_loop.c b/src/tdm_event_loop.c index 4496806..29a9763 100644 --- a/src/tdm_event_loop.c +++ b/src/tdm_event_loop.c @@ -75,7 +75,7 @@ _tdm_event_loop_main_fd_handler(int fd, tdm_event_loop_mask mask, void *user_dat private_loop = private_display->private_loop; - if (tdm_debug_thread) + if (tdm_debug_module & TDM_DEBUG_THREAD) TDM_INFO("backend fd(%d) event happens", private_loop->backend_fd); func_display = &private_display->func_display; @@ -225,7 +225,7 @@ tdm_event_loop_dispatch(tdm_private_display *private_display) TDM_RETURN_VAL_IF_FAIL(private_loop->wl_loop != NULL, TDM_ERROR_OPERATION_FAILED); - if (tdm_debug_thread) + if (tdm_debug_module & TDM_DEBUG_THREAD) TDM_INFO("dispatch"); if (tdm_thread_is_running() && diff --git a/src/tdm_pp.c b/src/tdm_pp.c index 91a1239..a43d257 100644 --- a/src/tdm_pp.c +++ b/src/tdm_pp.c @@ -144,7 +144,7 @@ tdm_pp_cb_done(tdm_pp *pp_backend, tbm_surface_h src, tbm_surface_h dst, tdm_helper_dump_buffer_str(dst, str); } - if (tdm_debug_buffer) + if (tdm_debug_module & TDM_DEBUG_BUFFER) TDM_INFO("pp(%p) done: src(%p) dst(%p)", private_pp, src, dst); if (!LIST_IS_EMPTY(&private_pp->buffer_list)) { @@ -399,7 +399,7 @@ tdm_pp_attach(tdm_pp *pp, tbm_surface_h src, tbm_surface_h dst) pp_buffer->src = tdm_buffer_ref_backend(src); pp_buffer->dst = tdm_buffer_ref_backend(dst); - if (tdm_debug_buffer) { + if (tdm_debug_module & TDM_DEBUG_BUFFER) { TDM_INFO("pp(%p) attached:", private_pp); _tdm_pp_print_list(&private_pp->pending_buffer_list); } diff --git a/src/tdm_private.h b/src/tdm_private.h index b2b61e6..0e792c8 100644 --- a/src/tdm_private.h +++ b/src/tdm_private.h @@ -73,9 +73,16 @@ extern "C" { * @brief The private header file for a frontend library */ -extern int tdm_debug_buffer; -extern int tdm_debug_mutex; -extern int tdm_debug_thread; +enum { + TDM_DEBUG_NONE, + TDM_DEBUG_BUFFER = (1 << 0), + TDM_DEBUG_MUTEX = (1 << 1), + TDM_DEBUG_THREAD = (1 << 2), + TDM_DEBUG_SERVER = (1 << 3), + TDM_DEBUG_VBLANK = (1 << 4), +}; + +extern int tdm_debug_module; extern int tdm_debug_dump; #ifdef HAVE_TTRACE @@ -466,7 +473,7 @@ extern int tdm_dump_enable; #define _pthread_mutex_unlock(l) \ do { \ - if (tdm_debug_mutex) \ + if (tdm_debug_module & TDM_DEBUG_MUTEX) \ TDM_INFO("mutex unlock"); \ pthread_mutex_lock(&tdm_mutex_check_lock); \ tdm_mutex_locked = 0; \ @@ -477,7 +484,7 @@ extern int tdm_dump_enable; #define MUTEX_TIMEOUT_SEC 5 #define _pthread_mutex_lock(l) \ do { \ - if (tdm_debug_mutex) \ + if (tdm_debug_module & TDM_DEBUG_MUTEX) \ TDM_INFO("mutex lock"); \ struct timespec rtime; \ clock_gettime(CLOCK_REALTIME, &rtime); \ @@ -495,7 +502,7 @@ extern int tdm_dump_enable; #else //TDM_CONFIG_MUTEX_TIMEOUT #define _pthread_mutex_lock(l) \ do { \ - if (tdm_debug_mutex) \ + if (tdm_debug_module & TDM_DEBUG_MUTEX) \ TDM_INFO("mutex lock"); \ pthread_mutex_lock(l); \ pthread_mutex_lock(&tdm_mutex_check_lock); \ @@ -522,9 +529,9 @@ static inline int TDM_MUTEX_IS_LOCKED(void) tdm_error tdm_display_update_output(tdm_private_display *private_display, tdm_output *output_backend, int pipe); -void -tdm_display_enable_debug(char *debug, int enable); -void +tdm_error +tdm_display_enable_debug_module(const char*modules); +tdm_error tdm_display_enable_dump(const char *dump_str); /** diff --git a/src/tdm_server.c b/src/tdm_server.c index a20984f..ab6467e 100644 --- a/src/tdm_server.c +++ b/src/tdm_server.c @@ -140,7 +140,8 @@ _tdm_server_send_done(tdm_server_wait_info *wait_info, tdm_error error, return; } - TDM_DBG("req_id(%d) done", wait_info->req_id); + if (tdm_debug_module & TDM_DEBUG_VBLANK) + TDM_INFO("req_id(%d) done", wait_info->req_id); vblank_info = wait_info->vblank_info; wl_tdm_vblank_send_done(vblank_info->resource, wait_info->req_id, @@ -254,7 +255,8 @@ _tdm_server_vblank_cb_wait_vblank(struct wl_client *client, struct wl_resource * wait_info->vblank_info = vblank_info; wait_info->req_id = req_id; - TDM_DBG("req_id(%d) wait", req_id); + if (tdm_debug_module & TDM_DEBUG_VBLANK) + TDM_INFO("req_id(%d) wait", req_id); ret = tdm_vblank_wait(vblank_info->vblank, req_sec, req_usec, interval, _tdm_server_cb_vblank, wait_info); TDM_GOTO_IF_FAIL(ret == TDM_ERROR_NONE, wait_failed); @@ -443,8 +445,6 @@ _tdm_server_bind(struct wl_client *client, void *data, return; } - TDM_DBG("tdm server binding"); - wl_resource_set_implementation(resource, &tdm_implementation, data, NULL); } diff --git a/src/tdm_thread.c b/src/tdm_thread.c index b9490a5..03ce03a 100644 --- a/src/tdm_thread.c +++ b/src/tdm_thread.c @@ -86,16 +86,16 @@ _tdm_thread_main(void *data) fds.revents = 0; while (1) { - if (tdm_debug_thread) + if (tdm_debug_module & TDM_DEBUG_THREAD) TDM_INFO("server flush"); tdm_event_loop_flush(private_loop->dpy); - if (tdm_debug_thread) + if (tdm_debug_module & TDM_DEBUG_THREAD) TDM_INFO("fd(%d) polling in", fd); ret = poll(&fds, 1, -1); - if (tdm_debug_thread) + if (tdm_debug_module & TDM_DEBUG_THREAD) TDM_INFO("fd(%d) polling out", fd); if (ret < 0) { @@ -107,7 +107,7 @@ _tdm_thread_main(void *data) } } - if (tdm_debug_thread) + if (tdm_debug_module & TDM_DEBUG_THREAD) TDM_INFO("thread got events"); if (tdm_event_loop_dispatch(private_loop->dpy) < 0) @@ -229,7 +229,7 @@ tdm_thread_send_cb(tdm_private_loop *private_loop, tdm_thread_cb_base *base) private_thread = private_loop->private_thread; - if (tdm_debug_thread) + if (tdm_debug_module & TDM_DEBUG_THREAD) TDM_INFO("fd(%d) type(%d), length(%d)", private_thread->pipe[1], base->type, base->length); @@ -261,7 +261,7 @@ tdm_thread_handle_cb(tdm_private_loop *private_loop) len = read(private_thread->pipe[0], buffer, sizeof buffer); - if (tdm_debug_thread) + if (tdm_debug_module & TDM_DEBUG_THREAD) TDM_INFO("fd(%d) read length(%d)", private_thread->pipe[0], len); if (len == 0) @@ -277,7 +277,7 @@ tdm_thread_handle_cb(tdm_private_loop *private_loop) i = 0; while (i < len) { base = (tdm_thread_cb_base*)&buffer[i]; - if (tdm_debug_thread) + if (tdm_debug_module & TDM_DEBUG_THREAD) TDM_INFO("type(%d), length(%d)", base->type, base->length); switch (base->type) { case TDM_THREAD_CB_OUTPUT_COMMIT: { diff --git a/src/tdm_vblank.c b/src/tdm_vblank.c index 30ed7df..0f278c2 100644 --- a/src/tdm_vblank.c +++ b/src/tdm_vblank.c @@ -335,8 +335,9 @@ tdm_vblank_create(tdm_display *dpy, tdm_output *output, tdm_error *error) LIST_ADD(&private_vblank->link, &vblank_list); - VDB("created. vrefresh(%d) dpms(%d)", - private_vblank->vrefresh, private_vblank->dpms); + if (tdm_debug_module & TDM_DEBUG_VBLANK) + VIN("created. vrefresh(%d) dpms(%d)", + private_vblank->vrefresh, private_vblank->dpms); return (tdm_vblank*)private_vblank; } @@ -382,7 +383,8 @@ tdm_vblank_destroy(tdm_vblank *vblank) free(w); } - VIN("destroyed"); + if (tdm_debug_module & TDM_DEBUG_VBLANK) + VIN("destroyed"); free(private_vblank); } @@ -401,7 +403,8 @@ tdm_vblank_set_fps(tdm_vblank *vblank, unsigned int fps) private_vblank->fps = fps; private_vblank->check_HW_or_SW = 1; - VDB("fps(%d)", private_vblank->fps); + if (tdm_debug_module & TDM_DEBUG_VBLANK) + VIN("fps(%d)", private_vblank->fps); return TDM_ERROR_NONE; } @@ -419,7 +422,8 @@ tdm_vblank_set_offset(tdm_vblank *vblank, int offset) private_vblank->offset = offset; private_vblank->check_HW_or_SW = 1; - VDB("offset(%d)", private_vblank->offset); + if (tdm_debug_module & TDM_DEBUG_VBLANK) + VIN("offset(%d)", private_vblank->offset); return TDM_ERROR_NONE; } @@ -436,7 +440,8 @@ tdm_vblank_set_enable_fake(tdm_vblank *vblank, unsigned int enable_fake) private_vblank->enable_fake = enable_fake; - VDB("enable_fake(%d)", private_vblank->enable_fake); + if (tdm_debug_module & TDM_DEBUG_VBLANK) + VIN("enable_fake(%d)", private_vblank->enable_fake); return TDM_ERROR_NONE; } @@ -473,7 +478,8 @@ _tdm_vblank_cb_vblank_HW(tdm_output *output, unsigned int sequence, wait_info->func(private_vblank, TDM_ERROR_NONE, private_vblank->last_seq, tv_sec, tv_usec, wait_info->user_data); - VDB("wait(%p) done", wait_info); + if (tdm_debug_module & TDM_DEBUG_VBLANK) + VIN("wait(%p) done", wait_info); free(wait_info); } @@ -497,7 +503,8 @@ _tdm_vblank_wait_HW(tdm_vblank_wait_info *wait_info) return ret; } - VDB("wait(%p) waiting", wait_info); + if (tdm_debug_module & TDM_DEBUG_VBLANK) + VIN("wait(%p) waiting", wait_info); return TDM_ERROR_NONE; } @@ -518,7 +525,8 @@ _tdm_vblank_cb_vblank_SW(void *user_data) first_wait_info = container_of(private_vblank->SW_wait_list.next, first_wait_info, link); TDM_RETURN_VAL_IF_FAIL(first_wait_info != NULL, TDM_ERROR_OPERATION_FAILED); - VDB("wait(%p) done", first_wait_info); + if (tdm_debug_module & TDM_DEBUG_VBLANK) + VIN("wait(%p) done", first_wait_info); private_vblank->last_seq = first_wait_info->target_seq; private_vblank->last_tv_sec = first_wait_info->target_sec; @@ -568,7 +576,8 @@ _tdm_vblank_cb_vblank_SW_first(tdm_output *output, unsigned int sequence, w = container_of((&private_vblank->SW_pending_wait_list)->next, w, link); TDM_RETURN_IF_FAIL(w != NULL); - VDB("wait(%p) done", w); + if (tdm_debug_module & TDM_DEBUG_VBLANK) + VIN("wait(%p) done", w); min_interval = w->interval; @@ -621,8 +630,9 @@ _tdm_vblank_sw_timer_update(tdm_private_vblank *private_vblank) if (ms_delay < 1) ms_delay = 1; - VDB("wait(%p) curr(%4lu) target(%4lu) ms_delay(%d)", - first_wait_info, curr, target, ms_delay); + if (tdm_debug_module & TDM_DEBUG_VBLANK) + VIN("wait(%p) curr(%4lu) target(%4lu) ms_delay(%d)", + first_wait_info, curr, target, ms_delay); tdm_display_lock(private_vblank->dpy); @@ -749,7 +759,8 @@ _tdm_vblank_wait_SW(tdm_vblank_wait_info *wait_info) LIST_DEL(&wait_info->link); return ret; } - VDB("wait(%p) waiting", wait_info); + if (tdm_debug_module & TDM_DEBUG_VBLANK) + VIN("wait(%p) waiting", wait_info); } return TDM_ERROR_NONE; } @@ -823,8 +834,9 @@ _tdm_vblank_calculate_target(tdm_vblank_wait_info *wait_info) } } - VDB("target_seq(%d) last_seq(%d) skip(%d)", - wait_info->target_seq, private_vblank->last_seq, skip); + if (tdm_debug_module & TDM_DEBUG_VBLANK) + VIN("target_seq(%d) last_seq(%d) skip(%d)", + wait_info->target_seq, private_vblank->last_seq, skip); #if 0 target -= (private_vblank->SW_align_offset * skip * private_vblank->HW_quotient); @@ -834,9 +846,10 @@ _tdm_vblank_calculate_target(tdm_vblank_wait_info *wait_info) wait_info->target_sec = target / 1000000; wait_info->target_usec = target % 1000000; - VDB("wait(%p) last(%4lu) req(%4lu) prev(%4lu) curr(%4lu) skip(%d) hw_interval(%d) target(%4lu,%4lu)", - wait_info, last, req - last, prev - last, curr - last, - skip, wait_info->target_hw_interval, target, target - last); + if (tdm_debug_module & TDM_DEBUG_VBLANK) + VIN("wait(%p) last(%4lu) req(%4lu) prev(%4lu) curr(%4lu) skip(%d) hw_interval(%d) target(%4lu,%4lu)", + wait_info, last, req - last, prev - last, curr - last, + skip, wait_info->target_hw_interval, target, target - last); } tdm_error -- 2.7.4 From 089e52cc5a6168fcda79f6c153d0ac0cf1db13bd Mon Sep 17 00:00:00 2001 From: Boram Park Date: Mon, 11 Jul 2016 16:25:24 +0900 Subject: [PATCH 03/16] fix seg.fault of tdm-test-server Change-Id: I09aa654347fd72b46e264a68b4e935f30b63f8af --- tools/tdm_test_server.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tools/tdm_test_server.c b/tools/tdm_test_server.c index 932e20d..aec7aee 100644 --- a/tools/tdm_test_server.c +++ b/tools/tdm_test_server.c @@ -601,6 +601,7 @@ interpret_args(tdm_test_server *data) TDM_EXIT_IF_FAIL(l != NULL); LIST_INITHEAD(&l->prop_list); LIST_ADDTAIL(&l->link, &o->layer_list); + l->data = data; l->o = o; l->idx = j; @@ -653,6 +654,7 @@ interpret_args(tdm_test_server *data) TDM_EXIT_IF_FAIL(l != NULL); LIST_INITHEAD(&l->prop_list); LIST_ADDTAIL(&l->link, &o->layer_list); + l->data = data; l->o = o; l->idx = i; l->is_primary = 1; @@ -849,7 +851,6 @@ main(int argc, char *argv[]) tdm_error ret; signal(SIGINT, exit_test); /* 2 */ - signal(SIGSEGV, exit_test); /* 11 */ signal(SIGTERM, exit_test); /* 15 */ memset(data, 0, sizeof * data); -- 2.7.4 From daae1f2e34e13c7d8f1ce2c36c94f9c0e29bf035 Mon Sep 17 00:00:00 2001 From: Boram Park Date: Tue, 12 Jul 2016 16:22:40 +0900 Subject: [PATCH 04/16] support TDM_DEBUG_PATH Change-Id: Ibc25d75ad797d1815987a2acceccb9b15d7723f3 --- common/tdm_log.c | 14 ++++++++++++-- include/tdm_log.h | 1 + src/tdm.c | 39 +++++++++++++++++++++++++++++++++++++++ src/tdm_dbg_server.c | 16 +++------------- src/tdm_private.h | 2 ++ 5 files changed, 57 insertions(+), 15 deletions(-) diff --git a/common/tdm_log.c b/common/tdm_log.c index c843c9b..5e1ab2c 100644 --- a/common/tdm_log.c +++ b/common/tdm_log.c @@ -61,6 +61,7 @@ #define LOG_TAG "TDM" static unsigned int dlog_enable; +static unsigned int color_enable = 1; static unsigned int debug_level = TDM_LOG_LEVEL_INFO; static unsigned int need_check_env = 1; @@ -85,6 +86,12 @@ _tdm_log_check_env(void) } EXTERN void +tdm_log_enable_color(unsigned int enable) +{ + color_enable = enable; +} + +EXTERN void tdm_log_enable_dlog(unsigned int enable) { dlog_enable = enable; @@ -146,9 +153,12 @@ tdm_log_print(int level, const char *fmt, ...) clock_gettime(CLOCK_MONOTONIC, &ts); - printf("%s", color[level]); + if (color_enable) + printf("%s", color[level]); printf("[%s]", lvl_str[level]); - printf(COLOR_RESET"[%d.%06d]", (int)ts.tv_sec, (int)ts.tv_nsec / 1000); + if (color_enable) + printf(COLOR_RESET); + printf("[%d.%06d]", (int)ts.tv_sec, (int)ts.tv_nsec / 1000); va_start(arg, fmt); vprintf(fmt, arg); va_end(arg); diff --git a/include/tdm_log.h b/include/tdm_log.h index 19abde5..e43a4af 100644 --- a/include/tdm_log.h +++ b/include/tdm_log.h @@ -63,6 +63,7 @@ enum { TDM_LOG_LEVEL_DBG, }; +void tdm_log_enable_color(unsigned int enable); void tdm_log_enable_dlog(unsigned int enable); void tdm_log_enable_debug(unsigned int enable); void tdm_log_set_debug_level(int level); diff --git a/src/tdm.c b/src/tdm.c index d388f19..5597bca 100644 --- a/src/tdm.c +++ b/src/tdm.c @@ -907,6 +907,10 @@ tdm_display_init(tdm_error *error) if (debug) tdm_display_enable_dump(debug); + debug = getenv("TDM_DEBUG_PATH"); + if (debug) + tdm_display_enable_path(debug); + private_display = calloc(1, sizeof(tdm_private_display)); if (!private_display) { ret = TDM_ERROR_OUT_OF_MEMORY; @@ -1064,6 +1068,8 @@ tdm_display_enable_debug_module(const char*modules) 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 return TDM_ERROR_BAD_REQUEST; @@ -1111,3 +1117,36 @@ tdm_display_enable_dump(const char *dump_str) 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; +} diff --git a/src/tdm_dbg_server.c b/src/tdm_dbg_server.c index c5db70a..83ea135 100644 --- a/src/tdm_dbg_server.c +++ b/src/tdm_dbg_server.c @@ -118,8 +118,6 @@ _tdm_dbg_server_log_path(unsigned int pid, char *cwd, int argc, char *argv[], ch { static int old_stdout = -1; char fd_name[TDM_PATH_LEN]; - int log_fd = -1; - FILE *log_fl; char *path; if (argc < 3) { @@ -149,22 +147,14 @@ _tdm_dbg_server_log_path(unsigned int pid, char *cwd, int argc, char *argv[], ch else snprintf(fd_name, TDM_PATH_LEN, "%s", path); } + tdm_log_enable_color(0); } - log_fl = fopen(fd_name, "a"); - if (!log_fl) { - TDM_SNPRINTF(reply, len, "failed: open file(%s)\n", fd_name); + if (tdm_display_enable_path((const char*)fd_name) != TDM_ERROR_NONE) { + TDM_SNPRINTF(reply, len, "failed: '%s'\n", path); return; } - fflush(stderr); - close(STDOUT_FILENO); - - setvbuf(log_fl, NULL, _IOLBF, 512); - log_fd = fileno(log_fl); - - dup2(log_fd, STDOUT_FILENO); - fclose(log_fl); done: TDM_SNPRINTF(reply, len, "log path: '%s'\n", path); } diff --git a/src/tdm_private.h b/src/tdm_private.h index 0e792c8..5b3a68d 100644 --- a/src/tdm_private.h +++ b/src/tdm_private.h @@ -533,6 +533,8 @@ tdm_error tdm_display_enable_debug_module(const char*modules); tdm_error tdm_display_enable_dump(const char *dump_str); +tdm_error +tdm_display_enable_path(const char *path); /** * @brief The tdm vblank object -- 2.7.4 From 8767d080f71e91388c6640329adb87d190c4ceac Mon Sep 17 00:00:00 2001 From: Boram Park Date: Mon, 18 Jul 2016 09:35:49 +0900 Subject: [PATCH 05/16] add the libtdm dependency Change-Id: I3b4846c913de5334a8d300b965ac3a0c0ebdaf1f --- packaging/libtdm.spec | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packaging/libtdm.spec b/packaging/libtdm.spec index 6e1472d..cb05c76 100644 --- a/packaging/libtdm.spec +++ b/packaging/libtdm.spec @@ -27,6 +27,7 @@ This supports frontend & backend library header and so %package client Summary: Client library for Tizen Display Manager Group: Development/Libraries +Requires: libtdm = %{version} %description client Tizen Display Manager Client Library @@ -45,7 +46,7 @@ Tizen Display Manager Client Library headers %package tools Summary: Tools for libtdm Group: Development/Utilities -#Provides: libtdm = %version +Requires: libtdm = %{version} %description tools This contains libtdm tools for fundamental testing -- 2.7.4 From bce9f6348bf434ffb0c3568fa5b02d1320a1dd95 Mon Sep 17 00:00:00 2001 From: Yunjin Lee Date: Wed, 20 Jul 2016 20:52:03 +0900 Subject: [PATCH 06/16] Set SmackProcessLabel to System Change-Id: Iae2e0a397bf1c333b101dc399e60f0a6be1548cb Signed-off-by: Yunjin Lee --- service/tdm-socket.service | 1 + 1 file changed, 1 insertion(+) diff --git a/service/tdm-socket.service b/service/tdm-socket.service index caabbd8..9bff69d 100644 --- a/service/tdm-socket.service +++ b/service/tdm-socket.service @@ -3,6 +3,7 @@ Description= tdm-socket setup service [Service] Type=oneshot +SmackProcessLabel=System ExecStart=/usr/bin/chmod g+w /run/tdm-socket ExecStart=/usr/bin/chgrp display /run/tdm-socket ExecStart=/usr/bin/chsmack -a User /run/tdm-socket -- 2.7.4 From 1c8d24af4b2302364e865e5819ee3bde469cffeb Mon Sep 17 00:00:00 2001 From: Boram Park Date: Wed, 20 Jul 2016 11:15:14 +0900 Subject: [PATCH 07/16] set 750 permission to tdm-dbg and tdm-test-server Change-Id: I461bacf02d9f6353d5cd9866c8f40f1429308554 --- packaging/libtdm.spec | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packaging/libtdm.spec b/packaging/libtdm.spec index cb05c76..536cd8e 100644 --- a/packaging/libtdm.spec +++ b/packaging/libtdm.spec @@ -93,7 +93,7 @@ rm -f %{_unitdir_user}/default.target.wants/tdm-socket-user.path %defattr(-,root,root,-) %{TZ_SYS_RO_SHARE}/license/%{name} %{_libdir}/libtdm.so.* -%{_bindir}/tdm-dbg +%attr(750,root,root) %{_bindir}/tdm-dbg %{_unitdir}/tdm-socket.path %{_unitdir}/tdm-socket.service %{_unitdir_user}/tdm-socket-user.path @@ -128,7 +128,7 @@ rm -f %{_unitdir_user}/default.target.wants/tdm-socket-user.path %files tools %manifest %{name}.manifest -%{_bindir}/tdm-test-server +%attr(750,root,root) %{_bindir}/tdm-test-server %{_bindir}/tdm-test-client %changelog -- 2.7.4 From bae285d7f37d74ed60ab8930879a2ef6b445cf81 Mon Sep 17 00:00:00 2001 From: Boram Park Date: Wed, 20 Jul 2016 13:38:57 +0900 Subject: [PATCH 08/16] set index to output, layer objects Change-Id: Ic430c677b0749d4cfca762f285d0e9401cf69a90 --- src/tdm.c | 6 ++++-- src/tdm_display.c | 9 ++------- src/tdm_private.h | 3 +++ 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/tdm.c b/src/tdm.c index 5597bca..d73e816 100644 --- a/src/tdm.c +++ b/src/tdm.c @@ -376,7 +376,7 @@ _tdm_display_update_caps_output(tdm_private_display *private_display, int pipe, static tdm_error _tdm_display_update_layer(tdm_private_display *private_display, tdm_private_output *private_output, - tdm_layer *layer_backend) + tdm_layer *layer_backend, int index) { tdm_private_layer *private_layer; tdm_error ret; @@ -387,6 +387,7 @@ _tdm_display_update_layer(tdm_private_display *private_display, TDM_RETURN_VAL_IF_FAIL(private_layer != NULL, TDM_ERROR_OUT_OF_MEMORY); LIST_ADDTAIL(&private_layer->link, &private_output->layer_list); + private_layer->index = index; private_layer->private_display = private_display; private_layer->private_output = private_output; private_layer->layer_backend = layer_backend; @@ -433,6 +434,7 @@ tdm_display_update_output(tdm_private_display *private_display, private_output->current_dpms_value = TDM_OUTPUT_DPMS_OFF; private_output->output_backend = output_backend; private_output->pipe = pipe; + private_output->index = pipe; LIST_INITHEAD(&private_output->layer_list); LIST_INITHEAD(&private_output->capture_list); @@ -461,7 +463,7 @@ tdm_display_update_output(tdm_private_display *private_display, goto failed_update; for (i = 0; i < layer_count; i++) { - ret = _tdm_display_update_layer(private_display, private_output, layers[i]); + ret = _tdm_display_update_layer(private_display, private_output, layers[i], i); if (ret != TDM_ERROR_NONE) goto failed_update; } diff --git a/src/tdm_display.c b/src/tdm_display.c index 8dcf66f..f1bbca5 100644 --- a/src/tdm_display.c +++ b/src/tdm_display.c @@ -275,7 +275,6 @@ EXTERN tdm_output * tdm_display_get_output(tdm_display *dpy, int index, tdm_error *error) { tdm_private_output *private_output = NULL; - int i = 0; DISPLAY_FUNC_ENTRY_ERROR(); @@ -284,13 +283,11 @@ tdm_display_get_output(tdm_display *dpy, int index, tdm_error *error) if (error) *error = TDM_ERROR_NONE; - i = 0; LIST_FOR_EACH_ENTRY(private_output, &private_display->output_list, link) { - if (i == index) { + if (private_output->index == index) { _pthread_mutex_unlock(&private_display->lock); return private_output; } - i++; } _pthread_mutex_unlock(&private_display->lock); @@ -618,7 +615,6 @@ EXTERN tdm_layer * tdm_output_get_layer(tdm_output *output, int index, tdm_error *error) { tdm_private_layer *private_layer = NULL; - int i = 0; OUTPUT_FUNC_ENTRY_ERROR(); @@ -628,11 +624,10 @@ tdm_output_get_layer(tdm_output *output, int index, tdm_error *error) *error = TDM_ERROR_NONE; LIST_FOR_EACH_ENTRY(private_layer, &private_output->layer_list, link) { - if (i == index) { + if (private_layer->index == index) { _pthread_mutex_unlock(&private_display->lock); return private_layer; } - i++; } _pthread_mutex_unlock(&private_display->lock); diff --git a/src/tdm_private.h b/src/tdm_private.h index 5b3a68d..a2740a0 100644 --- a/src/tdm_private.h +++ b/src/tdm_private.h @@ -160,6 +160,7 @@ struct _tdm_private_display { struct _tdm_private_output { struct list_head link; + int index; unsigned long stamp; tdm_private_display *private_display; @@ -192,6 +193,8 @@ struct _tdm_private_output { struct _tdm_private_layer { struct list_head link; + int index; + tdm_private_display *private_display; tdm_private_output *private_output; -- 2.7.4 From a229e0780e205fb1dc9551921c2b39fc33a6e26b Mon Sep 17 00:00:00 2001 From: Boram Park Date: Wed, 20 Jul 2016 13:41:33 +0900 Subject: [PATCH 09/16] code clean-up (macro, structure) Change-Id: I88124bbca87fe5206c6da5e2faa2adfaa949fb44 --- src/tdm_capture.c | 2 ++ src/tdm_macro.h | 6 ++++++ src/tdm_pp.c | 9 ++------- src/tdm_private.h | 9 +++++++++ 4 files changed, 19 insertions(+), 7 deletions(-) diff --git a/src/tdm_capture.c b/src/tdm_capture.c index f5bcfc2..2737805 100644 --- a/src/tdm_capture.c +++ b/src/tdm_capture.c @@ -352,6 +352,8 @@ tdm_capture_set_info(tdm_capture *capture, tdm_info_capture *info) ret = func_capture->capture_set_info(private_capture->capture_backend, info); TDM_WARNING_IF_FAIL(ret == TDM_ERROR_NONE); + private_capture->info = *info; + _pthread_mutex_unlock(&private_display->lock); return ret; diff --git a/src/tdm_macro.h b/src/tdm_macro.h index d56267d..fe762c2 100644 --- a/src/tdm_macro.h +++ b/src/tdm_macro.h @@ -128,6 +128,12 @@ extern "C" { return; \ } \ } +#define TDM_DBG_GOTO_IF_FAIL(cond, dst) { \ + if (!(cond)) { \ + TDM_SNPRINTF(reply, len, "[%s %d] '%s' failed\n", __func__, __LINE__, #cond); \ + goto dst; \ + } \ +} #define C(b, m) (((b) >> (m)) & 0xFF) #define B(c, s) ((((unsigned int)(c)) & 0xff) << (s)) diff --git a/src/tdm_pp.c b/src/tdm_pp.c index a43d257..e9d5183 100644 --- a/src/tdm_pp.c +++ b/src/tdm_pp.c @@ -42,13 +42,6 @@ #include "tdm_private.h" #include "tdm_helper.h" -typedef struct _tdm_pp_private_buffer { - tbm_surface_h src; - tbm_surface_h dst; - struct list_head link; - struct list_head commit_link; -} tdm_pp_private_buffer; - #define PP_FUNC_ENTRY() \ tdm_func_pp *func_pp; \ tdm_private_display *private_display; \ @@ -336,6 +329,8 @@ tdm_pp_set_info(tdm_pp *pp, tdm_info_pp *info) ret = func_pp->pp_set_info(private_pp->pp_backend, info); TDM_WARNING_IF_FAIL(ret == TDM_ERROR_NONE); + private_pp->info = *info; + _pthread_mutex_unlock(&private_display->lock); return ret; diff --git a/src/tdm_private.h b/src/tdm_private.h index a2740a0..f66bed3 100644 --- a/src/tdm_private.h +++ b/src/tdm_private.h @@ -223,6 +223,7 @@ struct _tdm_private_pp { struct list_head pending_buffer_list; struct list_head buffer_list; + tdm_info_pp info; pid_t owner_tid; }; @@ -243,6 +244,7 @@ struct _tdm_private_capture { struct list_head pending_buffer_list; struct list_head buffer_list; + tdm_info_capture info; pid_t owner_tid; }; @@ -321,6 +323,13 @@ typedef struct _tdm_buffer_info { struct list_head link; } tdm_buffer_info; +typedef struct _tdm_pp_private_buffer { + tbm_surface_h src; + tbm_surface_h dst; + struct list_head link; + struct list_head commit_link; +} tdm_pp_private_buffer; + int tdm_display_check_module_abi(tdm_private_display *private_display, int abimaj, int abimin); -- 2.7.4 From 5fd366dd8c8e882db91851d9c5c45508e703c589 Mon Sep 17 00:00:00 2001 From: Boram Park Date: Wed, 20 Jul 2016 13:43:45 +0900 Subject: [PATCH 10/16] enhance the display information Change-Id: Ie6a52cda9734137d9a76b4f0f1605869e108d454 --- src/tdm.c | 61 -------- src/tdm_helper.c | 387 ++++++++++++++++++++++++++---------------------- src/tdm_macro.h | 16 ++ tools/tdm_test_server.c | 5 +- 4 files changed, 224 insertions(+), 245 deletions(-) diff --git a/src/tdm.c b/src/tdm.c index d73e816..647230b 100644 --- a/src/tdm.c +++ b/src/tdm.c @@ -222,11 +222,6 @@ _tdm_display_update_caps_pp(tdm_private_display *private_display, tdm_caps_pp *caps) { tdm_func_display *func_display = &private_display->func_display; - char buf[1024]; - int bufsize = sizeof(buf); - char *str_buf = buf; - int *len_buf = &bufsize; - int i; tdm_error ret; if (!(private_display->capabilities & TDM_DISPLAY_CAPABILITY_PP)) @@ -243,15 +238,6 @@ _tdm_display_update_caps_pp(tdm_private_display *private_display, return TDM_ERROR_BAD_MODULE; } - TDM_DBG("pp capabilities: %x", caps->capabilities); - buf[0] = '\0'; - for (i = 0; i < caps->format_count; i++) - TDM_SNPRINTF(str_buf, len_buf, "%c%c%c%c ", FOURCC_STR(caps->formats[i])); - TDM_DBG("pp formats: %s", buf); - TDM_DBG("pp min : %dx%d", caps->min_w, caps->min_h); - TDM_DBG("pp max : %dx%d", caps->max_w, caps->max_h); - TDM_DBG("pp align: %d", caps->preferred_align); - return TDM_ERROR_NONE; } @@ -260,11 +246,6 @@ _tdm_display_update_caps_capture(tdm_private_display *private_display, tdm_caps_capture *caps) { tdm_func_display *func_display = &private_display->func_display; - char buf[1024]; - int bufsize = sizeof(buf); - char *str_buf = buf; - int *len_buf = &bufsize; - int i; tdm_error ret; if (!(private_display->capabilities & TDM_DISPLAY_CAPABILITY_CAPTURE)) @@ -281,11 +262,6 @@ _tdm_display_update_caps_capture(tdm_private_display *private_display, return TDM_ERROR_BAD_MODULE; } - buf[0] = '\0'; - for (i = 0; i < caps->format_count; i++) - TDM_SNPRINTF(str_buf, len_buf, "%c%c%c%c ", FOURCC_STR(caps->formats[i])); - TDM_DBG("capture formats: %s", buf); - return TDM_ERROR_NONE; } @@ -294,11 +270,6 @@ _tdm_display_update_caps_layer(tdm_private_display *private_display, tdm_layer *layer_backend, tdm_caps_layer *caps) { tdm_func_layer *func_layer = &private_display->func_layer; - char buf[1024]; - int bufsize = sizeof(buf); - char *str_buf = buf; - int *len_buf = &bufsize; - int i; tdm_error ret; if (!func_layer->layer_get_capability) { @@ -312,15 +283,6 @@ _tdm_display_update_caps_layer(tdm_private_display *private_display, return TDM_ERROR_BAD_MODULE; } - TDM_DBG("layer capabilities: %x", caps->capabilities); - TDM_DBG("layer zpos : %d", caps->zpos); - buf[0] = '\0'; - for (i = 0; i < caps->format_count; i++) - TDM_SNPRINTF(str_buf, len_buf, "%c%c%c%c ", FOURCC_STR(caps->formats[i])); - TDM_DBG("layer formats: %s", buf); - for (i = 0; i < caps->prop_count; i++) - TDM_DBG("layer props: %d, %s", caps->props[i].id, caps->props[i].name); - return TDM_ERROR_NONE; } @@ -330,7 +292,6 @@ _tdm_display_update_caps_output(tdm_private_display *private_display, int pipe, { tdm_func_output *func_output = &private_display->func_output; char temp[TDM_NAME_LEN]; - int i; tdm_error ret; if (!func_output->output_get_capability) { @@ -348,28 +309,6 @@ _tdm_display_update_caps_output(tdm_private_display *private_display, int pipe, snprintf(temp, TDM_NAME_LEN, "%s-%d", caps->model, pipe); snprintf(caps->model, TDM_NAME_LEN, "%s", temp); - TDM_DBG("output maker: %s", caps->maker); - TDM_DBG("output model: %s", caps->model); - TDM_DBG("output name: %s", caps->name); - TDM_DBG("output status: %d", caps->status); - TDM_DBG("output type : %d", caps->type); - for (i = 0; i < caps->prop_count; i++) - TDM_DBG("output props: %d, %s", caps->props[i].id, caps->props[i].name); - for (i = 0; i < caps->mode_count; i++) { - TDM_DBG("output modes: name(%s), clock(%d) vrefresh(%d), flags(%x), type(%d)", - caps->modes[i].name, caps->modes[i].clock, caps->modes[i].vrefresh, - caps->modes[i].flags, caps->modes[i].type); - TDM_DBG("\t\t %d, %d, %d, %d, %d", - caps->modes[i].hdisplay, caps->modes[i].hsync_start, caps->modes[i].hsync_end, - caps->modes[i].htotal, caps->modes[i].hskew); - TDM_DBG("\t\t %d, %d, %d, %d, %d", - caps->modes[i].vdisplay, caps->modes[i].vsync_start, caps->modes[i].vsync_end, - caps->modes[i].vtotal, caps->modes[i].vscan); - } - TDM_DBG("output min : %dx%d", caps->min_w, caps->min_h); - TDM_DBG("output max : %dx%d", caps->max_w, caps->max_h); - TDM_DBG("output align: %d", caps->preferred_align); - return TDM_ERROR_NONE; } diff --git a/src/tdm_helper.c b/src/tdm_helper.c index b9ad240..f2955ec 100644 --- a/src/tdm_helper.c +++ b/src/tdm_helper.c @@ -494,230 +494,255 @@ tdm_helper_capture_output(tdm_output *output, tbm_surface_h dst_buffer, EXTERN void tdm_helper_get_display_information(tdm_display *dpy, char *reply, int *len) { - const char *name, *vendor; - int major, minor; + tdm_private_display *private_display; + tdm_backend_module *module_data; + tdm_func_output *func_output; + tdm_func_layer *func_layer; + tdm_private_output *private_output = NULL; + tdm_private_layer *private_layer = NULL; + tdm_private_pp *private_pp = NULL; + tdm_private_capture *private_capture = NULL; tdm_error ret; - int i, count; - tdm_output *output; - const tdm_prop *props; - int min_w, min_h, max_w, max_h, preferred_align; - const tbm_format *formats; - tdm_display_capability display_caps; + int i; - ret = tdm_display_get_backend_info(dpy, &name, &vendor, &major, &minor); - TDM_DBG_RETURN_IF_FAIL(ret == TDM_ERROR_NONE); + TDM_DBG_RETURN_IF_FAIL(dpy != NULL); - TDM_SNPRINTF(reply, len, "TDM backend name: %s\n", name); - TDM_SNPRINTF(reply, len, "TDM backend vendor: %s\n", vendor); - TDM_SNPRINTF(reply, len, "TDM backend version: %d.%d\n\n", major, minor); + private_display = dpy; + func_output = &private_display->func_output; + func_layer = &private_display->func_layer; + _pthread_mutex_lock(&private_display->lock); - ret = tdm_display_get_output_count(dpy, &count); - TDM_DBG_RETURN_IF_FAIL(ret == TDM_ERROR_NONE); + /* 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); + 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, "-------------------------------------------------------------------------------------------\n"); - TDM_SNPRINTF(reply, len, "idx maker model name type status dpms subpix prefer min max phy\n"); - TDM_SNPRINTF(reply, len, "-------------------------------------------------------------------------------------------\n"); - - for (i = 0; i < count; i++) { - /* idx maker model name type status dpms subpix prefer min max phy */ - const char *maker, *model, *name; - tdm_output_type type; - tdm_output_conn_status status; - unsigned int subpixel; - unsigned int mmWidth, mmHeight; - tdm_output_dpms dpms; - const tdm_output_mode *mode, *modes; - int j, cnt; - - output = tdm_display_get_output(dpy, i, &ret); - TDM_DBG_RETURN_IF_FAIL(ret == TDM_ERROR_NONE); - ret = tdm_output_get_model_info(output, &maker, &model, &name); - TDM_DBG_RETURN_IF_FAIL(ret == TDM_ERROR_NONE); - ret = tdm_output_get_output_type(output, &type); - TDM_DBG_RETURN_IF_FAIL(ret == TDM_ERROR_NONE); - ret = tdm_output_get_conn_status(output, &status); - TDM_DBG_RETURN_IF_FAIL(ret == TDM_ERROR_NONE); - ret = tdm_output_get_dpms(output, &dpms); - TDM_DBG_RETURN_IF_FAIL(ret == TDM_ERROR_NONE); - ret = tdm_output_get_subpixel(output, &subpixel); - TDM_DBG_RETURN_IF_FAIL(ret == TDM_ERROR_NONE); - ret = tdm_output_get_available_size(output, &min_w, &min_h, &max_w, &max_h, &preferred_align); - TDM_DBG_RETURN_IF_FAIL(ret == TDM_ERROR_NONE); - ret = tdm_output_get_physical_size(output, &mmWidth, &mmHeight); - TDM_DBG_RETURN_IF_FAIL(ret == TDM_ERROR_NONE); - + 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) { TDM_SNPRINTF(reply, len, "%d %s %s %s %s %s %s %d %d %dx%d %dx%d %dx%d\n", - i, maker, model, name, tdm_conn_str(type), tdm_status_str(status), - tdm_dpms_str(dpms), subpixel, preferred_align, - min_w, min_h, max_w, max_h, mmWidth, mmHeight); - - ret = tdm_output_get_mode(output, &mode); - TDM_DBG_RETURN_IF_FAIL(ret == TDM_ERROR_NONE); - - ret = tdm_output_get_available_modes(output, &modes, &cnt); - TDM_DBG_RETURN_IF_FAIL(ret == TDM_ERROR_NONE); - - TDM_SNPRINTF(reply, len, "\t%d modes:\n", cnt); - - if (cnt > 0) { - TDM_SNPRINTF(reply, len, "\t\tname refresh (Hz) hdisp hss hse htot vdisp vss vse vtot\n"); - for (j = 0; j < cnt; j++) { - char *current = (mode == modes + j) ? "*" : " "; + private_output->index, private_output->caps.maker, + private_output->caps.model, private_output->caps.name, + tdm_conn_str(private_output->caps.type), + tdm_status_str(private_output->caps.status), + tdm_dpms_str(private_output->current_dpms_value), + private_output->caps.subpixel, + private_output->caps.preferred_align, + private_output->caps.min_w, private_output->caps.min_h, + private_output->caps.max_w, private_output->caps.max_h, + private_output->caps.mmWidth, private_output->caps.mmHeight); + + TDM_SNPRINTF(reply, len, "\t%d 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) hdisp hss hse htot vdisp vss vse vtot\n"); + for (i = 0; i < private_output->caps.mode_count; i++) { + char *current = (current_mode == private_output->caps.modes + i) ? "*" : " "; TDM_SNPRINTF(reply, len, "\t\t%s%s %d %d %d %d %d %d %d %d %d ", current, - modes[j].name, - modes[j].vrefresh, - modes[j].hdisplay, - modes[j].hsync_start, - modes[j].hsync_end, - modes[j].htotal, - modes[j].vdisplay, - modes[j].vsync_start, - modes[j].vsync_end, - modes[j].vtotal); - tdm_mode_flag_str(modes[j].flags, &reply, len); + private_output->caps.modes[i].name, + private_output->caps.modes[i].vrefresh, + private_output->caps.modes[i].hdisplay, + private_output->caps.modes[i].hsync_start, + private_output->caps.modes[i].hsync_end, + private_output->caps.modes[i].htotal, + private_output->caps.modes[i].vdisplay, + private_output->caps.modes[i].vsync_start, + private_output->caps.modes[i].vsync_end, + private_output->caps.modes[i].vtotal); + tdm_mode_flag_str(private_output->caps.modes[i].flags, &reply, len); TDM_SNPRINTF(reply, len, " "); - tdm_mode_type_str(modes[j].type, &reply, len); + tdm_mode_type_str(private_output->caps.modes[i].type, &reply, len); TDM_SNPRINTF(reply, len, "\n"); } } - ret = tdm_output_get_available_properties(output, &props, &cnt); - TDM_DBG_RETURN_IF_FAIL(ret == TDM_ERROR_NONE); - - TDM_SNPRINTF(reply, len, "\t%d properties:\n", cnt); - if (cnt > 0) { - TDM_SNPRINTF(reply, len, "\t\tname idx value\n"); - for (j = 0; j < cnt; j++) { + 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"); + for (i = 0; i < private_output->caps.prop_count; i++) { tdm_value value; - ret = tdm_output_get_property(output, props[j].id, &value); - TDM_SNPRINTF(reply, len, "\t\t%s %d %d\n", - props[j].name, - props[j].id, + TDM_DBG_GOTO_IF_FAIL(func_output->output_get_property, unlock); + 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%d\t%d\n", + private_output->caps.props[i].name, + private_output->caps.props[i].id, value.u32); } } - TDM_SNPRINTF(reply, len, "\n"); } + TDM_SNPRINTF(reply, len, "\n"); + /* layer information */ TDM_SNPRINTF(reply, len, "[Layer information]\n"); - for (i = 0; i < count; i++) { - int j, cnt; - - output = tdm_display_get_output(dpy, i, &ret); - TDM_DBG_RETURN_IF_FAIL(ret == TDM_ERROR_NONE); - - ret = tdm_output_get_layer_count(output, &cnt); - TDM_DBG_RETURN_IF_FAIL(ret == TDM_ERROR_NONE); - - if (cnt > 0) { - TDM_SNPRINTF(reply, len, "-----------------------------------------------------\n"); - TDM_SNPRINTF(reply, len, "idx output zpos buf info caps\n"); - TDM_SNPRINTF(reply, len, "-----------------------------------------------------\n"); - for (j = 0; j < cnt; j++) { - tdm_layer *layer; - tbm_surface_h buf; - tdm_layer_capability layer_caps; - int k, c, zpos; + 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_layer, &private_output->layer_list, link) { + if (!private_layer->usable) { tdm_info_layer info; + unsigned int format; + tdm_size size; + tbm_surface_info_s buf_info; + TDM_DBG_GOTO_IF_FAIL(func_layer->layer_get_info, unlock); 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); - layer = tdm_output_get_layer(output, j, &ret); - TDM_DBG_RETURN_IF_FAIL(ret == TDM_ERROR_NONE); - ret = tdm_layer_get_capabilities(layer, &layer_caps); - TDM_DBG_RETURN_IF_FAIL(ret == TDM_ERROR_NONE); - ret = tdm_layer_get_zpos(layer, &zpos); - TDM_DBG_RETURN_IF_FAIL(ret == TDM_ERROR_NONE); + format = tbm_surface_get_format(private_layer->showing_buffer); + tbm_surface_get_info(private_layer->showing_buffer, &buf_info); - ret = tdm_layer_get_info(layer, &info); - buf = tdm_layer_get_displaying_buffer(layer, &ret); + if (IS_RGB(format)) + size.h = buf_info.planes[0].stride >> 2; + else + size.h = buf_info.planes[0].stride; + size.v = tbm_surface_get_height(private_layer->showing_buffer); if (info.src_config.format) - TDM_SNPRINTF(reply, len, "%d %d %d %p %c%c%c%c %dx%d (%d,%d %dx%d) (%d,%d %dx%d) trans(%d) ", - j, i, zpos, buf, - FOURCC_STR(info.src_config.format), info.src_config.size.h, info.src_config.size.v, - info.src_config.pos.x, info.src_config.pos.y, info.src_config.pos.w, info.src_config.pos.h, - info.dst_pos.x, info.dst_pos.y, info.dst_pos.w, info.dst_pos.h, - info.transform); - else - TDM_SNPRINTF(reply, len, "%d %d %d %p %c%c%c%c %dx%d (%d,%d %dx%d) (%d,%d %dx%d) trans(%d) ", - j, i, zpos, buf, - 'N', 'O', 'N', 'E', info.src_config.size.h, info.src_config.size.v, - info.src_config.pos.x, info.src_config.pos.y, info.src_config.pos.w, info.src_config.pos.h, - info.dst_pos.x, info.dst_pos.y, info.dst_pos.w, info.dst_pos.h, - info.transform); - tdm_layer_caps_str(layer_caps, &reply, len); - TDM_SNPRINTF(reply, len, "\n"); + format = (info.src_config.format)?:format; + + TDM_SNPRINTF(reply, len, "%d %d %d %p %c%c%c%c %dx%d %dx%d+%d+%d %dx%d+%d+%d %s\n", + private_layer->index, + private_output->index, + private_layer->caps.zpos, + private_layer->showing_buffer, FOURCC_STR(format), size.h, size.v, + info.src_config.pos.w, info.src_config.pos.h, info.src_config.pos.x, info.src_config.pos.y, + info.dst_pos.w, info.dst_pos.h, info.dst_pos.x, info.dst_pos.y, + tdm_transform_str(info.transform)); + } else { + TDM_SNPRINTF(reply, len, "%d %d %d -\n", + private_layer->index, + private_output->index, + private_layer->caps.zpos); + } - ret = tdm_layer_get_available_properties(layer, &props, &c); - TDM_DBG_RETURN_IF_FAIL(ret == TDM_ERROR_NONE); - TDM_SNPRINTF(reply, len, "\t%d properties:\n", c); - if (c > 0) { - TDM_SNPRINTF(reply, len, "\t\tname idx value\n"); - for (k = 0; k < c; k++) { - tdm_value value; - ret = tdm_layer_get_property(layer, props[k].id, &value); - TDM_SNPRINTF(reply, len, "\t\t%s %d %d\n", - props[k].name, - props[k].id, - value.u32); - } - } + TDM_SNPRINTF(reply, len, "\tcaps\t: "); + tdm_layer_caps_str(private_layer->caps.capabilities, &reply, len); + TDM_SNPRINTF(reply, len, "\n"); - ret = tdm_layer_get_available_formats(layer, &formats, &c); - TDM_DBG_RETURN_IF_FAIL(ret == TDM_ERROR_NONE); - TDM_SNPRINTF(reply, len, "\tformats:"); - for (k = 0; k < c; k++) - TDM_SNPRINTF(reply, len, " %c%c%c%c", FOURCC_STR(formats[k])); + TDM_SNPRINTF(reply, len, "\tformats\t: "); + if (private_layer->caps.format_count > 0) { + const char *sep = ""; + for (i = 0; i < private_layer->caps.format_count; i++) { + TDM_SNPRINTF(reply, len, "%s%c%c%c%c", sep, FOURCC_STR(private_layer->caps.formats[i])); + sep = ","; + } TDM_SNPRINTF(reply, len, "\n"); } + + TDM_SNPRINTF(reply, len, "\t%d properties:\n", private_layer->caps.prop_count); + if (private_layer->caps.prop_count > 0) { + TDM_SNPRINTF(reply, len, "\t\tname\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); + 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%d\t%d\n", + private_layer->caps.props[i].name, + private_layer->caps.props[i].id, + value.u32); + } + } } } - TDM_SNPRINTF(reply, len, "\n"); - ret = tdm_display_get_capabilities(dpy, &display_caps); - TDM_DBG_RETURN_IF_FAIL(ret == TDM_ERROR_NONE); - - if (display_caps & TDM_DISPLAY_CAPABILITY_PP) { - tdm_pp_capability pp_caps; - - ret = tdm_display_get_pp_capabilities(dpy, &pp_caps); - TDM_DBG_RETURN_IF_FAIL(ret == TDM_ERROR_NONE); - ret = tdm_display_get_pp_available_formats(dpy, &formats, &count); - TDM_DBG_RETURN_IF_FAIL(ret == TDM_ERROR_NONE); - ret = tdm_display_get_pp_available_size(dpy, &min_w, &min_h, &max_w, &max_h, &preferred_align); - TDM_DBG_RETURN_IF_FAIL(ret == TDM_ERROR_NONE); - + if (private_display->capabilities & TDM_DISPLAY_CAPABILITY_PP) { + const char *sep = ""; TDM_SNPRINTF(reply, len, "[PP information]\n"); - TDM_SNPRINTF(reply, len, "caps: "); - tdm_pp_caps_str(pp_caps, &reply, len); + TDM_SNPRINTF(reply, len, "caps\t: "); + tdm_pp_caps_str(private_display->caps_pp.capabilities, &reply, len); TDM_SNPRINTF(reply, len, "\n"); - TDM_SNPRINTF(reply, len, "formats: "); - for (i = 0; i < count; i++) - TDM_SNPRINTF(reply, len, " %c%c%c%c", FOURCC_STR(formats[i])); + TDM_SNPRINTF(reply, len, "formats\t: "); + for (i = 0; i < private_display->caps_pp.format_count; i++) { + TDM_SNPRINTF(reply, len, "%s%c%c%c%c", sep, FOURCC_STR(private_display->caps_pp.formats[i])); + sep = ","; + } TDM_SNPRINTF(reply, len, "\n"); - TDM_SNPRINTF(reply, len, "size: min(%dx%d) max(%dx%d) preferred(%d)\n", - min_w, min_h, max_w, max_h, preferred_align); + TDM_SNPRINTF(reply, len, "size\t: min(%dx%d) max(%dx%d) align_w(%d)\n", + private_display->caps_pp.min_w, private_display->caps_pp.min_h, + private_display->caps_pp.max_w, private_display->caps_pp.max_h, + private_display->caps_pp.preferred_align); + if (!LIST_IS_EMPTY(&private_display->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) { + TDM_SNPRINTF(reply, len, "%c%c%c%c %dx%d %dx%d+%d+%d | %c%c%c%c %dx%d %dx%d+%d+%d | %s\n", + FOURCC_STR(private_pp->info.src_config.format), + private_pp->info.src_config.size.h, + private_pp->info.src_config.size.v, + private_pp->info.src_config.pos.x, private_pp->info.src_config.pos.y, + private_pp->info.src_config.pos.w, private_pp->info.src_config.pos.h, + FOURCC_STR(private_pp->info.dst_config.format), + private_pp->info.dst_config.size.h, + private_pp->info.dst_config.size.v, + private_pp->info.dst_config.pos.x, private_pp->info.dst_config.pos.y, + private_pp->info.dst_config.pos.w, private_pp->info.dst_config.pos.h, + tdm_transform_str(private_pp->info.transform)); + } + } + } else { + TDM_SNPRINTF(reply, len, "[No PP capability]\n"); } + TDM_SNPRINTF(reply, len, "\n"); - if (display_caps & TDM_DISPLAY_CAPABILITY_CAPTURE) { - tdm_capture_capability capture_caps; - - ret = tdm_display_get_capture_capabilities(dpy, &capture_caps); - TDM_DBG_RETURN_IF_FAIL(ret == TDM_ERROR_NONE); - ret = tdm_display_get_catpure_available_formats(dpy, &formats, &count); - TDM_DBG_RETURN_IF_FAIL(ret == TDM_ERROR_NONE); - + if (private_display->capabilities & TDM_DISPLAY_CAPABILITY_CAPTURE) { + const char *sep = ""; TDM_SNPRINTF(reply, len, "[Capture information]\n"); - TDM_SNPRINTF(reply, len, "caps: "); - tdm_capture_caps_str(capture_caps, &reply, len); + TDM_SNPRINTF(reply, len, "caps\t: "); + tdm_capture_caps_str(private_display->caps_capture.capabilities, &reply, len); TDM_SNPRINTF(reply, len, "\n"); - TDM_SNPRINTF(reply, len, "formats: "); - for (i = 0; i < count; i++) - TDM_SNPRINTF(reply, len, " %c%c%c%c", FOURCC_STR(formats[i])); + TDM_SNPRINTF(reply, len, "formats\t: "); + for (i = 0; i < private_display->caps_capture.format_count; i++) { + TDM_SNPRINTF(reply, len, "%s%c%c%c%c", sep, FOURCC_STR(private_display->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", + private_display->caps_capture.min_w, private_display->caps_capture.min_h, + private_display->caps_capture.max_w, private_display->caps_capture.max_h, + private_display->caps_capture.preferred_align); + if (!LIST_IS_EMPTY(&private_display->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) { + TDM_SNPRINTF(reply, len, "%c%c%c%c %dx%d %dx%d+%d+%d | %s\n", + FOURCC_STR(private_capture->info.dst_config.format), + private_capture->info.dst_config.size.h, + private_capture->info.dst_config.size.v, + private_capture->info.dst_config.pos.x, private_capture->info.dst_config.pos.y, + private_capture->info.dst_config.pos.w, private_capture->info.dst_config.pos.h, + tdm_transform_str(private_capture->info.transform)); + } + } + } else { + TDM_SNPRINTF(reply, len, "[No Capture capability]\n"); } + TDM_SNPRINTF(reply, len, "\n"); + +unlock: + _pthread_mutex_unlock(&private_display->lock); } diff --git a/src/tdm_macro.h b/src/tdm_macro.h index fe762c2..bc4c0bd 100644 --- a/src/tdm_macro.h +++ b/src/tdm_macro.h @@ -200,12 +200,28 @@ static struct tdm_type_name tdm_conn_names[] = { }; TDM_TYPE_NAME_FN(conn) +static struct tdm_type_name tdm_transform_names[] = { + { TDM_TRANSFORM_NORMAL, "none" }, + { TDM_TRANSFORM_90, "90" }, + { TDM_TRANSFORM_180, "180" }, + { TDM_TRANSFORM_270, "270" }, + { TDM_TRANSFORM_FLIPPED, "flipped" }, + { TDM_TRANSFORM_FLIPPED_90, "90,flipped" }, + { TDM_TRANSFORM_FLIPPED_180, "180,flipped" }, + { TDM_TRANSFORM_FLIPPED_270, "270,flipped" }, +}; +TDM_TYPE_NAME_FN(transform) + #define TDM_BIT_NAME_FB(res) \ static inline const char * tdm_##res##_str(int type, char **reply, int *len) \ { \ unsigned int i; \ const char *sep = ""; \ + if (type == 0) { \ + TDM_SNPRINTF(*reply, len, "none"); \ + return NULL; \ + } \ for (i = 0; i < TDM_ARRAY_SIZE(tdm_##res##_names); i++) { \ if (type & (1 << i)) { \ TDM_SNPRINTF(*reply, len, "%s%s", sep, tdm_##res##_names[i]); \ diff --git a/tools/tdm_test_server.c b/tools/tdm_test_server.c index aec7aee..95d78c0 100644 --- a/tools/tdm_test_server.c +++ b/tools/tdm_test_server.c @@ -709,10 +709,9 @@ print_args(tdm_test_server *data) tdm_test_server_capture *c = NULL; tdm_test_server_prop *w = NULL; - if (data->do_query) { - printf("query\n"); + if (data->do_query) return; - } + LIST_FOR_EACH_ENTRY(o, &data->output_list, link) { printf("output %d: %s", o->idx, o->mode); if (o->refresh > 0) -- 2.7.4 From 66351811df6ed459ac3a19197e96e61884947a7f Mon Sep 17 00:00:00 2001 From: Boram Park Date: Thu, 21 Jul 2016 14:39:08 +0900 Subject: [PATCH 11/16] add the buffer clear helper function Change-Id: Id9b20d38b3d1558d0a59db30b7ec302775f2f943 --- include/tdm_helper.h | 17 +++++++++++++++++ src/tdm_helper.c | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 68 insertions(+) diff --git a/include/tdm_helper.h b/include/tdm_helper.h index d526981..7342e5d 100644 --- a/include/tdm_helper.h +++ b/include/tdm_helper.h @@ -69,6 +69,23 @@ void tdm_helper_dump_buffer(tbm_surface_h buffer, const char *file); /** + * @brief fill a buffer with 0. + * @details + * This function supports only if a buffer has below formats. + * - TBM_FORMAT_ARGB8888 + * - TBM_FORMAT_XRGB8888 + * - TBM_FORMAT_YVU420 + * - TBM_FORMAT_YUV420 + * - TBM_FORMAT_NV12 + * - TBM_FORMAT_NV21 + * - TBM_FORMAT_YUYV + * - TBM_FORMAT_UYVY + * @param[in] buffer A TDM buffer + */ +void +tdm_helper_clear_buffer(tbm_surface_h buffer); + +/** * @brief Get a fd from the given enviroment variable. * @details * This function will dup the fd of the given enviroment variable. The Caller diff --git a/src/tdm_helper.c b/src/tdm_helper.c index f2955ec..92d7545 100644 --- a/src/tdm_helper.c +++ b/src/tdm_helper.c @@ -265,6 +265,57 @@ tdm_helper_dump_buffer(tbm_surface_h buffer, const char *file) TDM_INFO("dump %s", file); } +EXTERN void +tdm_helper_clear_buffer(tbm_surface_h buffer) +{ + tbm_surface_info_s info; + int ret; + + TDM_RETURN_IF_FAIL(buffer != NULL); + + ret = tbm_surface_map(buffer, TBM_OPTION_READ, &info); + TDM_RETURN_IF_FAIL(ret == TBM_SURFACE_ERROR_NONE); + + switch (info.format) { + case TBM_FORMAT_ARGB8888: + case TBM_FORMAT_XRGB8888: + memset(info.planes[0].ptr, 0, info.planes[0].stride * info.height); + break; + case TBM_FORMAT_YVU420: + case TBM_FORMAT_YUV420: + 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)); + memset((char*)info.planes[2].ptr, 0x80, info.planes[2].stride * (info.height >> 1)); + break; + case TBM_FORMAT_NV12: + case TBM_FORMAT_NV21: + 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; + } + + tbm_surface_unmap(buffer); +} + EXTERN int tdm_helper_get_fd(const char *env) { -- 2.7.4 From 7268ade514fc6cb79c7754e5696cbc169025ef3f Mon Sep 17 00:00:00 2001 From: Boram Park Date: Thu, 21 Jul 2016 10:30:23 +0900 Subject: [PATCH 12/16] correct the wrong behavior of tdm-test-server Change-Id: I5cba2ec5dbb8e8d42fda82f9d5a7b17b04ed49dd --- include/tdm.h | 9 ++ src/tdm_display.c | 21 +++ tools/buffers.c | 95 ++++++------- tools/tdm_test_server.c | 345 ++++++++++++++++++++++++------------------------ 4 files changed, 254 insertions(+), 216 deletions(-) diff --git a/include/tdm.h b/include/tdm.h index fa0a7f0..8b29a49 100644 --- a/include/tdm.h +++ b/include/tdm.h @@ -377,6 +377,15 @@ tdm_error tdm_output_get_pipe(tdm_output *output, unsigned int *pipe); /** + * @brief Get the index of a primary layer. + * @param[in] output A output object + * @param[out] index The primary layer index + * @return #TDM_ERROR_NONE if success. Otherwise, error value. + */ +tdm_error +tdm_output_get_primary_index(tdm_output *output, int *index); + +/** * @brief Set the property which has a given id. * @param[in] output A output object * @param[in] id The property id diff --git a/src/tdm_display.c b/src/tdm_display.c index f1bbca5..d84e329 100644 --- a/src/tdm_display.c +++ b/src/tdm_display.c @@ -745,6 +745,27 @@ tdm_output_get_pipe(tdm_output *output, unsigned int *pipe) return ret; } +EXTERN tdm_error +tdm_output_get_primary_index(tdm_output *output, int *index) +{ + tdm_private_layer *private_layer = NULL; + + OUTPUT_FUNC_ENTRY(); + TDM_RETURN_VAL_IF_FAIL(index != NULL, TDM_ERROR_INVALID_PARAMETER); + + _pthread_mutex_lock(&private_display->lock); + + LIST_FOR_EACH_ENTRY(private_layer, &private_output->layer_list, link) { + if (private_layer->caps.capabilities & TDM_LAYER_CAPABILITY_PRIMARY) { + *index = private_layer->index; + break; + } + } + + _pthread_mutex_unlock(&private_display->lock); + + return ret; +} EXTERN tdm_error tdm_output_set_property(tdm_output *output, unsigned int id, tdm_value value) diff --git a/tools/buffers.c b/tools/buffers.c index c4de575..805383b 100644 --- a/tools/buffers.c +++ b/tools/buffers.c @@ -41,6 +41,7 @@ #include "tdm_macro.h" #include "buffers.h" +#define ALPHA_VALUE 100 #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0])) /* ----------------------------------------------------------------------------- @@ -401,32 +402,32 @@ fill_smpte_rgb16(const struct rgb_info *rgb, unsigned char *mem, unsigned int width, unsigned int height, unsigned int stride) { const uint16_t colors_top[] = { - MAKE_RGBA(rgb, 192, 192, 192, 255), /* grey */ - MAKE_RGBA(rgb, 192, 192, 0, 255), /* yellow */ - MAKE_RGBA(rgb, 0, 192, 192, 255), /* cyan */ - MAKE_RGBA(rgb, 0, 192, 0, 255), /* green */ - MAKE_RGBA(rgb, 192, 0, 192, 255), /* magenta */ - MAKE_RGBA(rgb, 192, 0, 0, 255), /* red */ - MAKE_RGBA(rgb, 0, 0, 192, 255), /* blue */ + MAKE_RGBA(rgb, 192, 192, 192, ALPHA_VALUE), /* grey */ + MAKE_RGBA(rgb, 192, 192, 0, ALPHA_VALUE), /* yellow */ + MAKE_RGBA(rgb, 0, 192, 192, ALPHA_VALUE), /* cyan */ + MAKE_RGBA(rgb, 0, 192, 0, ALPHA_VALUE), /* green */ + MAKE_RGBA(rgb, 192, 0, 192, ALPHA_VALUE), /* magenta */ + MAKE_RGBA(rgb, 192, 0, 0, ALPHA_VALUE), /* red */ + MAKE_RGBA(rgb, 0, 0, 192, ALPHA_VALUE), /* blue */ }; const uint16_t colors_middle[] = { - MAKE_RGBA(rgb, 0, 0, 192, 255), /* blue */ - MAKE_RGBA(rgb, 19, 19, 19, 255), /* black */ - MAKE_RGBA(rgb, 192, 0, 192, 255), /* magenta */ - MAKE_RGBA(rgb, 19, 19, 19, 255), /* black */ - MAKE_RGBA(rgb, 0, 192, 192, 255), /* cyan */ - MAKE_RGBA(rgb, 19, 19, 19, 255), /* black */ - MAKE_RGBA(rgb, 192, 192, 192, 255), /* grey */ + MAKE_RGBA(rgb, 0, 0, 192, ALPHA_VALUE), /* blue */ + MAKE_RGBA(rgb, 19, 19, 19, ALPHA_VALUE), /* black */ + MAKE_RGBA(rgb, 192, 0, 192, ALPHA_VALUE), /* magenta */ + MAKE_RGBA(rgb, 19, 19, 19, ALPHA_VALUE), /* black */ + MAKE_RGBA(rgb, 0, 192, 192, ALPHA_VALUE), /* cyan */ + MAKE_RGBA(rgb, 19, 19, 19, ALPHA_VALUE), /* black */ + MAKE_RGBA(rgb, 192, 192, 192, ALPHA_VALUE), /* grey */ }; const uint16_t colors_bottom[] = { - MAKE_RGBA(rgb, 0, 33, 76, 255), /* in-phase */ - MAKE_RGBA(rgb, 255, 255, 255, 255), /* super white */ - MAKE_RGBA(rgb, 50, 0, 106, 255), /* quadrature */ - MAKE_RGBA(rgb, 19, 19, 19, 255), /* black */ - MAKE_RGBA(rgb, 9, 9, 9, 255), /* 3.5% */ - MAKE_RGBA(rgb, 19, 19, 19, 255), /* 7.5% */ - MAKE_RGBA(rgb, 29, 29, 29, 255), /* 11.5% */ - MAKE_RGBA(rgb, 19, 19, 19, 255), /* black */ + MAKE_RGBA(rgb, 0, 33, 76, ALPHA_VALUE), /* in-phase */ + MAKE_RGBA(rgb, 255, 255, 255, ALPHA_VALUE), /* super white */ + MAKE_RGBA(rgb, 50, 0, 106, ALPHA_VALUE), /* quadrature */ + MAKE_RGBA(rgb, 19, 19, 19, ALPHA_VALUE), /* black */ + MAKE_RGBA(rgb, 9, 9, 9, ALPHA_VALUE), /* 3.5% */ + MAKE_RGBA(rgb, 19, 19, 19, ALPHA_VALUE), /* 7.5% */ + MAKE_RGBA(rgb, 29, 29, 29, ALPHA_VALUE), /* 11.5% */ + MAKE_RGBA(rgb, 19, 19, 19, ALPHA_VALUE), /* black */ }; unsigned int x; unsigned int y; @@ -531,32 +532,32 @@ fill_smpte_rgb32(const struct rgb_info *rgb, unsigned char *mem, unsigned int width, unsigned int height, unsigned int stride) { const uint32_t colors_top[] = { - MAKE_RGBA(rgb, 192, 192, 192, 255), /* grey */ - MAKE_RGBA(rgb, 192, 192, 0, 255), /* yellow */ - MAKE_RGBA(rgb, 0, 192, 192, 255), /* cyan */ - MAKE_RGBA(rgb, 0, 192, 0, 255), /* green */ - MAKE_RGBA(rgb, 192, 0, 192, 255), /* magenta */ - MAKE_RGBA(rgb, 192, 0, 0, 255), /* red */ - MAKE_RGBA(rgb, 0, 0, 192, 255), /* blue */ + MAKE_RGBA(rgb, 192, 192, 192, ALPHA_VALUE), /* grey */ + MAKE_RGBA(rgb, 192, 192, 0, ALPHA_VALUE), /* yellow */ + MAKE_RGBA(rgb, 0, 192, 192, ALPHA_VALUE), /* cyan */ + MAKE_RGBA(rgb, 0, 192, 0, ALPHA_VALUE), /* green */ + MAKE_RGBA(rgb, 192, 0, 192, ALPHA_VALUE), /* magenta */ + MAKE_RGBA(rgb, 192, 0, 0, ALPHA_VALUE), /* red */ + MAKE_RGBA(rgb, 0, 0, 192, ALPHA_VALUE), /* blue */ }; const uint32_t colors_middle[] = { - MAKE_RGBA(rgb, 0, 0, 192, 255), /* blue */ - MAKE_RGBA(rgb, 19, 19, 19, 255), /* black */ - MAKE_RGBA(rgb, 192, 0, 192, 255), /* magenta */ - MAKE_RGBA(rgb, 19, 19, 19, 255), /* black */ - MAKE_RGBA(rgb, 0, 192, 192, 255), /* cyan */ - MAKE_RGBA(rgb, 19, 19, 19, 255), /* black */ - MAKE_RGBA(rgb, 192, 192, 192, 255), /* grey */ + MAKE_RGBA(rgb, 0, 0, 192, ALPHA_VALUE), /* blue */ + MAKE_RGBA(rgb, 19, 19, 19, ALPHA_VALUE), /* black */ + MAKE_RGBA(rgb, 192, 0, 192, ALPHA_VALUE), /* magenta */ + MAKE_RGBA(rgb, 19, 19, 19, ALPHA_VALUE), /* black */ + MAKE_RGBA(rgb, 0, 192, 192, ALPHA_VALUE), /* cyan */ + MAKE_RGBA(rgb, 19, 19, 19, ALPHA_VALUE), /* black */ + MAKE_RGBA(rgb, 192, 192, 192, ALPHA_VALUE), /* grey */ }; const uint32_t colors_bottom[] = { - MAKE_RGBA(rgb, 0, 33, 76, 255), /* in-phase */ - MAKE_RGBA(rgb, 255, 255, 255, 255), /* super white */ - MAKE_RGBA(rgb, 50, 0, 106, 255), /* quadrature */ - MAKE_RGBA(rgb, 19, 19, 19, 255), /* black */ - MAKE_RGBA(rgb, 9, 9, 9, 255), /* 3.5% */ - MAKE_RGBA(rgb, 19, 19, 19, 255), /* 7.5% */ - MAKE_RGBA(rgb, 29, 29, 29, 255), /* 11.5% */ - MAKE_RGBA(rgb, 19, 19, 19, 255), /* black */ + MAKE_RGBA(rgb, 0, 33, 76, ALPHA_VALUE), /* in-phase */ + MAKE_RGBA(rgb, 255, 255, 255, ALPHA_VALUE), /* super white */ + MAKE_RGBA(rgb, 50, 0, 106, ALPHA_VALUE), /* quadrature */ + MAKE_RGBA(rgb, 19, 19, 19, ALPHA_VALUE), /* black */ + MAKE_RGBA(rgb, 9, 9, 9, ALPHA_VALUE), /* 3.5% */ + MAKE_RGBA(rgb, 19, 19, 19, ALPHA_VALUE), /* 7.5% */ + MAKE_RGBA(rgb, 29, 29, 29, ALPHA_VALUE), /* 11.5% */ + MAKE_RGBA(rgb, 19, 19, 19, ALPHA_VALUE), /* black */ }; unsigned int x; unsigned int y; @@ -585,7 +586,7 @@ fill_smpte_rgb32(const struct rgb_info *rgb, unsigned char *mem, colors_bottom[(x - width * 5 / 7) * 3 / (width / 7) + 4]; for (; x < width; ++x) { - ((uint32_t *)mem)[x] = (rand_r(&rand_seed) % 2) ? MAKE_RGBA(rgb, 255, 255, 255, 255) : MAKE_RGBA(rgb, 0, 0, 0, 255); + ((uint32_t *)mem)[x] = (rand_r(&rand_seed) % 2) ? MAKE_RGBA(rgb, 255, 255, 255, ALPHA_VALUE) : MAKE_RGBA(rgb, 0, 0, 0, ALPHA_VALUE); } mem += stride; } @@ -751,7 +752,7 @@ fill_tiles_rgb16(const struct format_info *info, unsigned char *mem, uint16_t color = MAKE_RGBA(rgb, (rgb32 >> 16) & 0xff, (rgb32 >> 8) & 0xff, rgb32 & 0xff, - 255); + ALPHA_VALUE); ((uint16_t *)mem)[x] = color; } @@ -796,7 +797,7 @@ fill_tiles_rgb32(const struct format_info *info, unsigned char *mem, uint32_t color = MAKE_RGBA(rgb, (rgb32 >> 16) & 0xff, (rgb32 >> 8) & 0xff, rgb32 & 0xff, - 255); + ALPHA_VALUE); ((uint32_t *)mem)[x] = color; } diff --git a/tools/tdm_test_server.c b/tools/tdm_test_server.c index 95d78c0..3870448 100644 --- a/tools/tdm_test_server.c +++ b/tools/tdm_test_server.c @@ -112,7 +112,7 @@ static struct optstrings optstrs[] = { ":", NULL }, { - OPT_GEN, "b", "set the fill(smtpe,tiles,plane) and framebuffer type(scanout,noncachable,wc)", + OPT_GEN, "b", "set the fill(smtpe,tiles,plain) and framebuffer type(scanout,noncachable,wc)", "[:[,[,...]]]", NULL }, { @@ -121,11 +121,40 @@ static struct optstrings optstrs[] = { }, }; +struct usagestring { + const char *string; + const char *desc; +}; + +static struct usagestring usages[] = { + { + "-q", + NULL + }, + { + "-a -b plain", + "test all outputs, layers with plain buffers" + }, + { + "-o 0@1920x1080", + "Set the \"1920x1080\" mode to the output 0. And show a buffer via a primary layer of the output 0" + }, + { + "-o 0@1920x1080 -l 1~640x480+50+100", + "Create the 640x480 buffer and show it in the (50,100) pos of screen via the layer 1" + }, + { + "-p 320x240@NV12~480x360+80+40,640x480@AR24 -l 1~640x480+50+100", + "Convert the 320x240@NV12 buffer to the 640x480@AR24 buffer(480x360+80+40) and show the result via the layer 1" + }, +}; + static void usage(char *app_name) { int type_size = sizeof(typestrs) / sizeof(struct typestrings); int opt_size = sizeof(optstrs) / sizeof(struct optstrings); + int usages_size = sizeof(usages) / sizeof(struct usagestring); int t; printf("usage: %s \n\n", app_name); @@ -147,6 +176,13 @@ usage(char *app_name) printf("\n"); } + printf(" For example)\n\n"); + + for (t = 0; t < usages_size; t++) { + printf(" $ %s %s\n", app_name, usages[t].string); + printf("\t%s\n", usages[t].desc); + } + printf("\n"); exit(0); } @@ -159,6 +195,8 @@ static const char *tdm_buf_flag_names[] = { }; TDM_BIT_NAME_FB(buf_flag) +#define DEFAULT_FORMAT TBM_FORMAT_ARGB8888 + #define print_size(s) \ printf("%dx%d", (s)->h, (s)->v) #define print_pos(p) \ @@ -212,6 +250,8 @@ typedef struct _tdm_test_server_output { struct list_head layer_list; tdm_test_server *data; tdm_output *output; + + int fill_primary_layer; } tdm_test_server_output; typedef struct _tdm_test_server_pp { @@ -488,18 +528,16 @@ parse_args(tdm_test_server *data, int argc, char *argv[]) LIST_INITHEAD(&o->prop_list); LIST_ADDTAIL(&o->link, &data->output_list); parse_arg_o(o, argv[++i]); - last_option = o; last_object = o; } else if (!strncmp(argv[i] + 1, "p", 1)) { TDM_GOTO_IF_FAIL(data->do_all == 0, all); p = calloc(1, sizeof * p); TDM_EXIT_IF_FAIL(p != NULL); p->data = data; - p->fps = 30; + p->fps = 30; /* default 30 fps */ LIST_ADDTAIL(&p->link, &data->pp_list); parse_arg_p(p, argv[++i]); last_option = p; - last_object = o; } else if (!strncmp(argv[i] + 1, "c", 1)) { TDM_GOTO_IF_FAIL(data->do_all == 0, all); c = calloc(1, sizeof * c); @@ -510,11 +548,16 @@ parse_args(tdm_test_server *data, int argc, char *argv[]) LIST_ADDTAIL(&c->link, &data->capture_list); parse_arg_c(c, argv[++i]); last_option = c; - last_object = o; } else if (!strncmp(argv[i] + 1, "l", 1)) { TDM_GOTO_IF_FAIL(data->do_all == 0, all); - if (!o) - goto no_output; + if (!o) { + o = calloc(1, sizeof * o); + TDM_EXIT_IF_FAIL(o != NULL); + o->data = data; + LIST_INITHEAD(&o->layer_list); + LIST_INITHEAD(&o->prop_list); + LIST_ADDTAIL(&o->link, &data->output_list); + } l = calloc(1, sizeof * l); TDM_EXIT_IF_FAIL(l != NULL); LIST_INITHEAD(&l->prop_list); @@ -525,12 +568,11 @@ parse_args(tdm_test_server *data, int argc, char *argv[]) if (p && last_option == p) { p->l = l; l->owner_p = p; - } - else if (c && last_option == c) { + } else if (c && last_option == c) { c->l = l; l->owner_c = c; } - last_object = o; + last_object = l; } else if (!strncmp(argv[i] + 1, "w", 1)) { TDM_GOTO_IF_FAIL(data->do_all == 0, all); if (!last_object) @@ -551,12 +593,22 @@ parse_args(tdm_test_server *data, int argc, char *argv[]) exit(0); } } + + LIST_FOR_EACH_ENTRY(p, &data->pp_list, link) { + if (!p->l) + goto no_layer; + } + LIST_FOR_EACH_ENTRY(c, &data->capture_list, link) { + if (!c->l) + goto no_layer; + } + return; -no_output: - printf("Use '-o' to set a output first.\n"); +no_layer: + printf("Use '-l' to set a layer for '-p' or '-c'.\n"); exit(0); no_object: - printf("Use '-o' or '-l' or '-p' or '-c' to set a object first.\n"); + printf("Use '-o' or '-l' to set a object first.\n"); exit(0); all: printf("Can't use '-%s' with '-a'.\n", argv[i] + 1); @@ -570,6 +622,7 @@ interpret_args(tdm_test_server *data) tdm_test_server_layer *l = NULL; tdm_error ret; + /* create the objects of outputs */ if (data->do_all) { int i, output_count; @@ -577,9 +630,6 @@ interpret_args(tdm_test_server *data) TDM_EXIT_IF_FAIL(ret == TDM_ERROR_NONE); for (i = 0; i < output_count; i++) { - tdm_output *output; - int j, layer_count; - o = calloc(1, sizeof * o); TDM_EXIT_IF_FAIL(o != NULL); o->data = data; @@ -587,41 +637,16 @@ interpret_args(tdm_test_server *data) LIST_INITHEAD(&o->prop_list); LIST_ADDTAIL(&o->link, &data->output_list); o->idx = i; - - output = tdm_display_get_output(data->display, i, &ret); - TDM_EXIT_IF_FAIL(ret == TDM_ERROR_NONE); - ret = tdm_output_get_layer_count(output, &layer_count); - TDM_EXIT_IF_FAIL(ret == TDM_ERROR_NONE); - - for (j = 0; j < layer_count; j++) { - tdm_layer *layer; - tdm_layer_capability capabilities; - - l = calloc(1, sizeof * l); - TDM_EXIT_IF_FAIL(l != NULL); - LIST_INITHEAD(&l->prop_list); - LIST_ADDTAIL(&l->link, &o->layer_list); - l->data = data; - l->o = o; - l->idx = j; - - layer = tdm_output_get_layer(output, j, &ret); - TDM_EXIT_IF_FAIL(ret == TDM_ERROR_NONE); - ret = tdm_layer_get_capabilities(layer, &capabilities); - TDM_EXIT_IF_FAIL(ret == TDM_ERROR_NONE); - - if (capabilities & TDM_LAYER_CAPABILITY_PRIMARY) - l->is_primary = 1; - } + o->fill_primary_layer = 1; } } - /* fill layer information */ + /* check if the primary layer object exists */ LIST_FOR_EACH_ENTRY(o, &data->output_list, link) { tdm_output *output; const tdm_output_mode *mode; - int minw, minh, maxw, maxh; - int layer_count, i = 1; + int j, layer_count, primary_index = 0; + tdm_test_server_layer *primary_l = NULL; output_setup(o); @@ -631,142 +656,96 @@ interpret_args(tdm_test_server *data) TDM_EXIT_IF_FAIL(ret == TDM_ERROR_NONE); ret = tdm_output_get_layer_count(output, &layer_count); TDM_EXIT_IF_FAIL(ret == TDM_ERROR_NONE); - ret = tdm_output_get_available_size(output, &minw, &minh, &maxw, &maxh, NULL); + ret = tdm_output_get_primary_index(output, &primary_index); TDM_EXIT_IF_FAIL(ret == TDM_ERROR_NONE); - if (LIST_IS_EMPTY(&o->layer_list)) { - ret = tdm_output_get_layer_count(output, &layer_count); - TDM_EXIT_IF_FAIL(ret == TDM_ERROR_NONE); - - for (i = 0; i < layer_count; i++) { - tdm_layer *layer; - tdm_layer_capability capabilities; - - layer = tdm_output_get_layer(output, i, &ret); - TDM_EXIT_IF_FAIL(ret == TDM_ERROR_NONE); - ret = tdm_layer_get_capabilities(layer, &capabilities); - TDM_EXIT_IF_FAIL(ret == TDM_ERROR_NONE); + if (LIST_IS_EMPTY(&o->layer_list)) + o->fill_primary_layer = 1; + else { + LIST_FOR_EACH_ENTRY(l, &o->layer_list, link) { + if (l->idx == primary_index) { + l->is_primary = 1; + o->fill_primary_layer = 1; + primary_l = l; + break; + } + } + } - if (!(capabilities & TDM_LAYER_CAPABILITY_PRIMARY)) + if (!primary_l || data->do_all) { + for (j = 0; j < layer_count; j++) { + if (j != primary_index && !data->do_all) continue; - l = calloc(1, sizeof * l); TDM_EXIT_IF_FAIL(l != NULL); LIST_INITHEAD(&l->prop_list); LIST_ADDTAIL(&l->link, &o->layer_list); l->data = data; l->o = o; - l->idx = i; - l->is_primary = 1; - l->info.src_config.pos.w = l->info.src_config.size.h = mode->hdisplay; - l->info.src_config.pos.h = l->info.src_config.size.v = mode->vdisplay; - l->info.dst_pos = l->info.src_config.pos; - } - } else { - LIST_FOR_EACH_ENTRY(l, &o->layer_list, link) { - if (l->info.dst_pos.w == 0) { - TDM_EXIT_IF_FAIL(!l->owner_p && !l->owner_c); - if (l->is_primary) { - l->info.dst_pos.w = mode->hdisplay; - l->info.dst_pos.h = mode->vdisplay; - } else { - l->info.dst_pos.w = TDM_ALIGN(mode->hdisplay / 3, 2); - l->info.dst_pos.h = TDM_ALIGN(mode->vdisplay / 3, 2); - l->info.dst_pos.x = TDM_ALIGN(((mode->hdisplay / 3) / layer_count) * i, 2); - l->info.dst_pos.y = TDM_ALIGN(((mode->vdisplay / 3) / layer_count) * i, 2); - i++; - } - } - if (minw > 0 && minh > 0) { - TDM_EXIT_IF_FAIL(l->info.dst_pos.w >= minw); - TDM_EXIT_IF_FAIL(l->info.dst_pos.h >= minh); - } - if (maxw > 0 && maxh > 0) { - TDM_EXIT_IF_FAIL(l->info.dst_pos.w <= maxw); - TDM_EXIT_IF_FAIL(l->info.dst_pos.h <= maxh); - } - if (l->owner_p) { - l->info.src_config = l->owner_p->info.dst_config; - } else if (l->owner_c) { - l->info.src_config = l->owner_c->info.dst_config; + l->idx = j; + if (j == primary_index) { + l->is_primary = 1; + l->info.dst_pos.w = mode->hdisplay; + l->info.dst_pos.h = mode->vdisplay; + primary_l = l; } else { - if (l->info.src_config.pos.w == 0) { - l->info.src_config.pos.w = l->info.dst_pos.w; - l->info.src_config.pos.h = l->info.dst_pos.h; - } + l->info.dst_pos.w = TDM_ALIGN(mode->hdisplay / 3, 2); + l->info.dst_pos.h = TDM_ALIGN(mode->vdisplay / 3, 2); + l->info.dst_pos.x = TDM_ALIGN(((mode->hdisplay / 3) / layer_count) * j, 2); + l->info.dst_pos.y = TDM_ALIGN(((mode->vdisplay / 3) / layer_count) * j, 2); } } } + + TDM_EXIT_IF_FAIL(primary_l != NULL); + LIST_DEL(&primary_l->link); + LIST_ADD(&primary_l->link, &o->layer_list); } -} -static void -print_args(tdm_test_server *data) -{ - tdm_test_server_output *o = NULL; - tdm_test_server_layer *l = NULL; - tdm_test_server_pp *p = NULL; - tdm_test_server_capture *c = NULL; - tdm_test_server_prop *w = NULL; + /* fill the empty information of layers */ + LIST_FOR_EACH_ENTRY(o, &data->output_list, link) { + tdm_output *output; + int minw, minh, maxw, maxh; - if (data->do_query) - return; + output = tdm_display_get_output(data->display, o->idx, &ret); + TDM_EXIT_IF_FAIL(ret == TDM_ERROR_NONE); + ret = tdm_output_get_available_size(output, &minw, &minh, &maxw, &maxh, NULL); + TDM_EXIT_IF_FAIL(ret == TDM_ERROR_NONE); - LIST_FOR_EACH_ENTRY(o, &data->output_list, link) { - printf("output %d: %s", o->idx, o->mode); - if (o->refresh > 0) - printf(" %d\n", o->refresh); - else - printf("\n"); - if (!LIST_IS_EMPTY(&o->prop_list)) { - printf("\tprops: "); - LIST_FOR_EACH_ENTRY(w, &o->prop_list, link) { - print_prop(w); - printf(" "); - } - printf("\n"); - } + /* l->info.src_config.size will be decided when a buffer shows really */ LIST_FOR_EACH_ENTRY(l, &o->layer_list, link) { - printf("\t"); - printf("layer %d: ", l->idx); - print_config(&l->info.src_config); - printf(" ! "); - print_pos(&l->info.dst_pos); - printf(" trans(%d)\n", l->info.transform); - if (!LIST_IS_EMPTY(&l->prop_list)) { - printf("\t\tprops: "); - LIST_FOR_EACH_ENTRY(w, &l->prop_list, link) { - print_prop(w); - printf(" "); + if (minw > 0 && minh > 0) { + TDM_EXIT_IF_FAIL(l->info.dst_pos.w >= minw); + TDM_EXIT_IF_FAIL(l->info.dst_pos.h >= minh); + } + if (maxw > 0 && maxh > 0) { + TDM_EXIT_IF_FAIL(l->info.dst_pos.w <= maxw); + TDM_EXIT_IF_FAIL(l->info.dst_pos.h <= maxh); + } + + if (l->owner_p) { + l->info.src_config.format = l->owner_p->info.dst_config.format; + if (l->info.src_config.pos.w == 0) { + TDM_EXIT_IF_FAIL(l->owner_p->info.dst_config.size.h > 0); + l->info.src_config.pos.w = l->owner_p->info.dst_config.size.h; + l->info.src_config.pos.h = l->owner_p->info.dst_config.size.v; + } + } else if (l->owner_c) { + l->info.src_config.format = l->owner_c->info.dst_config.format; + if (l->info.src_config.pos.w == 0) { + TDM_EXIT_IF_FAIL(l->owner_c->info.dst_config.size.h > 0); + l->info.src_config.pos.w = l->owner_c->info.dst_config.size.h; + l->info.src_config.pos.h = l->owner_c->info.dst_config.size.v; + } + } else { + if (l->info.src_config.pos.w == 0) { + TDM_EXIT_IF_FAIL(l->info.dst_pos.w > 0); + l->info.src_config.pos.w = l->info.dst_pos.w; + l->info.src_config.pos.h = l->info.dst_pos.h; } - printf("\n"); } } } - LIST_FOR_EACH_ENTRY(p, &data->pp_list, link) { - printf("pp: "); - print_config(&p->info.src_config); - printf(" ! "); - print_config(&p->info.dst_config); - printf(" fps(%d) trans(%d)\n", p->fps, p->info.transform); - if (p->l) - printf("\toutput_idx(%d) layer_idx(%d)\n", p->l->o->idx, p->l->idx); - } - LIST_FOR_EACH_ENTRY(c, &data->capture_list, link) { - printf("capture: o(%d) l(%d) ", c->output_idx, c->layer_idx); - print_config(&c->info.dst_config); - printf(" trans(%d)\n", c->info.transform); - if (c->l) - printf("\toutput_idx(%d) layer_idx(%d)\n", c->l->o->idx, c->l->idx); - } - if (data->bflags != 0) { - printf("buffer: "); - char temp[256]; - char *p = temp; - int len = sizeof temp; - tdm_buf_flag_str(data->bflags, &p, &len); - printf(" (%s)\n", temp); - } } static tdm_test_server tts_data; @@ -866,7 +845,6 @@ main(int argc, char *argv[]) parse_args(data, argc, argv); interpret_args(data); - print_args(data); if (data->do_query) { tdm_helper_get_display_information(data->display, temp, &len); @@ -926,6 +904,8 @@ output_setup(tdm_test_server_output *o) ret = tdm_output_set_mode(o->output, found); TDM_EXIT_IF_FAIL(ret == TDM_ERROR_NONE); + printf("output %d: %s %d\n", o->idx, found->name, found->vrefresh); + ret = tdm_output_get_available_properties(o->output, &props, &count); TDM_EXIT_IF_FAIL(ret == TDM_ERROR_NONE); @@ -935,6 +915,7 @@ output_setup(tdm_test_server_output *o) continue; ret = tdm_output_set_property(o->output, props[i].id, w->value); TDM_EXIT_IF_FAIL(ret == TDM_ERROR_NONE); + printf("\tprop '%s': %d\n", props[i].name, w->value.u32); break; } } @@ -952,21 +933,19 @@ layer_get_buffer(tdm_test_server_layer *l) for (i = 0; i < size; i++) { int width = (l->info.src_config.size.h)?:l->info.src_config.pos.w; int height = (l->info.src_config.size.v)?:l->info.src_config.pos.h; - unsigned int format = (l->info.src_config.format)?:TBM_FORMAT_ARGB8888; + unsigned int format = (l->info.src_config.format)?:DEFAULT_FORMAT; int flags = l->o->data->bflags; tdm_test_server_buffer *b = calloc(1, sizeof *b); TDM_EXIT_IF_FAIL(b != NULL); b->buffer = tbm_surface_internal_create_with_flags(width, height, format, flags); TDM_EXIT_IF_FAIL(b->buffer != NULL); + tdm_helper_clear_buffer(b->buffer); l->bufs[i] = b; } } - for (i = 0; i < size; i++) { - if (!l->bufs[i]->in_use) { - tdm_test_buffer_fill(l->bufs[i]->buffer, l->data->b_fill); + for (i = 0; i < size; i++) + if (!l->bufs[i]->in_use) return l->bufs[i]; - } - } printf("no available layer buffer.\n"); exit(0); } @@ -979,8 +958,13 @@ layer_cb_commit(tdm_output *output, unsigned int sequence, tdm_test_server_layer *l = user_data; tdm_test_server_buffer *b = layer_get_buffer(l); + if (!l->is_primary || l->o->fill_primary_layer) + tdm_test_buffer_fill(b->buffer, l->data->b_fill); + TDM_EXIT_IF_FAIL(b != NULL); - layer_show_buffer(l, b); + + if (!l->is_primary || l->o->fill_primary_layer) + layer_show_buffer(l, b); } static void @@ -1040,6 +1024,12 @@ layer_setup(tdm_test_server_layer *l, tdm_test_server_buffer *b) ret = tdm_layer_set_info(l->layer, &l->info); TDM_EXIT_IF_FAIL(ret == TDM_ERROR_NONE); + printf("layer %d: output(%d) ", l->idx, l->o->idx); + print_config(&l->info.src_config); + printf(" ! "); + print_pos(&l->info.dst_pos); + printf(" transform(%s)\n", tdm_transform_str(l->info.transform)); + ret = tdm_layer_get_available_properties(l->layer, &props, &count); TDM_EXIT_IF_FAIL(ret == TDM_ERROR_NONE); @@ -1049,6 +1039,7 @@ layer_setup(tdm_test_server_layer *l, tdm_test_server_buffer *b) continue; ret = tdm_layer_set_property(l->layer, props[i].id, w->value); TDM_EXIT_IF_FAIL(ret == TDM_ERROR_NONE); + printf("\tprop '%s': %d\n", props[i].name, w->value.u32); break; } } @@ -1062,12 +1053,12 @@ pp_get_buffer(tdm_test_server_pp *p) for (i = 0; i < size; i++) { int width = (p->info.src_config.size.h)?:p->info.src_config.pos.w; int height = (p->info.src_config.size.v)?:p->info.src_config.pos.h; - unsigned int format = (p->info.src_config.format)?:TBM_FORMAT_ARGB8888; - int flags = p->l->o->data->bflags; + unsigned int format = (p->info.src_config.format)?:DEFAULT_FORMAT; tdm_test_server_buffer *b = calloc(1, sizeof *b); TDM_EXIT_IF_FAIL(b != NULL); - b->buffer = tbm_surface_internal_create_with_flags(width, height, format, flags); + b->buffer = tbm_surface_create(width, height, format); TDM_EXIT_IF_FAIL(b->buffer != NULL); + tdm_helper_clear_buffer(b->buffer); p->bufs[i] = b; } } @@ -1186,6 +1177,14 @@ pp_setup(tdm_test_server_pp *p, tdm_test_server_buffer *sb, tdm_test_server_buff ret = tdm_pp_set_info(p->pp, &p->info); TDM_EXIT_IF_FAIL(ret == TDM_ERROR_NONE); + printf("pp: "); + print_config(&p->info.src_config); + printf(" ! "); + print_config(&p->info.dst_config); + printf(" fps(%d) transform(%s)\n", p->fps, tdm_transform_str(p->info.transform)); + if (p->l) + printf("\toutput_idx(%d) layer_idx(%d)\n", p->l->o->idx, p->l->idx); + layer_setup(p->l, db); /* tdm_event_loop_xxx() function is not for the display server. It's for TDM @@ -1280,6 +1279,12 @@ capture_setup(tdm_test_server_capture *c, tdm_test_server_buffer *b) ret = tdm_capture_set_info(c->capture, &c->info); TDM_EXIT_IF_FAIL(ret == TDM_ERROR_NONE); + printf("capture: o(%d) l(%d) ", c->output_idx, c->layer_idx); + print_config(&c->info.dst_config); + printf(" transform(%s)\n", tdm_transform_str(c->info.transform)); + if (c->l) + printf("\toutput_idx(%d) layer_idx(%d)\n", c->l->o->idx, c->l->idx); + layer_setup(c->l, b); } @@ -1301,6 +1306,8 @@ run_test(tdm_test_server *data) if (!l->owner_p && !l->owner_c) { tdm_test_server_buffer *b; b = layer_get_buffer(l); + if (!l->is_primary || l->o->fill_primary_layer) + tdm_test_buffer_fill(b->buffer, data->b_fill); layer_setup(l, b); layer_show_buffer(l, b); } -- 2.7.4 From 5c5bc2f6f28ea4e8ed292516ab78953519bb6c43 Mon Sep 17 00:00:00 2001 From: Boram Park Date: Fri, 22 Jul 2016 17:13:00 +0900 Subject: [PATCH 13/16] correct the format information log Change-Id: I4331cd771a6b05cb497cab5029e54633dee68153 --- src/tdm_helper.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/tdm_helper.c b/src/tdm_helper.c index 92d7545..9547582 100644 --- a/src/tdm_helper.c +++ b/src/tdm_helper.c @@ -693,6 +693,8 @@ tdm_helper_get_display_information(tdm_display *dpy, char *reply, int *len) if (private_layer->caps.format_count > 0) { const char *sep = ""; for (i = 0; i < private_layer->caps.format_count; i++) { + if (private_layer->caps.formats[i] == 0) + continue; TDM_SNPRINTF(reply, len, "%s%c%c%c%c", sep, FOURCC_STR(private_layer->caps.formats[i])); sep = ","; } @@ -727,6 +729,8 @@ tdm_helper_get_display_information(tdm_display *dpy, char *reply, int *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) + continue; TDM_SNPRINTF(reply, len, "%s%c%c%c%c", sep, FOURCC_STR(private_display->caps_pp.formats[i])); sep = ","; } @@ -767,6 +771,8 @@ tdm_helper_get_display_information(tdm_display *dpy, char *reply, int *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) + continue; TDM_SNPRINTF(reply, len, "%s%c%c%c%c", sep, FOURCC_STR(private_display->caps_capture.formats[i])); sep = ","; } -- 2.7.4 From 66da0d9230b24c2ea6f9a98087a6642387144323 Mon Sep 17 00:00:00 2001 From: Boram Park Date: Tue, 26 Jul 2016 08:38:26 +0900 Subject: [PATCH 14/16] remove release handler when commit failed This is the temporary solution(kismo.kim@samsung.com) to avoid the release handler is called when commit failed. It looks we need something like the pp_done handler to let the display server know if the pp operation is done successfully or not. Change-Id: I1513a99c89102431fd3b74b656d1f1243528d28a --- src/tdm_buffer.c | 19 +++++++++++++++++++ src/tdm_pp.c | 3 +++ src/tdm_private.h | 3 +++ 3 files changed, 25 insertions(+) diff --git a/src/tdm_buffer.c b/src/tdm_buffer.c index 9b4bdb8..f6a5aea 100644 --- a/src/tdm_buffer.c +++ b/src/tdm_buffer.c @@ -162,6 +162,25 @@ tdm_buffer_remove_release_handler(tbm_surface_h buffer, } } +INTERN void +tdm_buffer_remove_release_handler_internal(tbm_surface_h buffer) +{ + tdm_buffer_info *buf_info; + tdm_buffer_func_info *func_info = NULL, *next = NULL; + + TDM_RETURN_IF_FAIL(buffer != NULL); + + buf_info = tdm_buffer_get_info(buffer); + TDM_RETURN_IF_FAIL(buf_info != NULL); + + LIST_FOR_EACH_ENTRY_SAFE(func_info, next, &buf_info->release_funcs, link) { + + LIST_DEL(&func_info->link); + free(func_info); + + return; + } +} EXTERN tbm_surface_h tdm_buffer_ref_backend(tbm_surface_h buffer) diff --git a/src/tdm_pp.c b/src/tdm_pp.c index e9d5183..dab6529 100644 --- a/src/tdm_pp.c +++ b/src/tdm_pp.c @@ -438,6 +438,9 @@ tdm_pp_commit(tdm_pp *pp) LIST_DEL(&b->commit_link); if (ret != TDM_ERROR_NONE) { + tdm_buffer_remove_release_handler_internal(b->src); + tdm_buffer_remove_release_handler_internal(b->dst); + tdm_buffer_unref_backend(b->src); tdm_buffer_unref_backend(b->dst); LIST_DEL(&b->link); diff --git a/src/tdm_private.h b/src/tdm_private.h index f66bed3..a641440 100644 --- a/src/tdm_private.h +++ b/src/tdm_private.h @@ -386,6 +386,9 @@ tdm_buffer_list_get_first_entry(struct list_head *list); void tdm_buffer_list_dump(struct list_head *list); +void +tdm_buffer_remove_release_handler_internal(tbm_surface_h buffer); + /* event functions for private */ tdm_error tdm_event_loop_init(tdm_private_display *private_display); -- 2.7.4 From d2cf78ae768f112cea87168ce47a47907c6d2eee Mon Sep 17 00:00:00 2001 From: Boram Park Date: Tue, 26 Jul 2016 08:53:46 +0900 Subject: [PATCH 15/16] unlock mutex before unref a buffer The frontend user release handler can be called when tdm_buffer_unref_backend is called. We have to unlock/lock the mutex before/after calling tdm_buffer_unref_backend function. Change-Id: Idd97a9286c9d7083d5a77ec23595686a81b61d8e --- src/tdm_pp.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/tdm_pp.c b/src/tdm_pp.c index dab6529..a87ac19 100644 --- a/src/tdm_pp.c +++ b/src/tdm_pp.c @@ -441,8 +441,10 @@ tdm_pp_commit(tdm_pp *pp) tdm_buffer_remove_release_handler_internal(b->src); tdm_buffer_remove_release_handler_internal(b->dst); + _pthread_mutex_unlock(&private_display->lock); tdm_buffer_unref_backend(b->src); tdm_buffer_unref_backend(b->dst); + _pthread_mutex_lock(&private_display->lock); LIST_DEL(&b->link); } } -- 2.7.4 From e71de9d3a503d0717ccc7bba7e0a347f0b8b219e Mon Sep 17 00:00:00 2001 From: Boram Park Date: Tue, 26 Jul 2016 18:31:07 +0900 Subject: [PATCH 16/16] add tdm_pp_set_done_handler and tdm_capture_set_done_handler Change-Id: Id6231d28be18540fe82fd1e6f8d22795539ac4b7 --- include/tdm.h | 30 ++++++++++++++++++++++++++++-- include/tdm_backend.h | 12 ------------ include/tdm_types.h | 11 +++++++++++ src/tdm_capture.c | 26 ++++++++++++++++++++++++++ src/tdm_pp.c | 26 ++++++++++++++++++++++++++ src/tdm_private.h | 6 ++++++ 6 files changed, 97 insertions(+), 14 deletions(-) diff --git a/include/tdm.h b/include/tdm.h index 8b29a49..b62beb7 100644 --- a/include/tdm.h +++ b/include/tdm.h @@ -693,12 +693,25 @@ tdm_error tdm_pp_set_info(tdm_pp *pp, tdm_info_pp *info); /** + * @brief Set the PP done handler to a pp object + * @details + * The user PP done handler will be called after converting a source buffer's image + * to a destination buffer. + * @param[in] pp A pp object + * @param[in] func A user PP done handler + * @param[in] user_data The user data + * @return #TDM_ERROR_NONE if success. Otherwise, error value. + */ +tdm_error +tdm_pp_set_done_handler(tdm_pp *pp, tdm_pp_done_handler func, void *user_data); + +/** * @brief Attach a source buffer and a destination buffer to a pp object * @param[in] pp A pp object * @param[in] src A source buffer * @param[in] dst A destination buffer * @return #TDM_ERROR_NONE if success. Otherwise, error value. - * @see tdm_pp_commit, tdm_buffer_add_release_handler, tdm_buffer_release_handler + * @see tdm_pp_commit, tdm_pp_set_done_handler */ tdm_error tdm_pp_attach(tdm_pp *pp, tbm_surface_h src, tbm_surface_h dst); @@ -730,11 +743,24 @@ tdm_error tdm_capture_set_info(tdm_capture *capture, tdm_info_capture *info); /** + * @brief Set the capture done handler to a capture object + * @details + * The user capture done handler will be called after capturing a screen into a + * buffer. + * @param[in] capture A capture object + * @param[in] func A user capture done handler + * @param[in] user_data The user data + * @return #TDM_ERROR_NONE if success. Otherwise, error value. + */ +tdm_error +tdm_capture_set_done_handler(tdm_capture *capture, tdm_capture_done_handler func, void *user_data); + +/** * @brief Attach a TDM buffer to a capture object * @param[in] capture A capture object * @param[in] buffer A TDM buffer * @return #TDM_ERROR_NONE if success. Otherwise, error value. - * @see tdm_capture_commit, tdm_buffer_add_release_handler, tdm_buffer_release_handler + * @see tdm_capture_commit, tdm_capture_set_done_handler */ tdm_error tdm_capture_attach(tdm_capture *capture, tbm_surface_h buffer); diff --git a/include/tdm_backend.h b/include/tdm_backend.h index 77b1e9b..8076fa2 100644 --- a/include/tdm_backend.h +++ b/include/tdm_backend.h @@ -639,12 +639,6 @@ typedef struct _tdm_func_layer { } tdm_func_layer; /** - * @brief The done handler of a pp object - */ -typedef void (*tdm_pp_done_handler)(tdm_pp *pp, tbm_surface_h src, - tbm_surface_h dst, void *user_data); - -/** * @brief The pp functions for a backend module. */ typedef struct _tdm_func_pp { @@ -713,12 +707,6 @@ typedef struct _tdm_func_pp { } tdm_func_pp; /** - * @brief The done handler of a capture object - */ -typedef void (*tdm_capture_done_handler)(tdm_capture *capture, - tbm_surface_h buffer, void *user_data); - -/** * @brief The capture functions for a backend module. */ typedef struct _tdm_func_capture { diff --git a/include/tdm_types.h b/include/tdm_types.h index 6073646..b11b3f5 100644 --- a/include/tdm_types.h +++ b/include/tdm_types.h @@ -167,6 +167,17 @@ typedef void (*tdm_output_vblank_handler)(tdm_output *output, unsigned int seque typedef void (*tdm_output_commit_handler)(tdm_output *output, unsigned int sequence, unsigned int tv_sec, unsigned int tv_usec, void *user_data); +/** + * @brief The done handler of a pp object + */ +typedef void (*tdm_pp_done_handler)(tdm_pp *pp, tbm_surface_h src, + tbm_surface_h dst, void *user_data); + +/** + * @brief The done handler of a capture object + */ +typedef void (*tdm_capture_done_handler)(tdm_capture *capture, + tbm_surface_h buffer, void *user_data); #ifdef __cplusplus } diff --git a/src/tdm_capture.c b/src/tdm_capture.c index 2737805..2069487 100644 --- a/src/tdm_capture.c +++ b/src/tdm_capture.c @@ -123,6 +123,8 @@ tdm_capture_cb_done(tdm_capture *capture_backend, tbm_surface_h buffer, LIST_DEL(&buf_info->link); _pthread_mutex_unlock(&private_display->lock); + if (private_capture->done_func) + private_capture->done_func(private_capture, buffer, private_capture->done_user_data); tdm_buffer_unref_backend(buffer); _pthread_mutex_lock(&private_display->lock); } @@ -360,6 +362,30 @@ tdm_capture_set_info(tdm_capture *capture, tdm_info_capture *info) } EXTERN tdm_error +tdm_capture_set_done_handler(tdm_capture *capture, tdm_capture_done_handler func, void *user_data) +{ + tdm_private_display *private_display; + tdm_private_capture *private_capture; + tdm_error ret = TDM_ERROR_NONE; + + TDM_RETURN_VAL_IF_FAIL(capture != NULL, TDM_ERROR_INVALID_PARAMETER); + + private_capture = (tdm_private_capture*)capture; + private_display = private_capture->private_display; + + TDM_RETURN_VAL_IF_FAIL(func != NULL, TDM_ERROR_INVALID_PARAMETER); + + _pthread_mutex_lock(&private_display->lock); + + private_capture->done_func = func; + private_capture->done_user_data = user_data; + + _pthread_mutex_unlock(&private_display->lock); + + return ret; +} + +EXTERN tdm_error tdm_capture_attach(tdm_capture *capture, tbm_surface_h buffer) { CAPTURE_FUNC_ENTRY(); diff --git a/src/tdm_pp.c b/src/tdm_pp.c index a87ac19..a1ba203 100644 --- a/src/tdm_pp.c +++ b/src/tdm_pp.c @@ -152,6 +152,8 @@ tdm_pp_cb_done(tdm_pp *pp_backend, tbm_surface_h src, tbm_surface_h dst, LIST_DEL(&pp_buffer->link); _pthread_mutex_unlock(&private_display->lock); + if (private_pp->done_func) + private_pp->done_func(private_pp, src, dst, private_pp->done_user_data); tdm_buffer_unref_backend(src); tdm_buffer_unref_backend(dst); _pthread_mutex_lock(&private_display->lock); @@ -337,6 +339,30 @@ tdm_pp_set_info(tdm_pp *pp, tdm_info_pp *info) } EXTERN tdm_error +tdm_pp_set_done_handler(tdm_pp *pp, tdm_pp_done_handler func, void *user_data) +{ + tdm_private_display *private_display; + tdm_private_pp *private_pp; + tdm_error ret = TDM_ERROR_NONE; + + TDM_RETURN_VAL_IF_FAIL(pp != NULL, TDM_ERROR_INVALID_PARAMETER); + + private_pp = (tdm_private_pp*)pp; + private_display = private_pp->private_display; + + TDM_RETURN_VAL_IF_FAIL(func != NULL, TDM_ERROR_INVALID_PARAMETER); + + _pthread_mutex_lock(&private_display->lock); + + private_pp->done_func = func; + private_pp->done_user_data = user_data; + + _pthread_mutex_unlock(&private_display->lock); + + return ret; +} + +EXTERN tdm_error tdm_pp_attach(tdm_pp *pp, tbm_surface_h src, tbm_surface_h dst) { tdm_pp_private_buffer *pp_buffer; diff --git a/src/tdm_private.h b/src/tdm_private.h index a641440..a15ffc5 100644 --- a/src/tdm_private.h +++ b/src/tdm_private.h @@ -225,6 +225,9 @@ struct _tdm_private_pp { tdm_info_pp info; pid_t owner_tid; + + tdm_pp_done_handler done_func; + void *done_user_data; }; struct _tdm_private_capture { @@ -246,6 +249,9 @@ struct _tdm_private_capture { tdm_info_capture info; pid_t owner_tid; + + tdm_capture_done_handler done_func; + void *done_user_data; }; /* CAUTION: -- 2.7.4