From 6eed5a1475df4076f697aafdc55a1e1c2f288a04 Mon Sep 17 00:00:00 2001 From: Jay Sorg Date: Fri, 12 Jul 2013 22:36:16 -0700 Subject: xorg: work on Xorg driver --- xorg/server/module/rdpPri.c | 89 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 89 insertions(+) create mode 100644 xorg/server/module/rdpPri.c (limited to 'xorg/server/module/rdpPri.c') diff --git a/xorg/server/module/rdpPri.c b/xorg/server/module/rdpPri.c new file mode 100644 index 00000000..d8346fa9 --- /dev/null +++ b/xorg/server/module/rdpPri.c @@ -0,0 +1,89 @@ +/* +Copyright 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. + +to deal with privates changing in xorg versions + +*/ + +#include +#include +#include + +/* this should be before all X11 .h files */ +#include + +/* all driver need this */ +#include +#include + +#include +#include +#include +#include + +#include "rdpPri.h" + +/*****************************************************************************/ +rdpDevPrivateKey +rdpAllocateGCPrivate(ScreenPtr pScreen, int bytes) +{ + return 0; +} + +/*****************************************************************************/ +rdpDevPrivateKey +rdpAllocatePixmapPrivate(ScreenPtr pScreen, int bytes) +{ + return 0; +} + +/*****************************************************************************/ +rdpDevPrivateKey +rdpAllocateWindowPrivate(ScreenPtr pScreen, int bytes) +{ + return 0; +} + +/*****************************************************************************/ +void* +rdpGetGCPrivate(GCPtr pGC, rdpDevPrivateKey key) +{ + return 0; +} + +/*****************************************************************************/ +void* +rdpGetPixmapPrivate(PixmapPtr pPixmap, rdpDevPrivateKey key) +{ + return 0; +} + +/*****************************************************************************/ +void* +rdpGetWindowPrivate(WindowPtr pWindow, rdpDevPrivateKey key) +{ + return 0; +} + +/*****************************************************************************/ +int +rdpPrivateInit(void) +{ + return 0; +} -- cgit v1.2.3 From 39b749e09d0b3958d015b1ab04de6068c763776b Mon Sep 17 00:00:00 2001 From: Jay Sorg Date: Sat, 13 Jul 2013 19:03:03 -0700 Subject: 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 (limited to 'xorg/server/module/rdpPri.c') 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; } -- cgit v1.2.3 From 2ad9b26c21dda68228e8ecd777375656de77dcc5 Mon Sep 17 00:00:00 2001 From: Jay Sorg Date: Wed, 17 Jul 2013 17:28:53 -0700 Subject: xorg driver, work on randr --- xorg/server/module/rdp.h | 4 +++ xorg/server/module/rdpDraw.c | 50 ++++++++++++++++++++++++++++++++++++ xorg/server/module/rdpDraw.h | 6 +++++ xorg/server/module/rdpPri.c | 38 +++++++++++++++------------- xorg/server/module/rdpRandR.c | 14 +++------- xorg/server/xrdpdev/xrdpdev.c | 59 +++++++++++++++++++++++++++++++++++++++---- 6 files changed, 137 insertions(+), 34 deletions(-) (limited to 'xorg/server/module/rdpPri.c') diff --git a/xorg/server/module/rdp.h b/xorg/server/module/rdp.h index 7bb2fbc1..e10ba779 100644 --- a/xorg/server/module/rdp.h +++ b/xorg/server/module/rdp.h @@ -30,6 +30,9 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include "rdpPri.h" +#define PixelDPI 100 +#define PixelToMM(_size) (((_size) * 254 + (PixelDPI) * 5) / ((PixelDPI) * 10)) + /* move this to common header */ struct _rdpRec { @@ -50,6 +53,7 @@ struct _rdpRec CreatePixmapProcPtr CreatePixmap; DestroyPixmapProcPtr DestroyPixmap; ModifyPixmapHeaderProcPtr ModifyPixmapHeader; + CloseScreenProcPtr CloseScreen; miPointerScreenFuncPtr pCursorFuncs; diff --git a/xorg/server/module/rdpDraw.c b/xorg/server/module/rdpDraw.c index 6495bf4a..4de9fa9f 100644 --- a/xorg/server/module/rdpDraw.c +++ b/xorg/server/module/rdpDraw.c @@ -118,3 +118,53 @@ rdpCopyWindow(WindowPtr pWin, DDXPointRec ptOldOrg, RegionPtr pOldRegion) dev->pScreen->CopyWindow(pWin, ptOldOrg, pOldRegion); dev->pScreen->CopyWindow = rdpCopyWindow; } + +/*****************************************************************************/ +Bool +rdpCloseScreen(int index, ScreenPtr pScreen) +{ + ScrnInfoPtr pScrn; + rdpPtr dev; + Bool rv; + + LLOGLN(0, ("rdpCloseScreen:")); + pScrn = xf86Screens[pScreen->myNum]; + dev = XRDPPTR(pScrn); + dev->pScreen->CloseScreen = dev->CloseScreen; + rv = dev->pScreen->CloseScreen(index, pScreen); + dev->pScreen->CloseScreen = rdpCloseScreen; + return rv; +} + +/******************************************************************************/ +WindowPtr +rdpGetRootWindowPtr(ScreenPtr pScreen) +{ +#if XORG_VERSION_CURRENT < (((1) * 10000000) + ((9) * 100000) + ((0) * 1000) + 0) + return WindowTable[pScreen->myNum]; /* in globals.c */ +#else + return pScreen->root; +#endif +} + +/******************************************************************************/ +int +rdpBitsPerPixel(int depth) +{ + if (depth == 1) + { + return 1; + } + else if (depth <= 8) + { + return 8; + } + else if (depth <= 16) + { + return 16; + } + else + { + return 32; + } +} diff --git a/xorg/server/module/rdpDraw.h b/xorg/server/module/rdpDraw.h index e0e3988e..632a7467 100644 --- a/xorg/server/module/rdpDraw.h +++ b/xorg/server/module/rdpDraw.h @@ -62,5 +62,11 @@ rdpModifyPixmapHeader(PixmapPtr pPixmap, int width, int height, int depth, int bitsPerPixel, int devKind, pointer pPixData); void rdpCopyWindow(WindowPtr pWin, DDXPointRec ptOldOrg, RegionPtr pOldRegion); +Bool +rdpCloseScreen(int index, ScreenPtr pScreen); +WindowPtr +rdpGetRootWindowPtr(ScreenPtr pScreen); +int +rdpBitsPerPixel(int depth); #endif diff --git a/xorg/server/module/rdpPri.c b/xorg/server/module/rdpPri.c index 6a10c59b..3de181a8 100644 --- a/xorg/server/module/rdpPri.c +++ b/xorg/server/module/rdpPri.c @@ -39,23 +39,25 @@ 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 +#if XORG_VERSION_CURRENT < (((1) * 10000000) + ((5) * 100000) + ((0) * 1000) + 0) +/* 1.1, 1.2, 1.3, 1.4 */ +#define XRDP_PRI 1 +#elif XORG_VERSION_CURRENT < (((1) * 10000000) + ((9) * 100000) + ((0) * 1000) + 0) +/* 1.5, 1.6, 1.7, 1.8 */ +#define XRDP_PRI 2 #else -#define FBDEV_PRI 3 +/* 1.9, 1.10, 1.11, 1.12 */ +#define XRDP_PRI 3 #endif #define PTR2INT(_ptr) ((int) ((long) ((void*) (_ptr)))) #define INT2PTR(_int) ((void *) ((long) ((int) (_int)))) -#if FBDEV_PRI == 3 +#if XRDP_PRI == 3 static DevPrivateKeyRec g_privateKeyRecGC; static DevPrivateKeyRec g_privateKeyRecPixmap; static DevPrivateKeyRec g_privateKeyRecWindow; -#elif FBDEV_PRI == 2 +#elif XRDP_PRI == 2 static int g_privateKeyRecGC = 0; static int g_privateKeyRecPixmap = 0; static int g_privateKeyRecWindow = 0; @@ -67,10 +69,10 @@ rdpAllocateGCPrivate(ScreenPtr pScreen, int bytes) { rdpDevPrivateKey rv; -#if FBDEV_PRI == 1 +#if XRDP_PRI == 1 rv = INT2PTR(AllocateGCPrivateIndex()); AllocateGCPrivate(pScreen, PTR2INT(rv), bytes); -#elif FBDEV_PRI == 2 +#elif XRDP_PRI == 2 dixRequestPrivate(&g_privateKeyRecGC, bytes); rv = &g_privateKeyRecGC; #else @@ -86,10 +88,10 @@ rdpAllocatePixmapPrivate(ScreenPtr pScreen, int bytes) { rdpDevPrivateKey rv; -#if FBDEV_PRI == 1 +#if XRDP_PRI == 1 rv = INT2PTR(AllocatePixmapPrivateIndex()); AllocatePixmapPrivate(pScreen, PTR2INT(rv), bytes); -#elif FBDEV_PRI == 2 +#elif XRDP_PRI == 2 dixRequestPrivate(&g_privateKeyRecPixmap, bytes); rv = &g_privateKeyRecPixmap; #else @@ -105,10 +107,10 @@ rdpAllocateWindowPrivate(ScreenPtr pScreen, int bytes) { rdpDevPrivateKey rv; -#if FBDEV_PRI == 1 +#if XRDP_PRI == 1 rv = INT2PTR(AllocateWindowPrivateIndex()); AllocateWindowPrivate(pScreen, PTR2INT(rv), bytes); -#elif FBDEV_PRI == 2 +#elif XRDP_PRI == 2 dixRequestPrivate(&g_privateKeyRecWindow, bytes); rv = &g_privateKeyRecWindow; #else @@ -124,7 +126,7 @@ rdpGetGCPrivate(GCPtr pGC, rdpDevPrivateKey key) { void *rv; -#if FBDEV_PRI == 1 +#if XRDP_PRI == 1 rv = pGC->devPrivates[PTR2INT(key)].ptr; #else rv = dixLookupPrivate(&(pGC->devPrivates), key); @@ -138,7 +140,7 @@ rdpGetPixmapPrivate(PixmapPtr pPixmap, rdpDevPrivateKey key) { void *rv; -#if FBDEV_PRI == 1 +#if XRDP_PRI == 1 rv = pPixmap->devPrivates[PTR2INT(key)].ptr; #else rv = dixLookupPrivate(&(pPixmap->devPrivates), key); @@ -152,7 +154,7 @@ rdpGetWindowPrivate(WindowPtr pWindow, rdpDevPrivateKey key) { void *rv; -#if FBDEV_PRI == 1 +#if XRDP_PRI == 1 rv = pWindow->devPrivates[PTR2INT(key)].ptr; #else rv = dixLookupPrivate(&(pWindow->devPrivates), key); @@ -164,7 +166,7 @@ rdpGetWindowPrivate(WindowPtr pWindow, rdpDevPrivateKey key) int rdpPrivateInit(void) { -#if FBDEV_PRI == 3 +#if XRDP_PRI == 3 memset(&g_privateKeyRecGC, 0, sizeof(g_privateKeyRecGC)); memset(&g_privateKeyRecWindow, 0, sizeof(g_privateKeyRecWindow)); memset(&g_privateKeyRecPixmap, 0, sizeof(g_privateKeyRecPixmap)); diff --git a/xorg/server/module/rdpRandR.c b/xorg/server/module/rdpRandR.c index b481ae8e..bcd01928 100644 --- a/xorg/server/module/rdpRandR.c +++ b/xorg/server/module/rdpRandR.c @@ -38,23 +38,13 @@ RandR draw calls #include #include "rdp.h" - -#define PixelDPI 100 -#define PixelToMM(_size) (((_size) * 254 + (PixelDPI) * 5) / ((PixelDPI) * 10)) +#include "rdpDraw.h" /******************************************************************************/ #define LOG_LEVEL 1 #define LLOGLN(_level, _args) \ do { if (_level < LOG_LEVEL) { ErrorF _args ; ErrorF("\n"); } } while (0) -/******************************************************************************/ -static WindowPtr -rdpGetRootWindowPtr(ScreenPtr pScreen) -{ - /* in globals.c */ - return WindowTable[pScreen->myNum]; -} - /******************************************************************************/ Bool rdpRRRegisterSize(ScreenPtr pScreen, int width, int height) @@ -139,6 +129,8 @@ rdpRRScreenSetSize(ScreenPtr pScreen, CARD16 width, CARD16 height, LLOGLN(0, (" resizing screenPixmap [%p] to %dx%d, " "currently at %dx%d", (void *)screenPixmap, width, height, screenPixmap->drawable.width, screenPixmap->drawable.height)); + free(dev->pfbMemory); + dev->pfbMemory = (char *) malloc(dev->sizeInBytes); pScreen->ModifyPixmapHeader(screenPixmap, width, height, dev->depth, dev->bitsPerPixel, dev->paddedWidthInBytes, diff --git a/xorg/server/xrdpdev/xrdpdev.c b/xorg/server/xrdpdev/xrdpdev.c index c68d8700..bd80b75c 100644 --- a/xorg/server/xrdpdev/xrdpdev.c +++ b/xorg/server/xrdpdev/xrdpdev.c @@ -279,6 +279,32 @@ rdpSaveScreen(ScreenPtr pScreen, int on) return 1; } +/******************************************************************************/ +static Bool +rdpResizeSession(rdpPtr dev, int width, int height) +{ + int mmwidth; + int mmheight; + RRScreenSizePtr pSize; + Bool ok; + + LLOGLN(0, ("rdpResizeSession: width %d height %d", width, height)); + mmwidth = PixelToMM(width); + mmheight = PixelToMM(height); + + pSize = RRRegisterSize(dev->pScreen, width, height, mmwidth, mmheight); + RRSetCurrentConfig(dev->pScreen, RR_Rotate_0, 0, pSize); + + ok = 1; + if ((dev->width != width) || (dev->height != height)) + { + LLOGLN(0, (" calling RRScreenSizeSet")); + ok = RRScreenSizeSet(dev->pScreen, width, height, mmwidth, mmheight); + LLOGLN(0, (" RRScreenSizeSet ok=[%d]", ok)); + } + return ok; +} + /******************************************************************************/ static CARD32 rdpDeferredRandR(OsTimerPtr timer, CARD32 now, pointer arg) @@ -287,6 +313,9 @@ rdpDeferredRandR(OsTimerPtr timer, CARD32 now, pointer arg) rrScrPrivPtr pRRScrPriv; ScrnInfoPtr pScrn; rdpPtr dev; + char *envvar; + int width; + int height; pScreen = (ScreenPtr) arg; pScrn = xf86Screens[pScreen->myNum]; @@ -325,6 +354,26 @@ rdpDeferredRandR(OsTimerPtr timer, CARD32 now, pointer arg) pRRScrPriv->rrGetPanning = rdpRRGetPanning; pRRScrPriv->rrSetPanning = rdpRRSetPanning; + rdpResizeSession(dev, dev->width, dev->height); + + envvar = getenv("XRDP_START_WIDTH"); + if (envvar != 0) + { + width = atoi(envvar); + if ((width >= 16) && (width < 8192)) + { + envvar = getenv("XRDP_START_HEIGHT"); + if (envvar != 0) + { + height = atoi(envvar); + if ((height >= 16) && (height < 8192)) + { + rdpResizeSession(dev, width, height); + } + } + } + } + return 0; } @@ -346,14 +395,14 @@ rdpScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv) miSetVisualTypes(pScrn->depth, miGetDefaultVisualMask(pScrn->depth), pScrn->rgbBits, TrueColor); miSetPixmapDepths(); - LLOGLN(0, ("rdpScreenInit: virtualX %d virtualY %d", - pScrn->virtualX, pScrn->virtualY)); + LLOGLN(0, ("rdpScreenInit: virtualX %d virtualY %d rgbBits %d depth %d", + pScrn->virtualX, pScrn->virtualY, pScrn->rgbBits, pScrn->depth)); - dev->depth = 24; + dev->depth = pScrn->depth; dev->paddedWidthInBytes = PixmapBytePad(dev->width, dev->depth); - dev->bitsPerPixel = 32; + dev->bitsPerPixel = rdpBitsPerPixel(dev->depth); dev->sizeInBytes = dev->paddedWidthInBytes * dev->height; - LLOGLN(0, ("pfbMemory bytes %d", dev->sizeInBytes)); + LLOGLN(0, ("rdpScreenInit: pfbMemory bytes %d", dev->sizeInBytes)); dev->pfbMemory = (char *) malloc(dev->sizeInBytes); if (!fbScreenInit(pScreen, dev->pfbMemory, pScrn->virtualX, pScrn->virtualY, -- cgit v1.2.3 From 058e2ecd2824475bb3866c89bab24cefab1b7f06 Mon Sep 17 00:00:00 2001 From: Jay Sorg Date: Sat, 20 Jul 2013 15:11:54 -0700 Subject: xorg driver, added region files, misc, cleanup --- xorg/server/module/Makefile | 2 +- xorg/server/module/rdpDraw.c | 22 --- xorg/server/module/rdpDraw.h | 2 - xorg/server/module/rdpMisc.c | 415 ++++++++++++++++++++++++++++++++++++++++++ xorg/server/module/rdpMisc.h | 78 ++++++++ xorg/server/module/rdpPri.c | 7 +- xorg/server/module/rdpRandR.c | 14 +- xorg/server/module/rdpReg.c | 233 ++++++++++++++++++++++++ xorg/server/module/rdpReg.h | 60 ++++++ xorg/server/xrdpdev/xrdpdev.c | 65 ++++--- 10 files changed, 834 insertions(+), 64 deletions(-) create mode 100644 xorg/server/module/rdpMisc.c create mode 100644 xorg/server/module/rdpMisc.h create mode 100644 xorg/server/module/rdpReg.c create mode 100644 xorg/server/module/rdpReg.h (limited to 'xorg/server/module/rdpPri.c') diff --git a/xorg/server/module/Makefile b/xorg/server/module/Makefile index 7ee49277..3662b218 100644 --- a/xorg/server/module/Makefile +++ b/xorg/server/module/Makefile @@ -4,7 +4,7 @@ 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 \ -rdpCursor.o rdpMain.o rdpRandR.o +rdpCursor.o rdpMain.o rdpRandR.o rdpMisc.o rdpReg.o CFLAGS = -g -O2 -Wall -fPIC -I/usr/include/xorg -I/usr/include/pixman-1 diff --git a/xorg/server/module/rdpDraw.c b/xorg/server/module/rdpDraw.c index 4de9fa9f..7abcb406 100644 --- a/xorg/server/module/rdpDraw.c +++ b/xorg/server/module/rdpDraw.c @@ -146,25 +146,3 @@ rdpGetRootWindowPtr(ScreenPtr pScreen) return pScreen->root; #endif } - -/******************************************************************************/ -int -rdpBitsPerPixel(int depth) -{ - if (depth == 1) - { - return 1; - } - else if (depth <= 8) - { - return 8; - } - else if (depth <= 16) - { - return 16; - } - else - { - return 32; - } -} diff --git a/xorg/server/module/rdpDraw.h b/xorg/server/module/rdpDraw.h index 632a7467..ba696541 100644 --- a/xorg/server/module/rdpDraw.h +++ b/xorg/server/module/rdpDraw.h @@ -66,7 +66,5 @@ Bool rdpCloseScreen(int index, ScreenPtr pScreen); WindowPtr rdpGetRootWindowPtr(ScreenPtr pScreen); -int -rdpBitsPerPixel(int depth); #endif diff --git a/xorg/server/module/rdpMisc.c b/xorg/server/module/rdpMisc.c new file mode 100644 index 00000000..34e71110 --- /dev/null +++ b/xorg/server/module/rdpMisc.c @@ -0,0 +1,415 @@ +/* +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. + +the rest + +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/* this should be before all X11 .h files */ +#include + +/* all driver need this */ +#include +#include + +/******************************************************************************/ +int +rdpBitsPerPixel(int depth) +{ + if (depth == 1) + { + return 1; + } + else if (depth <= 8) + { + return 8; + } + else if (depth <= 16) + { + return 16; + } + else + { + return 32; + } +} + +/* the g_ functions from os_calls.c */ + +/*****************************************************************************/ +int +g_tcp_recv(int sck, void *ptr, int len, int flags) +{ + return recv(sck, ptr, len, flags); +} + +/*****************************************************************************/ +void +g_tcp_close(int sck) +{ + if (sck == 0) + { + return; + } + + shutdown(sck, 2); + close(sck); +} + +/*****************************************************************************/ +int +g_tcp_last_error_would_block(int sck) +{ + return (errno == EWOULDBLOCK) || (errno == EINPROGRESS); +} + +/*****************************************************************************/ +void +g_sleep(int msecs) +{ + usleep(msecs * 1000); +} + +/*****************************************************************************/ +int +g_tcp_send(int sck, void *ptr, int len, int flags) +{ + return send(sck, ptr, len, flags); +} + +/*****************************************************************************/ +void * +g_malloc(int size, int zero) +{ + char *rv; + + rv = (char *)malloc(size); + if (zero) + { + if (rv != 0) + { + memset(rv, 0, size); + } + } + return rv; +} + +/*****************************************************************************/ +void +g_free(void *ptr) +{ + if (ptr != 0) + { + free(ptr); + } +} + +/*****************************************************************************/ +void +g_sprintf(char *dest, char *format, ...) +{ + va_list ap; + + va_start(ap, format); + vsprintf(dest, format, ap); + va_end(ap); +} + +/*****************************************************************************/ +int +g_tcp_socket(void) +{ + int rv; + int i; + + i = 1; + rv = socket(PF_INET, SOCK_STREAM, 0); + setsockopt(rv, IPPROTO_TCP, TCP_NODELAY, (void *)&i, sizeof(i)); + setsockopt(rv, SOL_SOCKET, SO_REUSEADDR, (void *)&i, sizeof(i)); + return rv; +} + +/*****************************************************************************/ +int +g_tcp_local_socket_dgram(void) +{ + return socket(AF_UNIX, SOCK_DGRAM, 0); +} + +/*****************************************************************************/ +int +g_tcp_local_socket_stream(void) +{ + return socket(AF_UNIX, SOCK_STREAM, 0); +} + +/*****************************************************************************/ +void +g_memcpy(void *d_ptr, const void *s_ptr, int size) +{ + memcpy(d_ptr, s_ptr, size); +} + +/*****************************************************************************/ +void +g_memset(void *d_ptr, const unsigned char chr, int size) +{ + memset(d_ptr, chr, size); +} + +/*****************************************************************************/ +int +g_tcp_set_no_delay(int sck) +{ + int i; + + i = 1; + setsockopt(sck, IPPROTO_TCP, TCP_NODELAY, (void *)&i, sizeof(i)); + return 0; +} + +/*****************************************************************************/ +int +g_tcp_set_non_blocking(int sck) +{ + unsigned long i; + + i = fcntl(sck, F_GETFL); + i = i | O_NONBLOCK; + fcntl(sck, F_SETFL, i); + return 0; +} + +/*****************************************************************************/ +int +g_tcp_accept(int sck) +{ + struct sockaddr_in s; + unsigned int i; + + i = sizeof(struct sockaddr_in); + memset(&s, 0, i); + return accept(sck, (struct sockaddr *)&s, &i); +} + +/*****************************************************************************/ +int +g_tcp_select(int sck1, int sck2, int sck3) +{ + fd_set rfds; + struct timeval time; + int max; + int rv; + + time.tv_sec = 0; + time.tv_usec = 0; + FD_ZERO(&rfds); + + if (sck1 > 0) + { + FD_SET(((unsigned int)sck1), &rfds); + } + + if (sck2 > 0) + { + FD_SET(((unsigned int)sck2), &rfds); + } + + if (sck3 > 0) + { + FD_SET(((unsigned int)sck3), &rfds); + } + + max = sck1; + + if (sck2 > max) + { + max = sck2; + } + + if (sck3 > max) + { + max = sck3; + } + + rv = select(max + 1, &rfds, 0, 0, &time); + + if (rv > 0) + { + rv = 0; + + if (FD_ISSET(((unsigned int)sck1), &rfds)) + { + rv = rv | 1; + } + + if (FD_ISSET(((unsigned int)sck2), &rfds)) + { + rv = rv | 2; + } + + if (FD_ISSET(((unsigned int)sck3), &rfds)) + { + rv = rv | 4; + } + } + else + { + rv = 0; + } + + return rv; +} + +/*****************************************************************************/ +int +g_tcp_bind(int sck, char *port) +{ + struct sockaddr_in s; + + memset(&s, 0, sizeof(struct sockaddr_in)); + s.sin_family = AF_INET; + s.sin_port = htons(atoi(port)); + s.sin_addr.s_addr = INADDR_ANY; + return bind(sck, (struct sockaddr *)&s, sizeof(struct sockaddr_in)); +} + +/*****************************************************************************/ +int +g_tcp_local_bind(int sck, char *port) +{ + struct sockaddr_un s; + + memset(&s, 0, sizeof(struct sockaddr_un)); + s.sun_family = AF_UNIX; + strcpy(s.sun_path, port); + return bind(sck, (struct sockaddr *)&s, sizeof(struct sockaddr_un)); +} + +/*****************************************************************************/ +int +g_tcp_listen(int sck) +{ + return listen(sck, 2); +} + +/*****************************************************************************/ +/* returns boolean */ +int +g_create_dir(const char *dirname) +{ + return mkdir(dirname, (mode_t) - 1) == 0; +} + +/*****************************************************************************/ +/* returns boolean, non zero if the directory exists */ +int +g_directory_exist(const char *dirname) +{ + struct stat st; + + if (stat(dirname, &st) == 0) + { + return S_ISDIR(st.st_mode); + } + else + { + return 0; + } +} + +/*****************************************************************************/ +/* returns error */ +int +g_chmod_hex(const char *filename, int flags) +{ + int fl; + + fl = 0; + fl |= (flags & 0x4000) ? S_ISUID : 0; + fl |= (flags & 0x2000) ? S_ISGID : 0; + fl |= (flags & 0x1000) ? S_ISVTX : 0; + fl |= (flags & 0x0400) ? S_IRUSR : 0; + fl |= (flags & 0x0200) ? S_IWUSR : 0; + fl |= (flags & 0x0100) ? S_IXUSR : 0; + fl |= (flags & 0x0040) ? S_IRGRP : 0; + fl |= (flags & 0x0020) ? S_IWGRP : 0; + fl |= (flags & 0x0010) ? S_IXGRP : 0; + fl |= (flags & 0x0004) ? S_IROTH : 0; + fl |= (flags & 0x0002) ? S_IWOTH : 0; + fl |= (flags & 0x0001) ? S_IXOTH : 0; + return chmod(filename, fl); +} + +/*****************************************************************************/ +/* produce a hex dump */ +void +g_hexdump(unsigned char *p, unsigned int len) +{ + unsigned char *line; + int i; + int thisline; + int offset; + + offset = 0; + line = p; + + while (offset < len) + { + ErrorF("%04x ", offset); + thisline = len - offset; + + if (thisline > 16) + { + thisline = 16; + } + + for (i = 0; i < thisline; i++) + { + ErrorF("%02x ", line[i]); + } + + for (; i < 16; i++) + { + ErrorF(" "); + } + + for (i = 0; i < thisline; i++) + { + ErrorF("%c", (line[i] >= 0x20 && line[i] < 0x7f) ? line[i] : '.'); + } + + ErrorF("\n"); + offset += thisline; + line += thisline; + } +} diff --git a/xorg/server/module/rdpMisc.h b/xorg/server/module/rdpMisc.h new file mode 100644 index 00000000..8318f7bd --- /dev/null +++ b/xorg/server/module/rdpMisc.h @@ -0,0 +1,78 @@ +/* +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. + +the rest + +*/ + +#ifndef __RDPMISC_H +#define __RDPMISC_H + +int +rdpBitsPerPixel(int depth); +int +g_tcp_recv(int sck, void *ptr, int len, int flags); +void +g_tcp_close(int sck); +int +g_tcp_last_error_would_block(int sck); +void +g_sleep(int msecs); +int +g_tcp_send(int sck, void *ptr, int len, int flags); +void * +g_malloc(int size, int zero); +void +g_free(void *ptr); +void +g_sprintf(char *dest, char *format, ...); +int +g_tcp_socket(void); +int +g_tcp_local_socket_dgram(void); +int +g_tcp_local_socket_stream(void); +void +g_memcpy(void *d_ptr, const void *s_ptr, int size); +void +g_memset(void *d_ptr, const unsigned char chr, int size); +int +g_tcp_set_no_delay(int sck); +int +g_tcp_set_non_blocking(int sck); +int +g_tcp_accept(int sck); +int +g_tcp_select(int sck1, int sck2, int sck3); +int +g_tcp_bind(int sck, char *port); +int +g_tcp_local_bind(int sck, char *port); +int +g_tcp_listen(int sck); +int +g_create_dir(const char *dirname); +int +g_directory_exist(const char *dirname); +int +g_chmod_hex(const char *filename, int flags); +void +g_hexdump(unsigned char *p, unsigned int len); + +#endif diff --git a/xorg/server/module/rdpPri.c b/xorg/server/module/rdpPri.c index 3de181a8..43f3d883 100644 --- a/xorg/server/module/rdpPri.c +++ b/xorg/server/module/rdpPri.c @@ -38,6 +38,7 @@ to deal with privates changing in xorg versions #include #include "rdpPri.h" +#include "rdpMisc.h" #if XORG_VERSION_CURRENT < (((1) * 10000000) + ((5) * 100000) + ((0) * 1000) + 0) /* 1.1, 1.2, 1.3, 1.4 */ @@ -167,9 +168,9 @@ int rdpPrivateInit(void) { #if XRDP_PRI == 3 - memset(&g_privateKeyRecGC, 0, sizeof(g_privateKeyRecGC)); - memset(&g_privateKeyRecWindow, 0, sizeof(g_privateKeyRecWindow)); - memset(&g_privateKeyRecPixmap, 0, sizeof(g_privateKeyRecPixmap)); + g_memset(&g_privateKeyRecGC, 0, sizeof(g_privateKeyRecGC)); + g_memset(&g_privateKeyRecWindow, 0, sizeof(g_privateKeyRecWindow)); + g_memset(&g_privateKeyRecPixmap, 0, sizeof(g_privateKeyRecPixmap)); #endif return 0; } diff --git a/xorg/server/module/rdpRandR.c b/xorg/server/module/rdpRandR.c index 82de2f2e..e5ce814b 100644 --- a/xorg/server/module/rdpRandR.c +++ b/xorg/server/module/rdpRandR.c @@ -39,6 +39,8 @@ RandR draw calls #include "rdp.h" #include "rdpDraw.h" +#include "rdpReg.h" +#include "rdpMisc.h" /******************************************************************************/ #define LOG_LEVEL 1 @@ -120,8 +122,8 @@ rdpRRScreenSetSize(ScreenPtr pScreen, CARD16 width, CARD16 height, pScreen->mmWidth = mmWidth; pScreen->mmHeight = mmHeight; screenPixmap = pScreen->GetScreenPixmap(pScreen); - free(dev->pfbMemory); - dev->pfbMemory = (char *) malloc(dev->sizeInBytes); + g_free(dev->pfbMemory); + dev->pfbMemory = (char *) g_malloc(dev->sizeInBytes, 1); if (screenPixmap != 0) { pScreen->ModifyPixmapHeader(screenPixmap, width, height, @@ -133,10 +135,10 @@ rdpRRScreenSetSize(ScreenPtr pScreen, CARD16 width, CARD16 height, box.y1 = 0; box.x2 = width; box.y2 = height; - REGION_INIT(pScreen, &root->winSize, &box, 1); - REGION_INIT(pScreen, &root->borderSize, &box, 1); - REGION_RESET(pScreen, &root->borderClip, &box); - REGION_BREAK(pScreen, &root->clipList); + rdpRegionInit(&root->winSize, &box, 1); + rdpRegionInit(&root->borderSize, &box, 1); + rdpRegionReset(&root->borderClip, &box); + rdpRegionBreak(&root->clipList); root->drawable.width = width; root->drawable.height = height; ResizeChildrenWinSize(root, 0, 0, 0, 0); diff --git a/xorg/server/module/rdpReg.c b/xorg/server/module/rdpReg.c new file mode 100644 index 00000000..3a343f14 --- /dev/null +++ b/xorg/server/module/rdpReg.c @@ -0,0 +1,233 @@ +/* +Copyright 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. + +to deal with regions changing in xorg versions + +*/ +#include +#include +#include + +/* this should be before all X11 .h files */ +#include + +/* all driver need this */ +#include +#include + +/* +miRegionCopy -> RegionCopy +miTranslateRegion -> RegionTranslate +miRegionNotEmpty -> RegionNotEmpty +miIntersect -> RegionIntersect +miRectIn -> RegionContainsRect +miRegionInit -> RegionInit +miRegionUninit -> RegionUninit +miRectsToRegion -> RegionFromRects +miRegionDestroy -> RegionDestroy +miRegionCreate -> RegionCreate +miUnion -> RegionUnion +miRegionExtents -> RegionExtents +miRegionReset -> RegionReset +miRegionBreak -> RegionBreak +*/ + +#if XORG_VERSION_CURRENT < (((1) * 10000000) + ((9) * 100000) + ((0) * 1000) + 0) +/* 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8 */ +#define XRDP_REG 1 +#else +/* 1.9, 1.10, 1.11, 1.12 */ +#define XRDP_REG 2 +#endif + +/*****************************************************************************/ +Bool +rdpRegionCopy(RegionPtr dst, RegionPtr src) +{ +#if XRDP_REG == 1 + return miRegionCopy(dst, src); +#else + return RegionCopy(dst, src); +#endif +} + +/*****************************************************************************/ +void +rdpRegionTranslate(RegionPtr pReg, int x, int y) +{ +#if XRDP_REG == 1 + miTranslateRegion(pReg, x, y); +#else + RegionTranslate(pReg, x, y); +#endif +} + +/*****************************************************************************/ +Bool +rdpRegionNotEmpty(RegionPtr pReg) +{ +#if XRDP_REG == 1 + return miRegionNotEmpty(pReg); +#else + return RegionNotEmpty(pReg); +#endif +} + +/*****************************************************************************/ +Bool +rdpRegionIntersect(RegionPtr newReg, RegionPtr reg1, RegionPtr reg2) +{ +#if XRDP_REG == 1 + return miIntersect(newReg, reg1, reg2); +#else + return RegionIntersect(newReg, reg1, reg2); +#endif +} + +/*****************************************************************************/ +int +rdpRegionContainsRect(RegionPtr region, BoxPtr prect) +{ +#if XRDP_REG == 1 + return miRectIn(region, prect); +#else + return RegionContainsRect(region, prect); +#endif +} + +/*****************************************************************************/ +void +rdpRegionInit(RegionPtr pReg, BoxPtr rect, int size) +{ +#if XRDP_REG == 1 + miRegionInit(pReg, rect, size); +#else + RegionInit(pReg, rect, size); +#endif +} + +/*****************************************************************************/ +void +rdpRegionUninit(RegionPtr pReg) +{ +#if XRDP_REG == 1 + miRegionUninit(pReg); +#else + RegionUninit(pReg); +#endif +} + +/*****************************************************************************/ +RegionPtr +rdpRegionFromRects(int nrects, xRectanglePtr prect, int ctype) +{ +#if XRDP_REG == 1 + return miRectsToRegion(nrects, prect, ctype); +#else + return RegionFromRects(nrects, prect, ctype); +#endif +} + +/*****************************************************************************/ +void +rdpRegionDestroy(RegionPtr pReg) +{ +#if XRDP_REG == 1 + miRegionDestroy(pReg); +#else + RegionDestroy(pReg); +#endif +} + +/*****************************************************************************/ +RegionPtr +rdpRegionCreate(BoxPtr rect, int size) +{ +#if XRDP_REG == 1 + return miRegionCreate(rect, size); +#else + return RegionCreate(rect, size); +#endif +} + +/*****************************************************************************/ +Bool +rdpRegionUnion(RegionPtr newReg, RegionPtr reg1, RegionPtr reg2) +{ +#if XRDP_REG == 1 + return miUnion(newReg, reg1, reg2); +#else + return RegionUnion(newReg, reg1, reg2); +#endif +} + +/*****************************************************************************/ +Bool +rdpRegionSubtract(RegionPtr newReg, RegionPtr reg1, RegionPtr reg2) +{ +#if XRDP_REG == 1 + return miSubtract(newReg, reg1, reg2); +#else + return RegionSubtract(newReg, reg1, reg2); +#endif +} + +/*****************************************************************************/ +Bool +rdpRegionInverse(RegionPtr newReg, RegionPtr reg1, BoxPtr invRect) +{ +#if XRDP_REG == 1 + return miInverse(newReg, reg1, invRect); +#else + return RegionInverse(newReg, reg1, invRect); +#endif +} + +/*****************************************************************************/ +BoxPtr +rdpRegionExtents(RegionPtr pReg) +{ +#if XRDP_REG == 1 + return miRegionExtents(pReg); +#else + return RegionExtents(pReg); +#endif +} + +/*****************************************************************************/ +void +rdpRegionReset(RegionPtr pReg, BoxPtr pBox) +{ +#if XRDP_REG == 1 + miRegionReset(pReg, pBox); +#else + RegionReset(pReg, pBox); +#endif +} + +/*****************************************************************************/ +Bool +rdpRegionBreak(RegionPtr pReg) +{ +#if XRDP_REG == 1 + return miRegionBreak(pReg); +#else + return RegionBreak(pReg); +#endif +} diff --git a/xorg/server/module/rdpReg.h b/xorg/server/module/rdpReg.h new file mode 100644 index 00000000..b788cd69 --- /dev/null +++ b/xorg/server/module/rdpReg.h @@ -0,0 +1,60 @@ +/* +Copyright 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. + +to deal with regions changing in xorg versions + +*/ + +#ifndef __RDPREG_H +#define __RDPREG_H + +Bool +rdpRegionCopy(RegionPtr dst, RegionPtr src); +void +rdpRegionTranslate(RegionPtr pReg, int x, int y); +Bool +rdpRegionNotEmpty(RegionPtr pReg); +Bool +rdpRegionIntersect(RegionPtr newReg, RegionPtr reg1, RegionPtr reg2); +int +rdpRegionContainsRect(RegionPtr region, BoxPtr prect); +void +rdpRegionInit(RegionPtr pReg, BoxPtr rect, int size); +void +rdpRegionUninit(RegionPtr pReg); +RegionPtr +rdpRegionFromRects(int nrects, xRectanglePtr prect, int ctype); +void +rdpRegionDestroy(RegionPtr pReg); +RegionPtr +rdpRegionCreate(BoxPtr rect, int size); +Bool +rdpRegionUnion(RegionPtr newReg, RegionPtr reg1, RegionPtr reg2); +Bool +rdpRegionSubtract(RegionPtr newReg, RegionPtr reg1, RegionPtr reg2); +Bool +rdpRegionInverse(RegionPtr newReg, RegionPtr reg1, BoxPtr invRect); +BoxPtr +rdpRegionExtents(RegionPtr pReg); +void +rdpRegionReset(RegionPtr pReg, BoxPtr pBox); +Bool +rdpRegionBreak(RegionPtr pReg); + +#endif diff --git a/xorg/server/xrdpdev/xrdpdev.c b/xorg/server/xrdpdev/xrdpdev.c index bd80b75c..9e3095c2 100644 --- a/xorg/server/xrdpdev/xrdpdev.c +++ b/xorg/server/xrdpdev/xrdpdev.c @@ -44,6 +44,7 @@ This is the main driver file #include "rdpGC.h" #include "rdpCursor.h" #include "rdpRandR.h" +#include "rdpMisc.h" #define XRDP_DRIVER_NAME "XRDPDEV" #define XRDP_NAME "XRDPDEV" @@ -108,10 +109,11 @@ rdpAllocRec(ScrnInfoPtr pScrn) LLOGLN(10, ("rdpAllocRec:")); if (pScrn->driverPrivate != 0) { - return 1; + return TRUE; } + /* xnfcalloc exits if alloc failed */ pScrn->driverPrivate = xnfcalloc(sizeof(rdpRec), 1); - return 1; + return TRUE; } /*****************************************************************************/ @@ -141,11 +143,11 @@ rdpPreInit(ScrnInfoPtr pScrn, int flags) LLOGLN(0, ("rdpPreInit:")); if (flags & PROBE_DETECT) { - return 0; + return FALSE; } if (pScrn->numEntities != 1) { - return 0; + return FALSE; } rdpPrivateInit(); @@ -179,35 +181,35 @@ rdpPreInit(ScrnInfoPtr pScrn, int flags) { LLOGLN(0, ("rdpPreInit: xf86SetDepthBpp failed")); rdpFreeRec(pScrn); - return 0; + return FALSE; } xf86PrintDepthBpp(pScrn); - memset(&zeros1, 0, sizeof(zeros1)); + g_memset(&zeros1, 0, sizeof(zeros1)); if (!xf86SetWeight(pScrn, zeros1, zeros1)) { LLOGLN(0, ("rdpPreInit: xf86SetWeight failed")); rdpFreeRec(pScrn); - return 0; + return FALSE; } - memset(&zeros2, 0, sizeof(zeros2)); + g_memset(&zeros2, 0, sizeof(zeros2)); if (!xf86SetGamma(pScrn, zeros2)) { LLOGLN(0, ("rdpPreInit: xf86SetGamma failed")); rdpFreeRec(pScrn); - return 0; + return FALSE; } if (!xf86SetDefaultVisual(pScrn, -1)) { LLOGLN(0, ("rdpPreInit: xf86SetDefaultVisual failed")); rdpFreeRec(pScrn); - return 0; + return FALSE; } xf86SetDpi(pScrn, 0, 0); if (0 == pScrn->display->modes) { LLOGLN(0, ("rdpPreInit: modes error")); rdpFreeRec(pScrn); - return 0; + return FALSE; } pScrn->virtualX = pScrn->display->virtualX; @@ -255,11 +257,12 @@ rdpPreInit(ScrnInfoPtr pScrn, int flags) { LLOGLN(0, ("rdpPreInit: could not find screen resolution %dx%d", dev->width, dev->height)); - return 0; + return FALSE; } - return 1; + return TRUE; } +/******************************************************************************/ static miPointerSpriteFuncRec g_rdpSpritePointerFuncs = { /* these are in rdpCursor.c */ @@ -276,7 +279,7 @@ static Bool rdpSaveScreen(ScreenPtr pScreen, int on) { LLOGLN(0, ("rdpSaveScreen:")); - return 1; + return TRUE; } /******************************************************************************/ @@ -295,7 +298,7 @@ rdpResizeSession(rdpPtr dev, int width, int height) pSize = RRRegisterSize(dev->pScreen, width, height, mmwidth, mmheight); RRSetCurrentConfig(dev->pScreen, RR_Rotate_0, 0, pSize); - ok = 1; + ok = TRUE; if ((dev->width != width) || (dev->height != height)) { LLOGLN(0, (" calling RRScreenSizeSet")); @@ -306,6 +309,7 @@ rdpResizeSession(rdpPtr dev, int width, int height) } /******************************************************************************/ +/* returns error */ static CARD32 rdpDeferredRandR(OsTimerPtr timer, CARD32 now, pointer arg) { @@ -384,7 +388,7 @@ rdpScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv) ScrnInfoPtr pScrn; rdpPtr dev; VisualPtr vis; - int vis_found; + Bool vis_found; pScrn = xf86Screens[scrnIndex]; dev = XRDPPTR(pScrn); @@ -403,14 +407,14 @@ rdpScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv) dev->bitsPerPixel = rdpBitsPerPixel(dev->depth); dev->sizeInBytes = dev->paddedWidthInBytes * dev->height; LLOGLN(0, ("rdpScreenInit: pfbMemory bytes %d", dev->sizeInBytes)); - dev->pfbMemory = (char *) malloc(dev->sizeInBytes); + dev->pfbMemory = (char *) g_malloc(dev->sizeInBytes, 1); if (!fbScreenInit(pScreen, dev->pfbMemory, pScrn->virtualX, pScrn->virtualY, pScrn->xDpi, pScrn->yDpi, pScrn->displayWidth, pScrn->bitsPerPixel)) { LLOGLN(0, ("rdpScreenInit: fbScreenInit failed")); - return 0; + return FALSE; } miInitializeBackingStore(pScreen); @@ -456,20 +460,20 @@ rdpScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv) /* must assign this one */ pScreen->SaveScreen = rdpSaveScreen; - vis_found = 0; + vis_found = FALSE; vis = pScreen->visuals + (pScreen->numVisuals - 1); while (vis >= pScreen->visuals) { if (vis->vid == pScreen->rootVisual) { - vis_found = 1; + vis_found = TRUE; } vis--; } if (!vis_found) { LLOGLN(0, ("rdpScreenInit: no root visual")); - return 0; + return FALSE; } dev->privateKeyRecGC = rdpAllocateGCPrivate(pScreen, sizeof(rdpGCRec)); @@ -493,7 +497,7 @@ rdpScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv) g_timer = TimerSet(g_timer, 0, 10, rdpDeferredRandR, pScreen); LLOGLN(0, ("rdpScreenInit: out")); - return 1; + return TRUE; } /*****************************************************************************/ @@ -501,7 +505,7 @@ static Bool rdpSwitchMode(int a, DisplayModePtr b, int c) { LLOGLN(0, ("rdpSwitchMode:")); - return 1; + return TRUE; } /*****************************************************************************/ @@ -516,7 +520,7 @@ static Bool rdpEnterVT(int a, int b) { LLOGLN(0, ("rdpEnterVT:")); - return 1; + return TRUE; } /*****************************************************************************/ @@ -548,24 +552,24 @@ rdpProbe(DriverPtr drv, int flags) LLOGLN(0, ("rdpProbe:")); if (flags & PROBE_DETECT) { - return 0; + return FALSE; } /* fbScreenInit, fbPictureInit, ... */ if (!xf86LoadDrvSubModule(drv, "fb")) { LLOGLN(0, ("rdpProbe: xf86LoadDrvSubModule for fb failed")); - return 0; + return FALSE; } num_dev_sections = xf86MatchDevice(XRDP_DRIVER_NAME, &dev_sections); if (num_dev_sections <= 0) { LLOGLN(0, ("rdpProbe: xf86MatchDevice failed")); - return 0; + return FALSE; } pscrn = 0; - found_screen = 0; + found_screen = FALSE; for (i = 0; i < num_dev_sections; i++) { entity = xf86ClaimFbSlot(drv, 0, dev_sections[i], 1); @@ -612,13 +616,13 @@ rdpDriverFunc(ScrnInfoPtr pScrn, xorgDriverFuncOp op, pointer ptr) xorgHWFlags *flags; int rv; - rv = 0; + rv = FALSE; LLOGLN(0, ("rdpDriverFunc: op %d", (int)op)); if (op == GET_REQUIRED_HW_INTERFACES) { flags = (xorgHWFlags *) ptr; *flags = HW_SKIP_CONSOLE; - rv = 1; + rv = TRUE; } return rv; } @@ -631,6 +635,7 @@ rdpIdentify(int flags) xf86PrintChipsets(XRDP_NAME, "driver for xrdp", g_Chipsets); } +/*****************************************************************************/ _X_EXPORT DriverRec g_DriverRec = { XRDP_VERSION, -- cgit v1.2.3