correct the header file dependency 36/167336/1
authorBoram Park <boram1288.park@samsung.com>
Wed, 17 Jan 2018 03:42:14 +0000 (12:42 +0900)
committerBoram Park <boram1288.park@samsung.com>
Wed, 17 Jan 2018 06:29:30 +0000 (15:29 +0900)
Change-Id: Icf6348180240bf23ae54f0c6a74e7ee193047b81

29 files changed:
client/tdm_client.c
client/tdm_client.h
client/tdm_client_types.h
client/tdm_monitor.c
include/tdm_common.h
include/tdm_helper.h
include/tdm_types.h
src/tdm.c
src/tdm_backend.c
src/tdm_buffer.c
src/tdm_capture.c
src/tdm_display.c
src/tdm_event_loop.c
src/tdm_helper.c
src/tdm_hwc_window.c
src/tdm_layer.c
src/tdm_macro.h
src/tdm_monitor_server.c
src/tdm_output.c
src/tdm_pp.c
src/tdm_private.h
src/tdm_private_types.h [new file with mode: 0644]
src/tdm_server.c
src/tdm_thread.c
src/tdm_thread.h [new file with mode: 0644]
src/tdm_vblank.c
tools/buffers.c
tools/tdm_test_client.c
tools/tdm_test_server.c

index a855e8f..349c454 100644 (file)
 #include <time.h>
 #include <strings.h>
 
+#include <tdm-client-protocol.h>
+
 #include "tdm_client.h"
 #include "tdm_log.h"
 #include "tdm_macro.h"
 #include "tdm_list.h"
 #include "tdm.h"
 #include "tdm_private.h"
-#include "tdm-client-protocol.h"
 
 typedef struct _tdm_private_client_vblank tdm_private_client_vblank;
 
index 175bb45..a96e4d4 100644 (file)
@@ -36,6 +36,8 @@
 #ifndef _TDM_CLIENT_H_
 #define _TDM_CLIENT_H_
 
+#include "tdm_client_types.h"
+
 #ifdef __cplusplus
 extern "C" {
 #endif
@@ -49,8 +51,6 @@ extern "C" {
  * @endcode
  */
 
-#include <tdm_client_types.h>
-
 /**
  * @brief Create a TDM client object.
  * @param[out] error #TDM_ERROR_NONE if success. Otherwise, error value.
index 94807ec..f799c0b 100644 (file)
@@ -36,6 +36,8 @@
 #ifndef _TDM_CLIENT_TYPES_H_
 #define _TDM_CLIENT_TYPES_H_
 
+#include "tdm_common.h"
+
 #ifdef __cplusplus
 extern "C" {
 #endif
@@ -45,8 +47,6 @@ extern "C" {
  * @brief The header file which defines Enumerations and Structures for client.
  */
 
-#include <tdm_common.h>
-
 /**
  * @deprecated
  */
index 60ce16d..30a1a12 100644 (file)
 #include "config.h"
 #endif
 
-#include <tdm_log.h>
-#include <tdm_macro.h>
-#include <tdm_list.h>
-#include <tdm-client-protocol.h>
+#include "tdm_log.h"
+#include "tdm_macro.h"
+#include "tdm_list.h"
+#include "tdm-client-protocol.h"
 
 #undef exit_if_fail
 #define exit_if_fail(cond) { \
index d706e19..dd01247 100644 (file)
@@ -279,11 +279,6 @@ typedef struct _tdm_pos {
        unsigned int h;
 } tdm_pos;
 
-typedef struct _tdm_hwc_region {
-       unsigned int num_rects;
-       tdm_pos const *rects;
-} tdm_hwc_region;
-
 /**
  * @brief The tdm value type enumeration
  */
@@ -307,14 +302,6 @@ typedef union {
        uint64_t u64;
 } tdm_value;
 
-/**
- * @brief The hwc window flag enumeration
- * @since 2.0.0
- */
-typedef enum {
-       TDM_HWC_WINDOW_FLAG_NONE     = 0,
-} tdm_hwc_window_flag;
-
 #ifdef __cplusplus
 }
 #endif
index 8bae8fa..4c501e3 100644 (file)
 #ifndef _TDM_HELPER_H_
 #define _TDM_HELPER_H_
 
-#include "tdm_types.h"
 #include <tbm_surface.h>
 
+#include "tdm_types.h"
+
 #ifdef __cplusplus
 extern "C" {
 #endif
index 6813c72..a20049f 100644 (file)
@@ -38,6 +38,8 @@
 
 #include <tbm_surface.h>
 
+#include "tdm_common.h"
+
 #ifdef __cplusplus
 extern "C" {
 #endif
@@ -57,8 +59,6 @@ extern "C" {
  * @endcode
  */
 
-#include <tdm_common.h>
-
 typedef enum {
        TDM_EVENT_LOOP_READABLE = (1 << 0),
        TDM_EVENT_LOOP_WRITABLE = (1 << 1),
@@ -116,6 +116,11 @@ typedef struct _tdm_hwc_window_info {
        tdm_transform transform;
 } tdm_hwc_window_info;
 
+typedef struct _tdm_hwc_region {
+       unsigned int num_rects;
+       tdm_pos const *rects;
+} tdm_hwc_region;
+
 /**
  * @brief The pp info structre
  */
@@ -195,6 +200,14 @@ typedef enum {
 } tdm_hwc_window_composition;
 
 /**
+ * @brief The hwc window flag enumeration
+ * @since 2.0.0
+ */
+typedef enum {
+       TDM_HWC_WINDOW_FLAG_NONE     = 0,
+} tdm_hwc_window_flag;
+
+/**
  * @brief The tdm display object
  */
 typedef void tdm_display;
index 9492336..30b4a91 100644 (file)
--- a/src/tdm.c
+++ b/src/tdm.c
 #include "config.h"
 #endif
 
-#include "tdm.h"
-#include "tdm_backend.h"
 #include "tdm_private.h"
-#include "tdm_helper.h"
-#include <tbm_drm_helper.h>
 
 pthread_mutex_t tdm_mutex_check_lock = PTHREAD_MUTEX_INITIALIZER;
 int tdm_mutex_locked;
@@ -790,7 +786,7 @@ static tdm_error
 _tdm_display_load_module_with_file(tdm_private_display *private_display,
                                                                   const char *file)
 {
-       char path[PATH_MAX] = {0,};
+       char path[TDM_PATH_LEN] = {0,};
        tdm_backend_module *module_data;
        void *module;
        tdm_error ret;
index f8d36d3..e6463bc 100644 (file)
@@ -37,8 +37,6 @@
 #include "config.h"
 #endif
 
-#include "tdm.h"
-#include "tdm_backend.h"
 #include "tdm_private.h"
 
 #define BACKEND_FUNC_ENTRY() \
index 6037dc2..3c9fb48 100644 (file)
@@ -37,9 +37,7 @@
 #include "config.h"
 #endif
 
-#include "tdm.h"
 #include "tdm_private.h"
-#include "tdm_list.h"
 
 static int tdm_buffer_key;
 #define TDM_BUFFER_KEY ((unsigned long)&tdm_buffer_key)
index add764a..de7439c 100644 (file)
 #include "config.h"
 #endif
 
-#include "tdm.h"
-#include "tdm_backend.h"
 #include "tdm_private.h"
-#include "tdm_helper.h"
 
 #define CAPTURE_FUNC_ENTRY() \
        tdm_func_capture *func_capture; \
index a009756..83fbec3 100644 (file)
 #include "config.h"
 #endif
 
-#include "tdm.h"
-#include "tdm_backend.h"
 #include "tdm_private.h"
-#include "tdm_helper.h"
 
 #define COUNT_MAX   10
 
index bb0ed57..4be20ce 100644 (file)
 #include "config.h"
 #endif
 
-#include "tdm.h"
 #include "tdm_private.h"
-#include "tdm_list.h"
-
-#include <wayland-server-core.h>
 
 typedef struct _tdm_event_loop_source_base {
        struct wl_event_source *wl_source;
index 74d8bb5..c8bcb1c 100644 (file)
 #endif
 
 #include <png.h>
-#include <string.h>
-#include <tbm_surface.h>
-#include <tbm_surface_internal.h>
-#include <tbm_drm_helper.h>
-#include <string.h>
-#include <time.h>
 #include <pixman.h>
-#include <inttypes.h>
 
-#include "tdm.h"
 #include "tdm_private.h"
-#include "tdm_helper.h"
 
 #define PNG_DEPTH 8
 
index 47ea149..40820ce 100644 (file)
 #include "config.h"
 #endif
 
-#include "tdm.h"
-#include "tdm_backend.h"
 #include "tdm_private.h"
-#include "tdm_helper.h"
 
 #define COUNT_MAX   10
 
@@ -240,7 +237,7 @@ _tdm_window_dump_buffer(tdm_hwc_window *hwc_window, tbm_surface_h buffer)
        tdm_private_output *private_output = private_window->private_output;
        unsigned int pipe;
        uint32_t zpos;
-       char fname[PATH_MAX];
+       char fname[TDM_PATH_LEN];
 
        pipe = private_output->pipe;
        zpos = private_window->zpos;
index 0e66228..8ef46a6 100644 (file)
 #include "config.h"
 #endif
 
-#include "tdm.h"
-#include "tdm_backend.h"
 #include "tdm_private.h"
-#include "tdm_helper.h"
 
 #define COUNT_MAX   10
 
@@ -291,8 +288,8 @@ _tdm_layer_dump_buffer(tdm_layer *layer, tbm_surface_h buffer)
        tdm_private_layer *private_layer = (tdm_private_layer*)layer;
        tdm_private_output *private_output = private_layer->private_output;
        unsigned int pipe;
-       char fname[PATH_MAX], bufs[PATH_MAX];
-       int zpos, len = PATH_MAX;
+       char fname[TDM_PATH_LEN], bufs[TDM_PATH_LEN];
+       int zpos, len = TDM_PATH_LEN;
        tdm_private_layer *l = NULL;
        char *p = bufs;
        int *remain = &len;
index a55251e..78e2643 100644 (file)
 #include <stdlib.h>
 #include <sys/types.h>
 
-#include <tdm_common.h>
 #include <tbm_surface.h>
 
+#include "tdm_private_types.h"
+#include "tdm_thread.h"
+
 #ifdef __cplusplus
 extern "C" {
 #endif
 
+#define TDM_DUMP_DIR    "/tmp"
+
 #define TDM_SERVER_REPLY_MSG_LEN       8192
 #define TDM_DEBUG_REPLY_MSG_LEN                2048
 
@@ -336,6 +340,74 @@ strtostr(char *buf, int len, char *str, char *delim)
        return str + len - 1;
 }
 
+#ifdef HAVE_TTRACE
+#include <ttrace.h>
+#define TDM_TRACE_BEGIN(fmt, ...) traceBegin(TTRACE_TAG_GRAPHICS, fmt, ##__VA_ARGS__)
+#define TDM_TRACE_END() traceEnd(TTRACE_TAG_GRAPHICS)
+#define TDM_TRACE_ASYNC_BEGIN(key, name,...) traceAsyncBegin(TTRACE_TAG_GRAPHICS, key, name, ##__VA_ARGS__)
+#define TDM_TRACE_ASYNC_END(key, name,...) traceAsyncEnd(TTRACE_TAG_GRAPHICS, key, name, ##__VA_ARGS__)
+#define TDM_TRACE_COUNT(count, fmt, ...) traceCounter(TTRACE_TAG_GRAPHICS, count, fmt, ##__VA_ARGS__)
+#define TDM_TRACE_MARK(fmt, ...) traceMark(TTRACE_TAG_GRAPHICS, fmt, ##__VA_ARGS__)
+#else
+#define TDM_TRACE_BEGIN(fmt, ...)
+#define TDM_TRACE_END()
+#define TDM_TRACE_ASYNC_BEGIN(key, name,...)
+#define TDM_TRACE_ASYNC_END(key, name,...)
+#define TDM_TRACE_COUNT(count, fmt, ...)
+#define TDM_TRACE_MARK(fmt, ...)
+#endif
+
+
+extern pthread_mutex_t tdm_mutex_check_lock;
+extern int tdm_mutex_locked;
+extern const char *tdm_mutex_lock_func;
+extern int tdm_mutex_lock_line;
+extern const char *tdm_mutex_unlock_func;
+extern int tdm_mutex_unlock_line;
+
+#define _pthread_mutex_lock(l) \
+       do { \
+               if (tdm_debug_module & TDM_DEBUG_MUTEX) \
+                       TDM_INFO("mutex lock"); \
+               pthread_mutex_lock(l); \
+               pthread_mutex_lock(&tdm_mutex_check_lock); \
+               tdm_mutex_locked = 1; \
+               tdm_mutex_lock_func = __FUNCTION__; \
+               tdm_mutex_lock_line = __LINE__; \
+               tdm_mutex_unlock_func = NULL; \
+               tdm_mutex_unlock_line = 0; \
+               pthread_mutex_unlock(&tdm_mutex_check_lock); \
+       } while (0)
+
+#define _pthread_mutex_unlock(l) \
+       do { \
+               if (tdm_debug_module & TDM_DEBUG_MUTEX) \
+                       TDM_INFO("mutex unlock"); \
+               pthread_mutex_lock(&tdm_mutex_check_lock); \
+               tdm_mutex_locked = 0; \
+               tdm_mutex_lock_func = NULL; \
+               tdm_mutex_lock_line = 0; \
+               tdm_mutex_unlock_func = __FUNCTION__; \
+               tdm_mutex_unlock_line = __LINE__; \
+               pthread_mutex_unlock(&tdm_mutex_check_lock); \
+               pthread_mutex_unlock(l); \
+       } while (0)
+
+static inline int TDM_MUTEX_IS_LOCKED(void)
+{
+       int ret;
+       /* if thread is not running, we don't need to consider mutex things. */
+       if (!tdm_thread_is_running())
+               return 1;
+       pthread_mutex_lock(&tdm_mutex_check_lock);
+       ret = (tdm_mutex_locked == 1);
+       pthread_mutex_unlock(&tdm_mutex_check_lock);
+       return ret;
+}
+
+#define tdm_display_lock(dpy)   _pthread_mutex_lock(&((tdm_private_display *)dpy)->lock)
+#define tdm_display_unlock(dpy)   _pthread_mutex_unlock(&((tdm_private_display *)dpy)->lock)
+
 #ifdef __cplusplus
 }
 #endif
index 7dbdc3c..8b28fa8 100644 (file)
  *
 **************************************************************************/
 
-#include <stdio.h>
-#include <string.h>
-#include <stdlib.h>
-#include <stdint.h>
-
-#include "tdm.h"
 #include "tdm_private.h"
-#include "tdm_helper.h"
-#include "tdm_log.h"
 
 #define TDM_DBG_SERVER_ARGS_MAX                32
 
index 76192a2..c58c272 100644 (file)
 #include "config.h"
 #endif
 
-#include "tdm.h"
-#include "tdm_backend.h"
 #include "tdm_private.h"
-#include "tdm_helper.h"
 
 #define COUNT_MAX   10
 
@@ -1692,7 +1689,7 @@ static void
 _tdm_target_window_dump_buffer(tdm_private_output *private_output, tbm_surface_h buffer)
 {
        unsigned int pipe;
-       char fname[PATH_MAX];
+       char fname[TDM_PATH_LEN];
 
        pipe = private_output->pipe;
 
index ccec73f..6e1dafd 100644 (file)
 #include "config.h"
 #endif
 
-#include "tdm.h"
-#include "tdm_backend.h"
 #include "tdm_private.h"
-#include "tdm_helper.h"
 
 #define PP_FUNC_ENTRY() \
        tdm_func_pp *func_pp; \
index 6d9c95f..058c228 100644 (file)
@@ -43,7 +43,6 @@
 #include <pthread.h>
 #include <errno.h>
 #include <unistd.h>
-#include <limits.h>
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <fcntl.h>
@@ -51,7 +50,6 @@
 #include <dirent.h>
 #include <poll.h>
 #include <sys/syscall.h>
-#include <sys/types.h>
 #include <sys/eventfd.h>
 #include <math.h>
 #include <grp.h>
 #include <wayland-server-protocol.h>
 #include <tbm_bufmgr.h>
 #include <tbm_surface_queue.h>
+#include <tbm_surface_internal.h>
+#include <tbm_drm_helper.h>
 
-#include "tdm_backend.h"
-#include "tdm_log.h"
-#include "tdm_list.h"
+#include "tdm_private_types.h"
 #include "tdm_macro.h"
+#include "tdm_helper.h"
+#include "tdm_thread.h"
 
 #ifdef __cplusplus
 extern "C" {
@@ -71,383 +71,17 @@ extern "C" {
 
 //#define INIT_BUFMGR
 
-/**
- * @file tdm_private.h
- * @brief The private header file for a frontend library
- */
-
-enum {
-       TDM_DEBUG_NONE,
-       TDM_DEBUG_BUFFER    = (1 << 0),
-       TDM_DEBUG_MUTEX     = (1 << 1),
-       TDM_DEBUG_THREAD    = (1 << 2),
-       TDM_DEBUG_SERVER    = (1 << 3),
-       TDM_DEBUG_VBLANK    = (1 << 4),
-       TDM_DEBUG_COMMIT    = (1 << 5),
-};
-
-enum {
-       TDM_TTRACE_NONE,
-       TDM_TTRACE_VBLANK    = (1 << 0),
-       TDM_TTRACE_CLIENT    = (1 << 1),
-       TDM_TTRACE_LAYER     = (1 << 2),
-       TDM_TTRACE_PP        = (1 << 3),
-       TDM_TTRACE_CAPTURE   = (1 << 4),
-};
+/*****************************************************************************
+ * This file includes
+ *  - other private headers
+ *  - function prototypes
+ *****************************************************************************/
 
 extern int tdm_debug_module;
 extern int tdm_debug_dump;
 extern int tdm_ttrace_module;
 extern int tdm_ttrace_output;
 
-#ifdef HAVE_TTRACE
-#include <ttrace.h>
-#define TDM_TRACE_BEGIN(fmt, ...) traceBegin(TTRACE_TAG_GRAPHICS, fmt, ##__VA_ARGS__)
-#define TDM_TRACE_END() traceEnd(TTRACE_TAG_GRAPHICS)
-#define TDM_TRACE_ASYNC_BEGIN(key, name,...) traceAsyncBegin(TTRACE_TAG_GRAPHICS, key, name, ##__VA_ARGS__)
-#define TDM_TRACE_ASYNC_END(key, name,...) traceAsyncEnd(TTRACE_TAG_GRAPHICS, key, name, ##__VA_ARGS__)
-#define TDM_TRACE_COUNT(count, fmt, ...) traceCounter(TTRACE_TAG_GRAPHICS, count, fmt, ##__VA_ARGS__)
-#define TDM_TRACE_MARK(fmt, ...) traceMark(TTRACE_TAG_GRAPHICS, fmt, ##__VA_ARGS__)
-#else
-#define TDM_TRACE_BEGIN(fmt, ...)
-#define TDM_TRACE_END()
-#define TDM_TRACE_ASYNC_BEGIN(key, name,...)
-#define TDM_TRACE_ASYNC_END(key, name,...)
-#define TDM_TRACE_COUNT(count, fmt, ...)
-#define TDM_TRACE_MARK(fmt, ...)
-#endif
-
-typedef enum {
-       TDM_CAPTURE_TARGET_OUTPUT,
-       TDM_CAPTURE_TARGET_LAYER,
-} tdm_capture_target;
-
-enum {
-       TDM_DUMP_FLAG_LAYER   = (1 << 0),
-       TDM_DUMP_FLAG_PP      = (1 << 1),
-       TDM_DUMP_FLAG_CAPTURE = (1 << 2),
-       TDM_DUMP_FLAG_WINDOW = (1 << 3),
-};
-
-#define TDM_DUMP_DIR    "/tmp"
-
-typedef enum {
-       TDM_COMMIT_TYPE_NONE,
-       TDM_COMMIT_TYPE_OUTPUT,
-       TDM_COMMIT_TYPE_LAYER,
-} tdm_commit_type;
-
-typedef struct _tdm_private_display tdm_private_display;
-typedef struct _tdm_private_output tdm_private_output;
-typedef struct _tdm_private_layer tdm_private_layer;
-typedef struct _tdm_private_hwc_window tdm_private_hwc_window;
-typedef struct _tdm_private_pp tdm_private_pp;
-typedef struct _tdm_private_capture tdm_private_capture;
-typedef struct _tdm_private_loop tdm_private_loop;
-typedef struct _tdm_private_server tdm_private_server;
-typedef struct _tdm_private_thread tdm_private_thread;
-typedef struct _tdm_private_vblank_handler tdm_private_vblank_handler;
-typedef struct _tdm_private_output_commit_handler tdm_private_output_commit_handler;
-typedef struct _tdm_private_layer_commit_handler tdm_private_layer_commit_handler;
-typedef struct _tdm_private_change_handler tdm_private_change_handler;
-typedef struct _tdm_private_layer_buffer tdm_private_layer_buffer;
-
-struct _tdm_private_display {
-       pthread_mutex_t lock;
-       unsigned int init_count;
-
-       /* backend module info */
-       void *module;
-       tdm_backend_module *module_data;
-       tdm_backend_data *bdata;
-
-#ifdef INIT_BUFMGR
-       tbm_bufmgr bufmgr;
-#endif
-
-       /* backend function */
-       tdm_display_capability capabilities;
-       tdm_func_display func_display;
-       tdm_func_output func_output;
-       tdm_func_layer func_layer;
-       tdm_func_hwc_window func_hwc_window;
-       tdm_func_pp func_pp;
-       tdm_func_capture func_capture;
-
-       /* backend capability */
-       tdm_caps_display caps_display;
-       tdm_caps_pp caps_pp;
-       tdm_caps_capture caps_capture;
-
-       /* output, pp list */
-       struct list_head output_list;
-       struct list_head pp_list;
-       struct list_head capture_list;
-
-       void **outputs_ptr;
-
-       /* for event handling */
-       tdm_private_loop *private_loop;
-
-       /* output order */
-       tdm_output **outputs;
-
-       int print_fps;
-};
-
-struct _tdm_private_output {
-       struct list_head link;
-
-       int index;
-       double stamp;
-
-       tdm_private_display *private_display;
-
-       tdm_caps_output caps;
-       tdm_output *output_backend;
-
-       unsigned int pipe;
-       tdm_output_dpms current_dpms_value;
-       unsigned int waiting_dpms_change;
-       const tdm_output_mode *current_mode;
-
-       int regist_vblank_cb;
-       int regist_commit_cb;
-       int regist_change_cb;
-       int regist_dpms_cb;
-
-       struct list_head layer_list;
-       struct list_head hwc_window_list;
-       struct list_head capture_list;
-       struct list_head vblank_handler_list;
-       struct list_head output_commit_handler_list;
-
-       /* for layer commit */
-       struct list_head layer_commit_handler_list;
-       struct list_head pending_commit_handler_list;
-       tdm_vblank *vblank;
-       int layer_waiting_vblank;
-
-       /* seperate list for multi-thread*/
-       struct list_head change_handler_list_main;
-       struct list_head change_handler_list_sub;
-
-       void **layers_ptr;
-
-       /* TODO: temp solution for handling DPMS things in sub-htread */
-       tdm_event_loop_source *dpms_changed_timer;
-
-       struct {
-               /* look at the tdm_output_set_need_revalidate_handler() declaration for the details */
-               tdm_output_need_validate_handler hndl;
-               int event_fd;
-               tdm_event_loop_source *event_source;
-       } need_validate;
-
-       /* calling a output commit per a vblank */
-       int commit_per_vblank;
-       tdm_commit_type commit_type;
-
-       /* for ttrace vblank */
-       tdm_vblank *ttrace_vblank;
-};
-
-struct _tdm_private_layer {
-       struct list_head link;
-
-       int index;
-
-       tdm_private_display *private_display;
-       tdm_private_output *private_output;
-
-       tdm_caps_layer caps;
-       tdm_layer *layer_backend;
-
-       /* pending data until committed */
-       unsigned int pending_info_changed;
-       tdm_info_layer pending_info;
-       unsigned int pending_buffer_changed;
-       tbm_surface_h pending_buffer;
-
-       /* When a buffer is set to a layer, it will be stored to waiting_buffer.
-        * And when a layer is committed, it will be moved to committed_buffer.
-        * Finally when a commit handler is called, it will be moved to showing_buffer.
-        */
-       tdm_private_layer_buffer *waiting_buffer;
-       tdm_private_layer_buffer *committed_buffer;   /* for output_commit */
-       tdm_private_layer_buffer *showing_buffer;
-       tbm_surface_queue_h buffer_queue;
-
-       struct list_head capture_list;
-
-       unsigned int usable;
-       unsigned int committing;
-
-       double fps_stamp;
-       unsigned int fps_count;
-};
-
-struct _tdm_private_hwc_window {
-       struct list_head link;
-
-       int index;
-       uint32_t zpos;
-
-       tdm_private_display *private_display;
-       tdm_private_output *private_output;
-
-       tdm_hwc_window *hwc_window_backend;
-};
-
-
-struct _tdm_private_pp {
-       struct list_head link;
-
-       double stamp;
-
-       tdm_private_display *private_display;
-
-       tdm_pp *pp_backend;
-
-       struct list_head pending_buffer_list;
-       struct list_head buffer_list;
-
-       tdm_info_pp info;
-       pid_t owner_tid;
-
-       tdm_pp_done_handler done_func;
-       void *done_user_data;
-};
-
-struct _tdm_private_capture {
-       struct list_head link;
-       struct list_head display_link;
-
-       double stamp;
-
-       tdm_capture_target target;
-
-       tdm_private_display *private_display;
-       tdm_private_output *private_output;
-       tdm_private_layer *private_layer;
-
-       tdm_capture *capture_backend;
-
-       struct list_head pending_buffer_list;
-       struct list_head buffer_list;
-
-       tdm_info_capture info;
-       pid_t owner_tid;
-
-       tdm_capture_done_handler done_func;
-       void *done_user_data;
-};
-
-/* CAUTION:
- * Note that we don't need to (un)lock mutex to use this structure. If there is
- * no TDM thread, all TDM resources are protected by private_display's mutex.
- * If there is a TDM thread, this struct will be used only in a TDM thread.
- * So, we don't need to protect this structure by mutex. Not thread-safe.
- */
-struct _tdm_private_loop {
-       /* TDM uses wl_event_loop to handle various event sources including the TDM
-        * backend's fd.
-        */
-       struct wl_display *wl_display;
-       struct wl_event_loop *wl_loop;
-
-       int backend_fd;
-       tdm_event_loop_source *backend_source;
-
-       /* In event loop, all resources are accessed by this dpy.
-        * CAUTION:
-        * - DO NOT include other private structure in this structure because this
-        *   struct is not protected by mutex.
-        */
-       tdm_display *dpy;
-
-       /* for handling TDM client requests */
-       tdm_private_server *private_server;
-
-       /* To have a TDM event thread. If TDM_THREAD enviroment variable is not set
-        * private_thread is NULL.
-        */
-       tdm_private_thread *private_thread;
-};
-
-struct _tdm_private_vblank_handler {
-       struct list_head link;
-
-       tdm_private_output *private_output;
-       int interval;
-       int sync;
-       tdm_output_vblank_handler func;
-       void *user_data;
-
-       pid_t owner_tid;
-};
-
-struct _tdm_private_output_commit_handler {
-       struct list_head link;
-
-       tdm_private_output *private_output;
-       tdm_output_commit_handler func;
-       void *user_data;
-
-       pid_t owner_tid;
-};
-
-struct _tdm_private_layer_commit_handler {
-       struct list_head link;
-
-       tdm_private_layer *private_layer;
-       tdm_layer_commit_handler func;
-       void *user_data;
-
-       tdm_private_layer_buffer *committed_buffer;   /* for layer_commit */
-};
-
-struct _tdm_private_change_handler {
-       struct list_head link;
-
-       tdm_private_output *private_output;
-       tdm_output_change_handler func;
-       void *user_data;
-
-       pid_t owner_tid;
-};
-
-struct _tdm_private_layer_buffer {
-       tbm_surface_h buffer;
-       struct list_head link;
-};
-
-typedef struct _tdm_buffer_info {
-       tbm_surface_h buffer;
-
-       /* ref_count for backend */
-       int backend_ref_count;
-
-       struct list_head release_funcs;
-       struct list_head destroy_funcs;
-
-       struct list_head *list;
-       struct list_head link;
-} tdm_buffer_info;
-
-typedef struct _tdm_pp_private_buffer {
-       tbm_surface_h src;
-       tbm_surface_h dst;
-       struct list_head link;
-       struct list_head commit_link;
-} tdm_pp_private_buffer;
-
-typedef struct _tdm_capture_private_buffer {
-       tbm_surface_h buffer;
-       struct list_head link;
-       struct list_head commit_link;
-} tdm_capture_private_buffer;
-
 int
 tdm_display_is_valid(tdm_display *display);
 
@@ -476,7 +110,7 @@ tdm_output_cb_status(tdm_output *output_backend, tdm_output_conn_status status,
 void
 tdm_output_cb_dpms(tdm_output *output_backend, tdm_output_dpms dpms,
                                   void *user_data);
-INTERN tdm_error
+tdm_error
 tdm_output_cb_need_validate(tdm_private_output *private_output);
 
 tdm_error
@@ -584,103 +218,6 @@ tdm_event_loop_flush(tdm_private_display *private_display);
 tdm_error
 tdm_event_loop_trace_enable(tdm_private_display *private_display, unsigned int enable);
 
-typedef enum {
-       TDM_THREAD_CB_NONE,
-       TDM_THREAD_CB_OUTPUT_COMMIT,
-       TDM_THREAD_CB_OUTPUT_VBLANK,
-       TDM_THREAD_CB_OUTPUT_STATUS,
-       TDM_THREAD_CB_OUTPUT_DPMS,
-       TDM_THREAD_CB_PP_DONE,
-       TDM_THREAD_CB_CAPTURE_DONE,
-       TDM_THREAD_CB_VBLANK_SW,
-       TDM_THREAD_CB_VBLANK_CREATE,
-       TDM_THREAD_CB_NEED_VALIDATE,
-} tdm_thread_cb_type;
-
-typedef struct _tdm_thread_cb_base tdm_thread_cb_base;
-typedef struct _tdm_thread_cb_output_vblank tdm_thread_cb_output_commit;
-typedef struct _tdm_thread_cb_output_vblank tdm_thread_cb_output_vblank;
-typedef struct _tdm_thread_cb_output_status tdm_thread_cb_output_status;
-typedef struct _tdm_thread_cb_output_dpms tdm_thread_cb_output_dpms;
-typedef struct _tdm_thread_cb_pp_done tdm_thread_cb_pp_done;
-typedef struct _tdm_thread_cb_capture_done tdm_thread_cb_capture_done;
-typedef struct _tdm_thread_cb_vblank_sw tdm_thread_cb_vblank_sw;
-typedef struct _tdm_thread_cb_vblank_create tdm_thread_cb_vblank_create;
-typedef struct _tdm_thread_cb_need_validate tdm_thread_cb_need_validate;
-
-struct _tdm_thread_cb_base {
-       tdm_thread_cb_type type;
-       unsigned int length;
-};
-
-struct _tdm_thread_cb_output_vblank {
-       tdm_thread_cb_base base;
-       double output_stamp;
-       unsigned int sequence;
-       unsigned int tv_sec;
-       unsigned int tv_usec;
-       void *user_data;
-};
-
-struct _tdm_thread_cb_output_status {
-       tdm_thread_cb_base base;
-       double output_stamp;
-       tdm_output_conn_status status;
-       void *user_data;
-};
-
-struct _tdm_thread_cb_output_dpms {
-       tdm_thread_cb_base base;
-       double output_stamp;
-       tdm_output_dpms dpms;
-       void *user_data;
-};
-
-struct _tdm_thread_cb_pp_done {
-       tdm_thread_cb_base base;
-       double pp_stamp;
-       tbm_surface_h src;
-       tbm_surface_h dst;
-       void *user_data;
-};
-
-struct _tdm_thread_cb_capture_done {
-       tdm_thread_cb_base base;
-       double capture_stamp;
-       tbm_surface_h buffer;
-       void *user_data;
-};
-
-struct _tdm_thread_cb_vblank_sw {
-       tdm_thread_cb_base base;
-       double vblank_stamp;
-};
-
-struct _tdm_thread_cb_vblank_create {
-       tdm_thread_cb_base base;
-       double vblank_stamp;
-};
-
-struct _tdm_thread_cb_need_validate {
-       tdm_thread_cb_base base;
-       tdm_private_output *o;
-};
-
-tdm_error
-tdm_thread_init(tdm_private_loop *private_loop);
-void
-tdm_thread_deinit(tdm_private_loop *private_loop);
-int
-tdm_thread_get_fd(tdm_private_loop *private_loop);
-tdm_error
-tdm_thread_send_cb(tdm_private_loop *private_loop, tdm_thread_cb_base *base);
-tdm_error
-tdm_thread_handle_cb(tdm_private_loop *private_loop);
-int
-tdm_thread_in_display_thread(pid_t tid);
-int
-tdm_thread_is_running(void);
-
 tdm_error
 tdm_server_init(tdm_private_loop *private_loop);
 void
@@ -697,82 +234,9 @@ tdm_helper_dump_buffer_str(tbm_surface_h buffer, char *dir, char *str);
 double
 tdm_helper_get_time(void);
 
-extern pthread_mutex_t tdm_mutex_check_lock;
-extern int tdm_mutex_locked;
-extern const char *tdm_mutex_lock_func;
-extern int tdm_mutex_lock_line;
-extern const char *tdm_mutex_unlock_func;
-extern int tdm_mutex_unlock_line;
 extern int tdm_dump_enable;
 extern char *tdm_debug_dump_dir;
 
-#define _pthread_mutex_unlock(l) \
-       do { \
-               if (tdm_debug_module & TDM_DEBUG_MUTEX) \
-                       TDM_INFO("mutex unlock"); \
-               pthread_mutex_lock(&tdm_mutex_check_lock); \
-               tdm_mutex_locked = 0; \
-               tdm_mutex_lock_func = NULL; \
-               tdm_mutex_lock_line = 0; \
-               tdm_mutex_unlock_func = __FUNCTION__; \
-               tdm_mutex_unlock_line = __LINE__; \
-               pthread_mutex_unlock(&tdm_mutex_check_lock); \
-               pthread_mutex_unlock(l); \
-       } while (0)
-#ifdef TDM_CONFIG_MUTEX_TIMEOUT
-#define MUTEX_TIMEOUT_SEC 5
-#define _pthread_mutex_lock(l) \
-       do { \
-               if (tdm_debug_module & TDM_DEBUG_MUTEX) \
-                       TDM_INFO("mutex lock"); \
-               struct timespec rtime; \
-               clock_gettime(CLOCK_REALTIME, &rtime); \
-               rtime.tv_sec += MUTEX_TIMEOUT_SEC; \
-               if (pthread_mutex_timedlock(l, &rtime)) { \
-                       TDM_ERR("Mutex lock failed PID %d", getpid()); \
-                       _pthread_mutex_unlock(l); \
-               } \
-               else { \
-                       pthread_mutex_lock(&tdm_mutex_check_lock); \
-                       tdm_mutex_locked = 1; \
-                       tdm_mutex_lock_func = __FUNCTION__; \
-                       tdm_mutex_lock_line = __LINE__; \
-                       tdm_mutex_unlock_func = NULL; \
-                       tdm_mutex_unlock_line = 0; \
-                       pthread_mutex_unlock(&tdm_mutex_check_lock); \
-               } \
-       } while (0)
-#else //TDM_CONFIG_MUTEX_TIMEOUT
-#define _pthread_mutex_lock(l) \
-       do { \
-               if (tdm_debug_module & TDM_DEBUG_MUTEX) \
-                       TDM_INFO("mutex lock"); \
-               pthread_mutex_lock(l); \
-               pthread_mutex_lock(&tdm_mutex_check_lock); \
-               tdm_mutex_locked = 1; \
-               tdm_mutex_lock_func = __FUNCTION__; \
-               tdm_mutex_lock_line = __LINE__; \
-               tdm_mutex_unlock_func = NULL; \
-               tdm_mutex_unlock_line = 0; \
-               pthread_mutex_unlock(&tdm_mutex_check_lock); \
-       } while (0)
-#endif //TDM_CONFIG_MUTEX_TIMEOUT
-//#define TDM_MUTEX_IS_LOCKED() (tdm_mutex_locked == 1)
-static inline int TDM_MUTEX_IS_LOCKED(void)
-{
-       int ret;
-       /* if thread is not running, we don't need to consider mutex things. */
-       if (!tdm_thread_is_running())
-               return 1;
-       pthread_mutex_lock(&tdm_mutex_check_lock);
-       ret = (tdm_mutex_locked == 1);
-       pthread_mutex_unlock(&tdm_mutex_check_lock);
-       return ret;
-}
-
-#define tdm_display_lock(dpy)   _pthread_mutex_lock(&((tdm_private_display *)dpy)->lock)
-#define tdm_display_unlock(dpy)   _pthread_mutex_unlock(&((tdm_private_display *)dpy)->lock)
-
 tdm_error
 tdm_display_update_output(tdm_private_display *private_display,
                                                  tdm_output *output_backend, int pipe);
@@ -790,12 +254,6 @@ tdm_display_enable_fps(tdm_private_display *private_display, int enable);
 void
 tdm_monitor_server_command(tdm_display *dpy, const char *options, char *reply, int *len);
 
-struct argument_details {
-       char type;
-       int nullable;
-};
-
-
 #ifdef __cplusplus
 }
 #endif
diff --git a/src/tdm_private_types.h b/src/tdm_private_types.h
new file mode 100644 (file)
index 0000000..fd641c1
--- /dev/null
@@ -0,0 +1,497 @@
+/**************************************************************************
+ *
+ * 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_PRIVATE_TYPES_H_
+#define _TDM_PRIVATE_TYPES_H_
+
+#include <pthread.h>
+#include <tbm_bufmgr.h>
+#include <tbm_surface_queue.h>
+
+#include "tdm_types.h"
+#include "tdm_list.h"
+#include "tdm_log.h"
+#include "tdm.h"
+#include "tdm_backend.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+//#define INIT_BUFMGR
+
+/*****************************************************************************
+ * This file defines private Enumerations and Structures for frontend
+ *****************************************************************************/
+
+enum {
+       TDM_DEBUG_NONE,
+       TDM_DEBUG_BUFFER    = (1 << 0),
+       TDM_DEBUG_MUTEX     = (1 << 1),
+       TDM_DEBUG_THREAD    = (1 << 2),
+       TDM_DEBUG_SERVER    = (1 << 3),
+       TDM_DEBUG_VBLANK    = (1 << 4),
+       TDM_DEBUG_COMMIT    = (1 << 5),
+};
+
+enum {
+       TDM_TTRACE_NONE,
+       TDM_TTRACE_VBLANK    = (1 << 0),
+       TDM_TTRACE_CLIENT    = (1 << 1),
+       TDM_TTRACE_LAYER     = (1 << 2),
+       TDM_TTRACE_PP        = (1 << 3),
+       TDM_TTRACE_CAPTURE   = (1 << 4),
+};
+
+typedef enum {
+       TDM_CAPTURE_TARGET_OUTPUT,
+       TDM_CAPTURE_TARGET_LAYER,
+} tdm_capture_target;
+
+enum {
+       TDM_DUMP_FLAG_LAYER   = (1 << 0),
+       TDM_DUMP_FLAG_PP      = (1 << 1),
+       TDM_DUMP_FLAG_CAPTURE = (1 << 2),
+       TDM_DUMP_FLAG_WINDOW = (1 << 3),
+};
+
+typedef enum {
+       TDM_COMMIT_TYPE_NONE,
+       TDM_COMMIT_TYPE_OUTPUT,
+       TDM_COMMIT_TYPE_LAYER,
+} tdm_commit_type;
+
+typedef struct _tdm_private_display tdm_private_display;
+typedef struct _tdm_private_output tdm_private_output;
+typedef struct _tdm_private_layer tdm_private_layer;
+typedef struct _tdm_private_hwc_window tdm_private_hwc_window;
+typedef struct _tdm_private_pp tdm_private_pp;
+typedef struct _tdm_private_capture tdm_private_capture;
+typedef struct _tdm_private_loop tdm_private_loop;
+typedef struct _tdm_private_server tdm_private_server;
+typedef struct _tdm_private_thread tdm_private_thread;
+typedef struct _tdm_private_vblank_handler tdm_private_vblank_handler;
+typedef struct _tdm_private_output_commit_handler tdm_private_output_commit_handler;
+typedef struct _tdm_private_layer_commit_handler tdm_private_layer_commit_handler;
+typedef struct _tdm_private_change_handler tdm_private_change_handler;
+typedef struct _tdm_private_layer_buffer tdm_private_layer_buffer;
+
+struct _tdm_private_display {
+       pthread_mutex_t lock;
+       unsigned int init_count;
+
+       /* backend module info */
+       void *module;
+       tdm_backend_module *module_data;
+       tdm_backend_data *bdata;
+
+#ifdef INIT_BUFMGR
+       tbm_bufmgr bufmgr;
+#endif
+
+       /* backend function */
+       tdm_display_capability capabilities;
+       tdm_func_display func_display;
+       tdm_func_output func_output;
+       tdm_func_layer func_layer;
+       tdm_func_hwc_window func_hwc_window;
+       tdm_func_pp func_pp;
+       tdm_func_capture func_capture;
+
+       /* backend capability */
+       tdm_caps_display caps_display;
+       tdm_caps_pp caps_pp;
+       tdm_caps_capture caps_capture;
+
+       /* output, pp list */
+       struct list_head output_list;
+       struct list_head pp_list;
+       struct list_head capture_list;
+
+       void **outputs_ptr;
+
+       /* for event handling */
+       tdm_private_loop *private_loop;
+
+       /* output order */
+       tdm_output **outputs;
+
+       int print_fps;
+};
+
+struct _tdm_private_output {
+       struct list_head link;
+
+       int index;
+       double stamp;
+
+       tdm_private_display *private_display;
+
+       tdm_caps_output caps;
+       tdm_output *output_backend;
+
+       unsigned int pipe;
+       tdm_output_dpms current_dpms_value;
+       unsigned int waiting_dpms_change;
+       const tdm_output_mode *current_mode;
+
+       int regist_vblank_cb;
+       int regist_commit_cb;
+       int regist_change_cb;
+       int regist_dpms_cb;
+
+       struct list_head layer_list;
+       struct list_head hwc_window_list;
+       struct list_head capture_list;
+       struct list_head vblank_handler_list;
+       struct list_head output_commit_handler_list;
+
+       /* for layer commit */
+       struct list_head layer_commit_handler_list;
+       struct list_head pending_commit_handler_list;
+       tdm_vblank *vblank;
+       int layer_waiting_vblank;
+
+       /* seperate list for multi-thread*/
+       struct list_head change_handler_list_main;
+       struct list_head change_handler_list_sub;
+
+       void **layers_ptr;
+
+       /* TODO: temp solution for handling DPMS things in sub-htread */
+       tdm_event_loop_source *dpms_changed_timer;
+
+       struct {
+               /* look at the tdm_output_set_need_revalidate_handler() declaration for the details */
+               tdm_output_need_validate_handler hndl;
+               int event_fd;
+               tdm_event_loop_source *event_source;
+       } need_validate;
+
+       /* calling a output commit per a vblank */
+       int commit_per_vblank;
+       tdm_commit_type commit_type;
+
+       /* for ttrace vblank */
+       tdm_vblank *ttrace_vblank;
+};
+
+struct _tdm_private_layer {
+       struct list_head link;
+
+       int index;
+
+       tdm_private_display *private_display;
+       tdm_private_output *private_output;
+
+       tdm_caps_layer caps;
+       tdm_layer *layer_backend;
+
+       /* pending data until committed */
+       unsigned int pending_info_changed;
+       tdm_info_layer pending_info;
+       unsigned int pending_buffer_changed;
+       tbm_surface_h pending_buffer;
+
+       /* When a buffer is set to a layer, it will be stored to waiting_buffer.
+        * And when a layer is committed, it will be moved to committed_buffer.
+        * Finally when a commit handler is called, it will be moved to showing_buffer.
+        */
+       tdm_private_layer_buffer *waiting_buffer;
+       tdm_private_layer_buffer *committed_buffer;   /* for output_commit */
+       tdm_private_layer_buffer *showing_buffer;
+       tbm_surface_queue_h buffer_queue;
+
+       struct list_head capture_list;
+
+       unsigned int usable;
+       unsigned int committing;
+
+       double fps_stamp;
+       unsigned int fps_count;
+};
+
+struct _tdm_private_hwc_window {
+       struct list_head link;
+
+       int index;
+       uint32_t zpos;
+
+       tdm_private_display *private_display;
+       tdm_private_output *private_output;
+
+       tdm_hwc_window *hwc_window_backend;
+};
+
+struct _tdm_private_pp {
+       struct list_head link;
+
+       double stamp;
+
+       tdm_private_display *private_display;
+
+       tdm_pp *pp_backend;
+
+       struct list_head pending_buffer_list;
+       struct list_head buffer_list;
+
+       tdm_info_pp info;
+       pid_t owner_tid;
+
+       tdm_pp_done_handler done_func;
+       void *done_user_data;
+};
+
+struct _tdm_private_capture {
+       struct list_head link;
+       struct list_head display_link;
+
+       double stamp;
+
+       tdm_capture_target target;
+
+       tdm_private_display *private_display;
+       tdm_private_output *private_output;
+       tdm_private_layer *private_layer;
+
+       tdm_capture *capture_backend;
+
+       struct list_head pending_buffer_list;
+       struct list_head buffer_list;
+
+       tdm_info_capture info;
+       pid_t owner_tid;
+
+       tdm_capture_done_handler done_func;
+       void *done_user_data;
+};
+
+/* CAUTION:
+ * Note that we don't need to (un)lock mutex to use this structure. If there is
+ * no TDM thread, all TDM resources are protected by private_display's mutex.
+ * If there is a TDM thread, this struct will be used only in a TDM thread.
+ * So, we don't need to protect this structure by mutex. Not thread-safe.
+ */
+struct _tdm_private_loop {
+       /* TDM uses wl_event_loop to handle various event sources including the TDM
+        * backend's fd.
+        */
+       struct wl_display *wl_display;
+       struct wl_event_loop *wl_loop;
+
+       int backend_fd;
+       tdm_event_loop_source *backend_source;
+
+       /* In event loop, all resources are accessed by this dpy.
+        * CAUTION:
+        * - DO NOT include other private structure in this structure because this
+        *   struct is not protected by mutex.
+        */
+       tdm_display *dpy;
+
+       /* for handling TDM client requests */
+       tdm_private_server *private_server;
+
+       /* To have a TDM event thread. If TDM_THREAD enviroment variable is not set
+        * private_thread is NULL.
+        */
+       tdm_private_thread *private_thread;
+};
+
+struct _tdm_private_vblank_handler {
+       struct list_head link;
+
+       tdm_private_output *private_output;
+       int interval;
+       int sync;
+       tdm_output_vblank_handler func;
+       void *user_data;
+
+       pid_t owner_tid;
+};
+
+struct _tdm_private_output_commit_handler {
+       struct list_head link;
+
+       tdm_private_output *private_output;
+       tdm_output_commit_handler func;
+       void *user_data;
+
+       pid_t owner_tid;
+};
+
+struct _tdm_private_layer_commit_handler {
+       struct list_head link;
+
+       tdm_private_layer *private_layer;
+       tdm_layer_commit_handler func;
+       void *user_data;
+
+       tdm_private_layer_buffer *committed_buffer;   /* for layer_commit */
+};
+
+struct _tdm_private_change_handler {
+       struct list_head link;
+
+       tdm_private_output *private_output;
+       tdm_output_change_handler func;
+       void *user_data;
+
+       pid_t owner_tid;
+};
+
+struct _tdm_private_layer_buffer {
+       tbm_surface_h buffer;
+       struct list_head link;
+};
+
+typedef struct _tdm_buffer_info {
+       tbm_surface_h buffer;
+
+       /* ref_count for backend */
+       int backend_ref_count;
+
+       struct list_head release_funcs;
+       struct list_head destroy_funcs;
+
+       struct list_head *list;
+       struct list_head link;
+} tdm_buffer_info;
+
+typedef struct _tdm_pp_private_buffer {
+       tbm_surface_h src;
+       tbm_surface_h dst;
+       struct list_head link;
+       struct list_head commit_link;
+} tdm_pp_private_buffer;
+
+typedef struct _tdm_capture_private_buffer {
+       tbm_surface_h buffer;
+       struct list_head link;
+       struct list_head commit_link;
+} tdm_capture_private_buffer;
+
+typedef enum {
+       TDM_THREAD_CB_NONE,
+       TDM_THREAD_CB_OUTPUT_COMMIT,
+       TDM_THREAD_CB_OUTPUT_VBLANK,
+       TDM_THREAD_CB_OUTPUT_STATUS,
+       TDM_THREAD_CB_OUTPUT_DPMS,
+       TDM_THREAD_CB_PP_DONE,
+       TDM_THREAD_CB_CAPTURE_DONE,
+       TDM_THREAD_CB_VBLANK_SW,
+       TDM_THREAD_CB_VBLANK_CREATE,
+       TDM_THREAD_CB_NEED_VALIDATE,
+} tdm_thread_cb_type;
+
+typedef struct _tdm_thread_cb_base tdm_thread_cb_base;
+typedef struct _tdm_thread_cb_output_vblank tdm_thread_cb_output_commit;
+typedef struct _tdm_thread_cb_output_vblank tdm_thread_cb_output_vblank;
+typedef struct _tdm_thread_cb_output_status tdm_thread_cb_output_status;
+typedef struct _tdm_thread_cb_output_dpms tdm_thread_cb_output_dpms;
+typedef struct _tdm_thread_cb_pp_done tdm_thread_cb_pp_done;
+typedef struct _tdm_thread_cb_capture_done tdm_thread_cb_capture_done;
+typedef struct _tdm_thread_cb_vblank_sw tdm_thread_cb_vblank_sw;
+typedef struct _tdm_thread_cb_vblank_create tdm_thread_cb_vblank_create;
+typedef struct _tdm_thread_cb_need_validate tdm_thread_cb_need_validate;
+
+struct _tdm_thread_cb_base {
+       tdm_thread_cb_type type;
+       unsigned int length;
+};
+
+struct _tdm_thread_cb_output_vblank {
+       tdm_thread_cb_base base;
+       double output_stamp;
+       unsigned int sequence;
+       unsigned int tv_sec;
+       unsigned int tv_usec;
+       void *user_data;
+};
+
+struct _tdm_thread_cb_output_status {
+       tdm_thread_cb_base base;
+       double output_stamp;
+       tdm_output_conn_status status;
+       void *user_data;
+};
+
+struct _tdm_thread_cb_output_dpms {
+       tdm_thread_cb_base base;
+       double output_stamp;
+       tdm_output_dpms dpms;
+       void *user_data;
+};
+
+struct _tdm_thread_cb_pp_done {
+       tdm_thread_cb_base base;
+       double pp_stamp;
+       tbm_surface_h src;
+       tbm_surface_h dst;
+       void *user_data;
+};
+
+struct _tdm_thread_cb_capture_done {
+       tdm_thread_cb_base base;
+       double capture_stamp;
+       tbm_surface_h buffer;
+       void *user_data;
+};
+
+struct _tdm_thread_cb_vblank_sw {
+       tdm_thread_cb_base base;
+       double vblank_stamp;
+};
+
+struct _tdm_thread_cb_vblank_create {
+       tdm_thread_cb_base base;
+       double vblank_stamp;
+};
+
+struct _tdm_thread_cb_need_validate {
+       tdm_thread_cb_base base;
+       tdm_private_output *o;
+};
+
+struct argument_details {
+       char type;
+       int nullable;
+};
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _TDM_PRIVATE_TYPES_H_ */
index e4a3e75..0a359f4 100644 (file)
 #include "config.h"
 #endif
 
-#include "tdm.h"
+#include <tdm-server-protocol.h>
+
 #include "tdm_private.h"
-#include "tdm_list.h"
-#include "tdm-server-protocol.h"
 
 /* CAUTION:
  * - tdm server doesn't care about thread things.
index a775690..22d67af 100644 (file)
 #include "config.h"
 #endif
 
-#include <sys/socket.h>
-
-#include "tdm.h"
 #include "tdm_private.h"
-#include "tdm_list.h"
 
 static tdm_private_thread *keep_private_thread;
 
diff --git a/src/tdm_thread.h b/src/tdm_thread.h
new file mode 100644 (file)
index 0000000..c9ef06d
--- /dev/null
@@ -0,0 +1,65 @@
+/**************************************************************************
+ *
+ * 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_THREAD_H_
+#define _TDM_THREAD_H_
+
+#include "tdm_private_types.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+tdm_error
+tdm_thread_init(tdm_private_loop *private_loop);
+void
+tdm_thread_deinit(tdm_private_loop *private_loop);
+int
+tdm_thread_get_fd(tdm_private_loop *private_loop);
+tdm_error
+tdm_thread_send_cb(tdm_private_loop *private_loop, tdm_thread_cb_base *base);
+tdm_error
+tdm_thread_handle_cb(tdm_private_loop *private_loop);
+int
+tdm_thread_in_display_thread(pid_t tid);
+int
+tdm_thread_is_running(void);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _TDM_THREAD_H_ */
+
index abba414..4a0d03f 100644 (file)
 #include "config.h"
 #endif
 
-#include "tdm.h"
 #include "tdm_private.h"
-#include "tdm_list.h"
-#include "tdm_macro.h"
 
 /* CAUTION:
  * Basically tdm vblank doesn't care about thread things.
index 907e6f8..318dcde 100644 (file)
@@ -37,7 +37,7 @@
 #include <tbm_bufmgr.h>
 #include <tbm_surface.h>
 
-#include <tdm_log.h>
+#include "tdm_log.h"
 #include "tdm_macro.h"
 #include "buffers.h"
 
index 879668e..a8e7c62 100644 (file)
@@ -41,7 +41,7 @@
 #include <time.h>
 #include <stdint.h>
 
-#include <tdm_client.h>
+#include "tdm_client.h"
 #include "tdm_macro.h"
 
 typedef struct _tdm_test_client_arg {
index 76a437d..7dff9eb 100644 (file)
 #include <tbm_surface.h>
 #include <tbm_surface_internal.h>
 
-#include <tdm.h>
-#include <tdm_log.h>
-#include <tdm_list.h>
-#include <tdm_helper.h>
-#include <tdm_backend.h>
+#include "tdm.h"
+#include "tdm_log.h"
+#include "tdm_list.h"
+#include "tdm_helper.h"
+#include "tdm_backend.h"
 
 #include "tdm_macro.h"
 #include "tdm_private.h"