From: Changyeon Lee Date: Tue, 9 Jul 2024 06:04:36 +0000 (+0900) Subject: Get ownership of acquire_fence fd when fd is set to tdm X-Git-Tag: accepted/tizen/unified/20240711.011448~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=b86bbddcd350fe0f5fd8af2c1363cb9c49f1ab02;p=platform%2Fhal%2Fapi%2Ftdm.git Get ownership of acquire_fence fd when fd is set to tdm It is better to transfer ownership when fd is set in tdm for fd management. Change-Id: I1388bbd62fb22277541761d1358cf6edaa80d0ac --- diff --git a/src/hal-api-tdm.c b/src/hal-api-tdm.c index e997846..2f41a3d 100644 --- a/src/hal-api-tdm.c +++ b/src/hal-api-tdm.c @@ -114,6 +114,14 @@ hwc_funcs = g_hal_tdm_backend_data->hwc_funcs; \ if (!hwc_funcs->__func__) return HAL_TDM_ERROR_NOT_IMPLEMENTED; +#define HWC_FUNC_ENTRY_FD_CLOSE(__func__, fd) \ + hal_tdm_hwc_funcs *hwc_funcs; \ + if (!hwc) { if (fd >= 0) close(fd); return HAL_TDM_ERROR_INVALID_PARAMETER; } \ + if (!g_hal_tdm_backend_data) { if (fd >= 0) close(fd); return HAL_TDM_ERROR_NO_MODULE; } \ + if (!g_hal_tdm_backend_data->hwc_funcs) { if (fd >= 0) close(fd); return HAL_TDM_ERROR_NOT_IMPLEMENTED; } \ + hwc_funcs = g_hal_tdm_backend_data->hwc_funcs; \ + if (!hwc_funcs->__func__) { if (fd >= 0) close(fd); return HAL_TDM_ERROR_NOT_IMPLEMENTED; } + #define HWC_FUNC_ENTRY_NULL(__func__) \ hal_tdm_hwc_funcs *hwc_funcs; \ if (!hwc) { if (*error) *error = HAL_TDM_ERROR_NOT_IMPLEMENTED; return NULL; } \ @@ -130,6 +138,14 @@ hwc_window_funcs = g_hal_tdm_backend_data->hwc_window_funcs; \ if (!hwc_window_funcs->__func__) return HAL_TDM_ERROR_NOT_IMPLEMENTED; +#define HWC_WINDOW_FUNC_ENTRY_FD_CLOSE(__func__, fd) \ + hal_tdm_hwc_window_funcs *hwc_window_funcs; \ + if (!hwc_window) { if (fd >= 0) close(fd); return HAL_TDM_ERROR_INVALID_PARAMETER; } \ + if (!g_hal_tdm_backend_data) { if (fd >= 0) close(fd); return HAL_TDM_ERROR_NO_MODULE; } \ + if (!g_hal_tdm_backend_data->hwc_window_funcs) { if (fd >= 0) close(fd); return HAL_TDM_ERROR_NOT_IMPLEMENTED; } \ + hwc_window_funcs = g_hal_tdm_backend_data->hwc_window_funcs; \ + if (!hwc_window_funcs->__func__) { if (fd >= 0) close(fd); return HAL_TDM_ERROR_NOT_IMPLEMENTED; } + #define HWC_WINDOW_FUNC_ENTRY_NULL(__func__) \ hal_tdm_hwc_window_funcs *hwc_window_funcs; \ if (!hwc_window) { if (*error) *error = HAL_TDM_ERROR_NOT_IMPLEMENTED; return NULL; } \ @@ -753,7 +769,7 @@ hal_tdm_hwc_set_client_target_buffer_info(hal_tdm_hwc *hwc, hal_tdm_hwc_window_i EXTERN hal_tdm_error hal_tdm_hwc_set_client_target_acquire_fence(hal_tdm_hwc *hwc, int acquire_fence) { - HWC_FUNC_ENTRY(hwc_set_client_target_acquire_fence); + HWC_FUNC_ENTRY_FD_CLOSE(hwc_set_client_target_acquire_fence, acquire_fence); return hwc_funcs->hwc_set_client_target_acquire_fence(hwc, acquire_fence); } @@ -939,7 +955,7 @@ hal_tdm_hwc_window_set_cursor_image(hal_tdm_hwc_window *hwc_window, int width, i EXTERN hal_tdm_error hal_tdm_hwc_window_set_acquire_fence(hal_tdm_hwc_window *hwc_window, int acquire_fence) { - HWC_WINDOW_FUNC_ENTRY(hwc_window_set_acquire_fence); + HWC_WINDOW_FUNC_ENTRY_FD_CLOSE(hwc_window_set_acquire_fence, acquire_fence); return hwc_window_funcs->hwc_window_set_acquire_fence(hwc_window, acquire_fence); }