From 70fed1b2a9e9a77f139e63fa1844cf90120322cb Mon Sep 17 00:00:00 2001 From: Junkyeong Kim Date: Tue, 11 Dec 2018 21:22:03 +0900 Subject: [PATCH 01/16] virtual: fix voutput commit buffer send fail add tdm_output_set_voutput_commit / tdm_output_unset_voutput_commit execute set_voutput_commit when connect. execute unset_voutput_commit when disconnect. cause of tdm thread, the voutput commit request has to be set by client. before code the voutput commit was set from server(main thread), client cannot get buffer attach and commit event from server. Change-Id: I244d9b8b93b3994cba760b9aa8b1ebdfa3102e68 Signed-off-by: Junkyeong Kim --- backends/virtual/tdm_virtual_display.c | 6 +- src/tdm_output.c | 170 ++++++++++++++++++++++++--------- src/tdm_private.h | 4 + src/tdm_private_types.h | 2 + src/tdm_server.c | 22 ++++- 5 files changed, 155 insertions(+), 49 deletions(-) diff --git a/backends/virtual/tdm_virtual_display.c b/backends/virtual/tdm_virtual_display.c index 875dce4..2d407fe 100644 --- a/backends/virtual/tdm_virtual_display.c +++ b/backends/virtual/tdm_virtual_display.c @@ -457,8 +457,9 @@ virtual_output_commit(tdm_output *output, int sync, void *user_data) output_data->status_user_data); } + layer_data = output_data->primary_layer; + if (voutput_data->vcommit_func) { - layer_data = output_data->primary_layer; if (layer_data->display_buffer_changed) { output_data->commit_user_data = user_data; event_data = calloc(1, sizeof(tdm_virtual_event_data)); @@ -495,6 +496,8 @@ virtual_output_commit(tdm_output *output, int sync, void *user_data) } } + layer_data->display_buffer_changed = 0; + return TDM_ERROR_NONE; } @@ -940,7 +943,6 @@ virtual_output_set_commit_func(tdm_voutput *voutput, tdm_voutput_commit_handler tdm_virtual_voutput_data *voutput_data = voutput; RETURN_VAL_IF_FAIL(voutput_data, TDM_ERROR_INVALID_PARAMETER); - RETURN_VAL_IF_FAIL(commit_func, TDM_ERROR_INVALID_PARAMETER); voutput_data->vcommit_func = commit_func; diff --git a/src/tdm_output.c b/src/tdm_output.c index e043569..dfc96ee 100644 --- a/src/tdm_output.c +++ b/src/tdm_output.c @@ -1101,7 +1101,7 @@ _tdm_voutput_thread_cb_commit(tdm_private_display *private_display, void *object TDM_INFO("handler(%p)", voutput_commit_handler); } - if (voutput_commit_handler->func) { + if (voutput_commit_handler->func && private_voutput->set_voutput_commit != 0) { _pthread_mutex_unlock(&private_display->lock); voutput_commit_handler->func(private_voutput, voutput_commit_handler->user_data); _pthread_mutex_lock(&private_display->lock); @@ -1137,9 +1137,9 @@ _tdm_voutput_cb_commit(tdm_voutput *voutput_backend, unsigned int sequence, return; } - LIST_FOR_EACH_ENTRY(voutput_commit_handler, &private_voutput->voutput_commit_handler_list, link) { - if (voutput_commit_handler) break; - } + if (LIST_LENGTH(&private_voutput->voutput_commit_handler_list) == 0) return; + + voutput_commit_handler = LIST_FIRST_ENTRY(&private_voutput->voutput_commit_handler_list, tdm_private_voutput_commit_handler, link); private_output = private_voutput->private_output; @@ -1401,6 +1401,119 @@ _voutput_commit_func(tdm_voutput *voutput, tbm_surface_h buffer) } INTERN tdm_error +tdm_output_set_voutput_commit(tdm_voutput *voutput) +{ + tdm_private_display *private_display; + tdm_private_output *private_output; + tdm_private_voutput *private_voutput; + tdm_private_voutput_commit_handler *voutput_commit_handler = NULL; + tdm_error ret = TDM_ERROR_NONE; + + TDM_RETURN_VAL_IF_FAIL(voutput != NULL, TDM_ERROR_INVALID_PARAMETER); + + private_voutput = (tdm_private_voutput *)voutput; + private_display = private_voutput->private_display; + private_output = (tdm_private_output *)private_voutput->private_output; + + _pthread_mutex_lock(&private_display->lock); + + if (LIST_LENGTH(&private_voutput->voutput_commit_handler_list) != 0) { + _pthread_mutex_unlock(&private_display->lock); + return ret; + } + + if (!private_voutput->regist_commit_cb) { + private_voutput->regist_commit_cb = 1; + ret = tdm_voutput_set_commit_func(private_voutput, _tdm_voutput_cb_commit); + if (ret != TDM_ERROR_NONE) { + TDM_ERR("failed: tdm_voutput_set_commit_func"); + return ret; + } + } + + voutput_commit_handler = calloc(1, sizeof(tdm_private_voutput_commit_handler)); + if (!voutput_commit_handler) { + /* LCOV_EXCL_START */ + TDM_ERR("failed: alloc memory"); + _pthread_mutex_unlock(&private_display->lock); + return TDM_ERROR_OUT_OF_MEMORY; + /* LCOV_EXCL_STOP */ + } + + ret = tdm_thread_cb_add(private_output->private_voutput, TDM_THREAD_CB_VOUTPUT_COMMIT, voutput_commit_handler, _tdm_voutput_thread_cb_commit, NULL); + if (ret != TDM_ERROR_NONE) { + TDM_ERR("tdm_thread_cb_add failed"); + free(voutput_commit_handler); + _pthread_mutex_unlock(&private_display->lock); + return ret; + } + + LIST_ADDTAIL(&voutput_commit_handler->link, &private_voutput->voutput_commit_handler_list); + voutput_commit_handler->private_voutput = private_voutput; + voutput_commit_handler->func = _voutput_commit_func; + voutput_commit_handler->owner_tid = syscall(SYS_gettid); + + private_voutput->set_voutput_commit = 1; + + _pthread_mutex_unlock(&private_display->lock); + + return ret; +} + +INTERN tdm_error +tdm_output_unset_voutput_commit(tdm_voutput *voutput) +{ + tdm_private_display *private_display; + tdm_private_output *private_output; + tdm_private_voutput *private_voutput; + tdm_private_voutput_commit_handler *voutput_commit_handler = NULL; + tdm_error ret = TDM_ERROR_NONE; + + TDM_RETURN_VAL_IF_FAIL(voutput != NULL, TDM_ERROR_INVALID_PARAMETER); + + private_voutput = (tdm_private_voutput *)voutput; + private_display = private_voutput->private_display; + private_output = (tdm_private_output *)private_voutput->private_output; + + _pthread_mutex_lock(&private_display->lock); + + private_voutput->set_voutput_commit = 0; + + if (private_voutput->regist_commit_cb) { + private_voutput->regist_commit_cb = 0; + ret = tdm_voutput_set_commit_func(private_voutput, NULL); + if (ret != TDM_ERROR_NONE) { + TDM_ERR("failed: tdm_voutput_set_commit_func"); + return ret; + } + } + + if (LIST_LENGTH(&private_voutput->voutput_commit_handler_list) == 0) { + _pthread_mutex_unlock(&private_display->lock); + return TDM_ERROR_NONE; + } + + if (LIST_LENGTH(&private_output->output_commit_handler_list) != 0) { + //commiting. don't remove voutput commit thread here + _pthread_mutex_unlock(&private_display->lock); + return TDM_ERROR_NONE; + } + + if (LIST_LENGTH(&private_voutput->voutput_commit_handler_list) != 0) { + voutput_commit_handler = LIST_FIRST_ENTRY(&private_voutput->voutput_commit_handler_list, tdm_private_voutput_commit_handler, link); + } else { + _pthread_mutex_unlock(&private_display->lock); + return TDM_ERROR_NONE; + } + + tdm_thread_cb_remove(private_output->private_voutput, TDM_THREAD_CB_VOUTPUT_COMMIT, voutput_commit_handler, _tdm_voutput_thread_cb_commit, NULL); + + _pthread_mutex_unlock(&private_display->lock); + + return TDM_ERROR_NONE; +} + +INTERN tdm_error tdm_output_commit_internal(tdm_output *output, int sync, tdm_output_commit_handler func, void *user_data) { tdm_private_display *private_display; @@ -1452,38 +1565,12 @@ tdm_output_commit_internal(tdm_output *output, int sync, tdm_output_commit_handl free(output_commit_handler); return TDM_ERROR_BAD_MODULE; } - private_voutput = private_output->private_voutput; - - if (!private_voutput->regist_commit_cb) { - private_voutput->regist_commit_cb = 1; - ret = tdm_voutput_set_commit_func(private_voutput, _tdm_voutput_cb_commit); - TDM_GOTO_IF_FAIL(ret == TDM_ERROR_NONE, commit_failed); - } - - voutput_commit_handler = calloc(1, sizeof(tdm_private_voutput_commit_handler)); - if (!voutput_commit_handler) { - /* LCOV_EXCL_START */ - TDM_ERR("failed: alloc memory"); - free(output_commit_handler); - return TDM_ERROR_OUT_OF_MEMORY; - /* LCOV_EXCL_STOP */ - } - - ret = tdm_thread_cb_add(private_output->private_voutput, TDM_THREAD_CB_VOUTPUT_COMMIT, voutput_commit_handler, _tdm_voutput_thread_cb_commit, NULL); - if (ret != TDM_ERROR_NONE) { - TDM_ERR("tdm_thread_cb_add failed"); - free(voutput_commit_handler); - free(output_commit_handler); - return ret; - } } ret = tdm_thread_cb_add(private_output, TDM_THREAD_CB_OUTPUT_COMMIT, output_commit_handler, _tdm_output_thread_cb_commit, NULL); if (ret != TDM_ERROR_NONE) { TDM_ERR("tdm_thread_cb_add failed"); free(output_commit_handler); - if (voutput_commit_handler) - free(voutput_commit_handler); return ret; } @@ -1493,17 +1580,16 @@ tdm_output_commit_internal(tdm_output *output, int sync, tdm_output_commit_handl output_commit_handler->user_data = user_data; output_commit_handler->owner_tid = syscall(SYS_gettid); - if (voutput_commit_handler) { + if (private_module == private_display->virtual_module) { + private_voutput = private_output->private_voutput; + /* voutput use only 1 layer */ - LIST_FOR_EACH_ENTRY(private_layer, &private_output->layer_list, link) { - if (private_layer) break; - } + private_layer = LIST_FIRST_ENTRY(&private_output->layer_list, tdm_private_layer, link); - LIST_ADDTAIL(&voutput_commit_handler->link, &private_voutput->voutput_commit_handler_list); - voutput_commit_handler->private_voutput = private_voutput; - voutput_commit_handler->func = _voutput_commit_func; - voutput_commit_handler->user_data = private_layer->commiting_buffer; - voutput_commit_handler->owner_tid = syscall(SYS_gettid); + if (LIST_LENGTH(&private_voutput->voutput_commit_handler_list) != 0) { + voutput_commit_handler = LIST_FIRST_ENTRY(&private_voutput->voutput_commit_handler_list, tdm_private_voutput_commit_handler, link); + voutput_commit_handler->user_data = private_layer->commiting_buffer; + } } ret = func_output->output_commit(private_output->output_backend, sync, @@ -1555,11 +1641,7 @@ commit_failed: LIST_DEL(&output_commit_handler->link); free(output_commit_handler); } - if (voutput_commit_handler) { - tdm_thread_cb_remove(private_output->private_voutput, TDM_THREAD_CB_VOUTPUT_COMMIT, voutput_commit_handler, _tdm_voutput_thread_cb_commit, NULL); - LIST_DEL(&voutput_commit_handler->link); - free(voutput_commit_handler); - } + return ret; /* LCOV_EXCL_STOP */ } diff --git a/src/tdm_private.h b/src/tdm_private.h index 9e10713..b65c01e 100644 --- a/src/tdm_private.h +++ b/src/tdm_private.h @@ -279,6 +279,10 @@ tdm_voutput_attach_buffer(tdm_voutput *voutput, tbm_surface_h buffer); tdm_error tdm_voutput_commit_buffer(tdm_voutput *voutput); tdm_error +tdm_output_set_voutput_commit(tdm_voutput *voutput); +tdm_error +tdm_output_unset_voutput_commit(tdm_voutput *voutput); +tdm_error tdm_voutput_commit_done(tdm_voutput *voutput); void * tdm_display_find_private_voutput(tdm_private_display *private_display, double stamp); diff --git a/src/tdm_private_types.h b/src/tdm_private_types.h index 993be0e..80d867f 100644 --- a/src/tdm_private_types.h +++ b/src/tdm_private_types.h @@ -267,6 +267,8 @@ struct _tdm_private_voutput { unsigned int mmwidth; unsigned int mmheight; int connect_status; + + int set_voutput_commit; }; struct _tdm_private_layer { diff --git a/src/tdm_server.c b/src/tdm_server.c index 31ddf14..dc4f25a 100644 --- a/src/tdm_server.c +++ b/src/tdm_server.c @@ -93,6 +93,7 @@ typedef struct _tdm_server_voutput_info { struct list_head buffer_list; tdm_server_voutput_buffer *attach_buffer; int committing; + unsigned int request_commit; } tdm_server_voutput_info; typedef struct _tdm_server_vblank_info { @@ -902,9 +903,12 @@ _tdm_voutput_cb_connect(struct wl_client *client, struct wl_resource *resource) voutput_info = wl_resource_get_user_data(resource); voutput_info->status = TDM_OUTPUT_CONN_STATUS_CONNECTED; + voutput_info->request_commit = 1; + tdm_voutput_set_physical_size(voutput_info->voutput, voutput_info->mmwidth, voutput_info->mmheight); tdm_voutput_set_available_mode(voutput_info->voutput, voutput_info->available_modes.modes, voutput_info->available_modes.count); tdm_voutput_connect(voutput_info->voutput); + tdm_output_set_voutput_commit(voutput_info->voutput); } static void @@ -929,6 +933,11 @@ _tdm_voutput_cb_disconnect(struct wl_client *client, struct wl_resource *resourc voutput_info->attach_buffer = NULL; } + if (voutput_info->request_commit == 1) { + tdm_output_unset_voutput_commit(voutput_info->voutput); + voutput_info->request_commit = 0; + } + tdm_voutput_disconnect(voutput_info->voutput); } @@ -949,6 +958,9 @@ _tdm_voutput_cb_commit_done(struct wl_client *client, struct wl_resource *resour voutput_info->committing = 0; voutput_info->attach_buffer = NULL; + if (voutput_info->request_commit == 1) + tdm_output_set_voutput_commit(voutput_info->voutput); + tdm_voutput_commit_done(voutput_info->voutput); } @@ -1237,10 +1249,14 @@ tdm_voutput_cb_resource_destroy(struct wl_resource *resource) voutput = voutput_info->voutput; - if (voutput) + if (voutput_info->request_commit) + tdm_output_unset_voutput_commit(voutput_info->voutput); + + if (voutput) { ret = tdm_voutput_destroy(voutput); - if (ret != TDM_ERROR_NONE) - TDM_ERR("_tdm_voutput_cb_destroy fail"); + if (ret != TDM_ERROR_NONE) + TDM_ERR("_tdm_voutput_cb_destroy fail"); + } if (voutput_info->attach_buffer) { tbm_surface_h buffer = voutput_info->attach_buffer->buffer; -- 2.7.4 From 9b8f15d39d36eab50e1de2b4fc1b0213081353dc Mon Sep 17 00:00:00 2001 From: SooChan Lim Date: Wed, 26 Dec 2018 19:17:50 +0900 Subject: [PATCH 02/16] Package version up to 2.8.0 Change-Id: I6783f44b97e495b956a1f8187723a052b28f1b53 --- packaging/libtdm.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packaging/libtdm.spec b/packaging/libtdm.spec index 23e7273..2d07234 100644 --- a/packaging/libtdm.spec +++ b/packaging/libtdm.spec @@ -2,7 +2,7 @@ %define HALTESTS_GCOV 0 Name: libtdm -Version: 2.7.1 +Version: 2.8.0 Release: 0 Summary: User Library of Tizen Display Manager Group: Development/Libraries -- 2.7.4 From 10e641800daa2f4e8e4fcc0d3f0336674ee68bef Mon Sep 17 00:00:00 2001 From: Seunghun Lee Date: Thu, 27 Dec 2018 17:31:30 +0900 Subject: [PATCH 03/16] fix typo Change-Id: I3cc0937b1b09007e1a76da8dfd16e5d0c25dac89 --- include/tdm.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/tdm.h b/include/tdm.h index 125ca56..0a2bcab 100644 --- a/include/tdm.h +++ b/include/tdm.h @@ -1051,7 +1051,7 @@ tdm_hwc_window_acquire_buffer_queue(tdm_hwc_window *hwc_window, tdm_error *error /** * @brief Release a buffer queue for the window object - * @details Release buffer queue when the client no longer uses buferrs of queue. + * @details Release buffer queue when the client no longer uses buffers of queue. * @param[in] hwc_window A window object * @param[in] A tbm buffer queue * @since 2.0.0 -- 2.7.4 From bff4891ead90b54d72722c22f72833ce749fa8dc Mon Sep 17 00:00:00 2001 From: Junkyeong Kim Date: Mon, 31 Dec 2018 12:44:59 +0900 Subject: [PATCH 04/16] client: documetation for voutput Change-Id: Icf6ebcb1a06ea4deff25e092143d769eab5514ab Signed-off-by: Junkyeong Kim --- client/tdm_client.h | 82 +++++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 77 insertions(+), 5 deletions(-) diff --git a/client/tdm_client.h b/client/tdm_client.h index f8b2dec..7f5d247 100644 --- a/client/tdm_client.h +++ b/client/tdm_client.h @@ -440,43 +440,115 @@ unsigned int tdm_client_vblank_is_waiting(tdm_client_vblank *vblank); -/* Virtual Output */ +/** + * @brief Create the client voutput object which has the given name + * @param[in] client The TDM client object + * @param[in] name The name of the TDM client virtual output object + * @param[out] error #TDM_ERROR_NONE if success. Otherwise, error value. + * @return A client voutput object if success. Otherwise, NULL. + */ tdm_client_voutput * tdm_client_create_voutput(tdm_client *client, const char *name, tdm_error *error); +/** + * @brief Destroy the client voutput object + * @param[in] voutput The client voutput object + */ void tdm_client_voutput_destroy(tdm_client_voutput *voutput); +/** + * @brief Set the available mode info to the client voutput object + * @param[in] voutput The client voutput object + * @param[in] modes The array of available mode info + * @param[in] count The mode count + * @return #TDM_ERROR_NONE if success. Otherwise, error value. + */ tdm_error tdm_client_voutput_set_available_modes(tdm_client_voutput *voutput, const tdm_client_output_mode *modes, int count); +/** + * @brief Set the physical size info to the client voutput object + * @param[in] voutput The client voutput object + * @param[in] mmWidth The width of voutput + * @param[in] mmHeight The height of voutput + * @return #TDM_ERROR_NONE if success. Otherwise, error value. + */ tdm_error tdm_client_voutput_set_physical_size(tdm_client_voutput *voutput, unsigned int mmWidth, unsigned int mmHeight); +/** + * @brief Set the client voutput buffer commit handler + * @details The handler will be called when server send buffer. + * Client can get the committed buffer in the handler function. + * @param[in] voutput The client voutput object + * @param[in] func The user client voutput buffer commit handler + * @param[in] user_data The user_data + * @return #TDM_ERROR_NONE if success. Otherwise, error value. + */ tdm_error tdm_client_voutput_add_commit_handler(tdm_client_voutput *voutput, tdm_client_voutput_commit_handler func, void *user_data); +/** + * @brief Remove the client voutput buffer commit handler + * @param[in] voutput The client voutput object + * @param[in] func The user client voutput buffer commit handler + * @param[in] user_data The user_data + */ void tdm_client_voutput_remove_commit_handler(tdm_client_voutput *voutput, tdm_client_voutput_commit_handler func, void *user_data); -tdm_error -tdm_client_voutput_get_committed_tbm_surface(tdm_client_voutput *voutput, tbm_surface_h surface); - +/** + * @brief Send the commit done event to server + * @details + * After using the commited buffer which is get from commit handler + * have to send done event to server. + * @param[in] voutput The client voutput object + * @return #TDM_ERROR_NONE if success. Otherwise, error value. + */ tdm_error tdm_client_voutput_commit_done(tdm_client_voutput *voutput); +/** + * @brief Get the client output object which was created by the given voutput object + * @details + * The client output object is made by voutput object. + * @param[in] voutput The client voutput object + * @param[out] error #TDM_ERROR_NONE if success. Otherwise, error value. + * @return A client output object if success. Otherwise, NULL. + */ tdm_client_output * tdm_client_voutput_get_client_output(tdm_client_voutput *voutput, tdm_error *error); +/** + * @brief Set the mode to the client voutput object + * details + * The client can set the mode of voutput object by send mode index. + * the index is the array number of available modes info. + * @param[in] voutput The client voutput object + * @param[in] modes The array of available mode info + * @param[in] index The index of avaliable modes + * @return #TDM_ERROR_NONE if success. Otherwise, error value. + */ tdm_error tdm_client_voutput_set_mode(tdm_client_voutput *voutput, int index); +/** + * @brief Set the client voutput object connected status + * @detail Send availabe_modes, physical size and connect info to the server. + * @param[in] voutput The client voutput object + * @return #TDM_ERROR_NONE if success. Otherwise, error value. + */ tdm_error tdm_client_voutput_connect(tdm_client_voutput *voutput); +/** + * @brief Set the client voutput object disconnected status + * @param[in] voutput The client voutput object + * @return #TDM_ERROR_NONE if success. Otherwise, error value. + */ tdm_error tdm_client_voutput_disconnect(tdm_client_voutput *voutput); -/* End of Virtual Output */ #ifdef __cplusplus } -- 2.7.4 From 7496e4d0e074a52d556163951198bc42d06bc41d Mon Sep 17 00:00:00 2001 From: Junkyeong Kim Date: Fri, 4 Jan 2019 16:36:03 +0900 Subject: [PATCH 05/16] tdm_server: fix voutput commit buffer double ref Change-Id: I0e45baf0c4585109ce5224a9df289a9cf82dfd9d Signed-off-by: Junkyeong Kim --- src/tdm_server.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/tdm_server.c b/src/tdm_server.c index dc4f25a..4d3ad7c 100644 --- a/src/tdm_server.c +++ b/src/tdm_server.c @@ -1229,7 +1229,6 @@ tdm_voutput_commit_buffer(tdm_voutput *voutput) TDM_RETURN_VAL_IF_FAIL(voutput_info->attach_buffer != NULL, TDM_ERROR_OPERATION_FAILED); TDM_RETURN_VAL_IF_FAIL(voutput_info->committing == 0, TDM_ERROR_OPERATION_FAILED); - tbm_surface_internal_ref(voutput_info->attach_buffer->buffer); voutput_info->committing = 1; wl_tdm_voutput_send_commit(voutput_info->resource); -- 2.7.4 From 08b58ca9e23ae943687ce94eadfb7fc2097735b0 Mon Sep 17 00:00:00 2001 From: Junkyeong Kim Date: Fri, 4 Jan 2019 16:37:26 +0900 Subject: [PATCH 06/16] tdm_server: execute voutput_disconnect when voutput destroy if voutput is connected Change-Id: Ia469a4c5c0a536010ecfc2137aff0d04fef5dcef Signed-off-by: Junkyeong Kim --- src/tdm_server.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/tdm_server.c b/src/tdm_server.c index 4d3ad7c..4dfcdc1 100644 --- a/src/tdm_server.c +++ b/src/tdm_server.c @@ -1252,6 +1252,12 @@ tdm_voutput_cb_resource_destroy(struct wl_resource *resource) tdm_output_unset_voutput_commit(voutput_info->voutput); if (voutput) { + if (voutput_info->request_commit == 1) { + tdm_output_unset_voutput_commit(voutput_info->voutput); + voutput_info->request_commit = 0; + tdm_voutput_disconnect(voutput_info->voutput); + } + ret = tdm_voutput_destroy(voutput); if (ret != TDM_ERROR_NONE) TDM_ERR("_tdm_voutput_cb_destroy fail"); -- 2.7.4 From 48923ff22e1e920d712b032650f5de932e18a477 Mon Sep 17 00:00:00 2001 From: Junkyeong Kim Date: Tue, 8 Jan 2019 13:30:01 +0900 Subject: [PATCH 07/16] virtual: treat unset buffer commit Change-Id: I41ad012b0fbbdc5ea22b6e1b50be38f8aa99c060 Signed-off-by: Junkyeong Kim --- backends/virtual/tdm_virtual_display.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/backends/virtual/tdm_virtual_display.c b/backends/virtual/tdm_virtual_display.c index 2d407fe..e9e503f 100644 --- a/backends/virtual/tdm_virtual_display.c +++ b/backends/virtual/tdm_virtual_display.c @@ -459,6 +459,25 @@ virtual_output_commit(tdm_output *output, int sync, void *user_data) layer_data = output_data->primary_layer; + if (layer_data->display_buffer == NULL && layer_data->display_buffer_changed == 1) { + event_data = calloc(1, sizeof(tdm_virtual_event_data)); + if (!event_data) { + TDM_ERR("alloc failed"); + return TDM_ERROR_OUT_OF_MEMORY; + } + + event_data->type = TDM_VIRTUAL_EVENT_TYPE_COMMIT; + event_data->output_data = output_data; + event_data->user_data = user_data; + + ret = _tdm_virtual_display_wait_vblank(output_data, 3, event_data); + if (ret != TDM_ERROR_NONE) { + free(event_data); + return ret; + } + goto done; + } + if (voutput_data->vcommit_func) { if (layer_data->display_buffer_changed) { output_data->commit_user_data = user_data; @@ -496,6 +515,7 @@ virtual_output_commit(tdm_output *output, int sync, void *user_data) } } +done: layer_data->display_buffer_changed = 0; return TDM_ERROR_NONE; -- 2.7.4 From 7ad0e46a663a9312c65213f3d2ef785189ef2787 Mon Sep 17 00:00:00 2001 From: SooChan Lim Date: Mon, 14 Jan 2019 18:51:54 +0900 Subject: [PATCH 08/16] tdm_hwc_window: fix the typo Change-Id: Ie98c84ff409839066ba8568ea60b80191a692dc5 --- src/tdm_hwc_window.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tdm_hwc_window.c b/src/tdm_hwc_window.c index 8f5fcda..1dd9e54 100644 --- a/src/tdm_hwc_window.c +++ b/src/tdm_hwc_window.c @@ -481,7 +481,7 @@ tdm_hwc_window_set_name(tdm_hwc_window *hwc_window, const char *name) private_module = private_output->private_module; func_hwc_window = &private_module->func_hwc_window; - if (!func_hwc_window->hwc_window_get_constraints) { + if (!func_hwc_window->hwc_window_set_name) { _pthread_mutex_unlock(&private_display->lock); TDM_WRN("not implemented!!"); return TDM_ERROR_NOT_IMPLEMENTED; -- 2.7.4 From 6eeb0de41fe29e626979bb1fd83588f59184d510 Mon Sep 17 00:00:00 2001 From: SooChan Lim Date: Mon, 14 Jan 2019 19:58:55 +0900 Subject: [PATCH 09/16] Package version up to 2.8.1 Change-Id: I11c67c40256a8e4670538b7d51c81de6a346a59f --- packaging/libtdm.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packaging/libtdm.spec b/packaging/libtdm.spec index 2d07234..63ab10c 100644 --- a/packaging/libtdm.spec +++ b/packaging/libtdm.spec @@ -2,7 +2,7 @@ %define HALTESTS_GCOV 0 Name: libtdm -Version: 2.8.0 +Version: 2.8.1 Release: 0 Summary: User Library of Tizen Display Manager Group: Development/Libraries -- 2.7.4 From 1ee366c5e9532ff4a9efdd5ba547f464617a8585 Mon Sep 17 00:00:00 2001 From: Junkyeong Kim Date: Mon, 21 Jan 2019 19:56:55 +0900 Subject: [PATCH 10/16] server: fix voutput buffer ref error Change-Id: I604afb6f48c17f7b724fadd01580f2abe692224b Signed-off-by: Junkyeong Kim --- src/tdm_server.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/tdm_server.c b/src/tdm_server.c index 4dfcdc1..c66948d 100644 --- a/src/tdm_server.c +++ b/src/tdm_server.c @@ -926,16 +926,17 @@ _tdm_voutput_cb_disconnect(struct wl_client *client, struct wl_resource *resourc voutput_info->mmwidth = 0; voutput_info->mmheight = 0; + if (voutput_info->request_commit == 1) { + tdm_output_unset_voutput_commit(voutput_info->voutput); + voutput_info->request_commit = 0; + } + if (voutput_info->attach_buffer) { tbm_surface_h buffer = voutput_info->attach_buffer->buffer; tbm_surface_internal_unref(buffer); voutput_info->committing = 0; voutput_info->attach_buffer = NULL; - } - - if (voutput_info->request_commit == 1) { - tdm_output_unset_voutput_commit(voutput_info->voutput); - voutput_info->request_commit = 0; + tdm_voutput_commit_done(voutput_info->voutput); } tdm_voutput_disconnect(voutput_info->voutput); @@ -1148,7 +1149,6 @@ _tdm_output_get_voutput_buffer(tdm_server_voutput_info *voutput_info, tbm_surfac LIST_FOR_EACH_ENTRY(vb, &voutput_info->buffer_list, link) { if (vb && vb->buffer == buffer) { - tbm_surface_internal_ref(vb->buffer); return vb; } } @@ -1206,6 +1206,7 @@ tdm_voutput_attach_buffer(tdm_voutput *voutput, tbm_surface_h buffer) voutput_info->attach_buffer = voutput_buffer; + tbm_surface_internal_ref(buffer); wl_tdm_voutput_send_attach_buffer(voutput_info->resource, voutput_buffer->wl_buffer); return TDM_ERROR_NONE; -- 2.7.4 From 97ed6da7ed4f7663a64fe9436c6ad4292b15c232 Mon Sep 17 00:00:00 2001 From: Junkyeong Kim Date: Mon, 21 Jan 2019 20:00:45 +0900 Subject: [PATCH 11/16] server: fix voutput mode change error 1. if mode changed, exported wl_buffer is not available. (buffer size changed) so have to destroy old shared wl_buffers. 2. do not executed tdm_output_set_mode directly in voutput_set_mode cb. Change-Id: Iec7bb13ee47949562020464ea1656ec078315816 Signed-off-by: Junkyeong Kim --- src/tdm_server.c | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/src/tdm_server.c b/src/tdm_server.c index c66948d..adddc5b 100644 --- a/src/tdm_server.c +++ b/src/tdm_server.c @@ -72,6 +72,7 @@ typedef struct _tdm_server_voutput_buffer { struct list_head link; struct wl_resource *wl_buffer; tbm_surface_h buffer; + int need_reset; } tdm_server_voutput_buffer; typedef struct _tdm_server_voutput_info { @@ -870,8 +871,8 @@ _tdm_voutput_cb_set_mode(struct wl_client *client, struct wl_resource *resource, tdm_server_voutput_info *voutput_info = NULL; tdm_output *output = NULL; tdm_output_conn_status status = TDM_OUTPUT_CONN_STATUS_DISCONNECTED; - const tdm_output_mode *modes, *mode; - + const tdm_output_mode *modes, *mode, *current_mode; + tdm_server_voutput_buffer *vb = NULL, *vbb = NULL; int count = 0; tdm_error ret; @@ -889,8 +890,21 @@ _tdm_voutput_cb_set_mode(struct wl_client *client, struct wl_resource *resource, mode = &modes[index]; TDM_DBG("mode set request to index:%d (%dx%d, %d)", index, mode->hdisplay, mode->vdisplay, mode->vrefresh); - ret = tdm_output_set_mode(output, mode); + ret = tdm_output_get_mode(output, ¤t_mode); TDM_RETURN_IF_FAIL(ret == TDM_ERROR_NONE); + if (mode == current_mode) { + TDM_DBG("same mode"); + return; + } + + if ((mode->hdisplay != current_mode->hdisplay) || (mode->vdisplay != current_mode->vdisplay)) { + LIST_FOR_EACH_ENTRY_SAFE(vb, vbb, &voutput_info->buffer_list, link) { + if (vb->wl_buffer == voutput_info->attach_buffer->wl_buffer) + voutput_info->attach_buffer->need_reset = 1; + else + wl_tdm_voutput_send_destroy_buffer(voutput_info->resource, vb->wl_buffer); + } + } tdm_output_request_mode_set(voutput_info->output, index); } @@ -935,6 +949,8 @@ _tdm_voutput_cb_disconnect(struct wl_client *client, struct wl_resource *resourc tbm_surface_h buffer = voutput_info->attach_buffer->buffer; tbm_surface_internal_unref(buffer); voutput_info->committing = 0; + if (voutput_info->attach_buffer->need_reset) + wl_tdm_voutput_send_destroy_buffer(voutput_info->resource, voutput_info->attach_buffer->wl_buffer); voutput_info->attach_buffer = NULL; tdm_voutput_commit_done(voutput_info->voutput); } @@ -957,6 +973,8 @@ _tdm_voutput_cb_commit_done(struct wl_client *client, struct wl_resource *resour buffer = voutput_info->attach_buffer->buffer; tbm_surface_internal_unref(buffer); voutput_info->committing = 0; + if (voutput_info->attach_buffer->need_reset) + wl_tdm_voutput_send_destroy_buffer(voutput_info->resource, voutput_info->attach_buffer->wl_buffer); voutput_info->attach_buffer = NULL; if (voutput_info->request_commit == 1) -- 2.7.4 From d71f22895842611f3da167a328351be931e2e0af Mon Sep 17 00:00:00 2001 From: Junkyeong Kim Date: Wed, 13 Feb 2019 16:54:50 +0900 Subject: [PATCH 12/16] tdm: check mutex lock status in tdm_display_destroy_private_output some cases the mutex is not locked when called tdm_display_destroy_private_output. so in this case, do not execute mutex unlock/lock for vblank destroy. Change-Id: Ic1439f9d66d763fac00613a37c0154eb0e7c1384 Signed-off-by: Junkyeong Kim --- src/tdm.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/tdm.c b/src/tdm.c index 21bd918..81e653a 100644 --- a/src/tdm.c +++ b/src/tdm.c @@ -262,6 +262,7 @@ tdm_display_destroy_private_output(tdm_private_output *private_output) tdm_private_output_change_handler *h = NULL, *hh = NULL; tdm_private_output_destroy_handler *dh = NULL, *dhh = NULL; tdm_error ret; + int mutex_locked = 0; ret = tdm_output_call_thread_cb_destroy(private_output); TDM_WARNING_IF_FAIL(ret == TDM_ERROR_NONE); @@ -312,18 +313,19 @@ tdm_display_destroy_private_output(tdm_private_output *private_output) free(dh); } + if (tdm_thread_is_running() && TDM_MUTEX_IS_LOCKED()) mutex_locked = 1; if (private_output->vblank) { /* tdm_vblank APIs is for server. it should be called in unlock status*/ - _pthread_mutex_unlock(&private_display->lock); + if (mutex_locked) _pthread_mutex_unlock(&private_display->lock); tdm_vblank_destroy(private_output->vblank); - _pthread_mutex_lock(&private_display->lock); + if (mutex_locked) _pthread_mutex_lock(&private_display->lock); } if (private_output->ttrace_vblank) { /* tdm_vblank APIs is for server. it should be called in unlock status*/ - _pthread_mutex_unlock(&private_display->lock); + if (mutex_locked) _pthread_mutex_unlock(&private_display->lock); tdm_vblank_destroy(private_output->ttrace_vblank); - _pthread_mutex_lock(&private_display->lock); + if (mutex_locked) _pthread_mutex_lock(&private_display->lock); } LIST_FOR_EACH_ENTRY_SAFE(c, cc, &private_output->capture_list, link) -- 2.7.4 From b28f4175918e663075033cc185959f69a710f7e0 Mon Sep 17 00:00:00 2001 From: Junkyeong Kim Date: Wed, 13 Feb 2019 17:00:24 +0900 Subject: [PATCH 13/16] virtual: add missed mutex unlock in voutput commit function Change-Id: Ibda51694a9c4c4e5d404a1885a185f350205b74c Signed-off-by: Junkyeong Kim --- src/tdm_output.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/tdm_output.c b/src/tdm_output.c index dfc96ee..43efed1 100644 --- a/src/tdm_output.c +++ b/src/tdm_output.c @@ -1484,6 +1484,7 @@ tdm_output_unset_voutput_commit(tdm_voutput *voutput) ret = tdm_voutput_set_commit_func(private_voutput, NULL); if (ret != TDM_ERROR_NONE) { TDM_ERR("failed: tdm_voutput_set_commit_func"); + _pthread_mutex_unlock(&private_display->lock); return ret; } } -- 2.7.4 From 0a37ccf8b2a60d62b7286e8f0debcfccb927e4e1 Mon Sep 17 00:00:00 2001 From: Junkyeong Kim Date: Wed, 13 Feb 2019 17:26:52 +0900 Subject: [PATCH 14/16] virtual: fix wrong sizeof argument Change-Id: Ib802b19b1aed42b0646d5bd2dd8e814d0aa9c9b2 Signed-off-by: Junkyeong Kim --- src/tdm_output.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tdm_output.c b/src/tdm_output.c index 43efed1..6516b6c 100644 --- a/src/tdm_output.c +++ b/src/tdm_output.c @@ -526,7 +526,7 @@ tdm_output_add_mode_change_request_handler(tdm_output *output, } } - mode_change_handler = calloc(1, sizeof(tdm_private_output_change_handler)); + mode_change_handler = calloc(1, sizeof(tdm_private_output_mode_change_handler)); if (!mode_change_handler) { /* LCOV_EXCL_START */ TDM_ERR("failed: alloc memory"); -- 2.7.4 From 0d7ce53d86894753ff1ce7bde7a2537aea4c20a3 Mon Sep 17 00:00:00 2001 From: Junkyeong Kim Date: Thu, 14 Feb 2019 17:28:34 +0900 Subject: [PATCH 15/16] Package version up to 2.8.2 Change-Id: I1badc7be786edbb2956ae27d16914910ffa04755 Signed-off-by: Junkyeong Kim --- packaging/libtdm.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packaging/libtdm.spec b/packaging/libtdm.spec index 63ab10c..7bf0a3e 100644 --- a/packaging/libtdm.spec +++ b/packaging/libtdm.spec @@ -2,7 +2,7 @@ %define HALTESTS_GCOV 0 Name: libtdm -Version: 2.8.1 +Version: 2.8.2 Release: 0 Summary: User Library of Tizen Display Manager Group: Development/Libraries -- 2.7.4 From 6a3f7d243844340bac9104b2e445663806d0db05 Mon Sep 17 00:00:00 2001 From: SooChan Lim Date: Sun, 24 Feb 2019 14:30:17 +0900 Subject: [PATCH 16/16] hwc: add tdm_hwc_set_property The user can set the property on the hwc object. Change-Id: I3b918f99957e72135190af95722ece8ff38341b7 --- include/tdm.h | 10 ++++++++++ include/tdm_backend.h | 9 +++++++++ src/tdm_hwc.c | 30 +++++++++++++++++++++++++++++- 3 files changed, 48 insertions(+), 1 deletion(-) diff --git a/include/tdm.h b/include/tdm.h index 0a2bcab..53aa771 100644 --- a/include/tdm.h +++ b/include/tdm.h @@ -1030,6 +1030,16 @@ tdm_error tdm_hwc_commit(tdm_hwc *hwc, int sync, tdm_hwc_commit_handler func, void *user_data); /** + * @brief Set the property which has a given id on the hwc object. + * @param[in] hwc A hwc object + * @param[in] id The property id + * @param[in] value The value of the propery id + * @return #TDM_ERROR_NONE if success. Otherwise, error value. + */ +tdm_error +tdm_hwc_set_property(tdm_hwc *hwc, uint32_t id, tdm_value value); + +/** * @brief Destroys the given window. * @param[in] window the pointer of the window to destroy * @since 2.0.0 diff --git a/include/tdm_backend.h b/include/tdm_backend.h index c515934..e89cd91 100644 --- a/include/tdm_backend.h +++ b/include/tdm_backend.h @@ -928,6 +928,15 @@ typedef struct _tdm_func_hwc { * @return #TDM_ERROR_NONE if success. Otherwise, error value. */ tdm_error (*hwc_set_commit_handler)(tdm_hwc *hwc, tdm_hwc_commit_handler func); + + /** + * @brief Set the property which has a given id on the hwc object. + * @param[in] hwc A hwc object + * @param[in] id The property id + * @param[in] value The value of the propery id + * @return #TDM_ERROR_NONE if success. Otherwise, error value. + */ + tdm_error (*hwc_set_property)(tdm_hwc *hwc, uint32_t id, tdm_value value); } tdm_func_hwc; /** diff --git a/src/tdm_hwc.c b/src/tdm_hwc.c index 2632c5b..b9029be 100644 --- a/src/tdm_hwc.c +++ b/src/tdm_hwc.c @@ -605,4 +605,32 @@ commit_failed: return ret; /* LCOV_EXCL_STOP */ -} \ No newline at end of file +} + +tdm_error +tdm_hwc_set_property(tdm_hwc *hwc, uint32_t id, tdm_value value) +{ + tdm_private_module *private_module; + tdm_func_hwc *func_hwc = NULL; + + HWC_FUNC_ENTRY(); + + _pthread_mutex_lock(&private_display->lock); + + private_module = private_hwc->private_module; + func_hwc = &private_module->func_hwc; + + if (!func_hwc->hwc_set_property) { + /* LCOV_EXCL_START */ + _pthread_mutex_unlock(&private_display->lock); + TDM_WRN("not implemented!!"); + return TDM_ERROR_NOT_IMPLEMENTED; + /* LCOV_EXCL_STOP */ + } + + ret = func_hwc->hwc_set_property(private_hwc->hwc_backend, id, value); + + _pthread_mutex_unlock(&private_display->lock); + + return ret; +} -- 2.7.4