summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAlan Hourihane <alanh@fairlite.demon.co.uk>2005-05-20 15:24:02 +0000
committerAlan Hourihane <alanh@fairlite.demon.co.uk>2005-05-20 15:24:02 +0000
commit89ec4ac201c09329d5d732323bdce6250b8592fe (patch)
tree07fe847994c3ca21d927702c514ab558fd3edeff /src
parentdf0964ea8f92c6b278dd87b95380dbc3ada625e5 (diff)
Bugzilla #3292: https://bugs.freedesktop.org/show_bug.cgi?id=3292XORG-6_8_99_8
Add shadowFB support to the Intel driver (Dima Dorfman)
Diffstat (limited to 'src')
-rw-r--r--src/common.h1
-rw-r--r--src/i810_driver.c6
-rw-r--r--src/i830.h14
-rw-r--r--src/i830_driver.c99
-rw-r--r--src/i830_shadow.c249
5 files changed, 361 insertions, 8 deletions
diff --git a/src/common.h b/src/common.h
index dda5d36b..0d901f95 100644
--- a/src/common.h
+++ b/src/common.h
@@ -79,6 +79,7 @@ extern const char *I810vbeSymbols[];
extern const char *I810ddcSymbols[];
extern const char *I810fbSymbols[];
extern const char *I810xaaSymbols[];
+extern const char *I810shadowFBSymbols[];
#ifdef XF86DRI
extern const char *I810driSymbols[];
extern const char *I810drmSymbols[];
diff --git a/src/i810_driver.c b/src/i810_driver.c
index fe4ed5ec..98c26581 100644
--- a/src/i810_driver.c
+++ b/src/i810_driver.c
@@ -309,7 +309,7 @@ const char *I810driSymbols[] = {
#ifdef XF86DRI
-static const char *driShadowFBSymbols[] = {
+const char *I810shadowFBSymbols[] = {
"ShadowFBInit",
NULL
};
@@ -392,7 +392,7 @@ i810Setup(pointer module, pointer opts, int *errmaj, int *errmin)
I810drmSymbols,
I810driSymbols,
I810shadowSymbols,
- driShadowFBSymbols,
+ I810shadowFBSymbols,
#endif
I810vbeSymbols, vbeOptionalSymbols,
I810ddcSymbols, I810int10Symbols, NULL);
@@ -1089,7 +1089,7 @@ I810PreInit(ScrnInfoPtr pScrn, int flags)
"Couldn't load shadowfb module:\n");
}
else {
- xf86LoaderReqSymLists(driShadowFBSymbols, NULL);
+ xf86LoaderReqSymLists(I810shadowFBSymbols, NULL);
}
}
diff --git a/src/i830.h b/src/i830.h
index 5ff5045b..46b0210a 100644
--- a/src/i830.h
+++ b/src/i830.h
@@ -302,7 +302,15 @@ typedef struct _I830Rec {
drm_handle_t ring_map;
#endif
+ /* Broken-out options. */
OptionInfoPtr Options;
+ int rotate;
+ Bool shadowFB;
+
+ /* Support for shadowFB and rotation. */
+ unsigned char *shadowPtr;
+ int shadowPitch;
+ void (*PointerMoved)(int, int, int);
/* Stolen memory support */
Bool StolenOnly;
@@ -438,6 +446,12 @@ extern void I830UnsetModeParameters(ScrnInfoPtr pScrn, vbeInfoPtr pVbe);
extern void I830PrintModes(ScrnInfoPtr pScrn);
extern int I830GetBestRefresh(ScrnInfoPtr pScrn, int refresh);
extern Bool I830CheckModeSupport(ScrnInfoPtr pScrn, int x, int y, int mode);
+extern void I830PointerMoved(int index, int x, int y);
+extern void I830RefreshArea(ScrnInfoPtr pScrn, int num, BoxPtr pbox);
+extern void I830RefreshArea8(ScrnInfoPtr pScrn, int num, BoxPtr pbox);
+extern void I830RefreshArea16(ScrnInfoPtr pScrn, int num, BoxPtr pbox);
+extern void I830RefreshArea24(ScrnInfoPtr pScrn, int num, BoxPtr pbox);
+extern void I830RefreshArea32(ScrnInfoPtr pScrn, int num, BoxPtr pbox);
/*
* 12288 is set as the maximum, chosen because it is enough for
diff --git a/src/i830_driver.c b/src/i830_driver.c
index 85d3d739..fc02e549 100644
--- a/src/i830_driver.c
+++ b/src/i830_driver.c
@@ -160,6 +160,7 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
#include "vgaHW.h"
#include "mipointer.h"
#include "micmap.h"
+#include "shadowfb.h"
#include "fb.h"
#include "miscstruct.h"
@@ -223,7 +224,9 @@ typedef enum {
OPTION_CLONE,
OPTION_CLONE_REFRESH,
OPTION_CHECKDEVICES,
- OPTION_FIXEDPIPE
+ OPTION_FIXEDPIPE,
+ OPTION_SHADOW_FB,
+ OPTION_ROTATE
} I830Opts;
static OptionInfoRec I830BIOSOptions[] = {
@@ -243,6 +246,8 @@ static OptionInfoRec I830BIOSOptions[] = {
{OPTION_CLONE_REFRESH,"CloneRefresh",OPTV_INTEGER, {0}, FALSE},
{OPTION_CHECKDEVICES, "CheckDevices",OPTV_BOOLEAN, {0}, FALSE},
{OPTION_FIXEDPIPE, "FixedPipe", OPTV_ANYSTR, {0}, FALSE},
+ {OPTION_SHADOW_FB, "ShadowFB", OPTV_BOOLEAN, {0}, FALSE},
+ {OPTION_ROTATE, "Rotate", OPTV_ANYSTR, {0}, FALSE},
{-1, NULL, OPTV_NONE, {0}, FALSE}
};
/* *INDENT-ON* */
@@ -2427,6 +2432,37 @@ I830BIOSPreInit(ScrnInfoPtr pScrn, int flags)
}
}
+ xf86GetOptValBool(pI830->Options, OPTION_SHADOW_FB, &pI830->shadowFB);
+ if (pI830->shadowFB) {
+ xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "Option: shadow FB enabled\n");
+ }
+
+ if ((s = xf86GetOptValString(pI830->Options, OPTION_ROTATE))) {
+ if(!xf86NameCmp(s, "CW")) {
+ /* accel is disabled below for shadowFB */
+ pI830->shadowFB = TRUE;
+ pI830->rotate = 1;
+ xf86DrvMsg(pScrn->scrnIndex, X_CONFIG,
+ "Rotating screen clockwise - acceleration disabled\n");
+ } else if(!xf86NameCmp(s, "CCW")) {
+ pI830->shadowFB = TRUE;
+ pI830->rotate = -1;
+ xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "Rotating screen"
+ "counter clockwise - acceleration disabled\n");
+ } else {
+ xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "\"%s\" is not a valid"
+ "value for Option \"Rotate\"\n", s);
+ xf86DrvMsg(pScrn->scrnIndex, X_INFO,
+ "Valid options are \"CW\" or \"CCW\"\n");
+ }
+ }
+
+ if (pI830->shadowFB && !pI830->noAccel) {
+ xf86DrvMsg(pScrn->scrnIndex, X_WARNING,
+ "HW acceleration not supported with \"shadowFB\".\n");
+ pI830->noAccel = TRUE;
+ }
+
/*
* Let's setup the mobile systems to check the lid status
*/
@@ -3269,6 +3305,15 @@ I830BIOSPreInit(ScrnInfoPtr pScrn, int flags)
xf86SetOperatingState(resVgaIo, pI830->pEnt->index, ResUnusedOpr);
xf86SetOperatingState(resVgaMem, pI830->pEnt->index, ResDisableOpr);
+ if (pI830->shadowFB) {
+ if (!xf86LoadSubModule(pScrn, "shadowfb")) {
+ I830BIOSFreeRec(pScrn);
+ vbeFree(pI830->pVbe);
+ return FALSE;
+ }
+ xf86LoaderReqSymLists(I810shadowFBSymbols, NULL);
+ }
+
VBEFreeVBEInfo(pI830->vbeInfo);
pI830->vbeInfo = NULL;
vbeFree(pI830->pVbe);
@@ -4398,6 +4443,8 @@ I830BIOSScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv)
VisualPtr visual;
I830EntPtr pI830Ent = NULL;
I830Ptr pI8301 = NULL;
+ int width, height, displayWidth;
+ unsigned char *fbbase;
#ifdef XF86DRI
Bool driDisabled;
#endif
@@ -4632,10 +4679,26 @@ I830BIOSScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv)
return FALSE;
DPRINTF(PFX, "assert( if(!fbScreenInit(pScreen, ...) )\n");
- if (!fbScreenInit(pScreen, pI830->FbBase + pScrn->fbOffset,
- pScrn->virtualX, pScrn->virtualY,
+ if (pI830->rotate) {
+ height = pScrn->virtualX;
+ width = pScrn->virtualY;
+ } else {
+ width = pScrn->virtualX;
+ height = pScrn->virtualY;
+ }
+ if (pI830->shadowFB) {
+ pI830->shadowPitch = BitmapBytePad(pScrn->bitsPerPixel * width);
+ pI830->shadowPtr = xalloc(pI830->shadowPitch * height);
+ displayWidth = pI830->shadowPitch / (pScrn->bitsPerPixel >> 3);
+ fbbase = pI830->shadowPtr;
+ } else {
+ pI830->shadowPtr = NULL;
+ fbbase = pI830->FbBase;
+ displayWidth = pScrn->displayWidth;
+ }
+ if (!fbScreenInit(pScreen, fbbase + pScrn->fbOffset, width, height,
pScrn->xDpi, pScrn->yDpi,
- pScrn->displayWidth, pScrn->bitsPerPixel))
+ displayWidth, pScrn->bitsPerPixel))
return FALSE;
if (pScrn->bitsPerPixel > 8) {
@@ -4657,7 +4720,8 @@ I830BIOSScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv)
xf86SetBlackWhitePixels(pScreen);
- I830DGAInit(pScreen);
+ if (!pI830->shadowFB)
+ I830DGAInit(pScreen);
DPRINTF(PFX,
"assert( if(!xf86InitFBManager(pScreen, &(pI830->FbMemBox))) )\n");
@@ -4695,6 +4759,31 @@ I830BIOSScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv)
} else
xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Initializing SW Cursor!\n");
+ if (pI830->shadowFB) {
+ RefreshAreaFuncPtr refreshArea = I830RefreshArea;
+ if (pI830->rotate) {
+ if (!pI830->PointerMoved) {
+ pI830->PointerMoved = pScrn->PointerMoved;
+ pScrn->PointerMoved = I830PointerMoved;
+ }
+ switch (pScrn->bitsPerPixel) {
+ case 8:
+ refreshArea = I830RefreshArea8;
+ break;
+ case 16:
+ refreshArea = I830RefreshArea16;
+ break;
+ case 24:
+ refreshArea = I830RefreshArea24;
+ break;
+ case 32:
+ refreshArea = I830RefreshArea32;
+ break;
+ }
+ }
+ ShadowFBInit(pScreen, refreshArea);
+ }
+
DPRINTF(PFX, "assert( if(!miCreateDefColormap(pScreen)) )\n");
if (!miCreateDefColormap(pScreen))
return FALSE;
diff --git a/src/i830_shadow.c b/src/i830_shadow.c
new file mode 100644
index 00000000..d12604a0
--- /dev/null
+++ b/src/i830_shadow.c
@@ -0,0 +1,249 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/s3virge/s3v_shadow.c,v 1.3 2000/03/31 20:13:33 dawes Exp $ */
+
+/*
+ Copyright (c) 1999,2000 The XFree86 Project Inc.
+ based on code written by Mark Vojkovich <markv@valinux.com>
+*/
+
+/*
+ * Ported from the savage driver to the I830 by
+ * Helmar Spangenberg <hspangenberg@frey.de> and Dima Dorfman
+ */
+
+#include "xf86.h"
+#include "i830.h"
+#include "shadowfb.h"
+#include "servermd.h"
+
+
+void
+I830RefreshArea(ScrnInfoPtr pScrn, int num, BoxPtr pbox)
+{
+ I830Ptr pI830 = I830PTR(pScrn);
+ int width, height, Bpp, FBPitch;
+ unsigned char *src, *dst;
+
+ Bpp = pScrn->bitsPerPixel >> 3;
+ FBPitch = BitmapBytePad(pScrn->displayWidth * pScrn->bitsPerPixel);
+
+ while(num--) {
+ width = (pbox->x2 - pbox->x1) * Bpp;
+ height = pbox->y2 - pbox->y1;
+ src = pI830->shadowPtr + (pbox->y1 * pI830->shadowPitch) +
+ (pbox->x1 * Bpp);
+ dst = pI830->FbBase + (pbox->y1 * FBPitch) + (pbox->x1 * Bpp);
+
+ while(height--) {
+ memcpy(dst, src, width);
+ dst += FBPitch;
+ src += pI830->shadowPitch;
+ }
+
+ pbox++;
+ }
+}
+
+
+void
+I830PointerMoved(int index, int x, int y)
+{
+ ScrnInfoPtr pScrn = xf86Screens[index];
+ I830Ptr pI830 = I830PTR(pScrn);
+ int newX, newY;
+
+ if(pI830->rotate == 1) {
+ newX = pScrn->pScreen->height - y - 1;
+ newY = x;
+ } else {
+ newX = y;
+ newY = pScrn->pScreen->width - x - 1;
+ }
+
+ (*pI830->PointerMoved)(index, newX, newY);
+}
+
+void
+I830RefreshArea8(ScrnInfoPtr pScrn, int num, BoxPtr pbox)
+{
+ I830Ptr pI830 = I830PTR(pScrn);
+ int count, width, height, y1, y2, dstPitch, srcPitch;
+ CARD8 *dstPtr, *srcPtr, *src;
+ CARD32 *dst;
+
+ dstPitch = pScrn->displayWidth;
+ srcPitch = -pI830->rotate * pI830->shadowPitch;
+
+ while(num--) {
+ width = pbox->x2 - pbox->x1;
+ y1 = pbox->y1 & ~3;
+ y2 = (pbox->y2 + 3) & ~3;
+ height = (y2 - y1) >> 2; /* in dwords */
+
+ if(pI830->rotate == 1) {
+ dstPtr = pI830->FbBase +
+ (pbox->x1 * dstPitch) + pScrn->virtualX - y2;
+ srcPtr = pI830->shadowPtr + ((1 - y2) * srcPitch) + pbox->x1;
+ } else {
+ dstPtr = pI830->FbBase +
+ ((pScrn->virtualY - pbox->x2) * dstPitch) + y1;
+ srcPtr = pI830->shadowPtr + (y1 * srcPitch) + pbox->x2 - 1;
+ }
+
+ while(width--) {
+ src = srcPtr;
+ dst = (CARD32*)dstPtr;
+ count = height;
+ while(count--) {
+ *(dst++) = src[0] | (src[srcPitch] << 8) |
+ (src[srcPitch * 2] << 16) |
+ (src[srcPitch * 3] << 24);
+ src += srcPitch * 4;
+ }
+ srcPtr += pI830->rotate;
+ dstPtr += dstPitch;
+ }
+
+ pbox++;
+ }
+}
+
+
+void
+I830RefreshArea16(ScrnInfoPtr pScrn, int num, BoxPtr pbox)
+{
+ I830Ptr pI830 = I830PTR(pScrn);
+ int count, width, height, y1, y2, dstPitch, srcPitch;
+ CARD16 *dstPtr, *srcPtr, *src;
+ CARD32 *dst;
+
+ dstPitch = pScrn->displayWidth;
+ srcPitch = -pI830->rotate * pI830->shadowPitch >> 1;
+
+ while(num--) {
+ width = pbox->x2 - pbox->x1;
+ y1 = pbox->y1 & ~1;
+ y2 = (pbox->y2 + 1) & ~1;
+ height = (y2 - y1) >> 1; /* in dwords */
+
+ if(pI830->rotate == 1) {
+ dstPtr = (CARD16*)pI830->FbBase +
+ (pbox->x1 * dstPitch) + pScrn->virtualX - y2;
+ srcPtr = (CARD16*)pI830->shadowPtr +
+ ((1 - y2) * srcPitch) + pbox->x1;
+ } else {
+ dstPtr = (CARD16*)pI830->FbBase +
+ ((pScrn->virtualY - pbox->x2) * dstPitch) + y1;
+ srcPtr = (CARD16*)pI830->shadowPtr +
+ (y1 * srcPitch) + pbox->x2 - 1;
+ }
+
+ while(width--) {
+ src = srcPtr;
+ dst = (CARD32*)dstPtr;
+ count = height;
+ while(count--) {
+ *(dst++) = src[0] | (src[srcPitch] << 16);
+ src += srcPitch * 2;
+ }
+ srcPtr += pI830->rotate;
+ dstPtr += dstPitch;
+ }
+
+ pbox++;
+ }
+}
+
+
+/* this one could be faster */
+void
+I830RefreshArea24(ScrnInfoPtr pScrn, int num, BoxPtr pbox)
+{
+ I830Ptr pI830 = I830PTR(pScrn);
+ int count, width, height, y1, y2, dstPitch, srcPitch;
+ CARD8 *dstPtr, *srcPtr, *src;
+ CARD32 *dst;
+
+ dstPitch = BitmapBytePad(pScrn->displayWidth * 24);
+ srcPitch = -pI830->rotate * pI830->shadowPitch;
+
+ while(num--) {
+ width = pbox->x2 - pbox->x1;
+ y1 = pbox->y1 & ~3;
+ y2 = (pbox->y2 + 3) & ~3;
+ height = (y2 - y1) >> 2; /* blocks of 3 dwords */
+
+ if(pI830->rotate == 1) {
+ dstPtr = pI830->FbBase +
+ (pbox->x1 * dstPitch) + ((pScrn->virtualX - y2) * 3);
+ srcPtr = pI830->shadowPtr + ((1 - y2) * srcPitch) + (pbox->x1 * 3);
+ } else {
+ dstPtr = pI830->FbBase +
+ ((pScrn->virtualY - pbox->x2) * dstPitch) + (y1 * 3);
+ srcPtr = pI830->shadowPtr + (y1 * srcPitch) + (pbox->x2 * 3) - 3;
+ }
+
+ while(width--) {
+ src = srcPtr;
+ dst = (CARD32*)dstPtr;
+ count = height;
+ while(count--) {
+ dst[0] = src[0] | (src[1] << 8) | (src[2] << 16) |
+ (src[srcPitch] << 24);
+ dst[1] = src[srcPitch + 1] | (src[srcPitch + 2] << 8) |
+ (src[srcPitch * 2] << 16) |
+ (src[(srcPitch * 2) + 1] << 24);
+ dst[2] = src[(srcPitch * 2) + 2] | (src[srcPitch * 3] << 8) |
+ (src[(srcPitch * 3) + 1] << 16) |
+ (src[(srcPitch * 3) + 2] << 24);
+ dst += 3;
+ src += srcPitch * 4;
+ }
+ srcPtr += pI830->rotate * 3;
+ dstPtr += dstPitch;
+ }
+
+ pbox++;
+ }
+}
+
+void
+I830RefreshArea32(ScrnInfoPtr pScrn, int num, BoxPtr pbox)
+{
+ I830Ptr pI830 = I830PTR(pScrn);
+ int count, width, height, dstPitch, srcPitch;
+ CARD32 *dstPtr, *srcPtr, *src, *dst;
+
+ dstPitch = pScrn->displayWidth;
+ srcPitch = -pI830->rotate * pI830->shadowPitch >> 2;
+
+ while(num--) {
+ width = pbox->x2 - pbox->x1;
+ height = pbox->y2 - pbox->y1;
+
+ if(pI830->rotate == 1) {
+ dstPtr = (CARD32*)pI830->FbBase +
+ (pbox->x1 * dstPitch) + pScrn->virtualX - pbox->y2;
+ srcPtr = (CARD32*)pI830->shadowPtr +
+ ((1 - pbox->y2) * srcPitch) + pbox->x1;
+ } else {
+ dstPtr = (CARD32*)pI830->FbBase +
+ ((pScrn->virtualY - pbox->x2) * dstPitch) + pbox->y1;
+ srcPtr = (CARD32*)pI830->shadowPtr +
+ (pbox->y1 * srcPitch) + pbox->x2 - 1;
+ }
+
+ while(width--) {
+ src = srcPtr;
+ dst = dstPtr;
+ count = height;
+ while(count--) {
+ *(dst++) = *src;
+ src += srcPitch;
+ }
+ srcPtr += pI830->rotate;
+ dstPtr += dstPitch;
+ }
+
+ pbox++;
+ }
+}