2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
#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 "os.h"
|
|
|
|
#include "dixstruct.h"
|
|
|
|
#include "resource.h"
|
|
|
|
#include "scrnintstr.h"
|
|
|
|
#include "extnsionst.h"
|
2013-06-07 11:28:45 -06:00
|
|
|
#include "extinit.h"
|
2006-11-26 11:13:41 -07:00
|
|
|
#include "servermd.h"
|
|
|
|
#include <X11/Xfuncproto.h>
|
|
|
|
#include "xvdix.h"
|
|
|
|
#include <X11/extensions/XvMC.h>
|
|
|
|
#include <X11/extensions/Xvproto.h>
|
|
|
|
#include <X11/extensions/XvMCproto.h>
|
|
|
|
#include "xvmcext.h"
|
2010-07-27 13:02:24 -06:00
|
|
|
#include "protocol-versions.h"
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
#ifdef HAS_XVMCSHM
|
|
|
|
#include <sys/ipc.h>
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/shm.h>
|
2012-06-10 07:21:05 -06:00
|
|
|
#endif /* HAS_XVMCSHM */
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
#define DR_CLIENT_DRIVER_NAME_SIZE 48
|
|
|
|
#define DR_BUSID_SIZE 48
|
|
|
|
|
2010-12-05 08:36:02 -07:00
|
|
|
static DevPrivateKeyRec XvMCScreenKeyRec;
|
2012-06-10 07:21:05 -06:00
|
|
|
|
2010-12-05 08:36:02 -07:00
|
|
|
#define XvMCScreenKey (&XvMCScreenKeyRec)
|
|
|
|
static Bool XvMCInUse;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
int XvMCReqCode;
|
|
|
|
int XvMCEventBase;
|
|
|
|
|
2011-11-05 07:32:40 -06:00
|
|
|
static RESTYPE XvMCRTContext;
|
|
|
|
static RESTYPE XvMCRTSurface;
|
|
|
|
static RESTYPE XvMCRTSubpicture;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2013-06-07 11:28:45 -06:00
|
|
|
int (*XvMCScreenInitProc)(ScreenPtr, int, XvMCAdaptorPtr) = NULL;
|
|
|
|
|
2006-11-26 11:13:41 -07:00
|
|
|
typedef struct {
|
2012-06-10 07:21:05 -06:00
|
|
|
int num_adaptors;
|
|
|
|
XvMCAdaptorPtr adaptors;
|
|
|
|
CloseScreenProcPtr CloseScreen;
|
|
|
|
char clientDriverName[DR_CLIENT_DRIVER_NAME_SIZE];
|
|
|
|
char busID[DR_BUSID_SIZE];
|
|
|
|
int major;
|
|
|
|
int minor;
|
|
|
|
int patchLevel;
|
|
|
|
} XvMCScreenRec, *XvMCScreenPtr;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
#define XVMC_GET_PRIVATE(pScreen) \
|
2008-11-02 08:26:08 -07:00
|
|
|
(XvMCScreenPtr)(dixLookupPrivate(&(pScreen)->devPrivates, XvMCScreenKey))
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
static int
|
|
|
|
XvMCDestroyContextRes(pointer data, XID id)
|
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
XvMCContextPtr pContext = (XvMCContextPtr) data;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
pContext->refcnt--;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
if (!pContext->refcnt) {
|
|
|
|
XvMCScreenPtr pScreenPriv = XVMC_GET_PRIVATE(pContext->pScreen);
|
|
|
|
|
|
|
|
(*pScreenPriv->adaptors[pContext->adapt_num].DestroyContext) (pContext);
|
|
|
|
free(pContext);
|
|
|
|
}
|
|
|
|
|
|
|
|
return Success;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
XvMCDestroySurfaceRes(pointer data, XID id)
|
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
XvMCSurfacePtr pSurface = (XvMCSurfacePtr) data;
|
|
|
|
XvMCContextPtr pContext = pSurface->context;
|
|
|
|
XvMCScreenPtr pScreenPriv = XVMC_GET_PRIVATE(pContext->pScreen);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
(*pScreenPriv->adaptors[pContext->adapt_num].DestroySurface) (pSurface);
|
|
|
|
free(pSurface);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
XvMCDestroyContextRes((pointer) pContext, pContext->context_id);
|
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
|
|
|
|
XvMCDestroySubpictureRes(pointer data, XID id)
|
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
XvMCSubpicturePtr pSubpict = (XvMCSubpicturePtr) data;
|
|
|
|
XvMCContextPtr pContext = pSubpict->context;
|
|
|
|
XvMCScreenPtr pScreenPriv = XVMC_GET_PRIVATE(pContext->pScreen);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
(*pScreenPriv->adaptors[pContext->adapt_num].DestroySubpicture) (pSubpict);
|
|
|
|
free(pSubpict);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
XvMCDestroyContextRes((pointer) pContext, pContext->context_id);
|
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
|
|
|
ProcXvMCQueryVersion(ClientPtr client)
|
|
|
|
{
|
2013-06-07 11:28:45 -06:00
|
|
|
xvmcQueryVersionReply rep = {
|
|
|
|
.type = X_Reply,
|
|
|
|
.sequenceNumber = client->sequence,
|
|
|
|
.length = 0,
|
|
|
|
.major = SERVER_XVMC_MAJOR_VERSION,
|
|
|
|
.minor = SERVER_XVMC_MINOR_VERSION
|
|
|
|
};
|
2012-06-10 07:21:05 -06:00
|
|
|
|
2006-11-26 11:13:41 -07:00
|
|
|
/* REQUEST(xvmcQueryVersionReq); */
|
|
|
|
REQUEST_SIZE_MATCH(xvmcQueryVersionReq);
|
2013-06-07 11:28:45 -06:00
|
|
|
|
|
|
|
WriteToClient(client, sizeof(xvmcQueryVersionReply), &rep);
|
2006-11-26 11:13:41 -07:00
|
|
|
return Success;
|
|
|
|
}
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
static int
|
2006-11-26 11:13:41 -07:00
|
|
|
ProcXvMCListSurfaceTypes(ClientPtr client)
|
|
|
|
{
|
|
|
|
XvPortPtr pPort;
|
|
|
|
int i;
|
|
|
|
XvMCScreenPtr pScreenPriv;
|
|
|
|
xvmcListSurfaceTypesReply rep;
|
|
|
|
xvmcSurfaceInfo info;
|
|
|
|
XvMCAdaptorPtr adaptor = NULL;
|
|
|
|
XvMCSurfaceInfoPtr surface;
|
2013-06-07 11:28:45 -06:00
|
|
|
int num_surfaces;
|
2012-06-10 07:21:05 -06:00
|
|
|
|
2006-11-26 11:13:41 -07:00
|
|
|
REQUEST(xvmcListSurfaceTypesReq);
|
|
|
|
REQUEST_SIZE_MATCH(xvmcListSurfaceTypesReq);
|
|
|
|
|
2010-07-27 13:02:24 -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 (XvMCInUse) { /* any adaptors at all */
|
|
|
|
ScreenPtr pScreen = pPort->pAdaptor->pScreen;
|
|
|
|
|
|
|
|
if ((pScreenPriv = XVMC_GET_PRIVATE(pScreen))) { /* any this screen */
|
|
|
|
for (i = 0; i < pScreenPriv->num_adaptors; i++) {
|
|
|
|
if (pPort->pAdaptor == pScreenPriv->adaptors[i].xv_adaptor) {
|
|
|
|
adaptor = &(pScreenPriv->adaptors[i]);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
2013-06-07 11:28:45 -06:00
|
|
|
num_surfaces = (adaptor) ? adaptor->num_surfaces : 0;
|
|
|
|
rep = (xvmcListSurfaceTypesReply) {
|
|
|
|
.type = X_Reply,
|
|
|
|
.sequenceNumber = client->sequence,
|
|
|
|
.num = num_surfaces,
|
|
|
|
.length = bytes_to_int32(num_surfaces * sizeof(xvmcSurfaceInfo)),
|
|
|
|
};
|
2012-06-10 07:21:05 -06:00
|
|
|
|
2013-06-07 11:28:45 -06:00
|
|
|
WriteToClient(client, sizeof(xvmcListSurfaceTypesReply), &rep);
|
2012-06-10 07:21:05 -06:00
|
|
|
|
2013-06-07 11:28:45 -06:00
|
|
|
for (i = 0; i < num_surfaces; i++) {
|
2012-06-10 07:21:05 -06:00
|
|
|
surface = adaptor->surfaces[i];
|
|
|
|
info.surface_type_id = surface->surface_type_id;
|
|
|
|
info.chroma_format = surface->chroma_format;
|
|
|
|
info.max_width = surface->max_width;
|
|
|
|
info.max_height = surface->max_height;
|
|
|
|
info.subpicture_max_width = surface->subpicture_max_width;
|
|
|
|
info.subpicture_max_height = surface->subpicture_max_height;
|
|
|
|
info.mc_type = surface->mc_type;
|
|
|
|
info.flags = surface->flags;
|
2013-06-07 11:28:45 -06:00
|
|
|
WriteToClient(client, sizeof(xvmcSurfaceInfo), &info);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
return Success;
|
|
|
|
}
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
static int
|
2006-11-26 11:13:41 -07:00
|
|
|
ProcXvMCCreateContext(ClientPtr client)
|
|
|
|
{
|
|
|
|
XvPortPtr pPort;
|
|
|
|
CARD32 *data = NULL;
|
2012-06-10 07:21:05 -06:00
|
|
|
int dwords = 0;
|
2006-11-26 11:13:41 -07:00
|
|
|
int i, result, adapt_num = -1;
|
|
|
|
ScreenPtr pScreen;
|
|
|
|
XvMCContextPtr pContext;
|
|
|
|
XvMCScreenPtr pScreenPriv;
|
|
|
|
XvMCAdaptorPtr adaptor = NULL;
|
|
|
|
XvMCSurfaceInfoPtr surface = NULL;
|
|
|
|
xvmcCreateContextReply rep;
|
2012-06-10 07:21:05 -06:00
|
|
|
|
2006-11-26 11:13:41 -07:00
|
|
|
REQUEST(xvmcCreateContextReq);
|
|
|
|
REQUEST_SIZE_MATCH(xvmcCreateContextReq);
|
|
|
|
|
2010-07-27 13:02:24 -06:00
|
|
|
VALIDATE_XV_PORT(stuff->port, pPort, DixReadAccess);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
pScreen = pPort->pAdaptor->pScreen;
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
if (!XvMCInUse) /* no XvMC adaptors */
|
|
|
|
return BadMatch;
|
|
|
|
|
|
|
|
if (!(pScreenPriv = XVMC_GET_PRIVATE(pScreen))) /* none this screen */
|
|
|
|
return BadMatch;
|
|
|
|
|
|
|
|
for (i = 0; i < pScreenPriv->num_adaptors; i++) {
|
|
|
|
if (pPort->pAdaptor == pScreenPriv->adaptors[i].xv_adaptor) {
|
|
|
|
adaptor = &(pScreenPriv->adaptors[i]);
|
|
|
|
adapt_num = i;
|
|
|
|
break;
|
|
|
|
}
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
if (adapt_num < 0) /* none this port */
|
|
|
|
return BadMatch;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
for (i = 0; i < adaptor->num_surfaces; i++) {
|
|
|
|
if (adaptor->surfaces[i]->surface_type_id == stuff->surface_type_id) {
|
2006-11-26 11:13:41 -07:00
|
|
|
surface = adaptor->surfaces[i];
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* adaptor doesn't support this suface_type_id */
|
2012-06-10 07:21:05 -06:00
|
|
|
if (!surface)
|
|
|
|
return BadMatch;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
if ((stuff->width > surface->max_width) ||
|
|
|
|
(stuff->height > surface->max_height))
|
2006-11-26 11:13:41 -07:00
|
|
|
return BadValue;
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
if (!(pContext = malloc(sizeof(XvMCContextRec)))) {
|
|
|
|
return BadAlloc;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
pContext->pScreen = pScreen;
|
|
|
|
pContext->adapt_num = adapt_num;
|
|
|
|
pContext->context_id = stuff->context_id;
|
|
|
|
pContext->surface_type_id = stuff->surface_type_id;
|
|
|
|
pContext->width = stuff->width;
|
|
|
|
pContext->height = stuff->height;
|
|
|
|
pContext->flags = stuff->flags;
|
|
|
|
pContext->refcnt = 1;
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
result = (*adaptor->CreateContext) (pPort, pContext, &dwords, &data);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
if (result != Success) {
|
|
|
|
free(pContext);
|
|
|
|
return result;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
2013-06-07 11:28:45 -06:00
|
|
|
rep = (xvmcCreateContextReply) {
|
|
|
|
.type = X_Reply,
|
|
|
|
.sequenceNumber = client->sequence,
|
|
|
|
.length = dwords,
|
|
|
|
.width_actual = pContext->width,
|
|
|
|
.height_actual = pContext->height,
|
|
|
|
.flags_return = pContext->flags
|
|
|
|
};
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2013-06-07 11:28:45 -06:00
|
|
|
WriteToClient(client, sizeof(xvmcCreateContextReply), &rep);
|
2012-06-10 07:21:05 -06:00
|
|
|
if (dwords)
|
2013-06-07 11:28:45 -06:00
|
|
|
WriteToClient(client, dwords << 2, data);
|
2006-11-26 11:13:41 -07:00
|
|
|
AddResource(pContext->context_id, XvMCRTContext, pContext);
|
|
|
|
|
2010-12-05 08:36:02 -07:00
|
|
|
free(data);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
return Success;
|
|
|
|
}
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
static int
|
2006-11-26 11:13:41 -07:00
|
|
|
ProcXvMCDestroyContext(ClientPtr client)
|
|
|
|
{
|
2010-07-27 13:02:24 -06:00
|
|
|
pointer val;
|
|
|
|
int rc;
|
2012-06-10 07:21:05 -06:00
|
|
|
|
2006-11-26 11:13:41 -07:00
|
|
|
REQUEST(xvmcDestroyContextReq);
|
|
|
|
REQUEST_SIZE_MATCH(xvmcDestroyContextReq);
|
|
|
|
|
2010-07-27 13:02:24 -06:00
|
|
|
rc = dixLookupResourceByType(&val, stuff->context_id, XvMCRTContext,
|
2012-06-10 07:21:05 -06:00
|
|
|
client, DixDestroyAccess);
|
2010-07-27 13:02:24 -06:00
|
|
|
if (rc != Success)
|
2012-06-10 07:21:05 -06:00
|
|
|
return rc;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
FreeResource(stuff->context_id, RT_NONE);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
return Success;
|
|
|
|
}
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
static int
|
2006-11-26 11:13:41 -07:00
|
|
|
ProcXvMCCreateSurface(ClientPtr client)
|
|
|
|
{
|
|
|
|
CARD32 *data = NULL;
|
|
|
|
int dwords = 0;
|
|
|
|
int result;
|
|
|
|
XvMCContextPtr pContext;
|
|
|
|
XvMCSurfacePtr pSurface;
|
|
|
|
XvMCScreenPtr pScreenPriv;
|
|
|
|
xvmcCreateSurfaceReply rep;
|
2012-06-10 07:21:05 -06:00
|
|
|
|
2006-11-26 11:13:41 -07:00
|
|
|
REQUEST(xvmcCreateSurfaceReq);
|
|
|
|
REQUEST_SIZE_MATCH(xvmcCreateSurfaceReq);
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
result = dixLookupResourceByType((pointer *) &pContext, stuff->context_id,
|
|
|
|
XvMCRTContext, client, DixUseAccess);
|
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
|
|
|
|
|
|
|
pScreenPriv = XVMC_GET_PRIVATE(pContext->pScreen);
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
if (!(pSurface = malloc(sizeof(XvMCSurfaceRec))))
|
2006-11-26 11:13:41 -07:00
|
|
|
return BadAlloc;
|
|
|
|
|
|
|
|
pSurface->surface_id = stuff->surface_id;
|
|
|
|
pSurface->surface_type_id = pContext->surface_type_id;
|
|
|
|
pSurface->context = pContext;
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
result =
|
|
|
|
(*pScreenPriv->adaptors[pContext->adapt_num].CreateSurface) (pSurface,
|
|
|
|
&dwords,
|
|
|
|
&data);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
if (result != Success) {
|
2010-12-05 08:36:02 -07:00
|
|
|
free(pSurface);
|
2006-11-26 11:13:41 -07:00
|
|
|
return result;
|
|
|
|
}
|
2013-06-07 11:28:45 -06:00
|
|
|
rep = (xvmcCreateSurfaceReply) {
|
|
|
|
.type = X_Reply,
|
|
|
|
.sequenceNumber = client->sequence,
|
|
|
|
.length = dwords
|
|
|
|
};
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2013-06-07 11:28:45 -06:00
|
|
|
WriteToClient(client, sizeof(xvmcCreateSurfaceReply), &rep);
|
2012-06-10 07:21:05 -06:00
|
|
|
if (dwords)
|
2013-06-07 11:28:45 -06:00
|
|
|
WriteToClient(client, dwords << 2, data);
|
2006-11-26 11:13:41 -07:00
|
|
|
AddResource(pSurface->surface_id, XvMCRTSurface, pSurface);
|
|
|
|
|
2010-12-05 08:36:02 -07:00
|
|
|
free(data);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
pContext->refcnt++;
|
|
|
|
|
|
|
|
return Success;
|
|
|
|
}
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
static int
|
2006-11-26 11:13:41 -07:00
|
|
|
ProcXvMCDestroySurface(ClientPtr client)
|
|
|
|
{
|
2010-07-27 13:02:24 -06:00
|
|
|
pointer val;
|
|
|
|
int rc;
|
2012-06-10 07:21:05 -06:00
|
|
|
|
2006-11-26 11:13:41 -07:00
|
|
|
REQUEST(xvmcDestroySurfaceReq);
|
|
|
|
REQUEST_SIZE_MATCH(xvmcDestroySurfaceReq);
|
|
|
|
|
2010-07-27 13:02:24 -06:00
|
|
|
rc = dixLookupResourceByType(&val, stuff->surface_id, XvMCRTSurface,
|
2012-06-10 07:21:05 -06:00
|
|
|
client, DixDestroyAccess);
|
2010-07-27 13:02:24 -06:00
|
|
|
if (rc != Success)
|
2010-12-05 08:36:02 -07:00
|
|
|
return rc;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
FreeResource(stuff->surface_id, RT_NONE);
|
|
|
|
|
|
|
|
return Success;
|
|
|
|
}
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
static int
|
2006-11-26 11:13:41 -07:00
|
|
|
ProcXvMCCreateSubpicture(ClientPtr client)
|
|
|
|
{
|
|
|
|
Bool image_supported = FALSE;
|
|
|
|
CARD32 *data = NULL;
|
|
|
|
int i, result, dwords = 0;
|
|
|
|
XvMCContextPtr pContext;
|
|
|
|
XvMCSubpicturePtr pSubpicture;
|
|
|
|
XvMCScreenPtr pScreenPriv;
|
|
|
|
xvmcCreateSubpictureReply rep;
|
|
|
|
XvMCAdaptorPtr adaptor;
|
|
|
|
XvMCSurfaceInfoPtr surface = NULL;
|
2012-06-10 07:21:05 -06:00
|
|
|
|
2006-11-26 11:13:41 -07:00
|
|
|
REQUEST(xvmcCreateSubpictureReq);
|
|
|
|
REQUEST_SIZE_MATCH(xvmcCreateSubpictureReq);
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
result = dixLookupResourceByType((pointer *) &pContext, stuff->context_id,
|
|
|
|
XvMCRTContext, client, DixUseAccess);
|
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
|
|
|
|
|
|
|
pScreenPriv = XVMC_GET_PRIVATE(pContext->pScreen);
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
adaptor = &(pScreenPriv->adaptors[pContext->adapt_num]);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
/* find which surface this context supports */
|
2012-06-10 07:21:05 -06:00
|
|
|
for (i = 0; i < adaptor->num_surfaces; i++) {
|
|
|
|
if (adaptor->surfaces[i]->surface_type_id == pContext->surface_type_id) {
|
|
|
|
surface = adaptor->surfaces[i];
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
if (!surface)
|
|
|
|
return BadMatch;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
/* make sure this surface supports that xvimage format */
|
2012-06-10 07:21:05 -06:00
|
|
|
if (!surface->compatible_subpictures)
|
|
|
|
return BadMatch;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
for (i = 0; i < surface->compatible_subpictures->num_xvimages; i++) {
|
|
|
|
if (surface->compatible_subpictures->xvimage_ids[i] ==
|
|
|
|
stuff->xvimage_id) {
|
|
|
|
image_supported = TRUE;
|
|
|
|
break;
|
|
|
|
}
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
if (!image_supported)
|
|
|
|
return BadMatch;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
/* make sure the size is OK */
|
2012-06-10 07:21:05 -06:00
|
|
|
if ((stuff->width > surface->subpicture_max_width) ||
|
|
|
|
(stuff->height > surface->subpicture_max_height))
|
|
|
|
return BadValue;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
if (!(pSubpicture = malloc(sizeof(XvMCSubpictureRec))))
|
2006-11-26 11:13:41 -07:00
|
|
|
return BadAlloc;
|
|
|
|
|
|
|
|
pSubpicture->subpicture_id = stuff->subpicture_id;
|
|
|
|
pSubpicture->xvimage_id = stuff->xvimage_id;
|
|
|
|
pSubpicture->width = stuff->width;
|
|
|
|
pSubpicture->height = stuff->height;
|
2012-06-10 07:21:05 -06:00
|
|
|
pSubpicture->num_palette_entries = 0; /* overwritten by DDX */
|
|
|
|
pSubpicture->entry_bytes = 0; /* overwritten by DDX */
|
|
|
|
pSubpicture->component_order[0] = 0; /* overwritten by DDX */
|
2006-11-26 11:13:41 -07:00
|
|
|
pSubpicture->component_order[1] = 0;
|
|
|
|
pSubpicture->component_order[2] = 0;
|
|
|
|
pSubpicture->component_order[3] = 0;
|
|
|
|
pSubpicture->context = pContext;
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
result =
|
|
|
|
(*pScreenPriv->adaptors[pContext->adapt_num].
|
|
|
|
CreateSubpicture) (pSubpicture, &dwords, &data);
|
|
|
|
|
|
|
|
if (result != Success) {
|
2010-12-05 08:36:02 -07:00
|
|
|
free(pSubpicture);
|
2006-11-26 11:13:41 -07:00
|
|
|
return result;
|
|
|
|
}
|
2013-06-07 11:28:45 -06:00
|
|
|
rep = (xvmcCreateSubpictureReply) {
|
|
|
|
.type = X_Reply,
|
|
|
|
.sequenceNumber = client->sequence,
|
|
|
|
.length = dwords,
|
|
|
|
.width_actual = pSubpicture->width,
|
|
|
|
.height_actual = pSubpicture->height,
|
|
|
|
.num_palette_entries = pSubpicture->num_palette_entries,
|
|
|
|
.entry_bytes = pSubpicture->entry_bytes,
|
|
|
|
.component_order[0] = pSubpicture->component_order[0],
|
|
|
|
.component_order[1] = pSubpicture->component_order[1],
|
|
|
|
.component_order[2] = pSubpicture->component_order[2],
|
|
|
|
.component_order[3] = pSubpicture->component_order[3]
|
|
|
|
};
|
|
|
|
|
|
|
|
WriteToClient(client, sizeof(xvmcCreateSubpictureReply), &rep);
|
2012-06-10 07:21:05 -06:00
|
|
|
if (dwords)
|
2013-06-07 11:28:45 -06:00
|
|
|
WriteToClient(client, dwords << 2, data);
|
2006-11-26 11:13:41 -07:00
|
|
|
AddResource(pSubpicture->subpicture_id, XvMCRTSubpicture, pSubpicture);
|
|
|
|
|
2010-12-05 08:36:02 -07:00
|
|
|
free(data);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
pContext->refcnt++;
|
|
|
|
|
|
|
|
return Success;
|
|
|
|
}
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
static int
|
2006-11-26 11:13:41 -07:00
|
|
|
ProcXvMCDestroySubpicture(ClientPtr client)
|
|
|
|
{
|
2010-07-27 13:02:24 -06:00
|
|
|
pointer val;
|
|
|
|
int rc;
|
2012-06-10 07:21:05 -06:00
|
|
|
|
2006-11-26 11:13:41 -07:00
|
|
|
REQUEST(xvmcDestroySubpictureReq);
|
|
|
|
REQUEST_SIZE_MATCH(xvmcDestroySubpictureReq);
|
|
|
|
|
2010-07-27 13:02:24 -06:00
|
|
|
rc = dixLookupResourceByType(&val, stuff->subpicture_id, XvMCRTSubpicture,
|
2012-06-10 07:21:05 -06:00
|
|
|
client, DixDestroyAccess);
|
2010-07-27 13:02:24 -06:00
|
|
|
if (rc != Success)
|
2010-12-05 08:36:02 -07:00
|
|
|
return rc;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
FreeResource(stuff->subpicture_id, RT_NONE);
|
|
|
|
|
|
|
|
return Success;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
ProcXvMCListSubpictureTypes(ClientPtr client)
|
|
|
|
{
|
|
|
|
XvPortPtr pPort;
|
|
|
|
xvmcListSubpictureTypesReply rep;
|
|
|
|
XvMCScreenPtr pScreenPriv;
|
|
|
|
ScreenPtr pScreen;
|
|
|
|
XvMCAdaptorPtr adaptor = NULL;
|
|
|
|
XvMCSurfaceInfoPtr surface = NULL;
|
|
|
|
xvImageFormatInfo info;
|
|
|
|
XvImagePtr pImage;
|
|
|
|
int i, j;
|
2012-06-10 07:21:05 -06:00
|
|
|
|
2006-11-26 11:13:41 -07:00
|
|
|
REQUEST(xvmcListSubpictureTypesReq);
|
|
|
|
REQUEST_SIZE_MATCH(xvmcListSubpictureTypesReq);
|
|
|
|
|
2010-07-27 13:02:24 -06:00
|
|
|
VALIDATE_XV_PORT(stuff->port, pPort, DixReadAccess);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
pScreen = pPort->pAdaptor->pScreen;
|
|
|
|
|
2011-11-05 07:32:40 -06:00
|
|
|
if (!dixPrivateKeyRegistered(XvMCScreenKey))
|
2012-06-10 07:21:05 -06:00
|
|
|
return BadMatch; /* No XvMC adaptors */
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
if (!(pScreenPriv = XVMC_GET_PRIVATE(pScreen)))
|
|
|
|
return BadMatch; /* None this screen */
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
for (i = 0; i < pScreenPriv->num_adaptors; i++) {
|
|
|
|
if (pPort->pAdaptor == pScreenPriv->adaptors[i].xv_adaptor) {
|
2006-11-26 11:13:41 -07:00
|
|
|
adaptor = &(pScreenPriv->adaptors[i]);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
if (!adaptor)
|
|
|
|
return BadMatch;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
for (i = 0; i < adaptor->num_surfaces; i++) {
|
|
|
|
if (adaptor->surfaces[i]->surface_type_id == stuff->surface_type_id) {
|
2006-11-26 11:13:41 -07:00
|
|
|
surface = adaptor->surfaces[i];
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
if (!surface)
|
|
|
|
return BadMatch;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2013-06-07 11:28:45 -06:00
|
|
|
rep = (xvmcListSubpictureTypesReply) {
|
|
|
|
.type = X_Reply,
|
|
|
|
.sequenceNumber = client->sequence,
|
|
|
|
.num = 0
|
|
|
|
};
|
2012-06-10 07:21:05 -06:00
|
|
|
if (surface->compatible_subpictures)
|
|
|
|
rep.num = surface->compatible_subpictures->num_xvimages;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2010-07-27 13:02:24 -06:00
|
|
|
rep.length = bytes_to_int32(rep.num * sizeof(xvImageFormatInfo));
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2013-06-07 11:28:45 -06:00
|
|
|
WriteToClient(client, sizeof(xvmcListSubpictureTypesReply), &rep);
|
2012-06-10 07:21:05 -06:00
|
|
|
|
|
|
|
for (i = 0; i < rep.num; i++) {
|
|
|
|
pImage = NULL;
|
|
|
|
for (j = 0; j < adaptor->num_subpictures; j++) {
|
|
|
|
if (surface->compatible_subpictures->xvimage_ids[i] ==
|
|
|
|
adaptor->subpictures[j]->id) {
|
|
|
|
pImage = adaptor->subpictures[j];
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!pImage)
|
|
|
|
return BadImplementation;
|
|
|
|
|
|
|
|
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);
|
2006-11-26 11:13:41 -07:00
|
|
|
info.scanline_order = pImage->scanline_order;
|
2013-06-07 11:28:45 -06:00
|
|
|
WriteToClient(client, sizeof(xvImageFormatInfo), &info);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
return Success;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
ProcXvMCGetDRInfo(ClientPtr client)
|
|
|
|
{
|
|
|
|
xvmcGetDRInfoReply rep;
|
|
|
|
XvPortPtr pPort;
|
|
|
|
ScreenPtr pScreen;
|
|
|
|
XvMCScreenPtr pScreenPriv;
|
|
|
|
|
|
|
|
#ifdef HAS_XVMCSHM
|
|
|
|
volatile CARD32 *patternP;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
REQUEST(xvmcGetDRInfoReq);
|
|
|
|
REQUEST_SIZE_MATCH(xvmcGetDRInfoReq);
|
|
|
|
|
2010-07-27 13:02:24 -06:00
|
|
|
VALIDATE_XV_PORT(stuff->port, pPort, DixReadAccess);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
pScreen = pPort->pAdaptor->pScreen;
|
|
|
|
pScreenPriv = XVMC_GET_PRIVATE(pScreen);
|
2012-06-10 07:21:05 -06:00
|
|
|
|
2013-06-07 11:28:45 -06:00
|
|
|
rep = (xvmcGetDRInfoReply) {
|
|
|
|
.type = X_Reply,
|
|
|
|
.sequenceNumber = client->sequence,
|
|
|
|
.major = pScreenPriv->major,
|
|
|
|
.minor = pScreenPriv->minor,
|
|
|
|
.patchLevel = pScreenPriv->patchLevel,
|
|
|
|
.nameLen = bytes_to_int32(strlen(pScreenPriv->clientDriverName) + 1),
|
|
|
|
.busIDLen = bytes_to_int32(strlen(pScreenPriv->busID) + 1),
|
|
|
|
.isLocal = 1
|
|
|
|
};
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
rep.length = rep.nameLen + rep.busIDLen;
|
2012-06-10 07:21:05 -06:00
|
|
|
rep.nameLen <<= 2;
|
|
|
|
rep.busIDLen <<= 2;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Read back to the client what she has put in the shared memory
|
|
|
|
* segment she prepared for us.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef HAS_XVMCSHM
|
2012-06-10 07:21:05 -06:00
|
|
|
patternP = (CARD32 *) shmat(stuff->shmKey, NULL, SHM_RDONLY);
|
|
|
|
if (-1 != (long) patternP) {
|
2009-09-06 13:44:18 -06:00
|
|
|
volatile CARD32 *patternC = patternP;
|
2012-06-10 07:21:05 -06:00
|
|
|
int i;
|
|
|
|
CARD32 magic = stuff->magic;
|
|
|
|
|
|
|
|
rep.isLocal = 1;
|
|
|
|
i = 1024 / sizeof(CARD32);
|
|
|
|
|
|
|
|
while (i--) {
|
|
|
|
if (*patternC++ != magic) {
|
|
|
|
rep.isLocal = 0;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
magic = ~magic;
|
|
|
|
}
|
|
|
|
shmdt((char *) patternP);
|
|
|
|
}
|
|
|
|
#endif /* HAS_XVMCSHM */
|
|
|
|
|
2013-06-07 11:28:45 -06:00
|
|
|
WriteToClient(client, sizeof(xvmcGetDRInfoReply), &rep);
|
2012-06-10 07:21:05 -06:00
|
|
|
if (rep.length) {
|
|
|
|
WriteToClient(client, rep.nameLen, pScreenPriv->clientDriverName);
|
|
|
|
WriteToClient(client, rep.busIDLen, pScreenPriv->busID);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
return Success;
|
|
|
|
}
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
int (*ProcXvMCVector[xvmcNumRequest]) (ClientPtr) = {
|
|
|
|
ProcXvMCQueryVersion,
|
|
|
|
ProcXvMCListSurfaceTypes,
|
|
|
|
ProcXvMCCreateContext,
|
|
|
|
ProcXvMCDestroyContext,
|
|
|
|
ProcXvMCCreateSurface,
|
|
|
|
ProcXvMCDestroySurface,
|
|
|
|
ProcXvMCCreateSubpicture,
|
|
|
|
ProcXvMCDestroySubpicture,
|
|
|
|
ProcXvMCListSubpictureTypes, ProcXvMCGetDRInfo};
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
static int
|
2012-06-10 07:21:05 -06:00
|
|
|
ProcXvMCDispatch(ClientPtr client)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
REQUEST(xReq);
|
2012-06-10 07:21:05 -06:00
|
|
|
|
|
|
|
if (stuff->data < xvmcNumRequest)
|
|
|
|
return (*ProcXvMCVector[stuff->data]) (client);
|
2006-11-26 11:13:41 -07:00
|
|
|
else
|
2012-06-10 07:21:05 -06:00
|
|
|
return BadRequest;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2012-06-10 07:21:05 -06:00
|
|
|
SProcXvMCDispatch(ClientPtr client)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
/* We only support local */
|
|
|
|
return BadImplementation;
|
|
|
|
}
|
|
|
|
|
2010-07-27 13:02:24 -06:00
|
|
|
void
|
2007-11-24 10:55:21 -07:00
|
|
|
XvMCExtensionInit(void)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
ExtensionEntry *extEntry;
|
|
|
|
|
|
|
|
if (!dixPrivateKeyRegistered(XvMCScreenKey))
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (!(XvMCRTContext = CreateNewResourceType(XvMCDestroyContextRes,
|
|
|
|
"XvMCRTContext")))
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (!(XvMCRTSurface = CreateNewResourceType(XvMCDestroySurfaceRes,
|
|
|
|
"XvMCRTSurface")))
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (!(XvMCRTSubpicture = CreateNewResourceType(XvMCDestroySubpictureRes,
|
|
|
|
"XvMCRTSubpicture")))
|
|
|
|
return;
|
|
|
|
|
|
|
|
extEntry = AddExtension(XvMCName, XvMCNumEvents, XvMCNumErrors,
|
|
|
|
ProcXvMCDispatch, SProcXvMCDispatch,
|
|
|
|
NULL, StandardMinorOpcode);
|
|
|
|
|
|
|
|
if (!extEntry)
|
|
|
|
return;
|
|
|
|
|
|
|
|
XvMCReqCode = extEntry->base;
|
|
|
|
XvMCEventBase = extEntry->eventBase;
|
|
|
|
SetResourceTypeErrorValue(XvMCRTContext,
|
|
|
|
extEntry->errorBase + XvMCBadContext);
|
|
|
|
SetResourceTypeErrorValue(XvMCRTSurface,
|
|
|
|
extEntry->errorBase + XvMCBadSurface);
|
|
|
|
SetResourceTypeErrorValue(XvMCRTSubpicture,
|
|
|
|
extEntry->errorBase + XvMCBadSubpicture);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static Bool
|
2013-06-07 11:28:45 -06:00
|
|
|
XvMCCloseScreen(ScreenPtr pScreen)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
XvMCScreenPtr pScreenPriv = XVMC_GET_PRIVATE(pScreen);
|
|
|
|
|
|
|
|
pScreen->CloseScreen = pScreenPriv->CloseScreen;
|
|
|
|
|
2010-12-05 08:36:02 -07:00
|
|
|
free(pScreenPriv);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2013-06-07 11:28:45 -06:00
|
|
|
return (*pScreen->CloseScreen) (pScreen);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
XvMCScreenInit(ScreenPtr pScreen, int num, XvMCAdaptorPtr pAdapt)
|
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
XvMCScreenPtr pScreenPriv;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
if (!dixRegisterPrivateKey(&XvMCScreenKeyRec, PRIVATE_SCREEN, 0))
|
|
|
|
return BadAlloc;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
if (!(pScreenPriv = malloc(sizeof(XvMCScreenRec))))
|
|
|
|
return BadAlloc;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
dixSetPrivate(&pScreen->devPrivates, XvMCScreenKey, pScreenPriv);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
pScreenPriv->CloseScreen = pScreen->CloseScreen;
|
|
|
|
pScreen->CloseScreen = XvMCCloseScreen;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
pScreenPriv->num_adaptors = num;
|
|
|
|
pScreenPriv->adaptors = pAdapt;
|
|
|
|
pScreenPriv->clientDriverName[0] = 0;
|
|
|
|
pScreenPriv->busID[0] = 0;
|
|
|
|
pScreenPriv->major = 0;
|
|
|
|
pScreenPriv->minor = 0;
|
|
|
|
pScreenPriv->patchLevel = 0;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
XvMCInUse = TRUE;
|
2010-12-05 08:36:02 -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
|
|
|
XvImagePtr
|
|
|
|
XvMCFindXvImage(XvPortPtr pPort, CARD32 id)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
XvImagePtr pImage = NULL;
|
|
|
|
ScreenPtr pScreen = pPort->pAdaptor->pScreen;
|
|
|
|
XvMCScreenPtr pScreenPriv;
|
|
|
|
XvMCAdaptorPtr adaptor = NULL;
|
|
|
|
int i;
|
|
|
|
|
2011-11-05 07:32:40 -06:00
|
|
|
if (!dixPrivateKeyRegistered(XvMCScreenKey))
|
|
|
|
return NULL;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
if (!(pScreenPriv = XVMC_GET_PRIVATE(pScreen)))
|
2006-11-26 11:13:41 -07:00
|
|
|
return NULL;
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
for (i = 0; i < pScreenPriv->num_adaptors; i++) {
|
|
|
|
if (pPort->pAdaptor == pScreenPriv->adaptors[i].xv_adaptor) {
|
|
|
|
adaptor = &(pScreenPriv->adaptors[i]);
|
|
|
|
break;
|
|
|
|
}
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
if (!adaptor)
|
|
|
|
return NULL;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
for (i = 0; i < adaptor->num_subpictures; i++) {
|
|
|
|
if (adaptor->subpictures[i]->id == id) {
|
2006-11-26 11:13:41 -07:00
|
|
|
pImage = adaptor->subpictures[i];
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return pImage;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
xf86XvMCRegisterDRInfo(ScreenPtr pScreen, char *name,
|
2012-06-10 07:21:05 -06:00
|
|
|
char *busID, int major, int minor, int patchLevel)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
XvMCScreenPtr pScreenPriv = XVMC_GET_PRIVATE(pScreen);
|
2012-06-10 07:21:05 -06:00
|
|
|
|
|
|
|
strlcpy(pScreenPriv->clientDriverName, name, DR_CLIENT_DRIVER_NAME_SIZE);
|
|
|
|
strlcpy(pScreenPriv->busID, busID, DR_BUSID_SIZE);
|
2006-11-26 11:13:41 -07:00
|
|
|
pScreenPriv->major = major;
|
|
|
|
pScreenPriv->minor = minor;
|
|
|
|
pScreenPriv->patchLevel = patchLevel;
|
|
|
|
return Success;
|
|
|
|
}
|