2006-11-26 11:13:41 -07:00
|
|
|
/***********************************************************
|
|
|
|
Copyright 1991 by Digital Equipment Corporation, Maynard, Massachusetts,
|
|
|
|
and the Massachusetts Institute of Technology, Cambridge, Massachusetts.
|
|
|
|
|
|
|
|
All Rights Reserved
|
|
|
|
|
|
|
|
Permission to use, copy, modify, and distribute this software and its
|
|
|
|
documentation for any purpose and without fee is hereby granted,
|
|
|
|
provided that the above copyright notice appear in all copies and that
|
|
|
|
both that copyright notice and this permission notice appear in
|
|
|
|
supporting documentation, and that the names of Digital or MIT not be
|
|
|
|
used in advertising or publicity pertaining to distribution of the
|
|
|
|
software without specific, written prior permission.
|
|
|
|
|
|
|
|
DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
|
|
|
|
ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
|
|
|
|
DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
|
|
|
|
ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
|
|
|
|
WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
|
|
|
|
ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
|
|
|
|
SOFTWARE.
|
|
|
|
******************************************************************/
|
|
|
|
|
|
|
|
#ifdef HAVE_DIX_CONFIG_H
|
|
|
|
#include <dix-config.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
#include <X11/X.h>
|
|
|
|
#include <X11/Xproto.h>
|
|
|
|
#include "misc.h"
|
|
|
|
#include "scrnintstr.h"
|
|
|
|
#include "windowstr.h"
|
|
|
|
#include "pixmapstr.h"
|
|
|
|
#include "gcstruct.h"
|
|
|
|
#include "dixstruct.h"
|
|
|
|
#include "resource.h"
|
|
|
|
#include "opaque.h"
|
|
|
|
|
|
|
|
#include <X11/extensions/Xv.h>
|
|
|
|
#include <X11/extensions/Xvproto.h>
|
|
|
|
#include "xvdix.h"
|
|
|
|
#ifdef MITSHM
|
2010-04-13 13:54:46 -06:00
|
|
|
#include <X11/extensions/shmproto.h>
|
|
|
|
#endif
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
#include "xvdisp.h"
|
|
|
|
|
|
|
|
#ifdef PANORAMIX
|
|
|
|
#include "panoramiX.h"
|
|
|
|
#include "panoramiXsrv.h"
|
|
|
|
|
|
|
|
unsigned long XvXRTPort;
|
|
|
|
#endif
|
|
|
|
|
2008-11-02 08:26:08 -07:00
|
|
|
static int
|
2012-06-10 07:21:05 -06:00
|
|
|
SWriteQueryExtensionReply(ClientPtr client, xvQueryExtensionReply * rep)
|
|
|
|
{
|
|
|
|
swaps(&rep->sequenceNumber);
|
|
|
|
swapl(&rep->length);
|
|
|
|
swaps(&rep->version);
|
|
|
|
swaps(&rep->revision);
|
2008-11-02 08:26:08 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
(void) WriteToClient(client, sz_xvQueryExtensionReply, (char *) rep);
|
2008-11-02 08:26:08 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
return Success;
|
2008-11-02 08:26:08 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2012-06-10 07:21:05 -06:00
|
|
|
SWriteQueryAdaptorsReply(ClientPtr client, xvQueryAdaptorsReply * rep)
|
|
|
|
{
|
|
|
|
swaps(&rep->sequenceNumber);
|
|
|
|
swapl(&rep->length);
|
|
|
|
swaps(&rep->num_adaptors);
|
2008-11-02 08:26:08 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
(void) WriteToClient(client, sz_xvQueryAdaptorsReply, (char *) rep);
|
2008-11-02 08:26:08 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
return Success;
|
2008-11-02 08:26:08 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2012-06-10 07:21:05 -06:00
|
|
|
SWriteQueryEncodingsReply(ClientPtr client, xvQueryEncodingsReply * rep)
|
|
|
|
{
|
|
|
|
swaps(&rep->sequenceNumber);
|
|
|
|
swapl(&rep->length);
|
|
|
|
swaps(&rep->num_encodings);
|
2008-11-02 08:26:08 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
(void) WriteToClient(client, sz_xvQueryEncodingsReply, (char *) rep);
|
2008-11-02 08:26:08 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
return Success;
|
2008-11-02 08:26:08 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2012-06-10 07:21:05 -06:00
|
|
|
SWriteAdaptorInfo(ClientPtr client, xvAdaptorInfo * pAdaptor)
|
|
|
|
{
|
|
|
|
swapl(&pAdaptor->base_id);
|
|
|
|
swaps(&pAdaptor->name_size);
|
|
|
|
swaps(&pAdaptor->num_ports);
|
|
|
|
swaps(&pAdaptor->num_formats);
|
2008-11-02 08:26:08 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
(void) WriteToClient(client, sz_xvAdaptorInfo, (char *) pAdaptor);
|
2008-11-02 08:26:08 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
return Success;
|
2008-11-02 08:26:08 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2012-06-10 07:21:05 -06:00
|
|
|
SWriteEncodingInfo(ClientPtr client, xvEncodingInfo * pEncoding)
|
|
|
|
{
|
|
|
|
|
|
|
|
swapl(&pEncoding->encoding);
|
|
|
|
swaps(&pEncoding->name_size);
|
|
|
|
swaps(&pEncoding->width);
|
|
|
|
swaps(&pEncoding->height);
|
|
|
|
swapl(&pEncoding->rate.numerator);
|
|
|
|
swapl(&pEncoding->rate.denominator);
|
|
|
|
(void) WriteToClient(client, sz_xvEncodingInfo, (char *) pEncoding);
|
|
|
|
|
|
|
|
return Success;
|
2008-11-02 08:26:08 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2012-06-10 07:21:05 -06:00
|
|
|
SWriteFormat(ClientPtr client, xvFormat * pFormat)
|
|
|
|
{
|
|
|
|
swapl(&pFormat->visual);
|
|
|
|
(void) WriteToClient(client, sz_xvFormat, (char *) pFormat);
|
2008-11-02 08:26:08 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
return Success;
|
2008-11-02 08:26:08 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2012-06-10 07:21:05 -06:00
|
|
|
SWriteAttributeInfo(ClientPtr client, xvAttributeInfo * pAtt)
|
|
|
|
{
|
|
|
|
swapl(&pAtt->flags);
|
|
|
|
swapl(&pAtt->size);
|
|
|
|
swapl(&pAtt->min);
|
|
|
|
swapl(&pAtt->max);
|
|
|
|
(void) WriteToClient(client, sz_xvAttributeInfo, (char *) pAtt);
|
2008-11-02 08:26:08 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
return Success;
|
2008-11-02 08:26:08 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2012-06-10 07:21:05 -06:00
|
|
|
SWriteImageFormatInfo(ClientPtr client, xvImageFormatInfo * pImage)
|
|
|
|
{
|
|
|
|
swapl(&pImage->id);
|
|
|
|
swapl(&pImage->red_mask);
|
|
|
|
swapl(&pImage->green_mask);
|
|
|
|
swapl(&pImage->blue_mask);
|
|
|
|
swapl(&pImage->y_sample_bits);
|
|
|
|
swapl(&pImage->u_sample_bits);
|
|
|
|
swapl(&pImage->v_sample_bits);
|
|
|
|
swapl(&pImage->horz_y_period);
|
|
|
|
swapl(&pImage->horz_u_period);
|
|
|
|
swapl(&pImage->horz_v_period);
|
|
|
|
swapl(&pImage->vert_y_period);
|
|
|
|
swapl(&pImage->vert_u_period);
|
|
|
|
swapl(&pImage->vert_v_period);
|
|
|
|
|
|
|
|
(void) WriteToClient(client, sz_xvImageFormatInfo, (char *) pImage);
|
|
|
|
|
|
|
|
return Success;
|
2008-11-02 08:26:08 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2012-06-10 07:21:05 -06:00
|
|
|
SWriteGrabPortReply(ClientPtr client, xvGrabPortReply * rep)
|
|
|
|
{
|
|
|
|
swaps(&rep->sequenceNumber);
|
|
|
|
swapl(&rep->length);
|
2008-11-02 08:26:08 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
(void) WriteToClient(client, sz_xvGrabPortReply, (char *) rep);
|
2008-11-02 08:26:08 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
return Success;
|
2008-11-02 08:26:08 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2012-06-10 07:21:05 -06:00
|
|
|
SWriteGetPortAttributeReply(ClientPtr client, xvGetPortAttributeReply * rep)
|
|
|
|
{
|
|
|
|
swaps(&rep->sequenceNumber);
|
|
|
|
swapl(&rep->length);
|
|
|
|
swapl(&rep->value);
|
2008-11-02 08:26:08 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
(void) WriteToClient(client, sz_xvGetPortAttributeReply, (char *) rep);
|
2008-11-02 08:26:08 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
return Success;
|
2008-11-02 08:26:08 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2012-06-10 07:21:05 -06:00
|
|
|
SWriteQueryBestSizeReply(ClientPtr client, xvQueryBestSizeReply * rep)
|
|
|
|
{
|
|
|
|
swaps(&rep->sequenceNumber);
|
|
|
|
swapl(&rep->length);
|
|
|
|
swaps(&rep->actual_width);
|
|
|
|
swaps(&rep->actual_height);
|
2008-11-02 08:26:08 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
(void) WriteToClient(client, sz_xvQueryBestSizeReply, (char *) rep);
|
2008-11-02 08:26:08 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
return Success;
|
2008-11-02 08:26:08 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2012-06-10 07:21:05 -06:00
|
|
|
SWriteQueryPortAttributesReply(ClientPtr client,
|
|
|
|
xvQueryPortAttributesReply * rep)
|
|
|
|
{
|
|
|
|
swaps(&rep->sequenceNumber);
|
|
|
|
swapl(&rep->length);
|
|
|
|
swapl(&rep->num_attributes);
|
|
|
|
swapl(&rep->text_size);
|
2008-11-02 08:26:08 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
(void) WriteToClient(client, sz_xvQueryPortAttributesReply, (char *) rep);
|
2008-11-02 08:26:08 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
return Success;
|
2008-11-02 08:26:08 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2012-06-10 07:21:05 -06:00
|
|
|
SWriteQueryImageAttributesReply(ClientPtr client,
|
|
|
|
xvQueryImageAttributesReply * rep)
|
|
|
|
{
|
|
|
|
swaps(&rep->sequenceNumber);
|
|
|
|
swapl(&rep->length);
|
|
|
|
swapl(&rep->num_planes);
|
|
|
|
swapl(&rep->data_size);
|
|
|
|
swaps(&rep->width);
|
|
|
|
swaps(&rep->height);
|
2008-11-02 08:26:08 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
(void) WriteToClient(client, sz_xvQueryImageAttributesReply, (char *) rep);
|
2008-11-02 08:26:08 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
return Success;
|
2008-11-02 08:26:08 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2012-06-10 07:21:05 -06:00
|
|
|
SWriteListImageFormatsReply(ClientPtr client, xvListImageFormatsReply * rep)
|
|
|
|
{
|
|
|
|
swaps(&rep->sequenceNumber);
|
|
|
|
swapl(&rep->length);
|
|
|
|
swapl(&rep->num_formats);
|
2008-11-02 08:26:08 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
(void) WriteToClient(client, sz_xvListImageFormatsReply, (char *) rep);
|
2008-11-02 08:26:08 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
return Success;
|
2008-11-02 08:26:08 -07:00
|
|
|
}
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
#define _WriteQueryAdaptorsReply(_c,_d) \
|
|
|
|
if ((_c)->swapped) SWriteQueryAdaptorsReply(_c, _d); \
|
|
|
|
else WriteToClient(_c, sz_xvQueryAdaptorsReply, (char*)_d)
|
|
|
|
|
|
|
|
#define _WriteQueryExtensionReply(_c,_d) \
|
|
|
|
if ((_c)->swapped) SWriteQueryExtensionReply(_c, _d); \
|
|
|
|
else WriteToClient(_c, sz_xvQueryExtensionReply, (char*)_d)
|
|
|
|
|
|
|
|
#define _WriteQueryEncodingsReply(_c,_d) \
|
|
|
|
if ((_c)->swapped) SWriteQueryEncodingsReply(_c, _d); \
|
|
|
|
else WriteToClient(_c, sz_xvQueryEncodingsReply, (char*)_d)
|
|
|
|
|
|
|
|
#define _WriteAdaptorInfo(_c,_d) \
|
|
|
|
if ((_c)->swapped) SWriteAdaptorInfo(_c, _d); \
|
|
|
|
else WriteToClient(_c, sz_xvAdaptorInfo, (char*)_d)
|
|
|
|
|
|
|
|
#define _WriteAttributeInfo(_c,_d) \
|
|
|
|
if ((_c)->swapped) SWriteAttributeInfo(_c, _d); \
|
|
|
|
else WriteToClient(_c, sz_xvAttributeInfo, (char*)_d)
|
|
|
|
|
|
|
|
#define _WriteEncodingInfo(_c,_d) \
|
|
|
|
if ((_c)->swapped) SWriteEncodingInfo(_c, _d); \
|
|
|
|
else WriteToClient(_c, sz_xvEncodingInfo, (char*)_d)
|
|
|
|
|
|
|
|
#define _WriteFormat(_c,_d) \
|
|
|
|
if ((_c)->swapped) SWriteFormat(_c, _d); \
|
|
|
|
else WriteToClient(_c, sz_xvFormat, (char*)_d)
|
|
|
|
|
|
|
|
#define _WriteGrabPortReply(_c,_d) \
|
|
|
|
if ((_c)->swapped) SWriteGrabPortReply(_c, _d); \
|
|
|
|
else WriteToClient(_c, sz_xvGrabPortReply, (char*)_d)
|
|
|
|
|
|
|
|
#define _WriteGetPortAttributeReply(_c,_d) \
|
|
|
|
if ((_c)->swapped) SWriteGetPortAttributeReply(_c, _d); \
|
|
|
|
else WriteToClient(_c, sz_xvGetPortAttributeReply, (char*)_d)
|
|
|
|
|
|
|
|
#define _WriteQueryBestSizeReply(_c,_d) \
|
|
|
|
if ((_c)->swapped) SWriteQueryBestSizeReply(_c, _d); \
|
|
|
|
else WriteToClient(_c, sz_xvQueryBestSizeReply,(char*) _d)
|
|
|
|
|
|
|
|
#define _WriteQueryPortAttributesReply(_c,_d) \
|
|
|
|
if ((_c)->swapped) SWriteQueryPortAttributesReply(_c, _d); \
|
|
|
|
else WriteToClient(_c, sz_xvQueryPortAttributesReply,(char*) _d)
|
|
|
|
|
|
|
|
#define _WriteQueryImageAttributesReply(_c,_d) \
|
|
|
|
if ((_c)->swapped) SWriteQueryImageAttributesReply(_c, _d); \
|
|
|
|
else WriteToClient(_c, sz_xvQueryImageAttributesReply,(char*) _d)
|
|
|
|
|
|
|
|
#define _WriteListImageFormatsReply(_c,_d) \
|
|
|
|
if ((_c)->swapped) SWriteListImageFormatsReply(_c, _d); \
|
|
|
|
else WriteToClient(_c, sz_xvListImageFormatsReply,(char*) _d)
|
|
|
|
|
|
|
|
#define _WriteImageFormatInfo(_c,_d) \
|
|
|
|
if ((_c)->swapped) SWriteImageFormatInfo(_c, _d); \
|
|
|
|
else WriteToClient(_c, sz_xvImageFormatInfo, (char*)_d)
|
|
|
|
|
|
|
|
#define _AllocatePort(_i,_p) \
|
|
|
|
((_p)->id != _i) ? (* (_p)->pAdaptor->ddAllocatePort)(_i,_p,&_p) : Success
|
|
|
|
|
|
|
|
static int
|
|
|
|
ProcXvQueryExtension(ClientPtr client)
|
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
xvQueryExtensionReply rep;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
/* REQUEST(xvQueryExtensionReq); */
|
|
|
|
REQUEST_SIZE_MATCH(xvQueryExtensionReq);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
rep.type = X_Reply;
|
|
|
|
rep.sequenceNumber = client->sequence;
|
|
|
|
rep.length = 0;
|
|
|
|
rep.version = XvVersion;
|
|
|
|
rep.revision = XvRevision;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
_WriteQueryExtensionReply(client, &rep);
|
|
|
|
|
|
|
|
return Success;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
ProcXvQueryAdaptors(ClientPtr client)
|
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
xvFormat format;
|
|
|
|
xvAdaptorInfo ainfo;
|
|
|
|
xvQueryAdaptorsReply rep;
|
|
|
|
int totalSize, na, nf, rc;
|
|
|
|
int nameSize;
|
|
|
|
XvAdaptorPtr pa;
|
|
|
|
XvFormatPtr pf;
|
|
|
|
WindowPtr pWin;
|
|
|
|
ScreenPtr pScreen;
|
|
|
|
XvScreenPtr pxvs;
|
|
|
|
|
|
|
|
REQUEST(xvQueryAdaptorsReq);
|
|
|
|
REQUEST_SIZE_MATCH(xvQueryAdaptorsReq);
|
|
|
|
|
|
|
|
rc = dixLookupWindow(&pWin, stuff->window, client, DixGetAttrAccess);
|
|
|
|
if (rc != Success)
|
|
|
|
return rc;
|
|
|
|
|
|
|
|
pScreen = pWin->drawable.pScreen;
|
|
|
|
pxvs = (XvScreenPtr) dixLookupPrivate(&pScreen->devPrivates,
|
|
|
|
XvGetScreenKey());
|
|
|
|
if (!pxvs) {
|
|
|
|
rep.type = X_Reply;
|
|
|
|
rep.sequenceNumber = client->sequence;
|
|
|
|
rep.num_adaptors = 0;
|
|
|
|
rep.length = 0;
|
|
|
|
|
|
|
|
_WriteQueryAdaptorsReply(client, &rep);
|
|
|
|
|
|
|
|
return Success;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
(*pxvs->ddQueryAdaptors) (pScreen, &pxvs->pAdaptors, &pxvs->nAdaptors);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
rep.type = X_Reply;
|
|
|
|
rep.sequenceNumber = client->sequence;
|
|
|
|
rep.num_adaptors = pxvs->nAdaptors;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
/* CALCULATE THE TOTAL SIZE OF THE REPLY IN BYTES */
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
totalSize = pxvs->nAdaptors * sz_xvAdaptorInfo;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
/* FOR EACH ADPATOR ADD UP THE BYTES FOR ENCODINGS AND FORMATS */
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
na = pxvs->nAdaptors;
|
|
|
|
pa = pxvs->pAdaptors;
|
|
|
|
while (na--) {
|
|
|
|
totalSize += pad_to_int32(strlen(pa->name));
|
|
|
|
totalSize += pa->nFormats * sz_xvFormat;
|
|
|
|
pa++;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
rep.length = bytes_to_int32(totalSize);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
_WriteQueryAdaptorsReply(client, &rep);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
na = pxvs->nAdaptors;
|
|
|
|
pa = pxvs->pAdaptors;
|
|
|
|
while (na--) {
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
ainfo.base_id = pa->base_id;
|
|
|
|
ainfo.num_ports = pa->nPorts;
|
|
|
|
ainfo.type = pa->type;
|
|
|
|
ainfo.name_size = nameSize = strlen(pa->name);
|
|
|
|
ainfo.num_formats = pa->nFormats;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
_WriteAdaptorInfo(client, &ainfo);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
WriteToClient(client, nameSize, pa->name);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
nf = pa->nFormats;
|
|
|
|
pf = pa->pFormats;
|
|
|
|
while (nf--) {
|
|
|
|
format.depth = pf->depth;
|
|
|
|
format.visual = pf->visual;
|
|
|
|
_WriteFormat(client, &format);
|
|
|
|
pf++;
|
|
|
|
}
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
pa++;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
return Success;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
ProcXvQueryEncodings(ClientPtr client)
|
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
xvEncodingInfo einfo;
|
|
|
|
xvQueryEncodingsReply rep;
|
|
|
|
int totalSize;
|
|
|
|
int nameSize;
|
|
|
|
XvPortPtr pPort;
|
|
|
|
int ne;
|
|
|
|
XvEncodingPtr pe;
|
|
|
|
int status;
|
|
|
|
|
|
|
|
REQUEST(xvQueryEncodingsReq);
|
|
|
|
REQUEST_SIZE_MATCH(xvQueryEncodingsReq);
|
|
|
|
|
|
|
|
VALIDATE_XV_PORT(stuff->port, pPort, DixReadAccess);
|
|
|
|
|
|
|
|
if ((status = _AllocatePort(stuff->port, pPort)) != Success) {
|
|
|
|
client->errorValue = stuff->port;
|
|
|
|
return status;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
rep.type = X_Reply;
|
|
|
|
rep.sequenceNumber = client->sequence;
|
|
|
|
rep.num_encodings = pPort->pAdaptor->nEncodings;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
/* FOR EACH ENCODING ADD UP THE BYTES FOR ENCODING NAMES */
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
ne = pPort->pAdaptor->nEncodings;
|
|
|
|
pe = pPort->pAdaptor->pEncodings;
|
|
|
|
totalSize = ne * sz_xvEncodingInfo;
|
|
|
|
while (ne--) {
|
|
|
|
totalSize += pad_to_int32(strlen(pe->name));
|
|
|
|
pe++;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
rep.length = bytes_to_int32(totalSize);
|
|
|
|
|
|
|
|
_WriteQueryEncodingsReply(client, &rep);
|
|
|
|
|
|
|
|
ne = pPort->pAdaptor->nEncodings;
|
|
|
|
pe = pPort->pAdaptor->pEncodings;
|
|
|
|
while (ne--) {
|
|
|
|
einfo.encoding = pe->id;
|
|
|
|
einfo.name_size = nameSize = strlen(pe->name);
|
|
|
|
einfo.width = pe->width;
|
|
|
|
einfo.height = pe->height;
|
|
|
|
einfo.rate.numerator = pe->rate.numerator;
|
|
|
|
einfo.rate.denominator = pe->rate.denominator;
|
|
|
|
_WriteEncodingInfo(client, &einfo);
|
|
|
|
WriteToClient(client, nameSize, pe->name);
|
|
|
|
pe++;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
return Success;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
ProcXvPutVideo(ClientPtr client)
|
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
DrawablePtr pDraw;
|
|
|
|
XvPortPtr pPort;
|
|
|
|
GCPtr pGC;
|
|
|
|
int status;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
REQUEST(xvPutVideoReq);
|
|
|
|
REQUEST_SIZE_MATCH(xvPutVideoReq);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, DixWriteAccess);
|
|
|
|
VALIDATE_XV_PORT(stuff->port, pPort, DixReadAccess);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
if ((status = _AllocatePort(stuff->port, pPort)) != Success) {
|
|
|
|
client->errorValue = stuff->port;
|
|
|
|
return status;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
if (!(pPort->pAdaptor->type & XvInputMask) ||
|
|
|
|
!(pPort->pAdaptor->type & XvVideoMask)) {
|
|
|
|
client->errorValue = stuff->port;
|
|
|
|
return BadMatch;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
status = XvdiMatchPort(pPort, pDraw);
|
|
|
|
if (status != Success) {
|
|
|
|
return status;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
return XvdiPutVideo(client, pDraw, pPort, pGC, stuff->vid_x, stuff->vid_y,
|
|
|
|
stuff->vid_w, stuff->vid_h, stuff->drw_x, stuff->drw_y,
|
|
|
|
stuff->drw_w, stuff->drw_h);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
ProcXvPutStill(ClientPtr client)
|
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
DrawablePtr pDraw;
|
|
|
|
XvPortPtr pPort;
|
|
|
|
GCPtr pGC;
|
|
|
|
int status;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
REQUEST(xvPutStillReq);
|
|
|
|
REQUEST_SIZE_MATCH(xvPutStillReq);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, DixWriteAccess);
|
|
|
|
VALIDATE_XV_PORT(stuff->port, pPort, DixReadAccess);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
if ((status = _AllocatePort(stuff->port, pPort)) != Success) {
|
|
|
|
client->errorValue = stuff->port;
|
|
|
|
return status;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
if (!(pPort->pAdaptor->type & XvInputMask) ||
|
|
|
|
!(pPort->pAdaptor->type & XvStillMask)) {
|
|
|
|
client->errorValue = stuff->port;
|
|
|
|
return BadMatch;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
status = XvdiMatchPort(pPort, pDraw);
|
|
|
|
if (status != Success) {
|
|
|
|
return status;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
return XvdiPutStill(client, pDraw, pPort, pGC, stuff->vid_x, stuff->vid_y,
|
|
|
|
stuff->vid_w, stuff->vid_h, stuff->drw_x, stuff->drw_y,
|
|
|
|
stuff->drw_w, stuff->drw_h);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
ProcXvGetVideo(ClientPtr client)
|
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
DrawablePtr pDraw;
|
|
|
|
XvPortPtr pPort;
|
|
|
|
GCPtr pGC;
|
|
|
|
int status;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
REQUEST(xvGetVideoReq);
|
|
|
|
REQUEST_SIZE_MATCH(xvGetVideoReq);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, DixReadAccess);
|
|
|
|
VALIDATE_XV_PORT(stuff->port, pPort, DixReadAccess);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
if ((status = _AllocatePort(stuff->port, pPort)) != Success) {
|
|
|
|
client->errorValue = stuff->port;
|
|
|
|
return status;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
if (!(pPort->pAdaptor->type & XvOutputMask) ||
|
|
|
|
!(pPort->pAdaptor->type & XvVideoMask)) {
|
|
|
|
client->errorValue = stuff->port;
|
|
|
|
return BadMatch;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
status = XvdiMatchPort(pPort, pDraw);
|
|
|
|
if (status != Success) {
|
|
|
|
return status;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
return XvdiGetVideo(client, pDraw, pPort, pGC, stuff->vid_x, stuff->vid_y,
|
|
|
|
stuff->vid_w, stuff->vid_h, stuff->drw_x, stuff->drw_y,
|
|
|
|
stuff->drw_w, stuff->drw_h);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
ProcXvGetStill(ClientPtr client)
|
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
DrawablePtr pDraw;
|
|
|
|
XvPortPtr pPort;
|
|
|
|
GCPtr pGC;
|
|
|
|
int status;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
REQUEST(xvGetStillReq);
|
|
|
|
REQUEST_SIZE_MATCH(xvGetStillReq);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, DixReadAccess);
|
|
|
|
VALIDATE_XV_PORT(stuff->port, pPort, DixReadAccess);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
if ((status = _AllocatePort(stuff->port, pPort)) != Success) {
|
|
|
|
client->errorValue = stuff->port;
|
|
|
|
return status;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
if (!(pPort->pAdaptor->type & XvOutputMask) ||
|
|
|
|
!(pPort->pAdaptor->type & XvStillMask)) {
|
|
|
|
client->errorValue = stuff->port;
|
|
|
|
return BadMatch;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
status = XvdiMatchPort(pPort, pDraw);
|
|
|
|
if (status != Success) {
|
|
|
|
return status;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
return XvdiGetStill(client, pDraw, pPort, pGC, stuff->vid_x, stuff->vid_y,
|
|
|
|
stuff->vid_w, stuff->vid_h, stuff->drw_x, stuff->drw_y,
|
|
|
|
stuff->drw_w, stuff->drw_h);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
ProcXvSelectVideoNotify(ClientPtr client)
|
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
DrawablePtr pDraw;
|
|
|
|
int rc;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
REQUEST(xvSelectVideoNotifyReq);
|
|
|
|
REQUEST_SIZE_MATCH(xvSelectVideoNotifyReq);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
rc = dixLookupDrawable(&pDraw, stuff->drawable, client, 0,
|
|
|
|
DixReceiveAccess);
|
|
|
|
if (rc != Success)
|
|
|
|
return rc;
|
|
|
|
|
|
|
|
return XvdiSelectVideoNotify(client, pDraw, stuff->onoff);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
ProcXvSelectPortNotify(ClientPtr client)
|
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
int status;
|
|
|
|
XvPortPtr pPort;
|
|
|
|
|
|
|
|
REQUEST(xvSelectPortNotifyReq);
|
|
|
|
REQUEST_SIZE_MATCH(xvSelectPortNotifyReq);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
VALIDATE_XV_PORT(stuff->port, pPort, DixReadAccess);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
if ((status = _AllocatePort(stuff->port, pPort)) != Success) {
|
|
|
|
client->errorValue = stuff->port;
|
|
|
|
return status;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
return XvdiSelectPortNotify(client, pPort, stuff->onoff);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
ProcXvGrabPort(ClientPtr client)
|
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
int result, status;
|
|
|
|
XvPortPtr pPort;
|
|
|
|
xvGrabPortReply rep;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
REQUEST(xvGrabPortReq);
|
|
|
|
REQUEST_SIZE_MATCH(xvGrabPortReq);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
VALIDATE_XV_PORT(stuff->port, pPort, DixReadAccess);
|
|
|
|
|
|
|
|
if ((status = _AllocatePort(stuff->port, pPort)) != Success) {
|
|
|
|
client->errorValue = stuff->port;
|
|
|
|
return status;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
status = XvdiGrabPort(client, pPort, stuff->time, &result);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
if (status != Success) {
|
|
|
|
return status;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
rep.type = X_Reply;
|
|
|
|
rep.sequenceNumber = client->sequence;
|
|
|
|
rep.length = 0;
|
|
|
|
rep.result = result;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
_WriteGrabPortReply(client, &rep);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
return Success;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
ProcXvUngrabPort(ClientPtr client)
|
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
int status;
|
|
|
|
XvPortPtr pPort;
|
|
|
|
|
|
|
|
REQUEST(xvGrabPortReq);
|
|
|
|
REQUEST_SIZE_MATCH(xvGrabPortReq);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
VALIDATE_XV_PORT(stuff->port, pPort, DixReadAccess);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
if ((status = _AllocatePort(stuff->port, pPort)) != Success) {
|
|
|
|
client->errorValue = stuff->port;
|
|
|
|
return status;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
return XvdiUngrabPort(client, pPort, stuff->time);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
ProcXvStopVideo(ClientPtr client)
|
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
int status, rc;
|
|
|
|
DrawablePtr pDraw;
|
|
|
|
XvPortPtr pPort;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
REQUEST(xvStopVideoReq);
|
|
|
|
REQUEST_SIZE_MATCH(xvStopVideoReq);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
VALIDATE_XV_PORT(stuff->port, pPort, DixReadAccess);
|
|
|
|
|
|
|
|
if ((status = _AllocatePort(stuff->port, pPort)) != Success) {
|
|
|
|
client->errorValue = stuff->port;
|
|
|
|
return status;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
rc = dixLookupDrawable(&pDraw, stuff->drawable, client, 0, DixWriteAccess);
|
|
|
|
if (rc != Success)
|
|
|
|
return rc;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
return XvdiStopVideo(client, pPort, pDraw);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
ProcXvSetPortAttribute(ClientPtr client)
|
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
int status;
|
|
|
|
XvPortPtr pPort;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
REQUEST(xvSetPortAttributeReq);
|
|
|
|
REQUEST_SIZE_MATCH(xvSetPortAttributeReq);
|
|
|
|
|
|
|
|
VALIDATE_XV_PORT(stuff->port, pPort, DixSetAttrAccess);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
if ((status = _AllocatePort(stuff->port, pPort)) != Success) {
|
|
|
|
client->errorValue = stuff->port;
|
|
|
|
return status;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
if (!ValidAtom(stuff->attribute)) {
|
|
|
|
client->errorValue = stuff->attribute;
|
|
|
|
return BadAtom;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
status =
|
|
|
|
XvdiSetPortAttribute(client, pPort, stuff->attribute, stuff->value);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
if (status == BadMatch)
|
|
|
|
client->errorValue = stuff->attribute;
|
|
|
|
else
|
|
|
|
client->errorValue = stuff->value;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
return status;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
ProcXvGetPortAttribute(ClientPtr client)
|
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
INT32 value;
|
|
|
|
int status;
|
|
|
|
XvPortPtr pPort;
|
|
|
|
xvGetPortAttributeReply rep;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
REQUEST(xvGetPortAttributeReq);
|
|
|
|
REQUEST_SIZE_MATCH(xvGetPortAttributeReq);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
VALIDATE_XV_PORT(stuff->port, pPort, DixGetAttrAccess);
|
|
|
|
|
|
|
|
if ((status = _AllocatePort(stuff->port, pPort)) != Success) {
|
|
|
|
client->errorValue = stuff->port;
|
|
|
|
return status;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
if (!ValidAtom(stuff->attribute)) {
|
|
|
|
client->errorValue = stuff->attribute;
|
|
|
|
return BadAtom;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
status = XvdiGetPortAttribute(client, pPort, stuff->attribute, &value);
|
|
|
|
if (status != Success) {
|
|
|
|
client->errorValue = stuff->attribute;
|
|
|
|
return status;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
rep.type = X_Reply;
|
|
|
|
rep.sequenceNumber = client->sequence;
|
|
|
|
rep.length = 0;
|
|
|
|
rep.value = value;
|
|
|
|
|
|
|
|
_WriteGetPortAttributeReply(client, &rep);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
return Success;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
ProcXvQueryBestSize(ClientPtr client)
|
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
int status;
|
|
|
|
unsigned int actual_width, actual_height;
|
|
|
|
XvPortPtr pPort;
|
|
|
|
xvQueryBestSizeReply rep;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
REQUEST(xvQueryBestSizeReq);
|
|
|
|
REQUEST_SIZE_MATCH(xvQueryBestSizeReq);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
VALIDATE_XV_PORT(stuff->port, pPort, DixReadAccess);
|
|
|
|
|
|
|
|
if ((status = _AllocatePort(stuff->port, pPort)) != Success) {
|
|
|
|
client->errorValue = stuff->port;
|
|
|
|
return status;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
rep.type = X_Reply;
|
|
|
|
rep.sequenceNumber = client->sequence;
|
|
|
|
rep.length = 0;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
(*pPort->pAdaptor->ddQueryBestSize) (client, pPort, stuff->motion,
|
|
|
|
stuff->vid_w, stuff->vid_h,
|
|
|
|
stuff->drw_w, stuff->drw_h,
|
|
|
|
&actual_width, &actual_height);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
rep.actual_width = actual_width;
|
|
|
|
rep.actual_height = actual_height;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
_WriteQueryBestSizeReply(client, &rep);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
return Success;
|
|
|
|
}
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
static int
|
|
|
|
ProcXvQueryPortAttributes(ClientPtr client)
|
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
int status, size, i;
|
|
|
|
XvPortPtr pPort;
|
|
|
|
XvAttributePtr pAtt;
|
|
|
|
xvQueryPortAttributesReply rep;
|
|
|
|
xvAttributeInfo Info;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
REQUEST(xvQueryPortAttributesReq);
|
|
|
|
REQUEST_SIZE_MATCH(xvQueryPortAttributesReq);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
VALIDATE_XV_PORT(stuff->port, pPort, DixGetAttrAccess);
|
|
|
|
|
|
|
|
if ((status = _AllocatePort(stuff->port, pPort)) != Success) {
|
|
|
|
client->errorValue = stuff->port;
|
|
|
|
return status;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
rep.type = X_Reply;
|
|
|
|
rep.sequenceNumber = client->sequence;
|
|
|
|
rep.num_attributes = pPort->pAdaptor->nAttributes;
|
|
|
|
rep.text_size = 0;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
for (i = 0, pAtt = pPort->pAdaptor->pAttributes;
|
|
|
|
i < pPort->pAdaptor->nAttributes; i++, pAtt++) {
|
|
|
|
rep.text_size += pad_to_int32(strlen(pAtt->name) + 1);
|
|
|
|
}
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
rep.length = (pPort->pAdaptor->nAttributes * sz_xvAttributeInfo)
|
|
|
|
+ rep.text_size;
|
|
|
|
rep.length >>= 2;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
_WriteQueryPortAttributesReply(client, &rep);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
for (i = 0, pAtt = pPort->pAdaptor->pAttributes;
|
|
|
|
i < pPort->pAdaptor->nAttributes; i++, pAtt++) {
|
|
|
|
size = strlen(pAtt->name) + 1; /* pass the NULL */
|
|
|
|
Info.flags = pAtt->flags;
|
|
|
|
Info.min = pAtt->min_value;
|
|
|
|
Info.max = pAtt->max_value;
|
|
|
|
Info.size = pad_to_int32(size);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
_WriteAttributeInfo(client, &Info);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
WriteToClient(client, size, pAtt->name);
|
|
|
|
}
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
return Success;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
static int
|
2006-11-26 11:13:41 -07:00
|
|
|
ProcXvPutImage(ClientPtr client)
|
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
DrawablePtr pDraw;
|
|
|
|
XvPortPtr pPort;
|
|
|
|
XvImagePtr pImage = NULL;
|
|
|
|
GCPtr pGC;
|
|
|
|
int status, i, size;
|
|
|
|
CARD16 width, height;
|
|
|
|
|
|
|
|
REQUEST(xvPutImageReq);
|
|
|
|
REQUEST_AT_LEAST_SIZE(xvPutImageReq);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, DixWriteAccess);
|
|
|
|
VALIDATE_XV_PORT(stuff->port, pPort, DixReadAccess);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
if ((status = _AllocatePort(stuff->port, pPort)) != Success) {
|
|
|
|
client->errorValue = stuff->port;
|
|
|
|
return status;
|
|
|
|
}
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
if (!(pPort->pAdaptor->type & XvImageMask) ||
|
|
|
|
!(pPort->pAdaptor->type & XvInputMask)) {
|
|
|
|
client->errorValue = stuff->port;
|
|
|
|
return BadMatch;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
status = XvdiMatchPort(pPort, pDraw);
|
|
|
|
if (status != Success) {
|
|
|
|
return status;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
for (i = 0; i < pPort->pAdaptor->nImages; i++) {
|
|
|
|
if (pPort->pAdaptor->pImages[i].id == stuff->id) {
|
|
|
|
pImage = &(pPort->pAdaptor->pImages[i]);
|
|
|
|
break;
|
|
|
|
}
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
if (!pImage)
|
|
|
|
return BadMatch;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
width = stuff->width;
|
|
|
|
height = stuff->height;
|
|
|
|
size = (*pPort->pAdaptor->ddQueryImageAttributes) (client,
|
|
|
|
pPort, pImage, &width,
|
|
|
|
&height, NULL, NULL);
|
|
|
|
size += sizeof(xvPutImageReq);
|
|
|
|
size = bytes_to_int32(size);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
if ((width < stuff->width) || (height < stuff->height))
|
|
|
|
return BadValue;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
if (client->req_len < size)
|
|
|
|
return BadLength;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
return XvdiPutImage(client, pDraw, pPort, pGC, stuff->src_x, stuff->src_y,
|
|
|
|
stuff->src_w, stuff->src_h, stuff->drw_x, stuff->drw_y,
|
|
|
|
stuff->drw_w, stuff->drw_h, pImage,
|
|
|
|
(unsigned char *) (&stuff[1]), FALSE,
|
|
|
|
stuff->width, stuff->height);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef MITSHM
|
|
|
|
/* redefined here since it's not in any header file */
|
|
|
|
typedef struct _ShmDesc {
|
|
|
|
struct _ShmDesc *next;
|
|
|
|
int shmid;
|
|
|
|
int refcnt;
|
|
|
|
char *addr;
|
|
|
|
Bool writable;
|
|
|
|
unsigned long size;
|
|
|
|
} ShmDescRec, *ShmDescPtr;
|
|
|
|
|
|
|
|
extern RESTYPE ShmSegType;
|
|
|
|
extern int ShmCompletionCode;
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
static int
|
2006-11-26 11:13:41 -07:00
|
|
|
ProcXvShmPutImage(ClientPtr client)
|
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
ShmDescPtr shmdesc;
|
|
|
|
DrawablePtr pDraw;
|
|
|
|
XvPortPtr pPort;
|
|
|
|
XvImagePtr pImage = NULL;
|
|
|
|
GCPtr pGC;
|
|
|
|
int status, size_needed, i;
|
|
|
|
CARD16 width, height;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
REQUEST(xvShmPutImageReq);
|
|
|
|
REQUEST_SIZE_MATCH(xvShmPutImageReq);
|
|
|
|
|
|
|
|
VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, DixWriteAccess);
|
|
|
|
VALIDATE_XV_PORT(stuff->port, pPort, DixReadAccess);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
if ((status = _AllocatePort(stuff->port, pPort)) != Success) {
|
|
|
|
client->errorValue = stuff->port;
|
|
|
|
return status;
|
|
|
|
}
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
if (!(pPort->pAdaptor->type & XvImageMask) ||
|
|
|
|
!(pPort->pAdaptor->type & XvInputMask)) {
|
|
|
|
client->errorValue = stuff->port;
|
|
|
|
return BadMatch;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
status = XvdiMatchPort(pPort, pDraw);
|
|
|
|
if (status != Success) {
|
|
|
|
return status;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
for (i = 0; i < pPort->pAdaptor->nImages; i++) {
|
|
|
|
if (pPort->pAdaptor->pImages[i].id == stuff->id) {
|
|
|
|
pImage = &(pPort->pAdaptor->pImages[i]);
|
|
|
|
break;
|
|
|
|
}
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
if (!pImage)
|
|
|
|
return BadMatch;
|
|
|
|
|
|
|
|
status = dixLookupResourceByType((pointer *) &shmdesc, stuff->shmseg,
|
|
|
|
ShmSegType, serverClient, DixReadAccess);
|
|
|
|
if (status != Success)
|
|
|
|
return status;
|
|
|
|
|
|
|
|
width = stuff->width;
|
|
|
|
height = stuff->height;
|
|
|
|
size_needed = (*pPort->pAdaptor->ddQueryImageAttributes) (client,
|
|
|
|
pPort, pImage,
|
|
|
|
&width, &height,
|
|
|
|
NULL, NULL);
|
|
|
|
if ((size_needed + stuff->offset) > shmdesc->size)
|
|
|
|
return BadAccess;
|
|
|
|
|
|
|
|
if ((width < stuff->width) || (height < stuff->height))
|
|
|
|
return BadValue;
|
|
|
|
|
|
|
|
status = XvdiPutImage(client, pDraw, pPort, pGC, stuff->src_x, stuff->src_y,
|
|
|
|
stuff->src_w, stuff->src_h, stuff->drw_x,
|
|
|
|
stuff->drw_y, stuff->drw_w, stuff->drw_h, pImage,
|
|
|
|
(unsigned char *) shmdesc->addr + stuff->offset,
|
|
|
|
stuff->send_event, stuff->width, stuff->height);
|
|
|
|
|
|
|
|
if ((status == Success) && stuff->send_event) {
|
2006-11-26 11:13:41 -07:00
|
|
|
xShmCompletionEvent ev;
|
|
|
|
|
|
|
|
ev.type = ShmCompletionCode;
|
|
|
|
ev.drawable = stuff->drawable;
|
|
|
|
ev.minorEvent = xv_ShmPutImage;
|
|
|
|
ev.majorEvent = XvReqCode;
|
|
|
|
ev.shmseg = stuff->shmseg;
|
|
|
|
ev.offset = stuff->offset;
|
|
|
|
WriteEventsToClient(client, 1, (xEvent *) &ev);
|
2012-06-10 07:21:05 -06:00
|
|
|
}
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
return status;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
2012-06-10 07:21:05 -06:00
|
|
|
#else /* !MITSHM */
|
2008-11-02 08:26:08 -07:00
|
|
|
static int
|
|
|
|
ProcXvShmPutImage(ClientPtr client)
|
|
|
|
{
|
|
|
|
SendErrorToClient(client, XvReqCode, xv_ShmPutImage, 0, BadImplementation);
|
2010-12-05 08:36:02 -07:00
|
|
|
return BadImplementation;
|
2008-11-02 08:26:08 -07:00
|
|
|
}
|
2006-11-26 11:13:41 -07:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef XvMCExtension
|
|
|
|
#include "xvmcext.h"
|
|
|
|
#endif
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
static int
|
2006-11-26 11:13:41 -07:00
|
|
|
ProcXvQueryImageAttributes(ClientPtr client)
|
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
xvQueryImageAttributesReply rep;
|
|
|
|
int size, num_planes, i;
|
|
|
|
CARD16 width, height;
|
|
|
|
XvImagePtr pImage = NULL;
|
|
|
|
XvPortPtr pPort;
|
|
|
|
int *offsets;
|
|
|
|
int *pitches;
|
|
|
|
int planeLength;
|
|
|
|
|
|
|
|
REQUEST(xvQueryImageAttributesReq);
|
|
|
|
|
|
|
|
REQUEST_SIZE_MATCH(xvQueryImageAttributesReq);
|
|
|
|
|
|
|
|
VALIDATE_XV_PORT(stuff->port, pPort, DixReadAccess);
|
|
|
|
|
|
|
|
for (i = 0; i < pPort->pAdaptor->nImages; i++) {
|
|
|
|
if (pPort->pAdaptor->pImages[i].id == stuff->id) {
|
|
|
|
pImage = &(pPort->pAdaptor->pImages[i]);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
#ifdef XvMCExtension
|
2012-06-10 07:21:05 -06:00
|
|
|
if (!pImage)
|
|
|
|
pImage = XvMCFindXvImage(pPort, stuff->id);
|
2006-11-26 11:13:41 -07:00
|
|
|
#endif
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
if (!pImage)
|
|
|
|
return BadMatch;
|
|
|
|
|
|
|
|
num_planes = pImage->num_planes;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
if (!(offsets = malloc(num_planes << 3)))
|
|
|
|
return BadAlloc;
|
|
|
|
pitches = offsets + num_planes;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
width = stuff->width;
|
|
|
|
height = stuff->height;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
size = (*pPort->pAdaptor->ddQueryImageAttributes) (client, pPort, pImage,
|
|
|
|
&width, &height, offsets,
|
|
|
|
pitches);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
rep.type = X_Reply;
|
|
|
|
rep.sequenceNumber = client->sequence;
|
|
|
|
rep.length = planeLength = num_planes << 1;
|
|
|
|
rep.num_planes = num_planes;
|
|
|
|
rep.width = width;
|
|
|
|
rep.height = height;
|
|
|
|
rep.data_size = size;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
_WriteQueryImageAttributesReply(client, &rep);
|
|
|
|
if (client->swapped)
|
|
|
|
SwapLongs((CARD32 *) offsets, planeLength);
|
|
|
|
WriteToClient(client, planeLength << 2, (char *) offsets);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
free(offsets);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
return Success;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
static int
|
2006-11-26 11:13:41 -07:00
|
|
|
ProcXvListImageFormats(ClientPtr client)
|
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
XvPortPtr pPort;
|
|
|
|
XvImagePtr pImage;
|
|
|
|
int i;
|
|
|
|
xvListImageFormatsReply rep;
|
|
|
|
xvImageFormatInfo info;
|
|
|
|
|
|
|
|
REQUEST(xvListImageFormatsReq);
|
|
|
|
|
|
|
|
REQUEST_SIZE_MATCH(xvListImageFormatsReq);
|
|
|
|
|
|
|
|
VALIDATE_XV_PORT(stuff->port, pPort, DixReadAccess);
|
|
|
|
|
|
|
|
rep.type = X_Reply;
|
|
|
|
rep.sequenceNumber = client->sequence;
|
|
|
|
rep.num_formats = pPort->pAdaptor->nImages;
|
|
|
|
rep.length =
|
|
|
|
bytes_to_int32(pPort->pAdaptor->nImages * sz_xvImageFormatInfo);
|
|
|
|
|
|
|
|
_WriteListImageFormatsReply(client, &rep);
|
|
|
|
|
|
|
|
pImage = pPort->pAdaptor->pImages;
|
|
|
|
|
|
|
|
for (i = 0; i < pPort->pAdaptor->nImages; i++, pImage++) {
|
|
|
|
info.id = pImage->id;
|
|
|
|
info.type = pImage->type;
|
|
|
|
info.byte_order = pImage->byte_order;
|
|
|
|
memcpy(&info.guid, pImage->guid, 16);
|
|
|
|
info.bpp = pImage->bits_per_pixel;
|
|
|
|
info.num_planes = pImage->num_planes;
|
|
|
|
info.depth = pImage->depth;
|
|
|
|
info.red_mask = pImage->red_mask;
|
|
|
|
info.green_mask = pImage->green_mask;
|
|
|
|
info.blue_mask = pImage->blue_mask;
|
|
|
|
info.format = pImage->format;
|
|
|
|
info.y_sample_bits = pImage->y_sample_bits;
|
|
|
|
info.u_sample_bits = pImage->u_sample_bits;
|
|
|
|
info.v_sample_bits = pImage->v_sample_bits;
|
|
|
|
info.horz_y_period = pImage->horz_y_period;
|
|
|
|
info.horz_u_period = pImage->horz_u_period;
|
|
|
|
info.horz_v_period = pImage->horz_v_period;
|
|
|
|
info.vert_y_period = pImage->vert_y_period;
|
|
|
|
info.vert_u_period = pImage->vert_u_period;
|
|
|
|
info.vert_v_period = pImage->vert_v_period;
|
|
|
|
memcpy(&info.comp_order, pImage->component_order, 32);
|
|
|
|
info.scanline_order = pImage->scanline_order;
|
|
|
|
_WriteImageFormatInfo(client, &info);
|
|
|
|
}
|
|
|
|
|
|
|
|
return Success;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int (*XvProcVector[xvNumRequests]) (ClientPtr) = {
|
|
|
|
ProcXvQueryExtension,
|
|
|
|
ProcXvQueryAdaptors,
|
|
|
|
ProcXvQueryEncodings,
|
|
|
|
ProcXvGrabPort,
|
|
|
|
ProcXvUngrabPort,
|
|
|
|
ProcXvPutVideo,
|
|
|
|
ProcXvPutStill,
|
|
|
|
ProcXvGetVideo,
|
|
|
|
ProcXvGetStill,
|
|
|
|
ProcXvStopVideo,
|
|
|
|
ProcXvSelectVideoNotify,
|
|
|
|
ProcXvSelectPortNotify,
|
|
|
|
ProcXvQueryBestSize,
|
|
|
|
ProcXvSetPortAttribute,
|
|
|
|
ProcXvGetPortAttribute,
|
|
|
|
ProcXvQueryPortAttributes,
|
|
|
|
ProcXvListImageFormats,
|
|
|
|
ProcXvQueryImageAttributes, ProcXvPutImage, ProcXvShmPutImage,};
|
2008-11-02 08:26:08 -07:00
|
|
|
|
|
|
|
int
|
|
|
|
ProcXvDispatch(ClientPtr client)
|
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
REQUEST(xReq);
|
2008-11-02 08:26:08 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
UpdateCurrentTime();
|
2008-11-02 08:26:08 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
if (stuff->data >= xvNumRequests) {
|
|
|
|
SendErrorToClient(client, XvReqCode, stuff->data, 0, BadRequest);
|
|
|
|
return BadRequest;
|
|
|
|
}
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
return XvProcVector[stuff->data] (client);
|
2008-11-02 08:26:08 -07:00
|
|
|
}
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
/* Swapped Procs */
|
|
|
|
|
|
|
|
static int
|
|
|
|
SProcXvQueryExtension(ClientPtr client)
|
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
REQUEST(xvQueryExtensionReq);
|
|
|
|
swaps(&stuff->length);
|
|
|
|
return XvProcVector[xv_QueryExtension] (client);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
SProcXvQueryAdaptors(ClientPtr client)
|
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
REQUEST(xvQueryAdaptorsReq);
|
|
|
|
swaps(&stuff->length);
|
|
|
|
swapl(&stuff->window);
|
|
|
|
return XvProcVector[xv_QueryAdaptors] (client);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
SProcXvQueryEncodings(ClientPtr client)
|
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
REQUEST(xvQueryEncodingsReq);
|
|
|
|
swaps(&stuff->length);
|
|
|
|
swapl(&stuff->port);
|
|
|
|
return XvProcVector[xv_QueryEncodings] (client);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
SProcXvGrabPort(ClientPtr client)
|
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
REQUEST(xvGrabPortReq);
|
|
|
|
swaps(&stuff->length);
|
|
|
|
swapl(&stuff->port);
|
|
|
|
swapl(&stuff->time);
|
|
|
|
return XvProcVector[xv_GrabPort] (client);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
SProcXvUngrabPort(ClientPtr client)
|
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
REQUEST(xvUngrabPortReq);
|
|
|
|
swaps(&stuff->length);
|
|
|
|
swapl(&stuff->port);
|
|
|
|
swapl(&stuff->time);
|
|
|
|
return XvProcVector[xv_UngrabPort] (client);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
SProcXvPutVideo(ClientPtr client)
|
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
REQUEST(xvPutVideoReq);
|
|
|
|
swaps(&stuff->length);
|
|
|
|
swapl(&stuff->port);
|
|
|
|
swapl(&stuff->drawable);
|
|
|
|
swapl(&stuff->gc);
|
|
|
|
swaps(&stuff->vid_x);
|
|
|
|
swaps(&stuff->vid_y);
|
|
|
|
swaps(&stuff->vid_w);
|
|
|
|
swaps(&stuff->vid_h);
|
|
|
|
swaps(&stuff->drw_x);
|
|
|
|
swaps(&stuff->drw_y);
|
|
|
|
swaps(&stuff->drw_w);
|
|
|
|
swaps(&stuff->drw_h);
|
|
|
|
return XvProcVector[xv_PutVideo] (client);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
SProcXvPutStill(ClientPtr client)
|
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
REQUEST(xvPutStillReq);
|
|
|
|
swaps(&stuff->length);
|
|
|
|
swapl(&stuff->port);
|
|
|
|
swapl(&stuff->drawable);
|
|
|
|
swapl(&stuff->gc);
|
|
|
|
swaps(&stuff->vid_x);
|
|
|
|
swaps(&stuff->vid_y);
|
|
|
|
swaps(&stuff->vid_w);
|
|
|
|
swaps(&stuff->vid_h);
|
|
|
|
swaps(&stuff->drw_x);
|
|
|
|
swaps(&stuff->drw_y);
|
|
|
|
swaps(&stuff->drw_w);
|
|
|
|
swaps(&stuff->drw_h);
|
|
|
|
return XvProcVector[xv_PutStill] (client);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
SProcXvGetVideo(ClientPtr client)
|
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
REQUEST(xvGetVideoReq);
|
|
|
|
swaps(&stuff->length);
|
|
|
|
swapl(&stuff->port);
|
|
|
|
swapl(&stuff->drawable);
|
|
|
|
swapl(&stuff->gc);
|
|
|
|
swaps(&stuff->vid_x);
|
|
|
|
swaps(&stuff->vid_y);
|
|
|
|
swaps(&stuff->vid_w);
|
|
|
|
swaps(&stuff->vid_h);
|
|
|
|
swaps(&stuff->drw_x);
|
|
|
|
swaps(&stuff->drw_y);
|
|
|
|
swaps(&stuff->drw_w);
|
|
|
|
swaps(&stuff->drw_h);
|
|
|
|
return XvProcVector[xv_GetVideo] (client);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
SProcXvGetStill(ClientPtr client)
|
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
REQUEST(xvGetStillReq);
|
|
|
|
swaps(&stuff->length);
|
|
|
|
swapl(&stuff->port);
|
|
|
|
swapl(&stuff->drawable);
|
|
|
|
swapl(&stuff->gc);
|
|
|
|
swaps(&stuff->vid_x);
|
|
|
|
swaps(&stuff->vid_y);
|
|
|
|
swaps(&stuff->vid_w);
|
|
|
|
swaps(&stuff->vid_h);
|
|
|
|
swaps(&stuff->drw_x);
|
|
|
|
swaps(&stuff->drw_y);
|
|
|
|
swaps(&stuff->drw_w);
|
|
|
|
swaps(&stuff->drw_h);
|
|
|
|
return XvProcVector[xv_GetStill] (client);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
SProcXvPutImage(ClientPtr client)
|
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
REQUEST(xvPutImageReq);
|
|
|
|
swaps(&stuff->length);
|
|
|
|
swapl(&stuff->port);
|
|
|
|
swapl(&stuff->drawable);
|
|
|
|
swapl(&stuff->gc);
|
|
|
|
swapl(&stuff->id);
|
|
|
|
swaps(&stuff->src_x);
|
|
|
|
swaps(&stuff->src_y);
|
|
|
|
swaps(&stuff->src_w);
|
|
|
|
swaps(&stuff->src_h);
|
|
|
|
swaps(&stuff->drw_x);
|
|
|
|
swaps(&stuff->drw_y);
|
|
|
|
swaps(&stuff->drw_w);
|
|
|
|
swaps(&stuff->drw_h);
|
|
|
|
swaps(&stuff->width);
|
|
|
|
swaps(&stuff->height);
|
|
|
|
return XvProcVector[xv_PutImage] (client);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef MITSHM
|
|
|
|
static int
|
|
|
|
SProcXvShmPutImage(ClientPtr client)
|
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
REQUEST(xvShmPutImageReq);
|
|
|
|
swaps(&stuff->length);
|
|
|
|
swapl(&stuff->port);
|
|
|
|
swapl(&stuff->drawable);
|
|
|
|
swapl(&stuff->gc);
|
|
|
|
swapl(&stuff->shmseg);
|
|
|
|
swapl(&stuff->id);
|
|
|
|
swapl(&stuff->offset);
|
|
|
|
swaps(&stuff->src_x);
|
|
|
|
swaps(&stuff->src_y);
|
|
|
|
swaps(&stuff->src_w);
|
|
|
|
swaps(&stuff->src_h);
|
|
|
|
swaps(&stuff->drw_x);
|
|
|
|
swaps(&stuff->drw_y);
|
|
|
|
swaps(&stuff->drw_w);
|
|
|
|
swaps(&stuff->drw_h);
|
|
|
|
swaps(&stuff->width);
|
|
|
|
swaps(&stuff->height);
|
|
|
|
return XvProcVector[xv_ShmPutImage] (client);
|
|
|
|
}
|
|
|
|
#else /* MITSHM */
|
2008-11-02 08:26:08 -07:00
|
|
|
#define SProcXvShmPutImage ProcXvShmPutImage
|
2006-11-26 11:13:41 -07:00
|
|
|
#endif
|
|
|
|
|
|
|
|
static int
|
|
|
|
SProcXvSelectVideoNotify(ClientPtr client)
|
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
REQUEST(xvSelectVideoNotifyReq);
|
|
|
|
swaps(&stuff->length);
|
|
|
|
swapl(&stuff->drawable);
|
|
|
|
return XvProcVector[xv_SelectVideoNotify] (client);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
SProcXvSelectPortNotify(ClientPtr client)
|
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
REQUEST(xvSelectPortNotifyReq);
|
|
|
|
swaps(&stuff->length);
|
|
|
|
swapl(&stuff->port);
|
|
|
|
return XvProcVector[xv_SelectPortNotify] (client);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
SProcXvStopVideo(ClientPtr client)
|
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
REQUEST(xvStopVideoReq);
|
|
|
|
swaps(&stuff->length);
|
|
|
|
swapl(&stuff->port);
|
|
|
|
swapl(&stuff->drawable);
|
|
|
|
return XvProcVector[xv_StopVideo] (client);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
SProcXvSetPortAttribute(ClientPtr client)
|
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
REQUEST(xvSetPortAttributeReq);
|
|
|
|
swaps(&stuff->length);
|
|
|
|
swapl(&stuff->port);
|
|
|
|
swapl(&stuff->attribute);
|
|
|
|
swapl(&stuff->value);
|
|
|
|
return XvProcVector[xv_SetPortAttribute] (client);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
SProcXvGetPortAttribute(ClientPtr client)
|
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
REQUEST(xvGetPortAttributeReq);
|
|
|
|
swaps(&stuff->length);
|
|
|
|
swapl(&stuff->port);
|
|
|
|
swapl(&stuff->attribute);
|
|
|
|
return XvProcVector[xv_GetPortAttribute] (client);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
SProcXvQueryBestSize(ClientPtr client)
|
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
REQUEST(xvQueryBestSizeReq);
|
|
|
|
swaps(&stuff->length);
|
|
|
|
swapl(&stuff->port);
|
|
|
|
swaps(&stuff->vid_w);
|
|
|
|
swaps(&stuff->vid_h);
|
|
|
|
swaps(&stuff->drw_w);
|
|
|
|
swaps(&stuff->drw_h);
|
|
|
|
return XvProcVector[xv_QueryBestSize] (client);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
SProcXvQueryPortAttributes(ClientPtr client)
|
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
REQUEST(xvQueryPortAttributesReq);
|
|
|
|
swaps(&stuff->length);
|
|
|
|
swapl(&stuff->port);
|
|
|
|
return XvProcVector[xv_QueryPortAttributes] (client);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
SProcXvQueryImageAttributes(ClientPtr client)
|
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
REQUEST(xvQueryImageAttributesReq);
|
|
|
|
swaps(&stuff->length);
|
|
|
|
swapl(&stuff->port);
|
|
|
|
swapl(&stuff->id);
|
|
|
|
swaps(&stuff->width);
|
|
|
|
swaps(&stuff->height);
|
|
|
|
return XvProcVector[xv_QueryImageAttributes] (client);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
SProcXvListImageFormats(ClientPtr client)
|
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
REQUEST(xvListImageFormatsReq);
|
|
|
|
swaps(&stuff->length);
|
|
|
|
swapl(&stuff->port);
|
|
|
|
return XvProcVector[xv_ListImageFormats] (client);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int (*SXvProcVector[xvNumRequests]) (ClientPtr) = {
|
|
|
|
SProcXvQueryExtension,
|
|
|
|
SProcXvQueryAdaptors,
|
|
|
|
SProcXvQueryEncodings,
|
|
|
|
SProcXvGrabPort,
|
|
|
|
SProcXvUngrabPort,
|
|
|
|
SProcXvPutVideo,
|
|
|
|
SProcXvPutStill,
|
|
|
|
SProcXvGetVideo,
|
|
|
|
SProcXvGetStill,
|
|
|
|
SProcXvStopVideo,
|
|
|
|
SProcXvSelectVideoNotify,
|
|
|
|
SProcXvSelectPortNotify,
|
|
|
|
SProcXvQueryBestSize,
|
|
|
|
SProcXvSetPortAttribute,
|
|
|
|
SProcXvGetPortAttribute,
|
|
|
|
SProcXvQueryPortAttributes,
|
|
|
|
SProcXvListImageFormats,
|
|
|
|
SProcXvQueryImageAttributes, SProcXvPutImage, SProcXvShmPutImage,};
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2008-11-02 08:26:08 -07:00
|
|
|
int
|
|
|
|
SProcXvDispatch(ClientPtr client)
|
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
REQUEST(xReq);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
UpdateCurrentTime();
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
if (stuff->data >= xvNumRequests) {
|
|
|
|
SendErrorToClient(client, XvReqCode, stuff->data, 0, BadRequest);
|
|
|
|
return BadRequest;
|
|
|
|
}
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
return SXvProcVector[stuff->data] (client);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef PANORAMIX
|
|
|
|
static int
|
|
|
|
XineramaXvStopVideo(ClientPtr client)
|
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
int result, i;
|
|
|
|
PanoramiXRes *draw, *port;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
REQUEST(xvStopVideoReq);
|
|
|
|
REQUEST_SIZE_MATCH(xvStopVideoReq);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
result = dixLookupResourceByClass((pointer *) &draw, stuff->drawable,
|
|
|
|
XRC_DRAWABLE, client, DixWriteAccess);
|
|
|
|
if (result != Success)
|
|
|
|
return (result == BadValue) ? BadDrawable : result;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
result = dixLookupResourceByType((pointer *) &port, stuff->port,
|
|
|
|
XvXRTPort, client, DixReadAccess);
|
|
|
|
if (result != Success)
|
|
|
|
return result;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
FOR_NSCREENS_BACKWARD(i) {
|
|
|
|
if (port->info[i].id) {
|
|
|
|
stuff->drawable = draw->info[i].id;
|
|
|
|
stuff->port = port->info[i].id;
|
|
|
|
result = ProcXvStopVideo(client);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return result;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
XineramaXvSetPortAttribute(ClientPtr client)
|
|
|
|
{
|
|
|
|
REQUEST(xvSetPortAttributeReq);
|
|
|
|
PanoramiXRes *port;
|
2010-07-27 13:02:24 -06:00
|
|
|
int result, i;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
REQUEST_SIZE_MATCH(xvSetPortAttributeReq);
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
result = dixLookupResourceByType((pointer *) &port, stuff->port,
|
|
|
|
XvXRTPort, client, DixReadAccess);
|
2010-07-27 13:02:24 -06:00
|
|
|
if (result != Success)
|
2012-06-10 07:21:05 -06:00
|
|
|
return result;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
FOR_NSCREENS_BACKWARD(i) {
|
2012-06-10 07:21:05 -06:00
|
|
|
if (port->info[i].id) {
|
|
|
|
stuff->port = port->info[i].id;
|
|
|
|
result = ProcXvSetPortAttribute(client);
|
|
|
|
}
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef MITSHM
|
2012-06-10 07:21:05 -06:00
|
|
|
static int
|
2006-11-26 11:13:41 -07:00
|
|
|
XineramaXvShmPutImage(ClientPtr client)
|
|
|
|
{
|
|
|
|
REQUEST(xvShmPutImageReq);
|
|
|
|
PanoramiXRes *draw, *gc, *port;
|
|
|
|
Bool send_event = stuff->send_event;
|
|
|
|
Bool isRoot;
|
2010-07-27 13:02:24 -06:00
|
|
|
int result, i, x, y;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
REQUEST_SIZE_MATCH(xvShmPutImageReq);
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
result = dixLookupResourceByClass((pointer *) &draw, stuff->drawable,
|
|
|
|
XRC_DRAWABLE, client, DixWriteAccess);
|
2010-07-27 13:02:24 -06:00
|
|
|
if (result != Success)
|
2012-06-10 07:21:05 -06:00
|
|
|
return (result == BadValue) ? BadDrawable : result;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
result = dixLookupResourceByType((pointer *) &gc, stuff->gc,
|
|
|
|
XRT_GC, client, DixReadAccess);
|
2010-07-27 13:02:24 -06:00
|
|
|
if (result != Success)
|
2010-12-05 08:36:02 -07:00
|
|
|
return result;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
result = dixLookupResourceByType((pointer *) &port, stuff->port,
|
|
|
|
XvXRTPort, client, DixReadAccess);
|
2010-07-27 13:02:24 -06:00
|
|
|
if (result != Success)
|
2012-06-10 07:21:05 -06:00
|
|
|
return result;
|
|
|
|
|
2006-11-26 11:13:41 -07:00
|
|
|
isRoot = (draw->type == XRT_WINDOW) && draw->u.win.root;
|
|
|
|
|
|
|
|
x = stuff->drw_x;
|
|
|
|
y = stuff->drw_y;
|
|
|
|
|
|
|
|
FOR_NSCREENS_BACKWARD(i) {
|
2012-06-10 07:21:05 -06:00
|
|
|
if (port->info[i].id) {
|
|
|
|
stuff->drawable = draw->info[i].id;
|
|
|
|
stuff->port = port->info[i].id;
|
|
|
|
stuff->gc = gc->info[i].id;
|
|
|
|
stuff->drw_x = x;
|
|
|
|
stuff->drw_y = y;
|
|
|
|
if (isRoot) {
|
|
|
|
stuff->drw_x -= screenInfo.screens[i]->x;
|
|
|
|
stuff->drw_y -= screenInfo.screens[i]->y;
|
|
|
|
}
|
|
|
|
stuff->send_event = (send_event && !i) ? 1 : 0;
|
|
|
|
|
|
|
|
result = ProcXvShmPutImage(client);
|
|
|
|
}
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
2008-11-02 08:26:08 -07:00
|
|
|
#else
|
|
|
|
#define XineramaXvShmPutImage ProcXvShmPutImage
|
2006-11-26 11:13:41 -07:00
|
|
|
#endif
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
static int
|
2006-11-26 11:13:41 -07:00
|
|
|
XineramaXvPutImage(ClientPtr client)
|
|
|
|
{
|
|
|
|
REQUEST(xvPutImageReq);
|
|
|
|
PanoramiXRes *draw, *gc, *port;
|
|
|
|
Bool isRoot;
|
2010-07-27 13:02:24 -06:00
|
|
|
int result, i, x, y;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
REQUEST_AT_LEAST_SIZE(xvPutImageReq);
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
result = dixLookupResourceByClass((pointer *) &draw, stuff->drawable,
|
|
|
|
XRC_DRAWABLE, client, DixWriteAccess);
|
2010-07-27 13:02:24 -06:00
|
|
|
if (result != Success)
|
2012-06-10 07:21:05 -06:00
|
|
|
return (result == BadValue) ? BadDrawable : result;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
result = dixLookupResourceByType((pointer *) &gc, stuff->gc,
|
|
|
|
XRT_GC, client, DixReadAccess);
|
2010-07-27 13:02:24 -06:00
|
|
|
if (result != Success)
|
2010-12-05 08:36:02 -07:00
|
|
|
return result;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
result = dixLookupResourceByType((pointer *) &port, stuff->port,
|
|
|
|
XvXRTPort, client, DixReadAccess);
|
2010-07-27 13:02:24 -06:00
|
|
|
if (result != Success)
|
2012-06-10 07:21:05 -06:00
|
|
|
return result;
|
|
|
|
|
2006-11-26 11:13:41 -07:00
|
|
|
isRoot = (draw->type == XRT_WINDOW) && draw->u.win.root;
|
|
|
|
|
|
|
|
x = stuff->drw_x;
|
|
|
|
y = stuff->drw_y;
|
|
|
|
|
|
|
|
FOR_NSCREENS_BACKWARD(i) {
|
2012-06-10 07:21:05 -06:00
|
|
|
if (port->info[i].id) {
|
|
|
|
stuff->drawable = draw->info[i].id;
|
|
|
|
stuff->port = port->info[i].id;
|
|
|
|
stuff->gc = gc->info[i].id;
|
|
|
|
stuff->drw_x = x;
|
|
|
|
stuff->drw_y = y;
|
|
|
|
if (isRoot) {
|
|
|
|
stuff->drw_x -= screenInfo.screens[i]->x;
|
|
|
|
stuff->drw_y -= screenInfo.screens[i]->y;
|
|
|
|
}
|
|
|
|
|
|
|
|
result = ProcXvPutImage(client);
|
|
|
|
}
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
XineramaXvPutVideo(ClientPtr client)
|
|
|
|
{
|
|
|
|
REQUEST(xvPutImageReq);
|
|
|
|
PanoramiXRes *draw, *gc, *port;
|
|
|
|
Bool isRoot;
|
2010-07-27 13:02:24 -06:00
|
|
|
int result, i, x, y;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
REQUEST_AT_LEAST_SIZE(xvPutVideoReq);
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
result = dixLookupResourceByClass((pointer *) &draw, stuff->drawable,
|
|
|
|
XRC_DRAWABLE, client, DixWriteAccess);
|
2010-07-27 13:02:24 -06:00
|
|
|
if (result != Success)
|
2012-06-10 07:21:05 -06:00
|
|
|
return (result == BadValue) ? BadDrawable : result;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
result = dixLookupResourceByType((pointer *) &gc, stuff->gc,
|
|
|
|
XRT_GC, client, DixReadAccess);
|
2010-07-27 13:02:24 -06:00
|
|
|
if (result != Success)
|
2010-12-05 08:36:02 -07:00
|
|
|
return result;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
result = dixLookupResourceByType((pointer *) &port, stuff->port,
|
|
|
|
XvXRTPort, client, DixReadAccess);
|
2010-07-27 13:02:24 -06:00
|
|
|
if (result != Success)
|
2012-06-10 07:21:05 -06:00
|
|
|
return result;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
isRoot = (draw->type == XRT_WINDOW) && draw->u.win.root;
|
|
|
|
|
|
|
|
x = stuff->drw_x;
|
|
|
|
y = stuff->drw_y;
|
|
|
|
|
|
|
|
FOR_NSCREENS_BACKWARD(i) {
|
2012-06-10 07:21:05 -06:00
|
|
|
if (port->info[i].id) {
|
|
|
|
stuff->drawable = draw->info[i].id;
|
|
|
|
stuff->port = port->info[i].id;
|
|
|
|
stuff->gc = gc->info[i].id;
|
|
|
|
stuff->drw_x = x;
|
|
|
|
stuff->drw_y = y;
|
|
|
|
if (isRoot) {
|
2010-12-05 08:36:02 -07:00
|
|
|
stuff->drw_x -= screenInfo.screens[i]->x;
|
|
|
|
stuff->drw_y -= screenInfo.screens[i]->y;
|
2012-06-10 07:21:05 -06:00
|
|
|
}
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
result = ProcXvPutVideo(client);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
XineramaXvPutStill(ClientPtr client)
|
|
|
|
{
|
|
|
|
REQUEST(xvPutImageReq);
|
|
|
|
PanoramiXRes *draw, *gc, *port;
|
|
|
|
Bool isRoot;
|
2010-07-27 13:02:24 -06:00
|
|
|
int result, i, x, y;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
REQUEST_AT_LEAST_SIZE(xvPutImageReq);
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
result = dixLookupResourceByClass((pointer *) &draw, stuff->drawable,
|
|
|
|
XRC_DRAWABLE, client, DixWriteAccess);
|
2010-07-27 13:02:24 -06:00
|
|
|
if (result != Success)
|
2012-06-10 07:21:05 -06:00
|
|
|
return (result == BadValue) ? BadDrawable : result;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
result = dixLookupResourceByType((pointer *) &gc, stuff->gc,
|
|
|
|
XRT_GC, client, DixReadAccess);
|
2010-07-27 13:02:24 -06:00
|
|
|
if (result != Success)
|
2010-12-05 08:36:02 -07:00
|
|
|
return result;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
result = dixLookupResourceByType((pointer *) &port, stuff->port,
|
|
|
|
XvXRTPort, client, DixReadAccess);
|
2010-07-27 13:02:24 -06:00
|
|
|
if (result != Success)
|
2012-06-10 07:21:05 -06:00
|
|
|
return result;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
isRoot = (draw->type == XRT_WINDOW) && draw->u.win.root;
|
|
|
|
|
|
|
|
x = stuff->drw_x;
|
|
|
|
y = stuff->drw_y;
|
|
|
|
|
|
|
|
FOR_NSCREENS_BACKWARD(i) {
|
2012-06-10 07:21:05 -06:00
|
|
|
if (port->info[i].id) {
|
|
|
|
stuff->drawable = draw->info[i].id;
|
|
|
|
stuff->port = port->info[i].id;
|
|
|
|
stuff->gc = gc->info[i].id;
|
|
|
|
stuff->drw_x = x;
|
|
|
|
stuff->drw_y = y;
|
|
|
|
if (isRoot) {
|
2010-12-05 08:36:02 -07:00
|
|
|
stuff->drw_x -= screenInfo.screens[i]->x;
|
|
|
|
stuff->drw_y -= screenInfo.screens[i]->y;
|
2012-06-10 07:21:05 -06:00
|
|
|
}
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
result = ProcXvPutStill(client);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2010-12-05 08:36:02 -07:00
|
|
|
static Bool
|
|
|
|
isImageAdaptor(XvAdaptorPtr pAdapt)
|
|
|
|
{
|
|
|
|
return (pAdapt->type & XvImageMask) && (pAdapt->nImages > 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
static Bool
|
|
|
|
hasOverlay(XvAdaptorPtr pAdapt)
|
|
|
|
{
|
|
|
|
int i;
|
2012-06-10 07:21:05 -06:00
|
|
|
|
|
|
|
for (i = 0; i < pAdapt->nAttributes; i++)
|
|
|
|
if (!strcmp(pAdapt->pAttributes[i].name, "XV_COLORKEY"))
|
|
|
|
return TRUE;
|
2010-12-05 08:36:02 -07:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static XvAdaptorPtr
|
|
|
|
matchAdaptor(ScreenPtr pScreen, XvAdaptorPtr refAdapt, Bool isOverlay)
|
|
|
|
{
|
|
|
|
int i;
|
2012-06-10 07:21:05 -06:00
|
|
|
XvScreenPtr xvsp =
|
|
|
|
dixLookupPrivate(&pScreen->devPrivates, XvGetScreenKey());
|
2010-12-05 08:36:02 -07:00
|
|
|
/* Do not try to go on if xv is not supported on this screen */
|
2012-06-10 07:21:05 -06:00
|
|
|
if (xvsp == NULL)
|
|
|
|
return NULL;
|
2010-12-05 08:36:02 -07:00
|
|
|
|
|
|
|
/* if the adaptor has the same name it's a perfect match */
|
2012-06-10 07:21:05 -06:00
|
|
|
for (i = 0; i < xvsp->nAdaptors; i++) {
|
|
|
|
XvAdaptorPtr pAdapt = xvsp->pAdaptors + i;
|
|
|
|
|
|
|
|
if (!strcmp(refAdapt->name, pAdapt->name))
|
|
|
|
return pAdapt;
|
2010-12-05 08:36:02 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
/* otherwise we only look for XvImage adaptors */
|
2012-06-10 07:21:05 -06:00
|
|
|
if (!isImageAdaptor(refAdapt))
|
|
|
|
return NULL;
|
2010-12-05 08:36:02 -07:00
|
|
|
|
|
|
|
/* prefer overlay/overlay non-overlay/non-overlay pairing */
|
2012-06-10 07:21:05 -06:00
|
|
|
for (i = 0; i < xvsp->nAdaptors; i++) {
|
|
|
|
XvAdaptorPtr pAdapt = xvsp->pAdaptors + i;
|
|
|
|
|
|
|
|
if (isImageAdaptor(pAdapt) && isOverlay == hasOverlay(pAdapt))
|
|
|
|
return pAdapt;
|
2010-12-05 08:36:02 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
/* but we'll take any XvImage pairing if we can get it */
|
2012-06-10 07:21:05 -06:00
|
|
|
for (i = 0; i < xvsp->nAdaptors; i++) {
|
|
|
|
XvAdaptorPtr pAdapt = xvsp->pAdaptors + i;
|
|
|
|
|
|
|
|
if (isImageAdaptor(pAdapt))
|
|
|
|
return pAdapt;
|
2010-12-05 08:36:02 -07:00
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
void
|
|
|
|
XineramifyXv(void)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
XvScreenPtr xvsp0 =
|
|
|
|
dixLookupPrivate(&screenInfo.screens[0]->devPrivates, XvGetScreenKey());
|
|
|
|
XvAdaptorPtr MatchingAdaptors[MAXSCREENS];
|
|
|
|
int i, j, k;
|
|
|
|
|
|
|
|
XvXRTPort = CreateNewResourceType(XineramaDeleteResource, "XvXRTPort");
|
|
|
|
|
|
|
|
if (!xvsp0 || !XvXRTPort)
|
|
|
|
return;
|
|
|
|
SetResourceTypeErrorValue(XvXRTPort, _XvBadPort);
|
|
|
|
|
|
|
|
for (i = 0; i < xvsp0->nAdaptors; i++) {
|
|
|
|
Bool isOverlay;
|
|
|
|
XvAdaptorPtr refAdapt = xvsp0->pAdaptors + i;
|
|
|
|
|
|
|
|
if (!(refAdapt->type & XvInputMask))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
MatchingAdaptors[0] = refAdapt;
|
|
|
|
isOverlay = hasOverlay(refAdapt);
|
|
|
|
FOR_NSCREENS_FORWARD_SKIP(j)
|
|
|
|
MatchingAdaptors[j] =
|
|
|
|
matchAdaptor(screenInfo.screens[j], refAdapt, isOverlay);
|
|
|
|
|
|
|
|
/* now create a resource for each port */
|
|
|
|
for (j = 0; j < refAdapt->nPorts; j++) {
|
|
|
|
PanoramiXRes *port = malloc(sizeof(PanoramiXRes));
|
|
|
|
|
|
|
|
if (!port)
|
|
|
|
break;
|
|
|
|
|
|
|
|
FOR_NSCREENS(k) {
|
|
|
|
if (MatchingAdaptors[k] && (MatchingAdaptors[k]->nPorts > j))
|
|
|
|
port->info[k].id = MatchingAdaptors[k]->base_id + j;
|
|
|
|
else
|
|
|
|
port->info[k].id = 0;
|
|
|
|
}
|
|
|
|
AddResource(port->info[0].id, XvXRTPort, port);
|
|
|
|
}
|
|
|
|
}
|
2008-11-02 08:26:08 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
/* munge the dispatch vector */
|
|
|
|
XvProcVector[xv_PutVideo] = XineramaXvPutVideo;
|
|
|
|
XvProcVector[xv_PutStill] = XineramaXvPutStill;
|
|
|
|
XvProcVector[xv_StopVideo] = XineramaXvStopVideo;
|
|
|
|
XvProcVector[xv_SetPortAttribute] = XineramaXvSetPortAttribute;
|
|
|
|
XvProcVector[xv_PutImage] = XineramaXvPutImage;
|
|
|
|
XvProcVector[xv_ShmPutImage] = XineramaXvShmPutImage;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
2012-06-10 07:21:05 -06:00
|
|
|
#endif /* PANORAMIX */
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2008-11-02 08:26:08 -07:00
|
|
|
void
|
|
|
|
XvResetProcVector(void)
|
|
|
|
{
|
|
|
|
#ifdef PANORAMIX
|
2012-06-10 07:21:05 -06:00
|
|
|
XvProcVector[xv_PutVideo] = ProcXvPutVideo;
|
|
|
|
XvProcVector[xv_PutStill] = ProcXvPutStill;
|
|
|
|
XvProcVector[xv_StopVideo] = ProcXvStopVideo;
|
|
|
|
XvProcVector[xv_SetPortAttribute] = ProcXvSetPortAttribute;
|
|
|
|
XvProcVector[xv_PutImage] = ProcXvPutImage;
|
|
|
|
XvProcVector[xv_ShmPutImage] = ProcXvShmPutImage;
|
2006-11-26 11:13:41 -07:00
|
|
|
#endif
|
2008-11-02 08:26:08 -07:00
|
|
|
}
|