1
/* $XdotOrg: xserver/xorg/Xext/xvdisp.c,v 1.6 2005/07/03 08:53:36 daniels Exp $ */
2
/***********************************************************
3
Copyright 1991 by Digital Equipment Corporation, Maynard, Massachusetts,
4
and the Massachusetts Institute of Technology, Cambridge, Massachusetts.
8
Permission to use, copy, modify, and distribute this software and its
9
documentation for any purpose and without fee is hereby granted,
10
provided that the above copyright notice appear in all copies and that
11
both that copyright notice and this permission notice appear in
12
supporting documentation, and that the names of Digital or MIT not be
13
used in advertising or publicity pertaining to distribution of the
14
software without specific, written prior permission.
16
DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
17
ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
18
DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
19
ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
20
WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
21
ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
24
******************************************************************/
25
/* $XFree86: xc/programs/Xserver/Xext/xvdisp.c,v 1.27 2003/07/16 01:38:31 dawes Exp $ */
30
** xvdisp.c --- Xv server extension dispatch module.
34
** David Carver (Digital Workstation Engineering/Project Athena)
39
** - changed SetPortControl to SetPortAttribute
40
** - changed GetPortControl to GetPortAttribute
41
** - changed QueryBestSize
44
** - version 2.0 upgrade
47
** - version 1.4 upgrade
51
#ifdef HAVE_DIX_CONFIG_H
52
#include <dix-config.h>
56
#include <X11/Xproto.h>
58
#include "scrnintstr.h"
59
#include "windowstr.h"
60
#include "pixmapstr.h"
62
#include "dixstruct.h"
66
#include <X11/extensions/Xv.h>
67
#include <X11/extensions/Xvproto.h>
71
#include <X11/extensions/shmstr.h>
75
#include "xf86_ansic.h"
81
#include "panoramiX.h"
82
#include "panoramiXsrv.h"
84
unsigned long XvXRTPort;
87
static int XineramaXvShmPutImage(ClientPtr);
89
static int XineramaXvPutImage(ClientPtr);
90
static int XineramaXvPutVideo(ClientPtr);
91
static int XineramaXvPutStill(ClientPtr);
92
static int XineramaXvSetPortAttribute(ClientPtr);
93
static int XineramaXvStopVideo(ClientPtr);
98
static int ProcXvQueryExtension(ClientPtr);
99
static int ProcXvQueryAdaptors(ClientPtr);
100
static int ProcXvQueryEncodings(ClientPtr);
101
static int ProcXvPutVideo(ClientPtr);
102
static int ProcXvPutStill(ClientPtr);
103
static int ProcXvGetVideo(ClientPtr);
104
static int ProcXvGetStill(ClientPtr);
105
static int ProcXvGrabPort(ClientPtr);
106
static int ProcXvUngrabPort(ClientPtr);
107
static int ProcXvSelectVideoNotify(ClientPtr);
108
static int ProcXvSelectPortNotify(ClientPtr);
109
static int ProcXvStopVideo(ClientPtr);
110
static int ProcXvSetPortAttribute(ClientPtr);
111
static int ProcXvGetPortAttribute(ClientPtr);
112
static int ProcXvQueryBestSize(ClientPtr);
113
static int ProcXvQueryPortAttributes(ClientPtr);
114
static int ProcXvPutImage(ClientPtr);
116
static int ProcXvShmPutImage(ClientPtr);
118
static int ProcXvQueryImageAttributes(ClientPtr);
119
static int ProcXvListImageFormats(ClientPtr);
121
static int SProcXvQueryExtension(ClientPtr);
122
static int SProcXvQueryAdaptors(ClientPtr);
123
static int SProcXvQueryEncodings(ClientPtr);
124
static int SProcXvPutVideo(ClientPtr);
125
static int SProcXvPutStill(ClientPtr);
126
static int SProcXvGetVideo(ClientPtr);
127
static int SProcXvGetStill(ClientPtr);
128
static int SProcXvGrabPort(ClientPtr);
129
static int SProcXvUngrabPort(ClientPtr);
130
static int SProcXvSelectVideoNotify(ClientPtr);
131
static int SProcXvSelectPortNotify(ClientPtr);
132
static int SProcXvStopVideo(ClientPtr);
133
static int SProcXvSetPortAttribute(ClientPtr);
134
static int SProcXvGetPortAttribute(ClientPtr);
135
static int SProcXvQueryBestSize(ClientPtr);
136
static int SProcXvQueryPortAttributes(ClientPtr);
137
static int SProcXvPutImage(ClientPtr);
139
static int SProcXvShmPutImage(ClientPtr);
141
static int SProcXvQueryImageAttributes(ClientPtr);
142
static int SProcXvListImageFormats(ClientPtr);
144
static int SWriteQueryAdaptorsReply(ClientPtr, xvQueryAdaptorsReply *);
145
static int SWriteQueryExtensionReply(ClientPtr, xvQueryExtensionReply *);
146
static int SWriteQueryEncodingsReply(ClientPtr, xvQueryEncodingsReply *);
147
static int SWriteAdaptorInfo(ClientPtr, xvAdaptorInfo *);
148
static int SWriteEncodingInfo(ClientPtr, xvEncodingInfo *);
149
static int SWriteFormat(ClientPtr, xvFormat *);
150
static int SWriteAttributeInfo(ClientPtr, xvAttributeInfo *);
151
static int SWriteGrabPortReply(ClientPtr, xvGrabPortReply *);
152
static int SWriteGetPortAttributeReply(ClientPtr, xvGetPortAttributeReply *);
153
static int SWriteQueryBestSizeReply(ClientPtr, xvQueryBestSizeReply *);
154
static int SWriteQueryPortAttributesReply(
155
ClientPtr, xvQueryPortAttributesReply *);
156
static int SWriteQueryImageAttributesReply(
157
ClientPtr, xvQueryImageAttributesReply*);
158
static int SWriteListImageFormatsReply(ClientPtr, xvListImageFormatsReply*);
159
static int SWriteImageFormatInfo(ClientPtr, xvImageFormatInfo*);
161
#define _WriteQueryAdaptorsReply(_c,_d) \
162
if ((_c)->swapped) SWriteQueryAdaptorsReply(_c, _d); \
163
else WriteToClient(_c, sz_xvQueryAdaptorsReply, (char*)_d)
165
#define _WriteQueryExtensionReply(_c,_d) \
166
if ((_c)->swapped) SWriteQueryExtensionReply(_c, _d); \
167
else WriteToClient(_c, sz_xvQueryExtensionReply, (char*)_d)
169
#define _WriteQueryEncodingsReply(_c,_d) \
170
if ((_c)->swapped) SWriteQueryEncodingsReply(_c, _d); \
171
else WriteToClient(_c, sz_xvQueryEncodingsReply, (char*)_d)
173
#define _WriteAdaptorInfo(_c,_d) \
174
if ((_c)->swapped) SWriteAdaptorInfo(_c, _d); \
175
else WriteToClient(_c, sz_xvAdaptorInfo, (char*)_d)
177
#define _WriteAttributeInfo(_c,_d) \
178
if ((_c)->swapped) SWriteAttributeInfo(_c, _d); \
179
else WriteToClient(_c, sz_xvAttributeInfo, (char*)_d)
181
#define _WriteEncodingInfo(_c,_d) \
182
if ((_c)->swapped) SWriteEncodingInfo(_c, _d); \
183
else WriteToClient(_c, sz_xvEncodingInfo, (char*)_d)
185
#define _WriteFormat(_c,_d) \
186
if ((_c)->swapped) SWriteFormat(_c, _d); \
187
else WriteToClient(_c, sz_xvFormat, (char*)_d)
189
#define _WriteGrabPortReply(_c,_d) \
190
if ((_c)->swapped) SWriteGrabPortReply(_c, _d); \
191
else WriteToClient(_c, sz_xvGrabPortReply, (char*)_d)
193
#define _WriteGetPortAttributeReply(_c,_d) \
194
if ((_c)->swapped) SWriteGetPortAttributeReply(_c, _d); \
195
else WriteToClient(_c, sz_xvGetPortAttributeReply, (char*)_d)
197
#define _WriteQueryBestSizeReply(_c,_d) \
198
if ((_c)->swapped) SWriteQueryBestSizeReply(_c, _d); \
199
else WriteToClient(_c, sz_xvQueryBestSizeReply,(char*) _d)
201
#define _WriteQueryPortAttributesReply(_c,_d) \
202
if ((_c)->swapped) SWriteQueryPortAttributesReply(_c, _d); \
203
else WriteToClient(_c, sz_xvQueryPortAttributesReply,(char*) _d)
205
#define _WriteQueryImageAttributesReply(_c,_d) \
206
if ((_c)->swapped) SWriteQueryImageAttributesReply(_c, _d); \
207
else WriteToClient(_c, sz_xvQueryImageAttributesReply,(char*) _d)
209
#define _WriteListImageFormatsReply(_c,_d) \
210
if ((_c)->swapped) SWriteListImageFormatsReply(_c, _d); \
211
else WriteToClient(_c, sz_xvListImageFormatsReply,(char*) _d)
213
#define _WriteImageFormatInfo(_c,_d) \
214
if ((_c)->swapped) SWriteImageFormatInfo(_c, _d); \
215
else WriteToClient(_c, sz_xvImageFormatInfo, (char*)_d)
217
#define _AllocatePort(_i,_p) \
218
((_p)->id != _i) ? (* (_p)->pAdaptor->ddAllocatePort)(_i,_p,&_p) : Success
228
ProcXvDispatch(ClientPtr client)
236
case xv_QueryExtension: return(ProcXvQueryExtension(client));
237
case xv_QueryAdaptors: return(ProcXvQueryAdaptors(client));
238
case xv_QueryEncodings: return(ProcXvQueryEncodings(client));
241
if(!noPanoramiXExtension)
242
return(XineramaXvPutVideo(client));
245
return(ProcXvPutVideo(client));
248
if(!noPanoramiXExtension)
249
return(XineramaXvPutStill(client));
252
return(ProcXvPutStill(client));
253
case xv_GetVideo: return(ProcXvGetVideo(client));
254
case xv_GetStill: return(ProcXvGetStill(client));
255
case xv_GrabPort: return(ProcXvGrabPort(client));
256
case xv_UngrabPort: return(ProcXvUngrabPort(client));
257
case xv_SelectVideoNotify: return(ProcXvSelectVideoNotify(client));
258
case xv_SelectPortNotify: return(ProcXvSelectPortNotify(client));
261
if(!noPanoramiXExtension)
262
return(XineramaXvStopVideo(client));
265
return(ProcXvStopVideo(client));
266
case xv_SetPortAttribute:
268
if(!noPanoramiXExtension)
269
return(XineramaXvSetPortAttribute(client));
272
return(ProcXvSetPortAttribute(client));
273
case xv_GetPortAttribute: return(ProcXvGetPortAttribute(client));
274
case xv_QueryBestSize: return(ProcXvQueryBestSize(client));
275
case xv_QueryPortAttributes: return(ProcXvQueryPortAttributes(client));
278
if(!noPanoramiXExtension)
279
return(XineramaXvPutImage(client));
282
return(ProcXvPutImage(client));
286
if(!noPanoramiXExtension)
287
return(XineramaXvShmPutImage(client));
290
return(ProcXvShmPutImage(client));
292
case xv_QueryImageAttributes: return(ProcXvQueryImageAttributes(client));
293
case xv_ListImageFormats: return(ProcXvListImageFormats(client));
295
if (stuff->data < xvNumRequests)
297
SendErrorToClient(client, XvReqCode, stuff->data, 0,
299
return(BadImplementation);
303
SendErrorToClient(client, XvReqCode, stuff->data, 0, BadRequest);
310
SProcXvDispatch(ClientPtr client)
318
case xv_QueryExtension: return(SProcXvQueryExtension(client));
319
case xv_QueryAdaptors: return(SProcXvQueryAdaptors(client));
320
case xv_QueryEncodings: return(SProcXvQueryEncodings(client));
321
case xv_PutVideo: return(SProcXvPutVideo(client));
322
case xv_PutStill: return(SProcXvPutStill(client));
323
case xv_GetVideo: return(SProcXvGetVideo(client));
324
case xv_GetStill: return(SProcXvGetStill(client));
325
case xv_GrabPort: return(SProcXvGrabPort(client));
326
case xv_UngrabPort: return(SProcXvUngrabPort(client));
327
case xv_SelectVideoNotify: return(SProcXvSelectVideoNotify(client));
328
case xv_SelectPortNotify: return(SProcXvSelectPortNotify(client));
329
case xv_StopVideo: return(SProcXvStopVideo(client));
330
case xv_SetPortAttribute: return(SProcXvSetPortAttribute(client));
331
case xv_GetPortAttribute: return(SProcXvGetPortAttribute(client));
332
case xv_QueryBestSize: return(SProcXvQueryBestSize(client));
333
case xv_QueryPortAttributes: return(SProcXvQueryPortAttributes(client));
334
case xv_PutImage: return(SProcXvPutImage(client));
336
case xv_ShmPutImage: return(SProcXvShmPutImage(client));
338
case xv_QueryImageAttributes: return(SProcXvQueryImageAttributes(client));
339
case xv_ListImageFormats: return(SProcXvListImageFormats(client));
341
if (stuff->data < xvNumRequests)
343
SendErrorToClient(client, XvReqCode, stuff->data, 0,
345
return(BadImplementation);
349
SendErrorToClient(client, XvReqCode, stuff->data, 0, BadRequest);
356
ProcXvQueryExtension(ClientPtr client)
358
xvQueryExtensionReply rep;
359
/* REQUEST(xvQueryExtensionReq); */
360
REQUEST_SIZE_MATCH(xvQueryExtensionReq);
363
rep.sequenceNumber = client->sequence;
365
rep.version = XvVersion;
366
rep.revision = XvRevision;
368
_WriteQueryExtensionReply(client, &rep);
375
ProcXvQueryAdaptors(ClientPtr client)
379
xvQueryAdaptorsReply rep;
389
REQUEST(xvQueryAdaptorsReq);
390
REQUEST_SIZE_MATCH(xvQueryAdaptorsReq);
392
if(!(pWin = (WindowPtr)LookupWindow(stuff->window, client) ))
394
client->errorValue = stuff->window;
398
pScreen = pWin->drawable.pScreen;
399
pxvs = (XvScreenPtr)pScreen->devPrivates[XvScreenIndex].ptr;
404
rep.sequenceNumber = client->sequence;
405
rep.num_adaptors = 0;
408
_WriteQueryAdaptorsReply(client, &rep);
413
(* pxvs->ddQueryAdaptors)(pScreen, &pxvs->pAdaptors, &pxvs->nAdaptors);
416
rep.sequenceNumber = client->sequence;
417
rep.num_adaptors = pxvs->nAdaptors;
419
/* CALCULATE THE TOTAL SIZE OF THE REPLY IN BYTES */
421
totalSize = pxvs->nAdaptors * sz_xvAdaptorInfo;
423
/* FOR EACH ADPATOR ADD UP THE BYTES FOR ENCODINGS AND FORMATS */
425
na = pxvs->nAdaptors;
426
pa = pxvs->pAdaptors;
429
totalSize += (strlen(pa->name) + 3) & ~3;
430
totalSize += pa->nFormats * sz_xvFormat;
434
rep.length = totalSize >> 2;
436
_WriteQueryAdaptorsReply(client, &rep);
438
na = pxvs->nAdaptors;
439
pa = pxvs->pAdaptors;
443
ainfo.base_id = pa->base_id;
444
ainfo.num_ports = pa->nPorts;
445
ainfo.type = pa->type;
446
ainfo.name_size = strlen(pa->name);
447
ainfo.num_formats = pa->nFormats;
449
_WriteAdaptorInfo(client, &ainfo);
451
WriteToClient(client, ainfo.name_size, pa->name);
457
format.depth = pf->depth;
458
format.visual = pf->visual;
459
_WriteFormat(client, &format);
467
return (client->noClientException);
472
ProcXvQueryEncodings(ClientPtr client)
474
xvEncodingInfo einfo;
475
xvQueryEncodingsReply rep;
482
REQUEST(xvQueryEncodingsReq);
483
REQUEST_SIZE_MATCH(xvQueryEncodingsReq);
485
if(!(pPort = LOOKUP_PORT(stuff->port, client) ))
487
client->errorValue = stuff->port;
491
if ((status = _AllocatePort(stuff->port, pPort)) != Success)
493
client->errorValue = stuff->port;
498
rep.sequenceNumber = client->sequence;
499
rep.num_encodings = pPort->pAdaptor->nEncodings;
501
/* FOR EACH ENCODING ADD UP THE BYTES FOR ENCODING NAMES */
503
ne = pPort->pAdaptor->nEncodings;
504
pe = pPort->pAdaptor->pEncodings;
505
totalSize = ne * sz_xvEncodingInfo;
508
totalSize += (strlen(pe->name) + 3) & ~3;
512
rep.length = totalSize >> 2;
514
_WriteQueryEncodingsReply(client, &rep);
516
ne = pPort->pAdaptor->nEncodings;
517
pe = pPort->pAdaptor->pEncodings;
520
einfo.encoding = pe->id;
521
einfo.name_size = strlen(pe->name);
522
einfo.width = pe->width;
523
einfo.height = pe->height;
524
einfo.rate.numerator = pe->rate.numerator;
525
einfo.rate.denominator = pe->rate.denominator;
526
_WriteEncodingInfo(client, &einfo);
527
WriteToClient(client, einfo.name_size, pe->name);
531
return (client->noClientException);
536
ProcXvPutVideo(ClientPtr client)
538
register DrawablePtr pDraw;
543
REQUEST(xvPutVideoReq);
544
REQUEST_SIZE_MATCH(xvPutVideoReq);
546
VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, pGC, client);
548
if(!(pPort = LOOKUP_PORT(stuff->port, client) ))
550
client->errorValue = stuff->port;
554
if ((status = _AllocatePort(stuff->port, pPort)) != Success)
556
client->errorValue = stuff->port;
560
if (!(pPort->pAdaptor->type & XvInputMask) ||
561
!(pPort->pAdaptor->type & XvVideoMask))
563
client->errorValue = stuff->port;
567
status = XVCALL(diMatchPort)(pPort, pDraw);
568
if (status != Success)
573
return XVCALL(diPutVideo)(client, pDraw, pPort, pGC,
574
stuff->vid_x, stuff->vid_y,
575
stuff->vid_w, stuff->vid_h,
576
stuff->drw_x, stuff->drw_y,
577
stuff->drw_w, stuff->drw_h);
582
ProcXvPutStill(ClientPtr client)
584
register DrawablePtr pDraw;
589
REQUEST(xvPutStillReq);
590
REQUEST_SIZE_MATCH(xvPutStillReq);
592
VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, pGC, client);
594
if(!(pPort = LOOKUP_PORT(stuff->port, client) ))
596
client->errorValue = stuff->port;
600
if ((status = _AllocatePort(stuff->port, pPort)) != Success)
602
client->errorValue = stuff->port;
606
if (!(pPort->pAdaptor->type & XvInputMask) ||
607
!(pPort->pAdaptor->type & XvStillMask))
609
client->errorValue = stuff->port;
613
status = XVCALL(diMatchPort)(pPort, pDraw);
614
if (status != Success)
619
return XVCALL(diPutStill)(client, pDraw, pPort, pGC,
620
stuff->vid_x, stuff->vid_y,
621
stuff->vid_w, stuff->vid_h,
622
stuff->drw_x, stuff->drw_y,
623
stuff->drw_w, stuff->drw_h);
629
ProcXvGetVideo(ClientPtr client)
631
register DrawablePtr pDraw;
636
REQUEST(xvGetVideoReq);
637
REQUEST_SIZE_MATCH(xvGetVideoReq);
639
VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, pGC, client);
641
if(!(pPort = LOOKUP_PORT(stuff->port, client) ))
643
client->errorValue = stuff->port;
647
if ((status = _AllocatePort(stuff->port, pPort)) != Success)
649
client->errorValue = stuff->port;
653
if (!(pPort->pAdaptor->type & XvOutputMask) ||
654
!(pPort->pAdaptor->type & XvVideoMask))
656
client->errorValue = stuff->port;
660
status = XVCALL(diMatchPort)(pPort, pDraw);
661
if (status != Success)
666
return XVCALL(diGetVideo)(client, pDraw, pPort, pGC,
667
stuff->vid_x, stuff->vid_y,
668
stuff->vid_w, stuff->vid_h,
669
stuff->drw_x, stuff->drw_y,
670
stuff->drw_w, stuff->drw_h);
676
ProcXvGetStill(ClientPtr client)
678
register DrawablePtr pDraw;
683
REQUEST(xvGetStillReq);
684
REQUEST_SIZE_MATCH(xvGetStillReq);
686
VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, pGC, client);
688
if(!(pPort = LOOKUP_PORT(stuff->port, client) ))
690
client->errorValue = stuff->port;
694
if ((status = _AllocatePort(stuff->port, pPort)) != Success)
696
client->errorValue = stuff->port;
700
if (!(pPort->pAdaptor->type & XvOutputMask) ||
701
!(pPort->pAdaptor->type & XvStillMask))
703
client->errorValue = stuff->port;
707
status = XVCALL(diMatchPort)(pPort, pDraw);
708
if (status != Success)
713
return XVCALL(diGetStill)(client, pDraw, pPort, pGC,
714
stuff->vid_x, stuff->vid_y,
715
stuff->vid_w, stuff->vid_h,
716
stuff->drw_x, stuff->drw_y,
717
stuff->drw_w, stuff->drw_h);
722
ProcXvSelectVideoNotify(ClientPtr client)
724
register DrawablePtr pDraw;
725
REQUEST(xvSelectVideoNotifyReq);
726
REQUEST_SIZE_MATCH(xvSelectVideoNotifyReq);
728
if(!(pDraw = (DrawablePtr)LOOKUP_DRAWABLE(stuff->drawable, client) ))
730
client->errorValue = stuff->drawable;
734
return XVCALL(diSelectVideoNotify)(client, pDraw, stuff->onoff);
739
ProcXvSelectPortNotify(ClientPtr client)
743
REQUEST(xvSelectPortNotifyReq);
744
REQUEST_SIZE_MATCH(xvSelectPortNotifyReq);
746
if(!(pPort = LOOKUP_PORT(stuff->port, client) ))
748
client->errorValue = stuff->port;
752
if ((status = _AllocatePort(stuff->port, pPort)) != Success)
754
client->errorValue = stuff->port;
758
return XVCALL(diSelectPortNotify)(client, pPort, stuff->onoff);
763
ProcXvGrabPort(ClientPtr client)
768
REQUEST(xvGrabPortReq);
769
REQUEST_SIZE_MATCH(xvGrabPortReq);
771
if(!(pPort = LOOKUP_PORT(stuff->port, client) ))
773
client->errorValue = stuff->port;
777
if ((status = _AllocatePort(stuff->port, pPort)) != Success)
779
client->errorValue = stuff->port;
783
status = XVCALL(diGrabPort)(client, pPort, stuff->time, &result);
785
if (status != Success)
791
rep.sequenceNumber = client->sequence;
795
_WriteGrabPortReply(client, &rep);
802
ProcXvUngrabPort(ClientPtr client)
806
REQUEST(xvGrabPortReq);
807
REQUEST_SIZE_MATCH(xvGrabPortReq);
809
if(!(pPort = LOOKUP_PORT(stuff->port, client) ))
811
client->errorValue = stuff->port;
815
if ((status = _AllocatePort(stuff->port, pPort)) != Success)
817
client->errorValue = stuff->port;
821
return XVCALL(diUngrabPort)(client, pPort, stuff->time);
827
ProcXvStopVideo(ClientPtr client)
830
register DrawablePtr pDraw;
832
REQUEST(xvStopVideoReq);
833
REQUEST_SIZE_MATCH(xvStopVideoReq);
835
if(!(pPort = LOOKUP_PORT(stuff->port, client) ))
837
client->errorValue = stuff->port;
841
if ((status = _AllocatePort(stuff->port, pPort)) != Success)
843
client->errorValue = stuff->port;
847
if(!(pDraw = LOOKUP_DRAWABLE(stuff->drawable, client) ))
849
client->errorValue = stuff->drawable;
850
return (BadDrawable);
853
return XVCALL(diStopVideo)(client, pPort, pDraw);
858
ProcXvSetPortAttribute(ClientPtr client)
862
REQUEST(xvSetPortAttributeReq);
863
REQUEST_SIZE_MATCH(xvSetPortAttributeReq);
865
if(!(pPort = LOOKUP_PORT(stuff->port, client) ))
867
client->errorValue = stuff->port;
871
if ((status = _AllocatePort(stuff->port, pPort)) != Success)
873
client->errorValue = stuff->port;
877
if (!ValidAtom(stuff->attribute))
879
client->errorValue = stuff->attribute;
883
status = XVCALL(diSetPortAttribute)(client, pPort,
884
stuff->attribute, stuff->value);
886
if (status == BadMatch)
887
client->errorValue = stuff->attribute;
889
client->errorValue = stuff->value;
895
ProcXvGetPortAttribute(ClientPtr client)
900
xvGetPortAttributeReply rep;
901
REQUEST(xvGetPortAttributeReq);
902
REQUEST_SIZE_MATCH(xvGetPortAttributeReq);
904
if(!(pPort = LOOKUP_PORT(stuff->port, client) ))
906
client->errorValue = stuff->port;
910
if ((status = _AllocatePort(stuff->port, pPort)) != Success)
912
client->errorValue = stuff->port;
916
if (!ValidAtom(stuff->attribute))
918
client->errorValue = stuff->attribute;
922
status = XVCALL(diGetPortAttribute)(client, pPort, stuff->attribute, &value);
923
if (status != Success)
925
client->errorValue = stuff->attribute;
930
rep.sequenceNumber = client->sequence;
934
_WriteGetPortAttributeReply(client, &rep);
940
ProcXvQueryBestSize(ClientPtr client)
943
unsigned int actual_width, actual_height;
945
xvQueryBestSizeReply rep;
946
REQUEST(xvQueryBestSizeReq);
947
REQUEST_SIZE_MATCH(xvQueryBestSizeReq);
949
if(!(pPort = LOOKUP_PORT(stuff->port, client) ))
951
client->errorValue = stuff->port;
955
if ((status = _AllocatePort(stuff->port, pPort)) != Success)
957
client->errorValue = stuff->port;
962
rep.sequenceNumber = client->sequence;
965
(* pPort->pAdaptor->ddQueryBestSize)(client, pPort, stuff->motion,
966
stuff->vid_w, stuff->vid_h,
967
stuff->drw_w, stuff->drw_h,
968
&actual_width, &actual_height);
970
rep.actual_width = actual_width;
971
rep.actual_height = actual_height;
973
_WriteQueryBestSizeReply(client, &rep);
980
ProcXvQueryPortAttributes(ClientPtr client)
985
xvQueryPortAttributesReply rep;
986
xvAttributeInfo Info;
987
REQUEST(xvQueryPortAttributesReq);
988
REQUEST_SIZE_MATCH(xvQueryPortAttributesReq);
990
if(!(pPort = LOOKUP_PORT(stuff->port, client) ))
992
client->errorValue = stuff->port;
996
if ((status = _AllocatePort(stuff->port, pPort)) != Success)
998
client->errorValue = stuff->port;
1003
rep.sequenceNumber = client->sequence;
1004
rep.num_attributes = pPort->pAdaptor->nAttributes;
1007
for(i = 0, pAtt = pPort->pAdaptor->pAttributes;
1008
i < rep.num_attributes; i++, pAtt++)
1010
rep.text_size += (strlen(pAtt->name) + 1 + 3) & ~3L;
1013
rep.length = (rep.num_attributes * sz_xvAttributeInfo) + rep.text_size;
1016
_WriteQueryPortAttributesReply(client, &rep);
1018
for(i = 0, pAtt = pPort->pAdaptor->pAttributes;
1019
i < rep.num_attributes; i++, pAtt++)
1021
size = strlen(pAtt->name) + 1; /* pass the NULL */
1022
Info.flags = pAtt->flags;
1023
Info.min = pAtt->min_value;
1024
Info.max = pAtt->max_value;
1025
Info.size = (size + 3) & ~3L;
1027
_WriteAttributeInfo(client, &Info);
1029
WriteToClient(client, size, pAtt->name);
1038
ProcXvPutImage(ClientPtr client)
1042
XvImagePtr pImage = NULL;
1044
int status, i, size;
1045
CARD16 width, height;
1047
REQUEST(xvPutImageReq);
1048
REQUEST_AT_LEAST_SIZE(xvPutImageReq);
1050
VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, pGC, client);
1052
if(!(pPort = LOOKUP_PORT(stuff->port, client) ))
1054
client->errorValue = stuff->port;
1055
return (_XvBadPort);
1058
if ((status = _AllocatePort(stuff->port, pPort)) != Success)
1060
client->errorValue = stuff->port;
1064
if (!(pPort->pAdaptor->type & XvImageMask) ||
1065
!(pPort->pAdaptor->type & XvInputMask))
1067
client->errorValue = stuff->port;
1071
status = XVCALL(diMatchPort)(pPort, pDraw);
1072
if (status != Success)
1077
for(i = 0; i < pPort->pAdaptor->nImages; i++) {
1078
if(pPort->pAdaptor->pImages[i].id == stuff->id) {
1079
pImage = &(pPort->pAdaptor->pImages[i]);
1087
width = stuff->width;
1088
height = stuff->height;
1089
size = (*pPort->pAdaptor->ddQueryImageAttributes)(client,
1090
pPort, pImage, &width, &height, NULL, NULL);
1091
size += sizeof(xvPutImageReq);
1092
size = (size + 3) >> 2;
1094
if((width < stuff->width) || (height < stuff->height))
1097
if(client->req_len < size)
1100
return XVCALL(diPutImage)(client, pDraw, pPort, pGC,
1101
stuff->src_x, stuff->src_y,
1102
stuff->src_w, stuff->src_h,
1103
stuff->drw_x, stuff->drw_y,
1104
stuff->drw_w, stuff->drw_h,
1105
pImage, (unsigned char*)(&stuff[1]), FALSE,
1106
stuff->width, stuff->height);
1110
/* redefined here since it's not in any header file */
1111
typedef struct _ShmDesc {
1112
struct _ShmDesc *next;
1118
} ShmDescRec, *ShmDescPtr;
1120
extern RESTYPE ShmSegType;
1121
extern int BadShmSegCode;
1122
extern int ShmCompletionCode;
1125
ProcXvShmPutImage(ClientPtr client)
1130
XvImagePtr pImage = NULL;
1132
int status, size_needed, i;
1133
CARD16 width, height;
1135
REQUEST(xvShmPutImageReq);
1136
REQUEST_SIZE_MATCH(xvShmPutImageReq);
1138
VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, pGC, client);
1140
if(!(pPort = LOOKUP_PORT(stuff->port, client) ))
1142
client->errorValue = stuff->port;
1143
return (_XvBadPort);
1146
if ((status = _AllocatePort(stuff->port, pPort)) != Success)
1148
client->errorValue = stuff->port;
1152
if (!(pPort->pAdaptor->type & XvImageMask) ||
1153
!(pPort->pAdaptor->type & XvInputMask))
1155
client->errorValue = stuff->port;
1159
status = XVCALL(diMatchPort)(pPort, pDraw);
1160
if (status != Success)
1165
for(i = 0; i < pPort->pAdaptor->nImages; i++) {
1166
if(pPort->pAdaptor->pImages[i].id == stuff->id) {
1167
pImage = &(pPort->pAdaptor->pImages[i]);
1175
if(!(shmdesc = (ShmDescPtr)LookupIDByType(stuff->shmseg, ShmSegType)))
1177
client->errorValue = stuff->shmseg;
1178
return BadShmSegCode;
1181
width = stuff->width;
1182
height = stuff->height;
1183
size_needed = (*pPort->pAdaptor->ddQueryImageAttributes)(client,
1184
pPort, pImage, &width, &height, NULL, NULL);
1185
if((size_needed + stuff->offset) > shmdesc->size)
1188
if((width < stuff->width) || (height < stuff->height))
1191
status = XVCALL(diPutImage)(client, pDraw, pPort, pGC,
1192
stuff->src_x, stuff->src_y,
1193
stuff->src_w, stuff->src_h,
1194
stuff->drw_x, stuff->drw_y,
1195
stuff->drw_w, stuff->drw_h, pImage,
1196
(unsigned char *)shmdesc->addr + stuff->offset,
1197
stuff->send_event, stuff->width, stuff->height);
1199
if((status == Success) && stuff->send_event) {
1200
xShmCompletionEvent ev;
1202
ev.type = ShmCompletionCode;
1203
ev.drawable = stuff->drawable;
1204
ev.sequenceNumber = client->sequence;
1205
ev.minorEvent = xv_ShmPutImage;
1206
ev.majorEvent = XvReqCode;
1207
ev.shmseg = stuff->shmseg;
1208
ev.offset = stuff->offset;
1209
WriteEventsToClient(client, 1, (xEvent *) &ev);
1216
#ifdef XvMCExtension
1217
#include "xvmcext.h"
1221
ProcXvQueryImageAttributes(ClientPtr client)
1223
xvQueryImageAttributesReply rep;
1224
int size, num_planes, i;
1225
CARD16 width, height;
1226
XvImagePtr pImage = NULL;
1230
REQUEST(xvQueryImageAttributesReq);
1232
REQUEST_SIZE_MATCH(xvQueryImageAttributesReq);
1234
if(!(pPort = LOOKUP_PORT(stuff->port, client) ))
1236
client->errorValue = stuff->port;
1237
return (_XvBadPort);
1240
for(i = 0; i < pPort->pAdaptor->nImages; i++) {
1241
if(pPort->pAdaptor->pImages[i].id == stuff->id) {
1242
pImage = &(pPort->pAdaptor->pImages[i]);
1247
#ifdef XvMCExtension
1249
pImage = XvMCFindXvImage(pPort, stuff->id);
1255
num_planes = pImage->num_planes;
1257
if(!(offsets = xalloc(num_planes << 3)))
1259
pitches = offsets + num_planes;
1261
width = stuff->width;
1262
height = stuff->height;
1264
size = (*pPort->pAdaptor->ddQueryImageAttributes)(client, pPort, pImage,
1265
&width, &height, offsets, pitches);
1268
rep.sequenceNumber = client->sequence;
1269
rep.length = num_planes << 1;
1270
rep.num_planes = num_planes;
1272
rep.height = height;
1273
rep.data_size = size;
1275
_WriteQueryImageAttributesReply(client, &rep);
1277
SwapLongs((CARD32*)offsets, rep.length);
1278
WriteToClient(client, rep.length << 2, (char*)offsets);
1286
ProcXvListImageFormats(ClientPtr client)
1291
xvListImageFormatsReply rep;
1292
xvImageFormatInfo info;
1293
REQUEST(xvListImageFormatsReq);
1295
REQUEST_SIZE_MATCH(xvListImageFormatsReq);
1297
if(!(pPort = LOOKUP_PORT(stuff->port, client) ))
1299
client->errorValue = stuff->port;
1300
return (_XvBadPort);
1304
rep.sequenceNumber = client->sequence;
1305
rep.num_formats = pPort->pAdaptor->nImages;
1306
rep.length = rep.num_formats * sz_xvImageFormatInfo >> 2;
1308
_WriteListImageFormatsReply(client, &rep);
1310
pImage = pPort->pAdaptor->pImages;
1312
for(i = 0; i < rep.num_formats; i++, pImage++) {
1313
info.id = pImage->id;
1314
info.type = pImage->type;
1315
info.byte_order = pImage->byte_order;
1316
memcpy(&info.guid, pImage->guid, 16);
1317
info.bpp = pImage->bits_per_pixel;
1318
info.num_planes = pImage->num_planes;
1319
info.depth = pImage->depth;
1320
info.red_mask = pImage->red_mask;
1321
info.green_mask = pImage->green_mask;
1322
info.blue_mask = pImage->blue_mask;
1323
info.format = pImage->format;
1324
info.y_sample_bits = pImage->y_sample_bits;
1325
info.u_sample_bits = pImage->u_sample_bits;
1326
info.v_sample_bits = pImage->v_sample_bits;
1327
info.horz_y_period = pImage->horz_y_period;
1328
info.horz_u_period = pImage->horz_u_period;
1329
info.horz_v_period = pImage->horz_v_period;
1330
info.vert_y_period = pImage->vert_y_period;
1331
info.vert_u_period = pImage->vert_u_period;
1332
info.vert_v_period = pImage->vert_v_period;
1333
memcpy(&info.comp_order, pImage->component_order, 32);
1334
info.scanline_order = pImage->scanline_order;
1335
_WriteImageFormatInfo(client, &info);
1346
SProcXvQueryExtension(ClientPtr client)
1349
REQUEST(xvQueryExtensionReq);
1350
swaps(&stuff->length, n);
1351
return ProcXvQueryExtension(client);
1355
SProcXvQueryAdaptors(ClientPtr client)
1358
REQUEST(xvQueryAdaptorsReq);
1359
swaps(&stuff->length, n);
1360
swapl(&stuff->window, n);
1361
return ProcXvQueryAdaptors(client);
1365
SProcXvQueryEncodings(ClientPtr client)
1368
REQUEST(xvQueryEncodingsReq);
1369
swaps(&stuff->length, n);
1370
swapl(&stuff->port, n);
1371
return ProcXvQueryEncodings(client);
1375
SProcXvGrabPort(ClientPtr client)
1378
REQUEST(xvGrabPortReq);
1379
swaps(&stuff->length, n);
1380
swapl(&stuff->port, n);
1381
swapl(&stuff->time, n);
1382
return ProcXvGrabPort(client);
1386
SProcXvUngrabPort(ClientPtr client)
1389
REQUEST(xvUngrabPortReq);
1390
swaps(&stuff->length, n);
1391
swapl(&stuff->port, n);
1392
swapl(&stuff->time, n);
1393
return ProcXvUngrabPort(client);
1397
SProcXvPutVideo(ClientPtr client)
1400
REQUEST(xvPutVideoReq);
1401
swaps(&stuff->length, n);
1402
swapl(&stuff->port, n);
1403
swapl(&stuff->drawable, n);
1404
swapl(&stuff->gc, n);
1405
swaps(&stuff->vid_x, n);
1406
swaps(&stuff->vid_y, n);
1407
swaps(&stuff->vid_w, n);
1408
swaps(&stuff->vid_h, n);
1409
swaps(&stuff->drw_x, n);
1410
swaps(&stuff->drw_y, n);
1411
swaps(&stuff->drw_w, n);
1412
swaps(&stuff->drw_h, n);
1413
return ProcXvPutVideo(client);
1417
SProcXvPutStill(ClientPtr client)
1420
REQUEST(xvPutStillReq);
1421
swaps(&stuff->length, n);
1422
swapl(&stuff->port, n);
1423
swapl(&stuff->drawable, n);
1424
swapl(&stuff->gc, n);
1425
swaps(&stuff->vid_x, n);
1426
swaps(&stuff->vid_y, n);
1427
swaps(&stuff->vid_w, n);
1428
swaps(&stuff->vid_h, n);
1429
swaps(&stuff->drw_x, n);
1430
swaps(&stuff->drw_y, n);
1431
swaps(&stuff->drw_w, n);
1432
swaps(&stuff->drw_h, n);
1433
return ProcXvPutStill(client);
1437
SProcXvGetVideo(ClientPtr client)
1440
REQUEST(xvGetVideoReq);
1441
swaps(&stuff->length, n);
1442
swapl(&stuff->port, n);
1443
swapl(&stuff->drawable, n);
1444
swapl(&stuff->gc, n);
1445
swaps(&stuff->vid_x, n);
1446
swaps(&stuff->vid_y, n);
1447
swaps(&stuff->vid_w, n);
1448
swaps(&stuff->vid_h, n);
1449
swaps(&stuff->drw_x, n);
1450
swaps(&stuff->drw_y, n);
1451
swaps(&stuff->drw_w, n);
1452
swaps(&stuff->drw_h, n);
1453
return ProcXvGetVideo(client);
1457
SProcXvGetStill(ClientPtr client)
1460
REQUEST(xvGetStillReq);
1461
swaps(&stuff->length, n);
1462
swapl(&stuff->port, n);
1463
swapl(&stuff->drawable, n);
1464
swapl(&stuff->gc, n);
1465
swaps(&stuff->vid_x, n);
1466
swaps(&stuff->vid_y, n);
1467
swaps(&stuff->vid_w, n);
1468
swaps(&stuff->vid_h, n);
1469
swaps(&stuff->drw_x, n);
1470
swaps(&stuff->drw_y, n);
1471
swaps(&stuff->drw_w, n);
1472
swaps(&stuff->drw_h, n);
1473
return ProcXvGetStill(client);
1477
SProcXvPutImage(ClientPtr client)
1480
REQUEST(xvPutImageReq);
1481
swaps(&stuff->length, n);
1482
swapl(&stuff->port, n);
1483
swapl(&stuff->drawable, n);
1484
swapl(&stuff->gc, n);
1485
swapl(&stuff->id, n);
1486
swaps(&stuff->src_x, n);
1487
swaps(&stuff->src_y, n);
1488
swaps(&stuff->src_w, n);
1489
swaps(&stuff->src_h, n);
1490
swaps(&stuff->drw_x, n);
1491
swaps(&stuff->drw_y, n);
1492
swaps(&stuff->drw_w, n);
1493
swaps(&stuff->drw_h, n);
1494
swaps(&stuff->width, n);
1495
swaps(&stuff->height, n);
1496
return ProcXvPutImage(client);
1501
SProcXvShmPutImage(ClientPtr client)
1504
REQUEST(xvShmPutImageReq);
1505
swaps(&stuff->length, n);
1506
swapl(&stuff->port, n);
1507
swapl(&stuff->drawable, n);
1508
swapl(&stuff->gc, n);
1509
swapl(&stuff->shmseg, n);
1510
swapl(&stuff->id, n);
1511
swaps(&stuff->src_x, n);
1512
swaps(&stuff->src_y, n);
1513
swaps(&stuff->src_w, n);
1514
swaps(&stuff->src_h, n);
1515
swaps(&stuff->drw_x, n);
1516
swaps(&stuff->drw_y, n);
1517
swaps(&stuff->drw_w, n);
1518
swaps(&stuff->drw_h, n);
1519
swaps(&stuff->offset, n);
1520
swaps(&stuff->width, n);
1521
swaps(&stuff->height, n);
1522
return ProcXvShmPutImage(client);
1528
SProcXvSelectVideoNotify(ClientPtr client)
1531
REQUEST(xvSelectVideoNotifyReq);
1532
swaps(&stuff->length, n);
1533
swapl(&stuff->drawable, n);
1534
return ProcXvSelectVideoNotify(client);
1538
SProcXvSelectPortNotify(ClientPtr client)
1541
REQUEST(xvSelectPortNotifyReq);
1542
swaps(&stuff->length, n);
1543
swapl(&stuff->port, n);
1544
return ProcXvSelectPortNotify(client);
1548
SProcXvStopVideo(ClientPtr client)
1551
REQUEST(xvStopVideoReq);
1552
swaps(&stuff->length, n);
1553
swapl(&stuff->port, n);
1554
swapl(&stuff->drawable, n);
1555
return ProcXvStopVideo(client);
1559
SProcXvSetPortAttribute(ClientPtr client)
1562
REQUEST(xvSetPortAttributeReq);
1563
swaps(&stuff->length, n);
1564
swapl(&stuff->port, n);
1565
swapl(&stuff->attribute, n);
1566
return ProcXvSetPortAttribute(client);
1570
SProcXvGetPortAttribute(ClientPtr client)
1573
REQUEST(xvGetPortAttributeReq);
1574
swaps(&stuff->length, n);
1575
swapl(&stuff->port, n);
1576
swapl(&stuff->attribute, n);
1577
return ProcXvGetPortAttribute(client);
1581
SProcXvQueryBestSize(ClientPtr client)
1584
REQUEST(xvQueryBestSizeReq);
1585
swaps(&stuff->length, n);
1586
swapl(&stuff->port, n);
1587
swaps(&stuff->vid_w, n);
1588
swaps(&stuff->vid_h, n);
1589
swaps(&stuff->drw_w, n);
1590
swaps(&stuff->drw_h, n);
1591
return ProcXvQueryBestSize(client);
1595
SProcXvQueryPortAttributes(ClientPtr client)
1598
REQUEST(xvQueryPortAttributesReq);
1599
swaps(&stuff->length, n);
1600
swapl(&stuff->port, n);
1601
return ProcXvQueryPortAttributes(client);
1605
SProcXvQueryImageAttributes(ClientPtr client)
1608
REQUEST(xvQueryImageAttributesReq);
1609
swaps(&stuff->length, n);
1610
swapl(&stuff->id, n);
1611
swaps(&stuff->width, n);
1612
swaps(&stuff->width, n);
1613
return ProcXvQueryImageAttributes(client);
1617
SProcXvListImageFormats(ClientPtr client)
1620
REQUEST(xvListImageFormatsReq);
1621
swaps(&stuff->length, n);
1622
swapl(&stuff->port, n);
1623
return ProcXvListImageFormats(client);
1628
SWriteQueryExtensionReply(
1630
xvQueryExtensionReply *rep
1634
swaps(&rep->sequenceNumber, n);
1635
swapl(&rep->length, n);
1636
swaps(&rep->version, n);
1637
swaps(&rep->revision, n);
1639
(void)WriteToClient(client, sz_xvQueryExtensionReply, (char *)&rep);
1645
SWriteQueryAdaptorsReply(
1647
xvQueryAdaptorsReply *rep
1651
swaps(&rep->sequenceNumber, n);
1652
swapl(&rep->length, n);
1653
swaps(&rep->num_adaptors, n);
1655
(void)WriteToClient(client, sz_xvQueryAdaptorsReply, (char *)&rep);
1661
SWriteQueryEncodingsReply(
1663
xvQueryEncodingsReply *rep
1667
swaps(&rep->sequenceNumber, n);
1668
swapl(&rep->length, n);
1669
swaps(&rep->num_encodings, n);
1671
(void)WriteToClient(client, sz_xvQueryEncodingsReply, (char *)&rep);
1679
xvAdaptorInfo *pAdaptor
1683
swapl(&pAdaptor->base_id, n);
1684
swaps(&pAdaptor->name_size, n);
1685
swaps(&pAdaptor->num_ports, n);
1686
swaps(&pAdaptor->num_formats, n);
1688
(void)WriteToClient(client, sz_xvAdaptorInfo, (char *)pAdaptor);
1696
xvEncodingInfo *pEncoding
1700
swapl(&pEncoding->encoding, n);
1701
swaps(&pEncoding->name_size, n);
1702
swaps(&pEncoding->width, n);
1703
swaps(&pEncoding->height, n);
1704
swapl(&pEncoding->rate.numerator, n);
1705
swapl(&pEncoding->rate.denominator, n);
1706
(void)WriteToClient(client, sz_xvEncodingInfo, (char *)pEncoding);
1718
swapl(&pFormat->visual, n);
1719
(void)WriteToClient(client, sz_xvFormat, (char *)pFormat);
1725
SWriteAttributeInfo(
1727
xvAttributeInfo *pAtt
1731
swapl(&pAtt->flags, n);
1732
swapl(&pAtt->size, n);
1733
swapl(&pAtt->min, n);
1734
swapl(&pAtt->max, n);
1735
(void)WriteToClient(client, sz_xvAttributeInfo, (char *)pAtt);
1741
SWriteImageFormatInfo(
1743
xvImageFormatInfo *pImage
1747
swapl(&pImage->id, n);
1748
swapl(&pImage->red_mask, n);
1749
swapl(&pImage->green_mask, n);
1750
swapl(&pImage->blue_mask, n);
1751
swapl(&pImage->y_sample_bits, n);
1752
swapl(&pImage->u_sample_bits, n);
1753
swapl(&pImage->v_sample_bits, n);
1754
swapl(&pImage->horz_y_period, n);
1755
swapl(&pImage->horz_u_period, n);
1756
swapl(&pImage->horz_v_period, n);
1757
swapl(&pImage->vert_y_period, n);
1758
swapl(&pImage->vert_u_period, n);
1759
swapl(&pImage->vert_v_period, n);
1761
(void)WriteToClient(client, sz_xvImageFormatInfo, (char *)pImage);
1769
SWriteGrabPortReply(
1771
xvGrabPortReply *rep
1775
swaps(&rep->sequenceNumber, n);
1776
swapl(&rep->length, n);
1778
(void)WriteToClient(client, sz_xvGrabPortReply, (char *)&rep);
1784
SWriteGetPortAttributeReply(
1786
xvGetPortAttributeReply *rep
1790
swaps(&rep->sequenceNumber, n);
1791
swapl(&rep->length, n);
1792
swapl(&rep->value, n);
1794
(void)WriteToClient(client, sz_xvGetPortAttributeReply, (char *)&rep);
1800
SWriteQueryBestSizeReply(
1802
xvQueryBestSizeReply *rep
1806
swaps(&rep->sequenceNumber, n);
1807
swapl(&rep->length, n);
1808
swaps(&rep->actual_width, n);
1809
swaps(&rep->actual_height, n);
1811
(void)WriteToClient(client, sz_xvQueryBestSizeReply, (char *)&rep);
1817
SWriteQueryPortAttributesReply(
1819
xvQueryPortAttributesReply *rep
1823
swaps(&rep->sequenceNumber, n);
1824
swapl(&rep->length, n);
1825
swapl(&rep->num_attributes, n);
1826
swapl(&rep->text_size, n);
1828
(void)WriteToClient(client, sz_xvQueryPortAttributesReply, (char *)&rep);
1834
SWriteQueryImageAttributesReply(
1836
xvQueryImageAttributesReply *rep
1840
swaps(&rep->sequenceNumber, n);
1841
swapl(&rep->length, n);
1842
swapl(&rep->num_planes, n);
1843
swapl(&rep->data_size, n);
1844
swaps(&rep->width, n);
1845
swaps(&rep->height, n);
1847
(void)WriteToClient(client, sz_xvQueryImageAttributesReply, (char *)&rep);
1854
SWriteListImageFormatsReply(
1856
xvListImageFormatsReply *rep
1860
swaps(&rep->sequenceNumber, n);
1861
swapl(&rep->length, n);
1862
swapl(&rep->num_formats, n);
1864
(void)WriteToClient(client, sz_xvListImageFormatsReply, (char *)&rep);
1876
XineramaXvStopVideo(ClientPtr client)
1878
int result = Success, i;
1879
PanoramiXRes *draw, *port;
1880
REQUEST(xvStopVideoReq);
1881
REQUEST_SIZE_MATCH(xvStopVideoReq);
1883
if(!(draw = (PanoramiXRes *)SecurityLookupIDByClass(
1884
client, stuff->drawable, XRC_DRAWABLE, SecurityWriteAccess)))
1887
if(!(port = (PanoramiXRes *)SecurityLookupIDByType(
1888
client, stuff->port, XvXRTPort, SecurityReadAccess)))
1891
FOR_NSCREENS_BACKWARD(i) {
1892
if(port->info[i].id) {
1893
stuff->drawable = draw->info[i].id;
1894
stuff->port = port->info[i].id;
1895
result = ProcXvStopVideo(client);
1903
XineramaXvSetPortAttribute(ClientPtr client)
1905
REQUEST(xvSetPortAttributeReq);
1907
int result = Success, i;
1909
REQUEST_SIZE_MATCH(xvSetPortAttributeReq);
1911
if(!(port = (PanoramiXRes *)SecurityLookupIDByType(
1912
client, stuff->port, XvXRTPort, SecurityReadAccess)))
1915
FOR_NSCREENS_BACKWARD(i) {
1916
if(port->info[i].id) {
1917
stuff->port = port->info[i].id;
1918
result = ProcXvSetPortAttribute(client);
1927
XineramaXvShmPutImage(ClientPtr client)
1929
REQUEST(xvShmPutImageReq);
1930
PanoramiXRes *draw, *gc, *port;
1931
Bool send_event = stuff->send_event;
1933
int result = Success, i, x, y;
1935
REQUEST_SIZE_MATCH(xvShmPutImageReq);
1937
if(!(draw = (PanoramiXRes *)SecurityLookupIDByClass(
1938
client, stuff->drawable, XRC_DRAWABLE, SecurityWriteAccess)))
1941
if(!(gc = (PanoramiXRes *)SecurityLookupIDByType(
1942
client, stuff->gc, XRT_GC, SecurityReadAccess)))
1945
if(!(port = (PanoramiXRes *)SecurityLookupIDByType(
1946
client, stuff->port, XvXRTPort, SecurityReadAccess)))
1949
isRoot = (draw->type == XRT_WINDOW) && draw->u.win.root;
1954
FOR_NSCREENS_BACKWARD(i) {
1955
if(port->info[i].id) {
1956
stuff->drawable = draw->info[i].id;
1957
stuff->port = port->info[i].id;
1958
stuff->gc = gc->info[i].id;
1962
stuff->drw_x -= panoramiXdataPtr[i].x;
1963
stuff->drw_y -= panoramiXdataPtr[i].y;
1965
stuff->send_event = (send_event && !i) ? 1 : 0;
1967
result = ProcXvShmPutImage(client);
1975
XineramaXvPutImage(ClientPtr client)
1977
REQUEST(xvPutImageReq);
1978
PanoramiXRes *draw, *gc, *port;
1980
int result = Success, i, x, y;
1982
REQUEST_AT_LEAST_SIZE(xvPutImageReq);
1984
if(!(draw = (PanoramiXRes *)SecurityLookupIDByClass(
1985
client, stuff->drawable, XRC_DRAWABLE, SecurityWriteAccess)))
1988
if(!(gc = (PanoramiXRes *)SecurityLookupIDByType(
1989
client, stuff->gc, XRT_GC, SecurityReadAccess)))
1992
if(!(port = (PanoramiXRes *)SecurityLookupIDByType(
1993
client, stuff->port, XvXRTPort, SecurityReadAccess)))
1996
isRoot = (draw->type == XRT_WINDOW) && draw->u.win.root;
2001
FOR_NSCREENS_BACKWARD(i) {
2002
if(port->info[i].id) {
2003
stuff->drawable = draw->info[i].id;
2004
stuff->port = port->info[i].id;
2005
stuff->gc = gc->info[i].id;
2009
stuff->drw_x -= panoramiXdataPtr[i].x;
2010
stuff->drw_y -= panoramiXdataPtr[i].y;
2013
result = ProcXvPutImage(client);
2020
XineramaXvPutVideo(ClientPtr client)
2022
REQUEST(xvPutImageReq);
2023
PanoramiXRes *draw, *gc, *port;
2025
int result = Success, i, x, y;
2027
REQUEST_AT_LEAST_SIZE(xvPutVideoReq);
2029
if(!(draw = (PanoramiXRes *)SecurityLookupIDByClass(
2030
client, stuff->drawable, XRC_DRAWABLE, SecurityWriteAccess)))
2033
if(!(gc = (PanoramiXRes *)SecurityLookupIDByType(
2034
client, stuff->gc, XRT_GC, SecurityReadAccess)))
2037
if(!(port = (PanoramiXRes *)SecurityLookupIDByType(
2038
client, stuff->port, XvXRTPort, SecurityReadAccess)))
2041
isRoot = (draw->type == XRT_WINDOW) && draw->u.win.root;
2046
FOR_NSCREENS_BACKWARD(i) {
2047
if(port->info[i].id) {
2048
stuff->drawable = draw->info[i].id;
2049
stuff->port = port->info[i].id;
2050
stuff->gc = gc->info[i].id;
2054
stuff->drw_x -= panoramiXdataPtr[i].x;
2055
stuff->drw_y -= panoramiXdataPtr[i].y;
2058
result = ProcXvPutVideo(client);
2065
XineramaXvPutStill(ClientPtr client)
2067
REQUEST(xvPutImageReq);
2068
PanoramiXRes *draw, *gc, *port;
2070
int result = Success, i, x, y;
2072
REQUEST_AT_LEAST_SIZE(xvPutImageReq);
2074
if(!(draw = (PanoramiXRes *)SecurityLookupIDByClass(
2075
client, stuff->drawable, XRC_DRAWABLE, SecurityWriteAccess)))
2078
if(!(gc = (PanoramiXRes *)SecurityLookupIDByType(
2079
client, stuff->gc, XRT_GC, SecurityReadAccess)))
2082
if(!(port = (PanoramiXRes *)SecurityLookupIDByType(
2083
client, stuff->port, XvXRTPort, SecurityReadAccess)))
2086
isRoot = (draw->type == XRT_WINDOW) && draw->u.win.root;
2091
FOR_NSCREENS_BACKWARD(i) {
2092
if(port->info[i].id) {
2093
stuff->drawable = draw->info[i].id;
2094
stuff->port = port->info[i].id;
2095
stuff->gc = gc->info[i].id;
2099
stuff->drw_x -= panoramiXdataPtr[i].x;
2100
stuff->drw_y -= panoramiXdataPtr[i].y;
2103
result = ProcXvPutStill(client);
2110
void XineramifyXv(void)
2112
ScreenPtr pScreen, screen0 = screenInfo.screens[0];
2113
XvScreenPtr xvsp0 = (XvScreenPtr)screen0->devPrivates[XvScreenIndex].ptr;
2114
XvAdaptorPtr refAdapt, pAdapt;
2115
XvAttributePtr pAttr;
2117
Bool isOverlay, hasOverlay;
2119
XvAdaptorPtr MatchingAdaptors[MAXSCREENS];
2122
XvXRTPort = CreateNewResourceType(XineramaDeleteResource);
2126
for(i = 0; i < xvsp0->nAdaptors; i++) {
2127
refAdapt = xvsp0->pAdaptors + i;
2129
bzero(MatchingAdaptors, sizeof(XvAdaptorPtr) * MAXSCREENS);
2131
MatchingAdaptors[0] = refAdapt;
2133
if(!(refAdapt->type & XvInputMask)) continue;
2136
for(j = 0; j < refAdapt->nAttributes; j++) {
2137
pAttr = refAdapt->pAttributes + j;
2138
if(!strcmp(pAttr->name, "XV_COLORKEY")) {
2144
for(j = 1; j < PanoramiXNumScreens; j++) {
2145
pScreen = screenInfo.screens[j];
2146
xvsp = (XvScreenPtr)pScreen->devPrivates[XvScreenIndex].ptr;
2148
/* Do not try to go on if xv is not supported on this screen */
2149
if (xvsp==NULL) continue ;
2151
/* if the adaptor has the same name it's a perfect match */
2152
for(k = 0; k < xvsp->nAdaptors; k++) {
2153
pAdapt = xvsp->pAdaptors + k;
2154
if(!strcmp(refAdapt->name, pAdapt->name)) {
2155
MatchingAdaptors[j] = pAdapt;
2159
if(MatchingAdaptors[j]) continue; /* found it */
2161
/* otherwise we only look for XvImage adaptors */
2162
if(!(refAdapt->type & XvImageMask)) continue;
2163
if(refAdapt->nImages <= 0) continue;
2165
/* prefer overlay/overlay non-overlay/non-overlay pairing */
2166
for(k = 0; k < xvsp->nAdaptors; k++) {
2167
pAdapt = xvsp->pAdaptors + k;
2168
if((pAdapt->type & XvImageMask) && (pAdapt->nImages > 0)) {
2170
for(l = 0; l < pAdapt->nAttributes; l++) {
2171
if(!strcmp(pAdapt->name, "XV_COLORKEY")) {
2176
if(isOverlay && hasOverlay) {
2177
MatchingAdaptors[j] = pAdapt;
2180
else if(!isOverlay && !hasOverlay) {
2181
MatchingAdaptors[j] = pAdapt;
2187
if(MatchingAdaptors[j]) continue; /* found it */
2189
/* but we'll take any XvImage pairing if we can get it */
2191
for(k = 0; k < xvsp->nAdaptors; k++) {
2192
pAdapt = xvsp->pAdaptors + k;
2193
if((pAdapt->type & XvImageMask) && (pAdapt->nImages > 0)) {
2194
MatchingAdaptors[j] = pAdapt;
2200
/* now create a resource for each port */
2201
for(j = 0; j < refAdapt->nPorts; j++) {
2202
if(!(port = xalloc(sizeof(PanoramiXRes))))
2204
port->info[0].id = MatchingAdaptors[0]->base_id + j;
2205
AddResource(port->info[0].id, XvXRTPort, port);
2207
for(k = 1; k < PanoramiXNumScreens; k++) {
2208
if(MatchingAdaptors[k] && (MatchingAdaptors[k]->nPorts > j))
2209
port->info[k].id = MatchingAdaptors[k]->base_id + j;
2211
port->info[k].id = 0;