From 0d10c57ab5dfb6aa418195e2489ce469fec937bb Mon Sep 17 00:00:00 2001 From: SooChan Lim Date: Wed, 28 Nov 2018 19:37:21 +0900 Subject: [PATCH 01/16] Package version up to 2.5.0 Change-Id: I549452dbc92a1dec46a2af144c996eaae061af18 --- packaging/libtdm.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packaging/libtdm.spec b/packaging/libtdm.spec index 73dd3ad..9477c6f 100644 --- a/packaging/libtdm.spec +++ b/packaging/libtdm.spec @@ -2,7 +2,7 @@ %define HALTESTS_GCOV 0 Name: libtdm -Version: 2.4.2 +Version: 2.5.0 Release: 0 Summary: User Library of Tizen Display Manager Group: Development/Libraries -- 2.7.4 From 26cfd43965439f3410908a0a6e76d91b33c883b1 Mon Sep 17 00:00:00 2001 From: Changyeon Lee Date: Fri, 2 Nov 2018 14:09:51 +0900 Subject: [PATCH 02/16] tdm_client: add timeout timer to tdm_server vblank if callback of timeout is called, send done event to client with TDM_ERROR_TIMEOUT. Change-Id: I3a1bd15bc733cf685f84f6eeb81acd03952b6183 --- src/tdm_server.c | 91 ++++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 89 insertions(+), 2 deletions(-) diff --git a/src/tdm_server.c b/src/tdm_server.c index d4166b4..76bae78 100644 --- a/src/tdm_server.c +++ b/src/tdm_server.c @@ -102,6 +102,9 @@ typedef struct _tdm_server_vblank_info { tdm_vblank *vblank; unsigned int stamp; + + /* for timeout */ + tdm_event_loop_source *vblank_timeout_timer; } tdm_server_vblank_info; typedef struct _tdm_server_wait_info { @@ -110,6 +113,8 @@ typedef struct _tdm_server_wait_info { unsigned int req_id; double req_time; + + unsigned int timeout; } tdm_server_wait_info; typedef struct _tdm_server_client_info { @@ -123,6 +128,7 @@ static tdm_private_server *keep_private_server; static struct list_head client_list; static void destroy_wait(tdm_server_wait_info *wait_info); +static void _tdm_server_vblank_timeout_update(tdm_server_vblank_info *vblank_info, int ms_delay); static void _tdm_server_get_process_name(pid_t pid, char *name, unsigned int size) @@ -158,6 +164,9 @@ _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_server_output_info *output_info; + tdm_private_server *private_server; + tdm_private_loop *private_loop; TDM_RETURN_IF_FAIL(keep_private_server != NULL); @@ -172,18 +181,82 @@ _tdm_server_send_done(tdm_server_wait_info *wait_info, tdm_error error, TDM_DBG("req_id(%d) done", wait_info->req_id); vblank_info = wait_info->vblank_info; + output_info = vblank_info->output_info; + private_server = output_info->private_server; + private_loop = private_server->private_loop; + + tdm_display_lock(private_loop->dpy); + _tdm_server_vblank_timeout_update(vblank_info, 0); + tdm_display_unlock(private_loop->dpy); if (tdm_ttrace_module & TDM_TTRACE_SERVER_VBLANK) TDM_TRACE_ASYNC_END((int)wait_info->req_time, "TDM_Server_Vblank:%u", vblank_info->stamp); - wl_tdm_vblank_send_done(vblank_info->resource, wait_info->req_id, - sequence, tv_sec, tv_usec, error); + if (!wait_info->timeout) + wl_tdm_vblank_send_done(vblank_info->resource, wait_info->req_id, + sequence, tv_sec, tv_usec, error); destroy_wait(wait_info); } /* LCOV_EXCL_STOP */ /* LCOV_EXCL_START */ +static tdm_error +_tdm_server_timeout_timer_cb(void *user_data) +{ + tdm_server_vblank_info *vblank_info = user_data; + tdm_server_wait_info *wait_info = NULL; + double curr; + unsigned int tv_sec; + unsigned int tv_usec; + + TDM_RETURN_VAL_IF_FAIL(vblank_info != NULL, TDM_ERROR_OPERATION_FAILED); + TDM_RETURN_VAL_IF_FAIL(keep_private_server != NULL, TDM_ERROR_OPERATION_FAILED); + + curr = tdm_helper_get_time(); + tv_sec = TDM_TIME_SEC(curr); + tv_usec = TDM_TIME_USEC(curr); + + LIST_FOR_EACH_ENTRY(wait_info, &keep_private_server->wait_list, link) { + wl_tdm_vblank_send_done(vblank_info->resource, wait_info->req_id, + 0, tv_sec, tv_usec, TDM_ERROR_TIMEOUT); + TDM_ERR("tdm_server_vblank(%p) req_id(%d) timeout force send vblank", vblank_info); + wait_info->timeout = 1; + } + + return TDM_ERROR_NONE; +} + +static void +_tdm_server_vblank_timeout_update(tdm_server_vblank_info *vblank_info, int ms_delay) +{ + tdm_server_output_info *output_info = vblank_info->output_info; + tdm_private_server *private_server = output_info->private_server; + tdm_private_loop *private_loop = private_server->private_loop; + tdm_error ret; + + if (!vblank_info->vblank_timeout_timer) { + vblank_info->vblank_timeout_timer = + tdm_event_loop_add_timer_handler(private_loop->dpy, + _tdm_server_timeout_timer_cb, + vblank_info, + &ret); + if (!vblank_info->vblank_timeout_timer) { + TDM_ERR("tdm_server_vblank(%p) couldn't add timer", vblank_info); + return; + } + + if (tdm_debug_module & TDM_DEBUG_VBLANK) + TDM_INFO("tdm_server_vblank(%p) create vblank timeout timer", vblank_info); + } + + ret = tdm_event_loop_source_timer_update(vblank_info->vblank_timeout_timer, ms_delay); + if (ret != TDM_ERROR_NONE) { + TDM_ERR("tdm_server_vblank(%p) couldn't update timer", vblank_info); + return; + } +} + static void _tdm_server_cb_vblank(tdm_vblank *vblank, tdm_error error, unsigned int sequence, unsigned int tv_sec, unsigned int tv_usec, void *user_data) @@ -257,10 +330,19 @@ static void destroy_vblank_callback(struct wl_resource *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_loop *private_loop = private_server->private_loop; tdm_server_wait_info *w = NULL, *ww = NULL; TDM_RETURN_IF_FAIL(vblank_info != NULL); + if (vblank_info->vblank_timeout_timer) { + tdm_display_lock(private_loop->dpy); + tdm_event_loop_source_remove(vblank_info->vblank_timeout_timer); + tdm_display_unlock(private_loop->dpy); + } + LIST_DEL(&vblank_info->link); if (vblank_info->vblank) @@ -335,6 +417,7 @@ _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_loop *private_loop = private_server->private_loop; tdm_server_wait_info *wait_info; unsigned int enable_fake = 0; tdm_error ret; @@ -369,6 +452,10 @@ _tdm_server_vblank_cb_wait_vblank(struct wl_client *client, struct wl_resource * TDM_GOTO_IF_FAIL(ret == TDM_ERROR_NONE, wait_failed); + tdm_display_lock(private_loop->dpy); + _tdm_server_vblank_timeout_update(vblank_info, 1000); + tdm_display_unlock(private_loop->dpy); + return; wait_failed: /* LCOV_EXCL_START */ -- 2.7.4 From 72370557b040eda09c48cfbb8c64cbe396e97b94 Mon Sep 17 00:00:00 2001 From: SooChan Lim Date: Fri, 30 Nov 2018 19:18:08 +0900 Subject: [PATCH 03/16] Package version up to 2.5.1 Change-Id: I61c5e15527581e784e3ffebd9a4c6b37101b29a6 --- packaging/libtdm.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packaging/libtdm.spec b/packaging/libtdm.spec index 9477c6f..94174cb 100644 --- a/packaging/libtdm.spec +++ b/packaging/libtdm.spec @@ -2,7 +2,7 @@ %define HALTESTS_GCOV 0 Name: libtdm -Version: 2.5.0 +Version: 2.5.1 Release: 0 Summary: User Library of Tizen Display Manager Group: Development/Libraries -- 2.7.4 From 3468a0272e41b8e63c5d7f2cf0b3650d6e795570 Mon Sep 17 00:00:00 2001 From: SooChan Lim Date: Mon, 3 Dec 2018 17:27:16 +0900 Subject: [PATCH 04/16] Revert "hwc: add the prototypes to avoid build break" This reverts commit 360af47b34a4fbcfb48be27fdae57654f22c91ef. Change-Id: Iff209d517462a5929f251187a523bfbfdd2776fe --- include/tdm.h | 3 --- include/tdm_types.h | 9 --------- src/tdm_hwc.c | 7 ------- 3 files changed, 19 deletions(-) diff --git a/include/tdm.h b/include/tdm.h index 8b74b0e..63edce4 100644 --- a/include/tdm.h +++ b/include/tdm.h @@ -1016,9 +1016,6 @@ tdm_hwc_get_changed_composition_types(tdm_hwc *hwc, uint32_t *num_elements, tdm_error tdm_hwc_accept_validation(tdm_hwc *hwc); -/* temporary prototype to avoid build break */ -tdm_error tdm_hwc_accept_changes(tdm_hwc *hwc); - /** * @brief Commit changes for a hwc * @details After all change of a window object are applied, a user commit handler diff --git a/include/tdm_types.h b/include/tdm_types.h index 50fb4b8..d9ab984 100644 --- a/include/tdm_types.h +++ b/include/tdm_types.h @@ -222,15 +222,6 @@ typedef enum { TDM_HWC_WIN_CONSTRAINT_BUFFER_QUEUE = (1 << 0), } tdm_hwc_window_constraint; -/* temporary prototype to avoid build break */ -#define TDM_CONSTRAINT_NONE 0 -#define TDM_CONSTRAINT_BUFFER_QUEUE (1 << 0) -#define TDM_COMPOSITION_NONE 0 -#define TDM_COMPOSITION_CLIENT 1 -#define TDM_COMPOSITION_DEVICE 3 -#define TDM_COMPOSITION_CURSOR 4 -#define TDM_COMPOSITION_VIDEO 5 - /** * @brief The tdm display object */ diff --git a/src/tdm_hwc.c b/src/tdm_hwc.c index bd7428c..fc9563c 100644 --- a/src/tdm_hwc.c +++ b/src/tdm_hwc.c @@ -510,13 +510,6 @@ tdm_hwc_accept_validation(tdm_hwc *hwc) return ret; } -/* temporary prototype to avoid build break */ -tdm_error -tdm_hwc_accept_changes(tdm_hwc *hwc) -{ - return tdm_hwc_accept_validation(hwc); -} - EXTERN tdm_error tdm_hwc_commit(tdm_hwc *hwc, int sync, tdm_hwc_commit_handler func, void *user_data) { -- 2.7.4 From 8f1377d4928ad9bdcc0cf10e16bfd24a3ed56de3 Mon Sep 17 00:00:00 2001 From: SooChan Lim Date: Tue, 4 Dec 2018 11:18:59 +0900 Subject: [PATCH 05/16] add tdm_hwc_window_set_cursor_image let the tdm backend know the virtual address and information of the cursor image. Change-Id: I31716a8fae97affb5ab801027c081bd0d2bdccbc --- include/tdm.h | 12 ++++++++++++ include/tdm_backend.h | 12 ++++++++++++ src/tdm_hwc_window.c | 26 ++++++++++++++++++++++++++ 3 files changed, 50 insertions(+) diff --git a/include/tdm.h b/include/tdm.h index 63edce4..c18b27e 100644 --- a/include/tdm.h +++ b/include/tdm.h @@ -1159,6 +1159,18 @@ tdm_error tdm_hwc_window_set_name(tdm_hwc_window *hwc_window, const char *name); /** + * @brief Get buffer flags of cursor hwc_window + * @param[in] hwc_window A hwc window object + * @param[in] width of the cursor image + * @param[in] height of the cursor image + * @param[in] stride of the cursor image + * @param[in] virtual address of the cursor image + * @return #TDM_ERROR_NONE if success. Otherwise, error value. + */ +tdm_error +tdm_hwc_window_set_cursor_image(tdm_hwc_window *hwc_window, int width, int height, int stride, void *ptr); + +/** * @brief Destroy a pp object * @param[in] pp A pp object * @see tdm_display_create_pp diff --git a/include/tdm_backend.h b/include/tdm_backend.h index 1b73ba9..b131ced 100644 --- a/include/tdm_backend.h +++ b/include/tdm_backend.h @@ -1056,6 +1056,18 @@ typedef struct _tdm_func_hwc_window { */ tdm_error (*hwc_window_set_name)(tdm_hwc_window *hwc_window, const char *name); + + /** + * @brief Get buffer flags of cursor hwc_window + * @param[in] hwc_window A hwc window object + * @param[in] width of the cursor image + * @param[in] height of the cursor image + * @param[in] stride of the cursor image + * @param[in] virtual address of the cursor image + * @return #TDM_ERROR_NONE if success. Otherwise, error value. + */ + tdm_error (*hwc_window_set_cursor_image)(tdm_hwc_window *hwc_window, + int width, int height, int stride, void *ptr); } tdm_func_hwc_window; /** diff --git a/src/tdm_hwc_window.c b/src/tdm_hwc_window.c index fd86345..8f5fcda 100644 --- a/src/tdm_hwc_window.c +++ b/src/tdm_hwc_window.c @@ -493,4 +493,30 @@ tdm_hwc_window_set_name(tdm_hwc_window *hwc_window, const char *name) return ret; } + +tdm_error +tdm_hwc_window_set_cursor_image(tdm_hwc_window *hwc_window, int width, int height, int stride, void *ptr) +{ + tdm_private_module *private_module; + tdm_func_hwc_window *func_hwc_window = NULL; + + HWC_WINDOW_FUNC_ENTRY(); + + _pthread_mutex_lock(&private_display->lock); + + private_module = private_output->private_module; + func_hwc_window = &private_module->func_hwc_window; + + if (!func_hwc_window->hwc_window_set_cursor_image) { + _pthread_mutex_unlock(&private_display->lock); + TDM_WRN("not implemented!!"); + return TDM_ERROR_NOT_IMPLEMENTED; + } + + ret = func_hwc_window->hwc_window_set_cursor_image(private_hwc_window->hwc_window_backend, width, height, stride, ptr); + + _pthread_mutex_unlock(&private_display->lock); + + return ret; +} /* LCOV_EXCL_STOP */ \ No newline at end of file -- 2.7.4 From d3cdde0ab4edb3711a9a31d02b2eb4e1ada07a05 Mon Sep 17 00:00:00 2001 From: SooChan Lim Date: Mon, 3 Dec 2018 17:27:55 +0900 Subject: [PATCH 06/16] Package version up to 2.6.0 Change-Id: Ia420089798803f6e3ae5e8000a466b7600c981f4 --- packaging/libtdm.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packaging/libtdm.spec b/packaging/libtdm.spec index 94174cb..cec90ca 100644 --- a/packaging/libtdm.spec +++ b/packaging/libtdm.spec @@ -2,7 +2,7 @@ %define HALTESTS_GCOV 0 Name: libtdm -Version: 2.5.1 +Version: 2.6.0 Release: 0 Summary: User Library of Tizen Display Manager Group: Development/Libraries -- 2.7.4 From 1e5cde6cf72bf4242af6e9d1c2a6d57b5e2311ad Mon Sep 17 00:00:00 2001 From: SooChan Lim Date: Fri, 14 Dec 2018 08:42:07 +0900 Subject: [PATCH 07/16] hwc: add the hwc capabilities replace hwc video capabilities into hwc capabilities Change-Id: I1b9640b5c3bd06dff5899f9628de40f3ac0fa911 --- include/tdm.h | 6 +++--- include/tdm_backend.h | 7 +++---- include/tdm_common.h | 11 ++++++----- src/tdm_hwc.c | 8 +++----- 4 files changed, 15 insertions(+), 17 deletions(-) diff --git a/include/tdm.h b/include/tdm.h index c18b27e..125ca56 100644 --- a/include/tdm.h +++ b/include/tdm.h @@ -917,13 +917,13 @@ tdm_error tdm_hwc_get_video_available_properties(tdm_hwc *hwc, const tdm_prop **props, int *count); /** - * @brief Get the hwc video capability + * @brief Get the hwc capabilites * @param[in] hwc A hwc object - * @param[out] video_capability A hwc video capability + * @param[out] capabilities A hwc capability * @return #TDM_ERROR_NONE if success. Otherwise, error value. */ tdm_error -tdm_hwc_get_video_capability(tdm_hwc *hwc, tdm_hwc_video_capability *video_capability); +tdm_hwc_get_capabilities(tdm_hwc *hwc, tdm_hwc_capability *capabilities); /** * @brief Get the available property array of a hwc object. diff --git a/include/tdm_backend.h b/include/tdm_backend.h index b131ced..c515934 100644 --- a/include/tdm_backend.h +++ b/include/tdm_backend.h @@ -813,13 +813,12 @@ typedef struct _tdm_func_hwc { int *count); /** - * @brief Get the hwc video capability + * @brief Get the hwc capabilities * @param[in] hwc A hwc object - * @param[out] video_capability A hwc hwc video capability + * @param[out] capabilities A hwc hwc capability * @return #TDM_ERROR_NONE if success. Otherwise, error value. */ - tdm_error (*hwc_get_video_capability)(tdm_hwc *hwc, - tdm_hwc_video_capability *video_capability); + tdm_error (*hwc_get_capabilities)(tdm_hwc *hwc, tdm_hwc_capability *capabilities); /** * @brief Get the available property array of a hwc object. diff --git a/include/tdm_common.h b/include/tdm_common.h index b402277..70a081c 100644 --- a/include/tdm_common.h +++ b/include/tdm_common.h @@ -261,13 +261,14 @@ typedef enum { /* * @brief The hwc video capability enumeration - * @since 2.0.0 + * @since 2.7.0 */ typedef enum { - TDM_HWC_VIDEO_CAPABILITY_SCALE = (1 << 1), /**< if a hwc video has scale capability */ - TDM_HWC_VIDEO_CAPABILITY_TRANSFORM = (1 << 2), /**< if a hwc video has transform capability */ - TDM_HWC_VIDEO_CAPABILITY_SCANOUT = (1 << 3), /**< if a video allows a scanout buffer only */ -} tdm_hwc_video_capability; + TDM_HWC_CAPABILITY_VIDEO_STREAM = (1 << 1), /**< if a hwc has video stream capability */ + TDM_HWC_CAPABILITY_VIDEO_SCALE = (1 << 2), /**< if a hwc allows to scale the video buffer */ + TDM_HWC_CAPABILITY_VIDEO_TRANSFORM = (1 << 3), /**< if a hwc allows video to transform the video buffer */ + TDM_HWC_CAPABILITY_VIDEO_SCANOUT = (1 << 4), /**< if a hwc allows video to accept the scanout buffer only */ +} tdm_hwc_capability; /** * @brief The size structure diff --git a/src/tdm_hwc.c b/src/tdm_hwc.c index fc9563c..2632c5b 100644 --- a/src/tdm_hwc.c +++ b/src/tdm_hwc.c @@ -240,8 +240,7 @@ tdm_hwc_get_video_available_properties(tdm_hwc *hwc, const tdm_prop **props, int } EXTERN tdm_error -tdm_hwc_get_video_capability(tdm_hwc *hwc, - tdm_hwc_video_capability *video_capability) +tdm_hwc_get_capabilities(tdm_hwc *hwc, tdm_hwc_capability *capabilities) { tdm_private_module *private_module; tdm_func_hwc *func_hwc; @@ -253,14 +252,13 @@ tdm_hwc_get_video_capability(tdm_hwc *hwc, private_module = private_output->private_module; func_hwc = &private_module->func_hwc; - if (!func_hwc->hwc_get_video_capability) { + if (!func_hwc->hwc_get_capabilities) { _pthread_mutex_unlock(&private_display->lock); TDM_WRN("not implemented!!"); return TDM_ERROR_NOT_IMPLEMENTED; } - ret = func_hwc->hwc_get_video_capability(private_hwc->hwc_backend, - video_capability); + ret = func_hwc->hwc_get_capabilities(private_hwc->hwc_backend, capabilities); _pthread_mutex_unlock(&private_display->lock); -- 2.7.4 From 95af5139e398eba6799b80b503ec2b98d0d9ee16 Mon Sep 17 00:00:00 2001 From: SooChan Lim Date: Fri, 14 Dec 2018 09:58:50 +0900 Subject: [PATCH 08/16] Package version up to 2.7.0 Change-Id: I3f0fbf6c8055b9d200d60dc93ab48bdc30da10e7 --- packaging/libtdm.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packaging/libtdm.spec b/packaging/libtdm.spec index cec90ca..fc162ee 100644 --- a/packaging/libtdm.spec +++ b/packaging/libtdm.spec @@ -2,7 +2,7 @@ %define HALTESTS_GCOV 0 Name: libtdm -Version: 2.6.0 +Version: 2.7.0 Release: 0 Summary: User Library of Tizen Display Manager Group: Development/Libraries -- 2.7.4 From be18f2c10b95570b5ea0c6c9839254febe4a6352 Mon Sep 17 00:00:00 2001 From: Changyeon Lee Date: Wed, 19 Dec 2018 16:42:08 +0900 Subject: [PATCH 09/16] tdm_server: check timeout flag and vblank_info in timeout callback Change-Id: Ie203b32e29bab94dcb386884e05a1e87a9c5bab4 --- src/tdm_server.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/tdm_server.c b/src/tdm_server.c index 76bae78..31ddf14 100644 --- a/src/tdm_server.c +++ b/src/tdm_server.c @@ -218,9 +218,12 @@ _tdm_server_timeout_timer_cb(void *user_data) tv_usec = TDM_TIME_USEC(curr); LIST_FOR_EACH_ENTRY(wait_info, &keep_private_server->wait_list, link) { + if (wait_info->timeout) continue; + if (vblank_info != wait_info->vblank_info) continue; + wl_tdm_vblank_send_done(vblank_info->resource, wait_info->req_id, 0, tv_sec, tv_usec, TDM_ERROR_TIMEOUT); - TDM_ERR("tdm_server_vblank(%p) req_id(%d) timeout force send vblank", vblank_info); + TDM_ERR("tdm_server_vblank(%p) req_id(%d) timeout force send vblank", vblank_info, wait_info->req_id); wait_info->timeout = 1; } -- 2.7.4 From b9ad695b3a0278c35bbe1deb419808c6a1fcb3df Mon Sep 17 00:00:00 2001 From: Changyeon Lee Date: Wed, 19 Dec 2018 16:47:46 +0900 Subject: [PATCH 10/16] Package version up to 2.7.1 Change-Id: I754504ebcac8b4af01c23e09a6037f264835fbfc --- packaging/libtdm.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packaging/libtdm.spec b/packaging/libtdm.spec index fc162ee..23e7273 100644 --- a/packaging/libtdm.spec +++ b/packaging/libtdm.spec @@ -2,7 +2,7 @@ %define HALTESTS_GCOV 0 Name: libtdm -Version: 2.7.0 +Version: 2.7.1 Release: 0 Summary: User Library of Tizen Display Manager Group: Development/Libraries -- 2.7.4 From 70fed1b2a9e9a77f139e63fa1844cf90120322cb Mon Sep 17 00:00:00 2001 From: Junkyeong Kim Date: Tue, 11 Dec 2018 21:22:03 +0900 Subject: [PATCH 11/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 12/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 13/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 14/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 15/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 16/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