From 12851c901363be59735440f9070dcc2180b17bdd Mon Sep 17 00:00:00 2001 From: SooChan Lim Date: Mon, 12 Feb 2018 11:04:06 +0900 Subject: [PATCH 01/16] hwc: add tdm_hwc_window_commit Change-Id: Ic6282508e8ce1a075c340b167ae821512de7bf90 --- include/tdm.h | 12 +++++ include/tdm_types.h | 7 +++ src/tdm_hwc_window.c | 117 ++++++++++++++++++++++++++++++++++++++++++++++++ src/tdm_private_types.h | 7 +++ 4 files changed, 143 insertions(+) diff --git a/include/tdm.h b/include/tdm.h index e317832..7437d86 100644 --- a/include/tdm.h +++ b/include/tdm.h @@ -1083,6 +1083,18 @@ tdm_error tdm_hwc_window_unset_flags(tdm_hwc_window *hwc_window, tdm_hwc_window_flag flags); /** + * @brief Commit changes for a window object + * @details After all change of a window object are applied, a user commit handler + * will be called. + * @param[in] hwc_window A window object + * @param[in] func A user commit handler + * @param[in] user_data The user data + * @return #TDM_ERROR_NONE if success. Otherwise, error value. + */ +tdm_error +tdm_hwc_window_commit(tdm_hwc_window *hwc_window, tdm_hwc_window_commit_handler func, void *user_data); + +/** * @brief Get the available property array of a video hwc window object. * @param[in] hwc window A video hwc window object * @param[out] props The available property array diff --git a/include/tdm_types.h b/include/tdm_types.h index a20049f..f08d347 100644 --- a/include/tdm_types.h +++ b/include/tdm_types.h @@ -267,6 +267,13 @@ typedef void (*tdm_layer_commit_handler)(tdm_layer *layer, unsigned int sequence void *user_data); /** + * @brief The hwc_window commit handler + */ +typedef void (*tdm_hwc_window_commit_handler)(tdm_hwc_window *hwc_window, unsigned int sequence, + unsigned int tv_sec, unsigned int tv_usec, + void *user_data); + +/** * @brief The done handler of a pp object */ typedef void (*tdm_pp_done_handler)(tdm_pp *pp, tbm_surface_h src, diff --git a/src/tdm_hwc_window.c b/src/tdm_hwc_window.c index 96d2698..08fc80c 100644 --- a/src/tdm_hwc_window.c +++ b/src/tdm_hwc_window.c @@ -409,6 +409,123 @@ tdm_hwc_window_unset_flags(tdm_hwc_window *hwc_window, tdm_hwc_window_flag flags return ret; } +static void +_tdm_hwc_window_layer_commit_handler(tdm_layer *layer, unsigned int sequence, + unsigned int tv_sec, unsigned int tv_usec, + void *user_data) +{ + tdm_private_hwc_window_commit_handler *hwc_window_commit_handler = (tdm_private_hwc_window_commit_handler *)user_data; + tdm_hwc_window_commit_handler func = hwc_window_commit_handler->func; + tdm_hwc_window *hwc_window = (tdm_hwc_window *)hwc_window_commit_handler->private_hwc_window; + void *data = hwc_window_commit_handler->user_data; + + func(hwc_window, sequence, tv_sec, tv_usec, data); + + free(hwc_window_commit_handler); +} + +tdm_error +tdm_hwc_window_commit(tdm_hwc_window *hwc_window, tdm_hwc_window_commit_handler func, void *user_data) +{ + tdm_func_hwc_window *func_hwc_window = NULL; + tdm_private_hwc_window_commit_handler *hwc_window_commit_handler; + tdm_layer *layer = NULL; + tdm_private_layer *private_layer; + tdm_info_layer *info_layer; + tdm_hwc_window_info window_info; + tbm_surface_h buffer; + + HWC_WINDOW_FUNC_ENTRY(); + + _pthread_mutex_lock(&private_display->lock); + + func_hwc_window = &private_display->func_hwc_window; + + if (!func_hwc_window->hwc_window_get_layer) { + /* LCOV_EXCL_START */ + _pthread_mutex_unlock(&private_display->lock); + TDM_ERR("not implemented!!"); + return TDM_ERROR_NOT_IMPLEMENTED; + /* LCOV_EXCL_STOP */ + } + + layer = func_hwc_window->hwc_window_get_layer(private_hwc_window->hwc_window_backend, + &ret); + if (!layer) { + /* LCOV_EXCL_START */ + _pthread_mutex_unlock(&private_display->lock); + TDM_ERR("no assigned layer!!"); + return TDM_ERROR_INVALID_PARAMETER; + /* LCOV_EXCL_STOP */ + } + + private_layer = (tdm_private_layer*)layer; + + buffer = func_hwc_window->hwc_window_get_buffer(private_hwc_window->hwc_window_backend, + &ret); + if (!buffer) { + /* LCOV_EXCL_START */ + _pthread_mutex_unlock(&private_display->lock); + TDM_ERR("no assigned buffer!!"); + return TDM_ERROR_INVALID_PARAMETER; + /* LCOV_EXCL_STOP */ + } + + if (buffer) + ret = tdm_layer_set_buffer_internal(private_layer, buffer); + else + ret = tdm_layer_unset_buffer_internal(private_layer); + if (ret != TDM_ERROR_NONE) { + /* LCOV_EXCL_START */ + TDM_ERR("failed: layer set buffer(window)"); + /* LCOV_EXCL_STOP */ + return ret; + } + + ret = func_hwc_window->hwc_window_get_info(private_hwc_window->hwc_window_backend, + &window_info); + if (ret != TDM_ERROR_NONE) { + /* LCOV_EXCL_START */ + TDM_ERR("failed: commit layer(window)"); + /* LCOV_EXCL_STOP */ + return ret; + } + + info_layer = (tdm_info_layer *)&window_info; + ret = tdm_layer_set_info_internal(private_layer, info_layer); + if (ret != TDM_ERROR_NONE) { + /* LCOV_EXCL_START */ + TDM_ERR("failed: layer set info(window)"); + /* LCOV_EXCL_STOP */ + return ret; + } + + hwc_window_commit_handler = calloc(1, sizeof(tdm_private_hwc_window_commit_handler)); + if (!hwc_window_commit_handler) { + /* LCOV_EXCL_START */ + TDM_ERR("failed: alloc memory"); + return TDM_ERROR_OUT_OF_MEMORY; + /* LCOV_EXCL_STOP */ + } + + hwc_window_commit_handler->private_hwc_window = private_hwc_window; + hwc_window_commit_handler->func = func; + hwc_window_commit_handler->user_data = user_data; + + ret = tdm_layer_commit_internal(private_layer, _tdm_hwc_window_layer_commit_handler, user_data); + if (ret != TDM_ERROR_NONE) { + /* LCOV_EXCL_START */ + TDM_ERR("failed: commit layer(window)"); + free(hwc_window_commit_handler); + /* LCOV_EXCL_STOP */ + return ret; + } + + _pthread_mutex_unlock(&private_display->lock); + + return ret; +} + EXTERN tdm_error tdm_hwc_window_video_get_capability(tdm_hwc_window *hwc_window, tdm_hwc_window_video_capability *video_capability) diff --git a/src/tdm_private_types.h b/src/tdm_private_types.h index 8f7fb7d..642e962 100644 --- a/src/tdm_private_types.h +++ b/src/tdm_private_types.h @@ -107,6 +107,7 @@ typedef struct _tdm_private_thread tdm_private_thread; typedef struct _tdm_private_vblank_handler tdm_private_vblank_handler; typedef struct _tdm_private_output_commit_handler tdm_private_output_commit_handler; typedef struct _tdm_private_layer_commit_handler tdm_private_layer_commit_handler; +typedef struct _tdm_private_hwc_window_commit_handler tdm_private_hwc_window_commit_handler; typedef struct _tdm_private_change_handler tdm_private_change_handler; typedef struct _tdm_private_layer_buffer tdm_private_layer_buffer; @@ -368,6 +369,12 @@ struct _tdm_private_layer_commit_handler { tdm_private_layer_buffer *committed_buffer; /* for layer_commit */ }; +struct _tdm_private_hwc_window_commit_handler { + tdm_private_hwc_window *private_hwc_window; + tdm_hwc_window_commit_handler func; + void *user_data; +}; + struct _tdm_private_change_handler { struct list_head link; -- 2.7.4 From 1eeff4b0b05d15287ed013a3529a3abe18563b8d Mon Sep 17 00:00:00 2001 From: SooChan Lim Date: Mon, 12 Feb 2018 11:17:05 +0900 Subject: [PATCH 02/16] hwc: add tdm_output_hwc_commit_client_target_buffer Change-Id: I48164e6e2ea918567355c7bf69a751e0dfdee472 --- include/tdm.h | 12 +++++ include/tdm_types.h | 7 +++ src/tdm_output.c | 137 ++++++++++++++++++++++++++++++++++++++++++++++++ src/tdm_private_types.h | 10 ++++ 4 files changed, 166 insertions(+) diff --git a/include/tdm.h b/include/tdm.h index 7437d86..f90fbe8 100644 --- a/include/tdm.h +++ b/include/tdm.h @@ -645,6 +645,18 @@ tdm_error tdm_output_hwc_unset_client_target_buffer(tdm_output *output); /** + * @brief Commit changes for a target_window + * @details After all change of a window object are applied, a user commit handler + * will be called. + * @param[in] hwc_window A window object + * @param[in] func A user commit handler + * @param[in] user_data The user data + * @return #TDM_ERROR_NONE if success. Otherwise, error value. + */ +tdm_error +tdm_output_hwc_commit_client_target_buffer(tdm_output *output, tdm_output_hwc_target_buffer_commit_handler func, void *user_data); + +/** * @brief Validate the output * @details Instructs the device to inspect all of the layer state and * determine if there are any composition type changes necessary before diff --git a/include/tdm_types.h b/include/tdm_types.h index f08d347..d2013b7 100644 --- a/include/tdm_types.h +++ b/include/tdm_types.h @@ -274,6 +274,13 @@ typedef void (*tdm_hwc_window_commit_handler)(tdm_hwc_window *hwc_window, unsign void *user_data); /** + * @brief The output target_buffer commit handler + */ +typedef void (*tdm_output_hwc_target_buffer_commit_handler)(tdm_output *output, unsigned int sequence, + unsigned int tv_sec, unsigned int tv_usec, + void *user_data); + +/** * @brief The done handler of a pp object */ typedef void (*tdm_pp_done_handler)(tdm_pp *pp, tbm_surface_h src, diff --git a/src/tdm_output.c b/src/tdm_output.c index e5edf93..74745bd 100644 --- a/src/tdm_output.c +++ b/src/tdm_output.c @@ -1858,6 +1858,143 @@ tdm_output_hwc_unset_client_target_buffer(tdm_output *output) return ret; } +static void +_tdm_output_hwc_layer_commit_handler(tdm_layer *layer, unsigned int sequence, + unsigned int tv_sec, unsigned int tv_usec, + void *user_data) +{ + tdm_private_output_hwc_target_buffer_commit_handler *output_hwc_target_buffer_commit_handler = (tdm_private_output_hwc_target_buffer_commit_handler *)user_data; + tdm_output_hwc_target_buffer_commit_handler func = output_hwc_target_buffer_commit_handler->func; + tdm_output *output = (tdm_output *)output_hwc_target_buffer_commit_handler->private_output; + void *data = output_hwc_target_buffer_commit_handler->user_data; + + func(output, sequence, tv_sec, tv_usec, data); + + free(output_hwc_target_buffer_commit_handler); +} + +tdm_error +tdm_output_hwc_commit_client_target_buffer(tdm_output *output, tdm_output_hwc_target_buffer_commit_handler func, void *user_data) +{ + tdm_func_output *func_output; + tdm_private_output_hwc_target_buffer_commit_handler *output_hwc_target_buffer_commit_handler; + tdm_layer *layer = NULL; + tdm_private_layer *private_layer; + const tdm_output_mode *mode; + tbm_surface_h buffer; + + OUTPUT_FUNC_ENTRY(); + + _pthread_mutex_lock(&private_display->lock); + + if (!(private_output->caps.capabilities & TDM_OUTPUT_CAPABILITY_HWC)) { + TDM_ERR("output(%p) not support HWC", private_output); + _pthread_mutex_unlock(&private_display->lock); + return TDM_ERROR_BAD_REQUEST; + } + + func_output = &private_display->func_output; + + if (!func_output->output_hwc_get_client_target_buffer_layer) { + /* LCOV_EXCL_START */ + _pthread_mutex_unlock(&private_display->lock); + TDM_ERR("not implemented!!"); + return TDM_ERROR_NOT_IMPLEMENTED; + /* LCOV_EXCL_STOP */ + } + + layer = func_output->output_hwc_get_client_target_buffer_layer(private_output->output_backend, + &ret); + if (!layer) { + /* LCOV_EXCL_START */ + _pthread_mutex_unlock(&private_display->lock); + TDM_ERR("no assigned layer!!"); + return TDM_ERROR_INVALID_PARAMETER; + /* LCOV_EXCL_STOP */ + } + + private_layer = (tdm_private_layer*)layer; + + if (!func_output->output_hwc_get_client_target_buffer) { + /* LCOV_EXCL_START */ + _pthread_mutex_unlock(&private_display->lock); + TDM_ERR("not implemented!!"); + return TDM_ERROR_NOT_IMPLEMENTED; + /* LCOV_EXCL_STOP */ + } + + buffer = func_output->output_hwc_get_client_target_buffer(private_output->output_backend, + &ret); + if (!buffer) { + /* LCOV_EXCL_START */ + _pthread_mutex_unlock(&private_display->lock); + TDM_ERR("no assigned buffer!!"); + return TDM_ERROR_INVALID_PARAMETER; + /* LCOV_EXCL_STOP */ + } + + if (buffer) + ret = tdm_layer_set_buffer_internal(private_layer, buffer); + else + ret = tdm_layer_unset_buffer_internal(private_layer); + if (ret != TDM_ERROR_NONE) { + /* LCOV_EXCL_START */ + TDM_ERR("failed: layer set info(window)"); + /* LCOV_EXCL_STOP */ + return ret; + } + + /* set layer_info only one time */ + /* TODO: if the mode changes, set again the target_buffer_info. */ + if (&private_output->target_buffer_info == NULL) { + mode = private_output->current_mode; + private_output->target_buffer_info.src_config.size.h = mode->hdisplay; + private_output->target_buffer_info.src_config.size.v = mode->vdisplay; + private_output->target_buffer_info.src_config.pos.x = 0; + private_output->target_buffer_info.src_config.pos.y = 0; + private_output->target_buffer_info.src_config.pos.w = mode->hdisplay; + private_output->target_buffer_info.src_config.pos.h = mode->vdisplay; + private_output->target_buffer_info.dst_pos.x = 0; + private_output->target_buffer_info.dst_pos.y = 0; + private_output->target_buffer_info.dst_pos.w = mode->hdisplay; + private_output->target_buffer_info.dst_pos.h = mode->vdisplay; + private_output->target_buffer_info.transform = TDM_TRANSFORM_NORMAL; + } + + ret = tdm_layer_set_info_internal(private_layer, &private_output->target_buffer_info); + if (ret != TDM_ERROR_NONE) { + /* LCOV_EXCL_START */ + TDM_ERR("failed: layer set info(window)"); + /* LCOV_EXCL_STOP */ + return ret; + } + + output_hwc_target_buffer_commit_handler = calloc(1, sizeof(tdm_private_output_hwc_target_buffer_commit_handler)); + if (!output_hwc_target_buffer_commit_handler) { + /* LCOV_EXCL_START */ + TDM_ERR("failed: alloc memory"); + return TDM_ERROR_OUT_OF_MEMORY; + /* LCOV_EXCL_STOP */ + } + + output_hwc_target_buffer_commit_handler->private_output = private_output; + output_hwc_target_buffer_commit_handler->func = func; + output_hwc_target_buffer_commit_handler->user_data = user_data; + + ret = tdm_layer_commit_internal(private_layer, _tdm_output_hwc_layer_commit_handler, user_data); + if (ret != TDM_ERROR_NONE) { + /* LCOV_EXCL_START */ + TDM_ERR("failed: commit layer(target buffer)"); + free(output_hwc_target_buffer_commit_handler); + /* LCOV_EXCL_STOP */ + return ret; + } + + _pthread_mutex_unlock(&private_display->lock); + + return ret; +} + tdm_error tdm_output_hwc_get_video_supported_formats(tdm_output *output, const tbm_format **formats, int *count) diff --git a/src/tdm_private_types.h b/src/tdm_private_types.h index 642e962..021be9c 100644 --- a/src/tdm_private_types.h +++ b/src/tdm_private_types.h @@ -108,6 +108,8 @@ typedef struct _tdm_private_vblank_handler tdm_private_vblank_handler; typedef struct _tdm_private_output_commit_handler tdm_private_output_commit_handler; typedef struct _tdm_private_layer_commit_handler tdm_private_layer_commit_handler; typedef struct _tdm_private_hwc_window_commit_handler tdm_private_hwc_window_commit_handler; +typedef struct _tdm_private_output_hwc_target_buffer_window_commit_handler tdm_private_output_hwc_target_buffer_commit_handler; + typedef struct _tdm_private_change_handler tdm_private_change_handler; typedef struct _tdm_private_layer_buffer tdm_private_layer_buffer; @@ -205,6 +207,8 @@ struct _tdm_private_output { tdm_event_loop_source *event_source; } need_validate; + tdm_info_layer target_buffer_info; /* layer_info for the target_buffer */ + /* calling a output commit per a vblank */ int commit_per_vblank; tdm_commit_type commit_type; @@ -375,6 +379,12 @@ struct _tdm_private_hwc_window_commit_handler { void *user_data; }; +struct _tdm_private_output_hwc_target_buffer_window_commit_handler { + tdm_private_output *private_output; + tdm_output_hwc_target_buffer_commit_handler func; + void *user_data; +}; + struct _tdm_private_change_handler { struct list_head link; -- 2.7.4 From 61a8f253c9196953a34e39a60c841a0b60c66caa Mon Sep 17 00:00:00 2001 From: SooChan Lim Date: Mon, 12 Feb 2018 12:44:53 +0900 Subject: [PATCH 03/16] hwc: remove the window zpos Change-Id: I15f6636b1875059ebe98742e7949ca97f2aeae10 --- src/tdm_private_types.h | 1 - 1 file changed, 1 deletion(-) diff --git a/src/tdm_private_types.h b/src/tdm_private_types.h index 021be9c..4ef5922 100644 --- a/src/tdm_private_types.h +++ b/src/tdm_private_types.h @@ -256,7 +256,6 @@ struct _tdm_private_hwc_window { struct list_head link; int index; - uint32_t zpos; tdm_private_display *private_display; tdm_private_output *private_output; -- 2.7.4 From 85530bee1c1714e2c8abf38d1612310063d7e6d5 Mon Sep 17 00:00:00 2001 From: Junkyeong Kim Date: Thu, 8 Feb 2018 11:30:36 +0900 Subject: [PATCH 04/16] do not update caps.status in sub thread Change-Id: Ib11fb4b9d448ade7740887b6aad9cc6a9ee3d91d Signed-off-by: Junkyeong Kim --- src/tdm_output.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/tdm_output.c b/src/tdm_output.c index 74745bd..67ec7e9 100644 --- a/src/tdm_output.c +++ b/src/tdm_output.c @@ -223,7 +223,6 @@ tdm_output_cb_status(tdm_output *output_backend, tdm_output_conn_status status, TDM_INFO("output(%d) %s", private_output->pipe, tdm_status_str(status)); _tdm_output_update(output_backend, user_data); - private_output->caps.status = status; output_status.base.type = TDM_THREAD_CB_OUTPUT_STATUS; output_status.base.length = sizeof output_status; -- 2.7.4 From fab10fef52eb5ace3c8e2d9db498f92b6578b24d Mon Sep 17 00:00:00 2001 From: Junkyeong Kim Date: Thu, 8 Feb 2018 11:34:41 +0900 Subject: [PATCH 05/16] enhance log for distinguishment of output status cb thread Change-Id: Ib78ddd3d3f6c9e1203512e451bf29a171b80d37d Signed-off-by: Junkyeong Kim --- src/tdm_output.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/tdm_output.c b/src/tdm_output.c index 67ec7e9..068cdcd 100644 --- a/src/tdm_output.c +++ b/src/tdm_output.c @@ -220,7 +220,7 @@ tdm_output_cb_status(tdm_output *output_backend, tdm_output_conn_status status, tdm_thread_cb_output_status output_status; tdm_error ret; - TDM_INFO("output(%d) %s", private_output->pipe, tdm_status_str(status)); + TDM_INFO("output(%d) sub %s", private_output->pipe, tdm_status_str(status)); _tdm_output_update(output_backend, user_data); @@ -242,7 +242,7 @@ tdm_output_cb_status(tdm_output *output_backend, tdm_output_conn_status status, return; } - TDM_INFO("output(%d) %s", private_output->pipe, tdm_status_str(status)); + TDM_INFO("output(%d) main %s", private_output->pipe, tdm_status_str(status)); if (!tdm_thread_is_running()) _tdm_output_update(output_backend, user_data); -- 2.7.4 From 18692b83856bce6d37967718f3258201bcd58220 Mon Sep 17 00:00:00 2001 From: SooChan Lim Date: Mon, 12 Feb 2018 15:54:34 +0900 Subject: [PATCH 06/16] package version up to 1.13.0 Change-Id: I193a586223f9ca8c9a1dfd36257e146d08905eac --- packaging/libtdm.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packaging/libtdm.spec b/packaging/libtdm.spec index 7fa85d4..226fcc0 100644 --- a/packaging/libtdm.spec +++ b/packaging/libtdm.spec @@ -2,7 +2,7 @@ %define UTEST_GCOV 0 Name: libtdm -Version: 1.12.0 +Version: 1.13.0 Release: 0 Summary: User Library of Tizen Display Manager Group: Development/Libraries -- 2.7.4 From cfd12ac159e0bf0557aabfb7c62869b704f8e335 Mon Sep 17 00:00:00 2001 From: SooChan Lim Date: Mon, 19 Feb 2018 11:36:37 +0900 Subject: [PATCH 07/16] tdm_hwc_window: do not check the null buffer Change-Id: Iffb2096ff4523d5416c01496a79c4d89413fb831 --- src/tdm_hwc_window.c | 8 -------- 1 file changed, 8 deletions(-) diff --git a/src/tdm_hwc_window.c b/src/tdm_hwc_window.c index 08fc80c..417fcd0 100644 --- a/src/tdm_hwc_window.c +++ b/src/tdm_hwc_window.c @@ -463,14 +463,6 @@ tdm_hwc_window_commit(tdm_hwc_window *hwc_window, tdm_hwc_window_commit_handler buffer = func_hwc_window->hwc_window_get_buffer(private_hwc_window->hwc_window_backend, &ret); - if (!buffer) { - /* LCOV_EXCL_START */ - _pthread_mutex_unlock(&private_display->lock); - TDM_ERR("no assigned buffer!!"); - return TDM_ERROR_INVALID_PARAMETER; - /* LCOV_EXCL_STOP */ - } - if (buffer) ret = tdm_layer_set_buffer_internal(private_layer, buffer); else -- 2.7.4 From 8e6edf470329479c8ad7aa00cccc71c996698bee Mon Sep 17 00:00:00 2001 From: SooChan Lim Date: Mon, 19 Feb 2018 11:38:11 +0900 Subject: [PATCH 08/16] tdm_output: do not check the null buffer Change-Id: Iaf8d0d134a6fb683bbc1d39afba51fb7768de945 --- src/tdm_output.c | 8 -------- 1 file changed, 8 deletions(-) diff --git a/src/tdm_output.c b/src/tdm_output.c index 068cdcd..dbd7fe4 100644 --- a/src/tdm_output.c +++ b/src/tdm_output.c @@ -1924,14 +1924,6 @@ tdm_output_hwc_commit_client_target_buffer(tdm_output *output, tdm_output_hwc_ta buffer = func_output->output_hwc_get_client_target_buffer(private_output->output_backend, &ret); - if (!buffer) { - /* LCOV_EXCL_START */ - _pthread_mutex_unlock(&private_display->lock); - TDM_ERR("no assigned buffer!!"); - return TDM_ERROR_INVALID_PARAMETER; - /* LCOV_EXCL_STOP */ - } - if (buffer) ret = tdm_layer_set_buffer_internal(private_layer, buffer); else -- 2.7.4 From 1b4102b50ffb433394a38f7f9423a35c9a2a548a Mon Sep 17 00:00:00 2001 From: SooChan Lim Date: Mon, 19 Feb 2018 13:13:27 +0900 Subject: [PATCH 09/16] tdm_output: set the layer_info of the target buffer only when the mode is set. Change-Id: I21bb59e31c6922a827bb5c614e78ee5a7f6b7922 --- src/tdm_output.c | 21 +++++++++++---------- src/tdm_private_types.h | 3 +++ 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/src/tdm_output.c b/src/tdm_output.c index dbd7fe4..54ad8dc 100644 --- a/src/tdm_output.c +++ b/src/tdm_output.c @@ -1144,6 +1144,7 @@ tdm_output_set_mode(tdm_output *output, const tdm_output_mode *mode) ret = func_output->output_set_mode(private_output->output_backend, mode); if (ret == TDM_ERROR_NONE) { private_output->current_mode = mode; + private_output->need_set_target_info = 1; TDM_INFO("mode: %dx%d %dhz", mode->hdisplay, mode->vdisplay, mode->vrefresh); } @@ -1935,9 +1936,7 @@ tdm_output_hwc_commit_client_target_buffer(tdm_output *output, tdm_output_hwc_ta return ret; } - /* set layer_info only one time */ - /* TODO: if the mode changes, set again the target_buffer_info. */ - if (&private_output->target_buffer_info == NULL) { + if (private_output->need_set_target_info) { mode = private_output->current_mode; private_output->target_buffer_info.src_config.size.h = mode->hdisplay; private_output->target_buffer_info.src_config.size.v = mode->vdisplay; @@ -1950,14 +1949,16 @@ tdm_output_hwc_commit_client_target_buffer(tdm_output *output, tdm_output_hwc_ta private_output->target_buffer_info.dst_pos.w = mode->hdisplay; private_output->target_buffer_info.dst_pos.h = mode->vdisplay; private_output->target_buffer_info.transform = TDM_TRANSFORM_NORMAL; - } - ret = tdm_layer_set_info_internal(private_layer, &private_output->target_buffer_info); - if (ret != TDM_ERROR_NONE) { - /* LCOV_EXCL_START */ - TDM_ERR("failed: layer set info(window)"); - /* LCOV_EXCL_STOP */ - return ret; + ret = tdm_layer_set_info_internal(private_layer, &private_output->target_buffer_info); + if (ret != TDM_ERROR_NONE) { + /* LCOV_EXCL_START */ + TDM_ERR("failed: layer set info(window)"); + /* LCOV_EXCL_STOP */ + return ret; + } + + private_output->need_set_target_info = 0; } output_hwc_target_buffer_commit_handler = calloc(1, sizeof(tdm_private_output_hwc_target_buffer_commit_handler)); diff --git a/src/tdm_private_types.h b/src/tdm_private_types.h index 4ef5922..26b4b12 100644 --- a/src/tdm_private_types.h +++ b/src/tdm_private_types.h @@ -215,6 +215,9 @@ struct _tdm_private_output { /* for ttrace vblank */ tdm_vblank *ttrace_vblank; + + /* hwc */ + int need_set_target_info; }; struct _tdm_private_layer { -- 2.7.4 From fb19bda7e3e4cd0889d07d565e193ff9cc6a897d Mon Sep 17 00:00:00 2001 From: SooChan Lim Date: Mon, 19 Feb 2018 13:47:49 +0900 Subject: [PATCH 10/16] package version up to 1.13.1 Change-Id: I42a9f79dfc2718c6cb2ad691d7636fdc89e16e5b --- packaging/libtdm.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packaging/libtdm.spec b/packaging/libtdm.spec index 226fcc0..4cb9d26 100644 --- a/packaging/libtdm.spec +++ b/packaging/libtdm.spec @@ -2,7 +2,7 @@ %define UTEST_GCOV 0 Name: libtdm -Version: 1.13.0 +Version: 1.13.1 Release: 0 Summary: User Library of Tizen Display Manager Group: Development/Libraries -- 2.7.4 From 3b03a716fd67d4aa909e6f12fa1cb4caa95edeb8 Mon Sep 17 00:00:00 2001 From: Boram Park Date: Mon, 12 Feb 2018 18:07:29 +0900 Subject: [PATCH 11/16] display: fix wrong typo Change-Id: Id67480b0ad585df0534d1c317da0ae49661ba654 --- include/tdm.h | 2 +- src/tdm_display.c | 2 +- utests/src/ut_tdm_capture.cpp | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/include/tdm.h b/include/tdm.h index f90fbe8..618f896 100644 --- a/include/tdm.h +++ b/include/tdm.h @@ -200,7 +200,7 @@ tdm_display_get_capture_capabilities(tdm_display *dpy, * @return #TDM_ERROR_NONE if success. Otherwise, error value. */ tdm_error -tdm_display_get_catpure_available_formats(tdm_display *dpy, +tdm_display_get_capture_available_formats(tdm_display *dpy, const tbm_format **formats, int *count); /** diff --git a/src/tdm_display.c b/src/tdm_display.c index 83fbec3..8febaf0 100644 --- a/src/tdm_display.c +++ b/src/tdm_display.c @@ -182,7 +182,7 @@ tdm_display_get_capture_capabilities(tdm_display *dpy, } EXTERN tdm_error -tdm_display_get_catpure_available_formats(tdm_display *dpy, +tdm_display_get_capture_available_formats(tdm_display *dpy, const tbm_format **formats, int *count) { DISPLAY_FUNC_ENTRY(); diff --git a/utests/src/ut_tdm_capture.cpp b/utests/src/ut_tdm_capture.cpp index 7670ea5..5e5e92f 100644 --- a/utests/src/ut_tdm_capture.cpp +++ b/utests/src/ut_tdm_capture.cpp @@ -227,7 +227,7 @@ void TDMCapture::SetUp(void) } error = - tdm_display_get_catpure_available_formats(dpy, &formats, &format_count); + tdm_display_get_capture_available_formats(dpy, &formats, &format_count); ASSERT_EQ(TDM_ERROR_NONE, error); ASSERT_NE(nullptr, formats); ASSERT_GE(format_count, 0); @@ -524,7 +524,7 @@ TEST_F(TDMCaptureWithoutCreation, DisplayGetCaptureAvailableFormatsSuccessful) SKIP_FLAG(has_capture); const tbm_format * formats = nullptr; int count = -42; - ASSERT_TRUE(TDM_ERROR_NONE == tdm_display_get_catpure_available_formats(dpy, &formats, &count)); + ASSERT_TRUE(TDM_ERROR_NONE == tdm_display_get_capture_available_formats(dpy, &formats, &count)); ASSERT_FALSE(-42 == count); ASSERT_FALSE(nullptr == formats); } @@ -977,4 +977,4 @@ TEST_F(TDMCaptureCommit, CaptureCommitSuccessScaleStream) UtHandleCaptureEvent(); ASSERT_EQ(captures.size(), utCaptureDoneHandlerSuccessCounter); -} \ No newline at end of file +} -- 2.7.4 From 17fa403ebeb3de0c042b684f45151e78a92483ce Mon Sep 17 00:00:00 2001 From: Boram Park Date: Mon, 12 Feb 2018 18:09:16 +0900 Subject: [PATCH 12/16] helper: export tdm_helper_dump_buffer_str Change-Id: I426b31bdbb93cfbfec651cac0a5a2eaeb139c0be --- include/tdm_helper.h | 10 ++++++++++ src/tdm_helper.c | 42 ++++++++++++++++++++++-------------------- src/tdm_private.h | 2 -- 3 files changed, 32 insertions(+), 22 deletions(-) diff --git a/include/tdm_helper.h b/include/tdm_helper.h index 4c501e3..d5d8d6e 100644 --- a/include/tdm_helper.h +++ b/include/tdm_helper.h @@ -77,6 +77,16 @@ void tdm_helper_dump_buffer(tbm_surface_h buffer, const char *file); /** + * @brief Dump a buffer. + * @details + * The filename will includes the buffer information. (width, height, format) + * @param[in] buffer A TDM buffer + * @param[in] file The path of file. + */ +void +tdm_helper_dump_buffer_str(tbm_surface_h buffer, char *dir, char *str); + +/** * @brief fill a buffer with 0 for given pos. * @details * This function supports only if a buffer has below formats. diff --git a/src/tdm_helper.c b/src/tdm_helper.c index c8bcb1c..cd6426f 100644 --- a/src/tdm_helper.c +++ b/src/tdm_helper.c @@ -237,30 +237,26 @@ failed_make: return NULL; } -INTERN void +EXTERN void tdm_helper_dump_buffer_str(tbm_surface_h buffer, char *dir, char *str) { tbm_surface_info_s info; - const char *ext; char file[TDM_PATH_LEN]; int ret, bw, bh; TDM_RETURN_IF_FAIL(buffer != NULL); - TDM_RETURN_IF_FAIL(dir != NULL); TDM_RETURN_IF_FAIL(str != NULL); + if (!dir) + dir = "."; + ret = tbm_surface_get_info(buffer, &info); TDM_RETURN_IF_FAIL(ret == TBM_SURFACE_ERROR_NONE); - if (IS_RGB(info.format)) - ext = file_exts[0]; - else - ext = file_exts[1]; - tdm_helper_get_buffer_full_size(buffer, &bw, &bh); - snprintf(file, TDM_PATH_LEN, "%s/%c%c%c%c_%dx%d_%dx%d_%s.%s", - dir, FOURCC_STR(info.format), bw, bh, info.width, info.height, str, ext); + snprintf(file, TDM_PATH_LEN, "%s/%c%c%c%c_%dx%d_%dx%d_%s", + dir, FOURCC_STR(info.format), bw, bh, info.width, info.height, str); tdm_helper_dump_buffer(buffer, file); } @@ -269,11 +265,13 @@ tdm_helper_dump_buffer_str(tbm_surface_h buffer, char *dir, char *str) EXTERN void tdm_helper_dump_buffer(tbm_surface_h buffer, const char *file) { + char temp[TDM_PATH_LEN] = {0,}; tbm_surface_info_s info; int len, ret; const char *ext; int bo_cnt; int bw, bh; + char *dot, *p = temp; TDM_RETURN_IF_FAIL(buffer != NULL); TDM_RETURN_IF_FAIL(file != NULL); @@ -281,16 +279,20 @@ tdm_helper_dump_buffer(tbm_surface_h buffer, const char *file) ret = tbm_surface_map(buffer, TBM_OPTION_READ, &info); TDM_RETURN_IF_FAIL(ret == TBM_SURFACE_ERROR_NONE); - len = strnlen(file, 1024); if (IS_RGB(info.format)) ext = file_exts[0]; else ext = file_exts[1]; - if (strncmp(file + (len - 3), ext, 3)) { - TDM_ERR("can't dump to '%s' file", file + (len - 3)); - tbm_surface_unmap(buffer); - return; + dot = strrchr(file, '.'); + if (!dot || strlen(dot + 1) != 3 || strncmp(dot + 1, ext, 3)) { + len = strnlen(file, TDM_PATH_LEN - 5); + strncat(p, file, len); + p += len; + *(p++) = '.'; + strncat(p, ext, 3); + p += 3; + *p = '\0'; } tdm_helper_get_buffer_full_size(buffer, &bw, &bh); @@ -305,11 +307,11 @@ tdm_helper_dump_buffer(tbm_surface_h buffer, const char *file) switch (info.format) { case TBM_FORMAT_ARGB8888: case TBM_FORMAT_XRGB8888: - _tdm_helper_dump_png(file, info.planes[0].ptr, bw, bh); + _tdm_helper_dump_png(temp, info.planes[0].ptr, bw, bh); break; case TBM_FORMAT_YVU420: case TBM_FORMAT_YUV420: - _tdm_helper_dump_raw(file, + _tdm_helper_dump_raw((const char*)temp, info.planes[0].ptr, info.planes[0].size, info.planes[1].ptr, @@ -319,7 +321,7 @@ tdm_helper_dump_buffer(tbm_surface_h buffer, const char *file) break; case TBM_FORMAT_NV12: case TBM_FORMAT_NV21: - _tdm_helper_dump_raw(file, + _tdm_helper_dump_raw((const char*)temp, info.planes[0].ptr, info.planes[0].size, info.planes[1].ptr, @@ -328,7 +330,7 @@ tdm_helper_dump_buffer(tbm_surface_h buffer, const char *file) break; case TBM_FORMAT_YUYV: case TBM_FORMAT_UYVY: - _tdm_helper_dump_raw(file, + _tdm_helper_dump_raw((const char*)temp, info.planes[0].ptr, info.planes[0].size, NULL, 0, NULL, 0); @@ -341,7 +343,7 @@ tdm_helper_dump_buffer(tbm_surface_h buffer, const char *file) tbm_surface_unmap(buffer); - TDM_INFO("dump %s", file); + TDM_INFO("dump %s", temp); } EXTERN void diff --git a/src/tdm_private.h b/src/tdm_private.h index 57f97b2..9c76d78 100644 --- a/src/tdm_private.h +++ b/src/tdm_private.h @@ -239,8 +239,6 @@ tdm_server_enable_ttrace_client_vblank(tdm_display *dpy, tdm_output *output, int char * tdm_helper_dump_make_directory(const char *path, char *reply, int *len); -void -tdm_helper_dump_buffer_str(tbm_surface_h buffer, char *dir, char *str); double tdm_helper_get_time(void); -- 2.7.4 From 9c4532473639a9a2f8002975bd7c1468ab86fe25 Mon Sep 17 00:00:00 2001 From: Boram Park Date: Mon, 12 Feb 2018 18:10:02 +0900 Subject: [PATCH 13/16] helper: correct symbolic check function Change-Id: Id52e6ed434ae6a2aba926362a2ce02bf58b5788d --- src/tdm_helper.c | 30 ++++++++++++++---------------- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/src/tdm_helper.c b/src/tdm_helper.c index cd6426f..a1b7427 100644 --- a/src/tdm_helper.c +++ b/src/tdm_helper.c @@ -61,26 +61,20 @@ tdm_helper_get_time(void) } static int -_tdm_helper_check_file_is_valid(const char* path, int del_link) +_tdm_helper_check_file_is_symbolic_link(const char* path) { - char *real_path; + struct stat sb; if (!path) return 0; - real_path = realpath(path, NULL); - if (real_path && strncmp(path, real_path, strlen(path))) { - if (del_link) - unlink(path); - free(real_path); - + if (stat(path, &sb) != 0) return 0; - } - if (real_path) - free(real_path); + if (S_ISLNK(sb.st_mode)) + return 1; - return 1; + return 0; } static void @@ -90,8 +84,10 @@ _tdm_helper_dump_raw(const char *file, void *data1, int size1, void *data2, unsigned int *blocks; FILE *fp; - if (!_tdm_helper_check_file_is_valid(file, 1)) - TDM_WRN("'%s' may be symbolic link\n", file); + if (_tdm_helper_check_file_is_symbolic_link(file)) { + TDM_ERR("'%s' may be symbolic link\n", file); + return; + } fp = fopen(file, "w+"); TDM_RETURN_IF_FAIL(fp != NULL); @@ -118,8 +114,10 @@ _tdm_helper_dump_png(const char *file, const void *data, int width, { FILE *fp; - if (!_tdm_helper_check_file_is_valid(file, 1)) - TDM_WRN("'%s' may be symbolic link\n", file); + if (_tdm_helper_check_file_is_symbolic_link(file)) { + TDM_ERR("'%s' may be symbolic link\n", file); + return; + } fp = fopen(file, "wb"); TDM_RETURN_IF_FAIL(fp != NULL); -- 2.7.4 From 586f8c6ea978452356d0a0793b375c4d450d2ece Mon Sep 17 00:00:00 2001 From: Boram Park Date: Tue, 20 Feb 2018 13:56:16 +0900 Subject: [PATCH 14/16] add tdm_layer_get_output Change-Id: Icbc2003297276a45b6d2d7f3cda54393aa12bc0d --- include/tdm.h | 8 ++++++++ src/tdm_layer.c | 19 +++++++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/include/tdm.h b/include/tdm.h index 618f896..70c99af 100644 --- a/include/tdm.h +++ b/include/tdm.h @@ -765,6 +765,14 @@ tdm_output_hwc_get_video_supported_formats(tdm_layer *layer, const tbm_format ** int *count); /** + * @brief Get a output object of a layer object + * @param[in] layer A layer object + * @return A TDM output object if success. Otherwise, NULL. + */ +tdm_output* +tdm_layer_get_output(tdm_layer *layer, tdm_error *error); + +/** * @brief Get the capabilities of a layer object. * @param[in] layer A layer object * @param[out] capabilities The capabilities of a layer object diff --git a/src/tdm_layer.c b/src/tdm_layer.c index 2f97c5c..0ce567e 100644 --- a/src/tdm_layer.c +++ b/src/tdm_layer.c @@ -80,6 +80,25 @@ static void _tdm_layer_cb_output_commit(tdm_output *output, unsigned int sequenc unsigned int tv_sec, unsigned int tv_usec, void *user_data); static void _tdm_layer_reset_pending_data(tdm_private_layer *private_layer); +EXTERN tdm_output* +tdm_layer_get_output(tdm_layer *layer, tdm_error *error) +{ + tdm_output *output; + + LAYER_FUNC_ENTRY_ERROR(); + + _pthread_mutex_lock(&private_display->lock); + + if (error) + *error = TDM_ERROR_NONE; + + output = private_layer->private_output; + + _pthread_mutex_unlock(&private_display->lock); + + return output; +} + EXTERN tdm_error tdm_layer_get_capabilities(tdm_layer *layer, tdm_layer_capability *capabilities) { -- 2.7.4 From f08216fac3a6803d459b5cd267197cc4448deb58 Mon Sep 17 00:00:00 2001 From: Boram Park Date: Tue, 20 Feb 2018 13:56:36 +0900 Subject: [PATCH 15/16] fix buffer leak when deiniting Change-Id: I7a742f011f0e75341f6a4d17140c2f0c184abc91 --- src/tdm.c | 2 ++ src/tdm_layer.c | 1 + 2 files changed, 3 insertions(+) diff --git a/src/tdm.c b/src/tdm.c index de6c179..33b27a7 100644 --- a/src/tdm.c +++ b/src/tdm.c @@ -137,6 +137,8 @@ _tdm_display_destroy_private_layer(tdm_private_layer *private_layer) LIST_DEL(&private_layer->link); + tdm_layer_unset_buffer_internal(private_layer); + LIST_FOR_EACH_ENTRY_SAFE(c, cc, &private_layer->capture_list, link) tdm_capture_destroy_internal(c); diff --git a/src/tdm_layer.c b/src/tdm_layer.c index 0ce567e..9add055 100644 --- a/src/tdm_layer.c +++ b/src/tdm_layer.c @@ -555,6 +555,7 @@ tdm_layer_unset_buffer(tdm_layer *layer) _pthread_mutex_lock(&private_display->lock); ret = tdm_layer_unset_buffer_internal(private_layer); + TDM_WARNING_IF_FAIL(ret == TDM_ERROR_NONE); _pthread_mutex_unlock(&private_display->lock); -- 2.7.4 From b73ff3145dafd2109ddac8f5ceda37286590994a Mon Sep 17 00:00:00 2001 From: Boram Park Date: Tue, 20 Feb 2018 13:57:40 +0900 Subject: [PATCH 16/16] buffers: add extern for testing Change-Id: Ib23b11d99fc399a0673272c39786989a6aa4973a --- tools/buffers.c | 4 +--- tools/buffers.h | 8 ++++++++ 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/tools/buffers.c b/tools/buffers.c index 318dcde..8b04b41 100644 --- a/tools/buffers.c +++ b/tools/buffers.c @@ -37,8 +37,6 @@ #include #include -#include "tdm_log.h" -#include "tdm_macro.h" #include "buffers.h" #define ALPHA_VALUE 100 @@ -944,7 +942,7 @@ tdm_test_buffer_fill(tbm_surface_h buffer, int pattern) rand_seed = time(NULL); ret = tbm_surface_map(buffer, TBM_OPTION_WRITE, &info); - TDM_EXIT_IF_FAIL(ret == 0); + assert(ret == 0); plane[0] = info.planes[0].ptr; plane[1] = info.planes[1].ptr; diff --git a/tools/buffers.h b/tools/buffers.h index 55afd3d..acf5661 100644 --- a/tools/buffers.h +++ b/tools/buffers.h @@ -27,6 +27,10 @@ #ifndef __BUFFERS_H__ #define __BUFFERS_H__ +#ifdef __cplusplus +extern "C" { +#endif + enum fill_pattern { PATTERN_TILES = 0, PATTERN_PLAIN = 1, @@ -36,4 +40,8 @@ enum fill_pattern { void tdm_test_buffer_fill(tbm_surface_h buffer, int pattern); +#ifdef __cplusplus +} +#endif + #endif -- 2.7.4