virtual: define functions and structure for supporting virtual output
[platform/core/uifw/libtdm.git] / src / tdm_macro.h
index e75220c..bd7e257 100644 (file)
@@ -9,7 +9,7 @@
  *          Taeheon Kim <th908.kim@samsung.com>,
  *          YoungJun Cho <yj44.cho@samsung.com>,
  *          SooChan Lim <sc1.lim@samsung.com>,
- *          Boram Park <sc1.lim@samsung.com>
+ *          Boram Park <boram1288.park@samsung.com>
  *
  * Permission is hereby granted, free of charge, to any person obtaining a
  * copy of this software and associated documentation files (the
@@ -74,8 +74,6 @@ extern "C" {
 #define TDM_SWAP(a, b)      ({ int t; t = a; a = b; b = t; })
 #define TDM_ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
 
-#define TDM_NEVER_GET_HERE() TDM_WRN("** NEVER GET HERE **")
-
 #define TDM_SNPRINTF(p, len, fmt, ARG...)  \
        do { \
                if (p && len && *len > 0) { \
@@ -85,6 +83,11 @@ extern "C" {
                } \
        } while (0)
 
+/* common backend names *****************************************************/
+#define TDM_DEFAULT_MODULE        "libtdm-default.so"
+#define TDM_DUMMY_MODULE          "libtdm-dummy.so"
+#define TDM_VIRTUAL_MODULE        "libtdm-virtual.so"
+
 /* dump directory ***********************************************************/
 #define TDM_DUMP_DIR    "/tmp"
 
@@ -101,6 +104,7 @@ extern "C" {
 #define TDM_OUTPUT_DPMS_VSYNC_IS_OFF(dpms)   ((dpms) & TDM_OUTPUT_DPMS_VSYNC_OFF_MASK)
 
 /* strtostr *****************************************************************/
+/* LCOV_EXCL_START */
 static inline char*
 strtostr(char *buf, int len, char *str, char *delim)
 {
@@ -115,6 +119,7 @@ strtostr(char *buf, int len, char *str, char *delim)
        snprintf(buf, len, "%s", str);
        return str + len - 1;
 }
+/* LCOV_EXCL_STOP */
 
 /* EXTERN, INTERN, DEPRECATED ***********************************************/
 #undef EXTERN
@@ -210,6 +215,12 @@ static struct tdm_type_name tdm_conn_names[] = {
 };
 TDM_TYPE_NAME_FN(conn)
 
+static struct tdm_type_name tdm_capture_type_names[] = {
+       { TDM_CAPTURE_TYPE_ONESHOT, "none" },
+       { TDM_CAPTURE_TYPE_STREAM, "90" },
+};
+TDM_TYPE_NAME_FN(capture_type)
+
 static struct tdm_type_name tdm_transform_names[] = {
        { TDM_TRANSFORM_NORMAL, "none" },
        { TDM_TRANSFORM_90, "90" },
@@ -232,6 +243,24 @@ static struct tdm_type_name tdm_value_type_names[] = {
 };
 TDM_TYPE_NAME_FN(value_type)
 
+static struct tdm_type_name tdm_cb_type_names[] = {
+       { TDM_THREAD_CB_NONE, "none" },
+       { TDM_THREAD_CB_EXIT, "exit" },
+       { TDM_THREAD_CB_DISPLAY_OUTPUT_CREATE, "output-create" },
+       { TDM_THREAD_CB_OUTPUT_DESTROY, "output-destroy" },
+       { TDM_THREAD_CB_OUTPUT_COMMIT, "output-commit" },
+       { TDM_THREAD_CB_OUTPUT_VBLANK, "output-vblank" },
+       { TDM_THREAD_CB_OUTPUT_STATUS, "output-status" },
+       { TDM_THREAD_CB_OUTPUT_DPMS, "output-dpms" },
+       { TDM_THREAD_CB_PP_DONE, "pp-done" },
+       { TDM_THREAD_CB_CAPTURE_DONE, "capture-done" },
+       { TDM_THREAD_CB_VBLANK_SW, "vblank-sw" },
+       { TDM_THREAD_CB_VBLANK_CREATE, "vblank-create" },
+       { TDM_THREAD_CB_HWC_COMMIT, "hwc-commit" },
+       { TDM_THREAD_CB_VOUTPUT_COMMIT, "voutput-commit" },
+};
+TDM_TYPE_NAME_FN(cb_type)
+
 #define TDM_BIT_NAME_FB(res)                                   \
 static inline const char * tdm_##res##_str(int type, char **reply, int *len)   \
 {                      \
@@ -355,6 +384,12 @@ TDM_BIT_NAME_FB(capture_caps)
                return; \
        } \
 }
+#define TDM_DBG_RETURN_VAL_IF_FAIL(cond, val) { \
+       if (!(cond))  { \
+               TDM_SNPRINTF(reply, len, "[%s %d] '%s' failed\n", __func__, __LINE__, #cond); \
+               return val; \
+       } \
+}
 #define TDM_DBG_GOTO_IF_FAIL(cond, dst) { \
        if (!(cond))  { \
                TDM_SNPRINTF(reply, len, "[%s %d] '%s' failed\n", __func__, __LINE__, #cond); \
@@ -433,6 +468,29 @@ static inline int TDM_MUTEX_IS_LOCKED(void)
 #define tdm_display_unlock(dpy)   _pthread_mutex_unlock(&((tdm_private_display *)dpy)->lock)
 
 
+/* debugging mutex ************************************************************/
+extern pthread_mutex_t tdm_debug_mutex_check_lock;
+extern const char *tdm_debug_mutex_lock_func;
+extern int tdm_debug_mutex_lock_line;
+
+#define _debug_pthread_mutex_lock(l) \
+       do { \
+               pthread_mutex_lock(l); \
+               pthread_mutex_lock(&tdm_debug_mutex_check_lock); \
+               tdm_debug_mutex_lock_func = __FUNCTION__; \
+               tdm_debug_mutex_lock_line = __LINE__; \
+               pthread_mutex_unlock(&tdm_debug_mutex_check_lock); \
+       } while (0)
+
+#define _debug_pthread_mutex_unlock(l) \
+       do { \
+               pthread_mutex_lock(&tdm_debug_mutex_check_lock); \
+               tdm_debug_mutex_lock_func = NULL; \
+               tdm_debug_mutex_lock_line = 0; \
+               pthread_mutex_unlock(&tdm_debug_mutex_check_lock); \
+               pthread_mutex_unlock(l); \
+       } while (0)
+
 #ifdef __cplusplus
 }
 #endif