From: Boram Park Date: Mon, 27 Jun 2016 04:35:24 +0000 (+0900) Subject: add tdm_common.h to share enumeration and structure with client X-Git-Tag: 1.3.0~3 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=3c28bfc94c9f680bc7bb5f8c2ca2aaa4b7b5081c;p=platform%2Fcore%2Fuifw%2Flibtdm.git add tdm_common.h to share enumeration and structure with client Change-Id: I6c64905cb8363cc99f3742fe40934872d5d2cb33 --- diff --git a/include/Makefile.am b/include/Makefile.am index b47ee006..aa1d5021 100644 --- a/include/Makefile.am +++ b/include/Makefile.am @@ -1,6 +1,7 @@ libtdmincludedir = ${includedir} libtdminclude_HEADERS = \ tdm.h \ + tdm_common.h \ tdm_types.h \ tdm_list.h \ tdm_log.h \ diff --git a/include/tdm.h b/include/tdm.h index 6ba49969..47afc19a 100644 --- a/include/tdm.h +++ b/include/tdm.h @@ -64,14 +64,6 @@ typedef enum { TDM_DISPLAY_CAPABILITY_CAPTURE = (1 << 1), /**< if hardware supports capture operation */ } tdm_display_capability; -/** - * @brief The output change enumeration of #tdm_output_change_handler - */ -typedef enum { - TDM_OUTPUT_CHANGE_CONNECTION = (1 << 0), /**< connection chagne */ - TDM_OUTPUT_CHANGE_DPMS = (1 << 1), /**< dpms change */ -} tdm_output_change_type; - /** * @brief The output change handler * @details This handler will be called when the status of a output object is diff --git a/include/tdm_common.h b/include/tdm_common.h new file mode 100644 index 00000000..79cdf69f --- /dev/null +++ b/include/tdm_common.h @@ -0,0 +1,131 @@ +/************************************************************************** + * + * 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. + * +**************************************************************************/ + +#ifndef _TDM_COMMON_H_ +#define _TDM_COMMON_H_ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#define TDM_NAME_LEN 64 + +/** + * @file tdm_common.h + * @brief The header file which defines Enumerations and Structures for TDM + * frontend, backend and client. + */ + +/** + * @brief The error enumeration + */ +typedef enum { + TDM_ERROR_NONE = 0, /**< none */ + TDM_ERROR_BAD_REQUEST = -1, /**< bad request */ + TDM_ERROR_OPERATION_FAILED = -2, /**< operaion failed */ + TDM_ERROR_INVALID_PARAMETER = -3, /**< wrong input parameter */ + TDM_ERROR_PERMISSION_DENIED = -4, /**< access denied */ + TDM_ERROR_BUSY = -5, /**< hardware resource busy */ + TDM_ERROR_OUT_OF_MEMORY = -6, /**< no free memory */ + TDM_ERROR_BAD_MODULE = -7, /**< bad backend module */ + TDM_ERROR_NOT_IMPLEMENTED = -8, /**< not implemented */ + TDM_ERROR_NO_CAPABILITY = -9, /**< no capability */ + TDM_ERROR_DPMS_OFF = -10, /**< dpms off */ +} tdm_error; + +/** + * @brief The output change enumeration of #tdm_output_change_handler + */ +typedef enum { + TDM_OUTPUT_CHANGE_CONNECTION = (1 << 0), /**< connection chagne */ + TDM_OUTPUT_CHANGE_DPMS = (1 << 1), /**< dpms change */ +} tdm_output_change_type; + +/** + * @brief The output connection status enumeration + */ +typedef enum { + TDM_OUTPUT_CONN_STATUS_DISCONNECTED, /**< output disconnected */ + TDM_OUTPUT_CONN_STATUS_CONNECTED, /**< output connected */ + TDM_OUTPUT_CONN_STATUS_MODE_SETTED, /**< output connected and setted a mode */ +} tdm_output_conn_status; + +/** + * @brief The DPMS enumeration + * @details bit compatible with the libdrm definitions. + */ +typedef enum { + TDM_OUTPUT_DPMS_ON, /**< On */ + TDM_OUTPUT_DPMS_STANDBY, /**< StandBy */ + TDM_OUTPUT_DPMS_SUSPEND, /**< Suspend */ + TDM_OUTPUT_DPMS_OFF, /**< Off */ +} tdm_output_dpms; + +/** + * @brief The size structure + */ +typedef struct _tdm_size { + unsigned int h; /**< width */ + unsigned int v; /**< height */ +} tdm_size; + +/** + * @brief The pos structure + */ +typedef struct _tdm_pos { + unsigned int x; + unsigned int y; + unsigned int w; + unsigned int h; +} tdm_pos; + +/** + * @brief The value union + */ +typedef union { + void *ptr; + int32_t s32; + uint32_t u32; + int64_t s64; + uint64_t u64; +} tdm_value; + +#ifdef __cplusplus +} +#endif + +#endif /* _TDM_COMMON_H_ */ diff --git a/include/tdm_types.h b/include/tdm_types.h index a6b68fa4..53988f29 100755 --- a/include/tdm_types.h +++ b/include/tdm_types.h @@ -42,8 +42,6 @@ extern "C" { #endif -#define TDM_NAME_LEN 64 - /** * @file tdm_types.h * @brief The header file which defines Enumerations and Structures for frontend and backend. @@ -59,21 +57,7 @@ extern "C" { * @endcode */ -/** - * @brief The error enumeration - */ -typedef enum { - TDM_ERROR_NONE = 0, /**< none */ - TDM_ERROR_BAD_REQUEST = -1, /**< bad request */ - TDM_ERROR_OPERATION_FAILED = -2, /**< operaion failed */ - TDM_ERROR_INVALID_PARAMETER = -3, /**< wrong input parameter */ - TDM_ERROR_PERMISSION_DENIED = -4, /**< access denied */ - TDM_ERROR_BUSY = -5, /**< hardware resource busy */ - TDM_ERROR_OUT_OF_MEMORY = -6, /**< no free memory */ - TDM_ERROR_BAD_MODULE = -7, /**< bad backend module */ - TDM_ERROR_NOT_IMPLEMENTED = -8, /**< not implemented */ - TDM_ERROR_NO_CAPABILITY = -9, /**< no capability */ -} tdm_error; +#include /** * @brief The transform enumeration(rotate, flip) @@ -89,15 +73,6 @@ typedef enum { TDM_TRANSFORM_FLIPPED_270 = 7, /**< rotate 270 and horizontal flip */ } tdm_transform; -/** - * @brief The output connection status enumeration - */ -typedef enum { - TDM_OUTPUT_CONN_STATUS_DISCONNECTED, /**< output disconnected */ - TDM_OUTPUT_CONN_STATUS_CONNECTED, /**< output connected */ - TDM_OUTPUT_CONN_STATUS_MODE_SETTED, /**< output connected and setted a mode */ -} tdm_output_conn_status; - /** * @brief The output connection status enumeration * @details bit compatible with the libdrm definitions. @@ -122,17 +97,6 @@ typedef enum { TDM_OUTPUT_TYPE_DSI, /**< DSI connection */ } tdm_output_type; -/** - * @brief The DPMS enumeration - * @details bit compatible with the libdrm definitions. - */ -typedef enum { - TDM_OUTPUT_DPMS_ON, /**< On */ - TDM_OUTPUT_DPMS_STANDBY, /**< StandBy */ - TDM_OUTPUT_DPMS_SUSPEND, /**< Suspend */ - TDM_OUTPUT_DPMS_OFF, /**< Off */ -} tdm_output_dpms; - /** * @brief The layer capability enumeration * @details @@ -252,35 +216,6 @@ typedef struct _tdm_prop { char name[TDM_NAME_LEN]; } tdm_prop; -/** - * @brief The size structure - */ -typedef struct _tdm_size { - unsigned int h; /**< width */ - unsigned int v; /**< height */ -} tdm_size; - -/** - * @brief The pos structure - */ -typedef struct _tdm_pos { - unsigned int x; - unsigned int y; - unsigned int w; - unsigned int h; -} tdm_pos; - -/** - * @brief The value union - */ -typedef union { - void *ptr; - int32_t s32; - uint32_t u32; - int64_t s64; - uint64_t u64; -} tdm_value; - /** * @brief The info config structure */ diff --git a/packaging/libtdm.spec b/packaging/libtdm.spec index 11cec9ac..28bb6928 100644 --- a/packaging/libtdm.spec +++ b/packaging/libtdm.spec @@ -35,6 +35,7 @@ Tizen Display Manager Client Library Summary: Client library for Tizen Display Manager Group: Development/Libraries Requires: libtdm-client = %{version} +Requires: libtdm-devel %description client-devel Tizen Display Manager Client Library headers @@ -100,6 +101,7 @@ rm -f %{_unitdir_user}/default.target.wants/tdm-socket-user.path %manifest %{name}.manifest %defattr(-,root,root,-) %{_includedir}/tdm.h +%{_includedir}/tdm_common.h %{_includedir}/tdm_backend.h %{_includedir}/tdm_helper.h %{_includedir}/tdm_list.h diff --git a/src/tdm_capture.c b/src/tdm_capture.c index ea67044a..8f562ab4 100644 --- a/src/tdm_capture.c +++ b/src/tdm_capture.c @@ -403,7 +403,7 @@ tdm_capture_commit(tdm_capture *capture) private_output = private_capture->private_output; if (private_output->current_dpms_value > TDM_OUTPUT_DPMS_ON) { TDM_ERR("output(%d) dpms: %s", private_output->pipe, - dpms_str(private_output->current_dpms_value)); + tdm_dpms_str(private_output->current_dpms_value)); _pthread_mutex_unlock(&private_display->lock); return TDM_ERROR_BAD_REQUEST; } diff --git a/src/tdm_display.c b/src/tdm_display.c index cab04a6d..2c094427 100644 --- a/src/tdm_display.c +++ b/src/tdm_display.c @@ -102,47 +102,6 @@ private_output = private_layer->private_output; \ private_display = private_output->private_display -#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0])) - -struct type_name { - int type; - const char *name; -}; - -#define type_name_fn(res) \ -const char * res##_str(int type) \ -{ \ - unsigned int i; \ - for (i = 0; i < ARRAY_SIZE(res##_names); i++) { \ - if (res##_names[i].type == type) \ - return res##_names[i].name; \ - } \ - return "(invalid)"; \ -} - -struct type_name dpms_names[] = { - { TDM_OUTPUT_DPMS_ON, "on" }, - { TDM_OUTPUT_DPMS_STANDBY, "standby" }, - { TDM_OUTPUT_DPMS_SUSPEND, "suspend" }, - { TDM_OUTPUT_DPMS_OFF, "off" }, -}; - -INTERN type_name_fn(dpms) - -struct type_name status_names[] = { - { TDM_OUTPUT_CONN_STATUS_DISCONNECTED, "disconnected" }, - { TDM_OUTPUT_CONN_STATUS_CONNECTED, "connected" }, - { TDM_OUTPUT_CONN_STATUS_MODE_SETTED, "mode_setted" }, -}; - -INTERN type_name_fn(status) - -INTERN const char* -tdm_get_dpms_str(tdm_output_dpms dpms_value) -{ - return dpms_str(dpms_value); -} - INTERN tdm_error _tdm_display_lock(tdm_display *dpy, const char *func) { @@ -988,7 +947,7 @@ tdm_output_wait_vblank(tdm_output *output, int interval, int sync, if (private_output->current_dpms_value > TDM_OUTPUT_DPMS_ON) { TDM_ERR("output(%d) dpms: %s", private_output->pipe, - dpms_str(private_output->current_dpms_value)); + tdm_dpms_str(private_output->current_dpms_value)); _pthread_mutex_unlock(&private_display->lock); return TDM_ERROR_BAD_REQUEST; } @@ -1082,7 +1041,7 @@ tdm_output_commit(tdm_output *output, int sync, tdm_output_commit_handler func, if (private_output->current_dpms_value > TDM_OUTPUT_DPMS_ON) { TDM_ERR("output(%d) dpms: %s", private_output->pipe, - dpms_str(private_output->current_dpms_value)); + tdm_dpms_str(private_output->current_dpms_value)); _pthread_mutex_unlock(&private_display->lock); return TDM_ERROR_BAD_REQUEST; } @@ -1245,10 +1204,10 @@ tdm_output_call_change_handler_internal(tdm_private_output *private_output, if (!tdm_thread_in_display_thread(syscall(SYS_gettid))) { if (type & TDM_OUTPUT_CHANGE_CONNECTION) TDM_INFO("output(%d) changed: %s (%d)", - private_output->pipe, status_str(value.u32), value.u32); + private_output->pipe, tdm_status_str(value.u32), value.u32); if (type & TDM_OUTPUT_CHANGE_DPMS) TDM_INFO("output(%d) changed: dpms %s (%d)", - private_output->pipe, dpms_str(value.u32), value.u32); + private_output->pipe, tdm_dpms_str(value.u32), value.u32); } if (LIST_IS_EMPTY(change_handler_list)) diff --git a/src/tdm_macro.h b/src/tdm_macro.h index b87b4a0c..659ead37 100644 --- a/src/tdm_macro.h +++ b/src/tdm_macro.h @@ -41,6 +41,8 @@ #include #include +#include + #ifdef __cplusplus extern "C" { #endif @@ -117,6 +119,42 @@ extern "C" { #define FOURCC_STR(id) C(id, 0), C(id, 8), C(id, 16), C(id, 24) #define FOURCC_ID(str) FOURCC(((char*)str)[0], ((char*)str)[1], ((char*)str)[2], ((char*)str)[3]) + +#define TDM_ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0])) + +struct tdm_type_name { + int type; + const char *name; +}; + +#define TDM_TYPE_NAME_FN(res) \ +static inline const char * tdm_##res##_str(int type) \ +{ \ + unsigned int i; \ + for (i = 0; i < TDM_ARRAY_SIZE(tdm_##res##_names); i++) { \ + if (tdm_##res##_names[i].type == type) \ + return tdm_##res##_names[i].name; \ + } \ + return "(invalid)"; \ +} + +static struct tdm_type_name tdm_dpms_names[] = { + { TDM_OUTPUT_DPMS_ON, "on" }, + { TDM_OUTPUT_DPMS_STANDBY, "standby" }, + { TDM_OUTPUT_DPMS_SUSPEND, "suspend" }, + { TDM_OUTPUT_DPMS_OFF, "off" }, +}; + +TDM_TYPE_NAME_FN(dpms) + +static struct tdm_type_name tdm_status_names[] = { + { TDM_OUTPUT_CONN_STATUS_DISCONNECTED, "disconnected" }, + { TDM_OUTPUT_CONN_STATUS_CONNECTED, "connected" }, + { TDM_OUTPUT_CONN_STATUS_MODE_SETTED, "mode_setted" }, +}; + +TDM_TYPE_NAME_FN(status) + #ifdef __cplusplus } #endif diff --git a/src/tdm_private.h b/src/tdm_private.h index db7426ed..bdb1a20d 100644 --- a/src/tdm_private.h +++ b/src/tdm_private.h @@ -38,6 +38,7 @@ #include #include +#include #include #include #include @@ -84,11 +85,6 @@ extern int tdm_debug_thread; #define TDM_TRACE_END() #endif -#define prototype_name_fn(res) const char * res##_str(int type) - -prototype_name_fn(dpms); -prototype_name_fn(status); - typedef enum { TDM_CAPTURE_TARGET_OUTPUT, TDM_CAPTURE_TARGET_LAYER, @@ -304,9 +300,6 @@ typedef struct _tdm_buffer_info { struct list_head link; } tdm_buffer_info; -const char* -tdm_get_dpms_str(tdm_output_dpms dpms_value); - int tdm_display_check_module_abi(tdm_private_display *private_display, int abimaj, int abimin); diff --git a/src/tdm_server.c b/src/tdm_server.c index 1233debd..b71c2a2a 100644 --- a/src/tdm_server.c +++ b/src/tdm_server.c @@ -321,8 +321,8 @@ _tdm_server_client_cb_wait_vblank(struct wl_client *client, if (dpms_value != TDM_OUTPUT_DPMS_ON && !sw_timer) { wl_resource_post_error(resource, WL_TDM_CLIENT_ERROR_DPMS_OFF, - "dpms '%s'", tdm_get_dpms_str(dpms_value)); - TDM_ERR("dpms '%s'", tdm_get_dpms_str(dpms_value)); + "dpms '%s'", tdm_dpms_str(dpms_value)); + TDM_ERR("dpms '%s'", tdm_dpms_str(dpms_value)); return; }