X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=src%2Ftdm_backend.c;h=b0d1576fbe38ad72bd5a819868d9cb22551ec47a;hb=efb743bd507754d6c6b97a168b3af7316e1bfcc8;hp=6f98b0f8f0ecd618668dd88bac12367919977fc9;hpb=a55a9a6fab8757a77fa2cca11cdcf583d005890d;p=platform%2Fcore%2Fuifw%2Flibtdm.git diff --git a/src/tdm_backend.c b/src/tdm_backend.c index 6f98b0f..b0d1576 100644 --- a/src/tdm_backend.c +++ b/src/tdm_backend.c @@ -1,122 +1,250 @@ /************************************************************************** - -libtdm - -Copyright 2015 Samsung Electronics co., Ltd. All Rights Reserved. - -Contact: Eunchul Kim , - JinYoung Jeon , - Taeheon Kim , - YoungJun Cho , - SooChan Lim , - Boram Park - -Permission is hereby granted, free of charge, to any person obtaining a -copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sub license, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice (including the -next paragraph) shall be included in all copies or substantial portions -of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. -IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR -ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - + * + * libtdm + * + * Copyright 2015 Samsung Electronics co., Ltd. All Rights Reserved. + * + * Contact: Eunchul Kim , + * JinYoung Jeon , + * Taeheon Kim , + * YoungJun Cho , + * SooChan Lim , + * Boram Park + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sub license, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial portions + * of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. + * IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR + * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * **************************************************************************/ #ifdef HAVE_CONFIG_H #include "config.h" #endif -#include "tdm.h" -#include "tdm_backend.h" #include "tdm_private.h" #define BACKEND_FUNC_ENTRY() \ - tdm_private_display *private_display; \ - TDM_RETURN_VAL_IF_FAIL(dpy != NULL, TDM_ERROR_INVALID_PARAMETER); \ - private_display = (tdm_private_display*)dpy; + tdm_private_display *private_display; \ + TDM_RETURN_VAL_IF_FAIL(dpy != NULL, TDM_ERROR_INVALID_PARAMETER); \ + private_display = (tdm_private_display*)dpy; + +static int +_check_abi_version(tdm_backend_module *module, int abimaj, int abimin) +{ + int major = TDM_BACKEND_GET_ABI_MAJOR(module->abi_version); + int minor = TDM_BACKEND_GET_ABI_MINOR(module->abi_version); + + if (major < abimaj) goto failed; + if (major > abimaj) return 0; + if (minor < abimin) goto failed; + return 0; +failed: + TDM_ERR("The ABI version(%d.%d) of '%s' is less than %d.%d", + major, minor, module->name ? module->name : "unknown", + abimaj, abimin); + return -1; +} EXTERN tdm_error -tdm_backend_register_func_display(tdm_display *dpy, tdm_func_display *func_display) +tdm_backend_register_func_display(tdm_display *dpy, + tdm_func_display *func_display) { - BACKEND_FUNC_ENTRY(); + 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_display != NULL, TDM_ERROR_INVALID_PARAMETER); + TDM_RETURN_VAL_IF_FAIL(func_display != NULL, TDM_ERROR_INVALID_PARAMETER); - pthread_mutex_lock(&private_display->lock); - private_display->func_display = *func_display; - pthread_mutex_unlock(&private_display->lock); + assert(private_display->current_module); - return TDM_ERROR_NONE; + /* the ABI version of backend module should be more than 1.1 */ + module = private_display->current_module->module_data; + if (_check_abi_version(module, 1, 1) < 0) + return TDM_ERROR_BAD_MODULE; + + private_display->current_module->func_display = *func_display; + + return TDM_ERROR_NONE; } EXTERN tdm_error tdm_backend_register_func_output(tdm_display *dpy, tdm_func_output *func_output) { - BACKEND_FUNC_ENTRY(); + 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_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->current_module->module_data; + if (_check_abi_version(module, 1, 1) < 0) + return TDM_ERROR_BAD_MODULE; + + private_display->current_module->func_output = *func_output; + + return TDM_ERROR_NONE; +} + +EXTERN tdm_error +tdm_backend_register_func_voutput(tdm_display *dpy, tdm_func_voutput *func_voutput) +{ + tdm_backend_module *module; + + TDM_RETURN_VAL_IF_FAIL(TDM_MUTEX_IS_LOCKED(), TDM_ERROR_OPERATION_FAILED); - TDM_RETURN_VAL_IF_FAIL(func_output != NULL, TDM_ERROR_INVALID_PARAMETER); + BACKEND_FUNC_ENTRY(); - pthread_mutex_lock(&private_display->lock); - private_display->func_output = *func_output; - pthread_mutex_unlock(&private_display->lock); + TDM_RETURN_VAL_IF_FAIL(func_voutput != NULL, TDM_ERROR_INVALID_PARAMETER); - return TDM_ERROR_NONE; + assert(private_display->current_module); + + /* the ABI version of backend module should be more than 1.1 */ + module = private_display->current_module->module_data; + if (_check_abi_version(module, 1, 1) < 0) + return TDM_ERROR_BAD_MODULE; + + private_display->current_module->func_voutput = *func_voutput; + + return TDM_ERROR_NONE; } + EXTERN tdm_error tdm_backend_register_func_layer(tdm_display *dpy, tdm_func_layer *func_layer) { - BACKEND_FUNC_ENTRY(); + 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_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->current_module->module_data; + if (_check_abi_version(module, 1, 1) < 0) + return TDM_ERROR_BAD_MODULE; + + 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); - TDM_RETURN_VAL_IF_FAIL(func_layer != NULL, TDM_ERROR_INVALID_PARAMETER); + assert(private_display->current_module); +// TODO : temp erase module check for virtual +// module = private_display->current_module->module_data; +// if (_check_abi_version(module, 2, 0) < 0) +// return TDM_ERROR_BAD_MODULE; - pthread_mutex_lock(&private_display->lock); - private_display->func_layer = *func_layer; - pthread_mutex_unlock(&private_display->lock); + private_display->current_module->func_hwc = *func_hwc; - return TDM_ERROR_NONE; + return TDM_ERROR_NONE; } EXTERN tdm_error -tdm_backend_register_func_pp(tdm_display *dpy, tdm_func_pp *func_pp) +tdm_backend_register_func_hwc_window(tdm_display *dpy, tdm_func_hwc_window *func_hwc_window) { - BACKEND_FUNC_ENTRY(); +// tdm_backend_module *module; + + TDM_RETURN_VAL_IF_FAIL(TDM_MUTEX_IS_LOCKED(), TDM_ERROR_OPERATION_FAILED); + + BACKEND_FUNC_ENTRY(); - if (!func_pp) - return TDM_ERROR_NONE; + TDM_RETURN_VAL_IF_FAIL(func_hwc_window != NULL, TDM_ERROR_INVALID_PARAMETER); - pthread_mutex_lock(&private_display->lock); - private_display->capabilities |= TDM_DISPLAY_CAPABILITY_PP; - private_display->func_pp = *func_pp; - pthread_mutex_unlock(&private_display->lock); + assert(private_display->current_module); +// TODO : temp erase module check for virtual +// module = private_display->current_module->module_data; +// if (_check_abi_version(module, 2, 0) < 0) +// return TDM_ERROR_BAD_MODULE; - return TDM_ERROR_NONE; + private_display->current_module->func_hwc_window = *func_hwc_window; + + return TDM_ERROR_NONE; } +/* LCOV_EXCL_STOP */ EXTERN tdm_error -tdm_backend_register_func_capture(tdm_display *dpy, tdm_func_capture *func_capture) +tdm_backend_register_func_pp(tdm_display *dpy, tdm_func_pp *func_pp) { - BACKEND_FUNC_ENTRY(); + TDM_RETURN_VAL_IF_FAIL(TDM_MUTEX_IS_LOCKED(), TDM_ERROR_OPERATION_FAILED); + + BACKEND_FUNC_ENTRY(); + + if (!func_pp) + return TDM_ERROR_NONE; - if (!func_capture) - return TDM_ERROR_NONE; + assert(private_display->current_module); - pthread_mutex_lock(&private_display->lock); - private_display->capabilities |= TDM_DISPLAY_CAPABILITY_CAPTURE; - private_display->func_capture = *func_capture; - pthread_mutex_unlock(&private_display->lock); + private_display->current_module->capabilities |= TDM_DISPLAY_CAPABILITY_PP; + private_display->current_module->func_pp = *func_pp; - return TDM_ERROR_NONE; + 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; } +EXTERN tdm_error +tdm_backend_register_func_capture(tdm_display *dpy, + tdm_func_capture *func_capture) +{ + TDM_RETURN_VAL_IF_FAIL(TDM_MUTEX_IS_LOCKED(), TDM_ERROR_OPERATION_FAILED); + + BACKEND_FUNC_ENTRY(); + + if (!func_capture) + return TDM_ERROR_NONE; + + 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; +}