tizen 2.4 release
[adaptation/xorg/driver/xserver-xorg-module-xdbg.git] / common / xdbg_evlog_dri3.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/dri3proto.h>
55
56 #include "xdbg_types.h"
57 #include "xdbg_evlog_dri3.h"
58 #include "xdbg_evlog.h"
59
60 static char *
61 _EvlogRequestDri3 (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_DRI3PixmapFromBuffer:
68         {
69             xDRI3PixmapFromBufferReq *stuff = (xDRI3PixmapFromBufferReq *)req;
70             REPLY (": Pixmap(0x%x) drawable(0x%x) size(%u) width(%u) height(%u) stride(%u) depth(%u) bpp(%u)",
71                 (unsigned int)stuff->pixmap,
72                 (unsigned int)stuff->drawable,
73                 (unsigned int)stuff->size,
74                 (unsigned int)stuff->width,
75                 (unsigned int)stuff->height,
76                 (unsigned int)stuff->stride,
77                 (unsigned int)stuff->depth,
78                 (unsigned int)stuff->bpp);
79
80             return reply;
81         }
82
83     case X_DRI3BufferFromPixmap:
84         {
85             xDRI3BufferFromPixmapReq *stuff = (xDRI3BufferFromPixmapReq *)req;
86             REPLY (": Pixmap(0x%x)",
87                 (unsigned int)stuff->pixmap);
88
89             return reply;
90         }
91
92     case X_DRI3FenceFromFD:
93         {
94             xDRI3FenceFromFDReq *stuff = (xDRI3FenceFromFDReq *)req;
95             REPLY (": drawable(0x%x) fence(0x%x) initially_triggered(%s)",
96                 (unsigned int)stuff->drawable,
97                 (unsigned int)stuff->fence,
98                 stuff->initially_triggered?"True":"False");
99
100             return reply;
101         }
102
103     case X_DRI3FDFromFence:
104         {
105             xDRI3FDFromFenceReq *stuff = (xDRI3FDFromFenceReq *)req;
106             REPLY (": drawable(0x%x) fence(0x%x)",
107                 (unsigned int)stuff->drawable,
108                 (unsigned int)stuff->fence);
109
110             return reply;
111         }
112
113     default:
114             break;
115     }
116
117     return reply;
118 }
119
120
121 static char *
122 _EvlogEventDri3 (EvlogInfo *evinfo, int first_base, int detail_level, char *reply, int *len)
123 {
124     xEvent *evt = evinfo->evt.ptr;
125
126     switch ((evt->u.u.type & 0x7F) - first_base)
127     {
128
129     default:
130             break;
131     }
132
133     return reply;
134 }
135
136 static char *
137 _EvlogReplyDri3 (EvlogInfo *evinfo, int detail_level, char *reply, int *len)
138 {
139     xGenericReply *rep = evinfo->rep.ptr;
140
141     switch (evinfo->rep.reqData)
142     {
143     case X_DRI3BufferFromPixmap:
144         {
145             if (evinfo->rep.isStart)
146             {
147                 xDRI3BufferFromPixmapReply *stuff = (xDRI3BufferFromPixmapReply *)rep;
148                 REPLY (": nfd(%u) sequenceNumber(%u) size(%u) width(%u) height(%u) stride(%u) depth(%u) bpp(%u)",
149                     (unsigned int)stuff->nfd,
150                     (unsigned int)stuff->sequenceNumber,
151                     (unsigned int)stuff->size,
152                     (unsigned int)stuff->width,
153                     (unsigned int)stuff->height,
154                     (unsigned int)stuff->stride,
155                     (unsigned int)stuff->depth,
156                     (unsigned int)stuff->bpp);
157             }
158             else
159             {
160                 return reply;
161             }
162
163             return reply;
164         }
165
166     case X_DRI3FDFromFence:
167         {
168             if (evinfo->rep.isStart)
169             {
170                 xDRI3FDFromFenceReply *stuff = (xDRI3FDFromFenceReply *)rep;
171                 REPLY (": nfd(%u) sequenceNumber(%u)",
172                     (unsigned int)stuff->nfd,
173                     (unsigned int)stuff->sequenceNumber);
174             }
175             else
176             {
177                 return reply;
178             }
179
180             return reply;
181         }
182
183     default:
184             break;
185     }
186
187     return reply;
188 }
189
190 void
191 xDbgEvlogDri3GetBase (ExtensionInfo *extinfo)
192 {
193 #ifdef XDBG_CLIENT
194     RETURN_IF_FAIL (extinfo != NULL);
195
196     extinfo->req_func = _EvlogRequestDri3;
197     extinfo->evt_func = _EvlogEventDri3;
198     extinfo->rep_func = _EvlogReplyDri3;
199 #else
200     ExtensionEntry *xext = CheckExtension (DRI3_NAME);
201     RETURN_IF_FAIL (xext != NULL);
202     RETURN_IF_FAIL (extinfo != NULL);
203
204     extinfo->opcode = xext->base;
205     extinfo->evt_base = xext->eventBase;
206     extinfo->err_base = xext->errorBase;
207     extinfo->req_func = _EvlogRequestDri3;
208     extinfo->evt_func = _EvlogEventDri3;
209     extinfo->rep_func = _EvlogReplyDri3;
210 #endif
211 }