tizen 2.3 release
[adaptation/xorg/driver/xserver-xorg-module-xdbg.git] / common / xdbg_evlog_hwc.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/hwcproto.h>
55 #include <X11/extensions/hwc.h>
56
57 #include "xdbg_types.h"
58 #include "xdbg_evlog_hwc.h"
59 #include "xdbg_evlog.h"
60
61 static char *
62 _EvlogRequestHwc (EvlogInfo *evinfo, int detail_level, char *reply, int *len)
63 {
64     xReq *req = evinfo->req.ptr;
65     int i;
66     CARD32 *p;
67
68     switch (req->data)
69     {
70     case X_HWCOpen:
71         {
72             xHWCOpenReq *stuff = (xHWCOpenReq *)req;
73             REPLY (": XID(0x%x)",
74                 (unsigned int)stuff->window);
75
76             return reply;
77         }
78
79     case X_HWCSetDrawables:
80         {
81             xHWCSetDrawablesReq *stuff = (xHWCSetDrawablesReq *)req;
82             REPLY (": XID(0x%x) count(%ld)",
83                 (unsigned int)stuff->window, stuff->count);
84
85             p = (CARD32 *) & req[3];
86             REPLY (" Drawables(");
87             for (i = 0; i < stuff->count; i++)
88                 REPLY (" 0x%x", (unsigned int)p[i]);
89             REPLY (" )");
90
91
92             return reply;
93         }
94
95     default:
96             break;
97     }
98
99     return reply;
100 }
101
102
103 static char *
104 _EvlogEventHwc (EvlogInfo *evinfo, int first_base, int detail_level, char *reply, int *len)
105 {
106     xGenericEvent *evt = (xGenericEvent *)evinfo->evt.ptr;
107
108     switch (evt->evtype)
109     {
110     case HWCConfigureNotify:
111         {
112             xHWCConfigureNotify *stuff = (xHWCConfigureNotify *) evt;
113             REPLY (": maxLayer(%d)",
114                 (unsigned int)stuff->maxLayer);
115
116             return reply;
117         }
118
119     default:
120             break;
121     }
122
123     return reply;
124 }
125
126 static char *
127 _EvlogReplyHwc (EvlogInfo *evinfo, int detail_level, char *reply, int *len)
128 {
129     xGenericReply *rep = evinfo->rep.ptr;
130
131     switch (evinfo->rep.reqData)
132     {
133     case X_HWCOpen:
134         {
135             if (evinfo->rep.isStart)
136             {
137                 xHWCOpenReply *stuff = (xHWCOpenReply *)rep;
138                 REPLY (": maxLayers(%d)",
139                     (unsigned int)stuff->maxLayer);
140             }
141
142             return reply;
143         }
144
145     default:
146             break;
147     }
148
149     return reply;
150 }
151
152 void
153 xDbgEvlogHwcGetBase (ExtensionInfo *extinfo)
154 {
155 #ifdef XDBG_CLIENT
156     RETURN_IF_FAIL (extinfo != NULL);
157
158     extinfo->req_func = _EvlogRequestHwc;
159     extinfo->evt_func = _EvlogEventHwc;
160     extinfo->rep_func = _EvlogReplyHwc;
161 #else
162     ExtensionEntry *xext = CheckExtension (HWC_NAME);
163     RETURN_IF_FAIL (xext != NULL);
164     RETURN_IF_FAIL (extinfo != NULL);
165
166     extinfo->opcode = xext->base;
167     extinfo->evt_base = xext->eventBase;
168     extinfo->err_base = xext->errorBase;
169     extinfo->req_func = _EvlogRequestHwc;
170     extinfo->evt_func = _EvlogEventHwc;
171     extinfo->rep_func = _EvlogReplyHwc;
172 #endif
173 }