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 **************************************************************************/
39 #include <sys/types.h>
40 #include <sys/fcntl.h>
51 #include <X11/Xatom.h>
53 #include <windowstr.h>
54 #include <dri2/dri2.h>
55 #include <X11/extensions/dri2proto.h>
58 #include "xdbg_types.h"
59 #include "xdbg_evlog_dri2.h"
60 #include "xdbg_evlog.h"
63 _EvlogRequestDri2 (EvlogInfo *evinfo, int detail_level, char *reply, int *len)
65 xReq *req = evinfo->req.ptr;
69 case X_DRI2CreateDrawable:
71 xDRI2CreateDrawableReq *stuff = (xDRI2CreateDrawableReq *)req;
73 (unsigned int)stuff->drawable);
78 case X_DRI2DestroyDrawable:
80 xDRI2DestroyDrawableReq *stuff = (xDRI2DestroyDrawableReq *)req;
82 (unsigned int)stuff->drawable);
87 case X_DRI2GetBuffers:
89 xDRI2GetBuffersReq *stuff = (xDRI2GetBuffersReq *)req;
91 (unsigned int)stuff->drawable);
93 if (detail_level >= EVLOG_PRINT_DETAIL)
96 (long int)stuff->count);
102 case X_DRI2CopyRegion:
104 xDRI2CopyRegionReq *stuff = (xDRI2CopyRegionReq *)req;
105 REPLY (": XID(0x%x) src(0x%x) dst(0x%x)",
106 (unsigned int)stuff->drawable,
107 (unsigned int)stuff->src,
108 (unsigned int)stuff->dest);
110 if (detail_level >= EVLOG_PRINT_DETAIL)
113 reply = xDbgGetRegion(stuff->region, evinfo, reply, len);
119 case X_DRI2GetBuffersWithFormat:
121 xDRI2GetBuffersReq *stuff = (xDRI2GetBuffersReq *)req;
122 REPLY (": XID(0x%x)",
123 (unsigned int)stuff->drawable);
125 if (detail_level >= EVLOG_PRINT_DETAIL)
127 REPLY (" count(%ld)",
128 (long int)stuff->count);
135 case X_DRI2SwapBuffers:
137 xDRI2SwapBuffersReq *stuff = (xDRI2SwapBuffersReq *)req;
138 REPLY (": XID(0x%x) msc(0x%x/0x%x) divisor(0x%x/0x%x) remainder(0x%x/0x%x)",
139 (unsigned int)stuff->drawable,
140 (unsigned int)stuff->target_msc_hi,
141 (unsigned int)stuff->target_msc_lo,
142 (unsigned int)stuff->divisor_hi,
143 (unsigned int)stuff->divisor_lo,
144 (unsigned int)stuff->remainder_hi,
145 (unsigned int)stuff->remainder_lo);
150 case X_DRI2SwapInterval:
152 xDRI2SwapIntervalReq *stuff = (xDRI2SwapIntervalReq *)req;
153 REPLY (": XID(0x%x)",
154 (unsigned int)stuff->drawable);
156 if (detail_level >= EVLOG_PRINT_DETAIL)
158 REPLY (" interval(%ld)",
159 (long int)stuff->interval);
165 case X_DRI2SwapBuffersWithRegion:
167 xDRI2SwapBuffersWithRegionReq *stuff = (xDRI2SwapBuffersWithRegionReq *)req;
168 REPLY (": XID(0x%x)",
169 (unsigned int)stuff->drawable);
171 if (detail_level >= EVLOG_PRINT_DETAIL)
174 reply = xDbgGetRegion(stuff->region, evinfo, reply, len);
189 _EvlogEventDri2 (EvlogInfo *evinfo, int first_base, int detail_level, char *reply, int *len)
191 xEvent *evt = evinfo->evt.ptr;
193 switch ((evt->u.u.type & 0x7F) - first_base)
195 case DRI2_BufferSwapComplete:
197 xDRI2BufferSwapComplete *stuff = (xDRI2BufferSwapComplete *) evt;
198 REPLY (": XID(0x%x) ust(0x%x/0x%x) msc(0x%x/0x%x) sbc(0x%x/0x%x)",
199 (unsigned int)stuff->drawable,
200 (unsigned int)stuff->ust_hi,
201 (unsigned int)stuff->ust_lo,
202 (unsigned int)stuff->msc_hi,
203 (unsigned int)stuff->msc_lo,
204 (unsigned int)stuff->sbc_hi,
205 (unsigned int)stuff->sbc_lo);
207 evinfo->evt.size = sizeof (xDRI2BufferSwapComplete);
209 if (detail_level >= EVLOG_PRINT_DETAIL)
212 REPLY ("%67s sequence_num(%d) event_type(%d)",
214 stuff->sequenceNumber,
221 case DRI2_InvalidateBuffers:
223 xDRI2InvalidateBuffers *stuff = (xDRI2InvalidateBuffers *) evt;
224 REPLY (": XID(0x%x)",
225 (unsigned int)stuff->drawable);
227 if (detail_level >= EVLOG_PRINT_DETAIL)
229 REPLY (" sequence_num(%d)",
230 stuff->sequenceNumber);
244 _EvlogReplyDri2 (EvlogInfo *evinfo, int detail_level, char *reply, int *len)
246 xGenericReply *rep = evinfo->rep.ptr;
248 switch (evinfo->rep.reqData)
250 case X_DRI2GetBuffers:
252 if (evinfo->rep.isStart)
254 xDRI2GetBuffersReply *stuff = (xDRI2GetBuffersReply *)rep;
255 REPLY (": size(%ldx%ld) count(%ld)",
256 (long int)stuff->width,
257 (long int)stuff->height,
258 (long int)stuff->count);
260 if (detail_level >= EVLOG_PRINT_DETAIL)
262 REPLY (" sequence_num(%d)",
263 stuff->sequenceNumber);
268 xDRI2Buffer *stuff = (xDRI2Buffer *)rep;
270 REPLY ("attachment(0x%x) Name(0x%x) pitch(0x%x) cpp(0x%x) flags(0x%x)",
271 (unsigned int)stuff->attachment,
272 (unsigned int)stuff->name,
273 (unsigned int)stuff->pitch,
274 (unsigned int)stuff->cpp,
275 (unsigned int)stuff->flags);
281 case X_DRI2SwapBuffers:
283 if (evinfo->rep.isStart)
285 xDRI2SwapBuffersReply *stuff = (xDRI2SwapBuffersReply *)rep;
286 REPLY (": swap(%ld/%ld)",
287 (long int)stuff->swap_hi,
288 (long int)stuff->swap_lo);
290 if (detail_level >= EVLOG_PRINT_DETAIL)
292 REPLY (" sequence_num(%d)",
293 stuff->sequenceNumber);
312 xDbgEvlogDri2GetBase (ExtensionInfo *extinfo)
315 RETURN_IF_FAIL (extinfo != NULL);
317 extinfo->req_func = _EvlogRequestDri2;
318 extinfo->evt_func = _EvlogEventDri2;
319 extinfo->rep_func = _EvlogReplyDri2;
321 ExtensionEntry *xext = CheckExtension (DRI2_NAME);
322 RETURN_IF_FAIL (xext != NULL);
323 RETURN_IF_FAIL (extinfo != NULL);
325 extinfo->opcode = xext->base;
326 extinfo->evt_base = xext->eventBase;
327 extinfo->err_base = xext->errorBase;
328 extinfo->req_func = _EvlogRequestDri2;
329 extinfo->evt_func = _EvlogEventDri2;
330 extinfo->rep_func = _EvlogReplyDri2;