xref: /OK3568_Linux_fs/external/xserver/Xext/xvdisp.c (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun /***********************************************************
2*4882a593Smuzhiyun Copyright 1991 by Digital Equipment Corporation, Maynard, Massachusetts,
3*4882a593Smuzhiyun and the Massachusetts Institute of Technology, Cambridge, Massachusetts.
4*4882a593Smuzhiyun 
5*4882a593Smuzhiyun                         All Rights Reserved
6*4882a593Smuzhiyun 
7*4882a593Smuzhiyun Permission to use, copy, modify, and distribute this software and its
8*4882a593Smuzhiyun documentation for any purpose and without fee is hereby granted,
9*4882a593Smuzhiyun provided that the above copyright notice appear in all copies and that
10*4882a593Smuzhiyun both that copyright notice and this permission notice appear in
11*4882a593Smuzhiyun supporting documentation, and that the names of Digital or MIT not be
12*4882a593Smuzhiyun used in advertising or publicity pertaining to distribution of the
13*4882a593Smuzhiyun software without specific, written prior permission.
14*4882a593Smuzhiyun 
15*4882a593Smuzhiyun DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
16*4882a593Smuzhiyun ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
17*4882a593Smuzhiyun DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
18*4882a593Smuzhiyun ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
19*4882a593Smuzhiyun WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
20*4882a593Smuzhiyun ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
21*4882a593Smuzhiyun SOFTWARE.
22*4882a593Smuzhiyun ******************************************************************/
23*4882a593Smuzhiyun 
24*4882a593Smuzhiyun #ifdef HAVE_DIX_CONFIG_H
25*4882a593Smuzhiyun #include <dix-config.h>
26*4882a593Smuzhiyun #endif
27*4882a593Smuzhiyun 
28*4882a593Smuzhiyun #include <string.h>
29*4882a593Smuzhiyun 
30*4882a593Smuzhiyun #include <X11/X.h>
31*4882a593Smuzhiyun #include <X11/Xproto.h>
32*4882a593Smuzhiyun #include "misc.h"
33*4882a593Smuzhiyun #include "scrnintstr.h"
34*4882a593Smuzhiyun #include "windowstr.h"
35*4882a593Smuzhiyun #include "pixmapstr.h"
36*4882a593Smuzhiyun #include "gcstruct.h"
37*4882a593Smuzhiyun #include "dixstruct.h"
38*4882a593Smuzhiyun #include "resource.h"
39*4882a593Smuzhiyun #include "opaque.h"
40*4882a593Smuzhiyun 
41*4882a593Smuzhiyun #include <X11/extensions/Xv.h>
42*4882a593Smuzhiyun #include <X11/extensions/Xvproto.h>
43*4882a593Smuzhiyun #include "xvdix.h"
44*4882a593Smuzhiyun #ifdef MITSHM
45*4882a593Smuzhiyun #include <X11/extensions/shmproto.h>
46*4882a593Smuzhiyun #include "shmint.h"
47*4882a593Smuzhiyun #endif
48*4882a593Smuzhiyun 
49*4882a593Smuzhiyun #include "xvdisp.h"
50*4882a593Smuzhiyun 
51*4882a593Smuzhiyun #ifdef PANORAMIX
52*4882a593Smuzhiyun #include "panoramiX.h"
53*4882a593Smuzhiyun #include "panoramiXsrv.h"
54*4882a593Smuzhiyun 
55*4882a593Smuzhiyun unsigned long XvXRTPort;
56*4882a593Smuzhiyun #endif
57*4882a593Smuzhiyun 
58*4882a593Smuzhiyun static int
SWriteQueryExtensionReply(ClientPtr client,xvQueryExtensionReply * rep)59*4882a593Smuzhiyun SWriteQueryExtensionReply(ClientPtr client, xvQueryExtensionReply * rep)
60*4882a593Smuzhiyun {
61*4882a593Smuzhiyun     swaps(&rep->sequenceNumber);
62*4882a593Smuzhiyun     swapl(&rep->length);
63*4882a593Smuzhiyun     swaps(&rep->version);
64*4882a593Smuzhiyun     swaps(&rep->revision);
65*4882a593Smuzhiyun 
66*4882a593Smuzhiyun     WriteToClient(client, sz_xvQueryExtensionReply, rep);
67*4882a593Smuzhiyun 
68*4882a593Smuzhiyun     return Success;
69*4882a593Smuzhiyun }
70*4882a593Smuzhiyun 
71*4882a593Smuzhiyun static int
SWriteQueryAdaptorsReply(ClientPtr client,xvQueryAdaptorsReply * rep)72*4882a593Smuzhiyun SWriteQueryAdaptorsReply(ClientPtr client, xvQueryAdaptorsReply * rep)
73*4882a593Smuzhiyun {
74*4882a593Smuzhiyun     swaps(&rep->sequenceNumber);
75*4882a593Smuzhiyun     swapl(&rep->length);
76*4882a593Smuzhiyun     swaps(&rep->num_adaptors);
77*4882a593Smuzhiyun 
78*4882a593Smuzhiyun     WriteToClient(client, sz_xvQueryAdaptorsReply, rep);
79*4882a593Smuzhiyun 
80*4882a593Smuzhiyun     return Success;
81*4882a593Smuzhiyun }
82*4882a593Smuzhiyun 
83*4882a593Smuzhiyun static int
SWriteQueryEncodingsReply(ClientPtr client,xvQueryEncodingsReply * rep)84*4882a593Smuzhiyun SWriteQueryEncodingsReply(ClientPtr client, xvQueryEncodingsReply * rep)
85*4882a593Smuzhiyun {
86*4882a593Smuzhiyun     swaps(&rep->sequenceNumber);
87*4882a593Smuzhiyun     swapl(&rep->length);
88*4882a593Smuzhiyun     swaps(&rep->num_encodings);
89*4882a593Smuzhiyun 
90*4882a593Smuzhiyun     WriteToClient(client, sz_xvQueryEncodingsReply, rep);
91*4882a593Smuzhiyun 
92*4882a593Smuzhiyun     return Success;
93*4882a593Smuzhiyun }
94*4882a593Smuzhiyun 
95*4882a593Smuzhiyun static int
SWriteAdaptorInfo(ClientPtr client,xvAdaptorInfo * pAdaptor)96*4882a593Smuzhiyun SWriteAdaptorInfo(ClientPtr client, xvAdaptorInfo * pAdaptor)
97*4882a593Smuzhiyun {
98*4882a593Smuzhiyun     swapl(&pAdaptor->base_id);
99*4882a593Smuzhiyun     swaps(&pAdaptor->name_size);
100*4882a593Smuzhiyun     swaps(&pAdaptor->num_ports);
101*4882a593Smuzhiyun     swaps(&pAdaptor->num_formats);
102*4882a593Smuzhiyun 
103*4882a593Smuzhiyun     WriteToClient(client, sz_xvAdaptorInfo, pAdaptor);
104*4882a593Smuzhiyun 
105*4882a593Smuzhiyun     return Success;
106*4882a593Smuzhiyun }
107*4882a593Smuzhiyun 
108*4882a593Smuzhiyun static int
SWriteEncodingInfo(ClientPtr client,xvEncodingInfo * pEncoding)109*4882a593Smuzhiyun SWriteEncodingInfo(ClientPtr client, xvEncodingInfo * pEncoding)
110*4882a593Smuzhiyun {
111*4882a593Smuzhiyun 
112*4882a593Smuzhiyun     swapl(&pEncoding->encoding);
113*4882a593Smuzhiyun     swaps(&pEncoding->name_size);
114*4882a593Smuzhiyun     swaps(&pEncoding->width);
115*4882a593Smuzhiyun     swaps(&pEncoding->height);
116*4882a593Smuzhiyun     swapl(&pEncoding->rate.numerator);
117*4882a593Smuzhiyun     swapl(&pEncoding->rate.denominator);
118*4882a593Smuzhiyun     WriteToClient(client, sz_xvEncodingInfo, pEncoding);
119*4882a593Smuzhiyun 
120*4882a593Smuzhiyun     return Success;
121*4882a593Smuzhiyun }
122*4882a593Smuzhiyun 
123*4882a593Smuzhiyun static int
SWriteFormat(ClientPtr client,xvFormat * pFormat)124*4882a593Smuzhiyun SWriteFormat(ClientPtr client, xvFormat * pFormat)
125*4882a593Smuzhiyun {
126*4882a593Smuzhiyun     swapl(&pFormat->visual);
127*4882a593Smuzhiyun     WriteToClient(client, sz_xvFormat, pFormat);
128*4882a593Smuzhiyun 
129*4882a593Smuzhiyun     return Success;
130*4882a593Smuzhiyun }
131*4882a593Smuzhiyun 
132*4882a593Smuzhiyun static int
SWriteAttributeInfo(ClientPtr client,xvAttributeInfo * pAtt)133*4882a593Smuzhiyun SWriteAttributeInfo(ClientPtr client, xvAttributeInfo * pAtt)
134*4882a593Smuzhiyun {
135*4882a593Smuzhiyun     swapl(&pAtt->flags);
136*4882a593Smuzhiyun     swapl(&pAtt->size);
137*4882a593Smuzhiyun     swapl(&pAtt->min);
138*4882a593Smuzhiyun     swapl(&pAtt->max);
139*4882a593Smuzhiyun     WriteToClient(client, sz_xvAttributeInfo, pAtt);
140*4882a593Smuzhiyun 
141*4882a593Smuzhiyun     return Success;
142*4882a593Smuzhiyun }
143*4882a593Smuzhiyun 
144*4882a593Smuzhiyun static int
SWriteImageFormatInfo(ClientPtr client,xvImageFormatInfo * pImage)145*4882a593Smuzhiyun SWriteImageFormatInfo(ClientPtr client, xvImageFormatInfo * pImage)
146*4882a593Smuzhiyun {
147*4882a593Smuzhiyun     swapl(&pImage->id);
148*4882a593Smuzhiyun     swapl(&pImage->red_mask);
149*4882a593Smuzhiyun     swapl(&pImage->green_mask);
150*4882a593Smuzhiyun     swapl(&pImage->blue_mask);
151*4882a593Smuzhiyun     swapl(&pImage->y_sample_bits);
152*4882a593Smuzhiyun     swapl(&pImage->u_sample_bits);
153*4882a593Smuzhiyun     swapl(&pImage->v_sample_bits);
154*4882a593Smuzhiyun     swapl(&pImage->horz_y_period);
155*4882a593Smuzhiyun     swapl(&pImage->horz_u_period);
156*4882a593Smuzhiyun     swapl(&pImage->horz_v_period);
157*4882a593Smuzhiyun     swapl(&pImage->vert_y_period);
158*4882a593Smuzhiyun     swapl(&pImage->vert_u_period);
159*4882a593Smuzhiyun     swapl(&pImage->vert_v_period);
160*4882a593Smuzhiyun 
161*4882a593Smuzhiyun     WriteToClient(client, sz_xvImageFormatInfo, pImage);
162*4882a593Smuzhiyun 
163*4882a593Smuzhiyun     return Success;
164*4882a593Smuzhiyun }
165*4882a593Smuzhiyun 
166*4882a593Smuzhiyun static int
SWriteGrabPortReply(ClientPtr client,xvGrabPortReply * rep)167*4882a593Smuzhiyun SWriteGrabPortReply(ClientPtr client, xvGrabPortReply * rep)
168*4882a593Smuzhiyun {
169*4882a593Smuzhiyun     swaps(&rep->sequenceNumber);
170*4882a593Smuzhiyun     swapl(&rep->length);
171*4882a593Smuzhiyun 
172*4882a593Smuzhiyun     WriteToClient(client, sz_xvGrabPortReply, rep);
173*4882a593Smuzhiyun 
174*4882a593Smuzhiyun     return Success;
175*4882a593Smuzhiyun }
176*4882a593Smuzhiyun 
177*4882a593Smuzhiyun static int
SWriteGetPortAttributeReply(ClientPtr client,xvGetPortAttributeReply * rep)178*4882a593Smuzhiyun SWriteGetPortAttributeReply(ClientPtr client, xvGetPortAttributeReply * rep)
179*4882a593Smuzhiyun {
180*4882a593Smuzhiyun     swaps(&rep->sequenceNumber);
181*4882a593Smuzhiyun     swapl(&rep->length);
182*4882a593Smuzhiyun     swapl(&rep->value);
183*4882a593Smuzhiyun 
184*4882a593Smuzhiyun     WriteToClient(client, sz_xvGetPortAttributeReply, rep);
185*4882a593Smuzhiyun 
186*4882a593Smuzhiyun     return Success;
187*4882a593Smuzhiyun }
188*4882a593Smuzhiyun 
189*4882a593Smuzhiyun static int
SWriteQueryBestSizeReply(ClientPtr client,xvQueryBestSizeReply * rep)190*4882a593Smuzhiyun SWriteQueryBestSizeReply(ClientPtr client, xvQueryBestSizeReply * rep)
191*4882a593Smuzhiyun {
192*4882a593Smuzhiyun     swaps(&rep->sequenceNumber);
193*4882a593Smuzhiyun     swapl(&rep->length);
194*4882a593Smuzhiyun     swaps(&rep->actual_width);
195*4882a593Smuzhiyun     swaps(&rep->actual_height);
196*4882a593Smuzhiyun 
197*4882a593Smuzhiyun     WriteToClient(client, sz_xvQueryBestSizeReply, rep);
198*4882a593Smuzhiyun 
199*4882a593Smuzhiyun     return Success;
200*4882a593Smuzhiyun }
201*4882a593Smuzhiyun 
202*4882a593Smuzhiyun static int
SWriteQueryPortAttributesReply(ClientPtr client,xvQueryPortAttributesReply * rep)203*4882a593Smuzhiyun SWriteQueryPortAttributesReply(ClientPtr client,
204*4882a593Smuzhiyun                                xvQueryPortAttributesReply * rep)
205*4882a593Smuzhiyun {
206*4882a593Smuzhiyun     swaps(&rep->sequenceNumber);
207*4882a593Smuzhiyun     swapl(&rep->length);
208*4882a593Smuzhiyun     swapl(&rep->num_attributes);
209*4882a593Smuzhiyun     swapl(&rep->text_size);
210*4882a593Smuzhiyun 
211*4882a593Smuzhiyun     WriteToClient(client, sz_xvQueryPortAttributesReply, rep);
212*4882a593Smuzhiyun 
213*4882a593Smuzhiyun     return Success;
214*4882a593Smuzhiyun }
215*4882a593Smuzhiyun 
216*4882a593Smuzhiyun static int
SWriteQueryImageAttributesReply(ClientPtr client,xvQueryImageAttributesReply * rep)217*4882a593Smuzhiyun SWriteQueryImageAttributesReply(ClientPtr client,
218*4882a593Smuzhiyun                                 xvQueryImageAttributesReply * rep)
219*4882a593Smuzhiyun {
220*4882a593Smuzhiyun     swaps(&rep->sequenceNumber);
221*4882a593Smuzhiyun     swapl(&rep->length);
222*4882a593Smuzhiyun     swapl(&rep->num_planes);
223*4882a593Smuzhiyun     swapl(&rep->data_size);
224*4882a593Smuzhiyun     swaps(&rep->width);
225*4882a593Smuzhiyun     swaps(&rep->height);
226*4882a593Smuzhiyun 
227*4882a593Smuzhiyun     WriteToClient(client, sz_xvQueryImageAttributesReply, rep);
228*4882a593Smuzhiyun 
229*4882a593Smuzhiyun     return Success;
230*4882a593Smuzhiyun }
231*4882a593Smuzhiyun 
232*4882a593Smuzhiyun static int
SWriteListImageFormatsReply(ClientPtr client,xvListImageFormatsReply * rep)233*4882a593Smuzhiyun SWriteListImageFormatsReply(ClientPtr client, xvListImageFormatsReply * rep)
234*4882a593Smuzhiyun {
235*4882a593Smuzhiyun     swaps(&rep->sequenceNumber);
236*4882a593Smuzhiyun     swapl(&rep->length);
237*4882a593Smuzhiyun     swapl(&rep->num_formats);
238*4882a593Smuzhiyun 
239*4882a593Smuzhiyun     WriteToClient(client, sz_xvListImageFormatsReply, rep);
240*4882a593Smuzhiyun 
241*4882a593Smuzhiyun     return Success;
242*4882a593Smuzhiyun }
243*4882a593Smuzhiyun 
244*4882a593Smuzhiyun #define _WriteQueryAdaptorsReply(_c,_d) \
245*4882a593Smuzhiyun   if ((_c)->swapped) SWriteQueryAdaptorsReply(_c, _d); \
246*4882a593Smuzhiyun   else WriteToClient(_c, sz_xvQueryAdaptorsReply, _d)
247*4882a593Smuzhiyun 
248*4882a593Smuzhiyun #define _WriteQueryExtensionReply(_c,_d) \
249*4882a593Smuzhiyun   if ((_c)->swapped) SWriteQueryExtensionReply(_c, _d); \
250*4882a593Smuzhiyun   else WriteToClient(_c, sz_xvQueryExtensionReply, _d)
251*4882a593Smuzhiyun 
252*4882a593Smuzhiyun #define _WriteQueryEncodingsReply(_c,_d) \
253*4882a593Smuzhiyun   if ((_c)->swapped) SWriteQueryEncodingsReply(_c, _d); \
254*4882a593Smuzhiyun   else WriteToClient(_c, sz_xvQueryEncodingsReply, _d)
255*4882a593Smuzhiyun 
256*4882a593Smuzhiyun #define _WriteAdaptorInfo(_c,_d) \
257*4882a593Smuzhiyun   if ((_c)->swapped) SWriteAdaptorInfo(_c, _d); \
258*4882a593Smuzhiyun   else WriteToClient(_c, sz_xvAdaptorInfo, _d)
259*4882a593Smuzhiyun 
260*4882a593Smuzhiyun #define _WriteAttributeInfo(_c,_d) \
261*4882a593Smuzhiyun   if ((_c)->swapped) SWriteAttributeInfo(_c, _d); \
262*4882a593Smuzhiyun   else WriteToClient(_c, sz_xvAttributeInfo, _d)
263*4882a593Smuzhiyun 
264*4882a593Smuzhiyun #define _WriteEncodingInfo(_c,_d) \
265*4882a593Smuzhiyun   if ((_c)->swapped) SWriteEncodingInfo(_c, _d); \
266*4882a593Smuzhiyun   else WriteToClient(_c, sz_xvEncodingInfo, _d)
267*4882a593Smuzhiyun 
268*4882a593Smuzhiyun #define _WriteFormat(_c,_d) \
269*4882a593Smuzhiyun   if ((_c)->swapped) SWriteFormat(_c, _d); \
270*4882a593Smuzhiyun   else WriteToClient(_c, sz_xvFormat, _d)
271*4882a593Smuzhiyun 
272*4882a593Smuzhiyun #define _WriteGrabPortReply(_c,_d) \
273*4882a593Smuzhiyun   if ((_c)->swapped) SWriteGrabPortReply(_c, _d); \
274*4882a593Smuzhiyun   else WriteToClient(_c, sz_xvGrabPortReply, _d)
275*4882a593Smuzhiyun 
276*4882a593Smuzhiyun #define _WriteGetPortAttributeReply(_c,_d) \
277*4882a593Smuzhiyun   if ((_c)->swapped) SWriteGetPortAttributeReply(_c, _d); \
278*4882a593Smuzhiyun   else WriteToClient(_c, sz_xvGetPortAttributeReply, _d)
279*4882a593Smuzhiyun 
280*4882a593Smuzhiyun #define _WriteQueryBestSizeReply(_c,_d) \
281*4882a593Smuzhiyun   if ((_c)->swapped) SWriteQueryBestSizeReply(_c, _d); \
282*4882a593Smuzhiyun   else WriteToClient(_c, sz_xvQueryBestSizeReply, _d)
283*4882a593Smuzhiyun 
284*4882a593Smuzhiyun #define _WriteQueryPortAttributesReply(_c,_d) \
285*4882a593Smuzhiyun   if ((_c)->swapped) SWriteQueryPortAttributesReply(_c, _d); \
286*4882a593Smuzhiyun   else WriteToClient(_c, sz_xvQueryPortAttributesReply, _d)
287*4882a593Smuzhiyun 
288*4882a593Smuzhiyun #define _WriteQueryImageAttributesReply(_c,_d) \
289*4882a593Smuzhiyun   if ((_c)->swapped) SWriteQueryImageAttributesReply(_c, _d); \
290*4882a593Smuzhiyun   else WriteToClient(_c, sz_xvQueryImageAttributesReply, _d)
291*4882a593Smuzhiyun 
292*4882a593Smuzhiyun #define _WriteListImageFormatsReply(_c,_d) \
293*4882a593Smuzhiyun   if ((_c)->swapped) SWriteListImageFormatsReply(_c, _d); \
294*4882a593Smuzhiyun   else WriteToClient(_c, sz_xvListImageFormatsReply, _d)
295*4882a593Smuzhiyun 
296*4882a593Smuzhiyun #define _WriteImageFormatInfo(_c,_d) \
297*4882a593Smuzhiyun   if ((_c)->swapped) SWriteImageFormatInfo(_c, _d); \
298*4882a593Smuzhiyun   else WriteToClient(_c, sz_xvImageFormatInfo, _d)
299*4882a593Smuzhiyun 
300*4882a593Smuzhiyun static int
ProcXvQueryExtension(ClientPtr client)301*4882a593Smuzhiyun ProcXvQueryExtension(ClientPtr client)
302*4882a593Smuzhiyun {
303*4882a593Smuzhiyun     xvQueryExtensionReply rep = {
304*4882a593Smuzhiyun         .type = X_Reply,
305*4882a593Smuzhiyun         .sequenceNumber = client->sequence,
306*4882a593Smuzhiyun         .length = 0,
307*4882a593Smuzhiyun         .version = XvVersion,
308*4882a593Smuzhiyun         .revision = XvRevision
309*4882a593Smuzhiyun     };
310*4882a593Smuzhiyun 
311*4882a593Smuzhiyun     /* REQUEST(xvQueryExtensionReq); */
312*4882a593Smuzhiyun     REQUEST_SIZE_MATCH(xvQueryExtensionReq);
313*4882a593Smuzhiyun 
314*4882a593Smuzhiyun     _WriteQueryExtensionReply(client, &rep);
315*4882a593Smuzhiyun 
316*4882a593Smuzhiyun     return Success;
317*4882a593Smuzhiyun }
318*4882a593Smuzhiyun 
319*4882a593Smuzhiyun static int
ProcXvQueryAdaptors(ClientPtr client)320*4882a593Smuzhiyun ProcXvQueryAdaptors(ClientPtr client)
321*4882a593Smuzhiyun {
322*4882a593Smuzhiyun     xvFormat format;
323*4882a593Smuzhiyun     xvAdaptorInfo ainfo;
324*4882a593Smuzhiyun     xvQueryAdaptorsReply rep;
325*4882a593Smuzhiyun     int totalSize, na, nf, rc;
326*4882a593Smuzhiyun     int nameSize;
327*4882a593Smuzhiyun     XvAdaptorPtr pa;
328*4882a593Smuzhiyun     XvFormatPtr pf;
329*4882a593Smuzhiyun     WindowPtr pWin;
330*4882a593Smuzhiyun     ScreenPtr pScreen;
331*4882a593Smuzhiyun     XvScreenPtr pxvs;
332*4882a593Smuzhiyun 
333*4882a593Smuzhiyun     REQUEST(xvQueryAdaptorsReq);
334*4882a593Smuzhiyun     REQUEST_SIZE_MATCH(xvQueryAdaptorsReq);
335*4882a593Smuzhiyun 
336*4882a593Smuzhiyun     rc = dixLookupWindow(&pWin, stuff->window, client, DixGetAttrAccess);
337*4882a593Smuzhiyun     if (rc != Success)
338*4882a593Smuzhiyun         return rc;
339*4882a593Smuzhiyun 
340*4882a593Smuzhiyun     pScreen = pWin->drawable.pScreen;
341*4882a593Smuzhiyun     pxvs = (XvScreenPtr) dixLookupPrivate(&pScreen->devPrivates,
342*4882a593Smuzhiyun                                           XvGetScreenKey());
343*4882a593Smuzhiyun     if (!pxvs) {
344*4882a593Smuzhiyun         rep = (xvQueryAdaptorsReply) {
345*4882a593Smuzhiyun             .type = X_Reply,
346*4882a593Smuzhiyun             .sequenceNumber = client->sequence,
347*4882a593Smuzhiyun             .length = 0,
348*4882a593Smuzhiyun             .num_adaptors = 0
349*4882a593Smuzhiyun         };
350*4882a593Smuzhiyun 
351*4882a593Smuzhiyun         _WriteQueryAdaptorsReply(client, &rep);
352*4882a593Smuzhiyun 
353*4882a593Smuzhiyun         return Success;
354*4882a593Smuzhiyun     }
355*4882a593Smuzhiyun 
356*4882a593Smuzhiyun     rep = (xvQueryAdaptorsReply) {
357*4882a593Smuzhiyun         .type = X_Reply,
358*4882a593Smuzhiyun         .sequenceNumber = client->sequence,
359*4882a593Smuzhiyun         .num_adaptors = pxvs->nAdaptors
360*4882a593Smuzhiyun     };
361*4882a593Smuzhiyun 
362*4882a593Smuzhiyun     /* CALCULATE THE TOTAL SIZE OF THE REPLY IN BYTES */
363*4882a593Smuzhiyun 
364*4882a593Smuzhiyun     totalSize = pxvs->nAdaptors * sz_xvAdaptorInfo;
365*4882a593Smuzhiyun 
366*4882a593Smuzhiyun     /* FOR EACH ADPATOR ADD UP THE BYTES FOR ENCODINGS AND FORMATS */
367*4882a593Smuzhiyun 
368*4882a593Smuzhiyun     na = pxvs->nAdaptors;
369*4882a593Smuzhiyun     pa = pxvs->pAdaptors;
370*4882a593Smuzhiyun     while (na--) {
371*4882a593Smuzhiyun         totalSize += pad_to_int32(strlen(pa->name));
372*4882a593Smuzhiyun         totalSize += pa->nFormats * sz_xvFormat;
373*4882a593Smuzhiyun         pa++;
374*4882a593Smuzhiyun     }
375*4882a593Smuzhiyun 
376*4882a593Smuzhiyun     rep.length = bytes_to_int32(totalSize);
377*4882a593Smuzhiyun 
378*4882a593Smuzhiyun     _WriteQueryAdaptorsReply(client, &rep);
379*4882a593Smuzhiyun 
380*4882a593Smuzhiyun     na = pxvs->nAdaptors;
381*4882a593Smuzhiyun     pa = pxvs->pAdaptors;
382*4882a593Smuzhiyun     while (na--) {
383*4882a593Smuzhiyun 
384*4882a593Smuzhiyun         ainfo.base_id = pa->base_id;
385*4882a593Smuzhiyun         ainfo.num_ports = pa->nPorts;
386*4882a593Smuzhiyun         ainfo.type = pa->type;
387*4882a593Smuzhiyun         ainfo.name_size = nameSize = strlen(pa->name);
388*4882a593Smuzhiyun         ainfo.num_formats = pa->nFormats;
389*4882a593Smuzhiyun 
390*4882a593Smuzhiyun         _WriteAdaptorInfo(client, &ainfo);
391*4882a593Smuzhiyun 
392*4882a593Smuzhiyun         WriteToClient(client, nameSize, pa->name);
393*4882a593Smuzhiyun 
394*4882a593Smuzhiyun         nf = pa->nFormats;
395*4882a593Smuzhiyun         pf = pa->pFormats;
396*4882a593Smuzhiyun         while (nf--) {
397*4882a593Smuzhiyun             format.depth = pf->depth;
398*4882a593Smuzhiyun             format.visual = pf->visual;
399*4882a593Smuzhiyun             _WriteFormat(client, &format);
400*4882a593Smuzhiyun             pf++;
401*4882a593Smuzhiyun         }
402*4882a593Smuzhiyun 
403*4882a593Smuzhiyun         pa++;
404*4882a593Smuzhiyun 
405*4882a593Smuzhiyun     }
406*4882a593Smuzhiyun 
407*4882a593Smuzhiyun     return Success;
408*4882a593Smuzhiyun }
409*4882a593Smuzhiyun 
410*4882a593Smuzhiyun static int
ProcXvQueryEncodings(ClientPtr client)411*4882a593Smuzhiyun ProcXvQueryEncodings(ClientPtr client)
412*4882a593Smuzhiyun {
413*4882a593Smuzhiyun     xvEncodingInfo einfo;
414*4882a593Smuzhiyun     xvQueryEncodingsReply rep;
415*4882a593Smuzhiyun     int totalSize;
416*4882a593Smuzhiyun     int nameSize;
417*4882a593Smuzhiyun     XvPortPtr pPort;
418*4882a593Smuzhiyun     int ne;
419*4882a593Smuzhiyun     XvEncodingPtr pe;
420*4882a593Smuzhiyun 
421*4882a593Smuzhiyun     REQUEST(xvQueryEncodingsReq);
422*4882a593Smuzhiyun     REQUEST_SIZE_MATCH(xvQueryEncodingsReq);
423*4882a593Smuzhiyun 
424*4882a593Smuzhiyun     VALIDATE_XV_PORT(stuff->port, pPort, DixReadAccess);
425*4882a593Smuzhiyun 
426*4882a593Smuzhiyun     rep = (xvQueryEncodingsReply) {
427*4882a593Smuzhiyun         .type = X_Reply,
428*4882a593Smuzhiyun         .sequenceNumber = client->sequence,
429*4882a593Smuzhiyun         .num_encodings = pPort->pAdaptor->nEncodings
430*4882a593Smuzhiyun     };
431*4882a593Smuzhiyun 
432*4882a593Smuzhiyun     /* FOR EACH ENCODING ADD UP THE BYTES FOR ENCODING NAMES */
433*4882a593Smuzhiyun 
434*4882a593Smuzhiyun     ne = pPort->pAdaptor->nEncodings;
435*4882a593Smuzhiyun     pe = pPort->pAdaptor->pEncodings;
436*4882a593Smuzhiyun     totalSize = ne * sz_xvEncodingInfo;
437*4882a593Smuzhiyun     while (ne--) {
438*4882a593Smuzhiyun         totalSize += pad_to_int32(strlen(pe->name));
439*4882a593Smuzhiyun         pe++;
440*4882a593Smuzhiyun     }
441*4882a593Smuzhiyun 
442*4882a593Smuzhiyun     rep.length = bytes_to_int32(totalSize);
443*4882a593Smuzhiyun 
444*4882a593Smuzhiyun     _WriteQueryEncodingsReply(client, &rep);
445*4882a593Smuzhiyun 
446*4882a593Smuzhiyun     ne = pPort->pAdaptor->nEncodings;
447*4882a593Smuzhiyun     pe = pPort->pAdaptor->pEncodings;
448*4882a593Smuzhiyun     while (ne--) {
449*4882a593Smuzhiyun         einfo.encoding = pe->id;
450*4882a593Smuzhiyun         einfo.name_size = nameSize = strlen(pe->name);
451*4882a593Smuzhiyun         einfo.width = pe->width;
452*4882a593Smuzhiyun         einfo.height = pe->height;
453*4882a593Smuzhiyun         einfo.rate.numerator = pe->rate.numerator;
454*4882a593Smuzhiyun         einfo.rate.denominator = pe->rate.denominator;
455*4882a593Smuzhiyun         _WriteEncodingInfo(client, &einfo);
456*4882a593Smuzhiyun         WriteToClient(client, nameSize, pe->name);
457*4882a593Smuzhiyun         pe++;
458*4882a593Smuzhiyun     }
459*4882a593Smuzhiyun 
460*4882a593Smuzhiyun     return Success;
461*4882a593Smuzhiyun }
462*4882a593Smuzhiyun 
463*4882a593Smuzhiyun static int
ProcXvPutVideo(ClientPtr client)464*4882a593Smuzhiyun ProcXvPutVideo(ClientPtr client)
465*4882a593Smuzhiyun {
466*4882a593Smuzhiyun     DrawablePtr pDraw;
467*4882a593Smuzhiyun     XvPortPtr pPort;
468*4882a593Smuzhiyun     GCPtr pGC;
469*4882a593Smuzhiyun     int status;
470*4882a593Smuzhiyun 
471*4882a593Smuzhiyun     REQUEST(xvPutVideoReq);
472*4882a593Smuzhiyun     REQUEST_SIZE_MATCH(xvPutVideoReq);
473*4882a593Smuzhiyun 
474*4882a593Smuzhiyun     VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, DixWriteAccess);
475*4882a593Smuzhiyun     VALIDATE_XV_PORT(stuff->port, pPort, DixReadAccess);
476*4882a593Smuzhiyun 
477*4882a593Smuzhiyun     if (!(pPort->pAdaptor->type & XvInputMask) ||
478*4882a593Smuzhiyun         !(pPort->pAdaptor->type & XvVideoMask)) {
479*4882a593Smuzhiyun         client->errorValue = stuff->port;
480*4882a593Smuzhiyun         return BadMatch;
481*4882a593Smuzhiyun     }
482*4882a593Smuzhiyun 
483*4882a593Smuzhiyun     status = XvdiMatchPort(pPort, pDraw);
484*4882a593Smuzhiyun     if (status != Success) {
485*4882a593Smuzhiyun         return status;
486*4882a593Smuzhiyun     }
487*4882a593Smuzhiyun 
488*4882a593Smuzhiyun     return XvdiPutVideo(client, pDraw, pPort, pGC, stuff->vid_x, stuff->vid_y,
489*4882a593Smuzhiyun                         stuff->vid_w, stuff->vid_h, stuff->drw_x, stuff->drw_y,
490*4882a593Smuzhiyun                         stuff->drw_w, stuff->drw_h);
491*4882a593Smuzhiyun }
492*4882a593Smuzhiyun 
493*4882a593Smuzhiyun static int
ProcXvPutStill(ClientPtr client)494*4882a593Smuzhiyun ProcXvPutStill(ClientPtr client)
495*4882a593Smuzhiyun {
496*4882a593Smuzhiyun     DrawablePtr pDraw;
497*4882a593Smuzhiyun     XvPortPtr pPort;
498*4882a593Smuzhiyun     GCPtr pGC;
499*4882a593Smuzhiyun     int status;
500*4882a593Smuzhiyun 
501*4882a593Smuzhiyun     REQUEST(xvPutStillReq);
502*4882a593Smuzhiyun     REQUEST_SIZE_MATCH(xvPutStillReq);
503*4882a593Smuzhiyun 
504*4882a593Smuzhiyun     VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, DixWriteAccess);
505*4882a593Smuzhiyun     VALIDATE_XV_PORT(stuff->port, pPort, DixReadAccess);
506*4882a593Smuzhiyun 
507*4882a593Smuzhiyun     if (!(pPort->pAdaptor->type & XvInputMask) ||
508*4882a593Smuzhiyun         !(pPort->pAdaptor->type & XvStillMask)) {
509*4882a593Smuzhiyun         client->errorValue = stuff->port;
510*4882a593Smuzhiyun         return BadMatch;
511*4882a593Smuzhiyun     }
512*4882a593Smuzhiyun 
513*4882a593Smuzhiyun     status = XvdiMatchPort(pPort, pDraw);
514*4882a593Smuzhiyun     if (status != Success) {
515*4882a593Smuzhiyun         return status;
516*4882a593Smuzhiyun     }
517*4882a593Smuzhiyun 
518*4882a593Smuzhiyun     return XvdiPutStill(client, pDraw, pPort, pGC, stuff->vid_x, stuff->vid_y,
519*4882a593Smuzhiyun                         stuff->vid_w, stuff->vid_h, stuff->drw_x, stuff->drw_y,
520*4882a593Smuzhiyun                         stuff->drw_w, stuff->drw_h);
521*4882a593Smuzhiyun }
522*4882a593Smuzhiyun 
523*4882a593Smuzhiyun static int
ProcXvGetVideo(ClientPtr client)524*4882a593Smuzhiyun ProcXvGetVideo(ClientPtr client)
525*4882a593Smuzhiyun {
526*4882a593Smuzhiyun     DrawablePtr pDraw;
527*4882a593Smuzhiyun     XvPortPtr pPort;
528*4882a593Smuzhiyun     GCPtr pGC;
529*4882a593Smuzhiyun     int status;
530*4882a593Smuzhiyun 
531*4882a593Smuzhiyun     REQUEST(xvGetVideoReq);
532*4882a593Smuzhiyun     REQUEST_SIZE_MATCH(xvGetVideoReq);
533*4882a593Smuzhiyun 
534*4882a593Smuzhiyun     VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, DixReadAccess);
535*4882a593Smuzhiyun     VALIDATE_XV_PORT(stuff->port, pPort, DixReadAccess);
536*4882a593Smuzhiyun 
537*4882a593Smuzhiyun     if (!(pPort->pAdaptor->type & XvOutputMask) ||
538*4882a593Smuzhiyun         !(pPort->pAdaptor->type & XvVideoMask)) {
539*4882a593Smuzhiyun         client->errorValue = stuff->port;
540*4882a593Smuzhiyun         return BadMatch;
541*4882a593Smuzhiyun     }
542*4882a593Smuzhiyun 
543*4882a593Smuzhiyun     status = XvdiMatchPort(pPort, pDraw);
544*4882a593Smuzhiyun     if (status != Success) {
545*4882a593Smuzhiyun         return status;
546*4882a593Smuzhiyun     }
547*4882a593Smuzhiyun 
548*4882a593Smuzhiyun     return XvdiGetVideo(client, pDraw, pPort, pGC, stuff->vid_x, stuff->vid_y,
549*4882a593Smuzhiyun                         stuff->vid_w, stuff->vid_h, stuff->drw_x, stuff->drw_y,
550*4882a593Smuzhiyun                         stuff->drw_w, stuff->drw_h);
551*4882a593Smuzhiyun }
552*4882a593Smuzhiyun 
553*4882a593Smuzhiyun static int
ProcXvGetStill(ClientPtr client)554*4882a593Smuzhiyun ProcXvGetStill(ClientPtr client)
555*4882a593Smuzhiyun {
556*4882a593Smuzhiyun     DrawablePtr pDraw;
557*4882a593Smuzhiyun     XvPortPtr pPort;
558*4882a593Smuzhiyun     GCPtr pGC;
559*4882a593Smuzhiyun     int status;
560*4882a593Smuzhiyun 
561*4882a593Smuzhiyun     REQUEST(xvGetStillReq);
562*4882a593Smuzhiyun     REQUEST_SIZE_MATCH(xvGetStillReq);
563*4882a593Smuzhiyun 
564*4882a593Smuzhiyun     VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, DixReadAccess);
565*4882a593Smuzhiyun     VALIDATE_XV_PORT(stuff->port, pPort, DixReadAccess);
566*4882a593Smuzhiyun 
567*4882a593Smuzhiyun     if (!(pPort->pAdaptor->type & XvOutputMask) ||
568*4882a593Smuzhiyun         !(pPort->pAdaptor->type & XvStillMask)) {
569*4882a593Smuzhiyun         client->errorValue = stuff->port;
570*4882a593Smuzhiyun         return BadMatch;
571*4882a593Smuzhiyun     }
572*4882a593Smuzhiyun 
573*4882a593Smuzhiyun     status = XvdiMatchPort(pPort, pDraw);
574*4882a593Smuzhiyun     if (status != Success) {
575*4882a593Smuzhiyun         return status;
576*4882a593Smuzhiyun     }
577*4882a593Smuzhiyun 
578*4882a593Smuzhiyun     return XvdiGetStill(client, pDraw, pPort, pGC, stuff->vid_x, stuff->vid_y,
579*4882a593Smuzhiyun                         stuff->vid_w, stuff->vid_h, stuff->drw_x, stuff->drw_y,
580*4882a593Smuzhiyun                         stuff->drw_w, stuff->drw_h);
581*4882a593Smuzhiyun }
582*4882a593Smuzhiyun 
583*4882a593Smuzhiyun static int
ProcXvSelectVideoNotify(ClientPtr client)584*4882a593Smuzhiyun ProcXvSelectVideoNotify(ClientPtr client)
585*4882a593Smuzhiyun {
586*4882a593Smuzhiyun     DrawablePtr pDraw;
587*4882a593Smuzhiyun     int rc;
588*4882a593Smuzhiyun 
589*4882a593Smuzhiyun     REQUEST(xvSelectVideoNotifyReq);
590*4882a593Smuzhiyun     REQUEST_SIZE_MATCH(xvSelectVideoNotifyReq);
591*4882a593Smuzhiyun 
592*4882a593Smuzhiyun     rc = dixLookupDrawable(&pDraw, stuff->drawable, client, 0,
593*4882a593Smuzhiyun                            DixReceiveAccess);
594*4882a593Smuzhiyun     if (rc != Success)
595*4882a593Smuzhiyun         return rc;
596*4882a593Smuzhiyun 
597*4882a593Smuzhiyun     return XvdiSelectVideoNotify(client, pDraw, stuff->onoff);
598*4882a593Smuzhiyun }
599*4882a593Smuzhiyun 
600*4882a593Smuzhiyun static int
ProcXvSelectPortNotify(ClientPtr client)601*4882a593Smuzhiyun ProcXvSelectPortNotify(ClientPtr client)
602*4882a593Smuzhiyun {
603*4882a593Smuzhiyun     XvPortPtr pPort;
604*4882a593Smuzhiyun 
605*4882a593Smuzhiyun     REQUEST(xvSelectPortNotifyReq);
606*4882a593Smuzhiyun     REQUEST_SIZE_MATCH(xvSelectPortNotifyReq);
607*4882a593Smuzhiyun 
608*4882a593Smuzhiyun     VALIDATE_XV_PORT(stuff->port, pPort, DixReadAccess);
609*4882a593Smuzhiyun 
610*4882a593Smuzhiyun     return XvdiSelectPortNotify(client, pPort, stuff->onoff);
611*4882a593Smuzhiyun }
612*4882a593Smuzhiyun 
613*4882a593Smuzhiyun static int
ProcXvGrabPort(ClientPtr client)614*4882a593Smuzhiyun ProcXvGrabPort(ClientPtr client)
615*4882a593Smuzhiyun {
616*4882a593Smuzhiyun     int result, status;
617*4882a593Smuzhiyun     XvPortPtr pPort;
618*4882a593Smuzhiyun     xvGrabPortReply rep;
619*4882a593Smuzhiyun 
620*4882a593Smuzhiyun     REQUEST(xvGrabPortReq);
621*4882a593Smuzhiyun     REQUEST_SIZE_MATCH(xvGrabPortReq);
622*4882a593Smuzhiyun 
623*4882a593Smuzhiyun     VALIDATE_XV_PORT(stuff->port, pPort, DixReadAccess);
624*4882a593Smuzhiyun 
625*4882a593Smuzhiyun     status = XvdiGrabPort(client, pPort, stuff->time, &result);
626*4882a593Smuzhiyun 
627*4882a593Smuzhiyun     if (status != Success) {
628*4882a593Smuzhiyun         return status;
629*4882a593Smuzhiyun     }
630*4882a593Smuzhiyun     rep = (xvGrabPortReply) {
631*4882a593Smuzhiyun         .type = X_Reply,
632*4882a593Smuzhiyun         .sequenceNumber = client->sequence,
633*4882a593Smuzhiyun         .length = 0,
634*4882a593Smuzhiyun         .result = result
635*4882a593Smuzhiyun     };
636*4882a593Smuzhiyun 
637*4882a593Smuzhiyun     _WriteGrabPortReply(client, &rep);
638*4882a593Smuzhiyun 
639*4882a593Smuzhiyun     return Success;
640*4882a593Smuzhiyun }
641*4882a593Smuzhiyun 
642*4882a593Smuzhiyun static int
ProcXvUngrabPort(ClientPtr client)643*4882a593Smuzhiyun ProcXvUngrabPort(ClientPtr client)
644*4882a593Smuzhiyun {
645*4882a593Smuzhiyun     XvPortPtr pPort;
646*4882a593Smuzhiyun 
647*4882a593Smuzhiyun     REQUEST(xvGrabPortReq);
648*4882a593Smuzhiyun     REQUEST_SIZE_MATCH(xvGrabPortReq);
649*4882a593Smuzhiyun 
650*4882a593Smuzhiyun     VALIDATE_XV_PORT(stuff->port, pPort, DixReadAccess);
651*4882a593Smuzhiyun 
652*4882a593Smuzhiyun     return XvdiUngrabPort(client, pPort, stuff->time);
653*4882a593Smuzhiyun }
654*4882a593Smuzhiyun 
655*4882a593Smuzhiyun static int
ProcXvStopVideo(ClientPtr client)656*4882a593Smuzhiyun ProcXvStopVideo(ClientPtr client)
657*4882a593Smuzhiyun {
658*4882a593Smuzhiyun     int ret;
659*4882a593Smuzhiyun     DrawablePtr pDraw;
660*4882a593Smuzhiyun     XvPortPtr pPort;
661*4882a593Smuzhiyun 
662*4882a593Smuzhiyun     REQUEST(xvStopVideoReq);
663*4882a593Smuzhiyun     REQUEST_SIZE_MATCH(xvStopVideoReq);
664*4882a593Smuzhiyun 
665*4882a593Smuzhiyun     VALIDATE_XV_PORT(stuff->port, pPort, DixReadAccess);
666*4882a593Smuzhiyun 
667*4882a593Smuzhiyun     ret = dixLookupDrawable(&pDraw, stuff->drawable, client, 0, DixWriteAccess);
668*4882a593Smuzhiyun     if (ret != Success)
669*4882a593Smuzhiyun         return ret;
670*4882a593Smuzhiyun 
671*4882a593Smuzhiyun     return XvdiStopVideo(client, pPort, pDraw);
672*4882a593Smuzhiyun }
673*4882a593Smuzhiyun 
674*4882a593Smuzhiyun static int
ProcXvSetPortAttribute(ClientPtr client)675*4882a593Smuzhiyun ProcXvSetPortAttribute(ClientPtr client)
676*4882a593Smuzhiyun {
677*4882a593Smuzhiyun     int status;
678*4882a593Smuzhiyun     XvPortPtr pPort;
679*4882a593Smuzhiyun 
680*4882a593Smuzhiyun     REQUEST(xvSetPortAttributeReq);
681*4882a593Smuzhiyun     REQUEST_SIZE_MATCH(xvSetPortAttributeReq);
682*4882a593Smuzhiyun 
683*4882a593Smuzhiyun     VALIDATE_XV_PORT(stuff->port, pPort, DixSetAttrAccess);
684*4882a593Smuzhiyun 
685*4882a593Smuzhiyun     if (!ValidAtom(stuff->attribute)) {
686*4882a593Smuzhiyun         client->errorValue = stuff->attribute;
687*4882a593Smuzhiyun         return BadAtom;
688*4882a593Smuzhiyun     }
689*4882a593Smuzhiyun 
690*4882a593Smuzhiyun     status =
691*4882a593Smuzhiyun         XvdiSetPortAttribute(client, pPort, stuff->attribute, stuff->value);
692*4882a593Smuzhiyun 
693*4882a593Smuzhiyun     if (status == BadMatch)
694*4882a593Smuzhiyun         client->errorValue = stuff->attribute;
695*4882a593Smuzhiyun     else
696*4882a593Smuzhiyun         client->errorValue = stuff->value;
697*4882a593Smuzhiyun 
698*4882a593Smuzhiyun     return status;
699*4882a593Smuzhiyun }
700*4882a593Smuzhiyun 
701*4882a593Smuzhiyun static int
ProcXvGetPortAttribute(ClientPtr client)702*4882a593Smuzhiyun ProcXvGetPortAttribute(ClientPtr client)
703*4882a593Smuzhiyun {
704*4882a593Smuzhiyun     INT32 value;
705*4882a593Smuzhiyun     int status;
706*4882a593Smuzhiyun     XvPortPtr pPort;
707*4882a593Smuzhiyun     xvGetPortAttributeReply rep;
708*4882a593Smuzhiyun 
709*4882a593Smuzhiyun     REQUEST(xvGetPortAttributeReq);
710*4882a593Smuzhiyun     REQUEST_SIZE_MATCH(xvGetPortAttributeReq);
711*4882a593Smuzhiyun 
712*4882a593Smuzhiyun     VALIDATE_XV_PORT(stuff->port, pPort, DixGetAttrAccess);
713*4882a593Smuzhiyun 
714*4882a593Smuzhiyun     if (!ValidAtom(stuff->attribute)) {
715*4882a593Smuzhiyun         client->errorValue = stuff->attribute;
716*4882a593Smuzhiyun         return BadAtom;
717*4882a593Smuzhiyun     }
718*4882a593Smuzhiyun 
719*4882a593Smuzhiyun     status = XvdiGetPortAttribute(client, pPort, stuff->attribute, &value);
720*4882a593Smuzhiyun     if (status != Success) {
721*4882a593Smuzhiyun         client->errorValue = stuff->attribute;
722*4882a593Smuzhiyun         return status;
723*4882a593Smuzhiyun     }
724*4882a593Smuzhiyun 
725*4882a593Smuzhiyun     rep = (xvGetPortAttributeReply) {
726*4882a593Smuzhiyun         .type = X_Reply,
727*4882a593Smuzhiyun         .sequenceNumber = client->sequence,
728*4882a593Smuzhiyun         .length = 0,
729*4882a593Smuzhiyun         .value = value
730*4882a593Smuzhiyun     };
731*4882a593Smuzhiyun 
732*4882a593Smuzhiyun     _WriteGetPortAttributeReply(client, &rep);
733*4882a593Smuzhiyun 
734*4882a593Smuzhiyun     return Success;
735*4882a593Smuzhiyun }
736*4882a593Smuzhiyun 
737*4882a593Smuzhiyun static int
ProcXvQueryBestSize(ClientPtr client)738*4882a593Smuzhiyun ProcXvQueryBestSize(ClientPtr client)
739*4882a593Smuzhiyun {
740*4882a593Smuzhiyun     unsigned int actual_width, actual_height;
741*4882a593Smuzhiyun     XvPortPtr pPort;
742*4882a593Smuzhiyun     xvQueryBestSizeReply rep;
743*4882a593Smuzhiyun 
744*4882a593Smuzhiyun     REQUEST(xvQueryBestSizeReq);
745*4882a593Smuzhiyun     REQUEST_SIZE_MATCH(xvQueryBestSizeReq);
746*4882a593Smuzhiyun 
747*4882a593Smuzhiyun     VALIDATE_XV_PORT(stuff->port, pPort, DixReadAccess);
748*4882a593Smuzhiyun 
749*4882a593Smuzhiyun     (*pPort->pAdaptor->ddQueryBestSize) (pPort, stuff->motion,
750*4882a593Smuzhiyun                                          stuff->vid_w, stuff->vid_h,
751*4882a593Smuzhiyun                                          stuff->drw_w, stuff->drw_h,
752*4882a593Smuzhiyun                                          &actual_width, &actual_height);
753*4882a593Smuzhiyun 
754*4882a593Smuzhiyun     rep = (xvQueryBestSizeReply) {
755*4882a593Smuzhiyun         .type = X_Reply,
756*4882a593Smuzhiyun         .sequenceNumber = client->sequence,
757*4882a593Smuzhiyun         .length = 0,
758*4882a593Smuzhiyun         .actual_width = actual_width,
759*4882a593Smuzhiyun         .actual_height = actual_height
760*4882a593Smuzhiyun     };
761*4882a593Smuzhiyun 
762*4882a593Smuzhiyun     _WriteQueryBestSizeReply(client, &rep);
763*4882a593Smuzhiyun 
764*4882a593Smuzhiyun     return Success;
765*4882a593Smuzhiyun }
766*4882a593Smuzhiyun 
767*4882a593Smuzhiyun static int
ProcXvQueryPortAttributes(ClientPtr client)768*4882a593Smuzhiyun ProcXvQueryPortAttributes(ClientPtr client)
769*4882a593Smuzhiyun {
770*4882a593Smuzhiyun     int size, i;
771*4882a593Smuzhiyun     XvPortPtr pPort;
772*4882a593Smuzhiyun     XvAttributePtr pAtt;
773*4882a593Smuzhiyun     xvQueryPortAttributesReply rep;
774*4882a593Smuzhiyun     xvAttributeInfo Info;
775*4882a593Smuzhiyun 
776*4882a593Smuzhiyun     REQUEST(xvQueryPortAttributesReq);
777*4882a593Smuzhiyun     REQUEST_SIZE_MATCH(xvQueryPortAttributesReq);
778*4882a593Smuzhiyun 
779*4882a593Smuzhiyun     VALIDATE_XV_PORT(stuff->port, pPort, DixGetAttrAccess);
780*4882a593Smuzhiyun 
781*4882a593Smuzhiyun     rep = (xvQueryPortAttributesReply) {
782*4882a593Smuzhiyun         .type = X_Reply,
783*4882a593Smuzhiyun         .sequenceNumber = client->sequence,
784*4882a593Smuzhiyun         .num_attributes = pPort->pAdaptor->nAttributes,
785*4882a593Smuzhiyun         .text_size = 0
786*4882a593Smuzhiyun     };
787*4882a593Smuzhiyun 
788*4882a593Smuzhiyun     for (i = 0, pAtt = pPort->pAdaptor->pAttributes;
789*4882a593Smuzhiyun          i < pPort->pAdaptor->nAttributes; i++, pAtt++) {
790*4882a593Smuzhiyun         rep.text_size += pad_to_int32(strlen(pAtt->name) + 1);
791*4882a593Smuzhiyun     }
792*4882a593Smuzhiyun 
793*4882a593Smuzhiyun     rep.length = (pPort->pAdaptor->nAttributes * sz_xvAttributeInfo)
794*4882a593Smuzhiyun         + rep.text_size;
795*4882a593Smuzhiyun     rep.length >>= 2;
796*4882a593Smuzhiyun 
797*4882a593Smuzhiyun     _WriteQueryPortAttributesReply(client, &rep);
798*4882a593Smuzhiyun 
799*4882a593Smuzhiyun     for (i = 0, pAtt = pPort->pAdaptor->pAttributes;
800*4882a593Smuzhiyun          i < pPort->pAdaptor->nAttributes; i++, pAtt++) {
801*4882a593Smuzhiyun         size = strlen(pAtt->name) + 1;  /* pass the NULL */
802*4882a593Smuzhiyun         Info.flags = pAtt->flags;
803*4882a593Smuzhiyun         Info.min = pAtt->min_value;
804*4882a593Smuzhiyun         Info.max = pAtt->max_value;
805*4882a593Smuzhiyun         Info.size = pad_to_int32(size);
806*4882a593Smuzhiyun 
807*4882a593Smuzhiyun         _WriteAttributeInfo(client, &Info);
808*4882a593Smuzhiyun 
809*4882a593Smuzhiyun         WriteToClient(client, size, pAtt->name);
810*4882a593Smuzhiyun     }
811*4882a593Smuzhiyun 
812*4882a593Smuzhiyun     return Success;
813*4882a593Smuzhiyun }
814*4882a593Smuzhiyun 
815*4882a593Smuzhiyun static int
ProcXvPutImage(ClientPtr client)816*4882a593Smuzhiyun ProcXvPutImage(ClientPtr client)
817*4882a593Smuzhiyun {
818*4882a593Smuzhiyun     DrawablePtr pDraw;
819*4882a593Smuzhiyun     XvPortPtr pPort;
820*4882a593Smuzhiyun     XvImagePtr pImage = NULL;
821*4882a593Smuzhiyun     GCPtr pGC;
822*4882a593Smuzhiyun     int status, i, size;
823*4882a593Smuzhiyun     CARD16 width, height;
824*4882a593Smuzhiyun 
825*4882a593Smuzhiyun     REQUEST(xvPutImageReq);
826*4882a593Smuzhiyun     REQUEST_AT_LEAST_SIZE(xvPutImageReq);
827*4882a593Smuzhiyun 
828*4882a593Smuzhiyun     VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, DixWriteAccess);
829*4882a593Smuzhiyun     VALIDATE_XV_PORT(stuff->port, pPort, DixReadAccess);
830*4882a593Smuzhiyun 
831*4882a593Smuzhiyun     if (!(pPort->pAdaptor->type & XvImageMask) ||
832*4882a593Smuzhiyun         !(pPort->pAdaptor->type & XvInputMask)) {
833*4882a593Smuzhiyun         client->errorValue = stuff->port;
834*4882a593Smuzhiyun         return BadMatch;
835*4882a593Smuzhiyun     }
836*4882a593Smuzhiyun 
837*4882a593Smuzhiyun     status = XvdiMatchPort(pPort, pDraw);
838*4882a593Smuzhiyun     if (status != Success) {
839*4882a593Smuzhiyun         return status;
840*4882a593Smuzhiyun     }
841*4882a593Smuzhiyun 
842*4882a593Smuzhiyun     for (i = 0; i < pPort->pAdaptor->nImages; i++) {
843*4882a593Smuzhiyun         if (pPort->pAdaptor->pImages[i].id == stuff->id) {
844*4882a593Smuzhiyun             pImage = &(pPort->pAdaptor->pImages[i]);
845*4882a593Smuzhiyun             break;
846*4882a593Smuzhiyun         }
847*4882a593Smuzhiyun     }
848*4882a593Smuzhiyun 
849*4882a593Smuzhiyun     if (!pImage)
850*4882a593Smuzhiyun         return BadMatch;
851*4882a593Smuzhiyun 
852*4882a593Smuzhiyun     width = stuff->width;
853*4882a593Smuzhiyun     height = stuff->height;
854*4882a593Smuzhiyun     size = (*pPort->pAdaptor->ddQueryImageAttributes) (pPort, pImage, &width,
855*4882a593Smuzhiyun                                                        &height, NULL, NULL);
856*4882a593Smuzhiyun     size += sizeof(xvPutImageReq);
857*4882a593Smuzhiyun     size = bytes_to_int32(size);
858*4882a593Smuzhiyun 
859*4882a593Smuzhiyun     if ((width < stuff->width) || (height < stuff->height))
860*4882a593Smuzhiyun         return BadValue;
861*4882a593Smuzhiyun 
862*4882a593Smuzhiyun     if (client->req_len < size)
863*4882a593Smuzhiyun         return BadLength;
864*4882a593Smuzhiyun 
865*4882a593Smuzhiyun     return XvdiPutImage(client, pDraw, pPort, pGC, stuff->src_x, stuff->src_y,
866*4882a593Smuzhiyun                         stuff->src_w, stuff->src_h, stuff->drw_x, stuff->drw_y,
867*4882a593Smuzhiyun                         stuff->drw_w, stuff->drw_h, pImage,
868*4882a593Smuzhiyun                         (unsigned char *) (&stuff[1]), FALSE,
869*4882a593Smuzhiyun                         stuff->width, stuff->height);
870*4882a593Smuzhiyun }
871*4882a593Smuzhiyun 
872*4882a593Smuzhiyun #ifdef MITSHM
873*4882a593Smuzhiyun 
874*4882a593Smuzhiyun static int
ProcXvShmPutImage(ClientPtr client)875*4882a593Smuzhiyun ProcXvShmPutImage(ClientPtr client)
876*4882a593Smuzhiyun {
877*4882a593Smuzhiyun     ShmDescPtr shmdesc;
878*4882a593Smuzhiyun     DrawablePtr pDraw;
879*4882a593Smuzhiyun     XvPortPtr pPort;
880*4882a593Smuzhiyun     XvImagePtr pImage = NULL;
881*4882a593Smuzhiyun     GCPtr pGC;
882*4882a593Smuzhiyun     int status, size_needed, i;
883*4882a593Smuzhiyun     CARD16 width, height;
884*4882a593Smuzhiyun 
885*4882a593Smuzhiyun     REQUEST(xvShmPutImageReq);
886*4882a593Smuzhiyun     REQUEST_SIZE_MATCH(xvShmPutImageReq);
887*4882a593Smuzhiyun 
888*4882a593Smuzhiyun     VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, DixWriteAccess);
889*4882a593Smuzhiyun     VALIDATE_XV_PORT(stuff->port, pPort, DixReadAccess);
890*4882a593Smuzhiyun 
891*4882a593Smuzhiyun     if (!(pPort->pAdaptor->type & XvImageMask) ||
892*4882a593Smuzhiyun         !(pPort->pAdaptor->type & XvInputMask)) {
893*4882a593Smuzhiyun         client->errorValue = stuff->port;
894*4882a593Smuzhiyun         return BadMatch;
895*4882a593Smuzhiyun     }
896*4882a593Smuzhiyun 
897*4882a593Smuzhiyun     status = XvdiMatchPort(pPort, pDraw);
898*4882a593Smuzhiyun     if (status != Success) {
899*4882a593Smuzhiyun         return status;
900*4882a593Smuzhiyun     }
901*4882a593Smuzhiyun 
902*4882a593Smuzhiyun     for (i = 0; i < pPort->pAdaptor->nImages; i++) {
903*4882a593Smuzhiyun         if (pPort->pAdaptor->pImages[i].id == stuff->id) {
904*4882a593Smuzhiyun             pImage = &(pPort->pAdaptor->pImages[i]);
905*4882a593Smuzhiyun             break;
906*4882a593Smuzhiyun         }
907*4882a593Smuzhiyun     }
908*4882a593Smuzhiyun 
909*4882a593Smuzhiyun     if (!pImage)
910*4882a593Smuzhiyun         return BadMatch;
911*4882a593Smuzhiyun 
912*4882a593Smuzhiyun     status = dixLookupResourceByType((void **) &shmdesc, stuff->shmseg,
913*4882a593Smuzhiyun                                      ShmSegType, serverClient, DixReadAccess);
914*4882a593Smuzhiyun     if (status != Success)
915*4882a593Smuzhiyun         return status;
916*4882a593Smuzhiyun 
917*4882a593Smuzhiyun     width = stuff->width;
918*4882a593Smuzhiyun     height = stuff->height;
919*4882a593Smuzhiyun     size_needed = (*pPort->pAdaptor->ddQueryImageAttributes) (pPort, pImage,
920*4882a593Smuzhiyun                                                               &width, &height,
921*4882a593Smuzhiyun                                                               NULL, NULL);
922*4882a593Smuzhiyun     if ((size_needed + stuff->offset) > shmdesc->size)
923*4882a593Smuzhiyun         return BadAccess;
924*4882a593Smuzhiyun 
925*4882a593Smuzhiyun     if ((width < stuff->width) || (height < stuff->height))
926*4882a593Smuzhiyun         return BadValue;
927*4882a593Smuzhiyun 
928*4882a593Smuzhiyun     status = XvdiPutImage(client, pDraw, pPort, pGC, stuff->src_x, stuff->src_y,
929*4882a593Smuzhiyun                           stuff->src_w, stuff->src_h, stuff->drw_x,
930*4882a593Smuzhiyun                           stuff->drw_y, stuff->drw_w, stuff->drw_h, pImage,
931*4882a593Smuzhiyun                           (unsigned char *) shmdesc->addr + stuff->offset,
932*4882a593Smuzhiyun                           stuff->send_event, stuff->width, stuff->height);
933*4882a593Smuzhiyun 
934*4882a593Smuzhiyun     if ((status == Success) && stuff->send_event) {
935*4882a593Smuzhiyun         xShmCompletionEvent ev = {
936*4882a593Smuzhiyun             .type = ShmCompletionCode,
937*4882a593Smuzhiyun             .drawable = stuff->drawable,
938*4882a593Smuzhiyun             .minorEvent = xv_ShmPutImage,
939*4882a593Smuzhiyun             .majorEvent = XvReqCode,
940*4882a593Smuzhiyun             .shmseg = stuff->shmseg,
941*4882a593Smuzhiyun             .offset = stuff->offset
942*4882a593Smuzhiyun         };
943*4882a593Smuzhiyun         WriteEventsToClient(client, 1, (xEvent *) &ev);
944*4882a593Smuzhiyun     }
945*4882a593Smuzhiyun 
946*4882a593Smuzhiyun     return status;
947*4882a593Smuzhiyun }
948*4882a593Smuzhiyun #else                           /* !MITSHM */
949*4882a593Smuzhiyun static int
ProcXvShmPutImage(ClientPtr client)950*4882a593Smuzhiyun ProcXvShmPutImage(ClientPtr client)
951*4882a593Smuzhiyun {
952*4882a593Smuzhiyun     return BadImplementation;
953*4882a593Smuzhiyun }
954*4882a593Smuzhiyun #endif
955*4882a593Smuzhiyun 
956*4882a593Smuzhiyun #ifdef XvMCExtension
957*4882a593Smuzhiyun #include "xvmcext.h"
958*4882a593Smuzhiyun #endif
959*4882a593Smuzhiyun 
960*4882a593Smuzhiyun static int
ProcXvQueryImageAttributes(ClientPtr client)961*4882a593Smuzhiyun ProcXvQueryImageAttributes(ClientPtr client)
962*4882a593Smuzhiyun {
963*4882a593Smuzhiyun     xvQueryImageAttributesReply rep;
964*4882a593Smuzhiyun     int size, num_planes, i;
965*4882a593Smuzhiyun     CARD16 width, height;
966*4882a593Smuzhiyun     XvImagePtr pImage = NULL;
967*4882a593Smuzhiyun     XvPortPtr pPort;
968*4882a593Smuzhiyun     int *offsets;
969*4882a593Smuzhiyun     int *pitches;
970*4882a593Smuzhiyun     int planeLength;
971*4882a593Smuzhiyun 
972*4882a593Smuzhiyun     REQUEST(xvQueryImageAttributesReq);
973*4882a593Smuzhiyun 
974*4882a593Smuzhiyun     REQUEST_SIZE_MATCH(xvQueryImageAttributesReq);
975*4882a593Smuzhiyun 
976*4882a593Smuzhiyun     VALIDATE_XV_PORT(stuff->port, pPort, DixReadAccess);
977*4882a593Smuzhiyun 
978*4882a593Smuzhiyun     for (i = 0; i < pPort->pAdaptor->nImages; i++) {
979*4882a593Smuzhiyun         if (pPort->pAdaptor->pImages[i].id == stuff->id) {
980*4882a593Smuzhiyun             pImage = &(pPort->pAdaptor->pImages[i]);
981*4882a593Smuzhiyun             break;
982*4882a593Smuzhiyun         }
983*4882a593Smuzhiyun     }
984*4882a593Smuzhiyun 
985*4882a593Smuzhiyun #ifdef XvMCExtension
986*4882a593Smuzhiyun     if (!pImage)
987*4882a593Smuzhiyun         pImage = XvMCFindXvImage(pPort, stuff->id);
988*4882a593Smuzhiyun #endif
989*4882a593Smuzhiyun 
990*4882a593Smuzhiyun     if (!pImage)
991*4882a593Smuzhiyun         return BadMatch;
992*4882a593Smuzhiyun 
993*4882a593Smuzhiyun     num_planes = pImage->num_planes;
994*4882a593Smuzhiyun 
995*4882a593Smuzhiyun     if (!(offsets = malloc(num_planes << 3)))
996*4882a593Smuzhiyun         return BadAlloc;
997*4882a593Smuzhiyun     pitches = offsets + num_planes;
998*4882a593Smuzhiyun 
999*4882a593Smuzhiyun     width = stuff->width;
1000*4882a593Smuzhiyun     height = stuff->height;
1001*4882a593Smuzhiyun 
1002*4882a593Smuzhiyun     size = (*pPort->pAdaptor->ddQueryImageAttributes) (pPort, pImage,
1003*4882a593Smuzhiyun                                                        &width, &height, offsets,
1004*4882a593Smuzhiyun                                                        pitches);
1005*4882a593Smuzhiyun 
1006*4882a593Smuzhiyun     rep = (xvQueryImageAttributesReply) {
1007*4882a593Smuzhiyun         .type = X_Reply,
1008*4882a593Smuzhiyun         .sequenceNumber = client->sequence,
1009*4882a593Smuzhiyun         .length = planeLength = num_planes << 1,
1010*4882a593Smuzhiyun         .num_planes = num_planes,
1011*4882a593Smuzhiyun         .width = width,
1012*4882a593Smuzhiyun         .height = height,
1013*4882a593Smuzhiyun         .data_size = size
1014*4882a593Smuzhiyun     };
1015*4882a593Smuzhiyun 
1016*4882a593Smuzhiyun     _WriteQueryImageAttributesReply(client, &rep);
1017*4882a593Smuzhiyun     if (client->swapped)
1018*4882a593Smuzhiyun         SwapLongs((CARD32 *) offsets, planeLength);
1019*4882a593Smuzhiyun     WriteToClient(client, planeLength << 2, offsets);
1020*4882a593Smuzhiyun 
1021*4882a593Smuzhiyun     free(offsets);
1022*4882a593Smuzhiyun 
1023*4882a593Smuzhiyun     return Success;
1024*4882a593Smuzhiyun }
1025*4882a593Smuzhiyun 
1026*4882a593Smuzhiyun static int
ProcXvListImageFormats(ClientPtr client)1027*4882a593Smuzhiyun ProcXvListImageFormats(ClientPtr client)
1028*4882a593Smuzhiyun {
1029*4882a593Smuzhiyun     XvPortPtr pPort;
1030*4882a593Smuzhiyun     XvImagePtr pImage;
1031*4882a593Smuzhiyun     int i;
1032*4882a593Smuzhiyun     xvListImageFormatsReply rep;
1033*4882a593Smuzhiyun     xvImageFormatInfo info;
1034*4882a593Smuzhiyun 
1035*4882a593Smuzhiyun     REQUEST(xvListImageFormatsReq);
1036*4882a593Smuzhiyun 
1037*4882a593Smuzhiyun     REQUEST_SIZE_MATCH(xvListImageFormatsReq);
1038*4882a593Smuzhiyun 
1039*4882a593Smuzhiyun     VALIDATE_XV_PORT(stuff->port, pPort, DixReadAccess);
1040*4882a593Smuzhiyun 
1041*4882a593Smuzhiyun     rep = (xvListImageFormatsReply) {
1042*4882a593Smuzhiyun         .type = X_Reply,
1043*4882a593Smuzhiyun         .sequenceNumber = client->sequence,
1044*4882a593Smuzhiyun         .num_formats = pPort->pAdaptor->nImages,
1045*4882a593Smuzhiyun         .length =
1046*4882a593Smuzhiyun             bytes_to_int32(pPort->pAdaptor->nImages * sz_xvImageFormatInfo)
1047*4882a593Smuzhiyun     };
1048*4882a593Smuzhiyun 
1049*4882a593Smuzhiyun     _WriteListImageFormatsReply(client, &rep);
1050*4882a593Smuzhiyun 
1051*4882a593Smuzhiyun     pImage = pPort->pAdaptor->pImages;
1052*4882a593Smuzhiyun 
1053*4882a593Smuzhiyun     for (i = 0; i < pPort->pAdaptor->nImages; i++, pImage++) {
1054*4882a593Smuzhiyun         info.id = pImage->id;
1055*4882a593Smuzhiyun         info.type = pImage->type;
1056*4882a593Smuzhiyun         info.byte_order = pImage->byte_order;
1057*4882a593Smuzhiyun         memcpy(&info.guid, pImage->guid, 16);
1058*4882a593Smuzhiyun         info.bpp = pImage->bits_per_pixel;
1059*4882a593Smuzhiyun         info.num_planes = pImage->num_planes;
1060*4882a593Smuzhiyun         info.depth = pImage->depth;
1061*4882a593Smuzhiyun         info.red_mask = pImage->red_mask;
1062*4882a593Smuzhiyun         info.green_mask = pImage->green_mask;
1063*4882a593Smuzhiyun         info.blue_mask = pImage->blue_mask;
1064*4882a593Smuzhiyun         info.format = pImage->format;
1065*4882a593Smuzhiyun         info.y_sample_bits = pImage->y_sample_bits;
1066*4882a593Smuzhiyun         info.u_sample_bits = pImage->u_sample_bits;
1067*4882a593Smuzhiyun         info.v_sample_bits = pImage->v_sample_bits;
1068*4882a593Smuzhiyun         info.horz_y_period = pImage->horz_y_period;
1069*4882a593Smuzhiyun         info.horz_u_period = pImage->horz_u_period;
1070*4882a593Smuzhiyun         info.horz_v_period = pImage->horz_v_period;
1071*4882a593Smuzhiyun         info.vert_y_period = pImage->vert_y_period;
1072*4882a593Smuzhiyun         info.vert_u_period = pImage->vert_u_period;
1073*4882a593Smuzhiyun         info.vert_v_period = pImage->vert_v_period;
1074*4882a593Smuzhiyun         memcpy(&info.comp_order, pImage->component_order, 32);
1075*4882a593Smuzhiyun         info.scanline_order = pImage->scanline_order;
1076*4882a593Smuzhiyun         _WriteImageFormatInfo(client, &info);
1077*4882a593Smuzhiyun     }
1078*4882a593Smuzhiyun 
1079*4882a593Smuzhiyun     return Success;
1080*4882a593Smuzhiyun }
1081*4882a593Smuzhiyun 
1082*4882a593Smuzhiyun static int (*XvProcVector[xvNumRequests]) (ClientPtr) = {
1083*4882a593Smuzhiyun ProcXvQueryExtension,
1084*4882a593Smuzhiyun         ProcXvQueryAdaptors,
1085*4882a593Smuzhiyun         ProcXvQueryEncodings,
1086*4882a593Smuzhiyun         ProcXvGrabPort,
1087*4882a593Smuzhiyun         ProcXvUngrabPort,
1088*4882a593Smuzhiyun         ProcXvPutVideo,
1089*4882a593Smuzhiyun         ProcXvPutStill,
1090*4882a593Smuzhiyun         ProcXvGetVideo,
1091*4882a593Smuzhiyun         ProcXvGetStill,
1092*4882a593Smuzhiyun         ProcXvStopVideo,
1093*4882a593Smuzhiyun         ProcXvSelectVideoNotify,
1094*4882a593Smuzhiyun         ProcXvSelectPortNotify,
1095*4882a593Smuzhiyun         ProcXvQueryBestSize,
1096*4882a593Smuzhiyun         ProcXvSetPortAttribute,
1097*4882a593Smuzhiyun         ProcXvGetPortAttribute,
1098*4882a593Smuzhiyun         ProcXvQueryPortAttributes,
1099*4882a593Smuzhiyun         ProcXvListImageFormats,
1100*4882a593Smuzhiyun         ProcXvQueryImageAttributes, ProcXvPutImage, ProcXvShmPutImage,};
1101*4882a593Smuzhiyun 
1102*4882a593Smuzhiyun int
ProcXvDispatch(ClientPtr client)1103*4882a593Smuzhiyun ProcXvDispatch(ClientPtr client)
1104*4882a593Smuzhiyun {
1105*4882a593Smuzhiyun     REQUEST(xReq);
1106*4882a593Smuzhiyun 
1107*4882a593Smuzhiyun     UpdateCurrentTime();
1108*4882a593Smuzhiyun 
1109*4882a593Smuzhiyun     if (stuff->data >= xvNumRequests) {
1110*4882a593Smuzhiyun         return BadRequest;
1111*4882a593Smuzhiyun     }
1112*4882a593Smuzhiyun 
1113*4882a593Smuzhiyun     return XvProcVector[stuff->data] (client);
1114*4882a593Smuzhiyun }
1115*4882a593Smuzhiyun 
1116*4882a593Smuzhiyun /* Swapped Procs */
1117*4882a593Smuzhiyun 
1118*4882a593Smuzhiyun static int _X_COLD
SProcXvQueryExtension(ClientPtr client)1119*4882a593Smuzhiyun SProcXvQueryExtension(ClientPtr client)
1120*4882a593Smuzhiyun {
1121*4882a593Smuzhiyun     REQUEST(xvQueryExtensionReq);
1122*4882a593Smuzhiyun     REQUEST_SIZE_MATCH(xvQueryExtensionReq);
1123*4882a593Smuzhiyun     swaps(&stuff->length);
1124*4882a593Smuzhiyun     return XvProcVector[xv_QueryExtension] (client);
1125*4882a593Smuzhiyun }
1126*4882a593Smuzhiyun 
1127*4882a593Smuzhiyun static int _X_COLD
SProcXvQueryAdaptors(ClientPtr client)1128*4882a593Smuzhiyun SProcXvQueryAdaptors(ClientPtr client)
1129*4882a593Smuzhiyun {
1130*4882a593Smuzhiyun     REQUEST(xvQueryAdaptorsReq);
1131*4882a593Smuzhiyun     REQUEST_SIZE_MATCH(xvQueryAdaptorsReq);
1132*4882a593Smuzhiyun     swaps(&stuff->length);
1133*4882a593Smuzhiyun     swapl(&stuff->window);
1134*4882a593Smuzhiyun     return XvProcVector[xv_QueryAdaptors] (client);
1135*4882a593Smuzhiyun }
1136*4882a593Smuzhiyun 
1137*4882a593Smuzhiyun static int _X_COLD
SProcXvQueryEncodings(ClientPtr client)1138*4882a593Smuzhiyun SProcXvQueryEncodings(ClientPtr client)
1139*4882a593Smuzhiyun {
1140*4882a593Smuzhiyun     REQUEST(xvQueryEncodingsReq);
1141*4882a593Smuzhiyun     REQUEST_SIZE_MATCH(xvQueryEncodingsReq);
1142*4882a593Smuzhiyun     swaps(&stuff->length);
1143*4882a593Smuzhiyun     swapl(&stuff->port);
1144*4882a593Smuzhiyun     return XvProcVector[xv_QueryEncodings] (client);
1145*4882a593Smuzhiyun }
1146*4882a593Smuzhiyun 
1147*4882a593Smuzhiyun static int _X_COLD
SProcXvGrabPort(ClientPtr client)1148*4882a593Smuzhiyun SProcXvGrabPort(ClientPtr client)
1149*4882a593Smuzhiyun {
1150*4882a593Smuzhiyun     REQUEST(xvGrabPortReq);
1151*4882a593Smuzhiyun     REQUEST_SIZE_MATCH(xvGrabPortReq);
1152*4882a593Smuzhiyun     swaps(&stuff->length);
1153*4882a593Smuzhiyun     swapl(&stuff->port);
1154*4882a593Smuzhiyun     swapl(&stuff->time);
1155*4882a593Smuzhiyun     return XvProcVector[xv_GrabPort] (client);
1156*4882a593Smuzhiyun }
1157*4882a593Smuzhiyun 
1158*4882a593Smuzhiyun static int _X_COLD
SProcXvUngrabPort(ClientPtr client)1159*4882a593Smuzhiyun SProcXvUngrabPort(ClientPtr client)
1160*4882a593Smuzhiyun {
1161*4882a593Smuzhiyun     REQUEST(xvUngrabPortReq);
1162*4882a593Smuzhiyun     REQUEST_SIZE_MATCH(xvUngrabPortReq);
1163*4882a593Smuzhiyun     swaps(&stuff->length);
1164*4882a593Smuzhiyun     swapl(&stuff->port);
1165*4882a593Smuzhiyun     swapl(&stuff->time);
1166*4882a593Smuzhiyun     return XvProcVector[xv_UngrabPort] (client);
1167*4882a593Smuzhiyun }
1168*4882a593Smuzhiyun 
1169*4882a593Smuzhiyun static int _X_COLD
SProcXvPutVideo(ClientPtr client)1170*4882a593Smuzhiyun SProcXvPutVideo(ClientPtr client)
1171*4882a593Smuzhiyun {
1172*4882a593Smuzhiyun     REQUEST(xvPutVideoReq);
1173*4882a593Smuzhiyun     REQUEST_SIZE_MATCH(xvPutVideoReq);
1174*4882a593Smuzhiyun     swaps(&stuff->length);
1175*4882a593Smuzhiyun     swapl(&stuff->port);
1176*4882a593Smuzhiyun     swapl(&stuff->drawable);
1177*4882a593Smuzhiyun     swapl(&stuff->gc);
1178*4882a593Smuzhiyun     swaps(&stuff->vid_x);
1179*4882a593Smuzhiyun     swaps(&stuff->vid_y);
1180*4882a593Smuzhiyun     swaps(&stuff->vid_w);
1181*4882a593Smuzhiyun     swaps(&stuff->vid_h);
1182*4882a593Smuzhiyun     swaps(&stuff->drw_x);
1183*4882a593Smuzhiyun     swaps(&stuff->drw_y);
1184*4882a593Smuzhiyun     swaps(&stuff->drw_w);
1185*4882a593Smuzhiyun     swaps(&stuff->drw_h);
1186*4882a593Smuzhiyun     return XvProcVector[xv_PutVideo] (client);
1187*4882a593Smuzhiyun }
1188*4882a593Smuzhiyun 
1189*4882a593Smuzhiyun static int _X_COLD
SProcXvPutStill(ClientPtr client)1190*4882a593Smuzhiyun SProcXvPutStill(ClientPtr client)
1191*4882a593Smuzhiyun {
1192*4882a593Smuzhiyun     REQUEST(xvPutStillReq);
1193*4882a593Smuzhiyun     REQUEST_SIZE_MATCH(xvPutStillReq);
1194*4882a593Smuzhiyun     swaps(&stuff->length);
1195*4882a593Smuzhiyun     swapl(&stuff->port);
1196*4882a593Smuzhiyun     swapl(&stuff->drawable);
1197*4882a593Smuzhiyun     swapl(&stuff->gc);
1198*4882a593Smuzhiyun     swaps(&stuff->vid_x);
1199*4882a593Smuzhiyun     swaps(&stuff->vid_y);
1200*4882a593Smuzhiyun     swaps(&stuff->vid_w);
1201*4882a593Smuzhiyun     swaps(&stuff->vid_h);
1202*4882a593Smuzhiyun     swaps(&stuff->drw_x);
1203*4882a593Smuzhiyun     swaps(&stuff->drw_y);
1204*4882a593Smuzhiyun     swaps(&stuff->drw_w);
1205*4882a593Smuzhiyun     swaps(&stuff->drw_h);
1206*4882a593Smuzhiyun     return XvProcVector[xv_PutStill] (client);
1207*4882a593Smuzhiyun }
1208*4882a593Smuzhiyun 
1209*4882a593Smuzhiyun static int _X_COLD
SProcXvGetVideo(ClientPtr client)1210*4882a593Smuzhiyun SProcXvGetVideo(ClientPtr client)
1211*4882a593Smuzhiyun {
1212*4882a593Smuzhiyun     REQUEST(xvGetVideoReq);
1213*4882a593Smuzhiyun     REQUEST_SIZE_MATCH(xvGetVideoReq);
1214*4882a593Smuzhiyun     swaps(&stuff->length);
1215*4882a593Smuzhiyun     swapl(&stuff->port);
1216*4882a593Smuzhiyun     swapl(&stuff->drawable);
1217*4882a593Smuzhiyun     swapl(&stuff->gc);
1218*4882a593Smuzhiyun     swaps(&stuff->vid_x);
1219*4882a593Smuzhiyun     swaps(&stuff->vid_y);
1220*4882a593Smuzhiyun     swaps(&stuff->vid_w);
1221*4882a593Smuzhiyun     swaps(&stuff->vid_h);
1222*4882a593Smuzhiyun     swaps(&stuff->drw_x);
1223*4882a593Smuzhiyun     swaps(&stuff->drw_y);
1224*4882a593Smuzhiyun     swaps(&stuff->drw_w);
1225*4882a593Smuzhiyun     swaps(&stuff->drw_h);
1226*4882a593Smuzhiyun     return XvProcVector[xv_GetVideo] (client);
1227*4882a593Smuzhiyun }
1228*4882a593Smuzhiyun 
1229*4882a593Smuzhiyun static int _X_COLD
SProcXvGetStill(ClientPtr client)1230*4882a593Smuzhiyun SProcXvGetStill(ClientPtr client)
1231*4882a593Smuzhiyun {
1232*4882a593Smuzhiyun     REQUEST(xvGetStillReq);
1233*4882a593Smuzhiyun     REQUEST_SIZE_MATCH(xvGetStillReq);
1234*4882a593Smuzhiyun     swaps(&stuff->length);
1235*4882a593Smuzhiyun     swapl(&stuff->port);
1236*4882a593Smuzhiyun     swapl(&stuff->drawable);
1237*4882a593Smuzhiyun     swapl(&stuff->gc);
1238*4882a593Smuzhiyun     swaps(&stuff->vid_x);
1239*4882a593Smuzhiyun     swaps(&stuff->vid_y);
1240*4882a593Smuzhiyun     swaps(&stuff->vid_w);
1241*4882a593Smuzhiyun     swaps(&stuff->vid_h);
1242*4882a593Smuzhiyun     swaps(&stuff->drw_x);
1243*4882a593Smuzhiyun     swaps(&stuff->drw_y);
1244*4882a593Smuzhiyun     swaps(&stuff->drw_w);
1245*4882a593Smuzhiyun     swaps(&stuff->drw_h);
1246*4882a593Smuzhiyun     return XvProcVector[xv_GetStill] (client);
1247*4882a593Smuzhiyun }
1248*4882a593Smuzhiyun 
1249*4882a593Smuzhiyun static int _X_COLD
SProcXvPutImage(ClientPtr client)1250*4882a593Smuzhiyun SProcXvPutImage(ClientPtr client)
1251*4882a593Smuzhiyun {
1252*4882a593Smuzhiyun     REQUEST(xvPutImageReq);
1253*4882a593Smuzhiyun     REQUEST_AT_LEAST_SIZE(xvPutImageReq);
1254*4882a593Smuzhiyun     swaps(&stuff->length);
1255*4882a593Smuzhiyun     swapl(&stuff->port);
1256*4882a593Smuzhiyun     swapl(&stuff->drawable);
1257*4882a593Smuzhiyun     swapl(&stuff->gc);
1258*4882a593Smuzhiyun     swapl(&stuff->id);
1259*4882a593Smuzhiyun     swaps(&stuff->src_x);
1260*4882a593Smuzhiyun     swaps(&stuff->src_y);
1261*4882a593Smuzhiyun     swaps(&stuff->src_w);
1262*4882a593Smuzhiyun     swaps(&stuff->src_h);
1263*4882a593Smuzhiyun     swaps(&stuff->drw_x);
1264*4882a593Smuzhiyun     swaps(&stuff->drw_y);
1265*4882a593Smuzhiyun     swaps(&stuff->drw_w);
1266*4882a593Smuzhiyun     swaps(&stuff->drw_h);
1267*4882a593Smuzhiyun     swaps(&stuff->width);
1268*4882a593Smuzhiyun     swaps(&stuff->height);
1269*4882a593Smuzhiyun     return XvProcVector[xv_PutImage] (client);
1270*4882a593Smuzhiyun }
1271*4882a593Smuzhiyun 
1272*4882a593Smuzhiyun #ifdef MITSHM
1273*4882a593Smuzhiyun static int _X_COLD
SProcXvShmPutImage(ClientPtr client)1274*4882a593Smuzhiyun SProcXvShmPutImage(ClientPtr client)
1275*4882a593Smuzhiyun {
1276*4882a593Smuzhiyun     REQUEST(xvShmPutImageReq);
1277*4882a593Smuzhiyun     REQUEST_SIZE_MATCH(xvShmPutImageReq);
1278*4882a593Smuzhiyun     swaps(&stuff->length);
1279*4882a593Smuzhiyun     swapl(&stuff->port);
1280*4882a593Smuzhiyun     swapl(&stuff->drawable);
1281*4882a593Smuzhiyun     swapl(&stuff->gc);
1282*4882a593Smuzhiyun     swapl(&stuff->shmseg);
1283*4882a593Smuzhiyun     swapl(&stuff->id);
1284*4882a593Smuzhiyun     swapl(&stuff->offset);
1285*4882a593Smuzhiyun     swaps(&stuff->src_x);
1286*4882a593Smuzhiyun     swaps(&stuff->src_y);
1287*4882a593Smuzhiyun     swaps(&stuff->src_w);
1288*4882a593Smuzhiyun     swaps(&stuff->src_h);
1289*4882a593Smuzhiyun     swaps(&stuff->drw_x);
1290*4882a593Smuzhiyun     swaps(&stuff->drw_y);
1291*4882a593Smuzhiyun     swaps(&stuff->drw_w);
1292*4882a593Smuzhiyun     swaps(&stuff->drw_h);
1293*4882a593Smuzhiyun     swaps(&stuff->width);
1294*4882a593Smuzhiyun     swaps(&stuff->height);
1295*4882a593Smuzhiyun     return XvProcVector[xv_ShmPutImage] (client);
1296*4882a593Smuzhiyun }
1297*4882a593Smuzhiyun #else                           /* MITSHM */
1298*4882a593Smuzhiyun #define SProcXvShmPutImage ProcXvShmPutImage
1299*4882a593Smuzhiyun #endif
1300*4882a593Smuzhiyun 
1301*4882a593Smuzhiyun static int _X_COLD
SProcXvSelectVideoNotify(ClientPtr client)1302*4882a593Smuzhiyun SProcXvSelectVideoNotify(ClientPtr client)
1303*4882a593Smuzhiyun {
1304*4882a593Smuzhiyun     REQUEST(xvSelectVideoNotifyReq);
1305*4882a593Smuzhiyun     REQUEST_SIZE_MATCH(xvSelectVideoNotifyReq);
1306*4882a593Smuzhiyun     swaps(&stuff->length);
1307*4882a593Smuzhiyun     swapl(&stuff->drawable);
1308*4882a593Smuzhiyun     return XvProcVector[xv_SelectVideoNotify] (client);
1309*4882a593Smuzhiyun }
1310*4882a593Smuzhiyun 
1311*4882a593Smuzhiyun static int _X_COLD
SProcXvSelectPortNotify(ClientPtr client)1312*4882a593Smuzhiyun SProcXvSelectPortNotify(ClientPtr client)
1313*4882a593Smuzhiyun {
1314*4882a593Smuzhiyun     REQUEST(xvSelectPortNotifyReq);
1315*4882a593Smuzhiyun     REQUEST_SIZE_MATCH(xvSelectPortNotifyReq);
1316*4882a593Smuzhiyun     swaps(&stuff->length);
1317*4882a593Smuzhiyun     swapl(&stuff->port);
1318*4882a593Smuzhiyun     return XvProcVector[xv_SelectPortNotify] (client);
1319*4882a593Smuzhiyun }
1320*4882a593Smuzhiyun 
1321*4882a593Smuzhiyun static int _X_COLD
SProcXvStopVideo(ClientPtr client)1322*4882a593Smuzhiyun SProcXvStopVideo(ClientPtr client)
1323*4882a593Smuzhiyun {
1324*4882a593Smuzhiyun     REQUEST(xvStopVideoReq);
1325*4882a593Smuzhiyun     REQUEST_SIZE_MATCH(xvStopVideoReq);
1326*4882a593Smuzhiyun     swaps(&stuff->length);
1327*4882a593Smuzhiyun     swapl(&stuff->port);
1328*4882a593Smuzhiyun     swapl(&stuff->drawable);
1329*4882a593Smuzhiyun     return XvProcVector[xv_StopVideo] (client);
1330*4882a593Smuzhiyun }
1331*4882a593Smuzhiyun 
1332*4882a593Smuzhiyun static int _X_COLD
SProcXvSetPortAttribute(ClientPtr client)1333*4882a593Smuzhiyun SProcXvSetPortAttribute(ClientPtr client)
1334*4882a593Smuzhiyun {
1335*4882a593Smuzhiyun     REQUEST(xvSetPortAttributeReq);
1336*4882a593Smuzhiyun     REQUEST_SIZE_MATCH(xvSetPortAttributeReq);
1337*4882a593Smuzhiyun     swaps(&stuff->length);
1338*4882a593Smuzhiyun     swapl(&stuff->port);
1339*4882a593Smuzhiyun     swapl(&stuff->attribute);
1340*4882a593Smuzhiyun     swapl(&stuff->value);
1341*4882a593Smuzhiyun     return XvProcVector[xv_SetPortAttribute] (client);
1342*4882a593Smuzhiyun }
1343*4882a593Smuzhiyun 
1344*4882a593Smuzhiyun static int _X_COLD
SProcXvGetPortAttribute(ClientPtr client)1345*4882a593Smuzhiyun SProcXvGetPortAttribute(ClientPtr client)
1346*4882a593Smuzhiyun {
1347*4882a593Smuzhiyun     REQUEST(xvGetPortAttributeReq);
1348*4882a593Smuzhiyun     REQUEST_SIZE_MATCH(xvGetPortAttributeReq);
1349*4882a593Smuzhiyun     swaps(&stuff->length);
1350*4882a593Smuzhiyun     swapl(&stuff->port);
1351*4882a593Smuzhiyun     swapl(&stuff->attribute);
1352*4882a593Smuzhiyun     return XvProcVector[xv_GetPortAttribute] (client);
1353*4882a593Smuzhiyun }
1354*4882a593Smuzhiyun 
1355*4882a593Smuzhiyun static int _X_COLD
SProcXvQueryBestSize(ClientPtr client)1356*4882a593Smuzhiyun SProcXvQueryBestSize(ClientPtr client)
1357*4882a593Smuzhiyun {
1358*4882a593Smuzhiyun     REQUEST(xvQueryBestSizeReq);
1359*4882a593Smuzhiyun     REQUEST_SIZE_MATCH(xvQueryBestSizeReq);
1360*4882a593Smuzhiyun     swaps(&stuff->length);
1361*4882a593Smuzhiyun     swapl(&stuff->port);
1362*4882a593Smuzhiyun     swaps(&stuff->vid_w);
1363*4882a593Smuzhiyun     swaps(&stuff->vid_h);
1364*4882a593Smuzhiyun     swaps(&stuff->drw_w);
1365*4882a593Smuzhiyun     swaps(&stuff->drw_h);
1366*4882a593Smuzhiyun     return XvProcVector[xv_QueryBestSize] (client);
1367*4882a593Smuzhiyun }
1368*4882a593Smuzhiyun 
1369*4882a593Smuzhiyun static int _X_COLD
SProcXvQueryPortAttributes(ClientPtr client)1370*4882a593Smuzhiyun SProcXvQueryPortAttributes(ClientPtr client)
1371*4882a593Smuzhiyun {
1372*4882a593Smuzhiyun     REQUEST(xvQueryPortAttributesReq);
1373*4882a593Smuzhiyun     REQUEST_SIZE_MATCH(xvQueryPortAttributesReq);
1374*4882a593Smuzhiyun     swaps(&stuff->length);
1375*4882a593Smuzhiyun     swapl(&stuff->port);
1376*4882a593Smuzhiyun     return XvProcVector[xv_QueryPortAttributes] (client);
1377*4882a593Smuzhiyun }
1378*4882a593Smuzhiyun 
1379*4882a593Smuzhiyun static int _X_COLD
SProcXvQueryImageAttributes(ClientPtr client)1380*4882a593Smuzhiyun SProcXvQueryImageAttributes(ClientPtr client)
1381*4882a593Smuzhiyun {
1382*4882a593Smuzhiyun     REQUEST(xvQueryImageAttributesReq);
1383*4882a593Smuzhiyun     REQUEST_SIZE_MATCH(xvQueryImageAttributesReq);
1384*4882a593Smuzhiyun     swaps(&stuff->length);
1385*4882a593Smuzhiyun     swapl(&stuff->port);
1386*4882a593Smuzhiyun     swapl(&stuff->id);
1387*4882a593Smuzhiyun     swaps(&stuff->width);
1388*4882a593Smuzhiyun     swaps(&stuff->height);
1389*4882a593Smuzhiyun     return XvProcVector[xv_QueryImageAttributes] (client);
1390*4882a593Smuzhiyun }
1391*4882a593Smuzhiyun 
1392*4882a593Smuzhiyun static int _X_COLD
SProcXvListImageFormats(ClientPtr client)1393*4882a593Smuzhiyun SProcXvListImageFormats(ClientPtr client)
1394*4882a593Smuzhiyun {
1395*4882a593Smuzhiyun     REQUEST(xvListImageFormatsReq);
1396*4882a593Smuzhiyun     REQUEST_SIZE_MATCH(xvListImageFormatsReq);
1397*4882a593Smuzhiyun     swaps(&stuff->length);
1398*4882a593Smuzhiyun     swapl(&stuff->port);
1399*4882a593Smuzhiyun     return XvProcVector[xv_ListImageFormats] (client);
1400*4882a593Smuzhiyun }
1401*4882a593Smuzhiyun 
1402*4882a593Smuzhiyun static int (*SXvProcVector[xvNumRequests]) (ClientPtr) = {
1403*4882a593Smuzhiyun SProcXvQueryExtension,
1404*4882a593Smuzhiyun         SProcXvQueryAdaptors,
1405*4882a593Smuzhiyun         SProcXvQueryEncodings,
1406*4882a593Smuzhiyun         SProcXvGrabPort,
1407*4882a593Smuzhiyun         SProcXvUngrabPort,
1408*4882a593Smuzhiyun         SProcXvPutVideo,
1409*4882a593Smuzhiyun         SProcXvPutStill,
1410*4882a593Smuzhiyun         SProcXvGetVideo,
1411*4882a593Smuzhiyun         SProcXvGetStill,
1412*4882a593Smuzhiyun         SProcXvStopVideo,
1413*4882a593Smuzhiyun         SProcXvSelectVideoNotify,
1414*4882a593Smuzhiyun         SProcXvSelectPortNotify,
1415*4882a593Smuzhiyun         SProcXvQueryBestSize,
1416*4882a593Smuzhiyun         SProcXvSetPortAttribute,
1417*4882a593Smuzhiyun         SProcXvGetPortAttribute,
1418*4882a593Smuzhiyun         SProcXvQueryPortAttributes,
1419*4882a593Smuzhiyun         SProcXvListImageFormats,
1420*4882a593Smuzhiyun         SProcXvQueryImageAttributes, SProcXvPutImage, SProcXvShmPutImage,};
1421*4882a593Smuzhiyun 
1422*4882a593Smuzhiyun int _X_COLD
SProcXvDispatch(ClientPtr client)1423*4882a593Smuzhiyun SProcXvDispatch(ClientPtr client)
1424*4882a593Smuzhiyun {
1425*4882a593Smuzhiyun     REQUEST(xReq);
1426*4882a593Smuzhiyun 
1427*4882a593Smuzhiyun     UpdateCurrentTime();
1428*4882a593Smuzhiyun 
1429*4882a593Smuzhiyun     if (stuff->data >= xvNumRequests) {
1430*4882a593Smuzhiyun         return BadRequest;
1431*4882a593Smuzhiyun     }
1432*4882a593Smuzhiyun 
1433*4882a593Smuzhiyun     return SXvProcVector[stuff->data] (client);
1434*4882a593Smuzhiyun }
1435*4882a593Smuzhiyun 
1436*4882a593Smuzhiyun #ifdef PANORAMIX
1437*4882a593Smuzhiyun static int
XineramaXvStopVideo(ClientPtr client)1438*4882a593Smuzhiyun XineramaXvStopVideo(ClientPtr client)
1439*4882a593Smuzhiyun {
1440*4882a593Smuzhiyun     int result, i;
1441*4882a593Smuzhiyun     PanoramiXRes *draw, *port;
1442*4882a593Smuzhiyun 
1443*4882a593Smuzhiyun     REQUEST(xvStopVideoReq);
1444*4882a593Smuzhiyun     REQUEST_SIZE_MATCH(xvStopVideoReq);
1445*4882a593Smuzhiyun 
1446*4882a593Smuzhiyun     result = dixLookupResourceByClass((void **) &draw, stuff->drawable,
1447*4882a593Smuzhiyun                                       XRC_DRAWABLE, client, DixWriteAccess);
1448*4882a593Smuzhiyun     if (result != Success)
1449*4882a593Smuzhiyun         return (result == BadValue) ? BadDrawable : result;
1450*4882a593Smuzhiyun 
1451*4882a593Smuzhiyun     result = dixLookupResourceByType((void **) &port, stuff->port,
1452*4882a593Smuzhiyun                                      XvXRTPort, client, DixReadAccess);
1453*4882a593Smuzhiyun     if (result != Success)
1454*4882a593Smuzhiyun         return result;
1455*4882a593Smuzhiyun 
1456*4882a593Smuzhiyun     FOR_NSCREENS_BACKWARD(i) {
1457*4882a593Smuzhiyun         if (port->info[i].id) {
1458*4882a593Smuzhiyun             stuff->drawable = draw->info[i].id;
1459*4882a593Smuzhiyun             stuff->port = port->info[i].id;
1460*4882a593Smuzhiyun             result = ProcXvStopVideo(client);
1461*4882a593Smuzhiyun         }
1462*4882a593Smuzhiyun     }
1463*4882a593Smuzhiyun 
1464*4882a593Smuzhiyun     return result;
1465*4882a593Smuzhiyun }
1466*4882a593Smuzhiyun 
1467*4882a593Smuzhiyun static int
XineramaXvSetPortAttribute(ClientPtr client)1468*4882a593Smuzhiyun XineramaXvSetPortAttribute(ClientPtr client)
1469*4882a593Smuzhiyun {
1470*4882a593Smuzhiyun     REQUEST(xvSetPortAttributeReq);
1471*4882a593Smuzhiyun     PanoramiXRes *port;
1472*4882a593Smuzhiyun     int result, i;
1473*4882a593Smuzhiyun 
1474*4882a593Smuzhiyun     REQUEST_SIZE_MATCH(xvSetPortAttributeReq);
1475*4882a593Smuzhiyun 
1476*4882a593Smuzhiyun     result = dixLookupResourceByType((void **) &port, stuff->port,
1477*4882a593Smuzhiyun                                      XvXRTPort, client, DixReadAccess);
1478*4882a593Smuzhiyun     if (result != Success)
1479*4882a593Smuzhiyun         return result;
1480*4882a593Smuzhiyun 
1481*4882a593Smuzhiyun     FOR_NSCREENS_BACKWARD(i) {
1482*4882a593Smuzhiyun         if (port->info[i].id) {
1483*4882a593Smuzhiyun             stuff->port = port->info[i].id;
1484*4882a593Smuzhiyun             result = ProcXvSetPortAttribute(client);
1485*4882a593Smuzhiyun         }
1486*4882a593Smuzhiyun     }
1487*4882a593Smuzhiyun     return result;
1488*4882a593Smuzhiyun }
1489*4882a593Smuzhiyun 
1490*4882a593Smuzhiyun #ifdef MITSHM
1491*4882a593Smuzhiyun static int
XineramaXvShmPutImage(ClientPtr client)1492*4882a593Smuzhiyun XineramaXvShmPutImage(ClientPtr client)
1493*4882a593Smuzhiyun {
1494*4882a593Smuzhiyun     REQUEST(xvShmPutImageReq);
1495*4882a593Smuzhiyun     PanoramiXRes *draw, *gc, *port;
1496*4882a593Smuzhiyun     Bool send_event;
1497*4882a593Smuzhiyun     Bool isRoot;
1498*4882a593Smuzhiyun     int result, i, x, y;
1499*4882a593Smuzhiyun 
1500*4882a593Smuzhiyun     REQUEST_SIZE_MATCH(xvShmPutImageReq);
1501*4882a593Smuzhiyun 
1502*4882a593Smuzhiyun     send_event = stuff->send_event;
1503*4882a593Smuzhiyun 
1504*4882a593Smuzhiyun     result = dixLookupResourceByClass((void **) &draw, stuff->drawable,
1505*4882a593Smuzhiyun                                       XRC_DRAWABLE, client, DixWriteAccess);
1506*4882a593Smuzhiyun     if (result != Success)
1507*4882a593Smuzhiyun         return (result == BadValue) ? BadDrawable : result;
1508*4882a593Smuzhiyun 
1509*4882a593Smuzhiyun     result = dixLookupResourceByType((void **) &gc, stuff->gc,
1510*4882a593Smuzhiyun                                      XRT_GC, client, DixReadAccess);
1511*4882a593Smuzhiyun     if (result != Success)
1512*4882a593Smuzhiyun         return result;
1513*4882a593Smuzhiyun 
1514*4882a593Smuzhiyun     result = dixLookupResourceByType((void **) &port, stuff->port,
1515*4882a593Smuzhiyun                                      XvXRTPort, client, DixReadAccess);
1516*4882a593Smuzhiyun     if (result != Success)
1517*4882a593Smuzhiyun         return result;
1518*4882a593Smuzhiyun 
1519*4882a593Smuzhiyun     isRoot = (draw->type == XRT_WINDOW) && draw->u.win.root;
1520*4882a593Smuzhiyun 
1521*4882a593Smuzhiyun     x = stuff->drw_x;
1522*4882a593Smuzhiyun     y = stuff->drw_y;
1523*4882a593Smuzhiyun 
1524*4882a593Smuzhiyun     FOR_NSCREENS_BACKWARD(i) {
1525*4882a593Smuzhiyun         if (port->info[i].id) {
1526*4882a593Smuzhiyun             stuff->drawable = draw->info[i].id;
1527*4882a593Smuzhiyun             stuff->port = port->info[i].id;
1528*4882a593Smuzhiyun             stuff->gc = gc->info[i].id;
1529*4882a593Smuzhiyun             stuff->drw_x = x;
1530*4882a593Smuzhiyun             stuff->drw_y = y;
1531*4882a593Smuzhiyun             if (isRoot) {
1532*4882a593Smuzhiyun                 stuff->drw_x -= screenInfo.screens[i]->x;
1533*4882a593Smuzhiyun                 stuff->drw_y -= screenInfo.screens[i]->y;
1534*4882a593Smuzhiyun             }
1535*4882a593Smuzhiyun             stuff->send_event = (send_event && !i) ? 1 : 0;
1536*4882a593Smuzhiyun 
1537*4882a593Smuzhiyun             result = ProcXvShmPutImage(client);
1538*4882a593Smuzhiyun         }
1539*4882a593Smuzhiyun     }
1540*4882a593Smuzhiyun     return result;
1541*4882a593Smuzhiyun }
1542*4882a593Smuzhiyun #else
1543*4882a593Smuzhiyun #define XineramaXvShmPutImage ProcXvShmPutImage
1544*4882a593Smuzhiyun #endif
1545*4882a593Smuzhiyun 
1546*4882a593Smuzhiyun static int
XineramaXvPutImage(ClientPtr client)1547*4882a593Smuzhiyun XineramaXvPutImage(ClientPtr client)
1548*4882a593Smuzhiyun {
1549*4882a593Smuzhiyun     REQUEST(xvPutImageReq);
1550*4882a593Smuzhiyun     PanoramiXRes *draw, *gc, *port;
1551*4882a593Smuzhiyun     Bool isRoot;
1552*4882a593Smuzhiyun     int result, i, x, y;
1553*4882a593Smuzhiyun 
1554*4882a593Smuzhiyun     REQUEST_AT_LEAST_SIZE(xvPutImageReq);
1555*4882a593Smuzhiyun 
1556*4882a593Smuzhiyun     result = dixLookupResourceByClass((void **) &draw, stuff->drawable,
1557*4882a593Smuzhiyun                                       XRC_DRAWABLE, client, DixWriteAccess);
1558*4882a593Smuzhiyun     if (result != Success)
1559*4882a593Smuzhiyun         return (result == BadValue) ? BadDrawable : result;
1560*4882a593Smuzhiyun 
1561*4882a593Smuzhiyun     result = dixLookupResourceByType((void **) &gc, stuff->gc,
1562*4882a593Smuzhiyun                                      XRT_GC, client, DixReadAccess);
1563*4882a593Smuzhiyun     if (result != Success)
1564*4882a593Smuzhiyun         return result;
1565*4882a593Smuzhiyun 
1566*4882a593Smuzhiyun     result = dixLookupResourceByType((void **) &port, stuff->port,
1567*4882a593Smuzhiyun                                      XvXRTPort, client, DixReadAccess);
1568*4882a593Smuzhiyun     if (result != Success)
1569*4882a593Smuzhiyun         return result;
1570*4882a593Smuzhiyun 
1571*4882a593Smuzhiyun     isRoot = (draw->type == XRT_WINDOW) && draw->u.win.root;
1572*4882a593Smuzhiyun 
1573*4882a593Smuzhiyun     x = stuff->drw_x;
1574*4882a593Smuzhiyun     y = stuff->drw_y;
1575*4882a593Smuzhiyun 
1576*4882a593Smuzhiyun     FOR_NSCREENS_BACKWARD(i) {
1577*4882a593Smuzhiyun         if (port->info[i].id) {
1578*4882a593Smuzhiyun             stuff->drawable = draw->info[i].id;
1579*4882a593Smuzhiyun             stuff->port = port->info[i].id;
1580*4882a593Smuzhiyun             stuff->gc = gc->info[i].id;
1581*4882a593Smuzhiyun             stuff->drw_x = x;
1582*4882a593Smuzhiyun             stuff->drw_y = y;
1583*4882a593Smuzhiyun             if (isRoot) {
1584*4882a593Smuzhiyun                 stuff->drw_x -= screenInfo.screens[i]->x;
1585*4882a593Smuzhiyun                 stuff->drw_y -= screenInfo.screens[i]->y;
1586*4882a593Smuzhiyun             }
1587*4882a593Smuzhiyun 
1588*4882a593Smuzhiyun             result = ProcXvPutImage(client);
1589*4882a593Smuzhiyun         }
1590*4882a593Smuzhiyun     }
1591*4882a593Smuzhiyun     return result;
1592*4882a593Smuzhiyun }
1593*4882a593Smuzhiyun 
1594*4882a593Smuzhiyun static int
XineramaXvPutVideo(ClientPtr client)1595*4882a593Smuzhiyun XineramaXvPutVideo(ClientPtr client)
1596*4882a593Smuzhiyun {
1597*4882a593Smuzhiyun     REQUEST(xvPutImageReq);
1598*4882a593Smuzhiyun     PanoramiXRes *draw, *gc, *port;
1599*4882a593Smuzhiyun     Bool isRoot;
1600*4882a593Smuzhiyun     int result, i, x, y;
1601*4882a593Smuzhiyun 
1602*4882a593Smuzhiyun     REQUEST_AT_LEAST_SIZE(xvPutVideoReq);
1603*4882a593Smuzhiyun 
1604*4882a593Smuzhiyun     result = dixLookupResourceByClass((void **) &draw, stuff->drawable,
1605*4882a593Smuzhiyun                                       XRC_DRAWABLE, client, DixWriteAccess);
1606*4882a593Smuzhiyun     if (result != Success)
1607*4882a593Smuzhiyun         return (result == BadValue) ? BadDrawable : result;
1608*4882a593Smuzhiyun 
1609*4882a593Smuzhiyun     result = dixLookupResourceByType((void **) &gc, stuff->gc,
1610*4882a593Smuzhiyun                                      XRT_GC, client, DixReadAccess);
1611*4882a593Smuzhiyun     if (result != Success)
1612*4882a593Smuzhiyun         return result;
1613*4882a593Smuzhiyun 
1614*4882a593Smuzhiyun     result = dixLookupResourceByType((void **) &port, stuff->port,
1615*4882a593Smuzhiyun                                      XvXRTPort, client, DixReadAccess);
1616*4882a593Smuzhiyun     if (result != Success)
1617*4882a593Smuzhiyun         return result;
1618*4882a593Smuzhiyun 
1619*4882a593Smuzhiyun     isRoot = (draw->type == XRT_WINDOW) && draw->u.win.root;
1620*4882a593Smuzhiyun 
1621*4882a593Smuzhiyun     x = stuff->drw_x;
1622*4882a593Smuzhiyun     y = stuff->drw_y;
1623*4882a593Smuzhiyun 
1624*4882a593Smuzhiyun     FOR_NSCREENS_BACKWARD(i) {
1625*4882a593Smuzhiyun         if (port->info[i].id) {
1626*4882a593Smuzhiyun             stuff->drawable = draw->info[i].id;
1627*4882a593Smuzhiyun             stuff->port = port->info[i].id;
1628*4882a593Smuzhiyun             stuff->gc = gc->info[i].id;
1629*4882a593Smuzhiyun             stuff->drw_x = x;
1630*4882a593Smuzhiyun             stuff->drw_y = y;
1631*4882a593Smuzhiyun             if (isRoot) {
1632*4882a593Smuzhiyun                 stuff->drw_x -= screenInfo.screens[i]->x;
1633*4882a593Smuzhiyun                 stuff->drw_y -= screenInfo.screens[i]->y;
1634*4882a593Smuzhiyun             }
1635*4882a593Smuzhiyun 
1636*4882a593Smuzhiyun             result = ProcXvPutVideo(client);
1637*4882a593Smuzhiyun         }
1638*4882a593Smuzhiyun     }
1639*4882a593Smuzhiyun     return result;
1640*4882a593Smuzhiyun }
1641*4882a593Smuzhiyun 
1642*4882a593Smuzhiyun static int
XineramaXvPutStill(ClientPtr client)1643*4882a593Smuzhiyun XineramaXvPutStill(ClientPtr client)
1644*4882a593Smuzhiyun {
1645*4882a593Smuzhiyun     REQUEST(xvPutImageReq);
1646*4882a593Smuzhiyun     PanoramiXRes *draw, *gc, *port;
1647*4882a593Smuzhiyun     Bool isRoot;
1648*4882a593Smuzhiyun     int result, i, x, y;
1649*4882a593Smuzhiyun 
1650*4882a593Smuzhiyun     REQUEST_AT_LEAST_SIZE(xvPutImageReq);
1651*4882a593Smuzhiyun 
1652*4882a593Smuzhiyun     result = dixLookupResourceByClass((void **) &draw, stuff->drawable,
1653*4882a593Smuzhiyun                                       XRC_DRAWABLE, client, DixWriteAccess);
1654*4882a593Smuzhiyun     if (result != Success)
1655*4882a593Smuzhiyun         return (result == BadValue) ? BadDrawable : result;
1656*4882a593Smuzhiyun 
1657*4882a593Smuzhiyun     result = dixLookupResourceByType((void **) &gc, stuff->gc,
1658*4882a593Smuzhiyun                                      XRT_GC, client, DixReadAccess);
1659*4882a593Smuzhiyun     if (result != Success)
1660*4882a593Smuzhiyun         return result;
1661*4882a593Smuzhiyun 
1662*4882a593Smuzhiyun     result = dixLookupResourceByType((void **) &port, stuff->port,
1663*4882a593Smuzhiyun                                      XvXRTPort, client, DixReadAccess);
1664*4882a593Smuzhiyun     if (result != Success)
1665*4882a593Smuzhiyun         return result;
1666*4882a593Smuzhiyun 
1667*4882a593Smuzhiyun     isRoot = (draw->type == XRT_WINDOW) && draw->u.win.root;
1668*4882a593Smuzhiyun 
1669*4882a593Smuzhiyun     x = stuff->drw_x;
1670*4882a593Smuzhiyun     y = stuff->drw_y;
1671*4882a593Smuzhiyun 
1672*4882a593Smuzhiyun     FOR_NSCREENS_BACKWARD(i) {
1673*4882a593Smuzhiyun         if (port->info[i].id) {
1674*4882a593Smuzhiyun             stuff->drawable = draw->info[i].id;
1675*4882a593Smuzhiyun             stuff->port = port->info[i].id;
1676*4882a593Smuzhiyun             stuff->gc = gc->info[i].id;
1677*4882a593Smuzhiyun             stuff->drw_x = x;
1678*4882a593Smuzhiyun             stuff->drw_y = y;
1679*4882a593Smuzhiyun             if (isRoot) {
1680*4882a593Smuzhiyun                 stuff->drw_x -= screenInfo.screens[i]->x;
1681*4882a593Smuzhiyun                 stuff->drw_y -= screenInfo.screens[i]->y;
1682*4882a593Smuzhiyun             }
1683*4882a593Smuzhiyun 
1684*4882a593Smuzhiyun             result = ProcXvPutStill(client);
1685*4882a593Smuzhiyun         }
1686*4882a593Smuzhiyun     }
1687*4882a593Smuzhiyun     return result;
1688*4882a593Smuzhiyun }
1689*4882a593Smuzhiyun 
1690*4882a593Smuzhiyun static Bool
isImageAdaptor(XvAdaptorPtr pAdapt)1691*4882a593Smuzhiyun isImageAdaptor(XvAdaptorPtr pAdapt)
1692*4882a593Smuzhiyun {
1693*4882a593Smuzhiyun     return (pAdapt->type & XvImageMask) && (pAdapt->nImages > 0);
1694*4882a593Smuzhiyun }
1695*4882a593Smuzhiyun 
1696*4882a593Smuzhiyun static Bool
hasOverlay(XvAdaptorPtr pAdapt)1697*4882a593Smuzhiyun hasOverlay(XvAdaptorPtr pAdapt)
1698*4882a593Smuzhiyun {
1699*4882a593Smuzhiyun     int i;
1700*4882a593Smuzhiyun 
1701*4882a593Smuzhiyun     for (i = 0; i < pAdapt->nAttributes; i++)
1702*4882a593Smuzhiyun         if (!strcmp(pAdapt->pAttributes[i].name, "XV_COLORKEY"))
1703*4882a593Smuzhiyun             return TRUE;
1704*4882a593Smuzhiyun     return FALSE;
1705*4882a593Smuzhiyun }
1706*4882a593Smuzhiyun 
1707*4882a593Smuzhiyun static XvAdaptorPtr
matchAdaptor(ScreenPtr pScreen,XvAdaptorPtr refAdapt,Bool isOverlay)1708*4882a593Smuzhiyun matchAdaptor(ScreenPtr pScreen, XvAdaptorPtr refAdapt, Bool isOverlay)
1709*4882a593Smuzhiyun {
1710*4882a593Smuzhiyun     int i;
1711*4882a593Smuzhiyun     XvScreenPtr xvsp =
1712*4882a593Smuzhiyun         dixLookupPrivate(&pScreen->devPrivates, XvGetScreenKey());
1713*4882a593Smuzhiyun     /* Do not try to go on if xv is not supported on this screen */
1714*4882a593Smuzhiyun     if (xvsp == NULL)
1715*4882a593Smuzhiyun         return NULL;
1716*4882a593Smuzhiyun 
1717*4882a593Smuzhiyun     /* if the adaptor has the same name it's a perfect match */
1718*4882a593Smuzhiyun     for (i = 0; i < xvsp->nAdaptors; i++) {
1719*4882a593Smuzhiyun         XvAdaptorPtr pAdapt = xvsp->pAdaptors + i;
1720*4882a593Smuzhiyun 
1721*4882a593Smuzhiyun         if (!strcmp(refAdapt->name, pAdapt->name))
1722*4882a593Smuzhiyun             return pAdapt;
1723*4882a593Smuzhiyun     }
1724*4882a593Smuzhiyun 
1725*4882a593Smuzhiyun     /* otherwise we only look for XvImage adaptors */
1726*4882a593Smuzhiyun     if (!isImageAdaptor(refAdapt))
1727*4882a593Smuzhiyun         return NULL;
1728*4882a593Smuzhiyun 
1729*4882a593Smuzhiyun     /* prefer overlay/overlay non-overlay/non-overlay pairing */
1730*4882a593Smuzhiyun     for (i = 0; i < xvsp->nAdaptors; i++) {
1731*4882a593Smuzhiyun         XvAdaptorPtr pAdapt = xvsp->pAdaptors + i;
1732*4882a593Smuzhiyun 
1733*4882a593Smuzhiyun         if (isImageAdaptor(pAdapt) && isOverlay == hasOverlay(pAdapt))
1734*4882a593Smuzhiyun             return pAdapt;
1735*4882a593Smuzhiyun     }
1736*4882a593Smuzhiyun 
1737*4882a593Smuzhiyun     /* but we'll take any XvImage pairing if we can get it */
1738*4882a593Smuzhiyun     for (i = 0; i < xvsp->nAdaptors; i++) {
1739*4882a593Smuzhiyun         XvAdaptorPtr pAdapt = xvsp->pAdaptors + i;
1740*4882a593Smuzhiyun 
1741*4882a593Smuzhiyun         if (isImageAdaptor(pAdapt))
1742*4882a593Smuzhiyun             return pAdapt;
1743*4882a593Smuzhiyun     }
1744*4882a593Smuzhiyun     return NULL;
1745*4882a593Smuzhiyun }
1746*4882a593Smuzhiyun 
1747*4882a593Smuzhiyun void
XineramifyXv(void)1748*4882a593Smuzhiyun XineramifyXv(void)
1749*4882a593Smuzhiyun {
1750*4882a593Smuzhiyun     XvScreenPtr xvsp0 =
1751*4882a593Smuzhiyun         dixLookupPrivate(&screenInfo.screens[0]->devPrivates, XvGetScreenKey());
1752*4882a593Smuzhiyun     XvAdaptorPtr MatchingAdaptors[MAXSCREENS];
1753*4882a593Smuzhiyun     int i, j, k;
1754*4882a593Smuzhiyun 
1755*4882a593Smuzhiyun     XvXRTPort = CreateNewResourceType(XineramaDeleteResource, "XvXRTPort");
1756*4882a593Smuzhiyun 
1757*4882a593Smuzhiyun     if (!xvsp0 || !XvXRTPort)
1758*4882a593Smuzhiyun         return;
1759*4882a593Smuzhiyun     SetResourceTypeErrorValue(XvXRTPort, _XvBadPort);
1760*4882a593Smuzhiyun 
1761*4882a593Smuzhiyun     for (i = 0; i < xvsp0->nAdaptors; i++) {
1762*4882a593Smuzhiyun         Bool isOverlay;
1763*4882a593Smuzhiyun         XvAdaptorPtr refAdapt = xvsp0->pAdaptors + i;
1764*4882a593Smuzhiyun 
1765*4882a593Smuzhiyun         if (!(refAdapt->type & XvInputMask))
1766*4882a593Smuzhiyun             continue;
1767*4882a593Smuzhiyun 
1768*4882a593Smuzhiyun         MatchingAdaptors[0] = refAdapt;
1769*4882a593Smuzhiyun         isOverlay = hasOverlay(refAdapt);
1770*4882a593Smuzhiyun         FOR_NSCREENS_FORWARD_SKIP(j)
1771*4882a593Smuzhiyun             MatchingAdaptors[j] =
1772*4882a593Smuzhiyun             matchAdaptor(screenInfo.screens[j], refAdapt, isOverlay);
1773*4882a593Smuzhiyun 
1774*4882a593Smuzhiyun         /* now create a resource for each port */
1775*4882a593Smuzhiyun         for (j = 0; j < refAdapt->nPorts; j++) {
1776*4882a593Smuzhiyun             PanoramiXRes *port = malloc(sizeof(PanoramiXRes));
1777*4882a593Smuzhiyun 
1778*4882a593Smuzhiyun             if (!port)
1779*4882a593Smuzhiyun                 break;
1780*4882a593Smuzhiyun 
1781*4882a593Smuzhiyun             FOR_NSCREENS(k) {
1782*4882a593Smuzhiyun                 if (MatchingAdaptors[k] && (MatchingAdaptors[k]->nPorts > j))
1783*4882a593Smuzhiyun                     port->info[k].id = MatchingAdaptors[k]->base_id + j;
1784*4882a593Smuzhiyun                 else
1785*4882a593Smuzhiyun                     port->info[k].id = 0;
1786*4882a593Smuzhiyun             }
1787*4882a593Smuzhiyun             AddResource(port->info[0].id, XvXRTPort, port);
1788*4882a593Smuzhiyun         }
1789*4882a593Smuzhiyun     }
1790*4882a593Smuzhiyun 
1791*4882a593Smuzhiyun     /* munge the dispatch vector */
1792*4882a593Smuzhiyun     XvProcVector[xv_PutVideo] = XineramaXvPutVideo;
1793*4882a593Smuzhiyun     XvProcVector[xv_PutStill] = XineramaXvPutStill;
1794*4882a593Smuzhiyun     XvProcVector[xv_StopVideo] = XineramaXvStopVideo;
1795*4882a593Smuzhiyun     XvProcVector[xv_SetPortAttribute] = XineramaXvSetPortAttribute;
1796*4882a593Smuzhiyun     XvProcVector[xv_PutImage] = XineramaXvPutImage;
1797*4882a593Smuzhiyun     XvProcVector[xv_ShmPutImage] = XineramaXvShmPutImage;
1798*4882a593Smuzhiyun }
1799*4882a593Smuzhiyun #endif                          /* PANORAMIX */
1800*4882a593Smuzhiyun 
1801*4882a593Smuzhiyun void
XvResetProcVector(void)1802*4882a593Smuzhiyun XvResetProcVector(void)
1803*4882a593Smuzhiyun {
1804*4882a593Smuzhiyun #ifdef PANORAMIX
1805*4882a593Smuzhiyun     XvProcVector[xv_PutVideo] = ProcXvPutVideo;
1806*4882a593Smuzhiyun     XvProcVector[xv_PutStill] = ProcXvPutStill;
1807*4882a593Smuzhiyun     XvProcVector[xv_StopVideo] = ProcXvStopVideo;
1808*4882a593Smuzhiyun     XvProcVector[xv_SetPortAttribute] = ProcXvSetPortAttribute;
1809*4882a593Smuzhiyun     XvProcVector[xv_PutImage] = ProcXvPutImage;
1810*4882a593Smuzhiyun     XvProcVector[xv_ShmPutImage] = ProcXvShmPutImage;
1811*4882a593Smuzhiyun #endif
1812*4882a593Smuzhiyun }
1813