xorg driver, work on randr

ulab-next
Jay Sorg 12 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"
#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;

@ -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;
}
}

@ -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

@ -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));

@ -38,23 +38,13 @@ RandR draw calls
#include <mi.h>
#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,

@ -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,

Loading…
Cancel
Save