summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorKaleb Keithley <kaleb@freedesktop.org>2003-11-25 19:28:37 +0000
committerKaleb Keithley <kaleb@freedesktop.org>2003-11-25 19:28:37 +0000
commit72063c52b82faf80a0183f66d2fd5789def76d8f (patch)
tree44777a8a902d417599c3e9abb0c70200e2aa274c /src
parente04a1a8f862eb63b546fb74e73ee602fefb82e00 (diff)
XFree86 4.3.99.16xf86-4_3_99_16
Bring the tree up to date for the Cygwin folks
Diffstat (limited to 'src')
-rw-r--r--src/common.h20
-rw-r--r--src/i810.h12
-rw-r--r--src/i810_accel.c2
-rw-r--r--src/i810_common.h14
-rw-r--r--src/i810_dri.c364
-rw-r--r--src/i810_dri.h11
-rw-r--r--src/i810_driver.c154
-rw-r--r--src/i810_memory.c8
-rw-r--r--src/i810_video.c132
-rw-r--r--src/i830.h14
-rw-r--r--src/i830_accel.c2
-rw-r--r--src/i830_cursor.c4
-rw-r--r--src/i830_dri.c41
-rw-r--r--src/i830_dri.h12
-rw-r--r--src/i830_driver.c290
-rw-r--r--src/i830_memory.c44
-rw-r--r--src/i830_video.c72
17 files changed, 848 insertions, 348 deletions
diff --git a/src/common.h b/src/common.h
index 5e71cad8..3d32432c 100644
--- a/src/common.h
+++ b/src/common.h
@@ -27,12 +27,12 @@ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
**************************************************************************/
-/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/i810/common.h,v 1.6 2003/02/06 04:18:04 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/i810/common.h,v 1.9 2003/09/24 02:43:23 dawes Exp $ */
/*
* Authors:
* Keith Whitwell <keith@tungstengraphics.com>
- * David Dawes <dawes@tungstengraphics.com>
+ * David Dawes <dawes@xfree86.org>
*
*/
@@ -79,7 +79,11 @@ extern const char *I810vbeSymbols[];
extern const char *I810ddcSymbols[];
extern const char *I810fbSymbols[];
extern const char *I810xaaSymbols[];
+#ifdef XF86DRI
+extern const char *I810driSymbols[];
+extern const char *I810drmSymbols[];
extern const char *I810shadowSymbols[];
+#endif
extern void I830DPRINTF_stub(const char *filename, int line,
const char *function, const char *fmt, ...);
@@ -111,7 +115,8 @@ extern void I830DPRINTF_stub(const char *filename, int line,
#define OUT_RING(n) do { \
if (I810_DEBUG & DEBUG_VERBOSE_RING) \
- ErrorF( "OUT_RING %x: %x, (mask %x)\n", outring, n, ringmask); \
+ ErrorF( "OUT_RING %lx: %x, (mask %x)\n", \
+ (unsigned long)(outring), (unsigned int)(n), ringmask); \
*(volatile unsigned int *)(virt + outring) = n; \
outring += 4; \
outring &= ringmask; \
@@ -227,21 +232,24 @@ extern void I830DPRINTF_stub(const char *filename, int line,
#define OUTREG8(addr, val) do { \
*(volatile CARD8 *)(RecPtr->MMIOBase + (addr)) = (val); \
if (I810_DEBUG&DEBUG_VERBOSE_OUTREG) { \
- ErrorF("OUTREG8(0x%x, 0x%x) in %s\n", addr, val, FUNCTION_NAME); \
+ ErrorF("OUTREG8(0x%lx, 0x%lx) in %s\n", (unsigned long)(addr), \
+ (unsigned long)(val), FUNCTION_NAME); \
} \
} while (0)
#define OUTREG16(addr, val) do { \
*(volatile CARD16 *)(RecPtr->MMIOBase + (addr)) = (val); \
if (I810_DEBUG&DEBUG_VERBOSE_OUTREG) { \
- ErrorF("OUTREG16(0x%x, 0x%x) in %s\n", addr, val, FUNCTION_NAME); \
+ ErrorF("OUTREG16(0x%lx, 0x%lx) in %s\n", (unsigned long)(addr), \
+ (unsigned long)(val), FUNCTION_NAME); \
} \
} while (0)
#define OUTREG(addr, val) do { \
*(volatile CARD32 *)(RecPtr->MMIOBase + (addr)) = (val); \
if (I810_DEBUG&DEBUG_VERBOSE_OUTREG) { \
- ErrorF("OUTREG(0x%x, 0x%x) in %s\n", addr, val, FUNCTION_NAME); \
+ ErrorF("OUTREG(0x%lx, 0x%lx) in %s\n", (unsigned long)(addr), \
+ (unsigned long)(val), FUNCTION_NAME); \
} \
} while (0)
diff --git a/src/i810.h b/src/i810.h
index 128b659a..f1232ba6 100644
--- a/src/i810.h
+++ b/src/i810.h
@@ -27,12 +27,12 @@ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
**************************************************************************/
-/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/i810/i810.h,v 1.38 2003/02/26 04:19:36 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/i810/i810.h,v 1.42 2003/09/28 20:15:57 alanh Exp $ */
/*
* Authors:
* Keith Whitwell <keith@tungstengraphics.com>
- * David Dawes <dawes@tungstengraphics.com>
+ * David Dawes <dawes@xfree86.org>
*
*/
@@ -221,6 +221,7 @@ typedef struct _I810Rec {
I810WriteByteFunc writeStandard;
I810ReadByteFunc readStandard;
+ Bool directRenderingDisabled; /* DRI disabled in PreInit */
Bool directRenderingEnabled; /* false if XF86DRI not defined. */
#ifdef XF86DRI
@@ -252,6 +253,9 @@ typedef struct _I810Rec {
Bool showCache;
Bool noAccel;
+ Bool allowPageFlip;
+ Bool have3DWindows;
+ int drmMinor;
} I810Rec;
#define I810PTR(p) ((I810Ptr)((p)->driverPrivate))
@@ -260,9 +264,13 @@ typedef struct _I810Rec {
#define I810_SELECT_BACK 1
#define I810_SELECT_DEPTH 2
+#ifdef XF86DRI
extern Bool I810DRIScreenInit(ScreenPtr pScreen);
extern void I810DRICloseScreen(ScreenPtr pScreen);
extern Bool I810DRIFinishScreenInit(ScreenPtr pScreen);
+extern Bool I810DRILeave(ScrnInfoPtr pScrn);
+extern Bool I810DRIEnter(ScrnInfoPtr pScrn);
+#endif
extern Bool I810InitDma(ScrnInfoPtr pScrn);
extern Bool I810CleanupDma(ScrnInfoPtr pScrn);
diff --git a/src/i810_accel.c b/src/i810_accel.c
index 17c24b37..d8467424 100644
--- a/src/i810_accel.c
+++ b/src/i810_accel.c
@@ -25,7 +25,7 @@ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
**************************************************************************/
-/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/i810/i810_accel.c,v 1.17 2002/11/25 14:04:59 eich Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/i810/i810_accel.c,v 1.19 2003/04/24 18:00:24 eich Exp $ */
/*
* Reformatted with GNU indent (2.2.8), using the following options:
diff --git a/src/i810_common.h b/src/i810_common.h
index 2a2e21a5..745b5a50 100644
--- a/src/i810_common.h
+++ b/src/i810_common.h
@@ -25,7 +25,7 @@
* Converted to common header format:
* Jens Owen <jens@tungstengraphics.com>
*
- * $XFree86: xc/programs/Xserver/hw/xfree86/drivers/i810/i810_common.h,v 1.1 2002/09/11 00:29:31 dawes Exp $
+ * $XFree86: xc/programs/Xserver/hw/xfree86/drivers/i810/i810_common.h,v 1.2 2003/09/28 20:15:58 alanh Exp $
*
*/
@@ -123,14 +123,18 @@
#define DRM_I810_OV0FLIP 0x0b
#define DRM_I810_MC 0x0c
#define DRM_I810_RSTATUS 0x0d
+#define DRM_I810_FLIP 0x0e
#endif
+typedef enum _drmI810Initfunc {
+ I810_INIT_DMA = 0x01,
+ I810_CLEANUP_DMA = 0x02,
+ I810_INIT_DMA_1_4 = 0x03
+} drmI810Initfunc;
+
typedef struct {
- enum {
- I810_INIT_DMA = 0x01,
- I810_CLEANUP_DMA = 0x02
- } func;
+ drmI810Initfunc func;
unsigned int mmio_offset;
unsigned int buffers_offset;
int sarea_priv_offset;
diff --git a/src/i810_dri.c b/src/i810_dri.c
index 11ecacf0..d1dc11b4 100644
--- a/src/i810_dri.c
+++ b/src/i810_dri.c
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/i810/i810_dri.c,v 1.33 2002/12/10 01:27:04 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/i810/i810_dri.c,v 1.42 2003/09/28 20:15:58 alanh Exp $ */
/*
* Reformatted with GNU indent (2.2.8), using the following options:
*
@@ -21,6 +21,8 @@
#include "xf86Pci.h"
#include "windowstr.h"
+#include "shadow.h"
+#include "shadowfb.h"
#include "GL/glxtokens.h"
@@ -45,6 +47,18 @@ static void I810DRIInitBuffers(WindowPtr pWin, RegionPtr prgn, CARD32 index);
static void I810DRIMoveBuffers(WindowPtr pParent, DDXPointRec ptOldOrg,
RegionPtr prgnSrc, CARD32 index);
+
+static Bool I810DRIOpenFullScreen(ScreenPtr pScreen);
+static Bool I810DRICloseFullScreen(ScreenPtr pScreen);
+static void I810EnablePageFlip(ScreenPtr pScreen);
+static void I810DisablePageFlip(ScreenPtr pScreen);
+static void I810DRITransitionSingleToMulti3d(ScreenPtr pScreen);
+static void I810DRITransitionMultiToSingle3d(ScreenPtr pScreen);
+static void I810DRITransitionTo3d(ScreenPtr pScreen);
+static void I810DRITransitionTo2d(ScreenPtr pScreen);
+
+static void I810DRIRefreshArea(ScrnInfoPtr pScrn, int num, BoxPtr pbox);
+
extern void GlxSetVisualConfigs(int nconfigs,
__GLXvisualConfig * configs,
void **configprivs);
@@ -65,6 +79,8 @@ static int i810_pitch_flags[] = {
0
};
+static unsigned int i810_drm_version = 0;
+
Bool
I810CleanupDma(ScrnInfoPtr pScrn)
{
@@ -94,8 +110,6 @@ I810InitDma(ScrnInfoPtr pScrn)
memset(&info, 0, sizeof(drmI810Init));
- info.func = I810_INIT_DMA;
-
info.ring_start = ring->mem.Start;
info.ring_end = ring->mem.End;
info.ring_size = ring->mem.Size;
@@ -113,6 +127,28 @@ I810InitDma(ScrnInfoPtr pScrn)
info.pitch = pI810->auxPitch;
info.pitch_bits = pI810->auxPitchBits;
+ /* We require DRM v1.2 or greater. Since DRM v1.2 broke compatibility
+ * we created a new v1.4 that supports a new init function. Eventually the
+ * old init function will go away. If you change the drm interface, make a
+ * new init type too so that we can detect the new client.
+ */
+ switch(i810_drm_version) {
+ case ((1<<16) | 0):
+ case ((1<<16) | 1):
+ case ((1<<16) | 2):
+ case ((1<<16) | 3):
+ /* Use OLD drm < 1.4 init */
+ info.func = I810_INIT_DMA;
+ xf86DrvMsg(pScrn->scrnIndex, X_INFO, "[drm] Init PRE v1.4 interface.\n");
+ break;
+ default:
+ case ((1<<16) | 4):
+ /* DRM version 1.3 or greater init */
+ info.func = I810_INIT_DMA_1_4;
+ xf86DrvMsg(pScrn->scrnIndex, X_INFO, "[drm] Init v1.4 interface.\n");
+ break;
+ }
+
if (drmCommandWrite(pI810->drmSubFD, DRM_I810_INIT,
&info, sizeof(drmI810Init))) {
xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
@@ -188,7 +224,7 @@ I810InitVisualConfigs(ScreenPtr pScreen)
pConfigs[i].accumRedSize = 16;
pConfigs[i].accumGreenSize = 16;
pConfigs[i].accumBlueSize = 16;
- pConfigs[i].accumAlphaSize = 16;
+ pConfigs[i].accumAlphaSize = 0;
} else {
pConfigs[i].accumRedSize = 0;
pConfigs[i].accumGreenSize = 0;
@@ -209,10 +245,10 @@ I810InitVisualConfigs(ScreenPtr pScreen)
pConfigs[i].auxBuffers = 0;
pConfigs[i].level = 0;
if (stencil || accum)
- pConfigs[i].visualRating = GLX_SLOW_VISUAL_EXT;
+ pConfigs[i].visualRating = GLX_SLOW_CONFIG;
else
- pConfigs[i].visualRating = GLX_NONE_EXT;
- pConfigs[i].transparentPixel = 0;
+ pConfigs[i].visualRating = GLX_NONE;
+ pConfigs[i].transparentPixel = GLX_NONE;
pConfigs[i].transparentRed = 0;
pConfigs[i].transparentGreen = 0;
pConfigs[i].transparentBlue = 0;
@@ -354,6 +390,12 @@ I810DRIScreenInit(ScreenPtr pScreen)
pDRIInfo->InitBuffers = I810DRIInitBuffers;
pDRIInfo->MoveBuffers = I810DRIMoveBuffers;
pDRIInfo->bufferRequests = DRI_ALL_WINDOWS;
+ pDRIInfo->OpenFullScreen = I810DRIOpenFullScreen;
+ pDRIInfo->CloseFullScreen = I810DRICloseFullScreen;
+ pDRIInfo->TransitionTo2d = I810DRITransitionTo2d;
+ pDRIInfo->TransitionTo3d = I810DRITransitionTo3d;
+ pDRIInfo->TransitionSingleToMulti3D = I810DRITransitionSingleToMulti3d;
+ pDRIInfo->TransitionMultiToSingle3D = I810DRITransitionMultiToSingle3d;
pDRIInfo->createDummyCtx = TRUE;
pDRIInfo->createDummyCtxPriv = FALSE;
@@ -416,6 +458,8 @@ I810DRIScreenInit(ScreenPtr pScreen)
/* Check the i810 DRM version */
version = drmGetVersion(pI810->drmSubFD);
if (version) {
+ i810_drm_version = (version->version_major<<16) |
+ version->version_minor;
if (version->version_major != 1 || version->version_minor < 2) {
/* incompatible drm version */
xf86DrvMsg(pScreen->myNum, X_ERROR,
@@ -428,6 +472,7 @@ I810DRIScreenInit(ScreenPtr pScreen)
drmFreeVersion(version);
return FALSE;
}
+ pI810->drmMinor = version->version_minor;
drmFreeVersion(version);
}
}
@@ -442,13 +487,13 @@ I810DRIScreenInit(ScreenPtr pScreen)
xf86DrvMsg(pScreen->myNum, X_INFO, "[drm] Registers = 0x%08lx\n",
pI810DRI->regs);
- pI810->backHandle = 0;
- pI810->zHandle = 0;
- pI810->cursorHandle = 0;
- pI810->xvmcHandle = 0;
- pI810->sysmemHandle = 0;
+ pI810->backHandle = DRM_AGP_NO_HANDLE;
+ pI810->zHandle = DRM_AGP_NO_HANDLE;
+ pI810->cursorHandle = DRM_AGP_NO_HANDLE;
+ pI810->xvmcHandle = DRM_AGP_NO_HANDLE;
+ pI810->sysmemHandle = DRM_AGP_NO_HANDLE;
pI810->agpAcquired = FALSE;
- pI810->dcacheHandle = 0;
+ pI810->dcacheHandle = DRM_AGP_NO_HANDLE;
/* Agp Support - Need this just to get the framebuffer.
*/
@@ -476,7 +521,8 @@ I810DRIScreenInit(ScreenPtr pScreen)
drmAgpAlloc(pI810->drmSubFD, 4096 * 1024, 1, NULL, &dcacheHandle);
pI810->dcacheHandle = dcacheHandle;
- xf86DrvMsg(pScreen->myNum, X_INFO, "[agp] dcacheHandle : %p\n",
+
+ xf86DrvMsg(pScreen->myNum, X_INFO, "[agp] dcacheHandle : 0x%lx\n",
dcacheHandle);
#define Elements(x) sizeof(x)/sizeof(*x)
@@ -490,18 +536,22 @@ I810DRIScreenInit(ScreenPtr pScreen)
DRICloseScreen(pScreen);
return FALSE;
} else {
- back_size = i810_pitches[pitch_idx] * (pScrn->virtualY + 4);
+ /* for tiled memory to work, the buffer needs to have the
+ * number of lines as a multiple of 16 (the tile size),
+ * - airlied */
+ int lines = (pScrn->virtualY + 15) / 16 * 16;
+ back_size = i810_pitches[pitch_idx] * lines;
back_size = ((back_size + 4096 - 1) / 4096) * 4096;
}
sysmem_size = pScrn->videoRam * 1024;
- if (dcacheHandle != 0) {
+ if (dcacheHandle != DRM_AGP_NO_HANDLE) {
if (back_size > 4 * 1024 * 1024) {
xf86DrvMsg(pScreen->myNum, X_INFO,
"[dri] Backsize is larger then 4 meg\n");
sysmem_size = sysmem_size - 2 * back_size;
drmAgpFree(pI810->drmSubFD, dcacheHandle);
- pI810->dcacheHandle = dcacheHandle = 0;
+ pI810->dcacheHandle = dcacheHandle = DRM_AGP_NO_HANDLE;
} else {
sysmem_size = sysmem_size - back_size;
}
@@ -545,7 +595,7 @@ I810DRIScreenInit(ScreenPtr pScreen)
pI810->SavedSysMem = pI810->SysMem;
- if (dcacheHandle != 0) {
+ if (dcacheHandle != DRM_AGP_NO_HANDLE) {
if (drmAgpBind(pI810->drmSubFD, dcacheHandle, pI810->DepthOffset) == 0) {
memset(&pI810->DcacheMem, 0, sizeof(I810MemRange));
xf86DrvMsg(pScrn->scrnIndex, X_INFO,
@@ -565,7 +615,7 @@ I810DRIScreenInit(ScreenPtr pScreen)
xf86DrvMsg(pScrn->scrnIndex, X_INFO,
"[agp] GART: dcache bind failed\n");
drmAgpFree(pI810->drmSubFD, dcacheHandle);
- pI810->dcacheHandle = dcacheHandle = 0;
+ pI810->dcacheHandle = dcacheHandle = DRM_AGP_NO_HANDLE;
}
} else {
xf86DrvMsg(pScrn->scrnIndex, X_INFO,
@@ -575,7 +625,7 @@ I810DRIScreenInit(ScreenPtr pScreen)
drmAgpAlloc(pI810->drmSubFD, back_size, 0, NULL, &agpHandle);
pI810->backHandle = agpHandle;
- if (agpHandle != 0) {
+ if (agpHandle != DRM_AGP_NO_HANDLE) {
if (drmAgpBind(pI810->drmSubFD, agpHandle, pI810->BackOffset) == 0) {
xf86DrvMsg(pScrn->scrnIndex, X_INFO,
"[agp] Bound backbuffer memory\n");
@@ -597,11 +647,12 @@ I810DRIScreenInit(ScreenPtr pScreen)
return FALSE;
}
- if (dcacheHandle == 0) {
- drmAgpAlloc(pI810->drmSubFD, back_size, 0, NULL, &agpHandle);
+ if (dcacheHandle == DRM_AGP_NO_HANDLE) {
+ drmAgpAlloc(pI810->drmSubFD, back_size, 0, NULL, &agpHandle);
+
pI810->zHandle = agpHandle;
- if (agpHandle != 0) {
+ if (agpHandle != DRM_AGP_NO_HANDLE) {
if (drmAgpBind(pI810->drmSubFD, agpHandle, pI810->DepthOffset) == 0) {
xf86DrvMsg(pScrn->scrnIndex, X_INFO,
"[agp] Bound depthbuffer memory\n");
@@ -627,7 +678,8 @@ I810DRIScreenInit(ScreenPtr pScreen)
* regular framebuffer as well as texture memory.
*/
drmAgpAlloc(pI810->drmSubFD, sysmem_size, 0, NULL, &agpHandle);
- if (agpHandle == 0) {
+
+ if (agpHandle == DRM_AGP_NO_HANDLE) {
xf86DrvMsg(pScreen->myNum, X_ERROR, "[agp] drmAgpAlloc failed\n");
DRICloseScreen(pScreen);
return FALSE;
@@ -666,9 +718,10 @@ I810DRIScreenInit(ScreenPtr pScreen)
pI810->MC.Start = pI810->FbMapSize - 8 * 1024 * 1024;
}
drmAgpAlloc(pI810->drmSubFD, pI810->MC.Size, 0, NULL, &agpHandle);
+
pI810->xvmcHandle = agpHandle;
- if (agpHandle != 0) {
+ if (agpHandle != DRM_AGP_NO_HANDLE) {
if (drmAgpBind(pI810->drmSubFD, agpHandle, pI810->MC.Start) == 0) {
xf86DrvMsg(pScrn->scrnIndex, X_INFO,
"GART: Allocated 7MB for HWMC\n");
@@ -690,9 +743,10 @@ I810DRIScreenInit(ScreenPtr pScreen)
drmAgpAlloc(pI810->drmSubFD, 4096, 2,
(unsigned long *)&pI810->CursorPhysical, &agpHandle);
+
pI810->cursorHandle = agpHandle;
- if (agpHandle != 0) {
+ if (agpHandle != DRM_AGP_NO_HANDLE) {
tom = sysmem_size;
if (drmAgpBind(pI810->drmSubFD, agpHandle, tom) == 0) {
@@ -932,32 +986,38 @@ I810DRICloseScreen(ScreenPtr pScreen)
{
ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
I810Ptr pI810 = I810PTR(pScrn);
+ I810DRIPtr pI810DRI = (I810DRIPtr) pI810->pDRIInfo->devPrivate;
+
+ if (pI810DRI->irq) {
+ drmCtlUninstHandler(pI810->drmSubFD);
+ pI810DRI->irq = 0;
+ }
I810CleanupDma(pScrn);
- if (pI810->dcacheHandle)
+ if (pI810->dcacheHandle!=DRM_AGP_NO_HANDLE)
drmAgpFree(pI810->drmSubFD, pI810->dcacheHandle);
- if (pI810->backHandle)
+ if (pI810->backHandle!=DRM_AGP_NO_HANDLE)
drmAgpFree(pI810->drmSubFD, pI810->backHandle);
- if (pI810->zHandle)
+ if (pI810->zHandle!=DRM_AGP_NO_HANDLE)
drmAgpFree(pI810->drmSubFD, pI810->zHandle);
- if (pI810->cursorHandle)
+ if (pI810->cursorHandle!=DRM_AGP_NO_HANDLE)
drmAgpFree(pI810->drmSubFD, pI810->cursorHandle);
- if (pI810->xvmcHandle)
+ if (pI810->xvmcHandle!=DRM_AGP_NO_HANDLE)
drmAgpFree(pI810->drmSubFD, pI810->xvmcHandle);
- if (pI810->sysmemHandle)
+ if (pI810->sysmemHandle!=DRM_AGP_NO_HANDLE)
drmAgpFree(pI810->drmSubFD, pI810->sysmemHandle);
if (pI810->agpAcquired == TRUE)
drmAgpRelease(pI810->drmSubFD);
- pI810->backHandle = 0;
- pI810->zHandle = 0;
- pI810->cursorHandle = 0;
- pI810->xvmcHandle = 0;
- pI810->sysmemHandle = 0;
+ pI810->backHandle = DRM_AGP_NO_HANDLE;
+ pI810->zHandle = DRM_AGP_NO_HANDLE;
+ pI810->cursorHandle = DRM_AGP_NO_HANDLE;
+ pI810->xvmcHandle = DRM_AGP_NO_HANDLE;
+ pI810->sysmemHandle = DRM_AGP_NO_HANDLE;
pI810->agpAcquired = FALSE;
- pI810->dcacheHandle = 0;
+ pI810->dcacheHandle = DRM_AGP_NO_HANDLE;
DRICloseScreen(pScreen);
@@ -993,8 +1053,18 @@ Bool
I810DRIFinishScreenInit(ScreenPtr pScreen)
{
I810SAREARec *sPriv = (I810SAREARec *) DRIGetSAREAPrivate(pScreen);
+ ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+ I810Ptr info = I810PTR(pScrn);
memset(sPriv, 0, sizeof(sPriv));
+
+ /* Have shadow run only while there is 3d active.
+ */
+ if (info->allowPageFlip && info->drmMinor >= 3) {
+ ShadowFBInit( pScreen, I810DRIRefreshArea );
+ }
+ else
+ info->allowPageFlip = 0;
return DRIFinishScreenInit(pScreen);
}
@@ -1198,7 +1268,7 @@ I810DRIMoveBuffers(WindowPtr pParent, DDXPointRec ptOldOrg,
if (I810_DEBUG & DEBUG_VERBOSE_DRI)
ErrorF("MoveBuffers %d,%d %dx%d dx: %d dy: %d\n",
x1, y1, w, h, dx, dy);
-
+
I810SelectBuffer(pScrn, I810_SELECT_BACK);
I810SubsequentScreenToScreenCopy(pScrn, x1, y1, destx, desty, w, h);
I810SelectBuffer(pScrn, I810_SELECT_DEPTH);
@@ -1218,3 +1288,219 @@ I810DRIMoveBuffers(WindowPtr pParent, DDXPointRec ptOldOrg,
pI810->AccelInfoRec->NeedToSync = TRUE;
}
+
+
+/* Fullscreen hooks. The DRI fullscreen mode can probably be removed as
+ * it adds little or nothing above the mechanism below (and isn't widely
+ * used).
+ */
+static Bool I810DRIOpenFullScreen(ScreenPtr pScreen)
+{
+ return TRUE;
+}
+
+static Bool I810DRICloseFullScreen(ScreenPtr pScreen)
+{
+ return TRUE;
+}
+/* Use the miext/shadow module to maintain a list of dirty rectangles.
+ * These are blitted to the back buffer to keep both buffers clean
+ * during page-flipping when the 3d application isn't fullscreen.
+ *
+ * Unlike most use of the shadow code, both buffers are in video memory.
+ *
+ * An alternative to this would be to organize for all on-screen drawing
+ * operations to be duplicated for the two buffers. That might be
+ * faster, but seems like a lot more work...
+ */
+
+
+/* This should be done *before* XAA syncs or fires its buffer.
+ * Otherwise will have to fire it again???
+ */
+static void I810DRIRefreshArea(ScrnInfoPtr pScrn, int num, BoxPtr pbox)
+{
+ I810Ptr pI810 = I810PTR(pScrn);
+ int i;
+ I810SAREAPtr pSAREAPriv = DRIGetSAREAPrivate(pScrn->pScreen);
+ unsigned int br13;
+ int cpp=2;
+
+
+ /* Don't want to do this when no 3d is active and pages are
+ * right-way-round
+ */
+ if (!pSAREAPriv->pf_active && pSAREAPriv->pf_current_page == 0)
+ return;
+
+ br13 = (pI810->auxPitch) | (0xcc << 16);
+
+ for (i = 0 ; i < num ; i++, pbox++) {
+ unsigned int w = min(pbox->y2, pScrn->virtualY-1) - max(pbox->y1, 0) + 1;
+ unsigned int h = min(pbox->x2, pScrn->virtualX-1) - max(pbox->x1, 0) + 1;
+ unsigned int dst = max(pbox->x1, 0)*cpp + (max(pbox->y1, 0)*pI810->auxPitch);
+
+ BEGIN_LP_RING(6);
+
+ OUT_RING(BR00_BITBLT_CLIENT | BR00_OP_SRC_COPY_BLT | 0x4);
+ OUT_RING(br13);
+ OUT_RING( (h<<16) | (w*cpp) );
+ OUT_RING(pI810->BackBuffer.Start + dst);
+ OUT_RING(br13 & 0xffff);
+ OUT_RING(dst);
+
+ ADVANCE_LP_RING();
+ }
+
+}
+
+static void I810EnablePageFlip(ScreenPtr pScreen)
+{
+ ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+ I810Ptr pI810 = I810PTR(pScrn);
+ I810SAREAPtr pSAREAPriv = DRIGetSAREAPrivate(pScreen);
+ int cpp=2;
+ pSAREAPriv->pf_enabled = pI810->allowPageFlip;
+ pSAREAPriv->pf_active = 0;
+
+ if (pI810->allowPageFlip) {
+ unsigned int br13 = pI810->auxPitch | (0xcc << 16);
+
+ BEGIN_LP_RING(6);
+
+ OUT_RING(BR00_BITBLT_CLIENT | BR00_OP_SRC_COPY_BLT | 0x4);
+ OUT_RING(br13);
+ OUT_RING((pScrn->virtualY << 16) | (pScrn->virtualX*cpp));
+ OUT_RING(pI810->BackBuffer.Start);
+ OUT_RING(br13 & 0xFFFF);
+ OUT_RING(0);
+ ADVANCE_LP_RING();
+
+ pSAREAPriv->pf_active = 1;
+ }
+
+}
+
+static void I810DisablePageFlip(ScreenPtr pScreen)
+{
+ I810SAREAPtr pSAREAPriv = DRIGetSAREAPrivate(pScreen);
+
+ pSAREAPriv->pf_active=0;
+}
+
+static void I810DRITransitionSingleToMulti3d(ScreenPtr pScreen)
+{
+ /* Tell the clients not to pageflip. How?
+ * -- Field in sarea, plus bumping the window counters.
+ * -- DRM needs to cope with Front-to-Back swapbuffers.
+ */
+ I810DisablePageFlip(pScreen);
+}
+
+static void I810DRITransitionMultiToSingle3d(ScreenPtr pScreen)
+{
+ /* Let the remaining 3d app start page flipping again */
+ I810EnablePageFlip(pScreen);
+}
+
+static void I810DRITransitionTo3d(ScreenPtr pScreen)
+{
+ ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+ I810Ptr pI810 = I810PTR(pScrn);
+
+ I810EnablePageFlip(pScreen);
+ pI810->have3DWindows = 1;
+}
+
+static void I810DRITransitionTo2d(ScreenPtr pScreen)
+{
+ ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+ I810Ptr pI810 = I810PTR(pScrn);
+ I810SAREAPtr pSAREAPriv = DRIGetSAREAPrivate(pScreen);
+
+ /* Shut down shadowing if we've made it back to the front page */
+ if (pSAREAPriv->pf_current_page == 0) {
+ I810DisablePageFlip(pScreen);
+ }
+ pI810->have3DWindows = 0;
+}
+
+Bool
+I810DRILeave(ScrnInfoPtr pScrn)
+{
+ I810Ptr pI810 = I810PTR(pScrn);
+
+ if (pI810->directRenderingEnabled) {
+ if (pI810->dcacheHandle != 0)
+ if (drmAgpUnbind(pI810->drmSubFD, pI810->dcacheHandle) != 0) {
+ xf86DrvMsg(pScrn->scrnIndex, X_ERROR,"%s\n",strerror(errno));
+ return FALSE;
+ }
+ if (pI810->backHandle != 0)
+ if (drmAgpUnbind(pI810->drmSubFD, pI810->backHandle) != 0) {
+ xf86DrvMsg(pScrn->scrnIndex, X_ERROR,"%s\n",strerror(errno));
+ return FALSE;
+ }
+ if (pI810->zHandle != 0)
+ if (drmAgpUnbind(pI810->drmSubFD, pI810->zHandle) != 0) {
+ xf86DrvMsg(pScrn->scrnIndex, X_ERROR,"%s\n",strerror(errno));
+ return FALSE;
+ }
+ if (pI810->sysmemHandle != 0)
+ if (drmAgpUnbind(pI810->drmSubFD, pI810->sysmemHandle) != 0) {
+ xf86DrvMsg(pScrn->scrnIndex, X_ERROR,"%s\n",strerror(errno));
+ return FALSE;
+ }
+ if (pI810->xvmcHandle != 0)
+ if (drmAgpUnbind(pI810->drmSubFD, pI810->xvmcHandle) != 0) {
+ xf86DrvMsg(pScrn->scrnIndex, X_ERROR,"%s\n",strerror(errno));
+ return FALSE;
+ }
+ if (pI810->cursorHandle != 0)
+ if (drmAgpUnbind(pI810->drmSubFD, pI810->cursorHandle) != 0) {
+ xf86DrvMsg(pScrn->scrnIndex, X_ERROR,"%s\n",strerror(errno));
+ return FALSE;
+ }
+ if (pI810->agpAcquired == TRUE)
+ drmAgpRelease(pI810->drmSubFD);
+ pI810->agpAcquired = FALSE;
+ }
+ return TRUE;
+}
+
+Bool
+I810DRIEnter(ScrnInfoPtr pScrn)
+{
+ I810Ptr pI810 = I810PTR(pScrn);
+
+ if (pI810->directRenderingEnabled) {
+
+ if (pI810->agpAcquired == FALSE)
+ drmAgpAcquire(pI810->drmSubFD);
+ pI810->agpAcquired = TRUE;
+ if (pI810->dcacheHandle != 0)
+ if (drmAgpBind(pI810->drmSubFD, pI810->dcacheHandle,
+ pI810->DepthOffset) != 0)
+ return FALSE;
+ if (pI810->backHandle != 0)
+ if (drmAgpBind(pI810->drmSubFD, pI810->backHandle,
+ pI810->BackOffset) != 0)
+ return FALSE;
+ if (pI810->zHandle != 0)
+ if (drmAgpBind(pI810->drmSubFD, pI810->zHandle,
+ pI810->DepthOffset) != 0)
+ return FALSE;
+ if (pI810->sysmemHandle != 0)
+ if (drmAgpBind(pI810->drmSubFD, pI810->sysmemHandle, 0) != 0)
+ return FALSE;
+ if (pI810->xvmcHandle != 0)
+ if (drmAgpBind(pI810->drmSubFD, pI810->xvmcHandle,
+ pI810->MC.Start) != 0)
+ return FALSE;
+ if (pI810->cursorHandle != 0)
+ if (drmAgpBind(pI810->drmSubFD, pI810->cursorHandle,
+ pI810->CursorStart) != 0)
+ return FALSE;
+ }
+ return TRUE;
+}
diff --git a/src/i810_dri.h b/src/i810_dri.h
index cf0532cb..11a33112 100644
--- a/src/i810_dri.h
+++ b/src/i810_dri.h
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/i810/i810_dri.h,v 1.10 2002/12/10 01:27:04 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/i810/i810_dri.h,v 1.11 2003/09/28 20:15:58 alanh Exp $ */
#ifndef _I810_DRI_
#define _I810_DRI_
@@ -95,8 +95,10 @@ typedef struct {
* kick out your own texture or someone else's - simply eject
* them all in LRU order.
*/
- I810TexRegionRec texList[I810_NR_TEX_REGIONS + 1]; /* Last elt is sentinal */
+
+ drmTextureRegion texList[I810_NR_TEX_REGIONS + 1];
+ /* Last elt is sentinal */
int texAge; /* last time texture was uploaded */
int last_enqueue; /* last time a buffer was enqueued */
@@ -107,6 +109,11 @@ typedef struct {
int vertex_prim;
+ int pf_enabled; /* is pageflipping allowed? */
+ int pf_active; /* is pageflipping active right now? */
+ int pf_current_page; /* which buffer is being displayed? */
+
+
} I810SAREARec, *I810SAREAPtr;
typedef struct {
diff --git a/src/i810_driver.c b/src/i810_driver.c
index 746e186f..62039190 100644
--- a/src/i810_driver.c
+++ b/src/i810_driver.c
@@ -25,7 +25,7 @@ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
**************************************************************************/
-/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/i810/i810_driver.c,v 1.80 2003/02/26 04:19:36 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/i810/i810_driver.c,v 1.95 2003/10/30 18:37:21 tsi Exp $ */
/*
* Reformatted with GNU indent (2.2.8), using the following options:
@@ -69,7 +69,7 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include "micmap.h"
#include "fb.h"
-#include "miscstruct.h"
+#include "regionstr.h"
#include "xf86xv.h"
#include "Xv.h"
#include "vbe.h"
@@ -96,8 +96,8 @@ static void I810FreeScreen(int scrnIndex, int flags);
static void I810DisplayPowerManagementSet(ScrnInfoPtr pScrn,
int PowerManagermentMode,
int flags);
-static int I810ValidMode(int scrnIndex, DisplayModePtr mode, Bool
- verbose, int flags);
+static ModeStatus I810ValidMode(int scrnIndex, DisplayModePtr mode,
+ Bool verbose, int flags);
#endif /* I830_ONLY */
@@ -151,7 +151,8 @@ typedef enum {
OPTION_DRI,
OPTION_NO_DDC,
OPTION_SHOW_CACHE,
- OPTION_XVMC_SURFACES
+ OPTION_XVMC_SURFACES,
+ OPTION_PAGEFLIP
} I810Opts;
static const OptionInfoRec I810Options[] = {
@@ -164,6 +165,7 @@ static const OptionInfoRec I810Options[] = {
{OPTION_NO_DDC, "NoDDC", OPTV_BOOLEAN, {0}, FALSE},
{OPTION_SHOW_CACHE, "ShowCache", OPTV_BOOLEAN, {0}, FALSE},
{OPTION_XVMC_SURFACES, "XvMCSurfaces", OPTV_INTEGER, {0}, FALSE},
+ {OPTION_PAGEFLIP, "PageFlip", OPTV_BOOLEAN, {0}, FALSE},
{-1, NULL, OPTV_NONE, {0}, FALSE}
};
/* *INDENT-ON* */
@@ -241,7 +243,6 @@ const char *I810int10Symbols[] = {
const char *I810xaaSymbols[] = {
"XAACreateInfoRec",
"XAADestroyInfoRec",
- "XAAFillSolidRects",
"XAAInit",
NULL
};
@@ -253,10 +254,8 @@ const char *I810ramdacSymbols[] = {
NULL
};
-#ifndef I830_ONLY
-#ifdef XFree86LOADER
#ifdef XF86DRI
-static const char *drmSymbols[] = {
+const char *I810drmSymbols[] = {
"drmAddBufs",
"drmAddMap",
"drmAgpAcquire",
@@ -265,10 +264,12 @@ static const char *drmSymbols[] = {
"drmAgpEnable",
"drmAgpFree",
"drmAgpRelease",
+ "drmAgpUnbind",
"drmAuthMagic",
"drmCommandWrite",
"drmCreateContext",
"drmCtlInstHandler",
+ "drmCtlUninstHandler",
"drmDestroyContext",
"drmFreeVersion",
"drmGetInterruptFromBusID",
@@ -278,7 +279,7 @@ static const char *drmSymbols[] = {
};
-static const char *driSymbols[] = {
+const char *I810driSymbols[] = {
"DRICloseScreen",
"DRICreateInfoRec",
"DRIDestroyInfoRec",
@@ -292,16 +293,20 @@ static const char *driSymbols[] = {
NULL
};
-#endif
-#endif
-
#ifdef XF86DRI
+
+static const char *driShadowFBSymbols[] = {
+ "ShadowFBInit",
+ NULL
+};
+
const char *I810shadowSymbols[] = {
- "shadowInit",
- "shadowSetup",
- "shadowAdd",
- NULL
+ "shadowInit",
+ "shadowSetup",
+ "shadowAdd",
+ NULL
};
+
#endif
#endif /* I830_ONLY */
@@ -368,8 +373,8 @@ i810Setup(pointer module, pointer opts, int *errmaj, int *errmin)
LoaderRefSymLists(I810vgahwSymbols,
I810fbSymbols, I810xaaSymbols, I810ramdacSymbols,
#ifdef XF86DRI
- drmSymbols,
- driSymbols,
+ I810drmSymbols,
+ I810driSymbols,
I810shadowSymbols,
#endif
I810vbeSymbols, vbeOptionalSymbols,
@@ -619,6 +624,7 @@ I810PreInit(ScrnInfoPtr pScrn, int flags)
int flags24;
rgb defaultWeight = { 0, 0, 0 };
int mem;
+ Bool enable;
if (pScrn->numEntities != 1)
return FALSE;
@@ -662,7 +668,7 @@ I810PreInit(ScrnInfoPtr pScrn, int flags)
pScrn->monitor = pScrn->confScreen->monitor;
flags24 = Support24bppFb | PreferConvert32to24 | SupportConvert32to24;
- if (!xf86SetDepthBpp(pScrn, 8, 8, 8, flags24)) {
+ if (!xf86SetDepthBpp(pScrn, 0, 0, 0, flags24)) {
return FALSE;
} else {
switch (pScrn->depth) {
@@ -995,6 +1001,47 @@ I810PreInit(ScrnInfoPtr pScrn, int flags)
1) << pScrn->offset.blue);
}
+ pI810->directRenderingDisabled =
+ !xf86ReturnOptValBool(pI810->Options, OPTION_DRI, TRUE);
+
+#ifdef XF86DRI
+ if (!pI810->directRenderingDisabled) {
+ if (pI810->noAccel) {
+ xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "DRI is disabled because it "
+ "needs 2D acceleration.\n");
+ pI810->directRenderingDisabled=TRUE;
+ } else if (pScrn->depth!=16) {
+ xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "DRI is disabled because it "
+ "runs only at 16-bit depth.\n");
+ pI810->directRenderingDisabled=TRUE;
+ }
+ }
+#endif
+
+ pI810->allowPageFlip=FALSE;
+ enable = xf86ReturnOptValBool(pI810->Options, OPTION_PAGEFLIP, FALSE);
+
+#ifdef XF86DRI
+ if (!pI810->directRenderingDisabled) {
+ pI810->allowPageFlip = enable;
+ if (pI810->allowPageFlip == enable)
+ {
+ if (!xf86LoadSubModule(pScrn, "shadowfb")) {
+ pI810->allowPageFlip = 0;
+ xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
+ "Couldn't load shadowfb module:\n");
+ }
+ else {
+ xf86LoaderReqSymLists(driShadowFBSymbols, NULL);
+ }
+ }
+
+ xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "page flipping %s\n",
+ enable ? "enabled" : "disabled");
+
+ }
+#endif
+
if (xf86GetOptValInteger(pI810->Options, OPTION_XVMC_SURFACES,
&(pI810->numSurfaces))) {
xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "%d XvMC Surfaces Requested.\n",
@@ -1015,6 +1062,15 @@ I810PreInit(ScrnInfoPtr pScrn, int flags)
pI810->numSurfaces = 0;
}
+#ifdef XF86DRI
+ /* Load the dri module if requested. */
+ if (xf86ReturnOptValBool(pI810->Options, OPTION_DRI, FALSE)) {
+ if (xf86LoadSubModule(pScrn, "dri")) {
+ xf86LoaderReqSymLists(I810driSymbols, I810drmSymbols, NULL);
+ }
+ }
+#endif
+
/* We won't be using the VGA access after the probe */
I810SetMMIOAccess(pI810);
xf86SetOperatingState(resVgaIo, pI810->pEnt->index, ResUnusedOpr);
@@ -1351,13 +1407,20 @@ DoRestore(ScrnInfoPtr pScrn, vgaRegPtr vgaReg, I810RegPtr i810Reg,
/* Setting the OVRACT Register for video overlay */
{
CARD32 LCD_TV_Control = INREG(LCD_TV_C);
+ CARD32 TV_HTotal = INREG(LCD_TV_HTOTAL);
+ CARD32 ActiveStart, ActiveEnd;
- if(!(LCD_TV_Control & LCD_TV_ENABLE)
- || (LCD_TV_Control & LCD_TV_VGAMOD)) {
- OUTREG(LCD_TV_OVRACT,
- (i810Reg->OverlayActiveEnd << 16)
- | i810Reg->OverlayActiveStart);
+ if((LCD_TV_Control & LCD_TV_ENABLE)
+ && !(LCD_TV_Control & LCD_TV_VGAMOD)
+ && TV_HTotal) {
+ ActiveStart = ((TV_HTotal >> 16) & 0xfff) - 31;
+ ActiveEnd = (TV_HTotal & 0x3ff) - 31;
+ } else {
+ ActiveStart = i810Reg->OverlayActiveStart;
+ ActiveEnd = i810Reg->OverlayActiveEnd;
}
+ OUTREG(LCD_TV_OVRACT,
+ (ActiveEnd << 16) | ActiveStart);
}
/* Turn on DRAM Refresh */
@@ -1538,7 +1601,7 @@ I810CalcVCLK(ScrnInfoPtr pScrn, double freq)
i810Reg->VideoClk2_DivisorSel = (p_best << 4);
xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 3,
- "Setting dot clock to %.1lf MHz " "[ 0x%x 0x%x 0x%x ] "
+ "Setting dot clock to %.1f MHz " "[ 0x%x 0x%x 0x%x ] "
"[ %d %d %d ]\n", CALC_VCLK(m_best, n_best, p_best),
i810Reg->VideoClk2_M, i810Reg->VideoClk2_N,
i810Reg->VideoClk2_DivisorSel, m_best, n_best, p_best);
@@ -1628,9 +1691,10 @@ I810SetMode(ScrnInfoPtr pScrn, DisplayModePtr mode)
i810Reg->OverlayActiveEnd = mode->CrtcHDisplay - 32;
/* Turn on interlaced mode if necessary */
- if (mode->Flags & V_INTERLACE)
+ if (mode->Flags & V_INTERLACE) {
i810Reg->InterlaceControl = INTERLACE_ENABLE;
- else
+ i810Reg->ExtVertDispEnd *= 2;
+ } else
i810Reg->InterlaceControl = INTERLACE_DISABLE;
/*
@@ -1977,14 +2041,16 @@ I810ScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv)
* is called. cfbScreenInit will eventually call into the drivers
* InitGLXVisuals call back.
*/
-
- if (xf86ReturnOptValBool(pI810->Options, OPTION_NOACCEL, FALSE) ||
- !xf86ReturnOptValBool(pI810->Options, OPTION_DRI, TRUE)) {
- pI810->directRenderingEnabled = FALSE;
- driFrom = X_CONFIG;
- } else {
- pI810->directRenderingEnabled = I810DRIScreenInit(pScreen);
- }
+ /*
+ * pI810->directRenderingDisabled is set once in PreInit. Reinitialise
+ * pI810->directRenderingEnabled based on it each generation.
+ */
+ pI810->directRenderingEnabled = !pI810->directRenderingDisabled;
+
+ if (pI810->directRenderingEnabled==TRUE)
+ pI810->directRenderingEnabled = I810DRIScreenInit(pScreen);
+ else
+ driFrom = X_CONFIG;
#else
pI810->directRenderingEnabled = FALSE;
@@ -2149,7 +2215,7 @@ I810SwitchMode(int scrnIndex, DisplayModePtr mode, int flags)
ScrnInfoPtr pScrn = xf86Screens[scrnIndex];
if (I810_DEBUG & DEBUG_VERBOSE_CURSOR)
- ErrorF("I810SwitchMode %p %x\n", mode, flags);
+ ErrorF("I810SwitchMode %p %x\n", (void *)mode, flags);
return I810ModeInit(pScrn, mode);
}
@@ -2161,6 +2227,7 @@ I810AdjustFrame(int scrnIndex, int x, int y, int flags)
I810Ptr pI810 = I810PTR(pScrn);
vgaHWPtr hwp = VGAHWPTR(pScrn);
int Base;
+
#if 1
if (pI810->showCache) {
int lastline = pI810->FbMapSize /
@@ -2217,10 +2284,13 @@ I810EnterVT(int scrnIndex, int flags)
if (I810_DEBUG & DEBUG_VERBOSE_DRI)
ErrorF("\n\nENTER VT\n");
- if (!I810BindGARTMemory(pScrn))
+ if (!I810BindGARTMemory(pScrn)) {
return FALSE;
-
+ }
#ifdef XF86DRI
+ if (!I810DRIEnter(pScrn)) {
+ return FALSE;
+ }
if (pI810->directRenderingEnabled) {
if (I810_DEBUG & DEBUG_VERBOSE_DRI)
ErrorF("calling dri unlock\n");
@@ -2263,6 +2333,10 @@ I810LeaveVT(int scrnIndex, int flags)
if (!I810UnbindGARTMemory(pScrn))
return;
+#ifdef XF86DRI
+ if (!I810DRILeave(pScrn))
+ return;
+#endif
vgaHWLock(hwp);
}
@@ -2336,7 +2410,7 @@ I810FreeScreen(int scrnIndex, int flags)
vgaHWFreeHWRec(xf86Screens[scrnIndex]);
}
-static int
+static ModeStatus
I810ValidMode(int scrnIndex, DisplayModePtr mode, Bool verbose, int flags)
{
if (mode->Flags & V_INTERLACE) {
diff --git a/src/i810_memory.c b/src/i810_memory.c
index 5efa23a9..bb67c434 100644
--- a/src/i810_memory.c
+++ b/src/i810_memory.c
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/i810/i810_memory.c,v 1.27 2002/12/10 01:27:05 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/i810/i810_memory.c,v 1.28 2003/09/24 02:43:23 dawes Exp $ */
/**************************************************************************
Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
@@ -149,7 +149,7 @@ I810AllocateGARTMemory(ScrnInfoPtr pScrn)
pI810->DcacheKey = key;
if (!xf86BindGARTMemory(pScrn->scrnIndex, key, tom)) {
xf86DrvMsg(pScrn->scrnIndex, X_INFO,
- "Allocation of %d bytes for DCACHE failed\n", size);
+ "Allocation of %ld bytes for DCACHE failed\n", size);
pI810->DcacheKey = -1;
} else {
pI810->DcacheMem.Start = tom;
@@ -159,7 +159,7 @@ I810AllocateGARTMemory(ScrnInfoPtr pScrn)
}
} else {
xf86DrvMsg(pScrn->scrnIndex, X_INFO,
- "No physical memory available for %d bytes of DCACHE\n",
+ "No physical memory available for %ld bytes of DCACHE\n",
size);
pI810->DcacheKey = -1;
}
@@ -188,7 +188,7 @@ I810AllocateGARTMemory(ScrnInfoPtr pScrn)
pI810->HwcursKey = key;
if (!xf86BindGARTMemory(pScrn->scrnIndex, key, tom)) {
xf86DrvMsg(pScrn->scrnIndex, X_INFO,
- "Allocation of %d bytes for HW cursor failed\n", size);
+ "Allocation of %ld bytes for HW cursor failed\n", size);
pI810->HwcursKey = -1;
} else {
pI810->CursorPhysical = physical;
diff --git a/src/i810_video.c b/src/i810_video.c
index 9ae60bc5..6bd3e134 100644
--- a/src/i810_video.c
+++ b/src/i810_video.c
@@ -23,7 +23,7 @@ OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
THE USE OR OTHER DEALINGS IN THE SOFTWARE.
**************************************************************************/
-/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/i810/i810_video.c,v 1.22 2002/09/11 00:29:32 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/i810/i810_video.c,v 1.27 2003/11/11 00:58:18 dawes Exp $ */
/*
* i810_video.c: i810 Xv driver. Based on the mga Xv driver by Mark Vojkovich.
@@ -216,14 +216,51 @@ static XF86AttributeRec Attributes[NUM_ATTRIBUTES] =
{XvSettable | XvGettable, 0, 255, "XV_CONTRAST"}
};
-#define NUM_IMAGES 4
+#define NUM_IMAGES 6
+
+#define I810_RV15 0x35315652
+#define I810_RV16 0x36315652
static XF86ImageRec Images[NUM_IMAGES] =
{
- XVIMAGE_YUY2,
- XVIMAGE_YV12,
- XVIMAGE_I420,
- XVIMAGE_UYVY
+ {
+ I810_RV15,
+ XvRGB,
+ LSBFirst,
+ {'R','V','1','5',
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
+ 16,
+ XvPacked,
+ 1,
+ 15, 0x7C00, 0x03E0, 0x001F,
+ 0, 0, 0,
+ 0, 0, 0,
+ 0, 0, 0,
+ {'R','V','B',0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
+ XvTopToBottom
+ },
+ {
+ I810_RV16,
+ XvRGB,
+ LSBFirst,
+ {'R','V','1','6',
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
+ 16,
+ XvPacked,
+ 1,
+ 16, 0xF800, 0x07E0, 0x001F,
+ 0, 0, 0,
+ 0, 0, 0,
+ 0, 0, 0,
+ {'R','V','B',0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
+ XvTopToBottom
+ },
+ XVIMAGE_YUY2,
+ XVIMAGE_YV12,
+ XVIMAGE_I420,
+ XVIMAGE_UYVY
};
/* *INDENT-ON* */
@@ -383,7 +420,7 @@ I810SetupImageVideo(ScreenPtr pScreen)
pPriv->currentBuf = 0;
/* gotta uninit this someplace */
- REGION_INIT(pScreen, &pPriv->clip, NullBox, 0);
+ REGION_NULL(pScreen, &pPriv->clip);
pI810->adaptor = adapt;
@@ -400,36 +437,6 @@ I810SetupImageVideo(ScreenPtr pScreen)
}
-static Bool
-RegionsEqual(RegionPtr A, RegionPtr B)
-{
- int *dataA, *dataB;
- int num;
-
- num = REGION_NUM_RECTS(A);
- if(num != REGION_NUM_RECTS(B))
- return FALSE;
-
- if((A->extents.x1 != B->extents.x1) ||
- (A->extents.x2 != B->extents.x2) ||
- (A->extents.y1 != B->extents.y1) ||
- (A->extents.y2 != B->extents.y2))
- return FALSE;
-
- dataA = (int*)REGION_RECTS(A);
- dataB = (int*)REGION_RECTS(B);
-
- while(num--) {
- if((dataA[0] != dataB[0]) || (dataA[1] != dataB[1]))
- return FALSE;
- dataA += 2;
- dataB += 2;
- }
-
- return TRUE;
-}
-
-
/* I810ClipVideo -
Takes the dst box in standard X BoxRec form (top and left
@@ -758,9 +765,9 @@ I810DisplayVideo(
} else {
overlay->OV0CONF = 0; /* two 720 pixel line buffers */
}
-
+
overlay->SHEIGHT = height | (height << 15);
- overlay->DWINPOS = (dstBox->y1 << 16) | dstBox->x1;
+ overlay->DWINPOS = (dstBox->y1 << 16) | (dstBox->x1);
overlay->DWINSZ = ((dstBox->y2 - dstBox->y1) << 16) |
(dstBox->x2 - dstBox->x1);
@@ -879,6 +886,15 @@ I810DisplayVideo(
overlay->OV0CMD &= ~SOURCE_FORMAT;
overlay->OV0CMD |= YUV_420;
break;
+ case I810_RV15:
+ case I810_RV16:
+ overlay->UV_VPH = 0;
+ overlay->INIT_PH = 0;
+ overlay->OV0STRIDE = dstPitch;
+ overlay->OV0CMD &= ~SOURCE_FORMAT;
+ overlay->OV0CMD |= (id==I810_RV15 ? RGB_555 : RGB_565);
+ overlay->OV0CMD &= ~OV_BYTE_ORDER;
+ break;
case FOURCC_UYVY:
case FOURCC_YUY2:
default:
@@ -975,14 +991,18 @@ I810PutImage(
dstBox.y2 = drw_y + drw_h;
I810ClipVideo(&dstBox, &x1, &x2, &y1, &y2,
- REGION_EXTENTS(pScreen, clipBoxes), width, height);
-
+ REGION_EXTENTS(pScrn->pScreen, clipBoxes), width, height);
+
if((x1 >= x2) || (y1 >= y2))
return Success;
-
- dstBox.x1 -= pScrn->frameX0;
- dstBox.x2 -= pScrn->frameX0;
- dstBox.y1 -= pScrn->frameY0;
+ /*
+ * Fix for 4 pixel granularity of AdjustFrame
+ * unless boarder is clipped by frame
+ */
+ dstBox.x1 -= (pScrn->frameX0 &
+ ((dstBox.x1 == pScrn->frameX0) ? ~0x0UL : ~0x3UL));
+ dstBox.x2 -= (pScrn->frameX0 & ~0x3);
+ dstBox.y1 -= pScrn->frameY0;
dstBox.y2 -= pScrn->frameY0;
switch(id) {
@@ -1057,15 +1077,12 @@ I810PutImage(
}
/* update cliplist */
- if(!RegionsEqual(&pPriv->clip, clipBoxes)) {
- REGION_COPY(pScreen, &pPriv->clip, clipBoxes);
+ if(!REGION_EQUAL(pScrn->pScreen, &pPriv->clip, clipBoxes)) {
+ REGION_COPY(pScrn->pScreen, &pPriv->clip, clipBoxes);
/* draw these */
- XAAFillSolidRects(pScrn, pPriv->colorKey, GXcopy, ~0,
- REGION_NUM_RECTS(clipBoxes),
- REGION_RECTS(clipBoxes));
+ xf86XVFillKeyHelper(pScrn->pScreen, pPriv->colorKey, clipBoxes);
}
-
I810DisplayVideo(pScrn, id, width, height, dstPitch,
x1, y1, x2, y2, &dstBox, src_w, src_h, drw_w, drw_h);
@@ -1322,8 +1339,13 @@ I810DisplaySurface(
REGION_EXTENTS(screenInfo.screens[0], clipBoxes),
surface->width, surface->height);
- dstBox.x1 -= pScrn->frameX0;
- dstBox.x2 -= pScrn->frameX0;
+ /*
+ * Fix for 4 pixel granularity of AdjustFrame
+ * unless boarder is clipped by frame
+ */
+ dstBox.x1 -= (pScrn->frameX0 &
+ ((dstBox.x1 == pScrn->frameX0) ? ~0x0UL : ~0x3UL));
+ dstBox.x2 -= (pScrn->frameX0 & ~0x3);
dstBox.y1 -= pScrn->frameY0;
dstBox.y2 -= pScrn->frameY0;
@@ -1352,9 +1374,7 @@ I810DisplaySurface(
surface->pitches[0], x1, y1, x2, y2, &dstBox,
src_w, src_h, drw_w, drw_h);
- XAAFillSolidRects(pScrn, pI810Priv->colorKey, GXcopy, ~0,
- REGION_NUM_RECTS(clipBoxes),
- REGION_RECTS(clipBoxes));
+ xf86XVFillKeyHelper(pScrn->pScreen, pI810Priv->colorKey, clipBoxes);
pPriv->isOn = TRUE;
/* we've prempted the XvImage stream so set its free timer */
diff --git a/src/i830.h b/src/i830.h
index e141931a..6b1efa49 100644
--- a/src/i830.h
+++ b/src/i830.h
@@ -27,12 +27,12 @@ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
**************************************************************************/
-/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/i810/i830.h,v 1.7 2003/01/28 22:47:09 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/i810/i830.h,v 1.11 2003/10/21 04:13:40 dawes Exp $ */
/*
* Authors:
* Keith Whitwell <keith@tungstengraphics.com>
- * David Dawes <dawes@tungstengraphics.com>
+ * David Dawes <dawes@xfree86.org>
*
*/
@@ -147,6 +147,7 @@ typedef struct _I830Rec {
unsigned long TotalVideoRam;
I830MemRange StolenMemory; /* pre-allocated memory */
unsigned long BIOSMemorySize; /* min stolen pool size */
+ int BIOSMemSizeLoc;
/* These change according to what has been allocated. */
long FreeMemory;
@@ -182,6 +183,7 @@ typedef struct _I830Rec {
Bool NeedRingBufferLow;
Bool allowPageFlip;
+ Bool disableTiling;
int auxPitch;
int auxPitchBits;
@@ -295,6 +297,11 @@ typedef struct _I830Rec {
Bool closing;
Bool suspended;
+ /* fbOffset converted to (x, y). */
+ int xoffset;
+ int yoffset;
+
+ int SaveGeneration;
} I830Rec;
#define I830PTR(p) ((I830Ptr)((p)->driverPrivate))
@@ -391,5 +398,8 @@ extern void I830ChangeFrontbuffer(ScrnInfoPtr pScrn,int buffer);
#define ALLOCATE_DRY_RUN 0x80000000
+/* Chipset registers for VIDEO BIOS memory RW access */
+#define DRAM_RW_CONTROL 0x58
+#define DRAM_WRITE 0x33330000
#endif /* _I830_H_ */
diff --git a/src/i830_accel.c b/src/i830_accel.c
index 1a071497..63dce22d 100644
--- a/src/i830_accel.c
+++ b/src/i830_accel.c
@@ -32,7 +32,7 @@ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
**************************************************************************/
-/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/i810/i830_accel.c,v 1.4 2002/12/10 01:27:05 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/i810/i830_accel.c,v 1.8 2003/04/24 18:00:24 eich Exp $ */
/*
* Reformatted with GNU indent (2.2.8), using the following options:
diff --git a/src/i830_cursor.c b/src/i830_cursor.c
index 419fd583..ef9a81ee 100644
--- a/src/i830_cursor.c
+++ b/src/i830_cursor.c
@@ -26,7 +26,7 @@ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
**************************************************************************/
-/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/i810/i830_cursor.c,v 1.6 2002/12/18 15:49:01 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/i810/i830_cursor.c,v 1.7 2003/06/18 13:14:17 dawes Exp $ */
/*
* Reformatted with GNU indent (2.2.8), using the following options:
@@ -44,7 +44,7 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
/*
* Authors:
* Keith Whitwell <keith@tungstengraphics.com>
- * David Dawes <dawes@tungstengraphics.com>
+ * David Dawes <dawes@xfree86.org>
*
*/
diff --git a/src/i830_dri.c b/src/i830_dri.c
index 197a8252..37e1d1d6 100644
--- a/src/i830_dri.c
+++ b/src/i830_dri.c
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/i810/i830_dri.c,v 1.12 2003/02/08 21:26:57 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/i810/i830_dri.c,v 1.16 2003/09/28 20:15:58 alanh Exp $ */
/**************************************************************************
Copyright 2001 VA Linux Systems Inc., Fremont, California.
@@ -42,7 +42,7 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
/*
* Authors: Jeff Hartmann <jhartmann@valinux.com>
- * David Dawes <dawes@tungstengraphics.com>
+ * David Dawes <dawes@xfree86.org>
* Keith Whitwell <keith@tungstengraphics.com>
*/
@@ -249,7 +249,7 @@ I830InitVisualConfigs(ScreenPtr pScreen)
pConfigs[i].accumRedSize = 16;
pConfigs[i].accumGreenSize = 16;
pConfigs[i].accumBlueSize = 16;
- pConfigs[i].accumAlphaSize = 16;
+ pConfigs[i].accumAlphaSize = 0;
} else {
pConfigs[i].accumRedSize = 0;
pConfigs[i].accumGreenSize = 0;
@@ -270,10 +270,10 @@ I830InitVisualConfigs(ScreenPtr pScreen)
pConfigs[i].auxBuffers = 0;
pConfigs[i].level = 0;
if (stencil || accum)
- pConfigs[i].visualRating = GLX_SLOW_VISUAL_EXT;
+ pConfigs[i].visualRating = GLX_SLOW_CONFIG;
else
- pConfigs[i].visualRating = GLX_NONE_EXT;
- pConfigs[i].transparentPixel = 0;
+ pConfigs[i].visualRating = GLX_NONE;
+ pConfigs[i].transparentPixel = GLX_NONE;
pConfigs[i].transparentRed = 0;
pConfigs[i].transparentGreen = 0;
pConfigs[i].transparentBlue = 0;
@@ -324,16 +324,16 @@ I830InitVisualConfigs(ScreenPtr pScreen)
pConfigs[i].redSize = 8;
pConfigs[i].greenSize = 8;
pConfigs[i].blueSize = 8;
- pConfigs[i].alphaSize = 0;
+ pConfigs[i].alphaSize = 8;
pConfigs[i].redMask = 0x00FF0000;
pConfigs[i].greenMask = 0x0000FF00;
pConfigs[i].blueMask = 0x000000FF;
- pConfigs[i].alphaMask = 0x00000000;;
+ pConfigs[i].alphaMask = 0xFF000000;;
if (accum) {
pConfigs[i].accumRedSize = 16;
pConfigs[i].accumGreenSize = 16;
pConfigs[i].accumBlueSize = 16;
- pConfigs[i].accumAlphaSize = 0;
+ pConfigs[i].accumAlphaSize = 16;
} else {
pConfigs[i].accumRedSize = 0;
pConfigs[i].accumGreenSize = 0;
@@ -346,7 +346,7 @@ I830InitVisualConfigs(ScreenPtr pScreen)
pConfigs[i].doubleBuffer = FALSE;
}
pConfigs[i].stereo = FALSE;
- pConfigs[i].bufferSize = 24;
+ pConfigs[i].bufferSize = 32;
if (depth) {
pConfigs[i].depthSize = 24;
pConfigs[i].stencilSize = 8;
@@ -357,11 +357,11 @@ I830InitVisualConfigs(ScreenPtr pScreen)
pConfigs[i].auxBuffers = 0;
pConfigs[i].level = 0;
if (accum) {
- pConfigs[i].visualRating = GLX_SLOW_VISUAL_EXT;
+ pConfigs[i].visualRating = GLX_SLOW_CONFIG;
} else {
- pConfigs[i].visualRating = GLX_NONE_EXT;
+ pConfigs[i].visualRating = GLX_NONE;
}
- pConfigs[i].transparentPixel = 0;
+ pConfigs[i].transparentPixel = GLX_NONE;
pConfigs[i].transparentRed = 0;
pConfigs[i].transparentGreen = 0;
pConfigs[i].transparentBlue = 0;
@@ -757,9 +757,15 @@ I830DRICloseScreen(ScreenPtr pScreen)
{
ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
I830Ptr pI830 = I830PTR(pScrn);
+ I830DRIPtr pI830DRI = (I830DRIPtr) pI830->pDRIInfo->devPrivate;
DPRINTF(PFX, "I830DRICloseScreen\n");
+ if (pI830DRI->irq) {
+ drmCtlUninstHandler(pI830->drmSubFD);
+ pI830DRI->irq = 0;
+ }
+
I830CleanupDma(pScrn);
DRICloseScreen(pScreen);
@@ -823,6 +829,9 @@ I830DRISwapContext(ScreenPtr pScreen, DRISyncType syncType,
ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
I830Ptr pI830 = I830PTR(pScrn);
+ if (!pScrn->vtSema)
+ return;
+
if (syncType == DRI_3D_SYNC &&
oldContextType == DRI_2D_CONTEXT && newContextType == DRI_2D_CONTEXT) {
ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
@@ -1455,7 +1464,11 @@ I830EmitInvarientState(ScrnInfoPtr pScrn)
STENCIL_TEST_FUNC(COMPAREFUNC_ALWAYS) |
ENABLE_STENCIL_REF_VALUE | STENCIL_REF_VALUE(0));
- OUT_RING(VRTX_FORMAT_NTEX(1));
+ OUT_RING(STATE3D_VERTEX_FORMAT_CMD |
+ VRTX_TEX_COORD_COUNT(1) |
+ VRTX_HAS_SPEC |
+ VRTX_HAS_DIFFUSE |
+ VRTX_HAS_XYZW);
OUT_RING(STATE3D_VERTEX_FORMAT_2_CMD |
VRTX_TEX_SET_0_FMT(TEXCOORDFMT_2D) |
diff --git a/src/i830_dri.h b/src/i830_dri.h
index b60c7201..51a7fdf6 100644
--- a/src/i830_dri.h
+++ b/src/i830_dri.h
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/i810/i830_dri.h,v 1.5 2002/12/10 01:27:05 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/i810/i830_dri.h,v 1.7 2003/10/21 02:17:52 dawes Exp $ */
#ifndef _I830_DRI_H
#define _I830_DRI_H
@@ -72,12 +72,6 @@ typedef struct {
/* Warning: If you change the SAREA structure you must change the kernel
* structure as well */
-typedef struct _I830TexRegion {
- unsigned char next, prev; /* indices to form a circular LRU */
- unsigned char in_use; /* owned by a client, or free? */
- int age; /* tracked by clients to update local LRU's */
-} I830TexRegion;
-
typedef struct _I830SAREA {
unsigned int ContextState[I830_CTX_SETUP_SIZE];
unsigned int BufferState[I830_DEST_SETUP_SIZE];
@@ -106,7 +100,7 @@ typedef struct _I830SAREA {
* them all in LRU order.
*/
- I830TexRegion texList[I830_NR_TEX_REGIONS + 1];
+ drmTextureRegion texList[I830_NR_TEX_REGIONS + 1];
/* Last elt is sentinal */
int texAge; /* last time texture was uploaded */
int last_enqueue; /* last time a buffer was enqueued */
@@ -131,7 +125,7 @@ typedef struct _I830SAREA {
unsigned int TexState3[I830_TEX_SETUP_SIZE];
unsigned int TexBlendState3[I830_TEXBLEND_SIZE];
unsigned int TexBlendStateWordsUsed3;
-
+
unsigned int StippleState[I830_STP_SETUP_SIZE];
} I830SAREARec, *I830SAREAPtr;
diff --git a/src/i830_driver.c b/src/i830_driver.c
index 073f8eb6..539dcece 100644
--- a/src/i830_driver.c
+++ b/src/i830_driver.c
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/i810/i830_driver.c,v 1.27 2003/02/14 17:12:42 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/i810/i830_driver.c,v 1.47 2003/11/03 14:47:28 alanh Exp $ */
/**************************************************************************
Copyright 2001 VA Linux Systems Inc., Fremont, California.
@@ -43,7 +43,7 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
/*
* Authors: Jeff Hartmann <jhartmann@valinux.com>
* Abraham van der Merwe <abraham@2d3d.co.za>
- * David Dawes <dawes@tungstengraphics.com>
+ * David Dawes <dawes@xfree86.org>
*/
/*
@@ -154,7 +154,7 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
#include "micmap.h"
#include "fb.h"
-#include "miscstruct.h"
+#include "regionstr.h"
#include "xf86xv.h"
#include "Xv.h"
#include "vbe.h"
@@ -201,9 +201,7 @@ typedef enum {
OPTION_PAGEFLIP,
OPTION_XVIDEO,
OPTION_VIDEO_KEY,
- OPTION_COLOR_KEY,
- OPTION_STRETCH,
- OPTION_CENTER
+ OPTION_COLOR_KEY
} I830Opts;
static OptionInfoRec I830BIOSOptions[] = {
@@ -215,8 +213,6 @@ static OptionInfoRec I830BIOSOptions[] = {
{OPTION_XVIDEO, "XVideo", OPTV_BOOLEAN, {0}, TRUE},
{OPTION_COLOR_KEY, "ColorKey", OPTV_INTEGER, {0}, FALSE},
{OPTION_VIDEO_KEY, "VideoKey", OPTV_INTEGER, {0}, FALSE},
- {OPTION_STRETCH, "Stretch", OPTV_BOOLEAN, {0}, FALSE},
- {OPTION_CENTER, "Center", OPTV_BOOLEAN, {0}, FALSE},
{-1, NULL, OPTV_NONE, {0}, FALSE}
};
/* *INDENT-ON* */
@@ -230,9 +226,6 @@ static Bool I830BIOSEnterVT(int scrnIndex, int flags);
static Bool I830VESASetVBEMode(ScrnInfoPtr pScrn, int mode,
VbeCRTCInfoBlock *block);
-static Bool OffsetFrame = FALSE;
-
-
#ifdef I830DEBUG
void
@@ -1066,6 +1059,93 @@ SaveBIOSMemSize(ScrnInfoPtr pScrn)
return FALSE;
}
+/*
+ * TweakMemorySize() tweaks the BIOS image to set the correct size.
+ * Original implementation by Christian Zietz in a stand-alone tool.
+ */
+static CARD32
+TweakMemorySize(ScrnInfoPtr pScrn, CARD32 newsize, Bool preinit)
+{
+#define SIZE 0x10000
+#define IDOFFSET (-23)
+ const char *MAGICstring = "Total time for VGA POST:";
+ const int len = strlen(MAGICstring);
+ I830Ptr pI830 = I830PTR(pScrn);
+ char *position;
+ char *biosAddr;
+ CARD32 oldsize;
+ CARD32 oldpermission;
+ CARD32 ret = 0;
+ int i,j = 0;
+ PCITAG tag =pciTag(0,0,0);
+
+ if(!pI830->PciInfo
+ || !(pI830->PciInfo->chipType == PCI_CHIP_I855_GM
+ || pI830->PciInfo->chipType == PCI_CHIP_I865_G))
+ return 0;
+
+ if (!pI830->pVbe)
+ return 0;
+
+ biosAddr = xf86int10Addr(pI830->pVbe->pInt10,
+ pI830->pVbe->pInt10->BIOSseg << 4);
+
+ if (!pI830->BIOSMemSizeLoc) {
+
+ if (!preinit)
+ return 0;
+
+ /* Search for MAGIC string */
+ for (i = 0; i < SIZE; i++) {
+ if (biosAddr[i] == MAGICstring[j]) {
+ if (++j == len)
+ break;
+ } else {
+ i -= j;
+ j = 0;
+ }
+ }
+ if (j < len) return 0;
+
+ pI830->BIOSMemSizeLoc = (i - j + 1 + IDOFFSET);
+ }
+
+ position = biosAddr + pI830->BIOSMemSizeLoc;
+ oldsize = *(CARD32 *)position;
+ ret = oldsize - (3 << 16);
+
+ /* verify that register really contains current size */
+ if (preinit && ((oldsize) >> 16) - 3 != pI830->vbeInfo->TotalMemory)
+ return 0;
+
+ oldpermission = pciReadLong(tag, DRAM_RW_CONTROL);
+ pciWriteLong(tag, DRAM_RW_CONTROL, 0x33330000);
+
+ *(CARD32 *)position = newsize + (3 << 16);
+ if (preinit) {
+ /* reinitialize VBE for new size */
+ VBEFreeVBEInfo(pI830->vbeInfo);
+ vbeFree(pI830->pVbe);
+ pI830->pVbe = VBEInit(NULL, pI830->pEnt->index);
+ pI830->vbeInfo = VBEGetVBEInfo(pI830->pVbe);
+
+ /* verify that change was successful */
+ if (pI830->vbeInfo->TotalMemory * 64 * 1024 != pI830->newBIOSMemSize) {
+ ret = 0;
+ *(CARD32 *)position = oldsize;
+ } else {
+ pI830->BIOSMemorySize = KB(pI830->vbeInfo->TotalMemory * 64);
+ xf86DrvMsg(pScrn->scrnIndex, X_INFO,
+ "Tweak BIOS image to %d kB VideoRAM\n",
+ (int)(pI830->BIOSMemorySize / 1024));
+ }
+ }
+
+ pciWriteLong(tag, DRAM_RW_CONTROL, oldpermission);
+
+ return ret;
+}
+
static void
RestoreBIOSMemSize(ScrnInfoPtr pScrn)
{
@@ -1074,6 +1154,9 @@ RestoreBIOSMemSize(ScrnInfoPtr pScrn)
DPRINTF(PFX, "RestoreBIOSMemSize\n");
+ if (TweakMemorySize(pScrn, pI830->saveBIOSMemSize,FALSE))
+ return;
+
if (!pI830->overrideBIOSMemSize)
return;
@@ -1096,7 +1179,7 @@ static void
SetBIOSMemSize(ScrnInfoPtr pScrn, int newSize)
{
I830Ptr pI830 = I830PTR(pScrn);
- CARD32 swf1;
+ unsigned long swf1;
Bool mapped;
DPRINTF(PFX, "SetBIOSMemSize: %d kB\n", newSize / 1024);
@@ -1112,7 +1195,7 @@ SetBIOSMemSize(ScrnInfoPtr pScrn, int newSize)
#endif
if ((IS_I830(pI830) || IS_845G(pI830)) && pI830->useSWF1) {
- CARD32 newSWF1;
+ unsigned long newSWF1;
/* Need MMIO access here. */
mapped = (pI830->MMIOBase != NULL);
@@ -1125,10 +1208,10 @@ SetBIOSMemSize(ScrnInfoPtr pScrn, int newSize)
newSWF1 = 8;
swf1 = INREG(SWF1);
- xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Before: SWF1 is 0x%08x\n", swf1);
+ xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Before: SWF1 is 0x%08lx\n", swf1);
swf1 &= ~0x0f;
swf1 |= (newSWF1 & 0x0f);
- xf86DrvMsg(pScrn->scrnIndex, X_INFO, "After: SWF1 is 0x%08x\n", swf1);
+ xf86DrvMsg(pScrn->scrnIndex, X_INFO, "After: SWF1 is 0x%08lx\n", swf1);
OUTREG(SWF1, swf1);
if (!mapped)
I830UnmapMMIO(pScrn);
@@ -1246,6 +1329,7 @@ I830BIOSPreInit(ScrnInfoPtr pScrn, int flags)
return FALSE;
pI830 = I830PTR(pScrn);
+ pI830->SaveGeneration = -1;
pI830->pEnt = pEnt;
if (pI830->pEnt->location.type != BUS_PCI)
@@ -1458,7 +1542,7 @@ I830BIOSPreInit(ScrnInfoPtr pScrn, int flags)
/* Sanity check: compare with what the BIOS thinks. */
if (pI830->vbeInfo->TotalMemory != pI830->StolenMemory.Size / 1024 / 64) {
xf86DrvMsg(pScrn->scrnIndex, X_WARNING,
- "Detected stolen memory (%d kB) doesn't match what the BIOS"
+ "Detected stolen memory (%ld kB) doesn't match what the BIOS"
" reports (%d kB)\n",
ROUND_DOWN_TO(pI830->StolenMemory.Size / 1024, 64),
pI830->vbeInfo->TotalMemory * 64);
@@ -1562,7 +1646,7 @@ I830BIOSPreInit(ScrnInfoPtr pScrn, int flags)
"VideoRam reduced to %d kByte (limited to aperture size)\n",
pScrn->videoRam);
}
-
+
if (mem > 0) {
/*
* If the reserved (BIOS accessible) memory is less than the desired
@@ -1589,13 +1673,11 @@ I830BIOSPreInit(ScrnInfoPtr pScrn, int flags)
else
pI830->newBIOSMemSize =
KB(ROUND_DOWN_TO(pScrn->videoRam - reserve, 64));
-
if (pI830->vbeInfo->TotalMemory * 64 < pI830->newBIOSMemSize / 1024) {
xf86DrvMsg(pScrn->scrnIndex, X_INFO,
"Will attempt to tell the BIOS that there is "
"%d kB VideoRAM\n", pI830->newBIOSMemSize / 1024);
-
if (SaveBIOSMemSize(pScrn)) {
pI830->overrideBIOSMemSize = TRUE;
SetBIOSMemSize(pScrn, pI830->newBIOSMemSize);
@@ -1608,17 +1690,22 @@ I830BIOSPreInit(ScrnInfoPtr pScrn, int flags)
pI830->BIOSMemorySize = KB(pI830->vbeInfo->TotalMemory * 64);
xf86DrvMsg(pScrn->scrnIndex, X_INFO,
- "BIOS now sees %d kB VideoRAM\n",
+ "BIOS now sees %ld kB VideoRAM\n",
pI830->BIOSMemorySize / 1024);
- } else {
- xf86DrvMsg(pScrn->scrnIndex, X_INFO,
- "BIOS view of memory size can't be changed "
- "(this is not an error).\n");
+ } else if ((pI830->saveBIOSMemSize
+ = TweakMemorySize(pScrn, pI830->newBIOSMemSize, TRUE)) != 0)
+ pI830->overrideBIOSMemSize = TRUE;
+ else {
+ xf86DrvMsg(pScrn->scrnIndex, X_INFO,
+ "BIOS view of memory size can't be changed "
+ "(this is not an error).\n");
}
}
}
- xf86DrvMsg(pScrn->scrnIndex, X_PROBED, "Pre-allocated VideoRAM: %d kByte\n",
+ pVbe = pI830->pVbe;
+
+ xf86DrvMsg(pScrn->scrnIndex, X_PROBED, "Pre-allocated VideoRAM: %ld kByte\n",
pI830->StolenMemory.Size / 1024);
xf86DrvMsg(pScrn->scrnIndex, from, "VideoRAM: %d kByte\n", pScrn->videoRam);
pI830->TotalVideoRam = KB(pScrn->videoRam);
@@ -1677,8 +1764,8 @@ I830BIOSPreInit(ScrnInfoPtr pScrn, int flags)
else
pI830->CursorNeedsPhysical = FALSE;
- /* Force ring buffer to be in low memory for the 845G. */
- if (IS_845G(pI830))
+ /* Force ring buffer to be in low memory for the 845G and later. */
+ if (IS_845G(pI830) || IS_I85X(pI830) || IS_I865G(pI830))
pI830->NeedRingBufferLow = TRUE;
/*
@@ -1923,7 +2010,7 @@ I830BIOSPreInit(ScrnInfoPtr pScrn, int flags)
xf86DrvMsg(pScrn->scrnIndex, X_WARNING,
"Allocation with DRI tiling enabled would "
"exceed the\n"
- "\tmemory aperture size (%d kB) by %d kB.\n"
+ "\tmemory aperture size (%ld kB) by %ld kB.\n"
"\tReduce VideoRam amount to avoid this!\n",
pI830->FbMapSize / 1024,
-pI830->MemoryAperture.Size / 1024);
@@ -1947,6 +2034,7 @@ I830BIOSPreInit(ScrnInfoPtr pScrn, int flags)
* Tiling can't be enabled. Check if there's enough memory for DRI
* without tiling.
*/
+ pI830->disableTiling = TRUE;
I830ResetAllocations(pScrn, 0);
if (I830Allocate2DMemory(pScrn, ALLOCATE_DRY_RUN | ALLOC_INITIAL) &&
I830Allocate3DMemory(pScrn, ALLOCATE_DRY_RUN | ALLOC_NO_TILING)) {
@@ -1962,7 +2050,7 @@ I830BIOSPreInit(ScrnInfoPtr pScrn, int flags)
xf86DrvMsg(pScrn->scrnIndex, X_WARNING,
"Allocation with DRI enabled would "
"exceed the\n"
- "\tmemory aperture size (%d kB) by %d kB.\n"
+ "\tmemory aperture size (%ld kB) by %ld kB.\n"
"\tReduce VideoRam amount to avoid this!\n",
pI830->FbMapSize / 1024,
-pI830->MemoryAperture.Size / 1024);
@@ -2037,6 +2125,14 @@ I830BIOSPreInit(ScrnInfoPtr pScrn, int flags)
vbeFree(pVbe);
#if defined(XF86DRI)
+ /* Load the dri module if requested. */
+ if (xf86ReturnOptValBool(pI830->Options, OPTION_DRI, FALSE) &&
+ !pI830->directRenderingDisabled) {
+ if (xf86LoadSubModule(pScrn, "dri")) {
+ xf86LoaderReqSymLists(I810driSymbols, I810drmSymbols, NULL);
+ }
+ }
+
if (!pI830->directRenderingDisabled) {
if (!xf86LoadSubModule(pScrn, "shadow")) {
PreInitCleanup(pScrn);
@@ -2063,26 +2159,26 @@ CheckInheritedState(ScrnInfoPtr pScrn)
/* Check first for page table errors */
temp = INREG(PGE_ERR);
if (temp != 0) {
- xf86DrvMsg(pScrn->scrnIndex, X_WARNING, "PGTBL_ER is 0x%08x\n", temp);
+ xf86DrvMsg(pScrn->scrnIndex, X_WARNING, "PGTBL_ER is 0x%08lx\n", temp);
errors++;
}
temp = INREG(PGETBL_CTL);
if (!(temp & 1)) {
xf86DrvMsg(pScrn->scrnIndex, X_WARNING,
- "PGTBL_CTL (0x%08x) indicates GTT is disabled\n", temp);
+ "PGTBL_CTL (0x%08lx) indicates GTT is disabled\n", temp);
errors++;
}
temp = INREG(LP_RING + RING_LEN);
if (temp & 1) {
xf86DrvMsg(pScrn->scrnIndex, X_WARNING,
- "PRB0_CTL (0x%08x) indicates ring buffer enabled\n", temp);
+ "PRB0_CTL (0x%08lx) indicates ring buffer enabled\n", temp);
errors++;
}
head = INREG(LP_RING + RING_HEAD);
tail = INREG(LP_RING + RING_TAIL);
if ((tail & I830_TAIL_MASK) != (head & I830_HEAD_MASK)) {
xf86DrvMsg(pScrn->scrnIndex, X_WARNING,
- "PRB0_HEAD (0x%08x) and PRB0_TAIL (0x%08x) indicate "
+ "PRB0_HEAD (0x%08lx) and PRB0_TAIL (0x%08lx) indicate "
"ring buffer not flushed\n", head, tail);
errors++;
}
@@ -2167,7 +2263,7 @@ SetRingRegs(ScrnInfoPtr pScrn)
if ((pI830->LpRing.mem.Start & I830_RING_START_MASK) !=
pI830->LpRing.mem.Start) {
xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
- "I830SetRingRegs: Ring buffer start (%x) violates its "
+ "I830SetRingRegs: Ring buffer start (%lx) violates its "
"mask (%x)\n", pI830->LpRing.mem.Start, I830_RING_START_MASK);
}
/* Don't care about the old value. Reserved bits must be zero anyway. */
@@ -2177,7 +2273,7 @@ SetRingRegs(ScrnInfoPtr pScrn)
if (((pI830->LpRing.mem.Size - 4096) & I830_RING_NR_PAGES) !=
pI830->LpRing.mem.Size - 4096) {
xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
- "I830SetRingRegs: Ring buffer size - 4096 (%x) violates its "
+ "I830SetRingRegs: Ring buffer size - 4096 (%lx) violates its "
"mask (%x)\n", pI830->LpRing.mem.Size - 4096,
I830_RING_NR_PAGES);
}
@@ -2238,16 +2334,17 @@ SaveHWState(ScrnInfoPtr pScrn)
#endif
pVesa = pI830->vesa;
- /* This save/restore method doesn't work for 845G BIOS */
/*
- * XXX If it's fixed in production versions, this could be removed.
- *
+ * This save/restore method doesn't work for 845G BIOS, or for some
+ * other platforms. Enable it in all cases.
+ */
+ /*
* KW: This may have been because of the behaviour I've found on my
* board: The 'save' command actually modifies the interrupt
* registers, turning off the irq & breaking the kernel module
* behaviour.
*/
- if (!I845G_VBE_WORKAROUND || !IS_845G(pI830)) {
+ if (!I845G_VBE_WORKAROUND) {
CARD16 imr = INREG16(IMR);
CARD16 ier = INREG16(IER);
CARD16 hwstam = INREG16(HWSTAM);
@@ -2546,10 +2643,10 @@ I830VESASetMode(ScrnInfoPtr pScrn, DisplayModePtr pMode)
* Print out the PIPEACONF and PIPEBCONF registers.
*/
temp = INREG(PIPEACONF);
- xf86DrvMsg(pScrn->scrnIndex, X_INFO, "PIPEACONF is 0x%08x\n", temp);
+ xf86DrvMsg(pScrn->scrnIndex, X_INFO, "PIPEACONF is 0x%08lx\n", temp);
if (IS_MOBILE(pI830)) {
temp = INREG(PIPEBCONF);
- xf86DrvMsg(pScrn->scrnIndex, X_INFO, "PIPEBCONF is 0x%08x\n", temp);
+ xf86DrvMsg(pScrn->scrnIndex, X_INFO, "PIPEBCONF is 0x%08lx\n", temp);
}
#if PRINT_MODE_INFO
@@ -2594,7 +2691,7 @@ I830VESASetMode(ScrnInfoPtr pScrn, DisplayModePtr pMode)
if (temp / pI830->cpp != pScrn->displayWidth) {
xf86DrvMsg(pScrn->scrnIndex, X_WARNING,
"Correcting plane %c stride (%d -> %d)\n", PIPE_NAME(i),
- temp / pI830->cpp, pScrn->displayWidth);
+ (int)(temp / pI830->cpp), pScrn->displayWidth);
OUTREG(stridereg, pScrn->displayWidth * pI830->cpp);
/* Trigger update */
temp = INREG(basereg);
@@ -2892,7 +2989,8 @@ I830BIOSScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv)
* first, then re-initialise the VBE information.
*/
pI830->pVbe = VBEInit(NULL, pI830->pEnt->index);
- SetBIOSMemSize(pScrn, pI830->newBIOSMemSize);
+ if (!TweakMemorySize(pScrn, pI830->newBIOSMemSize,FALSE))
+ SetBIOSMemSize(pScrn, pI830->newBIOSMemSize);
if (!pI830->pVbe)
return FALSE;
pI830->vbeInfo = VBEGetVBEInfo(pI830->pVbe);
@@ -2991,9 +3089,13 @@ I830BIOSScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv)
if (pI830->directRenderingEnabled)
pI830->directRenderingEnabled = I830DRIScreenInit(pScreen);
- if (pI830->directRenderingEnabled)
- if (!(pI830->directRenderingEnabled = I830Allocate3DMemory(pScrn, 0)))
+ if (pI830->directRenderingEnabled) {
+ pI830->directRenderingEnabled =
+ I830Allocate3DMemory(pScrn,
+ pI830->disableTiling ? ALLOC_NO_TILING : 0);
+ if (!pI830->directRenderingEnabled)
I830DRICloseScreen(pScreen);
+ }
#else
pI830->directRenderingEnabled = FALSE;
@@ -3027,6 +3129,9 @@ I830BIOSScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv)
pScrn->memPhysBase = (unsigned long)pI830->FbBase;
pScrn->fbOffset = pI830->FrontBuffer.Start;
+ pI830->xoffset = (pScrn->fbOffset / pI830->cpp) % pScrn->displayWidth;
+ pI830->yoffset = (pScrn->fbOffset / pI830->cpp) / pScrn->displayWidth;
+
vgaHWSetMmioFuncs(hwp, pI830->MMIOBase, 0);
vgaHWGetIOBase(hwp);
DPRINTF(PFX, "assert( if(!vgaHWMapMem(pScrn)) )\n");
@@ -3108,9 +3213,7 @@ I830BIOSScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv)
return FALSE;
}
-#ifdef DPMSExtension
xf86DPMSInit(pScreen, I830DisplayPowerManagementSet, 0);
-#endif
#ifdef I830_XV
/* Init video */
@@ -3164,34 +3267,15 @@ I830BIOSAdjustFrame(int scrnIndex, int x, int y, int flags)
ScrnInfoPtr pScrn;
I830Ptr pI830;
vbeInfoPtr pVbe;
- static int xoffset = 0, yoffset = 0;
- static int adjustGeneration = -1;
pScrn = xf86Screens[scrnIndex];
pI830 = I830PTR(pScrn);
pVbe = pI830->pVbe;
DPRINTF(PFX, "I830BIOSAdjustFrame: y = %d (+ %d), x = %d (+ %d)\n",
- x, xoffset, y, yoffset);
+ x, pI830->xoffset, y, pI830->yoffset);
- /* Calculate the offsets once per server generation. */
- if (adjustGeneration != serverGeneration) {
- adjustGeneration = serverGeneration;
- xoffset = (pScrn->fbOffset / pI830->cpp) % pScrn->displayWidth;
- yoffset = (pScrn->fbOffset / pI830->cpp) / pScrn->displayWidth;
- }
-
- if (OffsetFrame) {
- y = (pI830->FbMemBox.y2 - pScrn->currentMode->VDisplay);
- ErrorF("AdjustFrame: OffsetFrame is set, setting y to %d\n", y);
- }
- x += xoffset;
- y += yoffset;
-#if 0
- x >>= 4;
- x <<= 4;
-#endif
- VBESetDisplayStart(pVbe, x, y, TRUE);
+ VBESetDisplayStart(pVbe, x + pI830->xoffset, y + pI830->yoffset, TRUE);
}
static void
@@ -3234,9 +3318,7 @@ static void
I830BIOSLeaveVT(int scrnIndex, int flags)
{
ScrnInfoPtr pScrn = xf86Screens[scrnIndex];
-#ifdef XF86DRI
I830Ptr pI830 = I830PTR(pScrn);
-#endif
DPRINTF(PFX, "Leave VT\n");
@@ -3257,6 +3339,8 @@ I830BIOSLeaveVT(int scrnIndex, int flags)
RestoreHWState(pScrn);
RestoreBIOSMemSize(pScrn);
I830UnbindGARTMemory(pScrn);
+ if (pI830->AccelInfoRec)
+ pI830->AccelInfoRec->NeedToSync = FALSE;
}
/*
@@ -3267,7 +3351,6 @@ I830BIOSEnterVT(int scrnIndex, int flags)
{
ScrnInfoPtr pScrn = xf86Screens[scrnIndex];
I830Ptr pI830 = I830PTR(pScrn);
- static int SaveGeneration = -1;
DPRINTF(PFX, "Enter VT\n");
@@ -3275,14 +3358,15 @@ I830BIOSEnterVT(int scrnIndex, int flags)
return FALSE;
CheckInheritedState(pScrn);
- SetBIOSMemSize(pScrn, pI830->newBIOSMemSize);
+ if (!TweakMemorySize(pScrn, pI830->newBIOSMemSize,FALSE))
+ SetBIOSMemSize(pScrn, pI830->newBIOSMemSize);
/*
* Only save state once per server generation since that's what most
* drivers do. Could change this to save state at each VT enter.
*/
- if (SaveGeneration != serverGeneration) {
- SaveGeneration = serverGeneration;
+ if (pI830->SaveGeneration != serverGeneration) {
+ pI830->SaveGeneration = serverGeneration;
SaveHWState(pScrn);
}
ResetState(pScrn, FALSE);
@@ -3348,11 +3432,6 @@ I830BIOSSwitchMode(int scrnIndex, DisplayModePtr mode, int flags)
} while (_head != _tail);
}
-#if 0
- OffsetFrame = !OffsetFrame;
- pScrn->AdjustFrame(scrnIndex, 0, 0, 0);
-#endif
-
#ifndef BINDUNBIND
#define BINDUNBIND 0
#endif
@@ -3386,35 +3465,36 @@ I830BIOSSaveScreen(ScreenPtr pScreen, int mode)
DPRINTF(PFX, "I830BIOSSaveScreen: %d, on is %s\n", mode, BOOLTOSTRING(on));
- for (i = 0; i < MAX_DISPLAY_PIPES; i++) {
- if (i == 0) {
- ctrl = DSPACNTR;
- base = DSPABASE;
- } else {
- ctrl = DSPBCNTR;
- base = DSPBADDR;
+ if (pScrn->vtSema) {
+ for (i = 0; i < MAX_DISPLAY_PIPES; i++) {
+ if (i == 0) {
+ ctrl = DSPACNTR;
+ base = DSPABASE;
+ } else {
+ ctrl = DSPBCNTR;
+ base = DSPBADDR;
+ }
+ if (pI830->planeEnabled[i]) {
+ temp = INREG(ctrl);
+ if (on)
+ temp |= DISPLAY_PLANE_ENABLE;
+ else
+ temp &= ~DISPLAY_PLANE_ENABLE;
+ OUTREG(ctrl, temp);
+ /* Flush changes */
+ temp = INREG(base);
+ OUTREG(base, temp);
+ }
}
- if (pI830->planeEnabled[i]) {
- temp = INREG(ctrl);
+
+ if (pI830->CursorInfoRec && !pI830->SWCursor && pI830->cursorOn) {
if (on)
- temp |= DISPLAY_PLANE_ENABLE;
+ pI830->CursorInfoRec->ShowCursor(pScrn);
else
- temp &= ~DISPLAY_PLANE_ENABLE;
- OUTREG(ctrl, temp);
- /* Flush changes */
- temp = INREG(base);
- OUTREG(base, temp);
+ pI830->CursorInfoRec->HideCursor(pScrn);
+ pI830->cursorOn = TRUE;
}
}
-
- if (pI830->CursorInfoRec && !pI830->SWCursor && pI830->cursorOn) {
- if (on)
- pI830->CursorInfoRec->ShowCursor(pScrn);
- else
- pI830->CursorInfoRec->HideCursor(pScrn);
- pI830->cursorOn = TRUE;
- }
-
return TRUE;
}
@@ -3498,7 +3578,7 @@ I830BIOSCloseScreen(int scrnIndex, ScreenPtr pScreen)
return (*pScreen->CloseScreen) (scrnIndex, pScreen);
}
-static int
+static ModeStatus
I830ValidMode(int scrnIndex, DisplayModePtr mode, Bool verbose, int flags)
{
if (mode->Flags & V_INTERLACE) {
@@ -3584,3 +3664,5 @@ I830InitpScrn(ScrnInfoPtr pScrn)
pScrn->ValidMode = I830ValidMode;
pScrn->PMEvent = I830PMEvent;
}
+
+
diff --git a/src/i830_memory.c b/src/i830_memory.c
index 16693d4a..c038e5d7 100644
--- a/src/i830_memory.c
+++ b/src/i830_memory.c
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/i810/i830_memory.c,v 1.6 2003/02/08 02:26:56 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/i810/i830_memory.c,v 1.10 2003/10/21 02:17:52 dawes Exp $ */
/**************************************************************************
Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
@@ -44,7 +44,7 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
/*
* Authors:
* Keith Whitwell <keith@tungstengraphics.com>
- * David Dawes <dawes@tungstengraphics.com>
+ * David Dawes <dawes@xfree86.org>
*
*/
@@ -279,7 +279,7 @@ AllocateRingBuffer(ScrnInfoPtr pScrn, int flags)
return FALSE;
}
xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, verbosity,
- "%sAllocated %d kB for the ring buffer at 0x%x\n", s,
+ "%sAllocated %ld kB for the ring buffer at 0x%lx\n", s,
alloced / 1024, pI830->LpRing.mem.Start);
pI830->LpRing.tail_mask = pI830->LpRing.mem.Size - 1;
return TRUE;
@@ -335,8 +335,8 @@ AllocateOverlay(ScrnInfoPtr pScrn, int flags)
/* This failure isn't fatal. */
} else {
xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, verbosity,
- "%sAllocated %d kB for Overlay registers at 0x%x "
- "(0x%08x).\n", s,
+ "%sAllocated %ld kB for Overlay registers at 0x%lx "
+ "(0x%08lx).\n", s,
alloced / 1024, pI830->OverlayMem.Start,
pI830->OverlayMem.Physical);
}
@@ -503,7 +503,7 @@ I830Allocate2DMemory(ScrnInfoPtr pScrn, const int flags)
size = lineSize * (pScrn->virtualY + cacheLines);
size = ROUND_TO_PAGE(size);
xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, verbosity,
- "%sInitial framebuffer allocation size: %d kByte\n", s,
+ "%sInitial framebuffer allocation size: %ld kByte\n", s,
size / 1024);
alloced = I830AllocVidMem(pScrn, &(pI830->FrontBuffer),
&(pI830->StolenPool), size, align,
@@ -547,7 +547,7 @@ I830Allocate2DMemory(ScrnInfoPtr pScrn, const int flags)
xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
"Internal error in I830Allocate2DMemory():\n\t"
"Framebuffer isn't the last allocation at the bottom"
- " of StolenPool\n\t(%x != %x).\n",
+ " of StolenPool\n\t(%lx != %lx).\n",
pI830->FrontBuffer.End,
pI830->StolenPool.Free.Start);
return FALSE;
@@ -564,10 +564,10 @@ I830Allocate2DMemory(ScrnInfoPtr pScrn, const int flags)
pI830->StolenPool.Free.Size += pI830->FrontBuffer.Size;
pI830->StolenPool.Free.Start -= pI830->FrontBuffer.Size;
xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, verbosity,
- "%sUpdated framebuffer allocation size from %d "
- "to %d kByte\n", s, oldsize / 1024, maxFb / 1024);
+ "%sUpdated framebuffer allocation size from %ld "
+ "to %ld kByte\n", s, oldsize / 1024, maxFb / 1024);
xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, verbosity,
- "%sUpdated pixmap cache from %d scanlines to %d "
+ "%sUpdated pixmap cache from %ld scanlines to %ld "
"scanlines\n", s,
oldsize / lineSize - pScrn->virtualY,
maxFb / lineSize - pScrn->virtualY);
@@ -636,10 +636,10 @@ I830Allocate2DMemory(ScrnInfoPtr pScrn, const int flags)
}
} else {
xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, verbosity,
- "%sAllocated %d kB for HW cursor at 0x%x", s,
+ "%sAllocated %ld kB for HW cursor at 0x%lx", s,
alloced / 1024, pI830->CursorMem.Start);
if (pI830->CursorNeedsPhysical)
- xf86ErrorFVerb(verbosity, " (0x%08x)", pI830->CursorMem.Physical);
+ xf86ErrorFVerb(verbosity, " (0x%08lx)", pI830->CursorMem.Physical);
xf86ErrorFVerb(verbosity, "\n");
}
}
@@ -675,7 +675,7 @@ I830Allocate2DMemory(ScrnInfoPtr pScrn, const int flags)
return FALSE;
}
xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, verbosity,
- "%sAllocated %d kB for the scratch buffer at 0x%x\n", s,
+ "%sAllocated %ld kB for the scratch buffer at 0x%lx\n", s,
alloced / 1024, pI830->Scratch.Start);
}
return TRUE;
@@ -806,7 +806,7 @@ I830Allocate3DMemory(ScrnInfoPtr pScrn, const int flags)
return FALSE;
}
xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, verbosity,
- "%sAllocated %d kB for the back buffer at 0x%x.\n", s,
+ "%sAllocated %ld kB for the back buffer at 0x%lx.\n", s,
alloced / 1024, pI830->BackBuffer.Start);
/* Depth Buffer -- same size as the back buffer */
@@ -844,7 +844,7 @@ I830Allocate3DMemory(ScrnInfoPtr pScrn, const int flags)
return FALSE;
}
xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, verbosity,
- "%sAllocated %d kB for the depth buffer at 0x%x.\n", s,
+ "%sAllocated %ld kB for the depth buffer at 0x%lx.\n", s,
alloced / 1024, pI830->DepthBuffer.Start);
/* Space for logical context. 32k is fine for right now. */
@@ -862,7 +862,7 @@ I830Allocate3DMemory(ScrnInfoPtr pScrn, const int flags)
return FALSE;
}
xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, verbosity,
- "%sAllocated %d kB for the logical context at 0x%x.\n", s,
+ "%sAllocated %ld kB for the logical context at 0x%lx.\n", s,
alloced / 1024, pI830->ContextMem.Start);
/*
@@ -886,7 +886,7 @@ I830Allocate3DMemory(ScrnInfoPtr pScrn, const int flags)
return FALSE;
}
xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, verbosity,
- "%sAllocated %d kB for the DMA buffers at 0x%x.\n", s,
+ "%sAllocated %ld kB for the DMA buffers at 0x%lx.\n", s,
alloced / 1024, pI830->BufferMem.Start);
} else {
if (!dryrun) {
@@ -912,7 +912,7 @@ I830Allocate3DMemory(ScrnInfoPtr pScrn, const int flags)
if (size < KB(512)) {
if (!dryrun) {
xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
- "Less than %d kBytes for texture space.\n", size / 1024);
+ "Less than %ld kBytes for texture space.\n", size / 1024);
}
return FALSE;
}
@@ -927,7 +927,7 @@ I830Allocate3DMemory(ScrnInfoPtr pScrn, const int flags)
return FALSE;
}
xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, verbosity,
- "%sAllocated %d kB for textures at 0x%x\n", s,
+ "%sAllocated %ld kB for textures at 0x%lx\n", s,
alloced / 1024, pI830->TexMem.Start);
return TRUE;
@@ -1052,7 +1052,7 @@ FixOffset(ScrnInfoPtr pScrn, I830MemRange *mem)
}
#endif
xf86DrvMsg(pScrn->scrnIndex, X_INFO,
- "%p: Memory at offset 0x%08x, size %d kBytes\n", mem,
+ "%p: Memory at offset 0x%08lx, size %ld kBytes\n", (void *)mem,
mem->Start, mem->Size / 1024);
return TRUE;
}
@@ -1108,7 +1108,7 @@ SetFence(ScrnInfoPtr pScrn, int nr, unsigned int start, unsigned int pitch,
if (nr < 0 || nr > 7) {
xf86DrvMsg(X_WARNING, pScrn->scrnIndex,
- "SetFence: fence %d out of range\n");
+ "SetFence: fence %d out of range\n", nr);
return;
}
@@ -1298,7 +1298,7 @@ I830SetupMemoryTiling(ScrnInfoPtr pScrn)
"MakeTiles failed for the back buffer.\n");
}
}
-
+
}
#endif /* XF86DRI */
diff --git a/src/i830_video.c b/src/i830_video.c
index 25f9716b..f665d74e 100644
--- a/src/i830_video.c
+++ b/src/i830_video.c
@@ -1,6 +1,6 @@
#define VIDEO_DEBUG 0
/***************************************************************************
-
+
Copyright 2000 Intel Corporation. All Rights Reserved.
Permission is hereby granted, free of charge, to any person obtaining a
@@ -24,7 +24,7 @@ OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
THE USE OR OTHER DEALINGS IN THE SOFTWARE.
**************************************************************************/
-/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/i810/i830_video.c,v 1.6 2003/02/06 04:18:05 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/i810/i830_video.c,v 1.12 2003/11/10 18:22:22 tsi Exp $ */
/*
* Reformatted with GNU indent (2.2.8), using the following options:
@@ -46,7 +46,7 @@ THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
* Authors:
* Alan Hourihane <alanh@tungstengraphics.com>
- * David Dawes <dawes@tungstengraphics.com>
+ * David Dawes <dawes@xfree86.org>
*
* Derived from i810 Xv driver:
*
@@ -631,11 +631,15 @@ I830SetupImageVideo(ScreenPtr pScreen)
}
/* gotta uninit this someplace */
- REGION_INIT(pScreen, &pPriv->clip, NullBox, 0);
+ REGION_NULL(pScreen, &pPriv->clip);
pI830->adaptor = adapt;
- /* Initialise pPriv->refreshOK */
+ /*
+ * Initialise pPriv->refreshOK. Set it to TRUE here so that a warning will
+ * be generated if I830VideoSwitchModeAfter() sets it to FALSE.
+ */
+ pPriv->refreshOK = TRUE;
I830VideoSwitchModeAfter(pScrn, pScrn->currentMode);
pI830->BlockHandler = pScreen->BlockHandler;
@@ -650,34 +654,6 @@ I830SetupImageVideo(ScreenPtr pScreen)
return adapt;
}
-static Bool
-RegionsEqual(RegionPtr A, RegionPtr B)
-{
- int *dataA, *dataB;
- int num;
-
- num = REGION_NUM_RECTS(A);
- if (num != REGION_NUM_RECTS(B))
- return FALSE;
-
- if ((A->extents.x1 != B->extents.x1) ||
- (A->extents.x2 != B->extents.x2) ||
- (A->extents.y1 != B->extents.y1) || (A->extents.y2 != B->extents.y2))
- return FALSE;
-
- dataA = (int *)REGION_RECTS(A);
- dataB = (int *)REGION_RECTS(B);
-
- while (num--) {
- if ((dataA[0] != dataB[0]) || (dataA[1] != dataB[1]))
- return FALSE;
- dataA += 2;
- dataB += 2;
- }
-
- return TRUE;
-}
-
static void
I830StopVideo(ScrnInfoPtr pScrn, pointer data, Bool shutdown)
{
@@ -1013,7 +989,7 @@ UpdateCoeff(int taps, double fCutoff, Bool isHoriz, Bool isY, coeffPtr pCoeff)
SetCoeffRegs(&coeffs[i][tap2Fix], mantSize + 2, pCoeff, pos);
else
SetCoeffRegs(&coeffs[i][tap2Fix], mantSize, pCoeff, pos);
-
+
sum = 0.0;
for (j = 0; j < taps; j++)
sum += coeffs[i][j];
@@ -1175,7 +1151,7 @@ I830DisplayVideo(ScrnInfoPtr pScrn, int id, short width, short height,
scaleChanged = TRUE;
overlay->YRGBSCALE = newval;
}
-
+
newval = (xscaleIntUV << 16) | ((xscaleFractUV & 0xFFF) << 3) |
((yscaleFractUV & 0xFFF) << 20);
if (newval != overlay->UVSCALE) {
@@ -1190,14 +1166,14 @@ I830DisplayVideo(ScrnInfoPtr pScrn, int id, short width, short height,
}
/* Recalculate coefficients if the scaling changed. */
-
+
/*
* Only Horizontal coefficients so far.
*/
if (scaleChanged) {
double fCutoffY;
double fCutoffUV;
-
+
fCutoffY = xscaleFract / 4096.0;
fCutoffUV = xscaleFractUV / 4096.0;
@@ -1276,8 +1252,13 @@ I830AllocateMemory(ScrnInfoPtr pScrn, FBLinearPtr linear, int size)
{
ScreenPtr pScreen;
FBLinearPtr new_linear;
+ int bytespp = pScrn->bitsPerPixel >> 3;
DPRINTF(PFX, "I830AllocateMemory\n");
+
+ /* convert size in bytes into number of pixels */
+ size = (size + bytespp - 1) / bytespp;
+
if (linear) {
if (linear->size >= size)
return linear;
@@ -1436,7 +1417,7 @@ I830PutImage(ScrnInfoPtr pScrn,
* XXX Always draw the key. LinDVD seems to fill the window background
* with a colour different from the key. This works around that.
*/
- if (1 || !RegionsEqual(&pPriv->clip, clipBoxes)) {
+ if (1 || !REGION_EQUAL(pScreen, &pPriv->clip, clipBoxes)) {
REGION_COPY(pScreen, &pPriv->clip, clipBoxes);
xf86XVFillKeyHelper(pScreen, pPriv->colorKey, clipBoxes);
}
@@ -1814,6 +1795,9 @@ I830VideoSwitchModeBefore(ScrnInfoPtr pScrn, DisplayModePtr mode)
if (pixrate > pPriv->maxRate && pPriv->refreshOK) {
I830StopVideo(pScrn, pPriv, TRUE);
pPriv->refreshOK = FALSE;
+ xf86DrvMsg(pScrn->scrnIndex, X_WARNING,
+ "Disabling XVideo output because the mode pixel rate (%d MHz)\n"
+ "\texceeds the hardware limit (%d MHz).\n", pixrate, pPriv->maxRate);
}
}
@@ -1835,6 +1819,16 @@ I830VideoSwitchModeAfter(ScrnInfoPtr pScrn, DisplayModePtr mode)
mode->VRefresh = 60;
pixrate = (mode->HDisplay * mode->VDisplay * mode->VRefresh) / 1000000;
- pPriv->refreshOK = (pixrate <= pPriv->maxRate);
+ if (pPriv->refreshOK && pixrate > pPriv->maxRate) {
+ pPriv->refreshOK = FALSE;
+ xf86DrvMsg(pScrn->scrnIndex, X_WARNING,
+ "Disabling XVideo output because the mode pixel rate (%d MHz)\n"
+ "\texceeds the hardware limit (%d MHz)\n", pixrate, pPriv->maxRate);
+ } else if (!pPriv->refreshOK && pixrate <= pPriv->maxRate) {
+ pPriv->refreshOK = TRUE;
+ xf86DrvMsg(pScrn->scrnIndex, X_WARNING,
+ "Enabling XVideo output (mode pixel rate %d MHz is within limits).\n",
+ pixrate);
+ }
}