2 Copyright (C) 2015 Samsung Electronics co., Ltd. All Rights Reserved.
5 SooChan Lim <sc1.lim@samsung.com>,
6 Sangjin Lee <lsj119@samsung.com>,
7 Boram Park <boram1288.park@samsung.com>,
8 Changyeon Lee <cyeon.lee@samsung.com>
10 Permission is hereby granted, free of charge, to any person obtaining a
11 copy of this software and associated documentation files (the "Software"),
12 to deal in the Software without restriction, including without limitation
13 the rights to use, copy, modify, merge, publish, distribute, sublicense,
14 and/or sell copies of the Software, and to permit persons to whom the
15 Software is furnished to do so, subject to the following conditions:
17 The above copyright notice and this permission notice (including the next
18 paragraph) shall be included in all copies or substantial portions of the
21 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
24 THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
26 FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
27 DEALINGS IN THE SOFTWARE.
30 #ifndef WAYLAND_TBM_INT_H
31 #define WAYLAND_TBM_INT_H
37 #include <tbm_bufmgr.h>
38 #include <wayland-util.h>
51 #define LOG_TAG "WL_TBM"
53 #define WL_TBM_C_LOG(fmt, ...) {\
55 LOGE(fmt, ##__VA_ARGS__);\
58 fprintf(stderr, "[WL_TBM_C(%d):%s] " fmt"\n", getpid(), __func__, ##__VA_ARGS__);\
61 #define WL_TBM_S_LOG(fmt, ...) {\
63 LOGI(fmt, ##__VA_ARGS__);\
66 fprintf(stderr, "[WL_TBM_S(%d):%s] " fmt"\n", getpid(), __func__, ##__VA_ARGS__);\
69 #define WL_TBM_LOG(fmt, ...) {\
71 LOGI(fmt, ##__VA_ARGS__);\
74 fprintf(stderr, "[WL_TBM(%d)] " fmt"\n", getpid(), ##__VA_ARGS__);\
79 #define WL_TBM_LOG_E(fmt, ...) {\
81 LOGE(fmt, ##__VA_ARGS__);\
84 fprintf(stderr, "[WL_TBM(%d)] " fmt"\n", getpid(), ##__VA_ARGS__);\
89 #define WL_TBM_C_LOG(fmt, ...) fprintf(stderr, "[WL_TBM_C(%d):%s] " fmt"\n", getpid(), __func__, ##__VA_ARGS__)
90 #define WL_TBM_S_LOG(fmt, ...) fprintf(stderr, "[WL_TBM_S(%d):%s] " fmt"\n", getpid(), __func__, ##__VA_ARGS__)
91 #define WL_TBM_LOG(fmt, ...) fprintf(stderr, "[WL_TBM(%d)] " fmt"\n", getpid(), ##__VA_ARGS__)
92 #define WL_TBM_LOG_E(fmt, ...) fprintf(stderr, "[WL_TBM_E(%d)] " fmt"\n", getpid(), ##__VA_ARGS__)
93 #endif /* ENABLE_DLOG */
97 #define WL_TBM_RETURN_IF_FAIL(cond) {\
99 WL_TBM_LOG("'%s' failed.", #cond);\
103 #define WL_TBM_RETURN_VAL_IF_FAIL(cond, val) {\
105 WL_TBM_LOG("'%s' failed.", #cond);\
109 #define WL_TBM_GOTO_IF_FAIL(cond, dst) {\
111 WL_TBM_LOG("'%s' failed.", #cond);\
116 #define WL_TBM_ARRAY_NTH_DATA(array, type, n) (((type*)((array)->data)) + n)
119 WL_TBM_MONITOR_PROC_STATE_OFF,
120 WL_TBM_MONITOR_PROC_STATE_ON,
121 WL_TBM_MONITOR_PROC_STATE_STATUS,
122 WL_TBM_MONITOR_PROC_STATE_UNKNOWN,
123 } WL_TBM_MONITOR_PROC_STATE;
125 #define WL_TBM_MONITOR_REPLY_MSG_LEN 8192
126 #define WL_TBM_MONITOR_ARGS_MAX 12
127 #define WL_TBM_MONITOR_PATH_LEN 256
129 #define WL_TBM_MONITOR_SNPRINTF(p, len, fmt, ARG...) \
131 if (p && (len) > 0) { \
132 int s = snprintf(p, (len), fmt, ##ARG); \
142 struct wayland_tbm_server {
143 struct wl_display *display;
144 struct wl_global *wl_tbm_global;
145 struct wl_global *wl_tbm_monitor_global;
149 struct wl_list cqueue_list; /* for scanout buffer */
150 struct wl_list tbm_monitor_list; /* for tbm monitor */
151 struct wl_list tbm_monitor_request_list; /* for tbm monitor */
157 struct wayland_tbm_monitor_target {
163 struct wayland_tbm_monitor_path {
166 char file[WL_TBM_MONITOR_PATH_LEN];
169 /* internal functions */
171 _wayland_tbm_util_get_appname_brief(char *brief);
174 _wayland_tbm_util_get_appname_from_pid(long pid, char *str);
177 _wayland_tbm_check_dlog_enable(void);
180 _waylend_tbm_util_target_parse(char * target_str, struct wayland_tbm_monitor_target *target);
183 _waylend_tbm_util_scale_parse(char * scale_str, double *scale);
186 _wayland_tbm_util_show_path_parse(char * path_str, char * cwd, struct wayland_tbm_monitor_path *path);
188 WL_TBM_MONITOR_PROC_STATE
189 _waylend_tbm_util_proc_state_parse(char * str);
192 _waylend_tbm_util_dump_queue(WL_TBM_MONITOR_PROC_STATE cmd, tbm_bufmgr bufmgr, double scale);
195 _waylend_tbm_util_dump_snapshot(tbm_bufmgr bufmgr, double scale, char *path);
198 _waylend_tbm_util_trace(WL_TBM_MONITOR_PROC_STATE cmd, tbm_bufmgr bufmgr);
201 _wayland_tbm_dump_directory_make(void);
203 int wayland_tbm_monitor_server_init(struct wayland_tbm_server *tbm_srv);