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
22 ******************************************************************/
24 #ifdef HAVE_DIX_CONFIG_H
25 #include <dix-config.h>
31 #include <X11/Xproto.h>
33 #include "scrnintstr.h"
34 #include "windowstr.h"
35 #include "pixmapstr.h"
37 #include "dixstruct.h"
41 #include <X11/extensions/Xv.h>
42 #include <X11/extensions/Xvproto.h>
45 #include <X11/extensions/shmproto.h>
52 #include "panoramiX.h"
53 #include "panoramiXsrv.h"
55 unsigned long XvXRTPort
;
59 SWriteQueryExtensionReply(ClientPtr client
, xvQueryExtensionReply
* rep
)
61 swaps(&rep
->sequenceNumber
);
64 swaps(&rep
->revision
);
66 WriteToClient(client
, sz_xvQueryExtensionReply
, rep
);
72 SWriteQueryAdaptorsReply(ClientPtr client
, xvQueryAdaptorsReply
* rep
)
74 swaps(&rep
->sequenceNumber
);
76 swaps(&rep
->num_adaptors
);
78 WriteToClient(client
, sz_xvQueryAdaptorsReply
, rep
);
84 SWriteQueryEncodingsReply(ClientPtr client
, xvQueryEncodingsReply
* rep
)
86 swaps(&rep
->sequenceNumber
);
88 swaps(&rep
->num_encodings
);
90 WriteToClient(client
, sz_xvQueryEncodingsReply
, rep
);
96 SWriteAdaptorInfo(ClientPtr client
, xvAdaptorInfo
* pAdaptor
)
98 swapl(&pAdaptor
->base_id
);
99 swaps(&pAdaptor
->name_size
);
100 swaps(&pAdaptor
->num_ports
);
101 swaps(&pAdaptor
->num_formats
);
103 WriteToClient(client
, sz_xvAdaptorInfo
, pAdaptor
);
109 SWriteEncodingInfo(ClientPtr client
, xvEncodingInfo
* pEncoding
)
112 swapl(&pEncoding
->encoding
);
113 swaps(&pEncoding
->name_size
);
114 swaps(&pEncoding
->width
);
115 swaps(&pEncoding
->height
);
116 swapl(&pEncoding
->rate
.numerator
);
117 swapl(&pEncoding
->rate
.denominator
);
118 WriteToClient(client
, sz_xvEncodingInfo
, pEncoding
);
124 SWriteFormat(ClientPtr client
, xvFormat
* pFormat
)
126 swapl(&pFormat
->visual
);
127 WriteToClient(client
, sz_xvFormat
, pFormat
);
133 SWriteAttributeInfo(ClientPtr client
, xvAttributeInfo
* pAtt
)
139 WriteToClient(client
, sz_xvAttributeInfo
, pAtt
);
145 SWriteImageFormatInfo(ClientPtr client
, xvImageFormatInfo
* pImage
)
148 swapl(&pImage
->red_mask
);
149 swapl(&pImage
->green_mask
);
150 swapl(&pImage
->blue_mask
);
151 swapl(&pImage
->y_sample_bits
);
152 swapl(&pImage
->u_sample_bits
);
153 swapl(&pImage
->v_sample_bits
);
154 swapl(&pImage
->horz_y_period
);
155 swapl(&pImage
->horz_u_period
);
156 swapl(&pImage
->horz_v_period
);
157 swapl(&pImage
->vert_y_period
);
158 swapl(&pImage
->vert_u_period
);
159 swapl(&pImage
->vert_v_period
);
161 WriteToClient(client
, sz_xvImageFormatInfo
, pImage
);
167 SWriteGrabPortReply(ClientPtr client
, xvGrabPortReply
* rep
)
169 swaps(&rep
->sequenceNumber
);
172 WriteToClient(client
, sz_xvGrabPortReply
, rep
);
178 SWriteGetPortAttributeReply(ClientPtr client
, xvGetPortAttributeReply
* rep
)
180 swaps(&rep
->sequenceNumber
);
184 WriteToClient(client
, sz_xvGetPortAttributeReply
, rep
);
190 SWriteQueryBestSizeReply(ClientPtr client
, xvQueryBestSizeReply
* rep
)
192 swaps(&rep
->sequenceNumber
);
194 swaps(&rep
->actual_width
);
195 swaps(&rep
->actual_height
);
197 WriteToClient(client
, sz_xvQueryBestSizeReply
, rep
);
203 SWriteQueryPortAttributesReply(ClientPtr client
,
204 xvQueryPortAttributesReply
* rep
)
206 swaps(&rep
->sequenceNumber
);
208 swapl(&rep
->num_attributes
);
209 swapl(&rep
->text_size
);
211 WriteToClient(client
, sz_xvQueryPortAttributesReply
, rep
);
217 SWriteQueryImageAttributesReply(ClientPtr client
,
218 xvQueryImageAttributesReply
* rep
)
220 swaps(&rep
->sequenceNumber
);
222 swapl(&rep
->num_planes
);
223 swapl(&rep
->data_size
);
227 WriteToClient(client
, sz_xvQueryImageAttributesReply
, rep
);
233 SWriteListImageFormatsReply(ClientPtr client
, xvListImageFormatsReply
* rep
)
235 swaps(&rep
->sequenceNumber
);
237 swapl(&rep
->num_formats
);
239 WriteToClient(client
, sz_xvListImageFormatsReply
, rep
);
244 #define _WriteQueryAdaptorsReply(_c,_d) \
245 if ((_c)->swapped) SWriteQueryAdaptorsReply(_c, _d); \
246 else WriteToClient(_c, sz_xvQueryAdaptorsReply, _d)
248 #define _WriteQueryExtensionReply(_c,_d) \
249 if ((_c)->swapped) SWriteQueryExtensionReply(_c, _d); \
250 else WriteToClient(_c, sz_xvQueryExtensionReply, _d)
252 #define _WriteQueryEncodingsReply(_c,_d) \
253 if ((_c)->swapped) SWriteQueryEncodingsReply(_c, _d); \
254 else WriteToClient(_c, sz_xvQueryEncodingsReply, _d)
256 #define _WriteAdaptorInfo(_c,_d) \
257 if ((_c)->swapped) SWriteAdaptorInfo(_c, _d); \
258 else WriteToClient(_c, sz_xvAdaptorInfo, _d)
260 #define _WriteAttributeInfo(_c,_d) \
261 if ((_c)->swapped) SWriteAttributeInfo(_c, _d); \
262 else WriteToClient(_c, sz_xvAttributeInfo, _d)
264 #define _WriteEncodingInfo(_c,_d) \
265 if ((_c)->swapped) SWriteEncodingInfo(_c, _d); \
266 else WriteToClient(_c, sz_xvEncodingInfo, _d)
268 #define _WriteFormat(_c,_d) \
269 if ((_c)->swapped) SWriteFormat(_c, _d); \
270 else WriteToClient(_c, sz_xvFormat, _d)
272 #define _WriteGrabPortReply(_c,_d) \
273 if ((_c)->swapped) SWriteGrabPortReply(_c, _d); \
274 else WriteToClient(_c, sz_xvGrabPortReply, _d)
276 #define _WriteGetPortAttributeReply(_c,_d) \
277 if ((_c)->swapped) SWriteGetPortAttributeReply(_c, _d); \
278 else WriteToClient(_c, sz_xvGetPortAttributeReply, _d)
280 #define _WriteQueryBestSizeReply(_c,_d) \
281 if ((_c)->swapped) SWriteQueryBestSizeReply(_c, _d); \
282 else WriteToClient(_c, sz_xvQueryBestSizeReply, _d)
284 #define _WriteQueryPortAttributesReply(_c,_d) \
285 if ((_c)->swapped) SWriteQueryPortAttributesReply(_c, _d); \
286 else WriteToClient(_c, sz_xvQueryPortAttributesReply, _d)
288 #define _WriteQueryImageAttributesReply(_c,_d) \
289 if ((_c)->swapped) SWriteQueryImageAttributesReply(_c, _d); \
290 else WriteToClient(_c, sz_xvQueryImageAttributesReply, _d)
292 #define _WriteListImageFormatsReply(_c,_d) \
293 if ((_c)->swapped) SWriteListImageFormatsReply(_c, _d); \
294 else WriteToClient(_c, sz_xvListImageFormatsReply, _d)
296 #define _WriteImageFormatInfo(_c,_d) \
297 if ((_c)->swapped) SWriteImageFormatInfo(_c, _d); \
298 else WriteToClient(_c, sz_xvImageFormatInfo, _d)
300 #define _AllocatePort(_i,_p) \
301 ((_p)->id != _i) ? (* (_p)->pAdaptor->ddAllocatePort)(_i,_p,&_p) : Success
304 ProcXvQueryExtension(ClientPtr client
)
306 xvQueryExtensionReply rep
= {
308 .sequenceNumber
= client
->sequence
,
310 .version
= XvVersion
,
311 .revision
= XvRevision
314 /* REQUEST(xvQueryExtensionReq); */
315 REQUEST_SIZE_MATCH(xvQueryExtensionReq
);
317 _WriteQueryExtensionReply(client
, &rep
);
323 ProcXvQueryAdaptors(ClientPtr client
)
327 xvQueryAdaptorsReply rep
;
328 int totalSize
, na
, nf
, rc
;
336 REQUEST(xvQueryAdaptorsReq
);
337 REQUEST_SIZE_MATCH(xvQueryAdaptorsReq
);
339 rc
= dixLookupWindow(&pWin
, stuff
->window
, client
, DixGetAttrAccess
);
343 pScreen
= pWin
->drawable
.pScreen
;
344 pxvs
= (XvScreenPtr
) dixLookupPrivate(&pScreen
->devPrivates
,
347 rep
= (xvQueryAdaptorsReply
) {
349 .sequenceNumber
= client
->sequence
,
354 _WriteQueryAdaptorsReply(client
, &rep
);
359 (*pxvs
->ddQueryAdaptors
) (pScreen
, &pxvs
->pAdaptors
, &pxvs
->nAdaptors
);
361 rep
= (xvQueryAdaptorsReply
) {
363 .sequenceNumber
= client
->sequence
,
364 .num_adaptors
= pxvs
->nAdaptors
367 /* CALCULATE THE TOTAL SIZE OF THE REPLY IN BYTES */
369 totalSize
= pxvs
->nAdaptors
* sz_xvAdaptorInfo
;
371 /* FOR EACH ADPATOR ADD UP THE BYTES FOR ENCODINGS AND FORMATS */
373 na
= pxvs
->nAdaptors
;
374 pa
= pxvs
->pAdaptors
;
376 totalSize
+= pad_to_int32(strlen(pa
->name
));
377 totalSize
+= pa
->nFormats
* sz_xvFormat
;
381 rep
.length
= bytes_to_int32(totalSize
);
383 _WriteQueryAdaptorsReply(client
, &rep
);
385 na
= pxvs
->nAdaptors
;
386 pa
= pxvs
->pAdaptors
;
389 ainfo
.base_id
= pa
->base_id
;
390 ainfo
.num_ports
= pa
->nPorts
;
391 ainfo
.type
= pa
->type
;
392 ainfo
.name_size
= nameSize
= strlen(pa
->name
);
393 ainfo
.num_formats
= pa
->nFormats
;
395 _WriteAdaptorInfo(client
, &ainfo
);
397 WriteToClient(client
, nameSize
, pa
->name
);
402 format
.depth
= pf
->depth
;
403 format
.visual
= pf
->visual
;
404 _WriteFormat(client
, &format
);
416 ProcXvQueryEncodings(ClientPtr client
)
418 xvEncodingInfo einfo
;
419 xvQueryEncodingsReply rep
;
427 REQUEST(xvQueryEncodingsReq
);
428 REQUEST_SIZE_MATCH(xvQueryEncodingsReq
);
430 VALIDATE_XV_PORT(stuff
->port
, pPort
, DixReadAccess
);
432 if ((status
= _AllocatePort(stuff
->port
, pPort
)) != Success
) {
433 client
->errorValue
= stuff
->port
;
437 rep
= (xvQueryEncodingsReply
) {
439 .sequenceNumber
= client
->sequence
,
440 .num_encodings
= pPort
->pAdaptor
->nEncodings
443 /* FOR EACH ENCODING ADD UP THE BYTES FOR ENCODING NAMES */
445 ne
= pPort
->pAdaptor
->nEncodings
;
446 pe
= pPort
->pAdaptor
->pEncodings
;
447 totalSize
= ne
* sz_xvEncodingInfo
;
449 totalSize
+= pad_to_int32(strlen(pe
->name
));
453 rep
.length
= bytes_to_int32(totalSize
);
455 _WriteQueryEncodingsReply(client
, &rep
);
457 ne
= pPort
->pAdaptor
->nEncodings
;
458 pe
= pPort
->pAdaptor
->pEncodings
;
460 einfo
.encoding
= pe
->id
;
461 einfo
.name_size
= nameSize
= strlen(pe
->name
);
462 einfo
.width
= pe
->width
;
463 einfo
.height
= pe
->height
;
464 einfo
.rate
.numerator
= pe
->rate
.numerator
;
465 einfo
.rate
.denominator
= pe
->rate
.denominator
;
466 _WriteEncodingInfo(client
, &einfo
);
467 WriteToClient(client
, nameSize
, pe
->name
);
475 ProcXvPutVideo(ClientPtr client
)
482 REQUEST(xvPutVideoReq
);
483 REQUEST_SIZE_MATCH(xvPutVideoReq
);
485 VALIDATE_DRAWABLE_AND_GC(stuff
->drawable
, pDraw
, DixWriteAccess
);
486 VALIDATE_XV_PORT(stuff
->port
, pPort
, DixReadAccess
);
488 if ((status
= _AllocatePort(stuff
->port
, pPort
)) != Success
) {
489 client
->errorValue
= stuff
->port
;
493 if (!(pPort
->pAdaptor
->type
& XvInputMask
) ||
494 !(pPort
->pAdaptor
->type
& XvVideoMask
)) {
495 client
->errorValue
= stuff
->port
;
499 status
= XvdiMatchPort(pPort
, pDraw
);
500 if (status
!= Success
) {
504 return XvdiPutVideo(client
, pDraw
, pPort
, pGC
, stuff
->vid_x
, stuff
->vid_y
,
505 stuff
->vid_w
, stuff
->vid_h
, stuff
->drw_x
, stuff
->drw_y
,
506 stuff
->drw_w
, stuff
->drw_h
);
510 ProcXvPutStill(ClientPtr client
)
517 REQUEST(xvPutStillReq
);
518 REQUEST_SIZE_MATCH(xvPutStillReq
);
520 VALIDATE_DRAWABLE_AND_GC(stuff
->drawable
, pDraw
, DixWriteAccess
);
521 VALIDATE_XV_PORT(stuff
->port
, pPort
, DixReadAccess
);
523 if ((status
= _AllocatePort(stuff
->port
, pPort
)) != Success
) {
524 client
->errorValue
= stuff
->port
;
528 if (!(pPort
->pAdaptor
->type
& XvInputMask
) ||
529 !(pPort
->pAdaptor
->type
& XvStillMask
)) {
530 client
->errorValue
= stuff
->port
;
534 status
= XvdiMatchPort(pPort
, pDraw
);
535 if (status
!= Success
) {
539 return XvdiPutStill(client
, pDraw
, pPort
, pGC
, stuff
->vid_x
, stuff
->vid_y
,
540 stuff
->vid_w
, stuff
->vid_h
, stuff
->drw_x
, stuff
->drw_y
,
541 stuff
->drw_w
, stuff
->drw_h
);
545 ProcXvGetVideo(ClientPtr client
)
552 REQUEST(xvGetVideoReq
);
553 REQUEST_SIZE_MATCH(xvGetVideoReq
);
555 VALIDATE_DRAWABLE_AND_GC(stuff
->drawable
, pDraw
, DixReadAccess
);
556 VALIDATE_XV_PORT(stuff
->port
, pPort
, DixReadAccess
);
558 if ((status
= _AllocatePort(stuff
->port
, pPort
)) != Success
) {
559 client
->errorValue
= stuff
->port
;
563 if (!(pPort
->pAdaptor
->type
& XvOutputMask
) ||
564 !(pPort
->pAdaptor
->type
& XvVideoMask
)) {
565 client
->errorValue
= stuff
->port
;
569 status
= XvdiMatchPort(pPort
, pDraw
);
570 if (status
!= Success
) {
574 return XvdiGetVideo(client
, pDraw
, pPort
, pGC
, stuff
->vid_x
, stuff
->vid_y
,
575 stuff
->vid_w
, stuff
->vid_h
, stuff
->drw_x
, stuff
->drw_y
,
576 stuff
->drw_w
, stuff
->drw_h
);
580 ProcXvGetStill(ClientPtr client
)
587 REQUEST(xvGetStillReq
);
588 REQUEST_SIZE_MATCH(xvGetStillReq
);
590 VALIDATE_DRAWABLE_AND_GC(stuff
->drawable
, pDraw
, DixReadAccess
);
591 VALIDATE_XV_PORT(stuff
->port
, pPort
, DixReadAccess
);
593 if ((status
= _AllocatePort(stuff
->port
, pPort
)) != Success
) {
594 client
->errorValue
= stuff
->port
;
598 if (!(pPort
->pAdaptor
->type
& XvOutputMask
) ||
599 !(pPort
->pAdaptor
->type
& XvStillMask
)) {
600 client
->errorValue
= stuff
->port
;
604 status
= XvdiMatchPort(pPort
, pDraw
);
605 if (status
!= Success
) {
609 return XvdiGetStill(client
, pDraw
, pPort
, pGC
, stuff
->vid_x
, stuff
->vid_y
,
610 stuff
->vid_w
, stuff
->vid_h
, stuff
->drw_x
, stuff
->drw_y
,
611 stuff
->drw_w
, stuff
->drw_h
);
615 ProcXvSelectVideoNotify(ClientPtr client
)
620 REQUEST(xvSelectVideoNotifyReq
);
621 REQUEST_SIZE_MATCH(xvSelectVideoNotifyReq
);
623 rc
= dixLookupDrawable(&pDraw
, stuff
->drawable
, client
, 0,
628 return XvdiSelectVideoNotify(client
, pDraw
, stuff
->onoff
);
632 ProcXvSelectPortNotify(ClientPtr client
)
637 REQUEST(xvSelectPortNotifyReq
);
638 REQUEST_SIZE_MATCH(xvSelectPortNotifyReq
);
640 VALIDATE_XV_PORT(stuff
->port
, pPort
, DixReadAccess
);
642 if ((status
= _AllocatePort(stuff
->port
, pPort
)) != Success
) {
643 client
->errorValue
= stuff
->port
;
647 return XvdiSelectPortNotify(client
, pPort
, stuff
->onoff
);
651 ProcXvGrabPort(ClientPtr client
)
657 REQUEST(xvGrabPortReq
);
658 REQUEST_SIZE_MATCH(xvGrabPortReq
);
660 VALIDATE_XV_PORT(stuff
->port
, pPort
, DixReadAccess
);
662 if ((status
= _AllocatePort(stuff
->port
, pPort
)) != Success
) {
663 client
->errorValue
= stuff
->port
;
667 status
= XvdiGrabPort(client
, pPort
, stuff
->time
, &result
);
669 if (status
!= Success
) {
672 rep
= (xvGrabPortReply
) {
674 .sequenceNumber
= client
->sequence
,
679 _WriteGrabPortReply(client
, &rep
);
685 ProcXvUngrabPort(ClientPtr client
)
690 REQUEST(xvGrabPortReq
);
691 REQUEST_SIZE_MATCH(xvGrabPortReq
);
693 VALIDATE_XV_PORT(stuff
->port
, pPort
, DixReadAccess
);
695 if ((status
= _AllocatePort(stuff
->port
, pPort
)) != Success
) {
696 client
->errorValue
= stuff
->port
;
700 return XvdiUngrabPort(client
, pPort
, stuff
->time
);
704 ProcXvStopVideo(ClientPtr client
)
710 REQUEST(xvStopVideoReq
);
711 REQUEST_SIZE_MATCH(xvStopVideoReq
);
713 VALIDATE_XV_PORT(stuff
->port
, pPort
, DixReadAccess
);
715 if ((status
= _AllocatePort(stuff
->port
, pPort
)) != Success
) {
716 client
->errorValue
= stuff
->port
;
720 ret
= dixLookupDrawable(&pDraw
, stuff
->drawable
, client
, 0, DixWriteAccess
);
724 return XvdiStopVideo(client
, pPort
, pDraw
);
728 ProcXvSetPortAttribute(ClientPtr client
)
733 REQUEST(xvSetPortAttributeReq
);
734 REQUEST_SIZE_MATCH(xvSetPortAttributeReq
);
736 VALIDATE_XV_PORT(stuff
->port
, pPort
, DixSetAttrAccess
);
738 if ((status
= _AllocatePort(stuff
->port
, pPort
)) != Success
) {
739 client
->errorValue
= stuff
->port
;
743 if (!ValidAtom(stuff
->attribute
)) {
744 client
->errorValue
= stuff
->attribute
;
749 XvdiSetPortAttribute(client
, pPort
, stuff
->attribute
, stuff
->value
);
751 if (status
== BadMatch
)
752 client
->errorValue
= stuff
->attribute
;
754 client
->errorValue
= stuff
->value
;
760 ProcXvGetPortAttribute(ClientPtr client
)
765 xvGetPortAttributeReply rep
;
767 REQUEST(xvGetPortAttributeReq
);
768 REQUEST_SIZE_MATCH(xvGetPortAttributeReq
);
770 VALIDATE_XV_PORT(stuff
->port
, pPort
, DixGetAttrAccess
);
772 if ((status
= _AllocatePort(stuff
->port
, pPort
)) != Success
) {
773 client
->errorValue
= stuff
->port
;
777 if (!ValidAtom(stuff
->attribute
)) {
778 client
->errorValue
= stuff
->attribute
;
782 status
= XvdiGetPortAttribute(client
, pPort
, stuff
->attribute
, &value
);
783 if (status
!= Success
) {
784 client
->errorValue
= stuff
->attribute
;
788 rep
= (xvGetPortAttributeReply
) {
790 .sequenceNumber
= client
->sequence
,
795 _WriteGetPortAttributeReply(client
, &rep
);
801 ProcXvQueryBestSize(ClientPtr client
)
804 unsigned int actual_width
, actual_height
;
806 xvQueryBestSizeReply rep
;
808 REQUEST(xvQueryBestSizeReq
);
809 REQUEST_SIZE_MATCH(xvQueryBestSizeReq
);
811 VALIDATE_XV_PORT(stuff
->port
, pPort
, DixReadAccess
);
813 if ((status
= _AllocatePort(stuff
->port
, pPort
)) != Success
) {
814 client
->errorValue
= stuff
->port
;
818 (*pPort
->pAdaptor
->ddQueryBestSize
) (client
, pPort
, stuff
->motion
,
819 stuff
->vid_w
, stuff
->vid_h
,
820 stuff
->drw_w
, stuff
->drw_h
,
821 &actual_width
, &actual_height
);
823 rep
= (xvQueryBestSizeReply
) {
825 .sequenceNumber
= client
->sequence
,
827 .actual_width
= actual_width
,
828 .actual_height
= actual_height
831 _WriteQueryBestSizeReply(client
, &rep
);
837 ProcXvQueryPortAttributes(ClientPtr client
)
842 xvQueryPortAttributesReply rep
;
843 xvAttributeInfo Info
;
845 REQUEST(xvQueryPortAttributesReq
);
846 REQUEST_SIZE_MATCH(xvQueryPortAttributesReq
);
848 VALIDATE_XV_PORT(stuff
->port
, pPort
, DixGetAttrAccess
);
850 if ((status
= _AllocatePort(stuff
->port
, pPort
)) != Success
) {
851 client
->errorValue
= stuff
->port
;
855 rep
= (xvQueryPortAttributesReply
) {
857 .sequenceNumber
= client
->sequence
,
858 .num_attributes
= pPort
->pAdaptor
->nAttributes
,
862 for (i
= 0, pAtt
= pPort
->pAdaptor
->pAttributes
;
863 i
< pPort
->pAdaptor
->nAttributes
; i
++, pAtt
++) {
864 rep
.text_size
+= pad_to_int32(strlen(pAtt
->name
) + 1);
867 rep
.length
= (pPort
->pAdaptor
->nAttributes
* sz_xvAttributeInfo
)
871 _WriteQueryPortAttributesReply(client
, &rep
);
873 for (i
= 0, pAtt
= pPort
->pAdaptor
->pAttributes
;
874 i
< pPort
->pAdaptor
->nAttributes
; i
++, pAtt
++) {
875 size
= strlen(pAtt
->name
) + 1; /* pass the NULL */
876 Info
.flags
= pAtt
->flags
;
877 Info
.min
= pAtt
->min_value
;
878 Info
.max
= pAtt
->max_value
;
879 Info
.size
= pad_to_int32(size
);
881 _WriteAttributeInfo(client
, &Info
);
883 WriteToClient(client
, size
, pAtt
->name
);
890 ProcXvPutImage(ClientPtr client
)
894 XvImagePtr pImage
= NULL
;
897 CARD16 width
, height
;
899 REQUEST(xvPutImageReq
);
900 REQUEST_AT_LEAST_SIZE(xvPutImageReq
);
902 VALIDATE_DRAWABLE_AND_GC(stuff
->drawable
, pDraw
, DixWriteAccess
);
903 VALIDATE_XV_PORT(stuff
->port
, pPort
, DixReadAccess
);
905 if ((status
= _AllocatePort(stuff
->port
, pPort
)) != Success
) {
906 client
->errorValue
= stuff
->port
;
910 if (!(pPort
->pAdaptor
->type
& XvImageMask
) ||
911 !(pPort
->pAdaptor
->type
& XvInputMask
)) {
912 client
->errorValue
= stuff
->port
;
916 status
= XvdiMatchPort(pPort
, pDraw
);
917 if (status
!= Success
) {
921 for (i
= 0; i
< pPort
->pAdaptor
->nImages
; i
++) {
922 if (pPort
->pAdaptor
->pImages
[i
].id
== stuff
->id
) {
923 pImage
= &(pPort
->pAdaptor
->pImages
[i
]);
931 width
= stuff
->width
;
932 height
= stuff
->height
;
933 size
= (*pPort
->pAdaptor
->ddQueryImageAttributes
) (client
,
934 pPort
, pImage
, &width
,
935 &height
, NULL
, NULL
);
936 size
+= sizeof(xvPutImageReq
);
937 size
= bytes_to_int32(size
);
939 if ((width
< stuff
->width
) || (height
< stuff
->height
))
942 if (client
->req_len
< size
)
945 return XvdiPutImage(client
, pDraw
, pPort
, pGC
, stuff
->src_x
, stuff
->src_y
,
946 stuff
->src_w
, stuff
->src_h
, stuff
->drw_x
, stuff
->drw_y
,
947 stuff
->drw_w
, stuff
->drw_h
, pImage
,
948 (unsigned char *) (&stuff
[1]), FALSE
,
949 stuff
->width
, stuff
->height
);
955 ProcXvShmPutImage(ClientPtr client
)
960 XvImagePtr pImage
= NULL
;
962 int status
, size_needed
, i
;
963 CARD16 width
, height
;
965 REQUEST(xvShmPutImageReq
);
966 REQUEST_SIZE_MATCH(xvShmPutImageReq
);
968 VALIDATE_DRAWABLE_AND_GC(stuff
->drawable
, pDraw
, DixWriteAccess
);
969 VALIDATE_XV_PORT(stuff
->port
, pPort
, DixReadAccess
);
971 if ((status
= _AllocatePort(stuff
->port
, pPort
)) != Success
) {
972 client
->errorValue
= stuff
->port
;
976 if (!(pPort
->pAdaptor
->type
& XvImageMask
) ||
977 !(pPort
->pAdaptor
->type
& XvInputMask
)) {
978 client
->errorValue
= stuff
->port
;
982 status
= XvdiMatchPort(pPort
, pDraw
);
983 if (status
!= Success
) {
987 for (i
= 0; i
< pPort
->pAdaptor
->nImages
; i
++) {
988 if (pPort
->pAdaptor
->pImages
[i
].id
== stuff
->id
) {
989 pImage
= &(pPort
->pAdaptor
->pImages
[i
]);
997 status
= dixLookupResourceByType((pointer
*) &shmdesc
, stuff
->shmseg
,
998 ShmSegType
, serverClient
, DixReadAccess
);
999 if (status
!= Success
)
1002 width
= stuff
->width
;
1003 height
= stuff
->height
;
1004 size_needed
= (*pPort
->pAdaptor
->ddQueryImageAttributes
) (client
,
1008 if ((size_needed
+ stuff
->offset
) > shmdesc
->size
)
1011 if ((width
< stuff
->width
) || (height
< stuff
->height
))
1014 status
= XvdiPutImage(client
, pDraw
, pPort
, pGC
, stuff
->src_x
, stuff
->src_y
,
1015 stuff
->src_w
, stuff
->src_h
, stuff
->drw_x
,
1016 stuff
->drw_y
, stuff
->drw_w
, stuff
->drw_h
, pImage
,
1017 (unsigned char *) shmdesc
->addr
+ stuff
->offset
,
1018 stuff
->send_event
, stuff
->width
, stuff
->height
);
1020 if ((status
== Success
) && stuff
->send_event
) {
1021 xShmCompletionEvent ev
= {
1022 .type
= ShmCompletionCode
,
1023 .drawable
= stuff
->drawable
,
1024 .minorEvent
= xv_ShmPutImage
,
1025 .majorEvent
= XvReqCode
,
1026 .shmseg
= stuff
->shmseg
,
1027 .offset
= stuff
->offset
1029 WriteEventsToClient(client
, 1, (xEvent
*) &ev
);
1036 ProcXvShmPutImage(ClientPtr client
)
1038 SendErrorToClient(client
, XvReqCode
, xv_ShmPutImage
, 0, BadImplementation
);
1039 return BadImplementation
;
1043 #ifdef XvMCExtension
1044 #include "xvmcext.h"
1048 ProcXvQueryImageAttributes(ClientPtr client
)
1050 xvQueryImageAttributesReply rep
;
1051 int size
, num_planes
, i
;
1052 CARD16 width
, height
;
1053 XvImagePtr pImage
= NULL
;
1059 REQUEST(xvQueryImageAttributesReq
);
1061 REQUEST_SIZE_MATCH(xvQueryImageAttributesReq
);
1063 VALIDATE_XV_PORT(stuff
->port
, pPort
, DixReadAccess
);
1065 for (i
= 0; i
< pPort
->pAdaptor
->nImages
; i
++) {
1066 if (pPort
->pAdaptor
->pImages
[i
].id
== stuff
->id
) {
1067 pImage
= &(pPort
->pAdaptor
->pImages
[i
]);
1072 #ifdef XvMCExtension
1074 pImage
= XvMCFindXvImage(pPort
, stuff
->id
);
1080 num_planes
= pImage
->num_planes
;
1082 if (!(offsets
= malloc(num_planes
<< 3)))
1084 pitches
= offsets
+ num_planes
;
1086 width
= stuff
->width
;
1087 height
= stuff
->height
;
1089 size
= (*pPort
->pAdaptor
->ddQueryImageAttributes
) (client
, pPort
, pImage
,
1090 &width
, &height
, offsets
,
1093 rep
= (xvQueryImageAttributesReply
) {
1095 .sequenceNumber
= client
->sequence
,
1096 .length
= planeLength
= num_planes
<< 1,
1097 .num_planes
= num_planes
,
1103 _WriteQueryImageAttributesReply(client
, &rep
);
1104 if (client
->swapped
)
1105 SwapLongs((CARD32
*) offsets
, planeLength
);
1106 WriteToClient(client
, planeLength
<< 2, offsets
);
1114 ProcXvListImageFormats(ClientPtr client
)
1119 xvListImageFormatsReply rep
;
1120 xvImageFormatInfo info
;
1122 REQUEST(xvListImageFormatsReq
);
1124 REQUEST_SIZE_MATCH(xvListImageFormatsReq
);
1126 VALIDATE_XV_PORT(stuff
->port
, pPort
, DixReadAccess
);
1128 rep
= (xvListImageFormatsReply
) {
1130 .sequenceNumber
= client
->sequence
,
1131 .num_formats
= pPort
->pAdaptor
->nImages
,
1133 bytes_to_int32(pPort
->pAdaptor
->nImages
* sz_xvImageFormatInfo
)
1136 _WriteListImageFormatsReply(client
, &rep
);
1138 pImage
= pPort
->pAdaptor
->pImages
;
1140 for (i
= 0; i
< pPort
->pAdaptor
->nImages
; i
++, pImage
++) {
1141 info
.id
= pImage
->id
;
1142 info
.type
= pImage
->type
;
1143 info
.byte_order
= pImage
->byte_order
;
1144 memcpy(&info
.guid
, pImage
->guid
, 16);
1145 info
.bpp
= pImage
->bits_per_pixel
;
1146 info
.num_planes
= pImage
->num_planes
;
1147 info
.depth
= pImage
->depth
;
1148 info
.red_mask
= pImage
->red_mask
;
1149 info
.green_mask
= pImage
->green_mask
;
1150 info
.blue_mask
= pImage
->blue_mask
;
1151 info
.format
= pImage
->format
;
1152 info
.y_sample_bits
= pImage
->y_sample_bits
;
1153 info
.u_sample_bits
= pImage
->u_sample_bits
;
1154 info
.v_sample_bits
= pImage
->v_sample_bits
;
1155 info
.horz_y_period
= pImage
->horz_y_period
;
1156 info
.horz_u_period
= pImage
->horz_u_period
;
1157 info
.horz_v_period
= pImage
->horz_v_period
;
1158 info
.vert_y_period
= pImage
->vert_y_period
;
1159 info
.vert_u_period
= pImage
->vert_u_period
;
1160 info
.vert_v_period
= pImage
->vert_v_period
;
1161 memcpy(&info
.comp_order
, pImage
->component_order
, 32);
1162 info
.scanline_order
= pImage
->scanline_order
;
1163 _WriteImageFormatInfo(client
, &info
);
1169 static int (*XvProcVector
[xvNumRequests
]) (ClientPtr
) = {
1170 ProcXvQueryExtension
,
1171 ProcXvQueryAdaptors
,
1172 ProcXvQueryEncodings
,
1180 ProcXvSelectVideoNotify
,
1181 ProcXvSelectPortNotify
,
1182 ProcXvQueryBestSize
,
1183 ProcXvSetPortAttribute
,
1184 ProcXvGetPortAttribute
,
1185 ProcXvQueryPortAttributes
,
1186 ProcXvListImageFormats
,
1187 ProcXvQueryImageAttributes
, ProcXvPutImage
, ProcXvShmPutImage
,};
1190 ProcXvDispatch(ClientPtr client
)
1194 UpdateCurrentTime();
1196 if (stuff
->data
>= xvNumRequests
) {
1197 SendErrorToClient(client
, XvReqCode
, stuff
->data
, 0, BadRequest
);
1201 return XvProcVector
[stuff
->data
] (client
);
1207 SProcXvQueryExtension(ClientPtr client
)
1209 REQUEST(xvQueryExtensionReq
);
1210 swaps(&stuff
->length
);
1211 return XvProcVector
[xv_QueryExtension
] (client
);
1215 SProcXvQueryAdaptors(ClientPtr client
)
1217 REQUEST(xvQueryAdaptorsReq
);
1218 swaps(&stuff
->length
);
1219 swapl(&stuff
->window
);
1220 return XvProcVector
[xv_QueryAdaptors
] (client
);
1224 SProcXvQueryEncodings(ClientPtr client
)
1226 REQUEST(xvQueryEncodingsReq
);
1227 swaps(&stuff
->length
);
1228 swapl(&stuff
->port
);
1229 return XvProcVector
[xv_QueryEncodings
] (client
);
1233 SProcXvGrabPort(ClientPtr client
)
1235 REQUEST(xvGrabPortReq
);
1236 swaps(&stuff
->length
);
1237 swapl(&stuff
->port
);
1238 swapl(&stuff
->time
);
1239 return XvProcVector
[xv_GrabPort
] (client
);
1243 SProcXvUngrabPort(ClientPtr client
)
1245 REQUEST(xvUngrabPortReq
);
1246 swaps(&stuff
->length
);
1247 swapl(&stuff
->port
);
1248 swapl(&stuff
->time
);
1249 return XvProcVector
[xv_UngrabPort
] (client
);
1253 SProcXvPutVideo(ClientPtr client
)
1255 REQUEST(xvPutVideoReq
);
1256 swaps(&stuff
->length
);
1257 swapl(&stuff
->port
);
1258 swapl(&stuff
->drawable
);
1260 swaps(&stuff
->vid_x
);
1261 swaps(&stuff
->vid_y
);
1262 swaps(&stuff
->vid_w
);
1263 swaps(&stuff
->vid_h
);
1264 swaps(&stuff
->drw_x
);
1265 swaps(&stuff
->drw_y
);
1266 swaps(&stuff
->drw_w
);
1267 swaps(&stuff
->drw_h
);
1268 return XvProcVector
[xv_PutVideo
] (client
);
1272 SProcXvPutStill(ClientPtr client
)
1274 REQUEST(xvPutStillReq
);
1275 swaps(&stuff
->length
);
1276 swapl(&stuff
->port
);
1277 swapl(&stuff
->drawable
);
1279 swaps(&stuff
->vid_x
);
1280 swaps(&stuff
->vid_y
);
1281 swaps(&stuff
->vid_w
);
1282 swaps(&stuff
->vid_h
);
1283 swaps(&stuff
->drw_x
);
1284 swaps(&stuff
->drw_y
);
1285 swaps(&stuff
->drw_w
);
1286 swaps(&stuff
->drw_h
);
1287 return XvProcVector
[xv_PutStill
] (client
);
1291 SProcXvGetVideo(ClientPtr client
)
1293 REQUEST(xvGetVideoReq
);
1294 swaps(&stuff
->length
);
1295 swapl(&stuff
->port
);
1296 swapl(&stuff
->drawable
);
1298 swaps(&stuff
->vid_x
);
1299 swaps(&stuff
->vid_y
);
1300 swaps(&stuff
->vid_w
);
1301 swaps(&stuff
->vid_h
);
1302 swaps(&stuff
->drw_x
);
1303 swaps(&stuff
->drw_y
);
1304 swaps(&stuff
->drw_w
);
1305 swaps(&stuff
->drw_h
);
1306 return XvProcVector
[xv_GetVideo
] (client
);
1310 SProcXvGetStill(ClientPtr client
)
1312 REQUEST(xvGetStillReq
);
1313 swaps(&stuff
->length
);
1314 swapl(&stuff
->port
);
1315 swapl(&stuff
->drawable
);
1317 swaps(&stuff
->vid_x
);
1318 swaps(&stuff
->vid_y
);
1319 swaps(&stuff
->vid_w
);
1320 swaps(&stuff
->vid_h
);
1321 swaps(&stuff
->drw_x
);
1322 swaps(&stuff
->drw_y
);
1323 swaps(&stuff
->drw_w
);
1324 swaps(&stuff
->drw_h
);
1325 return XvProcVector
[xv_GetStill
] (client
);
1329 SProcXvPutImage(ClientPtr client
)
1331 REQUEST(xvPutImageReq
);
1332 swaps(&stuff
->length
);
1333 swapl(&stuff
->port
);
1334 swapl(&stuff
->drawable
);
1337 swaps(&stuff
->src_x
);
1338 swaps(&stuff
->src_y
);
1339 swaps(&stuff
->src_w
);
1340 swaps(&stuff
->src_h
);
1341 swaps(&stuff
->drw_x
);
1342 swaps(&stuff
->drw_y
);
1343 swaps(&stuff
->drw_w
);
1344 swaps(&stuff
->drw_h
);
1345 swaps(&stuff
->width
);
1346 swaps(&stuff
->height
);
1347 return XvProcVector
[xv_PutImage
] (client
);
1352 SProcXvShmPutImage(ClientPtr client
)
1354 REQUEST(xvShmPutImageReq
);
1355 swaps(&stuff
->length
);
1356 swapl(&stuff
->port
);
1357 swapl(&stuff
->drawable
);
1359 swapl(&stuff
->shmseg
);
1361 swapl(&stuff
->offset
);
1362 swaps(&stuff
->src_x
);
1363 swaps(&stuff
->src_y
);
1364 swaps(&stuff
->src_w
);
1365 swaps(&stuff
->src_h
);
1366 swaps(&stuff
->drw_x
);
1367 swaps(&stuff
->drw_y
);
1368 swaps(&stuff
->drw_w
);
1369 swaps(&stuff
->drw_h
);
1370 swaps(&stuff
->width
);
1371 swaps(&stuff
->height
);
1372 return XvProcVector
[xv_ShmPutImage
] (client
);
1375 #define SProcXvShmPutImage ProcXvShmPutImage
1379 SProcXvSelectVideoNotify(ClientPtr client
)
1381 REQUEST(xvSelectVideoNotifyReq
);
1382 swaps(&stuff
->length
);
1383 swapl(&stuff
->drawable
);
1384 return XvProcVector
[xv_SelectVideoNotify
] (client
);
1388 SProcXvSelectPortNotify(ClientPtr client
)
1390 REQUEST(xvSelectPortNotifyReq
);
1391 swaps(&stuff
->length
);
1392 swapl(&stuff
->port
);
1393 return XvProcVector
[xv_SelectPortNotify
] (client
);
1397 SProcXvStopVideo(ClientPtr client
)
1399 REQUEST(xvStopVideoReq
);
1400 swaps(&stuff
->length
);
1401 swapl(&stuff
->port
);
1402 swapl(&stuff
->drawable
);
1403 return XvProcVector
[xv_StopVideo
] (client
);
1407 SProcXvSetPortAttribute(ClientPtr client
)
1409 REQUEST(xvSetPortAttributeReq
);
1410 swaps(&stuff
->length
);
1411 swapl(&stuff
->port
);
1412 swapl(&stuff
->attribute
);
1413 swapl(&stuff
->value
);
1414 return XvProcVector
[xv_SetPortAttribute
] (client
);
1418 SProcXvGetPortAttribute(ClientPtr client
)
1420 REQUEST(xvGetPortAttributeReq
);
1421 swaps(&stuff
->length
);
1422 swapl(&stuff
->port
);
1423 swapl(&stuff
->attribute
);
1424 return XvProcVector
[xv_GetPortAttribute
] (client
);
1428 SProcXvQueryBestSize(ClientPtr client
)
1430 REQUEST(xvQueryBestSizeReq
);
1431 swaps(&stuff
->length
);
1432 swapl(&stuff
->port
);
1433 swaps(&stuff
->vid_w
);
1434 swaps(&stuff
->vid_h
);
1435 swaps(&stuff
->drw_w
);
1436 swaps(&stuff
->drw_h
);
1437 return XvProcVector
[xv_QueryBestSize
] (client
);
1441 SProcXvQueryPortAttributes(ClientPtr client
)
1443 REQUEST(xvQueryPortAttributesReq
);
1444 swaps(&stuff
->length
);
1445 swapl(&stuff
->port
);
1446 return XvProcVector
[xv_QueryPortAttributes
] (client
);
1450 SProcXvQueryImageAttributes(ClientPtr client
)
1452 REQUEST(xvQueryImageAttributesReq
);
1453 swaps(&stuff
->length
);
1454 swapl(&stuff
->port
);
1456 swaps(&stuff
->width
);
1457 swaps(&stuff
->height
);
1458 return XvProcVector
[xv_QueryImageAttributes
] (client
);
1462 SProcXvListImageFormats(ClientPtr client
)
1464 REQUEST(xvListImageFormatsReq
);
1465 swaps(&stuff
->length
);
1466 swapl(&stuff
->port
);
1467 return XvProcVector
[xv_ListImageFormats
] (client
);
1470 static int (*SXvProcVector
[xvNumRequests
]) (ClientPtr
) = {
1471 SProcXvQueryExtension
,
1472 SProcXvQueryAdaptors
,
1473 SProcXvQueryEncodings
,
1481 SProcXvSelectVideoNotify
,
1482 SProcXvSelectPortNotify
,
1483 SProcXvQueryBestSize
,
1484 SProcXvSetPortAttribute
,
1485 SProcXvGetPortAttribute
,
1486 SProcXvQueryPortAttributes
,
1487 SProcXvListImageFormats
,
1488 SProcXvQueryImageAttributes
, SProcXvPutImage
, SProcXvShmPutImage
,};
1491 SProcXvDispatch(ClientPtr client
)
1495 UpdateCurrentTime();
1497 if (stuff
->data
>= xvNumRequests
) {
1498 SendErrorToClient(client
, XvReqCode
, stuff
->data
, 0, BadRequest
);
1502 return SXvProcVector
[stuff
->data
] (client
);
1507 XineramaXvStopVideo(ClientPtr client
)
1510 PanoramiXRes
*draw
, *port
;
1512 REQUEST(xvStopVideoReq
);
1513 REQUEST_SIZE_MATCH(xvStopVideoReq
);
1515 result
= dixLookupResourceByClass((pointer
*) &draw
, stuff
->drawable
,
1516 XRC_DRAWABLE
, client
, DixWriteAccess
);
1517 if (result
!= Success
)
1518 return (result
== BadValue
) ? BadDrawable
: result
;
1520 result
= dixLookupResourceByType((pointer
*) &port
, stuff
->port
,
1521 XvXRTPort
, client
, DixReadAccess
);
1522 if (result
!= Success
)
1525 FOR_NSCREENS_BACKWARD(i
) {
1526 if (port
->info
[i
].id
) {
1527 stuff
->drawable
= draw
->info
[i
].id
;
1528 stuff
->port
= port
->info
[i
].id
;
1529 result
= ProcXvStopVideo(client
);
1537 XineramaXvSetPortAttribute(ClientPtr client
)
1539 REQUEST(xvSetPortAttributeReq
);
1543 REQUEST_SIZE_MATCH(xvSetPortAttributeReq
);
1545 result
= dixLookupResourceByType((pointer
*) &port
, stuff
->port
,
1546 XvXRTPort
, client
, DixReadAccess
);
1547 if (result
!= Success
)
1550 FOR_NSCREENS_BACKWARD(i
) {
1551 if (port
->info
[i
].id
) {
1552 stuff
->port
= port
->info
[i
].id
;
1553 result
= ProcXvSetPortAttribute(client
);
1561 XineramaXvShmPutImage(ClientPtr client
)
1563 REQUEST(xvShmPutImageReq
);
1564 PanoramiXRes
*draw
, *gc
, *port
;
1565 Bool send_event
= stuff
->send_event
;
1567 int result
, i
, x
, y
;
1569 REQUEST_SIZE_MATCH(xvShmPutImageReq
);
1571 result
= dixLookupResourceByClass((pointer
*) &draw
, stuff
->drawable
,
1572 XRC_DRAWABLE
, client
, DixWriteAccess
);
1573 if (result
!= Success
)
1574 return (result
== BadValue
) ? BadDrawable
: result
;
1576 result
= dixLookupResourceByType((pointer
*) &gc
, stuff
->gc
,
1577 XRT_GC
, client
, DixReadAccess
);
1578 if (result
!= Success
)
1581 result
= dixLookupResourceByType((pointer
*) &port
, stuff
->port
,
1582 XvXRTPort
, client
, DixReadAccess
);
1583 if (result
!= Success
)
1586 isRoot
= (draw
->type
== XRT_WINDOW
) && draw
->u
.win
.root
;
1591 FOR_NSCREENS_BACKWARD(i
) {
1592 if (port
->info
[i
].id
) {
1593 stuff
->drawable
= draw
->info
[i
].id
;
1594 stuff
->port
= port
->info
[i
].id
;
1595 stuff
->gc
= gc
->info
[i
].id
;
1599 stuff
->drw_x
-= screenInfo
.screens
[i
]->x
;
1600 stuff
->drw_y
-= screenInfo
.screens
[i
]->y
;
1602 stuff
->send_event
= (send_event
&& !i
) ? 1 : 0;
1604 result
= ProcXvShmPutImage(client
);
1610 #define XineramaXvShmPutImage ProcXvShmPutImage
1614 XineramaXvPutImage(ClientPtr client
)
1616 REQUEST(xvPutImageReq
);
1617 PanoramiXRes
*draw
, *gc
, *port
;
1619 int result
, i
, x
, y
;
1621 REQUEST_AT_LEAST_SIZE(xvPutImageReq
);
1623 result
= dixLookupResourceByClass((pointer
*) &draw
, stuff
->drawable
,
1624 XRC_DRAWABLE
, client
, DixWriteAccess
);
1625 if (result
!= Success
)
1626 return (result
== BadValue
) ? BadDrawable
: result
;
1628 result
= dixLookupResourceByType((pointer
*) &gc
, stuff
->gc
,
1629 XRT_GC
, client
, DixReadAccess
);
1630 if (result
!= Success
)
1633 result
= dixLookupResourceByType((pointer
*) &port
, stuff
->port
,
1634 XvXRTPort
, client
, DixReadAccess
);
1635 if (result
!= Success
)
1638 isRoot
= (draw
->type
== XRT_WINDOW
) && draw
->u
.win
.root
;
1643 FOR_NSCREENS_BACKWARD(i
) {
1644 if (port
->info
[i
].id
) {
1645 stuff
->drawable
= draw
->info
[i
].id
;
1646 stuff
->port
= port
->info
[i
].id
;
1647 stuff
->gc
= gc
->info
[i
].id
;
1651 stuff
->drw_x
-= screenInfo
.screens
[i
]->x
;
1652 stuff
->drw_y
-= screenInfo
.screens
[i
]->y
;
1655 result
= ProcXvPutImage(client
);
1662 XineramaXvPutVideo(ClientPtr client
)
1664 REQUEST(xvPutImageReq
);
1665 PanoramiXRes
*draw
, *gc
, *port
;
1667 int result
, i
, x
, y
;
1669 REQUEST_AT_LEAST_SIZE(xvPutVideoReq
);
1671 result
= dixLookupResourceByClass((pointer
*) &draw
, stuff
->drawable
,
1672 XRC_DRAWABLE
, client
, DixWriteAccess
);
1673 if (result
!= Success
)
1674 return (result
== BadValue
) ? BadDrawable
: result
;
1676 result
= dixLookupResourceByType((pointer
*) &gc
, stuff
->gc
,
1677 XRT_GC
, client
, DixReadAccess
);
1678 if (result
!= Success
)
1681 result
= dixLookupResourceByType((pointer
*) &port
, stuff
->port
,
1682 XvXRTPort
, client
, DixReadAccess
);
1683 if (result
!= Success
)
1686 isRoot
= (draw
->type
== XRT_WINDOW
) && draw
->u
.win
.root
;
1691 FOR_NSCREENS_BACKWARD(i
) {
1692 if (port
->info
[i
].id
) {
1693 stuff
->drawable
= draw
->info
[i
].id
;
1694 stuff
->port
= port
->info
[i
].id
;
1695 stuff
->gc
= gc
->info
[i
].id
;
1699 stuff
->drw_x
-= screenInfo
.screens
[i
]->x
;
1700 stuff
->drw_y
-= screenInfo
.screens
[i
]->y
;
1703 result
= ProcXvPutVideo(client
);
1710 XineramaXvPutStill(ClientPtr client
)
1712 REQUEST(xvPutImageReq
);
1713 PanoramiXRes
*draw
, *gc
, *port
;
1715 int result
, i
, x
, y
;
1717 REQUEST_AT_LEAST_SIZE(xvPutImageReq
);
1719 result
= dixLookupResourceByClass((pointer
*) &draw
, stuff
->drawable
,
1720 XRC_DRAWABLE
, client
, DixWriteAccess
);
1721 if (result
!= Success
)
1722 return (result
== BadValue
) ? BadDrawable
: result
;
1724 result
= dixLookupResourceByType((pointer
*) &gc
, stuff
->gc
,
1725 XRT_GC
, client
, DixReadAccess
);
1726 if (result
!= Success
)
1729 result
= dixLookupResourceByType((pointer
*) &port
, stuff
->port
,
1730 XvXRTPort
, client
, DixReadAccess
);
1731 if (result
!= Success
)
1734 isRoot
= (draw
->type
== XRT_WINDOW
) && draw
->u
.win
.root
;
1739 FOR_NSCREENS_BACKWARD(i
) {
1740 if (port
->info
[i
].id
) {
1741 stuff
->drawable
= draw
->info
[i
].id
;
1742 stuff
->port
= port
->info
[i
].id
;
1743 stuff
->gc
= gc
->info
[i
].id
;
1747 stuff
->drw_x
-= screenInfo
.screens
[i
]->x
;
1748 stuff
->drw_y
-= screenInfo
.screens
[i
]->y
;
1751 result
= ProcXvPutStill(client
);
1758 isImageAdaptor(XvAdaptorPtr pAdapt
)
1760 return (pAdapt
->type
& XvImageMask
) && (pAdapt
->nImages
> 0);
1764 hasOverlay(XvAdaptorPtr pAdapt
)
1768 for (i
= 0; i
< pAdapt
->nAttributes
; i
++)
1769 if (!strcmp(pAdapt
->pAttributes
[i
].name
, "XV_COLORKEY"))
1775 matchAdaptor(ScreenPtr pScreen
, XvAdaptorPtr refAdapt
, Bool isOverlay
)
1779 dixLookupPrivate(&pScreen
->devPrivates
, XvGetScreenKey());
1780 /* Do not try to go on if xv is not supported on this screen */
1784 /* if the adaptor has the same name it's a perfect match */
1785 for (i
= 0; i
< xvsp
->nAdaptors
; i
++) {
1786 XvAdaptorPtr pAdapt
= xvsp
->pAdaptors
+ i
;
1788 if (!strcmp(refAdapt
->name
, pAdapt
->name
))
1792 /* otherwise we only look for XvImage adaptors */
1793 if (!isImageAdaptor(refAdapt
))
1796 /* prefer overlay/overlay non-overlay/non-overlay pairing */
1797 for (i
= 0; i
< xvsp
->nAdaptors
; i
++) {
1798 XvAdaptorPtr pAdapt
= xvsp
->pAdaptors
+ i
;
1800 if (isImageAdaptor(pAdapt
) && isOverlay
== hasOverlay(pAdapt
))
1804 /* but we'll take any XvImage pairing if we can get it */
1805 for (i
= 0; i
< xvsp
->nAdaptors
; i
++) {
1806 XvAdaptorPtr pAdapt
= xvsp
->pAdaptors
+ i
;
1808 if (isImageAdaptor(pAdapt
))
1818 dixLookupPrivate(&screenInfo
.screens
[0]->devPrivates
, XvGetScreenKey());
1819 XvAdaptorPtr MatchingAdaptors
[MAXSCREENS
];
1822 XvXRTPort
= CreateNewResourceType(XineramaDeleteResource
, "XvXRTPort");
1824 if (!xvsp0
|| !XvXRTPort
)
1826 SetResourceTypeErrorValue(XvXRTPort
, _XvBadPort
);
1828 for (i
= 0; i
< xvsp0
->nAdaptors
; i
++) {
1830 XvAdaptorPtr refAdapt
= xvsp0
->pAdaptors
+ i
;
1832 if (!(refAdapt
->type
& XvInputMask
))
1835 MatchingAdaptors
[0] = refAdapt
;
1836 isOverlay
= hasOverlay(refAdapt
);
1837 FOR_NSCREENS_FORWARD_SKIP(j
)
1838 MatchingAdaptors
[j
] =
1839 matchAdaptor(screenInfo
.screens
[j
], refAdapt
, isOverlay
);
1841 /* now create a resource for each port */
1842 for (j
= 0; j
< refAdapt
->nPorts
; j
++) {
1843 PanoramiXRes
*port
= malloc(sizeof(PanoramiXRes
));
1849 if (MatchingAdaptors
[k
] && (MatchingAdaptors
[k
]->nPorts
> j
))
1850 port
->info
[k
].id
= MatchingAdaptors
[k
]->base_id
+ j
;
1852 port
->info
[k
].id
= 0;
1854 AddResource(port
->info
[0].id
, XvXRTPort
, port
);
1858 /* munge the dispatch vector */
1859 XvProcVector
[xv_PutVideo
] = XineramaXvPutVideo
;
1860 XvProcVector
[xv_PutStill
] = XineramaXvPutStill
;
1861 XvProcVector
[xv_StopVideo
] = XineramaXvStopVideo
;
1862 XvProcVector
[xv_SetPortAttribute
] = XineramaXvSetPortAttribute
;
1863 XvProcVector
[xv_PutImage
] = XineramaXvPutImage
;
1864 XvProcVector
[xv_ShmPutImage
] = XineramaXvShmPutImage
;
1866 #endif /* PANORAMIX */
1869 XvResetProcVector(void)
1872 XvProcVector
[xv_PutVideo
] = ProcXvPutVideo
;
1873 XvProcVector
[xv_PutStill
] = ProcXvPutStill
;
1874 XvProcVector
[xv_StopVideo
] = ProcXvStopVideo
;
1875 XvProcVector
[xv_SetPortAttribute
] = ProcXvSetPortAttribute
;
1876 XvProcVector
[xv_PutImage
] = ProcXvPutImage
;
1877 XvProcVector
[xv_ShmPutImage
] = ProcXvShmPutImage
;