* Taeheon Kim <th908.kim@samsung.com>,
* YoungJun Cho <yj44.cho@samsung.com>,
* SooChan Lim <sc1.lim@samsung.com>,
- * Boram Park <sc1.lim@samsung.com>
+ * Boram Park <boram1288.park@samsung.com>
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the
#include "config.h"
#endif
-#include "tdm.h"
-#include "tdm_backend.h"
#include "tdm_private.h"
#define BACKEND_FUNC_ENTRY() \
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)
{
TDM_RETURN_VAL_IF_FAIL(func_display != NULL, TDM_ERROR_INVALID_PARAMETER);
+ assert(private_display->current_module);
+
/* the ABI version of backend module should be more than 1.1 */
- module = private_display->module_data;
+ module = private_display->current_module->module_data;
if (_check_abi_version(module, 1, 1) < 0)
return TDM_ERROR_BAD_MODULE;
- private_display->func_display = *func_display;
+ private_display->current_module->func_display = *func_display;
return TDM_ERROR_NONE;
}
TDM_RETURN_VAL_IF_FAIL(func_output != NULL, TDM_ERROR_INVALID_PARAMETER);
+ assert(private_display->current_module);
+
/* the ABI version of backend module should be more than 1.1 */
- module = private_display->module_data;
+ module = private_display->current_module->module_data;
if (_check_abi_version(module, 1, 1) < 0)
return TDM_ERROR_BAD_MODULE;
- private_display->func_output = *func_output;
+ private_display->current_module->func_output = *func_output;
return TDM_ERROR_NONE;
}
TDM_RETURN_VAL_IF_FAIL(func_layer != NULL, TDM_ERROR_INVALID_PARAMETER);
+ assert(private_display->current_module);
+
/* the ABI version of backend module should be more than 1.1 */
- module = private_display->module_data;
+ module = private_display->current_module->module_data;
if (_check_abi_version(module, 1, 1) < 0)
return TDM_ERROR_BAD_MODULE;
- private_display->func_layer = *func_layer;
+ private_display->current_module->func_layer = *func_layer;
+
+ return TDM_ERROR_NONE;
+}
+
+/* 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;
+
+ TDM_RETURN_VAL_IF_FAIL(TDM_MUTEX_IS_LOCKED(), TDM_ERROR_OPERATION_FAILED);
+
+ BACKEND_FUNC_ENTRY();
+
+ TDM_RETURN_VAL_IF_FAIL(func_hwc_window != 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_window = *func_hwc_window;
return TDM_ERROR_NONE;
}
+/* LCOV_EXCL_STOP */
EXTERN tdm_error
tdm_backend_register_func_pp(tdm_display *dpy, tdm_func_pp *func_pp)
if (!func_pp)
return TDM_ERROR_NONE;
- private_display->capabilities |= TDM_DISPLAY_CAPABILITY_PP;
- private_display->func_pp = *func_pp;
+ assert(private_display->current_module);
+
+ private_display->current_module->capabilities |= TDM_DISPLAY_CAPABILITY_PP;
+ private_display->current_module->func_pp = *func_pp;
+
+ if (!private_display->pp_module)
+ private_display->pp_module = private_display->current_module;
+ else
+ TDM_ERR("already has pp backend(%s)", private_display->pp_module->module_data->name);
return TDM_ERROR_NONE;
}
if (!func_capture)
return TDM_ERROR_NONE;
- private_display->capabilities |= TDM_DISPLAY_CAPABILITY_CAPTURE;
- private_display->func_capture = *func_capture;
+ assert(private_display->current_module);
+
+ private_display->current_module->capabilities |= TDM_DISPLAY_CAPABILITY_CAPTURE;
+ private_display->current_module->func_capture = *func_capture;
+
+ //TODO: remove later
+ if (!private_display->capture_module)
+ private_display->capture_module = private_display->current_module;
+ else
+ TDM_ERR("already has capture backend(%s)", private_display->capture_module->module_data->name);
+
+ return TDM_ERROR_NONE;
+}
+
+EXTERN tdm_error
+tdm_backend_register_output(tdm_display *dpy, tdm_output *output)
+{
+ 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 void
+tdm_backend_unregister_output(tdm_display *dpy, tdm_output *output)
+{
+ tdm_private_output *private_output;
+
+ BACKEND_FUNC_ENTRY_VOID();
+
+ TDM_RETURN_IF_FAIL(TDM_MUTEX_IS_LOCKED());
+ TDM_RETURN_IF_FAIL(output != NULL);
+
+ /* 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);
+
+ private_output = tdm_display_find_private_output(private_display, output);
+ tdm_display_destroy_private_output(private_output);
+}