xorg driver, work on randr

ulab-next
Jay Sorg 11 years ago
parent a8c42c51c1
commit 2ad9b26c21

@ -30,6 +30,9 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include "rdpPri.h" #include "rdpPri.h"
#define PixelDPI 100
#define PixelToMM(_size) (((_size) * 254 + (PixelDPI) * 5) / ((PixelDPI) * 10))
/* move this to common header */ /* move this to common header */
struct _rdpRec struct _rdpRec
{ {
@ -50,6 +53,7 @@ struct _rdpRec
CreatePixmapProcPtr CreatePixmap; CreatePixmapProcPtr CreatePixmap;
DestroyPixmapProcPtr DestroyPixmap; DestroyPixmapProcPtr DestroyPixmap;
ModifyPixmapHeaderProcPtr ModifyPixmapHeader; ModifyPixmapHeaderProcPtr ModifyPixmapHeader;
CloseScreenProcPtr CloseScreen;
miPointerScreenFuncPtr pCursorFuncs; miPointerScreenFuncPtr pCursorFuncs;

@ -118,3 +118,53 @@ rdpCopyWindow(WindowPtr pWin, DDXPointRec ptOldOrg, RegionPtr pOldRegion)
dev->pScreen->CopyWindow(pWin, ptOldOrg, pOldRegion); dev->pScreen->CopyWindow(pWin, ptOldOrg, pOldRegion);
dev->pScreen->CopyWindow = rdpCopyWindow; 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;
}
}

@ -62,5 +62,11 @@ rdpModifyPixmapHeader(PixmapPtr pPixmap, int width, int height, int depth,
int bitsPerPixel, int devKind, pointer pPixData); int bitsPerPixel, int devKind, pointer pPixData);
void void
rdpCopyWindow(WindowPtr pWin, DDXPointRec ptOldOrg, RegionPtr pOldRegion); rdpCopyWindow(WindowPtr pWin, DDXPointRec ptOldOrg, RegionPtr pOldRegion);
Bool
rdpCloseScreen(int index, ScreenPtr pScreen);
WindowPtr
rdpGetRootWindowPtr(ScreenPtr pScreen);
int
rdpBitsPerPixel(int depth);
#endif #endif

@ -39,23 +39,25 @@ to deal with privates changing in xorg versions
#include "rdpPri.h" #include "rdpPri.h"
/* not sure if these versions are right */ #if XORG_VERSION_CURRENT < (((1) * 10000000) + ((5) * 100000) + ((0) * 1000) + 0)
#if XORG_VERSION_CURRENT < (((1) * 10000000) + ((5) * 100000) + ((1) * 1000) + 0) /* 1.1, 1.2, 1.3, 1.4 */
#define FBDEV_PRI 1 #define XRDP_PRI 1
#elif XORG_VERSION_CURRENT < (((1) * 10000000) + ((7) * 100000) + ((7) * 1000) + 1) #elif XORG_VERSION_CURRENT < (((1) * 10000000) + ((9) * 100000) + ((0) * 1000) + 0)
#define FBDEV_PRI 2 /* 1.5, 1.6, 1.7, 1.8 */
#define XRDP_PRI 2
#else #else
#define FBDEV_PRI 3 /* 1.9, 1.10, 1.11, 1.12 */
#define XRDP_PRI 3
#endif #endif
#define PTR2INT(_ptr) ((int) ((long) ((void*) (_ptr)))) #define PTR2INT(_ptr) ((int) ((long) ((void*) (_ptr))))
#define INT2PTR(_int) ((void *) ((long) ((int) (_int)))) #define INT2PTR(_int) ((void *) ((long) ((int) (_int))))
#if FBDEV_PRI == 3 #if XRDP_PRI == 3
static DevPrivateKeyRec g_privateKeyRecGC; static DevPrivateKeyRec g_privateKeyRecGC;
static DevPrivateKeyRec g_privateKeyRecPixmap; static DevPrivateKeyRec g_privateKeyRecPixmap;
static DevPrivateKeyRec g_privateKeyRecWindow; static DevPrivateKeyRec g_privateKeyRecWindow;
#elif FBDEV_PRI == 2 #elif XRDP_PRI == 2
static int g_privateKeyRecGC = 0; static int g_privateKeyRecGC = 0;
static int g_privateKeyRecPixmap = 0; static int g_privateKeyRecPixmap = 0;
static int g_privateKeyRecWindow = 0; static int g_privateKeyRecWindow = 0;
@ -67,10 +69,10 @@ rdpAllocateGCPrivate(ScreenPtr pScreen, int bytes)
{ {
rdpDevPrivateKey rv; rdpDevPrivateKey rv;
#if FBDEV_PRI == 1 #if XRDP_PRI == 1
rv = INT2PTR(AllocateGCPrivateIndex()); rv = INT2PTR(AllocateGCPrivateIndex());
AllocateGCPrivate(pScreen, PTR2INT(rv), bytes); AllocateGCPrivate(pScreen, PTR2INT(rv), bytes);
#elif FBDEV_PRI == 2 #elif XRDP_PRI == 2
dixRequestPrivate(&g_privateKeyRecGC, bytes); dixRequestPrivate(&g_privateKeyRecGC, bytes);
rv = &g_privateKeyRecGC; rv = &g_privateKeyRecGC;
#else #else
@ -86,10 +88,10 @@ rdpAllocatePixmapPrivate(ScreenPtr pScreen, int bytes)
{ {
rdpDevPrivateKey rv; rdpDevPrivateKey rv;
#if FBDEV_PRI == 1 #if XRDP_PRI == 1
rv = INT2PTR(AllocatePixmapPrivateIndex()); rv = INT2PTR(AllocatePixmapPrivateIndex());
AllocatePixmapPrivate(pScreen, PTR2INT(rv), bytes); AllocatePixmapPrivate(pScreen, PTR2INT(rv), bytes);
#elif FBDEV_PRI == 2 #elif XRDP_PRI == 2
dixRequestPrivate(&g_privateKeyRecPixmap, bytes); dixRequestPrivate(&g_privateKeyRecPixmap, bytes);
rv = &g_privateKeyRecPixmap; rv = &g_privateKeyRecPixmap;
#else #else
@ -105,10 +107,10 @@ rdpAllocateWindowPrivate(ScreenPtr pScreen, int bytes)
{ {
rdpDevPrivateKey rv; rdpDevPrivateKey rv;
#if FBDEV_PRI == 1 #if XRDP_PRI == 1
rv = INT2PTR(AllocateWindowPrivateIndex()); rv = INT2PTR(AllocateWindowPrivateIndex());
AllocateWindowPrivate(pScreen, PTR2INT(rv), bytes); AllocateWindowPrivate(pScreen, PTR2INT(rv), bytes);
#elif FBDEV_PRI == 2 #elif XRDP_PRI == 2
dixRequestPrivate(&g_privateKeyRecWindow, bytes); dixRequestPrivate(&g_privateKeyRecWindow, bytes);
rv = &g_privateKeyRecWindow; rv = &g_privateKeyRecWindow;
#else #else
@ -124,7 +126,7 @@ rdpGetGCPrivate(GCPtr pGC, rdpDevPrivateKey key)
{ {
void *rv; void *rv;
#if FBDEV_PRI == 1 #if XRDP_PRI == 1
rv = pGC->devPrivates[PTR2INT(key)].ptr; rv = pGC->devPrivates[PTR2INT(key)].ptr;
#else #else
rv = dixLookupPrivate(&(pGC->devPrivates), key); rv = dixLookupPrivate(&(pGC->devPrivates), key);
@ -138,7 +140,7 @@ rdpGetPixmapPrivate(PixmapPtr pPixmap, rdpDevPrivateKey key)
{ {
void *rv; void *rv;
#if FBDEV_PRI == 1 #if XRDP_PRI == 1
rv = pPixmap->devPrivates[PTR2INT(key)].ptr; rv = pPixmap->devPrivates[PTR2INT(key)].ptr;
#else #else
rv = dixLookupPrivate(&(pPixmap->devPrivates), key); rv = dixLookupPrivate(&(pPixmap->devPrivates), key);
@ -152,7 +154,7 @@ rdpGetWindowPrivate(WindowPtr pWindow, rdpDevPrivateKey key)
{ {
void *rv; void *rv;
#if FBDEV_PRI == 1 #if XRDP_PRI == 1
rv = pWindow->devPrivates[PTR2INT(key)].ptr; rv = pWindow->devPrivates[PTR2INT(key)].ptr;
#else #else
rv = dixLookupPrivate(&(pWindow->devPrivates), key); rv = dixLookupPrivate(&(pWindow->devPrivates), key);
@ -164,7 +166,7 @@ rdpGetWindowPrivate(WindowPtr pWindow, rdpDevPrivateKey key)
int int
rdpPrivateInit(void) rdpPrivateInit(void)
{ {
#if FBDEV_PRI == 3 #if XRDP_PRI == 3
memset(&g_privateKeyRecGC, 0, sizeof(g_privateKeyRecGC)); memset(&g_privateKeyRecGC, 0, sizeof(g_privateKeyRecGC));
memset(&g_privateKeyRecWindow, 0, sizeof(g_privateKeyRecWindow)); memset(&g_privateKeyRecWindow, 0, sizeof(g_privateKeyRecWindow));
memset(&g_privateKeyRecPixmap, 0, sizeof(g_privateKeyRecPixmap)); memset(&g_privateKeyRecPixmap, 0, sizeof(g_privateKeyRecPixmap));

@ -38,23 +38,13 @@ RandR draw calls
#include <mi.h> #include <mi.h>
#include "rdp.h" #include "rdp.h"
#include "rdpDraw.h"
#define PixelDPI 100
#define PixelToMM(_size) (((_size) * 254 + (PixelDPI) * 5) / ((PixelDPI) * 10))
/******************************************************************************/ /******************************************************************************/
#define LOG_LEVEL 1 #define LOG_LEVEL 1
#define LLOGLN(_level, _args) \ #define LLOGLN(_level, _args) \
do { if (_level < LOG_LEVEL) { ErrorF _args ; ErrorF("\n"); } } while (0) do { if (_level < LOG_LEVEL) { ErrorF _args ; ErrorF("\n"); } } while (0)
/******************************************************************************/
static WindowPtr
rdpGetRootWindowPtr(ScreenPtr pScreen)
{
/* in globals.c */
return WindowTable[pScreen->myNum];
}
/******************************************************************************/ /******************************************************************************/
Bool Bool
rdpRRRegisterSize(ScreenPtr pScreen, int width, int height) 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, " LLOGLN(0, (" resizing screenPixmap [%p] to %dx%d, "
"currently at %dx%d", (void *)screenPixmap, width, height, "currently at %dx%d", (void *)screenPixmap, width, height,
screenPixmap->drawable.width, screenPixmap->drawable.height)); screenPixmap->drawable.width, screenPixmap->drawable.height));
free(dev->pfbMemory);
dev->pfbMemory = (char *) malloc(dev->sizeInBytes);
pScreen->ModifyPixmapHeader(screenPixmap, width, height, pScreen->ModifyPixmapHeader(screenPixmap, width, height,
dev->depth, dev->bitsPerPixel, dev->depth, dev->bitsPerPixel,
dev->paddedWidthInBytes, dev->paddedWidthInBytes,

@ -279,6 +279,32 @@ rdpSaveScreen(ScreenPtr pScreen, int on)
return 1; 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 static CARD32
rdpDeferredRandR(OsTimerPtr timer, CARD32 now, pointer arg) rdpDeferredRandR(OsTimerPtr timer, CARD32 now, pointer arg)
@ -287,6 +313,9 @@ rdpDeferredRandR(OsTimerPtr timer, CARD32 now, pointer arg)
rrScrPrivPtr pRRScrPriv; rrScrPrivPtr pRRScrPriv;
ScrnInfoPtr pScrn; ScrnInfoPtr pScrn;
rdpPtr dev; rdpPtr dev;
char *envvar;
int width;
int height;
pScreen = (ScreenPtr) arg; pScreen = (ScreenPtr) arg;
pScrn = xf86Screens[pScreen->myNum]; pScrn = xf86Screens[pScreen->myNum];
@ -325,6 +354,26 @@ rdpDeferredRandR(OsTimerPtr timer, CARD32 now, pointer arg)
pRRScrPriv->rrGetPanning = rdpRRGetPanning; pRRScrPriv->rrGetPanning = rdpRRGetPanning;
pRRScrPriv->rrSetPanning = rdpRRSetPanning; 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; return 0;
} }
@ -346,14 +395,14 @@ rdpScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv)
miSetVisualTypes(pScrn->depth, miGetDefaultVisualMask(pScrn->depth), miSetVisualTypes(pScrn->depth, miGetDefaultVisualMask(pScrn->depth),
pScrn->rgbBits, TrueColor); pScrn->rgbBits, TrueColor);
miSetPixmapDepths(); miSetPixmapDepths();
LLOGLN(0, ("rdpScreenInit: virtualX %d virtualY %d", LLOGLN(0, ("rdpScreenInit: virtualX %d virtualY %d rgbBits %d depth %d",
pScrn->virtualX, pScrn->virtualY)); pScrn->virtualX, pScrn->virtualY, pScrn->rgbBits, pScrn->depth));
dev->depth = 24; dev->depth = pScrn->depth;
dev->paddedWidthInBytes = PixmapBytePad(dev->width, dev->depth); dev->paddedWidthInBytes = PixmapBytePad(dev->width, dev->depth);
dev->bitsPerPixel = 32; dev->bitsPerPixel = rdpBitsPerPixel(dev->depth);
dev->sizeInBytes = dev->paddedWidthInBytes * dev->height; 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); dev->pfbMemory = (char *) malloc(dev->sizeInBytes);
if (!fbScreenInit(pScreen, dev->pfbMemory, if (!fbScreenInit(pScreen, dev->pfbMemory,
pScrn->virtualX, pScrn->virtualY, pScrn->virtualX, pScrn->virtualY,

Loading…
Cancel
Save