tdm_hwc: add tdm_hwc_get_release_fences interface 62/237462/1
authorChangyeon Lee <cyeon.lee@samsung.com>
Wed, 24 Jun 2020 05:28:34 +0000 (14:28 +0900)
committerChangyeon Lee <cyeon.lee@samsung.com>
Tue, 30 Jun 2020 12:29:25 +0000 (21:29 +0900)
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
include/tdm_backend.h
src/tdm_hwc.c

index d064db3..127b7f0 100644 (file)
@@ -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
index 15e5be1..afbeb5c 100644 (file)
@@ -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
index 9238b29..47b6abb 100644 (file)
@@ -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)
 {