Module Name:    xsrc
Committed By:   mrg
Date:           Sat Jul 17 06:34:14 UTC 2010

Modified Files:
        xsrc/external/mit/xf86-video-ati/dist/src: legacy_crtc.c
            radeon_cursor.c radeon_dri.c radeon_driver.c radeon_exa_funcs.c

Log Message:
merge xf86-video-ati 6.13.1


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 \
    xsrc/external/mit/xf86-video-ati/dist/src/legacy_crtc.c \
    xsrc/external/mit/xf86-video-ati/dist/src/radeon_cursor.c \
    xsrc/external/mit/xf86-video-ati/dist/src/radeon_exa_funcs.c
cvs rdiff -u -r1.6 -r1.7 \
    xsrc/external/mit/xf86-video-ati/dist/src/radeon_dri.c
cvs rdiff -u -r1.5 -r1.6 \
    xsrc/external/mit/xf86-video-ati/dist/src/radeon_driver.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: xsrc/external/mit/xf86-video-ati/dist/src/legacy_crtc.c
diff -u xsrc/external/mit/xf86-video-ati/dist/src/legacy_crtc.c:1.3 xsrc/external/mit/xf86-video-ati/dist/src/legacy_crtc.c:1.4
--- xsrc/external/mit/xf86-video-ati/dist/src/legacy_crtc.c:1.3	Sun May 23 06:10:16 2010
+++ xsrc/external/mit/xf86-video-ati/dist/src/legacy_crtc.c	Sat Jul 17 06:34:13 2010
@@ -1185,10 +1185,12 @@
 
 /* Define PLL registers for requested video mode */
 static void
-RADEONInitPLLRegisters(ScrnInfoPtr pScrn, RADEONSavePtr save,
+RADEONInitPLLRegisters(xf86CrtcPtr crtc, RADEONSavePtr save,
 		       RADEONPLLPtr pll, DisplayModePtr mode,
 		       int flags)
 {
+    RADEONCrtcPrivatePtr radeon_crtc = crtc->driver_private;
+    ScrnInfoPtr pScrn = crtc->scrn;
     RADEONInfoPtr  info       = RADEONPTR(pScrn);
     uint32_t feedback_div = 0;
     uint32_t frac_fb_div = 0;
@@ -1224,7 +1226,13 @@
        return;
     }
 
-    RADEONComputePLL(pScrn, pll, mode->Clock, &freq, &feedback_div, &frac_fb_div, &reference_div, &post_divider, flags);
+    if (xf86ReturnOptValBool(info->Options, OPTION_NEW_PLL, FALSE))
+	radeon_crtc->pll_algo = RADEON_PLL_NEW;
+    else
+	radeon_crtc->pll_algo = RADEON_PLL_OLD;
+
+    RADEONComputePLL(crtc, pll, mode->Clock, &freq,
+		     &feedback_div, &frac_fb_div, &reference_div, &post_divider, flags);
 
     for (post_div = &post_divs[0]; post_div->divider; ++post_div) {
 	if (post_div->divider == post_divider)
@@ -1268,10 +1276,12 @@
 
 /* Define PLL2 registers for requested video mode */
 static void
-RADEONInitPLL2Registers(ScrnInfoPtr pScrn, RADEONSavePtr save,
+RADEONInitPLL2Registers(xf86CrtcPtr crtc, RADEONSavePtr save,
 			RADEONPLLPtr pll, DisplayModePtr mode,
 			int flags)
 {
+    RADEONCrtcPrivatePtr radeon_crtc = crtc->driver_private;
+    ScrnInfoPtr pScrn = crtc->scrn;
     RADEONInfoPtr  info       = RADEONPTR(pScrn);
     uint32_t feedback_div = 0;
     uint32_t frac_fb_div = 0;
@@ -1305,7 +1315,13 @@
        return;
     }
 
-    RADEONComputePLL(pScrn, pll, mode->Clock, &freq, &feedback_div, &frac_fb_div, &reference_div, &post_divider, flags);
+    if (xf86ReturnOptValBool(info->Options, OPTION_NEW_PLL, FALSE))
+	radeon_crtc->pll_algo = RADEON_PLL_NEW;
+    else
+	radeon_crtc->pll_algo = RADEON_PLL_OLD;
+
+    RADEONComputePLL(crtc, pll, mode->Clock, &freq,
+		     &feedback_div, &frac_fb_div, &reference_div, &post_divider, flags);
 
     for (post_div = &post_divs[0]; post_div->divider; ++post_div) {
 	if (post_div->divider == post_divider)
@@ -1797,7 +1813,7 @@
 	dot_clock = adjusted_mode->Clock / 1000.0;
 	if (dot_clock) {
 	    ErrorF("init pll1\n");
-	    RADEONInitPLLRegisters(pScrn, info->ModeReg, &info->pll, adjusted_mode, pll_flags);
+	    RADEONInitPLLRegisters(crtc, info->ModeReg, &info->pll, adjusted_mode, pll_flags);
 	} else {
 	    info->ModeReg->ppll_ref_div = info->SavedReg->ppll_ref_div;
 	    info->ModeReg->ppll_div_3   = info->SavedReg->ppll_div_3;
@@ -1811,7 +1827,7 @@
 	dot_clock = adjusted_mode->Clock / 1000.0;
 	if (dot_clock) {
 	    ErrorF("init pll2\n");
-	    RADEONInitPLL2Registers(pScrn, info->ModeReg, &info->pll, adjusted_mode, pll_flags);
+	    RADEONInitPLL2Registers(crtc, info->ModeReg, &info->pll, adjusted_mode, pll_flags);
 	}
 	break;
     }
Index: xsrc/external/mit/xf86-video-ati/dist/src/radeon_cursor.c
diff -u xsrc/external/mit/xf86-video-ati/dist/src/radeon_cursor.c:1.3 xsrc/external/mit/xf86-video-ati/dist/src/radeon_cursor.c:1.4
--- xsrc/external/mit/xf86-video-ati/dist/src/radeon_cursor.c:1.3	Sun May 23 06:10:16 2010
+++ xsrc/external/mit/xf86-video-ati/dist/src/radeon_cursor.c	Sat Jul 17 06:34:13 2010
@@ -343,7 +343,7 @@
     ScrnInfoPtr pScrn = crtc->scrn;
     RADEONCrtcPrivatePtr radeon_crtc = crtc->driver_private;
     RADEONInfoPtr info = RADEONPTR(pScrn);
-    uint32_t *pixels = (uint32_t *)(pointer)(info->FB + radeon_crtc->cursor_offset);
+    uint32_t *pixels = (uint32_t *)(pointer)(info->FB + pScrn->fbOffset + radeon_crtc->cursor_offset);
     int            pixel, i;
     CURSOR_SWAPPING_DECL_MMIO
 
@@ -386,7 +386,7 @@
     RADEONCrtcPrivatePtr radeon_crtc = crtc->driver_private;
     RADEONInfoPtr  info = RADEONPTR(pScrn);
     CURSOR_SWAPPING_DECL_MMIO
-    uint32_t *d = (uint32_t *)(pointer)(info->FB + radeon_crtc->cursor_offset);
+    uint32_t *d = (uint32_t *)(pointer)(info->FB + pScrn->fbOffset + radeon_crtc->cursor_offset);
 
     RADEONCTRACE(("RADEONLoadCursorARGB\n"));
 
Index: xsrc/external/mit/xf86-video-ati/dist/src/radeon_exa_funcs.c
diff -u xsrc/external/mit/xf86-video-ati/dist/src/radeon_exa_funcs.c:1.3 xsrc/external/mit/xf86-video-ati/dist/src/radeon_exa_funcs.c:1.4
--- xsrc/external/mit/xf86-video-ati/dist/src/radeon_exa_funcs.c:1.3	Sun May 23 06:10:16 2010
+++ xsrc/external/mit/xf86-video-ati/dist/src/radeon_exa_funcs.c	Sat Jul 17 06:34:13 2010
@@ -904,7 +904,7 @@
     RADEONEngineInit(pScrn);
 
     if (!exaDriverInit(pScreen, info->accel_state->exa)) {
-	xfree(info->accel_state->exa);
+	free(info->accel_state->exa);
 	return FALSE;
     }
     exaMarkSync(pScreen);

Index: xsrc/external/mit/xf86-video-ati/dist/src/radeon_dri.c
diff -u xsrc/external/mit/xf86-video-ati/dist/src/radeon_dri.c:1.6 xsrc/external/mit/xf86-video-ati/dist/src/radeon_dri.c:1.7
--- xsrc/external/mit/xf86-video-ati/dist/src/radeon_dri.c:1.6	Sun May 23 06:10:16 2010
+++ xsrc/external/mit/xf86-video-ati/dist/src/radeon_dri.c	Sat Jul 17 06:34:13 2010
@@ -124,21 +124,21 @@
 	if (use_db)             numConfigs *= 2;
 
 	if (!(pConfigs
-	      = (__GLXvisualConfig *)xcalloc(sizeof(__GLXvisualConfig),
-					     numConfigs))) {
+	      = (__GLXvisualConfig *)calloc(sizeof(__GLXvisualConfig),
+					    numConfigs))) {
 	    return FALSE;
 	}
 	if (!(pRADEONConfigs
-	      = (RADEONConfigPrivPtr)xcalloc(sizeof(RADEONConfigPrivRec),
-					     numConfigs))) {
-	    xfree(pConfigs);
+	      = (RADEONConfigPrivPtr)calloc(sizeof(RADEONConfigPrivRec),
+					    numConfigs))) {
+	    free(pConfigs);
 	    return FALSE;
 	}
 	if (!(pRADEONConfigPtrs
-	      = (RADEONConfigPrivPtr *)xcalloc(sizeof(RADEONConfigPrivPtr),
-					       numConfigs))) {
-	    xfree(pConfigs);
-	    xfree(pRADEONConfigs);
+	      = (RADEONConfigPrivPtr *)calloc(sizeof(RADEONConfigPrivPtr),
+					      numConfigs))) {
+	    free(pConfigs);
+	    free(pRADEONConfigs);
 	    return FALSE;
 	}
 
@@ -210,21 +210,21 @@
 	if (use_db)             numConfigs *= 2;
 
 	if (!(pConfigs
-	      = (__GLXvisualConfig *)xcalloc(sizeof(__GLXvisualConfig),
-					     numConfigs))) {
+	      = (__GLXvisualConfig *)calloc(sizeof(__GLXvisualConfig),
+					    numConfigs))) {
 	    return FALSE;
 	}
 	if (!(pRADEONConfigs
-	      = (RADEONConfigPrivPtr)xcalloc(sizeof(RADEONConfigPrivRec),
-					     numConfigs))) {
-	    xfree(pConfigs);
+	      = (RADEONConfigPrivPtr)calloc(sizeof(RADEONConfigPrivRec),
+					    numConfigs))) {
+	    free(pConfigs);
 	    return FALSE;
 	}
 	if (!(pRADEONConfigPtrs
-	      = (RADEONConfigPrivPtr *)xcalloc(sizeof(RADEONConfigPrivPtr),
-					       numConfigs))) {
-	    xfree(pConfigs);
-	    xfree(pRADEONConfigs);
+	      = (RADEONConfigPrivPtr *)calloc(sizeof(RADEONConfigPrivPtr),
+					      numConfigs))) {
+	    free(pConfigs);
+	    free(pRADEONConfigs);
 	    return FALSE;
 	}
 
@@ -302,36 +302,6 @@
 				drm_context_t hwContext, void *pVisualConfigPriv,
 				DRIContextType contextStore)
 {
-#ifdef PER_CONTEXT_SAREA
-    ScrnInfoPtr          pScrn = xf86Screens[pScreen->myNum];
-    RADEONInfoPtr        info  = RADEONPTR(pScrn);
-    RADEONDRIContextPtr  ctx_info;
-
-    ctx_info = (RADEONDRIContextPtr)contextStore;
-    if (!ctx_info) return FALSE;
-
-    if (drmAddMap(info->dri->drmFD, 0,
-		  info->dri->perctx_sarea_size,
-		  DRM_SHM,
-		  DRM_REMOVABLE,
-		  &ctx_info->sarea_handle) < 0) {
-	xf86DrvMsg(pScrn->scrnIndex, X_INFO,
-		   "[dri] could not create private sarea for ctx id (%d)\n",
-		   (int)hwContext);
-	return FALSE;
-    }
-
-    if (drmAddContextPrivateMapping(info->dri->drmFD, hwContext,
-				    ctx_info->sarea_handle) < 0) {
-	xf86DrvMsg(pScrn->scrnIndex, X_INFO,
-		   "[dri] could not associate private sarea to ctx id (%d)\n",
-		   (int)hwContext);
-	drmRmMap(info->dri->drmFD, ctx_info->sarea_handle);
-	return FALSE;
-    }
-
-    ctx_info->ctx_id = hwContext;
-#endif
     return TRUE;
 }
 
@@ -339,20 +309,6 @@
 static void RADEONDestroyContext(ScreenPtr pScreen, drm_context_t hwContext,
 				 DRIContextType contextStore)
 {
-#ifdef PER_CONTEXT_SAREA
-    ScrnInfoPtr          pScrn = xf86Screens[pScreen->myNum];
-    RADEONInfoPtr        info = RADEONPTR(pScrn);
-    RADEONDRIContextPtr  ctx_info;
-
-    ctx_info = (RADEONDRIContextPtr)contextStore;
-    if (!ctx_info) return;
-
-    if (drmRmMap(info->dri->drmFD, ctx_info->sarea_handle) < 0) {
-	xf86DrvMsg(pScrn->scrnIndex, X_INFO,
-		   "[dri] could not remove private sarea for ctx id (%d)\n",
-		   (int)hwContext);
-    }
-#endif
 }
 
 /* Called when the X server is woken up to allow the last client's
@@ -569,12 +525,12 @@
 
 	if (nbox > 1) {
 	    /* Keep ordering in each band, reverse order of bands */
-	    pboxNew1 = (BoxPtr)xalloc(sizeof(BoxRec)*nbox);
+	    pboxNew1 = (BoxPtr)malloc(sizeof(BoxRec)*nbox);
 	    if (!pboxNew1) return;
 
-	    pptNew1 = (DDXPointPtr)xalloc(sizeof(DDXPointRec)*nbox);
+	    pptNew1 = (DDXPointPtr)malloc(sizeof(DDXPointRec)*nbox);
 	    if (!pptNew1) {
-		xfree(pboxNew1);
+		free(pboxNew1);
 		return;
 	    }
 
@@ -611,14 +567,14 @@
 
 	if (nbox > 1) {
 	    /* reverse order of rects in each band */
-	    pboxNew2 = (BoxPtr)xalloc(sizeof(BoxRec)*nbox);
-	    pptNew2  = (DDXPointPtr)xalloc(sizeof(DDXPointRec)*nbox);
+	    pboxNew2 = (BoxPtr)malloc(sizeof(BoxRec)*nbox);
+	    pptNew2  = (DDXPointPtr)malloc(sizeof(DDXPointRec)*nbox);
 
 	    if (!pboxNew2 || !pptNew2) {
-		xfree(pptNew2);
-		xfree(pboxNew2);
-		xfree(pptNew1);
-		xfree(pboxNew1);
+		free(pptNew2);
+		free(pboxNew2);
+		free(pptNew1);
+		free(pboxNew1);
 		return;
 	    }
 
@@ -689,10 +645,10 @@
 
     info->accel_state->dst_pitch_offset = info->dri->frontPitchOffset;;
 
-    xfree(pptNew2);
-    xfree(pboxNew2);
-    xfree(pptNew1);
-    xfree(pboxNew1);
+    free(pptNew2);
+    free(pboxNew2);
+    free(pptNew1);
+    free(pboxNew1);
 
     info->accel_state->accel->NeedToSync = TRUE;
 #endif /* USE_XAA */
@@ -1453,7 +1409,7 @@
     if (xf86LoaderCheckSymbol("DRICreatePCIBusID")) {
 	busId = DRICreatePCIBusID(info->PciInfo);
     } else {
-	busId = xalloc(64);
+	busId = malloc(64);
 	sprintf(busId,
 		"PCI:%d:%d:%d",
 		PCI_DEV_BUS(info->PciInfo),
@@ -1463,7 +1419,7 @@
 
     /* Low level DRM open */
     fd = drmOpen(RADEON_DRIVER_NAME, busId);
-    xfree(busId);
+    free(busId);
     if (fd < 0) {
 	xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
 		   "[dri] RADEONDRIGetVersion failed to open the DRM\n"
@@ -1600,7 +1556,7 @@
     if (xf86LoaderCheckSymbol("DRICreatePCIBusID")) {
 	pDRIInfo->busIdString = DRICreatePCIBusID(info->PciInfo);
     } else {
-	pDRIInfo->busIdString            = xalloc(64);
+	pDRIInfo->busIdString            = malloc(64);
 	sprintf(pDRIInfo->busIdString,
 		"PCI:%d:%d:%d",
 		PCI_DEV_BUS(info->PciInfo),
@@ -1623,12 +1579,6 @@
        correctly with pageflip + mergedfb/color tiling */
     pDRIInfo->wrap.AdjustFrame = NULL;
 
-#ifdef PER_CONTEXT_SAREA
-    /* This is only here for testing per-context SAREAs.  When used, the
-       magic number below would be properly defined in a header file. */
-    info->perctx_sarea_size = 64 * 1024;
-#endif
-
 #ifdef NOT_DONE
     /* FIXME: Need to extend DRI protocol to pass this size back to
      * client for SAREA mapping that includes a device private record
@@ -1647,7 +1597,7 @@
     pDRIInfo->SAREASize = SAREA_MAX;
 #endif
 
-    if (!(pRADEONDRI = (RADEONDRIPtr)xcalloc(sizeof(RADEONDRIRec),1))) {
+    if (!(pRADEONDRI = (RADEONDRIPtr)calloc(sizeof(RADEONDRIRec),1))) {
 	DRIDestroyInfoRec(info->dri->pDRIInfo);
 	info->dri->pDRIInfo = NULL;
 	return FALSE;
@@ -1694,7 +1644,7 @@
     if (!DRIScreenInit(pScreen, pDRIInfo, &info->dri->drmFD)) {
 	xf86DrvMsg(pScreen->myNum, X_ERROR,
 		   "[dri] DRIScreenInit failed.  Disabling DRI.\n");
-	xfree(pDRIInfo->devPrivate);
+	free(pDRIInfo->devPrivate);
 	pDRIInfo->devPrivate = NULL;
 	DRIDestroyInfoRec(pDRIInfo);
 	pDRIInfo = NULL;
@@ -1845,11 +1795,6 @@
 
     pRADEONDRI->sarea_priv_offset = sizeof(XF86DRISAREARec);
 
-#ifdef PER_CONTEXT_SAREA
-    /* Set per-context SAREA size */
-    pRADEONDRI->perctx_sarea_size = info->dri->perctx_sarea_size;
-#endif
-
     info->directRenderingInited = TRUE;
 
     /* Wrap CloseScreen */
@@ -1988,7 +1933,7 @@
     }
 
     if (info->dri->pciGartBackup) {
-	xfree(info->dri->pciGartBackup);
+	free(info->dri->pciGartBackup);
 	info->dri->pciGartBackup = NULL;
     }
 
@@ -1998,18 +1943,18 @@
     /* De-allocate all DRI data structures */
     if (info->dri->pDRIInfo) {
 	if (info->dri->pDRIInfo->devPrivate) {
-	    xfree(info->dri->pDRIInfo->devPrivate);
+	    free(info->dri->pDRIInfo->devPrivate);
 	    info->dri->pDRIInfo->devPrivate = NULL;
 	}
 	DRIDestroyInfoRec(info->dri->pDRIInfo);
 	info->dri->pDRIInfo = NULL;
     }
     if (info->dri->pVisualConfigs) {
-	xfree(info->dri->pVisualConfigs);
+	free(info->dri->pVisualConfigs);
 	info->dri->pVisualConfigs = NULL;
     }
     if (info->dri->pVisualConfigsPriv) {
-	xfree(info->dri->pVisualConfigsPriv);
+	free(info->dri->pVisualConfigsPriv);
 	info->dri->pVisualConfigsPriv = NULL;
     }
 }

Index: xsrc/external/mit/xf86-video-ati/dist/src/radeon_driver.c
diff -u xsrc/external/mit/xf86-video-ati/dist/src/radeon_driver.c:1.5 xsrc/external/mit/xf86-video-ati/dist/src/radeon_driver.c:1.6
--- xsrc/external/mit/xf86-video-ati/dist/src/radeon_driver.c:1.5	Sun May 23 06:10:16 2010
+++ xsrc/external/mit/xf86-video-ati/dist/src/radeon_driver.c	Sat Jul 17 06:34:13 2010
@@ -181,7 +181,6 @@
     { OPTION_RENDER_ACCEL,   "RenderAccel",      OPTV_BOOLEAN, {0}, FALSE },
     { OPTION_SUBPIXEL_ORDER, "SubPixelOrder",    OPTV_ANYSTR,  {0}, FALSE },
 #endif
-    { OPTION_SHOWCACHE,      "ShowCache",        OPTV_BOOLEAN, {0}, FALSE },
     { OPTION_CLOCK_GATING,   "ClockGating",      OPTV_BOOLEAN, {0}, FALSE },
     { OPTION_VGA_ACCESS,     "VGAAccess",        OPTV_BOOLEAN, {0}, TRUE  },
     { OPTION_REVERSE_DDC,    "ReverseDDC",       OPTV_BOOLEAN, {0}, FALSE },
@@ -239,7 +238,7 @@
     stride = (pScrn->displayWidth * pScrn->bitsPerPixel) / 8;
     *size = stride;
 
-    return ((uint8_t *)info->FB + row * stride + offset);
+    return ((uint8_t *)info->FB + pScrn->fbOffset + row * stride + offset);
 }
 static Bool
 RADEONCreateScreenResources (ScreenPtr pScreen)
@@ -369,32 +368,32 @@
     info = RADEONPTR(pScrn);
 
     if (info->cp) {
-	xfree(info->cp);
+	free(info->cp);
 	info->cp = NULL;
     }
 
     if (info->dri) {
-	xfree(info->dri);
+	free(info->dri);
 	info->dri = NULL;
     }
 
     if (info->accel_state) {
-	xfree(info->accel_state);
+	free(info->accel_state);
 	info->accel_state = NULL;
     }
 
     for (i = 0; i < RADEON_MAX_BIOS_CONNECTOR; i++) {
 	if (info->encoders[i]) {
 	    if (info->encoders[i]->dev_priv) {
-		xfree(info->encoders[i]->dev_priv);
+		free(info->encoders[i]->dev_priv);
 		info->encoders[i]->dev_priv = NULL;
 	    }
-	    xfree(info->encoders[i]);
+	    free(info->encoders[i]);
 	    info->encoders[i]= NULL;
 	}
     }
 
-    xfree(pScrn->driverPrivate);
+    free(pScrn->driverPrivate);
     pScrn->driverPrivate = NULL;
 }
 
@@ -403,10 +402,14 @@
  */
 static Bool RADEONMapMMIO(ScrnInfoPtr pScrn)
 {
+#ifdef XSERVER_LIBPCIACCESS
+    int err;
+#endif
     RADEONInfoPtr  info = RADEONPTR(pScrn);
     RADEONEntPtr pRADEONEnt = RADEONEntPriv(pScrn);
 
     if (pRADEONEnt->MMIO) {
+        pRADEONEnt->MMIO_cnt++;
         info->MMIO = pRADEONEnt->MMIO;
         return TRUE;
     }
@@ -419,15 +422,15 @@
 			       info->MMIOAddr,
 			       info->MMIOSize);
 
-    if (!info->MMIO) return FALSE;
+    if (!info->MMIO)
+        return FALSE;
 #else
 
-    void** result = (void**)&info->MMIO;
-    int err = pci_device_map_range(info->PciInfo,
+    err = pci_device_map_range(info->PciInfo,
 				   info->MMIOAddr,
 				   info->MMIOSize,
 				   PCI_DEV_MAP_FLAG_WRITABLE,
-				   result);
+				   &info->MMIO);
 
     if (err) {
 	xf86DrvMsg (pScrn->scrnIndex, X_ERROR,
@@ -439,6 +442,7 @@
 #endif
 
     pRADEONEnt->MMIO = info->MMIO;
+    pRADEONEnt->MMIO_cnt = 1;
     return TRUE;
 }
 
@@ -450,8 +454,8 @@
     RADEONInfoPtr  info = RADEONPTR(pScrn);
     RADEONEntPtr pRADEONEnt = RADEONEntPriv(pScrn);
 
-    if (info->IsPrimary || info->IsSecondary) {
-      /* never unmap on zaphod */
+    /* refcount for zaphod */
+    if (--pRADEONEnt->MMIO_cnt != 0) {
       info->MMIO = NULL;
       return TRUE;
     }
@@ -474,6 +478,13 @@
     int err;
 #endif
     RADEONInfoPtr  info = RADEONPTR(pScrn);
+    RADEONEntPtr pRADEONEnt = RADEONEntPriv(pScrn);
+
+    if (pRADEONEnt->FB) {
+        pRADEONEnt->FB_cnt++;
+        info->FB = pRADEONEnt->FB;
+        return TRUE;
+    }
 
     xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, RADEON_LOGLEVEL_DEBUG,
 		   "Map: 0x%016llx, 0x%08lx\n", info->LinearAddr, info->FbMapSize);
@@ -506,6 +517,8 @@
 
 #endif
 
+    pRADEONEnt->FB = info->FB;
+    pRADEONEnt->FB_cnt = 1;
     return TRUE;
 }
 
@@ -513,6 +526,13 @@
 static Bool RADEONUnmapFB(ScrnInfoPtr pScrn)
 {
     RADEONInfoPtr  info = RADEONPTR(pScrn);
+    RADEONEntPtr pRADEONEnt = RADEONEntPriv(pScrn);
+
+    /* refcount for zaphod */
+    if (--pRADEONEnt->FB_cnt != 0) {
+      info->FB = NULL;
+      return TRUE;
+    }
 
 #ifndef XSERVER_LIBPCIACCESS
     xf86UnMapVidMem(pScrn->scrnIndex, info->FB, info->FbMapSize);
@@ -520,6 +540,7 @@
     pci_device_unmap_range(info->PciInfo, info->FB, info->FbMapSize);
 #endif
 
+    pRADEONEnt->FB = NULL;
     info->FB = NULL;
     return TRUE;
 }
@@ -1767,23 +1788,21 @@
     xf86DrvMsg(pScrn->scrnIndex, from,
 	       "Mapped VideoRAM: %d kByte (%d bit %s SDRAM)\n", pScrn->videoRam, info->RamWidth, info->IsDDR?"DDR":"SDR");
 
+    /* Do this before we truncate since we only map fb once */
+    info->FbMapSize  = (pScrn->videoRam & ~1023) * 1024;
+
     if (info->IsPrimary) {
 	pScrn->videoRam /= 2;
 	xf86DrvMsg(pScrn->scrnIndex, X_INFO,
 		   "Using %dk of videoram for primary head\n",
 		   pScrn->videoRam);
-    }
-    
-    if (info->IsSecondary) {
+    } else if (info->IsSecondary) {
 	pScrn->videoRam /= 2;
-	info->LinearAddr += pScrn->videoRam * 1024;
 	xf86DrvMsg(pScrn->scrnIndex, X_INFO,
 		   "Using %dk of videoram for secondary head\n",
 		   pScrn->videoRam);
     }
-
     pScrn->videoRam  &= ~1023;
-    info->FbMapSize  = pScrn->videoRam * 1024;
 
     /* if the card is PCI Express reserve the last 32k for the gart table */
 #ifdef XF86DRI
@@ -2070,11 +2089,6 @@
 	}
     }
 #endif
-    xf86GetOptValBool(info->Options, OPTION_SHOWCACHE, &info->showCache);
-    if (info->showCache)
-	xf86DrvMsg(pScrn->scrnIndex, X_CONFIG,
-		   "Option ShowCache enabled\n");
-
 #ifdef RENDER
     info->RenderAccel = xf86ReturnOptValBool(info->Options, OPTION_RENDER_ACCEL,
 					     info->Chipset != PCI_CHIP_RN50_515E &&
@@ -2140,9 +2154,11 @@
 #if defined(USE_EXA) && defined(USE_XAA)
     char *optstr;
 #endif
+#ifdef XF86DRI /* zaphod FbMapSize is wrong, but no dri then */
     int maxy = info->FbMapSize / (pScrn->displayWidth * info->CurrentLayout.pixel_bytes);
+#endif
 
-    if (!(info->accel_state = xcalloc(1, sizeof(struct radeon_accel_state)))) {
+    if (!(info->accel_state = calloc(1, sizeof(struct radeon_accel_state)))) {
 	xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "Unable to allocate accel_state rec!\n");
 	return FALSE;
     }
@@ -2313,12 +2329,12 @@
     info->directRenderingEnabled = FALSE;
     info->directRenderingInited = FALSE;
 
-    if (!(info->dri = xcalloc(1, sizeof(struct radeon_dri)))) {
+    if (!(info->dri = calloc(1, sizeof(struct radeon_dri)))) {
 	xf86DrvMsg(pScrn->scrnIndex, X_ERROR,"Unable to allocate dri rec!\n");
 	return FALSE;
     }
 
-    if (!(info->cp = xcalloc(1, sizeof(struct radeon_cp)))) {
+    if (!(info->cp = calloc(1, sizeof(struct radeon_cp)))) {
 	xf86DrvMsg(pScrn->scrnIndex, X_ERROR,"Unable to allocate cp rec!\n");
 	return FALSE;
     }
@@ -2701,7 +2717,11 @@
 	switch(info->ChipFamily){
 	case CHIP_FAMILY_R200:
 	case CHIP_FAMILY_R300:
+	case CHIP_FAMILY_R350:
 	case CHIP_FAMILY_RV350:
+	case CHIP_FAMILY_RV380:
+	case CHIP_FAMILY_R420:
+	case CHIP_FAMILY_RV410:
 		info->overlay_scaler_buffer_width = 1920;
 		break;
 	default:
@@ -3065,7 +3085,7 @@
 				/* We can't do this until we have a
 				   pScrn->display. */
     xf86CollectOptions(pScrn, NULL);
-    if (!(info->Options = xalloc(sizeof(RADEONOptions))))
+    if (!(info->Options = malloc(sizeof(RADEONOptions))))
 	goto fail;
 
     memcpy(info->Options, RADEONOptions, sizeof(RADEONOptions));
@@ -3229,7 +3249,7 @@
 				/* Pre-init failed. */
 				/* Free the video bios (if applicable) */
     if (info->VBIOS) {
-	xfree(info->VBIOS);
+	free(info->VBIOS);
 	info->VBIOS = NULL;
     }
 
@@ -3426,7 +3446,8 @@
     pScrn->fbOffset    = info->dri->frontOffset;
 #endif
 
-    if (info->IsSecondary) pScrn->fbOffset = pScrn->videoRam * 1024;
+    if (info->IsSecondary)
+        pScrn->fbOffset = pScrn->videoRam * 1024;
 #ifdef XF86DRI
     xf86DrvMsg(pScrn->scrnIndex, X_INFO, 
 		   "RADEONScreenInit %lx %ld %d\n",
@@ -3649,9 +3670,9 @@
 		   "Initializing fb layer\n");
 
     if (info->r600_shadow_fb) {
-	info->fb_shadow = xcalloc(1,
-				  pScrn->displayWidth * pScrn->virtualY *
-				  ((pScrn->bitsPerPixel + 7) >> 3));
+	info->fb_shadow = calloc(1,
+				 pScrn->displayWidth * pScrn->virtualY *
+				 ((pScrn->bitsPerPixel + 7) >> 3));
 	if (info->fb_shadow == NULL) {
 	    xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
                        "Failed to allocate shadow framebuffer\n");
@@ -3667,7 +3688,7 @@
 
     if (info->r600_shadow_fb == FALSE) {
 	/* Init fb layer */
-	if (!fbScreenInit(pScreen, info->FB,
+	if (!fbScreenInit(pScreen, info->FB + pScrn->fbOffset,
 			  pScrn->virtualX, pScrn->virtualY,
 			  pScrn->xDpi, pScrn->yDpi, pScrn->displayWidth,
 			  pScrn->bitsPerPixel))
@@ -5627,15 +5648,6 @@
 		   "RADEONDoAdjustFrame(%d,%d,%d)\n", x, y, clone);
 #endif
 
-    if (info->showCache && y) {
-	        int lastline = info->FbMapSize /
-		    ((pScrn->displayWidth * pScrn->bitsPerPixel) / 8);
-
-		lastline -= pScrn->currentMode->VDisplay;
-		y += (pScrn->virtualY - 1) * (y / 3 + 1);
-		if (y > lastline) y = lastline;
-    }
-
     Base = pScrn->fbOffset;
 
   /* note we cannot really simply use the info->ModeReg.crtc_offset_cntl value, since the
@@ -6007,7 +6019,7 @@
 #ifdef USE_EXA
     if (info->accel_state->exa) {
 	exaDriverFini(pScreen);
-	xfree(info->accel_state->exa);
+	free(info->accel_state->exa);
 	info->accel_state->exa = NULL;
     }
 #endif /* USE_EXA */
@@ -6018,7 +6030,7 @@
 	info->accel_state->accel = NULL;
 
 	if (info->accel_state->scratch_save)
-	    xfree(info->accel_state->scratch_save);
+	    free(info->accel_state->scratch_save);
 	info->accel_state->scratch_save = NULL;
     }
 #endif /* USE_XAA */

Reply via email to