xserver/hw/kdrive/ati ati.c, 1.14, 1.15 ati.h, 1.8, 1.9 ati_cursor.c, 1.2, 1.3 ati_draw.c, 1.17, 1.18

Keith Packard xserver-commit at pdx.freedesktop.org
Sun Jun 27 17:48:54 PDT 2004


Committed by: keithp

Update of /cvs/xserver/xserver/hw/kdrive/ati
In directory pdx:/tmp/cvs-serv4032/hw/kdrive/ati

Modified Files:
	ati.c ati.h ati_cursor.c ati_draw.c 
Log Message:
2004-06-27  Keith Packard  <keithp at keithp.com>

	* hw/kdrive/ati/ati.c: (ATICardInit), (ATISetOffscreen),
	(ATIScreenInit), (ATIRandRSetConfig), (ATIRandRInit),
	(ATIFinishInitScreen), (ATIEnable):
	* hw/kdrive/ati/ati.h:
	* hw/kdrive/ati/ati_cursor.c: (ATICursorInit):
	* hw/kdrive/ati/ati_draw.c: (RadeonSwitchTo2D), (RadeonSwitchTo3D),
	(ATIBlockHandler), (ATIWakeupHandler), (ATIDrawEnable),
	(ATIDrawDisable), (ATIDrawFini):
	Separate out off-screen allocation from Init.
	Fix Enable to update off-screen addresses.
	Wrap RandR to update off-screen addresses.
	
	* hw/kdrive/fbdev/fbdev.c: (fbdevMapFramebuffer):
	Set off_screen_base and memory_size fields correctly.


Index: ati.c
===================================================================
RCS file: /cvs/xserver/xserver/hw/kdrive/ati/ati.c,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -d -r1.14 -r1.15
--- ati.c	26 Jun 2004 04:13:02 -0000	1.14
+++ ati.c	28 Jun 2004 00:48:51 -0000	1.15
@@ -203,6 +203,9 @@
 		atic->backend_funcs.disable = fbdevDisable;
 		atic->backend_funcs.getColors = fbdevGetColors;
 		atic->backend_funcs.putColors = fbdevPutColors;
+#ifdef RANDR
+		atic->backend_funcs.randrSetConfig = fbdevRandRSetConfig;
+#endif
 	}
 #endif
 #ifdef KDRIVEVESA
@@ -221,6 +224,9 @@
 		atic->backend_funcs.disable = vesaDisable;
 		atic->backend_funcs.getColors = vesaGetColors;
 		atic->backend_funcs.putColors = vesaPutColors;
+#ifdef RANDR
+		atic->backend_funcs.randrSetConfig = vesaRandRSetConfig;
+#endif
 	}
 #endif
 
@@ -277,62 +283,31 @@
 	atic->backend_funcs.cardfini(card);
 }
 
-static Bool
-ATIScreenInit(KdScreenInfo *screen)
+/*
+ * Once screen->off_screen_base is set, this function
+ * allocates the remaining memory appropriately
+ */
+
+static void
+ATISetOffscreen (KdScreenInfo *screen)
 {
-	ATIScreenInfo *atis;
 	ATICardInfo(screen);
-	Bool success = FALSE;
-	int screen_size = 0;
-	int cursor_size;
+	ATIScreenInfo *atis = (ATIScreenInfo *)screen->driver;
+	int screen_size = screen->fb[0].byteStride * screen->height;
 #if defined(USE_DRI) && defined(GLXEXT)
 	int l;
 #endif
 
-	atis = xcalloc(sizeof(ATIScreenInfo), 1);
-	if (atis == NULL)
-		return FALSE;
-
-	atis->atic = atic;
-	atis->screen = screen;
-	screen->driver = atis;
-
-#ifdef KDRIVEFBDEV
-	if (atic->use_fbdev) {
-		success = fbdevScreenInitialize(screen,
-						&atis->backend_priv.fbdev);
-		screen->memory_size = atic->backend_priv.fbdev.fix.smem_len;
-		screen_size = atic->backend_priv.fbdev.var.yres_virtual *
-		    screen->fb[0].byteStride;
-	}
-#endif
-#ifdef KDRIVEVESA
-	if (atic->use_vesa) {
-		if (screen->fb[0].depth == 0)
-			screen->fb[0].depth = 16;
-		success = vesaScreenInitialize(screen,
-		    &atis->backend_priv.vesa);
-		screen_size = screen->off_screen_base;
-	}
-#endif
-
-	if (!success) {
-		screen->driver = NULL;
-		xfree(atis);
-		return FALSE;
-	}
-
 	screen->off_screen_base = screen_size;
 
 	if (atic->is_radeon)
-		cursor_size = ATI_CURSOR_HEIGHT * ATI_CURSOR_WIDTH * 4;
+		atis->cursor.cursor_size = ATI_CURSOR_HEIGHT * ATI_CURSOR_WIDTH * 4;
 	else
-		cursor_size = ATI_CURSOR_HEIGHT * ATI_CURSOR_PITCH * 2;
-	/* Reserve the area for the cursor. */
-	if (screen->off_screen_base + cursor_size <= screen->memory_size) {
-		atis->cursor.offset = screen->off_screen_base;
-		screen->off_screen_base += cursor_size;
-	}
+		atis->cursor.cursor_size = ATI_CURSOR_HEIGHT * ATI_CURSOR_PITCH * 3;
+
+	atis->cursor.offset = screen->off_screen_base;
+
+	screen->off_screen_base += atis->cursor.cursor_size;
 
 #if defined(USE_DRI) && defined(GLXEXT)
 	/* Reserve a static area for the back buffer the same size as the
@@ -393,13 +368,84 @@
 		atis->scratch_offset = screen->off_screen_base;
 		screen->off_screen_base += atis->scratch_size;
 		atis->scratch_next = atis->scratch_offset;
-	} else {
+	}
+	else 
+	{
 		atis->scratch_size = 0;
 	}
+}
+
+static Bool
+ATIScreenInit(KdScreenInfo *screen)
+{
+	ATIScreenInfo *atis;
+	ATICardInfo(screen);
+	Bool success = FALSE;
+
+	atis = xcalloc(sizeof(ATIScreenInfo), 1);
+	if (atis == NULL)
+		return FALSE;
+
+	atis->atic = atic;
+	atis->screen = screen;
+	screen->driver = atis;
+
+	if (screen->fb[0].depth == 0)
+		screen->fb[0].depth = 16;
+#ifdef KDRIVEFBDEV
+	if (atic->use_fbdev) {
+		success = fbdevScreenInitialize(screen,
+						&atis->backend_priv.fbdev);
+	}
+#endif
+#ifdef KDRIVEVESA
+	if (atic->use_vesa) {
+		success = vesaScreenInitialize(screen,
+					       &atis->backend_priv.vesa);
+	}
+#endif
+
+	if (!success) {
+		screen->driver = NULL;
+		xfree(atis);
+		return FALSE;
+	}
+
+	ATISetOffscreen (screen);
 
 	return TRUE;
 }
 
+#ifdef RANDR
+static Bool
+ATIRandRSetConfig (ScreenPtr		pScreen,
+		   Rotation		randr,
+		   int			rate,
+		   RRScreenSizePtr	pSize)
+{
+	KdScreenPriv(pScreen);
+	KdScreenInfo *screen = pScreenPriv->screen;
+	ATICardInfo *atic = screen->card->driver;
+	Bool ret;
+
+	ATIDrawDisable (pScreen);
+	ret = atic->backend_funcs.randrSetConfig(pScreen, randr, rate, pSize);
+	ATISetOffscreen (screen);
+	ATIDrawEnable (pScreen);
+	return ret;
+}
+
+static Bool
+ATIRandRInit (ScreenPtr pScreen)
+{
+    rrScrPrivPtr    pScrPriv;
+    
+    pScrPriv = rrGetScrPriv(pScreen);
+    pScrPriv->rrSetConfig = ATIRandRSetConfig;
+    return TRUE;
+}
+#endif
+
 static void
 ATIScreenFini(KdScreenInfo *screen)
 {
@@ -459,7 +505,13 @@
 	KdScreenPriv(pScreen);
 	ATICardInfo(pScreenPriv);
 
-	return atic->backend_funcs.finishInitScreen(pScreen);
+	if (!atic->backend_funcs.finishInitScreen(pScreen))
+		return FALSE;
+#ifdef RANDR
+	if (!ATIRandRInit (pScreen))
+		return FALSE;
+#endif
+	return TRUE;
 }
 
 static Bool
@@ -507,6 +559,8 @@
 	if (!atic->backend_funcs.enable(pScreen))
 		return FALSE;
 
+	ATISetOffscreen (pScreenPriv->screen);
+
 	if ((atic->reg_base == NULL) && !ATIMapReg(pScreenPriv->screen->card,
 	    atic))
 		return FALSE;

Index: ati.h
===================================================================
RCS file: /cvs/xserver/xserver/hw/kdrive/ati/ati.h,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- ati.h	17 May 2004 20:18:02 -0000	1.8
+++ ati.h	28 Jun 2004 00:48:51 -0000	1.9
@@ -122,6 +122,9 @@
 	void    (*disable)(ScreenPtr);
 	void    (*getColors)(ScreenPtr, int, int, xColorItem *);
 	void    (*putColors)(ScreenPtr, int, int, xColorItem *);
+#ifdef RANDR
+	Bool	(*randrSetConfig) (ScreenPtr, Rotation, int, RRScreenSizePtr);
+#endif
 };
 
 typedef struct _ATICardInfo {
@@ -161,6 +164,8 @@
 	Pixel		source, mask;
 	KdOffscreenArea	*area;
 	CARD32		offset;
+	
+	int		cursor_size;
 } ATICursor;
 
 typedef struct _ATIPortPriv {

Index: ati_cursor.c
===================================================================
RCS file: /cvs/xserver/xserver/hw/kdrive/ati/ati_cursor.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- ati_cursor.c	26 Jun 2004 04:13:03 -0000	1.2
+++ ati_cursor.c	28 Jun 2004 00:48:51 -0000	1.3
@@ -495,7 +495,7 @@
 
 	pCurPriv->has_cursor = FALSE;
 
-	if (pCurPriv->offset == 0)
+	if (pCurPriv->cursor_size == 0)
 		return FALSE;
 
 	if (atic->reg_base == NULL)

Index: ati_draw.c
===================================================================
RCS file: /cvs/xserver/xserver/hw/kdrive/ati/ati_draw.c,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -d -r1.17 -r1.18
--- ati_draw.c	26 Jun 2004 04:13:03 -0000	1.17
+++ ati_draw.c	28 Jun 2004 00:48:51 -0000	1.18
@@ -175,7 +175,9 @@
 {
 	RING_LOCALS;
 
-	BEGIN_DMA(2);
+	BEGIN_DMA(4);
+	OUT_REG(RADEON_REG_RB2D_DSTCACHE_CTLSTAT,
+		RADEON_RB2D_DC_FLUSH);
 	OUT_REG(ATI_REG_WAIT_UNTIL,
 	    RADEON_WAIT_HOST_IDLECLEAN | RADEON_WAIT_3D_IDLECLEAN);
 	END_DMA();
@@ -186,7 +188,9 @@
 {
 	RING_LOCALS;
 
-	BEGIN_DMA(2);
+	BEGIN_DMA(4);
+	OUT_REG(RADEON_REG_RB2D_DSTCACHE_CTLSTAT,
+		RADEON_RB2D_DC_FLUSH);
 	OUT_REG(ATI_REG_WAIT_UNTIL,
 	    RADEON_WAIT_HOST_IDLECLEAN | RADEON_WAIT_2D_IDLECLEAN);
 	END_DMA();
@@ -658,10 +662,9 @@
 }
 
 static void
-ATIBlockHandler (int screen, pointer blockData, pointer timeout,
-    pointer readmask)
+ATIBlockHandler (pointer blockData, OSTimePtr timeout, pointer readmask)
 {
-	ScreenPtr pScreen = screenInfo.screens[screen];
+	ScreenPtr pScreen = (ScreenPtr) blockData;
 	KdScreenPriv(pScreen);
 	ATIScreenInfo(pScreenPriv);
 
@@ -671,6 +674,11 @@
 	ATIFlushIndirect(atis, 1);
 }
 
+static void
+ATIWakeupHandler (pointer blockData, int result, pointer readmask)
+{
+}
+
 Bool
 ATIDrawInit(ScreenPtr pScreen)
 {
@@ -774,8 +782,8 @@
 	atis->kaa.UploadToScreen = ATIUploadToScreen;
 	atis->kaa.UploadToScratch = ATIUploadToScratch;
 
-	atis->save_blockhandler = pScreen->BlockHandler;
-	pScreen->BlockHandler = ATIBlockHandler;
+	RegisterBlockAndWakeupHandlers (ATIBlockHandler, ATIWakeupHandler,
+				       pScreen);
 
 	KdMarkSync(pScreen);
 }
@@ -783,19 +791,17 @@
 void
 ATIDrawDisable(ScreenPtr pScreen)
 {
-	KdScreenPriv(pScreen);
-	ATIScreenInfo(pScreenPriv);
-
 	ATIDMATeardown(pScreen);
 
-	pScreen->BlockHandler = atis->save_blockhandler;
+	RemoveBlockAndWakeupHandlers (ATIBlockHandler, ATIWakeupHandler,
+				      pScreen);
 }
 
 void
 ATIDrawFini(ScreenPtr pScreen)
 {
-	KdScreenPriv(pScreen);
 #ifdef USE_DRI
+	KdScreenPriv(pScreen);
 	ATIScreenInfo(pScreenPriv);
 	if (atis->using_dri) {
 		ATIDRICloseScreen(pScreen);




More information about the xserver-commit mailing list