add tdm_common.h to share enumeration and structure with client 56/77656/1
authorBoram Park <boram1288.park@samsung.com>
Mon, 27 Jun 2016 04:35:24 +0000 (13:35 +0900)
committerBoram Park <boram1288.park@samsung.com>
Thu, 30 Jun 2016 10:52:17 +0000 (19:52 +0900)
Change-Id: I6c64905cb8363cc99f3742fe40934872d5d2cb33

include/Makefile.am
include/tdm.h
include/tdm_common.h [new file with mode: 0644]
include/tdm_types.h
packaging/libtdm.spec
src/tdm_capture.c
src/tdm_display.c
src/tdm_macro.h
src/tdm_private.h
src/tdm_server.c

index b47ee0066efe7af92b2b02b7713112abc030606f..aa1d50210242bcaa5327640ede831ed012377bc2 100644 (file)
@@ -1,6 +1,7 @@
 libtdmincludedir = ${includedir}
 libtdminclude_HEADERS = \
        tdm.h \
+       tdm_common.h \
        tdm_types.h \
        tdm_list.h \
        tdm_log.h \
index 6ba49969449f7b4ad3479608bb581e581ef5c028..47afc19a931190a862d4ad1fe6a9a7cb64f01172 100644 (file)
@@ -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 (file)
index 0000000..79cdf69
--- /dev/null
@@ -0,0 +1,131 @@
+/**************************************************************************
+ *
+ * libtdm
+ *
+ * Copyright 2015 Samsung Electronics co., Ltd. All Rights Reserved.
+ *
+ * Contact: Eunchul Kim <chulspro.kim@samsung.com>,
+ *          JinYoung Jeon <jy0.jeon@samsung.com>,
+ *          Taeheon Kim <th908.kim@samsung.com>,
+ *          YoungJun Cho <yj44.cho@samsung.com>,
+ *          SooChan Lim <sc1.lim@samsung.com>,
+ *          Boram Park <sc1.lim@samsung.com>
+ *
+ * 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 <stdint.h>
+
+#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_ */
index a6b68fa4e886195e6e44f705161430f5b8a53d46..53988f297b85bde3161ec22b36871cdcb1c810e0 100755 (executable)
@@ -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 <tdm_common.h>
 
 /**
  * @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
  */
index 11cec9ac5811310f7dd05a89df9efe1be76864e7..28bb692885e0f2f37f940713f1c13776b156b2d7 100644 (file)
@@ -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
index ea67044ade74a61cb2868bd16479ce50f1fc0d5a..8f562ab40b748e902e95586266124533e6475e40 100644 (file)
@@ -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;
        }
index cab04a6d7fa99fb94dd56290a36188a94cc25f8d..2c09442710073b8d9ed59d337d372c663cd3f8c2 100644 (file)
        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))
index b87b4a0cc85c9c6938021fefabae9c490dd99b03..659ead37ee7a33931c5b8ec3bb7410f8d4318036 100644 (file)
@@ -41,6 +41,8 @@
 #include <stdlib.h>
 #include <sys/types.h>
 
+#include <tdm_common.h>
+
 #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
index db7426ed747307196de317f01a3db3f045d8414c..bdb1a20d9f7027632ade242d2f78c56ae6d1685e 100644 (file)
@@ -38,6 +38,7 @@
 
 #include <stdio.h>
 #include <string.h>
+#include <strings.h>
 #include <stdlib.h>
 #include <pthread.h>
 #include <errno.h>
@@ -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);
 
index 1233debdaa48403a15c152eab110e99ba576b558..b71c2a2a89730b6a91eb14afdd5f089413ce452b 100644 (file)
@@ -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;
        }