From 88a633c7b0681b0e66e9bbce50f0ca040f5da709 Mon Sep 17 00:00:00 2001 From: SooChan Lim Date: Wed, 7 Nov 2018 14:17:53 +0900 Subject: [PATCH 01/16] Package version up to 2.4.0 Change-Id: If507be05cfc0f18d9f820e10704b0d7c30e0d14e --- packaging/libtdm.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packaging/libtdm.spec b/packaging/libtdm.spec index e9a5468..5bc0659 100644 --- a/packaging/libtdm.spec +++ b/packaging/libtdm.spec @@ -2,7 +2,7 @@ %define HALTESTS_GCOV 0 Name: libtdm -Version: 2.3.1 +Version: 2.4.0 Release: 0 Summary: User Library of Tizen Display Manager Group: Development/Libraries -- 2.7.4 From c1f7ee3070a2cf11d5eaaede1312ef13a0f036cf Mon Sep 17 00:00:00 2001 From: SooChan Lim Date: Fri, 9 Nov 2018 19:21:35 +0900 Subject: [PATCH 02/16] hwc: modify the some symbol change tdm_hwc_accept_changes to tdm_hwc_accept_validation add the prefix TDM_HWC_ instead TDM_ Change-Id: I909695e485e1bfab32eb290ce6a8450b301862c4 --- haltests/src/tc_tdm_hwc.cpp | 16 ++++++++-------- haltests/src/tc_tdm_hwc_window.cpp | 10 +++++----- include/tdm.h | 10 +++++----- include/tdm_backend.h | 10 +++++----- include/tdm_types.h | 28 ++++++++++++++-------------- src/tdm_hwc.c | 4 ++-- src/tdm_hwc_window.c | 4 ++-- 7 files changed, 41 insertions(+), 41 deletions(-) diff --git a/haltests/src/tc_tdm_hwc.cpp b/haltests/src/tc_tdm_hwc.cpp index 4df9e54..541414f 100644 --- a/haltests/src/tc_tdm_hwc.cpp +++ b/haltests/src/tc_tdm_hwc.cpp @@ -378,12 +378,12 @@ TEST_P(TDMHwc, GetChangedCompositionTypesFailNull) } } -/* tdm_error tdm_hwc_accept_changes() */ +/* tdm_error tdm_hwc_accept_validation() */ TEST_P(TDMHwc, AcceptChangesFailNull) { TDM_UT_SKIP_FLAG(has_outputs); - error = tdm_hwc_accept_changes(NULL); + error = tdm_hwc_accept_validation(NULL); ASSERT_NE(TDM_ERROR_NONE, error); } @@ -395,10 +395,10 @@ TEST_P(TDMHwc, AcceptChangesFailNoHwc) for (int o = 0; o < output_count; o++) { hwc = tdm_output_get_hwc(outputs[o], &error); if (hwc) { - error = tdm_hwc_accept_changes(hwc); + error = tdm_hwc_accept_validation(hwc); ASSERT_NE(TDM_ERROR_NONE, error); } else { - error = tdm_hwc_accept_changes(hwc); + error = tdm_hwc_accept_validation(hwc); ASSERT_NE(TDM_ERROR_NONE, error); } } @@ -422,7 +422,7 @@ TEST_P(TDMHwc, AcceptChangesSuccessful) for (int w = 0; w < HWC_WIN_NUM; w++) { hwc_wnds[w] = tdm_hwc_create_window(hwc, &error); ASSERT_EQ(TDM_ERROR_NONE, error); - error = tdm_hwc_window_set_composition_type(hwc_wnds[w], TDM_COMPOSITION_DEVICE); + error = tdm_hwc_window_set_composition_type(hwc_wnds[w], TDM_HWC_WIN_COMPOSITION_DEVICE); ASSERT_EQ(TDM_ERROR_NONE, error); } @@ -437,7 +437,7 @@ TEST_P(TDMHwc, AcceptChangesSuccessful) ASSERT_EQ(TDM_ERROR_NONE, error); ASSERT_EQ(get_num, num_types); - error = tdm_hwc_accept_changes(hwc); + error = tdm_hwc_accept_validation(hwc); ASSERT_EQ(TDM_ERROR_NONE, error); free(composition_types); @@ -479,7 +479,7 @@ TEST_P(TDMHwc, CommitSuccessful) for (int w = 0; w < HWC_WIN_NUM; w++) { hwc_wnds[w] = tdm_hwc_create_window(hwc, &error); ASSERT_EQ(TDM_ERROR_NONE, error); - error = tdm_hwc_window_set_composition_type(hwc_wnds[w], TDM_COMPOSITION_DEVICE); + error = tdm_hwc_window_set_composition_type(hwc_wnds[w], TDM_HWC_WIN_COMPOSITION_DEVICE); ASSERT_EQ(TDM_ERROR_NONE, error); } @@ -494,7 +494,7 @@ TEST_P(TDMHwc, CommitSuccessful) ASSERT_EQ(TDM_ERROR_NONE, error); ASSERT_EQ(get_num, num_types); - error = tdm_hwc_accept_changes(hwc); + error = tdm_hwc_accept_validation(hwc); ASSERT_EQ(TDM_ERROR_NONE, error); free(composition_types); diff --git a/haltests/src/tc_tdm_hwc_window.cpp b/haltests/src/tc_tdm_hwc_window.cpp index 1e704a7..3f91ace 100644 --- a/haltests/src/tc_tdm_hwc_window.cpp +++ b/haltests/src/tc_tdm_hwc_window.cpp @@ -150,7 +150,7 @@ TEST_P(TDMHwcWindow, SetCompositionTypeFailNull) tdm_error error = TDM_ERROR_NONE; - error = tdm_hwc_window_set_composition_type(NULL, TDM_COMPOSITION_DEVICE); + error = tdm_hwc_window_set_composition_type(NULL, TDM_HWC_WIN_COMPOSITION_DEVICE); ASSERT_NE(TDM_ERROR_NONE, error); } @@ -167,7 +167,7 @@ TEST_P(TDMHwcWindow, SetCompositionTypeFailInvalieCompositionType) if (hwc) { hwc_win = tdm_hwc_create_window(hwc, &error); ASSERT_NE(NULL, hwc_win); - error = tdm_hwc_window_set_composition_type(hwc_win, tdm_hwc_window_composition(TDM_COMPOSITION_NONE - 1)); + error = tdm_hwc_window_set_composition_type(hwc_win, tdm_hwc_window_composition(TDM_HWC_WIN_COMPOSITION_NONE - 1)); ASSERT_NE(TDM_ERROR_NONE, error); tdm_hwc_window_destroy(hwc_win); } @@ -192,11 +192,11 @@ TEST_P(TDMHwcWindow, SetCompositionTypeSuccessful) } for (w = 0; w < HWC_WIN_NUM; w++) { - error = tdm_hwc_window_set_composition_type(hwc_wins[w], TDM_COMPOSITION_DEVICE); + error = tdm_hwc_window_set_composition_type(hwc_wins[w], TDM_HWC_WIN_COMPOSITION_DEVICE); ASSERT_EQ(TDM_ERROR_NONE, error); - error = tdm_hwc_window_set_composition_type(hwc_wins[w], TDM_COMPOSITION_CLIENT); + error = tdm_hwc_window_set_composition_type(hwc_wins[w], TDM_HWC_WIN_COMPOSITION_CLIENT); ASSERT_EQ(TDM_ERROR_NONE, error); - error = tdm_hwc_window_set_composition_type(hwc_wins[w], TDM_COMPOSITION_CURSOR); + error = tdm_hwc_window_set_composition_type(hwc_wins[w], TDM_HWC_WIN_COMPOSITION_CURSOR); ASSERT_EQ(TDM_ERROR_NONE, error); } diff --git a/include/tdm.h b/include/tdm.h index 169fd7c..538592b 100644 --- a/include/tdm.h +++ b/include/tdm.h @@ -943,7 +943,7 @@ tdm_hwc_get_client_target_buffer_queue(tdm_hwc *hwc, tdm_error *error); * @brief Set the client(relative to the TDM) target buffer * @details This function lets the backend know the target buffer. * The target buffer contains the result of the gl composition with the - * tdm_hwc_windows which marked as TDM_COMPOSITION_CLIENT. + * tdm_hwc_windows which marked as TDM_HWC_WIN_COMPOSITION_CLIENT. * @param[in] hwc A output hwc * @param[in] target_buffer The new target buffer * @param[in] damage The buffer damage region @@ -979,7 +979,7 @@ tdm_hwc_validate(tdm_hwc *hwc, tdm_hwc_window **composited_wnds, uint32_t num_wn * @details Retrieves the windows for which the backend requires a different * composition types that had been set prior to the last call to tdm_hwc_validate(). * The client will either update its state with these types and call - * tdm_hwc_accept_changes, or will set new types and attempt to validate the + * tdm_hwc_accept_validation, or will set new types and attempt to validate the * display again. The number of elements returned must be the same as the * value returned in num_types from the last call to tdm_hwc_validate(). * @param[in] hwc A hwc object @@ -997,15 +997,15 @@ tdm_hwc_get_changed_composition_types(tdm_hwc *hwc, uint32_t *num_elements, tdm_hwc_window_composition *composition_types); /** - * @brief Accepts the changes required by the backend - * @details Accepts the changes required by the backend from the previous + * @brief Accepts the validation required by the backend + * @details Accepts the validation required by the backend from the previous * tdm_hwc_validate() and tdm_hwc_get_chaged_composition_types(). * @param[in] hwc A hwc object * @return #TDM_ERROR_NONE if success. Otherwise, error value. * @since 2.0.0 */ tdm_error -tdm_hwc_accept_changes(tdm_hwc *hwc); +tdm_hwc_accept_validation(tdm_hwc *hwc); /** * @brief Commit changes for a hwc diff --git a/include/tdm_backend.h b/include/tdm_backend.h index 675d9c4..2de78c0 100644 --- a/include/tdm_backend.h +++ b/include/tdm_backend.h @@ -836,7 +836,7 @@ typedef struct _tdm_func_hwc { * @brief Set the client(relative to the TDM) target buffer * @details This function lets the backend know the target buffer. * The target buffer contains the result of the gl composition with the - * tdm_hwc_windows which marked as TDM_COMPOSITION_CLIENT. + * tdm_hwc_windows which marked as TDM_HWC_WIN_COMPOSITION_CLIENT. * @param[in] hwc A hwc object * @param[in] target_buffer The new target buffer * @param[in] damage The buffer damage region @@ -872,7 +872,7 @@ typedef struct _tdm_func_hwc { * @details Retrieves the windows for which the backend requires a different * composition types that had been set prior to the last call to tdm_hwc_validate(). * The client will either update its state with these types and call - * tdm_hwc_accept_changes, or will set new types and attempt to validate the + * tdm_hwc_accept_validation, or will set new types and attempt to validate the * display again. The number of elements returned must be the same as the * value returned in num_types from the last call to tdm_hwc_validate(). * @param[in] hwc A hwc object @@ -887,14 +887,14 @@ typedef struct _tdm_func_hwc { tdm_hwc_window **hwc_window, tdm_hwc_window_composition *composition_types); /** - * @brief Accepts the changes required by the backend - * @details Accepts the changes required by the backend from the previous + * @brief Accepts the validation required by the backend + * @details Accepts the validation required by the backend from the previous * tdm_hwc_validate() and tdm_hwc_get_chaged_composition_types(). * @param[in] hwc A hwc object * @return #TDM_ERROR_NONE if success. Otherwise, error value. * @since 2.0.0 */ - tdm_error (*hwc_accept_changes)(tdm_hwc *hwc); + tdm_error (*hwc_accept_validation)(tdm_hwc *hwc); /** * @brief Commit changes for a hwc object diff --git a/include/tdm_types.h b/include/tdm_types.h index 24423d3..d9ab984 100644 --- a/include/tdm_types.h +++ b/include/tdm_types.h @@ -165,19 +165,19 @@ typedef enum { * * The backend ignores windows of this type. */ - TDM_COMPOSITION_NONE = 0, + TDM_HWC_WIN_COMPOSITION_NONE = 0, /** The compostion type for an window to be compsoited by the client. * * When the client sets this composition type, * the backend MUST NOT modify this composition type into other types. * - * When the backend changes TDM_COMPOSITION_DEVICE or TDM_COMPOSITION_CURSOR + * When the backend changes TDM_HWC_WIN_COMPOSITION_DEVICE or TDM_HWC_WIN_COMPOSITION_CURSOR * to this composition type at the time of tdm_hwc_validate and * tdm_hwc_get_changed_composition_types, * the client has to composite this window with gl or other drawing operations. */ - TDM_COMPOSITION_CLIENT = 1, + TDM_HWC_WIN_COMPOSITION_CLIENT = 1, /** The compostion type for an window to be set to the hw overlay. * @@ -186,40 +186,40 @@ typedef enum { * Nomally, the backend leave it if the backend sets the window to the hw overlay. * If the backend does not set the window to the hw overlay at the time of * tdm_hwc_validate, the backend changes the composition type of the window into - * TDM_COMPOSITION_CLIENT. + * TDM_HWC_WIN_COMPOSITION_CLIENT. */ - TDM_COMPOSITION_DEVICE = 3, + TDM_HWC_WIN_COMPOSITION_DEVICE = 3, /** The compostion type for an window to be set to the cursor hw overlay. * * The client sets this composition type to the cursor window before requesting * the tdm_hwc_validate. * If the backend does not support the cursor hw overlay, the backend can change - * the comopsition type into the TDM_COMPOSITION_CLIENT. + * the comopsition type into the TDM_HWC_WIN_COMPOSITION_CLIENT. */ - TDM_COMPOSITION_CURSOR = 4, + TDM_HWC_WIN_COMPOSITION_CURSOR = 4, /** The compostion type for an window to be set to the video hw overlay. * * The client sets this composition type to the video window before requesting * the tdm_hwc_validate. * If the backend does not support the video hw overlay, the backend can change - * the comopsition type into the TDM_COMPOSITION_CLIENT. + * the comopsition type into the TDM_HWC_WIN_COMPOSITION_CLIENT. * Normally, this VIDEO window displays under the primary hw overlayer of the output. */ - TDM_COMPOSITION_VIDEO = 5, + TDM_HWC_WIN_COMPOSITION_VIDEO = 5, } tdm_hwc_window_composition; typedef enum { - TDM_CONSTRAINT_NONE = 0, + TDM_HWC_WIN_CONSTRAINT_NONE = 0, /** If the client needs to render to a specific buffer for compositing - * with TDM_COMPOSITION_DEVICE, the backend needs to set - * TDM_CONSTRAINT_BUFFER_QUEUE to hwc_window until the hwc_window is not - * TDM_COMPOSITION_DEVICE. The client gets the tbm_surface_queue_h through + * with TDM_HWC_WIN_COMPOSITION_DEVICE, the backend needs to set + * TDM_HWC_WIN_CONSTRAINT_BUFFER_QUEUE to hwc_window until the hwc_window is not + * TDM_HWC_WIN_COMPOSITION_DEVICE. The client gets the tbm_surface_queue_h through * the tdm_hwc_window_aquire_buffer_queue. It will render the frames on * the buffers which gets from the tbm_surface_queue_h. */ - TDM_CONSTRAINT_BUFFER_QUEUE = (1 << 0), + TDM_HWC_WIN_CONSTRAINT_BUFFER_QUEUE = (1 << 0), } tdm_hwc_window_constraint; /** diff --git a/src/tdm_hwc.c b/src/tdm_hwc.c index 49d4ca9..013eb34 100644 --- a/src/tdm_hwc.c +++ b/src/tdm_hwc.c @@ -452,7 +452,7 @@ tdm_hwc_get_changed_composition_types(tdm_hwc *hwc, uint32_t *num_elements, } EXTERN tdm_error -tdm_hwc_accept_changes(tdm_hwc *hwc) +tdm_hwc_accept_validation(tdm_hwc *hwc) { tdm_private_module *private_module; tdm_func_hwc *func_hwc = NULL; @@ -472,7 +472,7 @@ tdm_hwc_accept_changes(tdm_hwc *hwc) /* LCOV_EXCL_STOP */ } - ret = func_hwc->hwc_accept_changes(private_hwc->hwc_backend); + ret = func_hwc->hwc_accept_validation(private_hwc->hwc_backend); _pthread_mutex_unlock(&private_display->lock); diff --git a/src/tdm_hwc_window.c b/src/tdm_hwc_window.c index ce04c51..9248ff5 100644 --- a/src/tdm_hwc_window.c +++ b/src/tdm_hwc_window.c @@ -260,8 +260,8 @@ tdm_hwc_window_set_composition_type(tdm_hwc_window *hwc_window, tdm_func_hwc_window *func_hwc_window = NULL; HWC_WINDOW_FUNC_ENTRY(); - TDM_RETURN_VAL_IF_FAIL(composition_type >= TDM_COMPOSITION_NONE, TDM_ERROR_INVALID_PARAMETER); - TDM_RETURN_VAL_IF_FAIL(composition_type <= TDM_COMPOSITION_VIDEO, TDM_ERROR_INVALID_PARAMETER); + TDM_RETURN_VAL_IF_FAIL(composition_type >= TDM_HWC_WIN_COMPOSITION_NONE, TDM_ERROR_INVALID_PARAMETER); + TDM_RETURN_VAL_IF_FAIL(composition_type <= TDM_HWC_WIN_COMPOSITION_VIDEO, TDM_ERROR_INVALID_PARAMETER); _pthread_mutex_lock(&private_display->lock); -- 2.7.4 From 360af47b34a4fbcfb48be27fdae57654f22c91ef Mon Sep 17 00:00:00 2001 From: SooChan Lim Date: Mon, 12 Nov 2018 09:34:02 +0900 Subject: [PATCH 03/16] hwc: add the prototypes to avoid build break this patch will be reverted later Change-Id: I0fff096e12ce975fd7c4fd5a6f33d4e1d53afbce --- include/tdm.h | 3 +++ include/tdm_types.h | 9 +++++++++ src/tdm_hwc.c | 7 +++++++ 3 files changed, 19 insertions(+) diff --git a/include/tdm.h b/include/tdm.h index 538592b..c8ab346 100644 --- a/include/tdm.h +++ b/include/tdm.h @@ -1007,6 +1007,9 @@ 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 d9ab984..50fb4b8 100644 --- a/include/tdm_types.h +++ b/include/tdm_types.h @@ -222,6 +222,15 @@ 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 013eb34..5dd71a3 100644 --- a/src/tdm_hwc.c +++ b/src/tdm_hwc.c @@ -479,6 +479,13 @@ 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 6388e7980505cd3d91a12c9a91a0ac814e2b6aad Mon Sep 17 00:00:00 2001 From: SooChan Lim Date: Mon, 12 Nov 2018 21:33:46 +0900 Subject: [PATCH 04/16] fix indent Change-Id: Ic802bc1822fbb36e7c9c202011bdb9ba0f3b0945 --- include/tdm_backend.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/include/tdm_backend.h b/include/tdm_backend.h index 2de78c0..da89269 100644 --- a/include/tdm_backend.h +++ b/include/tdm_backend.h @@ -150,8 +150,7 @@ typedef struct _tdm_caps_layer { int zpos; unsigned int format_count; /**< The count of available formats */ - tbm_format - *formats; /**< The @b newly-allocated array of formats. will be freed in frontend. */ + tbm_format *formats; /**< The @b newly-allocated array of formats. will be freed in frontend. */ unsigned int prop_count; /**< The count of available properties */ tdm_prop *props; /**< The @b newly-allocated array of properties. will be freed in frontend. */ -- 2.7.4 From 111235f88e860ec2b11d876ee185dfedf117c4b2 Mon Sep 17 00:00:00 2001 From: SooChan Lim Date: Mon, 12 Nov 2018 21:27:14 +0900 Subject: [PATCH 05/16] hwc: add tdm_hwc_get_video_available_properties. The available video properties is different from the ui properties. The client needs to get the only available video properties. Change-Id: Ibb13dded2bec0efc486899daf1a59ea8e528e414 --- include/tdm.h | 9 +++++++++ include/tdm_backend.h | 10 ++++++++++ src/tdm_hwc.c | 31 +++++++++++++++++++++++++++++++ 3 files changed, 50 insertions(+) diff --git a/include/tdm.h b/include/tdm.h index c8ab346..ab9197c 100644 --- a/include/tdm.h +++ b/include/tdm.h @@ -906,6 +906,15 @@ tdm_hwc_create_window(tdm_hwc *hwc, tdm_error *error); tdm_error tdm_hwc_get_video_supported_formats(tdm_hwc *hwc, const tbm_format **formats, int *count); +/** + * @brief Get the available video property array of a hwc object. + * @param[in] hwc A hwc + * @param[out] props The available video property array + * @param[out] count The count of video properties + * @return #TDM_ERROR_NONE if success. Otherwise, error value. + */ +tdm_error +tdm_hwc_get_video_available_properties(tdm_hwc *hwc, const tdm_prop **props, int *count); /** * @brief Get the hwc video capability diff --git a/include/tdm_backend.h b/include/tdm_backend.h index da89269..40390c3 100644 --- a/include/tdm_backend.h +++ b/include/tdm_backend.h @@ -803,6 +803,16 @@ typedef struct _tdm_func_hwc { tdm_error (*hwc_get_video_supported_formats)(tdm_hwc *hwc, const tbm_format **formats, int *count); /** + * @brief Get the available video property array of a hwc object. + * @param[in] hwc A hwc object + * @param[out] props The available video property array + * @param[out] count The count of video properties + * @return #TDM_ERROR_NONE if success. Otherwise, error value. + */ + tdm_error (*hwc_get_video_available_properties)(tdm_hwc *hwc, const tdm_prop **props, + int *count); + + /** * @brief Get the hwc video capability * @param[in] hwc A hwc object * @param[out] video_capability A hwc hwc video capability diff --git a/src/tdm_hwc.c b/src/tdm_hwc.c index 5dd71a3..bd7428c 100644 --- a/src/tdm_hwc.c +++ b/src/tdm_hwc.c @@ -209,6 +209,37 @@ tdm_hwc_get_video_supported_formats(tdm_hwc *hwc, const tbm_format **formats, in } EXTERN tdm_error +tdm_hwc_get_video_available_properties(tdm_hwc *hwc, const tdm_prop **props, int *count) +{ + tdm_private_module *private_module; + tdm_func_hwc *func_hwc = NULL; + + HWC_FUNC_ENTRY(); + + TDM_RETURN_VAL_IF_FAIL(props != NULL, TDM_ERROR_INVALID_PARAMETER); + TDM_RETURN_VAL_IF_FAIL(count != NULL, TDM_ERROR_INVALID_PARAMETER); + + _pthread_mutex_lock(&private_display->lock); + + private_module = private_output->private_module; + func_hwc = &private_module->func_hwc; + + if (!func_hwc->hwc_get_video_available_properties) { + /* 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_get_video_available_properties(private_hwc->hwc_backend, props, count); + + _pthread_mutex_unlock(&private_display->lock); + + return ret; +} + +EXTERN tdm_error tdm_hwc_get_video_capability(tdm_hwc *hwc, tdm_hwc_video_capability *video_capability) { -- 2.7.4 From 12cfc64f966cc7ea84ac549a4fd8ec21f23285e9 Mon Sep 17 00:00:00 2001 From: Junkyeong Kim Date: Wed, 21 Nov 2018 17:52:12 +0900 Subject: [PATCH 06/16] add null checking before set error value Change-Id: I49ff7ab80ec8a7f337bb1b22b6e96798cae213eb Signed-off-by: Junkyeong Kim --- backends/virtual/tdm_virtual_display.c | 18 +++++++----------- src/tdm_output.c | 11 +++++------ 2 files changed, 12 insertions(+), 17 deletions(-) diff --git a/backends/virtual/tdm_virtual_display.c b/backends/virtual/tdm_virtual_display.c index fe4a5c9..3f9d9b5 100644 --- a/backends/virtual/tdm_virtual_display.c +++ b/backends/virtual/tdm_virtual_display.c @@ -761,25 +761,23 @@ virtual_output_create(tdm_backend_data *bdata, const char *name, tdm_error *erro tdm_virtual_voutput_data *voutput_data = NULL; tdm_virtual_output_data *output_data = NULL; tdm_virtual_layer_data *layer_data = NULL; - tdm_error ret; if (!virtual_data || !name) { TDM_ERR("invalid parameter"); - *error = TDM_ERROR_INVALID_PARAMETER; + if (error) *error = TDM_ERROR_INVALID_PARAMETER; return NULL; } voutput_data = calloc(1, sizeof(tdm_virtual_voutput_data)); if (!voutput_data) { TDM_ERR("alloc failed"); - *error = TDM_ERROR_OUT_OF_MEMORY; + if (error) *error = TDM_ERROR_OUT_OF_MEMORY; return NULL; } voutput_data->output_modes = calloc(1, sizeof(tdm_output_mode)); if (!voutput_data->output_modes) { TDM_ERR("alloc failed"); - ret = TDM_ERROR_OUT_OF_MEMORY; goto create_fail; } @@ -809,7 +807,6 @@ virtual_output_create(tdm_backend_data *bdata, const char *name, tdm_error *erro output_data = calloc(1, sizeof(tdm_virtual_output_data)); if (!output_data) { TDM_ERR("alloc failed"); - *error = TDM_ERROR_OUT_OF_MEMORY; goto create_fail; } voutput_data->output_data = output_data; @@ -833,7 +830,7 @@ virtual_output_create(tdm_backend_data *bdata, const char *name, tdm_error *erro output_data->timer = tdm_event_loop_add_timer_handler(virtual_data->dpy, _tdm_virtual_display_cb_timeout, output_data, - &ret); + NULL); if (!output_data->timer) goto create_fail; LIST_INITHEAD(&output_data->timer_event_list); @@ -842,7 +839,6 @@ virtual_output_create(tdm_backend_data *bdata, const char *name, tdm_error *erro layer_data = calloc(1, sizeof(tdm_virtual_layer_data)); if (!layer_data) { TDM_ERR("alloc failed"); - ret = TDM_ERROR_OUT_OF_MEMORY; goto create_fail; } @@ -857,7 +853,7 @@ virtual_output_create(tdm_backend_data *bdata, const char *name, tdm_error *erro LIST_ADDTAIL(&output_data->link, &virtual_data->output_list); LIST_ADDTAIL(&layer_data->link, &output_data->layer_list); - *error = TDM_ERROR_NONE; + if (error) *error = TDM_ERROR_NONE; TDM_DBG("virtual output create(%s)(%p)(%p)", output_data->name, voutput_data, output_data); @@ -869,7 +865,7 @@ create_fail: if (voutput_data->output_modes) free(voutput_data->output_modes); if (voutput_data) free(voutput_data); - *error = ret; + if (error) *error = TDM_ERROR_OUT_OF_MEMORY; return NULL; } @@ -937,11 +933,11 @@ virtual_output_get_output(tdm_voutput *voutput, tdm_error *error) RETURN_VAL_IF_FAIL(voutput_data, NULL); if (!voutput_data) { - *error = TDM_ERROR_INVALID_PARAMETER; + if (error) *error = TDM_ERROR_INVALID_PARAMETER; return NULL; } - *error = TDM_ERROR_NONE; + if (error) *error = TDM_ERROR_NONE; return voutput_data->output_data; } diff --git a/src/tdm_output.c b/src/tdm_output.c index 3d6686b..16b7bf1 100644 --- a/src/tdm_output.c +++ b/src/tdm_output.c @@ -1983,12 +1983,11 @@ tdm_voutput_create(tdm_display *dpy, const char *name, tdm_error *error) _pthread_mutex_lock(&private_display->lock); - if (error) - *error = TDM_ERROR_NONE; + if (error) *error = TDM_ERROR_NONE; private_voutput = calloc(1, sizeof(tdm_private_voutput)); if (!private_voutput) { - *error = TDM_ERROR_OUT_OF_MEMORY; + if (error) *error = TDM_ERROR_OUT_OF_MEMORY; _pthread_mutex_unlock(&private_display->lock); return NULL; } @@ -2003,7 +2002,7 @@ tdm_voutput_create(tdm_display *dpy, const char *name, tdm_error *error) if (voutput_backend == NULL || ret != TDM_ERROR_NONE) { TDM_ERR("voutput_create fail"); free(private_voutput); - *error = ret; + if (error) *error = ret; private_display->current_module = current_module; _pthread_mutex_unlock(&private_display->lock); return NULL; @@ -2017,7 +2016,7 @@ tdm_voutput_create(tdm_display *dpy, const char *name, tdm_error *error) if (output_backend == NULL || ret != TDM_ERROR_NONE) { TDM_ERR("voutput_get_output fail"); free(private_voutput); - *error = ret; + if (error) *error = ret; if (func_voutput->voutput_destroy) func_voutput->voutput_destroy(voutput_backend); else @@ -2035,7 +2034,7 @@ tdm_voutput_create(tdm_display *dpy, const char *name, tdm_error *error) func_voutput->voutput_destroy(voutput_backend); else TDM_ERR("no destroy function"); - *error = ret; + if (error) *error = ret; private_display->current_module = current_module; _pthread_mutex_unlock(&private_display->lock); return NULL; -- 2.7.4 From 4404204520eb5594257db1aa127963529247e41f Mon Sep 17 00:00:00 2001 From: Junkyeong Kim Date: Wed, 21 Nov 2018 17:55:41 +0900 Subject: [PATCH 07/16] erase unreachable code Change-Id: I67ac16533a0261ed62bb2591ae783e80f74c2e7e Signed-off-by: Junkyeong Kim --- backends/virtual/tdm_virtual_display.c | 12 ++---------- client/tdm_client.c | 4 ---- src/tdm_server.c | 2 -- 3 files changed, 2 insertions(+), 16 deletions(-) diff --git a/backends/virtual/tdm_virtual_display.c b/backends/virtual/tdm_virtual_display.c index 3f9d9b5..1f1cc06 100644 --- a/backends/virtual/tdm_virtual_display.c +++ b/backends/virtual/tdm_virtual_display.c @@ -819,13 +819,8 @@ virtual_output_create(tdm_backend_data *bdata, const char *name, tdm_error *erro output_data->connector_type = TDM_OUTPUT_TYPE_Unknown; output_data->status = TDM_OUTPUT_CONN_STATUS_DISCONNECTED; - if (name) { - snprintf(voutput_data->name, TDM_NAME_LEN, "%s", name); - snprintf(output_data->name, TDM_NAME_LEN, "%s", name); - } else { - snprintf(voutput_data->name, TDM_NAME_LEN, "unknown"); - snprintf(output_data->name, TDM_NAME_LEN, "%s", name); - } + snprintf(voutput_data->name, TDM_NAME_LEN, "%s", name); + snprintf(output_data->name, TDM_NAME_LEN, "%s", name); output_data->timer = tdm_event_loop_add_timer_handler(virtual_data->dpy, _tdm_virtual_display_cb_timeout, @@ -860,7 +855,6 @@ virtual_output_create(tdm_backend_data *bdata, const char *name, tdm_error *erro return voutput_data; create_fail: - if (layer_data) free(layer_data); if (output_data) free(output_data); if (voutput_data->output_modes) free(voutput_data->output_modes); if (voutput_data) free(voutput_data); @@ -930,8 +924,6 @@ virtual_output_get_output(tdm_voutput *voutput, tdm_error *error) { tdm_virtual_voutput_data *voutput_data = voutput; - RETURN_VAL_IF_FAIL(voutput_data, NULL); - if (!voutput_data) { if (error) *error = TDM_ERROR_INVALID_PARAMETER; return NULL; diff --git a/client/tdm_client.c b/client/tdm_client.c index 57f8ce3..d0aa6ea 100644 --- a/client/tdm_client.c +++ b/client/tdm_client.c @@ -2147,8 +2147,6 @@ tdm_client_voutput_destroy(tdm_client_voutput *voutput) LIST_FOR_EACH_ENTRY_SAFE(cb, cbb, &private_voutput->buffer_list, link) { tbm_surface_h tbm_surface = NULL; - if (!cb) continue; - LIST_DEL(&cb->link); tbm_surface = (tbm_surface_h)wl_buffer_get_user_data(cb->wl_buffer); @@ -2328,8 +2326,6 @@ tdm_client_voutput_remove_commit_handler(tdm_client_voutput *voutput, LIST_DEL(&h->link); free(h); - - pthread_mutex_unlock(&private_client->lock); } pthread_mutex_unlock(&private_client->lock); diff --git a/src/tdm_server.c b/src/tdm_server.c index d1619d9..632e820 100644 --- a/src/tdm_server.c +++ b/src/tdm_server.c @@ -1160,8 +1160,6 @@ tdm_voutput_cb_resource_destroy(struct wl_resource *resource) } LIST_FOR_EACH_ENTRY(vb, &voutput_info->buffer_list, link) { - if (!vb) continue; - if (vb->wl_buffer) wl_resource_destroy(vb->wl_buffer); } -- 2.7.4 From 85df06fb58e9d5db967869b2f74317b882fda126 Mon Sep 17 00:00:00 2001 From: Junkyeong Kim Date: Wed, 21 Nov 2018 17:58:25 +0900 Subject: [PATCH 08/16] set initialization value Change-Id: I5dfa735093995ff286a232db539063d441cce92d Signed-off-by: Junkyeong Kim --- backends/virtual/tdm_virtual_display.c | 2 +- client/tdm_client.c | 2 +- haltests/src/tc_tdm_client.cpp | 1 + src/tdm_server.c | 2 +- 4 files changed, 4 insertions(+), 3 deletions(-) diff --git a/backends/virtual/tdm_virtual_display.c b/backends/virtual/tdm_virtual_display.c index 1f1cc06..875dce4 100644 --- a/backends/virtual/tdm_virtual_display.c +++ b/backends/virtual/tdm_virtual_display.c @@ -868,7 +868,7 @@ tdm_error virtual_output_destroy(tdm_voutput *voutput) { tdm_virtual_data *virtual_data = NULL; - tdm_virtual_voutput_data *vo, *voutput_data = voutput; + tdm_virtual_voutput_data *vo = NULL, *voutput_data = voutput; int find = 0; RETURN_VAL_IF_FAIL(voutput_data, TDM_ERROR_INVALID_PARAMETER); diff --git a/client/tdm_client.c b/client/tdm_client.c index d0aa6ea..d60c6c9 100644 --- a/client/tdm_client.c +++ b/client/tdm_client.c @@ -2002,7 +2002,7 @@ tdm_client_voutput * tdm_client_create_voutput(tdm_client *client, const char *name, tdm_error *error) { tdm_private_client *private_client; - tdm_private_client_output *private_output; + tdm_private_client_output *private_output = NULL; tdm_private_client_voutput *private_voutput; struct wl_proxy *wrapper; diff --git a/haltests/src/tc_tdm_client.cpp b/haltests/src/tc_tdm_client.cpp index 282d8ab..8243d1f 100644 --- a/haltests/src/tc_tdm_client.cpp +++ b/haltests/src/tc_tdm_client.cpp @@ -145,6 +145,7 @@ TDMClient::TDMClient() client = NULL; output = NULL; vblank = NULL; + voutput = NULL; vrefresh_interval = start = end = 0.0; } diff --git a/src/tdm_server.c b/src/tdm_server.c index 632e820..d4166b4 100644 --- a/src/tdm_server.c +++ b/src/tdm_server.c @@ -1139,7 +1139,7 @@ void tdm_voutput_cb_resource_destroy(struct wl_resource *resource) { tdm_server_voutput_info *voutput_info = wl_resource_get_user_data(resource); - tdm_server_voutput_buffer *vb; + tdm_server_voutput_buffer *vb = NULL; tdm_voutput *voutput; tdm_error ret = TDM_ERROR_NONE; -- 2.7.4 From ba79ea1537a672c29709079f895d41b827b91a6b Mon Sep 17 00:00:00 2001 From: Junkyeong Kim Date: Wed, 21 Nov 2018 18:01:46 +0900 Subject: [PATCH 09/16] prevent copying error over TDM_NAME_LEN(64) length string Change-Id: I63b7a3f869fae588127bc5ea9c7b4728980a51aa Signed-off-by: Junkyeong Kim --- client/tdm_client.c | 3 ++- src/tdm_output.c | 9 ++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/client/tdm_client.c b/client/tdm_client.c index d60c6c9..fd51b29 100644 --- a/client/tdm_client.c +++ b/client/tdm_client.c @@ -2082,7 +2082,8 @@ tdm_client_create_voutput(tdm_client *client, const char *name, tdm_error *error LIST_INITHEAD(&private_voutput->buffer_list); private_voutput->private_client = private_client; - strncpy(private_voutput->name, name, TDM_NAME_LEN); + strncpy(private_voutput->name, name, TDM_NAME_LEN - 1); + private_voutput->name[TDM_NAME_LEN - 1] = '\0'; private_voutput->wl_voutput = wl_tdm_create_voutput((struct wl_tdm *)wrapper, name); wl_proxy_wrapper_destroy(wrapper); diff --git a/src/tdm_output.c b/src/tdm_output.c index 16b7bf1..e043569 100644 --- a/src/tdm_output.c +++ b/src/tdm_output.c @@ -1119,7 +1119,7 @@ _tdm_voutput_cb_commit(tdm_voutput *voutput_backend, unsigned int sequence, { tdm_private_voutput_commit_handler *voutput_commit_handler = NULL; tdm_private_module *private_module; - tdm_private_voutput *private_voutput = NULL, *v; + tdm_private_voutput *private_voutput = NULL, *v = NULL; tdm_private_output *private_output; tdm_thread_cb_voutput_commit voutput_commit; tdm_error ret; @@ -2054,9 +2054,12 @@ tdm_voutput_create(tdm_display *dpy, const char *name, tdm_error *error) func_voutput->voutput_destroy(voutput_backend); else TDM_ERR("no destroy function"); + private_voutput = NULL; } else { - strncpy(private_voutput->name, name, TDM_NAME_LEN); - strncpy(private_output->name, name, TDM_NAME_LEN); + strncpy(private_voutput->name, name, TDM_NAME_LEN - 1); + private_voutput->name[TDM_NAME_LEN - 1] = '\0'; + strncpy(private_output->name, name, TDM_NAME_LEN - 1); + private_output->name[TDM_NAME_LEN - 1] = '\0'; private_voutput->private_output = private_output; private_output->private_voutput = private_voutput; -- 2.7.4 From 5aa022f9020fbf011e177946ff5b63b402125a22 Mon Sep 17 00:00:00 2001 From: Junkyeong Kim Date: Thu, 22 Nov 2018 15:18:38 +0900 Subject: [PATCH 10/16] Package version up to 2.4.1 Change-Id: If3616fb2030168d2dc7ceb2df44f95b30c365f16 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 5bc0659..0466641 100644 --- a/packaging/libtdm.spec +++ b/packaging/libtdm.spec @@ -2,7 +2,7 @@ %define HALTESTS_GCOV 0 Name: libtdm -Version: 2.4.0 +Version: 2.4.1 Release: 0 Summary: User Library of Tizen Display Manager Group: Development/Libraries -- 2.7.4 From f101047f57b1a918a6f425eaff567a5038772f02 Mon Sep 17 00:00:00 2001 From: Junkyeong Kim Date: Fri, 23 Nov 2018 11:29:35 +0900 Subject: [PATCH 11/16] fix dummy module loading fail of no output device cause of _tdm_display_load_modules fail _tdm_display_setup cannot execute. the dummy backend is loaded in _tdm_display_setup. Change-Id: I4880095ad688fbccb259dd91cbefab8e8df1eaad Signed-off-by: Junkyeong Kim --- include/tdm_common.h | 1 + src/tdm.c | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/include/tdm_common.h b/include/tdm_common.h index 9492394..b402277 100644 --- a/include/tdm_common.h +++ b/include/tdm_common.h @@ -70,6 +70,7 @@ typedef enum { TDM_ERROR_OUTPUT_DISCONNECTED = -11, /**< output disconnected */ TDM_ERROR_PROTOCOL_ERROR = -12, /**< protocol error */ TDM_ERROR_TIMEOUT = -13, /**< timeout */ + TDM_ERROR_NO_MODULE = -14, /**< no backend module */ } tdm_error; /** diff --git a/src/tdm.c b/src/tdm.c index 6208859..21bd918 100644 --- a/src/tdm.c +++ b/src/tdm.c @@ -1000,7 +1000,7 @@ _tdm_display_load_module_with_file(tdm_private_display *private_display, if (!module) { TDM_ERR("%s", dlerror()); TDM_TRACE_END(); - ret = TDM_ERROR_BAD_MODULE; + ret = TDM_ERROR_NO_MODULE; goto failed_load; } @@ -1214,7 +1214,7 @@ tdm_display_init(tdm_error *error) goto failed_load; ret = _tdm_display_load_modules(private_display); - if (ret != TDM_ERROR_NONE) + if (!(ret == TDM_ERROR_NONE || ret == TDM_ERROR_NO_MODULE)) goto failed_load; stamp2 = tdm_helper_get_time(); -- 2.7.4 From 21ab2ce9f77ca364d4f9ae1d4f52162b951d4530 Mon Sep 17 00:00:00 2001 From: Junkyeong Kim Date: Fri, 23 Nov 2018 12:01:28 +0900 Subject: [PATCH 12/16] client: fix dealloacated error Change-Id: If64862dc4ac1cec654ac45e57bce5e5733ffea86 Signed-off-by: Junkyeong Kim --- client/tdm_client.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/client/tdm_client.c b/client/tdm_client.c index fd51b29..3a2ab48 100644 --- a/client/tdm_client.c +++ b/client/tdm_client.c @@ -2327,6 +2327,10 @@ tdm_client_voutput_remove_commit_handler(tdm_client_voutput *voutput, LIST_DEL(&h->link); free(h); + + pthread_mutex_unlock(&private_client->lock); + + return; } pthread_mutex_unlock(&private_client->lock); -- 2.7.4 From 90309910139e29ccd9523c08068a1565f37da702 Mon Sep 17 00:00:00 2001 From: Junkyeong Kim Date: Fri, 23 Nov 2018 12:02:13 +0900 Subject: [PATCH 13/16] Package version up to 2.4.2 Change-Id: I2c4b5f7e77f9bdeef03b4b0cedbaa6e6360833c0 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 0466641..73dd3ad 100644 --- a/packaging/libtdm.spec +++ b/packaging/libtdm.spec @@ -2,7 +2,7 @@ %define HALTESTS_GCOV 0 Name: libtdm -Version: 2.4.1 +Version: 2.4.2 Release: 0 Summary: User Library of Tizen Display Manager Group: Development/Libraries -- 2.7.4 From d18570c1256f15468761ccf7eece3f329c1d3c5b Mon Sep 17 00:00:00 2001 From: SooChan Lim Date: Thu, 29 Nov 2018 09:51:29 +0900 Subject: [PATCH 14/16] add tdm_hwc_window_set_name Change-Id: I496365a3babeb3e754166e1e1a5c95de124ab15d --- include/tdm.h | 9 +++++++++ include/tdm_backend.h | 9 +++++++++ src/tdm_hwc_window.c | 26 ++++++++++++++++++++++++++ 3 files changed, 44 insertions(+) diff --git a/include/tdm.h b/include/tdm.h index ab9197c..8b74b0e 100644 --- a/include/tdm.h +++ b/include/tdm.h @@ -1153,6 +1153,15 @@ tdm_error tdm_hwc_window_get_constraints(tdm_hwc_window *hwc_window, int *constraints); /** + * @brief Set the name of hwc_window + * @param[in] hwc_window A hwc window object + * @param[in] name of the hwc_window + * @return #TDM_ERROR_NONE if success. Otherwise, error value. + */ +tdm_error +tdm_hwc_window_set_name(tdm_hwc_window *hwc_window, const char *name); + +/** * @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 40390c3..1b73ba9 100644 --- a/include/tdm_backend.h +++ b/include/tdm_backend.h @@ -1047,6 +1047,15 @@ typedef struct _tdm_func_hwc_window { */ tdm_error (*hwc_window_get_constraints)(tdm_hwc_window *hwc_window, int *constraints); + + /** + * @brief Set the name of hwc_window + * @param[in] hwc_window A hwc window object + * @param[in] name of the hwc_window + * @return #TDM_ERROR_NONE if success. Otherwise, error value. + */ + tdm_error (*hwc_window_set_name)(tdm_hwc_window *hwc_window, + const char *name); } tdm_func_hwc_window; /** diff --git a/src/tdm_hwc_window.c b/src/tdm_hwc_window.c index 9248ff5..fd86345 100644 --- a/src/tdm_hwc_window.c +++ b/src/tdm_hwc_window.c @@ -467,4 +467,30 @@ tdm_hwc_window_get_constraints(tdm_hwc_window *hwc_window, int *constraints) return ret; } + +EXTERN tdm_error +tdm_hwc_window_set_name(tdm_hwc_window *hwc_window, const char *name) +{ + 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_get_constraints) { + _pthread_mutex_unlock(&private_display->lock); + TDM_WRN("not implemented!!"); + return TDM_ERROR_NOT_IMPLEMENTED; + } + + ret = func_hwc_window->hwc_window_set_name(private_hwc_window->hwc_window_backend, name); + + _pthread_mutex_unlock(&private_display->lock); + + return ret; +} /* LCOV_EXCL_STOP */ \ No newline at end of file -- 2.7.4 From 0d10c57ab5dfb6aa418195e2489ce469fec937bb Mon Sep 17 00:00:00 2001 From: SooChan Lim Date: Wed, 28 Nov 2018 19:37:21 +0900 Subject: [PATCH 15/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 16/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