diff options
Diffstat (limited to 'hw/xfree86/dixmods/extmod')
-rw-r--r-- | hw/xfree86/dixmods/extmod/dgaproc.h | 147 | ||||
-rw-r--r-- | hw/xfree86/dixmods/extmod/modinit.c | 362 | ||||
-rw-r--r-- | hw/xfree86/dixmods/extmod/vidmodeproc.h | 74 | ||||
-rw-r--r-- | hw/xfree86/dixmods/extmod/xf86dga.c | 302 | ||||
-rw-r--r-- | hw/xfree86/dixmods/extmod/xf86dga2.c | 773 | ||||
-rw-r--r-- | hw/xfree86/dixmods/extmod/xf86misc.c | 767 | ||||
-rw-r--r-- | hw/xfree86/dixmods/extmod/xf86miscproc.h | 64 | ||||
-rw-r--r-- | hw/xfree86/dixmods/extmod/xvmod.c | 20 | ||||
-rw-r--r-- | hw/xfree86/dixmods/extmod/xvmodproc.h | 10 |
9 files changed, 2519 insertions, 0 deletions
diff --git a/hw/xfree86/dixmods/extmod/dgaproc.h b/hw/xfree86/dixmods/extmod/dgaproc.h new file mode 100644 index 000000000..2b0118f15 --- /dev/null +++ b/hw/xfree86/dixmods/extmod/dgaproc.h @@ -0,0 +1,147 @@ +/* $XFree86: xc/programs/Xserver/Xext/dgaproc.h,v 1.21 2000/06/30 19:06:54 keithp Exp $ */ + +#ifndef __DGAPROC_H +#define __DGAPROC_H + +#include "Xproto.h" +#include "pixmap.h" + +#define DGA_CONCURRENT_ACCESS 0x00000001 +#define DGA_FILL_RECT 0x00000002 +#define DGA_BLIT_RECT 0x00000004 +#define DGA_BLIT_RECT_TRANS 0x00000008 +#define DGA_PIXMAP_AVAILABLE 0x00000010 + +#define DGA_INTERLACED 0x00010000 +#define DGA_DOUBLESCAN 0x00020000 + +#define DGA_FLIP_IMMEDIATE 0x00000001 +#define DGA_FLIP_RETRACE 0x00000002 + +#define DGA_COMPLETED 0x00000000 +#define DGA_PENDING 0x00000001 + +#define DGA_NEED_ROOT 0x00000001 + +typedef struct { + int num; /* A unique identifier for the mode (num > 0) */ + char *name; /* name of mode given in the XF86Config */ + int VSync_num; + int VSync_den; + int flags; /* DGA_CONCURRENT_ACCESS, etc... */ + int imageWidth; /* linear accessible portion (pixels) */ + int imageHeight; + int pixmapWidth; /* Xlib accessible portion (pixels) */ + int pixmapHeight; /* both fields ignored if no concurrent access */ + int bytesPerScanline; + int byteOrder; /* MSBFirst, LSBFirst */ + int depth; + int bitsPerPixel; + unsigned long red_mask; + unsigned long green_mask; + unsigned long blue_mask; + short visualClass; + int viewportWidth; + int viewportHeight; + int xViewportStep; /* viewport position granularity */ + int yViewportStep; + int maxViewportX; /* max viewport origin */ + int maxViewportY; + int viewportFlags; /* types of page flipping possible */ + int offset; + int reserved1; + int reserved2; +} XDGAModeRec, *XDGAModePtr; + + +void XFree86DGAExtensionInit(void); + +/* DDX interface */ + +int +DGASetMode( + int Index, + int num, + XDGAModePtr mode, + PixmapPtr *pPix +); + +void +DGASetInputMode( + int Index, + Bool keyboard, + Bool mouse +); + +void +DGASelectInput( + int Index, + ClientPtr client, + long mask +); + +Bool DGAAvailable(int Index); +Bool DGAActive(int Index); +void DGAShutdown(void); +void DGAInstallCmap(ColormapPtr cmap); +int DGAGetViewportStatus(int Index); +int DGASync(int Index); + +int +DGAFillRect( + int Index, + int x, int y, int w, int h, + unsigned long color +); + +int +DGABlitRect( + int Index, + int srcx, int srcy, + int w, int h, + int dstx, int dsty +); + +int +DGABlitTransRect( + int Index, + int srcx, int srcy, + int w, int h, + int dstx, int dsty, + unsigned long color +); + +int +DGASetViewport( + int Index, + int x, int y, + int mode +); + +int DGAGetModes(int Index); +int DGAGetOldDGAMode(int Index); + +int DGAGetModeInfo(int Index, XDGAModePtr mode, int num); + +Bool DGAVTSwitch(void); +Bool DGAStealMouseEvent(int Index, xEvent *e, int dx, int dy); +Bool DGAStealKeyEvent(int Index, xEvent *e); +Bool DGAIsDgaEvent (xEvent *e); + +Bool DGADeliverEvent (ScreenPtr pScreen, xEvent *e); + +Bool DGAOpenFramebuffer(int Index, char **name, unsigned char **mem, + int *size, int *offset, int *flags); +void DGACloseFramebuffer(int Index); +Bool DGAChangePixmapMode(int Index, int *x, int *y, int mode); +int DGACreateColormap(int Index, ClientPtr client, int id, int mode, + int alloc); + +extern unsigned char DGAReqCode; +extern int DGAErrorBase; +extern int DGAEventBase; +extern int *XDGAEventBase; + + + +#endif /* __DGAPROC_H */ diff --git a/hw/xfree86/dixmods/extmod/modinit.c b/hw/xfree86/dixmods/extmod/modinit.c new file mode 100644 index 000000000..d97b88fa4 --- /dev/null +++ b/hw/xfree86/dixmods/extmod/modinit.c @@ -0,0 +1,362 @@ +/* $XFree86: xc/programs/Xserver/Xext/extmod/modinit.c,v 1.16 2002/03/06 21:12:33 mvojkovi Exp $ */ + +/* + * + * Copyright (c) 1997 Matthieu Herrb + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that + * copyright notice and this permission notice appear in supporting + * documentation, and that the name of Matthieu Herrb not be used in + * advertising or publicity pertaining to distribution of the software without + * specific, written prior permission. Matthieu Herrb makes no + * representations about the suitability of this software for any purpose. + * It is provided "as is" without express or implied warranty. + * + * MATTHIEU HERRB DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL MATTHIEU HERRB BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + */ + +#ifdef XFree86LOADER +#include "xf86_ansic.h" + +#include "xf86Module.h" +#include "xf86Opt.h" + +#include "Xproto.h" + +static MODULESETUPPROTO(extmodSetup); + +extern Bool noTestExtensions; + +#ifdef SHAPE +extern void ShapeExtensionInit(INITARGS); +#define _SHAPE_SERVER_ /* don't want Xlib structures */ +#include "shapestr.h" +#endif + +#ifdef MULTIBUFFER +extern void MultibufferExtensionInit(INITARGS); +#define _MULTIBUF_SERVER_ /* don't want Xlib structures */ +#include "multibufst.h" +#endif + +#ifdef MITMISC +extern void MITMiscExtensionInit(INITARGS); +#define _MITMISC_SERVER_ +#include "mitmiscstr.h" +#endif + +#ifdef XTEST +extern void XTestExtensionInit(INITARGS); +#define _XTEST_SERVER_ +#include "XTest.h" +#include "xteststr.h" +#endif + +#ifdef BIGREQS +extern void BigReqExtensionInit(INITARGS); +#include "bigreqstr.h" +#endif + +#ifdef XSYNC +extern void SyncExtensionInit(INITARGS); +#define _SYNC_SERVER +#include "sync.h" +#include "syncstr.h" +#endif + +#ifdef SCREENSAVER +extern void ScreenSaverExtensionInit (INITARGS); +#include "saver.h" +#endif + +#ifdef XCMISC +extern void XCMiscExtensionInit(INITARGS); +#include "xcmiscstr.h" +#endif + +#ifdef XF86VIDMODE +extern void XFree86VidModeExtensionInit(INITARGS); +#define _XF86VIDMODE_SERVER_ +#include "xf86vmstr.h" +#endif + +#ifdef XF86MISC +extern void XFree86MiscExtensionInit(INITARGS); +#define _XF86MISC_SERVER_ +#define _XF86MISC_SAVER_COMPAT_ +#include "xf86mscstr.h" +#endif + +#ifdef XFreeXDGA +extern void XFree86DGAExtensionInit(INITARGS); +extern void XFree86DGARegister(INITARGS); +#define _XF86DGA_SERVER_ +#include "xf86dgastr.h" +#endif + +#ifdef DPMSExtension +extern void DPMSExtensionInit(INITARGS); +#include "dpmsstr.h" +#endif + +#ifdef FONTCACHE +extern void FontCacheExtensionInit(INITARGS); +#define _FONTCACHE_SERVER_ +#include "fontcacheP.h" +#include "fontcachstr.h" +#endif + +#ifdef TOGCUP +extern void XcupExtensionInit(INITARGS); +#define _XCUP_SERVER_ +#include "Xcupstr.h" +#endif + +#ifdef EVI +extern void EVIExtensionInit(INITARGS); +#define _XEVI_SERVER_ +#include "XEVIstr.h" +#endif + +#ifdef XV +extern void XvExtensionInit(INITARGS); +extern void XvMCExtensionInit(INITARGS); +extern void XvRegister(INITARGS); +#include "Xv.h" +#include "XvMC.h" +#endif + +#ifdef RES +extern void ResExtensionInit(INITARGS); +#include "XResproto.h" +#endif + +/* + * Array describing extensions to be initialized + */ +ExtensionModule extensionModules[] = { +#ifdef SHAPE + { + ShapeExtensionInit, + SHAPENAME, + NULL, + NULL, + NULL + }, +#endif +#ifdef MULTIBUFFER + { + MultibufferExtensionInit, + MULTIBUFFER_PROTOCOL_NAME, + NULL, + NULL, + NULL + }, +#endif +#ifdef MITMISC + { + MITMiscExtensionInit, + MITMISCNAME, + NULL, + NULL, + NULL + }, +#endif +#ifdef notyet + { + XTestExtensionInit, + XTestExtensionName, + &noTestExtensions, + NULL, + NULL + }, +#endif +#ifdef BIGREQS + { + BigReqExtensionInit, + XBigReqExtensionName, + NULL, + NULL, + NULL + }, +#endif +#ifdef XSYNC + { + SyncExtensionInit, + SYNC_NAME, + NULL, + NULL, + NULL + }, +#endif +#ifdef SCREENSAVER + { + ScreenSaverExtensionInit, + ScreenSaverName, + NULL, + NULL, + NULL + }, +#endif +#ifdef XCMISC + { + XCMiscExtensionInit, + XCMiscExtensionName, + NULL, + NULL, + NULL + }, +#endif +#ifdef XF86VIDMODE + { + XFree86VidModeExtensionInit, + XF86VIDMODENAME, + NULL, + NULL, + NULL + }, +#endif +#ifdef XF86MISC + { + XFree86MiscExtensionInit, + XF86MISCNAME, + NULL, + NULL, + NULL + }, +#endif +#ifdef XFreeXDGA + { + XFree86DGAExtensionInit, + XF86DGANAME, + NULL, + XFree86DGARegister, + NULL + }, +#endif +#ifdef DPMSExtension + { + DPMSExtensionInit, + DPMSExtensionName, + NULL, + NULL + }, +#endif +#ifdef FONTCACHE + { + FontCacheExtensionInit, + FONTCACHENAME, + NULL, + NULL, + NULL + }, +#endif +#ifdef TOGCUP + { + XcupExtensionInit, + XCUPNAME, + NULL, + NULL, + NULL + }, +#endif +#ifdef EVI + { + EVIExtensionInit, + EVINAME, + NULL, + NULL, + NULL + }, +#endif +#ifdef XV + { + XvExtensionInit, + XvName, + NULL, + XvRegister, + NULL + }, + { + XvMCExtensionInit, + XvMCName, + NULL, + NULL, + NULL + }, +#endif +#ifdef RES + { + ResExtensionInit, + XRES_NAME, + NULL, + NULL, + NULL + }, +#endif + { /* DON'T delete this entry ! */ + NULL, + NULL, + NULL, + NULL, + NULL + } +}; + +static XF86ModuleVersionInfo VersRec = +{ + "extmod", + MODULEVENDORSTRING, + MODINFOSTRING1, + MODINFOSTRING2, + XF86_VERSION_CURRENT, + 1, 0, 0, + ABI_CLASS_EXTENSION, + ABI_EXTENSION_VERSION, + MOD_CLASS_EXTENSION, + {0,0,0,0} +}; + +/* + * Data for the loader + */ +XF86ModuleData extmodModuleData = { &VersRec, extmodSetup, NULL }; + +static pointer +extmodSetup(pointer module, pointer opts, int *errmaj, int *errmin) +{ + int i; + + /* XXX the option stuff here is largely a sample/test case */ + + for (i = 0; extensionModules[i].name != NULL; i++) { + if (opts) { + char *s; + s = (char *)xalloc(strlen(extensionModules[i].name) + 5); + if (s) { + pointer o; + strcpy(s, "omit"); + strcat(s, extensionModules[i].name); + o = xf86FindOption(opts, s); + xfree(s); + if (o) { + xf86MarkOptionUsed(o); + continue; + } + } + } + LoadExtension(&extensionModules[i], FALSE); + } + /* Need a non-NULL return */ + return (pointer)1; +} + +#endif /* XFree86LOADER */ diff --git a/hw/xfree86/dixmods/extmod/vidmodeproc.h b/hw/xfree86/dixmods/extmod/vidmodeproc.h new file mode 100644 index 000000000..57a7872f0 --- /dev/null +++ b/hw/xfree86/dixmods/extmod/vidmodeproc.h @@ -0,0 +1,74 @@ +/* $XFree86: xc/programs/Xserver/Xext/vidmodeproc.h,v 1.5 2001/05/06 00:51:19 mvojkovi Exp $ */ + +/* Prototypes for DGA functions that the DDX must provide */ + +#ifndef _VIDMODEPROC_H_ +#define _VIDMODEPROC_H_ + + +typedef enum { + VIDMODE_H_DISPLAY, + VIDMODE_H_SYNCSTART, + VIDMODE_H_SYNCEND, + VIDMODE_H_TOTAL, + VIDMODE_H_SKEW, + VIDMODE_V_DISPLAY, + VIDMODE_V_SYNCSTART, + VIDMODE_V_SYNCEND, + VIDMODE_V_TOTAL, + VIDMODE_FLAGS, + VIDMODE_CLOCK +} VidModeSelectMode; + +typedef enum { + VIDMODE_MON_VENDOR, + VIDMODE_MON_MODEL, + VIDMODE_MON_NHSYNC, + VIDMODE_MON_NVREFRESH, + VIDMODE_MON_HSYNC_LO, + VIDMODE_MON_HSYNC_HI, + VIDMODE_MON_VREFRESH_LO, + VIDMODE_MON_VREFRESH_HI +} VidModeSelectMonitor; + +typedef union { + pointer ptr; + int i; + float f; +} vidMonitorValue; + +void XFree86VidModeExtensionInit(void); + +Bool VidModeAvailable(int scrnIndex); +Bool VidModeGetCurrentModeline(int scrnIndex, pointer *mode, int *dotClock); +Bool VidModeGetFirstModeline(int scrnIndex, pointer *mode, int *dotClock); +Bool VidModeGetNextModeline(int scrnIndex, pointer *mode, int *dotClock); +Bool VidModeDeleteModeline(int scrnIndex, pointer mode); +Bool VidModeZoomViewport(int scrnIndex, int zoom); +Bool VidModeGetViewPort(int scrnIndex, int *x, int *y); +Bool VidModeSetViewPort(int scrnIndex, int x, int y); +Bool VidModeSwitchMode(int scrnIndex, pointer mode); +Bool VidModeLockZoom(int scrnIndex, Bool lock); +Bool VidModeGetMonitor(int scrnIndex, pointer *monitor); +int VidModeGetNumOfClocks(int scrnIndex, Bool *progClock); +Bool VidModeGetClocks(int scrnIndex, int *Clocks); +ModeStatus VidModeCheckModeForMonitor(int scrnIndex, pointer mode); +ModeStatus VidModeCheckModeForDriver(int scrnIndex, pointer mode); +void VidModeSetCrtcForMode(int scrnIndex, pointer mode); +Bool VidModeAddModeline(int scrnIndex, pointer mode); +int VidModeGetDotClock(int scrnIndex, int Clock); +int VidModeGetNumOfModes(int scrnIndex); +Bool VidModeSetGamma(int scrnIndex, float red, float green, float blue); +Bool VidModeGetGamma(int scrnIndex, float *red, float *green, float *blue); +pointer VidModeCreateMode(void); +void VidModeCopyMode(pointer modefrom, pointer modeto); +int VidModeGetModeValue(pointer mode, int valtyp); +void VidModeSetModeValue(pointer mode, int valtyp, int val); +vidMonitorValue VidModeGetMonitorValue(pointer monitor, int valtyp, int indx); +Bool VidModeSetGammaRamp(int, int, CARD16 *, CARD16 *, CARD16 *); +Bool VidModeGetGammaRamp(int, int, CARD16 *, CARD16 *, CARD16 *); +int VidModeGetGammaRampSize(int scrnIndex); + +#endif + + diff --git a/hw/xfree86/dixmods/extmod/xf86dga.c b/hw/xfree86/dixmods/extmod/xf86dga.c new file mode 100644 index 000000000..9593c4a40 --- /dev/null +++ b/hw/xfree86/dixmods/extmod/xf86dga.c @@ -0,0 +1,302 @@ +/* $XFree86: xc/programs/Xserver/Xext/xf86dga.c,v 3.21 2000/06/30 19:06:54 keithp Exp $ */ + +/* + +Copyright (c) 1995 Jon Tombs +Copyright (c) 1995, 1996, 1999 XFree86 Inc + +*/ + +#define NEED_REPLIES +#define NEED_EVENTS +#include "X.h" +#include "Xproto.h" +#include "misc.h" +#include "dixstruct.h" +#include "extnsionst.h" +#include "colormapst.h" +#include "cursorstr.h" +#include "scrnintstr.h" +#include "servermd.h" +#define _XF86DGA_SERVER_ +#include "xf86dga.h" +#include "xf86dgastr.h" +#include "swaprep.h" +#include "dgaproc.h" + + +static DISPATCH_PROC(ProcXF86DGADirectVideo); +static DISPATCH_PROC(ProcXF86DGAGetVidPage); +static DISPATCH_PROC(ProcXF86DGAGetVideoLL); +static DISPATCH_PROC(ProcXF86DGAGetViewPortSize); +static DISPATCH_PROC(ProcXF86DGASetVidPage); +static DISPATCH_PROC(ProcXF86DGASetViewPort); +static DISPATCH_PROC(ProcXF86DGAInstallColormap); +static DISPATCH_PROC(ProcXF86DGAQueryDirectVideo); +static DISPATCH_PROC(ProcXF86DGAViewPortChanged); + + +static int +ProcXF86DGAGetVideoLL(ClientPtr client) +{ + REQUEST(xXF86DGAGetVideoLLReq); + xXF86DGAGetVideoLLReply rep; + XDGAModeRec mode; + int num, offset, flags; + char *name; + + if (stuff->screen > screenInfo.numScreens) + return BadValue; + + REQUEST_SIZE_MATCH(xXF86DGAGetVideoLLReq); + rep.type = X_Reply; + rep.length = 0; + rep.sequenceNumber = client->sequence; + + if(!DGAAvailable(stuff->screen)) + return (DGAErrorBase + XF86DGANoDirectVideoMode); + + if(!(num = DGAGetOldDGAMode(stuff->screen))) + return (DGAErrorBase + XF86DGANoDirectVideoMode); + + /* get the parameters for the mode that best matches */ + DGAGetModeInfo(stuff->screen, &mode, num); + + if(!DGAOpenFramebuffer(stuff->screen, &name, + (unsigned char**)(&rep.offset), + (int*)(&rep.bank_size), &offset, &flags)) + return BadAlloc; + + rep.offset += mode.offset; + rep.width = mode.bytesPerScanline / (mode.bitsPerPixel >> 3); + rep.ram_size = rep.bank_size >> 10; + + WriteToClient(client, SIZEOF(xXF86DGAGetVideoLLReply), (char *)&rep); + return (client->noClientException); +} + +static int +ProcXF86DGADirectVideo(ClientPtr client) +{ + int num; + PixmapPtr pix; + XDGAModeRec mode; + REQUEST(xXF86DGADirectVideoReq); + + if (stuff->screen > screenInfo.numScreens) + return BadValue; + + REQUEST_SIZE_MATCH(xXF86DGADirectVideoReq); + + if (!DGAAvailable(stuff->screen)) + return DGAErrorBase + XF86DGANoDirectVideoMode; + + if (stuff->enable & XF86DGADirectGraphics) { + if(!(num = DGAGetOldDGAMode(stuff->screen))) + return (DGAErrorBase + XF86DGANoDirectVideoMode); + } else + num = 0; + + if(Success != DGASetMode(stuff->screen, num, &mode, &pix)) + return (DGAErrorBase + XF86DGAScreenNotActive); + + DGASetInputMode (stuff->screen, + (stuff->enable & XF86DGADirectKeyb) != 0, + (stuff->enable & XF86DGADirectMouse) != 0); + + return (client->noClientException); +} + +static int +ProcXF86DGAGetViewPortSize(ClientPtr client) +{ + int num; + XDGAModeRec mode; + REQUEST(xXF86DGAGetViewPortSizeReq); + xXF86DGAGetViewPortSizeReply rep; + + if (stuff->screen > screenInfo.numScreens) + return BadValue; + + REQUEST_SIZE_MATCH(xXF86DGAGetViewPortSizeReq); + rep.type = X_Reply; + rep.length = 0; + rep.sequenceNumber = client->sequence; + + if (!DGAAvailable(stuff->screen)) + return (DGAErrorBase + XF86DGANoDirectVideoMode); + + if(!(num = DGAGetOldDGAMode(stuff->screen))) + return (DGAErrorBase + XF86DGANoDirectVideoMode); + + DGAGetModeInfo(stuff->screen, &mode, num); + + rep.width = mode.viewportWidth; + rep.height = mode.viewportHeight; + + WriteToClient(client, SIZEOF(xXF86DGAGetViewPortSizeReply), (char *)&rep); + return (client->noClientException); +} + +static int +ProcXF86DGASetViewPort(ClientPtr client) +{ + REQUEST(xXF86DGASetViewPortReq); + + if (stuff->screen > screenInfo.numScreens) + return BadValue; + + REQUEST_SIZE_MATCH(xXF86DGASetViewPortReq); + + if (!DGAActive(stuff->screen)) + { + int num; + PixmapPtr pix; + XDGAModeRec mode; + + if(!(num = DGAGetOldDGAMode(stuff->screen))) + return (DGAErrorBase + XF86DGANoDirectVideoMode); + if(Success != DGASetMode(stuff->screen, num, &mode, &pix)) + return (DGAErrorBase + XF86DGAScreenNotActive); + } + + if (DGASetViewport(stuff->screen, stuff->x, stuff->y, DGA_FLIP_RETRACE) + != Success) + return DGAErrorBase + XF86DGADirectNotActivated; + + return (client->noClientException); +} + +static int +ProcXF86DGAGetVidPage(ClientPtr client) +{ + REQUEST(xXF86DGAGetVidPageReq); + xXF86DGAGetVidPageReply rep; + + if (stuff->screen > screenInfo.numScreens) + return BadValue; + + REQUEST_SIZE_MATCH(xXF86DGAGetVidPageReq); + rep.type = X_Reply; + rep.length = 0; + rep.sequenceNumber = client->sequence; + rep.vpage = 0; /* silently fail */ + + WriteToClient(client, SIZEOF(xXF86DGAGetVidPageReply), (char *)&rep); + return (client->noClientException); +} + + +static int +ProcXF86DGASetVidPage(ClientPtr client) +{ + REQUEST(xXF86DGASetVidPageReq); + + if (stuff->screen > screenInfo.numScreens) + return BadValue; + + REQUEST_SIZE_MATCH(xXF86DGASetVidPageReq); + + /* silently fail */ + + return (client->noClientException); +} + + +static int +ProcXF86DGAInstallColormap(ClientPtr client) +{ + ColormapPtr pcmp; + REQUEST(xXF86DGAInstallColormapReq); + + REQUEST_SIZE_MATCH(xXF86DGAInstallColormapReq); + + if (!DGAActive(stuff->screen)) + return (DGAErrorBase + XF86DGADirectNotActivated); + + pcmp = (ColormapPtr )LookupIDByType(stuff->id, RT_COLORMAP); + if (pcmp) { + DGAInstallCmap(pcmp); + return (client->noClientException); + } else { + client->errorValue = stuff->id; + return (BadColor); + } +} + +static int +ProcXF86DGAQueryDirectVideo(ClientPtr client) +{ + REQUEST(xXF86DGAQueryDirectVideoReq); + xXF86DGAQueryDirectVideoReply rep; + + if (stuff->screen > screenInfo.numScreens) + return BadValue; + + REQUEST_SIZE_MATCH(xXF86DGAQueryDirectVideoReq); + rep.type = X_Reply; + rep.length = 0; + rep.sequenceNumber = client->sequence; + rep.flags = 0; + + if (DGAAvailable(stuff->screen)) + rep.flags = XF86DGADirectPresent; + + WriteToClient(client, SIZEOF(xXF86DGAQueryDirectVideoReply), (char *)&rep); + return (client->noClientException); +} + +static int +ProcXF86DGAViewPortChanged(ClientPtr client) +{ + REQUEST(xXF86DGAViewPortChangedReq); + xXF86DGAViewPortChangedReply rep; + + if (stuff->screen > screenInfo.numScreens) + return BadValue; + + REQUEST_SIZE_MATCH(xXF86DGAViewPortChangedReq); + + if (!DGAActive(stuff->screen)) + return (DGAErrorBase + XF86DGADirectNotActivated); + + rep.type = X_Reply; + rep.length = 0; + rep.sequenceNumber = client->sequence; + rep.result = 1; + + WriteToClient(client, SIZEOF(xXF86DGAViewPortChangedReply), (char *)&rep); + return (client->noClientException); +} + +int +ProcXF86DGADispatch (client) + register ClientPtr client; +{ + REQUEST(xReq); + + switch (stuff->data) + { + case X_XF86DGAGetVideoLL: + return ProcXF86DGAGetVideoLL(client); + case X_XF86DGADirectVideo: + return ProcXF86DGADirectVideo(client); + case X_XF86DGAGetViewPortSize: + return ProcXF86DGAGetViewPortSize(client); + case X_XF86DGASetViewPort: + return ProcXF86DGASetViewPort(client); + case X_XF86DGAGetVidPage: + return ProcXF86DGAGetVidPage(client); + case X_XF86DGASetVidPage: + return ProcXF86DGASetVidPage(client); + case X_XF86DGAInstallColormap: + return ProcXF86DGAInstallColormap(client); + case X_XF86DGAQueryDirectVideo: + return ProcXF86DGAQueryDirectVideo(client); + case X_XF86DGAViewPortChanged: + return ProcXF86DGAViewPortChanged(client); + default: + return BadRequest; + } +} + diff --git a/hw/xfree86/dixmods/extmod/xf86dga2.c b/hw/xfree86/dixmods/extmod/xf86dga2.c new file mode 100644 index 000000000..c0d51b809 --- /dev/null +++ b/hw/xfree86/dixmods/extmod/xf86dga2.c @@ -0,0 +1,773 @@ +/* + Copyright (c) 1999 - The XFree86 Project Inc. + + Written by Mark Vojkovich +*/ +/* $XFree86: xc/programs/Xserver/Xext/xf86dga2.c,v 1.17 2001/10/28 03:32:51 tsi Exp $ */ + + +#define NEED_REPLIES +#define NEED_EVENTS +#include "X.h" +#include "Xproto.h" +#include "misc.h" +#include "dixstruct.h" +#include "dixevents.h" +#include "pixmapstr.h" +#include "extnsionst.h" +#include "colormapst.h" +#include "cursorstr.h" +#include "scrnintstr.h" +#include "servermd.h" +#define _XF86DGA_SERVER_ +#include "xf86dga.h" +#include "xf86dgastr.h" +#include "swaprep.h" +#include "dgaproc.h" + +#ifdef EXTMODULE +#include "xf86_ansic.h" +#else +#include <string.h> +#endif + + +static DISPATCH_PROC(ProcXDGADispatch); +static DISPATCH_PROC(SProcXDGADispatch); +static DISPATCH_PROC(ProcXDGAQueryVersion); +static DISPATCH_PROC(ProcXDGAQueryModes); +static DISPATCH_PROC(ProcXDGASetMode); +static DISPATCH_PROC(ProcXDGAOpenFramebuffer); +static DISPATCH_PROC(ProcXDGACloseFramebuffer); +static DISPATCH_PROC(ProcXDGASetViewport); +static DISPATCH_PROC(ProcXDGAInstallColormap); +static DISPATCH_PROC(ProcXDGASelectInput); +static DISPATCH_PROC(ProcXDGAFillRectangle); +static DISPATCH_PROC(ProcXDGACopyArea); +static DISPATCH_PROC(ProcXDGACopyTransparentArea); +static DISPATCH_PROC(ProcXDGAGetViewportStatus); +static DISPATCH_PROC(ProcXDGASync); +static DISPATCH_PROC(ProcXDGASetClientVersion); +static DISPATCH_PROC(ProcXDGAChangePixmapMode); +static DISPATCH_PROC(ProcXDGACreateColormap); + + +extern DISPATCH_PROC(ProcXF86DGADispatch); + + +static void XDGAResetProc(ExtensionEntry *extEntry); + +static void DGAClientStateChange (CallbackListPtr*, pointer, pointer); + +static ClientPtr DGAClients[MAXSCREENS]; + +unsigned char DGAReqCode = 0; +int DGAErrorBase; +int DGAEventBase; + +static int DGAGeneration = 0; +static int DGAClientPrivateIndex; +static int DGACallbackRefCount = 0; + +/* This holds the client's version information */ +typedef struct { + int major; + int minor; +} DGAPrivRec, *DGAPrivPtr; + +#define DGAPRIV(c) ((c)->devPrivates[DGAClientPrivateIndex].ptr) + +void +XFree86DGAExtensionInit(void) +{ + ExtensionEntry* extEntry; + + if ((extEntry = AddExtension(XF86DGANAME, + XF86DGANumberEvents, + XF86DGANumberErrors, + ProcXDGADispatch, + SProcXDGADispatch, + XDGAResetProc, + StandardMinorOpcode))) { + int i; + + for(i = 0; i < MAXSCREENS; i++) + DGAClients[i] = NULL; + + DGAReqCode = (unsigned char)extEntry->base; + DGAErrorBase = extEntry->errorBase; + DGAEventBase = extEntry->eventBase; + for (i = KeyPress; i <= MotionNotify; i++) + SetCriticalEvent (DGAEventBase + i); + } + + /* + * Allocate a client private index to hold the client's version + * information. + */ + if (DGAGeneration != serverGeneration) { + DGAClientPrivateIndex = AllocateClientPrivateIndex(); + /* + * Allocate 0 length, and use the private to hold a pointer to + * our DGAPrivRec. + */ + if (!AllocateClientPrivate(DGAClientPrivateIndex, 0)) { + ErrorF("XFree86DGAExtensionInit: AllocateClientPrivate failed\n"); + return; + } + DGAGeneration = serverGeneration; + } +} + + + +static void +XDGAResetProc (ExtensionEntry *extEntry) +{ + DeleteCallback (&ClientStateCallback, DGAClientStateChange, NULL); + DGACallbackRefCount = 0; +} + + +static int +ProcXDGAQueryVersion(ClientPtr client) +{ + xXDGAQueryVersionReply rep; + + REQUEST_SIZE_MATCH(xXDGAQueryVersionReq); + rep.type = X_Reply; + rep.length = 0; + rep.sequenceNumber = client->sequence; + rep.majorVersion = XDGA_MAJOR_VERSION; + rep.minorVersion = XDGA_MINOR_VERSION; + + WriteToClient(client, sizeof(xXDGAQueryVersionReply), (char *)&rep); + return (client->noClientException); +} + + +static int +ProcXDGAOpenFramebuffer(ClientPtr client) +{ + REQUEST(xXDGAOpenFramebufferReq); + xXDGAOpenFramebufferReply rep; + char *deviceName; + int nameSize; + + if (stuff->screen > screenInfo.numScreens) + return BadValue; + + if (!DGAAvailable(stuff->screen)) + return DGAErrorBase + XF86DGANoDirectVideoMode; + + REQUEST_SIZE_MATCH(xXDGAOpenFramebufferReq); + rep.type = X_Reply; + rep.length = 0; + rep.sequenceNumber = client->sequence; + + if(!DGAOpenFramebuffer(stuff->screen, &deviceName, + (unsigned char**)(&rep.mem1), + (int*)&rep.size, (int*)&rep.offset, (int*)&rep.extra)) + { + return BadAlloc; + } + + nameSize = deviceName ? (strlen(deviceName) + 1) : 0; + rep.length = (nameSize + 3) >> 2; + + WriteToClient(client, sizeof(xXDGAOpenFramebufferReply), (char *)&rep); + if(rep.length) + WriteToClient(client, nameSize, deviceName); + + return (client->noClientException); +} + + +static int +ProcXDGACloseFramebuffer(ClientPtr client) +{ + REQUEST(xXDGACloseFramebufferReq); + + if (stuff->screen > screenInfo.numScreens) + return BadValue; + + if (!DGAAvailable(stuff->screen)) + return DGAErrorBase + XF86DGANoDirectVideoMode; + + REQUEST_SIZE_MATCH(xXDGACloseFramebufferReq); + + DGACloseFramebuffer(stuff->screen); + + return (client->noClientException); +} + +static int +ProcXDGAQueryModes(ClientPtr client) +{ + int i, num, size; + REQUEST(xXDGAQueryModesReq); + xXDGAQueryModesReply rep; + xXDGAModeInfo info; + XDGAModePtr mode; + + if (stuff->screen > screenInfo.numScreens) + return BadValue; + + REQUEST_SIZE_MATCH(xXDGAQueryModesReq); + rep.type = X_Reply; + rep.length = 0; + rep.number = 0; + rep.sequenceNumber = client->sequence; + + if (!DGAAvailable(stuff->screen)) { + rep.number = 0; + rep.length = 0; + WriteToClient(client, sz_xXDGAQueryModesReply, (char*)&rep); + return (client->noClientException); + } + + if(!(num = DGAGetModes(stuff->screen))) { + WriteToClient(client, sz_xXDGAQueryModesReply, (char*)&rep); + return (client->noClientException); + } + + if(!(mode = (XDGAModePtr)xalloc(num * sizeof(XDGAModeRec)))) + return BadAlloc; + + for(i = 0; i < num; i++) + DGAGetModeInfo(stuff->screen, mode + i, i + 1); + + size = num * sz_xXDGAModeInfo; + for(i = 0; i < num; i++) + size += (strlen(mode[i].name) + 4) & ~3L; /* plus NULL */ + + rep.number = num; + rep.length = size >> 2; + + WriteToClient(client, sz_xXDGAQueryModesReply, (char*)&rep); + + for(i = 0; i < num; i++) { + size = strlen(mode[i].name) + 1; + + info.byte_order = mode[i].byteOrder; + info.depth = mode[i].depth; + info.num = mode[i].num; + info.bpp = mode[i].bitsPerPixel; + info.name_size = (size + 3) & ~3L; + info.vsync_num = mode[i].VSync_num; + info.vsync_den = mode[i].VSync_den; + info.flags = mode[i].flags; + info.image_width = mode[i].imageWidth; + info.image_height = mode[i].imageHeight; + info.pixmap_width = mode[i].pixmapWidth; + info.pixmap_height = mode[i].pixmapHeight; + info.bytes_per_scanline = mode[i].bytesPerScanline; + info.red_mask = mode[i].red_mask; + info.green_mask = mode[i].green_mask; + info.blue_mask = mode[i].blue_mask; + info.visual_class = mode[i].visualClass; + info.viewport_width = mode[i].viewportWidth; + info.viewport_height = mode[i].viewportHeight; + info.viewport_xstep = mode[i].xViewportStep; + info.viewport_ystep = mode[i].yViewportStep; + info.viewport_xmax = mode[i].maxViewportX; + info.viewport_ymax = mode[i].maxViewportY; + info.viewport_flags = mode[i].viewportFlags; + info.reserved1 = mode[i].reserved1; + info.reserved2 = mode[i].reserved2; + + WriteToClient(client, sz_xXDGAModeInfo, (char*)(&info)); + WriteToClient(client, size, mode[i].name); + } + + xfree(mode); + + return (client->noClientException); +} + + +static void +DGAClientStateChange ( + CallbackListPtr* pcbl, + pointer nulldata, + pointer calldata +){ + NewClientInfoRec* pci = (NewClientInfoRec*) calldata; + ClientPtr client = NULL; + int i; + + for(i = 0; i < screenInfo.numScreens; i++) { + if(DGAClients[i] == pci->client) { + client = pci->client; + break; + } + } + + if(client && + ((client->clientState == ClientStateGone) || + (client->clientState == ClientStateRetained))) { + XDGAModeRec mode; + PixmapPtr pPix; + + DGAClients[i] = NULL; + DGASelectInput(i, NULL, 0); + DGASetMode(i, 0, &mode, &pPix); + + if(--DGACallbackRefCount == 0) + DeleteCallback(&ClientStateCallback, DGAClientStateChange, NULL); + } +} + +static int +ProcXDGASetMode(ClientPtr client) +{ + REQUEST(xXDGASetModeReq); + xXDGASetModeReply rep; + XDGAModeRec mode; + xXDGAModeInfo info; + PixmapPtr pPix; + int size; + + if (stuff->screen > screenInfo.numScreens) + return BadValue; + + REQUEST_SIZE_MATCH(xXDGASetModeReq); + rep.type = X_Reply; + rep.length = 0; + rep.offset = 0; + rep.flags = 0; + rep.sequenceNumber = client->sequence; + + if (!DGAAvailable(stuff->screen)) + return DGAErrorBase + XF86DGANoDirectVideoMode; + + if(DGAClients[stuff->screen] && + (DGAClients[stuff->screen] != client)) + return DGAErrorBase + XF86DGANoDirectVideoMode; + + if(!stuff->mode) { + if(DGAClients[stuff->screen]) { + if(--DGACallbackRefCount == 0) + DeleteCallback(&ClientStateCallback, DGAClientStateChange, NULL); + } + DGAClients[stuff->screen] = NULL; + DGASelectInput(stuff->screen, NULL, 0); + DGASetMode(stuff->screen, 0, &mode, &pPix); + WriteToClient(client, sz_xXDGASetModeReply, (char*)&rep); + return (client->noClientException); + } + + if(Success != DGASetMode(stuff->screen, stuff->mode, &mode, &pPix)) + return BadValue; + + if(!DGAClients[stuff->screen]) { + if(DGACallbackRefCount++ == 0) + AddCallback (&ClientStateCallback, DGAClientStateChange, NULL); + } + + DGAClients[stuff->screen] = client; + + if(pPix) { + if(AddResource(stuff->pid, RT_PIXMAP, (pointer)(pPix))) { + pPix->drawable.id = (int)stuff->pid; + rep.flags = DGA_PIXMAP_AVAILABLE; + } + } + + size = strlen(mode.name) + 1; + + info.byte_order = mode.byteOrder; + info.depth = mode.depth; + info.num = mode.num; + info.bpp = mode.bitsPerPixel; + info.name_size = (size + 3) & ~3L; + info.vsync_num = mode.VSync_num; + info.vsync_den = mode.VSync_den; + info.flags = mode.flags; + info.image_width = mode.imageWidth; + info.image_height = mode.imageHeight; + info.pixmap_width = mode.pixmapWidth; + info.pixmap_height = mode.pixmapHeight; + info.bytes_per_scanline = mode.bytesPerScanline; + info.red_mask = mode.red_mask; + info.green_mask = mode.green_mask; + info.blue_mask = mode.blue_mask; + info.visual_class = mode.visualClass; + info.viewport_width = mode.viewportWidth; + info.viewport_height = mode.viewportHeight; + info.viewport_xstep = mode.xViewportStep; + info.viewport_ystep = mode.yViewportStep; + info.viewport_xmax = mode.maxViewportX; + info.viewport_ymax = mode.maxViewportY; + info.viewport_flags = mode.viewportFlags; + info.reserved1 = mode.reserved1; + info.reserved2 = mode.reserved2; + + rep.length = (sz_xXDGAModeInfo + info.name_size) >> 2; + + WriteToClient(client, sz_xXDGASetModeReply, (char*)&rep); + WriteToClient(client, sz_xXDGAModeInfo, (char*)(&info)); + WriteToClient(client, size, mode.name); + + return (client->noClientException); +} + +static int +ProcXDGASetViewport(ClientPtr client) +{ + REQUEST(xXDGASetViewportReq); + + if (stuff->screen > screenInfo.numScreens) + return BadValue; + + if(DGAClients[stuff->screen] != client) + return DGAErrorBase + XF86DGADirectNotActivated; + + REQUEST_SIZE_MATCH(xXDGASetViewportReq); + + DGASetViewport(stuff->screen, stuff->x, stuff->y, stuff->flags); + + return (client->noClientException); +} + +static int +ProcXDGAInstallColormap(ClientPtr client) +{ + ColormapPtr cmap; + REQUEST(xXDGAInstallColormapReq); + + if (stuff->screen > screenInfo.numScreens) + return BadValue; + + if(DGAClients[stuff->screen] != client) + return DGAErrorBase + XF86DGADirectNotActivated; + + REQUEST_SIZE_MATCH(xXDGAInstallColormapReq); + + cmap = (ColormapPtr)LookupIDByType(stuff->cmap, RT_COLORMAP); + if (cmap) { + DGAInstallCmap(cmap); + return (client->noClientException); + } else { + client->errorValue = stuff->cmap; + return (BadColor); + } + + return (client->noClientException); +} + + +static int +ProcXDGASelectInput(ClientPtr client) +{ + REQUEST(xXDGASelectInputReq); + + if (stuff->screen > screenInfo.numScreens) + return BadValue; + + if(DGAClients[stuff->screen] != client) + return DGAErrorBase + XF86DGADirectNotActivated; + + REQUEST_SIZE_MATCH(xXDGASelectInputReq); + + if(DGAClients[stuff->screen] == client) + DGASelectInput(stuff->screen, client, stuff->mask); + + return (client->noClientException); +} + + +static int +ProcXDGAFillRectangle(ClientPtr client) +{ + REQUEST(xXDGAFillRectangleReq); + + if (stuff->screen > screenInfo.numScreens) + return BadValue; + + if(DGAClients[stuff->screen] != client) + return DGAErrorBase + XF86DGADirectNotActivated; + + REQUEST_SIZE_MATCH(xXDGAFillRectangleReq); + + if(Success != DGAFillRect(stuff->screen, stuff->x, stuff->y, + stuff->width, stuff->height, stuff->color)) + return BadMatch; + + return (client->noClientException); +} + +static int +ProcXDGACopyArea(ClientPtr client) +{ + REQUEST(xXDGACopyAreaReq); + + if (stuff->screen > screenInfo.numScreens) + return BadValue; + + if(DGAClients[stuff->screen] != client) + return DGAErrorBase + XF86DGADirectNotActivated; + + REQUEST_SIZE_MATCH(xXDGACopyAreaReq); + + if(Success != DGABlitRect(stuff->screen, stuff->srcx, stuff->srcy, + stuff->width, stuff->height, stuff->dstx, stuff->dsty)) + return BadMatch; + + return (client->noClientException); +} + + +static int +ProcXDGACopyTransparentArea(ClientPtr client) +{ + REQUEST(xXDGACopyTransparentAreaReq); + + if (stuff->screen > screenInfo.numScreens) + return BadValue; + + if(DGAClients[stuff->screen] != client) + return DGAErrorBase + XF86DGADirectNotActivated; + + REQUEST_SIZE_MATCH(xXDGACopyTransparentAreaReq); + + if(Success != DGABlitTransRect(stuff->screen, stuff->srcx, stuff->srcy, + stuff->width, stuff->height, stuff->dstx, stuff->dsty, stuff->key)) + return BadMatch; + + return (client->noClientException); +} + + +static int +ProcXDGAGetViewportStatus(ClientPtr client) +{ + REQUEST(xXDGAGetViewportStatusReq); + xXDGAGetViewportStatusReply rep; + + if (stuff->screen > screenInfo.numScreens) + return BadValue; + + if(DGAClients[stuff->screen] != client) + return DGAErrorBase + XF86DGADirectNotActivated; + + REQUEST_SIZE_MATCH(xXDGAGetViewportStatusReq); + rep.type = X_Reply; + rep.length = 0; + rep.sequenceNumber = client->sequence; + + rep.status = DGAGetViewportStatus(stuff->screen); + + WriteToClient(client, sizeof(xXDGAGetViewportStatusReply), (char *)&rep); + return (client->noClientException); +} + +static int +ProcXDGASync(ClientPtr client) +{ + REQUEST(xXDGASyncReq); + xXDGASyncReply rep; + + if (stuff->screen > screenInfo.numScreens) + return BadValue; + + if(DGAClients[stuff->screen] != client) + return DGAErrorBase + XF86DGADirectNotActivated; + + REQUEST_SIZE_MATCH(xXDGASyncReq); + rep.type = X_Reply; + rep.length = 0; + rep.sequenceNumber = client->sequence; + + DGASync(stuff->screen); + + WriteToClient(client, sizeof(xXDGASyncReply), (char *)&rep); + return (client->noClientException); +} + +static int +ProcXDGASetClientVersion(ClientPtr client) +{ + REQUEST(xXDGASetClientVersionReq); + + DGAPrivPtr pPriv; + + REQUEST_SIZE_MATCH(xXDGASetClientVersionReq); + if ((pPriv = DGAPRIV(client)) == NULL) { + pPriv = xalloc(sizeof(DGAPrivRec)); + /* XXX Need to look into freeing this */ + if (!pPriv) + return BadAlloc; + DGAPRIV(client) = pPriv; + } + pPriv->major = stuff->major; + pPriv->minor = stuff->minor; + + return (client->noClientException); +} + +static int +ProcXDGAChangePixmapMode(ClientPtr client) +{ + REQUEST(xXDGAChangePixmapModeReq); + xXDGAChangePixmapModeReply rep; + int x, y; + + if (stuff->screen > screenInfo.numScreens) + return BadValue; + + if(DGAClients[stuff->screen] != client) + return DGAErrorBase + XF86DGADirectNotActivated; + + REQUEST_SIZE_MATCH(xXDGAChangePixmapModeReq); + rep.type = X_Reply; + rep.length = 0; + rep.sequenceNumber = client->sequence; + + x = stuff->x; + y = stuff->y; + + if(!DGAChangePixmapMode(stuff->screen, &x, &y, stuff->flags)) + return BadMatch; + + rep.x = x; + rep.y = y; + WriteToClient(client, sizeof(xXDGAChangePixmapModeReply), (char *)&rep); + + return (client->noClientException); +} + + +static int +ProcXDGACreateColormap(ClientPtr client) +{ + REQUEST(xXDGACreateColormapReq); + int result; + + if (stuff->screen > screenInfo.numScreens) + return BadValue; + + if(DGAClients[stuff->screen] != client) + return DGAErrorBase + XF86DGADirectNotActivated; + + REQUEST_SIZE_MATCH(xXDGACreateColormapReq); + + if(!stuff->mode) + return BadValue; + + result = DGACreateColormap(stuff->screen, client, stuff->id, + stuff->mode, stuff->alloc); + if(result != Success) + return result; + + return (client->noClientException); +} + + +static int +SProcXDGADispatch (ClientPtr client) +{ + return DGAErrorBase + XF86DGAClientNotLocal; +} + +#if 0 +#define DGA_REQ_DEBUG +#endif + +#ifdef DGA_REQ_DEBUG +static char *dgaMinor[] = { + "QueryVersion", + "GetVideoLL", + "DirectVideo", + "GetViewPortSize", + "SetViewPort", + "GetVidPage", + "SetVidPage", + "InstallColormap", + "QueryDirectVideo", + "ViewPortChanged", + "10", + "11", + "QueryModes", + "SetMode", + "SetViewport", + "InstallColormap", + "SelectInput", + "FillRectangle", + "CopyArea", + "CopyTransparentArea", + "GetViewportStatus", + "Sync", + "OpenFramebuffer", + "CloseFramebuffer", + "SetClientVersion", + "ChangePixmapMode", + "CreateColormap", +}; +#endif + +static int +ProcXDGADispatch (ClientPtr client) +{ + REQUEST(xReq); + + if (!LocalClient(client)) + return DGAErrorBase + XF86DGAClientNotLocal; + +#ifdef DGA_REQ_DEBUG + if (stuff->data <= X_XDGACreateColormap) + fprintf (stderr, " DGA %s\n", dgaMinor[stuff->data]); +#endif + + /* divert old protocol */ +#if 1 + if( (stuff->data <= X_XF86DGAViewPortChanged) && + (stuff->data >= X_XF86DGAGetVideoLL)) + return ProcXF86DGADispatch(client); +#endif + + switch (stuff->data){ + case X_XDGAQueryVersion: + return ProcXDGAQueryVersion(client); + case X_XDGAQueryModes: + return ProcXDGAQueryModes(client); + case X_XDGASetMode: + return ProcXDGASetMode(client); + case X_XDGAOpenFramebuffer: + return ProcXDGAOpenFramebuffer(client); + case X_XDGACloseFramebuffer: + return ProcXDGACloseFramebuffer(client); + case X_XDGASetViewport: + return ProcXDGASetViewport(client); + case X_XDGAInstallColormap: + return ProcXDGAInstallColormap(client); + case X_XDGASelectInput: + return ProcXDGASelectInput(client); + case X_XDGAFillRectangle: + return ProcXDGAFillRectangle(client); + case X_XDGACopyArea: + return ProcXDGACopyArea(client); + case X_XDGACopyTransparentArea: + return ProcXDGACopyTransparentArea(client); + case X_XDGAGetViewportStatus: + return ProcXDGAGetViewportStatus(client); + case X_XDGASync: + return ProcXDGASync(client); + case X_XDGASetClientVersion: + return ProcXDGASetClientVersion(client); + case X_XDGAChangePixmapMode: + return ProcXDGAChangePixmapMode(client); + case X_XDGACreateColormap: + return ProcXDGACreateColormap(client); + default: + return BadRequest; + } +} + +#ifdef EXTMODULE +void +XFree86DGARegister() +{ + XDGAEventBase = &DGAEventBase; +} +#endif diff --git a/hw/xfree86/dixmods/extmod/xf86misc.c b/hw/xfree86/dixmods/extmod/xf86misc.c new file mode 100644 index 000000000..bc8e94b45 --- /dev/null +++ b/hw/xfree86/dixmods/extmod/xf86misc.c @@ -0,0 +1,767 @@ +/* $XFree86: xc/programs/Xserver/Xext/xf86misc.c,v 3.37 2002/11/20 04:04:58 dawes Exp $ */ + +/* + * Copyright (c) 1995, 1996 The XFree86 Project, Inc + */ + +/* THIS IS NOT AN X CONSORTIUM STANDARD */ + +#define NEED_REPLIES +#define NEED_EVENTS +#include "X.h" +#include "Xproto.h" +#include "misc.h" +#include "dixstruct.h" +#include "extnsionst.h" +#include "scrnintstr.h" +#include "inputstr.h" +#include "servermd.h" +#define _XF86MISC_SERVER_ +#undef _XF86MISC_SAVER_COMPAT_ +#include "xf86mscstr.h" +#include "swaprep.h" +#include "xf86.h" +#include "Xfuncproto.h" +#include "xf86miscproc.h" + +#if 0 +#include <X11/Xtrans.h> +#include "../os/osdep.h" +#include <X11/Xauth.h> +#ifndef USL +#ifndef Lynx +#include <sys/socket.h> +#else +#include <socket.h> +#endif +#endif /* USL */ +#endif + +#ifdef EXTMODULE +#include "xf86_ansic.h" +#endif + +static int miscErrorBase; +static int MiscGeneration = 0; +static int MiscClientPrivateIndex; + +/* This holds the client's version information */ +typedef struct { + int major; + int minor; +} MiscPrivRec, *MiscPrivPtr; + +#define MPRIV(c) ((c)->devPrivates[MiscClientPrivateIndex].ptr) + +static void XF86MiscResetProc( +#if NeedFunctionPrototypes + ExtensionEntry* /* extEntry */ +#endif +); + +static void +ClientVersion(ClientPtr client, int *major, int *minor) +{ + MiscPrivPtr pPriv; + + pPriv = MPRIV(client); + if (!pPriv) { + if (major) *major = 0; + if (minor) *minor = 0; + return; + } + + if (major) *major = pPriv->major; + if (minor) *minor = pPriv->minor; +} + +static DISPATCH_PROC(ProcXF86MiscDispatch); +static DISPATCH_PROC(ProcXF86MiscQueryVersion); +static DISPATCH_PROC(ProcXF86MiscGetKbdSettings); +static DISPATCH_PROC(ProcXF86MiscGetMouseSettings); +static DISPATCH_PROC(ProcXF86MiscSetKbdSettings); +static DISPATCH_PROC(ProcXF86MiscSetMouseSettings); +static DISPATCH_PROC(ProcXF86MiscSetGrabKeysState); +static DISPATCH_PROC(ProcXF86MiscSetClientVersion); +static DISPATCH_PROC(ProcXF86MiscGetFilePaths); +#ifdef _XF86MISC_SAVER_COMPAT_ +static DISPATCH_PROC(ProcXF86MiscGetSaver); +static DISPATCH_PROC(ProcXF86MiscSetSaver); +#endif +static DISPATCH_PROC(SProcXF86MiscDispatch); +static DISPATCH_PROC(SProcXF86MiscQueryVersion); +static DISPATCH_PROC(SProcXF86MiscGetKbdSettings); +static DISPATCH_PROC(SProcXF86MiscGetMouseSettings); +static DISPATCH_PROC(SProcXF86MiscSetKbdSettings); +static DISPATCH_PROC(SProcXF86MiscSetMouseSettings); +static DISPATCH_PROC(SProcXF86MiscSetGrabKeysState); +static DISPATCH_PROC(SProcXF86MiscSetClientVersion); +static DISPATCH_PROC(SProcXF86MiscGetFilePaths); +#ifdef _XF86MISC_SAVER_COMPAT_ +static DISPATCH_PROC(SProcXF86MiscGetSaver); +static DISPATCH_PROC(SProcXF86MiscSetSaver); +#endif + +static unsigned char XF86MiscReqCode = 0; + +#ifdef DEBUG +# define DEBUG_P(x) ErrorF(x"\n"); +#else +# define DEBUG_P(x) /**/ +#endif + +#define MISCERR(x) (miscErrorBase + x) + +void +XFree86MiscExtensionInit(void) +{ + ExtensionEntry* extEntry; + + DEBUG_P("XFree86MiscExtensionInit"); + + if (!xf86GetModInDevEnabled()) + return; + + /* + * Allocate a client private index to hold the client's version + * information. + */ + if (MiscGeneration != serverGeneration) { + MiscClientPrivateIndex = AllocateClientPrivateIndex(); + /* + * Allocate 0 length, and use the private to hold a pointer to our + * MiscPrivRec. + */ + if (!AllocateClientPrivate(MiscClientPrivateIndex, 0)) { + ErrorF("XFree86MiscExtensionInit: " + "AllocateClientPrivate failed\n"); + return; + } + MiscGeneration = serverGeneration; + } + + if ( + (extEntry = AddExtension(XF86MISCNAME, + XF86MiscNumberEvents, + XF86MiscNumberErrors, + ProcXF86MiscDispatch, + SProcXF86MiscDispatch, + XF86MiscResetProc, + StandardMinorOpcode))) { + XF86MiscReqCode = (unsigned char)extEntry->base; + miscErrorBase = extEntry->errorBase; + } +} + +/*ARGSUSED*/ +static void +XF86MiscResetProc (extEntry) + ExtensionEntry* extEntry; +{ +} + +static int +ProcXF86MiscQueryVersion(client) + register ClientPtr client; +{ + xXF86MiscQueryVersionReply rep; + register int n; + + DEBUG_P("XF86MiscQueryVersion"); + + REQUEST_SIZE_MATCH(xXF86MiscQueryVersionReq); + rep.type = X_Reply; + rep.length = 0; + rep.sequenceNumber = client->sequence; + rep.majorVersion = XF86MISC_MAJOR_VERSION; + rep.minorVersion = XF86MISC_MINOR_VERSION; + if (client->swapped) { + swaps(&rep.sequenceNumber, n); + swapl(&rep.length, n); + swaps(&rep.majorVersion, n); + swaps(&rep.minorVersion, n); + } + WriteToClient(client, sizeof(xXF86MiscQueryVersionReply), (char *)&rep); + return (client->noClientException); +} + +#ifdef _XF86MISC_SAVER_COMPAT_ +/* THESE HAVE NOT BEEN CONVERTED TO THE NEW DESIGN */ + +/* + * This will go away, but remains for now for compatibility with older + * clients. + */ +static int +ProcXF86MiscSetSaver(client) + register ClientPtr client; +{ + REQUEST(xXF86MiscSetSaverReq); + ScrnInfoPtr vptr; + + if (stuff->screen > screenInfo.numScreens) + return BadValue; + + vptr = (ScrnInfoPtr) screenInfo.screens[stuff->screen]->devPrivates[xf86ScreenIndex].ptr; + + REQUEST_SIZE_MATCH(xXF86MiscSetSaverReq); + + if (stuff->suspendTime < 0) + return BadValue; + if (stuff->offTime < 0) + return BadValue; + + return (client->noClientException); +} + +/* + * This will go away, but remains for now for compatibility with older + * clients. + */ +static int +ProcXF86MiscGetSaver(client) + register ClientPtr client; +{ + REQUEST(xXF86MiscGetSaverReq); + xXF86MiscGetSaverReply rep; + register int n; + ScrnInfoPtr vptr; + + if (stuff->screen > screenInfo.numScreens) + return BadValue; + + vptr = (ScrnInfoPtr) screenInfo.screens[stuff->screen]->devPrivates[xf86ScreenIndex].ptr; + + REQUEST_SIZE_MATCH(xXF86MiscGetSaverReq); + rep.type = X_Reply; + rep.length = 0; + rep.sequenceNumber = client->sequence; + rep.suspendTime = 0; + rep.offTime = 0; + + if (client->swapped) { + swaps(&rep.sequenceNumber, n); + swapl(&rep.length, n); + swapl(&rep.suspendTime, n); + swapl(&rep.offTime, n); + } + WriteToClient(client, SIZEOF(xXF86MiscGetSaverReply), (char *)&rep); + return (client->noClientException); +} + +#endif /* _XF86MISC_SAVER_COMPAT_ */ + +static int +ProcXF86MiscGetMouseSettings(client) + register ClientPtr client; +{ + xXF86MiscGetMouseSettingsReply rep; + char *devname; + pointer mouse; + register int n; + + DEBUG_P("XF86MiscGetMouseSettings"); + + REQUEST_SIZE_MATCH(xXF86MiscGetMouseSettingsReq); + rep.type = X_Reply; + rep.sequenceNumber = client->sequence; + + if (!MiscExtGetMouseSettings(&mouse, &devname)) + return BadValue; + + rep.mousetype = MiscExtGetMouseValue(mouse, MISC_MSE_PROTO); + rep.baudrate = MiscExtGetMouseValue(mouse, MISC_MSE_BAUDRATE); + rep.samplerate = MiscExtGetMouseValue(mouse, MISC_MSE_SAMPLERATE); + rep.resolution = MiscExtGetMouseValue(mouse, MISC_MSE_RESOLUTION); + rep.buttons = MiscExtGetMouseValue(mouse, MISC_MSE_BUTTONS); + rep.emulate3buttons = MiscExtGetMouseValue(mouse, MISC_MSE_EM3BUTTONS); + rep.emulate3timeout = MiscExtGetMouseValue(mouse, MISC_MSE_EM3TIMEOUT); + rep.chordmiddle = MiscExtGetMouseValue(mouse, MISC_MSE_CHORDMIDDLE); + rep.flags = MiscExtGetMouseValue(mouse, MISC_MSE_FLAGS); + rep.devnamelen = (devname? strlen(devname): 0); + rep.length = (sizeof(xXF86MiscGetMouseSettingsReply) - + sizeof(xGenericReply) + ((rep.devnamelen+3) & ~3)) >> 2; + + if (client->swapped) { + swaps(&rep.sequenceNumber, n); + swapl(&rep.length, n); + swapl(&rep.mousetype, n); + swapl(&rep.baudrate, n); + swapl(&rep.samplerate, n); + swapl(&rep.resolution, n); + swapl(&rep.buttons, n); + swapl(&rep.emulate3buttons, n); + swapl(&rep.emulate3timeout, n); + swapl(&rep.chordmiddle, n); + swapl(&rep.flags, n); + } + WriteToClient(client, SIZEOF(xXF86MiscGetMouseSettingsReply), (char *)&rep); + MiscExtDestroyStruct(mouse, MISC_POINTER); + + if (rep.devnamelen) + WriteToClient(client, rep.devnamelen, devname); + return (client->noClientException); +} + +static int +ProcXF86MiscGetKbdSettings(client) + register ClientPtr client; +{ + xXF86MiscGetKbdSettingsReply rep; + pointer kbd; + register int n; + + DEBUG_P("XF86MiscGetKbdSettings"); + + REQUEST_SIZE_MATCH(xXF86MiscGetKbdSettingsReq); + rep.type = X_Reply; + rep.length = 0; + rep.sequenceNumber = client->sequence; + if (!MiscExtGetKbdSettings(&kbd)) + return BadValue; + + rep.kbdtype = MiscExtGetKbdValue(kbd, MISC_KBD_TYPE); + rep.rate = MiscExtGetKbdValue(kbd, MISC_KBD_RATE); + rep.delay = MiscExtGetKbdValue(kbd, MISC_KBD_DELAY); + rep.servnumlock = MiscExtGetKbdValue(kbd, MISC_KBD_SERVNUMLOCK); + if (client->swapped) { + swaps(&rep.sequenceNumber, n); + swapl(&rep.length, n); + swapl(&rep.kbdtype, n); + swapl(&rep.rate, n); + swapl(&rep.delay, n); + } + WriteToClient(client, SIZEOF(xXF86MiscGetKbdSettingsReply), (char *)&rep); + return (client->noClientException); +} + +static int +ProcXF86MiscSetMouseSettings(client) + register ClientPtr client; +{ + MiscExtReturn ret; + pointer mouse; + char *devname = NULL; + int major, minor; + + REQUEST(xXF86MiscSetMouseSettingsReq); + + DEBUG_P("XF86MiscSetMouseSettings"); + + REQUEST_AT_LEAST_SIZE(xXF86MiscSetMouseSettingsReq); + + ClientVersion(client, &major, &minor); + + if (xf86GetVerbosity() > 1) { + ErrorF("SetMouseSettings - type: %d brate: %d srate: %d chdmid: %d\n", + stuff->mousetype, stuff->baudrate, + stuff->samplerate, stuff->chordmiddle); + ErrorF(" em3but: %d em3tim: %d res: %d flags: %d\n", + stuff->emulate3buttons, stuff->emulate3timeout, + stuff->resolution, stuff->flags); + } + + + if ((mouse = MiscExtCreateStruct(MISC_POINTER)) == (pointer) 0) + return BadAlloc; + + MiscExtSetMouseValue(mouse, MISC_MSE_PROTO, stuff->mousetype); + MiscExtSetMouseValue(mouse, MISC_MSE_BAUDRATE, stuff->baudrate); + MiscExtSetMouseValue(mouse, MISC_MSE_SAMPLERATE, stuff->samplerate); + MiscExtSetMouseValue(mouse, MISC_MSE_RESOLUTION, stuff->resolution); + MiscExtSetMouseValue(mouse, MISC_MSE_BUTTONS, stuff->buttons); + MiscExtSetMouseValue(mouse, MISC_MSE_EM3BUTTONS, stuff->emulate3buttons); + MiscExtSetMouseValue(mouse, MISC_MSE_EM3TIMEOUT, stuff->emulate3timeout); + MiscExtSetMouseValue(mouse, MISC_MSE_CHORDMIDDLE, stuff->chordmiddle); + MiscExtSetMouseValue(mouse, MISC_MSE_FLAGS, stuff->flags); + + if ((major > 0 || minor > 5) && stuff->devnamelen) { + int size = sizeof(xXF86MiscSetMouseSettingsReq) + stuff->devnamelen; + size = (size + 3) >> 2; + if (client->req_len < size) + return BadLength; + if (stuff->devnamelen) { + if (!(devname = xalloc(stuff->devnamelen))) + return BadAlloc; + strncpy(devname,(char*)(&stuff[1]),stuff->devnamelen); + if (xf86GetVerbosity() > 1) + ErrorF("SetMouseSettings - device: %s\n",devname); + MiscExtSetMouseDevice(mouse, devname); + } + } + + ret = MiscExtApply(mouse, MISC_POINTER); + + if (devname) + xfree(devname); + + switch ((ret)) { + case MISC_RET_SUCCESS: break; + case MISC_RET_BADVAL: return BadValue; + case MISC_RET_BADMSEPROTO: return MISCERR(XF86MiscBadMouseProtocol); + case MISC_RET_BADBAUDRATE: return MISCERR(XF86MiscBadMouseBaudRate); + case MISC_RET_BADFLAGS: return MISCERR(XF86MiscBadMouseFlags); + case MISC_RET_BADCOMBO: return MISCERR(XF86MiscBadMouseCombo); + case MISC_RET_NOMODULE: return MISCERR(XF86MiscNoModule); + default: + ErrorF("Unexpected return from MiscExtApply(POINTER) = %d\n", ret); + return BadImplementation; + } + + if (xf86GetVerbosity() > 1) + ErrorF("SetMouseSettings - Succeeded\n"); + return (client->noClientException); +} + +static int +ProcXF86MiscSetKbdSettings(client) + register ClientPtr client; +{ + MiscExtReturn ret; + pointer kbd; + REQUEST(xXF86MiscSetKbdSettingsReq); + + DEBUG_P("XF86MiscSetKbdSettings"); + + REQUEST_SIZE_MATCH(xXF86MiscSetKbdSettingsReq); + + if (xf86GetVerbosity() > 1) + ErrorF("SetKbdSettings - type: %d rate: %d delay: %d snumlk: %d\n", + stuff->kbdtype, stuff->rate, + stuff->delay, stuff->servnumlock); + + if ((kbd = MiscExtCreateStruct(MISC_KEYBOARD)) == (pointer) 0) + return BadAlloc; + + MiscExtSetKbdValue(kbd, MISC_KBD_TYPE, stuff->kbdtype); + MiscExtSetKbdValue(kbd, MISC_KBD_RATE, stuff->rate); + MiscExtSetKbdValue(kbd, MISC_KBD_DELAY, stuff->delay); + MiscExtSetKbdValue(kbd, MISC_KBD_SERVNUMLOCK, stuff->servnumlock); + + switch ((ret = MiscExtApply(kbd, MISC_KEYBOARD))) { + case MISC_RET_SUCCESS: break; + case MISC_RET_BADVAL: return BadValue; + case MISC_RET_BADKBDTYPE: return MISCERR(XF86MiscBadKbdType); + default: + ErrorF("Unexpected return from MiscExtApply(KEYBOARD) = %d\n", ret); + return BadImplementation; + } + + if (xf86GetVerbosity() > 1) + ErrorF("SetKbdSettings - Succeeded\n"); + return (client->noClientException); +} + +static int +ProcXF86MiscSetGrabKeysState(client) + register ClientPtr client; +{ + int n, status; + xXF86MiscSetGrabKeysStateReply rep; + REQUEST(xXF86MiscSetGrabKeysStateReq); + + DEBUG_P("XF86MiscSetGrabKeysState"); + + REQUEST_SIZE_MATCH(xXF86MiscSetGrabKeysStateReq); + + if ((status = MiscExtSetGrabKeysState(client, stuff->enable)) == 0) { + if (xf86GetVerbosity() > 1) + ErrorF("SetGrabKeysState - %s\n", + stuff->enable ? "enabled" : "disabled"); + } + + rep.type = X_Reply; + rep.length = 0; + rep.sequenceNumber = client->sequence; + rep.status = status; + if (client->swapped) { + swaps(&rep.sequenceNumber, n); + swapl(&rep.length, n); + swapl(&rep.status, n); + } + WriteToClient(client, SIZEOF(xXF86MiscSetGrabKeysStateReply), (char *)&rep); + + return (client->noClientException); +} + +static int +ProcXF86MiscSetClientVersion(ClientPtr client) +{ + REQUEST(xXF86MiscSetClientVersionReq); + + MiscPrivPtr pPriv; + + DEBUG_P("XF86MiscSetClientVersion"); + + REQUEST_SIZE_MATCH(xXF86MiscSetClientVersionReq); + + if ((pPriv = MPRIV(client)) == NULL) { + pPriv = xalloc(sizeof(MiscPrivRec)); + if (!pPriv) + return BadAlloc; + MPRIV(client) = pPriv; + } + ErrorF("SetClientVersion: %i %i\n",stuff->major,stuff->minor); + pPriv->major = stuff->major; + pPriv->minor = stuff->minor; + + return (client->noClientException); +} + +static int +ProcXF86MiscGetFilePaths(client) + register ClientPtr client; +{ + xXF86MiscGetFilePathsReply rep; + const char *configfile; + const char *modulepath; + const char *logfile; + register int n; + + DEBUG_P("XF86MiscGetFilePaths"); + + REQUEST_SIZE_MATCH(xXF86MiscGetFilePathsReq); + rep.type = X_Reply; + rep.sequenceNumber = client->sequence; + + if (!MiscExtGetFilePaths(&configfile, &modulepath, &logfile)) + return BadValue; + + rep.configlen = (configfile? strlen(configfile): 0); + rep.modulelen = (modulepath? strlen(modulepath): 0); + rep.loglen = (logfile? strlen(logfile): 0); + rep.length = (SIZEOF(xXF86MiscGetFilePathsReply) - SIZEOF(xGenericReply) + + ((rep.configlen + 3) & ~3) + + ((rep.modulelen + 3) & ~3) + + ((rep.loglen + 3) & ~3) ) >> 2; + + if (client->swapped) { + swaps(&rep.sequenceNumber, n); + swapl(&rep.length, n); + swaps(&rep.configlen, n); + swaps(&rep.modulelen, n); + swaps(&rep.loglen, n); + } + WriteToClient(client, SIZEOF(xXF86MiscGetFilePathsReply), (char *)&rep); + + if (rep.configlen) + WriteToClient(client, rep.configlen, (char *)configfile); + if (rep.modulelen) + WriteToClient(client, rep.modulelen, (char *)modulepath); + if (rep.loglen) + WriteToClient(client, rep.loglen, (char *)logfile); + + return (client->noClientException); +} + +static int +ProcXF86MiscDispatch (client) + register ClientPtr client; +{ + REQUEST(xReq); + switch (stuff->data) + { + case X_XF86MiscQueryVersion: + return ProcXF86MiscQueryVersion(client); +#ifdef _XF86MISC_SAVER_COMPAT_ + case X_XF86MiscGetSaver: + return ProcXF86MiscGetSaver(client); + case X_XF86MiscSetSaver: + return ProcXF86MiscSetSaver(client); +#endif + case X_XF86MiscGetMouseSettings: + return ProcXF86MiscGetMouseSettings(client); + case X_XF86MiscGetKbdSettings: + return ProcXF86MiscGetKbdSettings(client); + case X_XF86MiscSetClientVersion: + return ProcXF86MiscSetClientVersion(client); + case X_XF86MiscGetFilePaths: + return ProcXF86MiscGetFilePaths(client); + default: + if (!xf86GetModInDevEnabled()) + return miscErrorBase + XF86MiscModInDevDisabled; + if (xf86GetModInDevAllowNonLocal() || LocalClient (client)) { + switch (stuff->data) { + case X_XF86MiscSetMouseSettings: + return ProcXF86MiscSetMouseSettings(client); + case X_XF86MiscSetKbdSettings: + return ProcXF86MiscSetKbdSettings(client); + case X_XF86MiscSetGrabKeysState: + return ProcXF86MiscSetGrabKeysState(client); + default: + return BadRequest; + } + } else + return miscErrorBase + XF86MiscModInDevClientNotLocal; + } +} + +static int +SProcXF86MiscQueryVersion(client) + register ClientPtr client; +{ + register int n; + REQUEST(xXF86MiscQueryVersionReq); + swaps(&stuff->length, n); + return ProcXF86MiscQueryVersion(client); +} + +#ifdef _XF86MISC_SAVER_COMPAT_ +static int +SProcXF86MiscGetSaver(client) + ClientPtr client; +{ + register int n; + REQUEST(xXF86MiscGetSaverReq); + swaps(&stuff->length, n); + REQUEST_SIZE_MATCH(xXF86MiscGetSaverReq); + swaps(&stuff->screen, n); + return ProcXF86MiscGetSaver(client); +} + +static int +SProcXF86MiscSetSaver(client) + ClientPtr client; +{ + register int n; + REQUEST(xXF86MiscSetSaverReq); + swaps(&stuff->length, n); + REQUEST_SIZE_MATCH(xXF86MiscSetSaverReq); + swaps(&stuff->screen, n); + swapl(&stuff->suspendTime, n); + swapl(&stuff->offTime, n); + return ProcXF86MiscSetSaver(client); +} +#endif /* _XF86MISC_SAVER_COMPAT_ */ + +static int +SProcXF86MiscGetMouseSettings(client) + ClientPtr client; +{ + register int n; + REQUEST(xXF86MiscGetMouseSettingsReq); + swaps(&stuff->length, n); + REQUEST_SIZE_MATCH(xXF86MiscGetMouseSettingsReq); + return ProcXF86MiscGetMouseSettings(client); +} + +static int +SProcXF86MiscGetKbdSettings(client) + ClientPtr client; +{ + register int n; + REQUEST(xXF86MiscGetKbdSettingsReq); + swaps(&stuff->length, n); + REQUEST_SIZE_MATCH(xXF86MiscGetKbdSettingsReq); + return ProcXF86MiscGetKbdSettings(client); +} + +static int +SProcXF86MiscSetMouseSettings(client) + ClientPtr client; +{ + register int n; + REQUEST(xXF86MiscSetMouseSettingsReq); + swaps(&stuff->length, n); + REQUEST_SIZE_MATCH(xXF86MiscSetMouseSettingsReq); + swapl(&stuff->mousetype, n); + swapl(&stuff->baudrate, n); + swapl(&stuff->samplerate, n); + swapl(&stuff->resolution, n); + swapl(&stuff->buttons, n); + swapl(&stuff->emulate3timeout, n); + swapl(&stuff->flags, n); + return ProcXF86MiscSetMouseSettings(client); +} + +static int +SProcXF86MiscSetKbdSettings(client) + ClientPtr client; +{ + register int n; + REQUEST(xXF86MiscSetKbdSettingsReq); + swaps(&stuff->length, n); + REQUEST_SIZE_MATCH(xXF86MiscSetKbdSettingsReq); + swapl(&stuff->kbdtype, n); + swapl(&stuff->rate, n); + swapl(&stuff->delay, n); + return ProcXF86MiscSetKbdSettings(client); +} + +static int +SProcXF86MiscSetGrabKeysState(client) + ClientPtr client; +{ + register int n; + REQUEST(xXF86MiscSetGrabKeysStateReq); + swaps(&stuff->length, n); + REQUEST_SIZE_MATCH(xXF86MiscSetGrabKeysStateReq); + swaps(&stuff->enable, n); + return ProcXF86MiscSetGrabKeysState(client); +} + +static int +SProcXF86MiscSetClientVersion(ClientPtr client) +{ + register int n; + REQUEST(xXF86MiscSetClientVersionReq); + swaps(&stuff->length, n); + REQUEST_SIZE_MATCH(xXF86MiscSetClientVersionReq); + swaps(&stuff->major, n); + swaps(&stuff->minor, n); + return ProcXF86MiscSetClientVersion(client); +} + +static int +SProcXF86MiscGetFilePaths(client) + ClientPtr client; +{ + register int n; + REQUEST(xXF86MiscGetFilePathsReq); + swaps(&stuff->length, n); + REQUEST_SIZE_MATCH(xXF86MiscGetFilePathsReq); + return ProcXF86MiscGetFilePaths(client); +} + +static int +SProcXF86MiscDispatch (client) + register ClientPtr client; +{ + REQUEST(xReq); + switch (stuff->data) + { + case X_XF86MiscQueryVersion: + return SProcXF86MiscQueryVersion(client); +#ifdef _XF86MISC_SAVER_COMPAT_ + case X_XF86MiscGetSaver: + return SProcXF86MiscGetSaver(client); + case X_XF86MiscSetSaver: + return SProcXF86MiscSetSaver(client); +#endif + case X_XF86MiscGetMouseSettings: + return SProcXF86MiscGetMouseSettings(client); + case X_XF86MiscGetKbdSettings: + return SProcXF86MiscGetKbdSettings(client); + case X_XF86MiscSetClientVersion: + return SProcXF86MiscSetClientVersion(client); + case X_XF86MiscGetFilePaths: + return SProcXF86MiscGetFilePaths(client); + default: + if (!xf86GetModInDevEnabled()) + return miscErrorBase + XF86MiscModInDevDisabled; + if (xf86GetModInDevAllowNonLocal() || LocalClient (client)) { + switch (stuff->data) { + case X_XF86MiscSetMouseSettings: + return SProcXF86MiscSetMouseSettings(client); + case X_XF86MiscSetKbdSettings: + return SProcXF86MiscSetKbdSettings(client); + case X_XF86MiscSetGrabKeysState: + return SProcXF86MiscSetGrabKeysState(client); + default: + return BadRequest; + } + } else + return miscErrorBase + XF86MiscModInDevClientNotLocal; + } +} + diff --git a/hw/xfree86/dixmods/extmod/xf86miscproc.h b/hw/xfree86/dixmods/extmod/xf86miscproc.h new file mode 100644 index 000000000..63db938d1 --- /dev/null +++ b/hw/xfree86/dixmods/extmod/xf86miscproc.h @@ -0,0 +1,64 @@ +/* $XFree86: xc/programs/Xserver/Xext/xf86miscproc.h,v 1.5 2002/11/20 04:04:58 dawes Exp $ */ + +/* Prototypes for Pointer/Keyboard functions that the DDX must provide */ + +#ifndef _XF86MISCPROC_H_ +#define _XF86MISCPROC_H_ + +typedef enum { + MISC_MSE_PROTO, + MISC_MSE_BAUDRATE, + MISC_MSE_SAMPLERATE, + MISC_MSE_RESOLUTION, + MISC_MSE_BUTTONS, + MISC_MSE_EM3BUTTONS, + MISC_MSE_EM3TIMEOUT, + MISC_MSE_CHORDMIDDLE, + MISC_MSE_FLAGS +} MiscExtMseValType; + +typedef enum { + MISC_KBD_TYPE, + MISC_KBD_RATE, + MISC_KBD_DELAY, + MISC_KBD_SERVNUMLOCK +} MiscExtKbdValType; + +typedef enum { + MISC_RET_SUCCESS, + MISC_RET_BADVAL, + MISC_RET_BADMSEPROTO, + MISC_RET_BADBAUDRATE, + MISC_RET_BADFLAGS, + MISC_RET_BADCOMBO, + MISC_RET_BADKBDTYPE, + MISC_RET_NOMODULE +} MiscExtReturn; + +typedef enum { + MISC_POINTER, + MISC_KEYBOARD +} MiscExtStructType; + +#define MISC_MSEFLAG_CLEARDTR 1 +#define MISC_MSEFLAG_CLEARRTS 2 +#define MISC_MSEFLAG_REOPEN 128 + +void XFree86MiscExtensionInit(void); + +Bool MiscExtGetMouseSettings(pointer *mouse, char **devname); +int MiscExtGetMouseValue(pointer mouse, MiscExtMseValType valtype); +Bool MiscExtSetMouseValue(pointer mouse, MiscExtMseValType valtype, int value); +Bool MiscExtGetKbdSettings(pointer *kbd); +int MiscExtGetKbdValue(pointer kbd, MiscExtKbdValType valtype); +Bool MiscExtSetKbdValue(pointer kbd, MiscExtKbdValType valtype, int value); +int MiscExtSetGrabKeysState(ClientPtr client, int enable); +pointer MiscExtCreateStruct(MiscExtStructType mse_or_kbd); +void MiscExtDestroyStruct(pointer structure, MiscExtStructType mse_or_kbd); +MiscExtReturn MiscExtApply(pointer structure, MiscExtStructType mse_or_kbd); +Bool MiscExtSetMouseDevice(pointer mouse, char* device); +Bool MiscExtGetFilePaths(const char **configfile, const char **modulepath, + const char **logfile); + +#endif + diff --git a/hw/xfree86/dixmods/extmod/xvmod.c b/hw/xfree86/dixmods/extmod/xvmod.c new file mode 100644 index 000000000..4a9c461f6 --- /dev/null +++ b/hw/xfree86/dixmods/extmod/xvmod.c @@ -0,0 +1,20 @@ +/* $XFree86: xc/programs/Xserver/Xext/xvmod.c,v 1.2 2001/03/05 04:51:55 mvojkovi Exp $ */ + +#include "X.h" +#include "misc.h" +#include "scrnintstr.h" +#include "gc.h" +#include "Xv.h" +#include "Xvproto.h" +#include "xvdix.h" +#include "xvmodproc.h" + +void +XvRegister() +{ + XvScreenInitProc = XvScreenInit; + XvGetScreenIndexProc = XvGetScreenIndex; + XvGetRTPortProc = XvGetRTPort; + XvMCScreenInitProc = XvMCScreenInit; +} + diff --git a/hw/xfree86/dixmods/extmod/xvmodproc.h b/hw/xfree86/dixmods/extmod/xvmodproc.h new file mode 100644 index 000000000..2dcbd472a --- /dev/null +++ b/hw/xfree86/dixmods/extmod/xvmodproc.h @@ -0,0 +1,10 @@ +/* $XFree86: xc/programs/Xserver/Xext/xvmodproc.h,v 1.3 2001/04/08 16:33:22 dawes Exp $ */ + +#include "xvmcext.h" + +extern int (*XvGetScreenIndexProc)(void); +extern unsigned long (*XvGetRTPortProc)(void); +extern int (*XvScreenInitProc)(ScreenPtr); +extern int (*XvMCScreenInitProc)(ScreenPtr, int, XvMCAdaptorPtr); + +extern void XvRegister(void); |