From 24548acabc4c9021a5a8c932a2d1f8c3525ebfb6 Mon Sep 17 00:00:00 2001 From: Boram Park Date: Tue, 7 Mar 2017 16:56:25 +0900 Subject: [PATCH] output: support to remove the commit & vblank handler Change-Id: I36a569d4e6fdc018fb188444c3ca10f082c4c672 --- include/tdm.h | 20 +++++++++++++++++ src/tdm_output.c | 64 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/tdm_private.h | 5 +++++ 3 files changed, 89 insertions(+) diff --git a/include/tdm.h b/include/tdm.h index 91cabef..3d17d4b 100644 --- a/include/tdm.h +++ b/include/tdm.h @@ -486,6 +486,26 @@ tdm_output_commit(tdm_output *output, int sync, tdm_output_commit_handler func, void *user_data); /** + * @brief Remove the user vblank handler + * @param[in] output A output object + * @param[in] func A user vblank handler + * @param[in] user_data The user data + * @return #TDM_ERROR_NONE if success. Otherwise, error value. + */ +tdm_error +tdm_output_remove_vblank_handler(tdm_output *output, tdm_output_vblank_handler func, void *user_data); + +/** + * @brief Remove the user commit handler + * @param[in] output A output 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_remove_commit_handler(tdm_output *output, tdm_output_commit_handler func, void *user_data); + +/** * @brief Set one of available modes of a output object * @param[in] output A output object * @param[in] mode A output mode diff --git a/src/tdm_output.c b/src/tdm_output.c index 1b85566..cb5045c 100644 --- a/src/tdm_output.c +++ b/src/tdm_output.c @@ -803,6 +803,70 @@ tdm_output_wait_vblank_add_front(tdm_output *output, int interval, int sync, return ret; } +INTERN void +tdm_output_remove_vblank_handler_internal(tdm_output *output, tdm_output_vblank_handler func, void *user_data) +{ + tdm_private_output *private_output = (tdm_private_output*)output; + tdm_private_vblank_handler *v = NULL; + + TDM_RETURN_IF_FAIL(private_output != NULL); + + LIST_FOR_EACH_ENTRY(v, &private_output->vblank_handler_list, link) { + if (v->func == func && v->user_data == user_data) { + /* only set func & user_data to NULL. It will be freed when an event occurs */ + v->func = NULL; + v->user_data = NULL; + break; + } + } +} + +INTERN void +tdm_output_remove_commit_handler_internal(tdm_output *output, tdm_output_commit_handler func, void *user_data) +{ + tdm_private_output *private_output = (tdm_private_output*)output; + tdm_private_output_commit_handler *c = NULL; + + TDM_RETURN_IF_FAIL(private_output != NULL); + + LIST_FOR_EACH_ENTRY(c, &private_output->output_commit_handler_list, link) { + if (c->func == func && c->user_data == user_data) { + /* only set func & user_data to NULL. It will be freed when an event occurs */ + c->func = NULL; + c->user_data = NULL; + break; + } + } +} + +EXTERN tdm_error +tdm_output_remove_vblank_handler(tdm_output *output, tdm_output_vblank_handler func, void *user_data) +{ + OUTPUT_FUNC_ENTRY(); + + _pthread_mutex_lock(&private_display->lock); + + tdm_output_remove_vblank_handler_internal(output, func, user_data); + + _pthread_mutex_unlock(&private_display->lock); + + return ret; +} + +EXTERN tdm_error +tdm_output_remove_commit_handler(tdm_output *output, tdm_output_commit_handler func, void *user_data) +{ + OUTPUT_FUNC_ENTRY(); + + _pthread_mutex_lock(&private_display->lock); + + tdm_output_remove_commit_handler_internal(output, func, user_data); + + _pthread_mutex_unlock(&private_display->lock); + + return ret; +} + INTERN tdm_error tdm_output_commit_internal(tdm_output *output, int sync, tdm_output_commit_handler func, void *user_data) { diff --git a/src/tdm_private.h b/src/tdm_private.h index eb5e531..13e0610 100644 --- a/src/tdm_private.h +++ b/src/tdm_private.h @@ -428,6 +428,11 @@ tdm_error tdm_output_get_dpms_internal(tdm_output *output, tdm_output_dpms *dpms_value); void +tdm_output_remove_vblank_handler_internal(tdm_output *output, tdm_output_vblank_handler func, void *user_data); +void +tdm_output_remove_commit_handler_internal(tdm_output *output, tdm_output_commit_handler func, void *user_data); + +void tdm_layer_committed(tdm_private_layer *private_layer, tdm_private_layer_buffer **committed_buffer); void -- 2.7.4