From 39b749e09d0b3958d015b1ab04de6068c763776b Mon Sep 17 00:00:00 2001 From: Jay Sorg Date: Sat, 13 Jul 2013 19:03:03 -0700 Subject: [PATCH] work on xorg driver --- xorg/server/module/Makefile | 9 +-- xorg/server/module/rdp.h | 3 + xorg/server/module/rdpCursor.c | 91 +++++++++++++++++++++++++++++ xorg/server/module/rdpCursor.h | 44 ++++++++++++++ xorg/server/module/rdpDraw.c | 59 +++++++++---------- xorg/server/module/rdpGC.c | 1 + xorg/server/module/rdpPri.c | 102 ++++++++++++++++++++++++++++++--- 7 files changed, 267 insertions(+), 42 deletions(-) create mode 100644 xorg/server/module/rdpCursor.c create mode 100644 xorg/server/module/rdpCursor.h diff --git a/xorg/server/module/Makefile b/xorg/server/module/Makefile index f2442c82..70df8e72 100644 --- a/xorg/server/module/Makefile +++ b/xorg/server/module/Makefile @@ -3,17 +3,18 @@ OBJS = rdpDraw.o rdpPri.o rdpGC.o rdpFillSpans.o rdpSetSpans.o rdpPutImage.o \ rdpCopyArea.o rdpCopyPlane.o rdpPolyPoint.o rdpPolylines.o rdpPolySegment.o \ rdpPolyRectangle.o rdpPolyArc.o rdpFillPolygon.o rdpPolyFillRect.o \ rdpPolyFillArc.o rdpPolyText8.o rdpPolyText16.o rdpImageText8.o \ -rdpImageText16.o rdpImageGlyphBlt.o rdpPolyGlyphBlt.o rdpPushPixels.o +rdpImageText16.o rdpImageGlyphBlt.o rdpPolyGlyphBlt.o rdpPushPixels.o \ +rdpCursor.o -CFLAGS = -O2 -Wall -fPIC -I/usr/include/xorg -I/usr/include/pixman-1 +CFLAGS = -g -O2 -Wall -fPIC -I/usr/include/xorg -I/usr/include/pixman-1 LDFLAGS = LIBS = -all: xrdpdev_drv.so +all: libxorgxrdp.so -xrdpdev_drv.so: $(OBJS) Makefile +libxorgxrdp.so: $(OBJS) Makefile $(CC) -shared -o libxorgxrdp.so $(LDFLAGS) $(OBJS) $(LIBS) clean: diff --git a/xorg/server/module/rdp.h b/xorg/server/module/rdp.h index c812e251..ea48a8ee 100644 --- a/xorg/server/module/rdp.h +++ b/xorg/server/module/rdp.h @@ -25,6 +25,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include #include #include +#include #include "rdpPri.h" @@ -46,6 +47,8 @@ struct _rdpRec DestroyPixmapProcPtr DestroyPixmap; ModifyPixmapHeaderProcPtr ModifyPixmapHeader; + miPointerScreenFuncPtr pCursorFuncs; + }; typedef struct _rdpRec rdpRec; typedef struct _rdpRec * rdpPtr; diff --git a/xorg/server/module/rdpCursor.c b/xorg/server/module/rdpCursor.c new file mode 100644 index 00000000..82aafd78 --- /dev/null +++ b/xorg/server/module/rdpCursor.c @@ -0,0 +1,91 @@ +/* +Copyright 2005-2013 Jay Sorg + +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. + +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 +OPEN GROUP 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. + +cursor + +*/ + +#include +#include +#include + +/* this should be before all X11 .h files */ +#include + +/* all driver need this */ +#include +#include + +#include +#include +#include +#include + +#include "rdp.h" + +/******************************************************************************/ +#define LOG_LEVEL 1 +#define LLOGLN(_level, _args) \ + do { if (_level < LOG_LEVEL) { ErrorF _args ; ErrorF("\n"); } } while (0) + +/******************************************************************************/ +Bool +rdpSpriteRealizeCursor(DeviceIntPtr pDev, ScreenPtr pScr, CursorPtr pCurs) +{ + LLOGLN(0, ("rdpSpriteRealizeCursor:")); + return 1; +} + +/******************************************************************************/ +Bool +rdpSpriteUnrealizeCursor(DeviceIntPtr pDev, ScreenPtr pScr, CursorPtr pCurs) +{ + LLOGLN(0, ("rdpSpriteUnrealizeCursor:")); + return 1; +} + +/******************************************************************************/ +void +rdpSpriteSetCursor(DeviceIntPtr pDev, ScreenPtr pScr, CursorPtr pCurs, + int x, int y) +{ + LLOGLN(0, ("rdpSpriteSetCursor:")); +} + +/******************************************************************************/ +void +rdpSpriteMoveCursor(DeviceIntPtr pDev, ScreenPtr pScr, int x, int y) +{ + LLOGLN(0, ("rdpSpriteMoveCursor:")); +} + +/******************************************************************************/ +Bool +rdpSpriteDeviceCursorInitialize(DeviceIntPtr pDev, ScreenPtr pScr) +{ + LLOGLN(0, ("rdpSpriteDeviceCursorInitialize:")); + return 1; +} + +/******************************************************************************/ +void +rdpSpriteDeviceCursorCleanup(DeviceIntPtr pDev, ScreenPtr pScr) +{ + LLOGLN(0, ("rdpSpriteDeviceCursorCleanup:")); +} diff --git a/xorg/server/module/rdpCursor.h b/xorg/server/module/rdpCursor.h new file mode 100644 index 00000000..b847d842 --- /dev/null +++ b/xorg/server/module/rdpCursor.h @@ -0,0 +1,44 @@ +/* +Copyright 2005-2013 Jay Sorg + +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. + +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 +OPEN GROUP 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. + +misc draw calls + +*/ + +#ifndef __RDPCURSOR_H +#define __RDPCURSOR_H + +#include +#include + +Bool +rdpSpriteRealizeCursor(DeviceIntPtr pDev, ScreenPtr pScr, CursorPtr pCurs); +Bool +rdpSpriteUnrealizeCursor(DeviceIntPtr pDev, ScreenPtr pScr, CursorPtr pCurs); +void +rdpSpriteSetCursor(DeviceIntPtr pDev, ScreenPtr pScr, CursorPtr pCurs, + int x, int y); +void +rdpSpriteMoveCursor(DeviceIntPtr pDev, ScreenPtr pScr, int x, int y); +Bool +rdpSpriteDeviceCursorInitialize(DeviceIntPtr pDev, ScreenPtr pScr); +void +rdpSpriteDeviceCursorCleanup(DeviceIntPtr pDev, ScreenPtr pScr); + +#endif diff --git a/xorg/server/module/rdpDraw.c b/xorg/server/module/rdpDraw.c index 9e989fe7..ff8fdb7f 100644 --- a/xorg/server/module/rdpDraw.c +++ b/xorg/server/module/rdpDraw.c @@ -61,10 +61,12 @@ rdpCreatePixmap(ScreenPtr pScreen, int width, int height, int depth, rdpPtr dev; PixmapPtr rv; + LLOGLN(10, ("rdpCreatePixmap: width %d height %d depth %d", + width, height, depth)); pScrn = xf86Screens[pScreen->myNum]; dev = XRDPPTR(pScrn); pScreen->CreatePixmap = dev->CreatePixmap; - rv = pScreen->CreatePixmap(pScreen, 0, 0, 0, 0); + rv = pScreen->CreatePixmap(pScreen, width, height, depth, usage_hint); pScreen->CreatePixmap = rdpCreatePixmap; return rv; } @@ -73,19 +75,19 @@ rdpCreatePixmap(ScreenPtr pScreen, int width, int height, int depth, Bool rdpDestroyPixmap(PixmapPtr pPixmap) { - Bool rv; - ScreenPtr pScreen; - rdpPtr dev; - ScrnInfoPtr pScrn; - - LLOGLN(10, ("rdpDestroyPixmap: refcnt %d", pPixmap->refcnt)); - pScreen = pPixmap->drawable.pScreen; - pScrn = xf86Screens[pScreen->myNum]; - dev = XRDPPTR(pScrn); - pScreen->DestroyPixmap = dev->DestroyPixmap; - rv = pScreen->DestroyPixmap(pPixmap); - pScreen->DestroyPixmap = rdpDestroyPixmap; - return rv; + Bool rv; + ScreenPtr pScreen; + rdpPtr dev; + ScrnInfoPtr pScrn; + + LLOGLN(10, ("rdpDestroyPixmap: refcnt %d", pPixmap->refcnt)); + pScreen = pPixmap->drawable.pScreen; + pScrn = xf86Screens[pScreen->myNum]; + dev = XRDPPTR(pScrn); + pScreen->DestroyPixmap = dev->DestroyPixmap; + rv = pScreen->DestroyPixmap(pPixmap); + pScreen->DestroyPixmap = rdpDestroyPixmap; + return rv; } /******************************************************************************/ @@ -93,19 +95,20 @@ Bool rdpModifyPixmapHeader(PixmapPtr pPixmap, int width, int height, int depth, int bitsPerPixel, int devKind, pointer pPixData) { - Bool rv; - ScreenPtr pScreen; - rdpPtr dev; - ScrnInfoPtr pScrn; - - pScreen = pPixmap->drawable.pScreen; - pScrn = xf86Screens[pScreen->myNum]; - dev = XRDPPTR(pScrn); - pScreen->ModifyPixmapHeader = dev->ModifyPixmapHeader; - rv = pScreen->ModifyPixmapHeader(pPixmap, width, height, depth, bitsPerPixel, - devKind, pPixData); - pScreen->ModifyPixmapHeader = rdpModifyPixmapHeader; - return rv; + Bool rv; + ScreenPtr pScreen; + rdpPtr dev; + ScrnInfoPtr pScrn; + + LLOGLN(10, ("rdpModifyPixmapHeader:")); + pScreen = pPixmap->drawable.pScreen; + pScrn = xf86Screens[pScreen->myNum]; + dev = XRDPPTR(pScrn); + pScreen->ModifyPixmapHeader = dev->ModifyPixmapHeader; + rv = pScreen->ModifyPixmapHeader(pPixmap, width, height, depth, bitsPerPixel, + devKind, pPixData); + pScreen->ModifyPixmapHeader = rdpModifyPixmapHeader; + return rv; } /*****************************************************************************/ @@ -134,8 +137,6 @@ RDPSetup(pointer Module, pointer Options, int *ErrorMajor, int *ErrorMinor) if (!initialised) { initialised = 1; - //xf86AddModuleInfo(&THINC, Module); - //LoaderRefSymLists(cursorSymbols, NULL); } return (pointer) 1; } diff --git a/xorg/server/module/rdpGC.c b/xorg/server/module/rdpGC.c index a7fe9ff5..3a585e2c 100644 --- a/xorg/server/module/rdpGC.c +++ b/xorg/server/module/rdpGC.c @@ -132,6 +132,7 @@ rdpValidateGC(GCPtr pGC, unsigned long changes, DrawablePtr d) LLOGLN(10, ("rdpValidateGC:")); GC_FUNC_PROLOGUE(pGC); pGC->funcs->ValidateGC(pGC, changes, d); + priv->ops = pGC->ops; GC_FUNC_EPILOGUE(pGC); } diff --git a/xorg/server/module/rdpPri.c b/xorg/server/module/rdpPri.c index d8346fa9..6a10c59b 100644 --- a/xorg/server/module/rdpPri.c +++ b/xorg/server/module/rdpPri.c @@ -39,51 +39,135 @@ to deal with privates changing in xorg versions #include "rdpPri.h" +/* not sure if these versions are right */ +#if XORG_VERSION_CURRENT < (((1) * 10000000) + ((5) * 100000) + ((1) * 1000) + 0) +#define FBDEV_PRI 1 +#elif XORG_VERSION_CURRENT < (((1) * 10000000) + ((7) * 100000) + ((7) * 1000) + 1) +#define FBDEV_PRI 2 +#else +#define FBDEV_PRI 3 +#endif + +#define PTR2INT(_ptr) ((int) ((long) ((void*) (_ptr)))) +#define INT2PTR(_int) ((void *) ((long) ((int) (_int)))) + +#if FBDEV_PRI == 3 +static DevPrivateKeyRec g_privateKeyRecGC; +static DevPrivateKeyRec g_privateKeyRecPixmap; +static DevPrivateKeyRec g_privateKeyRecWindow; +#elif FBDEV_PRI == 2 +static int g_privateKeyRecGC = 0; +static int g_privateKeyRecPixmap = 0; +static int g_privateKeyRecWindow = 0; +#endif + /*****************************************************************************/ rdpDevPrivateKey rdpAllocateGCPrivate(ScreenPtr pScreen, int bytes) { - return 0; + rdpDevPrivateKey rv; + +#if FBDEV_PRI == 1 + rv = INT2PTR(AllocateGCPrivateIndex()); + AllocateGCPrivate(pScreen, PTR2INT(rv), bytes); +#elif FBDEV_PRI == 2 + dixRequestPrivate(&g_privateKeyRecGC, bytes); + rv = &g_privateKeyRecGC; +#else + dixRegisterPrivateKey(&g_privateKeyRecGC, PRIVATE_GC, bytes); + rv = &g_privateKeyRecGC; +#endif + return rv; } /*****************************************************************************/ rdpDevPrivateKey rdpAllocatePixmapPrivate(ScreenPtr pScreen, int bytes) { - return 0; + rdpDevPrivateKey rv; + +#if FBDEV_PRI == 1 + rv = INT2PTR(AllocatePixmapPrivateIndex()); + AllocatePixmapPrivate(pScreen, PTR2INT(rv), bytes); +#elif FBDEV_PRI == 2 + dixRequestPrivate(&g_privateKeyRecPixmap, bytes); + rv = &g_privateKeyRecPixmap; +#else + dixRegisterPrivateKey(&g_privateKeyRecPixmap, PRIVATE_PIXMAP, bytes); + rv = &g_privateKeyRecPixmap; +#endif + return rv; } /*****************************************************************************/ rdpDevPrivateKey rdpAllocateWindowPrivate(ScreenPtr pScreen, int bytes) { - return 0; + rdpDevPrivateKey rv; + +#if FBDEV_PRI == 1 + rv = INT2PTR(AllocateWindowPrivateIndex()); + AllocateWindowPrivate(pScreen, PTR2INT(rv), bytes); +#elif FBDEV_PRI == 2 + dixRequestPrivate(&g_privateKeyRecWindow, bytes); + rv = &g_privateKeyRecWindow; +#else + dixRegisterPrivateKey(&g_privateKeyRecWindow, PRIVATE_WINDOW, bytes); + rv = &g_privateKeyRecWindow; +#endif + return rv; } /*****************************************************************************/ -void* +void * rdpGetGCPrivate(GCPtr pGC, rdpDevPrivateKey key) { - return 0; + void *rv; + +#if FBDEV_PRI == 1 + rv = pGC->devPrivates[PTR2INT(key)].ptr; +#else + rv = dixLookupPrivate(&(pGC->devPrivates), key); +#endif + return rv; } /*****************************************************************************/ -void* +void * rdpGetPixmapPrivate(PixmapPtr pPixmap, rdpDevPrivateKey key) { - return 0; + void *rv; + +#if FBDEV_PRI == 1 + rv = pPixmap->devPrivates[PTR2INT(key)].ptr; +#else + rv = dixLookupPrivate(&(pPixmap->devPrivates), key); +#endif + return rv; } /*****************************************************************************/ -void* +void * rdpGetWindowPrivate(WindowPtr pWindow, rdpDevPrivateKey key) { - return 0; + void *rv; + +#if FBDEV_PRI == 1 + rv = pWindow->devPrivates[PTR2INT(key)].ptr; +#else + rv = dixLookupPrivate(&(pWindow->devPrivates), key); +#endif + return rv; } /*****************************************************************************/ int rdpPrivateInit(void) { +#if FBDEV_PRI == 3 + memset(&g_privateKeyRecGC, 0, sizeof(g_privateKeyRecGC)); + memset(&g_privateKeyRecWindow, 0, sizeof(g_privateKeyRecWindow)); + memset(&g_privateKeyRecPixmap, 0, sizeof(g_privateKeyRecPixmap)); +#endif return 0; }