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, char *reply, int *len)
65 xReq *req = evinfo->req.ptr;
69 case X_DRI2CreateDrawable:
71 xDRI2CreateDrawableReq *stuff = (xDRI2CreateDrawableReq *)req;
72 REPLY (": XID(0x%lx)",
78 case X_DRI2DestroyDrawable:
80 xDRI2DestroyDrawableReq *stuff = (xDRI2DestroyDrawableReq *)req;
81 REPLY (": XID(0x%lx)",
87 case X_DRI2GetBuffers:
89 xDRI2GetBuffersReq *stuff = (xDRI2GetBuffersReq *)req;
90 REPLY (": XID(0x%lx) Count(%ld)",
97 case X_DRI2CopyRegion:
99 xDRI2CopyRegionReq *stuff = (xDRI2CopyRegionReq *)req;
100 REPLY (": XID(0x%lx) src(0x%lx) dst(0x%lx)",
106 reply = xDbgGetRegion(stuff->region, evinfo, reply, len);
111 case X_DRI2GetBuffersWithFormat:
113 xDRI2GetBuffersReq *stuff = (xDRI2GetBuffersReq *)req;
114 REPLY (": XID(0x%lx) count(%ld)",
122 case X_DRI2SwapBuffers:
124 xDRI2SwapBuffersReq *stuff = (xDRI2SwapBuffersReq *)req;
125 REPLY (": XID(0x%lx) msc(0x%lx/0x%lx) divisor(0x%lx/0x%lx) remainder(0x%lx/0x%lx)",
127 stuff->target_msc_hi,
128 stuff->target_msc_lo,
132 stuff->remainder_lo);
137 case X_DRI2SwapInterval:
139 xDRI2SwapIntervalReq *stuff = (xDRI2SwapIntervalReq *)req;
140 REPLY (": XID(0x%lx) Interval(%ld)",
147 case X_DRI2SwapBuffersWithRegion:
149 xDRI2SwapBuffersWithRegionReq *stuff = (xDRI2SwapBuffersWithRegionReq *)req;
150 REPLY (": XID(0x%lx)",
154 reply = xDbgGetRegion(stuff->region, evinfo, reply, len);
168 _EvlogEventDri2 (EvlogInfo *evinfo, int first_base, char *reply, int *len)
170 xEvent *evt = evinfo->evt.ptr;
172 switch ((evt->u.u.type & 0x7F) - first_base)
174 case DRI2_BufferSwapComplete:
176 xDRI2BufferSwapComplete *stuff = (xDRI2BufferSwapComplete *) evt;
177 REPLY (": XID(0x%lx) ust(0x%lx/0x%lx) msc(0x%lx/0x%lx) sbc(0x%lx/0x%lx)",
186 evinfo->evt.size = sizeof (xDRI2BufferSwapComplete);
191 case DRI2_InvalidateBuffers:
193 xDRI2InvalidateBuffers *stuff = (xDRI2InvalidateBuffers *) evt;
194 REPLY (": XID(0x%lx)",
208 _EvlogReplyDri2 (EvlogInfo *evinfo, char *reply, int *len)
210 xGenericReply *rep = evinfo->rep.ptr;
212 switch (evinfo->rep.reqData)
214 case X_DRI2GetBuffers:
216 if (evinfo->rep.isStart)
218 xDRI2GetBuffersReply *stuff = (xDRI2GetBuffersReply *)rep;
219 REPLY (": size(%ldx%ld) Count(%ld)",
226 xDRI2Buffer *stuff = (xDRI2Buffer *)rep;
228 REPLY ("attachment(0x%lx) Name(0x%lx) pitch(0x%lx) cpp(0x%lx)",
238 case X_DRI2SwapBuffers:
240 if (evinfo->rep.isStart)
242 xDRI2SwapBuffersReply *stuff = (xDRI2SwapBuffersReply *)rep;
243 REPLY (": swap(%ld/%ld)",
263 xDbgEvlogDri2GetBase (ExtensionInfo *extinfo)
266 RETURN_IF_FAIL (extinfo != NULL);
268 extinfo->req_func = _EvlogRequestDri2;
269 extinfo->evt_func = _EvlogEventDri2;
270 extinfo->rep_func = _EvlogReplyDri2;
272 ExtensionEntry *xext = CheckExtension (DRI2_NAME);
273 RETURN_IF_FAIL (xext != NULL);
274 RETURN_IF_FAIL (extinfo != NULL);
276 extinfo->opcode = xext->base;
277 extinfo->evt_base = xext->eventBase;
278 extinfo->err_base = xext->errorBase;
279 extinfo->req_func = _EvlogRequestDri2;
280 extinfo->evt_func = _EvlogEventDri2;
281 extinfo->rep_func = _EvlogReplyDri2;