2003-11-14 17:48:57 +01:00
|
|
|
/**************************************************************************
|
|
|
|
|
|
|
|
Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
|
|
|
|
Copyright 2000 VA Linux Systems, Inc.
|
|
|
|
All Rights Reserved.
|
|
|
|
|
|
|
|
Permission is hereby granted, free of charge, to any person obtaining a
|
|
|
|
copy of this software and associated documentation files (the
|
|
|
|
"Software"), to deal in the Software without restriction, including
|
|
|
|
without limitation the rights to use, copy, modify, merge, publish,
|
|
|
|
distribute, sub license, and/or sell copies of the Software, and to
|
|
|
|
permit persons to whom the Software is furnished to do so, subject to
|
|
|
|
the following conditions:
|
|
|
|
|
|
|
|
The above copyright notice and this permission notice (including the
|
|
|
|
next paragraph) shall be included in all copies or substantial portions
|
|
|
|
of the Software.
|
|
|
|
|
|
|
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
|
|
|
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
|
|
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
|
|
|
|
IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
|
|
|
|
ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
|
|
|
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
|
|
|
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
|
|
|
|
|
|
**************************************************************************/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Authors:
|
|
|
|
* Kevin E. Martin <martin@valinux.com>
|
|
|
|
* Jens Owen <jens@tungstengraphics.com>
|
|
|
|
* Rickard E. (Rik) Faith <faith@valinux.com>
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2005-07-16 01:08:31 +02:00
|
|
|
#ifdef HAVE_XORG_CONFIG_H
|
|
|
|
#include <xorg-config.h>
|
2005-07-03 09:02:09 +02:00
|
|
|
#endif
|
|
|
|
|
2006-02-10 23:00:30 +01:00
|
|
|
#include <string.h>
|
|
|
|
|
2003-11-14 17:48:57 +01:00
|
|
|
#include "xf86.h"
|
|
|
|
|
2005-04-20 14:25:48 +02:00
|
|
|
#include <X11/X.h>
|
|
|
|
#include <X11/Xproto.h>
|
2005-07-03 10:53:54 +02:00
|
|
|
#include "misc.h"
|
2003-11-14 17:48:57 +01:00
|
|
|
#include "dixstruct.h"
|
|
|
|
#include "extnsionst.h"
|
2012-07-10 03:02:56 +02:00
|
|
|
#include "extinit.h"
|
2003-11-14 17:48:57 +01:00
|
|
|
#include "colormapst.h"
|
|
|
|
#include "cursorstr.h"
|
|
|
|
#include "scrnintstr.h"
|
|
|
|
#include "servermd.h"
|
|
|
|
#define _XF86DRI_SERVER_
|
2009-09-15 04:51:23 +02:00
|
|
|
#include <X11/dri/xf86driproto.h>
|
2003-11-14 17:48:57 +01:00
|
|
|
#include "swaprep.h"
|
2004-07-30 06:44:13 +02:00
|
|
|
#include "xf86str.h"
|
2003-11-14 17:48:57 +01:00
|
|
|
#include "dri.h"
|
|
|
|
#include "sarea.h"
|
|
|
|
#include "dristruct.h"
|
|
|
|
#include "xf86drm.h"
|
2009-09-18 08:27:54 +02:00
|
|
|
#include "protocol-versions.h"
|
2012-07-10 03:02:56 +02:00
|
|
|
#include "xf86Extensions.h"
|
2003-11-14 17:48:57 +01:00
|
|
|
|
|
|
|
static int DRIErrorBase;
|
|
|
|
|
2012-07-10 03:02:56 +02:00
|
|
|
static void XF86DRIResetProc(ExtensionEntry *extEntry);
|
2003-11-14 17:48:57 +01:00
|
|
|
|
|
|
|
static unsigned char DRIReqCode = 0;
|
|
|
|
|
2012-07-10 03:02:56 +02:00
|
|
|
/*ARGSUSED*/
|
|
|
|
static void
|
|
|
|
XF86DRIResetProc(ExtensionEntry *extEntry)
|
2003-11-14 17:48:57 +01:00
|
|
|
{
|
|
|
|
DRIReset();
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2012-03-21 20:55:09 +01:00
|
|
|
ProcXF86DRIQueryVersion(register ClientPtr client)
|
2003-11-14 17:48:57 +01:00
|
|
|
{
|
2012-07-10 04:12:43 +02:00
|
|
|
xXF86DRIQueryVersionReply rep = {
|
|
|
|
.type = X_Reply,
|
|
|
|
.sequenceNumber = client->sequence,
|
|
|
|
.length = 0,
|
|
|
|
.majorVersion = SERVER_XF86DRI_MAJOR_VERSION,
|
|
|
|
.minorVersion = SERVER_XF86DRI_MINOR_VERSION,
|
|
|
|
.patchVersion = SERVER_XF86DRI_PATCH_VERSION
|
|
|
|
};
|
2003-11-14 17:48:57 +01:00
|
|
|
|
|
|
|
REQUEST_SIZE_MATCH(xXF86DRIQueryVersionReq);
|
|
|
|
if (client->swapped) {
|
2012-03-21 20:55:09 +01:00
|
|
|
swaps(&rep.sequenceNumber);
|
|
|
|
swapl(&rep.length);
|
|
|
|
swaps(&rep.majorVersion);
|
|
|
|
swaps(&rep.minorVersion);
|
|
|
|
swapl(&rep.patchVersion);
|
2003-11-14 17:48:57 +01:00
|
|
|
}
|
2012-05-13 09:03:35 +02:00
|
|
|
WriteToClient(client, sizeof(xXF86DRIQueryVersionReply), &rep);
|
2010-05-11 05:22:05 +02:00
|
|
|
return Success;
|
2003-11-14 17:48:57 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2012-03-21 20:55:09 +01:00
|
|
|
ProcXF86DRIQueryDirectRenderingCapable(register ClientPtr client)
|
2003-11-14 17:48:57 +01:00
|
|
|
{
|
2012-03-21 20:55:09 +01:00
|
|
|
xXF86DRIQueryDirectRenderingCapableReply rep;
|
2003-11-14 17:48:57 +01:00
|
|
|
Bool isCapable;
|
|
|
|
|
|
|
|
REQUEST(xXF86DRIQueryDirectRenderingCapableReq);
|
|
|
|
REQUEST_SIZE_MATCH(xXF86DRIQueryDirectRenderingCapableReq);
|
|
|
|
if (stuff->screen >= screenInfo.numScreens) {
|
2012-03-21 20:55:09 +01:00
|
|
|
client->errorValue = stuff->screen;
|
|
|
|
return BadValue;
|
2003-11-14 17:48:57 +01:00
|
|
|
}
|
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
if (!DRIQueryDirectRenderingCapable(screenInfo.screens[stuff->screen],
|
|
|
|
&isCapable)) {
|
|
|
|
return BadValue;
|
2003-11-14 17:48:57 +01:00
|
|
|
}
|
|
|
|
|
2012-09-20 19:16:59 +02:00
|
|
|
if (!client->local || client->swapped)
|
2012-07-10 04:12:43 +02:00
|
|
|
isCapable = 0;
|
|
|
|
|
|
|
|
rep = (xXF86DRIQueryDirectRenderingCapableReply) {
|
|
|
|
.type = X_Reply,
|
|
|
|
.sequenceNumber = client->sequence,
|
|
|
|
.length = 0,
|
|
|
|
.isCapable = isCapable
|
|
|
|
};
|
2003-11-14 17:48:57 +01:00
|
|
|
|
2006-06-24 15:02:56 +02:00
|
|
|
if (client->swapped) {
|
2012-03-21 20:55:09 +01:00
|
|
|
swaps(&rep.sequenceNumber);
|
|
|
|
swapl(&rep.length);
|
2006-06-24 15:02:56 +02:00
|
|
|
}
|
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
WriteToClient(client,
|
|
|
|
sizeof(xXF86DRIQueryDirectRenderingCapableReply),
|
2012-05-13 09:03:35 +02:00
|
|
|
&rep);
|
2010-05-11 05:22:05 +02:00
|
|
|
return Success;
|
2003-11-14 17:48:57 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2012-03-21 20:55:09 +01:00
|
|
|
ProcXF86DRIOpenConnection(register ClientPtr client)
|
2003-11-14 17:48:57 +01:00
|
|
|
{
|
|
|
|
xXF86DRIOpenConnectionReply rep;
|
2012-03-21 20:55:09 +01:00
|
|
|
drm_handle_t hSAREA;
|
|
|
|
char *busIdString;
|
2012-07-10 04:12:42 +02:00
|
|
|
CARD32 busIdStringLength = 0;
|
2003-11-14 17:48:57 +01:00
|
|
|
|
|
|
|
REQUEST(xXF86DRIOpenConnectionReq);
|
|
|
|
REQUEST_SIZE_MATCH(xXF86DRIOpenConnectionReq);
|
|
|
|
if (stuff->screen >= screenInfo.numScreens) {
|
2012-03-21 20:55:09 +01:00
|
|
|
client->errorValue = stuff->screen;
|
|
|
|
return BadValue;
|
2003-11-14 17:48:57 +01:00
|
|
|
}
|
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
if (!DRIOpenConnection(screenInfo.screens[stuff->screen],
|
|
|
|
&hSAREA, &busIdString)) {
|
|
|
|
return BadValue;
|
2003-11-14 17:48:57 +01:00
|
|
|
}
|
|
|
|
|
2012-07-10 04:12:42 +02:00
|
|
|
if (busIdString)
|
|
|
|
busIdStringLength = strlen(busIdString);
|
|
|
|
|
2012-07-10 04:12:43 +02:00
|
|
|
rep = (xXF86DRIOpenConnectionReply) {
|
|
|
|
.type = X_Reply,
|
|
|
|
.sequenceNumber = client->sequence,
|
|
|
|
.length = bytes_to_int32(SIZEOF(xXF86DRIOpenConnectionReply) -
|
|
|
|
SIZEOF(xGenericReply) +
|
|
|
|
pad_to_int32(busIdStringLength)),
|
|
|
|
.busIdStringLength = busIdStringLength,
|
2003-11-14 17:48:57 +01:00
|
|
|
|
2012-07-10 04:12:43 +02:00
|
|
|
.hSAREALow = (CARD32) (hSAREA & 0xffffffff),
|
2005-11-19 00:34:04 +01:00
|
|
|
#if defined(LONG64) && !defined(__linux__)
|
2012-07-10 04:12:43 +02:00
|
|
|
.hSAREAHigh = (CARD32) (hSAREA >> 32),
|
2005-11-19 00:34:04 +01:00
|
|
|
#else
|
2012-07-10 04:12:43 +02:00
|
|
|
.hSAREAHigh = 0
|
2005-11-19 00:34:04 +01:00
|
|
|
#endif
|
2012-07-10 04:12:43 +02:00
|
|
|
};
|
2003-11-14 17:48:57 +01:00
|
|
|
|
2012-05-13 09:03:35 +02:00
|
|
|
WriteToClient(client, sizeof(xXF86DRIOpenConnectionReply), &rep);
|
2012-07-10 04:12:42 +02:00
|
|
|
if (busIdStringLength)
|
|
|
|
WriteToClient(client, busIdStringLength, busIdString);
|
2010-05-11 05:22:05 +02:00
|
|
|
return Success;
|
2003-11-14 17:48:57 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2012-03-21 20:55:09 +01:00
|
|
|
ProcXF86DRIAuthConnection(register ClientPtr client)
|
2003-11-14 17:48:57 +01:00
|
|
|
{
|
2012-07-10 04:12:43 +02:00
|
|
|
xXF86DRIAuthConnectionReply rep = {
|
|
|
|
.type = X_Reply,
|
|
|
|
.sequenceNumber = client->sequence,
|
|
|
|
.length = 0,
|
|
|
|
.authenticated = 1
|
|
|
|
};
|
2012-03-21 20:55:09 +01:00
|
|
|
|
2003-11-14 17:48:57 +01:00
|
|
|
REQUEST(xXF86DRIAuthConnectionReq);
|
|
|
|
REQUEST_SIZE_MATCH(xXF86DRIAuthConnectionReq);
|
|
|
|
if (stuff->screen >= screenInfo.numScreens) {
|
2012-03-21 20:55:09 +01:00
|
|
|
client->errorValue = stuff->screen;
|
|
|
|
return BadValue;
|
2003-11-14 17:48:57 +01:00
|
|
|
}
|
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
if (!DRIAuthConnection(screenInfo.screens[stuff->screen], stuff->magic)) {
|
|
|
|
ErrorF("Failed to authenticate %lu\n", (unsigned long) stuff->magic);
|
|
|
|
rep.authenticated = 0;
|
2003-11-14 17:48:57 +01:00
|
|
|
}
|
2012-05-13 09:03:35 +02:00
|
|
|
WriteToClient(client, sizeof(xXF86DRIAuthConnectionReply), &rep);
|
2010-05-11 05:22:05 +02:00
|
|
|
return Success;
|
2003-11-14 17:48:57 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2012-03-21 20:55:09 +01:00
|
|
|
ProcXF86DRICloseConnection(register ClientPtr client)
|
2003-11-14 17:48:57 +01:00
|
|
|
{
|
|
|
|
REQUEST(xXF86DRICloseConnectionReq);
|
|
|
|
REQUEST_SIZE_MATCH(xXF86DRICloseConnectionReq);
|
|
|
|
if (stuff->screen >= screenInfo.numScreens) {
|
2012-03-21 20:55:09 +01:00
|
|
|
client->errorValue = stuff->screen;
|
|
|
|
return BadValue;
|
2003-11-14 17:48:57 +01:00
|
|
|
}
|
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
DRICloseConnection(screenInfo.screens[stuff->screen]);
|
2003-11-14 17:48:57 +01:00
|
|
|
|
2010-05-11 05:22:05 +02:00
|
|
|
return Success;
|
2003-11-14 17:48:57 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2012-03-21 20:55:09 +01:00
|
|
|
ProcXF86DRIGetClientDriverName(register ClientPtr client)
|
2003-11-14 17:48:57 +01:00
|
|
|
{
|
2012-07-10 04:12:43 +02:00
|
|
|
xXF86DRIGetClientDriverNameReply rep = {
|
|
|
|
.type = X_Reply,
|
|
|
|
.sequenceNumber = client->sequence,
|
|
|
|
.clientDriverNameLength = 0
|
|
|
|
};
|
2012-03-21 20:55:09 +01:00
|
|
|
char *clientDriverName;
|
2003-11-14 17:48:57 +01:00
|
|
|
|
|
|
|
REQUEST(xXF86DRIGetClientDriverNameReq);
|
|
|
|
REQUEST_SIZE_MATCH(xXF86DRIGetClientDriverNameReq);
|
|
|
|
if (stuff->screen >= screenInfo.numScreens) {
|
2012-03-21 20:55:09 +01:00
|
|
|
client->errorValue = stuff->screen;
|
|
|
|
return BadValue;
|
2003-11-14 17:48:57 +01:00
|
|
|
}
|
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
DRIGetClientDriverName(screenInfo.screens[stuff->screen],
|
|
|
|
(int *) &rep.ddxDriverMajorVersion,
|
|
|
|
(int *) &rep.ddxDriverMinorVersion,
|
|
|
|
(int *) &rep.ddxDriverPatchVersion,
|
|
|
|
&clientDriverName);
|
2003-11-14 17:48:57 +01:00
|
|
|
|
|
|
|
if (clientDriverName)
|
2012-03-21 20:55:09 +01:00
|
|
|
rep.clientDriverNameLength = strlen(clientDriverName);
|
2009-07-06 04:12:20 +02:00
|
|
|
rep.length = bytes_to_int32(SIZEOF(xXF86DRIGetClientDriverNameReply) -
|
2012-03-21 20:55:09 +01:00
|
|
|
SIZEOF(xGenericReply) +
|
|
|
|
pad_to_int32(rep.clientDriverNameLength));
|
2003-11-14 17:48:57 +01:00
|
|
|
|
2012-05-13 09:03:35 +02:00
|
|
|
WriteToClient(client, sizeof(xXF86DRIGetClientDriverNameReply), &rep);
|
2003-11-14 17:48:57 +01:00
|
|
|
if (rep.clientDriverNameLength)
|
2012-03-21 20:55:09 +01:00
|
|
|
WriteToClient(client, rep.clientDriverNameLength, clientDriverName);
|
2010-05-11 05:22:05 +02:00
|
|
|
return Success;
|
2003-11-14 17:48:57 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2012-03-21 20:55:09 +01:00
|
|
|
ProcXF86DRICreateContext(register ClientPtr client)
|
2003-11-14 17:48:57 +01:00
|
|
|
{
|
2012-07-10 04:12:43 +02:00
|
|
|
xXF86DRICreateContextReply rep = {
|
|
|
|
.type = X_Reply,
|
|
|
|
.sequenceNumber = client->sequence,
|
|
|
|
.length = 0
|
|
|
|
};
|
2003-11-14 17:48:57 +01:00
|
|
|
ScreenPtr pScreen;
|
|
|
|
|
|
|
|
REQUEST(xXF86DRICreateContextReq);
|
|
|
|
REQUEST_SIZE_MATCH(xXF86DRICreateContextReq);
|
|
|
|
if (stuff->screen >= screenInfo.numScreens) {
|
2012-03-21 20:55:09 +01:00
|
|
|
client->errorValue = stuff->screen;
|
|
|
|
return BadValue;
|
2003-11-14 17:48:57 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
pScreen = screenInfo.screens[stuff->screen];
|
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
if (!DRICreateContext(pScreen,
|
|
|
|
NULL,
|
|
|
|
stuff->context, (drm_context_t *) & rep.hHWContext)) {
|
|
|
|
return BadValue;
|
2003-11-14 17:48:57 +01:00
|
|
|
}
|
|
|
|
|
2012-05-13 09:03:35 +02:00
|
|
|
WriteToClient(client, sizeof(xXF86DRICreateContextReply), &rep);
|
2010-05-11 05:22:05 +02:00
|
|
|
return Success;
|
2003-11-14 17:48:57 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2012-03-21 20:55:09 +01:00
|
|
|
ProcXF86DRIDestroyContext(register ClientPtr client)
|
2003-11-14 17:48:57 +01:00
|
|
|
{
|
|
|
|
REQUEST(xXF86DRIDestroyContextReq);
|
|
|
|
REQUEST_SIZE_MATCH(xXF86DRIDestroyContextReq);
|
|
|
|
if (stuff->screen >= screenInfo.numScreens) {
|
2012-03-21 20:55:09 +01:00
|
|
|
client->errorValue = stuff->screen;
|
|
|
|
return BadValue;
|
2003-11-14 17:48:57 +01:00
|
|
|
}
|
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
if (!DRIDestroyContext(screenInfo.screens[stuff->screen], stuff->context)) {
|
|
|
|
return BadValue;
|
2003-11-14 17:48:57 +01:00
|
|
|
}
|
|
|
|
|
2010-05-11 05:22:05 +02:00
|
|
|
return Success;
|
2003-11-14 17:48:57 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2012-03-21 20:55:09 +01:00
|
|
|
ProcXF86DRICreateDrawable(ClientPtr client)
|
2003-11-14 17:48:57 +01:00
|
|
|
{
|
2012-07-10 04:12:43 +02:00
|
|
|
xXF86DRICreateDrawableReply rep = {
|
|
|
|
.type = X_Reply,
|
|
|
|
.sequenceNumber = client->sequence,
|
|
|
|
.length = 0
|
|
|
|
};
|
2003-11-14 17:48:57 +01:00
|
|
|
DrawablePtr pDrawable;
|
2006-12-15 22:51:58 +01:00
|
|
|
int rc;
|
2003-11-14 17:48:57 +01:00
|
|
|
|
|
|
|
REQUEST(xXF86DRICreateDrawableReq);
|
|
|
|
REQUEST_SIZE_MATCH(xXF86DRICreateDrawableReq);
|
|
|
|
if (stuff->screen >= screenInfo.numScreens) {
|
2012-03-21 20:55:09 +01:00
|
|
|
client->errorValue = stuff->screen;
|
|
|
|
return BadValue;
|
2003-11-14 17:48:57 +01:00
|
|
|
}
|
|
|
|
|
2006-12-15 22:51:58 +01:00
|
|
|
rc = dixLookupDrawable(&pDrawable, stuff->drawable, client, 0,
|
2012-03-21 20:55:09 +01:00
|
|
|
DixReadAccess);
|
2006-12-15 22:51:58 +01:00
|
|
|
if (rc != Success)
|
2012-03-21 20:55:09 +01:00
|
|
|
return rc;
|
2003-11-14 17:48:57 +01:00
|
|
|
|
2007-07-10 09:02:08 +02:00
|
|
|
if (!DRICreateDrawable(screenInfo.screens[stuff->screen], client,
|
2012-03-21 20:55:09 +01:00
|
|
|
pDrawable, (drm_drawable_t *) & rep.hHWDrawable)) {
|
|
|
|
return BadValue;
|
2003-11-14 17:48:57 +01:00
|
|
|
}
|
|
|
|
|
2012-05-13 09:03:35 +02:00
|
|
|
WriteToClient(client, sizeof(xXF86DRICreateDrawableReply), &rep);
|
2010-05-11 05:22:05 +02:00
|
|
|
return Success;
|
2003-11-14 17:48:57 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2012-03-21 20:55:09 +01:00
|
|
|
ProcXF86DRIDestroyDrawable(register ClientPtr client)
|
2003-11-14 17:48:57 +01:00
|
|
|
{
|
|
|
|
REQUEST(xXF86DRIDestroyDrawableReq);
|
|
|
|
DrawablePtr pDrawable;
|
2006-12-15 22:51:58 +01:00
|
|
|
int rc;
|
2012-03-21 20:55:09 +01:00
|
|
|
|
2009-01-11 08:34:56 +01:00
|
|
|
REQUEST_SIZE_MATCH(xXF86DRIDestroyDrawableReq);
|
2006-12-15 22:51:58 +01:00
|
|
|
|
2003-11-14 17:48:57 +01:00
|
|
|
if (stuff->screen >= screenInfo.numScreens) {
|
2012-03-21 20:55:09 +01:00
|
|
|
client->errorValue = stuff->screen;
|
|
|
|
return BadValue;
|
2003-11-14 17:48:57 +01:00
|
|
|
}
|
|
|
|
|
2006-12-15 22:51:58 +01:00
|
|
|
rc = dixLookupDrawable(&pDrawable, stuff->drawable, client, 0,
|
2012-03-21 20:55:09 +01:00
|
|
|
DixReadAccess);
|
2006-12-15 22:51:58 +01:00
|
|
|
if (rc != Success)
|
2012-03-21 20:55:09 +01:00
|
|
|
return rc;
|
2003-11-14 17:48:57 +01:00
|
|
|
|
2007-07-10 09:02:08 +02:00
|
|
|
if (!DRIDestroyDrawable(screenInfo.screens[stuff->screen], client,
|
2012-03-21 20:55:09 +01:00
|
|
|
pDrawable)) {
|
|
|
|
return BadValue;
|
2003-11-14 17:48:57 +01:00
|
|
|
}
|
|
|
|
|
2010-05-11 05:22:05 +02:00
|
|
|
return Success;
|
2003-11-14 17:48:57 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2012-03-21 20:55:09 +01:00
|
|
|
ProcXF86DRIGetDrawableInfo(register ClientPtr client)
|
2003-11-14 17:48:57 +01:00
|
|
|
{
|
2012-07-10 04:12:43 +02:00
|
|
|
xXF86DRIGetDrawableInfoReply rep = {
|
|
|
|
.type = X_Reply,
|
|
|
|
.sequenceNumber = client->sequence,
|
|
|
|
.length = 0
|
|
|
|
};
|
2003-11-14 17:48:57 +01:00
|
|
|
DrawablePtr pDrawable;
|
|
|
|
int X, Y, W, H;
|
2012-03-21 20:55:09 +01:00
|
|
|
drm_clip_rect_t *pClipRects, *pClippedRects;
|
|
|
|
drm_clip_rect_t *pBackClipRects;
|
2006-12-15 22:51:58 +01:00
|
|
|
int backX, backY, rc;
|
2003-11-14 17:48:57 +01:00
|
|
|
|
|
|
|
REQUEST(xXF86DRIGetDrawableInfoReq);
|
|
|
|
REQUEST_SIZE_MATCH(xXF86DRIGetDrawableInfoReq);
|
|
|
|
if (stuff->screen >= screenInfo.numScreens) {
|
2012-03-21 20:55:09 +01:00
|
|
|
client->errorValue = stuff->screen;
|
|
|
|
return BadValue;
|
2003-11-14 17:48:57 +01:00
|
|
|
}
|
|
|
|
|
2006-12-15 22:51:58 +01:00
|
|
|
rc = dixLookupDrawable(&pDrawable, stuff->drawable, client, 0,
|
2012-03-21 20:55:09 +01:00
|
|
|
DixReadAccess);
|
2006-12-15 22:51:58 +01:00
|
|
|
if (rc != Success)
|
2012-03-21 20:55:09 +01:00
|
|
|
return rc;
|
|
|
|
|
|
|
|
if (!DRIGetDrawableInfo(screenInfo.screens[stuff->screen],
|
|
|
|
pDrawable,
|
|
|
|
(unsigned int *) &rep.drawableTableIndex,
|
|
|
|
(unsigned int *) &rep.drawableTableStamp,
|
|
|
|
(int *) &X,
|
|
|
|
(int *) &Y,
|
|
|
|
(int *) &W,
|
|
|
|
(int *) &H,
|
|
|
|
(int *) &rep.numClipRects,
|
|
|
|
&pClipRects,
|
|
|
|
&backX,
|
|
|
|
&backY,
|
|
|
|
(int *) &rep.numBackClipRects, &pBackClipRects)) {
|
|
|
|
return BadValue;
|
2003-11-14 17:48:57 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
rep.drawableX = X;
|
|
|
|
rep.drawableY = Y;
|
|
|
|
rep.drawableWidth = W;
|
|
|
|
rep.drawableHeight = H;
|
2012-03-21 20:55:09 +01:00
|
|
|
rep.length = (SIZEOF(xXF86DRIGetDrawableInfoReply) - SIZEOF(xGenericReply));
|
2003-11-14 17:48:57 +01:00
|
|
|
|
|
|
|
rep.backX = backX;
|
|
|
|
rep.backY = backY;
|
2012-03-21 20:55:09 +01:00
|
|
|
|
|
|
|
if (rep.numBackClipRects)
|
|
|
|
rep.length += sizeof(drm_clip_rect_t) * rep.numBackClipRects;
|
2003-11-14 17:48:57 +01:00
|
|
|
|
2007-06-11 09:23:19 +02:00
|
|
|
pClippedRects = pClipRects;
|
|
|
|
|
|
|
|
if (rep.numClipRects) {
|
2012-03-21 20:55:09 +01:00
|
|
|
/* Clip cliprects to screen dimensions (redirected windows) */
|
|
|
|
pClippedRects = malloc(rep.numClipRects * sizeof(drm_clip_rect_t));
|
|
|
|
|
|
|
|
if (pClippedRects) {
|
|
|
|
ScreenPtr pScreen = screenInfo.screens[stuff->screen];
|
|
|
|
int i, j;
|
|
|
|
|
|
|
|
for (i = 0, j = 0; i < rep.numClipRects; i++) {
|
|
|
|
pClippedRects[j].x1 = max(pClipRects[i].x1, 0);
|
|
|
|
pClippedRects[j].y1 = max(pClipRects[i].y1, 0);
|
|
|
|
pClippedRects[j].x2 = min(pClipRects[i].x2, pScreen->width);
|
|
|
|
pClippedRects[j].y2 = min(pClipRects[i].y2, pScreen->height);
|
|
|
|
|
|
|
|
if (pClippedRects[j].x1 < pClippedRects[j].x2 &&
|
|
|
|
pClippedRects[j].y1 < pClippedRects[j].y2) {
|
|
|
|
j++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
rep.numClipRects = j;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
rep.numClipRects = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
rep.length += sizeof(drm_clip_rect_t) * rep.numClipRects;
|
2007-06-11 09:23:19 +02:00
|
|
|
}
|
2012-03-21 20:55:09 +01:00
|
|
|
|
2009-07-06 04:12:20 +02:00
|
|
|
rep.length = bytes_to_int32(rep.length);
|
2003-11-14 17:48:57 +01:00
|
|
|
|
2012-05-13 09:03:35 +02:00
|
|
|
WriteToClient(client, sizeof(xXF86DRIGetDrawableInfoReply), &rep);
|
2003-11-14 17:48:57 +01:00
|
|
|
|
|
|
|
if (rep.numClipRects) {
|
2012-03-21 20:55:09 +01:00
|
|
|
WriteToClient(client,
|
|
|
|
sizeof(drm_clip_rect_t) * rep.numClipRects,
|
2012-05-13 09:03:35 +02:00
|
|
|
pClippedRects);
|
2012-03-21 20:55:09 +01:00
|
|
|
free(pClippedRects);
|
2003-11-14 17:48:57 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if (rep.numBackClipRects) {
|
2012-03-21 20:55:09 +01:00
|
|
|
WriteToClient(client,
|
|
|
|
sizeof(drm_clip_rect_t) * rep.numBackClipRects,
|
2012-05-13 09:03:35 +02:00
|
|
|
pBackClipRects);
|
2003-11-14 17:48:57 +01:00
|
|
|
}
|
|
|
|
|
2010-05-11 05:22:05 +02:00
|
|
|
return Success;
|
2003-11-14 17:48:57 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2012-03-21 20:55:09 +01:00
|
|
|
ProcXF86DRIGetDeviceInfo(register ClientPtr client)
|
2003-11-14 17:48:57 +01:00
|
|
|
{
|
2012-07-10 04:12:43 +02:00
|
|
|
xXF86DRIGetDeviceInfoReply rep = {
|
|
|
|
.type = X_Reply,
|
|
|
|
.sequenceNumber = client->sequence,
|
|
|
|
.length = 0
|
|
|
|
};
|
2004-06-16 11:25:21 +02:00
|
|
|
drm_handle_t hFrameBuffer;
|
2003-11-14 17:48:57 +01:00
|
|
|
void *pDevPrivate;
|
|
|
|
|
|
|
|
REQUEST(xXF86DRIGetDeviceInfoReq);
|
|
|
|
REQUEST_SIZE_MATCH(xXF86DRIGetDeviceInfoReq);
|
|
|
|
if (stuff->screen >= screenInfo.numScreens) {
|
2012-03-21 20:55:09 +01:00
|
|
|
client->errorValue = stuff->screen;
|
|
|
|
return BadValue;
|
2003-11-14 17:48:57 +01:00
|
|
|
}
|
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
if (!DRIGetDeviceInfo(screenInfo.screens[stuff->screen],
|
|
|
|
&hFrameBuffer,
|
|
|
|
(int *) &rep.framebufferOrigin,
|
|
|
|
(int *) &rep.framebufferSize,
|
|
|
|
(int *) &rep.framebufferStride,
|
|
|
|
(int *) &rep.devPrivateSize, &pDevPrivate)) {
|
|
|
|
return BadValue;
|
2003-11-14 17:48:57 +01:00
|
|
|
}
|
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
rep.hFrameBufferLow = (CARD32) (hFrameBuffer & 0xffffffff);
|
2005-11-19 00:34:04 +01:00
|
|
|
#if defined(LONG64) && !defined(__linux__)
|
2012-03-21 20:55:09 +01:00
|
|
|
rep.hFrameBufferHigh = (CARD32) (hFrameBuffer >> 32);
|
2005-11-19 00:34:04 +01:00
|
|
|
#else
|
2003-11-14 17:48:57 +01:00
|
|
|
rep.hFrameBufferHigh = 0;
|
2005-11-19 00:34:04 +01:00
|
|
|
#endif
|
2003-11-14 17:48:57 +01:00
|
|
|
|
|
|
|
if (rep.devPrivateSize) {
|
2012-03-21 20:55:09 +01:00
|
|
|
rep.length = bytes_to_int32(SIZEOF(xXF86DRIGetDeviceInfoReply) -
|
|
|
|
SIZEOF(xGenericReply) +
|
|
|
|
pad_to_int32(rep.devPrivateSize));
|
2003-11-14 17:48:57 +01:00
|
|
|
}
|
|
|
|
|
2012-05-13 09:03:35 +02:00
|
|
|
WriteToClient(client, sizeof(xXF86DRIGetDeviceInfoReply), &rep);
|
2003-11-14 17:48:57 +01:00
|
|
|
if (rep.length) {
|
2012-05-13 09:03:35 +02:00
|
|
|
WriteToClient(client, rep.devPrivateSize, pDevPrivate);
|
2003-11-14 17:48:57 +01:00
|
|
|
}
|
2010-05-11 05:22:05 +02:00
|
|
|
return Success;
|
2003-11-14 17:48:57 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2012-03-21 20:55:09 +01:00
|
|
|
ProcXF86DRIDispatch(register ClientPtr client)
|
2003-11-14 17:48:57 +01:00
|
|
|
{
|
|
|
|
REQUEST(xReq);
|
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
switch (stuff->data) {
|
2003-11-14 17:48:57 +01:00
|
|
|
case X_XF86DRIQueryVersion:
|
2012-03-21 20:55:09 +01:00
|
|
|
return ProcXF86DRIQueryVersion(client);
|
2003-11-14 17:48:57 +01:00
|
|
|
case X_XF86DRIQueryDirectRenderingCapable:
|
2012-03-21 20:55:09 +01:00
|
|
|
return ProcXF86DRIQueryDirectRenderingCapable(client);
|
2003-11-14 17:48:57 +01:00
|
|
|
}
|
|
|
|
|
2012-09-20 19:16:59 +02:00
|
|
|
if (!client->local)
|
2012-03-21 20:55:09 +01:00
|
|
|
return DRIErrorBase + XF86DRIClientNotLocal;
|
2003-11-14 17:48:57 +01:00
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
switch (stuff->data) {
|
2003-11-14 17:48:57 +01:00
|
|
|
case X_XF86DRIOpenConnection:
|
2012-03-21 20:55:09 +01:00
|
|
|
return ProcXF86DRIOpenConnection(client);
|
2003-11-14 17:48:57 +01:00
|
|
|
case X_XF86DRICloseConnection:
|
2012-03-21 20:55:09 +01:00
|
|
|
return ProcXF86DRICloseConnection(client);
|
2003-11-14 17:48:57 +01:00
|
|
|
case X_XF86DRIGetClientDriverName:
|
2012-03-21 20:55:09 +01:00
|
|
|
return ProcXF86DRIGetClientDriverName(client);
|
2003-11-14 17:48:57 +01:00
|
|
|
case X_XF86DRICreateContext:
|
2012-03-21 20:55:09 +01:00
|
|
|
return ProcXF86DRICreateContext(client);
|
2003-11-14 17:48:57 +01:00
|
|
|
case X_XF86DRIDestroyContext:
|
2012-03-21 20:55:09 +01:00
|
|
|
return ProcXF86DRIDestroyContext(client);
|
2003-11-14 17:48:57 +01:00
|
|
|
case X_XF86DRICreateDrawable:
|
2012-03-21 20:55:09 +01:00
|
|
|
return ProcXF86DRICreateDrawable(client);
|
2003-11-14 17:48:57 +01:00
|
|
|
case X_XF86DRIDestroyDrawable:
|
2012-03-21 20:55:09 +01:00
|
|
|
return ProcXF86DRIDestroyDrawable(client);
|
2003-11-14 17:48:57 +01:00
|
|
|
case X_XF86DRIGetDrawableInfo:
|
2012-03-21 20:55:09 +01:00
|
|
|
return ProcXF86DRIGetDrawableInfo(client);
|
2003-11-14 17:48:57 +01:00
|
|
|
case X_XF86DRIGetDeviceInfo:
|
2012-03-21 20:55:09 +01:00
|
|
|
return ProcXF86DRIGetDeviceInfo(client);
|
2003-11-14 17:48:57 +01:00
|
|
|
case X_XF86DRIAuthConnection:
|
2012-03-21 20:55:09 +01:00
|
|
|
return ProcXF86DRIAuthConnection(client);
|
|
|
|
/* {Open,Close}FullScreen are deprecated now */
|
2003-11-14 17:48:57 +01:00
|
|
|
default:
|
2012-03-21 20:55:09 +01:00
|
|
|
return BadRequest;
|
2003-11-14 17:48:57 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2012-03-21 20:55:09 +01:00
|
|
|
SProcXF86DRIQueryVersion(register ClientPtr client)
|
2003-11-14 17:48:57 +01:00
|
|
|
{
|
|
|
|
REQUEST(xXF86DRIQueryVersionReq);
|
2011-08-04 21:35:41 +02:00
|
|
|
swaps(&stuff->length);
|
2003-11-14 17:48:57 +01:00
|
|
|
return ProcXF86DRIQueryVersion(client);
|
|
|
|
}
|
|
|
|
|
2006-06-24 15:02:56 +02:00
|
|
|
static int
|
2012-03-21 20:55:09 +01:00
|
|
|
SProcXF86DRIQueryDirectRenderingCapable(register ClientPtr client)
|
2006-06-24 15:02:56 +02:00
|
|
|
{
|
|
|
|
REQUEST(xXF86DRIQueryDirectRenderingCapableReq);
|
2011-08-04 21:35:41 +02:00
|
|
|
swaps(&stuff->length);
|
|
|
|
swapl(&stuff->screen);
|
2006-06-24 15:02:56 +02:00
|
|
|
return ProcXF86DRIQueryDirectRenderingCapable(client);
|
|
|
|
}
|
|
|
|
|
2003-11-14 17:48:57 +01:00
|
|
|
static int
|
2012-03-21 20:55:09 +01:00
|
|
|
SProcXF86DRIDispatch(register ClientPtr client)
|
2003-11-14 17:48:57 +01:00
|
|
|
{
|
|
|
|
REQUEST(xReq);
|
|
|
|
|
2006-06-24 15:02:56 +02:00
|
|
|
/*
|
|
|
|
* Only local clients are allowed DRI access, but remote clients still need
|
|
|
|
* these requests to find out cleanly.
|
|
|
|
*/
|
2012-03-21 20:55:09 +01:00
|
|
|
switch (stuff->data) {
|
2003-11-14 17:48:57 +01:00
|
|
|
case X_XF86DRIQueryVersion:
|
2012-03-21 20:55:09 +01:00
|
|
|
return SProcXF86DRIQueryVersion(client);
|
2006-06-24 15:02:56 +02:00
|
|
|
case X_XF86DRIQueryDirectRenderingCapable:
|
2012-03-21 20:55:09 +01:00
|
|
|
return SProcXF86DRIQueryDirectRenderingCapable(client);
|
2003-11-14 17:48:57 +01:00
|
|
|
default:
|
2012-03-21 20:55:09 +01:00
|
|
|
return DRIErrorBase + XF86DRIClientNotLocal;
|
2003-11-14 17:48:57 +01:00
|
|
|
}
|
|
|
|
}
|
2010-07-16 19:19:50 +02:00
|
|
|
|
|
|
|
void
|
|
|
|
XFree86DRIExtensionInit(void)
|
|
|
|
{
|
2012-03-21 20:55:09 +01:00
|
|
|
ExtensionEntry *extEntry;
|
2010-07-16 19:19:50 +02:00
|
|
|
|
|
|
|
#ifdef XF86DRI_EVENTS
|
|
|
|
EventType = CreateNewResourceType(XF86DRIFreeEvents, "DRIEvent");
|
|
|
|
#endif
|
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
if (DRIExtensionInit() &&
|
2010-07-16 19:19:50 +02:00
|
|
|
#ifdef XF86DRI_EVENTS
|
|
|
|
EventType && ScreenPrivateIndex != -1 &&
|
|
|
|
#endif
|
2012-03-21 20:55:09 +01:00
|
|
|
(extEntry = AddExtension(XF86DRINAME,
|
|
|
|
XF86DRINumberEvents,
|
|
|
|
XF86DRINumberErrors,
|
|
|
|
ProcXF86DRIDispatch,
|
|
|
|
SProcXF86DRIDispatch,
|
|
|
|
XF86DRIResetProc, StandardMinorOpcode))) {
|
|
|
|
DRIReqCode = (unsigned char) extEntry->base;
|
|
|
|
DRIErrorBase = extEntry->errorBase;
|
2010-07-16 19:19:50 +02:00
|
|
|
}
|
|
|
|
}
|