Merge branch 'tizen' into sandbox/cyeon/devel
[platform/core/uifw/libtdm.git] / src / tdm_hwc.c
index 31394a5..9238b29 100644 (file)
@@ -86,6 +86,22 @@ _tdm_hwc_find_private_hwc_window(tdm_private_hwc *private_hwc, tdm_hwc_window *h
        return NULL;
 }
 
+static tdm_error
+_tdm_hwc_check_hwc_commit_handler_validation(tdm_private_hwc *private_hwc, tdm_private_hwc_commit_handler *hwc_commit_handler)
+{
+       tdm_private_hwc_commit_handler *commit_handler = NULL;
+
+       if (LIST_IS_EMPTY(&private_hwc->hwc_commit_handler_list))
+               return TDM_ERROR_INVALID_PARAMETER;
+
+       LIST_FOR_EACH_ENTRY(commit_handler, &private_hwc->hwc_commit_handler_list, link) {
+               if (commit_handler == hwc_commit_handler)
+                       return TDM_ERROR_NONE;
+       }
+
+       return TDM_ERROR_INVALID_PARAMETER;
+}
+
 static void
 _tdm_hwc_thread_cb_commit(tdm_private_display *private_display, void *object,
                                tdm_thread_cb_base *cb_base, void *user_data)
@@ -104,6 +120,8 @@ _tdm_hwc_thread_cb_commit(tdm_private_display *private_display, void *object,
        tdm_thread_cb_remove(private_hwc, TDM_THREAD_CB_HWC_COMMIT, hwc_commit_handler,
                                        _tdm_hwc_thread_cb_commit, NULL);
 
+       TDM_RETURN_IF_FAIL(_tdm_hwc_check_hwc_commit_handler_validation(private_hwc, hwc_commit_handler) == TDM_ERROR_NONE)
+
        LIST_DEL(&hwc_commit_handler->link);
 
        if (tdm_debug_module & TDM_DEBUG_COMMIT) {
@@ -506,6 +524,33 @@ tdm_hwc_set_client_target_buffer(tdm_hwc *hwc, tbm_surface_h target_buffer, tdm_
        return ret;
 }
 
+EXTERN tdm_error
+tdm_hwc_set_client_target_acquire_fence(tdm_hwc *hwc, int acquire_fence)
+{
+       tdm_private_module *private_module;
+       tdm_func_hwc *func_hwc = NULL;
+
+       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_set_client_target_acquire_fence) {
+               /* 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_set_client_target_acquire_fence(private_hwc->hwc_backend, acquire_fence);
+
+       _pthread_mutex_unlock(&private_display->lock);
+
+       return ret;
+}
 
 EXTERN tdm_error
 tdm_hwc_validate(tdm_hwc *hwc, tdm_hwc_window **composited_wnds, uint32_t num_wnds, uint32_t *num_types)
@@ -780,6 +825,34 @@ commit_failed:
        /* LCOV_EXCL_STOP */
 }
 
+EXTERN tdm_error
+tdm_hwc_get_commit_fence(tdm_hwc *hwc, int *commit_fence)
+{
+       tdm_private_module *private_module;
+       tdm_func_hwc *func_hwc = NULL;
+
+       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_commit_fence) {
+               /* 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_commit_fence(private_hwc->hwc_backend, commit_fence);
+
+       _pthread_mutex_unlock(&private_display->lock);
+
+       return ret;
+}
+
 tdm_error
 tdm_hwc_set_property(tdm_hwc *hwc, uint32_t id, tdm_value value)
 {