From: philipl Date: Tue, 7 Feb 2006 18:51:35 +0000 (+0000) Subject: Add VMWARE_CTRL extension. X-Git-Tag: release-10-12-0-0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=ac83dff5d6a54b05e0377ceac2b133238293fa0e;p=platform%2Fupstream%2Fxf86-video-vmware.git Add VMWARE_CTRL extension. --- diff --git a/ChangeLog b/ChangeLog index 77166fd..4004d20 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,35 @@ +2006-02-06 Philip Langdale + + * configure.ac: Bump version number. + * src/vmware.c + * src/vmware.h: (VMWAREScreenInit) Set up the additional + state required by the VMWARE_CTRL extension. + A src/vmwarectrl.c + A src/vmwarectrl.h + A src/vmwarectrlproto.h: Add implementation of the VMWARE_CTRL + extension. + + This change adds the VMWARE_CTRL extension which allows for + an X client to request an arbitrary resolution be made + available in the modeline list. The intent here is not to + replace XF86VidMode (which, if it would only work, would have + made VMWARE_CTRL unnecessary) so we are not providing an + Add/Remove functionality. Rather, a single command "SetRes" + is provided. This will update one of two special entries in + the modeline list with the requested resolution (assuming + it's possible given the fixed framebuffer restriction). + The client can then use RandR to find and switch to the + requested resolution. We need two entries because the + server gets confused when asked to switch to a new + mode that has the same position in the list as the old + mode. + + vmwarectrl.h and vmwarectrlproto.h follow the standard + pattern for extension headers and can be dropped into any + client side project that wishes to call the extension - + although it is probably of very limited use to non-VMware + clients. + 2006-01-12 Philip Langdale * configure.ac: Bump version number. diff --git a/configure.ac b/configure.ac index 8bc50f7..980cb1f 100644 --- a/configure.ac +++ b/configure.ac @@ -22,7 +22,7 @@ AC_PREREQ(2.57) AC_INIT([xf86-video-vmware], - 10.11.2.0, + 10.12.0.0, [https://bugs.freedesktop.org/enter_bug.cgi?product=xorg], xf86-video-vmware) diff --git a/src/Makefile.am b/src/Makefile.am index c761d10..f940770 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -43,4 +43,7 @@ vmware_drv_la_SOURCES = \ vmware.c \ vmwarecurs.c \ vmware.h \ - vmwarexaa.c + vmwarexaa.c \ + vmwarectrl.c \ + vmwarectrl.h \ + vmwarectrlproto.h diff --git a/src/vmware.c b/src/vmware.c index bdd3a89..3aa9be7 100644 --- a/src/vmware.c +++ b/src/vmware.c @@ -46,6 +46,19 @@ char rcsId_vmware[] = #endif /* + * So that the file compiles unmodified when dropped in to a < 6.9 source tree. + */ +#ifndef _X_EXPORT +#define _X_EXPORT +#endif +/* + * So that the file compiles unmodified when dropped into an xfree source tree. + */ +#ifndef XORG_VERSION_CURRENT +#define XORG_VERSION_CURRENT XF86_VERSION_CURRENT +#endif + +/* * Sanity check that xf86PciInfo.h has the correct values (which come from * the VMware source tree in vm_device_version.h. */ @@ -69,8 +82,8 @@ char rcsId_vmware[] = #define VMWARE_NAME "VMWARE" #define VMWARE_DRIVER_NAME "vmware" #define VMWARE_MAJOR_VERSION 10 -#define VMWARE_MINOR_VERSION 11 -#define VMWARE_PATCHLEVEL 2 +#define VMWARE_MINOR_VERSION 12 +#define VMWARE_PATCHLEVEL 0 #define VMWARE_DRIVER_VERSION \ (VMWARE_MAJOR_VERSION * 65536 + VMWARE_MINOR_VERSION * 256 + VMWARE_PATCHLEVEL) @@ -1151,6 +1164,33 @@ VMWARELoadPalette(ScrnInfoPtr pScrn, int numColors, int* indices, VmwareLog(("Palette loading done\n")); } + +static DisplayModeRec * +VMWAREAddDisplayMode(ScrnInfoPtr pScrn, + const char *name, + int width, + int height) +{ + DisplayModeRec *mode; + + mode = xalloc(sizeof(DisplayModeRec)); + + mode->name = xalloc(strlen(name) + 1); + strcpy(mode->name, name); + mode->status = MODE_OK; + mode->type = M_T_DEFAULT; + mode->HDisplay = width; + mode->VDisplay = height; + + mode->next = pScrn->modes; + mode->prev = pScrn->modes->prev; + pScrn->modes->prev->next = mode; + pScrn->modes->prev = mode; + + return mode; +} + + #if VMWARE_DRIVER_FUNC static Bool VMWareDriverFunc(ScrnInfoPtr pScrn, @@ -1370,6 +1410,16 @@ VMWAREScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv) return FALSE; } + /* + * The initial mode that fixes the framebuffer is the current mode + * at ScreenInit time. + */ + pVMWARE->initialMode = pScrn->currentMode; + pVMWARE->dynMode1 = VMWAREAddDisplayMode(pScrn, "DynMode1", 1, 1); + pVMWARE->dynMode2 = VMWAREAddDisplayMode(pScrn, "DynMode2", 2, 2); + + VMwareCtrl_ExtInit(pScrn); + #if VMWARE_DRIVER_FUNC pScrn->DriverFunc = VMWareDriverFunc; #endif diff --git a/src/vmware.h b/src/vmware.h index f3762ad..3993979 100644 --- a/src/vmware.h +++ b/src/vmware.h @@ -76,6 +76,10 @@ typedef struct { VMWARERegRec SavedReg; VMWARERegRec ModeReg; + DisplayModePtr initialMode; + DisplayModePtr dynMode1; + DisplayModePtr dynMode2; + Bool* pvtSema; Bool noAccel; @@ -242,4 +246,8 @@ void vmwareXAACloseScreen( ScreenPtr pScreen ); +/* vmware_ctl.c */ +void VMwareCtrl_ExtInit(ScrnInfoPtr pScrn); + + #endif diff --git a/src/vmwarectrl.c b/src/vmwarectrl.c new file mode 100644 index 0000000..49ccccd --- /dev/null +++ b/src/vmwarectrl.c @@ -0,0 +1,402 @@ +/* + * Copyright 2006 by VMware, Inc. + * + * 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, sublicense, + * 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 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 NONINFRINGEMENT. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) 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. + * + * Except as contained in this notice, the name of the copyright holder(s) + * and author(s) shall not be used in advertising or otherwise to promote + * the sale, use or other dealings in this Software without prior written + * authorization from the copyright holder(s) and author(s). + */ + +/* + * vmwarectrl.c -- + * + * The implementation of the VMWARE_CTRL protocol extension that + * allows X clients to communicate with the driver. + */ + + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#define NEED_REPLIES +#define NEED_EVENTS +#include +#include "dixstruct.h" +#include "extnsionst.h" + +#include "vmware.h" +#include "vmwarectrlproto.h" + + +/* + *---------------------------------------------------------------------------- + * + * VMwareCtrlQueryVersion -- + * + * Implementation of QueryVersion command handler. Initialises and + * sends a reply. + * + * Results: + * Standard response codes. + * + * Side effects: + * Writes reply to client + * + *---------------------------------------------------------------------------- + */ + +static int +VMwareCtrlQueryVersion(ClientPtr client) +{ + xVMwareCtrlQueryVersionReply rep = { 0, }; + register int n; + + REQUEST_SIZE_MATCH(xVMwareCtrlQueryVersionReq); + + rep.type = X_Reply; + rep.length = 0; + rep.sequenceNumber = client->sequence; + rep.majorVersion = VMWARE_CTRL_MAJOR_VERSION; + rep.minorVersion = VMWARE_CTRL_MINOR_VERSION; + if (client->swapped) { + swaps(&rep.sequenceNumber, n); + swapl(&rep.length, n); + swapl(&rep.majorVersion, n); + swapl(&rep.minorVersion, n); + } + WriteToClient(client, sizeof(xVMwareCtrlQueryVersionReply), (char *)&rep); + + return client->noClientException; +} + + +/* + *---------------------------------------------------------------------------- + * + * VMwareCtrlDoSetRes -- + * + * Set the custom resolution into the mode list. + * + * This is done by alternately updating one of two dynamic modes. It is + * done this way because the server gets upset if you try to switch + * to a new resolution that has the same index as the current one. + * + * Results: + * TRUE on success, FALSE otherwise. + * + * Side effects: + * One dynamic mode will be updated if successful. + * + *---------------------------------------------------------------------------- + */ + +static Bool +VMwareCtrlDoSetRes(ScrnInfoPtr pScrn, + CARD32 x, + CARD32 y) +{ + DisplayModePtr mode; + VMWAREPtr pVMWARE = VMWAREPTR(pScrn); + + if (pScrn && pScrn->modes) { + /* + * Don't resize larger than possible but don't + * return an X Error either. + */ + if (x > pVMWARE->initialMode->HDisplay || + y > pVMWARE->initialMode->VDisplay) { + return TRUE; + } + + /* + * Switch the dynamic modes so that we alternate + * which one gets updated on each call. + */ + mode = pVMWARE->dynMode1; + pVMWARE->dynMode1 = pVMWARE->dynMode2; + pVMWARE->dynMode2 = mode; + mode = pVMWARE->dynMode1; + + mode->HDisplay = x; + mode->VDisplay = y; + + return TRUE; + } else { + return FALSE; + } +} + + +/* + *---------------------------------------------------------------------------- + * + * VMwareCtrlSetRes -- + * + * Implementation of SetRes command handler. Initialises and sends a + * reply. + * + * Results: + * Standard response codes. + * + * Side effects: + * Writes reply to client + * + *---------------------------------------------------------------------------- + */ + +static int +VMwareCtrlSetRes(ClientPtr client) +{ + REQUEST(xVMwareCtrlSetResReq); + xVMwareCtrlSetResReply rep = { 0, }; + ScrnInfoPtr pScrn; + ExtensionEntry *ext; + register int n; + + REQUEST_SIZE_MATCH(xVMwareCtrlSetResReq); + + if (!(ext = CheckExtension(VMWARE_CTRL_PROTOCOL_NAME))) { + return BadMatch; + } + + pScrn = ext->extPrivate; + if (pScrn->scrnIndex != stuff->screen) { + return BadMatch; + } + + if (!VMwareCtrlDoSetRes(pScrn, stuff->x, stuff->y)) { + return BadValue; + } + + rep.type = X_Reply; + rep.length = (sizeof(xVMwareCtrlSetResReply) - sizeof(xGenericReply)) >> 2; + rep.sequenceNumber = client->sequence; + rep.screen = stuff->screen; + rep.x = stuff->x; + rep.y = stuff->y; + if (client->swapped) { + swaps(&rep.sequenceNumber, n); + swapl(&rep.length, n); + swapl(&rep.screen, n); + swapl(&rep.x, n); + swapl(&rep.y, n); + } + WriteToClient(client, sizeof(xVMwareCtrlSetResReply), (char *)&rep); + + return client->noClientException; +} + + +/* + *---------------------------------------------------------------------------- + * + * VMwareCtrlDispatch -- + * + * Dispatcher for VMWARE_CTRL commands. Calls the correct handler for + * each command type. + * + * Results: + * Standard response codes. + * + * Side effects: + * Side effects of individual command handlers. + * + *---------------------------------------------------------------------------- + */ + +static int +VMwareCtrlDispatch(ClientPtr client) +{ + REQUEST(xReq); + + switch(stuff->data) { + case X_VMwareCtrlQueryVersion: + return VMwareCtrlQueryVersion(client); + case X_VMwareCtrlSetRes: + return VMwareCtrlSetRes(client); + } + return BadRequest; +} + + +/* + *---------------------------------------------------------------------------- + * + * SVMwareCtrlQueryVersion -- + * + * Wrapper for QueryVersion handler that handles input from other-endian + * clients. + * + * Results: + * Standard response codes. + * + * Side effects: + * Side effects of unswapped implementation. + * + *---------------------------------------------------------------------------- + */ + +static int +SVMwareCtrlQueryVersion(ClientPtr client) +{ + register int n; + + REQUEST(xVMwareCtrlQueryVersionReq); + REQUEST_SIZE_MATCH(xVMwareCtrlQueryVersionReq); + + swaps(&stuff->length, n); + + return VMwareCtrlQueryVersion(client); +} + + +/* + *---------------------------------------------------------------------------- + * + * SVMwareCtrlSetRes -- + * + * Wrapper for SetRes handler that handles input from other-endian + * clients. + * + * Results: + * Standard response codes. + * + * Side effects: + * Side effects of unswapped implementation. + * + *---------------------------------------------------------------------------- + */ + +static int +SVMwareCtrlSetRes(ClientPtr client) +{ + register int n; + + REQUEST(xVMwareCtrlSetResReq); + REQUEST_SIZE_MATCH(xVMwareCtrlSetResReq); + + swaps(&stuff->length, n); + swapl(&stuff->screen, n); + swapl(&stuff->x, n); + swapl(&stuff->y, n); + + return VMwareCtrlSetRes(client); +} + + +/* + *---------------------------------------------------------------------------- + * + * SVMwareCtrlDispatch -- + * + * Wrapper for dispatcher that handles input from other-endian clients. + * + * Results: + * Standard response codes. + * + * Side effects: + * Side effects of individual command handlers. + * + *---------------------------------------------------------------------------- + */ + +static int +SVMwareCtrlDispatch(ClientPtr client) +{ + REQUEST(xReq); + + switch(stuff->data) { + case X_VMwareCtrlQueryVersion: + return SVMwareCtrlQueryVersion(client); + case X_VMwareCtrlSetRes: + return SVMwareCtrlSetRes(client); + } + return BadRequest; +} + + +/* + *---------------------------------------------------------------------------- + * + * VMwareCtrlResetProc -- + * + * Cleanup handler called when the extension is removed. + * + * Results: + * None + * + * Side effects: + * None + * + *---------------------------------------------------------------------------- + */ + +static void +VMwareCtrlResetProc(ExtensionEntry* extEntry) +{ + /* Currently, no cleanup is necessary. */ +} + + +/* + *---------------------------------------------------------------------------- + * + * VMwareCtrl_ExitInit -- + * + * Initialiser for the VMWARE_CTRL protocol extension. + * + * Results: + * None. + * + * Side effects: + * Protocol extension will be registered if successful. + * + *---------------------------------------------------------------------------- + */ + +void +VMwareCtrl_ExtInit(ScrnInfoPtr pScrn) +{ + ExtensionEntry *myext; + + if (!(myext = CheckExtension(VMWARE_CTRL_PROTOCOL_NAME))) { + if (!(myext = AddExtension(VMWARE_CTRL_PROTOCOL_NAME, 0, 0, + VMwareCtrlDispatch, + SVMwareCtrlDispatch, + VMwareCtrlResetProc, + StandardMinorOpcode))) { + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, + "Failed to add VMWARE_CTRL extension\n"); + return; + } + + /* + * For now, only support one screen as that's all the virtual + * hardware supports. + */ + myext->extPrivate = pScrn; + + xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "Initialized VMWARE_CTRL extension version %d.%d\n", + VMWARE_CTRL_MAJOR_VERSION, VMWARE_CTRL_MINOR_VERSION); + } +} diff --git a/src/vmwarectrl.h b/src/vmwarectrl.h new file mode 100644 index 0000000..f264494 --- /dev/null +++ b/src/vmwarectrl.h @@ -0,0 +1,47 @@ +/* + * Copyright 2006 by VMware, Inc. + * + * 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, sublicense, + * 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 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 NONINFRINGEMENT. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) 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. + * + * Except as contained in this notice, the name of the copyright holder(s) + * and author(s) shall not be used in advertising or otherwise to promote + * the sale, use or other dealings in this Software without prior written + * authorization from the copyright holder(s) and author(s). + */ + +/* + * vmwarectrl.h -- + * + * The definitions used by the VMWARE_CTRL protocol extension that + * allows X clients to communicate with the driver. + */ + + +#ifndef _VMWARE_CTRL_H_ +#define _VMWARE_CTRL_H_ + +#define VMWARE_CTRL_PROTOCOL_NAME "VMWARE_CTRL" + +#define VMWARE_CTRL_MAJOR_VERSION 0 +#define VMWARE_CTRL_MINOR_VERSION 1 + +#define X_VMwareCtrlQueryVersion 0 +#define X_VMwareCtrlSetRes 1 + +#endif /* _VMWARE_CTRL_H_ */ diff --git a/src/vmwarectrlproto.h b/src/vmwarectrlproto.h new file mode 100644 index 0000000..ecff744 --- /dev/null +++ b/src/vmwarectrlproto.h @@ -0,0 +1,95 @@ +/* + * Copyright 2006 by VMware, Inc. + * + * 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, sublicense, + * 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 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 NONINFRINGEMENT. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) 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. + * + * Except as contained in this notice, the name of the copyright holder(s) + * and author(s) shall not be used in advertising or otherwise to promote + * the sale, use or other dealings in this Software without prior written + * authorization from the copyright holder(s) and author(s). + */ + +/* + * vmwarectrlproto.h -- + * + * The description of the VMWARE_CTRL protocol extension that + * allows X clients to communicate with the driver. + */ + +#ifndef _VMWARE_CTRL_PROTO_H_ +#define _VMWARE_CTRL_PROTO_H_ + + +#include +#include "vmwarectrl.h" + + +/* + * Requests and Replies + */ + +typedef struct { + CARD8 reqType; /* always X_VMwareCtrlReqCode */ + CARD8 VMwareCtrlReqType; /* always X_VMwareCtrlQueryVersion */ + CARD16 length B16; + CARD32 majorVersion B32; + CARD32 minorVersion B32; +} xVMwareCtrlQueryVersionReq; +#define sz_xVMwareCtrlQueryVersionReq 12 + +typedef struct { + BYTE type; /* X_Reply */ + BYTE pad1; + CARD16 sequenceNumber B16; + CARD32 length B32; + CARD32 majorVersion B32; + CARD32 minorVersion B32; + CARD32 pad2 B32; + CARD32 pad3 B32; + CARD32 pad4 B32; + CARD32 pad5 B32; +} xVMwareCtrlQueryVersionReply; +#define sz_xVMwareCtrlQueryVersionReply 32 + +typedef struct { + CARD8 reqType; /* always X_VMwareCtrlReqCode */ + CARD8 VMwareCtrlReqType; /* always X_VMwareCtrlSetRes */ + CARD16 length B16; + CARD32 screen B32; + CARD32 x B32; + CARD32 y B32; +} xVMwareCtrlSetResReq; +#define sz_xVMwareCtrlSetResReq 16 + +typedef struct { + BYTE type; /* X_Reply */ + BYTE pad1; + CARD16 sequenceNumber B16; + CARD32 length B32; + CARD32 screen B32; + CARD32 x B32; + CARD32 y B32; + CARD32 pad2 B32; + CARD32 pad3 B32; + CARD32 pad4 B32; +} xVMwareCtrlSetResReply; +#define sz_xVMwareCtrlSetResReply 32 + + +#endif /* _VMWARE_CTRL_PROTO_H_ */