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
41 #include <tbm_bufmgr.h>
42 #include <wayland-util.h>
44 #include <wayland-tbm-client.h>
55 #define LOG_TAG "WL_TBM"
56 #define WL_TBM_C_LOG(fmt, ...) LOGI(fmt, ##__VA_ARGS__);
57 #define WL_TBM_S_LOG(fmt, ...) LOGI(fmt, ##__VA_ARGS__);
58 #define WL_TBM_LOG(fmt, ...) LOGI(fmt, ##__VA_ARGS__);
60 #define WL_TBM_LOG_E(fmt, ...) LOGE(fmt, ##__VA_ARGS__);
62 #define WL_TBM_C_LOG(fmt, ...) fprintf(stderr, "[WL_TBM_C(%d):%s] " fmt"\n", getpid(), __func__, ##__VA_ARGS__)
63 #define WL_TBM_S_LOG(fmt, ...) fprintf(stderr, "[WL_TBM_S(%d):%s] " fmt"\n", getpid(), __func__, ##__VA_ARGS__)
64 #define WL_TBM_LOG(fmt, ...) fprintf(stderr, "[WL_TBM(%d)] " fmt"\n", getpid(), ##__VA_ARGS__)
65 #define WL_TBM_LOG_E(fmt, ...) fprintf(stderr, "[WL_TBM_E(%d)] " fmt"\n", getpid(), ##__VA_ARGS__)
66 #endif /* ENABLE_DLOG */
68 #define C(b, m) (((b) >> (m)) & 0xFF)
69 #define FOURCC_STR(id) C(id, 0), C(id, 8), C(id, 16), C(id, 24)
72 #define WL_TBM_RETURN_IF_FAIL(cond) {\
74 WL_TBM_LOG_E("'%s' failed.", #cond);\
78 #define WL_TBM_RETURN_VAL_IF_FAIL(cond, val) {\
80 WL_TBM_LOG_E("'%s' failed.", #cond);\
84 #define WL_TBM_GOTO_IF_FAIL(cond, dst) {\
86 WL_TBM_LOG_E("'%s' failed.", #cond);\
91 #define WL_TBM_ARRAY_NTH_DATA(array, type, n) (((type*)((array)->data)) + n)
94 WL_TBM_MONITOR_PROC_STATE_OFF,
95 WL_TBM_MONITOR_PROC_STATE_ON,
96 WL_TBM_MONITOR_PROC_STATE_STATUS,
97 WL_TBM_MONITOR_PROC_STATE_UNKNOWN,
98 } WL_TBM_MONITOR_PROC_STATE;
101 WL_TBM_MONITOR_RES_BO,
102 WL_TBM_MONITOR_RES_SURFACE_INTERNAL,
103 WL_TBM_MONITOR_RES_SURFACE,
104 WL_TBM_MONITOR_RES_SURFACE_QUEUE,
105 WL_TBM_MONITOR_RES_WL_TBM,
106 WL_TBM_MONITOR_RES_ALL,
107 WL_TBM_MONITOR_RES_UNKNOWN,
108 } WL_TBM_MONITOR_RES;
110 #define WL_TBM_MONITOR_REPLY_MSG_LEN 8192
111 #define WL_TBM_MONITOR_ARGS_MAX 12
112 #define WL_TBM_MONITOR_PATH_LEN 256
114 #define WL_TBM_MONITOR_SNPRINTF(p, len, fmt, ARG...) \
116 if (p && (len) > 0) { \
117 int s = snprintf(p, (len), fmt, ##ARG); \
127 struct wayland_tbm_server {
128 struct wl_display *display;
129 struct wl_global *wl_tbm_global;
130 struct wl_global *wl_tbm_monitor_global;
134 struct wl_list cqueue_list; /* for scanout buffer */
135 struct wl_list tbm_monitor_list; /* for tbm monitor */
136 struct wl_list tbm_monitor_request_list; /* for tbm monitor */
142 struct wayland_tbm_monitor_target {
148 struct wayland_tbm_monitor_path {
151 char file[WL_TBM_MONITOR_PATH_LEN];
154 /* internal functions */
156 _wayland_tbm_util_get_appname_brief(char *brief);
159 _wayland_tbm_util_get_appname_from_pid(long pid, char *str);
162 _wayland_tbm_util_target_parse(char * target_str, struct wayland_tbm_monitor_target *target);
165 _wayland_tbm_util_scale_parse(char * scale_str, double *scale);
168 _wayland_tbm_util_debug_level_parse(char * str, int *debug_level);
171 _wayland_tbm_util_show_path_parse(char * path_str, char * cwd, struct wayland_tbm_monitor_path *path);
174 _wayland_tbm_util_dump_path_parse(char * path_str);
176 WL_TBM_MONITOR_PROC_STATE
177 _wayland_tbm_util_proc_state_parse(char * str);
180 _wayland_tbm_util_resource_parse(char * str);
183 _wayland_tbm_util_dump_queue(WL_TBM_MONITOR_PROC_STATE cmd, tbm_bufmgr bufmgr, double scale);
186 _wayland_tbm_util_dump_snapshot(tbm_bufmgr bufmgr, double scale, char *path);
189 _wayland_tbm_util_trace(WL_TBM_MONITOR_PROC_STATE cmd, WL_TBM_MONITOR_RES res, tbm_bufmgr bufmgr);
192 _wayland_tbm_dump_directory_make(const char *path);
195 _wayland_tbm_util_set_log_level(int debug_level);
198 wayland_tbm_monitor_server_init(struct wayland_tbm_server *tbm_srv);
201 wayland_tbm_monitor_client_init(struct wayland_tbm_client *tbm_client,
202 struct wl_registry *registry, uint32_t name, uint32_t version);
205 wayland_tbm_monitor_client_deinit(struct wayland_tbm_client *tbm_client);