virtual output: fix build break.
[platform/core/uifw/libtdm.git] / src / tdm_backend.c
index 8be51f0..7d469d1 100644 (file)
        TDM_RETURN_VAL_IF_FAIL(dpy != NULL, TDM_ERROR_INVALID_PARAMETER); \
        private_display = (tdm_private_display*)dpy;
 
+#define BACKEND_FUNC_ENTRY_VOID() \
+       tdm_private_display *private_display; \
+       TDM_RETURN_IF_FAIL(dpy != NULL); \
+       private_display = (tdm_private_display*)dpy;
+
 static int
 _check_abi_version(tdm_backend_module *module, int abimaj, int abimin)
 {
@@ -133,6 +138,28 @@ tdm_backend_register_func_layer(tdm_display *dpy, tdm_func_layer *func_layer)
 
 /* LCOV_EXCL_START */
 EXTERN tdm_error
+tdm_backend_register_func_hwc(tdm_display *dpy, tdm_func_hwc *func_hwc)
+{
+       tdm_backend_module *module;
+
+       TDM_RETURN_VAL_IF_FAIL(TDM_MUTEX_IS_LOCKED(), TDM_ERROR_OPERATION_FAILED);
+
+       BACKEND_FUNC_ENTRY();
+
+       TDM_RETURN_VAL_IF_FAIL(func_hwc != NULL, TDM_ERROR_INVALID_PARAMETER);
+
+       assert(private_display->current_module);
+
+       module = private_display->current_module->module_data;
+       if (_check_abi_version(module, 2, 0) < 0)
+               return TDM_ERROR_BAD_MODULE;
+
+       private_display->current_module->func_hwc = *func_hwc;
+
+       return TDM_ERROR_NONE;
+}
+
+EXTERN tdm_error
 tdm_backend_register_func_hwc_window(tdm_display *dpy, tdm_func_hwc_window *func_hwc_window)
 {
        tdm_backend_module *module;
@@ -146,10 +173,7 @@ tdm_backend_register_func_hwc_window(tdm_display *dpy, tdm_func_hwc_window *func
        assert(private_display->current_module);
 
        module = private_display->current_module->module_data;
-       /* FIX ME:
-                  Temporarily, we set the version of hwc window to 1.1 for the development.
-                  Originally the hwc window version is 2.0. */
-       if (_check_abi_version(module, 1, 1) < 0)
+       if (_check_abi_version(module, 2, 0) < 0)
                return TDM_ERROR_BAD_MODULE;
 
        private_display->current_module->func_hwc_window = *func_hwc_window;
@@ -206,48 +230,44 @@ tdm_backend_register_func_capture(tdm_display *dpy,
        return TDM_ERROR_NONE;
 }
 
-/* LCOV_EXCL_START */
-/* backend operates itself types */
-static tdm_private_output*
-_look_for_frontend_hwc_output(tdm_output *backend_output)
+EXTERN tdm_error
+tdm_backend_register_output(tdm_display *dpy, tdm_output *output)
 {
-       tdm_private_output *frontend_output = NULL, *o = NULL;
-       tdm_private_display *private_display = tdm_display_get();
-       tdm_private_module *private_module = NULL;
-
-       LIST_FOR_EACH_ENTRY(private_module, &private_display->module_list, link) {
-               LIST_FOR_EACH_ENTRY(o, &private_module->output_list, link) {
-                       if (!(o->caps.capabilities & TDM_OUTPUT_CAPABILITY_HWC))
-                               continue;
-
-                       if (o->output_backend == backend_output) {
-                               frontend_output = o;
-                               return frontend_output;
-                       }
-               }
-       }
-
-       return NULL;
+       tdm_error ret;
+
+       BACKEND_FUNC_ENTRY();
+
+       TDM_RETURN_VAL_IF_FAIL(TDM_MUTEX_IS_LOCKED(), TDM_ERROR_OPERATION_FAILED);
+       TDM_RETURN_VAL_IF_FAIL(output != NULL, TDM_ERROR_OPERATION_FAILED);
+
+       /* this function is only for backend. if backend calls this function, it means
+        * that it's triggered by frontend. frontend should set current_module before calling
+        * backend functions.
+        */
+       TDM_RETURN_VAL_IF_FAIL(private_display->current_module != NULL, TDM_ERROR_OPERATION_FAILED);
+
+       ret = tdm_display_update_output(private_display->current_module, output);
+       TDM_RETURN_VAL_IF_FAIL(ret == TDM_ERROR_NONE, ret);
+
+       return TDM_ERROR_NONE;
 }
 
-EXTERN tdm_error
-tdm_backend_trigger_need_validate_event(tdm_output *output)
+EXTERN void
+tdm_backend_unregister_output(tdm_display *dpy, tdm_output *output)
 {
        tdm_private_output *private_output;
-       uint64_t value;
-       int res;
-
-       private_output = _look_for_frontend_hwc_output(output);
-       TDM_RETURN_VAL_IF_FAIL(private_output != NULL, TDM_ERROR_INVALID_PARAMETER);
 
-       value = 1;
+       BACKEND_FUNC_ENTRY_VOID();
 
-       /* do not lock the global display lock here */
+       TDM_RETURN_IF_FAIL(TDM_MUTEX_IS_LOCKED());
+       TDM_RETURN_IF_FAIL(output != NULL);
 
-       res = write(private_output->need_validate.event_fd, &value, sizeof(value));
-       if (res < 0)
-               return TDM_ERROR_OPERATION_FAILED;
+       /* this function is only for backend. if backend calls this function, it means
+        * that it's triggered by frontend. frontend should set current_module before calling
+        * backend functions.
+        */
+       TDM_RETURN_IF_FAIL(private_display->current_module != NULL);
 
-       return TDM_ERROR_NONE;
+       private_output = tdm_display_find_private_output(private_display, output);
+       tdm_display_destroy_private_output(private_output);
 }
-/* LCOV_EXCL_STOP */