~ubuntu-branches/ubuntu/intrepid/xserver-xgl/intrepid

« back to all changes in this revision

Viewing changes to hw/xfree86/dri/xf86dri.c

  • Committer: Bazaar Package Importer
  • Author(s): Matthew Garrett
  • Date: 2006-02-13 14:21:43 UTC
  • Revision ID: james.westby@ubuntu.com-20060213142143-mad6z9xzem7hzxz9
Tags: upstream-7.0.0
ImportĀ upstreamĀ versionĀ 7.0.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* $XFree86: xc/programs/Xserver/GL/dri/xf86dri.c,v 1.12 2002/12/14 01:36:08 dawes Exp $ */
 
2
/**************************************************************************
 
3
 
 
4
Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
 
5
Copyright 2000 VA Linux Systems, Inc.
 
6
All Rights Reserved.
 
7
 
 
8
Permission is hereby granted, free of charge, to any person obtaining a
 
9
copy of this software and associated documentation files (the
 
10
"Software"), to deal in the Software without restriction, including
 
11
without limitation the rights to use, copy, modify, merge, publish,
 
12
distribute, sub license, and/or sell copies of the Software, and to
 
13
permit persons to whom the Software is furnished to do so, subject to
 
14
the following conditions:
 
15
 
 
16
The above copyright notice and this permission notice (including the
 
17
next paragraph) shall be included in all copies or substantial portions
 
18
of the Software.
 
19
 
 
20
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
 
21
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 
22
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
 
23
IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
 
24
ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
 
25
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
 
26
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 
27
 
 
28
**************************************************************************/
 
29
 
 
30
/*
 
31
 * Authors:
 
32
 *   Kevin E. Martin <martin@valinux.com>
 
33
 *   Jens Owen <jens@tungstengraphics.com>
 
34
 *   Rickard E. (Rik) Faith <faith@valinux.com>
 
35
 *
 
36
 */
 
37
 
 
38
#ifdef HAVE_XORG_CONFIG_H
 
39
#include <xorg-config.h>
 
40
#endif
 
41
 
 
42
#include "xf86.h"
 
43
#ifdef XFree86LOADER
 
44
#include "xf86_ansic.h"
 
45
#endif
 
46
 
 
47
#define NEED_REPLIES
 
48
#define NEED_EVENTS
 
49
#include <X11/X.h>
 
50
#include <X11/Xproto.h>
 
51
#include "misc.h"
 
52
#include "dixstruct.h"
 
53
#include "extnsionst.h"
 
54
#include "colormapst.h"
 
55
#include "cursorstr.h"
 
56
#include "scrnintstr.h"
 
57
#include "servermd.h"
 
58
#define _XF86DRI_SERVER_
 
59
#include "xf86dristr.h"
 
60
#include "swaprep.h"
 
61
#include "xf86str.h"
 
62
#include "dri.h"
 
63
#include "sarea.h"
 
64
#include "dristruct.h"
 
65
#include "xf86.h"
 
66
#include "xf86drm.h"
 
67
 
 
68
static int DRIErrorBase;
 
69
 
 
70
static DISPATCH_PROC(ProcXF86DRIQueryVersion);
 
71
static DISPATCH_PROC(ProcXF86DRIQueryDirectRenderingCapable);
 
72
static DISPATCH_PROC(ProcXF86DRIOpenConnection);
 
73
static DISPATCH_PROC(ProcXF86DRICloseConnection);
 
74
static DISPATCH_PROC(ProcXF86DRIGetClientDriverName);
 
75
static DISPATCH_PROC(ProcXF86DRICreateContext);
 
76
static DISPATCH_PROC(ProcXF86DRIDestroyContext);
 
77
static DISPATCH_PROC(ProcXF86DRICreateDrawable);
 
78
static DISPATCH_PROC(ProcXF86DRIDestroyDrawable);
 
79
static DISPATCH_PROC(ProcXF86DRIGetDrawableInfo);
 
80
static DISPATCH_PROC(ProcXF86DRIGetDeviceInfo);
 
81
static DISPATCH_PROC(ProcXF86DRIDispatch);
 
82
static DISPATCH_PROC(ProcXF86DRIAuthConnection);
 
83
 
 
84
static DISPATCH_PROC(SProcXF86DRIQueryVersion);
 
85
static DISPATCH_PROC(SProcXF86DRIDispatch);
 
86
 
 
87
static void XF86DRIResetProc(ExtensionEntry* extEntry);
 
88
 
 
89
static unsigned char DRIReqCode = 0;
 
90
 
 
91
extern void XFree86DRIExtensionInit(void);
 
92
 
 
93
void
 
94
XFree86DRIExtensionInit(void)
 
95
{
 
96
    ExtensionEntry* extEntry;
 
97
 
 
98
#ifdef XF86DRI_EVENTS
 
99
    EventType = CreateNewResourceType(XF86DRIFreeEvents);
 
100
#endif
 
101
 
 
102
    if (
 
103
        DRIExtensionInit() &&
 
104
#ifdef XF86DRI_EVENTS
 
105
        EventType && ScreenPrivateIndex != -1 &&
 
106
#endif
 
107
        (extEntry = AddExtension(XF86DRINAME,
 
108
                                 XF86DRINumberEvents,
 
109
                                 XF86DRINumberErrors,
 
110
                                 ProcXF86DRIDispatch,
 
111
                                 SProcXF86DRIDispatch,
 
112
                                 XF86DRIResetProc,
 
113
                                 StandardMinorOpcode))) {
 
114
        DRIReqCode = (unsigned char)extEntry->base;
 
115
        DRIErrorBase = extEntry->errorBase;
 
116
    }
 
117
}
 
118
 
 
119
/*ARGSUSED*/
 
120
static void
 
121
XF86DRIResetProc (
 
122
    ExtensionEntry* extEntry
 
123
)
 
124
{
 
125
    DRIReset();
 
126
}
 
127
 
 
128
static int
 
129
ProcXF86DRIQueryVersion(
 
130
    register ClientPtr client
 
131
)
 
132
{
 
133
    xXF86DRIQueryVersionReply rep;
 
134
    register int n;
 
135
 
 
136
    REQUEST_SIZE_MATCH(xXF86DRIQueryVersionReq);
 
137
    rep.type = X_Reply;
 
138
    rep.length = 0;
 
139
    rep.sequenceNumber = client->sequence;
 
140
    rep.majorVersion = XF86DRI_MAJOR_VERSION;
 
141
    rep.minorVersion = XF86DRI_MINOR_VERSION;
 
142
    rep.patchVersion = XF86DRI_PATCH_VERSION;
 
143
    if (client->swapped) {
 
144
        swaps(&rep.sequenceNumber, n);
 
145
        swapl(&rep.length, n);
 
146
    }
 
147
    WriteToClient(client, sizeof(xXF86DRIQueryVersionReply), (char *)&rep);
 
148
    return (client->noClientException);
 
149
}
 
150
 
 
151
static int
 
152
ProcXF86DRIQueryDirectRenderingCapable(
 
153
    register ClientPtr client
 
154
)
 
155
{
 
156
    xXF86DRIQueryDirectRenderingCapableReply    rep;
 
157
    Bool isCapable;
 
158
 
 
159
    REQUEST(xXF86DRIQueryDirectRenderingCapableReq);
 
160
    REQUEST_SIZE_MATCH(xXF86DRIQueryDirectRenderingCapableReq);
 
161
    if (stuff->screen >= screenInfo.numScreens) {
 
162
        client->errorValue = stuff->screen;
 
163
        return BadValue;
 
164
    }
 
165
 
 
166
    rep.type = X_Reply;
 
167
    rep.length = 0;
 
168
    rep.sequenceNumber = client->sequence;
 
169
 
 
170
    if (!DRIQueryDirectRenderingCapable( screenInfo.screens[stuff->screen], 
 
171
                                         &isCapable)) {
 
172
        return BadValue;
 
173
    }
 
174
    rep.isCapable = isCapable;
 
175
 
 
176
    if (!LocalClient(client))
 
177
        rep.isCapable = 0;
 
178
 
 
179
    WriteToClient(client, 
 
180
        sizeof(xXF86DRIQueryDirectRenderingCapableReply), (char *)&rep);
 
181
    return (client->noClientException);
 
182
}
 
183
 
 
184
static int
 
185
ProcXF86DRIOpenConnection(
 
186
    register ClientPtr client
 
187
)
 
188
{
 
189
    xXF86DRIOpenConnectionReply rep;
 
190
    drm_handle_t                        hSAREA;
 
191
    char*                       busIdString;
 
192
 
 
193
    REQUEST(xXF86DRIOpenConnectionReq);
 
194
    REQUEST_SIZE_MATCH(xXF86DRIOpenConnectionReq);
 
195
    if (stuff->screen >= screenInfo.numScreens) {
 
196
        client->errorValue = stuff->screen;
 
197
        return BadValue;
 
198
    }
 
199
 
 
200
    if (!DRIOpenConnection( screenInfo.screens[stuff->screen], 
 
201
                            &hSAREA,
 
202
                            &busIdString)) {
 
203
        return BadValue;
 
204
    }
 
205
 
 
206
    rep.type = X_Reply;
 
207
    rep.sequenceNumber = client->sequence;
 
208
    rep.busIdStringLength = 0;
 
209
    if (busIdString)
 
210
        rep.busIdStringLength = strlen(busIdString);
 
211
    rep.length = (SIZEOF(xXF86DRIOpenConnectionReply) - SIZEOF(xGenericReply) +
 
212
                  ((rep.busIdStringLength + 3) & ~3)) >> 2;
 
213
 
 
214
    rep.hSAREALow  = (CARD32)(hSAREA & 0xffffffff);
 
215
#if defined(LONG64) && !defined(__linux__)
 
216
    rep.hSAREAHigh = (CARD32)(hSAREA >> 32);
 
217
#else
 
218
    rep.hSAREAHigh = 0;
 
219
#endif
 
220
 
 
221
    WriteToClient(client, sizeof(xXF86DRIOpenConnectionReply), (char *)&rep);
 
222
    if (rep.busIdStringLength)
 
223
        WriteToClient(client, rep.busIdStringLength, busIdString);
 
224
    return (client->noClientException);
 
225
}
 
226
 
 
227
static int
 
228
ProcXF86DRIAuthConnection(
 
229
    register ClientPtr client
 
230
)
 
231
{
 
232
    xXF86DRIAuthConnectionReply rep;
 
233
    
 
234
    REQUEST(xXF86DRIAuthConnectionReq);
 
235
    REQUEST_SIZE_MATCH(xXF86DRIAuthConnectionReq);
 
236
    if (stuff->screen >= screenInfo.numScreens) {
 
237
        client->errorValue = stuff->screen;
 
238
        return BadValue;
 
239
    }
 
240
 
 
241
    rep.type = X_Reply;
 
242
    rep.length = 0;
 
243
    rep.sequenceNumber = client->sequence;
 
244
    rep.authenticated = 1;
 
245
 
 
246
    if (!DRIAuthConnection( screenInfo.screens[stuff->screen], stuff->magic)) {
 
247
        ErrorF("Failed to authenticate %lu\n", (unsigned long)stuff->magic);
 
248
        rep.authenticated = 0;
 
249
    }
 
250
    WriteToClient(client, sizeof(xXF86DRIAuthConnectionReply), (char *)&rep);
 
251
    return (client->noClientException);
 
252
}
 
253
 
 
254
static int
 
255
ProcXF86DRICloseConnection(
 
256
    register ClientPtr client
 
257
)
 
258
{
 
259
    REQUEST(xXF86DRICloseConnectionReq);
 
260
    REQUEST_SIZE_MATCH(xXF86DRICloseConnectionReq);
 
261
    if (stuff->screen >= screenInfo.numScreens) {
 
262
        client->errorValue = stuff->screen;
 
263
        return BadValue;
 
264
    }
 
265
 
 
266
    DRICloseConnection( screenInfo.screens[stuff->screen]);
 
267
 
 
268
    return (client->noClientException);
 
269
}
 
270
 
 
271
static int
 
272
ProcXF86DRIGetClientDriverName(
 
273
    register ClientPtr client
 
274
)
 
275
{
 
276
    xXF86DRIGetClientDriverNameReply    rep;
 
277
    char* clientDriverName;
 
278
 
 
279
    REQUEST(xXF86DRIGetClientDriverNameReq);
 
280
    REQUEST_SIZE_MATCH(xXF86DRIGetClientDriverNameReq);
 
281
    if (stuff->screen >= screenInfo.numScreens) {
 
282
        client->errorValue = stuff->screen;
 
283
        return BadValue;
 
284
    }
 
285
 
 
286
    DRIGetClientDriverName( screenInfo.screens[stuff->screen],
 
287
                            (int *)&rep.ddxDriverMajorVersion,
 
288
                            (int *)&rep.ddxDriverMinorVersion,
 
289
                            (int *)&rep.ddxDriverPatchVersion,
 
290
                            &clientDriverName);
 
291
 
 
292
    rep.type = X_Reply;
 
293
    rep.sequenceNumber = client->sequence;
 
294
    rep.clientDriverNameLength = 0;
 
295
    if (clientDriverName)
 
296
        rep.clientDriverNameLength = strlen(clientDriverName);
 
297
    rep.length = (SIZEOF(xXF86DRIGetClientDriverNameReply) - 
 
298
                        SIZEOF(xGenericReply) +
 
299
                        ((rep.clientDriverNameLength + 3) & ~3)) >> 2;
 
300
 
 
301
    WriteToClient(client, 
 
302
        sizeof(xXF86DRIGetClientDriverNameReply), (char *)&rep);
 
303
    if (rep.clientDriverNameLength)
 
304
        WriteToClient(client, 
 
305
                      rep.clientDriverNameLength, 
 
306
                      clientDriverName);
 
307
    return (client->noClientException);
 
308
}
 
309
 
 
310
static int
 
311
ProcXF86DRICreateContext(
 
312
    register ClientPtr client
 
313
)
 
314
{
 
315
    xXF86DRICreateContextReply  rep;
 
316
    ScreenPtr pScreen;
 
317
    VisualPtr visual;
 
318
    int i;
 
319
 
 
320
    REQUEST(xXF86DRICreateContextReq);
 
321
    REQUEST_SIZE_MATCH(xXF86DRICreateContextReq);
 
322
    if (stuff->screen >= screenInfo.numScreens) {
 
323
        client->errorValue = stuff->screen;
 
324
        return BadValue;
 
325
    }
 
326
 
 
327
    rep.type = X_Reply;
 
328
    rep.length = 0;
 
329
    rep.sequenceNumber = client->sequence;
 
330
 
 
331
    pScreen = screenInfo.screens[stuff->screen];
 
332
    visual = pScreen->visuals;
 
333
 
 
334
    /* Find the requested X visual */
 
335
    for (i = 0; i < pScreen->numVisuals; i++, visual++)
 
336
        if (visual->vid == stuff->visual)
 
337
            break;
 
338
    if (i == pScreen->numVisuals) {
 
339
        /* No visual found */
 
340
        return BadValue;
 
341
    }
 
342
 
 
343
    if (!DRICreateContext( pScreen,
 
344
                           visual,
 
345
                           stuff->context,
 
346
                           (drm_context_t *)&rep.hHWContext)) {
 
347
        return BadValue;
 
348
    }
 
349
 
 
350
    WriteToClient(client, sizeof(xXF86DRICreateContextReply), (char *)&rep);
 
351
    return (client->noClientException);
 
352
}
 
353
 
 
354
static int
 
355
ProcXF86DRIDestroyContext(
 
356
    register ClientPtr client
 
357
)
 
358
{
 
359
    REQUEST(xXF86DRIDestroyContextReq);
 
360
    REQUEST_SIZE_MATCH(xXF86DRIDestroyContextReq);
 
361
    if (stuff->screen >= screenInfo.numScreens) {
 
362
        client->errorValue = stuff->screen;
 
363
        return BadValue;
 
364
    }
 
365
 
 
366
    if (!DRIDestroyContext( screenInfo.screens[stuff->screen],
 
367
                            stuff->context)) {
 
368
        return BadValue;
 
369
    }
 
370
 
 
371
    return (client->noClientException);
 
372
}
 
373
 
 
374
static int
 
375
ProcXF86DRICreateDrawable(
 
376
    ClientPtr client
 
377
)
 
378
{
 
379
    xXF86DRICreateDrawableReply rep;
 
380
    DrawablePtr pDrawable;
 
381
 
 
382
    REQUEST(xXF86DRICreateDrawableReq);
 
383
    REQUEST_SIZE_MATCH(xXF86DRICreateDrawableReq);
 
384
    if (stuff->screen >= screenInfo.numScreens) {
 
385
        client->errorValue = stuff->screen;
 
386
        return BadValue;
 
387
    }
 
388
 
 
389
    rep.type = X_Reply;
 
390
    rep.length = 0;
 
391
    rep.sequenceNumber = client->sequence;
 
392
 
 
393
    if (!(pDrawable = (DrawablePtr)SecurityLookupDrawable(
 
394
                                                (Drawable)stuff->drawable,
 
395
                                                client, 
 
396
                                                SecurityReadAccess))) {
 
397
        return BadValue;
 
398
    }
 
399
 
 
400
    if (!DRICreateDrawable( screenInfo.screens[stuff->screen],
 
401
                            (Drawable)stuff->drawable,
 
402
                            pDrawable,
 
403
                            (drm_drawable_t *)&rep.hHWDrawable)) {
 
404
        return BadValue;
 
405
    }
 
406
 
 
407
    WriteToClient(client, sizeof(xXF86DRICreateDrawableReply), (char *)&rep);
 
408
    return (client->noClientException);
 
409
}
 
410
 
 
411
static int
 
412
ProcXF86DRIDestroyDrawable(
 
413
    register ClientPtr client
 
414
)
 
415
{
 
416
    REQUEST(xXF86DRIDestroyDrawableReq);
 
417
    DrawablePtr pDrawable;
 
418
    REQUEST_SIZE_MATCH(xXF86DRIDestroyDrawableReq);
 
419
    if (stuff->screen >= screenInfo.numScreens) {
 
420
        client->errorValue = stuff->screen;
 
421
        return BadValue;
 
422
    }
 
423
 
 
424
    if (!(pDrawable = (DrawablePtr)SecurityLookupDrawable(
 
425
                                                (Drawable)stuff->drawable,
 
426
                                                client, 
 
427
                                                SecurityReadAccess))) {
 
428
        return BadValue;
 
429
    }
 
430
 
 
431
    if (!DRIDestroyDrawable( screenInfo.screens[stuff->screen], 
 
432
                             (Drawable)stuff->drawable,
 
433
                             pDrawable)) {
 
434
        return BadValue;
 
435
    }
 
436
 
 
437
    return (client->noClientException);
 
438
}
 
439
 
 
440
static int
 
441
ProcXF86DRIGetDrawableInfo(
 
442
    register ClientPtr client
 
443
)
 
444
{
 
445
    xXF86DRIGetDrawableInfoReply        rep;
 
446
    DrawablePtr pDrawable;
 
447
    int X, Y, W, H;
 
448
    drm_clip_rect_t * pClipRects;
 
449
    drm_clip_rect_t * pBackClipRects;
 
450
    int backX, backY;
 
451
 
 
452
    REQUEST(xXF86DRIGetDrawableInfoReq);
 
453
    REQUEST_SIZE_MATCH(xXF86DRIGetDrawableInfoReq);
 
454
    if (stuff->screen >= screenInfo.numScreens) {
 
455
        client->errorValue = stuff->screen;
 
456
        return BadValue;
 
457
    }
 
458
 
 
459
    rep.type = X_Reply;
 
460
    rep.length = 0;
 
461
    rep.sequenceNumber = client->sequence;
 
462
 
 
463
    if (!(pDrawable = (DrawablePtr)SecurityLookupDrawable(
 
464
                                                (Drawable)stuff->drawable,
 
465
                                                client, 
 
466
                                                SecurityReadAccess))) {
 
467
        return BadValue;
 
468
    }
 
469
 
 
470
    if (!DRIGetDrawableInfo( screenInfo.screens[stuff->screen],
 
471
                             pDrawable,
 
472
                             (unsigned int*)&rep.drawableTableIndex,
 
473
                             (unsigned int*)&rep.drawableTableStamp,
 
474
                             (int*)&X,
 
475
                             (int*)&Y,
 
476
                             (int*)&W,
 
477
                             (int*)&H,
 
478
                             (int*)&rep.numClipRects,
 
479
                             &pClipRects,
 
480
                             &backX, 
 
481
                             &backY,
 
482
                             (int*)&rep.numBackClipRects,
 
483
                             &pBackClipRects)) {
 
484
        return BadValue;
 
485
    }
 
486
 
 
487
    rep.drawableX = X;
 
488
    rep.drawableY = Y;
 
489
    rep.drawableWidth = W;
 
490
    rep.drawableHeight = H;
 
491
    rep.length = (SIZEOF(xXF86DRIGetDrawableInfoReply) - 
 
492
                  SIZEOF(xGenericReply));
 
493
 
 
494
    rep.backX = backX;
 
495
    rep.backY = backY;
 
496
        
 
497
    if (rep.numBackClipRects) 
 
498
       rep.length += sizeof(drm_clip_rect_t) * rep.numBackClipRects;    
 
499
 
 
500
    if (rep.numClipRects) 
 
501
       rep.length += sizeof(drm_clip_rect_t) * rep.numClipRects;
 
502
    
 
503
    rep.length = ((rep.length + 3) & ~3) >> 2;
 
504
 
 
505
    WriteToClient(client, sizeof(xXF86DRIGetDrawableInfoReply), (char *)&rep);
 
506
 
 
507
    if (rep.numClipRects) {
 
508
        WriteToClient(client,  
 
509
                      sizeof(drm_clip_rect_t) * rep.numClipRects,
 
510
                      (char *)pClipRects);
 
511
    }
 
512
 
 
513
    if (rep.numBackClipRects) {
 
514
       WriteToClient(client, 
 
515
                     sizeof(drm_clip_rect_t) * rep.numBackClipRects,
 
516
                     (char *)pBackClipRects);
 
517
    }
 
518
 
 
519
    return (client->noClientException);
 
520
}
 
521
 
 
522
static int
 
523
ProcXF86DRIGetDeviceInfo(
 
524
    register ClientPtr client
 
525
)
 
526
{
 
527
    xXF86DRIGetDeviceInfoReply  rep;
 
528
    drm_handle_t hFrameBuffer;
 
529
    void *pDevPrivate;
 
530
 
 
531
    REQUEST(xXF86DRIGetDeviceInfoReq);
 
532
    REQUEST_SIZE_MATCH(xXF86DRIGetDeviceInfoReq);
 
533
    if (stuff->screen >= screenInfo.numScreens) {
 
534
        client->errorValue = stuff->screen;
 
535
        return BadValue;
 
536
    }
 
537
 
 
538
    rep.type = X_Reply;
 
539
    rep.length = 0;
 
540
    rep.sequenceNumber = client->sequence;
 
541
 
 
542
    if (!DRIGetDeviceInfo( screenInfo.screens[stuff->screen],
 
543
                           &hFrameBuffer,
 
544
                           (int*)&rep.framebufferOrigin,
 
545
                           (int*)&rep.framebufferSize,
 
546
                           (int*)&rep.framebufferStride,
 
547
                           (int*)&rep.devPrivateSize,
 
548
                           &pDevPrivate)) {
 
549
        return BadValue;
 
550
    }
 
551
 
 
552
    rep.hFrameBufferLow  = (CARD32)(hFrameBuffer & 0xffffffff);
 
553
#if defined(LONG64) && !defined(__linux__)
 
554
    rep.hFrameBufferHigh = (CARD32)(hFrameBuffer >> 32);
 
555
#else
 
556
    rep.hFrameBufferHigh = 0;
 
557
#endif
 
558
 
 
559
    rep.length = 0;
 
560
    if (rep.devPrivateSize) {
 
561
        rep.length = (SIZEOF(xXF86DRIGetDeviceInfoReply) - 
 
562
                      SIZEOF(xGenericReply) +
 
563
                      ((rep.devPrivateSize + 3) & ~3)) >> 2;
 
564
    }
 
565
 
 
566
    WriteToClient(client, sizeof(xXF86DRIGetDeviceInfoReply), (char *)&rep);
 
567
    if (rep.length) {
 
568
        WriteToClient(client, rep.devPrivateSize, (char *)pDevPrivate);
 
569
    }
 
570
    return (client->noClientException);
 
571
}
 
572
 
 
573
static int
 
574
ProcXF86DRIDispatch (
 
575
    register ClientPtr  client
 
576
)
 
577
{
 
578
    REQUEST(xReq);
 
579
 
 
580
    switch (stuff->data)
 
581
    {
 
582
    case X_XF86DRIQueryVersion:
 
583
        return ProcXF86DRIQueryVersion(client);
 
584
    case X_XF86DRIQueryDirectRenderingCapable:
 
585
        return ProcXF86DRIQueryDirectRenderingCapable(client);
 
586
    }
 
587
 
 
588
    if (!LocalClient(client))
 
589
        return DRIErrorBase + XF86DRIClientNotLocal;
 
590
 
 
591
    switch (stuff->data)
 
592
    {
 
593
    case X_XF86DRIOpenConnection:
 
594
        return ProcXF86DRIOpenConnection(client);
 
595
    case X_XF86DRICloseConnection:
 
596
        return ProcXF86DRICloseConnection(client);
 
597
    case X_XF86DRIGetClientDriverName:
 
598
        return ProcXF86DRIGetClientDriverName(client);
 
599
    case X_XF86DRICreateContext:
 
600
        return ProcXF86DRICreateContext(client);
 
601
    case X_XF86DRIDestroyContext:
 
602
        return ProcXF86DRIDestroyContext(client);
 
603
    case X_XF86DRICreateDrawable:
 
604
        return ProcXF86DRICreateDrawable(client);
 
605
    case X_XF86DRIDestroyDrawable:
 
606
        return ProcXF86DRIDestroyDrawable(client);
 
607
    case X_XF86DRIGetDrawableInfo:
 
608
        return ProcXF86DRIGetDrawableInfo(client);
 
609
    case X_XF86DRIGetDeviceInfo:
 
610
        return ProcXF86DRIGetDeviceInfo(client);
 
611
    case X_XF86DRIAuthConnection:
 
612
        return ProcXF86DRIAuthConnection(client);
 
613
    /* {Open,Close}FullScreen are deprecated now */
 
614
    default:
 
615
        return BadRequest;
 
616
    }
 
617
}
 
618
 
 
619
static int
 
620
SProcXF86DRIQueryVersion(
 
621
    register ClientPtr  client
 
622
)
 
623
{
 
624
    register int n;
 
625
    REQUEST(xXF86DRIQueryVersionReq);
 
626
    swaps(&stuff->length, n);
 
627
    return ProcXF86DRIQueryVersion(client);
 
628
}
 
629
 
 
630
static int
 
631
SProcXF86DRIDispatch (
 
632
    register ClientPtr  client
 
633
)
 
634
{
 
635
    REQUEST(xReq);
 
636
 
 
637
    /* It is bound to be non-local when there is byte swapping */
 
638
    if (!LocalClient(client))
 
639
        return DRIErrorBase + XF86DRIClientNotLocal;
 
640
 
 
641
    /* only local clients are allowed DRI access */
 
642
    switch (stuff->data)
 
643
    {
 
644
    case X_XF86DRIQueryVersion:
 
645
        return SProcXF86DRIQueryVersion(client);
 
646
    default:
 
647
        return BadRequest;
 
648
    }
 
649
}