Transfer ownership of acquire_fence fd when fd is set to tdm 29/314229/2
authorChangyeon Lee <cyeon.lee@samsung.com>
Tue, 9 Jul 2024 05:50:31 +0000 (14:50 +0900)
committerChangyeon Lee <cyeon.lee@samsung.com>
Tue, 9 Jul 2024 08:03:18 +0000 (17:03 +0900)
Change-Id: I1d1bae70a45a749979d820ce6f4f8951dfe7c383

include/tdm.h
include/tdm_backend.h
src/tdm_hwc.c
src/tdm_hwc_window.c

index 0772b7fb0a3038d1cfcd62f562b50f640f03834a..86eff26a262ca4d2c73937aa554051049566d444 100644 (file)
@@ -1004,6 +1004,7 @@ tdm_hwc_set_client_target_buffer(tdm_hwc *hwc, tbm_surface_h target_buffer, tdm_
 
 /**
  * @brief Set the acquire fence fd of client(relative to the TDM) target
+ * @details ownership of the acquire fence fd is transfered
  * @param[in] hwc A output hwc
  * @param[in] acquire_fence  The acquire fence fd of target
  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
@@ -1276,6 +1277,7 @@ tdm_hwc_window_set_cursor_image(tdm_hwc_window *hwc_window, int width, int heigh
 
 /**
  * @brief Set the acquire fence of hwc_window
+ * @details ownership of the acquire fence fd is transfered
  * @param[in] hwc_window A hwc window object
  * @param[in] acquire_fence the acquire fence fd of a hwc window object
  * @return #TDM_ERROR_NONE if success. Otherwise, error value.
index e53eb10ceb32a8fe1ad626b33ab736a6873ef848..75f06753486a9544ac6896dacd6090f468f6a987 100644 (file)
@@ -892,6 +892,8 @@ typedef struct _tdm_func_hwc {
 
        /**
         * @brief Set the acquire fence of client(relative to the TDM) target buffer
+        * @details ownership of the acquire fence fd is transfered and
+        * backend must close the acquire fence fd when it is no longer needed.
         * @param[in] hwc A output hwc
         * @param[in] acquire_fence The acquire fence fd of target
         * @return #TDM_ERROR_NONE if success. Otherwise, error value.
@@ -979,6 +981,8 @@ typedef struct _tdm_func_hwc {
         * @brief Get commit fence
         * @details After all change of a window object are applied to last tdm_hwc_commit,
         * the fence is signaled.
+        * ownership of the commit fence fd is transfered and
+        * backend must dup the commit fence fd if the commit fence is continued used it in backend.
         * @param[in] hwc A hwc object
         * @param[out] commit_fence the commit fence fd of tdm_hwc_commit
         * @return #TDM_ERROR_NONE if success. Otherwise, error value.
@@ -989,6 +993,8 @@ typedef struct _tdm_func_hwc {
         * @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.
+        * ownership of the release fence fd is transfered and
+        * backend must dup the release fence fd if the release fence is continued used it in backend.
         * @param[in] hwc A hwc object
         * @param[out] num_elements the number of hwc_windows
         * @param[out] hwc_windows An array of windows
@@ -1174,6 +1180,8 @@ typedef struct _tdm_func_hwc_window {
 
        /**
         * @brief Set the acquire fence of hwc_window
+        * @details ownership of the acquire fence fd is transfered and
+        * backend must close the acquire fence fd when it is no longer needed.
         * @param[in] hwc_window A hwc window object
         * @param[in] acquire_fence the acquire fence fd of a hwc window object
         * @return #TDM_ERROR_NONE if success. Otherwise, error value.
index 81fb042d6a9614f4a9be56e7bc27bf565eac9609..c2695c0f012edc7268240c2089e4f5572538dc84 100644 (file)
@@ -636,6 +636,8 @@ tdm_hwc_set_client_target_acquire_fence(tdm_hwc *hwc, int acquire_fence)
        } else {
                if (!func_hwc->hwc_set_client_target_acquire_fence) {
                        /* LCOV_EXCL_START */
+                       if (acquire_fence >= 0)
+                               close(acquire_fence);
                        _pthread_mutex_unlock(&private_display->lock);
                        TDM_WRN("not implemented!!");
                        return TDM_ERROR_NOT_IMPLEMENTED;
index a4f2fb6cc1addb57dc15da00431b6b34f73f7fe9..6504389a7c8fe55bfe6dfe7072281be6de4ad84d 100644 (file)
@@ -433,6 +433,8 @@ tdm_hwc_window_set_acquire_fence(tdm_hwc_window *hwc_window, int acquire_fence)
                ret = hal_tdm_hwc_window_set_acquire_fence((hal_tdm_hwc_window *)private_hwc_window->hwc_window_backend, acquire_fence);
        } else {
                if (!func_hwc_window->hwc_window_set_acquire_fence) {
+                       if (acquire_fence >= 0)
+                               close(acquire_fence);
                        _pthread_mutex_unlock(&private_display->lock);
                        TDM_WRN("not implemented!!");
                        return TDM_ERROR_NOT_IMPLEMENTED;