From 3874ada66d6b1f769b570e8a726d3a855b797984 Mon Sep 17 00:00:00 2001 From: Changyeon Lee Date: Wed, 24 Jun 2020 14:28:34 +0900 Subject: [PATCH] tdm_hwc: add tdm_hwc_get_release_fences interface Retrieves the windows which the backend requires setting the release fences the release fence is signaled when the backend is no longer using previous buffer. tdm_error tdm_hwc_get_release_fences(tdm_hwc *hwc, uint32_t *num_elements, tdm_hwc_window **hwc_windows, int *fences); tdm_error (*tdm_hwc_get_release_fences)(tdm_hwc *hwc, uint32_t *num_elements, tdm_hwc_window **hwc_windows, int *release_fences); Change-Id: Ie8bd337c6da2c49368263c701f2dcdcc31655f62 --- include/tdm.h | 15 +++++++++++++++ include/tdm_backend.h | 14 ++++++++++++++ src/tdm_hwc.c | 52 +++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 81 insertions(+) diff --git a/include/tdm.h b/include/tdm.h index d064db3..127b7f0 100644 --- a/include/tdm.h +++ b/include/tdm.h @@ -1079,6 +1079,21 @@ tdm_error tdm_hwc_get_commit_fence(tdm_hwc *hwc, int *commit_fence); /** + * @brief Get release fences + * @details Retrieves the windows which the backend requires setting the release fences + * the release fence is signaled when the backend is no longer using previous buffer. + * @param[in] hwc A hwc object + * @param[out] num_elements the number of hwc_windows + * @param[out] hwc_windows An array of windows + * @param[out] release_fences An array of release fences, each corresponding + * to an element of windows + * @return #TDM_ERROR_NONE if success. Otherwise, error value. + */ +EXTERN tdm_error +tdm_hwc_get_release_fences(tdm_hwc *hwc, uint32_t *num_elements, + tdm_hwc_window **hwc_windows, int *fences); + +/** * @brief Set the property which has a given id on the hwc object. * @param[in] hwc A hwc object * @param[in] id The property id diff --git a/include/tdm_backend.h b/include/tdm_backend.h index 15e5be1..afbeb5c 100644 --- a/include/tdm_backend.h +++ b/include/tdm_backend.h @@ -986,6 +986,20 @@ typedef struct _tdm_func_hwc { tdm_error (*hwc_get_commit_fence)(tdm_hwc *hwc, int *commit_fence); /** + * @brief Get release fences + * @details Retrieves the windows which the backend requires setting the release fences + * the release fence is signaled when the backend is no longer using previous buffer. + * @param[in] hwc A hwc object + * @param[out] num_elements the number of hwc_windows + * @param[out] hwc_windows An array of windows + * @param[out] release_fences An array of release fences, each corresponding + * to an element of windows + * @return #TDM_ERROR_NONE if success. Otherwise, error value. + */ + tdm_error (*tdm_hwc_get_release_fences)(tdm_hwc *hwc, uint32_t *num_elements, + tdm_hwc_window **hwc_windows, int *release_fences); + + /** * @brief Set the property which has a given id on the hwc object. * @param[in] hwc A hwc object * @param[in] id The property id diff --git a/src/tdm_hwc.c b/src/tdm_hwc.c index 9238b29..47b6abb 100644 --- a/src/tdm_hwc.c +++ b/src/tdm_hwc.c @@ -853,6 +853,58 @@ tdm_hwc_get_commit_fence(tdm_hwc *hwc, int *commit_fence) return ret; } +EXTERN tdm_error +tdm_hwc_get_release_fences(tdm_hwc *hwc, uint32_t *num_elements, + tdm_hwc_window **hwc_windows, int *fences) +{ + tdm_private_module *private_module; + tdm_func_hwc *func_hwc = NULL; + tdm_private_hwc_window *private_hwc_window = NULL; + int i; + + HWC_FUNC_ENTRY(); + + _pthread_mutex_lock(&private_display->lock); + + private_module = private_hwc->private_module; + func_hwc = &private_module->func_hwc; + + if (!func_hwc->hwc_get_release_fences) { + /* 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_release_fences(private_hwc->hwc_backend, num_elements, + hwc_windows, fences); + + if (hwc_windows == NULL || fences == NULL) { + _pthread_mutex_unlock(&private_display->lock); + return TDM_ERROR_NONE; + } + + for (i = 0; i < *num_elements; i++) { + private_hwc_window = _tdm_hwc_find_private_hwc_window(private_hwc, hwc_windows[i]); + if (private_hwc_window == NULL) { + /* LCOV_EXCL_START */ + TDM_ERR("failed! This should never happen!"); + tdm_hwc_window_destroy_internal(private_hwc_window); + *num_elements = 0; + _pthread_mutex_unlock(&private_display->lock); + return TDM_ERROR_OPERATION_FAILED; + /* LCOV_EXCL_STOP */ + } + + hwc_windows[i] = (tdm_hwc_window*)private_hwc_window; + } + + _pthread_mutex_unlock(&private_display->lock); + + return ret; +} + tdm_error tdm_hwc_set_property(tdm_hwc *hwc, uint32_t id, tdm_value value) { -- 2.7.4