tizen 2.3 release
[adaptation/xorg/driver/xserver-xorg-module-xdbg.git] / common / xdbg_evlog_randr.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/Xrandr.h>
56 #include <X11/extensions/randrproto.h>
57
58
59 #include "xdbg_types.h"
60 #include "xdbg_evlog_randr.h"
61 #include "xdbg_evlog.h"
62
63 static char *
64 _EvlogRequestRandr (EvlogInfo *evinfo, int detail_level, char *reply, int *len)
65 {
66     xReq *req = evinfo->req.ptr;
67
68     switch (req->data)
69     {
70     case X_RRGetScreenSizeRange:
71         {
72             xRRGetScreenSizeRangeReq *stuff = (xRRGetScreenSizeRangeReq *)req;
73             REPLY (": XID(0x%x)",
74                 (unsigned int)stuff->window);
75
76             return reply;
77         }
78
79     case X_RRSetScreenSize:
80         {
81             xRRSetScreenSizeReq *stuff = (xRRSetScreenSizeReq *)req;
82             REPLY (": XID(0x%x) size(%dx%d)",
83                 (unsigned int)stuff->window,
84                 stuff->width,
85                 stuff->height);
86
87             if (detail_level >= EVLOG_PRINT_DETAIL)
88             {
89                 REPLY (" milliSize(%ldx%ld)",
90                     (long int)stuff->widthInMillimeters,
91                     (long int)stuff->heightInMillimeters);
92             }
93
94             return reply;
95         }
96
97     case X_RRGetScreenResources:
98         {
99             xRRGetScreenResourcesReq *stuff = (xRRGetScreenResourcesReq *)req;
100             REPLY (": XID(0x%x)",
101                 (unsigned int)stuff->window);
102
103             return reply;
104         }
105
106     case X_RRGetOutputInfo:
107         {
108             xRRGetOutputInfoReq *stuff = (xRRGetOutputInfoReq *)req;
109             REPLY (": XID(0x%x)",
110                 (unsigned int)stuff->output);
111
112             if (detail_level >= EVLOG_PRINT_DETAIL)
113             {
114                 REPLY (" config_timestamp(%lums)",
115                     (unsigned long)stuff->configTimestamp);
116             }
117
118             return reply;
119         }
120
121     case X_RRListOutputProperties:
122         {
123             xRRListOutputPropertiesReq *stuff = (xRRListOutputPropertiesReq *)req;
124             REPLY (": XID(0x%x)",
125                 (unsigned int)stuff->output);
126
127             return reply;
128         }
129
130     case X_RRQueryOutputProperty:
131         {
132             xRRQueryOutputPropertyReq *stuff = (xRRQueryOutputPropertyReq *)req;
133             REPLY (": XID(0x%x)",
134                 (unsigned int)stuff->output);
135
136             REPLY (" Property");
137             reply = xDbgGetAtom(stuff->property, evinfo, reply, len);
138
139             return reply;
140         }
141
142     case X_RRConfigureOutputProperty:
143         {
144             xRRConfigureOutputPropertyReq *stuff = (xRRConfigureOutputPropertyReq *)req;
145             REPLY (": XID(0x%x)",
146                 (unsigned int)stuff->output);
147
148             REPLY (" Property");
149             reply = xDbgGetAtom(stuff->property, evinfo, reply, len);
150
151             if (detail_level >= EVLOG_PRINT_DETAIL)
152             {
153                 REPLY (" pending(%s) range(%s)",
154                     stuff->pending ? "YES" : "NO",
155                     stuff->range ? "YES" : "NO");
156             }
157
158             return reply;
159         }
160
161     case X_RRChangeOutputProperty:
162         {
163             xRRChangeOutputPropertyReq *stuff = (xRRChangeOutputPropertyReq *)req;
164             REPLY (": XID(0x%x)",
165                 (unsigned int)stuff->output);
166
167             REPLY (" Property");
168             reply = xDbgGetAtom(stuff->property, evinfo, reply, len);
169             REPLY (" Type");
170             reply = xDbgGetAtom(stuff->type, evinfo, reply, len);
171
172             if (detail_level >= EVLOG_PRINT_DETAIL)
173             {
174                 const char *mode;
175                 char dmode[10];
176
177                 switch (stuff->mode)
178                 {
179                     case PropModeReplace:  mode = "PropModeReplace"; break;
180                     case PropModePrepend:  mode = "PropModePrepend"; break;
181                     case PropModeAppend:  mode = "PropModeAppend"; break;
182                     default:  mode = dmode; snprintf (dmode, 10, "%d", stuff->mode); break;
183                 }
184
185                 REPLY ("\n");
186                 REPLY ("%67s mode(%s) format(%d) nUnits(%ld)",
187                     " ",
188                     mode,
189                     stuff->format,
190                     (long int)stuff->nUnits);
191             }
192
193             return reply;
194         }
195
196     case X_RRDeleteOutputProperty:
197         {
198             xRRDeleteOutputPropertyReq *stuff = (xRRDeleteOutputPropertyReq *)req;
199             REPLY (": XID(0x%x)",
200                 (unsigned int)stuff->output);
201
202             REPLY (" Property");
203             reply = xDbgGetAtom(stuff->property, evinfo, reply, len);
204
205             return reply;
206         }
207
208     case X_RRGetOutputProperty:
209         {
210             xRRGetOutputPropertyReq *stuff = (xRRGetOutputPropertyReq *)req;
211             REPLY (": XID(0x%x)",
212                 (unsigned int)stuff->output);
213
214             REPLY (" Property");
215             reply = xDbgGetAtom(stuff->property, evinfo, reply, len);
216             REPLY (" Type");
217             reply = xDbgGetAtom(stuff->type, evinfo, reply, len);
218
219             if (detail_level >= EVLOG_PRINT_DETAIL)
220             {
221                 REPLY (" longOffset(%ld) longLength(%ld)",
222                     (long int)stuff->longOffset,
223                     (long int)stuff->longLength);
224             }
225
226             return reply;
227         }
228
229     case X_RRGetCrtcInfo:
230         {
231             xRRGetCrtcInfoReq *stuff = (xRRGetCrtcInfoReq *)req;
232             REPLY (": XID(0x%x)",
233                 (unsigned int)stuff->crtc);
234
235             if (detail_level >= EVLOG_PRINT_DETAIL)
236             {
237                 REPLY (" config_timestamp(%lums)",
238                     (unsigned long)stuff->configTimestamp);
239             }
240
241             return reply;
242         }
243
244     case X_RRSetCrtcConfig:
245         {
246             xRRSetCrtcConfigReq *stuff = (xRRSetCrtcConfigReq *)req;
247             REPLY (": XID(0x%x) coord(%d,%d) ",
248                 (unsigned int)stuff->crtc,
249                 stuff->x,
250                 stuff->y);
251
252             if (detail_level >= EVLOG_PRINT_DETAIL)
253             {
254                 const char *rotation;
255
256                 switch (stuff->rotation & 0xf)
257                 {
258                     case RR_Rotate_0:  rotation = "RR_Rotate_0"; break;
259                     case RR_Rotate_90:  rotation = "RR_Rotate_90"; break;
260                     case RR_Rotate_180:  rotation = "RR_Rotate_180"; break;
261                     case RR_Rotate_270:  rotation = "RR_Rotate_270"; break;
262                     default:  rotation = "Invaild Rotation"; break;
263                 }
264
265                 REPLY ("\n");
266                 REPLY ("%67s timestamp(%lums) config_timestamp(%lums) RRmode(0x%x) rotation(%s)",
267                     " ",
268                     (unsigned long)stuff->timestamp,
269                     (unsigned long)stuff->configTimestamp,
270                     (unsigned int)stuff->mode,
271                     rotation);
272             }
273
274             return reply;
275         }
276
277     case X_RRGetScreenResourcesCurrent:
278         {
279             xRRGetScreenResourcesCurrentReq *stuff = (xRRGetScreenResourcesCurrentReq *)req;
280             REPLY (": XID(0x%x)",
281                 (unsigned int)stuff->window);
282
283             return reply;
284         }
285
286     default:
287             break;
288     }
289
290     return reply;
291 }
292
293
294 static char *
295 _EvlogEventRandr (EvlogInfo *evinfo, int first_base, int detail_level, char *reply, int *len)
296 {
297     xEvent *evt = evinfo->evt.ptr;
298
299     switch ((evt->u.u.type & 0x7F) - first_base)
300     {
301     case RRScreenChangeNotify:
302         {
303             xRRScreenChangeNotifyEvent *stuff = (xRRScreenChangeNotifyEvent *) evt;
304             REPLY (": Root(0x%x) Window(0x%x)",
305                 (unsigned int)stuff->root,
306                 (unsigned int)stuff->window);
307
308             if (detail_level >= EVLOG_PRINT_DETAIL)
309             {
310                 const char *rotation;
311
312                 switch (stuff->rotation & 0xf)
313                 {
314                     case RR_Rotate_0:  rotation = "RR_Rotate_0"; break;
315                     case RR_Rotate_90:  rotation = "RR_Rotate_90"; break;
316                     case RR_Rotate_180:  rotation = "RR_Rotate_180"; break;
317                     case RR_Rotate_270:  rotation = "RR_Rotate_270"; break;
318                     default:  rotation = "Invaild Rotation"; break;
319                 }
320
321                 REPLY (" sizeID(%d) subPixel(%d) Pixel(%d,%d) Milli(%d,%d)",
322                     stuff->sizeID,
323                     stuff->subpixelOrder,
324                     stuff->widthInPixels,
325                     stuff->heightInPixels,
326                     stuff->widthInMillimeters,
327                     stuff->heightInMillimeters);
328
329                 REPLY ("\n");
330                 REPLY ("%67s rotation(%s) sequence_num(%d) timestamp(%lums) config_timestamp(%lums)",
331                     " ",
332                     rotation,
333                     stuff->sequenceNumber,
334                     (unsigned long)stuff->timestamp,
335                     (unsigned long)stuff->configTimestamp);
336             }
337
338             return reply;
339         }
340
341     case RRNotify:
342         {
343             switch(evt->u.u.detail)
344             {
345             case RRNotify_CrtcChange:
346                 {
347                     xRRCrtcChangeNotifyEvent *stuff = (xRRCrtcChangeNotifyEvent *) evt;
348                     REPLY (": XID(0x%x) Crtc(0x%x) RRmode(0x%x) new_size(%udx%ud) new_coord(%d,%d)",
349                         (unsigned int)stuff->window,
350                         (unsigned int)stuff->crtc,
351                         (unsigned int)stuff->mode,
352                         stuff->width,
353                         stuff->height,
354                         stuff->x,
355                         stuff->y);
356
357                     if (detail_level >= EVLOG_PRINT_DETAIL)
358                     {
359                         const char *rotation;
360
361                         switch (stuff->rotation & 0xf)
362                         {
363                             case RR_Rotate_0:  rotation = "RR_Rotate_0"; break;
364                             case RR_Rotate_90:  rotation = "RR_Rotate_90"; break;
365                             case RR_Rotate_180:  rotation = "RR_Rotate_180"; break;
366                             case RR_Rotate_270:  rotation = "RR_Rotate_270"; break;
367                             default:  rotation = "Invaild Rotation"; break;
368                         }
369
370                         REPLY ("\n");
371                         REPLY ("%67s rotation(%s) sequence_num(%d) timestamp(%lums)",
372                             " ",
373                             rotation,
374                             stuff->sequenceNumber,
375                             (unsigned long)stuff->timestamp);
376                     }
377
378                     return reply;
379                 }
380
381             case RRNotify_OutputChange:
382                 {
383                     xRROutputChangeNotifyEvent *stuff = (xRROutputChangeNotifyEvent *) evt;
384                     REPLY (": XID(0x%x) Output(0x%x) Crtc(0x%x) RRmode(0x%x)",
385                         (unsigned int)stuff->window,
386                         (unsigned int)stuff->output,
387                         (unsigned int)stuff->crtc,
388                         (unsigned int)stuff->mode);
389
390                     if (detail_level >= EVLOG_PRINT_DETAIL)
391                     {
392                         const char *rotation, *connection, *subpixelOrder;
393                         char dconnection[10], dsubpixelOrder[10];
394
395                         switch (stuff->rotation & 0xf)
396                         {
397                             case RR_Rotate_0:    rotation = "RR_Rotate_0"; break;
398                             case RR_Rotate_90:   rotation = "RR_Rotate_90"; break;
399                             case RR_Rotate_180:  rotation = "RR_Rotate_180"; break;
400                             case RR_Rotate_270:  rotation = "RR_Rotate_270"; break;
401                             default:  rotation = "Invaild Rotation"; break;
402                         }
403
404                         switch (stuff->connection)
405                         {
406                             case RR_Connected:          connection = "RR_Connected"; break;
407                             case RR_Disconnected:       connection = "RR_Disconnected"; break;
408                             case RR_UnknownConnection:  connection = "RR_UnknownConnection"; break;
409                             default:  connection = dconnection; snprintf (dconnection, 10, "%d", stuff->connection); break;
410                         }
411
412                         switch (stuff->subpixelOrder)
413                         {
414                             case SubPixelUnknown:        subpixelOrder = "SubPixelUnknown"; break;
415                             case SubPixelHorizontalRGB:  subpixelOrder = "SubPixelHorizontalRGB"; break;
416                             case SubPixelHorizontalBGR:  subpixelOrder = "SubPixelHorizontalBGR"; break;
417                             case SubPixelVerticalRGB:    subpixelOrder = "SubPixelVerticalRGB"; break;
418                             case SubPixelVerticalBGR:    subpixelOrder = "SubPixelVerticalBGR"; break;
419                             case SubPixelNone:           subpixelOrder = "SubPixelNone"; break;
420                             default:  subpixelOrder = dsubpixelOrder; snprintf (dsubpixelOrder, 10, "%d", stuff->connection); break;
421                         }
422
423                         REPLY (" sequence_num(%d)",
424                             stuff->sequenceNumber);
425
426                         REPLY ("\n");
427                         REPLY ("%67s timestamp(%lums) config_timestamp(%lums) rotation(%s) connection(%s) subpixel_order(%s)",
428                             " ",
429                             (unsigned long)stuff->timestamp,
430                             (unsigned long)stuff->configTimestamp,
431                             rotation,
432                             connection,
433                             subpixelOrder);
434                     }
435
436                     return reply;
437                 }
438
439             case RRNotify_OutputProperty:
440                 {
441                     xRROutputPropertyNotifyEvent *stuff = (xRROutputPropertyNotifyEvent *) evt;
442                     REPLY (": XID(0x%x) Output(0x%x)",
443                         (unsigned int)stuff->window,
444                         (unsigned int)stuff->output);
445
446                     REPLY (" Property");
447                     reply = xDbgGetAtom(stuff->atom, evinfo, reply, len);
448
449                     if (detail_level >= EVLOG_PRINT_DETAIL)
450                     {
451                         const char *state;
452                         char dstate[10];
453
454                         switch (stuff->state)
455                         {
456                             case PropertyNewValue:    state = "PropertyNewValue"; break;
457                             case PropertyDelete:   state = "PropertyDelete"; break;
458                             default:  state = dstate; snprintf (dstate, 10, "%d", stuff->state); break;
459                         }
460
461                         REPLY ("\n");
462                         REPLY ("%67s sequence_num(%d) timestamp(%lums) state(%s)",
463                             " ",
464                             stuff->sequenceNumber,
465                             (unsigned long)stuff->timestamp,
466                             state);
467                     }
468
469                     return reply;
470                 }
471
472             case RRNotify_ProviderChange:
473                 {
474                     xRRProviderChangeNotifyEvent *stuff = (xRRProviderChangeNotifyEvent *) evt;
475                     REPLY (": XID(0x%x) Provider(0x%x)",
476                         (unsigned int)stuff->window,
477                         (unsigned int)stuff->provider);
478
479                     if (detail_level >= EVLOG_PRINT_DETAIL)
480                     {
481                         REPLY (" sequence_num(%d) timestamp(%lums)",
482                             stuff->sequenceNumber,
483                             (unsigned long)stuff->timestamp);
484                     }
485
486                     return reply;
487                 }
488
489             case RRNotify_ProviderProperty:
490                 {
491                     xRRProviderPropertyNotifyEvent *stuff = (xRRProviderPropertyNotifyEvent *) evt;
492                     REPLY (": XID(0x%x) Provider(0x%x)",
493                         (unsigned int)stuff->window,
494                         (unsigned int)stuff->provider);
495
496                     REPLY (" Atom");
497                     reply = xDbgGetAtom(stuff->atom, evinfo, reply, len);
498
499                     if (detail_level >= EVLOG_PRINT_DETAIL)
500                     {
501                         const char *state;
502                         char dstate[10];
503
504                         switch (stuff->state)
505                         {
506                             case PropertyNewValue:    state = "PropertyNewValue"; break;
507                             case PropertyDelete:   state = "PropertyDelete"; break;
508                             default:  state = dstate; snprintf (dstate, 10, "%d", stuff->state); break;
509                         }
510
511                         REPLY (" sequence_num(%d) timestamp(%lums) state(%s)",
512                             stuff->sequenceNumber,
513                             (unsigned long)stuff->timestamp,
514                             state);
515                     }
516
517                     return reply;
518                 }
519
520             case RRNotify_ResourceChange:
521                 {
522                     xRRResourceChangeNotifyEvent *stuff = (xRRResourceChangeNotifyEvent *) evt;
523                     REPLY (": XID(0x%x)",
524                         (unsigned int)stuff->window);
525
526                     if (detail_level >= EVLOG_PRINT_DETAIL)
527                     {
528                         REPLY (" sequence_num(%d) timestamp(%lums)",
529                             stuff->sequenceNumber,
530                             (unsigned long)stuff->timestamp);
531                     }
532
533                     return reply;
534                 }
535
536             default:
537                     break;
538             }
539         }
540
541     default:
542             break;
543     }
544
545     return reply;
546 }
547
548 static char *
549 _EvlogReplyRandr (EvlogInfo *evinfo, int detail_level, char *reply, int *len)
550 {
551     xGenericReply *rep = evinfo->rep.ptr;
552
553     switch (evinfo->rep.reqData)
554     {
555         case X_RRGetScreenSizeRange:
556         {
557             if (evinfo->rep.isStart)
558             {
559                 xRRGetScreenSizeRangeReply *stuff = (xRRGetScreenSizeRangeReply *)rep;
560                 REPLY (": minSize(%dx%d) maxSize(%dx%d)",
561                     stuff->minWidth,
562                     stuff->minHeight,
563                     stuff->maxWidth,
564                     stuff->maxHeight);
565             }
566             else
567             {
568                 return reply;
569             }
570
571             return reply;
572         }
573
574         case X_RRGetScreenResources:
575         {
576             static int nCrtcs, nOutputs, nModes, nbytesNames;
577
578             if (evinfo->rep.isStart)
579             {
580                 xRRGetScreenResourcesReply *stuff = (xRRGetScreenResourcesReply *)rep;
581                 REPLY (": Timestamp(%ldms) ConfigTimestamp(%ldms) nCrtcs(%d) nOutputs(%d) nModes(%d) nbytesNames(%d)",
582                     (long int)stuff->timestamp,
583                     (long int)stuff->configTimestamp,
584                     stuff->nCrtcs,
585                     stuff->nOutputs,
586                     stuff->nModes,
587                     stuff->nbytesNames);
588
589                 nCrtcs = stuff->nCrtcs;
590                 nOutputs = stuff->nOutputs;
591                 nModes = stuff->nModes;
592                 nbytesNames = stuff->nbytesNames;
593             }
594             else
595             {
596                 RRCrtc *crtcs = (RRCrtc *)rep;
597                 RROutput *outputs = (RROutput *)(crtcs + nCrtcs);
598                 xRRModeInfo *modeinfos = (xRRModeInfo *)(outputs + nOutputs);
599                 CARD8 *names = (CARD8 *)(modeinfos + nModes);
600                 char temp[64] = {0, };
601                 int i;
602
603                 names[nbytesNames] = '\0';
604
605                 REPLY ("Crtcs");
606                 REPLY ("(");
607                 for (i = 0 ; i < nCrtcs ; i++)
608                 {
609                     REPLY ("0x%x", (unsigned int)crtcs[i]);
610                     if(i != nCrtcs - 1)
611                         REPLY (", ");
612                 }
613                 REPLY (")");
614
615                 REPLY (" Outputs");
616                 REPLY ("(");
617                 for (i = 0 ; i < nOutputs ; i++)
618                 {
619                     REPLY ("0x%x", (unsigned int)outputs[i]);
620                     if(i != nOutputs - 1)
621                         REPLY (", ");
622                 }
623                 REPLY (")");
624
625                 REPLY (" Modes");
626                 REPLY ("(");
627                 for (i = 0 ; i < nModes ; i++)
628                 {
629                     REPLY ("0x%x %dx%d", (unsigned int)modeinfos[i].id, modeinfos[i].width, modeinfos[i].height);
630                     if(i != nModes - 1)
631                         REPLY (", ");
632                 }
633                 REPLY (")");
634
635                 REPLY (" Names");
636
637                 int min = MIN (sizeof (temp) - 1, nbytesNames);
638                 strncpy (temp, (char *)names, min);
639                 temp[min] = '\0';
640
641                 REPLY ("(");
642                 REPLY ("%s", temp);
643                 REPLY (")");
644
645             }
646
647             return reply;
648         }
649
650         case X_RRGetOutputInfo:
651         {
652             static int nCrtcs, nModes, nClones, namelength;
653             if (evinfo->rep.isStart)
654             {
655                 xRRGetOutputInfoReply *stuff = (xRRGetOutputInfoReply *)rep;
656                 REPLY (": Timestamp(%ldms) Crtc(0x%x) mmSize(%ldx%ld) nCrtcs(%d) nModes(%d) nPreferred(%d) nClones(%d)",
657                     (long int)stuff->timestamp,
658                     (unsigned int)stuff->crtc,
659                     (long int)stuff->mmWidth,
660                     (long int)stuff->mmHeight,
661                     stuff->nCrtcs,
662                     stuff->nModes,
663                     stuff->nPreferred,
664                     stuff->nClones);
665
666                 nCrtcs = stuff->nCrtcs;
667                 nModes = stuff->nModes;
668                 nClones = stuff->nClones;
669                 namelength = stuff->nameLength;
670             }
671             else
672             {
673                 RRCrtc *crtcs = (RRCrtc *) rep;
674                 RRMode *modes = (RRMode *) (crtcs + nCrtcs);
675                 RROutput *clones = (RROutput *) (modes + nModes);
676                 char *name = (char *) (clones + nClones);
677                 int i;
678
679                 name[namelength] = '\0';
680
681                 REPLY ("Crtcs");
682                 REPLY ("(");
683                 for (i = 0 ; i < nCrtcs ; i++)
684                 {
685                     REPLY ("0x%x", (unsigned int)crtcs[i]);
686                     if(i != nCrtcs - 1)
687                         REPLY (", ");
688                 }
689                 REPLY (")");
690
691                 REPLY (" Modes");
692                 REPLY ("(");
693                 for (i = 0 ; i < nModes ; i++)
694                 {
695                     REPLY ("0x%x", (unsigned int)modes[i]);
696                     if(i != nModes - 1)
697                         REPLY (", ");
698                 }
699                 REPLY (")");
700
701                 REPLY (" Clone");
702                 REPLY ("(");
703                 for (i = 0 ; i < nClones ; i++)
704                 {
705                     REPLY ("0x%x", (unsigned int)clones[i]);
706                     if(i != nClones - 1)
707                         REPLY (", ");
708                 }
709                 REPLY (")");
710
711                 REPLY (" Name");
712                 REPLY ("(");
713                 REPLY ("%s", name);
714                 REPLY (")");
715             }
716
717             return reply;
718         }
719
720         case X_RRListOutputProperties:
721         {
722             if (evinfo->rep.isStart)
723             {
724                 xRRListOutputPropertiesReply *stuff = (xRRListOutputPropertiesReply *)rep;
725                 REPLY (": nAtoms(%d)",
726                     stuff->nAtoms);
727             }
728             else
729             {
730                 Atom *stuff = (Atom *)rep;
731                 int i;
732
733                 REPLY ("Properties:");
734                 for (i = 0 ; i < evinfo->rep.size / sizeof(Atom) ; i++)
735                 {
736                     reply = xDbgGetAtom(stuff[i], evinfo, reply, len);
737                     if(i != evinfo->rep.size / sizeof(Atom) - 1)
738                         REPLY (", ");
739                 }
740             }
741
742             return reply;
743         }
744
745         case X_RRGetOutputProperty:
746         {
747             if (evinfo->rep.isStart)
748             {
749                 xRRGetOutputPropertyReply *stuff = (xRRGetOutputPropertyReply *)rep;
750                 REPLY (": Atoms");
751                 reply = xDbgGetAtom(stuff->propertyType, evinfo, reply, len);
752
753                 REPLY (" bytesAfter(%ld) nItems(%ld)",
754                     (long int)stuff->bytesAfter,
755                     (long int)stuff->nItems);
756             }
757             else
758             {
759                 return reply;
760             }
761
762             return reply;
763         }
764
765         case X_RRGetCrtcInfo:
766         {
767             static int nOutput, nPossibleOutput;
768
769             if (evinfo->rep.isStart)
770             {
771                 xRRGetCrtcInfoReply *stuff = (xRRGetCrtcInfoReply *)rep;
772                 REPLY (" Timestamp(%ldms) coord(%d,%d %dx%d) RRmode(0x%x) rot(%d) rots(%d) nOutput(%d) nPossibleOutput(%d)",
773                     (long int)stuff->timestamp,
774                     stuff->x,
775                     stuff->y,
776                     stuff->width,
777                     stuff->height,
778                     (unsigned int)stuff->mode,
779                     stuff->rotation,
780                     stuff->rotations,
781                     stuff->nOutput,
782                     stuff->nPossibleOutput);
783
784                 nOutput = stuff->nOutput;
785                 nPossibleOutput = stuff->nPossibleOutput;
786             }
787             else
788             {
789                 RROutput *outputs = (RROutput *) rep;
790                 RROutput *possible = (RROutput *) (outputs + nOutput);
791                 int i;
792
793                 REPLY ("Outputs");
794                 REPLY ("(");
795                 for (i = 0 ; i < nOutput ; i++)
796                 {
797                     REPLY ("0x%x", (unsigned int)outputs[i]);
798                     if(i != nOutput - 1)
799                         REPLY (", ");
800                 }
801                 REPLY (")");
802
803                 REPLY (" Possible");
804                 REPLY ("(");
805                 for (i = 0 ; i < nPossibleOutput ; i++)
806                 {
807                     REPLY ("0x%x", (unsigned int)possible[i]);
808                     if(i != nPossibleOutput - 1)
809                         REPLY (", ");
810                 }
811                 REPLY (")");
812             }
813
814             return reply;
815         }
816
817         case X_RRSetCrtcConfig:
818         {
819             if (evinfo->rep.isStart)
820             {
821                 xRRSetCrtcConfigReply *stuff = (xRRSetCrtcConfigReply *)rep;
822
823                 REPLY (" newTimestamp(%ldms)",
824                     (long int)stuff->newTimestamp);
825             }
826             else
827             {
828                 return reply;
829             }
830
831             return reply;
832         }
833
834         case X_RRGetScreenResourcesCurrent:
835         {
836             static int nCrtcs, nOutputs, nModes, nbytesNames;
837
838             if (evinfo->rep.isStart)
839             {
840                 xRRGetScreenResourcesReply *stuff = (xRRGetScreenResourcesReply *)rep;
841
842                 REPLY (" Timestamp(%ldms) ConfigTimestamp(%ldms) nCrtcs(%d) nOutputs(%d) nModes(%d) nbytesNames(%d)",
843                     (long int)stuff->timestamp,
844                     (long int)stuff->configTimestamp,
845                     stuff->nCrtcs,
846                     stuff->nOutputs,
847                     stuff->nModes,
848                     stuff->nbytesNames);
849
850                 nCrtcs = stuff->nCrtcs;
851                 nOutputs = stuff->nOutputs;
852                 nModes = stuff->nModes;
853                 nbytesNames = stuff->nbytesNames;
854             }
855             else
856             {
857                 RRCrtc *crtcs = (RRCrtc *)rep;
858                 RROutput *outputs = (RROutput *)(crtcs + nCrtcs);
859                 xRRModeInfo *modeinfos = (xRRModeInfo *)(outputs + nOutputs);
860                 CARD8 *names = (CARD8 *)(modeinfos + nModes);
861                 char temp[64] = {0, };
862                 int i;
863
864                 REPLY ("Crtcs");
865                 REPLY ("(");
866                 for (i = 0 ; i < nCrtcs ; i++)
867                 {
868                     REPLY ("0x%x", (unsigned int)crtcs[i]);
869                     if(i != nCrtcs - 1)
870                         REPLY (", ");
871                 }
872                 REPLY (")");
873
874                 REPLY (" Outputs");
875                 REPLY ("(");
876                 for (i = 0 ; i < nOutputs ; i++)
877                 {
878                     REPLY ("0x%x", (unsigned int)outputs[i]);
879                     if(i != nOutputs - 1)
880                         REPLY (", ");
881                 }
882                 REPLY (")");
883
884                 REPLY (" Modes");
885                 REPLY ("(");
886                 for (i = 0 ; i < nModes ; i++)
887                 {
888                     REPLY ("0x%x %dx%d", (unsigned int)modeinfos[i].id, modeinfos[i].width, modeinfos[i].height);
889                     if(i != nModes - 1)
890                         REPLY (", ");
891                 }
892                 REPLY (")");
893
894                 REPLY (" Names");
895
896                 int min = MIN (sizeof (temp) - 1, nbytesNames);
897                 strncpy (temp, (char *)names, min);
898                 temp[min] = '\0';
899
900                 REPLY ("(");
901                 REPLY ("%s", temp);
902                 REPLY (")");
903             }
904
905             return reply;
906         }
907
908     default:
909             break;
910     }
911
912     return reply;
913 }
914
915 void
916 xDbgEvlogRandrGetBase (ExtensionInfo *extinfo)
917 {
918 #ifdef XDBG_CLIENT
919     RETURN_IF_FAIL (extinfo != NULL);
920
921     extinfo->req_func = _EvlogRequestRandr;
922     extinfo->evt_func = _EvlogEventRandr;
923     extinfo->rep_func = _EvlogReplyRandr;
924 #else
925     ExtensionEntry *xext = CheckExtension (RANDR_NAME);
926     RETURN_IF_FAIL (xext != NULL);
927     RETURN_IF_FAIL (extinfo != NULL);
928
929     extinfo->opcode = xext->base;
930     extinfo->evt_base = xext->eventBase;
931     extinfo->err_base = xext->errorBase;
932     extinfo->req_func = _EvlogRequestRandr;
933     extinfo->evt_func = _EvlogEventRandr;
934     extinfo->rep_func = _EvlogReplyRandr;
935 #endif
936 }