From 6c6338dd5b9527db34621319b61d567bad57c226 Mon Sep 17 00:00:00 2001 From: Boram Park Date: Tue, 12 Dec 2017 11:44:44 +0900 Subject: [PATCH 01/16] monitor: enhance ttrace option for layer, pp, capture Change-Id: I3c142a49bff04844734137ea912cd5a84a81e05c --- src/tdm.c | 71 ++++++++++++++++++++++++++++++++++++++++++++++++ src/tdm_capture.c | 22 +++++++++++++++ src/tdm_layer.c | 21 ++++++++++++-- src/tdm_monitor_server.c | 56 ++++++++------------------------------ src/tdm_pp.c | 28 +++++++++++++++++-- src/tdm_private.h | 16 +++++++++-- src/tdm_server.c | 49 ++++++++++++--------------------- src/tdm_vblank.c | 4 --- 8 files changed, 178 insertions(+), 89 deletions(-) diff --git a/src/tdm.c b/src/tdm.c index 418010c..a66ebad 100644 --- a/src/tdm.c +++ b/src/tdm.c @@ -679,6 +679,8 @@ tdm_display_update(tdm_display *dpy) int tdm_debug_module; int tdm_debug_dump; +int tdm_ttrace_module; +int tdm_ttrace_output; static tdm_private_display *g_private_display; static pthread_mutex_t gLock = PTHREAD_MUTEX_INITIALIZER; @@ -1362,6 +1364,75 @@ enable_fail: } INTERN tdm_error +tdm_display_enable_ttrace(tdm_private_display *private_display, const char *ttrace, int output_id, char *reply, int *len) +{ + char temp[TDM_PATH_LEN]; + char *arg; + char *end; + tdm_output *output; + tdm_error ret; + tdm_output_type type; + + snprintf(temp, TDM_PATH_LEN, "%s", ttrace); + + tdm_ttrace_output = output_id; + tdm_ttrace_module = 0; + + output = tdm_display_get_output(private_display, output_id, &ret); + if (!output) { + TDM_SNPRINTF(reply, len, "can't find the output_id(%d)\n", output_id); + return ret; + } + + ret = tdm_output_get_output_type(output, &type); + if (ret != TDM_ERROR_NONE) { + TDM_SNPRINTF(reply, len, "can't find the type of output_id(%d)\n", output_id); + return ret; + } + + arg = strtok_r(temp, TDM_DELIM, &end); + while (arg) { + if (!strncmp(arg, "none", 4)) + tdm_ttrace_module = 0; + else if (!strncmp(arg, "all", 3)) + tdm_ttrace_module = 0xFFFFFFFF; + else if (!strncmp(arg, "vblank", 6)) + tdm_ttrace_module |= TDM_TTRACE_VBLANK; + else if (!strncmp(arg, "client", 6)) + tdm_ttrace_module |= TDM_TTRACE_CLIENT; + else if (!strncmp(arg, "layer", 5)) + tdm_ttrace_module |= TDM_TTRACE_LAYER; + else if (!strncmp(arg, "pp", 2)) + tdm_ttrace_module |= TDM_TTRACE_PP; + else if (!strncmp(arg, "capture", 7)) + tdm_ttrace_module |= TDM_TTRACE_CAPTURE; + else { + tdm_ttrace_module = 0; + tdm_display_enable_ttrace_vblank(private_display, NULL, 0); + tdm_server_enable_ttrace_client_vblank(private_display, NULL, 0); + TDM_SNPRINTF(reply, len, "unknown option: '%s'\n", arg); + return TDM_ERROR_NONE; + } + + arg = strtok_r(NULL, TDM_DELIM, &end); + } + + TDM_SNPRINTF(reply, len, "ttrace debugging... '%s' %x\n", ttrace, tdm_ttrace_module); + + if (tdm_ttrace_module & TDM_TTRACE_VBLANK) + tdm_display_enable_ttrace_vblank(private_display, output, 1); + else + tdm_display_enable_ttrace_vblank(private_display, NULL, 0); + + if (tdm_ttrace_module & TDM_TTRACE_CLIENT) + tdm_server_enable_ttrace_client_vblank(private_display, output, 1); + else + tdm_server_enable_ttrace_client_vblank(private_display, NULL, 0); + + return TDM_ERROR_NONE; +} + +INTERN tdm_error tdm_display_enable_fps(tdm_private_display *private_display, int enable) { private_display->print_fps = enable; diff --git a/src/tdm_capture.c b/src/tdm_capture.c index bfb9e40..f0b4be6 100644 --- a/src/tdm_capture.c +++ b/src/tdm_capture.c @@ -141,6 +141,11 @@ tdm_capture_cb_done(tdm_capture *capture_backend, tbm_surface_h buffer, if (tdm_debug_module & TDM_DEBUG_BUFFER) TDM_INFO("capture(%p) done: %p", private_capture, buffer); + if (tdm_ttrace_module & TDM_TTRACE_CAPTURE) { + tbm_bo bo = tbm_surface_internal_get_bo(buffer, 0); + TDM_TRACE_ASYNC_END((int)private_capture, "[CAPTURE] %d", tbm_bo_export(bo)); + } + if (!LIST_IS_EMPTY(&private_capture->buffer_list)) { first_entry = container_of((&private_capture->buffer_list)->next, capture_buffer, link); if (first_entry->buffer != buffer) @@ -370,6 +375,12 @@ tdm_capture_destroy_internal(tdm_private_capture *private_capture) _pthread_mutex_unlock(&private_display->lock); LIST_FOR_EACH_ENTRY_SAFE(b, bb, &clone_list, link) { LIST_DEL(&b->link); + + if (tdm_ttrace_module & TDM_TTRACE_CAPTURE) { + tbm_bo bo = tbm_surface_internal_get_bo(b->buffer, 0); + TDM_TRACE_ASYNC_END((int)private_capture, "[CAPTURE] %d", tbm_bo_export(bo)); + } + tdm_buffer_unref_backend(b->buffer); free(b); } @@ -389,6 +400,12 @@ tdm_capture_destroy_internal(tdm_private_capture *private_capture) _pthread_mutex_unlock(&private_display->lock); LIST_FOR_EACH_ENTRY_SAFE(b, bb, &clone_list, link) { LIST_DEL(&b->link); + + if (tdm_ttrace_module & TDM_TTRACE_CAPTURE) { + tbm_bo bo = tbm_surface_internal_get_bo(b->buffer, 0); + TDM_TRACE_ASYNC_END((int)private_capture, "[CAPTURE] %d", tbm_bo_export(bo)); + } + tdm_buffer_unref_backend(b->buffer); free(b); } @@ -544,6 +561,11 @@ tdm_capture_attach(tdm_capture *capture, tbm_surface_h buffer) tdm_buffer_list_dump(&private_capture->buffer_list); } + if (tdm_ttrace_module & TDM_TTRACE_CAPTURE) { + tbm_bo bo = tbm_surface_internal_get_bo(buffer, 0); + TDM_TRACE_ASYNC_BEGIN((int)capture, "[CAPTURE] %d", tbm_bo_export(bo)); + } + _pthread_mutex_unlock(&private_display->lock); return ret; diff --git a/src/tdm_layer.c b/src/tdm_layer.c index 5d3d1c9..d378622 100644 --- a/src/tdm_layer.c +++ b/src/tdm_layer.c @@ -453,11 +453,17 @@ tdm_layer_set_buffer(tdm_layer *layer, tbm_surface_h buffer) private_layer->pending_buffer_changed = 1; if (private_layer->pending_buffer) { - tbm_surface_internal_unref(private_layer->pending_buffer); if (tdm_debug_module & TDM_DEBUG_BUFFER) TDM_INFO("layer(%p) pending_buffer(%p) skipped", private_layer, private_layer->pending_buffer); + + if (tdm_ttrace_module & TDM_TTRACE_LAYER) { + tbm_bo bo = tbm_surface_internal_get_bo(private_layer->pending_buffer, 0); + TDM_TRACE_ASYNC_END((int)private_layer, "[LAYER] %d", tbm_bo_export(bo)); + } + + tbm_surface_internal_unref(private_layer->pending_buffer); } tbm_surface_internal_ref(buffer); @@ -467,6 +473,11 @@ tdm_layer_set_buffer(tdm_layer *layer, tbm_surface_h buffer) TDM_INFO("layer(%p) pending_buffer(%p)", private_layer, private_layer->pending_buffer); + if (tdm_ttrace_module & TDM_TTRACE_LAYER) { + tbm_bo bo = tbm_surface_internal_get_bo(private_layer->pending_buffer, 0); + TDM_TRACE_ASYNC_BEGIN((int)private_layer, "[LAYER] %d", tbm_bo_export(bo)); + } + _pthread_mutex_unlock(&private_display->lock); return ret; @@ -528,8 +539,14 @@ tdm_layer_committed(tdm_private_layer *private_layer, tdm_private_layer_buffer * } /* LCOV_EXCL_STOP */ - if (private_layer->showing_buffer) + if (private_layer->showing_buffer) { + if (tdm_ttrace_module & TDM_TTRACE_LAYER) { + tbm_bo bo = tbm_surface_internal_get_bo(private_layer->showing_buffer->buffer, 0); + TDM_TRACE_ASYNC_END((int)private_layer, "[LAYER] %d", tbm_bo_export(bo)); + } + _tdm_layer_free_buffer(private_layer, private_layer->showing_buffer); + } private_layer->showing_buffer = *committed_buffer; *committed_buffer = NULL; diff --git a/src/tdm_monitor_server.c b/src/tdm_monitor_server.c index ea56a8b..7dbdc3c 100644 --- a/src/tdm_monitor_server.c +++ b/src/tdm_monitor_server.c @@ -107,57 +107,22 @@ _tdm_monitor_server_dpms(unsigned int pid, char *cwd, int argc, char *argv[], ch } static void -_tdm_monitor_server_ttrace_vblank(unsigned int pid, char *cwd, int argc, char *argv[], char *reply, int *len, tdm_display *dpy) +_tdm_monitor_server_ttrace(unsigned int pid, char *cwd, int argc, char *argv[], char *reply, int *len, tdm_display *dpy) { - int ttrace_vblank, output_id = 0; - char *arg; + int output_id = 0; char *end; + tdm_error ret; if (argc < 3) { _tdm_monitor_server_usage(argv[0], reply, len); return; } - arg = argv[2]; - ttrace_vblank = strtol(arg, &end, 10); - - if (ttrace_vblank > 0) { - tdm_output *output; - tdm_error ret; - tdm_output_type type; - char *temp; - - if (*end == '@') { - arg = end + 1; - output_id = strtol(arg, &end, 10); - } - - output = tdm_display_get_output(dpy, output_id, NULL); - if (!output) { - TDM_SNPRINTF(reply, len, "can't find the output_id(%d)\n", output_id); - return; - } - - ret = tdm_output_get_output_type(output, &type); - if (ret != TDM_ERROR_NONE) { - TDM_SNPRINTF(reply, len, "can't find the type of output_id(%d)\n", output_id); - return; - } - - temp = "server"; - tdm_display_enable_ttrace_vblank(dpy, output, 1); - - if (ttrace_vblank > 1) { - temp = "clients"; - tdm_server_enable_ttrace_vblank(dpy, output, 1); - } + if (argv[3]) + output_id = strtol(argv[3], &end, 10); - TDM_SNPRINTF(reply, len, "enable ttrace vblank for '%s': %s \n", tdm_conn_str(type), temp); - } else { - tdm_display_enable_ttrace_vblank(dpy, NULL, 0); - tdm_server_enable_ttrace_vblank(dpy, NULL, 0); - TDM_SNPRINTF(reply, len, "disable ttrace vblank\n"); - } + ret = tdm_display_enable_ttrace(dpy, argv[2], output_id, reply, len); + TDM_DBG_RETURN_IF_FAIL(ret == TDM_ERROR_NONE); } static void @@ -547,9 +512,10 @@ static struct { "set output dpms", ":", "0:3 or 0:0" }, { - "ttrace_vblank", _tdm_monitor_server_ttrace_vblank, - "enable/disable the vblank for ttrace [0:disable, 1:server, 2:clients]", - "[@]", "0 or 1 or 2 or 1@0 or 2@0 or 1@1 or 2@1" + "ttrace", _tdm_monitor_server_ttrace, + "enable/disable ttrace (module: none, vblank, client, layer, pp, capture, all", + "[@]", + NULL }, { "debug", _tdm_monitor_server_debug, diff --git a/src/tdm_pp.c b/src/tdm_pp.c index a58e4fc..53f8c73 100644 --- a/src/tdm_pp.c +++ b/src/tdm_pp.c @@ -139,9 +139,6 @@ tdm_pp_cb_done(tdm_pp *pp_backend, tbm_surface_h src, tbm_surface_h dst, /* LCOV_EXCL_STOP */ } - 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)) { first_entry = container_of((&private_pp->buffer_list)->next, pp_buffer, link); if (first_entry->src != src || first_entry->dst != dst) @@ -154,6 +151,14 @@ tdm_pp_cb_done(tdm_pp *pp_backend, tbm_surface_h src, tbm_surface_h dst, LIST_DEL(&pp_buffer->link); LIST_DELINIT(&pp_buffer->commit_link); + if (tdm_debug_module & TDM_DEBUG_BUFFER) + TDM_INFO("pp(%p) done: src(%p) dst(%p)", private_pp, src, dst); + + if (tdm_ttrace_module & TDM_TTRACE_PP) { + tbm_bo bo = tbm_surface_internal_get_bo(dst, 0); + TDM_TRACE_ASYNC_END((int)private_pp, "[PP] %d", tbm_bo_export(bo)); + } + _pthread_mutex_unlock(&private_display->lock); if (private_pp->done_func) private_pp->done_func(private_pp, src, dst, private_pp->done_user_data); @@ -285,6 +290,12 @@ tdm_pp_destroy_internal(tdm_private_pp *private_pp) _pthread_mutex_unlock(&private_display->lock); LIST_FOR_EACH_ENTRY_SAFE(b, bb, &clone_list, link) { LIST_DEL(&b->link); + + if (tdm_ttrace_module & TDM_TTRACE_PP) { + tbm_bo bo = tbm_surface_internal_get_bo(b->dst, 0); + TDM_TRACE_ASYNC_END((int)private_pp, "[PP] %d", tbm_bo_export(bo)); + } + tdm_buffer_unref_backend(b->src); tdm_buffer_unref_backend(b->dst); free(b); @@ -305,6 +316,12 @@ tdm_pp_destroy_internal(tdm_private_pp *private_pp) _pthread_mutex_unlock(&private_display->lock); LIST_FOR_EACH_ENTRY_SAFE(b, bb, &clone_list, link) { LIST_DEL(&b->link); + + if (tdm_ttrace_module & TDM_TTRACE_PP) { + tbm_bo bo = tbm_surface_internal_get_bo(b->dst, 0); + TDM_TRACE_ASYNC_END((int)private_pp, "[PP] %d", tbm_bo_export(bo)); + } + tdm_buffer_unref_backend(b->src); tdm_buffer_unref_backend(b->dst); free(b); @@ -467,6 +484,11 @@ tdm_pp_attach(tdm_pp *pp, tbm_surface_h src, tbm_surface_h dst) _tdm_pp_print_list(&private_pp->pending_buffer_list); } + if (tdm_ttrace_module & TDM_TTRACE_PP) { + tbm_bo bo = tbm_surface_internal_get_bo(dst, 0); + TDM_TRACE_ASYNC_BEGIN((int)pp, "[PP] %d", tbm_bo_export(bo)); + } + _pthread_mutex_unlock(&private_display->lock); return ret; diff --git a/src/tdm_private.h b/src/tdm_private.h index 37cceb0..8c710a8 100644 --- a/src/tdm_private.h +++ b/src/tdm_private.h @@ -86,8 +86,19 @@ enum { TDM_DEBUG_COMMIT = (1 << 5), }; +enum { + TDM_TTRACE_NONE, + TDM_TTRACE_VBLANK = (1 << 0), + TDM_TTRACE_CLIENT = (1 << 1), + TDM_TTRACE_LAYER = (1 << 2), + TDM_TTRACE_PP = (1 << 3), + TDM_TTRACE_CAPTURE = (1 << 4), +}; + extern int tdm_debug_module; extern int tdm_debug_dump; +extern int tdm_ttrace_module; +extern int tdm_ttrace_output; #ifdef HAVE_TTRACE #include @@ -238,7 +249,6 @@ struct _tdm_private_output { /* for ttrace vblank */ tdm_vblank *ttrace_vblank; - unsigned int ttrace_vblank_client; }; struct _tdm_private_layer { @@ -658,7 +668,7 @@ tdm_server_deinit(tdm_private_loop *private_loop); const char* tdm_server_get_client_name(pid_t pid); tdm_error -tdm_server_enable_ttrace_vblank(tdm_display *dpy, tdm_output *output, int enable); +tdm_server_enable_ttrace_client_vblank(tdm_display *dpy, tdm_output *output, int enable); char * tdm_helper_dump_make_directory(const char *path, char *reply, int *len); @@ -753,7 +763,7 @@ tdm_display_enable_dump(tdm_private_display *private_display, const char *dump_s tdm_error tdm_display_enable_path(const char *path); tdm_error -tdm_display_enable_ttrace_vblank(tdm_display *dpy, tdm_output *output, int enable); +tdm_display_enable_ttrace(tdm_private_display *private_display, const char *ttrace, int output_id, char *reply, int *len); tdm_error tdm_display_enable_fps(tdm_private_display *private_display, int enable); diff --git a/src/tdm_server.c b/src/tdm_server.c index 3932819..3d9daf3 100644 --- a/src/tdm_server.c +++ b/src/tdm_server.c @@ -88,7 +88,6 @@ typedef struct _tdm_server_client_info { pid_t pid; char name[TDM_NAME_LEN]; struct wl_resource *resource; - tdm_private_server *private_server; } tdm_server_client_info; static tdm_private_server *keep_private_server; @@ -169,7 +168,6 @@ _tdm_server_send_done(tdm_server_wait_info *wait_info, tdm_error error, { tdm_server_wait_info *found; tdm_server_vblank_info *vblank_info; - tdm_private_output *private_output; if (!keep_private_server) return; @@ -188,10 +186,6 @@ _tdm_server_send_done(tdm_server_wait_info *wait_info, tdm_error error, wl_tdm_vblank_send_done(vblank_info->resource, wait_info->req_id, sequence, tv_sec, tv_usec, error); - private_output = vblank_info->output_info->output; - if (private_output->ttrace_vblank_client) - TDM_TRACE_ASYNC_END((int)wait_info->req_time, "TDM_Server_Vblank:%u", vblank_info->stamp); - destroy_wait(wait_info); } /* LCOV_EXCL_STOP */ @@ -322,7 +316,6 @@ _tdm_server_vblank_cb_wait_vblank(struct wl_client *client, struct wl_resource * tdm_server_vblank_info *vblank_info = wl_resource_get_user_data(resource); tdm_server_output_info *output_info = vblank_info->output_info; tdm_private_server *private_server = output_info->private_server; - tdm_private_output *private_output = output_info->output; tdm_server_wait_info *wait_info; unsigned int enable_fake = 0; tdm_error ret; @@ -346,10 +339,6 @@ _tdm_server_vblank_cb_wait_vblank(struct wl_client *client, struct wl_resource * if (tdm_debug_module & TDM_DEBUG_VBLANK) TDM_DBG("req_id(%d) wait", req_id); - private_output = vblank_info->output_info->output; - if (private_output->ttrace_vblank_client) - TDM_TRACE_ASYNC_BEGIN((int)wait_info->req_time, "TDM_Server_Vblank:%u", vblank_info->stamp); - ret = tdm_vblank_wait(vblank_info->vblank, req_sec, req_usec, interval, _tdm_server_cb_vblank, wait_info); tdm_vblank_get_enable_fake(vblank_info->vblank, &enable_fake); @@ -376,7 +365,6 @@ _tdm_server_vblank_cb_wait_vblank_seq(struct wl_client *client, struct wl_resour tdm_server_vblank_info *vblank_info = wl_resource_get_user_data(resource); tdm_server_output_info *output_info = vblank_info->output_info; tdm_private_server *private_server = output_info->private_server; - tdm_private_output *private_output = output_info->output; tdm_server_wait_info *wait_info; unsigned int enable_fake = 0; tdm_error ret; @@ -400,10 +388,6 @@ _tdm_server_vblank_cb_wait_vblank_seq(struct wl_client *client, struct wl_resour if (tdm_debug_module & TDM_DEBUG_VBLANK) TDM_DBG("req_id(%d) wait", req_id); - private_output = vblank_info->output_info->output; - if (private_output->ttrace_vblank_client) - TDM_TRACE_ASYNC_BEGIN((int)wait_info->req_time, "TDM_Server_Vblank:%u", vblank_info->stamp); - ret = tdm_vblank_wait_seq(vblank_info->vblank, req_sec, req_usec, sequence, _tdm_server_cb_vblank, wait_info); tdm_vblank_get_enable_fake(vblank_info->vblank, &enable_fake); @@ -502,6 +486,12 @@ _tdm_server_output_cb_create_vblank(struct wl_client *client, struct wl_resource wl_tdm_vblank_send_stamp(vblank_info->resource, vblank_info->stamp); + if (tdm_ttrace_module & TDM_TTRACE_CLIENT) { + tdm_output *output = tdm_display_get_output(private_loop->dpy, tdm_ttrace_output, NULL); + if (output == output_info->output) + wl_tdm_vblank_send_ttrace(vblank_info->resource, 1); + } + return; } @@ -815,7 +805,6 @@ _tdm_server_bind(struct wl_client *client, void *data, } cinfo->resource = resource; - cinfo->private_server = data; LIST_ADDTAIL(&cinfo->link, &client_list); wl_client_get_credentials(client, &cinfo->pid, NULL, NULL); @@ -1046,26 +1035,22 @@ tdm_server_get_client_name(pid_t pid) /* LCOV_EXCL_START */ INTERN tdm_error -tdm_server_enable_ttrace_vblank(tdm_display *dpy, tdm_output *output, int enable) +tdm_server_enable_ttrace_client_vblank(tdm_display *dpy, tdm_output *output, int enable) { - tdm_server_client_info *cinfo = NULL; - - LIST_FOR_EACH_ENTRY(cinfo, &client_list, link) { - tdm_private_server *private_server = cinfo->private_server; - tdm_server_output_info *output_info = NULL; + tdm_private_server *private_server = keep_private_server; + tdm_server_output_info *output_info = NULL; - LIST_FOR_EACH_ENTRY(output_info, &private_server->output_list, link) { - tdm_server_vblank_info *vblank_info = NULL; - tdm_private_output *private_output = output_info->output; + if (!keep_private_server) + return TDM_ERROR_NONE; - if (output && output_info->output != output) - continue; + LIST_FOR_EACH_ENTRY(output_info, &private_server->output_list, link) { + tdm_server_vblank_info *vblank_info = NULL; - private_output->ttrace_vblank_client = enable; + if (output && output_info->output != output) + continue; - LIST_FOR_EACH_ENTRY(vblank_info, &output_info->vblank_list, link) { - wl_tdm_vblank_send_ttrace(vblank_info->resource, enable); - } + LIST_FOR_EACH_ENTRY(vblank_info, &output_info->vblank_list, link) { + wl_tdm_vblank_send_ttrace(vblank_info->resource, enable); } } diff --git a/src/tdm_vblank.c b/src/tdm_vblank.c index 19c12dd..72b2525 100644 --- a/src/tdm_vblank.c +++ b/src/tdm_vblank.c @@ -971,8 +971,6 @@ tdm_vblank_cb_vblank_SW(tdm_vblank *vblank, double vblank_stamp) if (w->target_time != first_wait_info->target_time) break; - TDM_TRACE_ASYNC_END((int)w->req_time, "TDM_SW_Vblank:%u", (unsigned int)private_vblank->stamp); - LIST_DEL(&w->link); _tdm_vblank_valid_list_del(&w->valid_link); @@ -1044,8 +1042,6 @@ _tdm_vblank_wait_SW(tdm_vblank_wait_info *wait_info) _tdm_vblank_insert_wait(wait_info, &private_vblank->SW_wait_list); - TDM_TRACE_ASYNC_BEGIN((int)wait_info->req_time, "TDM_SW_Vblank:%u", (unsigned int)private_vblank->stamp); - ret = _tdm_vblank_sw_timer_update(private_vblank); if (ret != TDM_ERROR_NONE) { /* LCOV_EXCL_START */ -- 2.7.4 From 0ed66904ff4ea807afe44e74f9006e090208aa3b Mon Sep 17 00:00:00 2001 From: Boram Park Date: Tue, 12 Dec 2017 18:07:04 +0900 Subject: [PATCH 02/16] package version up to 1.9.2 Change-Id: I35b97e2b930648a98bb1768fbd08abf9f379794f --- packaging/libtdm.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packaging/libtdm.spec b/packaging/libtdm.spec index b747070..d5916a3 100644 --- a/packaging/libtdm.spec +++ b/packaging/libtdm.spec @@ -1,7 +1,7 @@ %define UTEST_PACKAGE 1 Name: libtdm -Version: 1.9.1 +Version: 1.9.2 Release: 0 Summary: User Library of Tizen Display Manager Group: Development/Libraries -- 2.7.4 From 3452e634e527f8dc29d107979787cf9a868a38cc Mon Sep 17 00:00:00 2001 From: Boram Park Date: Tue, 12 Dec 2017 18:42:06 +0900 Subject: [PATCH 03/16] fix build-break for aarch64 Change-Id: I1ea0c302e37f3fd44ddce44fae8045b8041d166b --- src/tdm_capture.c | 8 ++++---- src/tdm_layer.c | 6 +++--- src/tdm_pp.c | 8 ++++---- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/tdm_capture.c b/src/tdm_capture.c index f0b4be6..9d924c2 100644 --- a/src/tdm_capture.c +++ b/src/tdm_capture.c @@ -143,7 +143,7 @@ tdm_capture_cb_done(tdm_capture *capture_backend, tbm_surface_h buffer, if (tdm_ttrace_module & TDM_TTRACE_CAPTURE) { tbm_bo bo = tbm_surface_internal_get_bo(buffer, 0); - TDM_TRACE_ASYNC_END((int)private_capture, "[CAPTURE] %d", tbm_bo_export(bo)); + TDM_TRACE_ASYNC_END((intptr_t)private_capture, "[CAPTURE] %d", tbm_bo_export(bo)); } if (!LIST_IS_EMPTY(&private_capture->buffer_list)) { @@ -378,7 +378,7 @@ tdm_capture_destroy_internal(tdm_private_capture *private_capture) if (tdm_ttrace_module & TDM_TTRACE_CAPTURE) { tbm_bo bo = tbm_surface_internal_get_bo(b->buffer, 0); - TDM_TRACE_ASYNC_END((int)private_capture, "[CAPTURE] %d", tbm_bo_export(bo)); + TDM_TRACE_ASYNC_END((intptr_t)private_capture, "[CAPTURE] %d", tbm_bo_export(bo)); } tdm_buffer_unref_backend(b->buffer); @@ -403,7 +403,7 @@ tdm_capture_destroy_internal(tdm_private_capture *private_capture) if (tdm_ttrace_module & TDM_TTRACE_CAPTURE) { tbm_bo bo = tbm_surface_internal_get_bo(b->buffer, 0); - TDM_TRACE_ASYNC_END((int)private_capture, "[CAPTURE] %d", tbm_bo_export(bo)); + TDM_TRACE_ASYNC_END((intptr_t)private_capture, "[CAPTURE] %d", tbm_bo_export(bo)); } tdm_buffer_unref_backend(b->buffer); @@ -563,7 +563,7 @@ tdm_capture_attach(tdm_capture *capture, tbm_surface_h buffer) if (tdm_ttrace_module & TDM_TTRACE_CAPTURE) { tbm_bo bo = tbm_surface_internal_get_bo(buffer, 0); - TDM_TRACE_ASYNC_BEGIN((int)capture, "[CAPTURE] %d", tbm_bo_export(bo)); + TDM_TRACE_ASYNC_BEGIN((intptr_t)capture, "[CAPTURE] %d", tbm_bo_export(bo)); } _pthread_mutex_unlock(&private_display->lock); diff --git a/src/tdm_layer.c b/src/tdm_layer.c index d378622..2a7f3b1 100644 --- a/src/tdm_layer.c +++ b/src/tdm_layer.c @@ -460,7 +460,7 @@ tdm_layer_set_buffer(tdm_layer *layer, tbm_surface_h buffer) if (tdm_ttrace_module & TDM_TTRACE_LAYER) { tbm_bo bo = tbm_surface_internal_get_bo(private_layer->pending_buffer, 0); - TDM_TRACE_ASYNC_END((int)private_layer, "[LAYER] %d", tbm_bo_export(bo)); + TDM_TRACE_ASYNC_END((intptr_t)private_layer, "[LAYER] %d", tbm_bo_export(bo)); } tbm_surface_internal_unref(private_layer->pending_buffer); @@ -475,7 +475,7 @@ tdm_layer_set_buffer(tdm_layer *layer, tbm_surface_h buffer) if (tdm_ttrace_module & TDM_TTRACE_LAYER) { tbm_bo bo = tbm_surface_internal_get_bo(private_layer->pending_buffer, 0); - TDM_TRACE_ASYNC_BEGIN((int)private_layer, "[LAYER] %d", tbm_bo_export(bo)); + TDM_TRACE_ASYNC_BEGIN((intptr_t)private_layer, "[LAYER] %d", tbm_bo_export(bo)); } _pthread_mutex_unlock(&private_display->lock); @@ -542,7 +542,7 @@ tdm_layer_committed(tdm_private_layer *private_layer, tdm_private_layer_buffer * if (private_layer->showing_buffer) { if (tdm_ttrace_module & TDM_TTRACE_LAYER) { tbm_bo bo = tbm_surface_internal_get_bo(private_layer->showing_buffer->buffer, 0); - TDM_TRACE_ASYNC_END((int)private_layer, "[LAYER] %d", tbm_bo_export(bo)); + TDM_TRACE_ASYNC_END((intptr_t)private_layer, "[LAYER] %d", tbm_bo_export(bo)); } _tdm_layer_free_buffer(private_layer, private_layer->showing_buffer); diff --git a/src/tdm_pp.c b/src/tdm_pp.c index 53f8c73..80eb330 100644 --- a/src/tdm_pp.c +++ b/src/tdm_pp.c @@ -156,7 +156,7 @@ tdm_pp_cb_done(tdm_pp *pp_backend, tbm_surface_h src, tbm_surface_h dst, if (tdm_ttrace_module & TDM_TTRACE_PP) { tbm_bo bo = tbm_surface_internal_get_bo(dst, 0); - TDM_TRACE_ASYNC_END((int)private_pp, "[PP] %d", tbm_bo_export(bo)); + TDM_TRACE_ASYNC_END((intptr_t)private_pp, "[PP] %d", tbm_bo_export(bo)); } _pthread_mutex_unlock(&private_display->lock); @@ -293,7 +293,7 @@ tdm_pp_destroy_internal(tdm_private_pp *private_pp) if (tdm_ttrace_module & TDM_TTRACE_PP) { tbm_bo bo = tbm_surface_internal_get_bo(b->dst, 0); - TDM_TRACE_ASYNC_END((int)private_pp, "[PP] %d", tbm_bo_export(bo)); + TDM_TRACE_ASYNC_END((intptr_t)private_pp, "[PP] %d", tbm_bo_export(bo)); } tdm_buffer_unref_backend(b->src); @@ -319,7 +319,7 @@ tdm_pp_destroy_internal(tdm_private_pp *private_pp) if (tdm_ttrace_module & TDM_TTRACE_PP) { tbm_bo bo = tbm_surface_internal_get_bo(b->dst, 0); - TDM_TRACE_ASYNC_END((int)private_pp, "[PP] %d", tbm_bo_export(bo)); + TDM_TRACE_ASYNC_END((intptr_t)private_pp, "[PP] %d", tbm_bo_export(bo)); } tdm_buffer_unref_backend(b->src); @@ -486,7 +486,7 @@ tdm_pp_attach(tdm_pp *pp, tbm_surface_h src, tbm_surface_h dst) if (tdm_ttrace_module & TDM_TTRACE_PP) { tbm_bo bo = tbm_surface_internal_get_bo(dst, 0); - TDM_TRACE_ASYNC_BEGIN((int)pp, "[PP] %d", tbm_bo_export(bo)); + TDM_TRACE_ASYNC_BEGIN((intptr_t)pp, "[PP] %d", tbm_bo_export(bo)); } _pthread_mutex_unlock(&private_display->lock); -- 2.7.4 From 6e3b71431f66086254c00bb339711e6ef8e93486 Mon Sep 17 00:00:00 2001 From: Roman Marchenko Date: Mon, 11 Dec 2017 14:11:48 +0200 Subject: [PATCH 04/16] utest: fix wrong tests for tdm_vblank.c - VblankDestroyWrongVblankPtr: use exit(0) in a ASSERT_EXIT block - VblankGetOffsetFailWrongOffsetPtr: was deleted as libtdm can't check an offset pointer - VblankGetOffsetSucces: error has to be equel TDM_ERROR_NONE Change-Id: If346f47e01de9fe884563f9ddaa12dcd26142884 Signed-off-by: Roman Marchenko --- utests/src/ut_tdm_vblank.cpp | 19 +++---------------- 1 file changed, 3 insertions(+), 16 deletions(-) diff --git a/utests/src/ut_tdm_vblank.cpp b/utests/src/ut_tdm_vblank.cpp index 8f61790..fe4368d 100644 --- a/utests/src/ut_tdm_vblank.cpp +++ b/utests/src/ut_tdm_vblank.cpp @@ -460,7 +460,7 @@ TEST_F(TDMVblank, VblankDestroyWrongVblankPtr) { SKIP_FLAG(has_output); - ASSERT_EXIT({tdm_vblank_destroy((tdm_vblank *)0xFFFFFFFF);}, + ASSERT_EXIT({tdm_vblank_destroy((tdm_vblank *)0xFFFFFFFF); exit(0);}, ::testing::ExitedWithCode(0), ""); } @@ -872,19 +872,6 @@ TEST_F(TDMVblank, VblankGetOffsetFailWrongVblankPtr) ::testing::ExitedWithCode(0), ""); } -TEST_F(TDMVblank, VblankGetOffsetFailWrongOffsetPtr) -{ - tdm_error error = TDM_ERROR_BAD_MODULE; - SKIP_FLAG(has_output); - - ASSERT_EXIT({error = tdm_vblank_get_offset(default_vblank, (int *)0xFFFFFFFF); - if (error == TDM_ERROR_NONE) - exit(1); - else - exit(0);}, - ::testing::ExitedWithCode(0), ""); -} - TEST_F(TDMVblank, VblankGetOffsetSuccesWithoutSet) { tdm_error error; @@ -905,10 +892,10 @@ TEST_F(TDMVblank, VblankGetOffsetSucces) SKIP_FLAG(has_output); error = tdm_vblank_set_offset(default_vblank, set_offset); - ASSERT_TRUE(error != TDM_ERROR_NONE); + ASSERT_TRUE(error == TDM_ERROR_NONE); error = tdm_vblank_get_offset(default_vblank, &ret_offset); - ASSERT_TRUE(error != TDM_ERROR_NONE); + ASSERT_TRUE(error == TDM_ERROR_NONE); ASSERT_TRUE(set_offset == ret_offset); } -- 2.7.4 From 2950e1e558bec772cd75282ffd4dfa17042d65b5 Mon Sep 17 00:00:00 2001 From: Roman Marchenko Date: Mon, 11 Dec 2017 14:14:14 +0200 Subject: [PATCH 05/16] utest: fix wrong tests for tdm_hwc_window.c - check incorrect composition types Change-Id: I22f93ab4c609afe805abdbaca9b3cf62c484828b Signed-off-by: Roman Marchenko --- src/tdm_hwc_window.c | 3 +++ utests/src/ut_tdm_hwc_window.cpp | 4 +--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/tdm_hwc_window.c b/src/tdm_hwc_window.c index 24b6207..f9b735c 100644 --- a/src/tdm_hwc_window.c +++ b/src/tdm_hwc_window.c @@ -138,6 +138,9 @@ tdm_hwc_window_set_composition_type(tdm_hwc_window *hwc_window, tdm_func_hwc_window *func_hwc_window = NULL; HWC_WINDOW_FUNC_ENTRY(); + TDM_RETURN_VAL_IF_FAIL(composition_type >= TDM_COMPOSITION_NONE, TDM_ERROR_INVALID_PARAMETER); + TDM_RETURN_VAL_IF_FAIL(composition_type <= TDM_COMPOSITION_CURSOR, TDM_ERROR_INVALID_PARAMETER); + TDM_RETURN_VAL_IF_FAIL(composition_type != TDM_COMPOSITION_DEVICE_CANDIDATE, TDM_ERROR_INVALID_PARAMETER); _pthread_mutex_lock(&private_display->lock); diff --git a/utests/src/ut_tdm_hwc_window.cpp b/utests/src/ut_tdm_hwc_window.cpp index ed12a59..043d4c8 100644 --- a/utests/src/ut_tdm_hwc_window.cpp +++ b/utests/src/ut_tdm_hwc_window.cpp @@ -469,9 +469,7 @@ TEST_F(TDMHwcWindow, SetCompositionTypeFailInvalieCompositionType) for (int i = 0; i < hwc_count; i++) { error = tdm_hwc_window_set_composition_type(hwc_wins[i], TDM_COMPOSITION_DEVICE_CANDIDATE); ASSERT_NE(TDM_ERROR_NONE, error); - error = tdm_hwc_window_set_composition_type(hwc_wins[i], TDM_COMPOSITION_CLIENT_CANDIDATE); - ASSERT_NE(TDM_ERROR_NONE, error); - error = tdm_hwc_window_set_composition_type(hwc_wins[i], tdm_hwc_window_composition(TDM_COMPOSITION_CLIENT+1)); + error = tdm_hwc_window_set_composition_type(hwc_wins[i], tdm_hwc_window_composition(TDM_COMPOSITION_NONE-1)); ASSERT_NE(TDM_ERROR_NONE, error); } } -- 2.7.4 From 64e4b7867fa88b694d89aa8df29bdb9fa5c0e0a4 Mon Sep 17 00:00:00 2001 From: Roman Marchenko Date: Mon, 11 Dec 2017 14:28:27 +0200 Subject: [PATCH 06/16] tdm_layer_get_buffer_flags: add a checking to NULL pointer for flags Change-Id: Ib564f82715334d07d775261737787cbb7eeefd5c Signed-off-by: Roman Marchenko --- src/tdm_layer.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/tdm_layer.c b/src/tdm_layer.c index 2a7f3b1..b906f74 100644 --- a/src/tdm_layer.c +++ b/src/tdm_layer.c @@ -1278,6 +1278,7 @@ tdm_layer_get_buffer_flags(tdm_layer *layer, unsigned int *flags) { tdm_func_layer *func_layer; LAYER_FUNC_ENTRY(); + TDM_RETURN_VAL_IF_FAIL(flags != NULL, TDM_ERROR_INVALID_PARAMETER); _pthread_mutex_lock(&private_display->lock); -- 2.7.4 From be30a770af2b84b3492fdcb829e309fb859f56b0 Mon Sep 17 00:00:00 2001 From: Roman Marchenko Date: Mon, 11 Dec 2017 14:31:46 +0200 Subject: [PATCH 07/16] tdm_hwc_window_set_buffer_damage: add a checking to NULL pointer for damage region Change-Id: I9ac10c9f6df450e4b2a0e9e3312352a137850a20 Signed-off-by: Roman Marchenko --- src/tdm_hwc_window.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/tdm_hwc_window.c b/src/tdm_hwc_window.c index f9b735c..1bd00e0 100644 --- a/src/tdm_hwc_window.c +++ b/src/tdm_hwc_window.c @@ -167,6 +167,8 @@ tdm_hwc_window_set_buffer_damage(tdm_hwc_window *hwc_window, tdm_hwc_region dama tdm_func_hwc_window *func_hwc_window = NULL; HWC_WINDOW_FUNC_ENTRY(); + if (damage.num_rects > 0) + TDM_RETURN_VAL_IF_FAIL(damage.rects != NULL, TDM_ERROR_INVALID_PARAMETER); _pthread_mutex_lock(&private_display->lock); -- 2.7.4 From c2c81f110537bf909accfceb139efd14bcb1e8d6 Mon Sep 17 00:00:00 2001 From: Roman Marchenko Date: Fri, 8 Dec 2017 11:25:03 +0200 Subject: [PATCH 08/16] add verification for tdm_display Change-Id: I7f54f16c58fd13a079344075be3244f2f8e82488 Signed-off-by: Roman Marchenko --- src/tdm.c | 11 +++++++++++ src/tdm_display.c | 2 ++ src/tdm_private.h | 3 +++ src/tdm_vblank.c | 2 +- 4 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/tdm.c b/src/tdm.c index a66ebad..155a542 100644 --- a/src/tdm.c +++ b/src/tdm.c @@ -662,6 +662,7 @@ tdm_display_update(tdm_display *dpy) tdm_error ret; TDM_RETURN_VAL_IF_FAIL(dpy != NULL, TDM_ERROR_INVALID_PARAMETER); + TDM_RETURN_VAL_IF_FAIL(tdm_display_is_valide(dpy), TDM_ERROR_INVALID_PARAMETER); private_display = dpy; _pthread_mutex_lock(&private_display->lock); @@ -1080,6 +1081,8 @@ tdm_display_deinit(tdm_display *dpy) if (!private_display) return; + TDM_RETURN_IF_FAIL(tdm_display_is_valide(dpy)); + pthread_mutex_lock(&gLock); private_display->init_count--; @@ -1121,6 +1124,14 @@ tdm_display_deinit(tdm_display *dpy) TDM_INFO("done"); } +INTERN int +tdm_display_is_valide(tdm_display *dpy) +{ + if (dpy != NULL && dpy == g_private_display) + return 1; + return 0; +} + /* LCOV_EXCL_START */ INTERN int tdm_display_check_module_abi(tdm_private_display *private_display, int abimaj, int abimin) diff --git a/src/tdm_display.c b/src/tdm_display.c index 1f1caec..4b8ed34 100644 --- a/src/tdm_display.c +++ b/src/tdm_display.c @@ -48,12 +48,14 @@ tdm_private_display *private_display; \ tdm_error ret = TDM_ERROR_NONE; /* default TDM_ERROR_NONE */\ TDM_RETURN_VAL_IF_FAIL(dpy != NULL, TDM_ERROR_INVALID_PARAMETER); \ + TDM_RETURN_VAL_IF_FAIL(tdm_display_is_valide(dpy), TDM_ERROR_INVALID_PARAMETER); \ private_display = (tdm_private_display*)dpy; #define DISPLAY_FUNC_ENTRY_ERROR() \ tdm_private_display *private_display; \ tdm_error ret = TDM_ERROR_NONE; /* default TDM_ERROR_NONE */\ TDM_RETURN_VAL_IF_FAIL_WITH_ERROR(dpy != NULL, TDM_ERROR_INVALID_PARAMETER, NULL); \ + TDM_RETURN_VAL_IF_FAIL_WITH_ERROR(tdm_display_is_valide(dpy), TDM_ERROR_INVALID_PARAMETER, NULL); \ private_display = (tdm_private_display*)dpy; EXTERN tdm_error diff --git a/src/tdm_private.h b/src/tdm_private.h index 8c710a8..a3a5948 100644 --- a/src/tdm_private.h +++ b/src/tdm_private.h @@ -448,6 +448,9 @@ typedef struct _tdm_capture_private_buffer { } tdm_capture_private_buffer; int +tdm_display_is_valide(tdm_display *display); + +int tdm_display_check_module_abi(tdm_private_display *private_display, int abimaj, int abimin); tdm_private_output * diff --git a/src/tdm_vblank.c b/src/tdm_vblank.c index 72b2525..4f5b4fe 100644 --- a/src/tdm_vblank.c +++ b/src/tdm_vblank.c @@ -466,7 +466,7 @@ tdm_vblank_create(tdm_display *dpy, tdm_output *output, tdm_error *error) tdm_private_vblank *private_vblank; tdm_error ret; - TDM_RETURN_VAL_IF_FAIL_WITH_ERROR(dpy != NULL, TDM_ERROR_INVALID_PARAMETER, NULL); + TDM_RETURN_VAL_IF_FAIL_WITH_ERROR(tdm_display_is_valide(dpy), TDM_ERROR_INVALID_PARAMETER, NULL); TDM_RETURN_VAL_IF_FAIL_WITH_ERROR(output != NULL, TDM_ERROR_INVALID_PARAMETER, NULL); if (error) -- 2.7.4 From 9660d5c8c0976303704a7b3a7621f3b2792c48d6 Mon Sep 17 00:00:00 2001 From: Roman Marchenko Date: Mon, 11 Dec 2017 13:57:43 +0200 Subject: [PATCH 09/16] add verification for tdm_output Change-Id: I59ae702314890cad08c8881357e8928a9878bcd4 Signed-off-by: Roman Marchenko --- src/tdm.c | 14 ++++++++++++-- src/tdm_output.c | 6 +++--- src/tdm_private.h | 3 +++ src/tdm_vblank.c | 2 +- 4 files changed, 19 insertions(+), 6 deletions(-) diff --git a/src/tdm.c b/src/tdm.c index 155a542..e36adf9 100644 --- a/src/tdm.c +++ b/src/tdm.c @@ -1019,6 +1019,7 @@ tdm_display_init(tdm_error *error) tdm_event_loop_create_backend_source(private_display); private_display->init_count = 1; + g_private_display = private_display; tdm_private_output *o = NULL; LIST_FOR_EACH_ENTRY(o, &private_display->output_list, link) { @@ -1042,8 +1043,6 @@ tdm_display_init(tdm_error *error) tdm_output_choose_commit_per_vblank_mode(o, mode); } - g_private_display = private_display; - if (error) *error = TDM_ERROR_NONE; @@ -1132,6 +1131,17 @@ tdm_display_is_valide(tdm_display *dpy) return 0; } +INTERN int +tdm_output_is_valide(tdm_output *output) +{ + tdm_private_output *o = NULL, *private_output = output; + if (output && g_private_display) + LIST_FOR_EACH_ENTRY(o, &g_private_display->output_list, link) + if (o == private_output) + return 1; + return 0; +} + /* LCOV_EXCL_START */ INTERN int tdm_display_check_module_abi(tdm_private_display *private_display, int abimaj, int abimin) diff --git a/src/tdm_output.c b/src/tdm_output.c index 6e08225..4a4cef7 100644 --- a/src/tdm_output.c +++ b/src/tdm_output.c @@ -48,7 +48,7 @@ tdm_private_display *private_display; \ tdm_private_output *private_output; \ tdm_error ret = TDM_ERROR_NONE; /* default TDM_ERROR_NONE */\ - TDM_RETURN_VAL_IF_FAIL(output != NULL, TDM_ERROR_INVALID_PARAMETER); \ + TDM_RETURN_VAL_IF_FAIL(tdm_output_is_valide(output), TDM_ERROR_INVALID_PARAMETER); \ private_output = (tdm_private_output*)output; \ private_display = private_output->private_display @@ -56,7 +56,7 @@ tdm_private_display *private_display; \ tdm_private_output *private_output; \ tdm_error ret = TDM_ERROR_NONE; /* default TDM_ERROR_NONE */\ - TDM_RETURN_VAL_IF_FAIL_WITH_ERROR(output != NULL, TDM_ERROR_INVALID_PARAMETER, NULL); \ + TDM_RETURN_VAL_IF_FAIL_WITH_ERROR(tdm_output_is_valide(output), TDM_ERROR_INVALID_PARAMETER, NULL); \ private_output = (tdm_private_output*)output; \ private_display = private_output->private_display @@ -240,7 +240,7 @@ tdm_output_remove_change_handler(tdm_output *output, tdm_private_output *private_output; tdm_private_change_handler *h = NULL, *hh = NULL; - TDM_RETURN_IF_FAIL(output != NULL); + TDM_RETURN_IF_FAIL(tdm_output_is_valide(output)); TDM_RETURN_IF_FAIL(func != NULL); private_output = (tdm_private_output*)output; diff --git a/src/tdm_private.h b/src/tdm_private.h index a3a5948..de3e4d2 100644 --- a/src/tdm_private.h +++ b/src/tdm_private.h @@ -460,6 +460,9 @@ tdm_pp_find_stamp(tdm_private_display *private_display, double stamp); tdm_private_capture * tdm_capture_find_stamp(tdm_private_display *private_display, double stamp); +int +tdm_output_is_valide(tdm_output *output); + void tdm_output_cb_vblank(tdm_output *output_backend, unsigned int sequence, unsigned int tv_sec, unsigned int tv_usec, void *user_data); diff --git a/src/tdm_vblank.c b/src/tdm_vblank.c index 4f5b4fe..6f6e7d2 100644 --- a/src/tdm_vblank.c +++ b/src/tdm_vblank.c @@ -467,7 +467,7 @@ tdm_vblank_create(tdm_display *dpy, tdm_output *output, tdm_error *error) tdm_error ret; TDM_RETURN_VAL_IF_FAIL_WITH_ERROR(tdm_display_is_valide(dpy), TDM_ERROR_INVALID_PARAMETER, NULL); - TDM_RETURN_VAL_IF_FAIL_WITH_ERROR(output != NULL, TDM_ERROR_INVALID_PARAMETER, NULL); + TDM_RETURN_VAL_IF_FAIL_WITH_ERROR(tdm_output_is_valide(output), TDM_ERROR_INVALID_PARAMETER, NULL); if (error) *error = TDM_ERROR_NONE; -- 2.7.4 From 2234f62e15df950d33ce8962b6d3dc8aea6e295e Mon Sep 17 00:00:00 2001 From: Roman Marchenko Date: Mon, 11 Dec 2017 13:59:43 +0200 Subject: [PATCH 10/16] add verification for tdm_vblank Change-Id: I2858c8a23497ea205d25c732bda40492d9820d99 Signed-off-by: Roman Marchenko --- src/tdm_vblank.c | 56 +++++++++++++++++++++++++++++++++++++------------------- 1 file changed, 37 insertions(+), 19 deletions(-) diff --git a/src/tdm_vblank.c b/src/tdm_vblank.c index 6f6e7d2..ea485a3 100644 --- a/src/tdm_vblank.c +++ b/src/tdm_vblank.c @@ -175,6 +175,25 @@ _print_list(struct list_head *list) } #endif +static int +tdm_vblank_is_valide(tdm_vblank *vblank) +{ + tdm_private_vblank *v = NULL; + + if (vblank && vblank_list_inited) { + pthread_mutex_lock(&valid_list_lock); + LIST_FOR_EACH_ENTRY(v, &valid_vblank_list, valid_link) { + if (v == (tdm_private_vblank *)vblank) { + pthread_mutex_unlock(&valid_list_lock); + return 1; + } + } + pthread_mutex_unlock(&valid_list_lock); + + } + return 0; +} + static void _tdm_vblank_valid_list_add(struct list_head *valid_link, struct list_head *valid_list) { @@ -361,7 +380,7 @@ _tdm_vblank_cb_output_change(tdm_output *output, tdm_output_change_type type, { tdm_private_vblank *private_vblank = user_data; - TDM_RETURN_IF_FAIL(private_vblank != NULL); + TDM_RETURN_IF_FAIL(tdm_vblank_is_valide(private_vblank)); switch (type) { case TDM_OUTPUT_CHANGE_DPMS: @@ -527,8 +546,7 @@ tdm_vblank_destroy(tdm_vblank *vblank) tdm_private_vblank *private_vblank = vblank; tdm_vblank_wait_info *w = NULL, *ww = NULL; - if (!private_vblank) - return; + TDM_RETURN_IF_FAIL(tdm_vblank_is_valide(vblank)); _tdm_vblank_valid_list_del(&private_vblank->valid_link); @@ -559,7 +577,7 @@ tdm_vblank_set_name(tdm_vblank *vblank, const char *name) { tdm_private_vblank *private_vblank = vblank; - TDM_RETURN_VAL_IF_FAIL(private_vblank != NULL, TDM_ERROR_INVALID_PARAMETER); + TDM_RETURN_VAL_IF_FAIL(tdm_vblank_is_valide(vblank), TDM_ERROR_INVALID_PARAMETER); if (!name) name = TDM_VBLANK_DEFAULT_NAME; @@ -577,7 +595,7 @@ tdm_vblank_get_name(tdm_vblank *vblank, const char **name) { tdm_private_vblank *private_vblank = vblank; - TDM_RETURN_VAL_IF_FAIL(private_vblank != NULL, TDM_ERROR_INVALID_PARAMETER); + TDM_RETURN_VAL_IF_FAIL(tdm_vblank_is_valide(vblank), TDM_ERROR_INVALID_PARAMETER); TDM_RETURN_VAL_IF_FAIL(name != NULL, TDM_ERROR_INVALID_PARAMETER); *name = (const char*)private_vblank->name; @@ -590,7 +608,7 @@ tdm_vblank_set_fps(tdm_vblank *vblank, unsigned int fps) { tdm_private_vblank *private_vblank = vblank; - TDM_RETURN_VAL_IF_FAIL(private_vblank != NULL, TDM_ERROR_INVALID_PARAMETER); + TDM_RETURN_VAL_IF_FAIL(tdm_vblank_is_valide(vblank), TDM_ERROR_INVALID_PARAMETER); TDM_RETURN_VAL_IF_FAIL(fps > 0, TDM_ERROR_INVALID_PARAMETER); if (private_vblank->fps != fps || private_vblank->fps_changeable) @@ -612,7 +630,7 @@ tdm_vblank_get_fps(tdm_vblank *vblank, unsigned int *fps) { tdm_private_vblank *private_vblank = vblank; - TDM_RETURN_VAL_IF_FAIL(private_vblank != NULL, TDM_ERROR_INVALID_PARAMETER); + TDM_RETURN_VAL_IF_FAIL(tdm_vblank_is_valide(vblank), TDM_ERROR_INVALID_PARAMETER); TDM_RETURN_VAL_IF_FAIL(fps != NULL, TDM_ERROR_INVALID_PARAMETER); *fps = private_vblank->fps; @@ -625,7 +643,7 @@ tdm_vblank_ignore_global_fps(tdm_vblank *vblank, unsigned int ignore) { tdm_private_vblank *private_vblank = vblank; - TDM_RETURN_VAL_IF_FAIL(private_vblank != NULL, TDM_ERROR_INVALID_PARAMETER); + TDM_RETURN_VAL_IF_FAIL(tdm_vblank_is_valide(vblank), TDM_ERROR_INVALID_PARAMETER); if (private_vblank->ignore_global_fps == ignore) return TDM_ERROR_NONE; @@ -643,7 +661,7 @@ tdm_vblank_set_offset(tdm_vblank *vblank, int offset) { tdm_private_vblank *private_vblank = vblank; - TDM_RETURN_VAL_IF_FAIL(private_vblank != NULL, TDM_ERROR_INVALID_PARAMETER); + TDM_RETURN_VAL_IF_FAIL(tdm_vblank_is_valide(vblank), TDM_ERROR_INVALID_PARAMETER); if (private_vblank->offset == offset) return TDM_ERROR_NONE; @@ -661,7 +679,7 @@ tdm_vblank_get_offset(tdm_vblank *vblank, int *offset) { tdm_private_vblank *private_vblank = vblank; - TDM_RETURN_VAL_IF_FAIL(private_vblank != NULL, TDM_ERROR_INVALID_PARAMETER); + TDM_RETURN_VAL_IF_FAIL(tdm_vblank_is_valide(vblank), TDM_ERROR_INVALID_PARAMETER); TDM_RETURN_VAL_IF_FAIL(offset != NULL, TDM_ERROR_INVALID_PARAMETER); *offset = private_vblank->offset; @@ -674,7 +692,7 @@ tdm_vblank_set_enable_fake(tdm_vblank *vblank, unsigned int enable_fake) { tdm_private_vblank *private_vblank = vblank; - TDM_RETURN_VAL_IF_FAIL(private_vblank != NULL, TDM_ERROR_INVALID_PARAMETER); + TDM_RETURN_VAL_IF_FAIL(tdm_vblank_is_valide(vblank), TDM_ERROR_INVALID_PARAMETER); if (private_vblank->enable_fake == enable_fake) return TDM_ERROR_NONE; @@ -691,7 +709,7 @@ tdm_vblank_get_enable_fake(tdm_vblank *vblank, unsigned int *enable_fake) { tdm_private_vblank *private_vblank = vblank; - TDM_RETURN_VAL_IF_FAIL(private_vblank != NULL, TDM_ERROR_INVALID_PARAMETER); + TDM_RETURN_VAL_IF_FAIL(tdm_vblank_is_valide(vblank), TDM_ERROR_INVALID_PARAMETER); TDM_RETURN_VAL_IF_FAIL(enable_fake != NULL, TDM_ERROR_INVALID_PARAMETER); *enable_fake = private_vblank->enable_fake; @@ -774,7 +792,7 @@ _tdm_vblank_cb_vblank_HW(tdm_output *output, unsigned int sequence, } private_vblank = wait_info->private_vblank; - TDM_RETURN_IF_FAIL(private_vblank != NULL); + TDM_RETURN_IF_FAIL(tdm_vblank_is_valide(private_vblank)); if (!_tdm_vblank_find_wait(wait_info, &private_vblank->HW_wait_list)) { VDB("can't find wait(%p)", wait_info); @@ -913,7 +931,7 @@ _tdm_vblank_cb_vblank_SW(void *user_data) { tdm_private_vblank *private_vblank = user_data; - TDM_RETURN_VAL_IF_FAIL(private_vblank != NULL, TDM_ERROR_OPERATION_FAILED); + TDM_RETURN_VAL_IF_FAIL(tdm_vblank_is_valide(private_vblank), TDM_ERROR_OPERATION_FAILED); return tdm_vblank_cb_vblank_SW(private_vblank, 0); } @@ -1064,7 +1082,7 @@ tdm_vblank_wait(tdm_vblank *vblank, unsigned int req_sec, unsigned int req_usec, unsigned int fps; tdm_error ret; - TDM_RETURN_VAL_IF_FAIL(private_vblank != NULL, TDM_ERROR_INVALID_PARAMETER); + TDM_RETURN_VAL_IF_FAIL(tdm_vblank_is_valide(vblank), TDM_ERROR_INVALID_PARAMETER); TDM_RETURN_VAL_IF_FAIL(func != NULL, TDM_ERROR_INVALID_PARAMETER); if (private_vblank->owner_tid != syscall(SYS_gettid)) { @@ -1180,7 +1198,7 @@ tdm_vblank_wait_seq(tdm_vblank *vblank, unsigned int req_sec, unsigned int req_u tdm_private_vblank *private_vblank = vblank; unsigned int interval; - TDM_RETURN_VAL_IF_FAIL(private_vblank != NULL, TDM_ERROR_INVALID_PARAMETER); + TDM_RETURN_VAL_IF_FAIL(tdm_vblank_is_valide(vblank), TDM_ERROR_INVALID_PARAMETER); TDM_RETURN_VAL_IF_FAIL(func != NULL, TDM_ERROR_INVALID_PARAMETER); /* if the sequence of vblank reaches the max value, sequence can be 0. */ @@ -1230,7 +1248,7 @@ tdm_vblank_set_add_front(tdm_vblank *vblank, unsigned int add_front) { tdm_private_vblank *private_vblank = vblank; - TDM_RETURN_VAL_IF_FAIL(private_vblank != NULL, TDM_ERROR_INVALID_PARAMETER); + TDM_RETURN_VAL_IF_FAIL(tdm_vblank_is_valide(vblank), TDM_ERROR_INVALID_PARAMETER); TDM_RETURN_VAL_IF_FAIL(TDM_MUTEX_IS_LOCKED(), TDM_ERROR_OPERATION_FAILED); @@ -1248,7 +1266,7 @@ tdm_vblank_set_resource(tdm_vblank *vblank, struct wl_resource *resource) { tdm_private_vblank *private_vblank = vblank; - TDM_RETURN_VAL_IF_FAIL(private_vblank != NULL, TDM_ERROR_INVALID_PARAMETER); + TDM_RETURN_VAL_IF_FAIL(tdm_vblank_is_valide(vblank), TDM_ERROR_INVALID_PARAMETER); TDM_RETURN_VAL_IF_FAIL(private_vblank->resource == NULL, TDM_ERROR_OPERATION_FAILED); private_vblank->resource = resource; @@ -1261,7 +1279,7 @@ tdm_vblank_get_stamp(tdm_vblank *vblank) { tdm_private_vblank *private_vblank = vblank; - TDM_RETURN_VAL_IF_FAIL(private_vblank != NULL, TDM_ERROR_INVALID_PARAMETER); + TDM_RETURN_VAL_IF_FAIL(tdm_vblank_is_valide(vblank), TDM_ERROR_INVALID_PARAMETER); return private_vblank->stamp; } -- 2.7.4 From 743e9c0fc209e0243df8f22257f5e014236af27e Mon Sep 17 00:00:00 2001 From: SooChan Lim Date: Wed, 13 Dec 2017 08:02:24 +0900 Subject: [PATCH 11/16] fix the typo valide -> valid Change-Id: I7da023913f350f8c824faf81144e030f18239978 --- src/tdm.c | 8 ++++---- src/tdm_display.c | 4 ++-- src/tdm_output.c | 6 +++--- src/tdm_private.h | 4 ++-- src/tdm_vblank.c | 42 +++++++++++++++++++++--------------------- utests/src/ut_tdm_helper.cpp | 8 ++++---- 6 files changed, 36 insertions(+), 36 deletions(-) diff --git a/src/tdm.c b/src/tdm.c index e36adf9..955d5d5 100644 --- a/src/tdm.c +++ b/src/tdm.c @@ -662,7 +662,7 @@ tdm_display_update(tdm_display *dpy) tdm_error ret; TDM_RETURN_VAL_IF_FAIL(dpy != NULL, TDM_ERROR_INVALID_PARAMETER); - TDM_RETURN_VAL_IF_FAIL(tdm_display_is_valide(dpy), TDM_ERROR_INVALID_PARAMETER); + TDM_RETURN_VAL_IF_FAIL(tdm_display_is_valid(dpy), TDM_ERROR_INVALID_PARAMETER); private_display = dpy; _pthread_mutex_lock(&private_display->lock); @@ -1080,7 +1080,7 @@ tdm_display_deinit(tdm_display *dpy) if (!private_display) return; - TDM_RETURN_IF_FAIL(tdm_display_is_valide(dpy)); + TDM_RETURN_IF_FAIL(tdm_display_is_valid(dpy)); pthread_mutex_lock(&gLock); @@ -1124,7 +1124,7 @@ tdm_display_deinit(tdm_display *dpy) } INTERN int -tdm_display_is_valide(tdm_display *dpy) +tdm_display_is_valid(tdm_display *dpy) { if (dpy != NULL && dpy == g_private_display) return 1; @@ -1132,7 +1132,7 @@ tdm_display_is_valide(tdm_display *dpy) } INTERN int -tdm_output_is_valide(tdm_output *output) +tdm_output_is_valid(tdm_output *output) { tdm_private_output *o = NULL, *private_output = output; if (output && g_private_display) diff --git a/src/tdm_display.c b/src/tdm_display.c index 4b8ed34..a009756 100644 --- a/src/tdm_display.c +++ b/src/tdm_display.c @@ -48,14 +48,14 @@ tdm_private_display *private_display; \ tdm_error ret = TDM_ERROR_NONE; /* default TDM_ERROR_NONE */\ TDM_RETURN_VAL_IF_FAIL(dpy != NULL, TDM_ERROR_INVALID_PARAMETER); \ - TDM_RETURN_VAL_IF_FAIL(tdm_display_is_valide(dpy), TDM_ERROR_INVALID_PARAMETER); \ + TDM_RETURN_VAL_IF_FAIL(tdm_display_is_valid(dpy), TDM_ERROR_INVALID_PARAMETER); \ private_display = (tdm_private_display*)dpy; #define DISPLAY_FUNC_ENTRY_ERROR() \ tdm_private_display *private_display; \ tdm_error ret = TDM_ERROR_NONE; /* default TDM_ERROR_NONE */\ TDM_RETURN_VAL_IF_FAIL_WITH_ERROR(dpy != NULL, TDM_ERROR_INVALID_PARAMETER, NULL); \ - TDM_RETURN_VAL_IF_FAIL_WITH_ERROR(tdm_display_is_valide(dpy), TDM_ERROR_INVALID_PARAMETER, NULL); \ + TDM_RETURN_VAL_IF_FAIL_WITH_ERROR(tdm_display_is_valid(dpy), TDM_ERROR_INVALID_PARAMETER, NULL); \ private_display = (tdm_private_display*)dpy; EXTERN tdm_error diff --git a/src/tdm_output.c b/src/tdm_output.c index 4a4cef7..9e97abe 100644 --- a/src/tdm_output.c +++ b/src/tdm_output.c @@ -48,7 +48,7 @@ tdm_private_display *private_display; \ tdm_private_output *private_output; \ tdm_error ret = TDM_ERROR_NONE; /* default TDM_ERROR_NONE */\ - TDM_RETURN_VAL_IF_FAIL(tdm_output_is_valide(output), TDM_ERROR_INVALID_PARAMETER); \ + TDM_RETURN_VAL_IF_FAIL(tdm_output_is_valid(output), TDM_ERROR_INVALID_PARAMETER); \ private_output = (tdm_private_output*)output; \ private_display = private_output->private_display @@ -56,7 +56,7 @@ tdm_private_display *private_display; \ tdm_private_output *private_output; \ tdm_error ret = TDM_ERROR_NONE; /* default TDM_ERROR_NONE */\ - TDM_RETURN_VAL_IF_FAIL_WITH_ERROR(tdm_output_is_valide(output), TDM_ERROR_INVALID_PARAMETER, NULL); \ + TDM_RETURN_VAL_IF_FAIL_WITH_ERROR(tdm_output_is_valid(output), TDM_ERROR_INVALID_PARAMETER, NULL); \ private_output = (tdm_private_output*)output; \ private_display = private_output->private_display @@ -240,7 +240,7 @@ tdm_output_remove_change_handler(tdm_output *output, tdm_private_output *private_output; tdm_private_change_handler *h = NULL, *hh = NULL; - TDM_RETURN_IF_FAIL(tdm_output_is_valide(output)); + TDM_RETURN_IF_FAIL(tdm_output_is_valid(output)); TDM_RETURN_IF_FAIL(func != NULL); private_output = (tdm_private_output*)output; diff --git a/src/tdm_private.h b/src/tdm_private.h index de3e4d2..e4a3414 100644 --- a/src/tdm_private.h +++ b/src/tdm_private.h @@ -448,7 +448,7 @@ typedef struct _tdm_capture_private_buffer { } tdm_capture_private_buffer; int -tdm_display_is_valide(tdm_display *display); +tdm_display_is_valid(tdm_display *display); int tdm_display_check_module_abi(tdm_private_display *private_display, int abimaj, int abimin); @@ -461,7 +461,7 @@ tdm_private_capture * tdm_capture_find_stamp(tdm_private_display *private_display, double stamp); int -tdm_output_is_valide(tdm_output *output); +tdm_output_is_valid(tdm_output *output); void tdm_output_cb_vblank(tdm_output *output_backend, unsigned int sequence, diff --git a/src/tdm_vblank.c b/src/tdm_vblank.c index ea485a3..24dd991 100644 --- a/src/tdm_vblank.c +++ b/src/tdm_vblank.c @@ -176,7 +176,7 @@ _print_list(struct list_head *list) #endif static int -tdm_vblank_is_valide(tdm_vblank *vblank) +tdm_vblank_is_valid(tdm_vblank *vblank) { tdm_private_vblank *v = NULL; @@ -380,7 +380,7 @@ _tdm_vblank_cb_output_change(tdm_output *output, tdm_output_change_type type, { tdm_private_vblank *private_vblank = user_data; - TDM_RETURN_IF_FAIL(tdm_vblank_is_valide(private_vblank)); + TDM_RETURN_IF_FAIL(tdm_vblank_is_valid(private_vblank)); switch (type) { case TDM_OUTPUT_CHANGE_DPMS: @@ -485,8 +485,8 @@ tdm_vblank_create(tdm_display *dpy, tdm_output *output, tdm_error *error) tdm_private_vblank *private_vblank; tdm_error ret; - TDM_RETURN_VAL_IF_FAIL_WITH_ERROR(tdm_display_is_valide(dpy), TDM_ERROR_INVALID_PARAMETER, NULL); - TDM_RETURN_VAL_IF_FAIL_WITH_ERROR(tdm_output_is_valide(output), TDM_ERROR_INVALID_PARAMETER, NULL); + TDM_RETURN_VAL_IF_FAIL_WITH_ERROR(tdm_display_is_valid(dpy), TDM_ERROR_INVALID_PARAMETER, NULL); + TDM_RETURN_VAL_IF_FAIL_WITH_ERROR(tdm_output_is_valid(output), TDM_ERROR_INVALID_PARAMETER, NULL); if (error) *error = TDM_ERROR_NONE; @@ -546,7 +546,7 @@ tdm_vblank_destroy(tdm_vblank *vblank) tdm_private_vblank *private_vblank = vblank; tdm_vblank_wait_info *w = NULL, *ww = NULL; - TDM_RETURN_IF_FAIL(tdm_vblank_is_valide(vblank)); + TDM_RETURN_IF_FAIL(tdm_vblank_is_valid(vblank)); _tdm_vblank_valid_list_del(&private_vblank->valid_link); @@ -577,7 +577,7 @@ tdm_vblank_set_name(tdm_vblank *vblank, const char *name) { tdm_private_vblank *private_vblank = vblank; - TDM_RETURN_VAL_IF_FAIL(tdm_vblank_is_valide(vblank), TDM_ERROR_INVALID_PARAMETER); + TDM_RETURN_VAL_IF_FAIL(tdm_vblank_is_valid(vblank), TDM_ERROR_INVALID_PARAMETER); if (!name) name = TDM_VBLANK_DEFAULT_NAME; @@ -595,7 +595,7 @@ tdm_vblank_get_name(tdm_vblank *vblank, const char **name) { tdm_private_vblank *private_vblank = vblank; - TDM_RETURN_VAL_IF_FAIL(tdm_vblank_is_valide(vblank), TDM_ERROR_INVALID_PARAMETER); + TDM_RETURN_VAL_IF_FAIL(tdm_vblank_is_valid(vblank), TDM_ERROR_INVALID_PARAMETER); TDM_RETURN_VAL_IF_FAIL(name != NULL, TDM_ERROR_INVALID_PARAMETER); *name = (const char*)private_vblank->name; @@ -608,7 +608,7 @@ tdm_vblank_set_fps(tdm_vblank *vblank, unsigned int fps) { tdm_private_vblank *private_vblank = vblank; - TDM_RETURN_VAL_IF_FAIL(tdm_vblank_is_valide(vblank), TDM_ERROR_INVALID_PARAMETER); + TDM_RETURN_VAL_IF_FAIL(tdm_vblank_is_valid(vblank), TDM_ERROR_INVALID_PARAMETER); TDM_RETURN_VAL_IF_FAIL(fps > 0, TDM_ERROR_INVALID_PARAMETER); if (private_vblank->fps != fps || private_vblank->fps_changeable) @@ -630,7 +630,7 @@ tdm_vblank_get_fps(tdm_vblank *vblank, unsigned int *fps) { tdm_private_vblank *private_vblank = vblank; - TDM_RETURN_VAL_IF_FAIL(tdm_vblank_is_valide(vblank), TDM_ERROR_INVALID_PARAMETER); + TDM_RETURN_VAL_IF_FAIL(tdm_vblank_is_valid(vblank), TDM_ERROR_INVALID_PARAMETER); TDM_RETURN_VAL_IF_FAIL(fps != NULL, TDM_ERROR_INVALID_PARAMETER); *fps = private_vblank->fps; @@ -643,7 +643,7 @@ tdm_vblank_ignore_global_fps(tdm_vblank *vblank, unsigned int ignore) { tdm_private_vblank *private_vblank = vblank; - TDM_RETURN_VAL_IF_FAIL(tdm_vblank_is_valide(vblank), TDM_ERROR_INVALID_PARAMETER); + TDM_RETURN_VAL_IF_FAIL(tdm_vblank_is_valid(vblank), TDM_ERROR_INVALID_PARAMETER); if (private_vblank->ignore_global_fps == ignore) return TDM_ERROR_NONE; @@ -661,7 +661,7 @@ tdm_vblank_set_offset(tdm_vblank *vblank, int offset) { tdm_private_vblank *private_vblank = vblank; - TDM_RETURN_VAL_IF_FAIL(tdm_vblank_is_valide(vblank), TDM_ERROR_INVALID_PARAMETER); + TDM_RETURN_VAL_IF_FAIL(tdm_vblank_is_valid(vblank), TDM_ERROR_INVALID_PARAMETER); if (private_vblank->offset == offset) return TDM_ERROR_NONE; @@ -679,7 +679,7 @@ tdm_vblank_get_offset(tdm_vblank *vblank, int *offset) { tdm_private_vblank *private_vblank = vblank; - TDM_RETURN_VAL_IF_FAIL(tdm_vblank_is_valide(vblank), TDM_ERROR_INVALID_PARAMETER); + TDM_RETURN_VAL_IF_FAIL(tdm_vblank_is_valid(vblank), TDM_ERROR_INVALID_PARAMETER); TDM_RETURN_VAL_IF_FAIL(offset != NULL, TDM_ERROR_INVALID_PARAMETER); *offset = private_vblank->offset; @@ -692,7 +692,7 @@ tdm_vblank_set_enable_fake(tdm_vblank *vblank, unsigned int enable_fake) { tdm_private_vblank *private_vblank = vblank; - TDM_RETURN_VAL_IF_FAIL(tdm_vblank_is_valide(vblank), TDM_ERROR_INVALID_PARAMETER); + TDM_RETURN_VAL_IF_FAIL(tdm_vblank_is_valid(vblank), TDM_ERROR_INVALID_PARAMETER); if (private_vblank->enable_fake == enable_fake) return TDM_ERROR_NONE; @@ -709,7 +709,7 @@ tdm_vblank_get_enable_fake(tdm_vblank *vblank, unsigned int *enable_fake) { tdm_private_vblank *private_vblank = vblank; - TDM_RETURN_VAL_IF_FAIL(tdm_vblank_is_valide(vblank), TDM_ERROR_INVALID_PARAMETER); + TDM_RETURN_VAL_IF_FAIL(tdm_vblank_is_valid(vblank), TDM_ERROR_INVALID_PARAMETER); TDM_RETURN_VAL_IF_FAIL(enable_fake != NULL, TDM_ERROR_INVALID_PARAMETER); *enable_fake = private_vblank->enable_fake; @@ -792,7 +792,7 @@ _tdm_vblank_cb_vblank_HW(tdm_output *output, unsigned int sequence, } private_vblank = wait_info->private_vblank; - TDM_RETURN_IF_FAIL(tdm_vblank_is_valide(private_vblank)); + TDM_RETURN_IF_FAIL(tdm_vblank_is_valid(private_vblank)); if (!_tdm_vblank_find_wait(wait_info, &private_vblank->HW_wait_list)) { VDB("can't find wait(%p)", wait_info); @@ -931,7 +931,7 @@ _tdm_vblank_cb_vblank_SW(void *user_data) { tdm_private_vblank *private_vblank = user_data; - TDM_RETURN_VAL_IF_FAIL(tdm_vblank_is_valide(private_vblank), TDM_ERROR_OPERATION_FAILED); + TDM_RETURN_VAL_IF_FAIL(tdm_vblank_is_valid(private_vblank), TDM_ERROR_OPERATION_FAILED); return tdm_vblank_cb_vblank_SW(private_vblank, 0); } @@ -1082,7 +1082,7 @@ tdm_vblank_wait(tdm_vblank *vblank, unsigned int req_sec, unsigned int req_usec, unsigned int fps; tdm_error ret; - TDM_RETURN_VAL_IF_FAIL(tdm_vblank_is_valide(vblank), TDM_ERROR_INVALID_PARAMETER); + TDM_RETURN_VAL_IF_FAIL(tdm_vblank_is_valid(vblank), TDM_ERROR_INVALID_PARAMETER); TDM_RETURN_VAL_IF_FAIL(func != NULL, TDM_ERROR_INVALID_PARAMETER); if (private_vblank->owner_tid != syscall(SYS_gettid)) { @@ -1198,7 +1198,7 @@ tdm_vblank_wait_seq(tdm_vblank *vblank, unsigned int req_sec, unsigned int req_u tdm_private_vblank *private_vblank = vblank; unsigned int interval; - TDM_RETURN_VAL_IF_FAIL(tdm_vblank_is_valide(vblank), TDM_ERROR_INVALID_PARAMETER); + TDM_RETURN_VAL_IF_FAIL(tdm_vblank_is_valid(vblank), TDM_ERROR_INVALID_PARAMETER); TDM_RETURN_VAL_IF_FAIL(func != NULL, TDM_ERROR_INVALID_PARAMETER); /* if the sequence of vblank reaches the max value, sequence can be 0. */ @@ -1248,7 +1248,7 @@ tdm_vblank_set_add_front(tdm_vblank *vblank, unsigned int add_front) { tdm_private_vblank *private_vblank = vblank; - TDM_RETURN_VAL_IF_FAIL(tdm_vblank_is_valide(vblank), TDM_ERROR_INVALID_PARAMETER); + TDM_RETURN_VAL_IF_FAIL(tdm_vblank_is_valid(vblank), TDM_ERROR_INVALID_PARAMETER); TDM_RETURN_VAL_IF_FAIL(TDM_MUTEX_IS_LOCKED(), TDM_ERROR_OPERATION_FAILED); @@ -1266,7 +1266,7 @@ tdm_vblank_set_resource(tdm_vblank *vblank, struct wl_resource *resource) { tdm_private_vblank *private_vblank = vblank; - TDM_RETURN_VAL_IF_FAIL(tdm_vblank_is_valide(vblank), TDM_ERROR_INVALID_PARAMETER); + TDM_RETURN_VAL_IF_FAIL(tdm_vblank_is_valid(vblank), TDM_ERROR_INVALID_PARAMETER); TDM_RETURN_VAL_IF_FAIL(private_vblank->resource == NULL, TDM_ERROR_OPERATION_FAILED); private_vblank->resource = resource; @@ -1279,7 +1279,7 @@ tdm_vblank_get_stamp(tdm_vblank *vblank) { tdm_private_vblank *private_vblank = vblank; - TDM_RETURN_VAL_IF_FAIL(tdm_vblank_is_valide(vblank), TDM_ERROR_INVALID_PARAMETER); + TDM_RETURN_VAL_IF_FAIL(tdm_vblank_is_valid(vblank), TDM_ERROR_INVALID_PARAMETER); return private_vblank->stamp; } diff --git a/utests/src/ut_tdm_helper.cpp b/utests/src/ut_tdm_helper.cpp index 917c3e3..96607a2 100644 --- a/utests/src/ut_tdm_helper.cpp +++ b/utests/src/ut_tdm_helper.cpp @@ -211,7 +211,7 @@ TEST_F(TDMHelperSurface, DumpBufferFailNull) tdm_helper_dump_buffer(NULL, TMP_PATH_FOR_UTEST "/tmp"); } -TEST_F(TDMHelperSurface, DumpBufferFailInvalideOutput) +TEST_F(TDMHelperSurface, DumpBufferFailInvalidOutput) { int invalid_surface; tdm_helper_dump_buffer((tbm_surface_h)&invalid_surface, TMP_PATH_FOR_UTEST "/xyz.png"); @@ -258,7 +258,7 @@ TEST_F(TDMHelperSurface, ClearBufferColorFailNull) tdm_helper_clear_buffer_color(NULL, &pos, 0x0F0F0F); } -TEST_F(TDMHelperSurface, ClearBufferColorInvalideOutput) +TEST_F(TDMHelperSurface, ClearBufferColorInvalidOutput) { int invalid_surface; tdm_pos pos; @@ -310,7 +310,7 @@ TEST_F(TDMHelperSurface, ClearBufferPosFailNull) tdm_helper_clear_buffer_pos(NULL, &pos); } -TEST_F(TDMHelperSurface, ClearBufferPosInvalideOutput) +TEST_F(TDMHelperSurface, ClearBufferPosInvalidOutput) { int invalid_surface; tdm_pos pos; @@ -361,7 +361,7 @@ TEST_F(TDMHelperSurface, ClearBufferFailNull) tdm_helper_clear_buffer(NULL); } -TEST_F(TDMHelperSurface, ClearBufferInvalideOutput) +TEST_F(TDMHelperSurface, ClearBufferInvalidOutput) { int invalid_surface; tdm_helper_clear_buffer((tbm_surface_h)&invalid_surface); -- 2.7.4 From e71b628d13ebe00d834221671ad6959e62311e0c Mon Sep 17 00:00:00 2001 From: Boram Park Date: Thu, 14 Dec 2017 09:45:12 +0900 Subject: [PATCH 12/16] fix tained string issue Change-Id: I349b13d2d2731c69c4ee44dc6aef1c9613c00ff5 --- src/tdm.c | 12 +++++++----- src/tdm_server.c | 8 +++++++- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/src/tdm.c b/src/tdm.c index 955d5d5..4f8c253 100644 --- a/src/tdm.c +++ b/src/tdm.c @@ -862,20 +862,22 @@ static tdm_error _tdm_display_load_module(tdm_private_display *private_display) { const char *module_name; - char module[TDM_NAME_LEN]; struct dirent **namelist; - int n; + int n, len; tdm_error ret = 0; module_name = getenv("TDM_MODULE"); if (!module_name) module_name = TDM_DEFAULT_MODULE; - strncpy(module, module_name, TDM_NAME_LEN - 1); - module[TDM_NAME_LEN - 1] = '\0'; + len = strlen(module_name); + if (len > TDM_NAME_LEN - 1) { + TDM_ERR("TDM_MODULE is too long\n"); + return TDM_ERROR_OPERATION_FAILED; + } /* load bufmgr priv from default lib */ - ret = _tdm_display_load_module_with_file(private_display, (const char*)module); + ret = _tdm_display_load_module_with_file(private_display, module_name); if (ret == TDM_ERROR_NONE) return TDM_ERROR_NONE; diff --git a/src/tdm_server.c b/src/tdm_server.c index 3d9daf3..5f88332 100644 --- a/src/tdm_server.c +++ b/src/tdm_server.c @@ -874,7 +874,7 @@ _tdm_socket_init(tdm_private_loop *private_loop) { const char *dir = NULL; char socket_path[TDM_NAME_LEN * 2]; - int ret = -1; + int ret = -1, len; uid_t uid; gid_t gid; @@ -888,6 +888,12 @@ _tdm_socket_init(tdm_private_loop *private_loop) /* LCOV_EXCL_STOP */ } + len = strlen(dir); + if (len > TDM_NAME_LEN - 1) { + TDM_ERR("XDG_RUNTIME_DIR is too long\n"); + return; + } + strncpy(socket_path, dir, TDM_NAME_LEN - 1); socket_path[TDM_NAME_LEN - 1] = '\0'; -- 2.7.4 From 43a280a2815148175dce3dcd59d271cc580d3eb0 Mon Sep 17 00:00:00 2001 From: Sergey Sizonov Date: Mon, 11 Dec 2017 12:49:25 +0300 Subject: [PATCH 13/16] remove the old implementation of 'smooth transition' mechanism. Change-Id: I431a148841ae98b156eda141c0582c2f8dc7ab86 Signed-off-by: Sergey Sizonov --- include/tdm_types.h | 43 +++---------------------------------------- 1 file changed, 3 insertions(+), 40 deletions(-) diff --git a/include/tdm_types.h b/include/tdm_types.h index c64a351..75cb920 100644 --- a/include/tdm_types.h +++ b/include/tdm_types.h @@ -155,53 +155,16 @@ typedef enum { * User can choose this type for window to avoid a hardware composition for * this window. * - * User has to set this type for the window which has the TDM_COMPOSITION_CLIENT_CANDIDATE - * type. (see the TDM_COMPOSITION_CLIENT_CANDIDATE type) - * * The device must not request any composition type changes for windows of * this type. */ TDM_COMPOSITION_CLIENT = 1, - /* Set by the HWC after tdm_output_hwc_validate(). - * - * If the HWC decided that it doesn't want/can't to continue the composition for - * the window through a hardware overlay or other similar way it'll change - * a type to the TDM_COMPOSITION_CLIENT_CANDIDATE type. - * - * This transition can happen only if the window has the TDM_COMPOSITION_DEVICE - * type already. - * - * If an user changed type of a window from the TDM_COMPOSITION_DEVICE - * type to the the TDM_COMPOSITION_CLIENT type, the type - * will be rejected to the TDM_COMPOSITION_CLIENT_CANDIDATE type. - * - * The user has to composite this window itself. - * - * The underlying hardware overlay is owned by this window till a type being - * changed to the TDM_COMPOSITION_CLIENT type, but it's not possible to set a - * buffer for this window after a type's been changed to the - * TDM_COMPOSITION_CLIENT_CANDIDATE type. - * - * This transitional state is used to get rid of blinking at a transition from - * the TDM_COMPOSITION_DEVICE type to the - * TDM_COMPOSITION_CLIENT type where the hw has to wait till a buffer, which was - * on a hw overlay, get composited to the fb_target and only after this happens - * unset(or set another window on) this hw overlay. - * - * User has to inform the HWC (the HWC got no way to know when it happens) after a buffer, - * which was on a hw overlay, get composited to the fb_target by setting a type of this - * window to the TDM_COMPOSITION_CLIENT type, it causes a type of this window being changed - * to TDM_COMPOSITION_CLIENT. - */ - TDM_COMPOSITION_CLIENT_CANDIDATE = 2, - - /** Set by the client before tdm_output_hwc_validate(). * * Upon tdm_output_hwc_validate(), the device may request a change from this type to * TDM_COMPOSITION_DEVICE or TDM_COMPOSITION_CLIENT. */ - TDM_COMPOSITION_DEVICE_CANDIDATE = 3, + TDM_COMPOSITION_DEVICE_CANDIDATE = 2, /** Set by the HWC after tdm_output_hwc_validate(). * @@ -210,7 +173,7 @@ typedef enum { * * Upon tdm_output_hwc_validate(), the device may request a change from this type to * TDM_COMPOSITION_CLIENT or TDM_COMPOSITION_DEVICE_CANDIDATE. */ - TDM_COMPOSITION_DEVICE = 4, + TDM_COMPOSITION_DEVICE = 3, /** Similar to DEVICE, but the position of this layer may also be set * asynchronously through layer_set_cursor_position. If this functionality is not @@ -222,7 +185,7 @@ typedef enum { * either TDM_COMPOSITION_DEVICE or TDM_COMPOSITION_CLIENT. Changing to * TDM_COMPOSITION_DEVICE will prevent the use of layer_set_cursor_position but * still permit the device to composite the layer. */ - TDM_COMPOSITION_CURSOR = 5, + TDM_COMPOSITION_CURSOR = 4, } tdm_hwc_window_composition; -- 2.7.4 From 339d56bf5152ae317d7ddd458c042ba632003a23 Mon Sep 17 00:00:00 2001 From: Sergey Sizonov Date: Fri, 8 Dec 2017 19:45:58 +0300 Subject: [PATCH 14/16] implement new mechanism for smooth transition from DEVICE to CLIENT This implementation is based on the list of composited hwc_wnds passed along with target_surface these hwc_wnds are composited at. Change-Id: I0b4b6d77b418f3313d11b6a43263160281ae3f19 Signed-off-by: Sergey Sizonov --- include/tdm.h | 3 +- include/tdm_backend.h | 3 +- src/tdm.c | 3 ++ src/tdm_backend.c | 29 ++++++++++++++++-- src/tdm_hwc_window.c | 2 +- src/tdm_output.c | 63 +++++++++++++++++++++++++++++++++++++--- src/tdm_private.h | 1 + utests/src/ut_tdm_hwc_window.cpp | 28 +++++++++++------- 8 files changed, 112 insertions(+), 20 deletions(-) diff --git a/include/tdm.h b/include/tdm.h index 77866d5..ededcb1 100644 --- a/include/tdm.h +++ b/include/tdm.h @@ -626,7 +626,8 @@ tdm_output_hwc_destroy_window(tdm_output *output, tdm_hwc_window *hwc_window); */ tdm_error tdm_output_hwc_set_client_target_buffer(tdm_output *output, tbm_surface_h target_buffer, - tdm_hwc_region damage); + tdm_hwc_region damage, tdm_hwc_window **composited_wnds, + uint32_t num_wnds); /** * @brief Validate the output diff --git a/include/tdm_backend.h b/include/tdm_backend.h index b1a3657..3910184 100644 --- a/include/tdm_backend.h +++ b/include/tdm_backend.h @@ -587,7 +587,8 @@ typedef struct _tdm_func_output { * @since 2.0.0 */ tdm_error (*output_hwc_set_client_target_buffer)(tdm_output *output, tbm_surface_h target_buffer, - tdm_hwc_region damage); + tdm_hwc_region damage, tdm_hwc_window **composited_wnds, + uint32_t num_wnds); /** * @brief Validate the output diff --git a/src/tdm.c b/src/tdm.c index 4f8c253..53f1547 100644 --- a/src/tdm.c +++ b/src/tdm.c @@ -223,6 +223,9 @@ _tdm_display_destroy_private_output(tdm_private_output *private_output) if (private_output->dpms_changed_timer) tdm_event_loop_source_remove(private_output->dpms_changed_timer); + tdm_event_loop_source_remove(private_output->need_validate.event_source); + close(private_output->need_validate.event_fd); + private_output->stamp = 0; free(private_output); } diff --git a/src/tdm_backend.c b/src/tdm_backend.c index 482c933..f8d36d3 100644 --- a/src/tdm_backend.c +++ b/src/tdm_backend.c @@ -183,6 +183,31 @@ tdm_backend_register_func_capture(tdm_display *dpy, return TDM_ERROR_NONE; } +/* backend operates itself types */ +static tdm_private_output* +_look_for_frontend_hwc_output(tdm_output *backend_output) +{ + tdm_private_output *frontend_output = NULL, *o = NULL; + tdm_private_display *dpy; + + dpy = tdm_display_init(NULL); + TDM_RETURN_VAL_IF_FAIL(dpy != NULL, NULL); + + LIST_FOR_EACH_ENTRY(o, &dpy->output_list, link) { + if (!(o->caps.capabilities & TDM_OUTPUT_CAPABILITY_HWC)) + continue; + + if (o->output_backend == backend_output) { + frontend_output = o; + break; + } + } + + tdm_display_deinit(dpy); + + return frontend_output; +} + EXTERN tdm_error tdm_backend_trigger_need_validate_event(tdm_output *output) { @@ -190,9 +215,9 @@ tdm_backend_trigger_need_validate_event(tdm_output *output) uint64_t value; int res; - TDM_RETURN_VAL_IF_FAIL(output != NULL, TDM_ERROR_INVALID_PARAMETER); + private_output = _look_for_frontend_hwc_output(output); + TDM_RETURN_VAL_IF_FAIL(private_output != NULL, TDM_ERROR_INVALID_PARAMETER); - private_output = (tdm_private_output*)output; value = 1; /* do not lock the global display lock here */ diff --git a/src/tdm_hwc_window.c b/src/tdm_hwc_window.c index 1bd00e0..e9be4c3 100644 --- a/src/tdm_hwc_window.c +++ b/src/tdm_hwc_window.c @@ -343,7 +343,7 @@ tdm_hwc_window_create_internal(tdm_private_output *private_output, int is_video, } } - private_hwc_window = calloc(1, sizeof(tdm_private_capture)); + private_hwc_window = calloc(1, sizeof(tdm_private_hwc_window)); if (!private_hwc_window) { /* LCOV_EXCL_START */ TDM_ERR("failed: alloc memory"); diff --git a/src/tdm_output.c b/src/tdm_output.c index 9e97abe..27c83ae 100644 --- a/src/tdm_output.c +++ b/src/tdm_output.c @@ -1707,9 +1707,13 @@ _tdm_target_window_dump_buffer(tdm_private_output *private_output, tbm_surface_h EXTERN tdm_error tdm_output_hwc_set_client_target_buffer(tdm_output *output, tbm_surface_h target_buffer, - tdm_hwc_region damage) + tdm_hwc_region damage, tdm_hwc_window **composited_wnds, + uint32_t num_wnds) { tdm_func_output *func_output = NULL; + tdm_private_hwc_window **composited_wnds_frontend = NULL; + tdm_hwc_window **composited_wnds_backend = NULL; + int i; OUTPUT_FUNC_ENTRY(); @@ -1747,7 +1751,23 @@ tdm_output_hwc_set_client_target_buffer(tdm_output *output, tbm_surface_h target _tdm_target_window_dump_buffer((tdm_private_output *)output, target_buffer); /* LCOV_EXCL_STOP */ - ret = func_output->output_hwc_set_client_target_buffer(private_output->output_backend, target_buffer, damage); + composited_wnds_backend = calloc(num_wnds, sizeof(tdm_hwc_window *)); + if (!composited_wnds_backend) { + /* LCOV_EXCL_START */ + _pthread_mutex_unlock(&private_display->lock); + return TDM_ERROR_OUT_OF_MEMORY; + /* LCOV_EXCL_STOP */ + } + + composited_wnds_frontend = (tdm_private_hwc_window **)composited_wnds; + + for (i = 0; i < num_wnds; i++) + composited_wnds_backend[i] = composited_wnds_frontend[i]->hwc_window_backend; + + ret = func_output->output_hwc_set_client_target_buffer(private_output->output_backend, target_buffer, + damage, composited_wnds_backend, num_wnds); + + free(composited_wnds_backend); _pthread_mutex_unlock(&private_display->lock); @@ -1821,6 +1841,30 @@ tdm_output_call_change_handler_internal(tdm_private_output *private_output, } } +static int +_is_hwc_output_still_existed(tdm_private_output *private_output) +{ + tdm_private_display *dpy; + tdm_private_output *o = NULL; + + dpy = tdm_display_init(NULL); + TDM_RETURN_VAL_IF_FAIL(dpy != NULL, TDM_ERROR_OPERATION_FAILED); + + LIST_FOR_EACH_ENTRY(o, &dpy->output_list, link) { + if (!(o->caps.capabilities & TDM_OUTPUT_CAPABILITY_HWC)) + continue; + + if (o == private_output) + goto exist; + } + + tdm_display_deinit(dpy); + return 0; + +exist: + tdm_display_deinit(dpy); + return 1; +} /* gets called on behalf of the ecore-main-loop thread */ INTERN tdm_error @@ -1828,6 +1872,11 @@ tdm_output_cb_need_validate(tdm_private_output *private_output) { TDM_RETURN_VAL_IF_FAIL(private_output != NULL, TDM_ERROR_INVALID_PARAMETER); + /* as we get 'private_output' within an event, an output this 'private_output' + * points to can be destroyed already */ + if (!_is_hwc_output_still_existed(private_output)) + return TDM_ERROR_NONE; + TDM_INFO("tdm-backend asks for revalidation for the output:%p.", private_output); if (private_output->need_validate.hndl) @@ -1843,9 +1892,15 @@ _need_validate_handler(int fd, tdm_event_loop_mask mask, void *user_data) tdm_thread_cb_need_validate ev; tdm_private_output *private_output; tdm_error ret; + uint64_t value; private_output = (tdm_private_output *)user_data; + if (read(private_output->need_validate.event_fd, &value, sizeof(value)) < 0) { + TDM_ERR("error while trying to read from a need_validate.event_fd fd."); + return TDM_ERROR_OPERATION_FAILED; + } + ev.base.type = TDM_THREAD_CB_NEED_VALIDATE; ev.base.length = sizeof ev; ev.o = private_output; @@ -1877,8 +1932,8 @@ tdm_output_need_validate_event_init(tdm_output *output) fd = eventfd(0, 0); TDM_WARNING_IF_FAIL(fd >= 0); - tdm_event_loop_add_fd_handler(private_display, fd, TDM_EVENT_LOOP_READABLE, - _need_validate_handler, private_output, &ret); + private_output->need_validate.event_source = tdm_event_loop_add_fd_handler(private_display, + fd, TDM_EVENT_LOOP_READABLE, _need_validate_handler, private_output, &ret); TDM_WARNING_IF_FAIL(ret == TDM_ERROR_NONE); private_output->need_validate.event_fd = fd; diff --git a/src/tdm_private.h b/src/tdm_private.h index e4a3414..b7cb0a3 100644 --- a/src/tdm_private.h +++ b/src/tdm_private.h @@ -241,6 +241,7 @@ struct _tdm_private_output { /* look at the tdm_output_set_need_revalidate_handler() declaration for the details */ tdm_output_need_validate_handler hndl; int event_fd; + tdm_event_loop_source *event_source; } need_validate; /* calling a output commit per a vblank */ diff --git a/utests/src/ut_tdm_hwc_window.cpp b/utests/src/ut_tdm_hwc_window.cpp index 043d4c8..2b62c0e 100644 --- a/utests/src/ut_tdm_hwc_window.cpp +++ b/utests/src/ut_tdm_hwc_window.cpp @@ -282,30 +282,32 @@ TEST_F(TDMOutputHwc, DestroyWindowSuccessful) /* tdm_error tdm_output_hwc_set_client_target_buffer(tdm_output *output, - tbm_surface_h target_buffer, tdm_hwc_region damage); */ -TEST_F(TDMOutputHwc, SetClientTargetBufferFailNullOutput) + tbm_surface_h target_buffer, tdm_hwc_region damage, + tdm_hwc_window *composited_wnds, uint32_t num_wnds); */ +TEST_F(TDMOutputHwc, DISABLED_SetClientTargetBufferFailNullOutput) { tdm_hwc_region reg; tbm_surface_h target_buff = CreateBufferForOutput(0); - error = tdm_output_hwc_set_client_target_buffer(NULL, target_buff, reg); + error = tdm_output_hwc_set_client_target_buffer(NULL, target_buff, reg, NULL, 0 /* TODO: sergs_ut */); tbm_surface_internal_destroy(target_buff); ASSERT_NE(TDM_ERROR_NONE, error); } -TEST_F(TDMOutputHwcWithoutHwcCap, SetClientTargetBufferFailNoHwc) +TEST_F(TDMOutputHwcWithoutHwcCap, DISABLED_SetClientTargetBufferFailNoHwc) { tdm_hwc_region damage; for (int i = 0; i < output_count; i++) { tbm_surface_h target_buff = CreateBufferForOutput(i); ASSERT_NE(NULL, target_buff); - error = tdm_output_hwc_set_client_target_buffer(outputs[i], target_buff, damage); + error = tdm_output_hwc_set_client_target_buffer(outputs[i], target_buff, damage, + NULL, 0 /* TODO: sergs_ut */); tbm_surface_internal_destroy(target_buff); ASSERT_NE(TDM_ERROR_NONE, error); } } -TEST_F(TDMOutputHwc, SetClientTargetBufferSuccessfulSetBuff) +TEST_F(TDMOutputHwc, DISABLED_SetClientTargetBufferSuccessfulSetBuff) { tdm_hwc_region damage; @@ -313,27 +315,31 @@ TEST_F(TDMOutputHwc, SetClientTargetBufferSuccessfulSetBuff) tbm_surface_h target_buff = CreateBufferForOutput(i); ASSERT_NE(NULL, target_buff); if (IsHwcEnable(i)) { - error = tdm_output_hwc_set_client_target_buffer(outputs[i], target_buff, damage); + error = tdm_output_hwc_set_client_target_buffer(outputs[i], target_buff, damage, + NULL, 0 /* TODO: sergs_ut_ut */); tbm_surface_internal_destroy(target_buff); ASSERT_EQ(TDM_ERROR_NONE, error); } else { - error = tdm_output_hwc_set_client_target_buffer(outputs[i], target_buff, damage); + error = tdm_output_hwc_set_client_target_buffer(outputs[i], target_buff, damage, + NULL, 0 /* TODO: sergs_ut */); tbm_surface_internal_destroy(target_buff); ASSERT_NE(TDM_ERROR_NONE, error); } } } -TEST_F(TDMOutputHwc, SetClientTargetBufferSuccessfulResetBuff) +TEST_F(TDMOutputHwc, DISABLED_SetClientTargetBufferSuccessfulResetBuff) { tdm_hwc_region damage; for (int i = 0; i < output_count; i++) { if (IsHwcEnable(i)) { - error = tdm_output_hwc_set_client_target_buffer(outputs[i], NULL, damage); + error = tdm_output_hwc_set_client_target_buffer(outputs[i], NULL, damage, + NULL, 0 /* TODO: sergs_ut */); ASSERT_EQ(TDM_ERROR_NONE, error); } else { - error = tdm_output_hwc_set_client_target_buffer(outputs[i], NULL, damage); + error = tdm_output_hwc_set_client_target_buffer(outputs[i], NULL, damage, + NULL, 0 /* TODO: sergs_ut */); ASSERT_NE(TDM_ERROR_NONE, error); } } -- 2.7.4 From 82dee92cb08659f18ecbab60cfc30ba62b02e610 Mon Sep 17 00:00:00 2001 From: SooChan Lim Date: Thu, 14 Dec 2017 13:19:14 +0900 Subject: [PATCH 15/16] package version up to 1.10.0 Change-Id: I07f11f8b4cf5435f5d4a19a835c7dae395dca524 --- packaging/libtdm.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packaging/libtdm.spec b/packaging/libtdm.spec index d5916a3..de8fd86 100644 --- a/packaging/libtdm.spec +++ b/packaging/libtdm.spec @@ -1,7 +1,7 @@ %define UTEST_PACKAGE 1 Name: libtdm -Version: 1.9.2 +Version: 1.10.0 Release: 0 Summary: User Library of Tizen Display Manager Group: Development/Libraries -- 2.7.4 From 78f4a6d03360c3cb776a0532db76b75a34ef4421 Mon Sep 17 00:00:00 2001 From: Sergey Sizonov Date: Thu, 14 Dec 2017 15:48:19 +0300 Subject: [PATCH 16/16] add some comments Change-Id: I14ad80d9ded4cd81b43d94f21fcc479963182c7a Signed-off-by: Sergey Sizonov --- include/tdm.h | 13 +++++++++++-- include/tdm_backend.h | 10 ++++++++++ 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/include/tdm.h b/include/tdm.h index ededcb1..2c0ba6a 100644 --- a/include/tdm.h +++ b/include/tdm.h @@ -614,13 +614,19 @@ tdm_output_hwc_destroy_window(tdm_output *output, tdm_hwc_window *hwc_window); * The damage parameter describes a buffer damage region as defined in the * description of tdm_hwc_window_set_buffer_damage(). * - * Will be called before tdm_output_commit() if any of the layers are marked as + * List of composited hwc_windows (hwc_windows which buffers are presented on #target_buffer) + * should be passed along with #target_buffer to allow tdm to make the smooth transition + * from a DEVICE type to a CLIENT type. + * + * Should be called before tdm_output_commit() if any of the layers are marked as * TDM_COMPOSITION_CLIENT or TDM_COMPOSITION_DEVICE_CANDIDATE. If no layers are * so marked, then it is not necessary to call this function. It is not necessary * to call tdm_output_hwc_validate() after changing the target through this function. * @param[in] output A output object - * @param[in] target The new target buffer + * @param[in] target_buffer The new target buffer * @param[in] damage The buffer damage region + * @param[in] composited_wnds The array of composited hwc_wnds + * @param[in] num_wnds The size of #composited_wnds array * @return #TDM_ERROR_NONE if success. Otherwise, error value. * @since 2.0.0 */ @@ -1035,6 +1041,9 @@ tdm_hwc_window_set_info(tdm_hwc_window *hwc_window, tdm_hwc_window_info *info); * @param[in] hwc_window A window object * @param[in] buffer A TDM buffer * @return #TDM_ERROR_NONE if success. Otherwise, error value. + * @return #TDM_ERROR_BUSY if #hwc_window can't be updated right now, this + * can happen if #hwc_window is involved in the smooth transition from + * DEVICE to CLIENT, this shouldn't be interpreted like some critical error. * @since 2.0.0 */ tdm_error diff --git a/include/tdm_backend.h b/include/tdm_backend.h index 3910184..99eff29 100644 --- a/include/tdm_backend.h +++ b/include/tdm_backend.h @@ -576,6 +576,10 @@ typedef struct _tdm_func_output { * The damage parameter describes a buffer damage region as defined in the * description of hwc_window_set_buffer_damage(). * + * List of composited hwc_windows (hwc_windows which buffers are presented on #target_buffer) + * will be passed along with #target_buffer to allow tdm to make the smooth transition + * from a DEVICE type to a CLIENT type. + * * Will be called before output_commit() if any of the layers are marked as * TDM_COMPOSITION_CLIENT or TDM_COMPOSITION_DEVICE_CANDIDATE. If no layers are * so marked, then it is not necessary to call this function. It is not necessary @@ -583,6 +587,8 @@ typedef struct _tdm_func_output { * @param[in] output A output object * @param[in] target The new target buffer * @param[in] damage The buffer damage region + * @param[in] composited_wnds The array of composited hwc_wnds + * @param[in] num_wnds The size of #composited_wnds array * @return #TDM_ERROR_NONE if success. Otherwise, error value. * @since 2.0.0 */ @@ -891,6 +897,10 @@ typedef struct _tdm_func_window { * @param[in] hwc_window A window object * @param[in] buffer A TDM buffer * @return #TDM_ERROR_NONE if success. Otherwise, error value. + * + * Implementation should return #TDM_ERROR_BUSY if #hwc_window can't + * be updated right now, this won't be interpreted like some critical + * error. */ tdm_error (*hwc_window_set_buffer)(tdm_hwc_window *hwc_window, tbm_surface_h buffer); -- 2.7.4