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) type:%d ust(0x%x/0x%x) msc(0x%x/0x%x) sbc(0x%x/0x%x)",
199 (unsigned int)stuff->drawable,
200 (int)stuff->event_type,
201 (unsigned int)stuff->ust_hi,
202 (unsigned int)stuff->ust_lo,
203 (unsigned int)stuff->msc_hi,
204 (unsigned int)stuff->msc_lo,
205 (unsigned int)stuff->sbc_hi,
206 (unsigned int)stuff->sbc_lo);
208 evinfo->evt.size = sizeof (xDRI2BufferSwapComplete);
210 if (detail_level >= EVLOG_PRINT_DETAIL)
213 REPLY ("%67s sequence_num(%d) event_type(%d)",
215 stuff->sequenceNumber,
222 case DRI2_InvalidateBuffers:
224 xDRI2InvalidateBuffers *stuff = (xDRI2InvalidateBuffers *) evt;
225 REPLY (": XID(0x%x)",
226 (unsigned int)stuff->drawable);
228 if (detail_level >= EVLOG_PRINT_DETAIL)
230 REPLY (" sequence_num(%d)",
231 stuff->sequenceNumber);
245 _EvlogReplyDri2 (EvlogInfo *evinfo, int detail_level, char *reply, int *len)
247 xGenericReply *rep = evinfo->rep.ptr;
249 switch (evinfo->rep.reqData)
251 case X_DRI2GetBuffers:
253 if (evinfo->rep.isStart)
255 xDRI2GetBuffersReply *stuff = (xDRI2GetBuffersReply *)rep;
256 REPLY (": size(%ldx%ld) count(%ld)",
257 (long int)stuff->width,
258 (long int)stuff->height,
259 (long int)stuff->count);
261 if (detail_level >= EVLOG_PRINT_DETAIL)
263 REPLY (" sequence_num(%d)",
264 stuff->sequenceNumber);
269 xDRI2Buffer *stuff = (xDRI2Buffer *)rep;
271 REPLY ("attachment(0x%x) Name(0x%x) pitch(0x%x) cpp(0x%x) flags(0x%x)",
272 (unsigned int)stuff->attachment,
273 (unsigned int)stuff->name,
274 (unsigned int)stuff->pitch,
275 (unsigned int)stuff->cpp,
276 (unsigned int)stuff->flags);
282 case X_DRI2SwapBuffers:
284 if (evinfo->rep.isStart)
286 xDRI2SwapBuffersReply *stuff = (xDRI2SwapBuffersReply *)rep;
287 REPLY (": swap(%ld/%ld)",
288 (long int)stuff->swap_hi,
289 (long int)stuff->swap_lo);
291 if (detail_level >= EVLOG_PRINT_DETAIL)
293 REPLY (" sequence_num(%d)",
294 stuff->sequenceNumber);
313 xDbgEvlogDri2GetBase (ExtensionInfo *extinfo)
316 RETURN_IF_FAIL (extinfo != NULL);
318 extinfo->req_func = _EvlogRequestDri2;
319 extinfo->evt_func = _EvlogEventDri2;
320 extinfo->rep_func = _EvlogReplyDri2;
322 ExtensionEntry *xext = CheckExtension (DRI2_NAME);
323 RETURN_IF_FAIL (xext != NULL);
324 RETURN_IF_FAIL (extinfo != NULL);
326 extinfo->opcode = xext->base;
327 extinfo->evt_base = xext->eventBase;
328 extinfo->err_base = xext->errorBase;
329 extinfo->req_func = _EvlogRequestDri2;
330 extinfo->evt_func = _EvlogEventDri2;
331 extinfo->rep_func = _EvlogReplyDri2;