summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorairlied <airlied@optimus.localdomain>2006-11-28 17:26:10 +1100
committerairlied <airlied@optimus.localdomain>2006-11-28 17:26:10 +1100
commitba047ae863aac869595a31ea94f102084636fd29 (patch)
treeaf641275e6530d89e3bbddc467069997eedb6ab8
parent0d42cab2d889070ab6de05990e2b19724595f7af (diff)
radeon: initial move framebuffer away from zero prep.
In theory the driver should be able to handle the front buffer not at VRAM 0 In practice it didn't.. this is cleanup for at least XAA parts of the driver to allow for the frontbuffer to move. It has to re-organise a large part of ScreenInit so things happen in the correct order otherwise some things get setup in-correctly. (not sure EXA with fb not at 0 works yet...)
-rw-r--r--src/radeon_cursor.c11
-rw-r--r--src/radeon_dri.c2
-rw-r--r--src/radeon_driver.c232
-rw-r--r--src/radeon_exa.c15
4 files changed, 135 insertions, 125 deletions
diff --git a/src/radeon_cursor.c b/src/radeon_cursor.c
index ef07bac0..a45198ae 100644
--- a/src/radeon_cursor.c
+++ b/src/radeon_cursor.c
@@ -109,7 +109,7 @@ static CARD32 mono_cursor_color[] = {
static void RADEONSetCursorColors(ScrnInfoPtr pScrn, int bg, int fg)
{
RADEONInfoPtr info = RADEONPTR(pScrn);
- CARD32 *pixels = (CARD32 *)(pointer)(info->FB + info->cursor_offset);
+ CARD32 *pixels = (CARD32 *)(pointer)(info->FB + info->cursor_offset + pScrn->fbOffset);
int pixel, i;
CURSOR_SWAPPING_DECL_MMIO
@@ -180,8 +180,9 @@ static void RADEONSetCursorPosition(ScrnInfoPtr pScrn, int x, int y)
| ((xorigin ? 0 : x) << 16)
| (yorigin ? 0 : y)));
RADEONCTRACE(("cursor_offset: 0x%x, yorigin: %d, stride: %d\n",
- info->cursor_offset, yorigin, stride));
- OUTREG(RADEON_CUR_OFFSET, info->cursor_offset + yorigin * stride);
+ info->cursor_offset + pScrn->fbOffset, yorigin, stride));
+ OUTREG(RADEON_CUR_OFFSET,
+ info->cursor_offset + pScrn->fbOffset + yorigin * stride);
} else {
OUTREG(RADEON_CUR2_HORZ_VERT_OFF, (RADEON_CUR2_LOCK
| (xorigin << 16)
@@ -203,7 +204,7 @@ static void RADEONLoadCursorImage(ScrnInfoPtr pScrn, unsigned char *image)
RADEONInfoPtr info = RADEONPTR(pScrn);
unsigned char *RADEONMMIO = info->MMIO;
CARD8 *s = (CARD8 *)(pointer)image;
- CARD32 *d = (CARD32 *)(pointer)(info->FB + info->cursor_offset);
+ CARD32 *d = (CARD32 *)(pointer)(info->FB + info->cursor_offset + pScrn->fbOffset);
CARD32 save1 = 0;
CARD32 save2 = 0;
CARD8 chunk;
@@ -311,7 +312,7 @@ static void RADEONLoadCursorARGB (ScrnInfoPtr pScrn, CursorPtr pCurs)
{
RADEONInfoPtr info = RADEONPTR(pScrn);
unsigned char *RADEONMMIO = info->MMIO;
- CARD32 *d = (CARD32 *)(pointer)(info->FB + info->cursor_offset);
+ CARD32 *d = (CARD32 *)(pointer)(info->FB + info->cursor_offset + pScrn->fbOffset);
int x, y, w, h;
CARD32 save1 = 0;
CARD32 save2 = 0;
diff --git a/src/radeon_dri.c b/src/radeon_dri.c
index 73f9844b..70ff288b 100644
--- a/src/radeon_dri.c
+++ b/src/radeon_dri.c
@@ -1422,7 +1422,7 @@ Bool RADEONDRIScreenInit(ScreenPtr pScreen)
RADEON_VERSION_MAJOR_TILED : RADEON_VERSION_MAJOR;
pDRIInfo->ddxDriverMinorVersion = RADEON_VERSION_MINOR;
pDRIInfo->ddxDriverPatchVersion = RADEON_VERSION_PATCH;
- pDRIInfo->frameBufferPhysicalAddress = (void *)info->LinearAddr;
+ pDRIInfo->frameBufferPhysicalAddress = (void *)info->LinearAddr + info->frontOffset;
pDRIInfo->frameBufferSize = info->FbMapSize - info->FbSecureSize;
pDRIInfo->frameBufferStride = (pScrn->displayWidth *
info->CurrentLayout.pixel_bytes);
diff --git a/src/radeon_driver.c b/src/radeon_driver.c
index f5a84215..1950f750 100644
--- a/src/radeon_driver.c
+++ b/src/radeon_driver.c
@@ -3621,6 +3621,10 @@ Bool RADEONSetupMemXAA_DRI(int scrnIndex, ScreenPtr pScreen)
}
xf86DrvMsg(scrnIndex, X_INFO,
+ "Will use front buffer at offset 0x%x\n",
+ info->frontOffset);
+
+ xf86DrvMsg(scrnIndex, X_INFO,
"Will use back buffer at offset 0x%x\n",
info->backOffset);
xf86DrvMsg(scrnIndex, X_INFO,
@@ -3720,14 +3724,14 @@ _X_EXPORT Bool RADEONScreenInit(int scrnIndex, ScreenPtr pScreen,
char* s;
#endif
- RADEONTRACE(("RADEONScreenInit %lx %ld\n",
- pScrn->memPhysBase, pScrn->fbOffset));
+ RADEONTRACE(("RADEONScreenInit %lx %ld %lx\n",
+ pScrn->memPhysBase, pScrn->fbOffset, info->frontOffset));
info->accelOn = FALSE;
#ifdef USE_XAA
info->accel = NULL;
#endif
- pScrn->fbOffset = 0;
+ pScrn->fbOffset = info->frontOffset;
if (info->IsSecondary) pScrn->fbOffset = pScrn->videoRam * 1024;
if (!RADEONMapMem(pScrn)) return FALSE;
@@ -3800,47 +3804,6 @@ _X_EXPORT Bool RADEONScreenInit(int scrnIndex, ScreenPtr pScreen,
"Using %d bit depth buffer\n", info->depthBits);
}
- /* Setup DRI after visuals have been established, but before fbScreenInit is
- * called. fbScreenInit will eventually call the driver's InitGLXVisuals
- * call back. */
- if (info->directRenderingEnabled) {
- /* FIXME: When we move to dynamic allocation of back and depth
- * buffers, we will want to revisit the following check for 3
- * times the virtual size of the screen below.
- */
- int width_bytes = (pScrn->displayWidth *
- info->CurrentLayout.pixel_bytes);
- int maxy = info->FbMapSize / width_bytes;
-
- if (maxy <= pScrn->virtualY * 3) {
- xf86DrvMsg(scrnIndex, X_ERROR,
- "Static buffer allocation failed. Disabling DRI.\n");
- xf86DrvMsg(scrnIndex, X_ERROR,
- "At least %d kB of video memory needed at this "
- "resolution and depth.\n",
- (pScrn->displayWidth * pScrn->virtualY *
- info->CurrentLayout.pixel_bytes * 3 + 1023) / 1024);
- info->directRenderingEnabled = FALSE;
- } else {
- info->directRenderingEnabled = RADEONDRIScreenInit(pScreen);
- }
- }
-
- /* Tell DRI about new memory map */
- if (info->directRenderingEnabled && info->newMemoryMap) {
- drmRadeonSetParam radeonsetparam;
- RADEONTRACE(("DRI New memory map param\n"));
- memset(&radeonsetparam, 0, sizeof(drmRadeonSetParam));
- radeonsetparam.param = RADEON_SETPARAM_NEW_MEMMAP;
- radeonsetparam.value = 1;
- if (drmCommandWrite(info->drmFD, DRM_RADEON_SETPARAM,
- &radeonsetparam, sizeof(drmRadeonSetParam)) < 0) {
- xf86DrvMsg(pScrn->scrnIndex, X_WARNING,
- "[drm] failed to enable new memory map\n");
- RADEONDRICloseScreen(pScreen);
- info->directRenderingEnabled = FALSE;
- }
- }
hasDRI = info->directRenderingEnabled;
#endif /* XF86DRI */
@@ -3861,24 +3824,6 @@ _X_EXPORT Bool RADEONScreenInit(int scrnIndex, ScreenPtr pScreen,
}
}
- if (info->FBDev) {
- unsigned char *RADEONMMIO = info->MMIO;
-
- if (!fbdevHWModeInit(pScrn, pScrn->currentMode)) return FALSE;
- pScrn->displayWidth = fbdevHWGetLineLength(pScrn)
- / info->CurrentLayout.pixel_bytes;
- RADEONSaveMemMapRegisters(pScrn, &info->ModeReg);
- info->fbLocation = (info->ModeReg.mc_fb_location & 0xffff) << 16;
- info->ModeReg.surface_cntl = INREG(RADEON_SURFACE_CNTL);
- info->ModeReg.surface_cntl &= ~RADEON_SURF_TRANSLATION_DIS;
- } else {
- if (!RADEONModeInit(pScrn, pScrn->currentMode)) return FALSE;
- }
-
- RADEONSaveScreen(pScreen, SCREEN_SAVER_ON);
-
- pScrn->AdjustFrame(scrnIndex, pScrn->frameX0, pScrn->frameY0, 0);
-
#ifdef XF86DRI
/* Depth moves are disabled by default since they are extremely slow */
info->depthMoves = xf86ReturnOptValBool(info->Options,
@@ -3901,54 +3846,6 @@ _X_EXPORT Bool RADEONScreenInit(int scrnIndex, ScreenPtr pScreen,
RADEONChangeSurfaces(pScrn);
}
- RADEONTRACE(("Initializing fb layer\n"));
-
- /* Init fb layer */
- if (!fbScreenInit(pScreen, info->FB,
- pScrn->virtualX, pScrn->virtualY,
- pScrn->xDpi, pScrn->yDpi, pScrn->displayWidth,
- pScrn->bitsPerPixel))
- return FALSE;
-
- xf86SetBlackWhitePixels(pScreen);
-
- if (pScrn->bitsPerPixel > 8) {
- VisualPtr visual;
-
- visual = pScreen->visuals + pScreen->numVisuals;
- while (--visual >= pScreen->visuals) {
- if ((visual->class | DynamicClass) == DirectColor) {
- visual->offsetRed = pScrn->offset.red;
- visual->offsetGreen = pScrn->offset.green;
- visual->offsetBlue = pScrn->offset.blue;
- visual->redMask = pScrn->mask.red;
- visual->greenMask = pScrn->mask.green;
- visual->blueMask = pScrn->mask.blue;
- }
- }
- }
-
- /* Must be after RGB order fixed */
- fbPictureInit (pScreen, 0, 0);
-
-#ifdef RENDER
- if ((s = xf86GetOptValString(info->Options, OPTION_SUBPIXEL_ORDER))) {
- if (strcmp(s, "RGB") == 0) subPixelOrder = SubPixelHorizontalRGB;
- else if (strcmp(s, "BGR") == 0) subPixelOrder = SubPixelHorizontalBGR;
- else if (strcmp(s, "NONE") == 0) subPixelOrder = SubPixelNone;
- PictureSetSubpixelOrder (pScreen, subPixelOrder);
- }
-
- if (PictureGetSubpixelOrder (pScreen) == SubPixelUnknown) {
- switch (info->DisplayType) {
- case MT_NONE: subPixelOrder = SubPixelUnknown; break;
- case MT_LCD: subPixelOrder = SubPixelHorizontalRGB; break;
- case MT_DFP: subPixelOrder = SubPixelHorizontalRGB; break;
- default: subPixelOrder = SubPixelNone; break;
- }
- PictureSetSubpixelOrder (pScreen, subPixelOrder);
- }
-#endif
/* Memory manager setup */
RADEONTRACE(("Setting up accel memmap\n"));
@@ -4007,6 +3904,7 @@ _X_EXPORT Bool RADEONScreenInit(int scrnIndex, ScreenPtr pScreen,
}
if (!RADEONSetupMemXAA_DRI(scrnIndex, pScreen))
return FALSE;
+ pScrn->fbOffset = info->frontOffset;
}
#endif
@@ -4018,6 +3916,114 @@ _X_EXPORT Bool RADEONScreenInit(int scrnIndex, ScreenPtr pScreen,
info->dst_pitch_offset = (((pScrn->displayWidth * info->CurrentLayout.pixel_bytes / 64)
<< 22) | ((info->fbLocation + pScrn->fbOffset) >> 10));
+ /* Setup DRI after visuals have been established, but before fbScreenInit is
+ * called. fbScreenInit will eventually call the driver's InitGLXVisuals
+ * call back. */
+ if (info->directRenderingEnabled) {
+ /* FIXME: When we move to dynamic allocation of back and depth
+ * buffers, we will want to revisit the following check for 3
+ * times the virtual size of the screen below.
+ */
+ int width_bytes = (pScrn->displayWidth *
+ info->CurrentLayout.pixel_bytes);
+ int maxy = info->FbMapSize / width_bytes;
+
+ if (maxy <= pScrn->virtualY * 3) {
+ xf86DrvMsg(scrnIndex, X_ERROR,
+ "Static buffer allocation failed. Disabling DRI.\n");
+ xf86DrvMsg(scrnIndex, X_ERROR,
+ "At least %d kB of video memory needed at this "
+ "resolution and depth.\n",
+ (pScrn->displayWidth * pScrn->virtualY *
+ info->CurrentLayout.pixel_bytes * 3 + 1023) / 1024);
+ info->directRenderingEnabled = FALSE;
+ } else {
+ info->directRenderingEnabled = RADEONDRIScreenInit(pScreen);
+ }
+ }
+
+ /* Tell DRI about new memory map */
+ if (info->directRenderingEnabled && info->newMemoryMap) {
+ drmRadeonSetParam radeonsetparam;
+ RADEONTRACE(("DRI New memory map param\n"));
+ memset(&radeonsetparam, 0, sizeof(drmRadeonSetParam));
+ radeonsetparam.param = RADEON_SETPARAM_NEW_MEMMAP;
+ radeonsetparam.value = 1;
+ if (drmCommandWrite(info->drmFD, DRM_RADEON_SETPARAM,
+ &radeonsetparam, sizeof(drmRadeonSetParam)) < 0) {
+ xf86DrvMsg(pScrn->scrnIndex, X_WARNING,
+ "[drm] failed to enable new memory map\n");
+ RADEONDRICloseScreen(pScreen);
+ info->directRenderingEnabled = FALSE;
+ }
+ }
+ RADEONTRACE(("Initializing fb layer\n"));
+
+ /* Init fb layer */
+ if (!fbScreenInit(pScreen, info->FB + pScrn->fbOffset,
+ pScrn->virtualX, pScrn->virtualY,
+ pScrn->xDpi, pScrn->yDpi, pScrn->displayWidth,
+ pScrn->bitsPerPixel))
+ return FALSE;
+
+ xf86SetBlackWhitePixels(pScreen);
+
+ if (pScrn->bitsPerPixel > 8) {
+ VisualPtr visual;
+
+ visual = pScreen->visuals + pScreen->numVisuals;
+ while (--visual >= pScreen->visuals) {
+ if ((visual->class | DynamicClass) == DirectColor) {
+ visual->offsetRed = pScrn->offset.red;
+ visual->offsetGreen = pScrn->offset.green;
+ visual->offsetBlue = pScrn->offset.blue;
+ visual->redMask = pScrn->mask.red;
+ visual->greenMask = pScrn->mask.green;
+ visual->blueMask = pScrn->mask.blue;
+ }
+ }
+ }
+
+ /* Must be after RGB order fixed */
+ fbPictureInit (pScreen, 0, 0);
+
+#ifdef RENDER
+ if ((s = xf86GetOptValString(info->Options, OPTION_SUBPIXEL_ORDER))) {
+ if (strcmp(s, "RGB") == 0) subPixelOrder = SubPixelHorizontalRGB;
+ else if (strcmp(s, "BGR") == 0) subPixelOrder = SubPixelHorizontalBGR;
+ else if (strcmp(s, "NONE") == 0) subPixelOrder = SubPixelNone;
+ PictureSetSubpixelOrder (pScreen, subPixelOrder);
+ }
+
+ if (PictureGetSubpixelOrder (pScreen) == SubPixelUnknown) {
+ switch (info->DisplayType) {
+ case MT_NONE: subPixelOrder = SubPixelUnknown; break;
+ case MT_LCD: subPixelOrder = SubPixelHorizontalRGB; break;
+ case MT_DFP: subPixelOrder = SubPixelHorizontalRGB; break;
+ default: subPixelOrder = SubPixelNone; break;
+ }
+ PictureSetSubpixelOrder (pScreen, subPixelOrder);
+ }
+#endif
+
+ if (info->FBDev) {
+ unsigned char *RADEONMMIO = info->MMIO;
+
+ if (!fbdevHWModeInit(pScrn, pScrn->currentMode)) return FALSE;
+ pScrn->displayWidth = fbdevHWGetLineLength(pScrn)
+ / info->CurrentLayout.pixel_bytes;
+ RADEONSaveMemMapRegisters(pScrn, &info->ModeReg);
+ info->fbLocation = (info->ModeReg.mc_fb_location & 0xffff) << 16;
+ info->ModeReg.surface_cntl = INREG(RADEON_SURFACE_CNTL);
+ info->ModeReg.surface_cntl &= ~RADEON_SURF_TRANSLATION_DIS;
+ } else {
+ if (!RADEONModeInit(pScrn, pScrn->currentMode)) return FALSE;
+ }
+
+ RADEONSaveScreen(pScreen, SCREEN_SAVER_ON);
+
+ pScrn->AdjustFrame(scrnIndex, pScrn->frameX0, pScrn->frameY0, 0);
+
/* Backing store setup */
RADEONTRACE(("Initializing backing store\n"));
miInitializeBackingStore(pScreen);
@@ -4026,7 +4032,7 @@ _X_EXPORT Bool RADEONScreenInit(int scrnIndex, ScreenPtr pScreen,
/* DRI finalisation */
#ifdef XF86DRI
if (info->directRenderingEnabled && info->cardType==CARD_PCIE &&
- info->pciGartOffset && info->pKernelDRMVersion->version_minor >= 19)
+ info->pKernelDRMVersion->version_minor >= 19)
{
drmRadeonSetParam radeonsetparam;
RADEONTRACE(("DRI PCIGART param\n"));
@@ -6645,7 +6651,7 @@ void RADEONDoAdjustFrame(ScrnInfoPtr pScrn, int x, int y, int clone)
}
if (pSAREAPriv->pfCurrentPage == 1) {
- Base += info->backOffset;
+ Base += info->backOffset - info->frontOffset;
}
}
#endif
@@ -6728,7 +6734,7 @@ _X_EXPORT Bool RADEONEnterVT(int scrnIndex, int flags)
if (info->cardType == CARD_PCIE && info->pKernelDRMVersion->version_minor >= 19 && info->FbSecureSize)
{
/* we need to backup the PCIE GART TABLE from fb memory */
- memcpy(info->FB + info->pciGartOffset, info->pciGartBackup, info->pciGartSize);
+ memcpy(info->FB + info->pciGartOffset, info->pciGartBackup, info->pciGartSize);
}
/* get the DRI back into shape after resume */
diff --git a/src/radeon_exa.c b/src/radeon_exa.c
index 7e57fe76..0f4c42ee 100644
--- a/src/radeon_exa.c
+++ b/src/radeon_exa.c
@@ -394,16 +394,13 @@ Bool RADEONSetupMemEXA (ScreenPtr pScreen)
else
screen_size = pScrn->virtualY * byteStride;
- info->exa->memoryBase = info->FB + pScrn->fbOffset;
+ info->exa->memoryBase = info->FB + pScrn->fbOffset + info->FbSecureSize;
info->exa->memorySize = info->FbMapSize - info->FbSecureSize;
info->exa->offScreenBase = screen_size;
xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Allocating from a screen of %ld kb\n",
info->exa->memorySize / 1024);
- xf86DrvMsg(pScrn->scrnIndex, X_INFO,
- "Will use %d kb for front buffer at offset 0x%08x\n",
- screen_size / 1024, 0);
/* Reserve static area for hardware cursor */
if (!xf86ReturnOptValBool(info->Options, OPTION_SW_CURSOR, FALSE)) {
@@ -425,6 +422,9 @@ Bool RADEONSetupMemEXA (ScreenPtr pScreen)
info->frontOffset = 0;
info->frontPitch = pScrn->displayWidth;
+ xf86DrvMsg(pScrn->scrnIndex, X_INFO,
+ "Will use %d kb for front buffer at offset 0x%08x\n",
+ screen_size / 1024, info->frontOffset);
RADEONDRIAllocatePCIGARTTable(pScreen);
if (info->cardType==CARD_PCIE)
@@ -483,9 +483,12 @@ Bool RADEONSetupMemEXA (ScreenPtr pScreen)
/* Minimum texture size is for 2 256x256x32bpp textures */
info->textureSize = 0;
}
- }
+ } else
#endif /* XF86DRI */
-
+ xf86DrvMsg(pScrn->scrnIndex, X_INFO,
+ "Will use %d kb for front buffer at offset 0x%08x\n",
+ screen_size / 1024, 0);
+
xf86DrvMsg(pScrn->scrnIndex, X_INFO,
"Will use %ld kb for X Server offscreen at offset 0x%08lx\n",
(info->exa->memorySize - info->exa->offScreenBase) /