summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog18
-rw-r--r--src/radeon.h10
-rw-r--r--src/radeon_dri.c260
-rw-r--r--src/radeon_driver.c258
4 files changed, 320 insertions, 226 deletions
diff --git a/ChangeLog b/ChangeLog
index 3790311..ef66e59 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,21 @@
+2006-03-10 Benjamin Herrenschmidt <benh@kernel.crashing.org>
+
+ * src/radeon.h:
+ * src/radeon_dri.c: (RADEONDRIGartHeapInit), (RADEONDRIGetVersion),
+ (RADEONDRIScreenInit), (RADEONDRIInitPageFlip), (RADEONDRIResume),
+ (RADEONDRIAllocatePCIGARTTable):
+ * src/radeon_driver.c: (RADEONInitMemoryMap),
+ (RADEONGetAccessibleVRAM), (RADEONPreInitConfig),
+ (RADEONPreInitDRI), (RADEONPreInitColorTiling), (RADEONPreInit),
+ (RADEONScreenInit), (RADEONRestoreMode):
+ More memory map fixes !!! This time, we add a way to get the DRM
+ kernel module version early, in order to properly limit the
+ framebuffer size when a module that doesn't support the new map is
+ loaded. That will improve backward compatibility. I also made the
+ minimum required kernel module version 1.3 which hopefully shouldn't
+ be a problem for anybody, and cleaned up the ordering in which we test
+ for DRM version to enable features
+
2006-03-09 Michel Dänzer <michel@daenzer.net>
* src/radeon_driver.c: (RADEONGetClockInfo), (RADEONGetVRamType),
diff --git a/src/radeon.h b/src/radeon.h
index 355c64c..fc694c7 100644
--- a/src/radeon.h
+++ b/src/radeon.h
@@ -348,7 +348,8 @@ typedef struct {
CARD32 MemCntl;
CARD32 BusCntl;
unsigned long FbMapSize; /* Size of frame buffer, in bytes */
- unsigned long FbSecureSize; /* Size of secured fb area at end of framebuffer */
+ unsigned long FbSecureSize; /* Size of secured fb area at end of
+ framebuffer */
int Flags; /* Saved copy of mode flags */
/* VE/M6 support */
@@ -490,9 +491,12 @@ typedef struct {
RADEONFBLayout CurrentLayout;
CARD32 dst_pitch_offset;
#ifdef XF86DRI
- Bool noBackBuffer;
+ Bool noBackBuffer;
Bool directRenderingEnabled;
Bool directRenderingInited;
+ Bool newMemoryMap;
+ drmVersionPtr pLibDRMVersion;
+ drmVersionPtr pKernelDRMVersion;
DRIInfoPtr pDRIInfo;
int drmFD;
int numVisualConfigs;
@@ -512,7 +516,6 @@ typedef struct {
Bool depthMoves; /* Enable depth moves -- slow! */
Bool allowPageFlip; /* Enable 3d page flipping */
Bool have3DWindows; /* Are there any 3d clients? */
- int drmMinor;
drmSize gartSize;
drm_handle_t agpMemHandle; /* Handle from drmAgpAlloc */
@@ -777,6 +780,7 @@ extern void RADEONPllErrataAfterData(RADEONInfoPtr info);
#ifdef USE_XAA
extern void RADEONAccelInitCP(ScreenPtr pScreen, XAAInfoRecPtr a);
#endif
+extern Bool RADEONDRIGetVersion(ScrnInfoPtr pScrn);
extern Bool RADEONDRIScreenInit(ScreenPtr pScreen);
extern void RADEONDRICloseScreen(ScreenPtr pScreen);
extern void RADEONDRIResume(ScreenPtr pScreen);
diff --git a/src/radeon_dri.c b/src/radeon_dri.c
index 544bca2..f9e7c9a 100644
--- a/src/radeon_dri.c
+++ b/src/radeon_dri.c
@@ -1092,7 +1092,7 @@ static void RADEONDRIGartHeapInit(RADEONInfoPtr info, ScreenPtr pScreen)
drmRadeonMemInitHeap drmHeap;
/* Start up the simple memory manager for GART space */
- if (info->drmMinor >= 6) {
+ if (info->pKernelDRMVersion->version_minor >= 6) {
drmHeap.region = RADEON_MEM_REGION_GART;
drmHeap.start = 0;
drmHeap.size = info->gartTexMapSize;
@@ -1109,7 +1109,7 @@ static void RADEONDRIGartHeapInit(RADEONInfoPtr info, ScreenPtr pScreen)
} else {
xf86DrvMsg(pScreen->myNum, X_INFO,
"[drm] Kernel module too old (1.%d) for GART heap manager\n",
- info->drmMinor);
+ info->pKernelDRMVersion->version_minor);
}
}
@@ -1193,19 +1193,14 @@ static void RADEONDRICPInit(ScrnInfoPtr pScrn)
}
-/* Initialize the screen-specific data structures for the DRI and the
- * Radeon. This is the main entry point to the device-specific
- * initialization code. It calls device-independent DRI functions to
- * create the DRI data structures and initialize the DRI state.
- */
-Bool RADEONDRIScreenInit(ScreenPtr pScreen)
+/* Get the DRM version and do some basic useability checks of DRI */
+Bool RADEONDRIGetVersion(ScrnInfoPtr pScrn)
{
- ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
RADEONInfoPtr info = RADEONPTR(pScrn);
- DRIInfoPtr pDRIInfo;
- RADEONDRIPtr pRADEONDRI;
- int major, minor, patch;
- drmVersionPtr version;
+ int major, minor, patch, fd;
+ int req_minor, req_patch;
+ char *busId;
+ drmVersionPtr libVersion;
/* Check that the GLX, DRI, and DRM modules have been loaded by testing
* for known symbols in each module.
@@ -1213,16 +1208,17 @@ Bool RADEONDRIScreenInit(ScreenPtr pScreen)
if (!xf86LoaderCheckSymbol("GlxSetVisualConfigs")) return FALSE;
if (!xf86LoaderCheckSymbol("drmAvailable")) return FALSE;
if (!xf86LoaderCheckSymbol("DRIQueryVersion")) {
- xf86DrvMsg(pScreen->myNum, X_ERROR,
- "[dri] RADEONDRIScreenInit failed (libdri.a too old)\n");
+ xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
+ "[dri] RADEONDRIGetVersion failed (libdri.a too old)\n"
+ "[dri] Disabling DRI.\n");
return FALSE;
}
/* Check the DRI version */
DRIQueryVersion(&major, &minor, &patch);
if (major != DRIINFO_MAJOR_VERSION || minor < DRIINFO_MINOR_VERSION) {
- xf86DrvMsg(pScreen->myNum, X_ERROR,
- "[dri] RADEONDRIScreenInit failed because of a version "
+ xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
+ "[dri] RADEONDRIGetVersion failed because of a version "
"mismatch.\n"
"[dri] libdri version is %d.%d.%d but version %d.%d.x is "
"needed.\n"
@@ -1232,6 +1228,118 @@ Bool RADEONDRIScreenInit(ScreenPtr pScreen)
return FALSE;
}
+ /* Check the lib version */
+ if (xf86LoaderCheckSymbol("drmGetLibVersion"))
+ info->pLibDRMVersion = drmGetLibVersion(info->drmFD);
+ if (info->pLibDRMVersion == NULL) {
+ xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
+ "[dri] RADEONDRIGetVersion failed because libDRM is really "
+ "way to old to even get a version number out of it.\n"
+ "[dri] Disabling DRI.\n");
+ return FALSE;
+ }
+ if (info->pLibDRMVersion->version_major != 1 ||
+ info->pLibDRMVersion->version_minor < 2) {
+ /* incompatible drm library version */
+ xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
+ "[dri] RADEONDRIGetVersion failed because of a "
+ "version mismatch.\n"
+ "[dri] libdrm.a module version is %d.%d.%d but "
+ "version 1.2.x is needed.\n"
+ "[dri] Disabling DRI.\n",
+ info->pLibDRMVersion->version_major,
+ info->pLibDRMVersion->version_minor,
+ info->pLibDRMVersion->version_patchlevel);
+ drmFreeVersion(info->pLibDRMVersion);
+ info->pLibDRMVersion = NULL;
+ return FALSE;
+ }
+
+ /* Create a bus Id */
+ if (xf86LoaderCheckSymbol("DRICreatePCIBusID")) {
+ busId = DRICreatePCIBusID(info->PciInfo);
+ } else {
+ busId = xalloc(64);
+ sprintf(busId,
+ "PCI:%d:%d:%d",
+ info->PciInfo->bus,
+ info->PciInfo->device,
+ info->PciInfo->func);
+ }
+
+ /* Low level DRM open */
+ fd = drmOpen(RADEON_DRIVER_NAME, busId);
+ xfree(busId);
+ if (fd < 0) {
+ xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
+ "[dri] RADEONDRIGetVersion failed to open the DRM\n"
+ "[dri] Disabling DRI.\n");
+ return FALSE;
+ }
+
+ /* Get DRM version & close DRM */
+ info->pKernelDRMVersion = drmGetVersion(fd);
+ drmClose(fd);
+ if (info->pKernelDRMVersion == NULL) {
+ xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
+ "[dri] RADEONDRIGetVersion failed to get the DRM version\n"
+ "[dri] Disabling DRI.\n");
+ return FALSE;
+ }
+
+ /* Now check if we qualify */
+ if (info->IsIGP) {
+ req_minor = 10;
+ req_patch = 0;
+ } else if (info->ChipFamily >= CHIP_FAMILY_R300) {
+ req_minor = 17;
+ req_patch = 0;
+ } else if (info->ChipFamily >= CHIP_FAMILY_R200) {
+ req_minor = 5;
+ req_patch = 0;
+ } else {
+ req_minor = 3;
+ req_patch = 0;
+ }
+
+ /* We don't, bummer ! */
+ if (info->pKernelDRMVersion->version_major != 1 ||
+ info->pKernelDRMVersion->version_minor < req_minor ||
+ (info->pKernelDRMVersion->version_minor == req_minor &&
+ info->pKernelDRMVersion->version_patchlevel < req_patch)) {
+ /* Incompatible drm version */
+ xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
+ "[dri] RADEONDRIGetVersion failed because of a version "
+ "mismatch.\n"
+ "[dri] radeon.o kernel module version is %d.%d.%d "
+ "but version 1.%d.%d or newer is needed.\n"
+ "[dri] Disabling DRI.\n",
+ info->pKernelDRMVersion->version_major,
+ info->pKernelDRMVersion->version_minor,
+ info->pKernelDRMVersion->version_patchlevel,
+ req_minor,
+ req_patch);
+ drmFreeVersion(info->pKernelDRMVersion);
+ info->pKernelDRMVersion = NULL;
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+/* Initialize the screen-specific data structures for the DRI and the
+ * Radeon. This is the main entry point to the device-specific
+ * initialization code. It calls device-independent DRI functions to
+ * create the DRI data structures and initialize the DRI state.
+ */
+Bool RADEONDRIScreenInit(ScreenPtr pScreen)
+{
+ ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+ RADEONInfoPtr info = RADEONPTR(pScrn);
+ DRIInfoPtr pDRIInfo;
+ RADEONDRIPtr pRADEONDRI;
+ drmVersionPtr version;
+
switch (info->CurrentLayout.pixel_code) {
case 8:
case 15:
@@ -1350,117 +1458,6 @@ Bool RADEONDRIScreenInit(ScreenPtr pScreen)
pDRIInfo = NULL;
return FALSE;
}
-
- /* Check the DRM lib version.
- * drmGetLibVersion was not supported in version 1.0, so check for
- * symbol first to avoid possible crash or hang.
- */
- if (xf86LoaderCheckSymbol("drmGetLibVersion")) {
- version = drmGetLibVersion(info->drmFD);
- } else {
- /* drmlib version 1.0.0 didn't have the drmGetLibVersion
- * entry point. Fake it by allocating a version record
- * via drmGetVersion and changing it to version 1.0.0.
- */
- version = drmGetVersion(info->drmFD);
- version->version_major = 1;
- version->version_minor = 0;
- version->version_patchlevel = 0;
- }
-
- if (version) {
- if (version->version_major != 1 ||
- version->version_minor < 1) {
- /* incompatible drm library version */
- xf86DrvMsg(pScreen->myNum, X_ERROR,
- "[dri] RADEONDRIScreenInit failed because of a "
- "version mismatch.\n"
- "[dri] libdrm.a module version is %d.%d.%d but "
- "version 1.1.x is needed.\n"
- "[dri] Disabling DRI.\n",
- version->version_major,
- version->version_minor,
- version->version_patchlevel);
- drmFreeVersion(version);
- RADEONDRICloseScreen(pScreen);
- return FALSE;
- }
- drmFreeVersion(version);
- }
-
- /* Check the radeon DRM version */
- version = drmGetVersion(info->drmFD);
- if (version) {
- int req_minor, req_patch;
-
- if (info->IsIGP) {
- req_minor = 10;
- req_patch = 0;
- } else if (info->ChipFamily >= CHIP_FAMILY_R300) {
- req_minor = 17;
- req_patch = 0;
- } else if (info->ChipFamily >= CHIP_FAMILY_R200) {
- req_minor = 5;
- req_patch = 0;
- } else {
-#if X_BYTE_ORDER == X_LITTLE_ENDIAN
- req_minor = 1;
- req_patch = 0;
-#else
- req_minor = 2;
- req_patch = 1;
-#endif
- }
-
- if (version->version_major != 1 ||
- version->version_minor < req_minor ||
- (version->version_minor == req_minor &&
- version->version_patchlevel < req_patch)) {
- /* Incompatible drm version */
- xf86DrvMsg(pScreen->myNum, X_ERROR,
- "[dri] RADEONDRIScreenInit failed because of a version "
- "mismatch.\n"
- "[dri] radeon.o kernel module version is %d.%d.%d "
- "but version 1.%d.%d or newer is needed.\n"
- "[dri] Disabling DRI.\n",
- version->version_major,
- version->version_minor,
- version->version_patchlevel,
- req_minor,
- req_patch);
- drmFreeVersion(version);
- RADEONDRICloseScreen(pScreen);
- return FALSE;
- }
-
- if (version->version_minor < 3) {
- xf86DrvMsg(pScreen->myNum, X_WARNING,
- "[dri] Some DRI features disabled because of version "
- "mismatch.\n"
- "[dri] radeon.o kernel module version is %d.%d.%d but "
- "1.3.1 or later is preferred.\n",
- version->version_major,
- version->version_minor,
- version->version_patchlevel);
- }
- info->drmMinor = version->version_minor;
-
- if (info->allowColorTiling && version->version_minor < 14) {
- xf86DrvMsg(pScreen->myNum, X_WARNING,
- "[dri] color tiling disabled because of version "
- "mismatch.\n"
- "[dri] radeon.o kernel module version is %d.%d.%d but "
- "1.14.0 or later is required for color tiling.\n",
- version->version_major,
- version->version_minor,
- version->version_patchlevel);
- info->allowColorTiling = FALSE;
- info->tilingEnabled = FALSE;
- pDRIInfo->ddxDriverMajorVersion = RADEON_VERSION_MAJOR;
- }
- drmFreeVersion(version);
- }
-
/* Initialize AGP */
if (info->cardType==CARD_AGP && !RADEONDRIAgpInit(info, pScreen)) {
xf86DrvMsg(pScreen->myNum, X_ERROR,
@@ -1613,7 +1610,7 @@ void RADEONDRIInitPageFlip(ScreenPtr pScreen)
/* Have shadowfb run only while there is 3d active. This must happen late,
* after XAAInit has been called
*/
- if (!info->useEXA /* && info->drmMinor >= 3 */) {
+ if (!info->useEXA) {
if (!ShadowFBInit( pScreen, RADEONDRIRefreshArea )) {
xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
"ShadowFB init failed, Page Flipping disabled\n");
@@ -1638,7 +1635,7 @@ void RADEONDRIResume(ScreenPtr pScreen)
ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
RADEONInfoPtr info = RADEONPTR(pScrn);
- if (info->drmMinor >= 9) {
+ if (info->pKernelDRMVersion->version_minor >= 9) {
xf86DrvMsg(pScreen->myNum, X_INFO,
"[RESUME] Attempting to re-init Radeon hardware.\n");
} else {
@@ -2008,7 +2005,8 @@ void RADEONDRIAllocatePCIGARTTable(ScreenPtr pScreen)
ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
RADEONInfoPtr info = RADEONPTR(pScrn);
- if (info->cardType!=CARD_PCIE || info->drmMinor<19)
+ if (info->cardType != CARD_PCIE ||
+ info->pKernelDRMVersion->version_minor < 19)
return;
if (info->FbSecureSize==0)
diff --git a/src/radeon_driver.c b/src/radeon_driver.c
index d128a1c..deb00b7 100644
--- a/src/radeon_driver.c
+++ b/src/radeon_driver.c
@@ -1,5 +1,5 @@
/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/radeon_driver.c,v 1.117 2004/02/19 22:38:12 tsi Exp $ */
-/* $XdotOrg: driver/xf86-video-ati/src/radeon_driver.c,v 1.93 2006-03-09 06:06:24 anholt Exp $ */
+/* $XdotOrg: driver/xf86-video-ati/src/radeon_driver.c,v 1.94 2006/03/09 15:41:16 daenzer Exp $ */
/*
* Copyright 2000 ATI Technologies Inc., Markham, Ontario, and
* VA Linux Systems Inc., Fremont, California.
@@ -2301,6 +2301,14 @@ static void RADEONInitMemoryMap(ScrnInfoPtr pScrn)
if (mem_size == 0)
mem_size = 0x800000;
+#ifdef XF86DRI
+ /* Apply memory map limitation if using an old DRI */
+ if (info->directRenderingEnabled && !info->newMemoryMap) {
+ CARD32 aper_size = INREG(RADEON_CONFIG_APER_SIZE);
+ if (aper_size < mem_size)
+ mem_size = aper_size;
+ }
+#endif
/* We won't try to change MC_FB_LOCATION when using fbdev */
if (!info->FBDev) {
@@ -2309,7 +2317,8 @@ static void RADEONInitMemoryMap(ScrnInfoPtr pScrn)
else
#ifdef XF86DRI
/* Old DRI has restrictions on the memory map */
- if ( info->directRenderingEnabled && info->drmMinor < 10 )
+ if ( info->directRenderingEnabled &&
+ info->pKernelDRMVersion->version_minor < 10 )
info->mc_fb_location = (mem_size - 1) & 0xffff0000U;
else
#endif
@@ -2404,6 +2413,28 @@ static CARD32 RADEONGetAccessibleVRAM(ScrnInfoPtr pScrn)
unsigned char *RADEONMMIO = info->MMIO;
CARD32 aper_size = INREG(RADEON_CONFIG_APER_SIZE) / 1024;
+#ifdef XF86DRI
+ /* If we use the DRI, we need to check if it's a version that has the
+ * bug of always cropping MC_FB_LOCATION to one aperture, in which case
+ * we need to limit the amount of accessible video memory
+ */
+ if (info->directRenderingEnabled &&
+ info->pKernelDRMVersion->version_minor < 23) {
+ xf86DrvMsg(pScrn->scrnIndex, X_WARNING,
+ "[dri] limiting video memory to one aperture of %dK\n");
+ xf86DrvMsg(pScrn->scrnIndex, X_WARNING,
+ "[dri] use radeon.o kernel module version 1.23.0 for"
+ " full memory mapping.\n",
+ aper_size,
+ info->pKernelDRMVersion->version_major,
+ info->pKernelDRMVersion->version_minor,
+ info->pKernelDRMVersion->version_patchlevel);
+ info->newMemoryMap = FALSE;
+ return aper_size;
+ }
+ info->newMemoryMap = TRUE;
+#endif /* XF86DRI */
+
/* Set HDP_APER_CNTL only on cards that are known not to be broken,
* that is has the 2nd generation multifunction PCI interface
*/
@@ -2804,7 +2835,7 @@ static Bool RADEONPreInitConfig(ScrnInfoPtr pScrn)
accessible = bar_size;
xf86DrvMsg(pScrn->scrnIndex, X_INFO,
- "Detected total video RAM=%dK, accessible=%dK "
+ "Detected total video RAM=%dK, accessible=%dK "
"(PCI BAR=%dK)\n",
pScrn->videoRam, accessible, bar_size);
if (pScrn->videoRam > accessible)
@@ -2865,7 +2896,6 @@ static Bool RADEONPreInitConfig(ScrnInfoPtr pScrn)
pScrn->videoRam &= ~1023;
info->FbMapSize = pScrn->videoRam * 1024;
-
info->FbSecureSize = 0;
#ifdef XF86DRI
@@ -4429,6 +4459,44 @@ static Bool RADEONPreInitDRI(ScrnInfoPtr pScrn)
RADEONInfoPtr info = RADEONPTR(pScrn);
MessageType from;
+ info->directRenderingEnabled = FALSE;
+ info->directRenderingInited = FALSE;
+ info->CPInUse = FALSE;
+ info->CPStarted = FALSE;
+ info->pLibDRMVersion = NULL;
+ info->pKernelDRMVersion = NULL;
+
+ if (xf86IsEntityShared(info->pEnt->index)) {
+ xf86DrvMsg(pScrn->scrnIndex, X_WARNING,
+ "Direct Rendering Disabled -- "
+ "Dual-head configuration is not working with "
+ "DRI at present.\n"
+ "Please use the radeon MergedFB option if you "
+ "want Dual-head with DRI.\n");
+ return FALSE;
+ }
+ if (info->IsSecondary)
+ return FALSE;
+
+ if (xf86ReturnOptValBool(info->Options, OPTION_NOACCEL, FALSE)) {
+ xf86DrvMsg(pScrn->scrnIndex, X_WARNING,
+ "[dri] Acceleration disabled, not initializing the DRI\n");
+ return FALSE;
+ }
+
+ if (!RADEONDRIGetVersion(pScrn))
+ return FALSE;
+
+ xf86DrvMsg(pScrn->scrnIndex, X_INFO,
+ "[dri] Found DRI library version %d.%d.%d and kernel"
+ " module version %d.%d.%d\n",
+ info->pLibDRMVersion->version_major,
+ info->pLibDRMVersion->version_minor,
+ info->pLibDRMVersion->version_patchlevel,
+ info->pKernelDRMVersion->version_major,
+ info->pKernelDRMVersion->version_minor,
+ info->pKernelDRMVersion->version_patchlevel);
+
if (xf86ReturnOptValBool(info->Options, OPTION_CP_PIO, FALSE)) {
xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "Forcing CP into PIO mode\n");
info->CPMode = RADEON_DEFAULT_CP_PIO_MODE;
@@ -4576,7 +4644,63 @@ static Bool RADEONPreInitDRI(ScrnInfoPtr pScrn)
return TRUE;
}
-#endif
+#endif /* XF86DRI */
+
+static void RADEONPreInitColorTiling(ScrnInfoPtr pScrn)
+{
+ RADEONInfoPtr info = RADEONPTR(pScrn);
+
+ if (IS_R300_VARIANT) {
+ /* false by default on R3/4xx */
+ info->allowColorTiling = xf86ReturnOptValBool(info->Options,
+ OPTION_COLOR_TILING, FALSE);
+ info->MaxSurfaceWidth = 3968; /* one would have thought 4096...*/
+ info->MaxLines = 4096;
+ } else {
+ info->allowColorTiling = xf86ReturnOptValBool(info->Options,
+ OPTION_COLOR_TILING, TRUE);
+ info->MaxSurfaceWidth = 2048;
+ info->MaxLines = 2048;
+ }
+
+ if (!info->allowColorTiling)
+ return;
+
+#ifdef XF86DRI
+ if (info->directRenderingEnabled &&
+ info->pKernelDRMVersion->version_minor < 14) {
+ xf86DrvMsg(pScrn->scrnIndex, X_WARNING,
+ "[dri] color tiling disabled because of version "
+ "mismatch.\n"
+ "[dri] radeon.o kernel module version is %d.%d.%d but "
+ "1.14.0 or later is required for color tiling.\n",
+ info->pKernelDRMVersion->version_major,
+ info->pKernelDRMVersion->version_minor,
+ info->pKernelDRMVersion->version_patchlevel);
+ info->allowColorTiling = FALSE;
+ return;
+ }
+#endif /* XF86DRI */
+
+ if ((info->allowColorTiling) && (info->IsSecondary)) {
+ /* can't have tiling on the 2nd head (as long as it can't use drm).
+ * We'd never get the surface save/restore (vt switching) right...
+ */
+ xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Color tiling disabled for 2nd head\n");
+ info->allowColorTiling = FALSE;
+ }
+ else if ((info->allowColorTiling) && (info->FBDev)) {
+ xf86DrvMsg(pScrn->scrnIndex, X_WARNING,
+ "Color tiling not supported with UseFBDev option\n");
+ info->allowColorTiling = FALSE;
+ }
+ else if (info->allowColorTiling) {
+ xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Color tiling enabled by default\n");
+ } else {
+ xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Color tiling disabled\n");
+ }
+}
+
static Bool RADEONPreInitXv(ScrnInfoPtr pScrn)
{
@@ -4938,38 +5062,17 @@ _X_EXPORT Bool RADEONPreInit(ScrnInfoPtr pScrn, int flags)
RADEONPostInt10Check(pScrn, int10_save);
+#ifdef XF86DRI
+ /* PreInit DRI first of all since we need that for getting a proper
+ * memory map
+ */
+ info->directRenderingEnabled = RADEONPreInitDRI(pScrn);
+#endif
+
if (!RADEONPreInitConfig(pScrn))
goto fail;
- if (IS_R300_VARIANT) {
- /* false by default on R3/4xx */
- info->allowColorTiling = xf86ReturnOptValBool(info->Options,
- OPTION_COLOR_TILING, FALSE);
- info->MaxSurfaceWidth = 3968; /* one would have thought 4096...*/
- info->MaxLines = 4096;
- } else {
- info->allowColorTiling = xf86ReturnOptValBool(info->Options,
- OPTION_COLOR_TILING, TRUE);
- info->MaxSurfaceWidth = 2048;
- info->MaxLines = 2048;
- }
-
- if ((info->allowColorTiling) && (info->IsSecondary)) {
- /* can't have tiling on the 2nd head (as long as it can't use drm). We'd never
- get the surface save/restore (vt switching) right... */
- xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Color tiling disabled for 2nd head\n");
- info->allowColorTiling = FALSE;
- }
- else if ((info->allowColorTiling) && (info->FBDev)) {
- xf86DrvMsg(pScrn->scrnIndex, X_WARNING,
- "Color tiling not supported with UseFBDev option\n");
- info->allowColorTiling = FALSE;
- }
- else if (info->allowColorTiling) {
- xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Color tiling enabled by default\n");
- } else {
- xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Color tiling disabled\n");
- }
+ RADEONPreInitColorTiling(pScrn);
RADEONPreInitDDC(pScrn);
@@ -4992,13 +5095,9 @@ _X_EXPORT Bool RADEONPreInit(ScrnInfoPtr pScrn, int flags)
if (!RADEONPreInitAccel(pScrn)) goto fail;
-#ifdef XF86DRI
- if (!RADEONPreInitDRI(pScrn)) goto fail;
-#endif
-
if (!RADEONPreInitXv(pScrn)) goto fail;
- /* Free the video bios (if applicable) */
+ /* Free the video bios (if applicable) */
if (info->VBIOS) {
xfree(info->VBIOS);
info->VBIOS = NULL;
@@ -5543,13 +5642,6 @@ _X_EXPORT Bool RADEONScreenInit(int scrnIndex, ScreenPtr pScreen,
RADEONTRACE(("RADEONScreenInit %x %d\n",
pScrn->memPhysBase, pScrn->fbOffset));
-#ifdef XF86DRI
- /* Turn off the CP for now. */
- info->CPInUse = FALSE;
- info->CPStarted = FALSE;
- info->directRenderingEnabled = FALSE;
- info->directRenderingInited = FALSE;
-#endif
info->accelOn = FALSE;
info->accel = NULL;
pScrn->fbOffset = 0;
@@ -5573,13 +5665,6 @@ _X_EXPORT Bool RADEONScreenInit(int scrnIndex, ScreenPtr pScreen,
}
}
-#if 0
- if (info->allowColorTiling && info->useEXA) {
- xf86DrvMsg(pScrn->scrnIndex, X_INFO,
- "Color tiling not supported yet with EXA, disabling\n");
- info->allowColorTiling = FALSE;
- }
-#endif
if (info->allowColorTiling && (pScrn->virtualX > info->MaxSurfaceWidth)) {
xf86DrvMsg(pScrn->scrnIndex, X_INFO,
"Color tiling not supported with virtual x resolutions larger than %d, disabling\n",
@@ -5599,7 +5684,8 @@ _X_EXPORT Bool RADEONScreenInit(int scrnIndex, ScreenPtr pScreen,
info->tilingEnabled = (pScrn->currentMode->Flags & (V_DBLSCAN | V_INTERLACE)) ? FALSE : TRUE;
}
}
- /* Visual setup */
+
+ /* Visual setup */
miClearVisualTypes();
if (!miSetVisualTypes(pScrn->depth,
miGetDefaultVisualMask(pScrn->depth),
@@ -5608,12 +5694,10 @@ _X_EXPORT Bool RADEONScreenInit(int scrnIndex, ScreenPtr pScreen,
miSetPixmapDepths ();
#ifdef XF86DRI
- /* Setup DRI after visuals have been
- established, but before fbScreenInit is
- called. fbScreenInit will eventually
- call the driver's InitGLXVisuals call
- back. */
- {
+ /* 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.
@@ -5622,11 +5706,7 @@ _X_EXPORT Bool RADEONScreenInit(int scrnIndex, ScreenPtr pScreen,
info->CurrentLayout.pixel_bytes);
int maxy = info->FbMapSize / width_bytes;
- if (xf86ReturnOptValBool(info->Options, OPTION_NOACCEL, FALSE)) {
- xf86DrvMsg(scrnIndex, X_WARNING,
- "Acceleration disabled, not initializing the DRI\n");
- info->directRenderingEnabled = FALSE;
- } else if (maxy <= pScrn->virtualY * 3) {
+ if (maxy <= pScrn->virtualY * 3) {
xf86DrvMsg(scrnIndex, X_ERROR,
"Static buffer allocation failed. Disabling DRI.\n");
xf86DrvMsg(scrnIndex, X_ERROR,
@@ -5644,24 +5724,29 @@ _X_EXPORT Bool RADEONScreenInit(int scrnIndex, ScreenPtr pScreen,
"\t*** This message has been last modified on 2005-08-07.\n\n"
);
info->directRenderingEnabled = RADEONDRIScreenInit(pScreen);
- } else if (info->IsSecondary) {
- info->directRenderingEnabled = FALSE;
- } else if (xf86IsEntityShared(info->pEnt->index)) {
- /* Xinerama has sync problem with DRI, disable it for now */
- info->directRenderingEnabled = FALSE;
- xf86DrvMsg(scrnIndex, X_WARNING,
- "Direct Rendering Disabled -- "
- "Dual-head configuration is not working with "
- "DRI at present.\n"
- "Please use the radeon MergedFB option if you "
- "want Dual-head with DRI.\n");
} 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
+#endif /* XF86DRI */
/* Initialize the memory map, this basically calculates the values
* we'll use later on for MC_FB_LOCATION & MC_AGP_LOCATION
@@ -5812,20 +5897,8 @@ _X_EXPORT Bool RADEONScreenInit(int scrnIndex, ScreenPtr pScreen,
/* DRI finalisation */
#ifdef XF86DRI
- /* Tell DRI about new memory map */
- if (info->directRenderingEnabled) {
- 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");
- }
-
- if (info->cardType==CARD_PCIE && info->pciGartOffset && info->drmMinor>=19)
+ if (info->directRenderingEnabled && info->cardType==CARD_PCIE &&
+ info->pciGartOffset && info->pKernelDRMVersion->version_minor >= 19)
{
drmRadeonSetParam radeonsetparam;
RADEONTRACE(("DRI PCIGART param\n"));
@@ -6748,7 +6821,8 @@ static void RADEONRestoreMode(ScrnInfoPtr pScrn, RADEONSavePtr restore)
RADEONRestoreCrtc2Registers(pScrn, restore);
RADEONRestorePLL2Registers(pScrn, restore);
- if(info->IsSwitching) return;
+ if (info->IsSwitching)
+ return;
pRADEONEnt->IsSecondaryRestored = TRUE;