From 4b28857fe0498458daae5c1cbc6a6693785a2b5c Mon Sep 17 00:00:00 2001 From: Junkyeong Kim Date: Mon, 1 Feb 2021 14:31:18 +0900 Subject: [PATCH] init hal-api-tdm Change-Id: I59d627b409b743a97c08535ecbc2de84b0e9d88e Signed-off-by: Junkyeong Kim --- CMakeLists.txt | 53 ++ COPYING | 21 + README.md | 1 + hal-api-tdm.pc | 16 + include/hal-tdm-interface.h | 182 ++++++ include/hal-tdm-types.h | 665 ++++++++++++++++++++ include/hal-tdm.h | 140 +++++ packaging/hal-api-tdm-devel.manifest | 6 + packaging/hal-api-tdm.manifest | 6 + packaging/hal-api-tdm.spec | 71 +++ src/common.h | 44 ++ src/hal-api-tdm.c | 878 +++++++++++++++++++++++++++ 12 files changed, 2083 insertions(+) create mode 100644 CMakeLists.txt create mode 100644 COPYING create mode 100644 README.md create mode 100644 hal-api-tdm.pc create mode 100644 include/hal-tdm-interface.h create mode 100644 include/hal-tdm-types.h create mode 100644 include/hal-tdm.h create mode 100644 packaging/hal-api-tdm-devel.manifest create mode 100644 packaging/hal-api-tdm.manifest create mode 100644 packaging/hal-api-tdm.spec create mode 100644 src/common.h create mode 100644 src/hal-api-tdm.c diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..4d04a91 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,53 @@ +CMAKE_MINIMUM_REQUIRED(VERSION 2.6) +PROJECT(hal-api-tdm C) + +SET(PREFIX ${CMAKE_INSTALL_PREFIX}) +SET(EXEC_PREFIX "${CMAKE_INSTALL_PREFIX}/bin") +SET(INCLUDEDIR "${CMAKE_INSTALL_PREFIX}/include") +SET(LIBDIR ${CMAKE_LIBDIR_PREFIX}) +SET(VERSION_MAJOR 0) +SET(VERSION "${VERSION_MAJOR}.1.0") + +SET(PREFIX ${CMAKE_INSTALL_PREFIX}) +SET(EXEC_PREFIX "${PREFIX}/bin") +SET(INCLUDEDIR "${PREFIX}/include") +SET(LIBDIR ${CMAKE_LIBDIR_PREFIX}) + +INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}) +INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/src) +INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/include) + +SET(PKG_MODULES + hal-api-common + dlog + libtbm +) + +INCLUDE(FindPkgConfig) +pkg_check_modules(pkgs REQUIRED ${PKG_MODULES}) + +FOREACH(flag ${pkgs_CFLAGS}) + SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}") +ENDFOREACH(flag) + +SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -fvisibility=hidden -fPIE") +SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -g -fno-omit-frame-pointer -finstrument-functions") +SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -lrt") +SET(CMAKE_EXE_LINKER_FLAGS "-pie") + +ADD_DEFINITIONS("-DLOG_TAG=\"HALAPI_TDM\"") + +SET(SRCS + src/hal-api-tdm.c) + +ADD_LIBRARY( ${PROJECT_NAME} SHARED ${SRCS}) +TARGET_LINK_LIBRARIES( ${PROJECT_NAME} ${pkgs_LDFLAGS} -ldl -lm -Wl,-z,nodelete,--no-undefined) +SET_TARGET_PROPERTIES( ${PROJECT_NAME} PROPERTIES SOVERSION ${VERSION_MAJOR}) +SET_TARGET_PROPERTIES( ${PROJECT_NAME} PROPERTIES VERSION ${VERSION}) + +CONFIGURE_FILE( ${PROJECT_NAME}.pc ${PROJECT_NAME}.pc @ONLY) +INSTALL(TARGETS ${PROJECT_NAME} DESTINATION ${LIBDIR}/hal) +INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/include/hal-tdm-types.h DESTINATION ${INCLUDEDIR}/hal) +INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/include/hal-tdm.h DESTINATION ${INCLUDEDIR}/hal) +INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/include/hal-tdm-interface.h DESTINATION ${INCLUDEDIR}/hal) +INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_NAME}.pc DESTINATION ${LIBDIR}/pkgconfig) diff --git a/COPYING b/COPYING new file mode 100644 index 0000000..ccee209 --- /dev/null +++ b/COPYING @@ -0,0 +1,21 @@ +Copyright 2021 Samsung Electronics co., Ltd. All Rights Reserved. + +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. diff --git a/README.md b/README.md new file mode 100644 index 0000000..fcd76cd --- /dev/null +++ b/README.md @@ -0,0 +1 @@ +hal api tdm diff --git a/hal-api-tdm.pc b/hal-api-tdm.pc new file mode 100644 index 0000000..794f517 --- /dev/null +++ b/hal-api-tdm.pc @@ -0,0 +1,16 @@ +# Package Information for pkg-config + +package_name=hal-api-tdm +prefix=@PREFIX@ +exec_prefix=@EXEC_PREFIX@/hal +libdir=@LIBDIR@/hal +includedir=@INCLUDEDIR@/hal + +Name: ${package_name} +Description: ${package_name} interface +Version: @VERSION@ + +Requires: +Libs: -L${libdir} -l${package_name} +Cflags: -I${includedir} +CXXflags: -I${includedir} diff --git a/include/hal-tdm-interface.h b/include/hal-tdm-interface.h new file mode 100644 index 0000000..f72b828 --- /dev/null +++ b/include/hal-tdm-interface.h @@ -0,0 +1,182 @@ +/************************************************************************** + * + * hal-api-tdm + * + * Copyright 2021 Samsung Electronics co., Ltd. All Rights Reserved. + * + * Contact: SooChan Lim , + * Junkyeong Kim , + * Shawn Lee , + * Changyeon Lee , + * Joonbum Ko + * + * 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. + * +**************************************************************************/ + +#ifndef __HAL_TDM_INTERFACE__ +#define __HAL_TDM_INTERFACE__ + +#include +#include +#include + +#include "hal-tdm-types.h" + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct _hal_tdm_func_display { + hal_tdm_error (*display_get_capability)(hal_tdm_backend_data *bdata, hal_tdm_caps_display *caps); + hal_tdm_error (*display_get_pp_capability)(hal_tdm_backend_data *bdata, hal_tdm_caps_pp *caps); + hal_tdm_error (*display_get_capture_capability)(hal_tdm_backend_data *bdata, hal_tdm_caps_capture *caps); + hal_tdm_output **(*display_get_outputs)(hal_tdm_backend_data *bdata, int *count, hal_tdm_error *error); + hal_tdm_error (*display_get_fd)(hal_tdm_backend_data *bdata, int *fd); + hal_tdm_error (*display_handle_events)(hal_tdm_backend_data *bdata); + hal_tdm_pp *(*display_create_pp)(hal_tdm_backend_data *bdata, hal_tdm_error *error); + hal_tdm_voutput *(*display_voutput_create)(hal_tdm_backend_data *bdata, const char *name, hal_tdm_error *error); +} hal_tdm_func_display; + +typedef struct _hal_tdm_func_output { + hal_tdm_error (*output_get_capability)(hal_tdm_output *output, hal_tdm_caps_output *caps); + hal_tdm_error (*output_set_property)(hal_tdm_output *output, unsigned int id, hal_tdm_value value); + hal_tdm_error (*output_get_property)(hal_tdm_output *output, unsigned int id, hal_tdm_value *value); + hal_tdm_error (*output_wait_vblank)(hal_tdm_output *output, int interval, int sync, void *user_data); + hal_tdm_error (*output_set_vblank_handler)(hal_tdm_output *output, hal_tdm_output_vblank_handler func); + hal_tdm_error (*output_commit)(hal_tdm_output *output, int sync, void *user_data); + hal_tdm_error (*output_set_commit_handler)(hal_tdm_output *output, hal_tdm_output_commit_handler func); + hal_tdm_error (*output_set_dpms)(hal_tdm_output *output, hal_tdm_output_dpms dpms_value); + hal_tdm_error (*output_get_dpms)(hal_tdm_output *output, hal_tdm_output_dpms *dpms_value); + hal_tdm_error (*output_set_mode)(hal_tdm_output *output, const hal_tdm_output_mode *mode); + hal_tdm_error (*output_get_mode)(hal_tdm_output *output, const hal_tdm_output_mode **mode); + hal_tdm_capture *(*output_create_capture)(hal_tdm_output *output, hal_tdm_error *error); + hal_tdm_error (*output_set_status_handler)(hal_tdm_output *output, hal_tdm_output_status_handler func, void *user_data); + hal_tdm_error (*output_set_dpms_handler)(hal_tdm_output *output, hal_tdm_output_dpms_handler func, void *user_data); + hal_tdm_error (*output_set_dpms_async)(hal_tdm_output *output, hal_tdm_output_dpms dpms_value, int *sync); + hal_tdm_hwc *(*output_get_hwc)(hal_tdm_output *output, hal_tdm_error *error); + hal_tdm_error (*output_set_mirror)(hal_tdm_output *output, hal_tdm_output *src_output, hal_tdm_transform transform); + hal_tdm_error (*output_unset_mirror)(hal_tdm_output *output); +} hal_tdm_func_output; + +typedef struct _hal_tdm_func_voutput { + hal_tdm_error (*voutput_destroy)(hal_tdm_voutput *voutput); + hal_tdm_error (*voutput_set_available_mode)(hal_tdm_voutput *voutput, const hal_tdm_output_mode *modes, int count); + hal_tdm_error (*voutput_set_physical_size)(hal_tdm_voutput *voutput, unsigned int mmwidth, unsigned int mmheight); + hal_tdm_error (*voutput_connect)(hal_tdm_voutput *voutput); + hal_tdm_error (*voutput_disconnect)(hal_tdm_voutput *voutput); + hal_tdm_output *(*voutput_get_output)(hal_tdm_voutput *voutput, hal_tdm_error *error); + hal_tdm_error (*voutput_set_commit_func)(hal_tdm_voutput *voutput, hal_tdm_voutput_commit_handler commit_func); + hal_tdm_error (*voutput_commit_done)(hal_tdm_voutput *voutput); + hal_tdm_error (*voutput_set_target_buffer_queue_flag)(hal_tdm_voutput *voutput, int flags); +} hal_tdm_func_voutput; + +typedef struct _hal_tdm_func_hwc { + hal_tdm_hwc_window *(*hwc_create_window)(hal_tdm_hwc *hwc, hal_tdm_error *error); + hal_tdm_error (*hwc_get_video_supported_formats)(hal_tdm_hwc *hwc, const tbm_format **formats, int *count); + hal_tdm_error (*hwc_get_video_available_properties)(hal_tdm_hwc *hwc, const hal_tdm_prop **props, int *count); + hal_tdm_error (*hwc_get_capabilities)(hal_tdm_hwc *hwc, hal_tdm_hwc_capability *capabilities); + hal_tdm_error (*hwc_get_available_properties)(hal_tdm_hwc *hwc, const hal_tdm_prop **props, int *count); + tbm_surface_queue_h (*hwc_get_client_target_buffer_queue)(hal_tdm_hwc *hwc, hal_tdm_error *error); + hal_tdm_error (*hwc_set_client_target_buffer)(hal_tdm_hwc *hwc, tbm_surface_h target_buffer, hal_tdm_region damage); + hal_tdm_error (*hwc_set_client_target_acquire_fence)(hal_tdm_hwc *hwc, int acquire_fence); + hal_tdm_error (*hwc_validate)(hal_tdm_hwc *hwc, hal_tdm_hwc_window **composited_wnds, uint32_t num_wnds, uint32_t *num_types); + hal_tdm_error (*hwc_get_changed_composition_types)(hal_tdm_hwc *hwc, uint32_t *num_elements, hal_tdm_hwc_window **hwc_window, hal_tdm_hwc_window_composition *composition_types); + hal_tdm_error (*hwc_accept_validation)(hal_tdm_hwc *hwc); + hal_tdm_error (*hwc_commit)(hal_tdm_hwc *hwc, int sync, void *user_data); + hal_tdm_error (*hwc_set_commit_handler)(hal_tdm_hwc *hwc, hal_tdm_hwc_commit_handler func); + hal_tdm_error (*hwc_get_commit_fence)(hal_tdm_hwc *hwc, int *commit_fence); + hal_tdm_error (*hwc_get_release_fences)(hal_tdm_hwc *hwc, uint32_t *num_elements, hal_tdm_hwc_window **hwc_windows, int *release_fences); + hal_tdm_error (*hwc_set_property)(hal_tdm_hwc *hwc, uint32_t id, hal_tdm_value value); + hal_tdm_error (*hwc_get_property)(hal_tdm_hwc *hwc, uint32_t id, hal_tdm_value *value); + hal_tdm_error (*hwc_get_commit_interval)(hal_tdm_hwc *hwc, hal_tdm_hwc_commit_interval *interval); +} hal_tdm_func_hwc; + +typedef struct _hal_tdm_func_hwc_window { + void (*hwc_window_destroy)(hal_tdm_hwc_window *hwc_window); + tbm_surface_queue_h (*hwc_window_acquire_buffer_queue)(hal_tdm_hwc_window *hwc_window, hal_tdm_error *error); + void (*hwc_window_release_buffer_queue)(hal_tdm_hwc_window *hwc_window, tbm_surface_queue_h queue); + hal_tdm_error (*hwc_window_set_composition_type)(hal_tdm_hwc_window *hwc_window, hal_tdm_hwc_window_composition composition_type); + hal_tdm_error (*hwc_window_set_buffer_damage)(hal_tdm_hwc_window *hwc_window, hal_tdm_region damage); + hal_tdm_error (*hwc_window_set_info)(hal_tdm_hwc_window *hwc_window, hal_tdm_hwc_window_info *info); + hal_tdm_error (*hwc_window_set_buffer)(hal_tdm_hwc_window *hwc_window, tbm_surface_h buffer); + hal_tdm_error (*hwc_window_set_property)(hal_tdm_hwc_window *hwc_window, uint32_t id, hal_tdm_value value); + hal_tdm_error (*hwc_window_get_property)(hal_tdm_hwc_window *hwc_window, uint32_t id, hal_tdm_value *value); + hal_tdm_error (*hwc_window_get_constraints)(hal_tdm_hwc_window *hwc_window, int *constraints); + hal_tdm_error (*hwc_window_set_name)(hal_tdm_hwc_window *hwc_window, const char *name); + hal_tdm_error (*hwc_window_set_cursor_image)(hal_tdm_hwc_window *hwc_window, int width, int height, int stride, void *ptr); + hal_tdm_error (*hwc_window_set_acquire_fence)(hal_tdm_hwc_window *hwc_window, int acquire_fence); +} hal_tdm_func_hwc_window; + +typedef struct _hal_tdm_func_pp { + void (*pp_destroy)(hal_tdm_pp *pp); + hal_tdm_error (*pp_set_info)(hal_tdm_pp *pp, hal_tdm_info_pp *info); + hal_tdm_error (*pp_attach)(hal_tdm_pp *pp, tbm_surface_h src, tbm_surface_h dst); + hal_tdm_error (*pp_commit)(hal_tdm_pp *pp); + hal_tdm_error (*pp_set_done_handler)(hal_tdm_pp *pp, hal_tdm_pp_done_handler func, void *user_data); +} hal_tdm_func_pp; + +typedef struct _hal_tdm_func_capture { + void (*capture_destroy)(hal_tdm_capture *capture); + hal_tdm_error (*capture_set_info)(hal_tdm_capture *capture, hal_tdm_info_capture *info); + hal_tdm_error (*capture_attach)(hal_tdm_capture *capture, tbm_surface_h buffer); + hal_tdm_error (*capture_commit)(hal_tdm_capture *capture); + hal_tdm_error (*capture_set_done_handler)(hal_tdm_capture *capture, hal_tdm_capture_done_handler func, void *user_data); +} hal_tdm_func_capture; + +typedef struct _hal_backend_tdm_funcs { + hal_tdm_func_display *tdm_func_display; + hal_tdm_func_output *tdm_func_output; + hal_tdm_func_voutput *tdm_func_voutput; + hal_tdm_func_hwc *tdm_func_hwc; + hal_tdm_func_hwc_window *tdm_func_hwc_window; + hal_tdm_func_pp *tdm_func_pp; + hal_tdm_func_capture *tdm_func_capture; +} hal_backend_tdm_funcs; + +hal_tdm_error hal_tdm_backend_register_func_display(hal_tdm_display *dpy, hal_tdm_func_display *func_display); +hal_tdm_error hal_tdm_backend_register_func_output(hal_tdm_display *dpy, hal_tdm_func_output *func_output); +hal_tdm_error hal_tdm_backend_register_func_voutput(hal_tdm_display *dpy, hal_tdm_func_voutput *func_voutput); +hal_tdm_error hal_tdm_backend_register_func_hwc(hal_tdm_display *dpy, hal_tdm_func_hwc *func_hwc); +hal_tdm_error hal_tdm_backend_register_func_hwc_window(hal_tdm_display *dpy, hal_tdm_func_hwc_window *func_hwc_window); +hal_tdm_error hal_tdm_backend_register_func_pp(hal_tdm_display *dpy, hal_tdm_func_pp *func_pp); +hal_tdm_error hal_tdm_backend_register_func_capture(hal_tdm_display *dpy, hal_tdm_func_capture *func_capture); + +typedef void hal_tdm_event_loop_source; +typedef hal_tdm_error (*hal_tdm_event_loop_fd_handler)(int fd, hal_tdm_event_loop_mask mask, void *user_data); +typedef hal_tdm_error (*hal_tdm_event_loop_timer_handler)(void *user_data); + +tbm_surface_h hal_tdm_buffer_ref_backend(tbm_surface_h buffer); +void hal_tdm_buffer_unref_backend(tbm_surface_h buffer); +typedef void (*hal_tdm_buffer_destroy_handler)(tbm_surface_h buffer, void *user_data); +hal_tdm_error hal_tdm_buffer_add_destroy_handler(tbm_surface_h buffer, hal_tdm_buffer_destroy_handler func, void *user_data); +void hal_tdm_buffer_remove_destroy_handler(tbm_surface_h buffer, hal_tdm_buffer_destroy_handler func, void *user_data); +hal_tdm_event_loop_source *hal_tdm_event_loop_add_fd_handler(hal_tdm_display *dpy, int fd, hal_tdm_event_loop_mask mask, + hal_tdm_event_loop_fd_handler func, void *user_data, hal_tdm_error *error); +hal_tdm_event_loop_source *hal_tdm_event_loop_add_timer_handler(hal_tdm_display *dpy, hal_tdm_event_loop_timer_handler func, + void *user_data, hal_tdm_error *error); +hal_tdm_error hal_tdm_event_loop_source_timer_update(hal_tdm_event_loop_source *source, unsigned int ms_delay); +void hal_tdm_event_loop_source_remove(hal_tdm_event_loop_source *source); + +#ifdef __cplusplus +} +#endif +#endif /* __HAL_TDM_INTERFACE__ */ diff --git a/include/hal-tdm-types.h b/include/hal-tdm-types.h new file mode 100644 index 0000000..51edf7a --- /dev/null +++ b/include/hal-tdm-types.h @@ -0,0 +1,665 @@ +/************************************************************************** + * + * hal-api-tdm + * + * Copyright 2021 Samsung Electronics co., Ltd. All Rights Reserved. + * + * Contact: SooChan Lim , + * Junkyeong Kim , + * Shawn Lee , + * Changyeon Lee , + * Joonbum Ko + * + * 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. + * +**************************************************************************/ + +#ifndef _HAL_TDM_TYPES_H_ +#define _HAL_TDM_TYPES_H_ + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @file hal-tdm-types.h + * @brief The header file which defines Enumerations and Structures for frontend and backend. + * @details + * Both frontend(@ref hal-tdm.h) and backend(@ref hal-tdm-interface.h) header files + * include @ref hal-tdm-types.h + * @par Example + * @code + * #include //for a frontend user + * @endcode + * @code + * #include //for a vendor to implement a backend module + * @endcode + */ + +#define HAL_TDM_NAME_LEN 64 +#define HAL_TDM_PATH_LEN 1024 +#define HAL_TDM_VBLANK_DEFAULT_NAME "Unknown" + +/** + * @brief The error enumeration + */ +typedef enum { + HAL_TDM_ERROR_NONE = 0, /**< none */ + HAL_TDM_ERROR_BAD_REQUEST = -1, /**< bad request */ + HAL_TDM_ERROR_OPERATION_FAILED = -2, /**< operaion failed */ + HAL_TDM_ERROR_INVALID_PARAMETER = -3, /**< wrong input parameter */ + HAL_TDM_ERROR_PERMISSION_DENIED = -4, /**< access denied */ + HAL_TDM_ERROR_BUSY = -5, /**< hardware resource busy */ + HAL_TDM_ERROR_OUT_OF_MEMORY = -6, /**< no free memory */ + HAL_TDM_ERROR_BAD_MODULE = -7, /**< bad backend module */ + HAL_TDM_ERROR_NOT_IMPLEMENTED = -8, /**< not implemented */ + HAL_TDM_ERROR_NO_CAPABILITY = -9, /**< no capability */ + HAL_TDM_ERROR_DPMS_OFF = -10, /**< dpms off */ + HAL_TDM_ERROR_OUTPUT_DISCONNECTED = -11, /**< output disconnected */ + HAL_TDM_ERROR_PROTOCOL_ERROR = -12, /**< protocol error */ + HAL_TDM_ERROR_TIMEOUT = -13, /**< timeout */ + HAL_TDM_ERROR_NO_MODULE = -14, /**< no backend module */ +} hal_tdm_error; + +/** + * @brief The transform enumeration(rotate, flip) + */ +typedef enum { + HAL_TDM_TRANSFORM_NORMAL = 0, /**< no transform */ + HAL_TDM_TRANSFORM_90 = 1, /**< rotate 90 degrees clockwise */ + HAL_TDM_TRANSFORM_180 = 2, /**< rotate 180 degrees clockwise */ + HAL_TDM_TRANSFORM_270 = 3, /**< rotate 270 degrees clockwise */ + HAL_TDM_TRANSFORM_FLIPPED = 4, /**< no rotate and horizontal flip */ + HAL_TDM_TRANSFORM_FLIPPED_90 = 5, /**< rotate 90 degrees clockwise and horizontal flip */ + HAL_TDM_TRANSFORM_FLIPPED_180 = 6, /**< rotate 180 degrees clockwise and horizontal flip */ + HAL_TDM_TRANSFORM_FLIPPED_270 = 7, /**< rotate 270 degrees clockwise and horizontal flip */ +} hal_tdm_transform; + +/** + * @brief The output capability enumeration + * @details + * If a backend module provides #HAL_TDM_OUTPUT_CAPABILITY_EXTENDED_DPMS, we can set + * an extended DPMS mode to an output which a backend module supports. + * Don't use the low-4bit for an extended DPMS mode value. It's used for default + * DPMS modes. + */ +typedef enum { + HAL_TDM_OUTPUT_CAPABILITY_ASYNC_DPMS = (1 << 0), /**< if a outupt supports asynchronous DPMS operation */ + HAL_TDM_OUTPUT_CAPABILITY_HWC = (1 << 1), /**< if a outupt supports hwc operation @since 2.0.0*/ + HAL_TDM_OUTPUT_CAPABILITY_EXTENDED_DPMS = (1 << 2), /**< if a outupt supports extended DPMS operation @since 2.0.0 */ + HAL_TDM_OUTPUT_CAPABILITY_MIRROR = (1 << 3), /**< if a outupt supports the displying mirror image of the src_output @since 2.9.0 */ +} hal_tdm_output_capability; + +/** + * @brief The pp capability enumeration + * @details The scale, transform and CSC functionalities seem the default functions of PP. + * If hardware device doesn't support one of them, we'd better let a developer know + * what a backend doesn't support like TDM_PP_CAPABILITY_NO_CSC. + */ +typedef enum { + HAL_TDM_PP_CAPABILITY_SYNC = (1 << 0), /**< The pp device supports synchronous operation */ + HAL_TDM_PP_CAPABILITY_ASYNC = (1 << 1), /**< The pp device supports asynchronous operation */ + HAL_TDM_PP_CAPABILITY_SCANOUT = (1 << 4), /**< The pp device supports only scanout buffer */ + HAL_TDM_PP_CAPABILITY_NO_CSC = (1 << 5), /**< The pp device doesn't support Color Space Conversion */ + HAL_TDM_PP_CAPABILITY_NO_TRANSFORM_ROTATION = (1 << 6), /**< The pp device doesn't support rotation transform */ +} hal_tdm_pp_capability; + +/** + * @brief The capture capability enumeration + * @details The scale, transform and CSC functionalities seem the default functions of capture. + * If hardware device doesn't support one of them, we'd better let a developer know + * what a backend doesn't support like TDM_PP_CAPABILITY_NO_CSC. + */ +typedef enum { + HAL_TDM_CAPTURE_CAPABILITY_OUTPUT = (1 << 0), /**< The capture device supports to dump a output */ + HAL_TDM_CAPTURE_CAPABILITY_LAYER = (1 << 1), /**< The capture device supports to dump a layer */ + HAL_TDM_CAPTURE_CAPABILITY_ONESHOT = (1 << 4), /**< The capture device supports oneshot dump */ + HAL_TDM_CAPTURE_CAPABILITY_STREAM = (1 << 5), /**< The capture device supports streamp sump */ +} hal_tdm_capture_capability; + +/** + * @brief The capture type enumeration + */ +typedef enum { + HAL_TDM_CAPTURE_TYPE_ONESHOT = (1 << 0), /**< The oneshot capture */ + HAL_TDM_CAPTURE_TYPE_STREAM = (1 << 1), /**< The stream capture */ +} hal_tdm_capture_type; + +/** + * @brief The output change enumeration of #tdm_output_change_handler + */ +typedef enum { + HAL_TDM_OUTPUT_CHANGE_CONNECTION = (1 << 0), /**< connection chagne */ + HAL_TDM_OUTPUT_CHANGE_DPMS = (1 << 1), /**< dpms change */ +} hal_tdm_output_change_type; + +/** + * @brief The output connection status enumeration + */ +typedef enum { + HAL_TDM_OUTPUT_CONN_STATUS_DISCONNECTED, /**< output disconnected */ + HAL_TDM_OUTPUT_CONN_STATUS_CONNECTED, /**< output connected */ + HAL_TDM_OUTPUT_CONN_STATUS_MODE_SETTED, /**< output connected and setted a mode */ +} hal_tdm_output_conn_status; + +/** + * @brief The output connection status enumeration + * @details bit compatible with the libdrm definitions. + */ +typedef enum { + HAL_TDM_OUTPUT_TYPE_Unknown, /**< unknown */ + HAL_TDM_OUTPUT_TYPE_VGA, /**< VGA connection */ + HAL_TDM_OUTPUT_TYPE_DVII, /**< DVII connection */ + HAL_TDM_OUTPUT_TYPE_DVID, /**< DVID connection */ + HAL_TDM_OUTPUT_TYPE_DVIA, /**< DVIA connection */ + HAL_TDM_OUTPUT_TYPE_Composite, /**< Composite connection */ + HAL_TDM_OUTPUT_TYPE_SVIDEO, /**< SVIDEO connection */ + HAL_TDM_OUTPUT_TYPE_LVDS, /**< LVDS connection */ + HAL_TDM_OUTPUT_TYPE_Component, /**< Component connection */ + HAL_TDM_OUTPUT_TYPE_9PinDIN, /**< 9PinDIN connection */ + HAL_TDM_OUTPUT_TYPE_DisplayPort, /**< DisplayPort connection */ + HAL_TDM_OUTPUT_TYPE_HDMIA, /**< HDMIA connection */ + HAL_TDM_OUTPUT_TYPE_HDMIB, /**< HDMIB connection */ + HAL_TDM_OUTPUT_TYPE_TV, /**< TV connection */ + HAL_TDM_OUTPUT_TYPE_eDP, /**< eDP connection */ + HAL_TDM_OUTPUT_TYPE_VIRTUAL, /**< Virtual connection for WiFi Display */ + HAL_TDM_OUTPUT_TYPE_DSI, /**< DSI connection */ +} hal_tdm_output_type; + +/** + * @brief The DPMS enumeration + * @details bit compatible with the libdrm definitions. + */ +typedef enum { + HAL_TDM_OUTPUT_DPMS_ON, /**< On, Vsync On */ + HAL_TDM_OUTPUT_DPMS_STANDBY, /**< StandBy, Vsync On */ + HAL_TDM_OUTPUT_DPMS_SUSPEND, /**< Suspend, Vsync Off */ + HAL_TDM_OUTPUT_DPMS_OFF, /**< Off, Vsync Off */ + HAL_TDM_OUTPUT_DPMS_AOD = 0x10, /**< AOD, Vsync On, extended DPMS mode */ +} hal_tdm_output_dpms; + +/** + * @brief The output mode type enumeration + * @details bit compatible with the libdrm definitions. + */ +typedef enum { + HAL_TDM_OUTPUT_MODE_TYPE_BUILTIN = (1 << 0), + HAL_TDM_OUTPUT_MODE_TYPE_CLOCK_C = ((1 << 1) | HAL_TDM_OUTPUT_MODE_TYPE_BUILTIN), + HAL_TDM_OUTPUT_MODE_TYPE_CRTC_C = ((1 << 2) | HAL_TDM_OUTPUT_MODE_TYPE_BUILTIN), + HAL_TDM_OUTPUT_MODE_TYPE_PREFERRED = (1 << 3), + HAL_TDM_OUTPUT_MODE_TYPE_DEFAULT = (1 << 4), + HAL_TDM_OUTPUT_MODE_TYPE_USERDEF = (1 << 5), + HAL_TDM_OUTPUT_MODE_TYPE_DRIVER = (1 << 6), +} hal_tdm_output_mode_type; + +/** + * @brief The output mode flag enumeration + * @details bit compatible with the libdrm definitions. + */ +typedef enum { + HAL_TDM_OUTPUT_MODE_FLAG_PHSYNC = (1 << 0), + HAL_TDM_OUTPUT_MODE_FLAG_NHSYNC = (1 << 1), + HAL_TDM_OUTPUT_MODE_FLAG_PVSYNC = (1 << 2), + HAL_TDM_OUTPUT_MODE_FLAG_NVSYNC = (1 << 3), + HAL_TDM_OUTPUT_MODE_FLAG_INTERLACE = (1 << 4), + HAL_TDM_OUTPUT_MODE_FLAG_DBLSCAN = (1 << 5), + HAL_TDM_OUTPUT_MODE_FLAG_CSYNC = (1 << 6), + HAL_TDM_OUTPUT_MODE_FLAG_PCSYNC = (1 << 7), + HAL_TDM_OUTPUT_MODE_FLAG_NCSYNC = (1 << 8), + HAL_TDM_OUTPUT_MODE_FLAG_HSKEW = (1 << 9), /* hskew provided */ + HAL_TDM_OUTPUT_MODE_FLAG_BCAST = (1 << 10), + HAL_TDM_OUTPUT_MODE_FLAG_PIXMUX = (1 << 11), + HAL_TDM_OUTPUT_MODE_FLAG_DBLCLK = (1 << 12), + HAL_TDM_OUTPUT_MODE_FLAG_CLKDIV2 = (1 << 13), +} hal_tdm_output_mode_flag; + +/* + * @brief The hwc video capability enumeration + * @since 2.7.0 + */ +typedef enum { + HAL_TDM_HWC_CAPABILITY_VIDEO_STREAM = (1 << 1), /**< if a hwc has video stream capability */ + HAL_TDM_HWC_CAPABILITY_VIDEO_SCALE = (1 << 2), /**< if a hwc allows to scale the video buffer */ + HAL_TDM_HWC_CAPABILITY_VIDEO_TRANSFORM = (1 << 3), /**< if a hwc allows video to transform the video buffer */ + HAL_TDM_HWC_CAPABILITY_VIDEO_SCANOUT = (1 << 4), /**< if a hwc allows video to accept the scanout buffer only */ + HAL_TDM_HWC_CAPABILITY_FENCE = (1 << 5), /**< if a hwc allows fence */ +} hal_tdm_hwc_capability; + +/** + * @brief The size structure + */ +typedef struct _hal_tdm_size { + unsigned int h; /**< width */ + unsigned int v; /**< height */ +} hal_tdm_size; + +/** + * @brief The pos structure + */ +typedef struct _hal_tdm_pos { + unsigned int x; + unsigned int y; + unsigned int w; + unsigned int h; +} hal_tdm_pos; + +/** + * @brief The tdm value type enumeration + */ +typedef enum { + HAL_TDM_VALUE_TYPE_UNKNOWN, + HAL_TDM_VALUE_TYPE_PTR, + HAL_TDM_VALUE_TYPE_INT32, + HAL_TDM_VALUE_TYPE_UINT32, + HAL_TDM_VALUE_TYPE_INT64, + HAL_TDM_VALUE_TYPE_UINT64, +} hal_tdm_value_type; + +/** + * @brief The value union + */ +typedef union { + void *ptr; + int32_t s32; + uint32_t u32; + int64_t s64; + uint64_t u64; +} hal_tdm_value; + +typedef enum { + HAL_TDM_EVENT_LOOP_READABLE = (1 << 0), + HAL_TDM_EVENT_LOOP_WRITABLE = (1 << 1), + HAL_TDM_EVENT_LOOP_HANGUP = (1 << 2), + HAL_TDM_EVENT_LOOP_ERROR = (1 << 3), +} hal_tdm_event_loop_mask; + +/** + * @brief The display capability enumeration + */ +typedef enum { + HAL_TDM_DISPLAY_CAPABILITY_PP = (1 << 0), /**< if hardware supports pp operation */ + HAL_TDM_DISPLAY_CAPABILITY_CAPTURE = (1 << 1), /**< if hardware supports capture operation */ +} hal_tdm_display_capability; + +/** + * @brief The display capability enumeration + */ +typedef struct _hal_tdm_caps_display { + int max_layer_count; /**< The maximum layer count */ +} hal_tdm_caps_display; + +/** + * @brief The output mode structure + */ +typedef struct _hal_tdm_output_mode { + unsigned int clock; + unsigned int hdisplay, hsync_start, hsync_end, htotal, hskew; + unsigned int vdisplay, vsync_start, vsync_end, vtotal, vscan; + unsigned int vrefresh; + unsigned int flags; + unsigned int type; + char name[HAL_TDM_NAME_LEN]; +} hal_tdm_output_mode; + +/** + * @brief The property structure + */ +typedef struct _hal_tdm_prop { + unsigned int id; + char name[HAL_TDM_NAME_LEN]; + hal_tdm_value_type type; +} hal_tdm_prop; + +/** + * @brief The info config structure + */ +typedef struct _hal_tdm_info_config { + hal_tdm_size size; + hal_tdm_pos pos; + tbm_format format; +} hal_tdm_info_config; + +/** + * @brief The region structure + */ +typedef struct _hal_tdm_region { + unsigned int num_rects; + hal_tdm_pos const *rects; +} hal_tdm_region; + +/** + * @brief The hwc window info structure + */ +typedef struct _hal_tdm_hwc_window_info { + hal_tdm_info_config src_config; + hal_tdm_pos dst_pos; + hal_tdm_transform transform; +} hal_tdm_hwc_window_info; + +/** + * @brief The pp info structre + */ +typedef struct _hal_tdm_info_pp { + hal_tdm_info_config src_config; + hal_tdm_info_config dst_config; + hal_tdm_transform transform; + int sync; + int flags; +} hal_tdm_info_pp; + +/** + * @brief The capture info structre + */ +typedef struct _hal_tdm_info_capture { + hal_tdm_info_config dst_config; + hal_tdm_transform transform; + hal_tdm_capture_type type; + int frequency; + int flags; +} hal_tdm_info_capture; + +/** + * @brief Possible composition types for a given window + */ +typedef enum { + + /** The composition type for an invisible window. The value by default. + * + * The backend ignores windows of this type. + */ + HAL_TDM_HWC_WIN_COMPOSITION_NONE = 0, + + /** The compostion type for an window to be compsoited by the client. + * + * When the client sets this composition type, + * the backend MUST NOT modify this composition type into other types. + * + * When the backend changes TDM_HWC_WIN_COMPOSITION_DEVICE or TDM_HWC_WIN_COMPOSITION_CURSOR + * to this composition type at the time of tdm_hwc_validate and + * tdm_hwc_get_changed_composition_types, + * the client has to composite this window with gl or other drawing operations. + */ + HAL_TDM_HWC_WIN_COMPOSITION_CLIENT = 1, + + /** The compostion type for an window to be set to the hw overlay. + * + * The client sets this composition type to the visible windows before requesting + * the tdm_hwc_validate. + * Nomally, the backend leave it if the backend sets the window to the hw overlay. + * If the backend does not set the window to the hw overlay at the time of + * tdm_hwc_validate, the backend changes the composition type of the window into + * TDM_HWC_WIN_COMPOSITION_CLIENT. + */ + HAL_TDM_HWC_WIN_COMPOSITION_DEVICE = 3, + + /** The compostion type for an window to be set to the cursor hw overlay. + * + * The client sets this composition type to the cursor window before requesting + * the tdm_hwc_validate. + * If the backend does not support the cursor hw overlay, the backend can change + * the comopsition type into the TDM_HWC_WIN_COMPOSITION_CLIENT. + */ + HAL_TDM_HWC_WIN_COMPOSITION_CURSOR = 4, + + /** The compostion type for an window to be set to the video hw overlay. + * + * The client sets this composition type to the video window before requesting + * the tdm_hwc_validate. + * If the backend does not support the video hw overlay, the backend can change + * the comopsition type into the TDM_HWC_WIN_COMPOSITION_CLIENT. + * Normally, this VIDEO window displays under the primary hw overlayer of the output. + */ + HAL_TDM_HWC_WIN_COMPOSITION_VIDEO = 5, +} hal_tdm_hwc_window_composition; + +typedef enum { + HAL_TDM_HWC_WIN_CONSTRAINT_NONE = 0, + /** If the client needs to render to a specific buffer for compositing + * with TDM_HWC_WIN_COMPOSITION_DEVICE, the backend needs to set + * TDM_HWC_WIN_CONSTRAINT_BUFFER_QUEUE to hwc_window until the hwc_window is not + * TDM_HWC_WIN_COMPOSITION_DEVICE. The client gets the tbm_surface_queue_h through + * the tdm_hwc_window_aquire_buffer_queue. It will render the frames on + * the buffers which gets from the tbm_surface_queue_h. + */ + HAL_TDM_HWC_WIN_CONSTRAINT_BUFFER_QUEUE = (1 << 0), +} hal_tdm_hwc_window_constraint; + +typedef enum { + HAL_TDM_HWC_COMMIT_INTERVAL_NONE = 0, + /** If this interval is set by tdm backend, the compositor call commit per vblank + * even if the handler of commit isn't called. + */ + HAL_TDM_HWC_COMMIT_INTERVAL_VBLANK = 1, +} hal_tdm_hwc_commit_interval; + +/** + * @brief The tdm display object + */ +typedef void hal_tdm_display; + +/** + * @brief The tdm backend object + */ +typedef void hal_tdm_module; + +/** + * @brief The tdm output object + */ +typedef void hal_tdm_output; + +/** + * @brief The tdm voutput object + */ +typedef void hal_tdm_voutput; + +/** + * @brief The tdm hwc object + */ +typedef void hal_tdm_hwc; + +/** + * @brief The tdm hwc window object + */ +typedef void hal_tdm_hwc_window; + +/** + * @brief The tdm capture object + */ +typedef void hal_tdm_capture; + +/** + * @brief The tdm pp object + */ +typedef void hal_tdm_pp; + +/** + * @brief The tdm vblank object + */ +typedef void hal_tdm_vblank; + +/** + * @brief The tdm backend object + */ +typedef void hal_tdm_backend_data; + +/** + * @brief The output create handler + * @details This handler will be called when the output object is + * createed in runtime. + */ +typedef void (*hal_tdm_output_create_handler)(hal_tdm_display *dpy, hal_tdm_output *output, void *user_data); + +/** + * @brief The output destroy handler + * @details This handler will be called when the output object is + * destroied in runtime. + */ +typedef void (*hal_tdm_output_destroy_handler)(hal_tdm_output *output, void *user_data); + +/** + * @brief The output change handler + * @details This handler will be called when the status of a output object is + * changed in runtime. + */ +typedef void (*hal_tdm_output_change_handler)(hal_tdm_output *output, + hal_tdm_output_change_type type, + hal_tdm_value value, + void *user_data); + +/** + * @brief The vblank handler + * @see output_set_vblank_handler() function of #hal_tdm_func_display + */ +typedef void (*hal_tdm_output_vblank_handler)(hal_tdm_output *output, unsigned int sequence, + unsigned int tv_sec, unsigned int tv_usec, + void *user_data); + +/** + * @brief The output commit handler + * @see output_set_commit_handler() function of #hal_tdm_func_display + */ +typedef void (*hal_tdm_output_commit_handler)(hal_tdm_output *output, unsigned int sequence, + unsigned int tv_sec, unsigned int tv_usec, + void *user_data); + +/** + * @brief The output mode change request handler + */ +typedef void (*hal_tdm_output_mode_change_request_handler)(hal_tdm_output *output, + unsigned int index, void *user_data); + +/** + * @brief The output status handler + */ +typedef void (*hal_tdm_output_status_handler)(hal_tdm_output *output, + hal_tdm_output_conn_status status, void *user_data); + +/** + * @brief The output dpms handler + */ +typedef void (*hal_tdm_output_dpms_handler)(hal_tdm_output *output, + hal_tdm_output_dpms dpms, void *user_data); + +/** + * @brief The done handler of a pp object + */ +typedef void (*hal_tdm_pp_done_handler)(hal_tdm_pp *pp, tbm_surface_h src, + tbm_surface_h dst, void *user_data); + +/** + * @brief The done handler of a capture object + */ +typedef void (*hal_tdm_capture_done_handler)(hal_tdm_capture *capture, + tbm_surface_h buffer, void *user_data); + +/** + * @brief The create handler of a vblank object + */ +typedef void (*hal_tdm_vblank_create_handler)(hal_tdm_vblank *vblank, void *user_data); + +/** + * @brief The hwc commit handler + * @see hwc_set_commit_handler() function of #hal_tdm_func_hwc + */ +typedef void (*hal_tdm_hwc_commit_handler)(hal_tdm_hwc *hwc, unsigned int sequence, + unsigned int tv_sec, unsigned int tv_usec, + void *user_data); + +/** + * @brief The voutput commit handler + */ +typedef void (*hal_tdm_voutput_commit_handler)(hal_tdm_voutput *voutput, unsigned int sequence, + unsigned int tv_sec, unsigned int tv_usec, + void *user_data); + +/** + * @brief The voutput commit function + */ +typedef void (*hal_tdm_voutput_commit_func)(hal_tdm_voutput *voutput, tbm_surface_h buffer); + + +typedef struct _hal_tdm_caps_output { + char maker[HAL_TDM_NAME_LEN]; /**< The output maker */ + char model[HAL_TDM_NAME_LEN]; /**< The output model */ + char name[HAL_TDM_NAME_LEN]; /**< The output name */ + + hal_tdm_output_conn_status status; /**< The connection status */ + hal_tdm_output_type type; /**< The connection type */ + unsigned int type_id; /**< The connection type id */ + + unsigned int mode_count; /**< The count of available modes */ + hal_tdm_output_mode *modes; /**< The @b newly-allocated array of modes. will be freed in frontend. */ + + unsigned int prop_count; /**< The count of available properties */ + hal_tdm_prop *props; /**< The @b newly-allocated array of properties. will be freed in frontend. */ + + unsigned int mmWidth; /**< The physical width (milimeter) */ + unsigned int mmHeight; /**< The physical height (milimeter) */ + unsigned int subpixel; /**< The subpixel */ + + int min_w; /**< The minimun width */ + int min_h; /**< The minimun height */ + int max_w; /**< The maximum width */ + int max_h; /**< The maximum height */ + int preferred_align; /**< The prefered align */ + + hal_tdm_output_capability capabilities; /**< The capabilities of output. @since 1.4.1 */ + + int cursor_min_w; /**< The minimun width. @since 1.5.0 */ + int cursor_min_h; /**< The minimun height. @since 1.5.0 */ + int cursor_max_w; /**< The maximum width. @since 1.5.0 */ + int cursor_max_h; /**< The maximum height. @since 1.5.0 */ + int cursor_preferred_align; /**< The prefered align. @since 1.5.0 */ +} hal_tdm_caps_output; + +typedef struct _hal_tdm_caps_pp { + hal_tdm_pp_capability capabilities; /**< The capabilities of pp */ + unsigned int format_count; /**< The count of available formats */ + tbm_format *formats; /**< The @b newly-allocated array. will be freed in frontend. */ + int min_w; /**< The minimun width */ + int min_h; /**< The minimun height */ + int max_w; /**< The maximum width */ + int max_h; /**< The maximum height */ + int preferred_align; /**< The prefered align */ + int preferred_align_vertical; /**< The prefered align vertical */ + int max_attach_count; /**< The attach count which a PP object can handle. */ +} hal_tdm_caps_pp; + +typedef struct _hal_tdm_caps_capture { + hal_tdm_capture_capability capabilities; /**< The capabilities of capture */ + unsigned int format_count; /**< The count of available formats */ + tbm_format *formats; /**< The @b newly-allocated array of formats. will be freed in frontend. */ + int min_w; /**< The minimun width */ + int min_h; /**< The minimun height */ + int max_w; /**< The maximum width */ + int max_h; /**< The maximum height */ + int preferred_align; /**< The prefered align */ + int max_attach_count; /**< The attach count which a capture object can handle. */ +} hal_tdm_caps_capture; + +#ifdef __cplusplus +} +#endif + +#endif /* _HAL_TDM_TYPES_H_ */ diff --git a/include/hal-tdm.h b/include/hal-tdm.h new file mode 100644 index 0000000..31169fc --- /dev/null +++ b/include/hal-tdm.h @@ -0,0 +1,140 @@ +/************************************************************************** + * + * hal-api-tdm + * + * Copyright 2021 Samsung Electronics co., Ltd. All Rights Reserved. + * + * Contact: SooChan Lim , + * Junkyeong Kim , + * Shawn Lee , + * Changyeon Lee , + * Joonbum Ko + * + * 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. + * +**************************************************************************/ + +#ifndef __HAL_TDM__ +#define __HAL_TDM__ + +#ifdef __cplusplus +extern "C" { +#endif + +#include "hal-tdm-types.h" + +hal_tdm_error hal_tdm_get_backend(hal_tdm_display *dpy); +void hal_tdm_put_backend(void); + +/* tdm_func_display */ +hal_tdm_error hal_tdm_display_get_capability(hal_tdm_backend_data *bdata, hal_tdm_caps_display *caps); +hal_tdm_error hal_tdm_display_get_pp_capability(hal_tdm_backend_data *bdata, hal_tdm_caps_pp *caps); +hal_tdm_error hal_tdm_display_get_capture_capability(hal_tdm_backend_data *bdata, hal_tdm_caps_capture *caps); +hal_tdm_output **hal_tdm_display_get_outputs(hal_tdm_backend_data *bdata, int *count, hal_tdm_error *error); +hal_tdm_error hal_tdm_display_get_fd(hal_tdm_backend_data *bdata, int *fd); +hal_tdm_error hal_tdm_display_handle_events(hal_tdm_backend_data *bdata); +hal_tdm_pp *hal_tdm_display_create_pp(hal_tdm_backend_data *bdata, hal_tdm_error *error); +hal_tdm_voutput *hal_tdm_display_voutput_create(hal_tdm_backend_data *bdata, const char *name, hal_tdm_error *error); + +/* tdm_func_output */ +hal_tdm_error hal_tdm_output_get_capability(hal_tdm_output *output, hal_tdm_caps_output *caps); +hal_tdm_error hal_tdm_output_set_property(hal_tdm_output *output, unsigned int id, hal_tdm_value value); +hal_tdm_error hal_tdm_output_get_property(hal_tdm_output *output, unsigned int id, hal_tdm_value *value); +hal_tdm_error hal_tdm_output_wait_vblank(hal_tdm_output *output, int interval, int sync, void *user_data); +hal_tdm_error hal_tdm_output_set_vblank_handler(hal_tdm_output *output, hal_tdm_output_vblank_handler func); +hal_tdm_error hal_tdm_output_commit(hal_tdm_output *output, int sync, void *user_data); +hal_tdm_error hal_tdm_output_set_commit_handler(hal_tdm_output *output, hal_tdm_output_commit_handler func); +hal_tdm_error hal_tdm_output_set_dpms(hal_tdm_output *output, hal_tdm_output_dpms dpms_value); +hal_tdm_error hal_tdm_output_get_dpms(hal_tdm_output *output, hal_tdm_output_dpms *dpms_value); +hal_tdm_error hal_tdm_output_set_mode(hal_tdm_output *output, const hal_tdm_output_mode *mode); +hal_tdm_error hal_tdm_output_get_mode(hal_tdm_output *output, const hal_tdm_output_mode **mode); +hal_tdm_capture *hal_tdm_output_create_capture(hal_tdm_output *output, hal_tdm_error *error); +hal_tdm_error hal_tdm_output_set_status_handler(hal_tdm_output *output, hal_tdm_output_status_handler func, void *user_data); +hal_tdm_error hal_tdm_output_set_dpms_handler(hal_tdm_output *output, hal_tdm_output_dpms_handler func, void *user_data); +hal_tdm_error hal_tdm_output_set_dpms_async(hal_tdm_output *output, hal_tdm_output_dpms dpms_value, int *sync); +hal_tdm_hwc *hal_tdm_output_get_hwc(hal_tdm_output *output, hal_tdm_error *error); +hal_tdm_error hal_tdm_output_set_mirror(hal_tdm_output *output, hal_tdm_output *src_output, hal_tdm_transform transform); +hal_tdm_error hal_tdm_output_unset_mirror(hal_tdm_output *output); + +/* tdm_func_voutput */ +hal_tdm_error hal_tdm_voutput_destroy(hal_tdm_voutput *voutput); +hal_tdm_error hal_tdm_voutput_set_available_mode(hal_tdm_voutput *voutput, const hal_tdm_output_mode *modes, int count); +hal_tdm_error hal_tdm_voutput_set_physical_size(hal_tdm_voutput *voutput, unsigned int mmwidth, unsigned int mmheight); +hal_tdm_error hal_tdm_voutput_connect(hal_tdm_voutput *voutput); +hal_tdm_error hal_tdm_voutput_disconnect(hal_tdm_voutput *voutput); +hal_tdm_output *hal_tdm_voutput_get_output(hal_tdm_voutput *voutput, hal_tdm_error *error); +hal_tdm_error hal_tdm_voutput_set_commit_func(hal_tdm_voutput *voutput, hal_tdm_voutput_commit_handler commit_func); +hal_tdm_error hal_tdm_voutput_commit_done(hal_tdm_voutput *voutput); +hal_tdm_error hal_tdm_voutput_set_target_buffer_queue_flag(hal_tdm_voutput *voutput, int flags); + +/* tdm_func_hwc */ +hal_tdm_hwc_window *hal_tdm_hwc_create_window(hal_tdm_hwc *hwc, hal_tdm_error *error); +hal_tdm_error hal_tdm_hwc_get_video_supported_formats(hal_tdm_hwc *hwc, const tbm_format **formats, int *count); +hal_tdm_error hal_tdm_hwc_get_video_available_properties(hal_tdm_hwc *hwc, const hal_tdm_prop **props, int *count); +hal_tdm_error hal_tdm_hwc_get_capabilities(hal_tdm_hwc *hwc, hal_tdm_hwc_capability *capabilities); +hal_tdm_error hal_tdm_hwc_get_available_properties(hal_tdm_hwc *hwc, const hal_tdm_prop **props, int *count); +tbm_surface_queue_h hal_tdm_hwc_get_client_target_buffer_queue(hal_tdm_hwc *hwc, hal_tdm_error *error); +hal_tdm_error hal_tdm_hwc_set_client_target_buffer(hal_tdm_hwc *hwc, tbm_surface_h target_buffer, hal_tdm_region damage); +hal_tdm_error hal_tdm_hwc_set_client_target_acquire_fence(hal_tdm_hwc *hwc, int acquire_fence); +hal_tdm_error hal_tdm_hwc_validate(hal_tdm_hwc *hwc, hal_tdm_hwc_window **composited_wnds, uint32_t num_wnds, uint32_t *num_types); +hal_tdm_error hal_tdm_hwc_get_changed_composition_types(hal_tdm_hwc *hwc, uint32_t *num_elements, hal_tdm_hwc_window **hwc_window, hal_tdm_hwc_window_composition *composition_types); +hal_tdm_error hal_tdm_hwc_accept_validation(hal_tdm_hwc *hwc); +hal_tdm_error hal_tdm_hwc_commit(hal_tdm_hwc *hwc, int sync, void *user_data); +hal_tdm_error hal_tdm_hwc_set_commit_handler(hal_tdm_hwc *hwc, hal_tdm_hwc_commit_handler func); +hal_tdm_error hal_tdm_hwc_get_commit_fence(hal_tdm_hwc *hwc, int *commit_fence); +hal_tdm_error hal_tdm_hwc_get_release_fences(hal_tdm_hwc *hwc, uint32_t *num_elements, hal_tdm_hwc_window **hwc_windows, int *release_fences); +hal_tdm_error hal_tdm_hwc_set_property(hal_tdm_hwc *hwc, uint32_t id, hal_tdm_value value); +hal_tdm_error hal_tdm_hwc_get_property(hal_tdm_hwc *hwc, uint32_t id, hal_tdm_value *value); +hal_tdm_error hal_tdm_hwc_get_commit_interval(hal_tdm_hwc *hwc, hal_tdm_hwc_commit_interval *interval); + +/* tdm_func_hwc_window */ +void hal_tdm_hwc_window_destroy(hal_tdm_hwc_window *hwc_window); +tbm_surface_queue_h hal_tdm_hwc_window_acquire_buffer_queue(hal_tdm_hwc_window *hwc_window, hal_tdm_error *error); +void hal_tdm_hwc_window_release_buffer_queue(hal_tdm_hwc_window *hwc_window, tbm_surface_queue_h queue); +hal_tdm_error hal_tdm_hwc_window_set_composition_type(hal_tdm_hwc_window *hwc_window, hal_tdm_hwc_window_composition composition_type); +hal_tdm_error hal_tdm_hwc_window_set_buffer_damage(hal_tdm_hwc_window *hwc_window, hal_tdm_region damage); +hal_tdm_error hal_tdm_hwc_window_set_info(hal_tdm_hwc_window *hwc_window, hal_tdm_hwc_window_info *info); +hal_tdm_error hal_tdm_hwc_window_set_buffer(hal_tdm_hwc_window *hwc_window, tbm_surface_h buffer); +hal_tdm_error hal_tdm_hwc_window_set_property(hal_tdm_hwc_window *hwc_window, uint32_t id, hal_tdm_value value); +hal_tdm_error hal_tdm_hwc_window_get_property(hal_tdm_hwc_window *hwc_window, uint32_t id, hal_tdm_value *value); +hal_tdm_error hal_tdm_hwc_window_get_constraints(hal_tdm_hwc_window *hwc_window, int *constraints); +hal_tdm_error hal_tdm_hwc_window_set_name(hal_tdm_hwc_window *hwc_window, const char *name); +hal_tdm_error hal_tdm_hwc_window_set_cursor_image(hal_tdm_hwc_window *hwc_window, int width, int height, int stride, void *ptr); +hal_tdm_error hal_tdm_hwc_window_set_acquire_fence(hal_tdm_hwc_window *hwc_window, int acquire_fence); + +/* tdm_func_pp */ +void hal_tdm_pp_destroy(hal_tdm_pp *pp); +hal_tdm_error hal_tdm_pp_set_info(hal_tdm_pp *pp, hal_tdm_info_pp *info); +hal_tdm_error hal_tdm_pp_attach(hal_tdm_pp *pp, tbm_surface_h src, tbm_surface_h dst); +hal_tdm_error hal_tdm_pp_commit(hal_tdm_pp *pp); +hal_tdm_error hal_tdm_pp_set_done_handler(hal_tdm_pp *pp, hal_tdm_pp_done_handler func, void *user_data); + +/* tdm_func_capture */ +void hal_tdm_capture_destroy(hal_tdm_capture *capture); +hal_tdm_error hal_tdm_capture_set_info(hal_tdm_capture *capture, hal_tdm_info_capture *info); +hal_tdm_error hal_tdm_capture_attach(hal_tdm_capture *capture, tbm_surface_h buffer); +hal_tdm_error hal_tdm_capture_commit(hal_tdm_capture *capture); +hal_tdm_error hal_tdm_capture_set_done_handler(hal_tdm_capture *capture, hal_tdm_capture_done_handler func, void *user_data); + +#ifdef __cplusplus +} +#endif +#endif /* __HAL_TDM__ */ diff --git a/packaging/hal-api-tdm-devel.manifest b/packaging/hal-api-tdm-devel.manifest new file mode 100644 index 0000000..81ace0c --- /dev/null +++ b/packaging/hal-api-tdm-devel.manifest @@ -0,0 +1,6 @@ + + + + + + diff --git a/packaging/hal-api-tdm.manifest b/packaging/hal-api-tdm.manifest new file mode 100644 index 0000000..81ace0c --- /dev/null +++ b/packaging/hal-api-tdm.manifest @@ -0,0 +1,6 @@ + + + + + + diff --git a/packaging/hal-api-tdm.spec b/packaging/hal-api-tdm.spec new file mode 100644 index 0000000..e74b0b9 --- /dev/null +++ b/packaging/hal-api-tdm.spec @@ -0,0 +1,71 @@ +%define module_name tdm +%define name hal-api-tdm +%define devel_name hal-api-tdm-devel + +### main package ######### +Name: %{name} +Summary: %{name} interface +Version: 0.0.1 +Release: 1 +Group: Development/Libraries +License: MIT +Source0: %{name}-%{version}.tar.gz +Source1: %{name}.manifest +Source2: %{devel_name}.manifest + +Requires(post): /sbin/ldconfig +Requires(postun): /sbin/ldconfig +BuildRequires: cmake +BuildRequires: pkgconfig(dlog) +BuildRequires: pkgconfig(gmock) +BuildRequires: pkgconfig(hal-api-common) +BuildRequires: pkgconfig(libtbm) + +%description +%{name} interface + +### devel package ######### +%package -n %{devel_name} +Summary: %{name} interface +Group: Development/Libraries +Requires: %{name} = %{version}-%{release} + +%description -n %{devel_name} +%{name} Interface for product vendor developer + +### build and install ######### +%prep +%setup -q + +cmake . -DCMAKE_INSTALL_PREFIX=%{_prefix} -DCMAKE_LIBDIR_PREFIX=%{_libdir}/ + +%build +cp %{SOURCE1} . +cp %{SOURCE2} . +make %{?jobs:-j%jobs} + +%install +rm -rf %{buildroot} +%make_install + +%clean +rm -rf %{buildroot} + +%post +/sbin/ldconfig + +%postun +/sbin/ldconfig + +### contain files to package ######### +%files -n %{name} +%manifest %{name}.manifest +%license COPYING +%defattr(-,root,root,-) +%{_libdir}/hal/*.so* + +%files -n %{devel_name} +%defattr(-,root,root,-) +%manifest %{devel_name}.manifest +%{_includedir}/hal/*.h +%{_libdir}/pkgconfig/%{name}.pc diff --git a/src/common.h b/src/common.h new file mode 100644 index 0000000..419d506 --- /dev/null +++ b/src/common.h @@ -0,0 +1,44 @@ +/************************************************************************** + * + * hal-api-tdm + * + * Copyright 2021 Samsung Electronics co., Ltd. All Rights Reserved. + * + * Contact: SooChan Lim , + * Junkyeong Kim , + * Shawn Lee , + * Changyeon Lee , + * Joonbum Ko + * + * 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. + * +**************************************************************************/ + +#ifndef __COMMON_H__ +#define __COMMON_H__ + +#include +#define _D(fmt, args...) SLOGD(fmt, ##args) +#define _I(fmt, args...) SLOGI(fmt, ##args) +#define _W(fmt, args...) SLOGW(fmt, ##args) +#define _E(fmt, args...) SLOGE(fmt, ##args) + +#endif /* __COMMON_H__ */ diff --git a/src/hal-api-tdm.c b/src/hal-api-tdm.c new file mode 100644 index 0000000..05ec556 --- /dev/null +++ b/src/hal-api-tdm.c @@ -0,0 +1,878 @@ +/************************************************************************** + * + * hal-api-tdm + * + * Copyright 2021 Samsung Electronics co., Ltd. All Rights Reserved. + * + * Contact: SooChan Lim , + * Junkyeong Kim , + * Shawn Lee , + * Changyeon Lee , + * Joonbum Ko + * + * 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. + * +**************************************************************************/ + +#include +#include +#include +#include +#include + +#include +#include "hal-tdm-interface.h" +#include "hal-tdm.h" +#include "common.h" + +#if defined(__GNUC__) && __GNUC__ >= 4 +#define EXTERN __attribute__ ((visibility("default"))) +#else +#define EXTERN +#endif + +#if defined(__GNUC__) && __GNUC__ >= 4 +#define INTERN __attribute__ ((visibility("hidden"))) +#else +#define INTERN +#endif + +#define ARRAY_SIZE(name) (sizeof(name)/sizeof(name[0])) + +#define DISPLAY_FUNC_ENTRY(__func__) \ + hal_tdm_func_display *func_display; \ + if (!g_tdm_funcs) return HAL_TDM_ERROR_NO_MODULE; \ + if (!g_tdm_funcs->tdm_func_display) return HAL_TDM_ERROR_NOT_IMPLEMENTED; \ + func_display = g_tdm_funcs->tdm_func_display; \ + if (!func_display->__func__) return HAL_TDM_ERROR_NOT_IMPLEMENTED; + +#define DISPLAY_FUNC_ENTRY_NULL(__func__) \ + hal_tdm_func_display *func_display; \ + if (!g_tdm_funcs) { if (*error) *error = HAL_TDM_ERROR_NO_MODULE; return NULL; } \ + if (!g_tdm_funcs->tdm_func_display) { if (*error) *error = HAL_TDM_ERROR_NOT_IMPLEMENTED; return NULL; } \ + func_display = g_tdm_funcs->tdm_func_display; \ + if (!func_display->__func__) { if (*error) *error = HAL_TDM_ERROR_NOT_IMPLEMENTED; return NULL; }; + +#define OUTPUT_FUNC_ENTRY(__func__) \ + hal_tdm_func_output *func_output; \ + if (!g_tdm_funcs) return HAL_TDM_ERROR_NO_MODULE; \ + if (!g_tdm_funcs->tdm_func_output) return HAL_TDM_ERROR_NOT_IMPLEMENTED; \ + func_output = g_tdm_funcs->tdm_func_output; \ + if (!func_output->__func__) return HAL_TDM_ERROR_NOT_IMPLEMENTED; + +#define OUTPUT_FUNC_ENTRY_NULL(__func__) \ + hal_tdm_func_output *func_output; \ + if (!g_tdm_funcs) { if (*error) *error = HAL_TDM_ERROR_NO_MODULE; return NULL; } \ + if (!g_tdm_funcs->tdm_func_output) { if (*error) *error = HAL_TDM_ERROR_NOT_IMPLEMENTED; return NULL; } \ + func_output = g_tdm_funcs->tdm_func_output; \ + if (!func_output->__func__) { if (*error) *error = HAL_TDM_ERROR_NOT_IMPLEMENTED; return NULL; }; + +#define VOUTPUT_FUNC_ENTRY(__func__) \ + hal_tdm_func_voutput *func_voutput; \ + if (!g_tdm_funcs) return HAL_TDM_ERROR_NO_MODULE; \ + if (!g_tdm_funcs->tdm_func_voutput) return HAL_TDM_ERROR_NOT_IMPLEMENTED; \ + func_voutput = g_tdm_funcs->tdm_func_voutput; \ + if (!func_voutput->__func__) return HAL_TDM_ERROR_NOT_IMPLEMENTED; + +#define VOUTPUT_FUNC_ENTRY_NULL(__func__) \ + hal_tdm_func_voutput *func_voutput; \ + if (!g_tdm_funcs) { if (*error) *error = HAL_TDM_ERROR_NO_MODULE; return NULL; } \ + if (!g_tdm_funcs->tdm_func_voutput) { if (*error) *error = HAL_TDM_ERROR_NOT_IMPLEMENTED; return NULL; } \ + func_voutput = g_tdm_funcs->tdm_func_voutput; \ + if (!func_voutput->__func__) { if (*error) *error = HAL_TDM_ERROR_NOT_IMPLEMENTED; return NULL; }; + +#define HWC_FUNC_ENTRY(__func__) \ + hal_tdm_func_hwc *func_hwc; \ + if (!g_tdm_funcs) return HAL_TDM_ERROR_NO_MODULE; \ + if (!g_tdm_funcs->tdm_func_hwc) return HAL_TDM_ERROR_NOT_IMPLEMENTED; \ + func_hwc = g_tdm_funcs->tdm_func_hwc; \ + if (!func_hwc->__func__) return HAL_TDM_ERROR_NOT_IMPLEMENTED; + +#define HWC_FUNC_ENTRY_NULL(__func__) \ + hal_tdm_func_hwc *func_hwc; \ + if (!g_tdm_funcs) { if (*error) *error = HAL_TDM_ERROR_NO_MODULE; return NULL; } \ + if (!g_tdm_funcs->tdm_func_hwc) { if (*error) *error = HAL_TDM_ERROR_NOT_IMPLEMENTED; return NULL; } \ + func_hwc = g_tdm_funcs->tdm_func_hwc; \ + if (!func_hwc->__func__) { if (*error) *error = HAL_TDM_ERROR_NOT_IMPLEMENTED; return NULL; }; + +#define HWC_WINDOW_FUNC_ENTRY(__func__) \ + hal_tdm_func_hwc_window *func_hwc_window; \ + if (!g_tdm_funcs) return HAL_TDM_ERROR_NO_MODULE; \ + if (!g_tdm_funcs->tdm_func_hwc_window) return HAL_TDM_ERROR_NOT_IMPLEMENTED; \ + func_hwc_window = g_tdm_funcs->tdm_func_hwc_window; \ + if (!func_hwc_window->__func__) return HAL_TDM_ERROR_NOT_IMPLEMENTED; + +#define HWC_WINDOW_FUNC_ENTRY_NULL(__func__) \ + hal_tdm_func_hwc_window *func_hwc_window; \ + if (!g_tdm_funcs) { if (*error) *error = HAL_TDM_ERROR_NO_MODULE; return NULL; } \ + if (!g_tdm_funcs->tdm_func_hwc_window) { if (*error) *error = HAL_TDM_ERROR_NOT_IMPLEMENTED; return NULL; } \ + func_hwc_window = g_tdm_funcs->tdm_func_hwc_window; \ + if (!func_hwc_window->__func__) { if (*error) *error = HAL_TDM_ERROR_NOT_IMPLEMENTED; return NULL; }; + +#define HWC_WINDOW_FUNC_ENTRY_VOID(__func__) \ + hal_tdm_func_hwc_window *func_hwc_window; \ + if (!g_tdm_funcs) return; \ + if (!g_tdm_funcs->tdm_func_hwc_window) return; \ + func_hwc_window = g_tdm_funcs->tdm_func_hwc_window; \ + if (!func_hwc_window->__func__) return; + +#define PP_FUNC_ENTRY(__func__) \ + hal_tdm_func_pp *func_pp; \ + if (!g_tdm_funcs) return HAL_TDM_ERROR_NO_MODULE; \ + if (!g_tdm_funcs->tdm_func_pp) return HAL_TDM_ERROR_NOT_IMPLEMENTED; \ + func_pp = g_tdm_funcs->tdm_func_pp; \ + if (!func_pp->__func__) return HAL_TDM_ERROR_NOT_IMPLEMENTED; + +#define PP_FUNC_ENTRY_VOID(__func__) \ + hal_tdm_func_pp *func_pp; \ + if (!g_tdm_funcs) return; \ + if (!g_tdm_funcs->tdm_func_pp) return; \ + func_pp = g_tdm_funcs->tdm_func_pp; \ + if (!func_pp->__func__) return; + +#define CAPTURE_FUNC_ENTRY(__func__) \ + hal_tdm_func_capture *func_capture; \ + if (!g_tdm_funcs) return HAL_TDM_ERROR_NO_MODULE; \ + if (!g_tdm_funcs->tdm_func_capture) return HAL_TDM_ERROR_NOT_IMPLEMENTED; \ + func_capture = g_tdm_funcs->tdm_func_capture; \ + if (!func_capture->__func__) return HAL_TDM_ERROR_NOT_IMPLEMENTED; + +#define CAPTURE_FUNC_ENTRY_VOID(__func__) \ + hal_tdm_func_capture *func_capture; \ + if (!g_tdm_funcs) return; \ + if (!g_tdm_funcs->tdm_func_capture) return; \ + func_capture = g_tdm_funcs->tdm_func_capture; \ + if (!func_capture->__func__) return; + +static hal_backend_tdm_funcs *g_tdm_funcs = NULL; + +EXTERN hal_tdm_error +hal_tdm_get_backend(hal_tdm_display *dpy) +{ + int ret; + + if (!dpy) + return HAL_TDM_ERROR_INVALID_PARAMETER; + + if (g_tdm_funcs) + return HAL_TDM_ERROR_BAD_REQUEST; + + g_tdm_funcs = calloc(1, sizeof(hal_backend_tdm_funcs)); + if (!g_tdm_funcs) + return HAL_TDM_ERROR_OUT_OF_MEMORY; + + ret = hal_common_get_backend(HAL_MODULE_TDM, (void **)&dpy); + if (ret < 0) { + _E("Failed to get backend\n"); + free(g_tdm_funcs); + g_tdm_funcs = NULL; + return HAL_TDM_ERROR_NO_MODULE; + } + + _I("hal_tdm_get_backend"); + + return HAL_TDM_ERROR_NONE; +} + +EXTERN void +hal_tdm_put_backend(void) +{ + if (!g_tdm_funcs) + return; + + hal_common_put_backend(HAL_MODULE_TDM, NULL); + free(g_tdm_funcs); + g_tdm_funcs = NULL; + + _I("hal_tdm_put_backend"); +} + +/* tdm_func_display */ +EXTERN hal_tdm_error +hal_tdm_display_get_capability(hal_tdm_backend_data *bdata, hal_tdm_caps_display *caps) +{ + DISPLAY_FUNC_ENTRY(display_get_capability); + return func_display->display_get_capability(bdata, caps); +} + +EXTERN hal_tdm_error +hal_tdm_display_get_pp_capability(hal_tdm_backend_data *bdata, hal_tdm_caps_pp *caps) +{ + DISPLAY_FUNC_ENTRY(display_get_pp_capability); + return func_display->display_get_pp_capability(bdata, caps); +} + +EXTERN hal_tdm_error +hal_tdm_display_get_capture_capability(hal_tdm_backend_data *bdata, hal_tdm_caps_capture *caps) +{ + DISPLAY_FUNC_ENTRY(display_get_capture_capability); + return func_display->display_get_capture_capability(bdata, caps); +} + +EXTERN hal_tdm_output ** +hal_tdm_display_get_outputs(hal_tdm_backend_data *bdata, int *count, hal_tdm_error *error) +{ + DISPLAY_FUNC_ENTRY_NULL(display_get_outputs); + return func_display->display_get_outputs(bdata, count, error); +} + +EXTERN hal_tdm_error +hal_tdm_display_get_fd(hal_tdm_backend_data *bdata, int *fd) +{ + DISPLAY_FUNC_ENTRY(display_get_fd); + return func_display->display_get_fd(bdata, fd); +} + +EXTERN hal_tdm_error +hal_tdm_display_handle_events(hal_tdm_backend_data *bdata) +{ + DISPLAY_FUNC_ENTRY(display_handle_events); + return func_display->display_handle_events(bdata); +} + +EXTERN hal_tdm_pp * +hal_tdm_display_create_pp(hal_tdm_backend_data *bdata, hal_tdm_error *error) +{ + DISPLAY_FUNC_ENTRY_NULL(display_create_pp); + return func_display->display_create_pp(bdata, error); +} + +EXTERN hal_tdm_voutput * +hal_tdm_display_voutput_create(hal_tdm_backend_data *bdata, const char *name, hal_tdm_error *error) +{ + DISPLAY_FUNC_ENTRY_NULL(display_voutput_create); + return func_display->display_voutput_create(bdata, name, error); +} + + +/* tdm_func_output */ +EXTERN hal_tdm_error +hal_tdm_output_get_capability(hal_tdm_output *output, hal_tdm_caps_output *caps) +{ + OUTPUT_FUNC_ENTRY(output_get_capability); + return func_output->output_get_capability(output, caps); +} + +EXTERN hal_tdm_error +hal_tdm_output_set_property(hal_tdm_output *output, unsigned int id, hal_tdm_value value) +{ + OUTPUT_FUNC_ENTRY(output_set_property); + return func_output->output_set_property(output, id, value); +} + +EXTERN hal_tdm_error +hal_tdm_output_get_property(hal_tdm_output *output, unsigned int id, hal_tdm_value *value) +{ + OUTPUT_FUNC_ENTRY(output_get_property); + return func_output->output_get_property(output, id, value); +} + +EXTERN hal_tdm_error +hal_tdm_output_wait_vblank(hal_tdm_output *output, int interval, int sync, void *user_data) +{ + OUTPUT_FUNC_ENTRY(output_wait_vblank); + return func_output->output_wait_vblank(output, interval, sync, user_data); +} + +EXTERN hal_tdm_error +hal_tdm_output_set_vblank_handler(hal_tdm_output *output, hal_tdm_output_vblank_handler func) +{ + OUTPUT_FUNC_ENTRY(output_set_vblank_handler); + return func_output->output_set_vblank_handler(output, func); +} + +EXTERN hal_tdm_error +hal_tdm_output_commit(hal_tdm_output *output, int sync, void *user_data) +{ + OUTPUT_FUNC_ENTRY(output_commit); + return func_output->output_commit(output, sync, user_data); +} + +EXTERN hal_tdm_error +hal_tdm_output_set_commit_handler(hal_tdm_output *output, hal_tdm_output_commit_handler func) +{ + OUTPUT_FUNC_ENTRY(output_set_commit_handler); + return func_output->output_set_commit_handler(output, func); +} + +EXTERN hal_tdm_error +hal_tdm_output_set_dpms(hal_tdm_output *output, hal_tdm_output_dpms dpms_value) +{ + OUTPUT_FUNC_ENTRY(output_set_dpms); + return func_output->output_set_dpms(output, dpms_value); +} + +EXTERN hal_tdm_error +hal_tdm_output_get_dpms(hal_tdm_output *output, hal_tdm_output_dpms *dpms_value) +{ + OUTPUT_FUNC_ENTRY(output_get_dpms); + return func_output->output_get_dpms(output, dpms_value); +} + +EXTERN hal_tdm_error +hal_tdm_output_set_mode(hal_tdm_output *output, const hal_tdm_output_mode *mode) +{ + OUTPUT_FUNC_ENTRY(output_set_mode); + return func_output->output_set_mode(output, mode); +} + +EXTERN hal_tdm_error +hal_tdm_output_get_mode(hal_tdm_output *output, const hal_tdm_output_mode **mode) +{ + OUTPUT_FUNC_ENTRY(output_get_mode); + return func_output->output_get_mode(output, mode); +} + +EXTERN hal_tdm_capture * +hal_tdm_output_create_capture(hal_tdm_output *output, hal_tdm_error *error) +{ + OUTPUT_FUNC_ENTRY_NULL(output_create_capture); + return func_output->output_create_capture(output, error); +} + +EXTERN hal_tdm_error +hal_tdm_output_set_status_handler(hal_tdm_output *output, hal_tdm_output_status_handler func, void *user_data) +{ + OUTPUT_FUNC_ENTRY(output_set_status_handler); + return func_output->output_set_status_handler(output, func, user_data); +} + +EXTERN hal_tdm_error +hal_tdm_output_set_dpms_handler(hal_tdm_output *output, hal_tdm_output_dpms_handler func, void *user_data) +{ + OUTPUT_FUNC_ENTRY(output_set_dpms_handler); + return func_output->output_set_dpms_handler(output, func, user_data); +} + +EXTERN hal_tdm_error +hal_tdm_output_set_dpms_async(hal_tdm_output *output, hal_tdm_output_dpms dpms_value, int *sync) +{ + OUTPUT_FUNC_ENTRY(output_set_dpms_async); + return func_output->output_set_dpms_async(output, dpms_value, sync); +} + +EXTERN hal_tdm_hwc * +hal_tdm_output_get_hwc(hal_tdm_output *output, hal_tdm_error *error) +{ + OUTPUT_FUNC_ENTRY_NULL(output_get_hwc); + return func_output->output_get_hwc(output, error); +} + +EXTERN hal_tdm_error +hal_tdm_output_set_mirror(hal_tdm_output *output, hal_tdm_output *src_output, hal_tdm_transform transform) +{ + OUTPUT_FUNC_ENTRY(output_set_mirror); + return func_output->output_set_mirror(output, src_output, transform); +} + +EXTERN hal_tdm_error +hal_tdm_output_unset_mirror(hal_tdm_output *output) +{ + OUTPUT_FUNC_ENTRY(output_unset_mirror); + return func_output->output_unset_mirror(output); +} + + +/* tdm_func_voutput */ +EXTERN hal_tdm_error +hal_tdm_voutput_destroy(hal_tdm_voutput *voutput) +{ + VOUTPUT_FUNC_ENTRY(voutput_destroy); + return func_voutput->voutput_destroy(voutput); +} + +EXTERN hal_tdm_error +hal_tdm_voutput_set_available_mode(hal_tdm_voutput *voutput, const hal_tdm_output_mode *modes, int count) +{ + VOUTPUT_FUNC_ENTRY(voutput_set_available_mode); + return func_voutput->voutput_set_available_mode(voutput, modes, count); +} + +EXTERN hal_tdm_error +hal_tdm_voutput_set_physical_size(hal_tdm_voutput *voutput, unsigned int mmwidth, unsigned int mmheight) +{ + VOUTPUT_FUNC_ENTRY(voutput_set_physical_size); + return func_voutput->voutput_set_physical_size(voutput, mmwidth, mmheight); +} + +EXTERN hal_tdm_error +hal_tdm_voutput_connect(hal_tdm_voutput *voutput) +{ + VOUTPUT_FUNC_ENTRY(voutput_connect); + return func_voutput->voutput_connect(voutput); +} + +EXTERN hal_tdm_error +hal_tdm_voutput_disconnect(hal_tdm_voutput *voutput) +{ + VOUTPUT_FUNC_ENTRY(voutput_disconnect); + return func_voutput->voutput_disconnect(voutput); +} + +EXTERN hal_tdm_output * +hal_tdm_voutput_get_output(hal_tdm_voutput *voutput, hal_tdm_error *error) +{ + VOUTPUT_FUNC_ENTRY_NULL(voutput_get_output); + return func_voutput->voutput_get_output(voutput, error); +} + +EXTERN hal_tdm_error +hal_tdm_voutput_set_commit_func(hal_tdm_voutput *voutput, hal_tdm_voutput_commit_handler commit_func) +{ + VOUTPUT_FUNC_ENTRY(voutput_set_commit_func); + return func_voutput->voutput_set_commit_func(voutput, commit_func); +} + +EXTERN hal_tdm_error +hal_tdm_voutput_commit_done(hal_tdm_voutput *voutput) +{ + VOUTPUT_FUNC_ENTRY(voutput_commit_done); + return func_voutput->voutput_commit_done(voutput); +} + +EXTERN hal_tdm_error +hal_tdm_voutput_set_target_buffer_queue_flag(hal_tdm_voutput *voutput, int flags) +{ + VOUTPUT_FUNC_ENTRY(voutput_set_target_buffer_queue_flag); + return func_voutput->voutput_set_target_buffer_queue_flag(voutput, flags); +} + + +/* tdm_func_hwc */ +EXTERN hal_tdm_hwc_window * +hal_tdm_hwc_create_window(hal_tdm_hwc *hwc, hal_tdm_error *error) +{ + HWC_FUNC_ENTRY_NULL(hwc_create_window); + return func_hwc->hwc_create_window(hwc, error); +} + +EXTERN hal_tdm_error +hal_tdm_hwc_get_video_supported_formats(hal_tdm_hwc *hwc, const tbm_format **formats, int *count) +{ + HWC_FUNC_ENTRY(hwc_get_video_supported_formats); + return func_hwc->hwc_get_video_supported_formats(hwc, formats, count); +} + +EXTERN hal_tdm_error +hal_tdm_hwc_get_video_available_properties(hal_tdm_hwc *hwc, const hal_tdm_prop **props, int *count) +{ + HWC_FUNC_ENTRY(hwc_get_video_available_properties); + return func_hwc->hwc_get_video_available_properties(hwc, props, count); +} + +EXTERN hal_tdm_error +hal_tdm_hwc_get_capabilities(hal_tdm_hwc *hwc, hal_tdm_hwc_capability *capabilities) +{ + HWC_FUNC_ENTRY(hwc_get_capabilities); + return func_hwc->hwc_get_capabilities(hwc, capabilities); +} + +EXTERN hal_tdm_error +hal_tdm_hwc_get_available_properties(hal_tdm_hwc *hwc, const hal_tdm_prop **props, int *count) +{ + HWC_FUNC_ENTRY(hwc_get_available_properties); + return func_hwc->hwc_get_available_properties(hwc, props, count); +} + +EXTERN tbm_surface_queue_h +hal_tdm_hwc_get_client_target_buffer_queue(hal_tdm_hwc *hwc, hal_tdm_error *error) +{ + HWC_FUNC_ENTRY_NULL(hwc_get_client_target_buffer_queue); + return func_hwc->hwc_get_client_target_buffer_queue(hwc, error); +} + +EXTERN hal_tdm_error +hal_tdm_hwc_set_client_target_buffer(hal_tdm_hwc *hwc, tbm_surface_h target_buffer, hal_tdm_region damage) +{ + HWC_FUNC_ENTRY(hwc_set_client_target_buffer); + return func_hwc->hwc_set_client_target_buffer(hwc, target_buffer, damage); +} + +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); + return func_hwc->hwc_set_client_target_acquire_fence(hwc, acquire_fence); +} + +EXTERN hal_tdm_error +hal_tdm_hwc_validate(hal_tdm_hwc *hwc, hal_tdm_hwc_window **composited_wnds, uint32_t num_wnds, uint32_t *num_types) +{ + HWC_FUNC_ENTRY(hwc_validate); + return func_hwc->hwc_validate(hwc, composited_wnds, num_wnds, num_types); +} + +EXTERN hal_tdm_error +hal_tdm_hwc_get_changed_composition_types(hal_tdm_hwc *hwc, uint32_t *num_elements, hal_tdm_hwc_window **hwc_window, hal_tdm_hwc_window_composition *composition_types) +{ + HWC_FUNC_ENTRY(hwc_get_changed_composition_types); + return func_hwc->hwc_get_changed_composition_types(hwc, num_elements, hwc_window, composition_types); +} + +EXTERN hal_tdm_error +hal_tdm_hwc_accept_validation(hal_tdm_hwc *hwc) +{ + HWC_FUNC_ENTRY(hwc_accept_validation); + return func_hwc->hwc_accept_validation(hwc); +} + +EXTERN hal_tdm_error +hal_tdm_hwc_commit(hal_tdm_hwc *hwc, int sync, void *user_data) +{ + HWC_FUNC_ENTRY(hwc_commit); + return func_hwc->hwc_commit(hwc, sync, user_data); +} + +EXTERN hal_tdm_error +hal_tdm_hwc_set_commit_handler(hal_tdm_hwc *hwc, hal_tdm_hwc_commit_handler func) +{ + HWC_FUNC_ENTRY(hwc_set_commit_handler); + return func_hwc->hwc_set_commit_handler(hwc, func); +} + +EXTERN hal_tdm_error +hal_tdm_hwc_get_commit_fence(hal_tdm_hwc *hwc, int *commit_fence) +{ + HWC_FUNC_ENTRY(hwc_get_commit_fence); + return func_hwc->hwc_get_commit_fence(hwc, commit_fence); +} + +EXTERN hal_tdm_error +hal_tdm_hwc_get_release_fences(hal_tdm_hwc *hwc, uint32_t *num_elements, hal_tdm_hwc_window **hwc_windows, int *release_fences) +{ + HWC_FUNC_ENTRY(hwc_get_release_fences); + return func_hwc->hwc_get_release_fences(hwc, num_elements, hwc_windows, release_fences); +} + +EXTERN hal_tdm_error +hal_tdm_hwc_set_property(hal_tdm_hwc *hwc, uint32_t id, hal_tdm_value value) +{ + HWC_FUNC_ENTRY(hwc_set_property); + return func_hwc->hwc_set_property(hwc, id, value); +} + +EXTERN hal_tdm_error +hal_tdm_hwc_get_property(hal_tdm_hwc *hwc, uint32_t id, hal_tdm_value *value) +{ + HWC_FUNC_ENTRY(hwc_get_property); + return func_hwc->hwc_get_property(hwc, id, value); +} + +EXTERN hal_tdm_error +hal_tdm_hwc_get_commit_interval(hal_tdm_hwc *hwc, hal_tdm_hwc_commit_interval *interval) +{ + HWC_FUNC_ENTRY(hwc_get_commit_interval); + return func_hwc->hwc_get_commit_interval(hwc, interval); +} + + +/* tdm_func_hwc_window */ +EXTERN void +hal_tdm_hwc_window_destroy(hal_tdm_hwc_window *hwc_window) +{ + HWC_WINDOW_FUNC_ENTRY_VOID(hwc_window_destroy); + func_hwc_window->hwc_window_destroy(hwc_window); +} + +EXTERN tbm_surface_queue_h +hal_tdm_hwc_window_acquire_buffer_queue(hal_tdm_hwc_window *hwc_window, hal_tdm_error *error) +{ + HWC_WINDOW_FUNC_ENTRY_NULL(hwc_window_acquire_buffer_queue); + return func_hwc_window->hwc_window_acquire_buffer_queue(hwc_window, error); +} + +EXTERN void +hal_tdm_hwc_window_release_buffer_queue(hal_tdm_hwc_window *hwc_window, tbm_surface_queue_h queue) +{ + HWC_WINDOW_FUNC_ENTRY_VOID(hwc_window_release_buffer_queue); + func_hwc_window->hwc_window_release_buffer_queue(hwc_window, queue); +} + +EXTERN hal_tdm_error +hal_tdm_hwc_window_set_composition_type(hal_tdm_hwc_window *hwc_window, hal_tdm_hwc_window_composition composition_type) +{ + HWC_WINDOW_FUNC_ENTRY(hwc_window_set_composition_type); + return func_hwc_window->hwc_window_set_composition_type(hwc_window, composition_type); +} + +EXTERN hal_tdm_error +hal_tdm_hwc_window_set_buffer_damage(hal_tdm_hwc_window *hwc_window, hal_tdm_region damage) +{ + HWC_WINDOW_FUNC_ENTRY(hwc_window_set_buffer_damage); + return func_hwc_window->hwc_window_set_buffer_damage(hwc_window, damage); +} + +EXTERN hal_tdm_error +hal_tdm_hwc_window_set_info(hal_tdm_hwc_window *hwc_window, hal_tdm_hwc_window_info *info) +{ + HWC_WINDOW_FUNC_ENTRY(hwc_window_set_info); + return func_hwc_window->hwc_window_set_info(hwc_window, info); +} + +EXTERN hal_tdm_error +hal_tdm_hwc_window_set_buffer(hal_tdm_hwc_window *hwc_window, tbm_surface_h buffer) +{ + HWC_WINDOW_FUNC_ENTRY(hwc_window_set_buffer); + return func_hwc_window->hwc_window_set_buffer(hwc_window, buffer); +} + +EXTERN hal_tdm_error +hal_tdm_hwc_window_set_property(hal_tdm_hwc_window *hwc_window, uint32_t id, hal_tdm_value value) +{ + HWC_WINDOW_FUNC_ENTRY(hwc_window_set_property); + return func_hwc_window->hwc_window_set_property(hwc_window, id, value); +} + +EXTERN hal_tdm_error +hal_tdm_hwc_window_get_property(hal_tdm_hwc_window *hwc_window, uint32_t id, hal_tdm_value *value) +{ + HWC_WINDOW_FUNC_ENTRY(hwc_window_get_property); + return func_hwc_window->hwc_window_get_property(hwc_window, id, value); +} + +EXTERN hal_tdm_error +hal_tdm_hwc_window_get_constraints(hal_tdm_hwc_window *hwc_window, int *constraints) +{ + HWC_WINDOW_FUNC_ENTRY(hwc_window_get_constraints); + return func_hwc_window->hwc_window_get_constraints(hwc_window, constraints); +} + +EXTERN hal_tdm_error +hal_tdm_hwc_window_set_name(hal_tdm_hwc_window *hwc_window, const char *name) +{ + HWC_WINDOW_FUNC_ENTRY(hwc_window_set_name); + return func_hwc_window->hwc_window_set_name(hwc_window, name); +} + +EXTERN hal_tdm_error +hal_tdm_hwc_window_set_cursor_image(hal_tdm_hwc_window *hwc_window, int width, int height, int stride, void *ptr) +{ + HWC_WINDOW_FUNC_ENTRY(hwc_window_set_cursor_image); + return func_hwc_window->hwc_window_set_cursor_image(hwc_window, width, height, stride, ptr); +} + +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); + return func_hwc_window->hwc_window_set_acquire_fence(hwc_window, acquire_fence); +} + + +/* tdm_func_pp */ +EXTERN void +hal_tdm_pp_destroy(hal_tdm_pp *pp) +{ + PP_FUNC_ENTRY_VOID(pp_destroy); + func_pp->pp_destroy(pp); +} + +EXTERN hal_tdm_error +hal_tdm_pp_set_info(hal_tdm_pp *pp, hal_tdm_info_pp *info) +{ + PP_FUNC_ENTRY(pp_set_info); + return func_pp->pp_set_info(pp, info); +} + +EXTERN hal_tdm_error +hal_tdm_pp_attach(hal_tdm_pp *pp, tbm_surface_h src, tbm_surface_h dst) +{ + PP_FUNC_ENTRY(pp_attach); + return func_pp->pp_attach(pp, src, dst); +} + +EXTERN hal_tdm_error +hal_tdm_pp_commit(hal_tdm_pp *pp) +{ + PP_FUNC_ENTRY(pp_commit); + return func_pp->pp_commit(pp); +} + +EXTERN hal_tdm_error +hal_tdm_pp_set_done_handler(hal_tdm_pp *pp, hal_tdm_pp_done_handler func, void *user_data) +{ + PP_FUNC_ENTRY(pp_set_done_handler); + return func_pp->pp_set_done_handler(pp, func, user_data); +} + + +/* tdm_func_capture */ +EXTERN void +hal_tdm_capture_destroy(hal_tdm_capture *capture) +{ + CAPTURE_FUNC_ENTRY_VOID(capture_destroy); + func_capture->capture_destroy(capture); +} + +EXTERN hal_tdm_error +hal_tdm_capture_set_info(hal_tdm_capture *capture, hal_tdm_info_capture *info) +{ + CAPTURE_FUNC_ENTRY(capture_set_info); + return func_capture->capture_set_info(capture, info); +} + +EXTERN hal_tdm_error +hal_tdm_capture_attach(hal_tdm_capture *capture, tbm_surface_h buffer) +{ + CAPTURE_FUNC_ENTRY(capture_attach); + return func_capture->capture_attach(capture, buffer); +} + +EXTERN hal_tdm_error +hal_tdm_capture_commit(hal_tdm_capture *capture) +{ + CAPTURE_FUNC_ENTRY(capture_commit); + return func_capture->capture_commit(capture); +} + +EXTERN hal_tdm_error +hal_tdm_capture_set_done_handler(hal_tdm_capture *capture, hal_tdm_capture_done_handler func, void *user_data) +{ + CAPTURE_FUNC_ENTRY(capture_set_done_handler); + return func_capture->capture_set_done_handler(capture, func, user_data); +} + + +/* tdm_backend_func */ +EXTERN hal_tdm_error +hal_tdm_backend_register_func_display(hal_tdm_display *dpy, hal_tdm_func_display *func_display) +{ + if (!g_tdm_funcs) return HAL_TDM_ERROR_OPERATION_FAILED; + if (g_tdm_funcs->tdm_func_display) return HAL_TDM_ERROR_BAD_REQUEST; + if (!dpy || !func_display) return HAL_TDM_ERROR_INVALID_PARAMETER; + g_tdm_funcs->tdm_func_display = func_display; + return HAL_TDM_ERROR_NONE; +} + +EXTERN hal_tdm_error +hal_tdm_backend_register_func_output(hal_tdm_display *dpy, hal_tdm_func_output *func_output) +{ + if (!g_tdm_funcs) return HAL_TDM_ERROR_OPERATION_FAILED; + if (g_tdm_funcs->tdm_func_output) return HAL_TDM_ERROR_BAD_REQUEST; + if (!dpy || !func_output) return HAL_TDM_ERROR_INVALID_PARAMETER; + g_tdm_funcs->tdm_func_output = func_output; + return HAL_TDM_ERROR_NONE; +} + +EXTERN hal_tdm_error +hal_tdm_backend_register_func_voutput(hal_tdm_display *dpy, hal_tdm_func_voutput *func_voutput) +{ + if (!g_tdm_funcs) return HAL_TDM_ERROR_OPERATION_FAILED; + if (g_tdm_funcs->tdm_func_voutput) return HAL_TDM_ERROR_BAD_REQUEST; + if (!dpy || !func_voutput) return HAL_TDM_ERROR_INVALID_PARAMETER; + g_tdm_funcs->tdm_func_voutput = func_voutput; + return HAL_TDM_ERROR_NONE; +} + +EXTERN hal_tdm_error +hal_tdm_backend_register_func_hwc(hal_tdm_display *dpy, hal_tdm_func_hwc *func_hwc) +{ + if (!g_tdm_funcs) return HAL_TDM_ERROR_OPERATION_FAILED; + if (g_tdm_funcs->tdm_func_hwc) return HAL_TDM_ERROR_BAD_REQUEST; + if (!dpy || !func_hwc) return HAL_TDM_ERROR_INVALID_PARAMETER; + g_tdm_funcs->tdm_func_hwc = func_hwc; + return HAL_TDM_ERROR_NONE; +} + +EXTERN hal_tdm_error +hal_tdm_backend_register_func_hwc_window(hal_tdm_display *dpy, hal_tdm_func_hwc_window *func_hwc_window) +{ + if (!g_tdm_funcs) return HAL_TDM_ERROR_OPERATION_FAILED; + if (g_tdm_funcs->tdm_func_hwc_window) return HAL_TDM_ERROR_BAD_REQUEST; + if (!dpy || !func_hwc_window) return HAL_TDM_ERROR_INVALID_PARAMETER; + g_tdm_funcs->tdm_func_hwc_window = func_hwc_window; + return HAL_TDM_ERROR_NONE; +} + +EXTERN hal_tdm_error +hal_tdm_backend_register_func_pp(hal_tdm_display *dpy, hal_tdm_func_pp *func_pp) +{ + if (!g_tdm_funcs) return HAL_TDM_ERROR_OPERATION_FAILED; + if (g_tdm_funcs->tdm_func_pp) return HAL_TDM_ERROR_BAD_REQUEST; + if (!dpy || !func_pp) return HAL_TDM_ERROR_INVALID_PARAMETER; + g_tdm_funcs->tdm_func_pp = func_pp; + return HAL_TDM_ERROR_NONE; +} + +EXTERN hal_tdm_error +hal_tdm_backend_register_func_capture(hal_tdm_display *dpy, hal_tdm_func_capture *func_capture) +{ + if (!g_tdm_funcs) return HAL_TDM_ERROR_OPERATION_FAILED; + if (g_tdm_funcs->tdm_func_capture) return HAL_TDM_ERROR_BAD_REQUEST; + if (!dpy || !func_capture) return HAL_TDM_ERROR_INVALID_PARAMETER; + g_tdm_funcs->tdm_func_capture = func_capture; + return HAL_TDM_ERROR_NONE; +} + +EXTERN tbm_surface_h +hal_tdm_buffer_ref_backend(tbm_surface_h buffer) +{ +// return tdm_buffer_ref_backend(buffer); + return NULL; +} + +EXTERN void +hal_tdm_buffer_unref_backend(tbm_surface_h buffer) +{ +// tdm_buffer_unref_backend(buffer); +} + +EXTERN hal_tdm_error +hal_tdm_buffer_add_destroy_handler(tbm_surface_h buffer, hal_tdm_buffer_destroy_handler func, void *user_data) +{ +// return tdm_buffer_add_destroy_handler(buffer, func, user_data); + return HAL_TDM_ERROR_NONE; +} + +EXTERN void +hal_tdm_buffer_remove_destroy_handler(tbm_surface_h buffer, hal_tdm_buffer_destroy_handler func, void *user_data) +{ +// tdm_buffer_remove_destroy_handler(buffer, func, user_data); +} + +EXTERN hal_tdm_event_loop_source * +hal_tdm_event_loop_add_fd_handler(hal_tdm_display *dpy, int fd, hal_tdm_event_loop_mask mask, + hal_tdm_event_loop_fd_handler func, void *user_data, hal_tdm_error *error) +{ +// return tdm_event_loop_add_fd_handler(dpy, fd, mask, func, user_data, error); + return NULL; +} + +EXTERN hal_tdm_event_loop_source * +hal_tdm_event_loop_add_timer_handler(hal_tdm_display *dpy, hal_tdm_event_loop_timer_handler func, + void *user_data, hal_tdm_error *error) +{ +// return tdm_event_loop_add_timer_handler(dpy, func, user_data, error); + return NULL; +} + +EXTERN hal_tdm_error +hal_tdm_event_loop_source_timer_update(hal_tdm_event_loop_source *source, unsigned int ms_delay) +{ +// return tdm_event_loop_source_timer_update(source, ms_delay); + return HAL_TDM_ERROR_NONE; +} + +EXTERN void +hal_tdm_event_loop_source_remove(hal_tdm_event_loop_source *source) +{ +// tdm_event_loop_source_remove(source); +} -- 2.34.1