Hi,

I hope this is the correct place to report bugs and send bugfixes, if not,
please let me know.

The attached patch fixes few bugs in Radeon driver. Tested with R8500LE
on Linux with XFree86 4.2.0 (RedHat package) with current CVS radeon
driver.


1. Cloning the display and using XVideo halts the system when moving
the viewport. I've traced that to the fact XVideo routines change
pScrn->AdjustFrame to their internal function, which isn't prepared
to be called for "clone display".
I've changed all calls of pScrn->AdjustFrame() for "clone display"
to just RADEONAdjustFrame() - clone display has nothing to do with
XVideo anyway.


2. I've simplified some conditional code.


3. User should now be able to specify sync polarity for clone modes
(using ModeLine).


4. "Clone mode %s in config file is used" is now being displayed
correctly.


Some of these changes might be useful for 4.2.0/4.2.1 as well, but I
haven't tested that.


Another question: I'm possibly going to implement some more changes
to radeon driver, mainly related to connecting different output
devices (DFP, CRT, TV, etc) to primary/secondary CRT controllers
(current driver is unusable if you have something connected to TV-out,
and you have only CRT and no DVI device). The other thing would be
merging (portions of) GATOS code.
How should I do that? Is anyone working on similar things?
-- 
Krzysztof Halasa
Network Administrator
--- xc/programs/Xserver/hw/xfree86/drivers/ati-new/radeon.h	Thu Jul 11 22:11:51 2002
+++ xc/programs/Xserver/hw/xfree86/drivers/ati/radeon.h	Tue Sep 17 22:40:28 2002
@@ -511,6 +513,7 @@
 extern int         RADEONMinBits(int val);
 
 extern void        RADEONInitVideo(ScreenPtr);
+extern void        RADEONAdjustFrame(int scrnIndex, int x, int y, int flags);
 
 #ifdef XF86DRI
 extern Bool        RADEONDRIScreenInit(ScreenPtr pScreen);
--- xc/programs/Xserver/hw/xfree86/drivers/ati-new/radeon_cursor.c	Thu Jul 11 22:11:51 2002
+++ xc/programs/Xserver/hw/xfree86/drivers/ati/radeon_cursor.c	Tue Sep 17 22:42:49 2002
@@ -154,7 +154,7 @@
 
 	if ((X0 >= 0 || Y0 >= 0) &&
 	    ((info->CloneFrameX0 != X0) || (info->CloneFrameY0 != Y0))) {
-	    pScrn->AdjustFrame(pScrn->scrnIndex, X0, Y0, 1);
+	    RADEONAdjustFrame(pScrn->scrnIndex, X0, Y0, 1);
 	    info->CloneFrameX0 = X0;
 	    info->CloneFrameY0 = Y0;
 	}
@@ -168,18 +168,9 @@
 					   | ((xorigin ? 0 : x) << 16)
 					   | (yorigin ? 0 : y)));
 	OUTREG(RADEON_CUR_OFFSET, info->cursor_start + yorigin * 16);
-    } else {
-	OUTREG(RADEON_CUR2_HORZ_VERT_OFF,  (RADEON_CUR2_LOCK
-					    | (xorigin << 16)
-					    | yorigin));
-	OUTREG(RADEON_CUR2_HORZ_VERT_POSN, (RADEON_CUR2_LOCK
-					    | ((xorigin ? 0 : x) << 16)
-					    | (yorigin ? 0 : y)));
-	OUTREG(RADEON_CUR2_OFFSET,
-	       info->cursor_start + pScrn->fbOffset + yorigin * 16);
     }
 
-    if (info->Clone) {
+    if (info->IsSecondary || info->Clone) {
 	OUTREG(RADEON_CUR2_HORZ_VERT_OFF,  (RADEON_CUR2_LOCK
 					    | (xorigin << 16)
 					    | yorigin));
--- xc/programs/Xserver/hw/xfree86/drivers/ati-new/radeon_driver.c	Tue Sep 17 18:33:16 2002
+++ xc/programs/Xserver/hw/xfree86/drivers/ati/radeon_driver.c	Tue Sep 17 23:00:45 2002
@@ -616,33 +632,16 @@
     RADEONInfoPtr  info       = RADEONPTR(pScrn);
     unsigned char *RADEONMMIO = info->MMIO;
 
-    if (!info->IsSecondary) {
-	switch(info->DisplayType) {
-	case MT_LCD:
-	case MT_CRT:
-	case MT_DFP:
-	    OUTREGP(RADEON_CRTC_EXT_CNTL,
-		    RADEON_CRTC_DISPLAY_DIS |
-		    RADEON_CRTC_VSYNC_DIS |
-		    RADEON_CRTC_HSYNC_DIS,
-		    ~(RADEON_CRTC_DISPLAY_DIS |
-		      RADEON_CRTC_VSYNC_DIS |
-		      RADEON_CRTC_HSYNC_DIS));
-	    break;
+    if (!info->IsSecondary)
+	OUTREGP(RADEON_CRTC_EXT_CNTL,
+		RADEON_CRTC_DISPLAY_DIS |
+		RADEON_CRTC_VSYNC_DIS |
+		RADEON_CRTC_HSYNC_DIS,
+		~(RADEON_CRTC_DISPLAY_DIS |
+		  RADEON_CRTC_VSYNC_DIS |
+		  RADEON_CRTC_HSYNC_DIS));
 
-	case MT_NONE:
-	default:
-	    break;
-	}
-	if (info->Clone)
-	    OUTREGP(RADEON_CRTC2_GEN_CNTL,
-		    RADEON_CRTC2_DISP_DIS |
-		    RADEON_CRTC2_VSYNC_DIS |
-		    RADEON_CRTC2_HSYNC_DIS,
-		    ~(RADEON_CRTC2_DISP_DIS |
-		      RADEON_CRTC2_VSYNC_DIS |
-		      RADEON_CRTC2_HSYNC_DIS));
-    } else {
+    if (info->IsSecondary || info->Clone)
 	OUTREGP(RADEON_CRTC2_GEN_CNTL,
 		RADEON_CRTC2_DISP_DIS |
 		RADEON_CRTC2_VSYNC_DIS |
@@ -650,7 +649,6 @@
 		~(RADEON_CRTC2_DISP_DIS |
 		  RADEON_CRTC2_VSYNC_DIS |
 		  RADEON_CRTC2_HSYNC_DIS));
-    }
 }
 
 /* Unblank screen */
@@ -659,45 +657,19 @@
     RADEONInfoPtr  info       = RADEONPTR(pScrn);
     unsigned char *RADEONMMIO = info->MMIO;
 
-    if (!info->IsSecondary) {
-	switch (info->DisplayType) {
-	case MT_LCD:
-	case MT_CRT:
-	case MT_DFP:
-	    OUTREGP(RADEON_CRTC_EXT_CNTL,
-		    RADEON_CRTC_CRT_ON,
-		    ~(RADEON_CRTC_DISPLAY_DIS |
-		      RADEON_CRTC_VSYNC_DIS |
-		      RADEON_CRTC_HSYNC_DIS));
-	    break;
-
-	case MT_NONE:
-	default:
-	    break;
-	}
-	if (info->Clone)
-	    OUTREGP(RADEON_CRTC2_GEN_CNTL,
-		    0,
-		    ~(RADEON_CRTC2_DISP_DIS |
-		      RADEON_CRTC2_VSYNC_DIS |
-		      RADEON_CRTC2_HSYNC_DIS));
-    } else {
-	switch (info->DisplayType) {
-	case MT_LCD:
-	case MT_DFP:
-	case MT_CRT:
-	    OUTREGP(RADEON_CRTC2_GEN_CNTL,
-		    0,
-		    ~(RADEON_CRTC2_DISP_DIS |
-		      RADEON_CRTC2_VSYNC_DIS |
-		      RADEON_CRTC2_HSYNC_DIS));
-	    break;
+    if (!info->IsSecondary)
+	OUTREGP(RADEON_CRTC_EXT_CNTL,
+		RADEON_CRTC_CRT_ON,
+		~(RADEON_CRTC_DISPLAY_DIS |
+		  RADEON_CRTC_VSYNC_DIS |
+		  RADEON_CRTC_HSYNC_DIS));
 
-	case MT_NONE:
-	default:
-	    break;
-	}
-    }
+    if (info->IsSecondary || info->Clone)
+	OUTREGP(RADEON_CRTC2_GEN_CNTL,
+		0,
+		~(RADEON_CRTC2_DISP_DIS |
+		  RADEON_CRTC2_VSYNC_DIS |
+		  RADEON_CRTC2_HSYNC_DIS));
 }
 
 /* Compute log base 2 of val */
@@ -2365,7 +2338,8 @@
 	    else count++;
 	    clone_mode_names[0] = xnfalloc(strlen(s)+1);
 	    sprintf(clone_mode_names[0], "%dx%d", tmp_hdisplay, tmp_vdisplay);
-	    xf86DrvMsg(0, X_INFO, "Clone mode %s in config file is used\n");
+	    xf86DrvMsg(0, X_INFO, "Clone mode %s in config file is used\n",
+		       clone_mode_names[0]);
 	}
     }
 
@@ -3252,8 +3284,8 @@
 	    (pScrn->virtualX - info->CurCloneMode->HDisplay) / 2;
 	info->CloneFrameY0 =
 	    (pScrn->virtualY - info->CurCloneMode->VDisplay) / 2;
-	pScrn->AdjustFrame(scrnIndex,
-			   info->CloneFrameX0, info->CloneFrameY0, 1);
+	RADEONAdjustFrame(scrnIndex,
+			  info->CloneFrameX0, info->CloneFrameY0, 1);
     }
 
 				/* Visual setup */
@@ -4620,7 +4646,7 @@
 				   | (hsync_wid << 16)
 				   | ((mode->Flags & V_NHSYNC)
 				      ? RADEON_CRTC_H_SYNC_POL
-				      : RADEON_CRTC_H_SYNC_POL));
+				      : 0));
 
 #if 1
 				/* This works for double scan mode. */
@@ -4644,7 +4670,7 @@
 				   | (vsync_wid << 16)
 				   | ((mode->Flags & V_NVSYNC)
 				      ? RADEON_CRTC2_V_SYNC_POL
-				      : RADEON_CRTC2_V_SYNC_POL));
+				      : 0));
 
     save->crtc2_offset      = 0;
     save->crtc2_offset_cntl = 0;
@@ -5114,8 +5143,8 @@
 	else if (info->CloneFrameY0 < 0)
 	    info->CloneFrameY0 = 0;
 
-	pScrn->AdjustFrame(scrnIndex,
-			   info->CloneFrameX0, info->CloneFrameY0, 1);
+	RADEONAdjustFrame(scrnIndex,
+			  info->CloneFrameX0, info->CloneFrameY0, 1);
     }
 
     info->IsSwitching = FALSE;
@@ -5154,17 +5183,11 @@
 
     Base &= ~7;                 /* 3 lower bits are always 0 */
 
-    if (info->Clone && (flags == 1)) {
+    if (info->IsSecondary || (info->Clone && flags == 1)) {
 	Base += pScrn->fbOffset;
 	OUTREG(RADEON_CRTC2_OFFSET, Base);
-    } else {
-	if (info->IsSecondary) {
-	    Base += pScrn->fbOffset;
-	    OUTREG(RADEON_CRTC2_OFFSET, Base);
-	} else {
-	    OUTREG(RADEON_CRTC_OFFSET, Base);
-	}
-    }
+    } else
+	OUTREG(RADEON_CRTC_OFFSET, Base);
 }
 
 /* Called when VT switching back to the X server.  Reinitialize the
@@ -5204,8 +5227,8 @@
 
     RADEONAdjustFrame(scrnIndex, pScrn->frameX0, pScrn->frameY0, 0);
     if (info->CurCloneMode) {
-	pScrn->AdjustFrame(scrnIndex,
-			   info->CloneFrameX0, info->CloneFrameY0, 1);
+	RADEONAdjustFrame(scrnIndex,
+			  info->CloneFrameX0, info->CloneFrameY0, 1);
     }
 
     return TRUE;

Reply via email to