1 /***********************************************************
2 Copyright 1991 by Digital Equipment Corporation, Maynard, Massachusetts,
3 and the Massachusetts Institute of Technology, Cambridge, Massachusetts.
7 Permission to use, copy, modify, and distribute this software and its
8 documentation for any purpose and without fee is hereby granted,
9 provided that the above copyright notice appear in all copies and that
10 both that copyright notice and this permission notice appear in
11 supporting documentation, and that the names of Digital or MIT not be
12 used in advertising or publicity pertaining to distribution of the
13 software without specific, written prior permission.
15 DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
16 ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
17 DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
18 ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
19 WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
20 ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
23 ******************************************************************/
28 ** xvdisp.c --- Xv server extension dispatch module.
32 ** David Carver (Digital Workstation Engineering/Project Athena)
37 ** - changed SetPortControl to SetPortAttribute
38 ** - changed GetPortControl to GetPortAttribute
39 ** - changed QueryBestSize
42 ** - version 2.0 upgrade
45 ** - version 1.4 upgrade
49 #ifdef HAVE_DIX_CONFIG_H
50 #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>
77 #include "panoramiX.h"
78 #include "panoramiXsrv.h"
80 unsigned long XvXRTPort
;
83 static int XineramaXvShmPutImage(ClientPtr
);
85 static int XineramaXvPutImage(ClientPtr
);
86 static int XineramaXvPutVideo(ClientPtr
);
87 static int XineramaXvPutStill(ClientPtr
);
88 static int XineramaXvSetPortAttribute(ClientPtr
);
89 static int XineramaXvStopVideo(ClientPtr
);
94 static int ProcXvQueryExtension(ClientPtr
);
95 static int ProcXvQueryAdaptors(ClientPtr
);
96 static int ProcXvQueryEncodings(ClientPtr
);
97 static int ProcXvPutVideo(ClientPtr
);
98 static int ProcXvPutStill(ClientPtr
);
99 static int ProcXvGetVideo(ClientPtr
);
100 static int ProcXvGetStill(ClientPtr
);
101 static int ProcXvGrabPort(ClientPtr
);
102 static int ProcXvUngrabPort(ClientPtr
);
103 static int ProcXvSelectVideoNotify(ClientPtr
);
104 static int ProcXvSelectPortNotify(ClientPtr
);
105 static int ProcXvStopVideo(ClientPtr
);
106 static int ProcXvSetPortAttribute(ClientPtr
);
107 static int ProcXvGetPortAttribute(ClientPtr
);
108 static int ProcXvQueryBestSize(ClientPtr
);
109 static int ProcXvQueryPortAttributes(ClientPtr
);
110 static int ProcXvPutImage(ClientPtr
);
112 static int ProcXvShmPutImage(ClientPtr
);
114 static int ProcXvQueryImageAttributes(ClientPtr
);
115 static int ProcXvListImageFormats(ClientPtr
);
117 static int SProcXvQueryExtension(ClientPtr
);
118 static int SProcXvQueryAdaptors(ClientPtr
);
119 static int SProcXvQueryEncodings(ClientPtr
);
120 static int SProcXvPutVideo(ClientPtr
);
121 static int SProcXvPutStill(ClientPtr
);
122 static int SProcXvGetVideo(ClientPtr
);
123 static int SProcXvGetStill(ClientPtr
);
124 static int SProcXvGrabPort(ClientPtr
);
125 static int SProcXvUngrabPort(ClientPtr
);
126 static int SProcXvSelectVideoNotify(ClientPtr
);
127 static int SProcXvSelectPortNotify(ClientPtr
);
128 static int SProcXvStopVideo(ClientPtr
);
129 static int SProcXvSetPortAttribute(ClientPtr
);
130 static int SProcXvGetPortAttribute(ClientPtr
);
131 static int SProcXvQueryBestSize(ClientPtr
);
132 static int SProcXvQueryPortAttributes(ClientPtr
);
133 static int SProcXvPutImage(ClientPtr
);
135 static int SProcXvShmPutImage(ClientPtr
);
137 static int SProcXvQueryImageAttributes(ClientPtr
);
138 static int SProcXvListImageFormats(ClientPtr
);
140 static int SWriteQueryAdaptorsReply(ClientPtr
, xvQueryAdaptorsReply
*);
141 static int SWriteQueryExtensionReply(ClientPtr
, xvQueryExtensionReply
*);
142 static int SWriteQueryEncodingsReply(ClientPtr
, xvQueryEncodingsReply
*);
143 static int SWriteAdaptorInfo(ClientPtr
, xvAdaptorInfo
*);
144 static int SWriteEncodingInfo(ClientPtr
, xvEncodingInfo
*);
145 static int SWriteFormat(ClientPtr
, xvFormat
*);
146 static int SWriteAttributeInfo(ClientPtr
, xvAttributeInfo
*);
147 static int SWriteGrabPortReply(ClientPtr
, xvGrabPortReply
*);
148 static int SWriteGetPortAttributeReply(ClientPtr
, xvGetPortAttributeReply
*);
149 static int SWriteQueryBestSizeReply(ClientPtr
, xvQueryBestSizeReply
*);
150 static int SWriteQueryPortAttributesReply(
151 ClientPtr
, xvQueryPortAttributesReply
*);
152 static int SWriteQueryImageAttributesReply(
153 ClientPtr
, xvQueryImageAttributesReply
*);
154 static int SWriteListImageFormatsReply(ClientPtr
, xvListImageFormatsReply
*);
155 static int SWriteImageFormatInfo(ClientPtr
, xvImageFormatInfo
*);
157 #define _WriteQueryAdaptorsReply(_c,_d) \
158 if ((_c)->swapped) SWriteQueryAdaptorsReply(_c, _d); \
159 else WriteToClient(_c, sz_xvQueryAdaptorsReply, (char*)_d)
161 #define _WriteQueryExtensionReply(_c,_d) \
162 if ((_c)->swapped) SWriteQueryExtensionReply(_c, _d); \
163 else WriteToClient(_c, sz_xvQueryExtensionReply, (char*)_d)
165 #define _WriteQueryEncodingsReply(_c,_d) \
166 if ((_c)->swapped) SWriteQueryEncodingsReply(_c, _d); \
167 else WriteToClient(_c, sz_xvQueryEncodingsReply, (char*)_d)
169 #define _WriteAdaptorInfo(_c,_d) \
170 if ((_c)->swapped) SWriteAdaptorInfo(_c, _d); \
171 else WriteToClient(_c, sz_xvAdaptorInfo, (char*)_d)
173 #define _WriteAttributeInfo(_c,_d) \
174 if ((_c)->swapped) SWriteAttributeInfo(_c, _d); \
175 else WriteToClient(_c, sz_xvAttributeInfo, (char*)_d)
177 #define _WriteEncodingInfo(_c,_d) \
178 if ((_c)->swapped) SWriteEncodingInfo(_c, _d); \
179 else WriteToClient(_c, sz_xvEncodingInfo, (char*)_d)
181 #define _WriteFormat(_c,_d) \
182 if ((_c)->swapped) SWriteFormat(_c, _d); \
183 else WriteToClient(_c, sz_xvFormat, (char*)_d)
185 #define _WriteGrabPortReply(_c,_d) \
186 if ((_c)->swapped) SWriteGrabPortReply(_c, _d); \
187 else WriteToClient(_c, sz_xvGrabPortReply, (char*)_d)
189 #define _WriteGetPortAttributeReply(_c,_d) \
190 if ((_c)->swapped) SWriteGetPortAttributeReply(_c, _d); \
191 else WriteToClient(_c, sz_xvGetPortAttributeReply, (char*)_d)
193 #define _WriteQueryBestSizeReply(_c,_d) \
194 if ((_c)->swapped) SWriteQueryBestSizeReply(_c, _d); \
195 else WriteToClient(_c, sz_xvQueryBestSizeReply,(char*) _d)
197 #define _WriteQueryPortAttributesReply(_c,_d) \
198 if ((_c)->swapped) SWriteQueryPortAttributesReply(_c, _d); \
199 else WriteToClient(_c, sz_xvQueryPortAttributesReply,(char*) _d)
201 #define _WriteQueryImageAttributesReply(_c,_d) \
202 if ((_c)->swapped) SWriteQueryImageAttributesReply(_c, _d); \
203 else WriteToClient(_c, sz_xvQueryImageAttributesReply,(char*) _d)
205 #define _WriteListImageFormatsReply(_c,_d) \
206 if ((_c)->swapped) SWriteListImageFormatsReply(_c, _d); \
207 else WriteToClient(_c, sz_xvListImageFormatsReply,(char*) _d)
209 #define _WriteImageFormatInfo(_c,_d) \
210 if ((_c)->swapped) SWriteImageFormatInfo(_c, _d); \
211 else WriteToClient(_c, sz_xvImageFormatInfo, (char*)_d)
213 #define _AllocatePort(_i,_p) \
214 ((_p)->id != _i) ? (* (_p)->pAdaptor->ddAllocatePort)(_i,_p,&_p) : Success
224 ProcXvDispatch(ClientPtr client
)
232 case xv_QueryExtension
: return(ProcXvQueryExtension(client
));
233 case xv_QueryAdaptors
: return(ProcXvQueryAdaptors(client
));
234 case xv_QueryEncodings
: return(ProcXvQueryEncodings(client
));
237 if(!noPanoramiXExtension
)
238 return(XineramaXvPutVideo(client
));
241 return(ProcXvPutVideo(client
));
244 if(!noPanoramiXExtension
)
245 return(XineramaXvPutStill(client
));
248 return(ProcXvPutStill(client
));
249 case xv_GetVideo
: return(ProcXvGetVideo(client
));
250 case xv_GetStill
: return(ProcXvGetStill(client
));
251 case xv_GrabPort
: return(ProcXvGrabPort(client
));
252 case xv_UngrabPort
: return(ProcXvUngrabPort(client
));
253 case xv_SelectVideoNotify
: return(ProcXvSelectVideoNotify(client
));
254 case xv_SelectPortNotify
: return(ProcXvSelectPortNotify(client
));
257 if(!noPanoramiXExtension
)
258 return(XineramaXvStopVideo(client
));
261 return(ProcXvStopVideo(client
));
262 case xv_SetPortAttribute
:
264 if(!noPanoramiXExtension
)
265 return(XineramaXvSetPortAttribute(client
));
268 return(ProcXvSetPortAttribute(client
));
269 case xv_GetPortAttribute
: return(ProcXvGetPortAttribute(client
));
270 case xv_QueryBestSize
: return(ProcXvQueryBestSize(client
));
271 case xv_QueryPortAttributes
: return(ProcXvQueryPortAttributes(client
));
274 if(!noPanoramiXExtension
)
275 return(XineramaXvPutImage(client
));
278 return(ProcXvPutImage(client
));
282 if(!noPanoramiXExtension
)
283 return(XineramaXvShmPutImage(client
));
286 return(ProcXvShmPutImage(client
));
288 case xv_QueryImageAttributes
: return(ProcXvQueryImageAttributes(client
));
289 case xv_ListImageFormats
: return(ProcXvListImageFormats(client
));
291 if (stuff
->data
< xvNumRequests
)
293 SendErrorToClient(client
, XvReqCode
, stuff
->data
, 0,
295 return(BadImplementation
);
299 SendErrorToClient(client
, XvReqCode
, stuff
->data
, 0, BadRequest
);
306 SProcXvDispatch(ClientPtr client
)
314 case xv_QueryExtension
: return(SProcXvQueryExtension(client
));
315 case xv_QueryAdaptors
: return(SProcXvQueryAdaptors(client
));
316 case xv_QueryEncodings
: return(SProcXvQueryEncodings(client
));
317 case xv_PutVideo
: return(SProcXvPutVideo(client
));
318 case xv_PutStill
: return(SProcXvPutStill(client
));
319 case xv_GetVideo
: return(SProcXvGetVideo(client
));
320 case xv_GetStill
: return(SProcXvGetStill(client
));
321 case xv_GrabPort
: return(SProcXvGrabPort(client
));
322 case xv_UngrabPort
: return(SProcXvUngrabPort(client
));
323 case xv_SelectVideoNotify
: return(SProcXvSelectVideoNotify(client
));
324 case xv_SelectPortNotify
: return(SProcXvSelectPortNotify(client
));
325 case xv_StopVideo
: return(SProcXvStopVideo(client
));
326 case xv_SetPortAttribute
: return(SProcXvSetPortAttribute(client
));
327 case xv_GetPortAttribute
: return(SProcXvGetPortAttribute(client
));
328 case xv_QueryBestSize
: return(SProcXvQueryBestSize(client
));
329 case xv_QueryPortAttributes
: return(SProcXvQueryPortAttributes(client
));
330 case xv_PutImage
: return(SProcXvPutImage(client
));
332 case xv_ShmPutImage
: return(SProcXvShmPutImage(client
));
334 case xv_QueryImageAttributes
: return(SProcXvQueryImageAttributes(client
));
335 case xv_ListImageFormats
: return(SProcXvListImageFormats(client
));
337 if (stuff
->data
< xvNumRequests
)
339 SendErrorToClient(client
, XvReqCode
, stuff
->data
, 0,
341 return(BadImplementation
);
345 SendErrorToClient(client
, XvReqCode
, stuff
->data
, 0, BadRequest
);
352 ProcXvQueryExtension(ClientPtr client
)
354 xvQueryExtensionReply rep
;
355 /* REQUEST(xvQueryExtensionReq); */
356 REQUEST_SIZE_MATCH(xvQueryExtensionReq
);
359 rep
.sequenceNumber
= client
->sequence
;
361 rep
.version
= XvVersion
;
362 rep
.revision
= XvRevision
;
364 _WriteQueryExtensionReply(client
, &rep
);
371 ProcXvQueryAdaptors(ClientPtr client
)
375 xvQueryAdaptorsReply rep
;
376 int totalSize
, na
, nf
, rc
;
383 REQUEST(xvQueryAdaptorsReq
);
384 REQUEST_SIZE_MATCH(xvQueryAdaptorsReq
);
386 rc
= dixLookupWindow(&pWin
, stuff
->window
, client
, DixUnknownAccess
);
390 pScreen
= pWin
->drawable
.pScreen
;
391 pxvs
= (XvScreenPtr
)pScreen
->devPrivates
[XvScreenIndex
].ptr
;
396 rep
.sequenceNumber
= client
->sequence
;
397 rep
.num_adaptors
= 0;
400 _WriteQueryAdaptorsReply(client
, &rep
);
405 (* pxvs
->ddQueryAdaptors
)(pScreen
, &pxvs
->pAdaptors
, &pxvs
->nAdaptors
);
408 rep
.sequenceNumber
= client
->sequence
;
409 rep
.num_adaptors
= pxvs
->nAdaptors
;
411 /* CALCULATE THE TOTAL SIZE OF THE REPLY IN BYTES */
413 totalSize
= pxvs
->nAdaptors
* sz_xvAdaptorInfo
;
415 /* FOR EACH ADPATOR ADD UP THE BYTES FOR ENCODINGS AND FORMATS */
417 na
= pxvs
->nAdaptors
;
418 pa
= pxvs
->pAdaptors
;
421 totalSize
+= (strlen(pa
->name
) + 3) & ~3;
422 totalSize
+= pa
->nFormats
* sz_xvFormat
;
426 rep
.length
= totalSize
>> 2;
428 _WriteQueryAdaptorsReply(client
, &rep
);
430 na
= pxvs
->nAdaptors
;
431 pa
= pxvs
->pAdaptors
;
435 ainfo
.base_id
= pa
->base_id
;
436 ainfo
.num_ports
= pa
->nPorts
;
437 ainfo
.type
= pa
->type
;
438 ainfo
.name_size
= strlen(pa
->name
);
439 ainfo
.num_formats
= pa
->nFormats
;
441 _WriteAdaptorInfo(client
, &ainfo
);
443 WriteToClient(client
, ainfo
.name_size
, pa
->name
);
449 format
.depth
= pf
->depth
;
450 format
.visual
= pf
->visual
;
451 _WriteFormat(client
, &format
);
459 return (client
->noClientException
);
464 ProcXvQueryEncodings(ClientPtr client
)
466 xvEncodingInfo einfo
;
467 xvQueryEncodingsReply rep
;
474 REQUEST(xvQueryEncodingsReq
);
475 REQUEST_SIZE_MATCH(xvQueryEncodingsReq
);
477 if(!(pPort
= LOOKUP_PORT(stuff
->port
, client
) ))
479 client
->errorValue
= stuff
->port
;
483 if ((status
= _AllocatePort(stuff
->port
, pPort
)) != Success
)
485 client
->errorValue
= stuff
->port
;
490 rep
.sequenceNumber
= client
->sequence
;
491 rep
.num_encodings
= pPort
->pAdaptor
->nEncodings
;
493 /* FOR EACH ENCODING ADD UP THE BYTES FOR ENCODING NAMES */
495 ne
= pPort
->pAdaptor
->nEncodings
;
496 pe
= pPort
->pAdaptor
->pEncodings
;
497 totalSize
= ne
* sz_xvEncodingInfo
;
500 totalSize
+= (strlen(pe
->name
) + 3) & ~3;
504 rep
.length
= totalSize
>> 2;
506 _WriteQueryEncodingsReply(client
, &rep
);
508 ne
= pPort
->pAdaptor
->nEncodings
;
509 pe
= pPort
->pAdaptor
->pEncodings
;
512 einfo
.encoding
= pe
->id
;
513 einfo
.name_size
= strlen(pe
->name
);
514 einfo
.width
= pe
->width
;
515 einfo
.height
= pe
->height
;
516 einfo
.rate
.numerator
= pe
->rate
.numerator
;
517 einfo
.rate
.denominator
= pe
->rate
.denominator
;
518 _WriteEncodingInfo(client
, &einfo
);
519 WriteToClient(client
, einfo
.name_size
, pe
->name
);
523 return (client
->noClientException
);
528 ProcXvPutVideo(ClientPtr client
)
535 REQUEST(xvPutVideoReq
);
536 REQUEST_SIZE_MATCH(xvPutVideoReq
);
538 VALIDATE_DRAWABLE_AND_GC(stuff
->drawable
, pDraw
, pGC
, client
);
540 if(!(pPort
= LOOKUP_PORT(stuff
->port
, client
) ))
542 client
->errorValue
= stuff
->port
;
546 if ((status
= _AllocatePort(stuff
->port
, pPort
)) != Success
)
548 client
->errorValue
= stuff
->port
;
552 if (!(pPort
->pAdaptor
->type
& XvInputMask
) ||
553 !(pPort
->pAdaptor
->type
& XvVideoMask
))
555 client
->errorValue
= stuff
->port
;
559 status
= XVCALL(diMatchPort
)(pPort
, pDraw
);
560 if (status
!= Success
)
565 return XVCALL(diPutVideo
)(client
, pDraw
, pPort
, pGC
,
566 stuff
->vid_x
, stuff
->vid_y
,
567 stuff
->vid_w
, stuff
->vid_h
,
568 stuff
->drw_x
, stuff
->drw_y
,
569 stuff
->drw_w
, stuff
->drw_h
);
574 ProcXvPutStill(ClientPtr client
)
581 REQUEST(xvPutStillReq
);
582 REQUEST_SIZE_MATCH(xvPutStillReq
);
584 VALIDATE_DRAWABLE_AND_GC(stuff
->drawable
, pDraw
, pGC
, client
);
586 if(!(pPort
= LOOKUP_PORT(stuff
->port
, client
) ))
588 client
->errorValue
= stuff
->port
;
592 if ((status
= _AllocatePort(stuff
->port
, pPort
)) != Success
)
594 client
->errorValue
= stuff
->port
;
598 if (!(pPort
->pAdaptor
->type
& XvInputMask
) ||
599 !(pPort
->pAdaptor
->type
& XvStillMask
))
601 client
->errorValue
= stuff
->port
;
605 status
= XVCALL(diMatchPort
)(pPort
, pDraw
);
606 if (status
!= Success
)
611 return XVCALL(diPutStill
)(client
, pDraw
, pPort
, pGC
,
612 stuff
->vid_x
, stuff
->vid_y
,
613 stuff
->vid_w
, stuff
->vid_h
,
614 stuff
->drw_x
, stuff
->drw_y
,
615 stuff
->drw_w
, stuff
->drw_h
);
621 ProcXvGetVideo(ClientPtr client
)
628 REQUEST(xvGetVideoReq
);
629 REQUEST_SIZE_MATCH(xvGetVideoReq
);
631 VALIDATE_DRAWABLE_AND_GC(stuff
->drawable
, pDraw
, pGC
, client
);
633 if(!(pPort
= LOOKUP_PORT(stuff
->port
, client
) ))
635 client
->errorValue
= stuff
->port
;
639 if ((status
= _AllocatePort(stuff
->port
, pPort
)) != Success
)
641 client
->errorValue
= stuff
->port
;
645 if (!(pPort
->pAdaptor
->type
& XvOutputMask
) ||
646 !(pPort
->pAdaptor
->type
& XvVideoMask
))
648 client
->errorValue
= stuff
->port
;
652 status
= XVCALL(diMatchPort
)(pPort
, pDraw
);
653 if (status
!= Success
)
658 return XVCALL(diGetVideo
)(client
, pDraw
, pPort
, pGC
,
659 stuff
->vid_x
, stuff
->vid_y
,
660 stuff
->vid_w
, stuff
->vid_h
,
661 stuff
->drw_x
, stuff
->drw_y
,
662 stuff
->drw_w
, stuff
->drw_h
);
668 ProcXvGetStill(ClientPtr client
)
675 REQUEST(xvGetStillReq
);
676 REQUEST_SIZE_MATCH(xvGetStillReq
);
678 VALIDATE_DRAWABLE_AND_GC(stuff
->drawable
, pDraw
, pGC
, client
);
680 if(!(pPort
= LOOKUP_PORT(stuff
->port
, client
) ))
682 client
->errorValue
= stuff
->port
;
686 if ((status
= _AllocatePort(stuff
->port
, pPort
)) != Success
)
688 client
->errorValue
= stuff
->port
;
692 if (!(pPort
->pAdaptor
->type
& XvOutputMask
) ||
693 !(pPort
->pAdaptor
->type
& XvStillMask
))
695 client
->errorValue
= stuff
->port
;
699 status
= XVCALL(diMatchPort
)(pPort
, pDraw
);
700 if (status
!= Success
)
705 return XVCALL(diGetStill
)(client
, pDraw
, pPort
, pGC
,
706 stuff
->vid_x
, stuff
->vid_y
,
707 stuff
->vid_w
, stuff
->vid_h
,
708 stuff
->drw_x
, stuff
->drw_y
,
709 stuff
->drw_w
, stuff
->drw_h
);
714 ProcXvSelectVideoNotify(ClientPtr client
)
718 REQUEST(xvSelectVideoNotifyReq
);
719 REQUEST_SIZE_MATCH(xvSelectVideoNotifyReq
);
721 rc
= dixLookupDrawable(&pDraw
, stuff
->drawable
, client
, 0, DixUnknownAccess
);
725 return XVCALL(diSelectVideoNotify
)(client
, pDraw
, stuff
->onoff
);
730 ProcXvSelectPortNotify(ClientPtr client
)
734 REQUEST(xvSelectPortNotifyReq
);
735 REQUEST_SIZE_MATCH(xvSelectPortNotifyReq
);
737 if(!(pPort
= LOOKUP_PORT(stuff
->port
, client
) ))
739 client
->errorValue
= stuff
->port
;
743 if ((status
= _AllocatePort(stuff
->port
, pPort
)) != Success
)
745 client
->errorValue
= stuff
->port
;
749 return XVCALL(diSelectPortNotify
)(client
, pPort
, stuff
->onoff
);
754 ProcXvGrabPort(ClientPtr client
)
759 REQUEST(xvGrabPortReq
);
760 REQUEST_SIZE_MATCH(xvGrabPortReq
);
762 if(!(pPort
= LOOKUP_PORT(stuff
->port
, client
) ))
764 client
->errorValue
= stuff
->port
;
768 if ((status
= _AllocatePort(stuff
->port
, pPort
)) != Success
)
770 client
->errorValue
= stuff
->port
;
774 status
= XVCALL(diGrabPort
)(client
, pPort
, stuff
->time
, &result
);
776 if (status
!= Success
)
782 rep
.sequenceNumber
= client
->sequence
;
786 _WriteGrabPortReply(client
, &rep
);
793 ProcXvUngrabPort(ClientPtr client
)
797 REQUEST(xvGrabPortReq
);
798 REQUEST_SIZE_MATCH(xvGrabPortReq
);
800 if(!(pPort
= LOOKUP_PORT(stuff
->port
, client
) ))
802 client
->errorValue
= stuff
->port
;
806 if ((status
= _AllocatePort(stuff
->port
, pPort
)) != Success
)
808 client
->errorValue
= stuff
->port
;
812 return XVCALL(diUngrabPort
)(client
, pPort
, stuff
->time
);
818 ProcXvStopVideo(ClientPtr client
)
823 REQUEST(xvStopVideoReq
);
824 REQUEST_SIZE_MATCH(xvStopVideoReq
);
826 if(!(pPort
= LOOKUP_PORT(stuff
->port
, client
) ))
828 client
->errorValue
= stuff
->port
;
832 if ((status
= _AllocatePort(stuff
->port
, pPort
)) != Success
)
834 client
->errorValue
= stuff
->port
;
838 rc
= dixLookupDrawable(&pDraw
, stuff
->drawable
, client
, 0, DixUnknownAccess
);
842 return XVCALL(diStopVideo
)(client
, pPort
, pDraw
);
847 ProcXvSetPortAttribute(ClientPtr client
)
851 REQUEST(xvSetPortAttributeReq
);
852 REQUEST_SIZE_MATCH(xvSetPortAttributeReq
);
854 if(!(pPort
= LOOKUP_PORT(stuff
->port
, client
) ))
856 client
->errorValue
= stuff
->port
;
860 if ((status
= _AllocatePort(stuff
->port
, pPort
)) != Success
)
862 client
->errorValue
= stuff
->port
;
866 if (!ValidAtom(stuff
->attribute
))
868 client
->errorValue
= stuff
->attribute
;
872 status
= XVCALL(diSetPortAttribute
)(client
, pPort
,
873 stuff
->attribute
, stuff
->value
);
875 if (status
== BadMatch
)
876 client
->errorValue
= stuff
->attribute
;
878 client
->errorValue
= stuff
->value
;
884 ProcXvGetPortAttribute(ClientPtr client
)
889 xvGetPortAttributeReply rep
;
890 REQUEST(xvGetPortAttributeReq
);
891 REQUEST_SIZE_MATCH(xvGetPortAttributeReq
);
893 if(!(pPort
= LOOKUP_PORT(stuff
->port
, client
) ))
895 client
->errorValue
= stuff
->port
;
899 if ((status
= _AllocatePort(stuff
->port
, pPort
)) != Success
)
901 client
->errorValue
= stuff
->port
;
905 if (!ValidAtom(stuff
->attribute
))
907 client
->errorValue
= stuff
->attribute
;
911 status
= XVCALL(diGetPortAttribute
)(client
, pPort
, stuff
->attribute
, &value
);
912 if (status
!= Success
)
914 client
->errorValue
= stuff
->attribute
;
919 rep
.sequenceNumber
= client
->sequence
;
923 _WriteGetPortAttributeReply(client
, &rep
);
929 ProcXvQueryBestSize(ClientPtr client
)
932 unsigned int actual_width
, actual_height
;
934 xvQueryBestSizeReply rep
;
935 REQUEST(xvQueryBestSizeReq
);
936 REQUEST_SIZE_MATCH(xvQueryBestSizeReq
);
938 if(!(pPort
= LOOKUP_PORT(stuff
->port
, client
) ))
940 client
->errorValue
= stuff
->port
;
944 if ((status
= _AllocatePort(stuff
->port
, pPort
)) != Success
)
946 client
->errorValue
= stuff
->port
;
951 rep
.sequenceNumber
= client
->sequence
;
954 (* pPort
->pAdaptor
->ddQueryBestSize
)(client
, pPort
, stuff
->motion
,
955 stuff
->vid_w
, stuff
->vid_h
,
956 stuff
->drw_w
, stuff
->drw_h
,
957 &actual_width
, &actual_height
);
959 rep
.actual_width
= actual_width
;
960 rep
.actual_height
= actual_height
;
962 _WriteQueryBestSizeReply(client
, &rep
);
969 ProcXvQueryPortAttributes(ClientPtr client
)
974 xvQueryPortAttributesReply rep
;
975 xvAttributeInfo Info
;
976 REQUEST(xvQueryPortAttributesReq
);
977 REQUEST_SIZE_MATCH(xvQueryPortAttributesReq
);
979 if(!(pPort
= LOOKUP_PORT(stuff
->port
, client
) ))
981 client
->errorValue
= stuff
->port
;
985 if ((status
= _AllocatePort(stuff
->port
, pPort
)) != Success
)
987 client
->errorValue
= stuff
->port
;
992 rep
.sequenceNumber
= client
->sequence
;
993 rep
.num_attributes
= pPort
->pAdaptor
->nAttributes
;
996 for(i
= 0, pAtt
= pPort
->pAdaptor
->pAttributes
;
997 i
< rep
.num_attributes
; i
++, pAtt
++)
999 rep
.text_size
+= (strlen(pAtt
->name
) + 1 + 3) & ~3L;
1002 rep
.length
= (rep
.num_attributes
* sz_xvAttributeInfo
) + rep
.text_size
;
1005 _WriteQueryPortAttributesReply(client
, &rep
);
1007 for(i
= 0, pAtt
= pPort
->pAdaptor
->pAttributes
;
1008 i
< rep
.num_attributes
; i
++, pAtt
++)
1010 size
= strlen(pAtt
->name
) + 1; /* pass the NULL */
1011 Info
.flags
= pAtt
->flags
;
1012 Info
.min
= pAtt
->min_value
;
1013 Info
.max
= pAtt
->max_value
;
1014 Info
.size
= (size
+ 3) & ~3L;
1016 _WriteAttributeInfo(client
, &Info
);
1018 WriteToClient(client
, size
, pAtt
->name
);
1027 ProcXvPutImage(ClientPtr client
)
1031 XvImagePtr pImage
= NULL
;
1033 int status
, i
, size
;
1034 CARD16 width
, height
;
1036 REQUEST(xvPutImageReq
);
1037 REQUEST_AT_LEAST_SIZE(xvPutImageReq
);
1039 VALIDATE_DRAWABLE_AND_GC(stuff
->drawable
, pDraw
, pGC
, client
);
1041 if(!(pPort
= LOOKUP_PORT(stuff
->port
, client
) ))
1043 client
->errorValue
= stuff
->port
;
1044 return (_XvBadPort
);
1047 if ((status
= _AllocatePort(stuff
->port
, pPort
)) != Success
)
1049 client
->errorValue
= stuff
->port
;
1053 if (!(pPort
->pAdaptor
->type
& XvImageMask
) ||
1054 !(pPort
->pAdaptor
->type
& XvInputMask
))
1056 client
->errorValue
= stuff
->port
;
1060 status
= XVCALL(diMatchPort
)(pPort
, pDraw
);
1061 if (status
!= Success
)
1066 for(i
= 0; i
< pPort
->pAdaptor
->nImages
; i
++) {
1067 if(pPort
->pAdaptor
->pImages
[i
].id
== stuff
->id
) {
1068 pImage
= &(pPort
->pAdaptor
->pImages
[i
]);
1076 width
= stuff
->width
;
1077 height
= stuff
->height
;
1078 size
= (*pPort
->pAdaptor
->ddQueryImageAttributes
)(client
,
1079 pPort
, pImage
, &width
, &height
, NULL
, NULL
);
1080 size
+= sizeof(xvPutImageReq
);
1081 size
= (size
+ 3) >> 2;
1083 if((width
< stuff
->width
) || (height
< stuff
->height
))
1086 if(client
->req_len
< size
)
1089 return XVCALL(diPutImage
)(client
, pDraw
, pPort
, pGC
,
1090 stuff
->src_x
, stuff
->src_y
,
1091 stuff
->src_w
, stuff
->src_h
,
1092 stuff
->drw_x
, stuff
->drw_y
,
1093 stuff
->drw_w
, stuff
->drw_h
,
1094 pImage
, (unsigned char*)(&stuff
[1]), FALSE
,
1095 stuff
->width
, stuff
->height
);
1099 /* redefined here since it's not in any header file */
1100 typedef struct _ShmDesc
{
1101 struct _ShmDesc
*next
;
1107 } ShmDescRec
, *ShmDescPtr
;
1109 extern RESTYPE ShmSegType
;
1110 extern int BadShmSegCode
;
1111 extern int ShmCompletionCode
;
1114 ProcXvShmPutImage(ClientPtr client
)
1119 XvImagePtr pImage
= NULL
;
1121 int status
, size_needed
, i
;
1122 CARD16 width
, height
;
1124 REQUEST(xvShmPutImageReq
);
1125 REQUEST_SIZE_MATCH(xvShmPutImageReq
);
1127 VALIDATE_DRAWABLE_AND_GC(stuff
->drawable
, pDraw
, pGC
, client
);
1129 if(!(pPort
= LOOKUP_PORT(stuff
->port
, client
) ))
1131 client
->errorValue
= stuff
->port
;
1132 return (_XvBadPort
);
1135 if ((status
= _AllocatePort(stuff
->port
, pPort
)) != Success
)
1137 client
->errorValue
= stuff
->port
;
1141 if (!(pPort
->pAdaptor
->type
& XvImageMask
) ||
1142 !(pPort
->pAdaptor
->type
& XvInputMask
))
1144 client
->errorValue
= stuff
->port
;
1148 status
= XVCALL(diMatchPort
)(pPort
, pDraw
);
1149 if (status
!= Success
)
1154 for(i
= 0; i
< pPort
->pAdaptor
->nImages
; i
++) {
1155 if(pPort
->pAdaptor
->pImages
[i
].id
== stuff
->id
) {
1156 pImage
= &(pPort
->pAdaptor
->pImages
[i
]);
1164 if(!(shmdesc
= (ShmDescPtr
)LookupIDByType(stuff
->shmseg
, ShmSegType
)))
1166 client
->errorValue
= stuff
->shmseg
;
1167 return BadShmSegCode
;
1170 width
= stuff
->width
;
1171 height
= stuff
->height
;
1172 size_needed
= (*pPort
->pAdaptor
->ddQueryImageAttributes
)(client
,
1173 pPort
, pImage
, &width
, &height
, NULL
, NULL
);
1174 if((size_needed
+ stuff
->offset
) > shmdesc
->size
)
1177 if((width
< stuff
->width
) || (height
< stuff
->height
))
1180 status
= XVCALL(diPutImage
)(client
, pDraw
, pPort
, pGC
,
1181 stuff
->src_x
, stuff
->src_y
,
1182 stuff
->src_w
, stuff
->src_h
,
1183 stuff
->drw_x
, stuff
->drw_y
,
1184 stuff
->drw_w
, stuff
->drw_h
, pImage
,
1185 (unsigned char *)shmdesc
->addr
+ stuff
->offset
,
1186 stuff
->send_event
, stuff
->width
, stuff
->height
);
1188 if((status
== Success
) && stuff
->send_event
) {
1189 xShmCompletionEvent ev
;
1191 ev
.type
= ShmCompletionCode
;
1192 ev
.drawable
= stuff
->drawable
;
1193 ev
.sequenceNumber
= client
->sequence
;
1194 ev
.minorEvent
= xv_ShmPutImage
;
1195 ev
.majorEvent
= XvReqCode
;
1196 ev
.shmseg
= stuff
->shmseg
;
1197 ev
.offset
= stuff
->offset
;
1198 WriteEventsToClient(client
, 1, (xEvent
*) &ev
);
1205 #ifdef XvMCExtension
1206 #include "xvmcext.h"
1210 ProcXvQueryImageAttributes(ClientPtr client
)
1212 xvQueryImageAttributesReply rep
;
1213 int size
, num_planes
, i
;
1214 CARD16 width
, height
;
1215 XvImagePtr pImage
= NULL
;
1219 REQUEST(xvQueryImageAttributesReq
);
1221 REQUEST_SIZE_MATCH(xvQueryImageAttributesReq
);
1223 if(!(pPort
= LOOKUP_PORT(stuff
->port
, client
) ))
1225 client
->errorValue
= stuff
->port
;
1226 return (_XvBadPort
);
1229 for(i
= 0; i
< pPort
->pAdaptor
->nImages
; i
++) {
1230 if(pPort
->pAdaptor
->pImages
[i
].id
== stuff
->id
) {
1231 pImage
= &(pPort
->pAdaptor
->pImages
[i
]);
1236 #ifdef XvMCExtension
1238 pImage
= XvMCFindXvImage(pPort
, stuff
->id
);
1244 num_planes
= pImage
->num_planes
;
1246 if(!(offsets
= xalloc(num_planes
<< 3)))
1248 pitches
= offsets
+ num_planes
;
1250 width
= stuff
->width
;
1251 height
= stuff
->height
;
1253 size
= (*pPort
->pAdaptor
->ddQueryImageAttributes
)(client
, pPort
, pImage
,
1254 &width
, &height
, offsets
, pitches
);
1257 rep
.sequenceNumber
= client
->sequence
;
1258 rep
.length
= num_planes
<< 1;
1259 rep
.num_planes
= num_planes
;
1261 rep
.height
= height
;
1262 rep
.data_size
= size
;
1264 _WriteQueryImageAttributesReply(client
, &rep
);
1266 SwapLongs((CARD32
*)offsets
, rep
.length
);
1267 WriteToClient(client
, rep
.length
<< 2, (char*)offsets
);
1275 ProcXvListImageFormats(ClientPtr client
)
1280 xvListImageFormatsReply rep
;
1281 xvImageFormatInfo info
;
1282 REQUEST(xvListImageFormatsReq
);
1284 REQUEST_SIZE_MATCH(xvListImageFormatsReq
);
1286 if(!(pPort
= LOOKUP_PORT(stuff
->port
, client
) ))
1288 client
->errorValue
= stuff
->port
;
1289 return (_XvBadPort
);
1293 rep
.sequenceNumber
= client
->sequence
;
1294 rep
.num_formats
= pPort
->pAdaptor
->nImages
;
1295 rep
.length
= rep
.num_formats
* sz_xvImageFormatInfo
>> 2;
1297 _WriteListImageFormatsReply(client
, &rep
);
1299 pImage
= pPort
->pAdaptor
->pImages
;
1301 for(i
= 0; i
< rep
.num_formats
; i
++, pImage
++) {
1302 info
.id
= pImage
->id
;
1303 info
.type
= pImage
->type
;
1304 info
.byte_order
= pImage
->byte_order
;
1305 memcpy(&info
.guid
, pImage
->guid
, 16);
1306 info
.bpp
= pImage
->bits_per_pixel
;
1307 info
.num_planes
= pImage
->num_planes
;
1308 info
.depth
= pImage
->depth
;
1309 info
.red_mask
= pImage
->red_mask
;
1310 info
.green_mask
= pImage
->green_mask
;
1311 info
.blue_mask
= pImage
->blue_mask
;
1312 info
.format
= pImage
->format
;
1313 info
.y_sample_bits
= pImage
->y_sample_bits
;
1314 info
.u_sample_bits
= pImage
->u_sample_bits
;
1315 info
.v_sample_bits
= pImage
->v_sample_bits
;
1316 info
.horz_y_period
= pImage
->horz_y_period
;
1317 info
.horz_u_period
= pImage
->horz_u_period
;
1318 info
.horz_v_period
= pImage
->horz_v_period
;
1319 info
.vert_y_period
= pImage
->vert_y_period
;
1320 info
.vert_u_period
= pImage
->vert_u_period
;
1321 info
.vert_v_period
= pImage
->vert_v_period
;
1322 memcpy(&info
.comp_order
, pImage
->component_order
, 32);
1323 info
.scanline_order
= pImage
->scanline_order
;
1324 _WriteImageFormatInfo(client
, &info
);
1335 SProcXvQueryExtension(ClientPtr client
)
1338 REQUEST(xvQueryExtensionReq
);
1339 swaps(&stuff
->length
, n
);
1340 return ProcXvQueryExtension(client
);
1344 SProcXvQueryAdaptors(ClientPtr client
)
1347 REQUEST(xvQueryAdaptorsReq
);
1348 swaps(&stuff
->length
, n
);
1349 swapl(&stuff
->window
, n
);
1350 return ProcXvQueryAdaptors(client
);
1354 SProcXvQueryEncodings(ClientPtr client
)
1357 REQUEST(xvQueryEncodingsReq
);
1358 swaps(&stuff
->length
, n
);
1359 swapl(&stuff
->port
, n
);
1360 return ProcXvQueryEncodings(client
);
1364 SProcXvGrabPort(ClientPtr client
)
1367 REQUEST(xvGrabPortReq
);
1368 swaps(&stuff
->length
, n
);
1369 swapl(&stuff
->port
, n
);
1370 swapl(&stuff
->time
, n
);
1371 return ProcXvGrabPort(client
);
1375 SProcXvUngrabPort(ClientPtr client
)
1378 REQUEST(xvUngrabPortReq
);
1379 swaps(&stuff
->length
, n
);
1380 swapl(&stuff
->port
, n
);
1381 swapl(&stuff
->time
, n
);
1382 return ProcXvUngrabPort(client
);
1386 SProcXvPutVideo(ClientPtr client
)
1389 REQUEST(xvPutVideoReq
);
1390 swaps(&stuff
->length
, n
);
1391 swapl(&stuff
->port
, n
);
1392 swapl(&stuff
->drawable
, n
);
1393 swapl(&stuff
->gc
, n
);
1394 swaps(&stuff
->vid_x
, n
);
1395 swaps(&stuff
->vid_y
, n
);
1396 swaps(&stuff
->vid_w
, n
);
1397 swaps(&stuff
->vid_h
, n
);
1398 swaps(&stuff
->drw_x
, n
);
1399 swaps(&stuff
->drw_y
, n
);
1400 swaps(&stuff
->drw_w
, n
);
1401 swaps(&stuff
->drw_h
, n
);
1402 return ProcXvPutVideo(client
);
1406 SProcXvPutStill(ClientPtr client
)
1409 REQUEST(xvPutStillReq
);
1410 swaps(&stuff
->length
, n
);
1411 swapl(&stuff
->port
, n
);
1412 swapl(&stuff
->drawable
, n
);
1413 swapl(&stuff
->gc
, n
);
1414 swaps(&stuff
->vid_x
, n
);
1415 swaps(&stuff
->vid_y
, n
);
1416 swaps(&stuff
->vid_w
, n
);
1417 swaps(&stuff
->vid_h
, n
);
1418 swaps(&stuff
->drw_x
, n
);
1419 swaps(&stuff
->drw_y
, n
);
1420 swaps(&stuff
->drw_w
, n
);
1421 swaps(&stuff
->drw_h
, n
);
1422 return ProcXvPutStill(client
);
1426 SProcXvGetVideo(ClientPtr client
)
1429 REQUEST(xvGetVideoReq
);
1430 swaps(&stuff
->length
, n
);
1431 swapl(&stuff
->port
, n
);
1432 swapl(&stuff
->drawable
, n
);
1433 swapl(&stuff
->gc
, n
);
1434 swaps(&stuff
->vid_x
, n
);
1435 swaps(&stuff
->vid_y
, n
);
1436 swaps(&stuff
->vid_w
, n
);
1437 swaps(&stuff
->vid_h
, n
);
1438 swaps(&stuff
->drw_x
, n
);
1439 swaps(&stuff
->drw_y
, n
);
1440 swaps(&stuff
->drw_w
, n
);
1441 swaps(&stuff
->drw_h
, n
);
1442 return ProcXvGetVideo(client
);
1446 SProcXvGetStill(ClientPtr client
)
1449 REQUEST(xvGetStillReq
);
1450 swaps(&stuff
->length
, n
);
1451 swapl(&stuff
->port
, n
);
1452 swapl(&stuff
->drawable
, n
);
1453 swapl(&stuff
->gc
, n
);
1454 swaps(&stuff
->vid_x
, n
);
1455 swaps(&stuff
->vid_y
, n
);
1456 swaps(&stuff
->vid_w
, n
);
1457 swaps(&stuff
->vid_h
, n
);
1458 swaps(&stuff
->drw_x
, n
);
1459 swaps(&stuff
->drw_y
, n
);
1460 swaps(&stuff
->drw_w
, n
);
1461 swaps(&stuff
->drw_h
, n
);
1462 return ProcXvGetStill(client
);
1466 SProcXvPutImage(ClientPtr client
)
1469 REQUEST(xvPutImageReq
);
1470 swaps(&stuff
->length
, n
);
1471 swapl(&stuff
->port
, n
);
1472 swapl(&stuff
->drawable
, n
);
1473 swapl(&stuff
->gc
, n
);
1474 swapl(&stuff
->id
, n
);
1475 swaps(&stuff
->src_x
, n
);
1476 swaps(&stuff
->src_y
, n
);
1477 swaps(&stuff
->src_w
, n
);
1478 swaps(&stuff
->src_h
, n
);
1479 swaps(&stuff
->drw_x
, n
);
1480 swaps(&stuff
->drw_y
, n
);
1481 swaps(&stuff
->drw_w
, n
);
1482 swaps(&stuff
->drw_h
, n
);
1483 swaps(&stuff
->width
, n
);
1484 swaps(&stuff
->height
, n
);
1485 return ProcXvPutImage(client
);
1490 SProcXvShmPutImage(ClientPtr client
)
1493 REQUEST(xvShmPutImageReq
);
1494 swaps(&stuff
->length
, n
);
1495 swapl(&stuff
->port
, n
);
1496 swapl(&stuff
->drawable
, n
);
1497 swapl(&stuff
->gc
, n
);
1498 swapl(&stuff
->shmseg
, n
);
1499 swapl(&stuff
->id
, n
);
1500 swaps(&stuff
->src_x
, n
);
1501 swaps(&stuff
->src_y
, n
);
1502 swaps(&stuff
->src_w
, n
);
1503 swaps(&stuff
->src_h
, n
);
1504 swaps(&stuff
->drw_x
, n
);
1505 swaps(&stuff
->drw_y
, n
);
1506 swaps(&stuff
->drw_w
, n
);
1507 swaps(&stuff
->drw_h
, n
);
1508 swaps(&stuff
->offset
, n
);
1509 swaps(&stuff
->width
, n
);
1510 swaps(&stuff
->height
, n
);
1511 return ProcXvShmPutImage(client
);
1517 SProcXvSelectVideoNotify(ClientPtr client
)
1520 REQUEST(xvSelectVideoNotifyReq
);
1521 swaps(&stuff
->length
, n
);
1522 swapl(&stuff
->drawable
, n
);
1523 return ProcXvSelectVideoNotify(client
);
1527 SProcXvSelectPortNotify(ClientPtr client
)
1530 REQUEST(xvSelectPortNotifyReq
);
1531 swaps(&stuff
->length
, n
);
1532 swapl(&stuff
->port
, n
);
1533 return ProcXvSelectPortNotify(client
);
1537 SProcXvStopVideo(ClientPtr client
)
1540 REQUEST(xvStopVideoReq
);
1541 swaps(&stuff
->length
, n
);
1542 swapl(&stuff
->port
, n
);
1543 swapl(&stuff
->drawable
, n
);
1544 return ProcXvStopVideo(client
);
1548 SProcXvSetPortAttribute(ClientPtr client
)
1551 REQUEST(xvSetPortAttributeReq
);
1552 swaps(&stuff
->length
, n
);
1553 swapl(&stuff
->port
, n
);
1554 swapl(&stuff
->attribute
, n
);
1555 return ProcXvSetPortAttribute(client
);
1559 SProcXvGetPortAttribute(ClientPtr client
)
1562 REQUEST(xvGetPortAttributeReq
);
1563 swaps(&stuff
->length
, n
);
1564 swapl(&stuff
->port
, n
);
1565 swapl(&stuff
->attribute
, n
);
1566 return ProcXvGetPortAttribute(client
);
1570 SProcXvQueryBestSize(ClientPtr client
)
1573 REQUEST(xvQueryBestSizeReq
);
1574 swaps(&stuff
->length
, n
);
1575 swapl(&stuff
->port
, n
);
1576 swaps(&stuff
->vid_w
, n
);
1577 swaps(&stuff
->vid_h
, n
);
1578 swaps(&stuff
->drw_w
, n
);
1579 swaps(&stuff
->drw_h
, n
);
1580 return ProcXvQueryBestSize(client
);
1584 SProcXvQueryPortAttributes(ClientPtr client
)
1587 REQUEST(xvQueryPortAttributesReq
);
1588 swaps(&stuff
->length
, n
);
1589 swapl(&stuff
->port
, n
);
1590 return ProcXvQueryPortAttributes(client
);
1594 SProcXvQueryImageAttributes(ClientPtr client
)
1597 REQUEST(xvQueryImageAttributesReq
);
1598 swaps(&stuff
->length
, n
);
1599 swapl(&stuff
->id
, n
);
1600 swaps(&stuff
->width
, n
);
1601 swaps(&stuff
->width
, n
);
1602 return ProcXvQueryImageAttributes(client
);
1606 SProcXvListImageFormats(ClientPtr client
)
1609 REQUEST(xvListImageFormatsReq
);
1610 swaps(&stuff
->length
, n
);
1611 swapl(&stuff
->port
, n
);
1612 return ProcXvListImageFormats(client
);
1617 SWriteQueryExtensionReply(
1619 xvQueryExtensionReply
*rep
1623 swaps(&rep
->sequenceNumber
, n
);
1624 swapl(&rep
->length
, n
);
1625 swaps(&rep
->version
, n
);
1626 swaps(&rep
->revision
, n
);
1628 (void)WriteToClient(client
, sz_xvQueryExtensionReply
, (char *)&rep
);
1634 SWriteQueryAdaptorsReply(
1636 xvQueryAdaptorsReply
*rep
1640 swaps(&rep
->sequenceNumber
, n
);
1641 swapl(&rep
->length
, n
);
1642 swaps(&rep
->num_adaptors
, n
);
1644 (void)WriteToClient(client
, sz_xvQueryAdaptorsReply
, (char *)&rep
);
1650 SWriteQueryEncodingsReply(
1652 xvQueryEncodingsReply
*rep
1656 swaps(&rep
->sequenceNumber
, n
);
1657 swapl(&rep
->length
, n
);
1658 swaps(&rep
->num_encodings
, n
);
1660 (void)WriteToClient(client
, sz_xvQueryEncodingsReply
, (char *)&rep
);
1668 xvAdaptorInfo
*pAdaptor
1672 swapl(&pAdaptor
->base_id
, n
);
1673 swaps(&pAdaptor
->name_size
, n
);
1674 swaps(&pAdaptor
->num_ports
, n
);
1675 swaps(&pAdaptor
->num_formats
, n
);
1677 (void)WriteToClient(client
, sz_xvAdaptorInfo
, (char *)pAdaptor
);
1685 xvEncodingInfo
*pEncoding
1689 swapl(&pEncoding
->encoding
, n
);
1690 swaps(&pEncoding
->name_size
, n
);
1691 swaps(&pEncoding
->width
, n
);
1692 swaps(&pEncoding
->height
, n
);
1693 swapl(&pEncoding
->rate
.numerator
, n
);
1694 swapl(&pEncoding
->rate
.denominator
, n
);
1695 (void)WriteToClient(client
, sz_xvEncodingInfo
, (char *)pEncoding
);
1707 swapl(&pFormat
->visual
, n
);
1708 (void)WriteToClient(client
, sz_xvFormat
, (char *)pFormat
);
1714 SWriteAttributeInfo(
1716 xvAttributeInfo
*pAtt
1720 swapl(&pAtt
->flags
, n
);
1721 swapl(&pAtt
->size
, n
);
1722 swapl(&pAtt
->min
, n
);
1723 swapl(&pAtt
->max
, n
);
1724 (void)WriteToClient(client
, sz_xvAttributeInfo
, (char *)pAtt
);
1730 SWriteImageFormatInfo(
1732 xvImageFormatInfo
*pImage
1736 swapl(&pImage
->id
, n
);
1737 swapl(&pImage
->red_mask
, n
);
1738 swapl(&pImage
->green_mask
, n
);
1739 swapl(&pImage
->blue_mask
, n
);
1740 swapl(&pImage
->y_sample_bits
, n
);
1741 swapl(&pImage
->u_sample_bits
, n
);
1742 swapl(&pImage
->v_sample_bits
, n
);
1743 swapl(&pImage
->horz_y_period
, n
);
1744 swapl(&pImage
->horz_u_period
, n
);
1745 swapl(&pImage
->horz_v_period
, n
);
1746 swapl(&pImage
->vert_y_period
, n
);
1747 swapl(&pImage
->vert_u_period
, n
);
1748 swapl(&pImage
->vert_v_period
, n
);
1750 (void)WriteToClient(client
, sz_xvImageFormatInfo
, (char *)pImage
);
1758 SWriteGrabPortReply(
1760 xvGrabPortReply
*rep
1764 swaps(&rep
->sequenceNumber
, n
);
1765 swapl(&rep
->length
, n
);
1767 (void)WriteToClient(client
, sz_xvGrabPortReply
, (char *)&rep
);
1773 SWriteGetPortAttributeReply(
1775 xvGetPortAttributeReply
*rep
1779 swaps(&rep
->sequenceNumber
, n
);
1780 swapl(&rep
->length
, n
);
1781 swapl(&rep
->value
, n
);
1783 (void)WriteToClient(client
, sz_xvGetPortAttributeReply
, (char *)&rep
);
1789 SWriteQueryBestSizeReply(
1791 xvQueryBestSizeReply
*rep
1795 swaps(&rep
->sequenceNumber
, n
);
1796 swapl(&rep
->length
, n
);
1797 swaps(&rep
->actual_width
, n
);
1798 swaps(&rep
->actual_height
, n
);
1800 (void)WriteToClient(client
, sz_xvQueryBestSizeReply
, (char *)&rep
);
1806 SWriteQueryPortAttributesReply(
1808 xvQueryPortAttributesReply
*rep
1812 swaps(&rep
->sequenceNumber
, n
);
1813 swapl(&rep
->length
, n
);
1814 swapl(&rep
->num_attributes
, n
);
1815 swapl(&rep
->text_size
, n
);
1817 (void)WriteToClient(client
, sz_xvQueryPortAttributesReply
, (char *)&rep
);
1823 SWriteQueryImageAttributesReply(
1825 xvQueryImageAttributesReply
*rep
1829 swaps(&rep
->sequenceNumber
, n
);
1830 swapl(&rep
->length
, n
);
1831 swapl(&rep
->num_planes
, n
);
1832 swapl(&rep
->data_size
, n
);
1833 swaps(&rep
->width
, n
);
1834 swaps(&rep
->height
, n
);
1836 (void)WriteToClient(client
, sz_xvQueryImageAttributesReply
, (char *)&rep
);
1843 SWriteListImageFormatsReply(
1845 xvListImageFormatsReply
*rep
1849 swaps(&rep
->sequenceNumber
, n
);
1850 swapl(&rep
->length
, n
);
1851 swapl(&rep
->num_formats
, n
);
1853 (void)WriteToClient(client
, sz_xvListImageFormatsReply
, (char *)&rep
);
1865 XineramaXvStopVideo(ClientPtr client
)
1867 int result
= Success
, i
;
1868 PanoramiXRes
*draw
, *port
;
1869 REQUEST(xvStopVideoReq
);
1870 REQUEST_SIZE_MATCH(xvStopVideoReq
);
1872 if(!(draw
= (PanoramiXRes
*)SecurityLookupIDByClass(
1873 client
, stuff
->drawable
, XRC_DRAWABLE
, DixWriteAccess
)))
1876 if(!(port
= (PanoramiXRes
*)SecurityLookupIDByType(
1877 client
, stuff
->port
, XvXRTPort
, DixReadAccess
)))
1880 FOR_NSCREENS_BACKWARD(i
) {
1881 if(port
->info
[i
].id
) {
1882 stuff
->drawable
= draw
->info
[i
].id
;
1883 stuff
->port
= port
->info
[i
].id
;
1884 result
= ProcXvStopVideo(client
);
1892 XineramaXvSetPortAttribute(ClientPtr client
)
1894 REQUEST(xvSetPortAttributeReq
);
1896 int result
= Success
, i
;
1898 REQUEST_SIZE_MATCH(xvSetPortAttributeReq
);
1900 if(!(port
= (PanoramiXRes
*)SecurityLookupIDByType(
1901 client
, stuff
->port
, XvXRTPort
, DixReadAccess
)))
1904 FOR_NSCREENS_BACKWARD(i
) {
1905 if(port
->info
[i
].id
) {
1906 stuff
->port
= port
->info
[i
].id
;
1907 result
= ProcXvSetPortAttribute(client
);
1916 XineramaXvShmPutImage(ClientPtr client
)
1918 REQUEST(xvShmPutImageReq
);
1919 PanoramiXRes
*draw
, *gc
, *port
;
1920 Bool send_event
= stuff
->send_event
;
1922 int result
= Success
, i
, x
, y
;
1924 REQUEST_SIZE_MATCH(xvShmPutImageReq
);
1926 if(!(draw
= (PanoramiXRes
*)SecurityLookupIDByClass(
1927 client
, stuff
->drawable
, XRC_DRAWABLE
, DixWriteAccess
)))
1930 if(!(gc
= (PanoramiXRes
*)SecurityLookupIDByType(
1931 client
, stuff
->gc
, XRT_GC
, DixReadAccess
)))
1934 if(!(port
= (PanoramiXRes
*)SecurityLookupIDByType(
1935 client
, stuff
->port
, XvXRTPort
, DixReadAccess
)))
1938 isRoot
= (draw
->type
== XRT_WINDOW
) && draw
->u
.win
.root
;
1943 FOR_NSCREENS_BACKWARD(i
) {
1944 if(port
->info
[i
].id
) {
1945 stuff
->drawable
= draw
->info
[i
].id
;
1946 stuff
->port
= port
->info
[i
].id
;
1947 stuff
->gc
= gc
->info
[i
].id
;
1951 stuff
->drw_x
-= panoramiXdataPtr
[i
].x
;
1952 stuff
->drw_y
-= panoramiXdataPtr
[i
].y
;
1954 stuff
->send_event
= (send_event
&& !i
) ? 1 : 0;
1956 result
= ProcXvShmPutImage(client
);
1964 XineramaXvPutImage(ClientPtr client
)
1966 REQUEST(xvPutImageReq
);
1967 PanoramiXRes
*draw
, *gc
, *port
;
1969 int result
= Success
, i
, x
, y
;
1971 REQUEST_AT_LEAST_SIZE(xvPutImageReq
);
1973 if(!(draw
= (PanoramiXRes
*)SecurityLookupIDByClass(
1974 client
, stuff
->drawable
, XRC_DRAWABLE
, DixWriteAccess
)))
1977 if(!(gc
= (PanoramiXRes
*)SecurityLookupIDByType(
1978 client
, stuff
->gc
, XRT_GC
, DixReadAccess
)))
1981 if(!(port
= (PanoramiXRes
*)SecurityLookupIDByType(
1982 client
, stuff
->port
, XvXRTPort
, DixReadAccess
)))
1985 isRoot
= (draw
->type
== XRT_WINDOW
) && draw
->u
.win
.root
;
1990 FOR_NSCREENS_BACKWARD(i
) {
1991 if(port
->info
[i
].id
) {
1992 stuff
->drawable
= draw
->info
[i
].id
;
1993 stuff
->port
= port
->info
[i
].id
;
1994 stuff
->gc
= gc
->info
[i
].id
;
1998 stuff
->drw_x
-= panoramiXdataPtr
[i
].x
;
1999 stuff
->drw_y
-= panoramiXdataPtr
[i
].y
;
2002 result
= ProcXvPutImage(client
);
2009 XineramaXvPutVideo(ClientPtr client
)
2011 REQUEST(xvPutImageReq
);
2012 PanoramiXRes
*draw
, *gc
, *port
;
2014 int result
= Success
, i
, x
, y
;
2016 REQUEST_AT_LEAST_SIZE(xvPutVideoReq
);
2018 if(!(draw
= (PanoramiXRes
*)SecurityLookupIDByClass(
2019 client
, stuff
->drawable
, XRC_DRAWABLE
, DixWriteAccess
)))
2022 if(!(gc
= (PanoramiXRes
*)SecurityLookupIDByType(
2023 client
, stuff
->gc
, XRT_GC
, DixReadAccess
)))
2026 if(!(port
= (PanoramiXRes
*)SecurityLookupIDByType(
2027 client
, stuff
->port
, XvXRTPort
, DixReadAccess
)))
2030 isRoot
= (draw
->type
== XRT_WINDOW
) && draw
->u
.win
.root
;
2035 FOR_NSCREENS_BACKWARD(i
) {
2036 if(port
->info
[i
].id
) {
2037 stuff
->drawable
= draw
->info
[i
].id
;
2038 stuff
->port
= port
->info
[i
].id
;
2039 stuff
->gc
= gc
->info
[i
].id
;
2043 stuff
->drw_x
-= panoramiXdataPtr
[i
].x
;
2044 stuff
->drw_y
-= panoramiXdataPtr
[i
].y
;
2047 result
= ProcXvPutVideo(client
);
2054 XineramaXvPutStill(ClientPtr client
)
2056 REQUEST(xvPutImageReq
);
2057 PanoramiXRes
*draw
, *gc
, *port
;
2059 int result
= Success
, i
, x
, y
;
2061 REQUEST_AT_LEAST_SIZE(xvPutImageReq
);
2063 if(!(draw
= (PanoramiXRes
*)SecurityLookupIDByClass(
2064 client
, stuff
->drawable
, XRC_DRAWABLE
, DixWriteAccess
)))
2067 if(!(gc
= (PanoramiXRes
*)SecurityLookupIDByType(
2068 client
, stuff
->gc
, XRT_GC
, DixReadAccess
)))
2071 if(!(port
= (PanoramiXRes
*)SecurityLookupIDByType(
2072 client
, stuff
->port
, XvXRTPort
, DixReadAccess
)))
2075 isRoot
= (draw
->type
== XRT_WINDOW
) && draw
->u
.win
.root
;
2080 FOR_NSCREENS_BACKWARD(i
) {
2081 if(port
->info
[i
].id
) {
2082 stuff
->drawable
= draw
->info
[i
].id
;
2083 stuff
->port
= port
->info
[i
].id
;
2084 stuff
->gc
= gc
->info
[i
].id
;
2088 stuff
->drw_x
-= panoramiXdataPtr
[i
].x
;
2089 stuff
->drw_y
-= panoramiXdataPtr
[i
].y
;
2092 result
= ProcXvPutStill(client
);
2099 void XineramifyXv(void)
2101 ScreenPtr pScreen
, screen0
= screenInfo
.screens
[0];
2102 XvScreenPtr xvsp0
= (XvScreenPtr
)screen0
->devPrivates
[XvScreenIndex
].ptr
;
2103 XvAdaptorPtr refAdapt
, pAdapt
;
2104 XvAttributePtr pAttr
;
2106 Bool isOverlay
, hasOverlay
;
2108 XvAdaptorPtr MatchingAdaptors
[MAXSCREENS
];
2111 XvXRTPort
= CreateNewResourceType(XineramaDeleteResource
);
2115 for(i
= 0; i
< xvsp0
->nAdaptors
; i
++) {
2116 refAdapt
= xvsp0
->pAdaptors
+ i
;
2118 bzero(MatchingAdaptors
, sizeof(XvAdaptorPtr
) * MAXSCREENS
);
2120 MatchingAdaptors
[0] = refAdapt
;
2122 if(!(refAdapt
->type
& XvInputMask
)) continue;
2125 for(j
= 0; j
< refAdapt
->nAttributes
; j
++) {
2126 pAttr
= refAdapt
->pAttributes
+ j
;
2127 if(!strcmp(pAttr
->name
, "XV_COLORKEY")) {
2133 for(j
= 1; j
< PanoramiXNumScreens
; j
++) {
2134 pScreen
= screenInfo
.screens
[j
];
2135 xvsp
= (XvScreenPtr
)pScreen
->devPrivates
[XvScreenIndex
].ptr
;
2137 /* Do not try to go on if xv is not supported on this screen */
2138 if (xvsp
==NULL
) continue ;
2140 /* if the adaptor has the same name it's a perfect match */
2141 for(k
= 0; k
< xvsp
->nAdaptors
; k
++) {
2142 pAdapt
= xvsp
->pAdaptors
+ k
;
2143 if(!strcmp(refAdapt
->name
, pAdapt
->name
)) {
2144 MatchingAdaptors
[j
] = pAdapt
;
2148 if(MatchingAdaptors
[j
]) continue; /* found it */
2150 /* otherwise we only look for XvImage adaptors */
2151 if(!(refAdapt
->type
& XvImageMask
)) continue;
2152 if(refAdapt
->nImages
<= 0) continue;
2154 /* prefer overlay/overlay non-overlay/non-overlay pairing */
2155 for(k
= 0; k
< xvsp
->nAdaptors
; k
++) {
2156 pAdapt
= xvsp
->pAdaptors
+ k
;
2157 if((pAdapt
->type
& XvImageMask
) && (pAdapt
->nImages
> 0)) {
2159 for(l
= 0; l
< pAdapt
->nAttributes
; l
++) {
2160 if(!strcmp(pAdapt
->name
, "XV_COLORKEY")) {
2165 if(isOverlay
&& hasOverlay
) {
2166 MatchingAdaptors
[j
] = pAdapt
;
2169 else if(!isOverlay
&& !hasOverlay
) {
2170 MatchingAdaptors
[j
] = pAdapt
;
2176 if(MatchingAdaptors
[j
]) continue; /* found it */
2178 /* but we'll take any XvImage pairing if we can get it */
2180 for(k
= 0; k
< xvsp
->nAdaptors
; k
++) {
2181 pAdapt
= xvsp
->pAdaptors
+ k
;
2182 if((pAdapt
->type
& XvImageMask
) && (pAdapt
->nImages
> 0)) {
2183 MatchingAdaptors
[j
] = pAdapt
;
2189 /* now create a resource for each port */
2190 for(j
= 0; j
< refAdapt
->nPorts
; j
++) {
2191 if(!(port
= xalloc(sizeof(PanoramiXRes
))))
2193 port
->info
[0].id
= MatchingAdaptors
[0]->base_id
+ j
;
2194 AddResource(port
->info
[0].id
, XvXRTPort
, port
);
2196 for(k
= 1; k
< PanoramiXNumScreens
; k
++) {
2197 if(MatchingAdaptors
[k
] && (MatchingAdaptors
[k
]->nPorts
> j
))
2198 port
->info
[k
].id
= MatchingAdaptors
[k
]->base_id
+ j
;
2200 port
->info
[k
].id
= 0;