X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=src%2Ftdm_macro.h;h=bd7e2570cc48bd3ad69332cf60028b36d0162b00;hb=97ed6da7ed4f7663a64fe9436c6ad4292b15c232;hp=78e2643543036823b59d2ed9df06bef9cc9107d7;hpb=e77e3b05eea42d515618712dfc8cdc1d8569fc3f;p=platform%2Fcore%2Fuifw%2Flibtdm.git diff --git a/src/tdm_macro.h b/src/tdm_macro.h index 78e2643..bd7e257 100644 --- a/src/tdm_macro.h +++ b/src/tdm_macro.h @@ -9,7 +9,7 @@ * Taeheon Kim , * YoungJun Cho , * SooChan Lim , - * Boram Park + * Boram Park * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the @@ -50,96 +50,7 @@ extern "C" { #endif -#define TDM_DUMP_DIR "/tmp" - -#define TDM_SERVER_REPLY_MSG_LEN 8192 -#define TDM_DEBUG_REPLY_MSG_LEN 2048 - -#undef EXTERN -#undef DEPRECATED -#undef INTERN - -#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 - -#if defined(__GNUC__) && __GNUC__ >= 4 -#define DEPRECATED __attribute__ ((deprecated)) -#else -#define DEPRECATED -#endif - -/* check condition */ -#define TDM_RETURN_IF_FAIL(cond) { \ - if (!(cond)) { \ - TDM_ERR("'%s' failed", #cond); \ - return; \ - } \ -} -#define TDM_RETURN_VAL_IF_FAIL(cond, val) { \ - if (!(cond)) { \ - TDM_ERR("'%s' failed", #cond); \ - return val; \ - } \ -} -#define TDM_RETURN_VAL_IF_FAIL_WITH_ERROR(cond, error_v, val) { \ - if (!(cond)) { \ - TDM_ERR("'%s' failed", #cond); \ - ret = error_v; \ - if (error) *error = ret; \ - return val; \ - } \ -} - -#define TDM_WARNING_IF_FAIL(cond) { \ - if (!(cond)) \ - TDM_WRN("'%s' failed", #cond); \ -} -#define TDM_GOTO_IF_FAIL(cond, dst) { \ - if (!(cond)) { \ - TDM_ERR("'%s' failed", #cond); \ - goto dst; \ - } \ -} -#define TDM_EXIT_IF_FAIL(cond) { \ - if (!(cond)) { \ - TDM_ERR("'%s' failed", #cond); \ - exit(0); \ - } \ -} - -#define TDM_NEVER_GET_HERE() TDM_WRN("** NEVER GET HERE **") - -#define TDM_SNPRINTF(p, len, fmt, ARG...) \ - do { \ - if (p && len && *len > 0) { \ - int s = snprintf(p, *len, fmt, ##ARG); \ - p += s; \ - *len -= s; \ - } \ - } while (0) - -#define TDM_DBG_RETURN_IF_FAIL(cond) { \ - if (!(cond)) { \ - TDM_SNPRINTF(reply, len, "[%s %d] '%s' failed\n", __func__, __LINE__, #cond); \ - return; \ - } \ -} -#define TDM_DBG_GOTO_IF_FAIL(cond, dst) { \ - if (!(cond)) { \ - TDM_SNPRINTF(reply, len, "[%s %d] '%s' failed\n", __func__, __LINE__, #cond); \ - goto dst; \ - } \ -} - +/* not-categorized **********************************************************/ #define TDM_NOT_DEFINED_VALUE (-1) #define TDM_FRONT_VALUE(n) (((n) > 0) ? (n) : TDM_NOT_DEFINED_VALUE) @@ -163,6 +74,28 @@ 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_SNPRINTF(p, len, fmt, ARG...) \ + do { \ + if (p && len && *len > 0) { \ + int s = snprintf(p, *len, fmt, ##ARG); \ + p += s; \ + *len -= s; \ + } \ + } 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" + +/* message length ***********************************************************/ +#define TDM_SERVER_REPLY_MSG_LEN 8192 +#define TDM_DEBUG_REPLY_MSG_LEN 2048 + +/* DPMS *********************************************************************/ /* can't export VSYNC macro because we can't define the exact meaning of vsync off * at this time. Does committing in standy mode work? Doesn't committing in suspend mode work? */ @@ -170,6 +103,48 @@ extern "C" { #define TDM_OUTPUT_DPMS_VSYNC_OFF_MASK 0x2 #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) +{ + char *end; + end = strpbrk(str, delim); + if (end) + len = ((end - str + 1) < len) ? (end - str + 1) : len; + else { + int l = strlen(str); + len = ((l + 1) < len) ? (l + 1) : len; + } + snprintf(buf, len, "%s", str); + return str + len - 1; +} +/* LCOV_EXCL_STOP */ + +/* EXTERN, INTERN, DEPRECATED ***********************************************/ +#undef EXTERN +#undef DEPRECATED +#undef INTERN + +#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 + +#if defined(__GNUC__) && __GNUC__ >= 4 +#define DEPRECATED __attribute__ ((deprecated)) +#else +#define DEPRECATED +#endif + +/* type to string ***********************************************************/ struct tdm_type_name { int type; const char *name; @@ -186,6 +161,23 @@ static inline const char * tdm_##res##_str(int type) \ return "(invalid)"; \ } +static struct tdm_type_name tdm_error_names[] = { + { TDM_ERROR_NONE, "Success" }, + { TDM_ERROR_BAD_REQUEST, "bad request" }, + { TDM_ERROR_OPERATION_FAILED, "operaion failed" }, + { TDM_ERROR_INVALID_PARAMETER, "wrong input parameter" }, + { TDM_ERROR_PERMISSION_DENIED, "access denied" }, + { TDM_ERROR_BUSY, "hardware resource busy" }, + { TDM_ERROR_OUT_OF_MEMORY, "no free memory" }, + { TDM_ERROR_BAD_MODULE, "bad backend module" }, + { TDM_ERROR_NOT_IMPLEMENTED, "not implemented" }, + { TDM_ERROR_NO_CAPABILITY, "no capability" }, + { TDM_ERROR_DPMS_OFF, "dpms off" }, + { TDM_ERROR_OUTPUT_DISCONNECTED, "output disconnected" }, + { TDM_ERROR_PROTOCOL_ERROR, "protocol error" }, +}; +TDM_TYPE_NAME_FN(error) + static struct tdm_type_name tdm_dpms_names[] = { { TDM_OUTPUT_DPMS_ON, "on" }, { TDM_OUTPUT_DPMS_STANDBY, "standby" }, @@ -223,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" }, @@ -245,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) \ { \ @@ -325,21 +341,63 @@ static const char *tdm_capture_caps_names[] = { }; TDM_BIT_NAME_FB(capture_caps) -static inline char* -strtostr(char *buf, int len, char *str, char *delim) -{ - char *end; - end = strpbrk(str, delim); - if (end) - len = ((end - str + 1) < len) ? (end - str + 1) : len; - else { - int l = strlen(str); - len = ((l + 1) < len) ? (l + 1) : len; - } - snprintf(buf, len, "%s", str); - return str + len - 1; +/* check condition **********************************************************/ +#define TDM_RETURN_IF_FAIL(cond) { \ + if (!(cond)) { \ + TDM_ERR("'%s' failed", #cond); \ + return; \ + } \ +} +#define TDM_RETURN_VAL_IF_FAIL(cond, val) { \ + if (!(cond)) { \ + TDM_ERR("'%s' failed", #cond); \ + return val; \ + } \ +} +#define TDM_RETURN_VAL_IF_FAIL_WITH_ERROR(cond, error_v, val) { \ + if (!(cond)) { \ + TDM_ERR("'%s' failed", #cond); \ + ret = error_v; \ + if (error) *error = ret; \ + return val; \ + } \ +} +#define TDM_WARNING_IF_FAIL(cond) { \ + if (!(cond)) \ + TDM_WRN("'%s' failed", #cond); \ +} +#define TDM_GOTO_IF_FAIL(cond, dst) { \ + if (!(cond)) { \ + TDM_ERR("'%s' failed", #cond); \ + goto dst; \ + } \ +} +#define TDM_EXIT_IF_FAIL(cond) { \ + if (!(cond)) { \ + TDM_ERR("'%s' failed", #cond); \ + exit(0); \ + } \ +} +#define TDM_DBG_RETURN_IF_FAIL(cond) { \ + if (!(cond)) { \ + TDM_SNPRINTF(reply, len, "[%s %d] '%s' failed\n", __func__, __LINE__, #cond); \ + 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); \ + goto dst; \ + } \ } +/* trace ********************************************************************/ #ifdef HAVE_TTRACE #include #define TDM_TRACE_BEGIN(fmt, ...) traceBegin(TTRACE_TAG_GRAPHICS, fmt, ##__VA_ARGS__) @@ -357,13 +415,14 @@ strtostr(char *buf, int len, char *str, char *delim) #define TDM_TRACE_MARK(fmt, ...) #endif - +/* display mutex ************************************************************/ 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_debug_module; #define _pthread_mutex_lock(l) \ do { \ @@ -408,6 +467,30 @@ static inline int TDM_MUTEX_IS_LOCKED(void) #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) + +/* 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