tizen 2.4 release
[adaptation/xorg/driver/xserver-xorg-module-xdbg.git] / common / xdbg_evlog_present.c
1 /**************************************************************************
2
3 xdbg
4
5 Copyright (c) 2013 Samsung Electronics Co., Ltd All Rights Reserved
6
7 Contact: Boram Park <boram1288.park@samsung.com>
8          Sangjin LEE <lsj119@samsung.com>
9
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:
17
18 The above copyright notice and this permission notice (including the
19 next paragraph) shall be included in all copies or substantial portions
20 of the Software.
21
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.
29
30 **************************************************************************/
31
32 #ifdef HAVE_CONFIG_H
33 #include "config.h"
34 #endif
35
36 #include <stdio.h>
37 #include <string.h>
38 #include <strings.h>
39 #include <sys/types.h>
40 #include <sys/fcntl.h>
41 #include <unistd.h>
42 #include <stdarg.h>
43 #include <fcntl.h>
44 #include <unistd.h>
45
46 #include <dix.h>
47 #define XREGISTRY
48 #include <registry.h>
49 #include <xace.h>
50 #include <xacestr.h>
51 #include <X11/Xatom.h>
52 #include <X11/Xlib.h>
53 #include <windowstr.h>
54 #include <X11/extensions/presentproto.h>
55
56 #include "xdbg_types.h"
57 #include "xdbg_evlog_present.h"
58 #include "xdbg_evlog.h"
59
60 static char *
61 _EvlogRequestPresent (EvlogInfo *evinfo, int detail_level, char *reply, int *len)
62 {
63     xReq *req = evinfo->req.ptr;
64
65     switch (req->data)
66     {
67     case X_PresentPixmap:
68         {
69             xPresentPixmapReq *stuff = (xPresentPixmapReq *)req;
70             REPLY (": window(0x%x) pixmap(0x%x) (s,v,u)(%u,0x%x,0x%x) x,y(%d,%d) crtc(%u) wait(0x%x) idle(0x%x) op(0x%x) (t,d,r)(%u,%u,%u)",
71                 (unsigned int)stuff->window,
72                 (unsigned int)stuff->pixmap,
73                 (unsigned int)stuff->serial,
74                 (unsigned int)stuff->valid,
75                 (unsigned int)stuff->update,
76                 (int)stuff->x_off,
77                 (int)stuff->y_off,
78                 (unsigned int)stuff->target_crtc,
79                 (unsigned int)stuff->wait_fence,
80                 (unsigned int)stuff->idle_fence,
81                 (unsigned int)stuff->options,
82                 (unsigned int)stuff->target_msc,
83                 (unsigned int)stuff->divisor,
84                 (unsigned int)stuff->remainder);
85
86             return reply;
87         }
88
89     case X_PresentNotifyMSC:
90         {
91             xPresentNotifyMSCReq *stuff = (xPresentNotifyMSCReq *)req;
92             REPLY (": window(0x%x) serial(%u) target_msc(%lu) divisor(%lu) remainder(%lu)",
93                 (unsigned int)stuff->window,
94                 (unsigned int)stuff->serial,
95                 (unsigned long)stuff->target_msc,
96                 (unsigned long)stuff->divisor,
97                 (unsigned long)stuff->remainder);
98
99             return reply;
100         }
101
102     case X_PresentSelectInput :
103         {
104             xPresentSelectInputReq *stuff = (xPresentSelectInputReq *)req;
105             REPLY (": eid(0x%x) window(0x%x) eventMask (0x%x)",
106                 (unsigned int)stuff->eid,
107                 (unsigned int)stuff->window,
108                 (unsigned int)stuff->eventMask);
109
110             return reply;
111         }
112
113     case X_PresentQueryCapabilities :
114         {
115             xPresentQueryCapabilitiesReq *stuff = (xPresentQueryCapabilitiesReq *)req;
116             REPLY (": target(0x%x)",
117                 (unsigned int)stuff->target);
118
119             return reply;
120         }
121
122     default:
123             break;
124     }
125
126     return reply;
127 }
128
129
130 static char *
131 _EvlogEventPresent (EvlogInfo *evinfo, int first_base, int detail_level, char *reply, int *len)
132 {
133     xEvent *evt = evinfo->evt.ptr;
134
135     switch ((evt->u.u.type & 0x7F) - first_base)
136     {
137
138     case PresentConfigureNotify:
139          {
140              xPresentConfigureNotify *stuff = (xPresentConfigureNotify *) evt;
141              REPLY (": window(0x%x)(%ux%u+%d+%d) off x,y (%d,%d)  pximap width(%u) height(%u) flags(0x%x)",
142                  (unsigned int)stuff->window,
143                  (unsigned int)stuff->width,
144                  (unsigned int)stuff->height,
145                  (int)stuff->x,
146                  (int)stuff->y,
147                  (int)stuff->off_x,
148                  (int)stuff->off_y,
149                  (unsigned int)stuff->pixmap_width,
150                  (unsigned int)stuff->pixmap_height,
151                  (unsigned int)stuff->pixmap_flags);
152     
153              evinfo->evt.size = sizeof (xPresentConfigureNotify);
154     
155              return reply;
156          }
157     
158      case PresentCompleteNotify:
159          {
160              xPresentCompleteNotify *stuff = (xPresentCompleteNotify *) evt;
161              REPLY (": window(0x%x) serial(0x%x) kind(%u) mode(%u) ust(%lu)",
162                  (unsigned int)stuff->window,
163                  (unsigned int)stuff->serial,
164                  (unsigned int)stuff->kind,
165                  (unsigned int)stuff->mode,
166                  (unsigned long)stuff->ust);
167     
168             evinfo->evt.size = sizeof (xPresentCompleteNotify);
169
170              return reply;
171          }
172     
173     case PresentIdleNotify:
174         {
175             xPresentIdleNotify *stuff = (xPresentIdleNotify *) evt;
176             REPLY (": window(0x%x) serial(0x%x) pixmap(0x%x) idle_fence(0x%x)",
177                 (unsigned int)stuff->window,
178                 (unsigned int)stuff->serial,
179                 (unsigned int)stuff->pixmap,
180                 (unsigned int)stuff->idle_fence);
181     
182             evinfo->evt.size = sizeof (xPresentIdleNotify);
183
184             return reply;
185         }
186 #if 0
187     case PresentRedirectNotify:
188         {
189
190             xPresentRedirectNotify *stuff = (xPresentRedirectNotify *) evt;
191             REPLY (": window(0x%x) pixmap(0x%x) serial(%u) valid(0x%x) update(0x%x) x,y_off(%d,%d) target_crtc(%u) wait_fence(0x%x) idle_fence(0x%x) options(0x%x) target_msc(%u) divisor(%u) remainder(%u)",
192                 (unsigned int)stuff->pixmap,
193                 (unsigned int)stuff->drawable,
194                 (unsigned int)stuff->serial,
195                 (unsigned int)stuff->valid_region,
196                 (unsigned int)stuff->update_region,
197                 (int)stuff->x_off,
198                 (int)stuff->y_off,
199                 (unsigned int)stuff->target_crtc,
200                 (unsigned int)stuff->wait_fence,
201                 (unsigned int)stuff->idle_fence,
202                 (unsigned int)stuff->options,
203                 (unsigned int)stuff->target_msc,
204                 (unsigned int)stuff->divisor,
205                 (unsigned int)stuff->remainder);
206
207             evinfo->evt.size = sizeof (xPresentRedirectNotify);
208
209             return reply;
210         }
211 #endif
212
213     default:
214             break;
215     }
216
217     return reply;
218 }
219
220 static char *
221 _EvlogReplyPresent (EvlogInfo *evinfo, int detail_level, char *reply, int *len)
222 {
223     xGenericReply *rep = evinfo->rep.ptr;
224
225     switch (evinfo->rep.reqData)
226     {
227     case X_PresentQueryCapabilities:
228         {
229             if (evinfo->rep.isStart)
230             {
231                 xPresentQueryCapabilitiesReply *stuff = (xPresentQueryCapabilitiesReply *)rep;
232                 REPLY (": capabilities(0x%x)",
233                     (unsigned int)stuff->capabilities);
234             }
235             else
236             {
237                 return reply;
238             }
239
240             return reply;
241         }
242
243     default:
244             break;
245     }
246
247     return reply;
248 }
249
250 void
251 xDbgEvlogPresentGetBase (ExtensionInfo *extinfo)
252 {
253 #ifdef XDBG_CLIENT
254     RETURN_IF_FAIL (extinfo != NULL);
255
256     extinfo->req_func = _EvlogRequestPresent;
257     extinfo->evt_func = _EvlogEventPresent;
258     extinfo->rep_func = _EvlogReplyPresent;
259 #else
260     ExtensionEntry *xext = CheckExtension (PRESENT_NAME);
261     RETURN_IF_FAIL (xext != NULL);
262     RETURN_IF_FAIL (extinfo != NULL);
263
264     extinfo->opcode = xext->base;
265     extinfo->evt_base = xext->eventBase;
266     extinfo->err_base = xext->errorBase;
267     extinfo->req_func = _EvlogRequestPresent;
268     extinfo->evt_func = _EvlogEventPresent;
269     extinfo->rep_func = _EvlogReplyPresent;
270 #endif
271 }