2003-11-14 16:48:57 +00:00
|
|
|
|
2005-07-03 07:02:09 +00:00
|
|
|
#include <dix-config.h>
|
|
|
|
|
|
2006-02-10 22:00:30 +00:00
|
|
|
#include <string.h>
|
2005-04-20 12:25:48 +00:00
|
|
|
#include <X11/X.h>
|
2024-06-28 20:17:48 +02:00
|
|
|
#include <X11/Xfuncproto.h>
|
2005-04-20 12:25:48 +00:00
|
|
|
#include <X11/Xproto.h>
|
2024-06-28 20:17:48 +02:00
|
|
|
#include <X11/extensions/XvMC.h>
|
|
|
|
|
#include <X11/extensions/Xvproto.h>
|
|
|
|
|
#include <X11/extensions/XvMCproto.h>
|
2024-04-30 14:17:29 +02:00
|
|
|
|
2025-08-21 19:14:11 +02:00
|
|
|
#include "dix/dix_priv.h"
|
2025-09-22 15:14:38 +02:00
|
|
|
#include "dix/request_priv.h"
|
2025-04-30 10:30:56 +02:00
|
|
|
#include "dix/screen_hooks_priv.h"
|
2024-06-28 20:17:48 +02:00
|
|
|
#include "miext/extinit_priv.h"
|
2024-04-30 14:17:29 +02:00
|
|
|
#include "Xext/xvdix_priv.h"
|
|
|
|
|
|
2005-07-03 08:53:54 +00:00
|
|
|
#include "misc.h"
|
|
|
|
|
#include "os.h"
|
2003-11-14 16:48:57 +00:00
|
|
|
#include "dixstruct.h"
|
|
|
|
|
#include "resource.h"
|
|
|
|
|
#include "scrnintstr.h"
|
|
|
|
|
#include "extnsionst.h"
|
|
|
|
|
#include "servermd.h"
|
|
|
|
|
#include "xvmcext.h"
|
2004-11-23 17:29:47 +00:00
|
|
|
|
|
|
|
|
#ifdef HAS_XVMCSHM
|
|
|
|
|
#include <sys/ipc.h>
|
2004-11-24 09:07:58 +00:00
|
|
|
#include <sys/types.h>
|
2004-11-23 17:29:47 +00:00
|
|
|
#include <sys/shm.h>
|
|
|
|
|
#endif /* HAS_XVMCSHM */
|
2004-11-13 11:09:23 +00:00
|
|
|
|
2024-09-13 14:41:39 +02:00
|
|
|
#define SERVER_XVMC_MAJOR_VERSION 1
|
|
|
|
|
#define SERVER_XVMC_MINOR_VERSION 1
|
|
|
|
|
|
2004-11-13 11:09:23 +00:00
|
|
|
#define DR_CLIENT_DRIVER_NAME_SIZE 48
|
2004-11-23 17:29:47 +00:00
|
|
|
#define DR_BUSID_SIZE 48
|
2003-11-14 16:48:57 +00:00
|
|
|
|
2010-04-26 17:22:21 -07:00
|
|
|
static DevPrivateKeyRec XvMCScreenKeyRec;
|
2012-03-21 12:55:09 -07:00
|
|
|
|
2010-04-26 17:22:21 -07:00
|
|
|
#define XvMCScreenKey (&XvMCScreenKeyRec)
|
|
|
|
|
static Bool XvMCInUse;
|
2003-11-14 16:48:57 +00:00
|
|
|
|
|
|
|
|
int XvMCReqCode;
|
|
|
|
|
int XvMCEventBase;
|
|
|
|
|
|
2011-02-28 16:54:17 -05:00
|
|
|
static RESTYPE XvMCRTContext;
|
|
|
|
|
static RESTYPE XvMCRTSurface;
|
|
|
|
|
static RESTYPE XvMCRTSubpicture;
|
2003-11-14 16:48:57 +00:00
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
|
int num_adaptors;
|
|
|
|
|
XvMCAdaptorPtr adaptors;
|
2004-11-13 11:09:23 +00:00
|
|
|
char clientDriverName[DR_CLIENT_DRIVER_NAME_SIZE];
|
|
|
|
|
char busID[DR_BUSID_SIZE];
|
|
|
|
|
int major;
|
|
|
|
|
int minor;
|
|
|
|
|
int patchLevel;
|
2003-11-14 16:48:57 +00:00
|
|
|
} XvMCScreenRec, *XvMCScreenPtr;
|
|
|
|
|
|
|
|
|
|
#define XVMC_GET_PRIVATE(pScreen) \
|
2007-08-28 09:28:25 -04:00
|
|
|
(XvMCScreenPtr)(dixLookupPrivate(&(pScreen)->devPrivates, XvMCScreenKey))
|
2003-11-14 16:48:57 +00:00
|
|
|
|
|
|
|
|
static int
|
2013-12-15 01:05:51 -08:00
|
|
|
XvMCDestroyContextRes(void *data, XID id)
|
2003-11-14 16:48:57 +00:00
|
|
|
{
|
|
|
|
|
XvMCContextPtr pContext = (XvMCContextPtr) data;
|
|
|
|
|
|
|
|
|
|
pContext->refcnt--;
|
|
|
|
|
|
|
|
|
|
if (!pContext->refcnt) {
|
|
|
|
|
XvMCScreenPtr pScreenPriv = XVMC_GET_PRIVATE(pContext->pScreen);
|
2012-03-21 12:55:09 -07:00
|
|
|
|
2003-11-14 16:48:57 +00:00
|
|
|
(*pScreenPriv->adaptors[pContext->adapt_num].DestroyContext) (pContext);
|
2010-05-06 01:44:06 +07:00
|
|
|
free(pContext);
|
2012-03-21 12:55:09 -07:00
|
|
|
}
|
|
|
|
|
|
2003-11-14 16:48:57 +00:00
|
|
|
return Success;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static int
|
2013-12-15 01:05:51 -08:00
|
|
|
XvMCDestroySurfaceRes(void *data, XID id)
|
2003-11-14 16:48:57 +00:00
|
|
|
{
|
|
|
|
|
XvMCSurfacePtr pSurface = (XvMCSurfacePtr) data;
|
|
|
|
|
XvMCContextPtr pContext = pSurface->context;
|
|
|
|
|
XvMCScreenPtr pScreenPriv = XVMC_GET_PRIVATE(pContext->pScreen);
|
|
|
|
|
|
|
|
|
|
(*pScreenPriv->adaptors[pContext->adapt_num].DestroySurface) (pSurface);
|
2010-05-06 01:44:06 +07:00
|
|
|
free(pSurface);
|
2003-11-14 16:48:57 +00:00
|
|
|
|
2013-12-15 01:05:51 -08:00
|
|
|
XvMCDestroyContextRes((void *) pContext, pContext->context_id);
|
2003-11-14 16:48:57 +00:00
|
|
|
|
|
|
|
|
return Success;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static int
|
2013-12-15 01:05:51 -08:00
|
|
|
XvMCDestroySubpictureRes(void *data, XID id)
|
2003-11-14 16:48:57 +00:00
|
|
|
{
|
|
|
|
|
XvMCSubpicturePtr pSubpict = (XvMCSubpicturePtr) data;
|
|
|
|
|
XvMCContextPtr pContext = pSubpict->context;
|
|
|
|
|
XvMCScreenPtr pScreenPriv = XVMC_GET_PRIVATE(pContext->pScreen);
|
|
|
|
|
|
|
|
|
|
(*pScreenPriv->adaptors[pContext->adapt_num].DestroySubpicture) (pSubpict);
|
2010-05-06 01:44:06 +07:00
|
|
|
free(pSubpict);
|
2003-11-14 16:48:57 +00:00
|
|
|
|
2013-12-15 01:05:51 -08:00
|
|
|
XvMCDestroyContextRes((void *) pContext, pContext->context_id);
|
2003-11-14 16:48:57 +00:00
|
|
|
|
|
|
|
|
return Success;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static int
|
|
|
|
|
ProcXvMCQueryVersion(ClientPtr client)
|
|
|
|
|
{
|
2025-08-25 16:40:10 +02:00
|
|
|
xvmcQueryVersionReply reply = {
|
2012-07-09 19:12:43 -07:00
|
|
|
.major = SERVER_XVMC_MAJOR_VERSION,
|
|
|
|
|
.minor = SERVER_XVMC_MINOR_VERSION
|
|
|
|
|
};
|
2012-03-21 12:55:09 -07:00
|
|
|
|
2003-11-14 16:48:57 +00:00
|
|
|
/* REQUEST(xvmcQueryVersionReq); */
|
|
|
|
|
REQUEST_SIZE_MATCH(xvmcQueryVersionReq);
|
2012-07-09 19:12:43 -07:00
|
|
|
|
2025-08-25 18:30:58 +02:00
|
|
|
if (client->swapped) {
|
|
|
|
|
swapl(&reply.major);
|
|
|
|
|
swapl(&reply.minor);
|
|
|
|
|
}
|
|
|
|
|
|
2025-09-17 11:16:40 +02:00
|
|
|
return X_SEND_REPLY_SIMPLE(client, reply);
|
2003-11-14 16:48:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static int
|
|
|
|
|
ProcXvMCListSurfaceTypes(ClientPtr client)
|
|
|
|
|
{
|
|
|
|
|
XvPortPtr pPort;
|
|
|
|
|
XvMCScreenPtr pScreenPriv;
|
|
|
|
|
XvMCAdaptorPtr adaptor = NULL;
|
2012-03-21 12:55:09 -07:00
|
|
|
|
2003-11-14 16:48:57 +00:00
|
|
|
REQUEST(xvmcListSurfaceTypesReq);
|
|
|
|
|
REQUEST_SIZE_MATCH(xvmcListSurfaceTypesReq);
|
|
|
|
|
|
2009-04-29 01:04:37 -04:00
|
|
|
VALIDATE_XV_PORT(stuff->port, pPort, DixReadAccess);
|
2003-11-14 16:48:57 +00:00
|
|
|
|
2010-04-26 17:22:21 -07:00
|
|
|
if (XvMCInUse) { /* any adaptors at all */
|
2003-11-14 16:48:57 +00:00
|
|
|
ScreenPtr pScreen = pPort->pAdaptor->pScreen;
|
2012-03-21 12:55:09 -07:00
|
|
|
|
2003-11-14 16:48:57 +00:00
|
|
|
if ((pScreenPriv = XVMC_GET_PRIVATE(pScreen))) { /* any this screen */
|
2025-02-21 19:11:13 +01:00
|
|
|
for (int i = 0; i < pScreenPriv->num_adaptors; i++) {
|
2003-11-14 16:48:57 +00:00
|
|
|
if (pPort->pAdaptor == pScreenPriv->adaptors[i].xv_adaptor) {
|
|
|
|
|
adaptor = &(pScreenPriv->adaptors[i]);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2025-08-25 19:31:47 +02:00
|
|
|
x_rpcbuf_t rpcbuf = { .swapped = client->swapped, .err_clear = TRUE };
|
|
|
|
|
|
2024-07-12 16:43:55 +02:00
|
|
|
int num_surfaces = (adaptor) ? adaptor->num_surfaces : 0;
|
2025-08-25 19:31:47 +02:00
|
|
|
for (int i = 0; i < num_surfaces; i++) {
|
|
|
|
|
XvMCSurfaceInfoPtr surface = adaptor->surfaces[i];
|
2024-07-12 16:43:55 +02:00
|
|
|
|
2025-08-25 19:31:47 +02:00
|
|
|
/* write xvmcSurfaceInfo */
|
|
|
|
|
x_rpcbuf_write_CARD32(&rpcbuf, surface->surface_type_id);
|
|
|
|
|
x_rpcbuf_write_CARD16(&rpcbuf, surface->chroma_format);
|
|
|
|
|
x_rpcbuf_write_CARD16(&rpcbuf, 0);
|
|
|
|
|
x_rpcbuf_write_CARD16(&rpcbuf, surface->max_width);
|
|
|
|
|
x_rpcbuf_write_CARD16(&rpcbuf, surface->max_height);
|
|
|
|
|
x_rpcbuf_write_CARD16(&rpcbuf, surface->subpicture_max_width);
|
|
|
|
|
x_rpcbuf_write_CARD16(&rpcbuf, surface->subpicture_max_height);
|
|
|
|
|
x_rpcbuf_write_CARD32(&rpcbuf, surface->mc_type);
|
|
|
|
|
x_rpcbuf_write_CARD32(&rpcbuf, surface->flags);
|
2024-07-12 16:43:55 +02:00
|
|
|
}
|
|
|
|
|
|
2025-08-25 16:40:10 +02:00
|
|
|
xvmcListSurfaceTypesReply reply = {
|
2012-07-14 10:02:52 -07:00
|
|
|
.num = num_surfaces,
|
2012-07-09 19:12:43 -07:00
|
|
|
};
|
2003-11-14 16:48:57 +00:00
|
|
|
|
2025-08-25 18:30:58 +02:00
|
|
|
if (client->swapped) {
|
|
|
|
|
swapl(&reply.num);
|
|
|
|
|
}
|
|
|
|
|
|
2025-08-25 19:31:47 +02:00
|
|
|
return X_SEND_REPLY_WITH_RPCBUF(client, reply, rpcbuf);
|
2003-11-14 16:48:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static int
|
|
|
|
|
ProcXvMCCreateContext(ClientPtr client)
|
|
|
|
|
{
|
|
|
|
|
XvPortPtr pPort;
|
|
|
|
|
CARD32 *data = NULL;
|
|
|
|
|
int dwords = 0;
|
2025-02-21 19:11:13 +01:00
|
|
|
int result, adapt_num = -1;
|
2003-11-14 16:48:57 +00:00
|
|
|
ScreenPtr pScreen;
|
|
|
|
|
XvMCContextPtr pContext;
|
|
|
|
|
XvMCScreenPtr pScreenPriv;
|
|
|
|
|
XvMCAdaptorPtr adaptor = NULL;
|
|
|
|
|
XvMCSurfaceInfoPtr surface = NULL;
|
2012-03-21 12:55:09 -07:00
|
|
|
|
2003-11-14 16:48:57 +00:00
|
|
|
REQUEST(xvmcCreateContextReq);
|
|
|
|
|
REQUEST_SIZE_MATCH(xvmcCreateContextReq);
|
|
|
|
|
|
2009-04-29 01:04:37 -04:00
|
|
|
VALIDATE_XV_PORT(stuff->port, pPort, DixReadAccess);
|
2003-11-14 16:48:57 +00:00
|
|
|
|
|
|
|
|
pScreen = pPort->pAdaptor->pScreen;
|
|
|
|
|
|
2010-04-26 17:22:21 -07:00
|
|
|
if (!XvMCInUse) /* no XvMC adaptors */
|
2003-11-14 16:48:57 +00:00
|
|
|
return BadMatch;
|
|
|
|
|
|
|
|
|
|
if (!(pScreenPriv = XVMC_GET_PRIVATE(pScreen))) /* none this screen */
|
|
|
|
|
return BadMatch;
|
2012-03-21 12:55:09 -07:00
|
|
|
|
2025-02-21 19:11:13 +01:00
|
|
|
for (int i = 0; i < pScreenPriv->num_adaptors; i++) {
|
2003-11-14 16:48:57 +00:00
|
|
|
if (pPort->pAdaptor == pScreenPriv->adaptors[i].xv_adaptor) {
|
|
|
|
|
adaptor = &(pScreenPriv->adaptors[i]);
|
|
|
|
|
adapt_num = i;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (adapt_num < 0) /* none this port */
|
|
|
|
|
return BadMatch;
|
|
|
|
|
|
2025-02-21 19:11:13 +01:00
|
|
|
for (int i = 0; i < adaptor->num_surfaces; i++) {
|
2003-11-14 16:48:57 +00:00
|
|
|
if (adaptor->surfaces[i]->surface_type_id == stuff->surface_type_id) {
|
|
|
|
|
surface = adaptor->surfaces[i];
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* adaptor doesn't support this suface_type_id */
|
|
|
|
|
if (!surface)
|
|
|
|
|
return BadMatch;
|
|
|
|
|
|
|
|
|
|
if ((stuff->width > surface->max_width) ||
|
|
|
|
|
(stuff->height > surface->max_height))
|
|
|
|
|
return BadValue;
|
|
|
|
|
|
2025-04-10 18:43:08 +02:00
|
|
|
if (!(pContext = calloc(1, sizeof(XvMCContextRec)))) {
|
2003-11-14 16:48:57 +00:00
|
|
|
return BadAlloc;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
|
|
result = (*adaptor->CreateContext) (pPort, pContext, &dwords, &data);
|
|
|
|
|
|
|
|
|
|
if (result != Success) {
|
2010-05-06 01:44:06 +07:00
|
|
|
free(pContext);
|
2003-11-14 16:48:57 +00:00
|
|
|
return result;
|
|
|
|
|
}
|
2016-03-07 23:20:26 +01:00
|
|
|
if (!AddResource(pContext->context_id, XvMCRTContext, pContext)) {
|
|
|
|
|
free(data);
|
|
|
|
|
return BadAlloc;
|
|
|
|
|
}
|
2003-11-14 16:48:57 +00:00
|
|
|
|
2025-08-25 19:31:47 +02:00
|
|
|
x_rpcbuf_t rpcbuf = { .swapped = client->swapped, .err_clear = TRUE };
|
|
|
|
|
x_rpcbuf_write_CARD32s(&rpcbuf, data, dwords);
|
|
|
|
|
free(data);
|
|
|
|
|
|
2025-08-25 16:40:10 +02:00
|
|
|
xvmcCreateContextReply reply = {
|
2012-07-09 19:12:43 -07:00
|
|
|
.width_actual = pContext->width,
|
|
|
|
|
.height_actual = pContext->height,
|
|
|
|
|
.flags_return = pContext->flags
|
|
|
|
|
};
|
2003-11-14 16:48:57 +00:00
|
|
|
|
2025-08-25 18:30:58 +02:00
|
|
|
if (client->swapped) {
|
|
|
|
|
swaps(&reply.width_actual);
|
|
|
|
|
swaps(&reply.height_actual);
|
|
|
|
|
swapl(&reply.flags_return);
|
|
|
|
|
}
|
|
|
|
|
|
2025-08-25 19:31:47 +02:00
|
|
|
return X_SEND_REPLY_WITH_RPCBUF(client, reply, rpcbuf);
|
2003-11-14 16:48:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static int
|
|
|
|
|
ProcXvMCDestroyContext(ClientPtr client)
|
|
|
|
|
{
|
2013-12-15 01:05:51 -08:00
|
|
|
void *val;
|
2009-04-29 01:04:37 -04:00
|
|
|
int rc;
|
2012-03-21 12:55:09 -07:00
|
|
|
|
2003-11-14 16:48:57 +00:00
|
|
|
REQUEST(xvmcDestroyContextReq);
|
|
|
|
|
REQUEST_SIZE_MATCH(xvmcDestroyContextReq);
|
|
|
|
|
|
2009-04-29 01:04:37 -04:00
|
|
|
rc = dixLookupResourceByType(&val, stuff->context_id, XvMCRTContext,
|
|
|
|
|
client, DixDestroyAccess);
|
|
|
|
|
if (rc != Success)
|
2010-04-24 23:56:36 -07:00
|
|
|
return rc;
|
2003-11-14 16:48:57 +00:00
|
|
|
|
2024-03-04 15:08:32 +01:00
|
|
|
FreeResource(stuff->context_id, X11_RESTYPE_NONE);
|
2003-11-14 16:48:57 +00:00
|
|
|
|
|
|
|
|
return Success;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static int
|
|
|
|
|
ProcXvMCCreateSurface(ClientPtr client)
|
|
|
|
|
{
|
|
|
|
|
CARD32 *data = NULL;
|
|
|
|
|
int dwords = 0;
|
|
|
|
|
int result;
|
|
|
|
|
XvMCContextPtr pContext;
|
|
|
|
|
XvMCSurfacePtr pSurface;
|
|
|
|
|
XvMCScreenPtr pScreenPriv;
|
2012-03-21 12:55:09 -07:00
|
|
|
|
2003-11-14 16:48:57 +00:00
|
|
|
REQUEST(xvmcCreateSurfaceReq);
|
|
|
|
|
REQUEST_SIZE_MATCH(xvmcCreateSurfaceReq);
|
|
|
|
|
|
2013-12-15 01:05:51 -08:00
|
|
|
result = dixLookupResourceByType((void **) &pContext, stuff->context_id,
|
2009-04-29 01:04:37 -04:00
|
|
|
XvMCRTContext, client, DixUseAccess);
|
|
|
|
|
if (result != Success)
|
2010-04-24 23:56:36 -07:00
|
|
|
return result;
|
2003-11-14 16:48:57 +00:00
|
|
|
|
|
|
|
|
pScreenPriv = XVMC_GET_PRIVATE(pContext->pScreen);
|
|
|
|
|
|
2025-04-10 18:43:08 +02:00
|
|
|
if (!(pSurface = calloc(1, sizeof(XvMCSurfaceRec))))
|
2003-11-14 16:48:57 +00:00
|
|
|
return BadAlloc;
|
|
|
|
|
|
|
|
|
|
pSurface->surface_id = stuff->surface_id;
|
|
|
|
|
pSurface->surface_type_id = pContext->surface_type_id;
|
|
|
|
|
pSurface->context = pContext;
|
|
|
|
|
|
|
|
|
|
result =
|
|
|
|
|
(*pScreenPriv->adaptors[pContext->adapt_num].CreateSurface) (pSurface,
|
|
|
|
|
&dwords,
|
|
|
|
|
&data);
|
|
|
|
|
|
|
|
|
|
if (result != Success) {
|
2010-05-06 01:44:06 +07:00
|
|
|
free(pSurface);
|
2003-11-14 16:48:57 +00:00
|
|
|
return result;
|
|
|
|
|
}
|
2016-03-07 23:20:26 +01:00
|
|
|
if (!AddResource(pSurface->surface_id, XvMCRTSurface, pSurface)) {
|
|
|
|
|
free(data);
|
|
|
|
|
return BadAlloc;
|
|
|
|
|
}
|
|
|
|
|
|
2025-08-25 19:31:47 +02:00
|
|
|
x_rpcbuf_t rpcbuf = { .swapped = client->swapped, .err_clear = TRUE };
|
|
|
|
|
x_rpcbuf_write_CARD32s(&rpcbuf, data, dwords);
|
2010-06-06 15:28:30 +07:00
|
|
|
free(data);
|
2003-11-14 16:48:57 +00:00
|
|
|
|
2025-08-25 19:31:47 +02:00
|
|
|
xvmcCreateSurfaceReply reply = { 0 };
|
|
|
|
|
|
2003-11-14 16:48:57 +00:00
|
|
|
pContext->refcnt++;
|
|
|
|
|
|
2025-08-25 19:31:47 +02:00
|
|
|
return X_SEND_REPLY_WITH_RPCBUF(client, reply, rpcbuf);
|
2003-11-14 16:48:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static int
|
|
|
|
|
ProcXvMCDestroySurface(ClientPtr client)
|
|
|
|
|
{
|
2013-12-15 01:05:51 -08:00
|
|
|
void *val;
|
2009-04-29 01:04:37 -04:00
|
|
|
int rc;
|
2012-03-21 12:55:09 -07:00
|
|
|
|
2003-11-14 16:48:57 +00:00
|
|
|
REQUEST(xvmcDestroySurfaceReq);
|
|
|
|
|
REQUEST_SIZE_MATCH(xvmcDestroySurfaceReq);
|
|
|
|
|
|
2009-04-29 01:04:37 -04:00
|
|
|
rc = dixLookupResourceByType(&val, stuff->surface_id, XvMCRTSurface,
|
|
|
|
|
client, DixDestroyAccess);
|
|
|
|
|
if (rc != Success)
|
2010-04-24 23:56:36 -07:00
|
|
|
return rc;
|
2003-11-14 16:48:57 +00:00
|
|
|
|
2024-03-04 15:08:32 +01:00
|
|
|
FreeResource(stuff->surface_id, X11_RESTYPE_NONE);
|
2003-11-14 16:48:57 +00:00
|
|
|
|
|
|
|
|
return Success;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static int
|
|
|
|
|
ProcXvMCCreateSubpicture(ClientPtr client)
|
|
|
|
|
{
|
|
|
|
|
Bool image_supported = FALSE;
|
|
|
|
|
CARD32 *data = NULL;
|
2025-02-21 19:11:13 +01:00
|
|
|
int result, dwords = 0;
|
2003-11-14 16:48:57 +00:00
|
|
|
XvMCContextPtr pContext;
|
|
|
|
|
XvMCSubpicturePtr pSubpicture;
|
|
|
|
|
XvMCScreenPtr pScreenPriv;
|
|
|
|
|
XvMCAdaptorPtr adaptor;
|
|
|
|
|
XvMCSurfaceInfoPtr surface = NULL;
|
2012-03-21 12:55:09 -07:00
|
|
|
|
2003-11-14 16:48:57 +00:00
|
|
|
REQUEST(xvmcCreateSubpictureReq);
|
|
|
|
|
REQUEST_SIZE_MATCH(xvmcCreateSubpictureReq);
|
|
|
|
|
|
2013-12-15 01:05:51 -08:00
|
|
|
result = dixLookupResourceByType((void **) &pContext, stuff->context_id,
|
2009-04-29 01:04:37 -04:00
|
|
|
XvMCRTContext, client, DixUseAccess);
|
|
|
|
|
if (result != Success)
|
2010-04-24 23:56:36 -07:00
|
|
|
return result;
|
2003-11-14 16:48:57 +00:00
|
|
|
|
|
|
|
|
pScreenPriv = XVMC_GET_PRIVATE(pContext->pScreen);
|
|
|
|
|
|
|
|
|
|
adaptor = &(pScreenPriv->adaptors[pContext->adapt_num]);
|
|
|
|
|
|
|
|
|
|
/* find which surface this context supports */
|
2025-02-21 19:11:13 +01:00
|
|
|
for (int i = 0; i < adaptor->num_surfaces; i++) {
|
2003-11-14 16:48:57 +00:00
|
|
|
if (adaptor->surfaces[i]->surface_type_id == pContext->surface_type_id) {
|
|
|
|
|
surface = adaptor->surfaces[i];
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!surface)
|
|
|
|
|
return BadMatch;
|
2012-03-21 12:55:09 -07:00
|
|
|
|
2003-11-14 16:48:57 +00:00
|
|
|
/* make sure this surface supports that xvimage format */
|
|
|
|
|
if (!surface->compatible_subpictures)
|
|
|
|
|
return BadMatch;
|
2012-03-21 12:55:09 -07:00
|
|
|
|
2025-02-21 19:11:13 +01:00
|
|
|
for (int i = 0; i < surface->compatible_subpictures->num_xvimages; i++) {
|
2003-11-14 16:48:57 +00:00
|
|
|
if (surface->compatible_subpictures->xvimage_ids[i] ==
|
|
|
|
|
stuff->xvimage_id) {
|
|
|
|
|
image_supported = TRUE;
|
2012-03-21 12:55:09 -07:00
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2003-11-14 16:48:57 +00:00
|
|
|
if (!image_supported)
|
|
|
|
|
return BadMatch;
|
|
|
|
|
|
|
|
|
|
/* make sure the size is OK */
|
|
|
|
|
if ((stuff->width > surface->subpicture_max_width) ||
|
|
|
|
|
(stuff->height > surface->subpicture_max_height))
|
|
|
|
|
return BadValue;
|
|
|
|
|
|
2025-04-10 18:43:08 +02:00
|
|
|
if (!(pSubpicture = calloc(1, sizeof(XvMCSubpictureRec))))
|
2003-11-14 16:48:57 +00:00
|
|
|
return BadAlloc;
|
|
|
|
|
|
|
|
|
|
pSubpicture->subpicture_id = stuff->subpicture_id;
|
|
|
|
|
pSubpicture->xvimage_id = stuff->xvimage_id;
|
|
|
|
|
pSubpicture->width = stuff->width;
|
|
|
|
|
pSubpicture->height = stuff->height;
|
|
|
|
|
pSubpicture->num_palette_entries = 0; /* overwritten by DDX */
|
|
|
|
|
pSubpicture->entry_bytes = 0; /* overwritten by DDX */
|
|
|
|
|
pSubpicture->component_order[0] = 0; /* overwritten by DDX */
|
|
|
|
|
pSubpicture->component_order[1] = 0;
|
|
|
|
|
pSubpicture->component_order[2] = 0;
|
|
|
|
|
pSubpicture->component_order[3] = 0;
|
|
|
|
|
pSubpicture->context = pContext;
|
|
|
|
|
|
2012-03-21 12:55:09 -07:00
|
|
|
result =
|
2003-11-14 16:48:57 +00:00
|
|
|
(*pScreenPriv->adaptors[pContext->adapt_num].
|
|
|
|
|
CreateSubpicture) (pSubpicture, &dwords, &data);
|
2012-03-21 12:55:09 -07:00
|
|
|
|
2003-11-14 16:48:57 +00:00
|
|
|
if (result != Success) {
|
2010-05-06 01:44:06 +07:00
|
|
|
free(pSubpicture);
|
2003-11-14 16:48:57 +00:00
|
|
|
return result;
|
|
|
|
|
}
|
2016-03-07 23:20:26 +01:00
|
|
|
if (!AddResource(pSubpicture->subpicture_id, XvMCRTSubpicture, pSubpicture)) {
|
|
|
|
|
free(data);
|
|
|
|
|
return BadAlloc;
|
|
|
|
|
}
|
|
|
|
|
|
2025-08-25 19:31:47 +02:00
|
|
|
x_rpcbuf_t rpcbuf = { .swapped = client->swapped, .err_clear = TRUE };
|
|
|
|
|
x_rpcbuf_write_CARD32s(&rpcbuf, data, dwords);
|
|
|
|
|
free(data);
|
|
|
|
|
|
2025-08-25 16:40:10 +02:00
|
|
|
xvmcCreateSubpictureReply reply = {
|
2012-07-09 19:12:43 -07:00
|
|
|
.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]
|
|
|
|
|
};
|
2003-11-14 16:48:57 +00:00
|
|
|
|
2025-08-25 18:30:58 +02:00
|
|
|
if (client->swapped) {
|
|
|
|
|
swaps(&reply.width_actual);
|
|
|
|
|
swaps(&reply.height_actual);
|
|
|
|
|
swaps(&reply.num_palette_entries);
|
|
|
|
|
swaps(&reply.entry_bytes);
|
|
|
|
|
}
|
|
|
|
|
|
2003-11-14 16:48:57 +00:00
|
|
|
pContext->refcnt++;
|
|
|
|
|
|
2025-08-25 19:31:47 +02:00
|
|
|
return X_SEND_REPLY_WITH_RPCBUF(client, reply, rpcbuf);
|
2003-11-14 16:48:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static int
|
|
|
|
|
ProcXvMCDestroySubpicture(ClientPtr client)
|
|
|
|
|
{
|
2013-12-15 01:05:51 -08:00
|
|
|
void *val;
|
2009-04-29 01:04:37 -04:00
|
|
|
int rc;
|
2012-03-21 12:55:09 -07:00
|
|
|
|
2003-11-14 16:48:57 +00:00
|
|
|
REQUEST(xvmcDestroySubpictureReq);
|
|
|
|
|
REQUEST_SIZE_MATCH(xvmcDestroySubpictureReq);
|
|
|
|
|
|
2009-04-29 01:04:37 -04:00
|
|
|
rc = dixLookupResourceByType(&val, stuff->subpicture_id, XvMCRTSubpicture,
|
|
|
|
|
client, DixDestroyAccess);
|
|
|
|
|
if (rc != Success)
|
2010-04-24 23:56:36 -07:00
|
|
|
return rc;
|
2003-11-14 16:48:57 +00:00
|
|
|
|
2024-03-04 15:08:32 +01:00
|
|
|
FreeResource(stuff->subpicture_id, X11_RESTYPE_NONE);
|
2003-11-14 16:48:57 +00:00
|
|
|
|
|
|
|
|
return Success;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static int
|
|
|
|
|
ProcXvMCListSubpictureTypes(ClientPtr client)
|
|
|
|
|
{
|
|
|
|
|
XvPortPtr pPort;
|
|
|
|
|
XvMCScreenPtr pScreenPriv;
|
|
|
|
|
ScreenPtr pScreen;
|
|
|
|
|
XvMCAdaptorPtr adaptor = NULL;
|
|
|
|
|
XvMCSurfaceInfoPtr surface = NULL;
|
|
|
|
|
XvImagePtr pImage;
|
2012-03-21 12:55:09 -07:00
|
|
|
|
2003-11-14 16:48:57 +00:00
|
|
|
REQUEST(xvmcListSubpictureTypesReq);
|
|
|
|
|
REQUEST_SIZE_MATCH(xvmcListSubpictureTypesReq);
|
|
|
|
|
|
2009-04-29 01:04:37 -04:00
|
|
|
VALIDATE_XV_PORT(stuff->port, pPort, DixReadAccess);
|
2003-11-14 16:48:57 +00:00
|
|
|
|
|
|
|
|
pScreen = pPort->pAdaptor->pScreen;
|
|
|
|
|
|
2011-05-24 18:33:11 +02:00
|
|
|
if (!dixPrivateKeyRegistered(XvMCScreenKey))
|
|
|
|
|
return BadMatch; /* No XvMC adaptors */
|
2003-11-14 16:48:57 +00:00
|
|
|
|
|
|
|
|
if (!(pScreenPriv = XVMC_GET_PRIVATE(pScreen)))
|
|
|
|
|
return BadMatch; /* None this screen */
|
|
|
|
|
|
2025-02-21 19:11:13 +01:00
|
|
|
for (int i = 0; i < pScreenPriv->num_adaptors; i++) {
|
2003-11-14 16:48:57 +00:00
|
|
|
if (pPort->pAdaptor == pScreenPriv->adaptors[i].xv_adaptor) {
|
|
|
|
|
adaptor = &(pScreenPriv->adaptors[i]);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!adaptor)
|
|
|
|
|
return BadMatch;
|
|
|
|
|
|
2025-02-21 19:11:13 +01:00
|
|
|
for (int i = 0; i < adaptor->num_surfaces; i++) {
|
2003-11-14 16:48:57 +00:00
|
|
|
if (adaptor->surfaces[i]->surface_type_id == stuff->surface_type_id) {
|
|
|
|
|
surface = adaptor->surfaces[i];
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!surface)
|
|
|
|
|
return BadMatch;
|
|
|
|
|
|
2024-07-12 16:43:55 +02:00
|
|
|
int num = (surface->compatible_subpictures ?
|
|
|
|
|
surface->compatible_subpictures->num_xvimages : 0);
|
2003-11-14 16:48:57 +00:00
|
|
|
|
2025-08-25 19:31:47 +02:00
|
|
|
x_rpcbuf_t rpcbuf = { .swapped = client->swapped, .err_clear = TRUE };
|
2003-11-14 16:48:57 +00:00
|
|
|
|
2025-08-25 19:31:47 +02:00
|
|
|
if (num) {
|
2025-05-15 11:41:17 +02:00
|
|
|
for (int i = 0; i < num; i++) {
|
|
|
|
|
pImage = NULL;
|
|
|
|
|
for (int 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;
|
2012-03-21 12:55:09 -07:00
|
|
|
}
|
2003-11-14 16:48:57 +00:00
|
|
|
|
2025-08-25 19:31:47 +02:00
|
|
|
/* xvImageFormatInfo */
|
|
|
|
|
x_rpcbuf_write_CARD32(&rpcbuf, pImage->id);
|
|
|
|
|
x_rpcbuf_write_CARD8(&rpcbuf, pImage->type);
|
|
|
|
|
x_rpcbuf_write_CARD8(&rpcbuf, pImage->byte_order);
|
|
|
|
|
x_rpcbuf_write_CARD16(&rpcbuf, 0); /* pad1 */
|
|
|
|
|
x_rpcbuf_write_CARD8s(&rpcbuf, (CARD8*)pImage->guid, 16);
|
|
|
|
|
x_rpcbuf_write_CARD8(&rpcbuf, pImage->bits_per_pixel);
|
|
|
|
|
x_rpcbuf_write_CARD8(&rpcbuf, pImage->num_planes);
|
|
|
|
|
x_rpcbuf_write_CARD16(&rpcbuf, 0); /* pad2 */
|
|
|
|
|
x_rpcbuf_write_CARD8(&rpcbuf, pImage->depth);
|
|
|
|
|
x_rpcbuf_write_CARD8(&rpcbuf, 0); /* pad3 */
|
|
|
|
|
x_rpcbuf_write_CARD16(&rpcbuf, 0); /* pad4 */
|
|
|
|
|
x_rpcbuf_write_CARD32(&rpcbuf, pImage->red_mask);
|
|
|
|
|
x_rpcbuf_write_CARD32(&rpcbuf, pImage->green_mask);
|
|
|
|
|
x_rpcbuf_write_CARD32(&rpcbuf, pImage->blue_mask);
|
|
|
|
|
x_rpcbuf_write_CARD8(&rpcbuf, pImage->format);
|
|
|
|
|
x_rpcbuf_write_CARD8(&rpcbuf, 0); /* pad5 */
|
|
|
|
|
x_rpcbuf_write_CARD16(&rpcbuf, 0); /* pad6 */
|
|
|
|
|
x_rpcbuf_write_CARD32(&rpcbuf, pImage->y_sample_bits);
|
|
|
|
|
x_rpcbuf_write_CARD32(&rpcbuf, pImage->u_sample_bits);
|
|
|
|
|
x_rpcbuf_write_CARD32(&rpcbuf, pImage->v_sample_bits);
|
|
|
|
|
x_rpcbuf_write_CARD32(&rpcbuf, pImage->horz_y_period);
|
|
|
|
|
x_rpcbuf_write_CARD32(&rpcbuf, pImage->horz_u_period);
|
|
|
|
|
x_rpcbuf_write_CARD32(&rpcbuf, pImage->horz_v_period);
|
|
|
|
|
x_rpcbuf_write_CARD32(&rpcbuf, pImage->vert_y_period);
|
|
|
|
|
x_rpcbuf_write_CARD32(&rpcbuf, pImage->vert_u_period);
|
|
|
|
|
x_rpcbuf_write_CARD32(&rpcbuf, pImage->vert_v_period);
|
|
|
|
|
x_rpcbuf_write_CARD8s(&rpcbuf, (CARD8*)pImage->component_order, 32);
|
|
|
|
|
x_rpcbuf_write_CARD8(&rpcbuf, pImage->scanline_order);
|
|
|
|
|
x_rpcbuf_write_CARD8(&rpcbuf, 0); /* pad7 */
|
|
|
|
|
x_rpcbuf_write_CARD16(&rpcbuf, 0); /* pad8 */
|
|
|
|
|
x_rpcbuf_write_CARD32(&rpcbuf, 0); /* pad9 */
|
|
|
|
|
x_rpcbuf_write_CARD32(&rpcbuf, 0); /* pad10 */
|
2025-05-15 11:41:17 +02:00
|
|
|
}
|
2003-11-14 16:48:57 +00:00
|
|
|
}
|
|
|
|
|
|
2025-08-25 16:40:10 +02:00
|
|
|
xvmcListSubpictureTypesReply reply = {
|
2024-07-12 16:43:55 +02:00
|
|
|
.num = num,
|
|
|
|
|
};
|
|
|
|
|
|
2025-08-25 18:30:58 +02:00
|
|
|
if (client->swapped) {
|
|
|
|
|
swapl(&reply.num);
|
|
|
|
|
}
|
2025-08-25 19:31:47 +02:00
|
|
|
|
|
|
|
|
return X_SEND_REPLY_WITH_RPCBUF(client, reply, rpcbuf);
|
2003-11-14 16:48:57 +00:00
|
|
|
}
|
|
|
|
|
|
2004-11-13 11:09:23 +00:00
|
|
|
static int
|
|
|
|
|
ProcXvMCGetDRInfo(ClientPtr client)
|
|
|
|
|
{
|
|
|
|
|
XvPortPtr pPort;
|
|
|
|
|
ScreenPtr pScreen;
|
|
|
|
|
XvMCScreenPtr pScreenPriv;
|
2004-11-23 17:29:47 +00:00
|
|
|
|
|
|
|
|
#ifdef HAS_XVMCSHM
|
2004-11-13 11:09:23 +00:00
|
|
|
volatile CARD32 *patternP;
|
2004-11-23 17:29:47 +00:00
|
|
|
#endif
|
2004-11-13 11:09:23 +00:00
|
|
|
|
|
|
|
|
REQUEST(xvmcGetDRInfoReq);
|
|
|
|
|
REQUEST_SIZE_MATCH(xvmcGetDRInfoReq);
|
|
|
|
|
|
2009-04-29 01:04:37 -04:00
|
|
|
VALIDATE_XV_PORT(stuff->port, pPort, DixReadAccess);
|
2004-11-13 11:09:23 +00:00
|
|
|
|
|
|
|
|
pScreen = pPort->pAdaptor->pScreen;
|
|
|
|
|
pScreenPriv = XVMC_GET_PRIVATE(pScreen);
|
2012-03-21 12:55:09 -07:00
|
|
|
|
2024-07-12 16:43:55 +02:00
|
|
|
int nameLen = strlen(pScreenPriv->clientDriverName) + 1;
|
|
|
|
|
int busIDLen = strlen(pScreenPriv->busID) + 1;
|
|
|
|
|
|
2025-08-25 19:31:47 +02:00
|
|
|
x_rpcbuf_t rpcbuf = { .swapped = client->swapped, .err_clear = TRUE };
|
|
|
|
|
x_rpcbuf_write_CARD8s(&rpcbuf, (CARD8*)pScreenPriv->clientDriverName, nameLen);
|
|
|
|
|
x_rpcbuf_write_CARD8s(&rpcbuf, (CARD8*)pScreenPriv->busID, busIDLen);
|
2024-07-12 16:43:55 +02:00
|
|
|
|
2025-08-25 16:40:10 +02:00
|
|
|
xvmcGetDRInfoReply reply = {
|
2012-07-09 19:12:43 -07:00
|
|
|
.major = pScreenPriv->major,
|
|
|
|
|
.minor = pScreenPriv->minor,
|
|
|
|
|
.patchLevel = pScreenPriv->patchLevel,
|
2024-07-12 16:43:55 +02:00
|
|
|
.nameLen = nameLen,
|
|
|
|
|
.busIDLen = busIDLen,
|
2012-07-09 19:12:43 -07:00
|
|
|
.isLocal = 1
|
|
|
|
|
};
|
2004-11-13 11:09:23 +00:00
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Read back to the client what she has put in the shared memory
|
|
|
|
|
* segment she prepared for us.
|
|
|
|
|
*/
|
|
|
|
|
|
2004-11-23 17:29:47 +00:00
|
|
|
#ifdef HAS_XVMCSHM
|
|
|
|
|
patternP = (CARD32 *) shmat(stuff->shmKey, NULL, SHM_RDONLY);
|
|
|
|
|
if (-1 != (long) patternP) {
|
2007-11-21 15:59:31 +10:30
|
|
|
volatile CARD32 *patternC = patternP;
|
|
|
|
|
int i;
|
2004-11-13 11:09:23 +00:00
|
|
|
CARD32 magic = stuff->magic;
|
2012-03-21 12:55:09 -07:00
|
|
|
|
2025-08-25 16:40:10 +02:00
|
|
|
reply.isLocal = 1;
|
2004-11-23 17:29:47 +00:00
|
|
|
i = 1024 / sizeof(CARD32);
|
2012-03-21 12:55:09 -07:00
|
|
|
|
2004-11-13 11:09:23 +00:00
|
|
|
while (i--) {
|
|
|
|
|
if (*patternC++ != magic) {
|
2025-08-25 16:40:10 +02:00
|
|
|
reply.isLocal = 0;
|
2004-11-13 11:09:23 +00:00
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
magic = ~magic;
|
|
|
|
|
}
|
2004-11-23 17:29:47 +00:00
|
|
|
shmdt((char *) patternP);
|
2012-03-21 12:55:09 -07:00
|
|
|
}
|
2004-11-23 17:29:47 +00:00
|
|
|
#endif /* HAS_XVMCSHM */
|
2012-03-21 12:55:09 -07:00
|
|
|
|
2025-08-25 18:30:58 +02:00
|
|
|
if (client->swapped) {
|
|
|
|
|
swapl(&reply.major);
|
|
|
|
|
swapl(&reply.minor);
|
|
|
|
|
swapl(&reply.patchLevel);
|
|
|
|
|
swapl(&reply.nameLen);
|
|
|
|
|
swapl(&reply.busIDLen);
|
|
|
|
|
swapl(&reply.isLocal);
|
|
|
|
|
}
|
|
|
|
|
|
2025-08-25 19:31:47 +02:00
|
|
|
return X_SEND_REPLY_WITH_RPCBUF(client, reply, rpcbuf);
|
2004-11-13 11:09:23 +00:00
|
|
|
}
|
2003-11-14 16:48:57 +00:00
|
|
|
|
|
|
|
|
static int
|
|
|
|
|
ProcXvMCDispatch(ClientPtr client)
|
|
|
|
|
{
|
2025-09-25 16:34:33 +02:00
|
|
|
if (!(client->local))
|
|
|
|
|
return BadImplementation;
|
|
|
|
|
|
2003-11-14 16:48:57 +00:00
|
|
|
REQUEST(xReq);
|
2024-07-12 16:42:42 +02:00
|
|
|
switch (stuff->data)
|
|
|
|
|
{
|
|
|
|
|
case xvmc_QueryVersion:
|
|
|
|
|
return ProcXvMCQueryVersion(client);
|
|
|
|
|
case xvmc_ListSurfaceTypes:
|
|
|
|
|
return ProcXvMCListSurfaceTypes(client);
|
|
|
|
|
case xvmc_CreateContext:
|
|
|
|
|
return ProcXvMCCreateContext(client);
|
|
|
|
|
case xvmc_DestroyContext:
|
|
|
|
|
return ProcXvMCDestroyContext(client);
|
|
|
|
|
case xvmc_CreateSurface:
|
|
|
|
|
return ProcXvMCCreateSurface(client);
|
|
|
|
|
case xvmc_DestroySurface:
|
|
|
|
|
return ProcXvMCDestroySurface(client);
|
|
|
|
|
case xvmc_CreateSubpicture:
|
|
|
|
|
return ProcXvMCCreateSubpicture(client);
|
|
|
|
|
case xvmc_DestroySubpicture:
|
|
|
|
|
return ProcXvMCDestroySubpicture(client);
|
|
|
|
|
case xvmc_ListSubpictureTypes:
|
|
|
|
|
return ProcXvMCListSubpictureTypes(client);
|
|
|
|
|
case xvmc_GetDRInfo:
|
|
|
|
|
return ProcXvMCGetDRInfo(client);
|
|
|
|
|
default:
|
|
|
|
|
return BadRequest;
|
|
|
|
|
}
|
2003-11-14 16:48:57 +00:00
|
|
|
}
|
|
|
|
|
|
Rework symbol visibility for easier maintenance
Save in a few special cases, _X_EXPORT should not be used in C source
files. Instead, it should be used in headers, and the proper C source
include that header. Some special cases are symbols that need to be
shared between modules, but not expected to be used by external drivers,
and symbols that are accessible via LoaderSymbol/dlopen.
This patch also adds conditionally some new sdk header files, depending
on extensions enabled. These files were added to match pattern for
other extensions/modules, that is, have the headers "deciding" symbol
visibility in the sdk. These headers are:
o Xext/panoramiXsrv.h, Xext/panoramiX.h
o fbpict.h (unconditionally)
o vidmodeproc.h
o mioverlay.h (unconditionally, used only by xaa)
o xfixes.h (unconditionally, symbols required by dri2)
LoaderSymbol and similar functions now don't have different prototypes,
in loaderProcs.h and xf86Module.h, so that both headers can be included,
without the need of defining IN_LOADER.
xf86NewInputDevice() device prototype readded to xf86Xinput.h, but
not exported (and with a comment about it).
2008-12-03 05:43:34 -02:00
|
|
|
void
|
2007-04-09 14:33:15 -07:00
|
|
|
XvMCExtensionInit(void)
|
2003-11-14 16:48:57 +00:00
|
|
|
{
|
|
|
|
|
ExtensionEntry *extEntry;
|
|
|
|
|
|
2011-05-24 18:33:11 +02:00
|
|
|
if (!dixPrivateKeyRegistered(XvMCScreenKey))
|
|
|
|
|
return;
|
2003-11-14 16:48:57 +00:00
|
|
|
|
2009-12-02 17:43:01 -08:00
|
|
|
if (!(XvMCRTContext = CreateNewResourceType(XvMCDestroyContextRes,
|
|
|
|
|
"XvMCRTContext")))
|
2003-11-14 16:48:57 +00:00
|
|
|
return;
|
|
|
|
|
|
2009-12-02 17:43:01 -08:00
|
|
|
if (!(XvMCRTSurface = CreateNewResourceType(XvMCDestroySurfaceRes,
|
|
|
|
|
"XvMCRTSurface")))
|
2003-11-14 16:48:57 +00:00
|
|
|
return;
|
|
|
|
|
|
2009-12-02 17:43:01 -08:00
|
|
|
if (!(XvMCRTSubpicture = CreateNewResourceType(XvMCDestroySubpictureRes,
|
|
|
|
|
"XvMCRTSubpicture")))
|
2003-11-14 16:48:57 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
extEntry = AddExtension(XvMCName, XvMCNumEvents, XvMCNumErrors,
|
2025-09-25 16:34:33 +02:00
|
|
|
ProcXvMCDispatch, ProcXvMCDispatch,
|
2008-07-24 14:59:14 -04:00
|
|
|
NULL, StandardMinorOpcode);
|
2003-11-14 16:48:57 +00:00
|
|
|
|
|
|
|
|
if (!extEntry)
|
|
|
|
|
return;
|
2012-03-21 12:55:09 -07:00
|
|
|
|
2003-11-14 16:48:57 +00:00
|
|
|
XvMCReqCode = extEntry->base;
|
|
|
|
|
XvMCEventBase = extEntry->eventBase;
|
2010-04-24 23:56:36 -07:00
|
|
|
SetResourceTypeErrorValue(XvMCRTContext,
|
|
|
|
|
extEntry->errorBase + XvMCBadContext);
|
|
|
|
|
SetResourceTypeErrorValue(XvMCRTSurface,
|
|
|
|
|
extEntry->errorBase + XvMCBadSurface);
|
|
|
|
|
SetResourceTypeErrorValue(XvMCRTSubpicture,
|
|
|
|
|
extEntry->errorBase + XvMCBadSubpicture);
|
2003-11-14 16:48:57 +00:00
|
|
|
}
|
|
|
|
|
|
2025-04-30 10:30:56 +02:00
|
|
|
static void XvMCScreenClose(CallbackListPtr *pcbl, ScreenPtr pScreen, void *unused)
|
2003-11-14 16:48:57 +00:00
|
|
|
{
|
|
|
|
|
XvMCScreenPtr pScreenPriv = XVMC_GET_PRIVATE(pScreen);
|
2010-05-06 01:44:06 +07:00
|
|
|
free(pScreenPriv);
|
2025-04-30 10:30:56 +02:00
|
|
|
dixSetPrivate(&pScreen->devPrivates, XvMCScreenKey, NULL);
|
|
|
|
|
dixScreenUnhookClose(pScreen, XvMCScreenClose);
|
2003-11-14 16:48:57 +00:00
|
|
|
}
|
|
|
|
|
|
Rework symbol visibility for easier maintenance
Save in a few special cases, _X_EXPORT should not be used in C source
files. Instead, it should be used in headers, and the proper C source
include that header. Some special cases are symbols that need to be
shared between modules, but not expected to be used by external drivers,
and symbols that are accessible via LoaderSymbol/dlopen.
This patch also adds conditionally some new sdk header files, depending
on extensions enabled. These files were added to match pattern for
other extensions/modules, that is, have the headers "deciding" symbol
visibility in the sdk. These headers are:
o Xext/panoramiXsrv.h, Xext/panoramiX.h
o fbpict.h (unconditionally)
o vidmodeproc.h
o mioverlay.h (unconditionally, used only by xaa)
o xfixes.h (unconditionally, symbols required by dri2)
LoaderSymbol and similar functions now don't have different prototypes,
in loaderProcs.h and xf86Module.h, so that both headers can be included,
without the need of defining IN_LOADER.
xf86NewInputDevice() device prototype readded to xf86Xinput.h, but
not exported (and with a comment about it).
2008-12-03 05:43:34 -02:00
|
|
|
int
|
2003-11-14 16:48:57 +00:00
|
|
|
XvMCScreenInit(ScreenPtr pScreen, int num, XvMCAdaptorPtr pAdapt)
|
|
|
|
|
{
|
|
|
|
|
XvMCScreenPtr pScreenPriv;
|
|
|
|
|
|
2010-04-26 17:22:21 -07:00
|
|
|
if (!dixRegisterPrivateKey(&XvMCScreenKeyRec, PRIVATE_SCREEN, 0))
|
|
|
|
|
return BadAlloc;
|
2003-11-14 16:48:57 +00:00
|
|
|
|
2025-04-10 18:43:08 +02:00
|
|
|
if (!(pScreenPriv = calloc(1, sizeof(XvMCScreenRec))))
|
2003-11-14 16:48:57 +00:00
|
|
|
return BadAlloc;
|
|
|
|
|
|
2007-08-28 09:28:25 -04:00
|
|
|
dixSetPrivate(&pScreen->devPrivates, XvMCScreenKey, pScreenPriv);
|
2003-11-14 16:48:57 +00:00
|
|
|
|
2025-04-30 10:30:56 +02:00
|
|
|
dixScreenHookClose(pScreen, XvMCScreenClose);
|
2003-11-14 16:48:57 +00:00
|
|
|
|
|
|
|
|
pScreenPriv->num_adaptors = num;
|
|
|
|
|
pScreenPriv->adaptors = pAdapt;
|
2004-11-13 11:09:23 +00:00
|
|
|
pScreenPriv->clientDriverName[0] = 0;
|
|
|
|
|
pScreenPriv->busID[0] = 0;
|
|
|
|
|
pScreenPriv->major = 0;
|
|
|
|
|
pScreenPriv->minor = 0;
|
|
|
|
|
pScreenPriv->patchLevel = 0;
|
2003-11-14 16:48:57 +00:00
|
|
|
|
2010-04-26 17:22:21 -07:00
|
|
|
XvMCInUse = TRUE;
|
|
|
|
|
|
2003-11-14 16:48:57 +00:00
|
|
|
return Success;
|
|
|
|
|
}
|
|
|
|
|
|
Rework symbol visibility for easier maintenance
Save in a few special cases, _X_EXPORT should not be used in C source
files. Instead, it should be used in headers, and the proper C source
include that header. Some special cases are symbols that need to be
shared between modules, but not expected to be used by external drivers,
and symbols that are accessible via LoaderSymbol/dlopen.
This patch also adds conditionally some new sdk header files, depending
on extensions enabled. These files were added to match pattern for
other extensions/modules, that is, have the headers "deciding" symbol
visibility in the sdk. These headers are:
o Xext/panoramiXsrv.h, Xext/panoramiX.h
o fbpict.h (unconditionally)
o vidmodeproc.h
o mioverlay.h (unconditionally, used only by xaa)
o xfixes.h (unconditionally, symbols required by dri2)
LoaderSymbol and similar functions now don't have different prototypes,
in loaderProcs.h and xf86Module.h, so that both headers can be included,
without the need of defining IN_LOADER.
xf86NewInputDevice() device prototype readded to xf86Xinput.h, but
not exported (and with a comment about it).
2008-12-03 05:43:34 -02:00
|
|
|
XvImagePtr
|
|
|
|
|
XvMCFindXvImage(XvPortPtr pPort, CARD32 id)
|
2003-11-14 16:48:57 +00:00
|
|
|
{
|
|
|
|
|
XvImagePtr pImage = NULL;
|
|
|
|
|
ScreenPtr pScreen = pPort->pAdaptor->pScreen;
|
|
|
|
|
XvMCScreenPtr pScreenPriv;
|
|
|
|
|
XvMCAdaptorPtr adaptor = NULL;
|
|
|
|
|
|
2011-05-24 18:33:11 +02:00
|
|
|
if (!dixPrivateKeyRegistered(XvMCScreenKey))
|
|
|
|
|
return NULL;
|
2003-11-14 16:48:57 +00:00
|
|
|
|
|
|
|
|
if (!(pScreenPriv = XVMC_GET_PRIVATE(pScreen)))
|
|
|
|
|
return NULL;
|
|
|
|
|
|
2025-02-21 19:11:13 +01:00
|
|
|
for (int i = 0; i < pScreenPriv->num_adaptors; i++) {
|
2003-11-14 16:48:57 +00:00
|
|
|
if (pPort->pAdaptor == pScreenPriv->adaptors[i].xv_adaptor) {
|
|
|
|
|
adaptor = &(pScreenPriv->adaptors[i]);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!adaptor)
|
|
|
|
|
return NULL;
|
|
|
|
|
|
2025-02-21 19:11:13 +01:00
|
|
|
for (int i = 0; i < adaptor->num_subpictures; i++) {
|
2003-11-14 16:48:57 +00:00
|
|
|
if (adaptor->subpictures[i]->id == id) {
|
|
|
|
|
pImage = adaptor->subpictures[i];
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return pImage;
|
|
|
|
|
}
|
2004-11-13 11:09:23 +00:00
|
|
|
|
Rework symbol visibility for easier maintenance
Save in a few special cases, _X_EXPORT should not be used in C source
files. Instead, it should be used in headers, and the proper C source
include that header. Some special cases are symbols that need to be
shared between modules, but not expected to be used by external drivers,
and symbols that are accessible via LoaderSymbol/dlopen.
This patch also adds conditionally some new sdk header files, depending
on extensions enabled. These files were added to match pattern for
other extensions/modules, that is, have the headers "deciding" symbol
visibility in the sdk. These headers are:
o Xext/panoramiXsrv.h, Xext/panoramiX.h
o fbpict.h (unconditionally)
o vidmodeproc.h
o mioverlay.h (unconditionally, used only by xaa)
o xfixes.h (unconditionally, symbols required by dri2)
LoaderSymbol and similar functions now don't have different prototypes,
in loaderProcs.h and xf86Module.h, so that both headers can be included,
without the need of defining IN_LOADER.
xf86NewInputDevice() device prototype readded to xf86Xinput.h, but
not exported (and with a comment about it).
2008-12-03 05:43:34 -02:00
|
|
|
int
|
2013-11-15 21:57:05 +09:00
|
|
|
xf86XvMCRegisterDRInfo(ScreenPtr pScreen, const char *name,
|
|
|
|
|
const char *busID, int major, int minor, int patchLevel)
|
2004-11-13 11:09:23 +00:00
|
|
|
{
|
|
|
|
|
XvMCScreenPtr pScreenPriv = XVMC_GET_PRIVATE(pScreen);
|
2012-03-21 12:55:09 -07:00
|
|
|
|
2011-10-28 21:18:46 -07:00
|
|
|
strlcpy(pScreenPriv->clientDriverName, name, DR_CLIENT_DRIVER_NAME_SIZE);
|
|
|
|
|
strlcpy(pScreenPriv->busID, busID, DR_BUSID_SIZE);
|
2004-11-13 11:09:23 +00:00
|
|
|
pScreenPriv->major = major;
|
|
|
|
|
pScreenPriv->minor = minor;
|
|
|
|
|
pScreenPriv->patchLevel = patchLevel;
|
|
|
|
|
return Success;
|
|
|
|
|
}
|