add supplementary log massage of each major extension
[platform/adaptation/xf86-module-xdbg.git] / common / xdbg_evlog_xv.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
55 #include <X11/extensions/Xvlib.h>
56 #include <X11/extensions/Xv.h>
57 #include <X11/extensions/Xvproto.h>
58
59 #include "xdbg_types.h"
60 #include "xdbg_evlog_xv.h"
61
62 static char *
63 _EvlogRequestXv(xReq *req, char *reply, int *len)
64 {
65     xReq *stuff = req;
66
67     switch (stuff->data)
68     {
69     case xv_GrabPort:
70         {
71             xvGrabPortReq *stuff = (xvGrabPortReq *)req;
72             REPLY (": XID(0x%lx)",
73                 stuff->port);
74
75             return reply;
76         }
77
78     case xv_UngrabPort:
79         {
80             xvUngrabPortReq *stuff = (xvUngrabPortReq *)req;
81             REPLY (": XID(0x%lx)",
82                 stuff->port);
83
84             return reply;
85         }
86
87     case xv_GetStill:
88         {
89             xvGetStillReq *stuff = (xvGetStillReq *)req;
90             REPLY (": XID(0x%lx) Drawable(0x%lx) GC(0x%lx) Vid(%d,%d) Drw(%d,%d)",
91                 stuff->port,
92                 stuff->drawable,
93                 stuff->gc,
94                 stuff->vid_x,
95                 stuff->vid_y,
96                 stuff->drw_x,
97                 stuff->drw_y);
98
99             return reply;
100         }
101
102     case xv_StopVideo:
103         {
104             xvStopVideoReq *stuff = (xvStopVideoReq *)req;
105             REPLY (": XID(0x%lx) Drawable(0x%lx)",
106                 stuff->port,
107                 stuff->drawable);
108
109             return reply;
110         }
111
112     case xv_SelectVideoNotify:
113         {
114             xvSelectVideoNotifyReq *stuff = (xvSelectVideoNotifyReq *)req;
115             REPLY (": XID(0x%lx) On/Off(%d)",
116                 stuff->drawable,
117                 stuff->onoff);
118
119             return reply;
120         }
121
122     case xv_SelectPortNotify:
123         {
124             xvSelectPortNotifyReq *stuff = (xvSelectPortNotifyReq *)req;
125             REPLY (": XID(0x%lx) On/Off(%d)",
126                 stuff->port,
127                 stuff->onoff);
128
129             return reply;
130         }
131
132     case xv_QueryBestSize:
133         {
134             xvQueryBestSizeReq *stuff = (xvQueryBestSizeReq *)req;
135             REPLY (": XID(0x%lx) VidSize(%dx%d) DrwSize(%dx%d)",
136                 stuff->port,
137                 stuff->vid_w,
138                 stuff->vid_h,
139                 stuff->drw_w,
140                 stuff->drw_h);
141
142             return reply;
143         }
144
145     case xv_SetPortAttribute:
146         {
147             xvSetPortAttributeReq *stuff = (xvSetPortAttributeReq *)req;
148             REPLY (": XID(0x%lx) Attribute(0x%lx) value(0x%lx)",
149                 stuff->port,
150                 stuff->attribute,
151                 stuff->value);
152
153             return reply;
154         }
155
156     case xv_PutImage:
157         {
158             xvPutImageReq *stuff = (xvPutImageReq *)req;
159             REPLY (": XID(0x%lx) Drawable(0x%lx) GC(0x%lx) ID(0x%lx) src(%d,%d) drw(%d,%d)",
160                 stuff->port,
161                 stuff->drawable,
162                 stuff->gc,
163                 stuff->id,
164                 stuff->src_x,
165                 stuff->src_y,
166                 stuff->drw_x,
167                 stuff->drw_y);
168
169             return reply;
170         }
171
172     case xv_ShmPutImage:
173         {
174             xvShmPutImageReq *stuff = (xvShmPutImageReq *)req;
175             REPLY (": XID(0x%lx) Drawable(0x%lx) GC(0x%lx) ID(0x%lx) src(%d,%d) drw(%d,%d)",
176                 stuff->port,
177                 stuff->drawable,
178                 stuff->gc,
179                 stuff->id,
180                 stuff->src_x,
181                 stuff->src_y,
182                 stuff->drw_x,
183                 stuff->drw_y);
184
185             return reply;
186         }
187
188     default:
189             break;
190     }
191
192     return reply;
193 }
194
195 static char *
196 _EvlogEventXv (xEvent *evt, int first_base, char *reply, int *len)
197 {
198     xEvent *stuff = evt;
199
200     switch ((stuff->u.u.type & 0x7F) - first_base)
201     {
202     case XvVideoNotify:
203         {
204             XvVideoNotifyEvent *stuff = (XvVideoNotifyEvent *) evt;
205             REPLY (": XID(0x%lx) reason(%ld) portID(0x%lx)",
206                 stuff->drawable,
207                 stuff->reason,
208                 stuff->port_id);
209
210             return reply;
211         }
212
213     case XvPortNotify:
214         {
215             XvPortNotifyEvent *stuff = (XvPortNotifyEvent *) evt;
216             REPLY (": XID(0x%lx) Attribute(%lx) Value(%ld)",
217                 stuff->port_id,
218                 stuff->attribute,
219                 stuff->value);
220
221             return reply;
222         }
223
224     default:
225             break;
226     }
227
228     return reply;
229 }
230
231 void
232 xDbgEvlogXvGetBase (void *dpy, ExtensionInfo *extinfo)
233 {
234 #ifdef XDBG_CLIENT
235     Display *d = (Display*)dpy;
236
237     RETURN_IF_FAIL (d != NULL);
238     RETURN_IF_FAIL (extinfo != NULL);
239
240     if (!XQueryExtension(d, XvName, &extinfo->opcode, &extinfo->evt_base, &extinfo->err_base))
241     {
242         fprintf (stderr, "[UTILX] no Xv extension. \n");
243         return;
244     }
245     extinfo->req_func = _EvlogRequestXv;
246     extinfo->evt_func = _EvlogEventXv;
247 #else
248     ExtensionEntry *xext = CheckExtension (XvName);
249     RETURN_IF_FAIL (xext != NULL);
250
251     extinfo->opcode = xext->base;
252     extinfo->evt_base = xext->eventBase;
253     extinfo->err_base = xext->errorBase;
254     extinfo->req_func = _EvlogRequestXv;
255     extinfo->evt_func = _EvlogEventXv;
256
257 #endif
258 }