1 /**************************************************************************
5 Copyright (c) 2013 Samsung Electronics Co., Ltd All Rights Reserved
7 Contact: Boram Park <boram1288.park@samsung.com>
8 Sangjin LEE <lsj119@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
12 "Software"), to deal in the Software without restriction, including
13 without limitation the rights to use, copy, modify, merge, publish,
14 distribute, sub license, and/or sell copies of the Software, and to
15 permit persons to whom the Software is furnished to do so, subject to
16 the following conditions:
18 The above copyright notice and this permission notice (including the
19 next paragraph) shall be included in all copies or substantial portions
22 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
23 OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
24 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
25 IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
26 ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
27 TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
28 SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
30 **************************************************************************/
32 #if defined(XDBG_CLIENT)
33 #error "This header is not for client."
36 #ifndef __XDBG_DUMP_H__
37 #define __XDBG_DUMP_H__
39 #include <X11/Xdefs.h>
40 #include <X11/Xprotostr.h>
42 /* "xdbg dump" is designed for "x video driver" to dump various buffers without
43 * losing performance. When it starts, it allocates 50 dump-buffers by default.
44 * You can change the count of dump-buffers with "-count" option. After starting,
45 * various buffers will be copied into dump-buffers. Finally when it stops,
46 * all copied buffers will be saved into "/tmp/xdump" directory.
47 * You can use "-type" option to distinguish the type of various buffers inside of
50 * # xdbg dump on //begin
51 * # xdbg dump off //off with saving
52 * # xdbg dump clear //off without saving
53 * # xdbg dump -count [n]
54 * # xdbg dump -type [drawable|fb|ui|video]
55 * # xdbg dump on -type ui -count 100
56 * # xdbg dump -type 0x2000 //user-defined type(number only)
57 * # xdbg dump -crop 10,10,200,200 //dump only (10,10 200x200) area
61 XDBG_DUMP_TYPE_NONE = 0x00000000,
62 XDBG_DUMP_TYPE_DRAWABLE = 0x00000001,
63 XDBG_DUMP_TYPE_FB = 0x00000010,
64 XDBG_DUMP_TYPE_UI = 0x00000011,
65 XDBG_DUMP_TYPE_VIDEO = 0x00000100,
68 /* "xDbgDumpBufferFunc" should be implemented in "x video driver". */
71 /* [in ] dump_buf_size: size of dump-buffer
72 * [out] a newly-allocated dump-buffer
74 void* (*alloc) (int dump_buf_size);
76 /* map() should return virtual address of dump-buffer. If alloc() returns
77 * virtual address, map() and unmap() can be NULL. Don't need to implement.
78 * [in ] dump_buf: a dump-buffer
79 * [out] virtual address of a dump-buffer
81 void* (*map) (void *dump_buf);
82 void (*unmap) (void *dump_buf);
83 void (*free) (void *dump_buf);
85 /* xDbgDumpBmp() calls dumpBum(). Returned dump_w, dump_h and dump_rect will
86 * be used when a dump-buffer is saved to a bmp file.
87 * If you don't call xDbgDumpBmp(), dumpBmp() can be NULL.
88 * [in ] data: user-data
89 * [in ] type: dump-type
90 * [in ] var_buf: various buffer
91 * [in ] dump_buf: a dump-buffer
92 * [in ] dump_buf_size: size of dump-buffer
93 * [out] dump_w: a dump-buffer's width
94 * [out] dump_h a dump-buffer's height
95 * [out] dump_rect: rect which contains copied-image within a dump-buffer
96 * [out] TRUE if success to copy, FALSE if fail
98 Bool (*dumpBmp) (void *data, xDbgDumpType type,
99 void *var_buf, void *dump_buf, int dump_buf_size,
100 int *dump_w, int *dump_h, xRectangle *dump_rect);
102 /* xDbgDumpRaw() calls dumpRaw(). Returned dump_size will be used when a
103 * dump-buffer is saved to a raw file.
104 * If you don't call xDbgDumpRaw(), dumpRaw() can be NULL.
105 * [in ] data: user-data
106 * [in ] type: dump-type
107 * [in ] var_buf: various buffer
108 * [in ] dump_buf: a dump-buffer
109 * [in ] dump_buf_size: size of dump-buffer
110 * [out] dump_size: size which contains copied-image in a dump-buffer
111 * [out] TRUE if success to copy, FALSE if fail
113 Bool (*dumpRaw) (void *data, xDbgDumpType type,
114 void *var_buf, void *dump_buf, int dump_buf_size,
117 void (*reserved1) (void);
118 void (*reserved2) (void);
119 void (*reserved3) (void);
120 void (*reserved4) (void);
121 } xDbgDumpBufferFunc;
123 /* Register dump-buffer-functions and set max-size of a dump-buffer.
124 * [in ] func: dump-buffer-functions
125 * [in ] dump_buf_size: dump-buffer size. alloc() receives this size.
126 * [out] TRUE if success, FALSE if fail
128 Bool xDbgDumpSetBufferFunc (xDbgDumpBufferFunc *func, int dump_buf_size);
130 /* Check if "xdbg dump" is on.
131 * [in ] type: dump-type
132 * [out] TRUE if on, FALSE if off
135 * if (xDbgDumpIsEnable (XDBG_DUMP_TYPE_UI))
136 * xDbgDumpBmp (scrn, XDBG_DUMP_TYPE_UI, pPixmap, "drawable_1.bmp");
138 * if (xDbgDumpIsEnable (XDBG_DUMP_TYPE_VIDEO))
139 * xDbgDumpRaw (scrn, XDBG_DUMP_TYPE_VIDEO, yuv_buffer, "video_1.yuv");
141 Bool xDbgDumpIsEnable (xDbgDumpType type);
143 /* Dump various buffer as raw file
144 * [in ] data: user-data
145 * [in ] type: dump-type
146 * [in ] var_buf: various buffer
147 * [in ] file: filename to save
149 void xDbgDumpRaw (void *data, xDbgDumpType type, void *var_buf, const char *file);
151 /* Dump various buffer as bmp file
152 * [in ] data: user-data
153 * [in ] type: dump-type
154 * [in ] var_buf: various buffer
155 * [in ] file: filename to save
157 void xDbgDumpBmp (void *data, xDbgDumpType type, void *var_buf, const char *file);
159 /* Replace a old dump-buffer to a new dump-buffer.
160 * [in ] old_dump_buf: old dump-buffer
161 * [in ] new_dump_buf: new dump-buffer
162 * [in ] new_dump_buf_size: new dump-buffer's size
163 * [out] TRUE if success, FALSE if fail
165 Bool xDbgDumpReplaceBuffer (void *old_dump_buf, void *new_dump_buf, int new_dump_buf_size);
167 #endif /* __XDBG_DUMP_H__ */